From f6d786c8a0fd774857be9815e27ec01585bc8bd5 Mon Sep 17 00:00:00 2001 From: Morty Date: Thu, 17 Apr 2025 22:27:23 +0800 Subject: [PATCH 1/6] feat: update L2 base fee formula --- consensus/misc/eip1559.go | 8 ++++---- consensus/misc/eip1559_test.go | 14 +++++++------- core/state_processor_test.go | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/consensus/misc/eip1559.go b/consensus/misc/eip1559.go index 483878fc0e4a..6f5413245c99 100644 --- a/consensus/misc/eip1559.go +++ b/consensus/misc/eip1559.go @@ -55,12 +55,12 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header, parentL1BaseF return big.NewInt(10000000) // 0.01 Gwei } l2SequencerFee := big.NewInt(1000000) // 0.001 Gwei - provingFee := big.NewInt(38200000) // 0.0382 Gwei + provingFee := big.NewInt(15680000) // 0.01568 Gwei - // L1_base_fee * 0.00017 + // L1_base_fee * 0.0000155 verificationFee := parentL1BaseFee - verificationFee = new(big.Int).Mul(verificationFee, big.NewInt(17)) - verificationFee = new(big.Int).Div(verificationFee, big.NewInt(100000)) + verificationFee = new(big.Int).Mul(verificationFee, big.NewInt(155)) + verificationFee = new(big.Int).Div(verificationFee, big.NewInt(10000000)) baseFee := big.NewInt(0) baseFee.Add(baseFee, l2SequencerFee) diff --git a/consensus/misc/eip1559_test.go b/consensus/misc/eip1559_test.go index 3b48c2e58107..ac73ca7b6672 100644 --- a/consensus/misc/eip1559_test.go +++ b/consensus/misc/eip1559_test.go @@ -112,13 +112,13 @@ func TestCalcBaseFee(t *testing.T) { parentL1BaseFee int64 expectedL2BaseFee int64 }{ - {0, 39200000}, - {1000000000, 39370000}, - {2000000000, 39540000}, - {100000000000, 56200000}, - {111111111111, 58088888}, - {2164000000000, 407080000}, - {58592942000000, 10000000000}, // cap at max L2 base fee + {0, 16680000}, + {1000000000, 16695500}, + {2000000000, 16711000}, + {100000000000, 18230000}, + {111111111111, 18402222}, + {2164000000000, 50222000}, + {644086151290322, 10000000000}, // cap at max L2 base fee } for i, test := range tests { if have, want := CalcBaseFee(config(), nil, big.NewInt(test.parentL1BaseFee)), big.NewInt(test.expectedL2BaseFee); have.Cmp(want) != 0 { diff --git a/core/state_processor_test.go b/core/state_processor_test.go index a2585941ce8f..b34e81222e5b 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -389,13 +389,13 @@ func TestStateProcessorErrors(t *testing.T) { txs: []*types.Transaction{ mkDynamicCreationTx(0, 500000, common.Big0, misc.CalcBaseFee(config, genesis.Header(), parentL1BaseFee), tooBigInitCode[:]), }, - want: "could not apply tx 0 [0xa31de6e26bd5ffba0ca91a2bc29fc2eaad6a6cfc5ad9ab6ffb69cac121e0125c]: max initcode size exceeded: code size 49153 limit 49152", + want: "could not apply tx 0 [0x992c0e217368a7ecf7c7eb16eac8327568133664e2963bd1051be7a180cf1796]: max initcode size exceeded: code size 49153 limit 49152", }, { // ErrIntrinsicGas: Not enough gas to cover init code txs: []*types.Transaction{ mkDynamicCreationTx(0, 54299, common.Big0, misc.CalcBaseFee(config, genesis.Header(), parentL1BaseFee), smallInitCode[:]), }, - want: "could not apply tx 0 [0xf36b7d68cf239f956f7c36be26688a97aaa317ea5f5230d109bb30dbc8598ccb]: intrinsic gas too low: have 54299, want 54300", + want: "could not apply tx 0 [0xd85b39f8148b4bf4d974a211715f79f6f20c88858f302daf11bf8397d9612f52]: intrinsic gas too low: have 54299, want 54300", }, } { block := GenerateBadBlock(genesis, ethash.NewFaker(), tt.txs, gspec.Config) From 85e059e497fbdfbf333ad443abb281f7b561b47d Mon Sep 17 00:00:00 2001 From: yiweichi <70688412+yiweichi@users.noreply.github.com> Date: Thu, 17 Apr 2025 14:30:26 +0000 Subject: [PATCH 2/6] =?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 94e8f3fe028d..265cf8050392 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 = 38 // Patch version component of the current release + VersionPatch = 39 // Patch version component of the current release VersionMeta = "mainnet" // Version metadata to append to the version string ) From 0647f62131cb3f2661b37bca96323cc3bbd01bb4 Mon Sep 17 00:00:00 2001 From: Morty Date: Thu, 17 Apr 2025 22:47:57 +0800 Subject: [PATCH 3/6] fix --- consensus/misc/eip1559.go | 2 +- consensus/misc/eip1559_test.go | 14 +++++++------- core/state_processor_test.go | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/consensus/misc/eip1559.go b/consensus/misc/eip1559.go index 6f5413245c99..d9862eea523f 100644 --- a/consensus/misc/eip1559.go +++ b/consensus/misc/eip1559.go @@ -55,7 +55,7 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header, parentL1BaseF return big.NewInt(10000000) // 0.01 Gwei } l2SequencerFee := big.NewInt(1000000) // 0.001 Gwei - provingFee := big.NewInt(15680000) // 0.01568 Gwei + provingFee := big.NewInt(14680000) // 0.01468 Gwei // L1_base_fee * 0.0000155 verificationFee := parentL1BaseFee diff --git a/consensus/misc/eip1559_test.go b/consensus/misc/eip1559_test.go index ac73ca7b6672..29a1335837fc 100644 --- a/consensus/misc/eip1559_test.go +++ b/consensus/misc/eip1559_test.go @@ -112,13 +112,13 @@ func TestCalcBaseFee(t *testing.T) { parentL1BaseFee int64 expectedL2BaseFee int64 }{ - {0, 16680000}, - {1000000000, 16695500}, - {2000000000, 16711000}, - {100000000000, 18230000}, - {111111111111, 18402222}, - {2164000000000, 50222000}, - {644086151290322, 10000000000}, // cap at max L2 base fee + {0, 15680000}, + {1000000000, 15695500}, + {2000000000, 15711000}, + {100000000000, 17230000}, + {111111111111, 17402222}, + {2164000000000, 49222000}, + {644149677419355, 10000000000}, // cap at max L2 base fee } for i, test := range tests { if have, want := CalcBaseFee(config(), nil, big.NewInt(test.parentL1BaseFee)), big.NewInt(test.expectedL2BaseFee); have.Cmp(want) != 0 { diff --git a/core/state_processor_test.go b/core/state_processor_test.go index b34e81222e5b..9fa5ca8dc04b 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -389,13 +389,13 @@ func TestStateProcessorErrors(t *testing.T) { txs: []*types.Transaction{ mkDynamicCreationTx(0, 500000, common.Big0, misc.CalcBaseFee(config, genesis.Header(), parentL1BaseFee), tooBigInitCode[:]), }, - want: "could not apply tx 0 [0x992c0e217368a7ecf7c7eb16eac8327568133664e2963bd1051be7a180cf1796]: max initcode size exceeded: code size 49153 limit 49152", + want: "could not apply tx 0 [0xdafff4b339f58272aa15a1b332dc88c039503c60d893047e86b2d31f5fcfcffa]: max initcode size exceeded: code size 49153 limit 49152", }, { // ErrIntrinsicGas: Not enough gas to cover init code txs: []*types.Transaction{ mkDynamicCreationTx(0, 54299, common.Big0, misc.CalcBaseFee(config, genesis.Header(), parentL1BaseFee), smallInitCode[:]), }, - want: "could not apply tx 0 [0xd85b39f8148b4bf4d974a211715f79f6f20c88858f302daf11bf8397d9612f52]: intrinsic gas too low: have 54299, want 54300", + want: "could not apply tx 0 [0x01a67f1a7cf29cc91da9ca3cd7793ca7bc47516da5bec74c79727dde31a60651]: intrinsic gas too low: have 54299, want 54300", }, } { block := GenerateBadBlock(genesis, ethash.NewFaker(), tt.txs, gspec.Config) From 0065e34b7997cd21a732931b1da458e124b0ed0f Mon Sep 17 00:00:00 2001 From: Morty Date: Thu, 17 Apr 2025 22:55:19 +0800 Subject: [PATCH 4/6] fix: lint --- consensus/misc/eip1559.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consensus/misc/eip1559.go b/consensus/misc/eip1559.go index d9862eea523f..90f41a043f45 100644 --- a/consensus/misc/eip1559.go +++ b/consensus/misc/eip1559.go @@ -55,7 +55,7 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header, parentL1BaseF return big.NewInt(10000000) // 0.01 Gwei } l2SequencerFee := big.NewInt(1000000) // 0.001 Gwei - provingFee := big.NewInt(14680000) // 0.01468 Gwei + provingFee := big.NewInt(14680000) // 0.01468 Gwei // L1_base_fee * 0.0000155 verificationFee := parentL1BaseFee From 1496631f47d2d7cbbec6cb5d3d3404a0f78f2ebc Mon Sep 17 00:00:00 2001 From: Morty Date: Fri, 18 Apr 2025 14:51:24 +0800 Subject: [PATCH 5/6] fix: upgrade ci runner --- .github/workflows/semgrep.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/semgrep.yml b/.github/workflows/semgrep.yml index 393b7a7fad6d..8b3f139d4711 100644 --- a/.github/workflows/semgrep.yml +++ b/.github/workflows/semgrep.yml @@ -14,7 +14,7 @@ name: Semgrep jobs: semgrep: name: semgrep/ci - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 permissions: {} env: SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }} From 3916abec8719a1e2c73ec1fb60b70f594e189da3 Mon Sep 17 00:00:00 2001 From: Morty Date: Fri, 18 Apr 2025 15:04:14 +0800 Subject: [PATCH 6/6] update multiplier --- consensus/misc/eip1559.go | 6 +++--- consensus/misc/eip1559_test.go | 10 +++++----- core/state_processor_test.go | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/consensus/misc/eip1559.go b/consensus/misc/eip1559.go index 90f41a043f45..382ad2ada5f2 100644 --- a/consensus/misc/eip1559.go +++ b/consensus/misc/eip1559.go @@ -57,10 +57,10 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header, parentL1BaseF l2SequencerFee := big.NewInt(1000000) // 0.001 Gwei provingFee := big.NewInt(14680000) // 0.01468 Gwei - // L1_base_fee * 0.0000155 + // L1_base_fee * 0.000034 verificationFee := parentL1BaseFee - verificationFee = new(big.Int).Mul(verificationFee, big.NewInt(155)) - verificationFee = new(big.Int).Div(verificationFee, big.NewInt(10000000)) + verificationFee = new(big.Int).Mul(verificationFee, big.NewInt(34)) + verificationFee = new(big.Int).Div(verificationFee, big.NewInt(1000000)) baseFee := big.NewInt(0) baseFee.Add(baseFee, l2SequencerFee) diff --git a/consensus/misc/eip1559_test.go b/consensus/misc/eip1559_test.go index 29a1335837fc..12aa2b17c2bb 100644 --- a/consensus/misc/eip1559_test.go +++ b/consensus/misc/eip1559_test.go @@ -113,11 +113,11 @@ func TestCalcBaseFee(t *testing.T) { expectedL2BaseFee int64 }{ {0, 15680000}, - {1000000000, 15695500}, - {2000000000, 15711000}, - {100000000000, 17230000}, - {111111111111, 17402222}, - {2164000000000, 49222000}, + {1000000000, 15714000}, + {2000000000, 15748000}, + {100000000000, 19080000}, + {111111111111, 19457777}, + {2164000000000, 89256000}, {644149677419355, 10000000000}, // cap at max L2 base fee } for i, test := range tests { diff --git a/core/state_processor_test.go b/core/state_processor_test.go index 9fa5ca8dc04b..ac5babcac3bc 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -389,13 +389,13 @@ func TestStateProcessorErrors(t *testing.T) { txs: []*types.Transaction{ mkDynamicCreationTx(0, 500000, common.Big0, misc.CalcBaseFee(config, genesis.Header(), parentL1BaseFee), tooBigInitCode[:]), }, - want: "could not apply tx 0 [0xdafff4b339f58272aa15a1b332dc88c039503c60d893047e86b2d31f5fcfcffa]: max initcode size exceeded: code size 49153 limit 49152", + want: "could not apply tx 0 [0x9fff9d187a68f9dce9664475ed9a01a5178992f15b44ce88ee7b1129a183e6af]: max initcode size exceeded: code size 49153 limit 49152", }, { // ErrIntrinsicGas: Not enough gas to cover init code txs: []*types.Transaction{ mkDynamicCreationTx(0, 54299, common.Big0, misc.CalcBaseFee(config, genesis.Header(), parentL1BaseFee), smallInitCode[:]), }, - want: "could not apply tx 0 [0x01a67f1a7cf29cc91da9ca3cd7793ca7bc47516da5bec74c79727dde31a60651]: intrinsic gas too low: have 54299, want 54300", + want: "could not apply tx 0 [0x272eefb0eeb3b973e933ae5dba17e7ecf6bfded5ce358f2a78426153c247f677]: intrinsic gas too low: have 54299, want 54300", }, } { block := GenerateBadBlock(genesis, ethash.NewFaker(), tt.txs, gspec.Config)