From 39ab532d6ee20920130646f287f155530e3b6b33 Mon Sep 17 00:00:00 2001 From: codchen Date: Tue, 30 Jan 2024 13:42:33 +0800 Subject: [PATCH] Set EVM in StateDB in gasestimator --- core/state/statedb.go | 2 ++ core/vm/interface.go | 1 + eth/gasestimator/gasestimator.go | 1 + 3 files changed, 4 insertions(+) diff --git a/core/state/statedb.go b/core/state/statedb.go index 8639f180ab..ebf29e0520 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -1389,6 +1389,8 @@ func (s *StateDB) convertAccountSet(set map[common.Address]*types.StateAccount) return ret } +func (s *StateDB) SetEVM(evm *vm.EVM) {} + // copySet returns a deep-copied set. func copySet[k comparable](set map[k][]byte) map[k][]byte { copied := make(map[k][]byte, len(set)) diff --git a/core/vm/interface.go b/core/vm/interface.go index 25ea39c5f1..3bbc6993cb 100644 --- a/core/vm/interface.go +++ b/core/vm/interface.go @@ -92,6 +92,7 @@ type StateDB interface { GetLogs(hash common.Hash, blockNumber uint64, blockHash common.Hash) []*types.Log TxIndex() int Preimages() map[common.Hash][]byte + SetEVM(evm *EVM) } // CallContext provides a basic interface for the EVM calling conventions. The EVM diff --git a/eth/gasestimator/gasestimator.go b/eth/gasestimator/gasestimator.go index e7eabb9a67..bff205fbfd 100644 --- a/eth/gasestimator/gasestimator.go +++ b/eth/gasestimator/gasestimator.go @@ -212,6 +212,7 @@ func run(ctx context.Context, call *core.Message, opts *Options) (*core.Executio dirtyState = opts.State.Copy() evm = vm.NewEVM(evmContext, msgContext, dirtyState, opts.Config, vm.Config{NoBaseFee: true}) ) + dirtyState.SetEVM(evm) // Monitor the outer context and interrupt the EVM upon cancellation. To avoid // a dangling goroutine until the outer estimation finishes, create an internal // context for the lifetime of this method call.