core/vm: evm fix panic (#23047)

This commit is contained in:
Daniel Liu 2024-09-19 13:58:57 +08:00
parent 18bc355e89
commit c7d49072f1
2 changed files with 6 additions and 0 deletions

View file

@ -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, nil, cfg.ChainConfig, cfg.EVMConfig)

View file

@ -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
@ -68,6 +69,7 @@ func setDefaults(cfg *Config) {
LondonBlock: new(big.Int),
MergeBlock: new(big.Int),
ShanghaiBlock: new(big.Int),
Eip1559Block: new(big.Int),
}
}
@ -94,6 +96,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.