Repository navigation
Mainnet readiness - #19
Conversation
…quirements # Conflicts: # compose.yaml
Production validation now runs in two tiers. The behavioral tier (non-default credentials, explicit payout addresses, strict difficulty and readiness policies, zero stale grace, commit-pinned sources) keeps its existing trigger: QBIT_PRODUCTION=1, QBIT_TOOLS_PRODUCTION=1, or QBIT_CHAIN=mainnet. The release-provenance tier (digest-qualified *_IMAGE references, absolute *_DATA_SOURCE host paths, and fresh PRISM capacity evidence) is enforced unconditionally on mainnet -- no environment variable can disable it there -- and on other chains only with the new QBIT_REQUIRE_RELEASE_PROVENANCE=1 opt-in. A production pool that builds its images from the pinned source in place (for example a public testnet4 deployment) can never satisfy digest-pinned image references or image-digest-matched capacity evidence, so the previous single-tier gate made such deployments impossible without weakening any real safety property they rely on. The same tiering applies to every enforcement point of the capacity evidence contract: scripts/check-env.sh, the PRISM coordinator startup gate, and prism-self-check's capacity.evidence row. No check is deleted or weakened; each is re-tiered with identical mainnet-always semantics. Co-Authored-By: Claude Fable 5 <[email protected]>
Production gate split: behavioral checks vs. release provenance
WhyThe single-tier gate coupled two different contracts behind
A live public testnet4 pool runs with What changed
Validation
|
A miner can resubmit the same solved block after a transient submit outcome. The rebuilt candidate intent differs from the persisted one only in pending_share.accepted_at_ms, so whenever the retry crossed a millisecond boundary the durable outbox rejected it with "block candidate payload mismatch" -- a timing-dependent failure seen in CI and reproducible locally about one run in eight. Compare candidates by an identity form that excludes the volatile acknowledgment stamp, in both ledger backends and on both the persist-intent and landed-append paths. The first persisted payload stays authoritative and any divergence other than the stamp is still a hard payload mismatch. The previously flaky transient-outcome test now forces every call onto a new millisecond, and a ledger-level test pins drift-idempotence, first-payload retention, and the surviving mismatch error. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Follow-up A resubmission of the same solved block after a transient outcome rebuilds its candidate intent with a fresh |
Port of the fixes reviewed and merged on the private branch (SwapLabsInc #175, commit 74ff97b): - Classify template-policy misconfiguration (CKPOOL_TEMPLATE_MAX_AGE_SECONDS <= 0, CKPOOL_TEMPLATE_MAX_FUTURE_SECONDS < 0) as TemplateValidationError so the watchdog fails closed immediately instead of routing them through the transient-RPC grace window while CKPool keeps mining. - Require a previousblockhash/tip mismatch to persist across three time-separated snapshots (1s apart) before fetch_and_validate_template raises MiningStateValidationError. A block arriving between getblocktemplate and getbestblockhash no longer kills the pool on an innocent tip advance, while a genuinely wedged or forked template builder still fails closed. Co-Authored-By: Claude Fable 5 <[email protected]>
Before the ledger has accepted shares from PRISM_MIN_READY_MINERS distinct miners, jobs run in collection mode, and a block solved on such a job was silently withheld: the share was ledgered but the block was never submitted. On a fresh ledger at bootstrap difficulty -- where the high-diff listener's share floor sits above the network target and every accepted share is also a valid block -- that structurally discards the first solved block(s), and in the degenerate single-lane case stalls the chain at its starting height while the pool keeps acknowledging shares. The collection bundle already commits the whole coinbase to the submitting worker through a signed bootstrap manifest, so solver-pays- all is a valid, auditable settlement. Make collection candidates block-worthy: they submit through the same synchronous and queued paths as ready-window candidates, are counted by a new qbit_prism_collection_block_submissions_total metric with an explicit log line, and carry a collection_only flag through the durable block-candidate intent (absent in previously persisted intents, which replay unchanged as ready-window candidates). Also close the propagation gap after readiness flips: crossing min_ready_miners is invisible to the template fingerprint, so already connected miners kept their collection jobs until an unrelated event. The template poller now latches the (monotonic) readiness transition once and replaces outstanding collection jobs with windowed work on its next pass. Co-Authored-By: Claude Fable 5 <[email protected]>
|
The collection bundle already commits the whole coinbase to the submitting worker via a signed bootstrap manifest — a valid, auditable solver-pays-all settlement — so collection candidates are now block-worthy through the same sync/queued submit paths, counted by Suite: 693 tests OK. Mature ledgers (any live pool) never re-enter collection mode, so this is inert for existing deployments; it matters for fresh-ledger launches. |
The zero-grace requirement sat in the behavioral production tier, so a public test-chain pool running QBIT_PRODUCTION=1 could not credit shares that raced a block within the miner job-switch latency (~2s): during difficulty catch-up sprints every one of those shares became a miner-visible reject, which reads as pool instability to rented hashpower even though the work was real and the safety property -- never build a block on a stale template -- is enforced independently of crediting. Require PRISM_STRATUM_STALE_GRACE_SECONDS=0 only when QBIT_CHAIN=mainnet, in all three enforcement points (check-env.sh, the coordinator production gate, prism-self-check). Other chains may configure a bounded grace window; grace-credited shares remain excluded from block submission everywhere. Co-Authored-By: Claude Fable 5 <[email protected]>
|
|
The chain-trust gate refuses to issue jobs while qbitd reports initial block download, and a virgin regtest chain stays in IBD until its first block -- so the harness deadlocked: no jobs without a block, no block without jobs. Pre-mine one block before starting the coordinator; the PRISM ledger stays empty, so the fresh-ledger collection path is still what the miners exercise. The first-difficulty probes also predated the stamped job floor: the advertised share difficulty is now clamped to the network difficulty (a share is never required to be harder than a block), with only the high-diff wire floor holding above the clamp; password d=/md= bound vardiff but do not lift the first job. Expect the clamp dynamically and keep the 500k floor expectation. Finally, with every share also being a block, a share in flight during the stop-after-block shutdown can land one extra block, so the final height check requires at least -- not exactly -- the target. Verified end to end with one miner (PRISM_MIN_READY_MINERS=1): the fresh-ledger collection candidate is submitted solver-pays-all and the run passes through the evidence and verifier stages. Co-Authored-By: Claude Fable 5 <[email protected]>
|
With those fixed, the run passes end-to-end with one miner and One launch-planning note falls out of finding 1: the same IBD gate (coordinator chain-trust plus the ckpool preflight readiness gate) applies to a fresh mainnet — qbitd reports IBD=true whenever the tip is older than ~24h, so if the final mainnet genesis is timestamped well before public launch, no lane will serve work at t=0. Either timestamp the genesis close to launch or plan an explicit bootstrap posture for the first block; worth deciding before the launch runbook is frozen. |
…quirements # Conflicts: # compose.yaml # docker/ckpool/qbit-ckpool-preflight.py # scripts/check-env.sh # tests/test_check_env_production_gate.py # tests/test_qbit_ckpool_preflight.py
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 e230222. Configure here.
…quirements # Conflicts: # .env.example # README.md # compose.yaml # docker/ckpool/qbit-ckpool-preflight.py # docker/ckpool/start-ckpool.sh # tests/test_qbit_ckpool_preflight.py
…ited, not rejected The production gate pinned PRISM_STRATUM_STALE_GRACE_SECONDS=0 on mainnet (coordinator startup, scripts/check-env.sh, scripts/prism-self-check.py). With a zero window every in-flight share on the just-replaced tip is rejected with Stratum error 21 (stale-job / unknown-job) at each block, and miner firmware counts any pool-side error as a reject: "stale" on the miner side is only ever derived client-side, so the only way the pool avoids a reject is to accept the share. That is exactly what the stale-grace credit policy does (ack, ledger with credit_policy=stale-grace, never block-submit), and the classification logic itself was verified against the existing tip-flip tests. Mainnet now follows the same bounded-grace rule as every other production chain (default 3 s; an explicit 0 remains valid). The pin was added in #19 citing audit-bundle v1.1 verifier compatibility; this release's verifier accepts v1.1, and the docs now say to keep external mirrors and verifiers on a release that does too. No hot-path code changes. On this release line the coordinator-side gate lives in lab/prism/coordinator_config.py rather than lab/prism/prism_coordinator.py, and its regression test lives in tests/test_prism_coordinator_config.py. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ited, not rejected (#225) * Stop forcing zero stale grace on mainnet so prior-tip shares are credited, not rejected The production gate pinned PRISM_STRATUM_STALE_GRACE_SECONDS=0 on mainnet (coordinator startup, scripts/check-env.sh, scripts/prism-self-check.py). With a zero window every in-flight share on the just-replaced tip is rejected with Stratum error 21 (stale-job / unknown-job) at each block, and miner firmware counts any pool-side error as a reject: "stale" on the miner side is only ever derived client-side, so the only way the pool avoids a reject is to accept the share. That is exactly what the stale-grace credit policy does (ack, ledger with credit_policy=stale-grace, never block-submit), and the classification logic itself was verified against the existing tip-flip tests. Mainnet now follows the same bounded-grace rule as every other production chain (default 3 s; an explicit 0 remains valid). The pin was added in #19 citing audit-bundle v1.1 verifier compatibility; this release's verifier accepts v1.1, and the docs now say to keep external mirrors and verifiers on a release that does too. No hot-path code changes. On this release line the coordinator-side gate lives in lab/prism/coordinator_config.py rather than lab/prism/prism_coordinator.py, and its regression test lives in tests/test_prism_coordinator_config.py. Co-Authored-By: Claude Fable 5.1 <[email protected]> * check-env: validate the exported stale-grace value instead of dropping the check Restore the ENV_ preservation for PRISM_STRATUM_STALE_GRACE_SECONDS so the doctor validates the value Compose will hand the coordinator rather than the .env.example default, and replace the removed mainnet-only equality check with a lane-level non-negative numeric check that runs in every mode. Without this, an exported value such as "not-a-number" passed the doctor and then crashed the coordinator at startup in env_nonnegative_float(). Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01K8uGJEY2npTQuJPwS9Qg6M * prism-self-check: parse stale grace with the coordinator's float semantics The coordinator accepts any finite non-negative float for PRISM_STRATUM_STALE_GRACE_SECONDS and check-env now validates the same shape, but the self-check still parsed the value with int(), so a valid fractional window such as 0.5 failed `make prism-self-check`. Parse a finite non-negative decimal instead. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01K8uGJEY2npTQuJPwS9Qg6M * Validate stale grace with the coordinator's float conversion in the doctor and self-check A hand-written regex cannot match env_nonnegative_float(): it rejected valid runtime syntax such as 1e-1, .5 and 3., and accepted an integer large enough to overflow to infinity at startup. Both check-env.sh and prism-self-check.py now convert with float() and require a finite, non-negative result, exactly as the coordinator does. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01K8uGJEY2npTQuJPwS9Qg6M * Address the rebase review: doc contradiction, doctor prerequisite, mainnet coverage Four follow-ups from reviewing the rebase against this release line. Docs: the ledger-ops share-accounting paragraph still told auditors to upgrade "before operators enable stale-grace crediting", which contradicts the deployment paragraph in the same document now that the window is on by default. It also, along with two other lines, named the v1.1 bundle schema without saying it is the logical schema; the on-disk body is the v2 container carrying logical_audit_bundle_schema once share segmentation is on. Both are now stated precisely. check-env: validating stale grace with python3 made the interpreter a hard prerequisite for every prism-lane doctor run. Production already required it for the difficulty validation, but lab bring-up did not, and README lists Python 3 only for the unit-test helpers. Keep the hard failure in production and skip the check with a doctor notice otherwise, with a test covering both branches over a python3-free PATH. Tests: the production environment fixtures still pinned the retired zero, so every full-environment production test proved the old contract, and the mainnet positive test asserted only that the old message was gone while its non-zero exit came from unrelated missing inputs. The fixtures now carry the bounded default, and the mainnet test runs a complete production environment and asserts a clean exit for 3, 0.5, and an explicit 0. --------- Co-authored-by: Alex <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]> Co-authored-by: Robert Clarke <[email protected]>

Summary
Validation
python3 -m unittest discover -s tests -p 'test_*.py'(679 tests)cargo test --locked --workspace --all-targetsmake test-prism-postgres-ledgermake test-permissionless(accepted block through CKPool)make test-real-miner(cpuminer accepted block throughckpool:3333)make test-auxpow-stratum(shared real-miner image accepted an AuxPoW block)Note
High Risk
Touches production deployment contracts, ledger durability, block submission outbox, and mainnet/AuxPoW/CKPool readiness gates—errors could affect payouts, share accounting, or pool availability on public chains.
Overview
Introduces a fail-closed production deployment path:
compose.production.yamlpins digest-qualified images, absolute host bind mounts for chain/ledger/audit state, and disables lab-only services;DEPLOY_ENV_FILEand new*_IMAGE/*_DATA_SOURCEenv knobs separate operator deploys from local.env. Mainnet unconditionally enforces release provenance (images, paths, PRISM capacity evidence); other chains can opt in viaQBIT_REQUIRE_RELEASE_PROVENANCE. Docs cover mainnet sequence, Bitcoin tarball SHA256 verification, PRISM capacity qualification, and Postgres WAL/storage recovery.Permissionless mining collapses onto a single
ckpoolon port 3333: the separateckpool-realstack is removed in favor ofreal-miner-smokesharing payout state with ordinary CKPool. CKPool/AuxPoW/PRISM preflight and supervisors tighten chain/genesis identity, explicit production payout addresses, template age bounds, and bounded refresh-failure exits. AuxPoW gains startup readiness checks (IBD, peers, fresh parent templates) and stricter mainnet rules (explicit addresses, no diagnostic header variants).PRISM moves share ACKs to Postgres commit (batch/linger settings), adds
qbit_block_candidate_outboxfor durable block submission after restart, documents collection mode belowPRISM_MIN_READY_MINERS, and validates deployment-matched capacity evidence vialab/prism/capacity_evidence.py. Makefile/CI add lab-mode guards, isolated test compose projects,purge-local-volumeswith confirmation, and Postgres ledger + mainnet compose contract tests.Reviewed by Cursor Bugbot for commit 9d2647d. Bugbot is set up for automated code reviews on this repo. Configure here.