From 65af7ee9e5651262e250ca7479b1ecbde64cb72a Mon Sep 17 00:00:00 2001 From: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> Date: Wed, 10 Jul 2024 09:36:29 +0800 Subject: [PATCH] feat: update L2 base fee formula (#892) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat: update L2 base fee formula (#891) * feat: update L2 base fee formula * update test tx hashes Co-authored-by: Péter Garamvölgyi --- consensus/misc/eip1559/eip1559_scroll.go | 12 ++++++------ consensus/misc/eip1559/eip1559_scroll_test.go | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/consensus/misc/eip1559/eip1559_scroll.go b/consensus/misc/eip1559/eip1559_scroll.go index eabcad19c816..056b50588288 100644 --- a/consensus/misc/eip1559/eip1559_scroll.go +++ b/consensus/misc/eip1559/eip1559_scroll.go @@ -26,7 +26,7 @@ import ( ) // Protocol-enforced maximum L2 base fee. -// We would only go above this if L1 base fee hits 700 Gwei. +// We would only go above this if L1 base fee hits 2164 Gwei. const MaximumL2BaseFee = 10000000000 // VerifyEIP1559Header verifies some header attributes which were changed in EIP-1559, @@ -52,13 +52,13 @@ func VerifyEIP1559Header(config *params.ChainConfig, parent, header *types.Heade // CalcBaseFee calculates the basefee of the header. func CalcBaseFee(config *params.ChainConfig, parent *types.Header, parentL1BaseFee *big.Int) *big.Int { - l2SequencerFee := big.NewInt(10000000) // 0.01 Gwei - provingFee := big.NewInt(140000000) // 0.14 Gwei + l2SequencerFee := big.NewInt(1000000) // 0.001 Gwei + provingFee := big.NewInt(47700000) // 0.0477 Gwei - // L1_base_fee * 0.014 + // L1_base_fee * 0.0046 verificationFee := parentL1BaseFee - verificationFee = new(big.Int).Mul(verificationFee, big.NewInt(14)) - verificationFee = new(big.Int).Div(verificationFee, big.NewInt(1000)) + verificationFee = new(big.Int).Mul(verificationFee, big.NewInt(46)) + verificationFee = new(big.Int).Div(verificationFee, big.NewInt(10000)) baseFee := big.NewInt(0) baseFee.Add(baseFee, l2SequencerFee) diff --git a/consensus/misc/eip1559/eip1559_scroll_test.go b/consensus/misc/eip1559/eip1559_scroll_test.go index 4c965c35ccf2..4ea9d53dd95f 100644 --- a/consensus/misc/eip1559/eip1559_scroll_test.go +++ b/consensus/misc/eip1559/eip1559_scroll_test.go @@ -111,12 +111,12 @@ func TestCalcBaseFee(t *testing.T) { parentL1BaseFee int64 expectedL2BaseFee int64 }{ - {0, 150000000}, - {1000000000, 164000000}, - {2000000000, 178000000}, - {100000000000, 1550000000}, - {111111111111, 1705555555}, - {1000000000000, 10000000000}, // cap at max L2 base fee + {0, 48700000}, + {1000000000, 53300000}, + {2000000000, 57900000}, + {100000000000, 508700000}, + {111111111111, 559811111}, + {2164000000000, 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 {