From a676bdea62c3d0d106fe5c953f0ccc4d0fdb5336 Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Wed, 13 Nov 2024 09:21:58 +0800 Subject: [PATCH] cmd, core: polish code --- cmd/evm/internal/t8ntool/execution.go | 5 +++-- core/vm/evm.go | 8 +++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index d2ff4f4dc1..a868fbf11c 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -245,9 +245,10 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, if err != nil { return nil, nil, nil, err } + // TODO (rjl493456442) it's a bit weird to reset the tracer in the + // middle of block execution, please improve it somehow. if tracer != nil { - vmConfig.Tracer = tracer.Hooks - evm.SetConfig(vmConfig) + evm.SetTracer(tracer.Hooks) } statedb.SetTxContext(tx.Hash(), txIndex) diff --git a/core/vm/evm.go b/core/vm/evm.go index f66b12bb80..34e5fa766b 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -133,11 +133,9 @@ func NewEVM(blockCtx BlockContext, statedb StateDB, chainConfig *params.ChainCon return evm } -// SetConfig resets the config and re-initialize the interpreter just in case -// some additional EIPs are activated by new config. -func (evm *EVM) SetConfig(config Config) { - evm.Config = config - evm.interpreter = NewEVMInterpreter(evm) +// SetTracer sets the tracer for following state transition. +func (evm *EVM) SetTracer(tracer *tracing.Hooks) { + evm.Config.Tracer = tracer } // SetPrecompiles sets the precompiled contracts for the EVM.