@@ -632,7 +632,6 @@ func (api *API) traceBlockParallel(ctx context.Context, block *types.Block, stat
632632 var (
633633 txs = block .Transactions ()
634634 blockHash = block .Hash ()
635- blockCtx = core .NewEVMBlockContext (block .Header (), api .chainContext (ctx ), nil )
636635 signer = types .MakeSigner (api .backend .ChainConfig (), block .Number (), block .Time ())
637636 results = make ([]* txTraceResult , len (txs ))
638637 pend sync.WaitGroup
@@ -655,6 +654,11 @@ func (api *API) traceBlockParallel(ctx context.Context, block *types.Block, stat
655654 TxIndex : task .index ,
656655 TxHash : txs [task .index ].Hash (),
657656 }
657+ // Reconstruct the block context for each transaction
658+ // as the GetHash function of BlockContext is not safe for
659+ // concurrent use.
660+ // See: https://github.com/ethereum/go-ethereum/issues/29114
661+ blockCtx := core .NewEVMBlockContext (block .Header (), api .chainContext (ctx ), nil )
658662 res , err := api .traceTx (ctx , msg , txctx , blockCtx , task .statedb , config )
659663 if err != nil {
660664 results [task .index ] = & txTraceResult {TxHash : txs [task .index ].Hash (), Error : err .Error ()}
@@ -667,6 +671,7 @@ func (api *API) traceBlockParallel(ctx context.Context, block *types.Block, stat
667671
668672 // Feed the transactions into the tracers and return
669673 var failed error
674+ blockCtx := core .NewEVMBlockContext (block .Header (), api .chainContext (ctx ), nil )
670675txloop:
671676 for i , tx := range txs {
672677 // Send the trace task over for execution
0 commit comments