feat(core,cmd,eth,docs): handle chain config mismatch by cli flag#2444
feat(core,cmd,eth,docs): handle chain config mismatch by cli flag#2444gzliudan wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
9598a83 to
9b80fea
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces an explicit operator-controlled startup policy for handling stored ChainConfig incompatibilities, replacing the previous unconditional “rewind and rewrite config” behavior with a CLI/TOML-configurable decision.
Changes:
- Add
ChainConfigMismatchPolicy(TOML +--chain-config-mismatch-policy) with validated values and defaultexit. - Thread the resolved policy through blockchain open paths and adjust readonly behavior to prevent any DB mutation.
- Update operator-facing error messages, docs, and tests to reflect the new startup semantics.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
core/chain_config_mismatch_policy.go |
Defines mismatch policy enum + parsing/normalization/validation helpers. |
core/chain_config_mismatch_policy_test.go |
Adds unit tests for normalization and parsing behavior. |
core/blockchain.go |
Threads policy through open config and applies policy-specific actions on ConfigCompatError. |
core/blockchain_test.go |
Updates existing blockchain open tests and adds invalid-policy coverage. |
cmd/utils/flags.go |
Adds CLI flag, resolves policy from CLI/config, threads into MakeChain, and improves operator errors. |
cmd/utils/flags_test.go |
Updates tests for new error messages and adds tests for policy resolution precedence/validation. |
cmd/XDC/main.go |
Registers the new CLI flag on the XDC command. |
cmd/XDC/chaincmd.go |
Passes resolved policy from node config into MakeChain for chain commands. |
cmd/XDC/genesis_startup_test.go |
Updates startup tests to pass explicit policy where the old implicit rewind behavior is required. |
eth/ethconfig/config.go |
Adds ChainConfigMismatchPolicy to ethconfig.Config and defaults it to exit. |
eth/ethconfig/gen_config.go |
Regenerates TOML marshal/unmarshal to include ChainConfigMismatchPolicy. |
eth/backend.go |
Passes the configured mismatch policy into core.NewBlockChainExResolved. |
docs/upgrade.md |
Documents the new mismatch policy behaviors and operator guidance. |
Files not reviewed (1)
- eth/ethconfig/gen_config.go: Generated file
5574391 to
f5f7331
Compare
d51d22f to
cf523b4
Compare
Replace unconditional rewind-on-mismatch with an explicit chain-config mismatch policy exposed via --chain-config-mismatch-policy and ethconfig.Config.ChainConfigMismatchPolicy. Supported policies: - exit (default): fail fast without mutating the database. - rewind-and-update: rewind to compatErr.RewindTo and persist the resolved config. - update-config-only: persist the resolved config without rewinding. - ignore-mismatch: keep the in-memory config and skip database writes. Writable opens preserve the selected recovery mode, while readonly opens reject policies that would require rewinds or writes. The CLI resolves the policy from config or flag, threads it through MakeChain, and documents the new operator-facing startup behavior.
cf523b4 to
0cd48b0
Compare
Proposed changes
Replace unconditional rewind-on-mismatch startup behavior with an explicit chain config mismatch policy exposed through
--chain-config-mismatch-policyandethconfig.Config.ChainConfigMismatchPolicy.Behavior
Supported policies:
exit(default): fail fast without mutating the database.rewind-and-update: rewind tocompatErr.RewindToand persist the resolved config.update-config-only: persist the resolved config without rewinding.ignore-mismatch: keep the in-memory config and skip database writes.Writable opens preserve the selected recovery mode. Readonly opens reject policies that would require rewinds or writes.
Changes
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which parts of the codebase does this PR touch?
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that