Skip to content

Commit b0d6329

Browse files
committed
Remove error from signatures of UnaggregatedAttestations and pruneAttsFromPool (#15028)
1 parent e033909 commit b0d6329

17 files changed

+30
-70
lines changed

beacon-chain/blockchain/forkchoice_update_execution.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,7 @@ func (s *Service) forkchoiceUpdateWithExecution(ctx context.Context, args *fcuCo
105105
go firePayloadAttributesEvent(ctx, s.cfg.StateNotifier.StateFeed(), s.CurrentSlot()+1)
106106

107107
// Only need to prune attestations from pool if the head has changed.
108-
if err := s.pruneAttsFromPool(s.ctx, args.headState, args.headBlock); err != nil {
109-
log.WithError(err).Error("could not prune attestations from pool")
110-
}
108+
s.pruneAttsFromPool(s.ctx, args.headState, args.headBlock)
111109
return nil
112110
}
113111

beacon-chain/blockchain/process_block.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,13 +423,12 @@ func (s *Service) savePostStateInfo(ctx context.Context, r [32]byte, b interface
423423

424424
// pruneAttsFromPool removes these attestations from the attestation pool
425425
// which are covered by attestations from the received block.
426-
func (s *Service) pruneAttsFromPool(ctx context.Context, headState state.BeaconState, headBlock interfaces.ReadOnlySignedBeaconBlock) error {
426+
func (s *Service) pruneAttsFromPool(ctx context.Context, headState state.BeaconState, headBlock interfaces.ReadOnlySignedBeaconBlock) {
427427
for _, att := range headBlock.Block().Body().Attestations() {
428428
if err := s.pruneCoveredAttsFromPool(ctx, headState, att); err != nil {
429429
log.WithError(err).Warn("Could not prune attestations covered by a received block's attestation")
430430
}
431431
}
432-
return nil
433432
}
434433

435434
func (s *Service) pruneCoveredAttsFromPool(ctx context.Context, headState state.BeaconState, att ethpb.Att) error {

beacon-chain/blockchain/process_block_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,10 @@ func Test_pruneAttsFromPool_Electra(t *testing.T) {
126126
// into the correct number of aggregates.
127127
require.Equal(t, 4, len(committees))
128128

129-
require.NoError(t, s.pruneAttsFromPool(ctx, st, rob))
129+
s.pruneAttsFromPool(ctx, st, rob)
130130
require.LogsDoNotContain(t, logHook, "Could not prune attestations")
131131

132-
attsInPool, err := s.cfg.AttPool.UnaggregatedAttestations()
133-
require.NoError(t, err)
132+
attsInPool := s.cfg.AttPool.UnaggregatedAttestations()
134133
assert.Equal(t, 0, len(attsInPool))
135134
attsInPool = s.cfg.AttPool.AggregatedAttestations()
136135
require.Equal(t, 1, len(attsInPool))
@@ -934,7 +933,7 @@ func TestRemoveBlockAttestationsInPool(t *testing.T) {
934933
require.NoError(t, service.cfg.AttPool.SaveAggregatedAttestations(atts))
935934
wsb, err := consensusblocks.NewSignedBeaconBlock(b)
936935
require.NoError(t, err)
937-
require.NoError(t, service.pruneAttsFromPool(context.Background(), nil /* state not needed pre-Electra */, wsb))
936+
service.pruneAttsFromPool(context.Background(), nil /* state not needed pre-Electra */, wsb)
938937
require.LogsDoNotContain(t, logHook, "Could not prune attestations")
939938
require.Equal(t, 0, service.cfg.AttPool.AggregatedAttestationCount())
940939
}

beacon-chain/operations/attestations/kv/aggregated.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ import (
2323
func (c *AttCaches) AggregateUnaggregatedAttestations(ctx context.Context) error {
2424
ctx, span := trace.StartSpan(ctx, "operations.attestations.kv.AggregateUnaggregatedAttestations")
2525
defer span.End()
26-
unaggregatedAtts, err := c.UnaggregatedAttestations()
27-
if err != nil {
28-
return err
29-
}
26+
unaggregatedAtts := c.UnaggregatedAttestations()
3027
return c.aggregateUnaggregatedAtts(ctx, unaggregatedAtts)
3128
}
3229

beacon-chain/operations/attestations/kv/unaggregated.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (c *AttCaches) SaveUnaggregatedAttestations(atts []ethpb.Att) error {
5353
}
5454

5555
// UnaggregatedAttestations returns all the unaggregated attestations in cache.
56-
func (c *AttCaches) UnaggregatedAttestations() ([]ethpb.Att, error) {
56+
func (c *AttCaches) UnaggregatedAttestations() []ethpb.Att {
5757
c.unAggregateAttLock.RLock()
5858
defer c.unAggregateAttLock.RUnlock()
5959
unAggregatedAtts := c.unAggregatedAtt
@@ -68,7 +68,7 @@ func (c *AttCaches) UnaggregatedAttestations() ([]ethpb.Att, error) {
6868
atts = append(atts, att.Clone())
6969
}
7070
}
71-
return atts, nil
71+
return atts
7272
}
7373

7474
// UnaggregatedAttestationsBySlotIndex returns the unaggregated attestations in cache,

beacon-chain/operations/attestations/kv/unaggregated_test.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ func TestKV_Unaggregated_UnaggregatedAttestations(t *testing.T) {
2929
// cache a bitlist whose length is different from the attestation bitlist's length
3030
cache.seenAtt.Set(id.String(), []bitfield.Bitlist{{0b1001}}, c.DefaultExpiration)
3131

32-
atts, err := cache.UnaggregatedAttestations()
33-
require.NoError(t, err)
32+
atts := cache.UnaggregatedAttestations()
3433
assert.Equal(t, 0, len(atts))
3534
})
3635
}
@@ -169,8 +168,7 @@ func TestKV_Unaggregated_DeleteUnaggregatedAttestation(t *testing.T) {
169168
for _, att := range atts {
170169
assert.NoError(t, cache.DeleteUnaggregatedAttestation(att))
171170
}
172-
returned, err := cache.UnaggregatedAttestations()
173-
require.NoError(t, err)
171+
returned := cache.UnaggregatedAttestations()
174172
assert.DeepEqual(t, []ethpb.Att{}, returned)
175173
})
176174

@@ -234,11 +232,10 @@ func TestKV_Unaggregated_DeleteSeenUnaggregatedAttestations(t *testing.T) {
234232
assert.NoError(t, err)
235233
assert.Equal(t, 1, count)
236234
assert.Equal(t, 2, cache.UnaggregatedAttestationCount())
237-
returned, err := cache.UnaggregatedAttestations()
235+
returned := cache.UnaggregatedAttestations()
238236
sort.Slice(returned, func(i, j int) bool {
239237
return bytes.Compare(returned[i].GetAggregationBits(), returned[j].GetAggregationBits()) < 0
240238
})
241-
require.NoError(t, err)
242239
assert.DeepEqual(t, []ethpb.Att{atts[0], atts[2]}, returned)
243240
})
244241

@@ -261,8 +258,7 @@ func TestKV_Unaggregated_DeleteSeenUnaggregatedAttestations(t *testing.T) {
261258
assert.NoError(t, err)
262259
assert.Equal(t, 3, count)
263260
assert.Equal(t, 0, cache.UnaggregatedAttestationCount())
264-
returned, err := cache.UnaggregatedAttestations()
265-
require.NoError(t, err)
261+
returned := cache.UnaggregatedAttestations()
266262
assert.DeepEqual(t, []ethpb.Att{}, returned)
267263
})
268264

beacon-chain/operations/attestations/mock/mock.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ func (m *PoolMock) SaveUnaggregatedAttestations(atts []ethpb.Att) error {
7979
}
8080

8181
// UnaggregatedAttestations --
82-
func (m *PoolMock) UnaggregatedAttestations() ([]ethpb.Att, error) {
83-
return m.UnaggregatedAtts, nil
82+
func (m *PoolMock) UnaggregatedAttestations() []ethpb.Att {
83+
return m.UnaggregatedAtts
8484
}
8585

8686
// UnaggregatedAttestationsBySlotIndex --

beacon-chain/operations/attestations/pool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type Pool interface {
2626
// For unaggregated attestations.
2727
SaveUnaggregatedAttestation(att ethpb.Att) error
2828
SaveUnaggregatedAttestations(atts []ethpb.Att) error
29-
UnaggregatedAttestations() ([]ethpb.Att, error)
29+
UnaggregatedAttestations() []ethpb.Att
3030
UnaggregatedAttestationsBySlotIndex(ctx context.Context, slot primitives.Slot, committeeIndex primitives.CommitteeIndex) []*ethpb.Attestation
3131
UnaggregatedAttestationsBySlotIndexElectra(ctx context.Context, slot primitives.Slot, committeeIndex primitives.CommitteeIndex) []*ethpb.AttestationElectra
3232
DeleteUnaggregatedAttestation(att ethpb.Att) error

beacon-chain/operations/attestations/prune_expired.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,8 @@ func (s *Service) pruneExpiredAtts() {
6161
if _, err := s.cfg.Pool.DeleteSeenUnaggregatedAttestations(); err != nil {
6262
log.WithError(err).Error("Cannot delete seen attestations")
6363
}
64-
unAggregatedAtts, err := s.cfg.Pool.UnaggregatedAttestations()
65-
if err != nil {
66-
log.WithError(err).Error("Could not get unaggregated attestations")
67-
return
68-
}
69-
for _, att := range unAggregatedAtts {
64+
65+
for _, att := range s.cfg.Pool.UnaggregatedAttestations() {
7066
if s.expired(att.GetData().Slot) {
7167
if err := s.cfg.Pool.DeleteUnaggregatedAttestation(att); err != nil {
7268
log.WithError(err).Error("Could not delete expired unaggregated attestation")

beacon-chain/operations/attestations/prune_expired_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ func TestPruneExpired_Ticker(t *testing.T) {
5454

5555
done := make(chan struct{}, 1)
5656
async.RunEvery(ctx, 500*time.Millisecond, func() {
57-
atts, err := s.cfg.Pool.UnaggregatedAttestations()
58-
require.NoError(t, err)
59-
for _, attestation := range atts {
57+
for _, attestation := range s.cfg.Pool.UnaggregatedAttestations() {
6058
if attestation.GetData().Slot == 0 {
6159
return
6260
}

0 commit comments

Comments
 (0)