cmd, core: polish code

This commit is contained in:
Gary Rong 2024-11-13 09:21:58 +08:00
parent 88d9f83692
commit a676bdea62
2 changed files with 6 additions and 7 deletions

View file

@ -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)

View file

@ -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.