mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-15 00:13:46 +00:00
feat(eip1559): remove CalcBaseFeeOntake() method (#293)
This commit is contained in:
parent
06b29039cb
commit
124fde7e02
2 changed files with 2 additions and 44 deletions
|
|
@ -93,38 +93,3 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int {
|
||||||
return math.BigMax(baseFee, common.Big0)
|
return math.BigMax(baseFee, common.Big0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CHANGE(taiko): CalcBaseFeeOntake calculates the basefee of the an ontake block header.
|
|
||||||
func CalcBaseFeeOntake(config *params.ChainConfig, parent *types.Header, parentGasTarget uint64) *big.Int {
|
|
||||||
// If the parent gasUsed is the same as the target, the baseFee remains unchanged.
|
|
||||||
if parent.GasUsed == parentGasTarget {
|
|
||||||
return new(big.Int).Set(parent.BaseFee)
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
num = new(big.Int)
|
|
||||||
denom = new(big.Int)
|
|
||||||
)
|
|
||||||
|
|
||||||
if parent.GasUsed > parentGasTarget {
|
|
||||||
// If the parent block used more gas than its target, the baseFee should increase.
|
|
||||||
// max(1, parentBaseFee * gasUsedDelta / parentGasTarget / baseFeeChangeDenominator)
|
|
||||||
num.SetUint64(parent.GasUsed - parentGasTarget)
|
|
||||||
num.Mul(num, parent.BaseFee)
|
|
||||||
num.Div(num, denom.SetUint64(parentGasTarget))
|
|
||||||
num.Div(num, denom.SetUint64(config.BaseFeeChangeDenominator()))
|
|
||||||
baseFeeDelta := math.BigMax(num, common.Big1)
|
|
||||||
|
|
||||||
return num.Add(parent.BaseFee, baseFeeDelta)
|
|
||||||
} else {
|
|
||||||
// Otherwise if the parent block used less gas than its target, the baseFee should decrease.
|
|
||||||
// max(0, parentBaseFee * gasUsedDelta / parentGasTarget / baseFeeChangeDenominator)
|
|
||||||
num.SetUint64(parentGasTarget - parent.GasUsed)
|
|
||||||
num.Mul(num, parent.BaseFee)
|
|
||||||
num.Div(num, denom.SetUint64(parentGasTarget))
|
|
||||||
num.Div(num, denom.SetUint64(config.BaseFeeChangeDenominator()))
|
|
||||||
baseFee := num.Sub(parent.BaseFee, num)
|
|
||||||
|
|
||||||
return math.BigMax(baseFee, common.Big0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -987,15 +987,8 @@ func (w *worker) prepareWork(genParams *generateParams) (*environment, error) {
|
||||||
}
|
}
|
||||||
// Set baseFee and GasLimit if we are on an EIP-1559 chain
|
// Set baseFee and GasLimit if we are on an EIP-1559 chain
|
||||||
if w.chainConfig.IsLondon(header.Number) {
|
if w.chainConfig.IsLondon(header.Number) {
|
||||||
if w.chainConfig.Taiko {
|
if w.chainConfig.Taiko && genParams.baseFeePerGas != nil {
|
||||||
if w.chainConfig.IsOntake(header.Number) {
|
header.BaseFee = genParams.baseFeePerGas
|
||||||
_, blockGasTargetMillion := core.DecodeOntakeExtraData(header.Extra)
|
|
||||||
header.BaseFee = eip1559.CalcBaseFeeOntake(w.chainConfig, parent, uint64(blockGasTargetMillion)*1_000_000)
|
|
||||||
} else if genParams.baseFeePerGas != nil {
|
|
||||||
header.BaseFee = genParams.baseFeePerGas
|
|
||||||
} else {
|
|
||||||
header.BaseFee = eip1559.CalcBaseFee(w.chainConfig, parent)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
header.BaseFee = eip1559.CalcBaseFee(w.chainConfig, parent)
|
header.BaseFee = eip1559.CalcBaseFee(w.chainConfig, parent)
|
||||||
if !w.chainConfig.IsLondon(parent.Number) {
|
if !w.chainConfig.IsLondon(parent.Number) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue