Compare commits

...

11 Commits

Author SHA1 Message Date
terence tsao
747414bddd Ignore subset aggregates 2022-05-10 16:42:21 -07:00
terence tsao
676092594a Merge branch 'develop' of github.com:prysmaticlabs/prysm into develop 2022-05-10 16:09:55 -07:00
terence tsao
3567e36125 Merge branch 'develop' of github.com:prysmaticlabs/prysm into develop 2022-05-10 13:27:56 -07:00
prylabs-bulldozer[bot]
071af32616 Merge refs/heads/develop into cache-justified-finalized-payload-hash 2022-05-10 19:13:36 +00:00
terencechain
711eab91e6 Merge branch 'develop' into cache-justified-finalized-payload-hash 2022-05-10 12:05:34 -07:00
terence tsao
2419d653f9 Use real byte 2022-05-09 15:19:41 -07:00
terencechain
e2d76b3f6f Merge branch 'develop' into cache-justified-finalized-payload-hash 2022-05-09 11:54:40 -07:00
terence tsao
543f183d76 Fix tests 2022-05-09 08:19:40 -07:00
terence tsao
82739305be Merge branch 'develop' of github.com:prysmaticlabs/prysm into cache-justified-finalized-payload-hash 2022-05-09 08:05:08 -07:00
terencechain
8c5955f7c0 Merge branch 'develop' into cache-justified-finalized-payload-hash 2022-05-06 14:49:13 -07:00
terence tsao
3b6679cb6b Cache and use justified and finalized payload block hash 2022-05-06 14:44:27 -07:00
4 changed files with 57 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
package synccommittee
import (
"bytes"
"strconv"
"github.com/pkg/errors"
@@ -85,6 +86,35 @@ func (s *Store) SyncCommitteeContributions(slot types.Slot) ([]*ethpb.SyncCommit
return contributions, nil
}
// HasSyncCommitteeContribution returns true if a sync committee contribution exits in the cache.
// Exist means there's a similar contribution where the aggregation bits is the superset of the input bits.
func (s *Store) HasSyncCommitteeContribution(c *ethpb.SyncCommitteeContribution) (bool, error) {
s.contributionLock.RLock()
defer s.contributionLock.RUnlock()
item := s.contributionCache.RetrieveByKey(syncCommitteeKey(c.Slot))
if item == nil {
return false, nil
}
contributions, ok := item.Value.([]*ethpb.SyncCommitteeContribution)
if !ok {
return false, errors.New("not typed []ethpb.SyncCommitteeContribution")
}
for _, contribution := range contributions {
if bytes.Equal(c.BlockRoot, contribution.BlockRoot) && c.SubcommitteeIndex == contribution.SubcommitteeIndex {
c, err := contribution.AggregationBits.Contains(c.AggregationBits)
if err != nil {
return false, err
}
if c {
return true, nil
}
}
}
return false, nil
}
func syncCommitteeKey(slot types.Slot) string {
return strconv.FormatUint(uint64(slot), 10)
}

View File

@@ -19,6 +19,8 @@ type Pool interface {
// Methods for Sync Committee Messages.
SaveSyncCommitteeMessage(sig *ethpb.SyncCommitteeMessage) error
SyncCommitteeMessages(slot types.Slot) ([]*ethpb.SyncCommitteeMessage, error)
HasSyncCommitteeContribution(c *ethpb.SyncCommitteeContribution) (bool, error)
}
// NewPool returns the sync committee store fulfilling the pool interface.

View File

@@ -91,6 +91,14 @@ func (s *Service) validateAggregateAndProof(ctx context.Context, pid peer.ID, ms
return pubsub.ValidationIgnore, err
}
has, err := s.cfg.attPool.HasAggregatedAttestation(m.Message.Aggregate)
if err != nil {
return pubsub.ValidationIgnore, err
}
if has {
return pubsub.ValidationIgnore, err
}
// Verify this is the first aggregate received from the aggregator with index and slot.
if s.hasSeenAggregatorIndexEpoch(m.Message.Aggregate.Data.Target.Epoch, m.Message.AggregatorIndex) {
return pubsub.ValidationIgnore, nil

View File

@@ -148,6 +148,23 @@ func rejectEmptyContribution(m *ethpb.SignedContributionAndProof) validationFn {
}
func (s *Service) ignoreSeenSyncContribution(m *ethpb.SignedContributionAndProof) validationFn {
return func(ctx context.Context) (pubsub.ValidationResult, error) {
seen := s.hasSeenSyncContributionIndexSlot(m.Message.Contribution.Slot, m.Message.AggregatorIndex, types.CommitteeIndex(m.Message.Contribution.SubcommitteeIndex))
if seen {
return pubsub.ValidationIgnore, nil
}
seen, err := s.cfg.syncCommsPool.HasSyncCommitteeContribution(m.Message.Contribution)
if err != nil {
return pubsub.ValidationIgnore, err
}
if seen {
return pubsub.ValidationIgnore, nil
}
return pubsub.ValidationAccept, nil
}
}
func (s *Service) ignoreCached(m *ethpb.SignedContributionAndProof) validationFn {
return func(ctx context.Context) (pubsub.ValidationResult, error) {
seen := s.hasSeenSyncContributionIndexSlot(m.Message.Contribution.Slot, m.Message.AggregatorIndex, types.CommitteeIndex(m.Message.Contribution.SubcommitteeIndex))
if seen {