Repository navigation
Description
Summary
A single transient transport drop mid-transfer permanently strands a payment channel (and its on-chain deposit). The payment layer is not resilient to disconnects: the client's persisted voucher watermark lags what it actually signed/sent, so an unclean exit desyncs it below the node's last-accepted nonce; every subsequent fetch on that channel then re-signs a stale nonce and is rejected, and there is no non-terminal way to recover — coop-close's over-claim guard refuses to settle above the client's (now-behind) record.
This turns an ordinary flaky-network event into a lost channel + locked deposit. It is easy to hit on large transfers and single-stack/NAT'd nodes.
Real-world repro (observed)
Serving a 708 MB blob; the first fetch exited before persisting its full voucher watermark. The exact trigger (a timeout, an interrupt, a transient drop) is incidental — normal transfers complete fine — the point is the client had advanced further than it durably saved:
- First fetch ran and vouchers flowed; the client signed/sent up to nonce 182 (the node accepted them) but exited having persisted only up to nonce 119.
- Retry →
Error: frame read failed: frame I/O error: early eof(client re-signs a stale nonce ≤119; node drops the stream after the first chunk). decdn channel coop-close→Error: provider over-claimed: waiver (1792, 182, 187522216) exceeds authorized (1162, 119, 121461928).
The node holds vouchers up to nonce 182 (amount 1792 µUSDC, 187,522,216 bytes); the client only persisted up to nonce 119 (1162 µUSDC, 121,461,928 bytes) — it signed the rest but lost them on the unclean exit. The channel is now unusable and its deposit un-reclaimable without a unilateral on-chain close. (Recovery required abandoning the channel and opening a fresh one.)
Proposed fixes (resilience, in priority order)
- Durable, write-ahead voucher watermark (client). Persist the outgoing nonce/amount to the buyer-channel store before the voucher is put on the wire (or make send+persist atomic), so a crash/drop can never leave the persisted watermark behind what the node accepted. This alone prevents the desync. Relevant:
decdn_client_pull(voucher signing/send loop) + the buyer-channelredbstore; see the existing "the next reuse may re-sign a stale nonce" warning incrates/cli/src/commands/fetch.rs. - Resumable
fetch. The wire protocol already supports byte-offset resume (StreamRequest.byte_offset, "resume from the last BLAKE3-verified byte" —crates/protocol/src/client.rs:158-178). Havedecdn fetchkeep a partial output + resume from the last verified byte on a transient drop, instead of restarting (which re-poisons the channel and re-downloads). - Non-terminal channel-state resync query. Add a client→node request that returns the node's signed last-accepted
{nonce, amount, bytes_delivered}WITHOUT setting the cooperative-close-signed flag (unlikeCooperativeCloseRequest, which is terminal —handle_cooperative_close→mark_cooperative_close_signed, after which serves reject withCooperativeCloseSigned). A client with a lagging watermark can then resync and resume the same channel. - Coop-close reconciliation when the client is behind. When the node's declared state exceeds the client's record, the node holds the client's OWN signed vouchers for the gap — it should return them (or the highest signed voucher) as proof so the client can verify (they're its own signatures), advance its watermark, and settle at the true state, instead of the current over-claim dead-end that strands the deposit.
Impact
Any mid-transfer disconnect (common on large blobs / single-stack / NAT'd nodes) currently strands a channel and its deposit and blocks further fetches on it. Fix #1 makes drops non-fatal; #2 makes large transfers survive them; #3/#4 provide recovery when a desync happens anyway.
Related
- fetch: stream_fetch omits the ADR 005 client identity binding, so reactive origin pull-through never fires for a direct client fetch #1115 (client identity binding for reactive origin pull-through) — same client pull path.
- This issue is about the payment layer being resilient regardless of why a fetch exits early (timeout, interrupt, crash, or a transient drop). Normal transfers complete fine; the failure mode is specifically that an early exit strands the channel + deposit.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
alpergundogdu commentedon Jul 13, 2026
Sharper spec for fixes #3 (resync) + #4 (coop-close reconciliation): "channel sync"
The recovery primitive for both is the same and is cryptographically clean: the node returns the client's OWN signed voucher(s) above the client's persisted watermark as proof. The client verifies the signature is its own; if valid, it advances its watermark to that nonce. It can never be tricked into over-paying, because it only ever advances on a voucher it actually signed — the node cannot forge a higher one.
Surface it two ways:
Explicit —
decdn channel sync --provider-address …: asks the node for the highest voucher it holds from this client; the node returns that signed voucher; the client verifies its own signature and advances its persisted watermark to that nonce.Automatic (self-healing): when the node rejects a voucher mid-fetch for an invalid/stale nonce, it returns its highest-held client voucher; the client verifies + bumps its watermark + resumes — no manual step.
This subsumes the earlier stopgap idea of a
--accept-overclaim/DECDN_ACCEPT_OVERCLAIMflag (which just "trusts the node"): with sync, the client reconciles against its own signatures, and the coop-close over-claim dead-end disappears entirely (once synced,coop-closesettles normally). Recommend implementing #3/#4 as this single "channel sync" mechanism (explicit command + automatic on nonce-reject).fix: the money the last round's fixes could still lose (#1145 review)
fix: make the reservation structural, and correct the claims that wer…
fix: bound the requester's fetch loop, and classify what comes back (#…
yigitdot commentedon Jul 18, 2026
Cross-reference: #1293 (DECDNMAN chunk-manifest reconstruction, #1183) lands a partial, chunk-granularity version of fix #2 (resumable fetch) for manifest-published files specifically.
For a chunked file, part files at
~/.decdn/downloads/<manifest-hash>/chunk-<index>.partare retained by default, and a retained part that still verifies against itsChunkEntryBLAKE3 hash is reused rather than re-fetched. So an interrupted multi-chunk download resumes at chunk granularity without re-paying for chunks already pulled and verified.Two things that does not cover, so this issue stays fully open:
StreamRequest{byte_offset}resume this issue asks for is untouched.Worth flagging one thing #1293 surfaced that bears directly on the watermark-desync mechanism at the heart of this issue.
ChannelContextsnapshots the channel's voucher watermark (prior_nonce) at construction, andfetch_blobadvances it in the store as it pays. Hoisting a single context across a multi-chunk file would therefore re-sign an already-spent nonce and the node would reject it — the same stale-nonce failure this issue reports, reachable without any crash or disconnect. #1293 avoids it by rebuilding the channel context per chunk (see the comment atcrates/cli/src/commands/fetch.rs:527).That is a workaround at the call site, not a fix to the underlying invariant. It reinforces fix #1 (write-ahead durable watermark): as long as the persisted watermark can lag what was actually signed, every new multi-request caller has to know to rebuild context or silently poison the channel.
altanoruc commentedon Jul 24, 2026
Automated implementation triage note for a later run: this combines four independently mergeable fixes (write-ahead voucher durability, byte-range fetch resume, non-terminal signed-voucher sync, and cooperative-close reconciliation), so one agent cannot satisfy the closure condition within the small-PR ceiling. Please split them in dependency order. For the first slice, pin the exact durability boundary (persist-before-sign vs persist-before-send and rollback/retry behavior); for channel sync, pin the wire request/response/error variants and whether automatic stale-nonce recovery ships with or after the explicit CLI command. Each slice then has a deterministic crash/drop regression.
thiras commentedon Jul 28, 2026
Status update after working through this alongside #1132 and #1120. Three of the four proposed fixes are addressed; the fourth is split out to #1495.
1. Durable write-ahead voucher watermark — recommend closing as superseded, not implementing.
A pre-send persist would add a client-side fsync per voucher, which cuts directly against the group-commit direction #1483 just took, to close a residual the reconciliation path already recovers from. The
VoucherProgressdocs (crates/client-pull/src/lib.rs) already scope the gap to one-sided ack loss and name a reconciliation read as the fix — which is what #1481 shipped. Both fetch paths persist the acked watermark on the error path, so an unclean exit loses at most the one voucher whose ack was in flight.2. Resumable
fetch— done.decdn fetchnow writes each bao chunk group to<output>.partialas it verifies and renames it into place, instead of buffering the blob and writing once. A partial from an interrupted run is picked up automatically, the node is asked for the un-fetched tail only, and only that tail is paid for. Peak memory is one chunk group rather than ~2x the blob.One thing that fell out of implementing it, worth recording: a prefix inherited from disk cannot be verified in isolation. bao verifies a chunk group through the parent hashes covering the rest of the tree, and a client holding only a prefix never received them — so the plan of "recompute the prefix's outboard" does not actually work. A resumed fetch instead re-hashes the assembled file against the content hash before promoting it, and discards the partial on mismatch. A fetch from byte 0 skips that, since every byte was verified on the wire.
3. Non-terminal channel-state resync — already delivered by #1481.
The
WatermarkBundleon a watermark-gatedVoucherRejectedis exactly this: the client verifies the higher watermark against its own signature and reseeds, without the channel being frozen. Confirmed non-terminal —mark_cooperative_close_signedis called only from the coop-close handler (crates/node/src/handlers/client/voucher.rs:575), never from the reject path.4. Coop-close reconciliation — still open, moved to #1495.
This one needs a wire change, so it was kept out of the batch.
CooperativeCloseAuthcarries only the provider's waiver signature, so the client has nothing to check against its own key andprepare_closecan only refuse. The node holds the client's last-accepted voucher signature but does not send it. Details and proposed surface in #1495.Net effect on the repro: reaching the stranded-channel dead-end now requires a desync and never fetching again on that channel before closing, since any fetch heals the watermark.
Leaving this issue open to track item 4 via #1495, or it can be closed in favour of #1495 if you prefer that shape.
perf(cache,cli,node): bounded-memory blob delivery + resumable decdn …
fix: address multi-agent review of the two-tier deposit (#1497)