Repository navigation
csnode: replay the other special orders after a quick start - #18
Merged
Merged
Conversation
Special orders 5, 11, 21, 22, 24-31 and 35 set Consensus statics and the node-version limits in memory only. A slow start rebuilds them by reading every block, but a quick start skips the blocks in the checkpoint, so a restarted node runs with the compiled-in defaults until its next slow start: for example the default MinStakeValue (who may be trusted), MaxTransactionSize (which transactions it rejects) or syncroChangeRound (which protocol messages it sends). BlockChain now records the payload of the last order of each of these kinds when it applies a block to the caches, that is before a checkpoint of that block is saved, so an order carried by the checkpoint block itself is included. The records go into the optional consensus_pending.dat companion file (format 2; format 1 is still read, the file stays outside the checkpoint hash). After a quick start Node replays them through the same code that handles them live, now split out of processSpecialInfo into processSpecialOrder (body unchanged, so the diff stays small). Orders not recorded, because they are already kept: 2 (initial confidants in blockchain.dat), 9 and 37 (pending settings and StartingDPOS), 23 (TimeMinStage1), 32 and 33 (smart-contract caches); 10 does nothing. Checkpoints written before this change have no records, so only a slow start or the first checkpoint saved by this version fills them in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Several special "managing" orders set values that live only in memory:
Consensus::*statics and the node-version limits.A slow start rebuilds them, because it reads every block and runs
processSpecialInfo. A quick start skips the blocks already covered by the checkpoint. A restarted node therefore runs with the compiled-in defaults until its next slow start:MaxRoundsExecuteContractMinStakeValueGrayListPunishmentsyncroChangeRoundThe other orders are already kept and are not touched here:
blockchain.dat.TimeMinStage1.Fix
BlockChain::recordSpecialOrderskeeps the payload of the last order of each kind above. It runs when a block is applied to the caches, on both the live and the slow-start path, so before a checkpoint of that block is saved. An order carried by the checkpoint block itself is therefore included.consensus_pending.datfrom csnode: keep pending consensus-settings changes across a quick start #17:Node::restoreSpecialOrdersreplays the records through the code that handles them live. That code is the loop body ofprocessSpecialInfo, now split intoprocessSpecialOrder. The body is unchanged and its indentation is kept, so the diff stays small; the only edit inside it iscontinue→return.The change adds no new consensus rule, changes no network message, and leaves the node version unchanged.
Limitation: checkpoints written before this change carry no records. Only a slow start, or the first checkpoint saved by this version, fills them in.
Verification
Unit test.
BlockChain.SpecialOrdersSurviveCheckpointcovers:nodetests: 134/134 pass.Private 7-node network (
testnet.yml, inputmin_stake=55000, node 7 restarted at block ~320, order 22 sent before that):testnet/delegations): n7 applies order 22 only once, before the restart. Result:FAIL: n7 lost special order 22 across its quick start.testnet/special-check= this branch + the testnet tooling): n7 logsRestoring 1 special order(s) from caches/MinStakeValue changed to: 55000.00at its quick start (checkpoint 327). All 7 nodes reach block 1100 with matching state digests. Result: PASS.🤖 Generated with Claude Code