diff --git a/ethapi/api.go b/ethapi/api.go index 1b5d72f78..35fc218c4 100644 --- a/ethapi/api.go +++ b/ethapi/api.go @@ -2179,12 +2179,14 @@ func (api *PublicDebugAPI) traceBlock(ctx context.Context, block *evmcore.EvmBlo threads = len(txs) } - blockCtx := api.b.GetBlockContext(block.Header()) + blockHeader := block.Header() blockHash := block.Hash for th := 0; th < threads; th++ { pend.Add(1) go func() { defer pend.Done() + blockCtx := api.b.GetBlockContext(blockHeader) + // Fetch and execute the next transaction trace tasks for task := range jobs { msg, _ := txs[task.index].AsMessage(signer, block.BaseFee) @@ -2203,6 +2205,7 @@ func (api *PublicDebugAPI) traceBlock(ctx context.Context, block *evmcore.EvmBlo }() } // Feed the transactions into the tracers and return + blockCtx := api.b.GetBlockContext(blockHeader) var failed error for i, tx := range txs { // Send the trace task over for execution diff --git a/evmcore/evm.go b/evmcore/evm.go index d4dfcb496..8958754f1 100644 --- a/evmcore/evm.go +++ b/evmcore/evm.go @@ -48,7 +48,7 @@ func NewEVMBlockContext(header *EvmHeader, chain DummyChain, author *common.Addr return vm.BlockContext{ CanTransfer: CanTransfer, Transfer: Transfer, - GetHash: GetHashFn(*header, chain), + GetHash: GetHashFn(header, chain), Coinbase: beneficiary, BlockNumber: new(big.Int).Set(header.Number), Time: new(big.Int).SetUint64(uint64(header.Time.Unix())), @@ -67,7 +67,7 @@ func NewEVMTxContext(msg Message) vm.TxContext { } // GetHashFn returns a GetHashFunc which retrieves header hashes by number -func GetHashFn(ref EvmHeader, chain DummyChain) func(n uint64) common.Hash { +func GetHashFn(ref *EvmHeader, chain DummyChain) func(n uint64) common.Hash { // Cache will initially contain [refHash.parent], // Then fill up with [refHash.p, refHash.pp, refHash.ppp, ...] var cache []common.Hash