diff --git a/cmd/opera/launcher/config.go b/cmd/opera/launcher/config.go index 6107efbbc..73b1d8d3d 100644 --- a/cmd/opera/launcher/config.go +++ b/cmd/opera/launcher/config.go @@ -4,6 +4,7 @@ import ( "bufio" "errors" "fmt" + "math/big" "os" "path" "path/filepath" @@ -540,6 +541,13 @@ func mayMakeAllConfigs(ctx *cli.Context) (*config, error) { // Process DBs defaults in the end because they are applied only in absence of config or flags cfg = setDBConfigDefault(cfg, cacheRatio) + // Sanitize GPO config + if cfg.Opera.GPO.MinGasTip == nil || cfg.Opera.GPO.MinGasTip.Sign() == 0 { + cfg.Opera.GPO.MinGasTip = new(big.Int).SetUint64(cfg.TxPool.PriceLimit) + } + if cfg.Opera.GPO.MinGasTip.Cmp(new(big.Int).SetUint64(cfg.TxPool.PriceLimit)) < 0 { + log.Warn(fmt.Sprintf("GPO minimum gas tip (Opera.GPO.MinGasTip=%s) is lower than txpool minimum gas tip (TxPool.PriceLimit=%d)", cfg.Opera.GPO.MinGasTip.String(), cfg.TxPool.PriceLimit)) + } if err := cfg.Opera.Validate(); err != nil { return nil, err diff --git a/evmcore/tx_pool.go b/evmcore/tx_pool.go index 754d4cde7..f994fb626 100644 --- a/evmcore/tx_pool.go +++ b/evmcore/tx_pool.go @@ -153,7 +153,7 @@ type TxPoolConfig struct { Journal string // Journal of local transactions to survive node restarts Rejournal time.Duration // Time interval to regenerate the local transaction journal - PriceLimit uint64 // Minimum gas price to enforce for acceptance into the pool + PriceLimit uint64 // Minimum gas tip to enforce for acceptance into the pool PriceBump uint64 // Minimum price bump percentage to replace an already existing transaction (nonce) AccountSlots uint64 // Number of executable transaction slots guaranteed per account @@ -170,7 +170,7 @@ var DefaultTxPoolConfig = TxPoolConfig{ Journal: "transactions.rlp", Rejournal: time.Hour, - PriceLimit: 1, + PriceLimit: 0, PriceBump: 10, AccountSlots: 16, @@ -189,10 +189,6 @@ func (config *TxPoolConfig) sanitize() TxPoolConfig { log.Warn("Sanitizing invalid txpool journal time", "provided", conf.Rejournal, "updated", time.Second) conf.Rejournal = time.Second } - if conf.PriceLimit < 1 { - log.Warn("Sanitizing invalid txpool price limit", "provided", conf.PriceLimit, "updated", DefaultTxPoolConfig.PriceLimit) - conf.PriceLimit = DefaultTxPoolConfig.PriceLimit - } if conf.PriceBump < 1 { log.Warn("Sanitizing invalid txpool price bump", "provided", conf.PriceBump, "updated", DefaultTxPoolConfig.PriceBump) conf.PriceBump = DefaultTxPoolConfig.PriceBump diff --git a/gossip/config.go b/gossip/config.go index 0c44b34d2..6f2c2e50f 100644 --- a/gossip/config.go +++ b/gossip/config.go @@ -213,6 +213,7 @@ func DefaultConfig(scale cachescale.Func) Config { GPO: gasprice.Config{ MaxGasPrice: gasprice.DefaultMaxGasPrice, MinGasPrice: new(big.Int), + MinGasTip: new(big.Int), DefaultCertainty: 0.5 * gasprice.DecimalUnit, }, diff --git a/gossip/gasprice/gasprice.go b/gossip/gasprice/gasprice.go index 64997da2f..4035a0bdf 100644 --- a/gossip/gasprice/gasprice.go +++ b/gossip/gasprice/gasprice.go @@ -49,6 +49,7 @@ const ( type Config struct { MaxGasPrice *big.Int `toml:",omitempty"` MinGasPrice *big.Int `toml:",omitempty"` + MinGasTip *big.Int `toml:",omitempty"` DefaultCertainty uint64 `toml:",omitempty"` } @@ -107,7 +108,8 @@ func sanitizeBigInt(val, min, max, _default *big.Int, name string) *big.Int { // gasprice for newly created transaction. func NewOracle(params Config) *Oracle { params.MaxGasPrice = sanitizeBigInt(params.MaxGasPrice, nil, nil, DefaultMaxGasPrice, "MaxGasPrice") - params.MinGasPrice = sanitizeBigInt(params.MinGasPrice, nil, nil, new(big.Int), "MinGasPrice") + params.MinGasPrice = sanitizeBigInt(params.MinGasPrice, nil, params.MaxGasPrice, new(big.Int), "MinGasPrice") + params.MinGasTip = sanitizeBigInt(params.MinGasTip, nil, new(big.Int).Sub(params.MaxGasPrice, params.MinGasPrice), new(big.Int), "MinGasTip") params.DefaultCertainty = sanitizeBigInt(new(big.Int).SetUint64(params.DefaultCertainty), big.NewInt(0), DecimalUnitBn, big.NewInt(DecimalUnit/2), "DefaultCertainty").Uint64() tCache, _ := lru.New(100) return &Oracle{ @@ -148,8 +150,8 @@ func (gpo *Oracle) suggestTip(certainty uint64) *big.Int { } tip := new(big.Int).Sub(combined, minPrice) - if tip.Sign() < 0 { - return new(big.Int) + if tip.Cmp(gpo.cfg.MinGasTip) < 0 { + return new(big.Int).Set(gpo.cfg.MinGasTip) } return tip }