From caa29c298bd80e9659d427368d598e7f46d04ec3 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..3ba9c6676c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (evm) [tharsis#901](https://github.com/tharsis/ethermint/pull/901) Support multiple MsgEthereumTx in single tx. * (config) [tharsis#908](https://github.com/tharsis/ethermint/pull/908) Add api.enable flag for Cosmos SDK Rest server * (feemarket) [tharsis#919](https://github.com/tharsis/ethermint/pull/919) Initialize baseFee in default genesis state. +* (evm) [tharsis#932](https://github.com/tharsis/ethermint/pull/932) Fix base fee check logic in state transition. ### Bug Fixes 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(), } }