Repository navigation
3.x.x: offer again a won block whose submitblock qbitd answered from its warmup, instead of losing it as unknown (#526) - #566
Merged
Conversation
…its warmup, instead of losing it as unknown (#526) A submitblock retry that reached qbitd while it was still warming up after a restart was answered with JSON-RPC error -28 (RPC_IN_WARMUP) and recorded as an unknown outcome. Under the never-offer-twice rule the block was never offered again and the reward was lost, although the warm node would have accepted it on the same tip. qbitd, like the Bitcoin Core it derives from, checks its warmup flag as the first step of CRPCTable::execute, before it looks the method up; nothing else raises -28, and the flag is cleared once, at the end of startup, and never set again. Checked in the pinned v1.0.0 source and against the v1.0.0 binary held in its warmup: a submitblock sent then is answered -28 (HTTP 500), the node has no record of the block once warm, and the same block is then accepted. A -28 reply to submitblock is therefore classified like #522's refused connection: the call provably never ran, so the reservation returns to pending through Ledger::release_unsent_offer, with the ordinary backoff and the pre-offer screen on the next claim. Only a submitblock reply counts; every other error code, a warmup answer to any other call, and every answered call keep today's behaviour. Tests: unit tests for the classification; gated PostgreSQL tests for the state transition and for a warmup answer after the call ran (never offered again); and a live regtest sibling of #522's outage case that restarts qbitd held in its warmup, so the retry is answered -28 by the real node and the block lands exactly once. Closes #526 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…, and the one-node RPC endpoint assumption - The test relay keeps its warmup state in one Submit mode (Warming) instead of a mode plus a flag. - The live case releases qbitd's fee-estimates FIFO with a non-blocking open polled until the node waits in its open, so a node that never gets there fails the wait instead of hanging the test. - The live case uses RPC_IN_WARMUP instead of a literal -28; the coordinator names the classification not_run and logs that the node never ran the offer (the stored "offer not sent" prefix is unchanged). - RpcReplyError::in_warmup and the ledger operations doc state the assumption both not-run rules make: the RPC URL reaches one node; an endpoint that retries a failed POST on another backend is unsupported. Refs #526 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Member
Author
Deep-review ledger (head
|
| # | Lane | Finding | Disposition |
|---|---|---|---|
| 1 | code-review | A -28 reply is trusted without checking the reply id. A proxy that retries the POST on a second, warming backend could re-offer a block the first backend ran. |
Fixed (docs), ac571d23. An id check would not catch that scenario: a retrying proxy resends the same body and id. Such a proxy can double-submit on its own, with or without this rule. The assumption both not-run rules make is now stated on RpcReplyError::in_warmup and in the ledger operations doc: the RPC URL reaches one node, and an endpoint that retries a failed POST on another backend is unsupported. |
| 2 | thermo | Move the not-executed predicate to rpc.rs and drop the submitblock method filter as dead code. |
Rejected. Scoping the rule to submitblock is a stated requirement, pinned by the mutant that drops it (only the scope pin fails, and no state-machine test changes). The decision belongs next to classify_offer, and the filter keeps the helper safe if it is ever reused for another call. |
| 3 | thermo | Model Hold::Warmup as a restart mode (Fault::Kill(Restart)) instead of a hold. |
Rejected. It follows the existing Hold::Reservation pattern from #527, which is also never armed in the proxy. Restructuring Fault would rewrite shared live-test support that other lanes are editing. |
| 4 | thermo | live_node_outage.rs is over 1k lines; extract the RPC proxy. |
Rejected. The repo has no such limit (coordinator.rs is over 3k lines). Moving shared support is out of scope, and this change keeps shared support additive. |
| 5 | thermo | The gated warmup test duplicates #522's refused test; share a scenario helper. | Rejected. Two explicit scenario scripts read clearly. A helper would rewrite #527's test for little gain. |
| 6 | thermo | The test relay keeps its warmup state in two places, a flag and a mode. | Fixed, ac571d23. One Submit::Warming mode. |
| 7 | thermo | The FIFO release (spawn_blocking open behind a timeout) could hang the test instead of failing it. |
Fixed, ac571d23. It now polls a non-blocking write open, which fails with ENXIO until the node is waiting in its own open. A node that never gets there now fails the wait. |
| 8 | thermo | Literal -28 in the live test, and "not sent" wording on the warmup path. |
Fixed, ac571d23. The test uses RPC_IN_WARMUP, the binding is renamed not_run, and the log line is reworded. The stored offer not sent prefix is unchanged. Reusing code() in tools.rs is left out of scope. |
| 9 | adversarial | No refutation found. It attacked the -28 proof, reply attribution, and the ledger and capture path. |
No action. |
| 10 | adversarial (note) | capture_offer_decisions_total{decision="offered"} counts once per reservation, so a warmup retry of a capture block counts again. |
Rejected. This was known and accepted in #527 and affects the metric only. |
| 11 | adversarial (note) | A capture block that is re-reserved after a warmup answer, and later abandoned as parent-superseded, keeps offer_decision='offered' in its payout-divergence row. |
Deferred. It predates this PR (#527's not-sent path has it too), it affects the audit record only, and no funds move. A follow-up issue is left to the maintainers. |
Totals: 4 fixed, 6 rejected, 1 deferred.
1 of 10 tasks
This was referenced Sep 28, 2026
djh58
added a commit
that referenced
this pull request
Sep 29, 2026
…cenario manifest (#560) (#584) The manifest check added by #560 fails on 3.x.x (tests/test_check_e2e_scenarios.py::test_the_checked_in_manifest_passes): two live_regtest tests in the PR gated list are cited by no running scenario. Both belong to existing #521 scenarios: - pg_failover_tests::offer_standby::a_found_block_offered_after_the_standby_flush_survives_a_replication_cut_at_submitblock (#570, #529 item c) runs on the #521 scenario 3 failover fixture; its criteria gain the standby flush wait's claim. - node_outage_tests::node_restarted_into_warmup_before_submitblock_lands_the_block_once (#566) is a #521 scenario 4 node-outage drill. scripts/check_e2e_scenarios.py and its tests pass. Refs #560, #570, #566. Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Closes #526 (follows #522 / #527)
Problem
A
submitblockretry that reaches qbitd while it is still warming up after a restart gets JSON-RPC error-28(RPC_IN_WARMUP). PRISM recorded that as an unknown outcome, so under the never-offer-twice rule the block was never offered again. The reward was lost, although the warm node would have accepted the block on the same tip. This is #522's failure class, narrowed to a retry that lands inside the warmup window.Is
-28really "not executed"?Yes. I checked the source and ran the node:
v1.0.0, the version CI pins):CRPCTable::executechecks the warmup flag as its first statement and throwsRPC_IN_WARMUPbefore it looks the method up. The wholesrc/tree raises-28nowhere else. The flag startstrueand is cleared once, bySetRPCWarmupFinished()at the end ofAppInitMain(step 13).SetRPCWarmupStarting()is called only from test setup, so warmup never comes back after startup. Any exception inside a running command becomesRPC_MISC_ERROR(-1) inExecuteCommand, never-28. PRISM sends JSON-RPC 1.0, so qbitd answers this-28with HTTP 500 and the error object.Rpcalready surfaces that asRpcReplyError.v1.0.0binary): I created a valid block without submitting it, restarted the node held in its warmup, and sentsubmitblock. The reply was{"code":-28,"message":"Loading banlist…"}with HTTP 500. Once the node was warm,getblockheaderfor that block returnedBlock not foundanddebug.lognever mentioned it. The samesubmitblockwas then accepted, and the block became the tip.Fix
offer_candidatenow asks one question before it classifies an outcome: did the node provably never run this call (offer_not_executed)? The answer is yes in two cases:RpcNotSentError, 3.x.x: a block found while qbitd refuses the connection is never offered again and is lost #522, unchanged);submitblockwithRPC_IN_WARMUP(RpcReplyError::in_warmup(), new).Both take #527's path unchanged.
Ledger::release_unsent_offerreturns the reservation topendingin one claim-fenced transaction. The row keeps no outcome, nooffered_at_msand no first-offer sample, and gets the ordinarymin(60, attempt_count)s backoff. The next claim runs the pre-offer screen again.last_errorkeeps theoffer not sentprefix and records the node's reply, for exampleoffer not sent: qbit RPC submitblock: {"code":-28,"message":"Loading banlist…"}; the node was still warming up and ran no call; the reservation taken by <instance> was returned to pending for another offer.Kept exactly as before:
submitblockstays unknown, including-1,-9(shutting down),-22,-25, a non-integercodeor no code at all. So does every transport failure after the connection existed, and the timeout.-28answer to any other call is not this offer's. A pre-offer probe that gets-28fails the attempt into the ordinary retry, with the row stillpending, as any probe error does. After the call ran, a-28on an observation settles into reconciliation like any node error, and the block is never offered again.-28reply and the release commit leavesoffer_reserved, which recovery treats as delivery unknown, as in 3.x.x: offer again a won block whose submitblock never connected, instead of losing it as unknown (#522) #527.RpcReplyError::in_warmupand in the ledger operations doc: the RPC URL reaches one node (a path-routing reverse proxy is fine). An endpoint that retries a failed POST on another backend is unsupported, because it could submit a block twice by itself.RpcReplyErrorgainscode()andin_warmup(), andrpc.rsexportsRPC_IN_WARMUP. Every caller keeps the same error type and message.Tests
coordinator::offer_not_executed_tests(5 cases)-28tosubmitblock→ not executed; refused connect still not executed;-28to another method → not this offer's; every othersubmitblockerror code, a non-integer code or no code →NoneandUnknown; answers, transport failures and timeouts →None…::offer_not_sent_tests::offer_warmup_tests::a_submitblock_answered_in_warmup_returns_the_row_to_pending_and_lands_the_block_once_when_the_node_is_warmpending, offer columns empty, reason with-28, backoff, no unknown outcome, no sample; a second warmup reply is also not executed; once the node is warm the block lands with exactly onesubmitblockthe node ran…::offer_warmup_tests::a_warmup_answer_after_the_submitblock_ran_keeps_the_offer_and_never_offers_again-28: the offer staysaccepted, the row never returns topending, later claims (warming, then warm) never offer again, the block lands with onesubmitblocklive_regtest::node_outage_tests::node_restarted_into_warmup_before_submitblock_lands_the_block_oncesubmitblock, and the connect is refused (as in #527). qbitd then restarts held in its warmup and the port reopens. The retry reaches the real node, which answers-28; the row is back inpending, and the node is proven still in warmup. The node is released and the block lands. Each block is run by the node exactly once, and only the held block ever got a warmup answer.The gated tests are listed, sorted, in
test/prism-gated-tests.txt. Net per-PR CI time: about +21 s, almost all of it the live case in the live shard.Holding a real qbitd in warmup, deterministically. qbitd opens
<datadir>/regtest/fee_estimates.datwith a blockingfopenin startup step 6. That is after its RPC server is up (step 4a) and before its warmup ends (step 13). The test makes that path a FIFO, so startup blocks in thatopenuntil the test opens the write end. Until then every call is answered-28. The test checks this directly (a direct probe returns-28before and after the retry), so it fails loudly rather than passing vacuously if a future qbitd reorders startup. Releasing the FIFO feeds an empty file, which qbitd rejects and ignores ("Continue anyway"). The FIFO is removed only after the warmup has ended, because qbitd still reads the file's time after theopenreturns. The other outage cases sharespawn_nodeand await_unsentthat now takes the expected reason. Their behaviour is unchanged, and all five pass.The proxy now records which
submitblockcalls the node answered from its warmup. "Offered exactly once" counts only the calls the node ran.Mutants (each run on the relevant tests, then reverted):
-28treated as unknown (the warmup branch removed). The unit casea_warmup_answer_to_submitblock_was_not_executedfails. The gated warmup test fails withstate reconciliation, outcome Some("unknown"). The live case fails withrecorded with outcome Some("unknown"). That is the lost-block path.-28classified as not executed for any method, not onlysubmitblock. Only the scope pina_warmup_answer_to_another_call_is_not_this_offersfails. Every state-machine test passes unchanged, including the post-offer warmup test.-28reply, for every method, into "not sent". The post-offer warmup test still passes: a-28after the call ran never re-offers, because only the onesubmitblockresult is ever classified. Only the reason-text pin of the gated warmup test fails.Also run on this branch: the full
qbit-prism-serverlib suite (583 passed, gated tests required),rpc_not_sent,offer_lifecycle, and all fivenode_outage_testslive cases.cargo fmt --checkandcargo clippy --all-targets -D warningsare clean. After the FIFO-removal fix, the live warmup case passed 70 of 70 runs on a shared, heavily loaded host (about 18 s each). Three of those runs took 28 to 67 s. The waits were in the landing of a block after the node recovered, well inside the case's 90 s and 60 s budgets, and did not reproduce in 40 further instrumented runs.🤖 Generated with Claude Code