Skip to content

Commit e2f18ee

Browse files
author
colinlyguo
committed
reuse baseFeeOverhead as proving base fee
1 parent 13b13f9 commit e2f18ee

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

consensus/misc/eip1559.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,20 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header, parentL1BaseF
107107
return big.NewInt(10000000) // 0.01 Gwei
108108
}
109109

110+
scalar, overhead := ReadL2BaseFeeCoefficients()
111+
110112
if parent == nil || parent.Number == nil || !config.IsFeynman(currentHeaderTime) {
111-
scalar, overhead := ReadL2BaseFeeCoefficients()
112113
return calcBaseFee(scalar, overhead, parentL1BaseFee)
113114
}
114-
return calcBaseFeeFeynman(config, parent)
115+
// In Feynman base fee calculation, we reuse the contract's baseFeeOverhead slot as the proving base fee.
116+
return calcBaseFeeFeynman(config, parent, overhead)
115117
}
116118

117119
// calcBaseFeeFeynman calculates the basefee of the header for Feynman fork.
118-
func calcBaseFeeFeynman(config *params.ChainConfig, parent *types.Header) *big.Int {
120+
func calcBaseFeeFeynman(config *params.ChainConfig, parent *types.Header, overhead *big.Int) *big.Int {
119121
baseFeeEIP1559 := calcBaseFeeEIP1559(config, parent)
120122
baseFee := new(big.Int).Set(baseFeeEIP1559)
121-
baseFee.Add(baseFee, config.ProvingBaseFee)
123+
baseFee.Add(baseFee, overhead)
122124

123125
return baseFee
124126
}
@@ -170,7 +172,9 @@ func calcBaseFeeEIP1559(config *params.ChainConfig, parent *types.Header) *big.I
170172
}
171173

172174
func extractBaseFeeEIP1559(config *params.ChainConfig, baseFee *big.Int) *big.Int {
173-
return new(big.Int).Sub(baseFee, config.ProvingBaseFee)
175+
_, overhead := ReadL2BaseFeeCoefficients()
176+
// In Feynman base fee calculation, we reuse the contract's baseFeeOverhead slot as the proving base fee.
177+
return new(big.Int).Sub(baseFee, overhead)
174178
}
175179

176180
// MinBaseFee calculates the minimum L2 base fee based on the current coefficients.

core/state_processor_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ func TestStateProcessorErrors(t *testing.T) {
6868
EuclidTime: new(uint64),
6969
EuclidV2Time: new(uint64),
7070
FeynmanTime: new(uint64),
71-
ProvingBaseFee: new(big.Int),
7271
Ethash: new(params.EthashConfig),
7372
}
7473
signer = types.LatestSigner(config)

params/config.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,6 @@ var (
524524
EuclidTime: new(uint64),
525525
EuclidV2Time: new(uint64),
526526
FeynmanTime: new(uint64),
527-
ProvingBaseFee: new(big.Int),
528527
TerminalTotalDifficulty: nil,
529528
Ethash: new(EthashConfig),
530529
Clique: nil,
@@ -667,7 +666,6 @@ type ChainConfig struct {
667666
EuclidTime *uint64 `json:"euclidTime,omitempty"` // Euclid switch time (nil = no fork, 0 = already on euclid)
668667
EuclidV2Time *uint64 `json:"euclidv2Time,omitempty"` // EuclidV2 switch time (nil = no fork, 0 = already on euclidv2)
669668
FeynmanTime *uint64 `json:"feynmanTime,omitempty"` // Feynman switch time (nil = no fork, 0 = already on feynman)
670-
ProvingBaseFee *big.Int `json:"provingFee,omitempty"` // Proving base fee to be added to EIP1559 l2 base fee to account for proving costs
671669

672670
// TerminalTotalDifficulty is the amount of total difficulty reached by
673671
// the network that triggers the consensus upgrade.

0 commit comments

Comments
 (0)