Merge pull request #13 from sei-protocol/evm-set-evm

Set EVM in StateDB in gasestimator
This commit is contained in:
codchen 2024-01-30 13:43:13 +08:00 committed by GitHub
commit c047698e66
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 0 deletions

View file

@ -1389,6 +1389,8 @@ func (s *StateDB) convertAccountSet(set map[common.Address]*types.StateAccount)
return ret return ret
} }
func (s *StateDB) SetEVM(evm *vm.EVM) {}
// copySet returns a deep-copied set. // copySet returns a deep-copied set.
func copySet[k comparable](set map[k][]byte) map[k][]byte { func copySet[k comparable](set map[k][]byte) map[k][]byte {
copied := make(map[k][]byte, len(set)) copied := make(map[k][]byte, len(set))

View file

@ -92,6 +92,7 @@ type StateDB interface {
GetLogs(hash common.Hash, blockNumber uint64, blockHash common.Hash) []*types.Log GetLogs(hash common.Hash, blockNumber uint64, blockHash common.Hash) []*types.Log
TxIndex() int TxIndex() int
Preimages() map[common.Hash][]byte Preimages() map[common.Hash][]byte
SetEVM(evm *EVM)
} }
// CallContext provides a basic interface for the EVM calling conventions. The EVM // CallContext provides a basic interface for the EVM calling conventions. The EVM

View file

@ -212,6 +212,7 @@ func run(ctx context.Context, call *core.Message, opts *Options) (*core.Executio
dirtyState = opts.State.Copy() dirtyState = opts.State.Copy()
evm = vm.NewEVM(evmContext, msgContext, dirtyState, opts.Config, vm.Config{NoBaseFee: true}) 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 // Monitor the outer context and interrupt the EVM upon cancellation. To avoid
// a dangling goroutine until the outer estimation finishes, create an internal // a dangling goroutine until the outer estimation finishes, create an internal
// context for the lifetime of this method call. // context for the lifetime of this method call.