From 8db5f9ad3ac80e318b37fb863457c49a06789dc0 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Thu, 11 Sep 2025 17:56:16 -0700 Subject: [PATCH] fix(config): Use *big.Int for MinBaseFee config (#90) --- consensus/misc/eip1559/eip1559.go | 4 ++-- core/block_validator_test.go | 4 ++-- params/config.go | 16 ++++++++-------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/consensus/misc/eip1559/eip1559.go b/consensus/misc/eip1559/eip1559.go index fcba5f2056..d8b6aa7fbe 100644 --- a/consensus/misc/eip1559/eip1559.go +++ b/consensus/misc/eip1559/eip1559.go @@ -57,8 +57,8 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int { calculatedBaseFee := calcBaseFee(config, parent) // 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)) - if calculatedBaseFee.Cmp(minBaseFee) < 0 { + minBaseFee := config.MinBaseFee(parent.Number, parent.Time) + if calculatedBaseFee.Cmp(config.MinBaseFee(parent.Number, parent.Time)) < 0 { calculatedBaseFee = minBaseFee } diff --git a/core/block_validator_test.go b/core/block_validator_test.go index 492df7436d..ce5d91fe8f 100644 --- a/core/block_validator_test.go +++ b/core/block_validator_test.go @@ -45,7 +45,7 @@ func newPrague1Config(distributor common.Address) *params.ChainConfig { cfg.Berachain.Prague1 = params.Prague1Config{ Time: &zero, BaseFeeChangeDenominator: 48, - MinimumBaseFeeWei: 10000000000, + MinimumBaseFeeWei: big.NewInt(10000000000), PoLDistributorAddress: distributor, } return &cfg @@ -143,7 +143,7 @@ func TestValidateBody_PrePrague1_PoLProhibited(t *testing.T) { cfg := *params.AllDevChainProtocolChanges cfg.Berachain.Prague1.Time = &future cfg.Berachain.Prague1.BaseFeeChangeDenominator = 48 - cfg.Berachain.Prague1.MinimumBaseFeeWei = 10000000000 + cfg.Berachain.Prague1.MinimumBaseFeeWei = big.NewInt(10000000000) cfg.Berachain.Prague1.PoLDistributorAddress = distributor chain, validator := buildTestChain(t, &cfg) diff --git a/params/config.go b/params/config.go index 7ef189d53c..0b950530f6 100644 --- a/params/config.go +++ b/params/config.go @@ -194,13 +194,13 @@ var ( Berachain: BerachainConfig{ Prague1: Prague1Config{ Time: newUint64(1756915200), // Sep 03 2025 16:00:00 UTC - MinimumBaseFeeWei: 1 * GWei, + MinimumBaseFeeWei: big.NewInt(1 * GWei), BaseFeeChangeDenominator: BerachainBaseFeeChangeDenominator, PoLDistributorAddress: PoLDistributorAddress, }, Prague2: Prague2Config{ Time: newUint64(9999999999), // TODO(Prague2): Replace with actual time. - MinimumBaseFeeWei: 0, + MinimumBaseFeeWei: big.NewInt(0), }, }, } @@ -236,13 +236,13 @@ var ( Berachain: BerachainConfig{ Prague1: Prague1Config{ Time: newUint64(1754496000), // Aug 6th 2025 16:00:00 UTC - MinimumBaseFeeWei: 10 * GWei, + MinimumBaseFeeWei: big.NewInt(10 * GWei), BaseFeeChangeDenominator: BerachainBaseFeeChangeDenominator, PoLDistributorAddress: PoLDistributorAddress, }, Prague2: Prague2Config{ 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 uint64 `json:"baseFeeChangeDenominator,omitempty"` // 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 common.Address `json:"polDistributorAddress,omitempty"` } @@ -594,7 +594,7 @@ type Prague2Config struct { // Time is the time of the Prague2 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 uint64 `json:"minimumBaseFeeWei,omitempty"` + MinimumBaseFeeWei *big.Int `json:"minimumBaseFeeWei,omitempty"` } // 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. -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) { return c.Berachain.Prague2.MinimumBaseFeeWei } if c.IsPrague1(num, time) { return c.Berachain.Prague1.MinimumBaseFeeWei } - return 0 + return common.Big0 } // ElasticityMultiplier bounds the maximum gas limit an EIP-1559 block may have.