From 080b6ebe9138b19d0757c57d1f537eea9b20a782 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Wed, 16 Jun 2021 08:53:27 +0200 Subject: [PATCH] core/vm: evm fix panic (#23047) * core/vm: evm fix panic * core/vm/runtime: default to params.initialbasefee --- core/vm/runtime/env.go | 1 + core/vm/runtime/runtime.go | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core/vm/runtime/env.go b/core/vm/runtime/env.go index 6c4c72eea..dcb097428 100644 --- a/core/vm/runtime/env.go +++ b/core/vm/runtime/env.go @@ -35,6 +35,7 @@ func NewEnv(cfg *Config) *vm.EVM { Time: cfg.Time, Difficulty: cfg.Difficulty, GasLimit: cfg.GasLimit, + BaseFee: cfg.BaseFee, } return vm.NewEVM(blockContext, txContext, cfg.State, cfg.ChainConfig, cfg.EVMConfig) diff --git a/core/vm/runtime/runtime.go b/core/vm/runtime/runtime.go index be612fb0e..103ce3e17 100644 --- a/core/vm/runtime/runtime.go +++ b/core/vm/runtime/runtime.go @@ -43,6 +43,7 @@ type Config struct { Value *big.Int Debug bool EVMConfig vm.Config + BaseFee *big.Int State *state.StateDB GetHashFn func(n uint64) common.Hash @@ -66,7 +67,7 @@ func setDefaults(cfg *Config) { IstanbulBlock: new(big.Int), MuirGlacierBlock: new(big.Int), BerlinBlock: new(big.Int), - LondonBlock: nil, + LondonBlock: new(big.Int), } } @@ -93,6 +94,9 @@ func setDefaults(cfg *Config) { return common.BytesToHash(crypto.Keccak256([]byte(new(big.Int).SetUint64(n).String()))) } } + if cfg.BaseFee == nil { + cfg.BaseFee = big.NewInt(params.InitialBaseFee) + } } // Execute executes the code using the input as call data during the execution.