fix(config): Use *big.Int for MinBaseFee config (#90)

This commit is contained in:
Cal Bera 2025-09-11 17:56:16 -07:00 committed by GitHub
parent 65267adfcb
commit 8db5f9ad3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 12 deletions

View file

@ -57,8 +57,8 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int {
calculatedBaseFee := calcBaseFee(config, parent) calculatedBaseFee := calcBaseFee(config, parent)
// Starting at the Prague1 fork, the base fee must be at least the minimum base fee. // Starting at the Prague1 fork, the base fee must be at least the minimum base fee.
minBaseFee := new(big.Int).SetUint64(config.MinBaseFee(parent.Number, parent.Time)) minBaseFee := config.MinBaseFee(parent.Number, parent.Time)
if calculatedBaseFee.Cmp(minBaseFee) < 0 { if calculatedBaseFee.Cmp(config.MinBaseFee(parent.Number, parent.Time)) < 0 {
calculatedBaseFee = minBaseFee calculatedBaseFee = minBaseFee
} }

View file

@ -45,7 +45,7 @@ func newPrague1Config(distributor common.Address) *params.ChainConfig {
cfg.Berachain.Prague1 = params.Prague1Config{ cfg.Berachain.Prague1 = params.Prague1Config{
Time: &zero, Time: &zero,
BaseFeeChangeDenominator: 48, BaseFeeChangeDenominator: 48,
MinimumBaseFeeWei: 10000000000, MinimumBaseFeeWei: big.NewInt(10000000000),
PoLDistributorAddress: distributor, PoLDistributorAddress: distributor,
} }
return &cfg return &cfg
@ -143,7 +143,7 @@ func TestValidateBody_PrePrague1_PoLProhibited(t *testing.T) {
cfg := *params.AllDevChainProtocolChanges cfg := *params.AllDevChainProtocolChanges
cfg.Berachain.Prague1.Time = &future cfg.Berachain.Prague1.Time = &future
cfg.Berachain.Prague1.BaseFeeChangeDenominator = 48 cfg.Berachain.Prague1.BaseFeeChangeDenominator = 48
cfg.Berachain.Prague1.MinimumBaseFeeWei = 10000000000 cfg.Berachain.Prague1.MinimumBaseFeeWei = big.NewInt(10000000000)
cfg.Berachain.Prague1.PoLDistributorAddress = distributor cfg.Berachain.Prague1.PoLDistributorAddress = distributor
chain, validator := buildTestChain(t, &cfg) chain, validator := buildTestChain(t, &cfg)

View file

@ -194,13 +194,13 @@ var (
Berachain: BerachainConfig{ Berachain: BerachainConfig{
Prague1: Prague1Config{ Prague1: Prague1Config{
Time: newUint64(1756915200), // Sep 03 2025 16:00:00 UTC Time: newUint64(1756915200), // Sep 03 2025 16:00:00 UTC
MinimumBaseFeeWei: 1 * GWei, MinimumBaseFeeWei: big.NewInt(1 * GWei),
BaseFeeChangeDenominator: BerachainBaseFeeChangeDenominator, BaseFeeChangeDenominator: BerachainBaseFeeChangeDenominator,
PoLDistributorAddress: PoLDistributorAddress, PoLDistributorAddress: PoLDistributorAddress,
}, },
Prague2: Prague2Config{ Prague2: Prague2Config{
Time: newUint64(9999999999), // TODO(Prague2): Replace with actual time. Time: newUint64(9999999999), // TODO(Prague2): Replace with actual time.
MinimumBaseFeeWei: 0, MinimumBaseFeeWei: big.NewInt(0),
}, },
}, },
} }
@ -236,13 +236,13 @@ var (
Berachain: BerachainConfig{ Berachain: BerachainConfig{
Prague1: Prague1Config{ Prague1: Prague1Config{
Time: newUint64(1754496000), // Aug 6th 2025 16:00:00 UTC Time: newUint64(1754496000), // Aug 6th 2025 16:00:00 UTC
MinimumBaseFeeWei: 10 * GWei, MinimumBaseFeeWei: big.NewInt(10 * GWei),
BaseFeeChangeDenominator: BerachainBaseFeeChangeDenominator, BaseFeeChangeDenominator: BerachainBaseFeeChangeDenominator,
PoLDistributorAddress: PoLDistributorAddress, PoLDistributorAddress: PoLDistributorAddress,
}, },
Prague2: Prague2Config{ Prague2: Prague2Config{
Time: newUint64(9999999999), // TODO(Prague2): Replace with actual time. Time: newUint64(9999999999), // TODO(Prague2): Replace with actual time.
MinimumBaseFeeWei: 0, MinimumBaseFeeWei: big.NewInt(0),
}, },
}, },
} }
@ -572,7 +572,7 @@ type Prague1Config struct {
// BaseFeeChangeDenominator is the base fee change denominator. // BaseFeeChangeDenominator is the base fee change denominator.
BaseFeeChangeDenominator uint64 `json:"baseFeeChangeDenominator,omitempty"` BaseFeeChangeDenominator uint64 `json:"baseFeeChangeDenominator,omitempty"`
// MinimumBaseFeeWei is the minimum base fee in wei. // MinimumBaseFeeWei is the minimum base fee in wei.
MinimumBaseFeeWei uint64 `json:"minimumBaseFeeWei,omitempty"` MinimumBaseFeeWei *big.Int `json:"minimumBaseFeeWei,omitempty"`
// PoLDistributorAddress is the address of the PoL distributor. // PoLDistributorAddress is the address of the PoL distributor.
PoLDistributorAddress common.Address `json:"polDistributorAddress,omitempty"` PoLDistributorAddress common.Address `json:"polDistributorAddress,omitempty"`
} }
@ -594,7 +594,7 @@ type Prague2Config struct {
// Time is the time of the Prague2 fork. // Time is the time of the Prague2 fork.
Time *uint64 `json:"time,omitempty"` // Prague2 switch time (0 = already on prague2, nil = no fork) Time *uint64 `json:"time,omitempty"` // Prague2 switch time (0 = already on prague2, nil = no fork)
// MinimumBaseFeeWei is the minimum base fee in wei. // MinimumBaseFeeWei is the minimum base fee in wei.
MinimumBaseFeeWei uint64 `json:"minimumBaseFeeWei,omitempty"` MinimumBaseFeeWei *big.Int `json:"minimumBaseFeeWei,omitempty"`
} }
// String implements the stringer interface. // String implements the stringer interface.
@ -1167,14 +1167,14 @@ func (c *ChainConfig) BaseFeeChangeDenominator(num *big.Int, time uint64) uint64
} }
// MinBaseFee returns the minimum base fee (in wei) based on the active fork. // MinBaseFee returns the minimum base fee (in wei) based on the active fork.
func (c *ChainConfig) MinBaseFee(num *big.Int, time uint64) uint64 { func (c *ChainConfig) MinBaseFee(num *big.Int, time uint64) *big.Int {
if c.IsPrague2(num, time) { if c.IsPrague2(num, time) {
return c.Berachain.Prague2.MinimumBaseFeeWei return c.Berachain.Prague2.MinimumBaseFeeWei
} }
if c.IsPrague1(num, time) { if c.IsPrague1(num, time) {
return c.Berachain.Prague1.MinimumBaseFeeWei return c.Berachain.Prague1.MinimumBaseFeeWei
} }
return 0 return common.Big0
} }
// ElasticityMultiplier bounds the maximum gas limit an EIP-1559 block may have. // ElasticityMultiplier bounds the maximum gas limit an EIP-1559 block may have.