mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
feat: update L2 base fee formula (#892)
feat: update L2 base fee formula (#891) * feat: update L2 base fee formula * update test tx hashes Co-authored-by: Péter Garamvölgyi <peter@scroll.io>
This commit is contained in:
parent
f777318776
commit
65af7ee9e5
2 changed files with 12 additions and 12 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue