Skip to content

Commit

Permalink
eth/tracers: avoid using blockCtx concurrently (#24286)
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman authored and palango committed Mar 15, 2023
1 parent 9cfc93d commit f56b115
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion eth/tracers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,6 @@ 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()

isEspresso := api.backend.ChainConfig().IsEspresso(block.Number())
Expand All @@ -631,6 +630,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
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 {
Expand All @@ -654,6 +654,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
vmRunner := api.backend.NewEVMRunner(block.Header(), statedb)
// 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}
Expand Down

0 comments on commit f56b115

Please sign in to comment.