Repository navigation
Bound PRISM refresh build supersession - #57
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3effb012fa
ℹ️ 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".
b295984 to
6d69e75
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 6d69e75. Configure here.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6d69e75ef3
ℹ️ 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".
6d69e75 to
581a482
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 581a48294c
ℹ️ 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".
| or current.fingerprint != artifacts.fingerprint | ||
| or current.generation != artifacts.generation | ||
| ): | ||
| # Snapshot-owned artifacts remain usable even if a newer | ||
| # template won the global cache race; just do not retain them. | ||
| return True | ||
| return False |
There was a problem hiding this comment.
Do not drop clock-only template builds
When a same-tip getblocktemplate update changes only volatile fields such as curtime, the fingerprint remains the same but artifacts.generation advances; if that cache fill happens while a normal initial/per-client build is running, this check rejects the completed bundle and shared_job_bundle() raises JobBuildSuperseded for non-refresh callers. With slow ready-pool builds and the poller refreshing every few seconds, miners can repeatedly retry without receiving work even though the built bundle still extends the current tip.
Useful? React with 👍 / 👎.
| now = time.monotonic() | ||
| if active.request.cancellation.cancel("superseded"): | ||
| active.request.superseded_monotonic = now | ||
| self.job_build_scheduler_counts["supersessions"] += 1 | ||
| request.superseded_monotonic = now |
There was a problem hiding this comment.
Do not supersede independent collection builds
Before the pool reaches min_ready_miners, collection-mode bundles are worker-specific, so a second worker's different equivalence_key is not a newer replacement for the first worker's job. This unconditional cancellation makes concurrent initial collection jobs cancel each other; with several miners connecting or authorizing at once, earlier miners keep retrying and can time out or disconnect instead of receiving the bootstrap work needed to make the pool ready.
Useful? React with 👍 / 👎.
…ocking Reconciles the bounded build-supersession machinery (#57) with this branch's prospective payout publication and snapshot anchor floor: - job snapshot anchors clamp below pending share commits at the frozen per-generation issued time in _new_job_build_request, which also makes the frozen anchor's window byte-reproducible across rebuilds - bundles built from a reused payout ledger artifact declare the artifact's own snapshot anchor - child builds wait for a pending accepted-parent preview before acquiring any confirmed payout input, so no stale confirmed read is taken or cached into the published payout state artifact while the parent lands - an accepted-block preview publication installs its preview balances as the published payout state artifact instead of reading the ledger, whose durable state only catches up after persistence - accepted blocks cancel obsolete job builds before preview publication, preserving the #57 refresh handoff Co-Authored-By: Claude Fable 5 <[email protected]>
Reconcile the tip publication boundary (build/validate before submit authority moves) with 1.x.x's short publication lane (#58), bounded build supersession (#57), superseded-vs-blocked budget taxonomy (#56), and delivery priorities: - keep construction outside the publication lane, then run the PR's final validation and atomic prepared publication inside it - drop the base's early tip publication before template fetch; the poll now only records a detection there - compare build-pipeline supersession gates against the newest detected tip so a replacement build for a detected-but-unpublished tip can cache and publish itself - cancel obsolete bundle/job builds at detection time - clear retained ready bundles when publication flips the tip - classify prepared-publication races as TemplateRefreshSuperseded so coordination churn cannot arm the restart budget

Summary
1.x.xtipCorrectness coverage
mining.notifyValidation
1.x.xbaseline replacement: 2.0037sNote
High Risk
Changes core mining job construction, payout stamping, tip refresh ordering, and subprocess cancellation paths; incorrect supersession or cache gating could deliver stale jobs or block refresh under load.
Overview
Replaces per-identity singleflight shared bundle preparation with a bounded latest-wins job build scheduler (active + retiring + one pending slot, 2-worker executor). Builds are keyed by
JobBuildKeyand immutable snapshots (template, payout artifact, policy, CTV, signing, decimal context);PayoutStateArtifactis published with each payout generation and must match before cache or delivery.Cooperative cancellation (
JobBuildCancelled/JobBuildSuperseded) runs through ledger, payout prep, and the audit-bundle subprocess (terminate/kill on supersession or timeout). Tip, template fingerprint, and payout generation changes preempt in-flight builds; stale bundles are rejected at cache, validation token, and client delivery boundaries.Tip refresh observes the chain tip earlier (before heavy template work), shortens holding of
_tip_refresh_lockto publication only, and revalidates client selection at fanout.poll_qbit_tip_template_oncecan include clients that became eligible after build selection. New Prometheus metrics cover scheduler, cancellation latency, replacement start, and builder worker lifecycle.Tests add coverage for scheduler equivalence, tip staleness, payout artifact mismatch fallback, lock ordering, and rapid supersession races.
Reviewed by Cursor Bugbot for commit 581a482. Bugbot is set up for automated code reviews on this repo. Configure here.
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.