Skip to content

Commit 5892e56

Browse files
0xmountaintoplwedge99
authored andcommitted
feat: update L2 base fee formula (scroll-tech#951)
* update `CalcBaseFee` * update `TestCalcBaseFee` * update `TestStateProcessorErrors` * bump version * update threshold
1 parent b87bd31 commit 5892e56

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

consensus/misc/eip1559.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
)
2626

2727
// Protocol-enforced maximum L2 base fee.
28-
// We would only go above this if L1 base fee hits 2164 Gwei.
28+
// We would only go above this if L1 base fee hits 2931 Gwei.
2929
const MaximumL2BaseFee = 10000000000
3030

3131
// VerifyEip1559Header verifies some header attributes which were changed in EIP-1559,
@@ -55,11 +55,11 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header, parentL1BaseF
5555
return big.NewInt(10000000) // 0.01 Gwei
5656
}
5757
l2SequencerFee := big.NewInt(1000000) // 0.001 Gwei
58-
provingFee := big.NewInt(47700000) // 0.0477 Gwei
58+
provingFee := big.NewInt(33700000) // 0.0337 Gwei
5959

60-
// L1_base_fee * 0.0046
60+
// L1_base_fee * 0.0034
6161
verificationFee := parentL1BaseFee
62-
verificationFee = new(big.Int).Mul(verificationFee, big.NewInt(46))
62+
verificationFee = new(big.Int).Mul(verificationFee, big.NewInt(34))
6363
verificationFee = new(big.Int).Div(verificationFee, big.NewInt(10000))
6464

6565
baseFee := big.NewInt(0)

consensus/misc/eip1559_test.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,13 @@ func TestCalcBaseFee(t *testing.T) {
112112
parentL1BaseFee int64
113113
expectedL2BaseFee int64
114114
}{
115-
{0, 48700000},
116-
{1000000000, 53300000},
117-
{2000000000, 57900000},
118-
{100000000000, 508700000},
119-
{111111111111, 559811111},
120-
{2164000000000, 10000000000}, // cap at max L2 base fee
115+
{0, 34700000},
116+
{1000000000, 38100000},
117+
{2000000000, 41500000},
118+
{100000000000, 374700000},
119+
{111111111111, 412477777},
120+
{2164000000000, 7392300000},
121+
{2931000000000, 10000000000}, // cap at max L2 base fee
121122
}
122123
for i, test := range tests {
123124
if have, want := CalcBaseFee(config(), nil, big.NewInt(test.parentL1BaseFee)), big.NewInt(test.expectedL2BaseFee); have.Cmp(want) != 0 {

core/state_processor_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -360,13 +360,13 @@ func TestStateProcessorErrors(t *testing.T) {
360360
txs: []*types.Transaction{
361361
mkDynamicCreationTx(0, 500000, common.Big0, misc.CalcBaseFee(config, genesis.Header(), parentL1BaseFee), tooBigInitCode[:]),
362362
},
363-
want: "could not apply tx 0 [0x13f95e090076d99bb91e3c61923b4ddfa270940363b282ac2d17ea07dada4aa4]: max initcode size exceeded: code size 49153 limit 49152",
363+
want: "could not apply tx 0 [0x8f780c3573ac61e2d7796f7b447afd0ad753623ed95bc99ef94eb083d9e0d039]: max initcode size exceeded: code size 49153 limit 49152",
364364
},
365365
{ // ErrIntrinsicGas: Not enough gas to cover init code
366366
txs: []*types.Transaction{
367367
mkDynamicCreationTx(0, 54299, common.Big0, misc.CalcBaseFee(config, genesis.Header(), parentL1BaseFee), smallInitCode[:]),
368368
},
369-
want: "could not apply tx 0 [0x74d818187d75665003870481a53dc4bc938fe7ee79d24ebf941ca9042d8ef3ae]: intrinsic gas too low: have 54299, want 54300",
369+
want: "could not apply tx 0 [0xbf812bb88c3f53402b6cf5488ac89360595e524b65582b648d1f4ef197690e89]: intrinsic gas too low: have 54299, want 54300",
370370
},
371371
} {
372372
block := GenerateBadBlock(genesis, ethash.NewFaker(), tt.txs, gspec.Config)

params/version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
const (
2525
VersionMajor = 5 // Major version component of the current release
2626
VersionMinor = 5 // Minor version component of the current release
27-
VersionPatch = 20 // Patch version component of the current release
27+
VersionPatch = 21 // Patch version component of the current release
2828
VersionMeta = "mainnet" // Version metadata to append to the version string
2929
)
3030

0 commit comments

Comments
 (0)