diff --git a/consensus/misc/eip1559.go b/consensus/misc/eip1559.go index 1021ba9b07ac8..e0216243f0572 100644 --- a/consensus/misc/eip1559.go +++ b/consensus/misc/eip1559.go @@ -71,6 +71,7 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *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)) @@ -80,6 +81,7 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int { 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))