diff --git a/consensus/misc/eip1559.go b/consensus/misc/eip1559.go index 977538b7e09f4..5de5685dbf8a8 100644 --- a/consensus/misc/eip1559.go +++ b/consensus/misc/eip1559.go @@ -69,6 +69,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) r := new(big.Int).SetUint64(parent.GasUsed - parentGasTarget) r.Mul(r, parent.BaseFee) r.Div(r, parentGasTargetAdjusted) @@ -77,6 +78,7 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int { return r } else { // Otherwise if the parent block used less gas than its target, the baseFee should decrease. + // max(0, parentBaseFee * gasUsedDelta / parentGasTarget * baseFeeChangeDenominator) r := new(big.Int).SetUint64(parentGasTarget - parent.GasUsed) r.Mul(r, parent.BaseFee) r.Div(r, parentGasTargetAdjusted)