From f7009b0e94e4f353ec32f675462732466bf43b31 Mon Sep 17 00:00:00 2001 From: yihuang Date: Tue, 15 Feb 2022 19:01:30 +0800 Subject: [PATCH] fix: base fee check logic in state transition (#932) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix base fee check logic in state transition - should check london hardfork first, otherwise it panic if feemarket not registered. * fix lint Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> --- 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 5e335623..f755cabf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (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. * (rpc) [tharsis#933](https://github.com/tharsis/ethermint/pull/933) Fix newPendingTransactions subscription deadlock when a Websocket client exits without unsubscribing and the node errors. +* (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 749fd2d0..f2cb09d0 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.EVMLogger) vm.Config { - fmParams := k.feeMarketKeeper.GetParams(ctx) +func (k Keeper) VMConfig(ctx sdk.Context, msg core.Message, cfg *types.EVMConfig, tracer vm.EVMLogger) 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 { @@ -109,8 +112,8 @@ func (k Keeper) VMConfig(ctx sdk.Context, msg core.Message, params types.Params, return vm.Config{ Debug: debug, Tracer: tracer, - NoBaseFee: fmParams.NoBaseFee, - ExtraEips: params.EIPs(), + NoBaseFee: noBaseFee, + ExtraEips: cfg.Params.EIPs(), } }