Ignore subset aggregates - #10674
Conversation
c1a22ac to
e1368e9
Compare
| s.seenUnAggregatedAttestationCache = lruwrpr.New(seenUnaggregatedAttSize) | ||
| s.seenSyncMessageCache = lruwrpr.New(seenSyncMsgSize) | ||
| s.seenSyncContributionCache = lruwrpr.New(seenSyncContributionSize) | ||
| s.syncContributionBitsOverlapCache = lruwrpr.New(seenSyncContributionSize) |
There was a problem hiding this comment.
For simplicity, I opted in same cache size as seenSyncContributionSize, open for other suggestions
871d8f5 to
d7c3fd3
Compare
d7c3fd3 to
b1f7eeb
Compare
44511ef to
417187f
Compare
| if seen { | ||
| return pubsub.ValidationIgnore, nil | ||
| } | ||
| seen = s.hasSeenSyncContributionIndexSlot(c.Slot, m.Message.AggregatorIndex, types.CommitteeIndex(c.SubcommitteeIndex)) |
There was a problem hiding this comment.
this is copying ignoreCached
There was a problem hiding this comment.
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())) |
There was a problem hiding this comment.
you need to check whether it contains a bitlist that already contains over what the contribution has.
There was a problem hiding this comment.
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))...) |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
| func ConvertSyncContributionBitVector(b []byte) bitfield.Bitvector128 { | |
| func ConvertToSyncContributionBitVector(b []byte) bitfield.Bitvector128 { |
| return bitfield.NewBitvector8() | ||
| } | ||
|
|
||
| func ConvertSyncContributionBitVector(b []byte) bitfield.Bitvector8 { |
There was a problem hiding this comment.
| func ConvertSyncContributionBitVector(b []byte) bitfield.Bitvector8 { | |
| func ConvertToSyncContributionBitVector(b []byte) bitfield.Bitvector8 { |
This reverts commit 61cbe37.
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,
HasAggregatedAttestationalready checks the subset 🙌🏼