Repository navigation
3.x.x: check legacy carry-forward chains per payout program, as 2.x keeps them, not per case-sensitive label (migration 025) (#708) - #710
Merged
Conversation
…eeps them, not per case-sensitive label (migration 025) (#708) 2.x keeps a miner's carry balance per payout program: qbit_current_carry_forward_balances() sums a program's per-label rows, and the payout policy reads the prior balance by program. Stratum keeps an address as typed and bech32 is case-insensitive, so one program can be paid under an uppercase and a lowercase label. On union one program carries both: 5,527 uppercase rows (heights 11341 to 118151) and 116 lowercase rows (11470 to 12772), one running balance between them. The legacy sequential rule of qbit_carry_forward_integrity_mismatches(), from 001 and kept by 011, sums each (miner_id, payout_order_key, p2mr_program) apart. On the restored union copy it reports 5,506 mismatches, all in that program. Summed per p2mr_program it reports 0 over all 2,753,849 active rows, with no current drift. self-check and fatal-state clear refuse any mismatch, and the recovery summarizer refused the export, so the false alarm blocks the cutover. Migration 025 replaces the validator with 011's body and changes only the legacy rule's window, to PARTITION BY p2mr_program. The marked (as-issued) rule, the report, the per-label summary and its drift check are unchanged, and labels stay as written. 025 changes no stored row and needs no capability or shutdown proof: it is applied in the migration transaction, and an earlier native binary accepts the unknown migration with a warning and reads the corrected report. Because 011 defines the validator 025 replaces, migrate runs 025 again whenever it runs 011, so a record missing 11 but holding 25 cannot bring the label rule back. scripts/prism-recovery-evidence.py re-checks every unmarked active carry row against its program's running chain, from the exported rows. A legacy finding in the database's report is cleared only when 2.x's per-label rule makes it on a row whose program chain holds; any other finding, a real chain break, an as-issued finding, current drift, an incomplete or malformed mismatch list, a malformed amount or out-of-order records fail. The summary keeps the database's report less the cleared findings, so a clean ledger summarizes byte for byte as before, and a 2.x source and its migrated copy summarize alike. A note on stderr names the findings it cleared. Tests: - offer_lifecycle: union's shape (one program, two case labels, interleaved, paid on chain under both) is clean under 025. A ledger at 24 with 011's rule reports 5 of its 7 rows, and migrate clears them with every balance and summary row unchanged. A break under either label is a finding on that row alone, and a changed amount moves the chain under both labels. A #258 record without 11 but with 25 keeps the per-program rule after migrate runs 011 again. - migration_rollback: the same shape on a frozen 2.x source. 2.x's rule reports 5 and the migrated validator 0, the source's and the migrated copy's recovery evidence are equal, balances are unchanged, and a break under either label fails the validator and the summary. - ledger_postgres::fatal_state: self-check passes its integrity gate and fatal-state clear succeeds on the shape; a break under either label stops both. - With 025 reverted to the label rule, the three #708 tests fail; with the 011 rerun guard removed, the #258 test fails. - tests/test_prism_recovery_evidence.py: the per-program chain, real breaks under any label, unexplained and as-issued findings, marked rows, the clean report kept as written, and malformed exports. recovery::seed_legacy gave three miners one program, each starting from zero, which 2.x cannot write. Each now has its own program, and the pinned carry head is recomputed independently. Migration pins, the evidence script's required versions, the undo fixtures, the gated-test list and the ledger-ops and migration docs include 025. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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. |
RobertClarke
added a commit
that referenced
this pull request
Oct 6, 2026
…rade's sidecar and FETCH_COUNT steps, and migrate-before-start From the review of the rc.2 notes: - Known issues now list what opened since rc.1 and isn't fixed here: #716 (a valid share can lose its credit on "commit gate closed" at a tip change; seen on the pair at rc.1), #711 (the order lock across about nine round trips), #712 (85-minute evidence export), #713 (verify-ca checks the host name) and #704 (a drill flake). - Upgrading from 2.0.x adds running the sidecar tool before import-audits and exporting the evidence with FETCH_COUNT. Upgrading from rc.1 says to run migrate first, because an rc.2 frontend refuses a database without 025. - #708's bullet says #710 also changes the evidence summarizer, which must be this candidate's on both sides of a cutover, and puts #710 next to the fix, not the refusal. - #600's fix (#627) was already in rc.1. The carried-over soak passed every gate, and its job failed only on the tripwire #714 removed. faults-long-real-node is not re-run here. - docs/prism-e2e-load-ci.md's example tag reads v3.0.0-rc.1. Co-Authored-By: Claude Opus 5.5 <[email protected]>
RobertClarke
added a commit
that referenced
this pull request
Oct 6, 2026
Set VERSION and [workspace.package].version to 3.0.0-rc.2: rc.1 plus migration 025 (#708, #710) and the legacy-audit-body sidecar tool (#715). Cargo.lock and the fuzz crate's lock move only their workspace-member entries. doc/release-notes-3.0.0-rc.2.md covers: - the changes since rc.1: 025's per-program carry-forward rule, the canonical sidecars for escaped legacy range digests, FETCH_COUNT for the recovery evidence (#706), and the harness and CI fixes; - upgrading from 2.0.x and from rc.1; - the lean verification, since the only runtime change is 025; - the known issues. The development-line notes name 3.0.0-rc.2 as the tree's identity, and they and the 3.0.0 notes link both candidates' notes. U3 wrote the change lines. Co-Authored-By: Claude Opus 5.5 <[email protected]>
RobertClarke
added a commit
that referenced
this pull request
Oct 6, 2026
…rade's sidecar and FETCH_COUNT steps, and migrate-before-start From the review of the rc.2 notes: - Known issues now list what opened since rc.1 and isn't fixed here: #716 (a valid share can lose its credit on "commit gate closed" at a tip change; seen on the pair at rc.1), #711 (the order lock across about nine round trips), #712 (85-minute evidence export), #713 (verify-ca checks the host name) and #704 (a drill flake). - Upgrading from 2.0.x adds running the sidecar tool before import-audits and exporting the evidence with FETCH_COUNT. Upgrading from rc.1 says to run migrate first, because an rc.2 frontend refuses a database without 025. - #708's bullet says #710 also changes the evidence summarizer, which must be this candidate's on both sides of a cutover, and puts #710 next to the fix, not the refusal. - #600's fix (#627) was already in rc.1. The carried-over soak passed every gate, and its job failed only on the tripwire #714 removed. faults-long-real-node is not re-run here. - docs/prism-e2e-load-ci.md's example tag reads v3.0.0-rc.1. Co-Authored-By: Claude Opus 5.5 <[email protected]>
RobertClarke
added a commit
that referenced
this pull request
Oct 6, 2026
Set VERSION and [workspace.package].version to 3.0.0-rc.2: rc.1 plus migration 025 (#708, #710), #718's commit-gate answer for #716, and the legacy-audit-body sidecar tool (#715). Both Cargo.lock files move only their workspace-member entries. doc/release-notes-3.0.0-rc.2.md covers: - the changes since rc.1 (U3's lines, and #716 fix A in the coordinator's words); - upgrading from 2.0.x (the sidecar tool and FETCH_COUNT) and from rc.1 (migrate before any rc.2 frontend starts); - the lean verification, since the runtime changes are 025 and #718; - the known issues, including #711, #712, #713 and #704. The development-line notes name 3.0.0-rc.2 as the tree's identity, they and the 3.0.0 notes link both candidates' notes, and a doc example's tag reads v3.0.0-rc.1. L3 run 37444397320 (l3-full) measured this tree. 32 of 33 runs passed. throughput-400k-window-2fe-async-3-blocks-r2 refused one valid share at the commit gate (#716's open part, answered backend-rpc-unavailable), and the coordinator carried that verdict as a named exception. Co-Authored-By: Claude Opus 5.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.
Fixes #708 (close by hand: base is not the default branch)
Problem
qbit_carry_forward_integrity_report()reports 5,506 mismatches on union's restored ledger (current_drift_count0, 2,753,849 active carry rows). All of them are in one payout program, which carries two spellings of one bech32 address: uppercase on 5,527 rows (heights 11341 to 118151) and lowercase on 116 rows (11470 to 12772).The money is right. 2.x keeps a carry balance per payout program:
qbit_current_carry_forward_balances()groups byp2mr_program, and the payout policy reads the prior balance by program. 3.x's native writer reads the same function. The legacy sequential rule ofqbit_carry_forward_integrity_mismatches()(001, kept by 011) instead sums each(miner_id, payout_order_key, p2mr_program)apart, so each label looks like a chain missing the other label's balance. Run read-only over the restored copy, the same rule partitioned byp2mr_programalone finds 0 mismatches over all 2,753,849 active rows.Refused while
mismatch_count > 0, and unblocked by this change:self-check(tools.rs:1866-1880), so every pre-admission and cutover gate;fatal-state clear(ledger/fatal_state.rs:253-261);scripts/prism-recovery-evidence.py, so the C1/C3 evidencecmp./audit/carry-forward-integrity(api.rs:981) only reports; it now reports the corrected count.Change
Migration 025 (
025_carry_forward_integrity_by_program.sql) replaces the validator with 011's body. Against 011's definition, the only change is the legacy rule's window:The marked (as-issued) rule, the report, the per-label summary and
qbit_carry_forward_current_drift()are unchanged. Labels stay as written, since the signed as-issued manifests and the summary name them.Upgrade. 025 changes no stored row, so it is a plain in-transaction migration: no capability and no shutdown proof. An earlier native binary, rc.1 included, accepts the unknown migration with a warning (
require_schema_version, #321) and keeps starting; it reads the corrected report. Because 011 defines the validator that 025 replaces,migrateruns 025 again whenever it runs 011. So a record missing 11 but holding 25 cannot bring the label rule back.Recovery summarizer.
scripts/prism-recovery-evidence.pyre-checks every unmarked active carry row against its program's running chain, from the exported rows.note:on stderr names the findings it cleared.Fixture.
recovery::seed_legacygave three miners one program, each chain starting from zero, which 2.x cannot write. Each miner now has its own program, and the pinned carry head was recomputed independently, from the rows written out by hand.Plumbing:
REQUIRED_SCHEMA_VERSIONS,NATIVE_MIGRATIONSand themigrate_schemablock;required_versions;ledger_2x::undo_006;prism-ledger-ops.mdandprism-rust-migration.md.Tests
The new PostgreSQL tests use union's shape (
tests/support/case_labels.rs): one program under two case labels, interleaved over seven blocks, paid on chain under both.offer_lifecycle::integrity_validator_follows_a_legacy_chain_per_payout_program_across_case_labels:migrateclears them with every balance and per-label summary row unchanged;offer_lifecycle::migration_025_runs_again_after_011_runs: a v2.0.2 fix: bound candidate replay and audit finalization #258 record without 11 but with 25 keeps the per-program rule aftermigrateruns 011 again.migration_rollback::a_2x_program_paid_under_case_labels_migrates_clean_and_summarizes_as_its_source, on a frozen 2.x source:recovery::evidenceof the source and of the migrated copy are equal;qbit_current_carry_forward_balances()is unchanged;ledger_postgres::fatal_state::self_check_and_clear_accept_a_programs_legacy_chain_across_case_labels:self-checkpasses its integrity gate andfatal-state clearsucceeds; a break under either label stops both.mismatch_count5, which is the false alarm. With the 011-rerun guard removed, the v2.0.2 fix: bound candidate replay and audit finalization #258 test fails.tests/test_prism_recovery_evidence.py(16 tests): the per-program chain, real breaks under any label, unexplained and as-issued findings, marked rows, the clean report kept as written, and malformed exports.Local run, on a private PostgreSQL 16:
--liband everytests/*.rsbutlive_regtest,--test-threads=6): 1,930 passed and 3 failed. The 3 failures are environmental, and each passes on rerun:compact_runtime_observertests hitcanceling statement due to lock timeoutunder the suite's load. The binary passes 25/25 alone, with 1 thread and with 6.public_database_config::direct_public_binary_authenticates_only_with_effective_reader_credentialsfailed because my cluster had trust auth, so a login with no password succeeded. It passes 5/5 once pg_hba requires scram, as CI's PostgreSQL does.cargo clippy --locked --workspace --all-targets -- -D warnings: clean.cargo fmt --all --check: clean.python3 -m unittest tests.test_prism_recovery_evidence: 16/16 passed.Read-only check for the restored copy
This is 025's legacy rule as a standalone query. On a
2.x.xcopy every block is unmarked, so every active row is legacy. Expectlegacy_mismatch_count0 andchecked_active_rows2753849:Do not merge: 3.x.x waits for the
v3.0.0-rc.1tag and the coordinator's go after reading the SQL diff.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.