Skip to content

Commit f9236f0

Browse files
committed
Handle unaggregated attestations when decomposing (#15027)
1 parent ef85653 commit f9236f0

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

beacon-chain/blockchain/process_block.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,10 @@ func (s *Service) pruneCoveredElectraAttsFromPool(ctx context.Context, headState
503503
if err = s.cfg.AttestationCache.DeleteCovered(a); err != nil {
504504
return errors.Wrap(err, "could not delete covered attestation")
505505
}
506+
} else if !a.IsAggregated() {
507+
if err = s.cfg.AttPool.DeleteUnaggregatedAttestation(a); err != nil {
508+
return errors.Wrap(err, "could not delete unaggregated attestation")
509+
}
506510
} else if err = s.cfg.AttPool.DeleteAggregatedAttestation(a); err != nil {
507511
return errors.Wrap(err, "could not delete aggregated attestation")
508512
}

beacon-chain/blockchain/process_block_test.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import (
5050

5151
func Test_pruneAttsFromPool_Electra(t *testing.T) {
5252
ctx := context.Background()
53+
logHook := logTest.NewGlobal()
5354

5455
params.SetupTestConfigCleanup(t)
5556
cfg := params.BeaconConfig().Copy()
@@ -71,7 +72,7 @@ func Test_pruneAttsFromPool_Electra(t *testing.T) {
7172
cb := primitives.NewAttestationCommitteeBits()
7273
cb.SetBitAt(0, true)
7374
att1 := &ethpb.AttestationElectra{
74-
AggregationBits: bitfield.Bitlist{0b11110111, 0b00000001},
75+
AggregationBits: bitfield.Bitlist{0b10000000, 0b00000001},
7576
Data: data,
7677
Signature: make([]byte, 96),
7778
CommitteeBits: cb,
@@ -95,16 +96,15 @@ func Test_pruneAttsFromPool_Electra(t *testing.T) {
9596
CommitteeBits: cb,
9697
}
9798

98-
require.NoError(t, s.cfg.AttPool.SaveAggregatedAttestation(att1))
99+
require.NoError(t, s.cfg.AttPool.SaveUnaggregatedAttestation(att1))
99100
require.NoError(t, s.cfg.AttPool.SaveAggregatedAttestation(att2))
100101
require.NoError(t, s.cfg.AttPool.SaveAggregatedAttestation(att3))
101-
require.Equal(t, 3, len(s.cfg.AttPool.AggregatedAttestations()))
102102

103103
cb = primitives.NewAttestationCommitteeBits()
104104
cb.SetBitAt(0, true)
105105
cb.SetBitAt(1, true)
106106
onChainAtt := &ethpb.AttestationElectra{
107-
AggregationBits: bitfield.Bitlist{0b11110111, 0b11110111, 0b00000001},
107+
AggregationBits: bitfield.Bitlist{0b10000000, 0b11110111, 0b00000001},
108108
Data: data,
109109
Signature: make([]byte, 96),
110110
CommitteeBits: cb,
@@ -127,7 +127,12 @@ func Test_pruneAttsFromPool_Electra(t *testing.T) {
127127
require.Equal(t, 4, len(committees))
128128

129129
require.NoError(t, s.pruneAttsFromPool(ctx, st, rob))
130-
attsInPool := s.cfg.AttPool.AggregatedAttestations()
130+
require.LogsDoNotContain(t, logHook, "Could not prune attestations")
131+
132+
attsInPool, err := s.cfg.AttPool.UnaggregatedAttestations()
133+
require.NoError(t, err)
134+
assert.Equal(t, 0, len(attsInPool))
135+
attsInPool = s.cfg.AttPool.AggregatedAttestations()
131136
require.Equal(t, 1, len(attsInPool))
132137
assert.DeepEqual(t, att3, attsInPool[0])
133138
}
@@ -908,6 +913,8 @@ func TestInsertFinalizedDeposits_MultipleFinalizedRoutines(t *testing.T) {
908913
}
909914

910915
func TestRemoveBlockAttestationsInPool(t *testing.T) {
916+
logHook := logTest.NewGlobal()
917+
911918
genesis, keys := util.DeterministicGenesisState(t, 64)
912919
b, err := util.GenerateFullBlock(genesis, keys, util.DefaultBlockGenConfig(), 1)
913920
assert.NoError(t, err)
@@ -928,6 +935,7 @@ func TestRemoveBlockAttestationsInPool(t *testing.T) {
928935
wsb, err := consensusblocks.NewSignedBeaconBlock(b)
929936
require.NoError(t, err)
930937
require.NoError(t, service.pruneAttsFromPool(context.Background(), nil /* state not needed pre-Electra */, wsb))
938+
require.LogsDoNotContain(t, logHook, "Could not prune attestations")
931939
require.Equal(t, 0, service.cfg.AttPool.AggregatedAttestationCount())
932940
}
933941

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Fixed
2+
3+
- Handle unaggregated attestations when decomposing Electra block attestations.

0 commit comments

Comments
 (0)