Skip to content

fix(node): wait out a proof while the stream's bytes still drain - #2272

Merged
thiras merged 2 commits into
mainfrom
fix/2230-proof-wait-transport-progress
Oct 2, 2026
Merged

thiras merged 2 commits into
mainfrom
fix/2230-proof-wait-transport-progress

Conversation

@thiras

@thiras thiras commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

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_window at noq's 10 MB per-connection default (runtime/mod.rs), so commit_one_proof started its fixed 10 s VOUCHER_READ_TIMEOUT clock 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

  • New handlers/client/proof_wait.rs. The read future stays pinned for the whole wait and races a 1 s progress poll. Each poll samples Connection::stats().frame_tx.stream, the count of STREAM frames sent. The wait faults with PeerFault:
    • no proof and no transport progress for 10s after 10 s with no new STREAM frame;
    • the chunk's proof wait passed 30s at PROOF_WAIT_CEILING, even while frames keep advancing. The ceiling is per owed chunk: a ChunkDeadline starts 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.
    • Keep-alive PINGs are not STREAM frames, so an idle client still faults at 10 s.
    • The decision lives in the pure proof_wait_verdict / ProgressClock pair.
  • Path stats on the fault (2b). The fault names the selected path from iroh 1.3 Connection::paths() → Path::is_selected / remote_addr(): relay, direct IPv4 or direct IPv6, with no address. It also gives that path's PathStats: RTT, cwnd, lost_packets, congestion_events and black_holes_detected. All of it lands in the serve_stream failure span, with no new metric.
  • Plumbing. serve_stream takes the Connection (a cheap clone from the accept loop). It passes &conn through deliver/deliver_loop, serve_via_window_pull_through, serve_via_backend_origin and serve_leg/serve_leg_loop to commit_one_proof.
  • Comments. Test and e2e comments that described the 10 s backstop now say it is 10 s with no transport progress. A parked client that has read every byte shows no progress, so those tests still hold at 10 s.
  • CHANGELOG entry under Fixed: the operator-visible error text changed.

No ADR, wire, config or on-chain change. No ADR states the proof-read timeout.

Reviewer notes

  • Poll cadence (deviation from the plan sketch). The plan sketched a check once per 10 s sleep. Sampling every 1 s and timing from the last observed progress gives a tighter bound. With 10 s ticks, a wait that starts while the buffer drains for 100 ms sees "progress" at the first tick, so a dead client gets 20 s. With 1 s polls it faults between 10 s and 11 s.
  • The signal is per connection, and it counts retransmissions. Sibling streams on the same connection, and PTO retransmits on a lossy or black-holed path, also advance 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.
  • An IPv4-mapped IPv6 address reports as direct IPv4.

Verification

  • cargo fmt -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items
  • cargo nextest run -p decdn-node: 1549 passed. This includes 10 new proof_wait unit 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 is repeated_zero_credit_proofs_cannot_extend_a_chunk_past_the_ceiling, which fails with 8 proofs if the ceiling restarts per attempt.
  • New loopback test 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.
  • Existing voucher_read_timeout_ends_a_parked_delivery and the 8 s-budget heal tests still pass.
  • cargo build --bin decdn-node, then cargo nextest run -p decdn-e2e --features anvil-e2e -E 'binary(pool_floor_ceiling_aggregate)': passed.
  • pre-commit run --files <changed files>: passed
  • User-visible change: CHANGELOG.md entry added
  • Design change: none (node-local constant)

🤖 Generated with Claude Code

https://claude.ai/code/session_01NHKbG6Jm75vFMLTNqK8ppz

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
Copilot AI balanced review requested due to automatic review settings October 1, 2026 20:55
@thiras thiras self-assigned this Oct 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Medium severity

Open (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.

@github-code-quality

github-code-quality Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 99d15de in the fix/2230-proof-wait-... branch remains at 87%, unchanged from commit e8a4a77 in the main branch.

Show a line coverage summary of the most impacted files.
File main e8a4a77 fix/2230-proof-wait-... 99d15de +/-
crates/cache/src/engine.rs 95% 94% -1%
crates/node/src/dht/publish.rs 92% 92% 0%
crates/client/src/lib.rs 92% 92% 0%
crates/client/s...c/connection.rs 97% 97% 0%
crates/protocol/src/framing.rs 97% 97% 0%
crates/client/src/scheduler.rs 95% 95% 0%
crates/node/src...lient/window.rs 76% 76% 0%
crates/node/src...ent/dispatch.rs 83% 83% 0%
crates/node/src...nt/serve_leg.rs 91% 91% 0%
crates/node/src...t/proof_wait.rs 0% 96% +96%

Updated October 02, 2026 02:12 UTC

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
@thiras
thiras merged commit 3a565c1 into main Oct 2, 2026
30 checks passed
@thiras
thiras deleted the fix/2230-proof-wait-transport-progress branch October 2, 2026 02:17
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants