From 87e5f850c7845f61ff46c1a2a8dc8e5413929753 Mon Sep 17 00:00:00 2001 From: colinlyguo Date: Thu, 17 Jul 2025 16:39:02 +0800 Subject: [PATCH 1/3] fix: feynman fee ranges --- consensus/misc/eip1559.go | 23 ++++++++++++++++++----- params/version.go | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/consensus/misc/eip1559.go b/consensus/misc/eip1559.go index c20b627aa212..5c4a456e02fb 100644 --- a/consensus/misc/eip1559.go +++ b/consensus/misc/eip1559.go @@ -122,6 +122,11 @@ func calcBaseFeeFeynman(config *params.ChainConfig, parent *types.Header, overhe baseFee := new(big.Int).Set(baseFeeEIP1559) baseFee.Add(baseFee, overhead) + // Apply maximum base fee bound to the final result (including overhead) + if baseFee.Cmp(big.NewInt(MaximumL2BaseFee)) > 0 { + baseFee = big.NewInt(MaximumL2BaseFee) + } + return baseFee } @@ -159,9 +164,6 @@ func calcBaseFeeEIP1559(config *params.ChainConfig, parent *types.Header) *big.I return num.Add(parentBaseFeeEIP1559, common.Big1) } baseFee := num.Add(parentBaseFeeEIP1559, num) - if baseFee.Cmp(big.NewInt(MaximumL2BaseFee)) > 0 { - baseFee = big.NewInt(MaximumL2BaseFee) - } return baseFee } else { // Otherwise if the parent block used less gas than its target, the baseFee should decrease. @@ -179,10 +181,21 @@ func calcBaseFeeEIP1559(config *params.ChainConfig, parent *types.Header) *big.I } } -func extractBaseFeeEIP1559(config *params.ChainConfig, baseFee *big.Int) *big.Int { +func extractBaseFeeEIP1559(_ *params.ChainConfig, baseFee *big.Int) *big.Int { _, overhead := ReadL2BaseFeeCoefficients() // In Feynman base fee calculation, we reuse the contract's baseFeeOverhead slot as the proving base fee. - return new(big.Int).Sub(baseFee, overhead) + result := new(big.Int).Sub(baseFee, overhead) + + // Add underflow protection: return max(0, baseFee - overhead) + // + // Potential underflow scenarios: + // 1. During transition to Feynman: parent base fee might be < overhead + // 2. Contract overhead updates: when overhead is updated via contract, + // it might become larger than current base fee + if result.Sign() < 0 { + return big.NewInt(0) + } + return result } // MinBaseFee calculates the minimum L2 base fee based on the current coefficients. diff --git a/params/version.go b/params/version.go index dc939fa77110..9df687409283 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ import ( const ( VersionMajor = 5 // Major version component of the current release VersionMinor = 8 // Minor version component of the current release - VersionPatch = 70 // Patch version component of the current release + VersionPatch = 71 // Patch version component of the current release VersionMeta = "mainnet" // Version metadata to append to the version string ) From 3a5a70566113fd7f5b5c1e9d355ce76f2cdbbc76 Mon Sep 17 00:00:00 2001 From: colinlyguo Date: Thu, 17 Jul 2025 19:32:25 +0800 Subject: [PATCH 2/3] remove an impossible underflow scenario --- consensus/misc/eip1559.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/consensus/misc/eip1559.go b/consensus/misc/eip1559.go index 5c4a456e02fb..2ac839f7ec54 100644 --- a/consensus/misc/eip1559.go +++ b/consensus/misc/eip1559.go @@ -183,15 +183,15 @@ func calcBaseFeeEIP1559(config *params.ChainConfig, parent *types.Header) *big.I func extractBaseFeeEIP1559(_ *params.ChainConfig, baseFee *big.Int) *big.Int { _, overhead := ReadL2BaseFeeCoefficients() + // In Feynman base fee calculation, we reuse the contract's baseFeeOverhead slot as the proving base fee. result := new(big.Int).Sub(baseFee, overhead) // Add underflow protection: return max(0, baseFee - overhead) // // Potential underflow scenarios: - // 1. During transition to Feynman: parent base fee might be < overhead - // 2. Contract overhead updates: when overhead is updated via contract, - // it might become larger than current base fee + // - Contract overhead updates: when overhead is updated via contract, + // it might become larger than current base fee if result.Sign() < 0 { return big.NewInt(0) } From 9e79beaa475c90b8977b0e92cb050108e2326e6a Mon Sep 17 00:00:00 2001 From: jonastheis <4181434+jonastheis@users.noreply.github.com> Date: Thu, 17 Jul 2025 23:52:48 +0000 Subject: [PATCH 3/3] =?UTF-8?q?chore:=20auto=20version=20bump=E2=80=89[bot?= =?UTF-8?q?]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- params/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/params/version.go b/params/version.go index 9df687409283..cafb96053c50 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ import ( const ( VersionMajor = 5 // Major version component of the current release VersionMinor = 8 // Minor version component of the current release - VersionPatch = 71 // Patch version component of the current release + VersionPatch = 72 // Patch version component of the current release VersionMeta = "mainnet" // Version metadata to append to the version string )