From bed07cd5906e6c26168512f0bf3047e1a948c0e1 Mon Sep 17 00:00:00 2001 From: Guruprasad Kamath <48196632+gurukamath@users.noreply.github.com> Date: Mon, 3 Apr 2023 09:33:17 +0200 Subject: [PATCH] cmd/evm: use correct parent number for t8n base fee calculation (#27032) Currently the t8n tool uses the same block number for the current block and its parent while calculating the base fee. This causes incorrect base fee calculation for the london fork block. This commit sets the parent block number to be one less than the current block number --- cmd/evm/internal/t8ntool/transition.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/evm/internal/t8ntool/transition.go b/cmd/evm/internal/t8ntool/transition.go index cb7466d86..f63635687 100644 --- a/cmd/evm/internal/t8ntool/transition.go +++ b/cmd/evm/internal/t8ntool/transition.go @@ -250,9 +250,9 @@ func Transition(ctx *cli.Context) error { if chainConfig.IsLondon(big.NewInt(int64(prestate.Env.Number))) { if prestate.Env.BaseFee != nil { // Already set, base fee has precedent over parent base fee. - } else if prestate.Env.ParentBaseFee != nil { + } else if prestate.Env.ParentBaseFee != nil && prestate.Env.Number != 0 { parent := &types.Header{ - Number: new(big.Int).SetUint64(prestate.Env.Number), + Number: new(big.Int).SetUint64(prestate.Env.Number - 1), BaseFee: prestate.Env.ParentBaseFee, GasUsed: prestate.Env.ParentGasUsed, GasLimit: prestate.Env.ParentGasLimit,