diff --git a/beacon-chain/blockchain/chain_info.go b/beacon-chain/blockchain/chain_info.go index 30dfeac9642b..f6a6e5dec924 100644 --- a/beacon-chain/blockchain/chain_info.go +++ b/beacon-chain/blockchain/chain_info.go @@ -509,13 +509,6 @@ func (s *Service) Ancestor(ctx context.Context, root []byte, slot primitives.Slo return ar[:], nil } -// SetOptimisticToInvalid wraps the corresponding method in forkchoice -func (s *Service) SetOptimisticToInvalid(ctx context.Context, root, parent, lvh [32]byte) ([][32]byte, error) { - s.cfg.ForkChoiceStore.Lock() - defer s.cfg.ForkChoiceStore.Unlock() - return s.cfg.ForkChoiceStore.SetOptimisticToInvalid(ctx, root, parent, lvh) -} - // SetGenesisTime sets the genesis time of beacon chain. func (s *Service) SetGenesisTime(t time.Time) { s.genesisTime = t diff --git a/beacon-chain/blockchain/execution_engine.go b/beacon-chain/blockchain/execution_engine.go index 6d6f85cdf78b..3d4e72442c03 100644 --- a/beacon-chain/blockchain/execution_engine.go +++ b/beacon-chain/blockchain/execution_engine.go @@ -256,7 +256,7 @@ func (s *Service) notifyNewPayload(ctx context.Context, preStateVersion int, // reportInvalidBlock deals with the event that an invalid block was detected by the execution layer func (s *Service) pruneInvalidBlock(ctx context.Context, root, parentRoot, lvh [32]byte) error { newPayloadInvalidNodeCount.Inc() - invalidRoots, err := s.SetOptimisticToInvalid(ctx, root, parentRoot, lvh) + invalidRoots, err := s.cfg.ForkChoiceStore.SetOptimisticToInvalid(ctx, root, parentRoot, lvh) if err != nil { return err } diff --git a/beacon-chain/blockchain/receive_block.go b/beacon-chain/blockchain/receive_block.go index dd6cba229b0b..23a6f9de1e2a 100644 --- a/beacon-chain/blockchain/receive_block.go +++ b/beacon-chain/blockchain/receive_block.go @@ -497,7 +497,10 @@ func (s *Service) sendBlockAttestationsToSlasher(signed interfaces.ReadOnlySigne func (s *Service) validateExecutionOnBlock(ctx context.Context, ver int, header interfaces.ExecutionData, signed interfaces.ReadOnlySignedBeaconBlock, blockRoot [32]byte) (bool, error) { isValidPayload, err := s.notifyNewPayload(ctx, ver, header, signed) if err != nil { - return false, s.handleInvalidExecutionError(ctx, err, blockRoot, signed.Block().ParentRoot()) + s.cfg.ForkChoiceStore.Lock() + err = s.handleInvalidExecutionError(ctx, err, blockRoot, signed.Block().ParentRoot()) + s.cfg.ForkChoiceStore.Unlock() + return false, err } if signed.Version() < version.Capella && isValidPayload { if err := s.validateMergeTransitionBlock(ctx, ver, header, signed); err != nil {