From 1a9935625fda647d02e925e29ad0ed15a7e72272 Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Mon, 22 Dec 2025 14:31:38 +0800 Subject: [PATCH] cmd/XDC: fix txpool gasPrice being overridden at checkpoints (#1878) This commit removes two redundant SetGasPrice() calls in the startNode function that were causing multiple issues: 1. Overriding txpool's configured price limit with the miner's gas price setting, mixing two independent configurations: - cfg.Eth.GasPrice (from --miner-gasprice --gasprice flag) - cfg.TxPool.PriceLimit (from --txpool-pricelimit flag) 2. Reverting runtime gasPrice changes made via RPC. When users call miner_setGasPrice RPC method to adjust the gasPrice dynamically, the changes would be unexpectedly reverted at the next checkpoint when startNode re-applies cfg.Eth.GasPrice. The txpool already initializes its gasPrice from config.PriceLimit during construction (core/txpool/txpool.go:333): ```go func NewTxPool(config Config, chainconfig *params.ChainConfig, chain blockChain) *TxPool { pool := &TxPool{ gasPrice: new(big.Int).SetUint64(config.PriceLimit), } ``` When mining is started via RPC (miner_start), the MinerAPI.Start() method handles gasPrice propagation correctly. This change ensures: - The txpool respects its own configuration - Runtime gasPrice adjustments via RPC persist across checkpoints - No unexpected overriding of user-configured values --- cmd/XDC/main.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cmd/XDC/main.go b/cmd/XDC/main.go index 9a5ef531bd..80356f1028 100644 --- a/cmd/XDC/main.go +++ b/cmd/XDC/main.go @@ -361,8 +361,6 @@ func startNode(ctx *cli.Context, stack *node.Node, backend ethapi.Backend, cfg X th.SetThreads(threads) } } - // Set the gas price to the limits from the CLI and start mining - ethBackend.TxPool().SetGasPrice(cfg.Eth.GasPrice) if err := ethBackend.StartStaking(true); err != nil { utils.Fatalf("Failed to start staking: %v", err) } @@ -398,8 +396,6 @@ func startNode(ctx *cli.Context, stack *node.Node, backend ethapi.Backend, cfg X th.SetThreads(threads) } } - // Set the gas price to the limits from the CLI and start mining - ethBackend.TxPool().SetGasPrice(cfg.Eth.GasPrice) if err := ethBackend.StartStaking(true); err != nil { utils.Fatalf("Failed to start staking: %v", err) }