Skip to content

Ignore subset aggregates - #10674

Merged
prylabs-bulldozer[bot] merged 23 commits into
developfrom
ignore-subset-aggregate
May 25, 2022
Merged

Ignore subset aggregates#10674
prylabs-bulldozer[bot] merged 23 commits into
developfrom
ignore-subset-aggregate

Conversation

@terencechain

@terencechain terencechain commented May 10, 2022

Copy link
Copy Markdown
Collaborator

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 force-pushed the ignore-subset-aggregate branch from c1a22ac to e1368e9 Compare May 17, 2022 20:44
s.seenUnAggregatedAttestationCache = lruwrpr.New(seenUnaggregatedAttSize)
s.seenSyncMessageCache = lruwrpr.New(seenSyncMsgSize)
s.seenSyncContributionCache = lruwrpr.New(seenSyncContributionSize)
s.syncContributionBitsOverlapCache = lruwrpr.New(seenSyncContributionSize)

Copy link
Copy Markdown
Collaborator 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
@terencechain
terencechain force-pushed the ignore-subset-aggregate branch from d7c3fd3 to b1f7eeb Compare May 18, 2022 18:04
@terencechain
terencechain force-pushed the ignore-subset-aggregate branch from 44511ef to 417187f Compare May 18, 2022 20:44
if seen {
return pubsub.ValidationIgnore, nil
}
seen = s.hasSeenSyncContributionIndexSlot(c.Slot, m.Message.AggregatorIndex, types.CommitteeIndex(c.SubcommitteeIndex))

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Collaborator 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
Copy Markdown
Contributor

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
Copy Markdown
Collaborator 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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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.

return bitfield.NewBitvector128()
}

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

Copy link
Copy Markdown
Contributor

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 {

return bitfield.NewBitvector8()
}

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

Copy link
Copy Markdown
Contributor

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants