From a3a86bdf195ed9eb6ebe59a78189a61fd2d743f0 Mon Sep 17 00:00:00 2001 From: alan <652732310@qq.com> Date: Tue, 17 Jun 2025 16:14:16 +0800 Subject: [PATCH] make basefee 0 always reachable --- consensus/misc/eip1559/eip1559.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/consensus/misc/eip1559/eip1559.go b/consensus/misc/eip1559/eip1559.go index a90bd744b2..e7335a5ebd 100644 --- a/consensus/misc/eip1559/eip1559.go +++ b/consensus/misc/eip1559/eip1559.go @@ -89,7 +89,13 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int { num.Div(num, denom.SetUint64(parentGasTarget)) num.Div(num, denom.SetUint64(config.BaseFeeChangeDenominator())) - baseFee := num.Sub(parent.BaseFee, num) + var baseFee *big.Int + if num.Cmp(common.Big1) < 0 { + baseFee = num.Sub(parent.BaseFee, common.Big1) + } else { + baseFee = num.Sub(parent.BaseFee, num) + } + if baseFee.Cmp(common.Big0) < 0 { baseFee = common.Big0 }