Repository navigation
3.x.x: cap each recipient's CTV fanout fee at its slack above the payout floor (no refused template builds near the floor) - #764
RobertClarke wants to merge 4 commits into
Conversation
…out floor (no refused template builds near the floor) A CTV fanout pays its fee out of its own recipients, split in proportion to their amounts. A recipient a few sats above the payout floor could be left below it by its share, and apply_ctv_fanout_fee_accounting then refused the whole audit bundle, so the frontend built no template until the window moved. Simulated at the production settlement settings with 3,000 miners and a 1.92e10 coinbase, 0.75% of carry-free and 1.4% of carry-paying builds were refused, and far more at smaller coinbases or higher fee rates. apply_floor_capped_fanout_fee returns the proportional split unchanged whenever it keeps every recipient at or above the floor, so every bundle that builds today is byte-identical. Otherwise each recipient whose share exceeds its slack pays exactly that slack, and the rest of the fee is spread over the others by the same integer allocation until no share exceeds its slack. It still refuses, with the same error, when the fanout's total slack is smaller than its fee or a recipient is already below the floor. Builder and verifier share apply_ctv_fanout_fee_accounting, so neither the schema nor the verifier changes, but a 3.0.0-rc.6 or earlier verifier rejects a capped bundle: frontends and the audit CLI ship together. 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2be009c600
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
cargo deny fails on rustls 0.23.45 since four advisories were published: Debug impls that expose TLS secrets, buffered data sent to the outer server after an ECH rejection, unbounded Brotli certificate decompression, and a ServerHello downgrade to classical key exchange. This is the one-package bump, cargo update -p rustls, identical on every 3.1 branch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rontends fence it Codex P1 on #764. The floor cap makes bundles that an older builder refuses, yet they carried builder version 1. During a mixed deployment or after a rollback, an older frontend took a capped candidate for its own, failed to rebuild it, and retried it. qbit_prism::audit_builder_version_for_parts stamps version 2 (AUDIT_BUILDER_VERSION_FANOUT_FEE_CAP) exactly when a CTV fanout's fee could not be split proportionally without carrying a recipient, which are the builds an older builder refused. Every other build keeps version 1 with unchanged bytes, so no golden digest moves and no migration is needed. The compact refresh stamps its record from the built body. A candidate takes the version of the body its coinbase commits to (PreparedBundle), which covers bootstrap work too: its body is built per worker after the record was stamped. This binary's fences accept versions 1 and 2 (audit_builder_version_supported). Older binaries accept only 1, so they leave capped work for a newer frontend. Tests: a capped build is stamped 2 and an uncapped one 1, with the old fence refusing 2; a candidate at version 2 is rebuilt and lands (gated, listed); and the existing incompatibility tests now use version 99 rather than "current + 1". PRISM.md says to let version-2 candidates finish before a rollback, and the bump rule now says the next canonical change takes version 3. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Parking this for 3.2; it's tracked in #784. We don't hit this at today's pool size: the measurements above found no refused builds up to 300 miners, and the pool has about 15. It also changes what verifiers accept (fee-cap builder version 2), so it needs a minor release with a plan for upgrading verifiers. The branch is kept and will be rebased onto 3.x.x when 3.2 is planned. |
Do not merge: teed up for review. This is a 3.0 bug fix and stands outside the 3.1 dual-writer stack, so it can ship on its own schedule.
The bug
What PRISM does. Every CTV fanout pays its own transaction fee (the market rate times the premium) out of its recipients' amounts, split in proportion to them (
apply_proportional_fanout_fee).What goes wrong. A recipient a few bits above the payout floor can draw a share larger than that margin, which leaves it below the floor.
apply_ctv_fanout_fee_accountingthen refused the whole audit bundle withcannot select a settlement mode: fanout fee would push a recipient below the payout floor. The frontend built no new template until its inputs changed.Who triggers it. Miners active for only part of the window, whose gross lands just above the floor. Every refused build we measured had a fanout recipient with gross 14,720–14,725 bits and a fee share of 1–9 bits.
Measured rate
The real builder at the production settlement settings:
pool-fee-first;52,000 builds over windows of 8 × network difficulty, with a mainnet-like hashrate shape (one dominant miner plus a Zipf tail) and 30% partial-window miners. Share of builds refused:
These are carry-paying builds, as 3.0 builds them. Carry-free builds, which the 3.1 non-owner makes, were refused at the same or lower rates in the same cells (0.04%, 0.25%, 0.75% and 13.8%). A 5× fee rate raises them further, for example 7.5% at 3,000 miners and 1.92e10. Pareto and log-uniform hashrate shapes were refused rarely or never.
The fix
apply_floor_capped_fanout_fee(crates/qbit-prism/src/settlement.rs) works as follows:When the proportional split keeps every recipient at or above the floor, it returns that split unchanged. Every bundle that builds today is byte-identical.
Otherwise:
gross − floor) pays exactly that slack;The whole fee is charged, and nobody is carried or dropped from the fanout.
It still refuses, with the same error, in two cases:
Wiring.
apply_ctv_fanout_fee_accounting(crates/qbit-prism/src/lib.rs) now calls it. The builder and the verifier both go through that function, so there is no schema or verifier-rule change.Tests
only_a_capped_build_carries_the_fee_cap_builder_version(qbit-prism): a capped build is stamped 2 and an uncapped one 1; the old version-1-only fence refuses 2.window_switch_tests::a_candidate_at_the_fee_cap_builder_version_is_rebuilt_and_lands(gated): this binary rebuilds and lands a version-2 candidate.Unit tests (
settlement.rs):End to end (
crates/qbit-prism/tests/ctv_fanout_fee_floor_cap.rs): the smallest reproducer of the measured refusals. A 14,721-bit recipient used to draw a 2-bit share of a 213-bit fee and refuse the build. Now it pays 1 bit, the build succeeds, andverify_audit_bundleaccepts the bundle.The two existing refusal tests still refuse, because their fee exceeds their chunk's entire amount.
cargo test -p qbit-prismis green, includingmoney_path_vectors, which is unchanged.qbit-prism-serverCTV unit tests andctv_fanout_bookkeepingare green.Rollout caveat
A verifier from 3.0.0-rc.6 or earlier re-runs the proportional split and rejects a bundle whose fee was capped. Upgrade every frontend and the audit CLI together;
PRISM.mdsays so beside the CTV settings.Builder version. Work whose fee needed the cap is stamped with audit builder version 2 (
AUDIT_BUILDER_VERSION_FANOUT_FEE_CAP). Everything else keeps version 1, byte for byte as before, so no golden digest moves and no migration is needed. This release rebuilds both versions.Lockfile.
rustls0.23.46 (cargo update -p rustls) clears RUSTSEC-2026-0346 to 0349, which now failcargo denyon every branch.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.