Repository navigation
3.x.x: refuse CTV settlement without a pool fee and page when no work reaches the observed tip (#525) - #534
Conversation
… reaches the observed tip (#525) With CTV settlement on and the pool fee off, the first positive balance below the payout floor fails every work build on the next tip with PayoutExceedsCandidateBalance: only the pool fee can take sub-floor dust (add_swept_dust_to_pool_fee). No job is published on the new parent, and mining stops until the dust reaches the floor or leaves the window. The only symptom was a WARN line per refresh. Fail fast. Config::ensure_pool_fee_settles_dust refuses PRISM_CTV_SETTLEMENT_ENABLED=1 without PRISM_POOL_FEE_ENABLED=1, names both settings and the reason, and accepts any fee, 0 bps included. Four entry points check it: server::run (before any listener or the database), check-config, self-check, and a policy-transition target. The current side of a transition, and the operator tools, still read a fee-less configuration, so policy-transition can repair a cluster that ran without a fee. make doctor mirrors the rule, including a process-environment override of the sourced .env. apply_payout_policy is unchanged. Make the stall page. Semantic coverage cannot see it: sessions are compared with the latest published generation, which stays on the old parent while every refresh fails, so the ratio reads 1. The new gauge qbit_prism_current_parent_work_missing_seconds reads the coordinator's tip state at each health publication. It is the time since the observed tip first departed from the published tip, clocked like the replacement-build lease: retries and newer tips never renew it, and it is 0 once work is published on the tip and -1 before any tip observation. PrismCurrentParentWorkMissingCritical pages at 120 s for 1 m, gated on a fresh snapshot, on either settlement path. That makes it the safety net for direct settlement, which applies the same policy and is not refused here. Fixtures: the live regtest CTV servers run a 0-bps fee unless a case sets its own PRISM_POOL_FEE_* in server_env, as the weighted-recipients case does with an address. The config_cli CTV success case and the CTV policy-transition support also run a 0-bps fee. The mainnet Compose fixture enables a fee. .env.example and compose.yaml explain the exposure; their defaults (CTV off) were already accepted. Tests: - config unit tests: refuse, accept at 200 and at 0 bps, direct not refused. - pool_fee_guard (CLI): check-config refuses and accepts; run and self-check refuse; a policy-transition target is refused, but not a fee-less current configuration. - TipState unit tests. - Gated parent_work_metric: the real server against the fake node. One miner holds work on tip A; tip B fails every refresh after its observation. The gauge grows while coverage stays 1 and health 0, and it returns to 0 when B publishes. - Six promtool scenarios and doctor tests. Mutants caught: gauge never published, gauge blind to the departure, guard disabled, doctor check disabled, and rule threshold, dwell or unknown gate broken. repro_prism_stall still pins the policy. Closes #525 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@cursor review |
…525 review) Review found that the first gauge counted only after the observed tip departed from the published one. A #525 stall can start on the same parent: in direct mode, dust from gross alone fails the 60 s re-anchor rebuild on the current tip. Readiness then lapses and shares are refused, but the gauge read 0, and it paged only after the next network block, never if the pool finds most blocks. A refresh that failed before its own tip observation (e.g. a database error) or hung was also invisible. The gauge is now qbit_prism_work_refresh_stalled_seconds: the time since Coordinator::refresh_once last succeeded (published or revalidated work), counted from start before the first success. Only that success renews readiness, so the age is exactly how long the frontend has been unable to serve current work, whatever the cause. The rule is renamed PrismWorkRefreshStalledCritical, with the same 120 s / 1 m / fresh-snapshot shape. The TipState departure clock and its tests are removed, so the lease predicate is no longer duplicated. work_refresh_metric replaces parent_work_metric. The real server runs against the fake node through two stalls: a same-parent one (tip unchanged, template for another parent) and a new-tip one. The gauge keeps growing through both while semantic coverage reads 1, and it drops back below 3 s once a refresh succeeds. Mutants caught: the clock renewed on failed refreshes, never renewed, or never published. Also from review: - self-check runs its local checks before returning the pool-fee refusal; - the mainnet-deployment pool-fee block no longer splits the walletless broadcaster lead-in from its example; - the non-CTV exposure cites #535; - the policy-transition fixture derives its fee policy from one list; - a doctor test proves a process-environment disable beats an env-file enable (it fails with the override removed). Refs #525 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 5953d79. Configure here.
Deep-review ledger (#525)Stakes: high. This PR gates pool-fee and payout configuration and adds a paging rule, so bugbot was summoned for both commits. Lanes:
Commits: For review, @kiwidream
Findings
Verification of 5953d79
CI on 5953d79: green (21 pass, 1 skipped). The first run had one shard failure: 🤖 Generated with Claude Code |
…h setup to a 0-bps fee (#535) (#568) * 3.x.x: require a pool fee in every settlement mode and default a fresh setup to a 0-bps fee (#535) Without a pool fee, apply_payout_policy cannot settle sub-floor dust, so the first positive balance below the payout floor fails every work build and mining stops. #534 refused this only for CTV settlement; direct settlement applies the same policy and was the default in .env.example, compose.yaml and the load harness. Config::ensure_pool_fee_settles_dust now refuses a pool without a fee in both modes, naming the mode, the setting and the reason. run, check-config, self-check and a policy-transition target refuse it; the current side of a transition still reads a fee-less configuration, so policy-transition remains the way to enable a fee on a cluster that ran without one. make doctor mirrors the rule. PRISM_POOL_FEE_BPS=0 is still allowed and pays nothing until dust must be swept. apply_payout_policy is unchanged. Defaults: compose.yaml enables the fee (rate unset, so 0 bps) but sets no recipient, because the deploy role runs compose.yaml alone and renders an address without a program; a recipient default there would put both beside each other and every server would refuse to start. .env.example, which a fresh setup copies to .env, enables a 0-bps fee to a synthetic lab program (recipient dev-pool-fee) that nobody holds a key for, and production refuses that program. The "exactly one address or program" and "requires PRISM_POOL_FEE_ENABLED=1" messages now say what to set. The load harness launches every frontend with the fee on; legacy presets run it at 0 bps. A 0-bps fee adds no output until dust must be swept, where a fee-off frontend would have stalled, so a run that completed fee-off reproduces its results at 0 bps. Tests: config unit tests and the pool_fee_guard CLI tests cover refusal and acceptance in both modes (0 and 200 bps), the production refusal of the lab program, and .env.example as a valid configuration in both modes; doctor tests cover both modes and the .env.example defaults; the mainnet compose contract renders compose.yaml as the deploy role does and checks it names exactly one recipient. Every test fixture that launched a fee-less server now runs a 0-bps fee. Closes #535 Co-Authored-By: Claude Opus 5.5 <[email protected]> * 3.x.x: keep compose.yaml's pool fee off by default, and check the fee recipient in make doctor (#535 review) Review of the first commit found that compose.yaml's new PRISM_POOL_FEE_ENABLED default of 1, with no recipient default, broke a deployment that never set the flag. Such a deployment got the fee enabled with an empty address and an empty program, so Config::from_env failed. Every tool that reads the configuration failed with it, including the current side of policy-transition, which is the documented way to enable a fee. Compose cannot supply a recipient, so the default goes back to 0: that deployment now gets the clear startup refusal, and policy-transition still reads it. .env.example stays the valid fresh setup. make doctor now also refuses an enabled fee with no recipient. In production it refuses .env.example's lab program where no address replaces it; an address beside the sourced lab program is left to the server, which sees only what Compose passes. As with the flag, process-environment overrides of the address and program apply. Tests: policy-transition from compose's fee-off defaults (every fee setting empty, the flag unset or 0, both modes) reads the current configuration and accepts a 0-bps target; doctor tests for the missing recipient and the production lab program. The 0-bps fixture now lives only in tests/support/pool_fee.rs, which live_regtest and fatal_state reuse. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Closes #525
Problem
With CTV settlement on and the pool fee off, the first positive balance below the payout floor stops all work. Every build on the next tip fails with
PayoutExceedsCandidateBalance, because only the pool fee can take sub-floor dust (add_swept_dust_to_pool_fee). No job is published on the new parent. Nothing paged: the symptoms were atemplate refresh deferredWARN per refresh and, once readiness lapsed,health_state0, which no rule reads.This PR takes the small pre-GA route from the issue: refuse the configuration, and page on the stall.
apply_payout_policyis unchanged.1. Fail fast
Config::ensure_pool_fee_settles_dustrefusesPRISM_CTV_SETTLEMENT_ENABLED=1withoutPRISM_POOL_FEE_ENABLED=1. The message names both settings and the reason. Any fee is accepted,PRISM_POOL_FEE_BPS=0included: a 0-bps fee pays nothing until dust must be swept.run(server::run)check-configself-checkok: falsepolicy-transitiontargetpolicy-transitioncurrent side, operator toolspolicy-transitioncan repair a cluster that ran without a feemake doctor(check-env.sh).envDirect (non-CTV) settlement is equally exposed and is not refused here. It calls the same
apply_payout_policywith the same floor and prior balances..env.example,compose.yamland the load harness default to direct settlement with the fee off, so a fee-off pool in any mode stalls on the first sub-floor balance. Making a fee mandatory in all modes, or adding a no-fee dust path, is tracked in #535. Until then, the paging rule below covers both paths..env.example,compose.yamlandPRISM.mdnow say so.2. Make the stall page
qbit_prism_work_refresh_stalled_seconds.Coordinator::refresh_oncelast succeeded, whether that refresh published new work or revalidated the current work. Before the first success it counts from process start, so a restart into a stall still grows.PrismWorkRefreshStalledCritical(qbit-prism-work-refresh-stalled-critical).>= 120 sfor1m, critical,page=true.The first commit measured only the time since the observed tip departed from the published one. Review showed that design missed same-parent stalls, so the second commit replaces it; the departure clock is gone.
Tests
config::tests::ctv_settlement_without_a_pool_fee_is_refused/..._with_any_pool_fee_is_accepted(200 and 0 bps) /direct_settlement_without_a_pool_fee_is_not_refused_herepool_fee_guard(5 tests)check-configrefuses (unset and=0) and accepts (200 and 0 bps);runandself-checkrefuse; a transition target is refused, but not a fee-less current configurationwork_refresh_metric::failing_refreshes_grow_the_refresh_stall_gauge_while_coverage_reads_one#525promtool scenariostest_check_env_production_gate(+3),test_mainnet_compose_contract(+1)crates/qbit-prism/tests/repro_prism_stall.rsstill pins the policy-level error.Mutants (each applied, rebuilt and run)
publish_work_refresh_stalledcall removed)work_refresh_metric: times out waiting for work on tip Awork_refresh_metric: times out waiting for the same-parent stallwork_refresh_metric: "healthy frontend drifted"pool_fee_guardtests, and the config unit testtest_ctv_settlement_requires_a_pool_fee_before_docker_checktest_process_environment_disables_a_pool_fee_the_env_file_enablesand the acceptance subtests0s/!= 0(counts -1)Fixtures changed (additive)
live_regtestCTV servers, theconfig_cliCTV success case and the CTV policy-transition support now run a 0-bps fee, withPRISM_POOL_FEE_P2MR_PROGRAM_HEXand a recipient ID.PRISM_POOL_FEE_*inserver_env(3.x.x: follow weighted multi-address shares to spent outputs on a live regtest node (#521 scenario 7) #524's weighted-recipients case sets an address) replaces the CTV default whole. Otherwise its address would sit beside the default program, and startup would refuse with "configure exactly one pool fee address or P2MR program".observabilitycensus counts are bumped by one family and one series.tests/fixtures/mainnet-compose.envenables a 200-bps fee.Local verification
cargo test -p qbit-prism-server --lib: 576 passed.pool_fee_guard,work_refresh_metric(gated,PRISM_TEST_REQUIRE_INTEGRATION=1),observability,config_cli,metrics_allocationandledger_postgres -- policy_transition(13) all pass.real_weighted_recipients_pay_exact_pplns_outputs_through_fanout_spend, with its own 200-bps address fee;node_outage_tests, one of which is opt-in and ignored;ctvandcpfp, 4 cases with the 0-bps default.repro_prism_stallpasses.cargo clippy -p qbit-prism-server --all-targets -D warningsandcargo fmt --checkare clean.test_prism_alert_promql.py(promtool 3.14.0): 154 scenarios.generate_prism_alerts.py --check,test_prism_alert_deployment.py(73 rules),generate_prism_metrics.py --check,check_prism_settings.py,check_gate_env_reads.pyandcheck_deleted_test_map.pyall pass.test_mainnet_compose_contractneeds Docker, which the local host does not have, so CI runs it.Per-PR CI runtime added
pool_fee_guardadds about 15 s wall-clock. One case waits out the closed-port database pool timeout, and the other cases run alongside it. The unit tests add under 0.1 s.work_refresh_metricadds about 25 s.🤖 Generated with Claude Code