Repository navigation
Conversation
…ered stale-job, not ledger-confirmation-failed (#885) A deferred-share proof (block-only, or a share-pass block captured under #657) whose candidate the node held only off its best chain (a side-chain reply) and the chain observation after its landing found not active, or that was settled as a proven orphan, is answered stale-job with cause parent_grace and an INFO line, as a race lost before the offer is. It no longer warns PrismShareAppendFailures or logs "share persistence failed" on a healthy ledger. A block the node refused as invalid, or a side-chain block whose landing or post-offer processing failed, keeps ledger-confirmation-failed; its WARN now names the node's reply. The not-active reconciliation reason is a shared constant, so the answer path and the settler agree. A race the node first accepted with a null reply is unchanged (ledger-outcome-unknown). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and found it inactive is a lost tip race too (#885) The landing run again after a lost payout-revision race reconciles a block it no longer finds active with "block left the active chain ...", now a shared prefix constant. With a side-chain reply that is the same lost tip race, so its deferred share is answered stale-job too. The docs say which proven orphans count (not one the node refused as invalid), and when a null-reply race can still be answered stale-job (orphan confirmations at 1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ger-confirmation-failed to a rejected offer (#885) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
Findings without an inline location
1. [low · red team] Load harness flags a share credited after a stale-job answer as durability loss
crates/qbit-prism-load/src/run.rs:5276
The PR changes deferred_share_disposition (crates/qbit-prism-server/src/coordinator/miner_submit.rs:1636-1653) so a lost tip race now returns Superseded(ParentGrace), sent on the wire as stale-job. The deferred share is not discarded. The comment at 1632-1635 says reconciliation can still credit it. If the block later becomes active again, the chain reconciler (ledger/blocks.rs:740-783) calls credit_deferred_share (859-877), which appends the share. The load harness's attribute_unexpected (crates/qbit-prism-load/src/digest.rs:95-125) collects committed rows that were never acknowledged, and run.rs:5405-5463 passes them to classify_committed_gap. That function only recognises ledger-confirmation-failed, ledger-outcome-unknown and NoResponse. A stale-job answer falls through to GapKind::DurabilityLoss at run.rs:5276, and the run reports a false durability finding (exit 4 instead of the earlier exit 5 AckCommitDivergence). The trigger is narrow: a block that lost the race must be reorganised back onto the active chain during a load run. PR.md acknowledges this gap as unverified.
Not posted: 2 nits and 1 lead. Reviews post bugs and security points only; the rest stay in Sixth Man's ledger.
Reviewed by Claude Opus 5.5. Red team: deepseek-v4.1-flash-abliterated, checked by Claude Opus 5.5 (1 added).
|
On qbit-reviewer's finding "Load harness flags a share credited after a stale-job answer as durability loss" (review 6161560792): the mechanism is right, and it is a known limit kept out of this PR on purpose. The 3.1.3 contract for #885 leaves |
Refs #885. This PR targets
3.x.x, so GitHub will not close the issue on merge: close #885 by hand once it lands.What was wrong
A block-only proof waits in
deferred_share_disposition(crates/qbit-prism-server/src/coordinator/miner_submit.rs) for its candidate's outcome. So does a share-pass proof whose block was captured under #657. If the node refused the offered block, or the chain proved it an orphan, the poll returnedSaveOutcome::Failed. The miner was answeredledger-confirmation-failedand the frontend logged WARNshare persistence failed. One such answer firesPrismShareAppendFailures, which points the operator at PostgreSQL even when the ledger is healthy and the block simply lost a tip race. A candidate abandoned before its offer has answeredstale-jobsince #478. A block that lost a race after its offer did not.The issue's proposed fix (answer every rejected or orphaned candidate
stale-job) is too broad. The samereconciliation+rejectedrow is also written when:Neither is a tip race.
What changed
candidate_lost_tip_race(miner_submit.rs) decides when the chain has proven a lost race. A proven race is answeredstale-job, causeparent_grace, with an INFO line that names the block, its state, the node's reply and the row's reason. That is the answer a race lost before the offer already gets. Two cases count as proven:orphaned(3.x.x: lost-race regression test and a terminal orphan disposition for reconciliation rows #415), unless the node had rejected the block with a non-side-chain reply.reconciliation, its offer wasrejectedwith a side-chain reply (inconclusive,duplicateorduplicate-inconclusive,SIDE_CHAIN_REPLIES), and itslast_erroris the ordinary "block is not on the active chain after the offer" reason, or "block left the active chain" (the landing ran again after a lost payout-revision race and found the block inactive).ledger-confirmation-failed: an invalid-block reply, a landing refusal, a post-offer error. Its WARN now names the proof's path, the candidate state and the node's reply.offer_replyin the same statement and snapshot as its other columns. The column exists since migration 011, so there is no schema change.NOT_ACTIVE_AFTER_OFFER_REASON_PREFIXandLEFT_ACTIVE_CHAIN_REASON_PREFIX(ledger/candidates.rs). The settler incoordinator.rswrites the same text as before through them.docs/prism-rejections.md: theledger-confirmation-failedrow no longer claims abandoned, side-chain and orphaned blocks, and theparent_gracecause row names the post-offer race.docs/prism-ledger-ops.md: the capture section says the same, and names what is still answeredledger-outcome-unknown.Unchanged: no metric family, label value, alert rule, configuration, migration or dependency. Cardinality and rule counts are unchanged.
No path of the found-block "not recorded" counter (#954) reaches this answer. That counter acts before the candidate is written, and these blocks were recorded and offered. The branch merges cleanly with
orca/313-found-block-counterandorca/313-found-block-retry(git merge-tree).Miner-visible change for these submissions: error code 20
ledger-confirmation-failed/share was not confirmed by the databasebecomes code 21stale-job/stale job.The node's reply for a lost race (verified from source)
The pinned qbit (v1.0.1,
.github/scripts/install-prism-qbit.sh) answerssubmitblockas Bitcoin Core does. Insrc/rpc/mining.cpp(ProcessSubmittedBlock, around line 1370), a block it already had returnsduplicate. A new valid block that was never connected returnsinconclusive. The second case is a block with no more work than the tip, so theBlockCheckedcallback never fired. So a block that reaches the node after the competing block is answeredinconclusive, and this fix applies. Not verified against a running node; no qbitd run was made.Mixed 3.1.2/3.1.3 pair and rollback
Each frontend writes its own database and peer sync copies rows between the two; the candidate outbox is a local table that peer sync does not copy (
ledger/table_inventory.rs). The answer is computed locally by the frontend that holds the submission, from its own database's outbox row. The row's columns and thelast_errortexts the settler writes are byte-for-byte what 3.1.2 writes. So in a mixed pair:stale-joband a 3.1.2 frontend still answersledger-confirmation-failed.Rollback to 3.1.2 needs nothing: no stored data or format changed.
Tests
Run locally against a private PostgreSQL 16 cluster with
PRISM_TEST_REQUIRE_INTEGRATION=1:cargo test --locked --offline -p qbit-prism-server --lib -- --test-threads=4 miner_submit::acquire_tests d2_below_target_tests window_switch_tests::leased_candidate: 17 passed.... --lib -- commit_reconcile_tests::commit_reconcile_: 17 passed (after the review fixes, both lib runs together: 34 passed).cargo test --locked --offline -p qbit-prism-server --test post_offer_revision_race --test lost_race_pin -- --test-threads=4: 8 + 8 passed. They assert the two reason texts.New or changed tests:
miner_submit::acquire_tests::block_only_poll_terminal_results_preserve_checkout_success(extended) checks the real poll against a real outbox row. Expected answers:ParentGraceFailedParentGraceinconclusiveand the left-the-active-chain reasonParentGraceFailedinconclusive,duplicateorduplicate-inconclusiveand the not-active reasonParentGraceFailedFailedFailedd2_below_target_tests::block_only_proof_whose_block_loses_the_tip_race_is_stale_job_without_credit(new, gated). The scripted node answersinconclusive. Asserts:stale-job;parent_gracecounted once,payout_revisionnot counted;commit_reconcile_tests::commit_reconcile_captured_block_that_loses_the_tip_race_is_answered_stale_job(new, gated): the same for a 3.x.x: a block found on the current tip is dropped when the payout revision moves between its submit check and its append's revision fence (#478 capture gap) #657 capture on the share path.d2_below_target_tests::block_only_proof_the_node_rejects_fails_the_submission_without_credit(unchanged): its scripted reply"rejected"is not a side-chain reply, so it still assertsledger-confirmation-failed.Mutations, each applied, built and run, then reverted:
last_errorcheck droppedpayout_revision!rejected)Lints and guards:
cargo fmt --all --checkandcargo clippy --locked --offline -p qbit-prism-server --all-targets -- -D warningsare clean. The only warnings are the existing ones invendor/sqlx-core.scripts/check_prism_pool_acquires.py,scripts/check_gate_env_reads.pyandscripts/check_toolchain_pin.pypass.test/prism-gated-tests.txtin sorted position.Left to CI: the full PostgreSQL shards, the gate manifest proof (this host runs the gate in downgraded mode), the dual-writer lane and every other suite.
Engineering lessons
ledger-confirmation-failed, and by the null-reply race left atledger-outcome-unknown. Operator docs now match the code.Unverified
The qbit reply was read from source, not observed on a running node.
Load harness:
crates/qbit-prism-load/src/run.rs(classify_committed_gap) treats a share later found in PostgreSQL afterledger-confirmation-failedas an ACK/commit divergence (exit 5). Afterstale-jobit treats it as a durability loss (exit 4). The harness is not changed here. A real-node run where a race-lost block is later reorganised back onto the chain, crediting its share after astale-jobanswer, would now report exit 4 instead of exit 5. Not observed; likely rare.A side-chain race in which a third block arrives during the chain observation ("tip changed while observing candidate") is recorded as a post-offer processing failure and is still answered
ledger-confirmation-failed. The window is milliseconds.Release note
A block-only proof (or a captured share-pass proof) whose block lost a tip race after its offer, by a side-chain reply (
inconclusive) or a proven orphan the node did not refuse as invalid, is answeredstale-job(counted underqbit_prism_stale_job_rejections_total{cause="parent_grace"}). It is no longer answeredledger-confirmation-failed, so it no longer firesPrismShareAppendFailuresor logs "share persistence failed" on a healthy ledger. Miners see code 21stale jobinstead of code 20 for these submissions. This does not cover every lost race. A block the node first accepted and a competitor then replaced, or one whose landing is still running at the 15 s acknowledgement bound, is still answeredledger-outcome-unknownand can still fire the warning. A block the node refused as invalid still answersledger-confirmation-failed.Follow-ups not done
stale-job.docs/prism-metric-metadata.json(thestale_job_rejections_totalstatus, which generatesdocs/prism-native-metrics.md) anddocs/prism-rust-migration.md(around line 2464) do not yet describe the post-offer race. Both are outside this PR's file scope.crates/qbit-prism-server/tests/lost_race_pin.rs(around line 817) still says the acknowledgement path "fails" a proven orphan. That file is outside this PR's scope.🤖 Generated with Claude Code