From c71157fd810d4367c0277a7647622b4e7dde4565 Mon Sep 17 00:00:00 2001 From: frozen <355847+Frozen@users.noreply.github.com> Date: Sat, 8 Jun 2024 18:52:33 -0400 Subject: [PATCH] Fixed data race. --- core/blockchain_impl.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/blockchain_impl.go b/core/blockchain_impl.go index d71371986e..a065ecfd6d 100644 --- a/core/blockchain_impl.go +++ b/core/blockchain_impl.go @@ -490,6 +490,9 @@ func (bc *BlockChainImpl) ValidateNewBlock(block *types.Block, beaconChain Block if block.NumberU64() <= bc.CurrentBlock().NumberU64() { return errors.Errorf("block with the same block number is already committed: %d", block.NumberU64()) } + + bc.chainmu.Lock() + defer bc.chainmu.Unlock() if err := bc.validator.ValidateHeader(block, true); err != nil { utils.Logger().Error(). Str("blockHash", block.Hash().Hex()).