Skip to content

refactor(miner): polish miner configuration #19480#2135

Merged
AnilChinchawale merged 1 commit intoXinFinOrg:dev-upgradefrom
gzliudan:disable-empty
Mar 10, 2026
Merged

refactor(miner): polish miner configuration #19480#2135
AnilChinchawale merged 1 commit intoXinFinOrg:dev-upgradefrom
gzliudan:disable-empty

Conversation

@gzliudan
Copy link
Copy Markdown
Collaborator

@gzliudan gzliudan commented Mar 5, 2026

Proposed changes

Miner configuration is unified under [Eth.Miner] (GasCeil/GasPrice/Etherbase/ExtraData), replacing legacy top-level [Eth] miner keys.

Operational impact:
existing config files using [Eth].GasPrice/[Eth].Etherbase/[Eth].ExtraData must be migrated before upgrade.

Behavior update:
gasprice=0 remains valid; only negative gas prices are sanitized at startup.

Default change:
XDCGenesisGasLimit is reduced to 42,000,000 and now feeds miner default GasCeil (including default --miner-gaslimit), so nodes relying on defaults should review capacity expectations.

Ref: ethereum#19480

Types of changes

What types of changes does your code introduce to XDC network?
Put an in the boxes that apply

  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Changes that don't change source code or tests
  • docs: Documentation only changes
  • feat: A new feature
  • fix: A bug fix
  • perf: A code change that improves performance
  • refactor: A code change that neither fixes a bug nor adds a feature
  • revert: Revert something
  • style: Changes that do not affect the meaning of the code
  • test: Adding missing tests or correcting existing tests

Impacted Components

Which parts of the codebase does this PR touch?
Put an in the boxes that apply

  • Consensus
  • Account
  • Network
  • Geth
  • Smart Contract
  • External components
  • Not sure (Please specify below)

Checklist

Put an in the boxes once you have confirmed below actions (or provide reasons on not doing so) that

  • This PR has sufficient test coverage (unit/integration test) OR I have provided reason in the PR description for not having test coverage
  • Tested on a private network from the genesis block and monitored the chain operating correctly for multiple epochs.
  • Provide an end-to-end test plan in the PR description on how to manually test it on the devnet/testnet.
  • Tested the backwards compatibility.
  • Tested with XDC nodes running this version co-exist with those running the previous version.
  • Relevant documentation has been updated as part of this PR
  • N/A

Copilot AI review requested due to automatic review settings March 5, 2026 02:31
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 5, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 78e8c258-ec29-4109-8dc1-30844b302bab

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors mining-related runtime configuration to be instance-scoped under ethconfig.Config.Miner, removing the global params.TargetGasLimit dependency and rewiring initialization/CLI/test paths accordingly.

Changes:

  • Introduces miner.Config (Etherbase/ExtraData/GasCeil/GasPrice) and threads it through eth service creation and miner/worker construction.
  • Removes params.TargetGasLimit and updates mining gas limit selection to use the miner config (GasCeil) while updating chain maker/bench code to use params.XDCGenesisGasLimit.
  • Updates TOML marshaling/unmarshaling, CLI flag wiring, and tests to use the nested miner config.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
params/protocol_params.go Removes global TargetGasLimit.
miner/worker.go Splits miner runtime config from chain config; uses GasCeil from miner config for block gas limits.
miner/miner.go Adds miner.Config/DefaultConfig and updates Miner constructor signature.
eth/ethconfig/config.go Moves mining options into Config.Miner and updates defaults/gencodec directive.
eth/ethconfig/gen_config.go Updates TOML encoding/decoding to include nested Miner config.
eth/backend.go Validates/sanitizes config.Miner fields; wires miner + GPO to nested miner config.
core/chain_makers.go Replaces removed target gas limit usage with params.XDCGenesisGasLimit.
core/bench_test.go Updates benchmark gas limit target constant.
console/console_test.go Updates test config initialization to set Config.Miner.Etherbase.
cmd/utils/flags.go Rewires CLI flags into cfg.Miner and adds setMiner.
cmd/XDC/main.go Removes mutation of the deleted global params.TargetGasLimit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread miner/miner.go Outdated
Comment thread miner/miner.go
Comment on lines 81 to 103
type Config struct {
Genesis *core.Genesis `toml:",omitempty"`
NetworkId *uint64
SyncMode *downloader.SyncMode
NoPruning *bool
Prefetch *bool
LightServ *int `toml:",omitempty"`
LightPeers *int `toml:",omitempty"`
SkipBcVersionCheck *bool `toml:"-"`
DeleteAllBadBlocks *bool `toml:"-"`
DatabaseHandles *int `toml:"-"`
DatabaseCache *int
TrieCleanCache *int
TrieDirtyCache *int
TrieTimeout *time.Duration
Preimages *bool
FilterLogCacheSize *int
Miner *miner.Config
LogQueryLimit *int
Etherbase *common.Address `toml:",omitempty"`
MinerThreads *int `toml:",omitempty"`
ExtraData *hexutil.Bytes `toml:",omitempty"`
GasPrice *big.Int
MinerThreads *int `toml:",omitempty"`
TxPool *legacypool.Config
GPO *gasprice.Config
EnablePreimageRecording *bool
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This TOML unmarshal shape no longer recognizes the legacy top-level mining keys (etherbase, extraData, gasPrice) that previously existed on ethconfig.Config. Existing config files using the old keys will now silently ignore them and fall back to defaults, which is a backward-compatibility break. Consider supporting both the legacy keys and the new nested [Miner] table during a deprecation window (e.g., by mapping legacy fields into c.Miner when present).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/utils/flags.go Outdated
@gzliudan gzliudan force-pushed the disable-empty branch 5 times, most recently from 4f8c1d5 to 093b171 Compare March 9, 2026 11:39
Miner configuration is unified under [Eth.Miner] (GasCeil/GasPrice/Etherbase/ExtraData), replacing legacy top-level [Eth] miner keys.

Operational impact: existing config files using [Eth].GasPrice/[Eth].Etherbase/[Eth].ExtraData must be migrated before upgrade.

Behavior update: gasprice=0 remains valid; only negative gas prices are sanitized at startup.

Default change: XDCGenesisGasLimit is reduced to 42,000,000 and now feeds miner default GasCeil (including default --miner-gaslimit), so nodes relying on defaults should review capacity expectations.
@AnilChinchawale AnilChinchawale merged commit d8fd092 into XinFinOrg:dev-upgrade Mar 10, 2026
13 checks passed
@gzliudan gzliudan deleted the disable-empty branch March 10, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants