Repository navigation
Shorten PRISM payout delivery gate critical sections - #49
Merged
Merged
Conversation
kiwidream
force-pushed
the
shorten-prism-payout-gate
branch
from
July 17, 2026 19:27
610f97b to
0968de4
Compare
kiwidream
force-pushed
the
shorten-prism-payout-gate
branch
from
July 17, 2026 20:15
5449ee3 to
c84feeb
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 120a9b4. Configure here.
kiwidream
pushed a commit
that referenced
this pull request
Jul 18, 2026
* Skip PRISM payout republish on covered block replays Since #49, every block-candidate finalization ran the reserve/publish sequence even when confirm_accepted_block reported nothing new. A candidate stuck in replay therefore bumped the payout-state generation, wiped the job-bundle cache, and scheduled an immediate tip-refresh retry on every block_submit_loop iteration, aborting each in-flight template refresh ("payout state changed after refresh client selection") and livelocking job delivery after a found block. Peel off the fully idempotent replay: when confirmed_count == 0 and no reserved payout source awaits publication, the published payout state already covers the candidate, so skip source reservation, publication blocking, and the post-lock force-publish fallbacks entirely. A replay whose prior attempt confirmed rows but failed before publishing always leaves its source reserved (or fenced as direct_block_uncertain), so it still publishes through the existing path, and a genuinely new confirmation (confirmed_count == 1) publishes exactly as before. _advance_payout_state_generation no longer has production callers; keep it for the tests that use it as the smallest complete invalidation cycle, with a comment saying so. Co-Authored-By: Claude Fable 5 <[email protected]> * Model production confirm semantics in the replay skip test qbit_confirm_pool_block reports confirmed_count=0 for an already- confirmed block only once the active tip height moved past it; while the block is still the tip an idempotent replay reports 1 and must keep publishing because it is indistinguishable from a freshly flipped row. Rework the regression test to replay as an active ancestor under an advanced tip, and document the confirm semantics plus the restart case at the covered-replay skip. Co-Authored-By: Claude Fable 5 <[email protected]> * Keep leaked publication fences healing through covered replays A finalization attempt can force-block delivery after a superseding source already published (its own reservation lost the race), then fail before the republish lands. That leaks a delivery fence whose source generation matches the published source, so the covered-replay skip would bail out and nothing would ever clear the fence, blocking every job build. Require a clear publication fence before skipping, so a confirmed_count=0 replay of that tail still republishes and unblocks delivery. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Claude Fable 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.

Summary
Synchronization invariant
Payout ledger mutations and the ledger reads used to construct a signed job snapshot serialize on the preparation lock. Publication then closes admission and drains only deliveries already admitted under generation N before entering the short atomic section that swaps PublishedPayoutState to N+1 and clears the signed-bundle cache. After that swap, the gate rejects generation N and prioritizes the first N+1 current-tip delivery. A bundle can therefore be sent only under the same published generation captured with its payout snapshot; no old-generation job can cross the publication boundary.
Validation
No deployment performed.
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Note
High Risk
Changes core coordinator concurrency around payout ledger mutations, job stamping, and Stratum delivery ordering; mistakes could ship stale payout work or stall miners under tip churn.
Overview
Refactors how PRISM invalidates and publishes payout state so expensive ledger/RPC work no longer holds fleet job-delivery admission.
Preparation vs publication: Reconciliation, job-bundle ledger reads, and direct-block persistence run under a serialized
_payout_state_prepare_lock. A preparedPayoutStateCandidateis published in a shortpublication()section that drains already-admitted sends, bumpsPublishedPayoutState, clears the signed-bundle cache, and updates the gate—without blocking parallel socket I/O during preparation.Delivery gate:
_PayoutStateDeliveryGatenow admits deliveries by generation (current/stale/future), can block admission while publication is pending, and prioritizes the first current-tip delivery after a new generation. Tip refresh and direct client sends record gate waits, mark deliveries, and treat pending publication as skipped work (_PayoutStatePublicationBlocked) rather than build failures.Reorg / tip paths:
reconcile_prism_pool_blocks_onceprepares mutations outside the gate, fences builds when publication is needed, publishes with a bounded supersession retry budget, and surfacessupersededin trust checks. External tip observation can reserve payout sources without waiting on in-flight preparation.Observability: New Prometheus histograms for payout preparation, publish, invalidation-to-first-delivery, gate wait by generation, plus a discarded-candidate counter. Tests cover direct-block uncertainty, 250-client shared bundles, priority ordering, and tip churn fences.
Reviewed by Cursor Bugbot for commit 3b8b6c9. Bugbot is set up for automated code reviews on this repo. Configure here.