Skip to content

fix(e2e): advance voucher watermark across ClientFixture::fetch retries (#1062) - #1125

Merged
thiras merged 3 commits into
mainfrom
fix/1062-clientfixture-retry-voucher-nonce
Jul 12, 2026
Merged

thiras merged 3 commits into
mainfrom
fix/1062-clientfixture-retry-voucher-nonce

Conversation

@yigitdot

Copy link
Copy Markdown
Contributor

What

Closes #1062.

The e2e ClientFixture::fetch retries stream_fetch in a loop (to wait out the node's chain-watcher catch-up) while reusing one immutable ChannelContext pinned at prior_nonce = prior_bytes_delivered = prior_amount = ZERO. Once the node has observed the channel, an attempt that consumes a voucher then fails mid-stream advances the node's last_nonce; every subsequent retry then replays nonce 0 and is rejected (StaleNonce / BytesRegression) until the 45s deadline expires.

Fix

Swap stream_fetch → stream_fetch_tracked with a per-attempt &mut VoucherProgress, and fold progress.acked() back into a now-mutable ctx in the retry arm. This mirrors the production watermark-advance idiom already used by persist_buyer_progress (node_origin.rs), the CLI fetch.rs, and the client_reused_channel_resumes integration test — the fixture's "store" is just its in-memory ctx.

When nothing was acked (the common pre-observation failure), acked() returns None and ctx stays at zero, preserving today's correct behavior for a never-observed channel.

Chose advancing the context over the issue's alternative (re-open a fresh channel per attempt), which would cost an openChannel tx per retry, leave dangling channels, and change channel_id between attempts (breaking the deterministic FetchOutcome.channel_id).

Notes for reviewers

  • No regression test added. Forcing a mid-stream failure after voucher consumption through this loopback fixture is impractical (it needs a node that accepts a voucher then drops the stream). The fix reuses the already-tested production watermark path.
  • One-sided ack loss remains a residual by design, documented on VoucherProgress in client-pull/src/lib.rs; not something this fixture change closes.

Verification

  • cargo build -p decdn-e2e — clean
  • cargo clippy -p decdn-e2e --all-targets -- -D warnings — clean
  • cargo nextest run -p decdn-e2e --features anvil-e2e --no-fail-fast — 7/7 passed, including smoke_compose_fixtures which drives ClientFixture::fetch

🤖 Generated with Claude Code

…es (#1062)

ClientFixture::fetch retried stream_fetch in a loop while reusing one
immutable ChannelContext pinned at prior_nonce/bytes/amount = ZERO. Once
the node's chain watcher had observed the channel, an attempt that
consumed a voucher then failed mid-stream advanced the node's last_nonce,
so every subsequent retry replayed nonce 0 and was rejected (StaleNonce /
BytesRegression) until the 45s deadline expired.

Swap stream_fetch -> stream_fetch_tracked with a per-attempt
&mut VoucherProgress, and fold progress.acked() back into a now-mutable
ctx in the retry arm. This mirrors the production watermark-advance idiom
(persist_buyer_progress in node_origin.rs, the CLI in fetch.rs, and the
client_reused_channel_resumes integration test). When nothing was acked
(the common pre-observation failure) acked() is None and ctx stays at
zero, preserving existing behavior for a never-observed channel.

Verified: cargo build + clippy clean; the full anvil-e2e suite (7 tests,
including smoke_compose_fixtures which drives ClientFixture::fetch) passes.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@yigitdot, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 31 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: ff15e173-a908-40ee-832e-9296ae886a11

📥 Commits

Reviewing files that changed from the base of the PR and between 6ce282b and d5baf89.

📒 Files selected for processing (1)
  • crates/e2e/src/client.rs

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@github-actions

github-actions Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 88.71% (2452/2764 lines)
▲ +0.00pp vs base (88.71% → 88.71%)
Run: 29205246058

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates the end-to-end client fixture to use stream_fetch_tracked instead of stream_fetch. This allows tracking the acked voucher watermark via VoucherProgress on failures, updating the ChannelContext with the advanced nonce, bytes delivered, and amount before retrying. This prevents replaying stale nonces after mid-stream failures. No review comments were provided, so there is no feedback to address.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@github-actions

github-actions Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 80.31% (was 80.34%, ▼ 0.03%) — 44803/55788 lines

File Coverage Lines Δ
crates/e2e/src/client.rs 0.00% 0/146 ● 0.00%
History
Commit Total Δ vs base
40d4f77 80.33% ▼ 0.01%
2960fa6 80.31% ▼ 0.03%
d5baf89 (HEAD) 80.31% ▼ 0.03%

yigitdot and others added 2 commits July 12, 2026 21:58
…eadline

Follow-up to the retry review on #1062. The retry guard
(`Err(e) if now < deadline`) retried EVERY error as if it were the
transient watcher-catch-up condition, so a deterministic failure —
corrupt delivery (HashMismatch), a buyer-side size-cap rejection
(BlobTooLargeClaim), or a terminal voucher desync (UpstreamVoucherRejected,
e.g. a stale nonce from one-sided ack loss, deposit exhaustion, an expired
channel) — spun ~90 times over the full 45s budget and then surfaced as
"paid fetch failed", misframing corruption/desync as a readiness timeout.

Add an is_retryable() classifier and gate the retry arm on it. Only the
transient conditions the loop exists to wait out stay retryable: the
node's up-front "delivery refused: UnknownChannel" pre-observation refusal
(a plain string error, not a typed sentinel), transport errors, a
per-attempt PullTimeout, and the node's explicit RetryLater resend signal.
Every typed terminal error now returns its real cause immediately. This
also tightens the one-sided-ack-loss residual noted in the review: a
replayed stale nonce now fails fast rather than spinning to the deadline.

Verified: cargo build + clippy clean; full anvil-e2e suite (7 tests) passes.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The `matches!` on the voucher-reject reason exceeded the 100-col limit;
rustfmt wraps it. Fixes the rustfmt CI job on #1125.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

@altanoruc altanoruc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One issue in the new fail-fast classifier: stream_fetch_tracked currently erases every initial delivery-side StreamError into a plain anyhow string at bail!("delivery refused: {:?}", resp.error), while is_retryable defaults all untyped errors to true. That means terminal wire refusals such as BlobTooLarge, InternalError, and EvictedSinceProbe still retry for the full 45s budget, despite the comment saying only watcher catch-up/transport/timeout/RetryLater are retryable.

Could we preserve the refusal as a typed error (carrying the StreamError) and classify it here? NotFound will necessarily remain retryable because UnknownChannel is intentionally wire-indistinguishable from cache miss and several other cases, but the distinct terminal variants can fail fast as intended.

@thiras
thiras merged commit 610b0fc into main Jul 12, 2026
23 checks passed
@thiras
thiras deleted the fix/1062-clientfixture-retry-voucher-nonce branch July 12, 2026 20:12
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.

e2e: ClientFixture::fetch retry replays voucher nonce 0 after a mid-stream failure

3 participants