From 31d30754c2c446846e22e78a5a640caf9de8058e Mon Sep 17 00:00:00 2001 From: HuangYi Date: Wed, 9 Feb 2022 13:38:43 +0800 Subject: [PATCH] fix base fee check logic in state transition - should check london hardfork first, otherwise it panic if feemarket not registered. --- CHANGELOG.md | 1 + x/evm/keeper/state_transition.go | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 598ea49616..ea37c25b5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (evm) [tharsis#871](https://github.com/tharsis/ethermint/pull/871) Set correct nonce in `EthCall` and `EstimateGas` grpc query. * (rpc) [tharsis#878](https://github.com/tharsis/ethermint/pull/878) Workaround to make GetBlock RPC api report correct block gas used. * (rpc) [tharsis#900](https://github.com/tharsis/ethermint/pull/900) newPendingTransactions filter return ethereum tx hash. +* (evm) [tharsis#932](https://github.com/tharsis/ethermint/pull/932) Fix base fee check logic in state transition. ## [v0.9.0] - 2021-12-01 diff --git a/x/evm/keeper/state_transition.go b/x/evm/keeper/state_transition.go index 10b66aacf7..4bbdb92949 100644 --- a/x/evm/keeper/state_transition.go +++ b/x/evm/keeper/state_transition.go @@ -92,14 +92,17 @@ func (k *Keeper) NewEVM( if tracer == nil { tracer = k.Tracer(ctx, msg, cfg.ChainConfig) } - vmConfig := k.VMConfig(ctx, msg, cfg.Params, tracer) + vmConfig := k.VMConfig(ctx, msg, cfg, tracer) return vm.NewEVM(blockCtx, txCtx, stateDB, cfg.ChainConfig, vmConfig) } // VMConfig creates an EVM configuration from the debug setting and the extra EIPs enabled on the // module parameters. The config generated uses the default JumpTable from the EVM. -func (k Keeper) VMConfig(ctx sdk.Context, msg core.Message, params types.Params, tracer vm.Tracer) vm.Config { - fmParams := k.feeMarketKeeper.GetParams(ctx) +func (k Keeper) VMConfig(ctx sdk.Context, msg core.Message, cfg *types.EVMConfig, tracer vm.Tracer) vm.Config { + noBaseFee := true + if types.IsLondon(cfg.ChainConfig, ctx.BlockHeight()) { + noBaseFee = k.feeMarketKeeper.GetParams(ctx).NoBaseFee + } var debug bool if _, ok := tracer.(types.NoOpTracer); !ok { @@ -110,8 +113,8 @@ func (k Keeper) VMConfig(ctx sdk.Context, msg core.Message, params types.Params, Debug: debug, Tracer: tracer, NoRecursion: false, // TODO: consider disabling recursion though params - NoBaseFee: fmParams.NoBaseFee, - ExtraEips: params.EIPs(), + NoBaseFee: noBaseFee, + ExtraEips: cfg.Params.EIPs(), } }