Skip to content

3.x.x: run #521's chain-event scenarios under 2,000 Stratum sessions, and add tip-disagreement, peer-loss and external-tip scenarios (#553) - #618

Merged
djh58 merged 6 commits into
3.x.xfrom
djh58/prism-b553-chain-events2
Sep 30, 2026
Merged

djh58 merged 6 commits into
3.x.xfrom
djh58/prism-b553-chain-events2

Conversation

@djh58

@djh58 djh58 commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Refs #553 (#487 S15, L4). Test-only: no server or harness code changes.

What

#521's fixtures run unchanged under session load (#487 decision 12). Each case opens the fixture as its own test does, starts a session load against the fixture's frontends, and calls the scenario's own function. The live_regtest support files change only in visibility and in the additive support listed below.

The load, tests/support/live_session_load.rs

  • 2,000 Stratum sessions (D1's count) offer a fixed share rate. Each has a home frontend and fails over to the next ready one, as a pool's miners do. First connections are spread over 10 s from the first ready frontend.
  • Every proof is a share that misses its job's block target, so the load never finds a block and never changes which own blocks a scenario has.
  • The frontends run 3.x.x: pre-release test gaps (cutover rehearsal, soak, real miners, fuzzing, resource exhaustion) #575's share-only settings (vardiff off, 2^-32 share difficulty). A load share therefore weighs almost nothing in the window, and the scenarios' economics are unchanged. They also run the production 60 s reanchor.
  • Every tip of every watched node is stamped with a waitfornewblock long-poll, and each frontend's /healthz is sampled.

The load adds three checks of its own:

  • every acknowledged share is a durable ledger row, no refused share is one, and every durable row was acknowledged or has an unknown answer. ledger-outcome-unknown counts as unknown, because its share may still land;
  • every refusal is one a correct miner can earn, from an allow-list (the harness's expected and backend classes). An impossible refusal (duplicate, low-difficulty, unauthorized, any invalid-*) fails, and so does one nobody has classified yet;
  • every session on a frontend gets work on each tip that lasts 15 s within 15 s (PRISM: an orphaned own block stalls job delivery for ~300 s on every lost tip race #413's condition, the two-node scenarios' NOTIFY_BOUND). This applies when the frontend's node answered throughout and the frontend reported itself ready when the bound expired. A frontend fences its health for about 2 s after each tip, so readiness is read at expiry.

It reports #481's time to usable work per frontend and per tip, from the node's stamp to each session's first notify on that parent. A tip replaced before a session got it is counted as replaced, not as zero. Every notify is recorded, so work on a parent a session held before still serves that tip after a reorg back. The report is one live-load <case>: {json} line in the test log.

The whole load is present at each scenario's first event. #521's scenarios start their own servers, and their first events follow within seconds. So server_ready waits on a ready gate that the load installs while it runs (99% of sessions holding work), and scenario 4's case takes a ready hook before its first block. Before this, scenario 1's race came with 42 of 2,000 sessions connected, and scenario 4's fault with about 1,350.

The cases, tests/support/live_chain_events_load.rs

Case Set What it asserts
#521 scenario 1, lost race nightly #521's assertions, plus the load's checks
#521 scenario 2, deep reorg nightly the same
#521 scenario 4, killed after accepting nightly the same
#521 scenario 4, the other four cases weekly the same, at 400 shares/s
#521 scenario 5, dense soak (20 min) weekly the same, and every frontend holds at least one tip to the bound
Two frontends on two nodes disagree about the tip nightly Propagation lag, then a partitioned split at equal work. The ledger takes one side's tip, the other side's frontend reports itself unready and gives no session work on its node's tip, no payout divergence or duplicate header follows, and after convergence every session on both frontends has work within 15 s
The node loses its only peer nightly Regtest exempts the peer floor (readiness.rs; readiness_rpc.rs pins both sides), so the case is an isolated node. The pool's own block there is deactivated when the node reorganizes onto its peer's chain and credited exactly once, with no divergence or duplicate header. Every session gets work on the isolated block within 15 s, and on the healed chain
External tips at the 60 s target spacing nightly 5 min, weekly 45 min at 400/s Seeded exponential gaps, so about 1 in 10 is under 6 s (#481's replaced-tip case). Every lasting tip reaches every session on both frontends within 15 s, at least one tip per frontend is held to the bound, and time to usable work is reported per frontend
#598's guard: 2,000 sessions on one frontend at the fixture's 1 s reanchor nightly Each of three external tips, 20 s apart, at 5 shares/s (#598's reproducer rate) reaches every session within 15 s

After scenarios 1, 2 and 4, one more tip is mined and the bound is waited out, so every frontend still serving sessions is held to the bound at least once. A scenario often ends seconds after its last tip.

Not in a lane: #521 scenario 7 at 2,000 wallets. wallets_2000_share_to_spend_starves_first_jobs_until_604_is_fixed stays as an #[ignore] case for running by hand, and wallets-2000-cap stays unexercised. In debug it is #604's expected failure: the fixture opens its ~3,000 worker sessions one at a time, and at its 1 s reanchor first jobs queue behind same-tip rebuilds. It counts as #604 only once at least 100 sessions opened, and the wallet fixture's error now says how many had. In release, which the weekly job builds, every session opens, and then a later round's new tip reaches some worker late while both frontends defer job preparation with tip polling stale (#622, 3 of 3 runs).

Found

Shared support touched (additive or visibility only)

  • live_two_node.rs, live_dense_soak.rs, live_weighted_recipients.rs: pub(super) on the scenario functions and helpers used here; the atomic header count above.
  • live_two_node.rs: READY_GATE, which server_ready waits on once the server is ready, and only while a load installs one. It is None otherwise, so every existing caller behaves as before.
  • live_node_outage.rs: outage_case_on. It is outage_case on a caller's fixture, with a ready hook before the first block and an after hook while the servers still reach the node through the proxy; outage_case passes no-ops.
  • live_share_client.rs: solve_share, the existing solver fixed to a share-only proof.
  • live_weighted_recipients.rs: the connection limit is raised above the default only when a case has more workers than it (the 2,000-wallet case), and a session that fails to open says how many had opened. The per-PR and nightly cases start with exactly the settings they had.

Tests and mutants

Local runs used a private PostgreSQL 16 (fsync on) and the pinned qbit, on this code over current 3.x.x (with #616 and #617).

Nightly case (debug) Wall time Worst all-session time to usable work (fe0 / fe1)
#598's guard 77 s 3.8 s
scenario 1 72 s 3.6 s / —
scenario 2 88 s 4.0 s / 3.0 s
scenario 4, killed after accepting 43 s 1.0 s / 2.0 s
node loses its peer 67 s 1.0 s / 1.1 s
two frontends disagree 100 s 0.9 s / 0.9 s
external tips, 5 min 330 s 0.8 s / 0.8 s

All seven passed, about 13 minutes in total, and check_gate_manifest.py proved each executed. After merging 3.x.x into this branch, the guard, scenario 1, scenario 4's crash case and the peer-loss case passed again (78, 73, 48 and 67 s), again proven executed.

The weekly set ran in release, as live-weekly builds it: scenario 4's other four cases passed (40–57 s each), and the soak passed at 5 minutes rather than 20 to fit the shared test host. The 45-minute external tips were not rerun in full locally (the first commit's 8-minute run passed); the full-length soak and external tips run first in CI.

Mutants and negative checks, local only:

cargo fmt --all --check and cargo clippy -p qbit-prism-server --all-targets -- -D warnings are clean. scripts/check_e2e_scenarios.py passes, and so do tests.test_check_e2e_scenarios and tests.test_check_gate_manifest.

Review fixes

Review of the second commit (the ledger comment lists every finding) led to a third:

  • Work a session got before a tip's stamp counts only while it still held that work at the stamp. Before this, a republication on X after the next tip Y, followed by Y itself, could count as work on X when the node returned to X. A unit test fails on the old lookup.
  • The report adds held_tips: gated tips that lasted the bound, so a session can't be counted as replaced on them. The "at least one tip held to the bound" checks and 3.x.x: job delivery starves when publications outpace one fan-out (payout snapshot stale livelock) #598's guard use it, and the weekly soak ends on a closing tip.
  • The one refusal without a reason_id a correct load can earn, the unknown-job budget, is matched on its code and exact message, as the harness does.

After it, all seven nightly cases and a 60 s soak passed again, each proven executed. After merging 3.x.x (#607's direct-settlement recipients), the weighted-recipients per-PR, nightly and 1,001-recipient cases and #598's guard passed. The CI lane guide (#612) now describes L4 under session load.

CI cost

  • Per PR: about 0. The helper's unit tests run in under 10 ms, the checker's in under 0.1 s, and nothing else runs per PR.
  • Nightly: the seven ids join test/prism-nightly-gated-tests.txt, which live-nightly (8 vCPU, debug) already runs. That adds about 13 minutes locally on 22 cores, likely more on 8 vCPU, to a job that took 21 minutes on 09-30 and has a 60-minute timeout.
  • Weekly: the six ids join test/prism-weekly-gated-tests.txt and add about 75 minutes (45 of external tips, a 20-minute soak, four shorter cases) to live-weekly. This PR raises that job's timeout from 120 to 180 minutes.

Manifest

scripts/check_e2e_scenarios.py now reads test/prism-weekly-gated-tests.txt. An id there runs in the weekly lane (#588's), whose wiring now also needs the live-weekly schedule and its gate-manifest step. Every weekly id must be named by a running scenario, as for the nightly list, and each rule has unit tests. test/e2e-scenarios.toml:

Not merge-blocking: nothing here runs per PR.

🤖 Generated with Claude Code

… and add tip-disagreement, peer-loss and external-tip scenarios (#553)

#487 S15 (L4). #521's fixtures run unchanged under load: each case
opens the fixture as its own test does, starts a session load against
its frontends, and calls the scenario's own function (decision 12).

- live_session_load.rs: 2,000 Stratum sessions that fail over between
  frontends and submit share-only proofs at a fixed rate, so the load
  never finds a block. It stamps every node tip with a waitfornewblock
  long-poll and checks three things: every acknowledged share is a
  durable row and no refused share is; no refusal a correct miner
  cannot earn; every session gets work on every lasting tip within
  15 s while its node answers and its frontend is ready. It reports
  #481's time to usable work per frontend and per tip.
- live_chain_events_load.rs, nightly: scenarios 1 and 2, scenario 4's
  crash after acceptance, and three new scenarios with their criteria.
  Two frontends on two nodes disagree about the tip: the ledger takes
  one side, and the other frontend stands down with no work on its
  node's tip. The pool's node loses its only peer: regtest exempts the
  peer floor, so the isolated own block is deactivated and credited
  once. External tips come at the 60 s target spacing. Weekly: the
  other scenario-4 cases, the soak, 45 minutes of external tips at
  400 shares/s, and two expected failures: 2,000 sessions on one
  frontend at a 1 s reanchor (#598) and scenario 7 at 2,000 wallets
  (#604).
- Load frontends use the production 60 s reanchor. At the fixture's
  1 s, 2,000 sessions on one frontend get no work (#598).
- check_e2e_scenarios.py: ids in test/prism-weekly-gated-tests.txt run
  in the weekly lane, which now also needs the live-weekly job's
  schedule and gate-manifest step, and every weekly id must be named by
  a running scenario, as for the nightly list. The manifest cites every
  weekly id, #545's and #575's included, and each expected failure has
  its own scenario owned by its issue.
- live-weekly's timeout goes from 120 to 180 min for the long set,
  about 85 minutes.
- Shared support changes: pub(super) on scenario functions,
  outage_case_on, solve_share, the 2,000-wallet connection limit, and
  assert_no_duplicate_headers reading its two counts in one statement
  (under load, shares landed between them).

Refs #553

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@djh58
djh58 requested a review from kiwidream September 30, 2026 18:47
djh58 and others added 5 commits September 30, 2026 16:39
… of expecting its failure weekly (#553)

Review of the first commit found checks weaker than the manifest claims,
and #616 has since fixed #598.

- Scenarios 1, 2 and 4 now reach their first event under the whole
  load. #521's server_ready waits on a ready gate that the load
  installs (99% of sessions holding work), and scenario 4's case takes
  a `ready` hook before its first block. Before this, scenario 1's
  race came with 42 of 2,000 sessions connected and scenario 4's fault
  with about 1,350.
- Sessions spread their first connections from the first ready
  frontend, not from the load's start.
- The load records every notify, so work on a parent a session held
  before still serves that tip after a reorg back.
- Refusals are an allow-list (the harness's expected and backend
  classes). An impossible or unclassified refusal fails, and
  ledger-outcome-unknown counts as unanswered, since its share may
  land.
- External tips and the weekly soak hold at least one tip per frontend
  to the bound. The peer-loss case holds the isolated block itself to
  it on every session.
- The 1 s-reanchor case becomes #598's nightly guard at 5 shares/s,
  #598's reproducer rate: each of three tips must reach all 2,000
  sessions on the one frontend within 15 s. It fails before #616 and
  passes after it. It runs nightly because live-nightly builds debug;
  in release the fan-out outruns a 1 s reanchor even without the fix.
- The 2,000-wallet case leaves the weekly list, since in release (the
  weekly job's build) it fails on #622 rather than #604. It stays an
  ignored case for running by hand, counting as #604 only once at
  least 100 sessions opened; the wallet fixture's error now says how
  many had. wallets-2000-cap stays unexercised, naming #604 and #622,
  and the expected-failure scenarios go.
- The load soak validates its duration and budget as #521's does, and
  the load settings reuse the soak's env reader.
- live-nightly's and live-weekly's comments name the jobs they run.

Refs #553

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he bound, and match the untyped refusal exactly (#553)

Review of the second commit found two checks that could pass without
holding what they claim.

- Since the load records every notify, a republication on a parent
  after the next tip's stamp could count as work on that parent when
  the node returned to it, although the session had moved to the next
  tip's work in between. Work before a stamp now counts only while the
  session still held it at the stamp: its last run of notifies on the
  tip, from after the node's previous tip. A new unit test fails on
  the old lookup.
- "At least one tip held to the bound" counted gated tips, and a gated
  tip replaced within 15 s can only count sessions as replaced. The
  report adds held_tips (gated and lasting the bound), which the
  external-tips, soak, scenario 1, 2 and 4 checks and #598's guard now
  use; the soak ends on a closing tip, since its own blocks come seconds
  apart.
- The one refusal without a reason_id a correct load can earn is the
  unknown-job budget, now matched on its code and exact message as the
  harness does. "too many connections" is an authorize-time error and
  never reaches the submit counts.
- The manifest's criteria say what the load checks: the refusal
  allow-list, and every session holding work in #598's guard. Stale
  comments are fixed, and until_connected reuses holding.

Refs #553

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolves live_weighted_recipients.rs against #607: its Policy, Payees and
the ctv and wallets fields stay, with #553's visibility, the opened-count
context and the connection-limit raise. The raise moves to
start_servers_for, so #607's 1,001-recipient case keeps start_servers as
it was, and #553's 2,000-wallet shape takes ctv and 8 wallets like the
other CTV shapes.
… guide (#553)

#612's lane guide still listed #553's scenarios as not yet running. L4
now names the nightly and weekly sets, the load's own checks and #598's
guard, and keeps only the 2,000-wallet case, on #604 and #622, as not
proven.

Refs #553

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@djh58

djh58 commented Sep 30, 2026

Copy link
Copy Markdown
Member Author

Review ledger: commit 2 (5fdcf6d) and its review fixes (b6ad808)

Two local lanes reviewed the second commit: /code-review high (10 findings) and an adversarial Opus review (6 findings, 2 duplicates of the first). No blockers. There were no bot or human review comments on the PR when this was posted.

# Source Finding Disposition
1 code-review, adversarial Recording every notify let a republication on parent X after the next tip Y's stamp count as work on X when the node returned to X, although the session had moved to Y's work in between. A missed delivery on a reorg back could pass. Fixed in b6ad808. served_at counts work before the stamp only while the session still held it at the stamp: its last run of notifies on the tip, from after the previous tip. The new unit test work_the_session_moved_off_before_a_reorg_back_does_not_serve_it fails on the old lookup.
2 adversarial held_to_the_bound counted gated tips, and a gated tip replaced within 15 s can only count sessions as replaced. In the soak, whose blocks come seconds apart, "one tip held to the bound" could pass without one. Fixed in b6ad808. The report adds held_tips (gated and lasting the bound). held_to_the_bound and #598's guard use it, and the soak ends on a closing tip. A 60 s soak held 1 tip on each frontend.
3 code-review The untyped refusal allow-list matched substrings, looser than the harness's is_unknown_job_budget. Fixed in b6ad808. It now matches code 20 and the exact message. "too many connections" is dropped: it is an authorize-time error and never reaches the submit counts.
4 code-review The Connection::parents doc still described deduplicated notifies. Fixed in b6ad808.
5 code-review holding and until_connected each computed the threshold. Fixed in b6ad808. until_connected polls holding.
6 code-review deliveries() scans every notify for each tip. Fixed in part. The pre-stamp lookup uses partition_point on the time-sorted notifies. The rest is linear. A 5-minute soak case at 400 shares/s (release) took 315 s including setup and the check.
7 adversarial The chain-events criteria still said "no impossible refusal"; #598's guard criteria said "every one of 2,000 sessions". Fixed in b6ad808. They now name the allow-list and the sessions holding work.
8 adversarial The peer-loss comment said "whatever the load's check gated", but the assertion requires gated. Fixed in b6ad808.
9 code-review READY_GATE is process-global state in the shared server_ready; a ready parameter, as outage_case_on has, would avoid it. Rejected. lost_race and deep_reorg are #521's scenario functions and call server_ready themselves. Decision 12 keeps their bodies unchanged, and a parameter would change their signatures and every #521 caller. The gate is RAII-cleared on error or panic. Only ignored cases install it, and both live jobs run --test-threads=1.
10 code-review live-nightly keeps its 60-minute timeout on 8 vCPU. Deferred to the first nightly. The last scheduled run took 21.5 minutes, and the chain-event set takes about 13 minutes on 22 cores. If a nightly passes 45 minutes, the set is split.
11 code-review #598's guard was calibrated on a faster host, and PRISM_L4_SHARE_RATE overrides its rate. Deferred / rejected. The worst all-session time was 4.0 s locally against the 15 s bound; the first nightly on 8 vCPU confirms the margin. The rate override is a documented local knob that no workflow sets.
12 code-review Hand-copied allow-list instead of calling classify. Rejected. qbit-prism-load depends on qbit-prism-server, so the server's tests can't depend on it without a cycle. The list is pinned by only_refusals_a_correct_miner_can_earn_are_expected.
13 code-review The soak's duration and budget validation copies live_dense_soak.rs. Rejected. It is eight lines mirroring #521's rules, and sharing it would mean another edit to #521's support file.
14 code-review The live-weekly comment's "about 75 minutes, measured in debug" sizes a release job. Rejected. The time is dominated by fixed-duration phases (45 minutes of tips, a 20-minute soak), and a release build only shortens the rest, so the debug figure is an upper bound.

After the fixes, all seven nightly chain-event cases passed again in debug (guard 84 s, deep reorg 85 s, external tips 331 s, lost race 71 s, killed after accepting 43 s, peer loss 67 s, two frontends 100 s), as did the soak at 60 s. check_gate_manifest.py proved each executed. fmt, clippy -D warnings and check_e2e_scenarios.py are clean.

Since then, 3.x.x is merged in (c9e371a), resolving live_weighted_recipients.rs against #607. #607's direct-settlement fields and payee wallets stay, and #553's connection-limit raise moves to start_servers_for, so #607's 1,001-recipient case is unchanged. The weighted-recipients per-PR cases (direct and fanout), the nightly mainnet-floor and 1,001-recipient cases and #598's guard passed on the merge. 791b7c1 updates #612's CI lane guide for L4 under session load. CI is green on 791b7c1.

@djh58
djh58 merged commit 1bcc8f6 into 3.x.x Sep 30, 2026
30 checks passed
RobertClarke added a commit that referenced this pull request Oct 6, 2026
#551, #553, #554, #582)

The file is 3.x.x's copy byte for byte again, as of 3.x.x c95febb; the
last change to it there is bd1ddeb (#663). Since 1932cb3 (#597), five
3.x.x changes landed in it:

- #552 (#613): the `bridging` job runs the short plan on the fake and
  the real node on one runner, nightly, on the run-load label and on a
  dispatch with the new `bridging` input.
- #551 (#606): every preset job builds a trend row; on a schedule the
  `evidence` job (the one job with `contents: write`) appends the rows to
  the orphan `ci-evidence` branch, applies the report-only regression
  rule, promotes the soak's and flagged runs' bundles to the rolling
  `ci-evidence/YYYY-MM` pre-release, and keeps one
  `prism-load-regression` issue. PR and dispatch runs get the read-only
  `evidence-preview` instead.
- #553 (#618): the live nightly and weekly lists gain the chain-event
  scenarios under 2,000 sessions; the workflow's comments say so.
- #554 (#635): the run job installs fuse2fs and fuse3 for a preset whose
  faults fill the WAL volume (faults-long-real-node, Saturday).
- #582 (#663): comment only.

Without this, main's scheduled copy (#595) still has no qbitd install
step, so every `--node qbitd` preset fails with "--node qbitd needs
--qbitd-bin or QBITD_BIN" (scheduled runs 37188928798 and 37287515779).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Anatolie added a commit that referenced this pull request Oct 16, 2026
 (#590, #596, #588, #597, #552, #551, #553, #554) (#601)

* main: sync the PRISM load-harness nightly workflow from 3.x.x (#590, #596)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* main: sync the PRISM load-harness nightly workflow from 3.x.x (#590, #596, #588, #597)

Adds #588's Saturday 5.5 h soak schedule and its live-nightly step that runs every listed test binary, so qbit-prism-load::soak_smoke runs beside the live_regtest variants, and #597's L6 shipped-images lane on the Sunday schedule. Byte-identical to 3.x.x at 1932cb3.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* main: re-sync the PRISM load-harness nightly workflow from 3.x.x (#552, #551, #553, #554, #582)

The file is 3.x.x's copy byte for byte again, as of 3.x.x c95febb; the
last change to it there is bd1ddeb (#663). Since 1932cb3 (#597), five
3.x.x changes landed in it:

- #552 (#613): the `bridging` job runs the short plan on the fake and
  the real node on one runner, nightly, on the run-load label and on a
  dispatch with the new `bridging` input.
- #551 (#606): every preset job builds a trend row; on a schedule the
  `evidence` job (the one job with `contents: write`) appends the rows to
  the orphan `ci-evidence` branch, applies the report-only regression
  rule, promotes the soak's and flagged runs' bundles to the rolling
  `ci-evidence/YYYY-MM` pre-release, and keeps one
  `prism-load-regression` issue. PR and dispatch runs get the read-only
  `evidence-preview` instead.
- #553 (#618): the live nightly and weekly lists gain the chain-event
  scenarios under 2,000 sessions; the workflow's comments say so.
- #554 (#635): the run job installs fuse2fs and fuse3 for a preset whose
  faults fill the WAL volume (faults-long-real-node, Saturday).
- #582 (#663): comment only.

Without this, main's scheduled copy (#595) still has no qbitd install
step, so every `--node qbitd` preset fails with "--node qbitd needs
--qbitd-bin or QBITD_BIN" (scheduled runs 37188928798 and 37287515779).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Robert Clarke <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant