mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-03 16:37:39 +00:00
Hardening aggregated attestation queue check (#7826)
This commit is contained in:
parent
f75a8efc0d
commit
ad5151f25d
@ -75,6 +75,7 @@ func (s *Service) processPendingAtts(ctx context.Context) error {
|
|||||||
if err := s.attPool.SaveAggregatedAttestation(att.Aggregate); err != nil {
|
if err := s.attPool.SaveAggregatedAttestation(att.Aggregate); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
s.setAggregatorIndexEpochSeen(att.Aggregate.Data.Target.Epoch, att.AggregatorIndex)
|
||||||
|
|
||||||
// Broadcasting the signed attestation again once a node is able to process it.
|
// Broadcasting the signed attestation again once a node is able to process it.
|
||||||
if err := s.p2p.Broadcast(ctx, signedAtt); err != nil {
|
if err := s.p2p.Broadcast(ctx, signedAtt); err != nil {
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/p2p/enr"
|
"github.com/ethereum/go-ethereum/p2p/enr"
|
||||||
|
lru "github.com/hashicorp/golang-lru"
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p-core/network"
|
||||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||||
"github.com/prysmaticlabs/go-bitfield"
|
"github.com/prysmaticlabs/go-bitfield"
|
||||||
@ -173,7 +174,7 @@ func TestProcessPendingAtts_HasBlockSaveAggregatedAtt(t *testing.T) {
|
|||||||
Data: ðpb.AttestationData{
|
Data: ðpb.AttestationData{
|
||||||
BeaconBlockRoot: root[:],
|
BeaconBlockRoot: root[:],
|
||||||
Source: ðpb.Checkpoint{Epoch: 0, Root: bytesutil.PadTo([]byte("hello-world"), 32)},
|
Source: ðpb.Checkpoint{Epoch: 0, Root: bytesutil.PadTo([]byte("hello-world"), 32)},
|
||||||
Target: ðpb.Checkpoint{Epoch: 0, Root: bytesutil.PadTo([]byte("hello-world"), 32)},
|
Target: ðpb.Checkpoint{Epoch: 0, Root: root[:]},
|
||||||
},
|
},
|
||||||
AggregationBits: aggBits,
|
AggregationBits: aggBits,
|
||||||
}
|
}
|
||||||
@ -207,6 +208,8 @@ func TestProcessPendingAtts_HasBlockSaveAggregatedAtt(t *testing.T) {
|
|||||||
|
|
||||||
require.NoError(t, beaconState.SetGenesisTime(uint64(time.Now().Unix())))
|
require.NoError(t, beaconState.SetGenesisTime(uint64(time.Now().Unix())))
|
||||||
|
|
||||||
|
c, err := lru.New(10)
|
||||||
|
require.NoError(t, err)
|
||||||
r := &Service{
|
r := &Service{
|
||||||
p2p: p1,
|
p2p: p1,
|
||||||
db: db,
|
db: db,
|
||||||
@ -219,6 +222,7 @@ func TestProcessPendingAtts_HasBlockSaveAggregatedAtt(t *testing.T) {
|
|||||||
blkRootToPendingAtts: make(map[[32]byte][]*ethpb.SignedAggregateAttestationAndProof),
|
blkRootToPendingAtts: make(map[[32]byte][]*ethpb.SignedAggregateAttestationAndProof),
|
||||||
attPool: attestations.NewPool(),
|
attPool: attestations.NewPool(),
|
||||||
stateSummaryCache: cache.NewStateSummaryCache(),
|
stateSummaryCache: cache.NewStateSummaryCache(),
|
||||||
|
seenAttestationCache: c,
|
||||||
}
|
}
|
||||||
|
|
||||||
sb = testutil.NewBeaconBlock()
|
sb = testutil.NewBeaconBlock()
|
||||||
|
@ -80,15 +80,6 @@ func (s *Service) validateAggregateAndProof(ctx context.Context, pid peer.ID, ms
|
|||||||
return pubsub.ValidationIgnore
|
return pubsub.ValidationIgnore
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify attestation target root is consistent with the head root.
|
|
||||||
// This verification is not in the spec, however we guard against it as it opens us up
|
|
||||||
// to weird edge cases during verification. The attestation technically could be used to add value to a block,
|
|
||||||
// but it's invalid in the spirit of the protocol. Here we choose safety over profit.
|
|
||||||
if err := s.chain.VerifyLmdFfgConsistency(ctx, m.Message.Aggregate); err != nil {
|
|
||||||
traceutil.AnnotateError(span, err)
|
|
||||||
return pubsub.ValidationReject
|
|
||||||
}
|
|
||||||
|
|
||||||
validationRes := s.validateAggregatedAtt(ctx, m)
|
validationRes := s.validateAggregatedAtt(ctx, m)
|
||||||
if validationRes != pubsub.ValidationAccept {
|
if validationRes != pubsub.ValidationAccept {
|
||||||
return validationRes
|
return validationRes
|
||||||
@ -105,6 +96,16 @@ func (s *Service) validateAggregatedAtt(ctx context.Context, signed *ethpb.Signe
|
|||||||
ctx, span := trace.StartSpan(ctx, "sync.validateAggregatedAtt")
|
ctx, span := trace.StartSpan(ctx, "sync.validateAggregatedAtt")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
|
// Verify attestation target root is consistent with the head root.
|
||||||
|
// This verification is not in the spec, however we guard against it as it opens us up
|
||||||
|
// to weird edge cases during verification. The attestation technically could be used to add value to a block,
|
||||||
|
// but it's invalid in the spirit of the protocol. Here we choose safety over profit.
|
||||||
|
if err := s.chain.VerifyLmdFfgConsistency(ctx, signed.Message.Aggregate); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
traceutil.AnnotateError(span, err)
|
||||||
|
return pubsub.ValidationReject
|
||||||
|
}
|
||||||
|
|
||||||
attSlot := signed.Message.Aggregate.Data.Slot
|
attSlot := signed.Message.Aggregate.Data.Slot
|
||||||
|
|
||||||
bs, err := s.chain.AttestationPreState(ctx, signed.Message.Aggregate)
|
bs, err := s.chain.AttestationPreState(ctx, signed.Message.Aggregate)
|
||||||
|
Loading…
Reference in New Issue
Block a user