Skip to content

csnode: replay the other special orders after a quick start - #18

Merged
EnzinoBB merged 1 commit into
masterfrom
fix/persist-special-orders
Oct 10, 2026
Merged

EnzinoBB merged 1 commit into
masterfrom
fix/persist-special-orders

Conversation

@EnzinoBB

Copy link
Copy Markdown
Collaborator

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:

Order Sets Effect of losing it
5 node-version limits an obsolete node does not stop
11 MaxRoundsExecuteContract contract timeouts differ
21, 25–31 stage-1 / block / packet / queue / transaction size limits the node rejects transactions or packets the network accepts
22 MinStakeValue wrong view of who may be trusted
24 GrayListPunishment local only
35 syncroChangeRound the node sends the old protocol messages

The other orders are already kept and are not touched here:

Fix

  • Recording. BlockChain::recordSpecialOrders keeps 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.
  • Storage. The records go into the optional consensus_pending.dat from csnode: keep pending consensus-settings changes across a quick start #17:
    • its format goes from 1 to 2, and format 1 is still read;
    • the file stays outside the checkpoint hash.
  • Replay. After a quick start, Node::restoreSpecialOrders replays the records through the code that handles them live. That code is the loop body of processSpecialInfo, now split into processSpecialOrder. The body is unchanged and its indentation is kept, so the diff stays small; the only edit inside it is continue → 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.SpecialOrdersSurviveCheckpoint covers:

    • the round trip through the checkpoint;
    • that the later order of the same kind wins;
    • that order 37 is not recorded;
    • that a checkpoint without the companion file loads with nothing to replay.

    nodetests: 134/134 pass.

  • Private 7-node network (testnet.yml, input min_stake=55000, node 7 restarted at block ~320, order 22 sent before that):

    • without this fix (run 38033638986, branch testnet/delegations): n7 applies order 22 only once, before the restart. Result: FAIL: n7 lost special order 22 across its quick start.
    • with this fix (run 38033640276, branch testnet/special-check = this branch + the testnet tooling): n7 logs Restoring 1 special order(s) from caches / MinStakeValue changed to: 55000.00 at its quick start (checkpoint 327). All 7 nodes reach block 1100 with matching state digests. Result: PASS.

🤖 Generated with Claude Code

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>
@EnzinoBB
EnzinoBB merged commit 227389e into master Oct 10, 2026
2 checks passed
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.

1 participant