Repository navigation
refactor(node): cut per-signer abandonment subsystem; reduce #1697 to a heal-path counter - #1957
Conversation
… a heal-path counter Spec-discipline review of the two serve-path concurrency "fan-out" defenses: KEEP the genuine fan-out defenses (getPool authoritative `remaining` alone does not close the hole — it is a read, not a reservation): - the pool-level floor accumulator, bounding aggregate live un-vouchered floor across every signer to `remaining − M`; - the per-signer live cap `k · one_window`, protecting a shared pool's named co-tenants. CUT the per-signer abandonment leaky-bucket subsystem: the durable PoolFloorLossStore (trait + redb `floor-loss.redb` database + memory impl), the `pool_floor_signer_bucket_windows` / `pool_floor_signer_refill_secs` config knobs, debit-on-drop with fronted-upstream sizing, the forget tombstones, the `floor_loss_persist_failures` metric + its alert, and the e2e test. It fails the trustless axiom — a free-to-mint signer defeats any signer-keyed rate tally by rotation — and the sequential-abuse residual it closed is one ADR 003 already accepts (a real-egress trickle that grows with neither the pool nor the network). REDUCE the #1697 per-lane surcharge to just the `active_streams` counter the wallet-less-resume heal reads. The pool ceiling plus the per-signer live cap already bound same-lane concurrency, and more correctly: they reserve the actual span-capped floor, not a flat full-window surcharge, so two sub-window streams that genuinely fit are no longer spuriously refused. The floor accumulator is now purely in-memory (no stream is live at restart), so nothing persists it. ADR 003 §Pool solvency and the observability appendix are updated to match. Net -3855 lines. Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
A changed-region comment in crates/node/src/handlers/client/dispatch.rs still describes FloorReservation as reconciling unpaid loss at stream end, which no longer matches the implementation after removing abandonment/dead-charge behavior.
Pull request overview
This PR refactors the node’s serve-path payment concurrency defenses by removing the per-signer abandonment leaky-bucket subsystem (and its durable persistence/alerts) and tightening the focus onto the in-memory pool-level floor ceiling plus the per-signer live reservation cap, while preserving the active_streams counter for the wallet-less resume heal path.
Changes:
- Remove the durable per-signer abandonment bucket subsystem (store trait + redb tables, metrics/alerts, config knobs, and related tests/e2e).
- Keep and clarify the in-memory pool floor ceiling + per-signer live cap as the concurrency/fan-out defenses; retain
active_streamsas a heal-path signal (not a solvency gate). - Update docs (ADR 003 + observability appendix) and adjust unit/integration/e2e tests and config surfaces accordingly.
File summaries
| File | Description |
|---|---|
| monitoring/prometheus-alerts.yml | Removes the alert tied to the deleted floor-loss persist failure metric. |
| crates/node/tests/sighup_signal.rs | Drops removed config fields from test config seeding. |
| crates/node/tests/node_origin_pull.rs | Updates test commentary to attribute refusal to pool ceiling behavior. |
| crates/node/tests/client_loopback.rs | Refactors loopback tests away from abandonment-bucket persistence and toward pool-ceiling semantics. |
| crates/node/tests/channel_state_store.rs | Removes tests that exercised the deleted floor-loss bucket persistence/race behavior. |
| crates/node/tests/anvil_bringup_shutdown_e2e.rs | Drops removed config fields from e2e bringup config. |
| crates/node/src/runtime/reload.rs | Removes restart-required warnings and defaults for deleted config knobs. |
| crates/node/src/runtime/mod.rs | Removes wiring for the deleted floor-loss store and bucket parameters; keeps live cap. |
| crates/node/src/payment_settlement.rs | Switches to synchronous forget_pool_floor call after pool reclaim. |
| crates/node/src/metrics.rs | Removes floor-loss persist failure metric and lane-at-capacity metric; simplifies signer cap metric docs. |
| crates/node/src/handlers/client/wire.rs | Removes metrics recording branch for the removed LaneAtCapacity reject reason. |
| crates/node/src/handlers/client/window.rs | Updates comments to reflect that reservations only free live headroom now. |
| crates/node/src/handlers/client/serve_leg.rs | Removes abandonment-bucket reconciliation hooks now that the subsystem is deleted. |
| crates/node/src/handlers/client/dispatch.rs | Removes per-lane solvency surcharge gate; keeps active_streams counting and pool ceiling reservation. |
| crates/node/src/handlers/client/delivery.rs | Updates comments and removes abandonment-bucket reconciliation hooks. |
| crates/node/src/channel_store.rs | Removes the floor-loss redb family/tables and related helper code/tests. |
| crates/incentive/src/store.rs | Removes the PoolFloorLossStore trait and in-memory implementation. |
| crates/incentive/src/lib.rs | Stops re-exporting the removed floor-loss store types. |
| crates/e2e/tests/pool_floor_ceiling_aggregate.rs | Updates e2e to rely on pool ceiling + per-signer live cap only. |
| crates/e2e/tests/abandonment_bucket_throttle.rs | Deletes the now-obsolete abandonment-bucket throttle e2e. |
| crates/e2e/src/node.rs | Updates node config rewriting helper to only manage pool_floor_signer_live_windows. |
| crates/common/src/config/types.rs | Removes abandoned-bucket config fields; keeps live cap config and docs. |
| crates/common/src/config/resolved.rs | Removes resolved fields for the deleted abandonment-bucket knobs. |
| crates/common/src/config/mod.rs | Removes defaults and resolution logic for deleted abandonment-bucket knobs. |
| crates/cli/tests/config_validate.rs | Drops removed resolved config fields from CLI config validation test fixture. |
| crates/cli/src/commands/config.rs | Removes CLI validate-summary output and default-config comments for deleted knobs. |
| adr/appendix-observability.md | Removes the deleted decdn_floor_loss_persist_failures_total metric from the appendix. |
| adr/003-payments.md | Updates ADR 003 to remove abandonment bucket design and describe the remaining defenses/residuals. |
Review details
Suppressed comments (1)
crates/node/src/handlers/client/dispatch.rs:460
- The comment still says
FloorReservation“reconciles … to the actual unpaid loss” at stream end, butFloorReservationnow only tracks and releases live reservation (released when repaid, otherwise released on drop). This wording is misleading and still implies the removed abandonment/dead-charge behavior.
// a bounded range or tail resume — and held for the stream's lifetime; the
// `FloorReservation` guard reconciles it to the actual unpaid loss at stream
// end.
- Files reviewed: 28/29 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ubsystem # Conflicts: # crates/node/src/handlers/client/mod.rs # crates/node/src/handlers/client/wire.rs # crates/node/src/metrics.rs
Address Copilot review on #1957: several changed-region comments still described `FloorReservation` as debiting a signer's abandonment bucket / dead charge on an abnormal drop. With that subsystem gone, an unrepaid drop only releases the pool's live floor headroom — no charge survives it. Corrected the dispatch/window/mod comments, the runbook's signer-floor-cap section (which also named a non-existent knob — the real one is `pool_floor_signer_live_windows`), and two stale test docstrings. Comments and docs only; no behavior change. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Coverage reportTotal: 82.63% (was 82.77%, ▼ 0.14%) — 74361/89995 lines
History
|
* fix(node): keep an abandoned stream's free floor as floor debt Every stream opens with a free credit floor of one interval plus the verify lag. An unpaid stream's guard released its reservation on drop and kept nothing, so the pool ceiling and the per-signer cap bounded only concurrent floors. A client that never paid could take a floor, reset, and repeat: about 100 MiB/s of free download per peer at the default serve limit, with upstream USDC fronted on every miss. An unrepaid FloorReservation now charges its unpaid bytes, capped at the reserved floor, as floor debt on the signer and the pool row, in the same lock hold that releases its live reservation. Admission counts live floor plus debt at both levels, so rotating signer keys meets the pool bound (Unfunded) and one key meets its k-window cap (NotFound). Payment past a stream's own floor clears debt; time does not, so it is not the signer-keyed rate #1957 removed. The in-flight re-checks stay live-only. No wire, config or persistence change: a restart or a pool reclaim forgives debt. ADR 003 states the floor-debt bound and its residuals (cross-node fan-out, restart forgiveness, honest-key lockout at about k unrepaid windows) and drops the "sequential abuse is not gated" position. Closes #2767 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(node): count a frame as unpaid before its write A client controls its stream receive window, so it can read part of a frame and then stop the stream. The write fails, `delivered` never counts the frame, and the abandoned stream charged no floor debt for bytes that left the node. Both serve loops now report the frame's exposure to the floor guard before the write. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(node): reconcile the floor at each credit and keep clearing sibling debt The serve loops reconciled the floor reservation only after a whole recoup batch. A stream that paid past its floor and then failed a later proof in the same batch left before the reconcile, so its drop charged debt and its surplus cleared none. Both loops now reconcile at each credited proof through `FloorReservation::reconcile_paid`. A paying guard also latched "owes nothing" after its first clear, so a sibling stream that abandoned later never had its debt cleared by that guard's further surplus. The latch is gone; the surplus tally alone keeps the lock to reconciles where the surplus grew. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(node): charge floor debt for the client's own conduct only A strict lockout makes a wrong charge permanent, so who ended the stream now decides the debt. Both serve wrappers judge the end through `FloorReservation::settle_end`: a peer-attributable error, a rejected voucher or a spent proof budget keeps the unpaid floor as debt; a node or upstream fault, a takedown, the size cap or a funding stop forgives it. The drop also charges a stream that paid its floor and then left a window unpaid, so pay-a-floor-take-a-floor no longer escapes the bound. `PoolFloorState` gains `charge_live`/`release_live` and a debug-build sum check, so every two-level change lives in one impl. The guard reads its entry through one epoch-filtered helper and updates the surplus tally under the lock. Floor refusal logs carry the live and debt parts, and a debt-driven pool refusal gets its own line. Tests pin the clearing arithmetic (no double offer, pool clears only what the signer cleared, fully paid small streams owe nothing), the end classification, the stale-guard clear, and the repaid-then-left charge. ADR 003/005/039, the runbook (new cause 4), the CHANGELOG and stale "live cap" comments match the behaviour. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
What
Spec-discipline review of the two serve-path concurrency fan-out payment defenses, run through the
decdn-spec-disciplinelens. The attack: N distinct signers/streams on one shared pool each individually pass "remaining ≥ floor" but collectively exceedremaining.Keep — the genuine fan-out defenses
Authoritative
getPool remainingalone does not close the hole: it is a read, not a reservation, so N concurrent admits all see the sameremaining ≥ floorand all pass. The local accumulator is what turns that number into a bound.remaining − M. The one bound a free-to-mint signer cannot evade.k · one_window) — protects a shared pool's named co-tenants from one key taking the whole live budget. Also correctly subsumes the feat(payments): bound per-lane credit exposure with a concurrent-stream admission cap #1697 per-lane concurrency bound (per-lane ≡ per-signer on one node).Cut — the per-signer abandonment leaky-bucket subsystem
Fails the trustless axiom (gate 2): a signer identity is free to mint, so rotating the key resets any signer-keyed rate tally — the same reason the client-reputation ledger was deleted. The sequential-abuse residual it closed is one ADR 003 already accepts: a slow real-egress trickle that grows with neither the pool nor the network, so it is not scale infrastructure.
Removed: the durable
PoolFloorLossStore(trait + memory impl + the redbfloor-loss.redbdatabase), thepool_floor_signer_bucket_windows/pool_floor_signer_refill_secsconfig knobs, debit-on-drop with fronted-upstream sizing, the forget tombstones (#1781 machinery), thefloor_loss_persist_failuresmetric + Prometheus alert, and the dedicated e2e test. The floor accumulator is now purely in-memory (no stream is live at restart, so a restart correctly clears it).Reduce — the #1697 per-lane surcharge → a heal-path counter
The pool ceiling + per-signer live cap already bound same-lane concurrency, and more correctly: they reserve the actual span-capped floor rather than a flat full-window surcharge, so two sub-window streams that genuinely fit are no longer spuriously refused (the surcharge was the discouraged "fraction of deposit" shape the absolute per-signer cap replaced). The
active_streamscounter stays — the wallet-less-resume heal (#1954) reads it to tell a lone wedged stream from a concurrent-sibling out-of-order voucher.Net
29 files, +315 / −4170. ADR 003 §Pool solvency and the observability appendix updated to match.
Verification
cargo clippy --workspace --all-targets --all-features— cleancargo nextest run(incentive/common/cli/node) — all passRUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items— cleancargo fmt --check— cleancargo test --no-run -p decdn-e2e --features anvil-e2e— compilesScope note
The pool-existence + solvency work (synchronous
getPoolbefore admit, deleting the fail-open branches / mid-stream recheck / async resolver) is owned in a separate change; this PR touches only the two concurrency defenses.🤖 Generated with Claude Code