Repository navigation
3.x.x: require a pool fee in every settlement mode and default a fresh setup to a 0-bps fee (#535) - #568
Merged
Conversation
…h 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]>
Member
Author
|
@cursor review |
… 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]>
Member
Author
|
@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 5e5d38e. Configure here.
Member
Author
Deep-review ledger (head
|
| Finding | Source | Disposition |
|---|---|---|
The compose :-1 default with no recipient made a flag-unset deployment unreadable by every tool, policy-transition included (compose.yaml) |
code-review | fixed in 5e5d38ea: reverted to :-0, plus the migration test above |
make doctor passed a config with no recipient, or with the lab program in production (scripts/check-env.sh) |
code-review | fixed in 5e5d38ea: an enabled fee needs a recipient; production refuses the lab program where no address replaces it; process-environment overrides of the address and program apply |
The doctor read an empty PRISM_POOL_FEE_ENABLED as 0, while compose's :-1 read it as 1 |
adversarial | fixed in 5e5d38ea: resolved by the :-0 revert; both now read it as 0 |
The 0-bps fee fixture was defined in three places (support/pool_fee.rs, live_regtest, fatal_state) |
quality | fixed in 5e5d38ea: live_regtest and fatal_state reuse tests/support/pool_fee.rs |
Cursor Bugbot on db75bbab and on 5e5d38ea |
bugbot | no issues |
Every new check was mutation-tested. Each mutant was caught:
- the guard back to CTV-only;
- no production refusal of the lab program;
- the harness skipping the fee at 0 bps;
- the doctor refusing only under CTV;
- the doctor's recipient check removed;
- the doctor's production lab check removed;
policy-transitionalso refusing a fee-less current configuration.
The PR body has the full results.
Anatolie
added a commit
that referenced
this pull request
Sep 30, 2026
…uilds from #536 to #568 launched (#511) From 0c8842e (#536) up to 65c9751 (#568) the harness has --pool-fee-bps but leaves the fee off at 0, so the comparison FAILed a base in that range at every throughput preset. A fee-off frontend now satisfies a pinned 0, as legacy-flags.json already accepts; a fee off at a nonzero pin or an enabled fee at another rate still fails. 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.
Closes #535
Problem
Without a pool fee, sub-floor dust cannot be settled.
apply_payout_policypays only balances that reach the payout floor, so once any positive balance sits below it, the paid balances fall short of the coinbase. Only a pool fee, at any rate, can take the difference (add_swept_dust_to_pool_fee). Without one, every work build fails withPayoutExceedsCandidateBalanceand mining stops.#534 refused this only for CTV settlement. Direct settlement applies the same policy, and it was the default in
.env.example,compose.yamland the load harness.This PR takes option 1 from the issue: a pool fee is required in every settlement mode, and 0 bps is allowed.
apply_payout_policyis unchanged.1. The refusal, in both modes
Config::ensure_pool_fee_settles_dustnow refuses a pool without a fee whateverPRISM_CTV_SETTLEMENT_ENABLEDsays. The message names the mode, the setting and the reason:runcheck-configself-checkok: falsepolicy-transitiontargetpolicy-transitioncurrent side, operator toolspolicy-transitioncan enable a fee on a cluster that ran without onemake doctor(check-env.sh)check_pool_fee_config. With the fee enabled it also requires a recipient, and in production it refuses the lab program when no address replaces it. Process-environment overrides of the address and program apply, as for the flag.Two existing messages now say what to set:
2. Defaults: a fresh setup is valid, and deployments are unaffected
compose.yamlkeeps its fee-off defaults and sets no recipient. A deployment enables the fee and names exactly one recipient. One that names neither gets the clear refusal at startup, while every tool andpolicy-transition's current side still read its configuration.1: compose cannot also supply a recipient. An enabled flag with no recipient fails insideConfig::from_env, so every tool would fail, including the current side ofpolicy-transition, the repair path. This came out of review; the first commit had:-1.PRISM_POOL_FEE_BPSempty by default rather than0. The server reads an unset rate as 0 bps.compose.yamlalone. It rendersPRISM_POOL_FEE_ADDRESSand omits the program line. A program default here would give mainnet both an address and a program, and every server would refuse "configure exactly one pool fee address or P2MR program". Compose interpolation cannot express "default only when the address is unset".PRISM_POOL_FEE_ENABLED=1with its own address..env.examplecarries the lab recipient. A fresh setup copies it to.env.PRISM_POOL_FEE_ENABLED=1,PRISM_POOL_FEE_BPS=0,PRISM_POOL_FEE_P2MR_PROGRAM_HEX=dfee…dfeeandPRISM_POOL_FEE_RECIPIENT_ID=dev-pool-fee.config::DEVELOPMENT_POOL_FEE_P2MR_PROGRAM_HEX.QBIT_PRODUCTION/QBIT_TOOLS_PRODUCTION). The check compares the decoded bytes, so a change of case does not get past it.PRISM_POOL_FEE_ADDRESSand leave the program and recipient ID empty, or set their own program and a recipient ID. It must be exactly one of the two.A cluster that ran without a fee now refuses to start until it enables one offline with
policy-transition.docs/prism-ledger-ops.mdgives the target file.3. Load harness
Every frontend is launched with the fee on:
apply_pool_feeno longer returns early at 0 bps;frontend_environmentno longer setsPRISM_POOL_FEE_ENABLED=0;pool_fee_address.Legacy presets keep
--pool-fee-bps 0, and no preset file changes.The legacy presets' results reproduce.
zero_bps_pool_fee_is_audited_without_onchain_fee_outputalready pins that.Measured on the
pr-smokepreset (then namedsmoke; seed 1, debug server):c99abdd8with the fee off, against this branch on the same base at 0 bps. #540 and #559, rebased in afterwards, add a live test and rename presets;load_smokepasses on the final tree.stale-job(expected) ×1stale-job(expected) ×2Both builds produce the same outcome set. The single
stale-jobis a pre-existing race between a warm-up share and a tip change, which base hits too.Every other field that differs between base and branch also differs between two base runs: timings, latencies and rates. The exceptions are the fee's own traces:
topology.pool_fee_address;validateaddresscall, as the frontend validates its fee address at startup.Tests
config::tests::settlement_without_a_pool_fee_is_refused_in_every_mode/…_with_any_pool_fee_is_accepted_in_every_mode(0 and 200 bps)pool_fee_guard(8 tests)check-config,runandself-checkrefuse either mode, with the flag unset,0orCTV=0implicit; they accept 0 and 200 bps; a transition target is refused in both modes but a fee-less current configuration is not; production refuses the lab program (in either case) but not a pool's own;.env.exampleitself passescheck-configin both modes, and its recipient instructions hold: an address beside the lab program is refused, while an address with the program cleared is accepted;policy-transitionfrom compose's fee-off defaults (every fee setting empty, the flag unset or0, both modes) reads the current configuration and accepts a 0-bps targettest_settlement_requires_a_pool_fee_in_every_mode_before_docker_check,test_env_example_defaults_enable_a_pool_fee_in_every_mode,test_settlement_accepts_any_enabled_pool_fee_in_every_mode,test_an_enabled_pool_fee_needs_a_recipient,test_production_rejects_the_lab_pool_fee_recipient.env.exampledefaults pass; a missing recipient is refused; production refuses the lab program without an address, but not with one, not a pool's own program, and not in lab modetest_role_rendered_compose_names_exactly_one_pool_fee_recipientcompose.yamlalone with an address-only env, as the deploy role does: fee on, the address, an empty program, in both modes; a bare env gets compose's fee-off default and no recipientrealism_presets_run_mainnets_fee_and_legacy_ones_do_notapply_pool_feeenables the fee at 0 and at 200 bpsNone of the new tests needs PostgreSQL or qbitd, so none is gated, and
test/prism-gated-tests.txtis unchanged. No gated test was added or renamed.Mutants (each applied, rebuilt and run)
pool_fee_guardtestsproduction_refuses_the_development_pool_fee_recipientrealism_presets_run_mainnets_fee_and_legacy_ones_do_nottest_an_enabled_pool_fee_needs_a_recipienttest_production_rejects_the_lab_pool_fee_recipientpolicy-transitionalso refuses a fee-less current configurationpool_fee_guardtransition teststest_settlement_requires_a_pool_fee_in_every_mode_before_docker_checkFixtures changed (additive; each launched a fee-less server)
tests/support/pool_fee.rs:ZERO_BPS_POOL_FEE;default_pool_fee, which yields to a case that configures its ownPRISM_POOL_FEE_*, since an address beside the default program would be refused.config_cli,self_check_cli,stratum_protocol,api_config,audit_completeness,work_refresh_metric,stratum_restart_bindandcandidate_storm_restart.live_regtest: the 0-bps default now covers every server, not only CTV ones. The in-process coordinator inlive_highdiffpins the same policy throughlive_payout_policy(); otherwise its fingerprint differs from the servers'.fatal_state: the one-shot-tools case pins a 0-bps fee on its cluster and gives it to every tool.Local verification
cargo test -p qbit-prism-server --lib: 575 passed.PRISM_TEST_REQUIRE_INTEGRATION=1, PostgreSQL 16:ledger_postgres: 183 passed;config_cli21,api_config5,self_check_cli5,audit_completeness3,work_refresh_metric1,stratum_restart_bind5,stratum_protocol39,candidate_storm_restart19,healthcheck_cli2,signing_transition14 andpublic_database_config5 all passed.public_database_configran undertest/prism-native-tests.shfor its SCRAM cluster.live_regtestagainst a real regtest node: every case passes; in the last full run on the final tree, 5 cases failed only because another job deleted the borrowedqbitdbinary mid-run and all 5 passed on rerun;real_async_failover_mid_landing_loses_only_the_replication_gapfailed once under host load (lease-bound 120 s landing wait) and passed 3 times alone. The opt-in nightly dense soak also passes, atPRISM_DENSE_SOAK_SECONDS=120.load_smoke(gated),realism21,harness136 andchurn6 all passed.cargo clippy -p qbit-prism-server -p qbit-prism-load --all-targets -D warningsandcargo fmt --checkare clean.check_prism_settings.py,check_gate_env_reads.pyandcheck_deleted_test_map.pypass.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. The policy-transition case now waits out the closed-port database pool timeout once per mode. The compose-default transition cases run concurrently inside that window, so the test binary's wall-clock is unchanged at about 30 s. The other new cases are sub-second subprocesses.🤖 Generated with Claude Code