Repository navigation
csnode: keep pending consensus-settings changes across a quick start - #17
Merged
Merged
Conversation
Special order 37 announces new reward settings (staking/mining flags, block reward, mining coefficient) that take effect at a given round. Until that round the change lives only in Node's memory (consensusSettingsChangingRound_ and friends). Order 9 sets Consensus::StartingDPOS, also in memory only. A node restarted from quick-start caches between the order and its activation therefore lost both: it kept blockReward 0, dropped every trusted reward (WalletsCache caps rewards at the local blockReward), and its balances drifted from the network. This was reproduced on the private test network. A node restarted after the order but before activation logged "Changing consensus settings after qs to: blockReward = 0.00", then "confidant reward ... dropped (local blockReward 0.00)", and its STATE DIGEST at block 1000 differed from the six other nodes. It is the mechanism that leaves a node unable to validate a validator's reward withdrawal (cf. block 176'776'210). - BlockChain keeps the pending change and the order-9 StartingDPOS. Node updates them when it processes orders 37 and 9, and clears the pending change when it activates. - BlockChain_Serializer writes them to an optional consensus_pending.dat next to blockchain.dat. It is not part of the checkpoint hash, and a checkpoint without it loads exactly as before (nothing pending, StartingDPOS unchanged), so existing checkpoints stay valid and no node is forced into a slow start. - After a quick start (and on the --set-bc-top path) Node restores them. A checkpoint is written before the special-info handlers of its own block run, so if the activation round is already behind the change is applied immediately. Round 0, which never activates live, is treated as nothing pending. Test: BlockChain.PendingConsensusSettingsSurviveCheckpoint (round trip, plus a checkpoint without the companion file). nodetests: 133/133 pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Special "managing" transactions change consensus settings in two steps:
Nodemembers (consensusSettingsChangingRound_,blockReward_, ...) until that round is reached.Consensus::StartingDPOS, a static that is also held only in memory.The cache checkpoint (quick start,
qs/) does not save either of them. Suppose a node restarts from a checkpoint taken after the order was applied, but before the round it targets. That node has lost the pending change: it keeps the old block reward (0) and the default StartingDPOS. The other nodes switch to the new settings at the given round. From then on, the restarted node computes different confidant rewards, and its balances silently diverge from the network.Fix
BlockChainholds a copy of the pending order-37 settings and the order-9 StartingDPOS. They are set by the existing handlers inNodeand cleared whencheckConsensusSettingsapplies the change.BlockChain_Serializerwrites them to an optionalconsensus_pending.datnext to the other checkpoint files:Node::restorePendingConsensusSettings()restores StartingDPOS and the pending settings. If the target round is already in the chain, it applies them right away.The change is additive. It adds no new consensus rule, changes no network message, and leaves the node version unchanged.
Verification
BlockChain.PendingConsensusSettingsSurviveCheckpoint: the settings survive a save/load round trip, and a checkpoint without the companion file loads with the defaults.nodetests: 133/133 pass.testnet.yml), with node 7 restarted at sequence ~150, order 9 with StartingDPOS = 450, and order 37 with rewards from round 400:Changing consensus settings after qs to: blockReward = 0.00and drops its confidant rewards. Its STATE DIGEST (B8AE54...) differs from the other six nodes (7E7BFE...). FAIL.testnet/b-check= this branch + testnet tooling): n7 logsStartingDPOS restored from caches: 450andPending consensus settings restored from caches, active from round 400: blockReward 1.00, then switches to the new settings at round 400. All 7 nodes reach sequence 1100 with matching digests. PASS.This is divergence path B from the stuck-at-176,776,210 analysis.
Known gap, out of scope here: other special orders (for example 22, MinStakeValue) are still not persisted across a quick start.
🤖 Generated with Claude Code