Repository navigation
3.x.x: live regtest: a qbitd stop or crash around submitblock offers each block once and lands or reconciles it (#521 scenario 4) - #523
Merged
Conversation
…each block once and lands or reconciles it (#521 scenario 4) Four gated live_regtest cases put a test-owned JSON-RPC proxy between both PRISM servers and the real regtest qbitd. The proxy forwards every call unchanged, records every submitblock, and holds one: before the request is forwarded, or after the node's accepting reply was read. With the call held and all proxy traffic paused, the test SIGSTOPs the node (resumed with SIGCONT) or SIGKILLs it (restarted on the same data directory and RPC port), then releases the call. A Stratum client in the test mines one block at a time, so each fault has exactly one block in flight. Every case asserts that /healthz and /metrics (health_state, node_observation_age_seconds) on both servers show the node unavailable and then recovered; that each block is offered exactly once; that the held block's offer outcome is recorded (unknown or accepted); that no row is left pending, offer_reserved or offered; that the accepted-unlanded alarm is raised only for an accepted block and clears; that a new block mined through the other server after recovery lands; and that the carry integrity report is clean. - stopped before submitblock: the node processes the buffered request when resumed and the block lands. - stopped after accepting: the post-offer observation fails, the row waits in reconciliation, and the block lands after resume. - killed before submitblock: the node never had the block; the row stays in reconciliation, is never offered again, and settles as a proven orphan once a competing block has six confirmations. This pins the known defect #522 (the restarted node would accept the block on the same tip) rather than desired behaviour; the #522 fix flips the case. - killed after accepting: an unclean qbitd exit loses the accepted block it had not flushed (the test flushes the chain before the fault, so only the held block is lost), and the row reconciles to a proven orphan as above. A fifth case, killed after accepting and restarted with -reindex (which recovers the block, so it lands), is #[ignore] for a nightly run and is not in the gated list. Mutants each fail at least one case: a blind submitblock retry on a transport error (both before-submitblock cases, "offered exactly once"), readiness that ignores the node poll age (all four), reconciliation rows that never observe the chain again (stopped after accepting), and no proven-orphan settlement (both killed cases). Refs #521 Co-Authored-By: Claude Opus 5.5 <[email protected]>
… node's, and release held replies inside the submitblock deadline (#521) Review fixes to the scenario-4 test fixture: - The proxy only read from the node after forwarding a request, so a node connection that closed while idle (qbitd's idle timeout, or the kill) left the server's side open; the server could reuse it and have a submitblock recorded as unknown. The relay now closes the server's connection as soon as the node's closes, as a direct connection would. - The Stratum client no longer polls the outbox after submitting, so a held accepting reply is released well inside the server's 1-second submitblock deadline on a slow runner. - The -reindex variant is described as opt-in (run with --ignored, for the nightly job #521 adds) rather than as already nightly, and the proxy's Content-Length-only framing is documented. Refs #521 Co-Authored-By: Claude Opus 5.5 <[email protected]>
7 tasks done
6 tasks
Member
Author
Review ledger (head b944153, CI green)This PR only adds tests, so the review is proportionate: one Code-review findings (3 found, all fixed in b944153)
Mutants. Each gated case fails against at least one:
Flakiness check. Three consecutive local runs of the four cases all passed: 4/4 in 87.3 s, 4/4 in 92.3 s and 4/4 in 87.0 s. The opt-in CI runtime added per PR. About 106 s in the Known defect pinned. #522: the killed-before case asserts the current loss, and the #522 fix should flip it. |
This was referenced Sep 28, 2026
Closed
3 tasks
3 tasks
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.
Refs #521 (scenario 4: a qbitd outage or restart around
submitblock).What
Four new gated cases in
live_regtest(tests/support/live_node_outage.rs, registered asnode_outage_tests), plus one nightly-only#[ignore]variant. Shared support is untouched apart from the three-linemodregistration inlive_regtest.rs.Both PRISM servers reach the real regtest
qbitdthrough a JSON-RPC proxy owned by the test. The proxy forwards every call unchanged, records everysubmitblock, and can hold one call at one of two points:While the call is held, all proxy traffic pauses. The test then either
SIGSTOPs the node (laterSIGCONT) orSIGKILLs it (later restarted on the same data directory and RPC port), and only then releases the call. A Stratum client in the test mines one block at a time, so each fault has exactly one block in flight.node_stopped_before_submitblock_lands_the_block_once_after_resumesubmitted(outcomeunknown)node_stopped_after_accepting_lands_the_block_once_after_resumesubmitted(outcomeaccepted)node_killed_before_submitblock_never_reoffers_the_unsent_block_known_defectorphaned(outcomeunknown)node_killed_after_accepting_reconciles_the_lost_block_onceorphaned(outcomeaccepted)qbitdexit loses the accepted block it had not flushednode_killed_after_accepting_and_reindexed_lands_the_block_once(#[ignore], nightly)submitted-reindexrecovers the block from the block filesEvery case asserts:
/healthzand/metrics(qbit_prism_health_state,qbit_prism_node_observation_age_seconds) on both servers show the node unavailable, then recovered.pending,offer_reservedoroffered.qbit_prism_accepted_block_unlanded_secondsis raised only for an accepted block and clears afterwards. For the lost block it clears through the peer-orphan collector.qbit_carry_forward_integrity_report()is clean.In the crash cases the test flushes the chain state (
gettxoutsetinfo) before the fault, so the kill loses at most the held block.Mutants
Each case fails against at least one deliberately broken build:
submitblockretry after a transport erroreach block must be offered exactly once(the held hash is offered twice)timed out waiting for server N health unavailabletimed out waiting for candidate … submittedtimed out waiting for candidate … orphanedCI runtime
The four gated cases take 87–93 s in total in the live suite, measured on two local runs. Fixed waits dominate: the 15 s health timeout per outage, the reconciliation backoff, and the 10 s metrics collector. The whole
live_regtestbinary passed locally (47 passed, 1 ignored). The nightly-reindexvariant adds about 15 s and does not run in PR CI.Known defect pinned: #522
A block whose
submitblockfails becauseqbitdis down gets the outcomeunknown. It is never offered again, so it ends orphaned even though the restarted node would accept it on the same tip. The killed-before case pins this current behavior as a named known defect, and its doc comment explains it. The #522 fix should flip that case to expect the block to land.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.