Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore subset aggregates #10674

Merged
merged 23 commits into from
May 25, 2022
Merged

Ignore subset aggregates #10674

merged 23 commits into from
May 25, 2022

Conversation

terencechain
Copy link
Member

@terencechain terencechain commented May 10, 2022

Implements and rationale: ethereum/consensus-specs#2847

This PR drops aggregated objects if a better aggregate has been seen. (i.e. bitfield overlaps). As a result, we should see a reduction in CPU usage and incoming and outgoing bandwidth.

Note: we did not have to do anything with aggregated attestation, HasAggregatedAttestation already checks the subset 🙌🏼

@terencechain terencechain marked this pull request as ready for review May 17, 2022 16:38
@terencechain terencechain requested a review from a team as a code owner May 17, 2022 16:38
@terencechain terencechain self-assigned this May 17, 2022
@terencechain terencechain added Spec Ready For Review A pull request ready for code review labels May 17, 2022
@@ -221,6 +223,7 @@ func (s *Service) initCaches() {
s.seenUnAggregatedAttestationCache = lruwrpr.New(seenUnaggregatedAttSize)
s.seenSyncMessageCache = lruwrpr.New(seenSyncMsgSize)
s.seenSyncContributionCache = lruwrpr.New(seenSyncContributionSize)
s.syncContributionBitsOverlapCache = lruwrpr.New(seenSyncContributionSize)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For simplicity, I opted in same cache size as seenSyncContributionSize, open for other suggestions

@terencechain terencechain force-pushed the ignore-subset-aggregate branch 2 times, most recently from 871d8f5 to d7c3fd3 Compare May 18, 2022 16:53
if seen {
return pubsub.ValidationIgnore, nil
}
seen = s.hasSeenSyncContributionIndexSlot(c.Slot, m.Message.AggregatorIndex, types.CommitteeIndex(c.SubcommitteeIndex))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is copying ignoreCached

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I removed ignoreCached. I could also use ignoreCached here too if you prefer that

if !ok {
return errors.New("could not covert cached value to []bitfield.Bitvector")
}
s.syncContributionBitsOverlapCache.Add(string(b), append(bitsList, c.AggregationBits.Bytes()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to check whether it contains a bitlist that already contains over what the contribution has.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, thanks!

func (s *Service) setSyncContributionBits(c *ethpb.SyncCommitteeContribution) error {
s.syncContributionBitsOverlapLock.Lock()
defer s.syncContributionBitsOverlapLock.Unlock()
b := append(c.BlockRoot, bytesutil.Bytes32(uint64(c.Slot))...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should copy c.BlockRoot first before appending it here. Due to how protobuf unmarshalling is carried out, you could unintentionally mutate this sync contribution.

}

// BitListOverlaps returns true if there's an overlap between two bitlists.
func BitListOverlaps(bitLists [][]byte, b []byte) (bool, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to export it here, as no consumer is going to use this from the sync package currently.

@@ -10,3 +10,7 @@ import (
func NewSyncCommitteeAggregationBits() bitfield.Bitvector128 {
return bitfield.NewBitvector128()
}

func ConvertSyncContributionBitVector(b []byte) bitfield.Bitvector128 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func ConvertSyncContributionBitVector(b []byte) bitfield.Bitvector128 {
func ConvertToSyncContributionBitVector(b []byte) bitfield.Bitvector128 {

@@ -10,3 +10,7 @@ import (
func NewSyncCommitteeAggregationBits() bitfield.Bitvector8 {
return bitfield.NewBitvector8()
}

func ConvertSyncContributionBitVector(b []byte) bitfield.Bitvector8 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func ConvertSyncContributionBitVector(b []byte) bitfield.Bitvector8 {
func ConvertToSyncContributionBitVector(b []byte) bitfield.Bitvector8 {

nisdas
nisdas previously approved these changes May 24, 2022
@prylabs-bulldozer prylabs-bulldozer bot merged commit 61cbe37 into develop May 25, 2022
@delete-merged-branch delete-merged-branch bot deleted the ignore-subset-aggregate branch May 25, 2022 05:40
rauljordan added a commit that referenced this pull request May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready For Review A pull request ready for code review Spec
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants