Skip to content

Commit

Permalink
fix race condition on blockcontext
Browse files Browse the repository at this point in the history
  • Loading branch information
zjubfd authored and unclezoro committed Dec 23, 2021
1 parent 62a3bc2 commit 7e2c1d9
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 @@ -604,7 +604,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()
for th := 0; th < threads; th++ {
pend.Add(1)
Expand All @@ -618,6 +617,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
TxIndex: task.index,
TxHash: txs[task.index].Hash(),
}
blockCtx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil)
res, err := api.traceTx(ctx, msg, txctx, blockCtx, task.statedb, config)
if err != nil {
results[task.index] = &txTraceResult{Error: err.Error()}
Expand Down Expand Up @@ -647,6 +647,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
}

statedb.Prepare(tx.Hash(), block.Hash(), i)
blockCtx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil)
vmenv := vm.NewEVM(blockCtx, core.NewEVMTxContext(msg), statedb, api.backend.ChainConfig(), vm.Config{})
if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas())); err != nil {
failed = err
Expand Down

0 comments on commit 7e2c1d9

Please sign in to comment.