Skip to content

Commit

Permalink
feat: update L2 base fee formula (#1058)
Browse files Browse the repository at this point in the history
* feat: update L2 base fee formula (#1053)

* feat: update L2 base fee formula

* update 1559 unit test

* use current block's base fee in txpool

* fix unit test

* Revert "use current block's base fee in txpool"

This reverts commit 8a7d7ff.

* update `TestCalcBaseFee`

* update `TestStateProcessorErrors`

---------

Co-authored-by: Péter Garamvölgyi <peter@scroll.io>
  • Loading branch information
0xmountaintop and Thegaram authored Oct 9, 2024
1 parent bb4b703 commit 00ba80c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions consensus/misc/eip1559/eip1559_scroll.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,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(33700000) // 0.0337 Gwei
provingFee := big.NewInt(38200000) // 0.0382 Gwei

// L1_base_fee * 0.0034
// L1_base_fee * 0.00017
verificationFee := parentL1BaseFee
verificationFee = new(big.Int).Mul(verificationFee, big.NewInt(34))
verificationFee = new(big.Int).Div(verificationFee, big.NewInt(10000))
verificationFee = new(big.Int).Mul(verificationFee, big.NewInt(17))
verificationFee = new(big.Int).Div(verificationFee, big.NewInt(100000))

baseFee := big.NewInt(0)
baseFee.Add(baseFee, l2SequencerFee)
Expand Down
14 changes: 7 additions & 7 deletions consensus/misc/eip1559/eip1559_scroll_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ func TestCalcBaseFee(t *testing.T) {
parentL1BaseFee int64
expectedL2BaseFee int64
}{
{0, 34700000},
{1000000000, 38100000},
{2000000000, 41500000},
{100000000000, 374700000},
{111111111111, 412477777},
{2164000000000, 7392300000},
{2931000000000, 10000000000}, // cap at max L2 base fee
{0, 39200000},
{1000000000, 39370000},
{2000000000, 39540000},
{100000000000, 56200000},
{111111111111, 58088888},
{2164000000000, 407080000},
{58592942000000, 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 {
Expand Down
4 changes: 2 additions & 2 deletions core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,13 @@ func TestStateProcessorErrors(t *testing.T) {
txs: []*types.Transaction{
mkDynamicCreationTx(0, 500000, common.Big0, big.NewInt(params.InitialBaseFee), tooBigInitCode[:]),
},
want: "could not apply tx 0 [0xd491405f06c92d118dd3208376fcee18a57c54bc52063ee4a26b1cf296857c25]: max initcode size exceeded: code size 49153 limit 49152",
want: "could not apply tx 0 [0xa31de6e26bd5ffba0ca91a2bc29fc2eaad6a6cfc5ad9ab6ffb69cac121e0125c]: 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, big.NewInt(params.InitialBaseFee), make([]byte, 320)),
},
want: "could not apply tx 0 [0xfd49536a9b323769d8472fcb3ebb3689b707a349379baee3e2ee3fe7baae06a1]: intrinsic gas too low: have 54299, want 54300",
want: "could not apply tx 0 [0xf36b7d68cf239f956f7c36be26688a97aaa317ea5f5230d109bb30dbc8598ccb]: intrinsic gas too low: have 54299, want 54300",
},
{ // ErrBlobFeeCapTooLow
txs: []*types.Transaction{
Expand Down

0 comments on commit 00ba80c

Please sign in to comment.