Repository navigation
Description
Summary
Flip the direction of credit on cdn/client/v1. Today the node delivers ahead of payment and the payer pays only for bytes it has verified. This proposal has the node deliver only what the lane has already paid for, and has the client pay ahead within a window it sets itself.
The reason is identity cost. A node is a bonded operator with a persistent identity. A client is a key that costs nothing. Credit extended to a free identity is credit extended to everyone, so every node-side defense against a newly arriving client is either evadable by key rotation or turns into a lockout for the honest users who share a pool. Trust in this network only grows in one direction: a client decides over time how much it trusts deCDN nodes. A node never has a reason to trust clients more.
This came out of the review of #2873, which removes floor debt and reopens #2767.
The problem today
All figures use the market rate of about $0.00001 per MiB.
| Hole | What a patched client gets | Bound today |
|---|---|---|
| Free floor (#2767) | About 1 MiB per stream before any payment, with a fresh key each time | Request rate limits only: about 100 MiB/s per peer |
| Abandon at the top of the ramp | The window is paid / 2 up to 64 MiB, so paying for 128 MiB and leaving yields 192 MiB. Up to a third off every large transfer, repeatable |
None |
| Cache-miss drain | On a miss the node has already paid its upstream for the bytes the client never pays for. One floor per stream, two in the worst case | Request rate limits only |
The cache-miss case is theft, not only free riding: the attacker can be both the client and the upstream node, and collect the serving node's USDC.
Floor debt (#2779) tried to close the first hole with per-signer memory. It bounded the loss and created a lockout: one abuser on a shared pool stops service for every user of that pool, and a fresh key resets it anyway.
The proposal
- The node sends a chunk only when the lane's confirmed payment covers it. Node exposure to unpaid delivery is zero by construction.
- The client pays ahead within a client-local window. The window is capped in USDC per node, starts at about one chunk, and ramps with bytes verified from that node. A client may raise its caps as its confidence in the network grows. There is no node-side counterpart.
- Payment that is ahead of delivery is credit on the lane. A later stream on the same lane draws it down without a new signature.
- The contract and the voucher format stay as they are. Preimage
istill pays chunki. It is released earlier. - Voucher solvency rules stay as they are. Admission still confirms the pool, the capability and the signer cap on-chain. The reserve
Mand the mid-stream re-checks still cover proved-but-unredeemed vouchers.
What we gain
- The three holes close by construction. There is nothing for a fresh key to take, at the floor, at the top of the ramp, or through a cache miss.
- No memory held against a signer or a pool, so one abuser cannot lock out a sponsor's other users.
- Less node code. Estimated from a read of the node crate: 1,100 to 1,250 lines of production code and 1,500 to 1,800 lines of tests. This covers the floor reservation types, the per-pool floor ceiling, the per-signer window cap, the ramp-credit pool, the config keys
credit_ramp_divisorandpool_floor_signer_live_windows, the metricdecdn_serve_stream_rejected_signer_floor_at_cap_totaland the reject reasonSignerFloorAtCap. - Three accepted residuals in ADR 003 disappear: restart forgiveness, honest-key lockout, and the cross-node fan-out of free floors.
- A stolen window is hard to profit from. At first contact one chunk is worth less than the gas to redeem a lane. Mid-stream, delivering the prepaid window earns the node the same USDC and keeps the customer.
- The client's ramp survives key rotation and node restarts, because it is keyed on the node, not on the lane.
- Takedown latency drops, because the check can run before each send.
What we lose
- The payer's exposure is no longer zero. ADR 003 states that a byte that fails verification is never paid for. Under this proposal a dishonest or failing node can keep up to one client window, once per client. ADR 003, ADR 038 and ADR 039 state the zero-exposure property and change with it.
- Honest cancellation costs money. A cancelled download can leave up to one window per live lane on nodes the client never returns to: about $0.0026 for four lanes at 64 MiB. Today that is zero.
- Stranded credit is common, not rare. Multi-source steals, watchdog cancels, key rotation, capability expiry, pool replacement, a takedown and a gateway restart all leave prepayment on a lane. Over a run the loss is the cap times every node tried, not the cap times concurrency.
- Credit disagreement cannot be proven. What the client paid is authenticated by its own signature and the chain tip. What the node delivered is not. Every disagreement is a capped write-off.
- Small objects gain a round trip. A transfer under one chunk completes in one round trip today because bytes arrive before any payment. It needs payment before the first byte, unless payment rides in the opening flight or the lane holds standing credit.
- A network attacker can now cost a client money by cutting connections after payment.
- Sponsored key rotation strands credit. Sponsored capabilities live at most 48 hours, each renewal is a new lane, and the sponsor's pool pays for what is left on the old one.
- New durable state on both sides. The node needs a per-lane delivered counter that survives a restart (today it deliberately zeroes lane headroom). The client needs per-node memory of verified bytes and write-offs.
- The cache-miss serve loop must be re-derived. It is held together by matched constants whose failure mode is a silent hang. This is the riskiest part of the implementation.
- A coordinated release. An old client waits for bytes and a new node waits for payment. The SDKs and the mobile demos move in the same release.
What does not change
- Paper against an oversubscribed pool. One deposit can still back vouchers to many nodes, and each node still serves up to its redeem threshold before a redemption shows the drain. fix(node)!: drop floor debt and the per-IP rate layers, lower the default redeem threshold #2873 lowers that threshold from 1 USDC to 0.05 USDC.
- Request rate limits. A node does fifteen steps of work on an open before any payment could be read (signature recovery, chain reads, pool view lookups). The per-peer and global limits bound that and stay.
- Self-dealing and capability games.
Conditions for shipping
The adversarial pass concluded that the direction is right and the first sketch was under-specified. It should not ship without these.
- A per-node cap in USDC, a default maximum rate, and a ramp that remembers losses. The window is
min(cap, (verified_lifetime − k × lost_lifetime) / 2). A reset-and-re-ramp rule lets a node deliver 2W, keep W, and repeat. A permanent ban punishes an honest crash. A loss is recorded when the node is reached again and refuses to deliver against credit, never at a disconnect. - Carry fully specified. The node persists delivered bytes per lane. A stream draws lane credit with one lane-wide atomic debit before each send, so concurrent streams cannot each claim the same payment. The client stops paying ahead and drains before a cancel, a steal, a credential swap and an expiry. The
Underpaidrebase never moves below the price of bytes verified from that node. - Payment in the opening flight, so a small object keeps its single round trip.
- On a miss, the node's upstream prepayment for a stream never exceeds the downstream credit it holds for it. Otherwise the abandonment hole reopens one hop up.
Open decisions
- The meaning of the voucher field
bytes_deliveredunder pay-ahead: received bytes or paid bytes. Paid bytes would accrue governance vote weight on undelivered bytes. - The loss multiplier
kand the write-off age for an unreachable node. - Small objects: an exact voucher in the opening flight, or standing chunk-sized lane credit that needs no signature per object.
- Whether a node may prepay its upstream ahead of its downstream for latency, with its own capped exposure.
- The default per-node cap. It should sit near the real per-lane redemption gas, which needs measuring on the target L2. A client that raises its cap to dollars across many nodes is what would make an exit scam worth running.
- Whether to also lower the redeem threshold for unseen pools, to shrink the paper fan-out this proposal leaves open.
Evidence and limits
The analysis rests on a read of the ADRs and of the node and client crates at the head of #2873. Nothing was built, run or measured. Line counts and USDC figures are estimates. The per-lane gas figure in particular is an assumption.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsDone
Activity
alpergundogdu commentedon Nov 11, 2026
Draft ADR change: #2877, stacked on #2873.
One addition since the proposal was filed: verified blob size. The draft adds a size proof to
StreamResponseand to aProbeResponsethat carriestotal_bytes(the final BLAKE3 chunk and its path to the root). The receiver verifies it against the content hash, and any party can pass it on, starting from the origin at import.It belongs with this proposal because an unverified size is what stops a prepaying client from paying the tail of a transfer exactly: a node that inflates the claim can draw prepayment up to the client's window. With a verified size the client never overpays on a guessed size, a relay can compare the size with its
max_blob_sizebefore it pulls, and a multi-source fetch plans its ranges on a size that does not change. The wire encoding is not specified yet.alpergundogdu commentedon Nov 11, 2026
The verified blob size is now its own proposal, #2879, with its own draft ADR change, #2880. It is removed from #2877, which carries the credit direction only.
docs(adr): give a resuming payer a small backfill
alpergundogdu commentedon Nov 12, 2026
A gap in the proposal, now in the draft (#2877): the node counts a frame as delivered when it sends it, so the frames in flight when a connection drops are the payer's loss, and the proposal said a disconnect costs nothing. The draft adds a small backfill. A resume that follows a stream with no clean close gets the gap back as lane credit, within an allowance of the lane's paid bytes divided by 64 and a 4 MiB cap. The allowance comes from the lane's own payments, so a fresh key has none, and the node enforces it with no wire field. A patched client that claims a drop at every resume gets at most 1/64 of its paid bytes again.
feat(node)!: send only against lane credit, pace the miss pull by it
docs(adr)!: the payer fronts credit (#2877)
yigitdot commentedon Nov 26, 2026
Implemented by #2877 (95da7ad), whose body says "Implements #2876". A node sends a frame only when the payment on that stream covers it, and the payer pays ahead within a per-node window that is payer policy. ADRs 003, 005, 022, 037, 038 and 039 and
architecture.mddescribe per-stream credit. The one deferred credit-liveness case, a steal split, is tracked in #2902.yigitdot commentedon Nov 26, 2026
Follow-up to the closing comment: #2877 departs from this proposal in two places.
crates/node/src/handlers/client/credit.rsand ADR 003 § Credit Window.decdn getbuilds aPayAheadPolicy(crates/cli/src/commands/fetch.rs). Gateway pulls run the default policy. docs(adr)!: the payer fronts credit #2877 lists this as a known gap, and no issue tracks it yet.The steal-split gap is tracked in #2902.