Repository navigation
Description
Client half of #1477. Filed separately because it has no durability constraint and can land independently of both #1477's serve-side work and the #1483 fsync debate.
What happens
After sending a voucher, the client blocks until VoucherAck returns before reading another chunk:
crates/client-pull/src/lib.rs:2212—self_payawaitsread_client_message(recv)for the ack.crates/client-pull/src/lib.rs:1604-1620(buffered path) and:2053(progressivenext_chunk) — both awaitself_payinline in the receive loop.
Why this half is free to fix
Unlike the serve side, there is nothing behind the client's wait. ChannelLedger::issue commits purely in memory — *self.committed.lock() = next at crates/client-pull/src/ledger.rs:213-216, a std::sync::Mutex<Cumulative>. No store write, no fsync.
The client's fsynced buyer-store write (Durability::Immediate, crates/incentive/src/buyer_channel_redb.rs:37) happens once per pull, not per voucher — ledger.snapshot() at crates/client-pull/src/lib.rs:1154, or settlement() on the abandon path (#852).
So the client's blocking wait is pure dead latency: one full RTT per voucher interval, protecting nothing. None of the ADR 003 §Off-chain voucher state persistence reasoning in #1483 applies here — that rule binds the delivering node.
Second effect: it serializes parallel streams to one provider
ChannelLedger::issue holds the per-channel mutex across the entire send→ack exchange (ledger.rs:180-191), by design — it is what guarantees strict nonce ordering.
Ledgers are keyed per channel ((Address, ChannelId), crates/node/src/buyer_ledgers.rs:43), so this does not affect multi-source fetches across different providers, which hold different channels and different ledgers. But it does throttle parallel range streams to a single provider: every voucher round trip on any one stream blocks voucher issuance on all the others, so N parallel streams to one fast provider degrade toward serial at the payment layer.
That is precisely the shape of "download a large file, fast" from a well-provisioned peer.
Fix
Issue the voucher and keep receiving; process acks off the critical path.
Nonce ordering is preserved by serializing issuance — the lock need only cover compute → sign → send, not the ack wait. The node requires monotonically increasing nonces, never ack-before-next.
The in-flight/settlement machinery already models this correctly. ChannelLedger distinguishes committed, in-flight, and settlement watermarks precisely because a voucher's fate can be unresolved (#1122, #1145) — pipelining widens that existing window from one voucher to a bounded few rather than introducing a new state. settlement() already settles high on ambiguity, which stays correct with several vouchers outstanding, though it will need to track a set rather than a single slot.
Bound the outstanding vouchers so a silent provider cannot make the client pay unboundedly ahead — though note the client still never pays for bytes it has not received, since vouchers are cumulative over delivered bytes.
Why it matters
Large-file delivery is the first wedge. With #1477 and #1483 fixed on the serve side but this left in place, the client remains the binding constraint at exactly the RTTs that matter for a geographically distributed CDN — ~10 MiB/s at 100 ms RTT, per the table in #1477.
Related
- Paid delivery is stop-and-wait per voucher: throughput is RTT-bound, not link-bound #1477 — serve-side credit window (the same change on the other end)
- Group-commit voucher fsyncs (ack after commit): amortise the 3.18 ms per-voucher commit #1483 — group-commit voucher fsyncs (serve-side only; does not apply here)
- Payment channels aren't resilient to a fetch exiting early: it strands the channel + deposit (durable watermark, resumable fetch, resync, coop-close reconciliation) #1122 / Buffered origin pull-through loads the whole blob into memory before serving #1132 — whole-blob materialization on both ends, the other large-file blocker
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
feat(payments): credit-window pipelined paid delivery (#1477)
refactor(client-pull): drop the outstanding-voucher cap (#1484)
feat(client-pull): optimistic paid-fetch loop, pipelined vouchers (#1484
feat(payments): credit-window pipelined paid delivery (#1477)
feat(payments): credit-window pipelined paid delivery (#1477) (#1485)