feat(BRIP-2): Gas Fee Modifications (#2)

* impl with fork-awareness

* Update protocol_params.go

* remove the change comments

* hak

* Update eip1559.go

* Update config.go

* Update protocol_params.go

* renove forkstuff

* Update genesis.go

* Update eip1559.go

* Update eip1559.go

* Update config.go

* Check for isBerachain

* feat(BRIP-2): Gas Fee Modifications

* make fork aware

* more fork aware

* more prague1 stuff

* Move all changes except EIP-1559 to prepare-fork branch

* Reset all files except EIP-1559 to match master

* fix build

* resolve conflict

* nit

* empty bera configs

* defaults

* undo unneeded changes

* undo

* Changelog

---------

Co-authored-by: Rez <rez@berachain.com>
This commit is contained in:
Cal Bera 2025-06-18 20:12:18 -07:00 committed by GitHub
parent c901125e84
commit b09d57285e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 25 additions and 3 deletions

View file

@ -16,5 +16,7 @@ and this project adheres to
### Changed
- BRIP-2: Allowed configuration of the `MinimumBaseFeeWei`. For Berachain, this will be set as 1 gwei. (https://github.com/berachain/bera-geth/pull/2)
- BRIP-2: Allowed configuration of the `BaseFeeChangeDenominator`. For Berachain, this will be set as 48 (a 6x increase corresponding to 6x faster block times). (https://github.com/berachain/bera-geth/pull/2)
- [WIP] Updated release GH workflow to publish tarballs and push built images to GHCR.
- Removed support for appveyor, gitea, travis, circleci.

View file

@ -54,6 +54,21 @@ func VerifyEIP1559Header(config *params.ChainConfig, parent, header *types.Heade
// CalcBaseFee calculates the basefee of the header.
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.
if config.IsPrague1(parent.Number, parent.Time) {
minBaseFee := new(big.Int).SetUint64(config.Berachain.Prague1.MinimumBaseFeeWei)
if calculatedBaseFee.Cmp(minBaseFee) < 0 {
calculatedBaseFee = minBaseFee
}
}
return calculatedBaseFee
}
// calcBaseFee calculates the basefee of the header in wei.
func calcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int {
// If the current block is the first EIP-1559 block, return the InitialBaseFee.
if !config.IsLondon(parent.Number) {
return new(big.Int).SetUint64(params.InitialBaseFee)
@ -76,7 +91,7 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int {
num.SetUint64(parent.GasUsed - parentGasTarget)
num.Mul(num, parent.BaseFee)
num.Div(num, denom.SetUint64(parentGasTarget))
num.Div(num, denom.SetUint64(config.BaseFeeChangeDenominator()))
num.Div(num, denom.SetUint64(config.BaseFeeChangeDenominator(parent.Number, parent.Time)))
if num.Cmp(common.Big1) < 0 {
return num.Add(parent.BaseFee, common.Big1)
}
@ -87,7 +102,7 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int {
num.SetUint64(parentGasTarget - parent.GasUsed)
num.Mul(num, parent.BaseFee)
num.Div(num, denom.SetUint64(parentGasTarget))
num.Div(num, denom.SetUint64(config.BaseFeeChangeDenominator()))
num.Div(num, denom.SetUint64(config.BaseFeeChangeDenominator(parent.Number, parent.Time)))
baseFee := num.Sub(parent.BaseFee, num)
if baseFee.Cmp(common.Big0) < 0 {

View file

@ -1020,7 +1020,12 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, headNumber *big.Int,
}
// BaseFeeChangeDenominator bounds the amount the base fee can change between blocks.
func (c *ChainConfig) BaseFeeChangeDenominator() uint64 {
func (c *ChainConfig) BaseFeeChangeDenominator(num *big.Int, time uint64) uint64 {
// Starting at the Prague1 fork, we use the Berachain base fee change denominator.
if c.IsPrague1(num, time) {
return c.Berachain.Prague1.BaseFeeChangeDenominator
}
return DefaultBaseFeeChangeDenominator
}