Skip to content

Commit 94af17a

Browse files
feat: update L2 base fee formula (#951) (#973)
* feat: update L2 base fee formula (#951) * update `CalcBaseFee` * update `TestCalcBaseFee` * update `TestStateProcessorErrors` * bump version * update threshold * update core/state_processor_test.go
1 parent 0c6436d commit 94af17a

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

consensus/misc/eip1559/eip1559_scroll.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
)
2727

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

3232
// VerifyEIP1559Header verifies some header attributes which were changed in EIP-1559,
@@ -53,11 +53,11 @@ func VerifyEIP1559Header(config *params.ChainConfig, parent, header *types.Heade
5353
// CalcBaseFee calculates the basefee of the header.
5454
func CalcBaseFee(config *params.ChainConfig, parent *types.Header, parentL1BaseFee *big.Int) *big.Int {
5555
l2SequencerFee := big.NewInt(1000000) // 0.001 Gwei
56-
provingFee := big.NewInt(47700000) // 0.0477 Gwei
56+
provingFee := big.NewInt(33700000) // 0.0337 Gwei
5757

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

6363
baseFee := big.NewInt(0)

consensus/misc/eip1559/eip1559_scroll_test.go

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

core/state_processor_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"math/big"
2222
"testing"
2323

24+
"github.com/holiman/uint256"
2425
"github.com/scroll-tech/go-ethereum/common"
2526
"github.com/scroll-tech/go-ethereum/common/math"
2627
"github.com/scroll-tech/go-ethereum/consensus"
@@ -34,7 +35,6 @@ import (
3435
"github.com/scroll-tech/go-ethereum/crypto"
3536
"github.com/scroll-tech/go-ethereum/params"
3637
"github.com/scroll-tech/go-ethereum/trie"
37-
"github.com/holiman/uint256"
3838
"golang.org/x/crypto/sha3"
3939
)
4040

@@ -199,7 +199,7 @@ func TestStateProcessorErrors(t *testing.T) {
199199
txs: []*types.Transaction{
200200
mkDynamicTx(0, common.Address{}, params.TxGas, big.NewInt(0), big.NewInt(0)),
201201
},
202-
want: "could not apply tx 0 [0xc4ab868fef0c82ae0387b742aee87907f2d0fc528fc6ea0a021459fb0fc4a4a8]: max fee per gas less than block base fee: address 0x71562b71999873DB5b286dF957af199Ec94617F7, maxFeePerGas: 0 baseFee: 875000000",
202+
want: "could not apply tx 0 [0xc4ab868fef0c82ae0387b742aee87907f2d0fc528fc6ea0a021459fb0fc4a4a8]: max fee per gas less than block base fee: address 0x71562b71999873DB5b286dF957af199Ec94617F7, maxFeePerGas: 0 baseFee: 38100000",
203203
},
204204
{ // ErrTipVeryHigh
205205
txs: []*types.Transaction{
@@ -252,7 +252,7 @@ func TestStateProcessorErrors(t *testing.T) {
252252
txs: []*types.Transaction{
253253
mkBlobTx(0, common.Address{}, params.TxGas, big.NewInt(1), big.NewInt(1), []common.Hash{(common.Hash{1})}),
254254
},
255-
want: "could not apply tx 0 [0x6c11015985ce82db691d7b2d017acda296db88b811c3c60dc71449c76256c716]: max fee per gas less than block base fee: address 0x71562b71999873DB5b286dF957af199Ec94617F7, maxFeePerGas: 1 baseFee: 875000000",
255+
want: "could not apply tx 0 [0x6c11015985ce82db691d7b2d017acda296db88b811c3c60dc71449c76256c716]: max fee per gas less than block base fee: address 0x71562b71999873DB5b286dF957af199Ec94617F7, maxFeePerGas: 1 baseFee: 38100000",
256256
},
257257
} {
258258
block := GenerateBadBlock(gspec.ToBlock(), beacon.New(ethash.NewFaker()), tt.txs, gspec.Config)

0 commit comments

Comments
 (0)