From 015fde9a2c4b6e722a9de5bfea2a14226806a231 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Tue, 25 Jan 2022 14:45:30 +0100 Subject: [PATCH] eth/tracers: avoid using blockCtx concurrently (#24286) --- eth/tracers/api.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eth/tracers/api.go b/eth/tracers/api.go index 5e553c114..b16b68c1f 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -592,11 +592,11 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac if threads > len(txs) { threads = len(txs) } - blockCtx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil) blockHash := block.Hash() for th := 0; th < threads; th++ { pend.Add(1) go func() { + blockCtx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil) defer pend.Done() // Fetch and execute the next transaction trace tasks for task := range jobs { @@ -617,6 +617,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac } // Feed the transactions into the tracers and return var failed error + blockCtx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil) for i, tx := range txs { // Send the trace task over for execution jobs <- &txTraceTask{statedb: statedb.Copy(), index: i}