test: exercise the reorg's fatal path, through a persister it can refuse - #580
Merged
Merged
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: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
fpelliccioni
force-pushed
the
test/reorg-11-restart
branch
from
August 4, 2026 20:05
24c9374 to
7bccb50
Compare
fpelliccioni
force-pushed
the
test/reorg-12-fatal-path
branch
from
August 4, 2026 20:07
2d2d9e7 to
c8aeb6e
Compare
The write that makes a switch survivable is the one that re-describes the replaced heights. If it fails, the chain in memory and the chain on disk name different branches, nothing repairs that while the node runs, and a restart would come back on the abandoned branch with the UTXO set rewound below it. #578 added that path — reorg_outcome::fatal, on_fatal, full_node::notify_fatal, the executor's stop — and nothing exercised it. Reaching it needs the write to fail on demand. Corrupting a database to get there would test the corruption, not the handling, and filling LMDB's map would depend on page sizes and break on changes that have nothing to do with this. So execute_reorg takes the persister as a parameter. Not a test flag: the write is what decides whether the switch can be lived with, and a caller that runs a reorg has to say where it goes. The coordinator passes block_chain::replace_headers_from; the test passes one that refuses. The test then pins what happens on refusal: - the persister was reached at all (the case is not skipped elsewhere); - the switch itself succeeded — the UTXO set was rewound, the chain moved — and it is describing that on disk which failed; - the by-height table is untouched: height 13 still answers with A's block, so nothing changed it on the way out (not that the write is atomic — the persister here never reaches the database, so there is no transaction to have been left half-applied); - the reorg is reported as fatal, and no blocks are connected for the new branch; - after a restart the node is on A, whole, with the validated tip and the UTXO-built height both back at the fork — so it re-downloads rather than trust a UTXO state that no longer matches the chain it came back on; - the heavier branch can be announced again and becomes a candidate again. Adds test/fatal_shutdown.cpp for the hinge above it: notify_fatal hands the reason to the owner once and verbatim, and a node with no handler is still safe to report to. What is NOT pinned is stated there too — that notify_fatal stops the node cannot be shown on a node that never started, since stopped() is already true before the call, and the executor's own stop path needs a running node with a network that no test stands up.
fpelliccioni
force-pushed
the
test/reorg-12-fatal-path
branch
from
August 4, 2026 20:50
c8aeb6e to
6b82106
Compare
This was referenced Aug 4, 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.
Stacked on #579 — it touches the same test file. Merge #579 first; this rebases onto master after.
The write that makes a switch survivable is the one that re-describes the replaced heights. If it fails, the chain in memory and the chain on disk name different branches, nothing repairs that while the node runs, and a restart would come back on the abandoned branch with the UTXO set rewound below it. #578 added that path —
reorg_outcome::fatal,on_fatal,full_node::notify_fatal, the executor's stop — and nothing exercised it.The seam
Reaching the path needs the write to fail on demand. Corrupting a database to get there would test the corruption, not the handling; filling LMDB's map would depend on page sizes and break on changes that have nothing to do with this.
So
execute_reorgtakes the persister as a parameter:Not a test flag. The write is what decides whether the switch can be lived with, and a caller that runs a reorg has to say where it goes — the same shape as the
abortcallback already there. The coordinator passesblock_chain::replace_headers_from; the test passes one that refuses.What the test pins
fatal, and no blocks are connected for the new branch;The hinge above it
test/fatal_shutdown.cpp:notify_fatalhands the reason to the owner once and verbatim, and a node with no handler installed is still safe to report to.What is not pinned, and why — stated in the file so a passing run is not read as more than it is: that
notify_fatalstops the node cannot be shown on a node that never started, becausestopped()is already true before the call; and the executor's own stop path (state to stopping, heartbeat ending,join()) needs a running node with a network, which no test stands up.Local:
kth_node_test773 assertions / 114 cases,kth_blockchain_test2009 / 178.