Repository navigation
3.x.x: follow weighted multi-address shares to spent outputs on a live regtest node (#521 scenario 7) - #524
Conversation
…e regtest node (#521 scenario 7) Add a gated live_regtest case in which 40 payout addresses, with a seeded whale, Zipf tail, near-floor and near-zero weights, mine through four found blocks. They submit real Stratum shares from 59 sessions on both servers, at worker difficulties spanning about three orders of magnitude. The node is restarted with -legacyretarget and ramped 1024x under a mock clock, because on regtest's limit a share can be at most twice as easy as a block. The case recomputes each block's payout from the ledger's accepted shares and the chain alone: - the PPLNS window, including the partly counted oldest share; - the gross split, floor, carry-forward and pool-fee dust sweep; - the direct/fanout partition and the fanout fee. It checks that recomputation against the coinbase outputs, every carry-forward row and the final balances. After maturity, it checks each fanout's net outputs, every payee address's receipts in the payees' wallet, a confirmed wallet spend of direct and fanout outputs, and the carry-forward integrity report. A 130-recipient nightly variant is #[ignore] and opt-in. The fixture gains an additive server_env hook, applied after every other server setting. Refs #521 Refs #474 Co-Authored-By: Claude Opus 5.5 <[email protected]>
b90056b to
ebc464e
Compare
Review ledger: head
|
| Run | Result | Wall time |
|---|---|---|
| 1 | pass | 53.7 s |
| 2 | pass | 50.2 s |
| 3 | pass | 50.2 s |
Every run had the same seeded shape: 1,425 accepted shares, 135 stale retries, 954x weight spread, 3 of 4 windows cut.
CI. All checks pass on ebc464e9, and check-gate-manifest reports all 745 expected gated tests executed. The new case took 55.7 s on the 2-vCPU native runner; that is the per-PR CI time it adds. live_regtest on that shard passed 48 with 2 ignored, the two opt-in nightly variants. One native shard first failed in landing_metrics::lost_commit_reply_timeouts_are_not_revision_work_failures ("Stratum closed before a response"). That binary is outside this diff, the test passed 5 of 5 locally, and it passed on rerun.
The full live_regtest binary on 3.x.x plus this branch (with #523 scenario 4) passed 48 with 2 ignored. All 15 expected live_regtest ids executed, with none missing or unexpected. #523's RPC-proxy fixture works with server_env, which is empty by default and applied after the proxy's port swap.
Nightly 130-recipient variant (opt-in, not listed): passed twice, in 99 s and 142 s. It covered 3,053 shares from 202 sessions over six blocks, paid 102 payees, and carried 71–92 sub-floor accounts per block.
Mutants. Each was applied to the server, rebuilt, and caught by the new case:
| Mutant | Caught by |
|---|---|
A: the authorize identity cache is keyed by worker name, so addrB.w1 reuses addrA.w1's payout identity |
attribution: share <addrB>.w1:… credited to <addrA>/…, not <addrB> |
B: the credited share weight is rounded down to a multiple of 1,000 (miner_submit.rs) |
attribution: weighs 58294000, its worker's difficulty … weighs 58294013 |
C: allocate_weighted_amounts gives leftover sats to the smallest remainders |
independent PPLNS recompute: direct outputs differ (58402734 vs 58402733, and so on), a 1-sat split that the server's own audit cannot see |
Follow-up filed separately. With the pool fee disabled, any positive sub-floor carry makes apply_payout_policy fail with PayoutExceedsCandidateBalance on every refresh: "template refresh deferred", and no work on the new tip. This was reproduced live by removing the pool-fee settings from this case. The case therefore runs with a 200-bps pool fee, as mainnet does.
🤖 Generated with Claude Code
… 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]>
… fake node's difficulty and reconciled against the chain (#547) (#590) `--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]>
Refs #521 (scenario 7). Refs #474 (its many-recipient share-to-spend item only; the 1,001-recipient chunk boundary, direct-only mode, async failover and lost-reply slices stay with #474).
What this adds
A gated
live_regtestcase,weighted_recipients_tests::real_weighted_recipients_pay_exact_pplns_outputs_through_fanout_spend, in a new support moduletests/support/live_weighted_recipients.rs. It follows every sat from the accepted share to the spent output, with a real qbitd, both PRISM servers and PostgreSQL:mining.submit, and each worker asks for its difficulty in its password. Worker difficulty spans about 950x (about three orders of magnitude, as on mainnet). 16 addresses mine on both servers, and 11 mine at more than one difficulty.It asserts the following. Every expected value is recomputed in the test from the ledger's accepted shares and the chain, never from the server's bundles or summaries.
qbit_payout_carry_forwardrow matches (gross, prior, candidate, on-chain, fee, carry, action), and the final carried balances match.qbit_carry_forward_integrity_report()is clean.nightly_mainnet_floor_weighted_recipients_share_to_spendis the same case at the #521 mainnet floor: 130 recipients, one whale near 85%, 202 sessions and six blocks. It is#[ignore]and opt-in, and is not in the gate list until a nightly job selects it. It passed locally in 99 s and 142 s, the second run on a busier host.Why the chain is made harder first
On regtest's proof-of-work limit, a share can be at most twice as easy as a block, so a spread of worker difficulty cannot exist there. The case therefore restarts the fixture's node with
-legacyretargetand mines about 8,500 blocks quickly under a mock clock pinned to the tip. Each epoch's 4x clamp raises the target 1,024x in about ten seconds. The mock clock only runs ahead of the wall clock, and the server accepts a future template time.Server settings the case uses
PRISM_STRATUM_VARDIFF=0.PRISM_PAYOUT_MIN_OUTPUT_BITSso dust exists at regtest scale.PRISM_MAX_DIRECT_COINBASE_OUTPUTS=4, so direct-eligible overflow reaches the fanout by amount priority.repro_prism_stall).Shared fixture change
The shared fixture change is additive.
Fixturegainsserver_env, which is applied after every other server setting and is empty unless a case sets it; this case uses it for the settings above.live_regtest.rsalso gains themodline for the new module. No other test is affected.Mutants the case catches
Each mutant was applied to the server, rebuilt, and run against the new case:
addrB.w1reusesaddrA.w1's payout identitycoordinator.rsauthorizeshare <addrB>.w1:… credited to <addrA>/…, not <addrB>miner_submit.rsshare … weighs 58294000, its worker's difficulty … weighs 58294013qbit-prismallocate_weighted_amountsblock … direct outputs differ from the recomputed PPLNS split(e.g. 58402734 vs 58402733)Observation, not changed here
Each round shows one
stale-jobrefusal per active session, 135 in the per-PR run and deterministic. After every landing, the first job each session receives on the new parent is retired by the same-parent payout-revision bump that follows. The client retries on newer work, as a miner would, and the count is reported. Share accounting stays exact.CI runtime
The per-PR case adds about 50-54 s locally (ramp, four rounds, maturity, fanout, spend and cleanup) to the
live_regtestbinary's serial run on the native job's shard. On the 2-vCPU CI runner it measured 55.7 s.Validation
cargo fmt --all -- --check, andcargo clippy --locked -p qbit-prism-server --test live_regtest -- -D warningsPRISM_TEST_REQUIRE_INTEGRATION=1against PostgreSQL 16 (fsync on) and qbitd 1.0.0, in 53.7 s, 50.2 s and 50.2 s wall time. The nightly case passed twice.live_regtestbinary passed with the fixture change: 44 passed and 1 ignored (the nightly case)scripts/check_gate_env_reads.pyis clean, and the gate list stays sorted🤖 Generated with Claude Code