Stabilize PRISM payout snapshot publication under share churn - #70
Stabilize PRISM payout snapshot publication under share churn#70kiwidream wants to merge 1 commit into
Conversation
|
Found 14 test failures on Blacksmith runners: Failures
|
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 82392ed. Configure here.
| self._mark_payout_snapshot_published( | ||
| payout_publication_snapshot.snapshot_id, | ||
| payout_publication_snapshot.snapshot_sha256, | ||
| ) |
There was a problem hiding this comment.
Idle poll publishes payout snapshots
Medium Severity
In ready mode, every tip poll claims an immutable payout snapshot and later calls _mark_payout_snapshot_published even when no prepared ready bundle was built or faned out (use_prepared_fanout is false). That marks an epoch published and can schedule a coalesced follow-up without the audit-bundle validation path used elsewhere, so retained_published may point at a snapshot that never completed a successful job build.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 82392ed. Configure here.



Summary
Concurrency invariants
Observability
Adds bounded-cardinality metrics for selected, published, and latest snapshot IDs; coalesced advances; scheduled and completed follow-ups; chain-tip versus payout supersession; oldest unpublished age; retention count; and eviction reason. Snapshot selection, publication, follow-up, and eviction also emit lifecycle logs.
Tests
Rollout risks
Rollback
Revert commit
82392edand restart the PRISM coordinator. This patch has no database migration and does not change payout formulas or stale-grace policy. Durable candidate intents keep the existing schema version and add optional fields, so rollback readers ignore the extra snapshot metadata. A restart invalidates connected issued jobs in the normal way and restores the prior payout-generation supersession behavior.Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Note
High Risk
Large concurrent changes to tip refresh, payout publication, job delivery, and block submission in the mining coordinator; incorrect snapshot binding could mis-attribute payouts or reject valid blocks.
Overview
Introduces immutable payout publication snapshots so ready-tip job builds pin a single ledger epoch (shares, balances, payout policy, CTV settlement) instead of being torn down when accepted shares or payout state advance mid-build.
Each snapshot gets an ID and canonical digest; that identity flows through
JobBuildKey, issued jobs, tip-refresh validation tokens, block-candidate intents, and block submission checks. Tip refresh and startup prewarm select and optionally own a snapshot before building; share commits advancelatest_availableunder a short lock but do not cancel an active snapshot-bound build. Multiple same-tip advances coalesce into one scheduled follow-up refresh after publication, while a new chain tip still supersedes immediately.Retention is bounded (
MAX_PRISM_RETAINED_PAYOUT_SNAPSHOTS) with eviction only when no submit-capable job still references a snapshot. The payout delivery gate gainsallow_stalefor snapshot-pinned work; payout-generation supersession skips builds that already carrypayout_snapshot_id > 0. New Prometheus metrics cover snapshot IDs, coalescing, follow-ups, supersession reasons, retention, and evictions. Tests addPayoutSnapshotEpochTestsand adjust initial-delivery / tip-refresh expectations for pinned bundles.Reviewed by Cursor Bugbot for commit 82392ed. Bugbot is set up for automated code reviews on this repo. Configure here.