mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
Revert "Subscriber: use target epoch for hasSeen cache" (#6944)
* Revert "Subscriber: use target epoch for hasSeen cache (#6908)"
This reverts commit 3275a86ece
.
This commit is contained in:
parent
f575a81afd
commit
7591240366
@ -24,7 +24,7 @@ func (s *Service) committeeIndexBeaconAttestationSubscriber(ctx context.Context,
|
|||||||
if a.Data == nil {
|
if a.Data == nil {
|
||||||
return errors.New("nil attestation")
|
return errors.New("nil attestation")
|
||||||
}
|
}
|
||||||
s.setSeenCommitteeIndicesEpoch(a.Data.Target.Epoch, a.Data.CommitteeIndex, a.AggregationBits)
|
s.setSeenCommitteeIndicesSlot(a.Data.Slot, a.Data.CommitteeIndex, a.AggregationBits)
|
||||||
|
|
||||||
exists, err := s.attPool.HasAggregatedAttestation(a)
|
exists, err := s.attPool.HasAggregatedAttestation(a)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -69,8 +69,8 @@ func (s *Service) validateCommitteeIndexBeaconAttestation(ctx context.Context, p
|
|||||||
return pubsub.ValidationIgnore
|
return pubsub.ValidationIgnore
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify this the first attestation received for the participating validator for the target epoch.
|
// Verify this the first attestation received for the participating validator for the slot.
|
||||||
if s.hasSeenCommitteeIndicesEpoch(att.Data.Target.Epoch, att.Data.CommitteeIndex, att.AggregationBits) {
|
if s.hasSeenCommitteeIndicesSlot(att.Data.Slot, att.Data.CommitteeIndex, att.AggregationBits) {
|
||||||
return pubsub.ValidationIgnore
|
return pubsub.ValidationIgnore
|
||||||
}
|
}
|
||||||
// Reject an attestation if it references an invalid block.
|
// Reject an attestation if it references an invalid block.
|
||||||
@ -138,28 +138,28 @@ func (s *Service) validateCommitteeIndexBeaconAttestation(ctx context.Context, p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s.setSeenCommitteeIndicesEpoch(att.Data.Target.Epoch, att.Data.CommitteeIndex, att.AggregationBits)
|
s.setSeenCommitteeIndicesSlot(att.Data.Slot, att.Data.CommitteeIndex, att.AggregationBits)
|
||||||
|
|
||||||
msg.ValidatorData = att
|
msg.ValidatorData = att
|
||||||
|
|
||||||
return pubsub.ValidationAccept
|
return pubsub.ValidationAccept
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if the attestation was already seen for the participating validator for the target epoch.
|
// Returns true if the attestation was already seen for the participating validator for the slot.
|
||||||
func (s *Service) hasSeenCommitteeIndicesEpoch(epoch uint64, committeeID uint64, aggregateBits []byte) bool {
|
func (s *Service) hasSeenCommitteeIndicesSlot(slot uint64, committeeID uint64, aggregateBits []byte) bool {
|
||||||
s.seenAttestationLock.RLock()
|
s.seenAttestationLock.RLock()
|
||||||
defer s.seenAttestationLock.RUnlock()
|
defer s.seenAttestationLock.RUnlock()
|
||||||
b := append(bytesutil.Bytes32(epoch), bytesutil.Bytes32(committeeID)...)
|
b := append(bytesutil.Bytes32(slot), bytesutil.Bytes32(committeeID)...)
|
||||||
b = append(b, aggregateBits...)
|
b = append(b, aggregateBits...)
|
||||||
_, seen := s.seenAttestationCache.Get(string(b))
|
_, seen := s.seenAttestationCache.Get(string(b))
|
||||||
return seen
|
return seen
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set committee's indices and target epoch as seen for incoming attestations.
|
// Set committee's indices and slot as seen for incoming attestations.
|
||||||
func (s *Service) setSeenCommitteeIndicesEpoch(epoch uint64, committeeID uint64, aggregateBits []byte) {
|
func (s *Service) setSeenCommitteeIndicesSlot(slot uint64, committeeID uint64, aggregateBits []byte) {
|
||||||
s.seenAttestationLock.Lock()
|
s.seenAttestationLock.Lock()
|
||||||
defer s.seenAttestationLock.Unlock()
|
defer s.seenAttestationLock.Unlock()
|
||||||
b := append(bytesutil.Bytes32(epoch), bytesutil.Bytes32(committeeID)...)
|
b := append(bytesutil.Bytes32(slot), bytesutil.Bytes32(committeeID)...)
|
||||||
b = append(b, aggregateBits...)
|
b = append(b, aggregateBits...)
|
||||||
s.seenAttestationCache.Add(string(b), true)
|
s.seenAttestationCache.Add(string(b), true)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user