Repository navigation
Description
Goal
Let multiple streams on one (pool_id, signer, provider) lane settle out of order / concurrently, by making vouchers self-describing instead of reconstructing bytes_delivered from per-stream state.
Background
Today the wire Voucher carries only {signature, amount}; the node reconstructs cumulative bytes_delivered as shared_counter + this_stream's_delta (voucher.rs::verify_voucher). That reconstruction depends on stream-processing order, so an out-of-order / skip-ahead voucher recovers the wrong signer and is rejected — pinned by skip_ahead_voucher_on_a_concurrent_lane_is_rejected (#1698). Correctly-ordered concurrent settlement already works (#1690). This issue removes the ordering dependency.
Core change
Add bytes_delivered to the wire Voucher (it is already in the EIP-712 signed payload — just transmit it). The node verifies the signature against the wire-provided (amount, bytes_delivered) — identical to what the client signed — so verification is order-independent, and a higher cumulative supersedes lower ones.
Chosen over deriving bytes from amount: min_payment is many-to-one (~MB/rate ambiguity), so amount → bytes is not exact without a canonical-inverse spec plus a rounding residual, and on-chain redeem's floor check needs a signed byte count (or rate) regardless. Transmitting the already-signed value is simpler and exact.
Design rules (decided)
- Paid frontier correct-by-construction, not a clamp. The node advances a per-lane aggregate paid frontier from its own authoritative delivered count, capped by what the voucher amount covers — so
paidcannot exceeddeliveredbecause it is derived from it. No removable guard. - Attribution proportional to per-stream unbilled delivered, not equal — the serve leg knows its own delivered bytes, so per-hash / per-region receipts stay accurate. Advance each stream toward its own delivered.
- Credit window fixed at admission; refuse, never resize (ties to feat(payments): bound per-lane credit exposure with a concurrent-stream admission cap #1697). A new same-lane stream must fit the remaining budget or be refused (
BudgetExhausted); a drop frees budget for future admissions only. Live streams' windows never shrink (50+50→ refuse the third, not33+50+50). - Single-signer invariant. No nonce; highest-cumulative-wins is only safe with one monotone signer per lane. Make it explicit (reject divergent vouchers at equal amount; constrain delegated-signer setups).
Footguns to close
- Per-hash receipt attribution (a cross-stream voucher spans multiple blobs).
- Advertised-rate re-derivation over the aggregate jump, including the
RateFloorRaised(fix(node): rate-bounds race between signed StreamResponse and voucher acceptance #1382) interaction — which rate applies to a skipped span. - The coalescing frontier guards (
also_pace/ DECISION-B, serve_leg.rs:269) assume contiguous paid prefixes. - The no-progress guard and per-stream serve-loop locals (serve_leg.rs:334) assume this stream's vouchers settle this stream's deltas in order.
Open question
Delivery-vs-receipt lag: the node's delivered count runs ahead of what the client has received-and-signed. Bytes-on-the-wire resolves the signature side (both verify the client's signed value); the node still caps its paid frontier at its own delivered.
Wire / on-chain
Adding bytes_delivered to the postcard Voucher is a wire break — pre-launch, so change every side in one PR and delete the old shape (no compat shim). On-chain redeem already takes a signed (amount, bytes), so it is unaffected; confirm the floor path.
Acceptance
MUST flip skip_ahead_voucher_on_a_concurrent_lane_is_rejected (client_loopback.rs) — that test's scenario becomes accepted, landing the correct aggregate watermark — while keeping #1690's ordered-settlement correctness. Add coverage for: concurrent out-of-order settlement, drop-mid-flight continuation, admission refusal, proportional attribution.
Relationship
Complementary to #1697 (which bounds exposure via refuse-not-resize admission). This issue enables concurrent settlement; #1697 makes concurrent delivery safe.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsDone
Activity
test(protocol): update public-API snapshot for the Voucher bytes_deli…
fix(payments): address review — precise Voucher doc + fail-closed cre…
feat(payments): self-describing vouchers for concurrent same-lane set…
Merge origin/main into pool floor-credit bound
perf(node): hoist voucher ecrecover out of the per-lane lock (#1735) (#…
docs(adr): apply review dispositions to the PayWord ADR (#1670)
docs(adr): land PayWord (hash-chained per-MB meter) into ADR 003 (#1751)