Repository navigation
fix(node): wait out a proof while the stream's bytes still drain - #2272
Merged
Merged
Conversation
A write returns once noq buffers it, and the node's send window is noq's 10 MB per-connection default, so the 10 s proof clock could start while about 9.5 MiB was still in flight. On a slow or young path the client could not receive and pay chunk 1 in time, and the leg died at proof 1 with its lane's ramp carry. The proof wait now samples the connection's sent STREAM frame count every second. It faults after 10 s with no proof and no new STREAM frame, and in every case after 30 s (PROOF_WAIT_CEILING), counted from the start of that proof's wait. Keep-alive PINGs are not STREAM frames, so an idle client still faults at 10 s. The read future stays pinned across samples. Both faults keep PeerFault and name the selected path (relay or direct, IPv4 or IPv6) with its RTT, cwnd, lost packets, congestion events and black holes detected, so the serve_stream failure span shows the path state the issue asked for. The connection is threaded from serve_stream to commit_one_proof through deliver, serve_leg and both window serve paths. The decision is a pure function with unit tests; a loopback test pins that a payer that stops reading and paying faults at the 10 s no-progress timeout, not at the 30 s ceiling. Refs #2230 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NHKbG6Jm75vFMLTNqK8ppz
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The per-proof ceiling compounds across eight allowed attempts, extending the documented stream-liveness bound to nearly four minutes.
Review effort: Balanced
Findings: 1
What changed in this PR
Adds transport-aware payment-proof waiting so slow clients are not faulted while buffered bytes drain.
Changes:
- Adds 10-second no-progress and 30-second per-proof limits.
- Reports selected-path congestion diagnostics on timeout.
- Threads connections through delivery paths and updates tests/docs.
| File | Description |
|---|---|
CHANGELOG.md |
Documents proof-wait behavior. |
crates/e2e/src/client.rs |
Updates timeout documentation. |
crates/e2e/tests/pool_floor_ceiling_aggregate.rs |
Updates held-stream timing comments. |
crates/node/src/handlers/client/delivery.rs |
Passes connections into proof collection. |
crates/node/src/handlers/client/dispatch.rs |
Supplies connections to stream handlers. |
crates/node/src/handlers/client/mod.rs |
Registers proof-wait logic and documents timeout semantics. |
crates/node/src/handlers/client/proof_wait.rs |
Implements progress-aware waiting and path diagnostics. |
crates/node/src/handlers/client/serve_leg.rs |
Passes connections through pull-through delivery. |
crates/node/src/handlers/client/voucher.rs |
Uses the new proof wait. |
crates/node/src/handlers/client/window.rs |
Threads connections through origin paths. |
crates/node/src/handlers/client/wire.rs |
Updates fault-source documentation. |
crates/node/tests/client_loopback.rs |
Adds no-progress timeout coverage. |
crates/node/tests/node_origin_pull.rs |
Updates proof-wait comments. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit 99d15de in the Show a line coverage summary of the most impacted files.
Updated |
PROOF_WAIT_CEILING bounded a single proof read. Both recoup loops (serve_leg.rs and delivery.rs) call commit_one_proof up to MAX_PROOFS_PER_CHUNK = 8 times for one chunk, and each call started a fresh 30 s ceiling. A payer that sent a zero-credit proof just before each deadline, on a connection whose STREAM frames kept advancing, could hold the stream for about 8 x 30 s, against 8 x 10 s before. Each owed chunk now starts one ChunkDeadline before its first attempt, and every proof wait for that chunk counts the 30 s ceiling from it. The 10 s no-progress timeout still runs per attempt. The time a chunk can hold the stream is now 30 s in total. A paused-time unit test sends a proof 1 s before each per-proof deadline on a progressing connection and asserts the chunk faults at the ceiling after one proof. It fails with eight proofs when the ceiling restarts per attempt. Refs #2230 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NHKbG6Jm75vFMLTNqK8ppz
7 tasks done
thiras
added a commit
that referenced
this pull request
Oct 2, 2026
* fix(node): bound the proof wait on time and classify its faults Follow-up to #2272, from its review. - Hard ceiling. The per-chunk ceiling was checked only on progress ticks, and each new proof wait restarted its own 1 s poll, so sub-second zero-credit proofs around the deadline let a chunk run past 30 s. A sleep_until arm now fires the ceiling on time, after the biased read arm, so a proof already buffered still wins and a wait that starts past the deadline faults at once. - One per-chunk value. ChunkProofs holds a chunk's proof count and its wait start; both recoup loops make it once per owed chunk and pass it by reference, replacing ChunkDeadline and the separate attempts counters. - Typed fault marker. ProofWaitFault (stalled or past the ceiling) rides beside PeerFault. The miss serve leg leaves the ceiling out of decdn_node_pull_through_client_abandoned_total; the inbound reason split (declined or abandoned) is unchanged, so every inbound failure still counts on exactly one reason counter. - Measured fault text: the time since the last STREAM frame, the chunk's total wait, and the STREAM frames this wait saw; the path's loss counters are labelled lifetime totals. - Seam test on a real loopback connection: writing stream data raises the STREAM frame count, and keep-alive PINGs over 3 s of idle do not. - Paused-time tests for sub-second proofs around the deadline and for a wait that starts past it; the loopback stall test now checks inbound failure attribution and that no node fault counts. - Docs and comments: the per-chunk bound, the effect of sibling traffic, and stale "voucher-read"/"proof-read timeout" wording. Refs #2230 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NHKbG6Jm75vFMLTNqK8ppz * fix(node): report the sample that decided a proof-wait fault The proof wait re-sampled the STREAM frame count after the select had already chosen a fault. A frame sent in between reset the no-progress clock, so a stall could report "no transport progress for 0.0s" and a frame the decision never saw. Each arm now takes its sample and the fault text formats that same sample. Refs #2230 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NHKbG6Jm75vFMLTNqK8ppz --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What
The node's wait for a payment proof now counts transport progress, so it no longer faults a paying client whose bytes are still in flight. This is PR 2 of the #2211/#2230 plan (cause 3, plus node-side diagnostics).
Refs #2230
Root cause
A write returns once noq buffers it. The node leaves
send_windowat noq's 10 MB per-connection default (runtime/mod.rs), socommit_one_proofstarted its fixed 10 sVOUCHER_READ_TIMEOUTclock while up to ~9.5 MiB could still be in flight. On a slow or young path the client could not receive and pay chunk 1 within 10 s. The leg died at proof 1 (proof 1 of at most 8 … proof read timed out after 10s), and the lane's ramp carry died with it. That is the shape in every #2230 node trace.Change
handlers/client/proof_wait.rs. The read future stays pinned for the whole wait and races a 1 s progress poll. Each poll samplesConnection::stats().frame_tx.stream, the count of STREAM frames sent. The wait faults withPeerFault:no proof and no transport progress for 10safter 10 s with no new STREAM frame;the chunk's proof wait passed 30satPROOF_WAIT_CEILING, even while frames keep advancing. The ceiling is per owed chunk: aChunkDeadlinestarts before the chunk's first attempt in both recoup loops, and every proof wait for that chunk counts from it. Proofs that credit nothing cannot stretch it past 30 s in total.proof_wait_verdict/ProgressClockpair.Connection::paths()→Path::is_selected/remote_addr(): relay, direct IPv4 or direct IPv6, with no address. It also gives that path'sPathStats: RTT, cwnd,lost_packets,congestion_eventsandblack_holes_detected. All of it lands in theserve_streamfailure span, with no new metric.serve_streamtakes theConnection(a cheap clone from the accept loop). It passes&connthroughdeliver/deliver_loop,serve_via_window_pull_through,serve_via_backend_originandserve_leg/serve_leg_looptocommit_one_proof.No ADR, wire, config or on-chain change. No ADR states the proof-read timeout.
Reviewer notes
frame_tx.stream. The 30 s ceiling bounds the wait in those cases. Because the ceiling is per chunk, a chunk holds the stream for at most 30 s, against 8 attempts × 10 s = 80 s before this PR.Verification
cargo fmt -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningsRUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-itemscargo nextest run -p decdn-node: 1549 passed. This includes 10 newproof_waitunit tests: verdict bounds; progress keeps waiting; the no-progress clock runs from the last progress; the ceiling holds with progress; a later proof of a chunk keeps the chunk's ceiling; and paused-time tests of the async loop at 10 s and 30 s. One of them isrepeated_zero_credit_proofs_cannot_extend_a_chunk_past_the_ceiling, which fails with 8 proofs if the ceiling restarts per attempt.a_payer_that_stops_reading_faults_at_the_no_progress_timeout: a client reads the response, then reads and pays nothing, and is stopped in 9–15 s. As a mutation check, with the no-progress branch disabled it fails, because the stream is held to the 30 s ceiling.voucher_read_timeout_ends_a_parked_deliveryand the 8 s-budget heal tests still pass.cargo build --bin decdn-node, thencargo nextest run -p decdn-e2e --features anvil-e2e -E 'binary(pool_floor_ceiling_aggregate)': passed.pre-commit run --files <changed files>: passedCHANGELOG.mdentry added🤖 Generated with Claude Code
https://claude.ai/code/session_01NHKbG6Jm75vFMLTNqK8ppz