Repository navigation
Description
Summary
Every new lane starts with a small credit window and ramps quickly to a credit_max ceiling as its own payments confirm. No per-client/per-lane reputation storage, no graduation ledger — just a fixed ramp curve. This is deliberately much simpler than storing client/lane identities and graduating them to a max window (the reputation approach in #1668).
Why
The credit window (unbilled egress a node fronts per lane) must be ≥ BDP = throughput × RTT for continuous streaming:
| Lane | 20 ms | 50 ms | 150 ms |
|---|---|---|---|
| 1 Gbps | 2.5 MB | 6.25 MB | 18.75 MB |
| 10 Gbps | 25 MB | 62.5 MB | 187.5 MB |
But that standing window is exactly the per-lane free-ride an attacker draws once. A fixed window is therefore either throughput-wrecked (small → chunk/RTT, ~10 Mbps at 1 chunk / 50 ms) or a large free-ride (big). A ramp resolves the tension: start small (safe), grow with confirmed payment (fast for payers, pinned for non-payers).
Design
credit_max— window ceiling, BDP-derived per lane (a 10 Gbps lane needs a larger max than 1 Gbps), node config. Not a fixed global constant.- New lane starts at the floor: one chunk (~100 KB–1 MB, the payable cadence).
- Window grows per confirmed payment at a fixed
credit_ramp_speed— lower = faster ramp,0= instant fullcredit_max. - A non-paying lane stays pinned at the floor → one chunk, RTT-bound. It never unlocks the big window, so it never gets the big free-ride.
- Exponential ramp reaches
credit_maxin ~log₂(target)RTTs (sub-second for an honest payer).
Explicitly not reputation
Stateless per lane beyond the current window value — no stored client history, no graduation table. The window is a pure function of this lane's confirmed payments. That statelessness is the point.
Params
credit_max— window ceiling, BDP-derived, node config.credit_ramp_speed— ramp rate; lower = faster,0= instant full speed.
Retires — the existing fixed credit window
This replaces the flat downstream credit window that ships today:
credit_window_bytes— config, default 8 MiB (DEFAULT_CREDIT_WINDOW_BYTES,crates/common/src/config/mod.rs), ADR 003 §Credit window: "how far past cleared payment the node streams before collecting a voucher; floored at one voucher interval." Every lane receives the full window immediately — no ramp. Resolves toResolvedConfig.credit_window_bytes: u64and is consumed on the serve path (and referenced client-side incrates/cli/src/commands/fetch.rs).
Retire it and its credit_window_bytes / DEFAULT_CREDIT_WINDOW_BYTES surface, folding the 8 MiB default into the new credit_max ceiling. The behavioural change: a lane no longer gets the full window on first contact — it starts at one chunk and ramps to credit_max per credit_ramp_speed. The ADR 003 §Credit window text is rewritten from "fixed window" to "ramped window, ceiling credit_max".
Retires — the upstream cache-miss seed-leech caps (ADR 037 / #856)
The three ADR 037 §Seed-leech caps are the same "bounded, history-ramped credit" idea on the upstream (node-as-buyer) leg. On the fused serve-miss path each pulled chunk is forwarded to the client immediately (pulled ≈ served), so the upstream pull and the downstream serve are one stream — the per-lane ramp governs both, and all three caps are deleted, not merged:
pull_ahead_bytes(per-requestpulled − paidwindow) → replaced bycredit_max. The serve path already takes.max(credit_window, pull_ahead_bytes); on the fused stream there is nothing left for a separate per-request pull window to do.share_ratio/pull_share_ratio_percent(pull ≤ratio × served-to-peer+ allowance) → replaced bycredit_ramp_speed. History-gated window growth is the ramp.max_unrecouped_leech_bytes(node-wide aggregateΣ pulled − Σ served) → replaced by the existing pre-flight deposit guard + pool solvencyM. ADR 037's deposit guard already refuses a cache-miss pull unless the requesting pool's remaining deposit covers it, so the node never fronts upstream USDC that isn't deposit-backed. Node-wide speculative exposure is therefore already bounded byΣ pool deposits— a real-capital bound, tighter than a byte counter, and un-gameable by a flood of throwaway pools (unfunded → refused). The crude node-wide byte budget is strictly dominated by it.
Delete all three [cache] knobs (pull_ahead_bytes, pull_share_ratio_percent, max_unrecouped_leech_bytes) and the crate::leech_governor::LeechGovernor they drive. The per-lane ramp (this issue) plus the pre-flight deposit guard already do everything they did — the whole seed-leech-cap layer is subsumed, not carried forward.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsDone
Activity
Merge origin/main into #1669: reconcile ramped credit window with fix…
docs: qualify credit-window exposure bound with floor + divisor=0; fi…
feat: credit slow-start — ramped credit window (start at floor, ramp …
feat(payments): implement PayWord hash-chained per-MB meter (#1752)