Skip to content

3.x.x: drive a real regtest qbitd from qbit-prism-load, ramped to the fake node's difficulty and reconciled against the chain (#547) - #590

Merged
djh58 merged 2 commits into
3.x.xfrom
djh58/prism-b547-real-node
Sep 29, 2026
Merged

djh58 merged 2 commits into
3.x.xfrom
djh58/prism-b547-real-node

Conversation

@djh58

@djh58 djh58 commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Closes #547 (#487 S8). This extends the existing load harness to drive a real regtest qbitd, following the design note agreed on #547. There is no new load generator and no server change.

What it does

--node qbitd (default fake) and the operational --qbitd-bin (default QBITD_BIN) run the same phases, share reconciliation and exit codes against a managed pair of regtest nodes:

  • Topology. Pool node A (-listen=0) is reached by the frontends through a recording JSON-RPC relay. Peer B (-listen=1), which A connects to as 3.x.x: live two-node regtest scenarios for a lost same-height race and a deep reorg with own blocks on both branches (#521 scenarios 1 and 2) #530's PeerNode does, mints every external tip with generatetoaddress. Both use the live_regtest launcher's arguments plus -legacyretarget. PRISM_MIN_PEERS=1 is met by a real peer, and the frontends get QBIT_CHAIN=regtest.
  • Ramp. The chain is ramped as 3.x.x: follow weighted multi-address shares to spent outputs on a live regtest node (#521 scenario 7) #524 does. On qbit regtest, epochs are 1,440 blocks, each clamped to 4×. Eight retargets reach 1e7fffc0 at height 12,960, which is the fake node's 1e7fffff to within 0.0008%, so the window, share difficulty and hashes per share match the fake run. The ramp took 25–40 s on a loaded host.
  • Clock traps, measured on qbit 1.0.0.
    • qbit refuses a block about 10 min ahead of its clock, so the ramp's shared mock clock ends at wall time.
    • A template more than 150 s after the tip is served at the regtest limit. After the ramp the clocks are cleared, and B mints a keepalive once the tip's own timestamp is 120 s old. It keys on the tip's timestamp, not on when the tip was seen, because a pool block carries its job's template time.
    • The 1,439 blocks before the next retarget are headroom, checked at entry.
  • Cadence band. A share is a block with probability 8 / window whatever the ramp, so a phase at R shares/s implies an own block every W / (8R) s. Real-node mode refuses a phase outside 9–600 s. The report's node.cadence_band states the band, each phase's interval, and how many block solutions the miners stepped over against how many were expected. --plan short at its defaults implies one own block every 50 s.
  • Node-reported, not assumed.
    • A watcher on A stamps every tip change with a waitfornewblock long-poll that is given the last tip, then walks the heights so no block is skipped.
    • The relay records each submitblock with the node's verdict verbatim, in the fake node's submission shape, so the dense-cadence and landing reports read it unchanged.
    • After the load, the run checks that every block above the ramp is exactly one peer mint or one accepted submission, that it is on A's active chain and carries the ramped bits, and that every template kept those bits.
  • Contract unchanged.

Fake-node mode is unchanged

  • The fake path is not edited. Presets gain "--node": "fake"; that one line is their only change.
  • fake_node_mode_is_unchanged (an ordinary test, needing nothing) compares against goldens taken on the base commit: the fake node's answers to a fixed RPC corpus (plain and retargeting) and a pr-smoke frontend's launch environment.
  • load_smoke also checks the side report's top-level, versions, topology, window and node key sets against a golden.

One harness behaviour changed outside real-node mode: under --plan tips, --scheduled-blocks is now scheduled in warm-up, the plan's only phase. Before, it silently scheduled none. No checked-in preset combined the two.

Tests

Test What Per-PR CI cost
real_node::real_node_smoke_reconciles_against_postgres_and_the_chain (gated: QBITD_BIN, PRISM_TEST_PG_BIN_DIR) The real-node-smoke preset: 1 debug frontend, 50 sessions, 20 shares/s over 20k, 3 peer tips and 1 own block in a tips plan. It checks exit 0, the chain reconciliation (1 pool block and 3 or more external blocks), every template at 1e7fffc0, every session served on every tip, and that the cadence band is stated ~85–105 s wall on its shard: 65–70 s run (ramp ~28 s) plus ~20 s debug server build
real_node::fake_node_mode_is_unchanged Fake RPC transcript and launch environment against the goldens <1 s
load_smoke (existing) Now also checks the side report key-set golden 0

The gated id is listed in test/prism-gated-tests.txt. test/e2e-scenarios.toml gains real-node-harness-smoke (pr) and real-node-short-plan-pair (nightly), and bridging-fake-and-real-node now points at the pair.

Mutants, each run against the gated test file:

  • The relay drops its submission record: the smoke exits 8 ("block … is neither one of the peer's mints nor one accepted relay submission") and the test fails.
  • The minter records the wrong hash: 3 unattributed blocks, exit 8, and the test fails.
  • The fake node's chainwork steps by 2: fake_node_mode_is_unchanged fails at /0/answers/20/result/chainwork.

--plan short against the real node (short-plan-real-node, release binaries, clean tree, loaded 2 vCPU-class host):

  • Exit 0, reconciled exactly, and the gate passes.
  • Chain reconciled: 1 pool block and 4 external blocks (3 warm-up tips and 1 keepalive in slow_database), all at 1e7fffc0.
  • The band was stated at 50 s and in band for every phase. 5 block solutions were stepped over against 3.1 expected.
  • submitblock took 4.4 ms through the relay; getblocktemplate p50 0.36 ms and p99 0.64 ms.
  • The fake twin (short-plan-fake-node) on the same host also exits 0. slow_database, which is ungated in both presets, is equally degraded on both there, so that is the host and not the node.

Nightly. short-plan-real-node and short-plan-fake-node run nightly on 8 vCPU. prism-load-nightly.yml's preset jobs now restore and install the pinned qbit release, exactly as its live-nightly job already does. The install script exports QBITD_BIN, which is where a real-node preset finds qbitd. Fake-node presets ignore it. Reporting the difference between the two runs is #552's job.

For S12, S15, S16 and S18

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@djh58
djh58 requested a review from kiwidream September 29, 2026 18:51
@blacksmith-sh

This comment has been minimized.

… fake node's difficulty and reconciled against the chain (#547)

`--node qbitd` runs the harness's existing phases, share reconciliation and
exit codes against a managed pair of regtest qbitd nodes instead of the
in-process fake. The frontends reach pool node A through a recording
JSON-RPC relay. Peer B, which A connects to as #530's PeerNode does, mints
every external tip with generatetoaddress.

The chain is ramped first, as #524 does. -legacyretarget epochs on qbit
regtest are 1,440 blocks, each clamped to 4x, so eight retargets reach bits
1e7fffc0 at height 12,960. That is the fake node's 1e7fffff to 0.0008%, so
the window, share difficulty and hashes per share are the fake run's. Two
node rules shape the clock: qbit refuses a block about ten minutes ahead of
its clock, and it serves a template more than 150 s after the tip at the
regtest limit. So the ramp's shared mock clock ends at wall time, the clocks
are then cleared, and B mints a keepalive once the tip's own timestamp is
120 s old. The timestamp matters because a pool block carries its job's
template time. The 1,439 blocks before the next retarget are headroom,
checked at entry.

A share is a block with probability 8 / window whatever the ramp, so a phase
at R shares/s implies an own block every W / (8R) seconds. Real-node mode
refuses a phase outside 9-600 s and reports the band, each phase's interval
and the stepped-over block solutions under node.cadence_band. --plan short
at its defaults implies one every 50 s.

A watcher on A stamps every tip change: a waitfornewblock long-poll given
the last tip, then a height walk. The relay records each submitblock verdict
verbatim in the fake node's submission shape. After the load, every block
above the ramp must be exactly one peer mint or one accepted submission, on
A's active chain, at the ramped bits, with every template at those bits.
Any disagreement is a contradicted premise (exit 8); a node that exits is an
abort (6). Provenance checks are unchanged; artifact_kind is always example
(#487 decision 1).

Fake-node mode is unchanged. Its code path is not edited, real-node report
keys appear only in real-node runs, and presets gain "--node": "fake".
fake_node_mode_is_unchanged checks the fake node's answers to a fixed RPC
corpus and a pr-smoke frontend's environment against goldens taken before
this change; load_smoke checks the side report's key sets against a third.

The tips plan now schedules --scheduled-blocks in its warm-up, its only
phase; before, it silently scheduled none. The gated
real_node_smoke_reconciles_against_postgres_and_the_chain runs the new
real-node-smoke preset on every PR: 50 sessions, 3 peer tips and 1 own
block. short-plan-real-node and short-plan-fake-node, the bridging pair for
#552, run nightly: the load harness's preset jobs now install the pinned
qbit, as the live-nightly job does.

Review fixes. The peer link is kept against
qbit's peer timeouts with a very large -peertimeout (the ramp's message
stamps are taken under a mock clock that starts about 36 minutes in the
past), and a lost link is named: peer-to-peer logging goes on after the
ramp, a disagreement adds both nodes' peers and chain tips to
node.chain_reconciliation, and the smoke test prints that and the nodes'
post-ramp logs when it fails. A mint first waits (10 s at most) for B to hold
A's tip, so it never forks a pool block still on its way. The relay forwards
and records in its own task, so a frontend that gives up on a request cannot
lose the record of a block A took. A rejected submitblock verdict (anything
but acceptance, duplicate or inconclusive), an unreadable submit and a tip
asked of B but never minted are problems. A node that exits or can no longer
be reached aborts the run (exit 6) instead of becoming a contradiction (8).
Tips are stamped when B minted them or A answered the submit, if earlier
than the watcher's wake-up. A failed start and an early drop remove the
data only after both nodes are dead. QBITD_BIN is read through the test
gate's name for it, and the runner-probe preset pins "--node": "fake".

Closes #547

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@djh58
djh58 force-pushed the djh58/prism-b547-real-node branch 2 times, most recently from 7dc2093 to 1805c88 Compare September 29, 2026 19:31
Resolves test/e2e-scenarios.toml: keeps #547's real-node scenarios and #586's #575 scenarios; check_e2e_scenarios and its unit tests pass.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@djh58

djh58 commented Sep 29, 2026

Copy link
Copy Markdown
Member Author

Review ledger: head ee1ac6d (CI green)

Reviews run: /code-review at high effort (10 findings), plus one independent adversarial Claude review (10 findings). The adversarial review covered chain reconciliation, the ramp and clock traps, fake-mode byte identity, the exit-code contract and CI cost. Overlapping findings are merged below. The fixes landed as the squashed, signed 1805c88, rebased onto 3.x.x. Its CI run was all green, and so is the run on the 3.x.x merge ee1ac6d. real_node_smoke_reconciles_against_postgres_and_the_chain passed on the runner both times, with a harness run of 68–82 s.

CI failures on the first head (3978278)

# Finding Disposition
CI1 The real-node smoke exited 8 on the runner: none of the peer's 3 warm-up mints reached the pool node, and the tips diverged. Fixed (diagnosed). It did not reproduce locally, pinned to 1 or 2 CPUs, and the run kept no node logs. A mutant that cuts the P2P link after the ramp reproduces it exactly. Both nodes now get a very large -peertimeout, as qbit advises for tests that use mocktime; this is a precaution, not a proven cause. Peer-to-peer logging now switches on after the ramp. A disagreement adds diagnosis (both nodes' peers and chain tips, and what A knows of each missing mint), and the smoke prints that and the nodes' post-ramp logs when it fails. qbit's debug.log is not valid UTF-8, so it is read lossily. A mint that finds the link lost now fails naming both connection counts.
CI2 cli.rs read QBITD_BIN directly, which the gate env-read check refuses. Fixed. It is read through qbit_prism_test_gate::Input::QbitdBin.name(), and the gate crate becomes a normal dependency.
CI3 short-plan-20k-window-1fe, added to 3.x.x since the branch point, did not pin --node. Fixed. It pins "--node": "fake".
CI4 The Python shard 1 e2e-manifest gap. Fixed on the base (#584), picked up by the rebase.

Review findings

# Source Finding Disposition
1 both A mint on B's own tip can fork a pool block still on its way to B. Fixed. A mint first waits (10 s at most) until B holds A's tip, re-reading both tips each time.
2 both A tip is stamped when the watcher wakes, so a notify served earlier, or on a coalesced tip, is dropped. Fixed. A mint is stamped when generatetoaddress returned (as the fake node stamps its mints), and a pool block when A answered submitblock, whenever that is earlier. Per-mint propagation still uses the watcher's stamp.
3 code-review The relay loses a submitblock record when the frontend cancels the request. Fixed. Forwarding and logging run in a spawned task.
4 adversarial Reconciliation passes when the node rejects the pool's own block, and when a submit is unparseable. Fixed. Any verdict other than null, duplicate, inconclusive or duplicate-inconclusive is a problem, and so is an unreadable submit. Mutant: the relay corrupts the forwarded block → exit 8, qbitd rejected submitted block …: high-hash.
5 adversarial A node that dies exits 8, not 6. Fixed. A process exit, or a watcher that lost A, aborts the run (6). The reconciliation stays in the report and is not folded into the premise.
6 adversarial A tip asked of B that was never minted is not flagged. Fixed. Requested and minted counts are compared.
7 adversarial A keepalive can be requested after quiesce. Fixed. Minting closes under a lock the keepalive holds while it sends.
8 both A failed start leaks the relay task and the data directory. Drop removes the directories before the nodes die, and loses the logs. Fixed. A guard removes the root after both nodes are dead. Drop kills the nodes and keeps their logs first.
9 code-review A waitfornewblock answer without a hash is read as a reorg. Fixed. An answer missing its hash or height counts as an RPC failure.
10 both The tips plan now schedules --scheduled-blocks in fake mode too. Rejected. This is disclosed in the PR body. No preset or test combines the two, the tips plan writes no artifact, and before the change the flag was silently ignored.
11 code-review start_qbitd re-derives addresses that cannot differ. Rejected. It is a cheap guard against the two seed sites drifting apart.
12 code-review real_node_block duplicates the fake node block's construction. Deferred. A follow-up could share one builder; the key-set golden covers the fake side today.
13 both The nightly installs qbit for every preset job. Deferred. A cached restore costs seconds. Making it conditional needs the matrix to expose --node.
14 adversarial The count of pool blocks is not compared with the scheduled own blocks. Deferred. A scheduled block that never reaches the node is a server finding the landing reports already carry. Rejected and unreadable submits (item 4) are now caught.

Verification. All run locally:

  • clippy -D warnings, check_gate_env_reads, check_e2e_scenarios, and the Python unit tests;
  • qbit-prism-load's lib, churn, harness (136) and realism tests;
  • gated load_smoke;
  • gated real_node twice, the second pinned to 2 CPUs.

The mutants for items 4 and CI1 are above. Per-PR CI cost is unchanged: about 85 s on the shard (ramp 27–41 s).

🤖 Generated with Claude Code

@djh58
djh58 merged commit a3f1b1c into 3.x.x Sep 29, 2026
21 checks passed
djh58 added a commit that referenced this pull request Sep 29, 2026
Brings in #590's real-node mode and resolves where it meets the soak:

- run.rs execute_with_preset: #590's node_mode and args rebinding first,
  then the soak plan over the rebound args.
- run.rs side report: #590's node_block, plus the soak entry.
- run.rs block scheduling: #590's rule (the tips plan lands its scheduled
  blocks in warm_up, every other plan in steady_state) is kept, on the
  phase's kind rather than its name, as holds_scheduled_blocks. A soak's
  c<cycle>.<preset>.<kind> phases therefore land their looped preset's
  blocks where that preset would, and each segment refreshes its block
  budget on the same rule. soak_plan asserts the weekly soak's 26 landings.
- launch_environment's map is bound mut for the soak's
  PRISM_SHARE_PARTITION_ENSURE_INTERVAL_SECONDS, inserted only when a soak
  runs; the fake-node frontend environment golden is unchanged.
- The soak presets pin --node fake, as #590 requires of every preset.
  --node qbitd refuses --plan soak by name: the looped segments are parsed
  from fake-node presets.
- The fake-node side report key golden gains the soak key.
- README preset table and test/prism-gated-tests.txt keep both sides,
  the gated list sorted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Anatolie added a commit that referenced this pull request Sep 30, 2026
…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]>
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