Repository navigation
Stop forcing zero stale grace on mainnet so prior-tip shares are credited, not rejected - #225
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 87b8230a99
ℹ️ 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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf7855eeb3
ℹ️ 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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d508744b32
ℹ️ 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".
…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]>
…g 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
…ntics 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
…octor 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
…innet 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.
94f27b5 to
400a6f5
Compare
Summary
Verifies how PRISM classifies prior-tip shares and lifts the one production pin that turned them into miner-facing rejects.
What was verified (no behavior bug found in the classification itself):
credit_policy=stale-gracewhen the window is open: acknowledgedtrueto the miner, ledgered, counted inqbit_prism_grace_credited_shares_total, and never block-submitted. The window stays open until the connection receives new-tip work and forPRISM_STRATUM_STALE_GRACE_SECONDSafter that delivery; eligibility is exactly one tip back.stale-job/unknown-job, because the buried job context expires immediately).{"result": null, "error": [code, message, {"reason_id": ...}]}. Miner firmware counts any pool-side error as a reject; "stale" on the miner side is only ever derived client-side. The only way the pool avoids a reject is to accept the share, which is what stale grace does.The issue: the production gate (coordinator startup,
scripts/check-env.sh,scripts/prism-self-check.py) forcedPRISM_STRATUM_STALE_GRACE_SECONDS=0on mainnet. So on mainnet every in-flight prior-tip share became an error-21 reject at each ~75 s block. That was introduced in #19 citing audit-bundle v1.1 verifier compatibility; this release's verifier still selects and accepts the v1.1 logical schema (audit_bundle_schema_for_shares,AUDIT_BUNDLE_SCHEMA_V1_1incrates/qbit-prism/src/lib.rs).The change (narrow, no hot-path code touched):
0remains a valid explicit choice).env_nonnegative_float()semantics in both the doctor and the self-check, so a value that passes validation cannot then crash the coordinator at startup. The self-check previously parsed withint(), which rejected a valid fractional window such as0.5..env.examplecomment that described the pin, and note that reward windows containing a credited share publish the logicalqbit.prism.audit-bundle.v1.1schema.Operator note: external mirrors or verifiers that only understand
qbit.prism.audit-bundle.v1must be on a release that accepts v1.1 before a mainnet pool runs with the default window. The in-repo verifier already does.Rebase onto 2.x.x
This branch was authored against
mainand rebased onto2.x.x, which had diverged by 60 commits. Three things moved on this release line and the change was re-landed accordingly:validate_prism_production_gate()now lives inlab/prism/coordinator_config.py(with anenviron=keyword) rather thanlab/prism/prism_coordinator.py.tests/test_prism_coordinator_config.pyrather thantests/test_prism_coordinator_vardiff.py.lab/prism/tip_refresh.py.The one
main-only commit the branch had picked up — "Gate PRISM Postgres test containers on the real server" (#134), already merged tomain— is not part of this change and was dropped.Review follow-ups
An independent review of the rebase raised four items, all addressed in the final commit:
docs/prism-ledger-ops.mdstill told auditors to upgrade "before operators enable stale-grace crediting", contradicting the deployment guidance in the same document now that the window is on by default.python3made the interpreter a hard prerequisite for every prism-lane doctor run; production already required it, but lab bring-up did not. The hard failure is kept in production and the check is skipped with a doctor notice otherwise.3,0.5, and an explicit0.Validation
python3 -m unittest tests.test_check_env_production_gate tests.test_prism_self_check tests.test_prism_coordinator_config tests.test_mainnet_compose_contract tests.test_prism_compose_profile(286 tests)python3 -m unittest discover -s tests -p 'test_*.py'(3173 tests; the only failures are the fivetest_prism_job_builder.ShareWindowSpoolTestscases that needos.splice, which macOS lacks and CI covers on Linux)git ls-files '*.sh' | xargs shellcheck -xandbash -ncleanpython3 -m compileall -q docker lab tests examples scriptsclean