Skip to content

Commit

Permalink
Merge pull request ethereum#44 from saddoc/zero-fees
Browse files Browse the repository at this point in the history
consensus/misc: Handle case when maxBaseFee is lower than current base fee
  • Loading branch information
cp-khs authored May 3, 2023
2 parents 19f4521 + 8cfc738 commit 72b27e0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions consensus/misc/eip1559.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,19 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int {
var baseFeeDelta *big.Int
if wemixminer.IsPoW() {
baseFeeDelta = x.Div(y, baseFeeChangeDenominator)
return math.BigMax(
x.Sub(parent.BaseFee, baseFeeDelta),
common.Big1,
)
} else {
baseFeeDelta = x.Div(y.Mul(y, baseFeeChangeRate), big.NewInt(100))
if baseFeeDelta.Cmp(common.Big0) == 0 && parent.BaseFee.Cmp(common.Big1) > 0 {
baseFeeDelta.SetUint64(1)
}
return math.BigMin(math.BigMax(
x.Sub(parent.BaseFee, baseFeeDelta),
common.Big1,
), maxBaseFee)
}
return math.BigMax(
x.Sub(parent.BaseFee, baseFeeDelta),
common.Big1,
)
}
}

0 comments on commit 72b27e0

Please sign in to comment.