Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce min base fee #1372

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion consensus/misc/eip1559/eip1559.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
num = new(big.Int)
denom = new(big.Int)
baseFeeChangeDenominatorUint64 = params.BaseFeeChangeDenominator(config.Bor, parent.Number)
minBaseFee = params.GetMinBaseFee(config.Bor, parent.Number)
)

if parent.GasUsed > parentGasTarget {
Expand All @@ -94,8 +95,14 @@
num.Div(num, denom.SetUint64(baseFeeChangeDenominatorUint64))
baseFee := num.Sub(parent.BaseFee, num)

return math.BigMax(baseFee, common.Big0)
// Because the min base fee is enforced on polygon pos, use that as the minimum
if config.Bor != nil {
return math.BigMax(baseFee, minBaseFee)
} else {
return math.BigMax(baseFee, common.Big0)
}

}

Check failure on line 105 in consensus/misc/eip1559/eip1559.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-20.04)

unnecessary trailing newline (whitespace)
}

// CalcBaseFeeUint calculates the base fee of the header.
Expand Down
10 changes: 8 additions & 2 deletions params/protocol_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ const (
BaseFeeChangeDenominatorPreDelhi = 8 // Bounds the amount the base fee can change between blocks before Delhi Hard Fork.
BaseFeeChangeDenominatorPostDelhi = 16 // Bounds the amount the base fee can change between blocks after Delhi Hard Fork.

ElasticityMultiplier = 2 // Bounds the maximum gas limit an EIP-1559 block may have.
InitialBaseFee = 1000000000 // Initial base fee for EIP-1559 blocks.
ElasticityMultiplier = 2 // Bounds the maximum gas limit an EIP-1559 block may have.
InitialBaseFee = 25000000000 // Initial base fee for EIP-1559 blocks.
MinBaseFee = 25000000000 // Mininum enforced base fee for EIP-1559 blocks (for polygon)

DefaultBaseFeeChangeDenominator = 8 // Bounds the amount the base fee can change between blocks.
DefaultElasticityMultiplier = 2 // Bounds the maximum gas limit an EIP-1559 block may have.
Expand Down Expand Up @@ -219,3 +220,8 @@ func BaseFeeChangeDenominator(borConfig *BorConfig, number *big.Int) uint64 {
return BaseFeeChangeDenominatorPreDelhi
}
}

func GetMinBaseFee(borConfig *BorConfig, number *big.Int) *big.Int {
// TODO: Check for HF here
return big.NewInt(MinBaseFee)
}
Loading