Repository navigation
3.x.x: add a block submission and broadcast kill switch for rehearsals against a real node (#291) - #661
Merged
Conversation
…s against a real node (#291) PRISM_BLOCK_SUBMIT_ENABLED (default 1) lets the production pair run a rehearsal against a restored mainnet ledger and a real mainnet qbitd with no block submission or transaction broadcast reaching the network. With PRISM_BLOCK_SUBMIT_ENABLED=0: - the submit loop claims no candidate, so a found block is validated, credited and enqueued but stays pending, and submitblock is never called; offer_candidate also refuses before its probe and reservation, so no other caller can offer; - the CTV fanout broadcaster (PRISM's only sendrawtransaction, submitpackage and CPFP wallet user) is not started even when PRISM_CTV_BROADCASTER_ENABLED=1, broadcast-ctv refuses before it connects, and run_pass refuses before it reads the node; - check-config leads with a WARNING, self-check reports a block_submission section and warns on stderr, the health payload and heartbeat carry block_submission_enabled, the new qbit_prism_block_submission_enabled gauge reads 0, and the hold logs a warning at startup. The setting is per frontend, read at startup, and outside the cluster fingerprint. Compose passes it to both HA frontends; the ops runbook, configuration reference, README table, .env.example and go-live checks document it. Tests: config and gauge unit tests; check-config, broadcast-ctv and self-check CLI tests; in-process PostgreSQL tests of the held submit loop and the refused offer; a real-binary test in which a held frontend serves a due outbox for a health cadence and its counting fake node sees no submitblock, then the same frontend relaunched enabled offers each block exactly once; and a broadcaster test in which a held frontend claims and sends no due fanout that its enabled peer then sends. 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. |
…old every claim it is handed (#291) Review follow-ups for the block submission kill switch: - Rpc::without_relay: a frontend with PRISM_BLOCK_SUBMIT_ENABLED off talks to its node through a client, and wallet clients made from it, that refuse submitblock, sendrawtransaction, submitpackage and the wallet's own sends before anything is written (RpcRelayRefused). The offer path treats that refusal as provably not sent, so a reservation it ever reached would return to pending rather than become unknown. - The processing backstop moves from offer_candidate to process_candidate_inner: a held frontend processes no claim in any state, so no caller can settle or offer a held row either. - Config::require_block_submission is the one refusal the processing, the broadcaster pass and broadcast-ctv share. - qbit_prism_block_submission_enabled is -1 until run publishes the setting, never 1 by default. - Messages name the setting rather than a value, since 0, false, no and off all turn it off; check-config no longer prints the standby-wait line for a frontend that makes no offer. - The runbook covers the node client's refusal, check-config's exit status and frontends still starting. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 5, 2026
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
candidate_window_switch::as_issued_snapshot_preparation_runs_off_the_runtime_on_both_write_paths timed out writing its 300k-recipient snapshot on run 37359680165. The failed jobs could not be re-run with the available token, so this empty commit runs CI again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
RobertClarke
added a commit
that referenced
this pull request
Oct 5, 2026
…holds a found block (#666) (#676) #661's kill switch (PRISM_BLOCK_SUBMIT_ENABLED=0) holds every block a frontend finds. A production frontend left that way paged only once a found block had been held for a while: PrismBlockCandidateOldestPendingCritical needs an age of 60 s and then a 3-minute dwell, which may be too late for the block. PrismBlockSubmissionHeld (critical, page=true) pages a minute after a frontend reports qbit_prism_block_submission_enabled != 1, whether or not it has found anything: 0 while the switch holds submission, and -1 for a frontend that has not published its setting. The gauge is served from the cached metrics snapshot, so the rule is gated on a successful scrape rather than a fresh snapshot, and a held frontend keeps paging through a stale one. It reads the gauge's last sample over 2 minutes and requires one successful scrape in that window, so a failed scrape's staleness markers do not restart the dwell. No data and evaluation errors are OK, as for the other paging rules, and an image older than #661 exports no series. Nine promtool scenarios cover the page and its pending dwell, a failed scrape every 50 s, a submitting frontend, the unpublished setting, a failed scrape, a missing series, one held frontend of a pair, and a stale snapshot. The deployment test expects 79 rules and checks the rule's dwell, gauge and gate; the migration table and the review-only qbit-tools patch are regenerated. The rehearsal runbook says to scrape a rehearsal's frontends under another job or network, or to silence this rule and the pending-candidate rules by the rehearsal frontends' instance labels; the configuration reference and the go-live checks name the rule. Co-Authored-By: Claude Opus 5.5 <[email protected]>
RobertClarke
added a commit
that referenced
this pull request
Oct 5, 2026
…hatever each frontend's switch says (#664) (#682) #661's PRISM_BLOCK_SUBMIT_ENABLED=0 holds only a frontend started with it. On a rehearsal against a restored mainnet ledger, a frontend started without it would claim and offer every pending row. Migration 023 (offline, like 021 and 022) adds a permanent one-row table, qbit_prism_submission_hold, and an append-only journal of each set and clear that changes it, qbit_prism_submission_hold_events, and declares block_submission_hold = 1 so a pre-023 binary refuses the database at connect. While the hold is set: - claim_candidate and claim_fanout claim nothing, in the same single writer-fence statement as before; - reserve_offer_within reads the hold FOR SHARE on the hold's own row and refuses with SubmissionHeld, leaving the row pending. Only submission-hold set and clear lock that row, so a hold commits either before a reservation or after one, and the read takes no lock on the cluster row, so the hold adds no wait behind a landing or blob GC; - the CTV broadcaster refuses its pass and rechecks before every send; a hold set during an attempt hands its claim back unattempted, bounded at 5 s like the shutdown hand-back. qbit-prism-server submission-hold show|set|clear reads only PRISM_DATABASE_URL, so a frontend-only setting left invalid cannot stop an operator. show is read-only, gives up after 15 s and reads pre-023 ledgers; set and clear require --reason and are journaled, and clear is refused while candidates are pending unless --offer-pending-candidates. fatal-state clear, candidates abandon and submission-hold share one operator-reason rule, and writable shares its columns and checks with the hold-aware fence. Health and the heartbeat keep block_submission_enabled as the frontend's own switch and add block_submission_hold as the frontend last read it, in one statement with the payout revision: held is null until the first read succeeds, and a later failed read keeps the last one, so a database outage neither reports nor pages a frontend as held. A running frontend logs when the hold appears and clears. qbit_prism_block_submission_enabled is now live: 0 when the switch or the hold holds, 1 when neither does, -1 when the switch is on and the hold has not been read yet. check-config stays offline and says where the hold is reported; self-check reports submission_hold and warns. PrismBlockSubmissionHeld (#666) now covers the hold and its remedy. The ops runbook documents the hold, its journal and the set and clear procedures for rehearsal and cutover; the migration notes, the configuration reference, the server README and the go-live checks name it. Fixtures, capability rollbacks, the recovery-evidence script and the pool-acquire gate cover 023. Tests: a real-binary test (a frontend started without the switch on a held ledger sends no submitblock until clear --offer-pending-candidates, then offers each block once), PostgreSQL tests of the held claim and reservation, the hold fence (a reservation waits for a hold being set, never for the cluster row), the journal's immutability, the held broadcaster and a hold set mid-attempt, and CLI, self-check, gauge and hold-view tests. 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.
Part of #291.
Problem
The production PRISM pair will run #291's rehearsals against a restored copy of the mainnet ledger and a real mainnet qbitd. Before this change:
runalways started the submit loop. Any pending candidate would have been offered to mainnet withsubmitblock: a restored row, or a block a rehearsal miner found.There was no supported way to guarantee that no block submission or transaction broadcast reaches mainnet.
Change
This adds
PRISM_BLOCK_SUBMIT_ENABLED, a boolean that defaults to1. It applies per frontend, is read at startup, and is outside the cluster fingerprint. Setting it off (0,false,nooroff) has these effects.Blocks
Coordinator::submit_loopclaims nothing until shutdown.pending. Restored rows are not reserved, offered, settled or abandoned either.process_candidate_innerrefuses a claim in any state, before the probe, the reservation or a settlement. Soprocess_candidate, or any future caller, can neither offer nor settle a held row.Transactions
sendrawtransactionandsubmitpackage, and its only CPFP wallet user. PRISM 3 has no separate payout broadcaster.PRISM_CTV_BROADCASTER_ENABLED=1, and the frontend logs that it is held.broadcast-ctvexits non-zero before it connects to anything.broadcaster::run_passrefuses before it reads the node.Node client.
Rpc::without_relaymakes the structural guarantee. A held frontend talks to its node through a client that refuses every call that would relay a block or a transaction, before anything is written:submitblock,sendrawtransaction,submitpackage, and the wallet's own sends. Wallet clients made from it inherit the refusal. The offer path classifies that refusal as provably not sent, so even a reservation reached some other way returns topendinginstead of becoming unknown.Config::require_block_submissionis the single refusal that the processing, the broadcaster pass andbroadcast-ctvshare.Reporting
check-configleads withWARNING: block submission is disabled by PRISM_BLOCK_SUBMIT_ENABLED: …. It adds a second warning when a configured broadcaster is held, and omits the standby-wait line, since a held frontend makes no offer. With the switch on, it prints the enabled mode.self-checkadds ablock_submissionsection, filled before any connection, and repeats the warning on stderr.block_submission_enabled. That covers/healthzand the heartbeat, soself-check'slive_instancesshows each running frontend's own value.qbit_prism_block_submission_enabled:1or0, and-1(never1) untilrunpublishes the setting.Wiring and docs
compose.yamlpasses the setting to both HA frontends, defaulting to1. It is also in.env.exampleand the server README table.docs/prism-configuration.mdgains a reference section.docs/prism-ledger-ops.mdgains a rehearsal runbook: what is held, how to verify the mode on running frontends, held-candidate visibility, and what to do after the rehearsal.docs/mainnet-deployment.mdgains a go-live check.Everything else is unchanged: templates, readiness, Stratum, share acknowledgement and every database write.
Tests
config::tests::the_block_submit_kill_switch_holds_the_broadcaster_and_is_per_frontendmetrics::snapshots::tests::block_submission_gauge_follows_the_kill_switchconfig_cli::check_config_reports_the_block_submission_kill_switch_firstconfig_cli::broadcast_ctv_refuses_before_reaching_services_when_block_submission_is_disabledbroadcast-ctvrefuses before it touches the node or the databaseself_check_cli::disabled_block_submission_is_reported_when_the_services_are_unavailablecandidate_lease_tests::submit_disabled_tests::a_submit_loop_with_block_submission_disabled_claims_nothing_until_shutdowncandidate_lease_tests::submit_disabled_tests::an_offer_on_a_frontend_with_block_submission_disabled_is_refused_before_its_reservationprocess_candidateis refused and the row stays untouched; the enabled frontend then offers the row oncerpc_not_sent::a_client_without_relay_sends_no_relaying_call_and_every_other_callsubmitblockarrivesoffer_not_executed_tests::a_relay_refused_under_the_kill_switch_was_not_executedsubmitblockis classified as provably not sentcandidate_storm_restart::a_frontend_with_block_submission_disabled_sends_its_node_no_block_until_it_is_enabledctv_fanout_bookkeeping::a_frontend_with_block_submission_disabled_claims_and_sends_no_fanoutobservabilitycensustests/test_mainnet_compose_contract.py::test_block_submission_kill_switch_defaults_on_and_reaches_both_frontends1In the integration test, the real
qbit-prism-server runis started withPRISM_BLOCK_SUBMIT_ENABLED=0andPRISM_CTV_BROADCASTER_ENABLED=1, over 3 due candidates.submitblockper block hash and sees none.pendingand unclaimed, the dispatch sequence never advances, the heartbeat reportsblock_submission_enabled=false, and both warnings appear in the log.Mutation checks were run locally on the first revision. Removing each gate makes its test fail:
attempt_count: 2. The offer backstop still kept the block unoffered.run_passrefusal fails the broadcaster test.Risks and follow-ups
0in production holds every found block. Mitigations in this PR: warnings incheck-config,self-checkand the logs; the gauge and the health field; and the go-live check. The existing pending-candidate alerts also page within 15 s of a held block. A dedicated alert is not added here, because alert rules go through their own migration process. It is follow-up 3.x.x: page when a production frontend runs with block submission held (qbit_prism_block_submission_enabled != 1) #666.ledger-outcome-unknownafterPRISM_SHARE_COMMIT_TIMEOUT_SECONDS, because its block never confirms. This cannot happen at mainnet difficulty.submitblock,sendrawtransactionorsubmitpackage, as an independent layer.🤖 Generated with Claude Code