mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
consensus/misc/eip1559: remove unused function which used deprecated math methods
This commit is contained in:
parent
cc1ebb7dd8
commit
f84745e194
1 changed files with 0 additions and 53 deletions
|
|
@ -21,8 +21,6 @@ import (
|
|||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/holiman/uint256"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/consensus/misc"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
|
|
@ -100,54 +98,3 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int {
|
|||
return baseFee
|
||||
}
|
||||
}
|
||||
|
||||
// CalcBaseFeeUint calculates the base fee of the header.
|
||||
func CalcBaseFeeUint(config *params.ChainConfig, parent *types.Header) *uint256.Int {
|
||||
var (
|
||||
initialBaseFeeUint = uint256.NewInt(params.InitialBaseFee)
|
||||
baseFeeChangeDenominatorUint64 = params.BaseFeeChangeDenominator(config.Bor, parent.Number)
|
||||
baseFeeChangeDenominatorUint = uint256.NewInt(baseFeeChangeDenominatorUint64)
|
||||
)
|
||||
|
||||
// If the current block is the first EIP-1559 block, return the InitialBaseFee.
|
||||
if !config.IsLondon(parent.Number) {
|
||||
return initialBaseFeeUint.Clone()
|
||||
}
|
||||
|
||||
var (
|
||||
parentGasTarget = parent.GasLimit / params.ElasticityMultiplier
|
||||
parentGasTargetBig = uint256.NewInt(parentGasTarget)
|
||||
)
|
||||
|
||||
// If the parent gasUsed is the same as the target, the baseFee remains unchanged.
|
||||
if parent.GasUsed == parentGasTarget {
|
||||
return math.FromBig(parent.BaseFee)
|
||||
}
|
||||
|
||||
if parent.GasUsed > parentGasTarget {
|
||||
// If the parent block used more gas than its target, the baseFee should increase.
|
||||
gasUsedDelta := uint256.NewInt(parent.GasUsed - parentGasTarget)
|
||||
|
||||
parentBaseFee := math.FromBig(parent.BaseFee)
|
||||
x := gasUsedDelta.Mul(parentBaseFee, gasUsedDelta)
|
||||
y := x.Div(x, parentGasTargetBig)
|
||||
baseFeeDelta := math.BigMaxUint(
|
||||
x.Div(y, baseFeeChangeDenominatorUint),
|
||||
math.U1,
|
||||
)
|
||||
|
||||
return x.Add(parentBaseFee, baseFeeDelta)
|
||||
}
|
||||
|
||||
// Otherwise if the parent block used less gas than its target, the baseFee should decrease.
|
||||
gasUsedDelta := uint256.NewInt(parentGasTarget - parent.GasUsed)
|
||||
parentBaseFee := math.FromBig(parent.BaseFee)
|
||||
x := gasUsedDelta.Mul(parentBaseFee, gasUsedDelta)
|
||||
y := x.Div(x, parentGasTargetBig)
|
||||
baseFeeDelta := x.Div(y, baseFeeChangeDenominatorUint)
|
||||
|
||||
return math.BigMaxUint(
|
||||
x.Sub(parentBaseFee, baseFeeDelta),
|
||||
math.U0.Clone(),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue