Skip to content

Commit 124fde7

Browse files
feat(eip1559): remove CalcBaseFeeOntake() method (#293)
1 parent 06b2903 commit 124fde7

File tree

2 files changed

+2
-44
lines changed

2 files changed

+2
-44
lines changed

consensus/misc/eip1559/eip1559.go

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -93,38 +93,3 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int {
9393
return math.BigMax(baseFee, common.Big0)
9494
}
9595
}
96-
97-
// CHANGE(taiko): CalcBaseFeeOntake calculates the basefee of the an ontake block header.
98-
func CalcBaseFeeOntake(config *params.ChainConfig, parent *types.Header, parentGasTarget uint64) *big.Int {
99-
// If the parent gasUsed is the same as the target, the baseFee remains unchanged.
100-
if parent.GasUsed == parentGasTarget {
101-
return new(big.Int).Set(parent.BaseFee)
102-
}
103-
104-
var (
105-
num = new(big.Int)
106-
denom = new(big.Int)
107-
)
108-
109-
if parent.GasUsed > parentGasTarget {
110-
// If the parent block used more gas than its target, the baseFee should increase.
111-
// max(1, parentBaseFee * gasUsedDelta / parentGasTarget / baseFeeChangeDenominator)
112-
num.SetUint64(parent.GasUsed - parentGasTarget)
113-
num.Mul(num, parent.BaseFee)
114-
num.Div(num, denom.SetUint64(parentGasTarget))
115-
num.Div(num, denom.SetUint64(config.BaseFeeChangeDenominator()))
116-
baseFeeDelta := math.BigMax(num, common.Big1)
117-
118-
return num.Add(parent.BaseFee, baseFeeDelta)
119-
} else {
120-
// Otherwise if the parent block used less gas than its target, the baseFee should decrease.
121-
// max(0, parentBaseFee * gasUsedDelta / parentGasTarget / baseFeeChangeDenominator)
122-
num.SetUint64(parentGasTarget - parent.GasUsed)
123-
num.Mul(num, parent.BaseFee)
124-
num.Div(num, denom.SetUint64(parentGasTarget))
125-
num.Div(num, denom.SetUint64(config.BaseFeeChangeDenominator()))
126-
baseFee := num.Sub(parent.BaseFee, num)
127-
128-
return math.BigMax(baseFee, common.Big0)
129-
}
130-
}

miner/worker.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -987,15 +987,8 @@ func (w *worker) prepareWork(genParams *generateParams) (*environment, error) {
987987
}
988988
// Set baseFee and GasLimit if we are on an EIP-1559 chain
989989
if w.chainConfig.IsLondon(header.Number) {
990-
if w.chainConfig.Taiko {
991-
if w.chainConfig.IsOntake(header.Number) {
992-
_, blockGasTargetMillion := core.DecodeOntakeExtraData(header.Extra)
993-
header.BaseFee = eip1559.CalcBaseFeeOntake(w.chainConfig, parent, uint64(blockGasTargetMillion)*1_000_000)
994-
} else if genParams.baseFeePerGas != nil {
995-
header.BaseFee = genParams.baseFeePerGas
996-
} else {
997-
header.BaseFee = eip1559.CalcBaseFee(w.chainConfig, parent)
998-
}
990+
if w.chainConfig.Taiko && genParams.baseFeePerGas != nil {
991+
header.BaseFee = genParams.baseFeePerGas
999992
} else {
1000993
header.BaseFee = eip1559.CalcBaseFee(w.chainConfig, parent)
1001994
if !w.chainConfig.IsLondon(parent.Number) {

0 commit comments

Comments
 (0)