diff --git a/erigon-lib/txpool/txpoolcfg/txpoolcfg.go b/erigon-lib/txpool/txpoolcfg/txpoolcfg.go index 17e4232da74..303faad96a1 100644 --- a/erigon-lib/txpool/txpoolcfg/txpoolcfg.go +++ b/erigon-lib/txpool/txpoolcfg/txpoolcfg.go @@ -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 diff --git a/eth/backend.go b/eth/backend.go index 5da94c18d7f..bf83413dc7c 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -71,6 +71,7 @@ import ( "github.com/ledgerwatch/erigon-lib/kv/remotedbserver" 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" @@ -313,6 +314,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 { @@ -1636,3 +1640,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 + } +} diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index c741adc6851..ae52182f576 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -47,6 +47,9 @@ import ( //const HistoryV3AggregationStep = 3_125_000 / 100 // 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, diff --git a/eth/gasprice/gasprice.go b/eth/gasprice/gasprice.go index 81c47fc161d..ad3bfd369d9 100644 --- a/eth/gasprice/gasprice.go +++ b/eth/gasprice/gasprice.go @@ -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, @@ -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 + } +} diff --git a/eth/gasprice/gaspricecfg/gaspricecfg.go b/eth/gasprice/gaspricecfg/gaspricecfg.go index af364b0a220..a1c2b92a82a 100644 --- a/eth/gasprice/gaspricecfg/gaspricecfg.go +++ b/eth/gasprice/gaspricecfg/gaspricecfg.go @@ -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) )