diff --git a/beacon-chain/blockchain/process_block.go b/beacon-chain/blockchain/process_block.go index 7b4a112e24..4b30818503 100644 --- a/beacon-chain/blockchain/process_block.go +++ b/beacon-chain/blockchain/process_block.go @@ -111,6 +111,11 @@ func (s *Service) onBlock(ctx context.Context, signed block.SignedBeaconBlock, b return errors.Wrap(err, "could not verify new payload") } + // TODO(10261) Check optimistic status + if err := s.savePostStateInfo(ctx, blockRoot, signed, postState, false /* reg sync */, false /*optimistic sync*/); err != nil { + return err + } + // We add a proposer score boost to fork choice for the block root if applicable, right after // running a successful state transition for the block. if err := s.cfg.ForkChoiceStore.BoostProposerRoot( @@ -119,11 +124,6 @@ func (s *Service) onBlock(ctx context.Context, signed block.SignedBeaconBlock, b return err } - // TODO(10261) Check optimistic status - if err := s.savePostStateInfo(ctx, blockRoot, signed, postState, false /* reg sync */, false /*optimistic sync*/); err != nil { - return err - } - // If slasher is configured, forward the attestations in the block via // an event feed for processing. if features.Get().EnableSlasher { diff --git a/beacon-chain/blockchain/process_block_test.go b/beacon-chain/blockchain/process_block_test.go index 688c6d471e..2a2dede2f0 100644 --- a/beacon-chain/blockchain/process_block_test.go +++ b/beacon-chain/blockchain/process_block_test.go @@ -229,6 +229,24 @@ func TestStore_OnBlock_DoublyLinkedTree(t *testing.T) { } } +func TestStore_OnBlock_ProposerBoostEarly(t *testing.T) { + ctx := context.Background() + + beaconDB := testDB.SetupDB(t) + fcs := doublylinkedtree.New(0, 0) + opts := []Option{ + WithStateGen(stategen.New(beaconDB)), + WithForkChoiceStore(fcs), + } + + service, err := NewService(ctx, opts...) + require.NoError(t, err) + require.NoError(t, service.cfg.ForkChoiceStore.BoostProposerRoot(ctx, 0, [32]byte{'A'}, time.Now())) + _, err = service.cfg.ForkChoiceStore.Head(ctx, 0, + params.BeaconConfig().ZeroHash, []uint64{}, 0) + require.ErrorContains(t, "could not apply proposer boost score: invalid proposer boost root", err) +} + func TestStore_OnBlockBatch_ProtoArray(t *testing.T) { ctx := context.Background() beaconDB := testDB.SetupDB(t)