diff --git a/eth/api_backend.go b/eth/api_backend.go index 0983056bca..ba4b67ac61 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -418,3 +418,7 @@ func (b *EthAPIBackend) StateAtTransaction(ctx context.Context, block *types.Blo func (b *EthAPIBackend) GetCustomPrecompiles(int64) map[common.Address]vm.PrecompiledContract { return nil } + +func (b *EthAPIBackend) PrepareTx(statedb vm.StateDB, tx *types.Transaction) error { + return nil +} diff --git a/eth/tracers/api.go b/eth/tracers/api.go index f37d77731e..9d0b7537a5 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -90,6 +90,7 @@ type Backend interface { StateAtBlock(ctx context.Context, block *types.Block, reexec uint64, base vm.StateDB, readOnly bool, preferDisk bool) (vm.StateDB, StateReleaseFunc, error) StateAtTransaction(ctx context.Context, block *types.Block, txIndex int, reexec uint64) (*types.Transaction, vm.BlockContext, vm.StateDB, StateReleaseFunc, error) GetCustomPrecompiles(int64) map[common.Address]vm.PrecompiledContract + PrepareTx(statedb vm.StateDB, tx *types.Transaction) error } // API is the collection of tracing APIs exposed over the private debugging endpoint. @@ -1010,6 +1011,9 @@ func (api *API) traceTx(ctx context.Context, tx *types.Transaction, message *cor // Call Prepare to clear out the statedb access list statedb.SetTxContext(txctx.TxHash, txctx.TxIndex) + if err := api.backend.PrepareTx(statedb, tx); err != nil { + return nil, err + } _, err = core.ApplyTransactionWithEVM(message, api.backend.ChainConfig(), new(core.GasPool).AddGas(message.GasLimit), statedb, vmctx.BlockNumber, txctx.BlockHash, tx, &usedGas, vmenv) if err != nil { // Due to how our mempool works, a transaction with insufficient funds can be included in a block. For tracing purposes, we should ignore this. diff --git a/eth/tracers/api_test.go b/eth/tracers/api_test.go index 0d92b2cf1e..4ede408743 100644 --- a/eth/tracers/api_test.go +++ b/eth/tracers/api_test.go @@ -188,6 +188,10 @@ func (b *testBackend) GetCustomPrecompiles(int64) map[common.Address]vm.Precompi return nil } +func (b *testBackend) PrepareTx(statedb vm.StateDB, tx *types.Transaction) error { + return nil +} + func TestTraceCall(t *testing.T) { t.Parallel()