mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 11:57:18 +00:00
Don't mark block as bad in validateBeaconBlock
for pending queue (#12983)
* Don't mark block as bad in validateBeaconBlock for pending queue * Fix tests
This commit is contained in:
parent
4628c19f51
commit
58c0899676
@ -159,7 +159,6 @@ func (s *Service) processPendingBlocks(ctx context.Context) error {
|
|||||||
case errors.Is(ErrOptimisticParent, err): // Ok to continue process block with parent that is an optimistic candidate.
|
case errors.Is(ErrOptimisticParent, err): // Ok to continue process block with parent that is an optimistic candidate.
|
||||||
case err != nil:
|
case err != nil:
|
||||||
log.WithError(err).WithField("slot", b.Block().Slot()).Debug("Could not validate block")
|
log.WithError(err).WithField("slot", b.Block().Slot()).Debug("Could not validate block")
|
||||||
s.setBadBlock(ctx, blkRoot)
|
|
||||||
tracing.AnnotateError(span, err)
|
tracing.AnnotateError(span, err)
|
||||||
span.End()
|
span.End()
|
||||||
continue
|
continue
|
||||||
|
@ -108,7 +108,7 @@ func TestRegularSyncBeaconBlockSubscriber_ProcessPendingBlocks1(t *testing.T) {
|
|||||||
require.NoError(t, r.processPendingBlocks(context.Background())) // Marks a block as bad
|
require.NoError(t, r.processPendingBlocks(context.Background())) // Marks a block as bad
|
||||||
require.NoError(t, r.processPendingBlocks(context.Background())) // Bad block removed on second run
|
require.NoError(t, r.processPendingBlocks(context.Background())) // Bad block removed on second run
|
||||||
|
|
||||||
assert.Equal(t, 1, len(r.slotToPendingBlocks.Items()), "Incorrect size for slot to pending blocks cache")
|
assert.Equal(t, 2, len(r.slotToPendingBlocks.Items()), "Incorrect size for slot to pending blocks cache")
|
||||||
assert.Equal(t, 2, len(r.seenPendingBlocks), "Incorrect size for seen pending block")
|
assert.Equal(t, 2, len(r.seenPendingBlocks), "Incorrect size for seen pending block")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ func TestRegularSyncBeaconBlockSubscriber_OptimisticStatus(t *testing.T) {
|
|||||||
require.NoError(t, r.processPendingBlocks(context.Background())) // Marks a block as bad
|
require.NoError(t, r.processPendingBlocks(context.Background())) // Marks a block as bad
|
||||||
require.NoError(t, r.processPendingBlocks(context.Background())) // Bad block removed on second run
|
require.NoError(t, r.processPendingBlocks(context.Background())) // Bad block removed on second run
|
||||||
|
|
||||||
assert.Equal(t, 1, len(r.slotToPendingBlocks.Items()), "Incorrect size for slot to pending blocks cache")
|
assert.Equal(t, 2, len(r.slotToPendingBlocks.Items()), "Incorrect size for slot to pending blocks cache")
|
||||||
assert.Equal(t, 2, len(r.seenPendingBlocks), "Incorrect size for seen pending block")
|
assert.Equal(t, 2, len(r.seenPendingBlocks), "Incorrect size for seen pending block")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,9 +255,9 @@ func TestRegularSyncBeaconBlockSubscriber_ExecutionEngineTimesOut(t *testing.T)
|
|||||||
require.NoError(t, r.processPendingBlocks(context.Background())) // Marks a block as bad
|
require.NoError(t, r.processPendingBlocks(context.Background())) // Marks a block as bad
|
||||||
require.NoError(t, r.processPendingBlocks(context.Background())) // Bad block removed on second run
|
require.NoError(t, r.processPendingBlocks(context.Background())) // Bad block removed on second run
|
||||||
|
|
||||||
assert.Equal(t, 1, len(r.slotToPendingBlocks.Items()), "Incorrect size for slot to pending blocks cache")
|
assert.Equal(t, 2, len(r.slotToPendingBlocks.Items()), "Incorrect size for slot to pending blocks cache")
|
||||||
assert.Equal(t, 2, len(r.seenPendingBlocks), "Incorrect size for seen pending block")
|
assert.Equal(t, 2, len(r.seenPendingBlocks), "Incorrect size for seen pending block")
|
||||||
require.Equal(t, 1, len(r.badBlockCache.Keys())) // Account for the bad block above
|
require.Equal(t, 0, len(r.badBlockCache.Keys())) // Account for the bad block above
|
||||||
require.Equal(t, 0, len(r.seenBlockCache.Keys()))
|
require.Equal(t, 0, len(r.seenBlockCache.Keys()))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,8 +464,8 @@ func TestRegularSyncBeaconBlockSubscriber_ProcessPendingBlocks_2Chains(t *testin
|
|||||||
require.NoError(t, r.processPendingBlocks(context.Background())) // Marks a block as bad
|
require.NoError(t, r.processPendingBlocks(context.Background())) // Marks a block as bad
|
||||||
require.NoError(t, r.processPendingBlocks(context.Background())) // Bad block removed on second run
|
require.NoError(t, r.processPendingBlocks(context.Background())) // Bad block removed on second run
|
||||||
|
|
||||||
assert.Equal(t, 1, len(r.slotToPendingBlocks.Items()), "Incorrect size for slot to pending blocks cache")
|
assert.Equal(t, 2, len(r.slotToPendingBlocks.Items()), "Incorrect size for slot to pending blocks cache")
|
||||||
assert.Equal(t, 1, len(r.seenPendingBlocks), "Incorrect size for seen pending block")
|
assert.Equal(t, 2, len(r.seenPendingBlocks), "Incorrect size for seen pending block")
|
||||||
|
|
||||||
// Add b2 to the cache
|
// Add b2 to the cache
|
||||||
wsb, err = blocks.NewSignedBeaconBlock(b2)
|
wsb, err = blocks.NewSignedBeaconBlock(b2)
|
||||||
@ -477,8 +477,8 @@ func TestRegularSyncBeaconBlockSubscriber_ProcessPendingBlocks_2Chains(t *testin
|
|||||||
require.NoError(t, r.processPendingBlocks(context.Background())) // Marks a block as bad
|
require.NoError(t, r.processPendingBlocks(context.Background())) // Marks a block as bad
|
||||||
require.NoError(t, r.processPendingBlocks(context.Background())) // Bad block removed on second run
|
require.NoError(t, r.processPendingBlocks(context.Background())) // Bad block removed on second run
|
||||||
|
|
||||||
assert.Equal(t, 0, len(r.slotToPendingBlocks.Items()), "Incorrect size for slot to pending blocks cache")
|
assert.Equal(t, 2, len(r.slotToPendingBlocks.Items()), "Incorrect size for slot to pending blocks cache")
|
||||||
assert.Equal(t, 0, len(r.seenPendingBlocks), "Incorrect size for seen pending block")
|
assert.Equal(t, 2, len(r.seenPendingBlocks), "Incorrect size for seen pending block")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRegularSyncBeaconBlockSubscriber_PruneOldPendingBlocks(t *testing.T) {
|
func TestRegularSyncBeaconBlockSubscriber_PruneOldPendingBlocks(t *testing.T) {
|
||||||
|
@ -229,6 +229,7 @@ func (s *Service) validateBeaconBlock(ctx context.Context, blk interfaces.ReadOn
|
|||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
if err := validateDenebBeaconBlock(blk.Block()); err != nil {
|
if err := validateDenebBeaconBlock(blk.Block()); err != nil {
|
||||||
|
s.setBadBlock(ctx, blockRoot)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user