Repository navigation
Close the accepted-block blind spot behind lost submitblock acks - #93
Conversation
qbitd can accept a submitted PRISM block while the submitblock ack is lost in transport: acceptance then arrives only as a blockwait tip observation of the pool's own candidate hash, the accepted success tail never runs, and #89's protections both miss -- the accounted registry is only written in the direct-accept tail, and the retry disposition trusts one instantaneous chain snapshot in which the tip has already raced past the candidate and the header probe cannot prove it active. The stale-job abandon then terminally discards the pool's own on-chain block, withdraws its landed payout preview, fences payout publication, and leaves template refreshes coordination-blocked until the #90 watchdog restart (observed three times on mainnet 2026-07-25). Every tip-observation channel now registers an outstanding candidate hash seen as the chain tip as acceptance evidence, and every disposition/abandon-capable path re-checks fresh chain state plus that evidence before committing a terminal abandonment: candidates that are (or were recently observed as) active defer and retry until the accepted tail finalizes them as submitted; hashes provably absent from the active chain past the observation window stay terminally stale. Co-Authored-By: Claude Fable 5 <[email protected]>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cc0865500f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…rejection - check acceptance evidence BEFORE reject_prepared_block on the post-persist stale-chain path, and commit that abandon terminally (recheck_acceptance=False) once prepared rows are rejected -- a rejected row cannot be confirmed by a later settled view - consult tip-observation evidence again after the blocking payout-preview withdrawal, atomically with the terminal counts, so evidence arriving during the withdrawal window still defers - require a probe-proven active block (not observation evidence alone) to open the pool-closed gate, so a closed pool can never fall through to submitblock on stale evidence; unprovable views defer via the abandon path instead Co-Authored-By: Claude Fable 5 <[email protected]>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d66363149c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…epared rows Reorder the post-persist stale-chain path to decide-then-reject: the abandon runs first (its terminal commit reads tip-observation evidence atomically with the counts under the coordinator lock, so no observation can land between the decision and the rejection unseen) and the prepared payout rows are rejected only after a sealed terminal outcome. Live evidence defers with the rows untouched; a crash between the sealed decision and the rejection leaves the outbox row pending for restart replay. The recheck_acceptance escape hatch is gone -- every abandon path now takes the full evidence check unconditionally. Co-Authored-By: Claude Fable 5 <[email protected]>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fffaa4fcf4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ations The terminal commit in _abandon_block_candidate now drops the hash from the outstanding-candidate set inside the same critical section that commits the abandonment counts. Observation registration takes the same lock and only matches outstanding hashes, so acceptance evidence is structurally excluded from the gap between a sealed terminal decision and the follow-up durable rejection of prepared payout rows -- no evidence can register mid-rejection and contradict the sealed disposition. A crash before the durable outbox update still replays the candidate, which re-registers the hash and re-evaluates from live chain state before rejecting. Co-Authored-By: Claude Fable 5 <[email protected]>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2a55f5728a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…te defer - probe getbestblockhash and the active header independently so a best-tip lookup failure no longer suppresses the header check, which subsumes it and can prove acceptance (or wrong-height staleness) alone (Codex) - when acceptance evidence arrives during the payout-preview withdrawal, re-begin and re-land the preview before deferring: the restored barrier pops the fail-closed tombstone so descendant builders wait on the preview instead of fencing template refreshes while retries defer on observation evidence (Cursor) Co-Authored-By: Claude Fable 5 <[email protected]>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6328777afa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…drawal - startup replay restores acceptance evidence for durable candidates whose prepared/confirmed pool-block row proves a prior process's submitblock succeeded, so a replay disposition racing a transient fork view cannot terminally abandon the accepted block after a restart dropped the in-memory observation registry (Codex) - the late-acceptance defer republishes the withdrawn preview after restoring the landed barrier: a withdrawal whose own publication lost its race had fenced delivery, and the deferral cycles must not leave template refreshes coordination-blocked until the accepted tail republishes (Cursor) Co-Authored-By: Claude Fable 5 <[email protected]>
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…e check The late-acceptance gate now reuses the pre-check chain-probe verdict: a candidate the probe proved active at the wrong height stays terminally abandonable even when a tip observation registers during the payout-preview withdrawal. Header heights are immutable, so the wrong-height verdict cannot be overtaken by later evidence, and a corrupt-height candidate no longer defers until window expiry. Co-Authored-By: Claude Fable 5 <[email protected]>
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
bugbot run |
|
@codex review |
|
bugbot run |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d3ab0d1529
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 0a4d6d6. Configure here.
|
@codex review |
|
bugbot run |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0a4d6d6. Configure here.
#94) * Address Bugbot round 7: re-probe after withdrawal; fail-safe replay reads - an unknown pre-withdrawal probe verdict re-probes the chain after the blocking payout-preview withdrawal: a buried accepted block is not always re-observed as the tip (blockwait reports only the newest of rapid connects), so a healed view must be able to defer the terminal commit on its own; provably wrong-height verdicts stay immutable - startup replay treats a failed pool_block_state read as protection, not absence of proof: the candidate replays with restored acceptance evidence bounded by the observation window instead of racing a transient fork view unprotected after a flaky read Co-Authored-By: Claude Fable 5 <[email protected]> * Address Codex round 8: re-register retained candidates for tip observations The disposition seal stops observation matching at a terminal commit, but the terminal cleanup after it can still fail (prepared-row rejection or the durable outbox update raising), retaining the candidate for a full re-disposition. Re-register the hash inside _retain_block_candidate_for_retry -- the funnel every retained path crosses -- so acceptance evidence arriving during the retry backoff registers again instead of vanishing behind the seal. The same-pass exclusion between a sealed commit and its rejection is unchanged: retention only happens after that pass has aborted. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: admin <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>

Summary
observe_tip_for_refresh) as acceptance evidence for that block candidate, at observation time_abandon_block_candidateitself: a candidate whose own hash equals the freshgetbestblockhash, is an active chain header at its expected height, or was recently observed as the chain tip defers with the new retryable reasonaccepted-pending-finalizationinstead of abandoning, and the retry resumes the accepted success tail so the durable outbox finalizes as submitted exactly like Fix stale abandon of accepted PRISM blocks #89's preserve outcomePRISM_OBSERVED_TIP_ACCEPT_WINDOW_SECONDS, default 300s) expires — or provably active at the wrong height — abandons exactly as beforeqbit_prism_block_candidate_accept_pending_defers_totalso operators can see the protection fireRoot cause (mainnet 2026-07-25, rev d3f8e95 — three blocks: 15b645a8… ~20:58, 69390a0e… 21:06:58, 6e32560b… 21:07:20)
JsonRpcretries a transport-failedsubmitblockonce and otherwise raises to the caller — but qbitd can have accepted the block while the ack was lost. The only acceptance signal is then blockwait'swaitfornewblockreturning the pool candidate's own hash ("saw new tip …"); no "qbit accepted direct" tail ever runs, so #89's_accounted_accepted_block_hashesregistry (written only in that tail) stays empty. The candidate is retained for retry with its landed payout preview (the pre-submitblock barrier).The retry's disposition then trusts a single instantaneous chain snapshot. Under ~40s cadence with blocks in quick succession, that snapshot can show a tip that has already raced past (or transiently forked away from) the candidate while the
getblockheaderprobe cannot prove the candidate active — so the pre-checks miss and_abandon_block_candidatecommits a terminalstale-job: tip moved before submitfor the pool's own on-chain block. The terminal abandon withdraws the landed preview withinvalidate_published=True, fencing payout publication; descendant template builds fail closed on the tombstone; refreshes stay coordination-blocked (gauge climbing to 600s, initial-job queue backup, sidecar PrismStratumUnavailable) until the #90 watchdog restarts the coordinator — and the restart replays into the same blind spot.The fix closes the gap at its root: seeing your own candidate hash as the chain tip is durable acceptance evidence — qbitd only ever reports it after accepting the block — and no single racing snapshot may override it into a terminal abandonment.
Deployment
Validation
python3 -m unittest tests.test_prism_coordinator_vardiff— 285 tests passed (280 pre-existing + 5 new)python3 -m unittest discover -s tests -p 'test_*.py'— 1,237 tests passed, 3 skipped (baseline)python3 -m compileall -q lab tests docker examples scriptsgit diff --checkNew regression coverage: the exact blockwait-first interleaving (lost ack → own-hash tip observation → racing stale snapshot → must defer, keep the landed preview unfenced, then finalize as submitted with the payout tail running exactly once), the three-blocks-in-quick-succession pattern from tonight (all three finalize as submitted, publication never fenced), observed-window expiry keeping genuinely-stale abandons terminal, the acceptance-probe decision matrix, and the pool-closed gate yielding to an on-chain candidate.
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
High Risk
Changes critical block-candidate disposition, payout-preview fencing, and prepared-row rejection ordering in the live mining coordinator; incorrect defer/abandon logic could stall settlement or wrongly reject accepted blocks.
Overview
Fixes a production blind spot where lost
submitblockacks left block candidates without a completed acceptance tail, so a single racing chain snapshot could terminally abandon a pool block that qbitd had already accepted—withdrawn payout previews then fenced template refreshes until watchdog restart.The coordinator now treats an own-candidate hash seen as the chain tip (blockwait/blockpoll/template paths via
observe_tip_for_refresh) as acceptance evidence, tracks outstanding candidate hashes from enqueue through replay, and before any terminal abandon runs a fresh chain probe plus a bounded observation window (PRISM_OBSERVED_TIP_ACCEPT_WINDOW_SECONDS, default 300s). Candidates that are active, recently observed, or deferred with retryable reasonaccepted-pending-finalizationretry instead of abandoning; genuinely stale hashes (wrong height, expired window, no probe proof) still abandon. Ordering fixes seal disposition beforereject_prepared_block, restore payout previews when evidence arrives during withdrawal, and let the pool-closed gate yield only when the probe proves the block is on-chain.Config/docs/compose wire the new env var; metrics add
qbit_prism_block_candidate_accept_pending_defers_total. Large regression suite covers lost-ack + blockwait interleaving, quick-succession blocks, and edge races.Reviewed by Cursor Bugbot for commit 0a4d6d6. Bugbot is set up for automated code reviews on this repo. Configure here.