Skip to content

Commit

Permalink
PIP-35 for amoy: enforce 25gwei gas config for amoy for erigon 2 (#11078
Browse files Browse the repository at this point in the history
)

Cherry picks #11077

> A followup PR to #10119
which sets the fields `txpool.pricelimit`, `miner.gasprice` and
`gpo.ignoreprice` to 25gwei only for polygon amoy network.
> Upon sufficient announcements, it will be generalised to all polygon
chains later.
  • Loading branch information
manav2401 authored Jul 9, 2024
1 parent 1f73ed5 commit f55073f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion erigon-lib/txpool/txpoolcfg/txpoolcfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
)

// BorDefaultTxPoolPriceLimit defines the minimum gas price limit for bor to enforce txs acceptance into the pool.
const BorDefaultTxPoolPriceLimit = 30 * common.GWei
const BorDefaultTxPoolPriceLimit = 25 * common.GWei

type Config struct {
DBDir string
Expand Down
10 changes: 6 additions & 4 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -1649,17 +1649,19 @@ func (s *Ethereum) DataDir() string {
return s.config.Dirs.DataDir
}

// setBorDefaultMinerGasPrice enforces Miner.GasPrice to be equal to BorDefaultMinerGasPrice (30gwei by default)
// setBorDefaultMinerGasPrice enforces Miner.GasPrice to be equal to BorDefaultMinerGasPrice (25gwei by default)
// only for polygon amoy network.
func setBorDefaultMinerGasPrice(chainConfig *chain.Config, config *ethconfig.Config, logger log.Logger) {
if chainConfig.Bor != nil && (config.Miner.GasPrice == nil || config.Miner.GasPrice.Cmp(ethconfig.BorDefaultMinerGasPrice) != 0) {
if chainConfig.Bor != nil && chainConfig.ChainID.Cmp(params.AmoyChainConfig.ChainID) == 0 && (config.Miner.GasPrice == nil || config.Miner.GasPrice.Cmp(ethconfig.BorDefaultMinerGasPrice) != 0) {
logger.Warn("Sanitizing invalid bor miner gas price", "provided", config.Miner.GasPrice, "updated", ethconfig.BorDefaultMinerGasPrice)
config.Miner.GasPrice = ethconfig.BorDefaultMinerGasPrice
}
}

// setBorDefaultTxPoolPriceLimit enforces MinFeeCap to be equal to BorDefaultTxPoolPriceLimit (30gwei by default)
// setBorDefaultTxPoolPriceLimit enforces MinFeeCap to be equal to BorDefaultTxPoolPriceLimit (25gwei by default)
// only for polygon amoy network.
func setBorDefaultTxPoolPriceLimit(chainConfig *chain.Config, config txpoolcfg.Config, logger log.Logger) {
if chainConfig.Bor != nil && config.MinFeeCap != txpoolcfg.BorDefaultTxPoolPriceLimit {
if chainConfig.Bor != nil && chainConfig.ChainID.Cmp(params.AmoyChainConfig.ChainID) == 0 && config.MinFeeCap != txpoolcfg.BorDefaultTxPoolPriceLimit {
logger.Warn("Sanitizing invalid bor min fee cap", "provided", config.MinFeeCap, "updated", txpoolcfg.BorDefaultTxPoolPriceLimit)
config.MinFeeCap = txpoolcfg.BorDefaultTxPoolPriceLimit
}
Expand Down
2 changes: 1 addition & 1 deletion eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import (
)

// BorDefaultMinerGasPrice defines the minimum gas price for bor validators to mine a transaction.
var BorDefaultMinerGasPrice = big.NewInt(30 * params.GWei)
var BorDefaultMinerGasPrice = big.NewInt(25 * params.GWei)

// FullNodeGPO contains default gasprice oracle settings for full node.
var FullNodeGPO = gaspricecfg.Config{
Expand Down
6 changes: 4 additions & 2 deletions eth/gasprice/gasprice.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/ledgerwatch/erigon-lib/chain"
libcommon "github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon/eth/gasprice/gaspricecfg"
"github.com/ledgerwatch/erigon/params"
"github.com/ledgerwatch/log/v3"

"github.com/ledgerwatch/erigon/core/types"
Expand Down Expand Up @@ -284,9 +285,10 @@ func (s *sortingHeap) Pop() interface{} {
return x
}

// setBorDefaultGpoIgnorePrice enforces gpo IgnorePrice to be equal to BorDefaultGpoIgnorePrice (30gwei by default)
// setBorDefaultGpoIgnorePrice enforces gpo IgnorePrice to be equal to BorDefaultGpoIgnorePrice (25gwei by default)
// only for polygon amoy network.
func setBorDefaultGpoIgnorePrice(chainConfig *chain.Config, gasPriceConfig gaspricecfg.Config) {
if chainConfig.Bor != nil && gasPriceConfig.IgnorePrice != gaspricecfg.BorDefaultGpoIgnorePrice {
if chainConfig.Bor != nil && chainConfig.ChainID.Cmp(params.AmoyChainConfig.ChainID) == 0 && gasPriceConfig.IgnorePrice != gaspricecfg.BorDefaultGpoIgnorePrice {
log.Warn("Sanitizing invalid bor gasprice oracle ignore price", "provided", gasPriceConfig.IgnorePrice, "updated", gaspricecfg.BorDefaultGpoIgnorePrice)
gasPriceConfig.IgnorePrice = gaspricecfg.BorDefaultGpoIgnorePrice
}
Expand Down
2 changes: 1 addition & 1 deletion eth/gasprice/gaspricecfg/gaspricecfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
var DefaultIgnorePrice = big.NewInt(2 * params.Wei)

// BorDefaultGpoIgnorePrice defines the minimum gas price below which bor gpo will ignore transactions.
var BorDefaultGpoIgnorePrice = big.NewInt(30 * params.Wei)
var BorDefaultGpoIgnorePrice = big.NewInt(25 * params.Wei)

var (
DefaultMaxPrice = big.NewInt(500 * params.GWei)
Expand Down

0 comments on commit f55073f

Please sign in to comment.