Skip to content

Commit

Permalink
eth, txpool: enforce 30gwei for gas related configs for polygon (#10119)
Browse files Browse the repository at this point in the history
This PR enforces the params `txpool.pricelimit`, `miner.gasprice` and
`gpo.ignoreprice` to be set to 30 gwei when running `erigon` for Polygon
chains.

`bor` related PR: maticnetwork/bor#1232
  • Loading branch information
marcello33 authored May 1, 2024
1 parent e1fba03 commit d291552
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
4 changes: 4 additions & 0 deletions erigon-lib/txpool/txpoolcfg/txpoolcfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ import (

"github.com/c2h5oh/datasize"

"github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon-lib/common/fixedgas"
emath "github.com/ledgerwatch/erigon-lib/common/math"
"github.com/ledgerwatch/erigon-lib/types"
)

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

type Config struct {
DBDir string
TracedSenders []string // List of senders for which tx pool should print out debugging info
Expand Down
20 changes: 20 additions & 0 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import (
"github.com/ledgerwatch/erigon-lib/kv/temporal"
libstate "github.com/ledgerwatch/erigon-lib/state"
"github.com/ledgerwatch/erigon-lib/txpool"
"github.com/ledgerwatch/erigon-lib/txpool/txpoolcfg"
"github.com/ledgerwatch/erigon-lib/txpool/txpooluitl"
libtypes "github.com/ledgerwatch/erigon-lib/types"
"github.com/ledgerwatch/erigon-lib/wrap"
Expand Down Expand Up @@ -314,6 +315,9 @@ func New(ctx context.Context, stack *node.Node, config *ethconfig.Config, logger
backend.genesisBlock = genesis
backend.genesisHash = genesis.Hash()

setBorDefaultMinerGasPrice(chainConfig, config, logger)
setBorDefaultTxPoolPriceLimit(chainConfig, config.TxPool, logger)

if err := chainKv.Update(context.Background(), func(tx kv.RwTx) error {
isCorrectSync, useSnapshots, err := snap.EnsureNotChanged(tx, config.Snapshot)
if err != nil {
Expand Down Expand Up @@ -1709,3 +1713,19 @@ func (s *Ethereum) Sentinel() rpcsentinel.SentinelClient {
func (s *Ethereum) DataDir() string {
return s.config.Dirs.DataDir
}

// setBorDefaultMinerGasPrice enforces Miner.GasPrice to be equal to BorDefaultMinerGasPrice (30gwei by default)
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 {
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)
func setBorDefaultTxPoolPriceLimit(chainConfig *chain.Config, config txpoolcfg.Config, logger log.Logger) {
if chainConfig.Bor != nil && config.MinFeeCap != txpoolcfg.BorDefaultTxPoolPriceLimit {
logger.Warn("Sanitizing invalid bor min fee cap", "provided", config.MinFeeCap, "updated", txpoolcfg.BorDefaultTxPoolPriceLimit)
config.MinFeeCap = txpoolcfg.BorDefaultTxPoolPriceLimit
}
}
3 changes: 3 additions & 0 deletions eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ import (

//const HistoryV3AggregationStep = 1_562_500 / 10 // use this to reduce step size for dev/debug

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

// FullNodeGPO contains default gasprice oracle settings for full node.
var FullNodeGPO = gaspricecfg.Config{
Blocks: 20,
Expand Down
11 changes: 11 additions & 0 deletions eth/gasprice/gasprice.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ func NewOracle(backend OracleBackend, params gaspricecfg.Config, cache Cache) *O
ignorePrice = gaspricecfg.DefaultIgnorePrice
log.Warn("Sanitizing invalid gasprice oracle ignore price", "provided", params.IgnorePrice, "updated", ignorePrice)
}

setBorDefaultGpoIgnorePrice(backend.ChainConfig(), params)

return &Oracle{
backend: backend,
lastPrice: params.Default,
Expand Down Expand Up @@ -280,3 +283,11 @@ func (s *sortingHeap) Pop() interface{} {
*s = old[0 : n-1]
return x
}

// setBorDefaultGpoIgnorePrice enforces gpo IgnorePrice to be equal to BorDefaultGpoIgnorePrice (30gwei by default)
func setBorDefaultGpoIgnorePrice(chainConfig *chain.Config, gasPriceConfig gaspricecfg.Config) {
if chainConfig.Bor != nil && gasPriceConfig.IgnorePrice != gaspricecfg.BorDefaultGpoIgnorePrice {
log.Warn("Sanitizing invalid bor gasprice oracle ignore price", "provided", gasPriceConfig.IgnorePrice, "updated", gaspricecfg.BorDefaultGpoIgnorePrice)
gasPriceConfig.IgnorePrice = gaspricecfg.BorDefaultGpoIgnorePrice
}
}
3 changes: 3 additions & 0 deletions eth/gasprice/gaspricecfg/gaspricecfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ 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 (
DefaultMaxPrice = big.NewInt(500 * params.GWei)
)
Expand Down

0 comments on commit d291552

Please sign in to comment.