Skip to content

test(payments): pin that a skip-ahead voucher on a concurrent lane is rejected - #1698

Merged
alpergundogdu merged 1 commit into
mainfrom
claude/skip-ahead-voucher-guard
Aug 14, 2026
Merged

alpergundogdu merged 1 commit into
mainfrom
claude/skip-ahead-voucher-guard

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

What

A characterization test that locks in today's behaviour before anyone starts on concurrent (skip-ahead) settlement: a voucher whose cumulative bytes_delivered assumes another same-lane stream's bytes are already settled — paid before that stream is settled — is rejected.

Two same-lane streams deliver fully and park at their closing voucher, with the shared lane counter still at 0. Stream B then pays a skip-ahead voucher signed over wire_a + wire_b. The node reconstructs B's cumulative as 0 + wire_b — the shared counter plus this stream's own delivered delta (voucher.rs::verify_voucher) — so the well-formed signature recovers a different address than the lane's pinned signer and comes back as VoucherRejected { WrongSigner }. The lane watermark stays at zero.

Why

This documents the reason a client with concurrent same-lane streams must serialize its voucher signing (rather than pay out of order), which is what the shipped bundle-pull client does via its per-provider lock. It's the negative counterpart to the aggregate-accounting test from #1690, which proved correctly-ordered concurrent settlement works.

Enabling skip-ahead settlement is a deliberate protocol change (self-describing vouchers) that must flip this test — with the footguns in view:

  • per-hash receipts vs cross-hash vouchers,
  • the paid ≤ delivered clamp (window underflow),
  • advertised-rate re-derivation over the aggregate jump,
  • the single-signer assumption (no nonce, highest-cumulative-wins),
  • the coalescing frontier guards.

Related: the per-lane credit-window admission cap in #1697 (bounds exposure; orthogonal to this settlement-ordering limitation).

Verification

  • cargo nextest run -p decdn-node --test client_loopback --no-fail-fast → 75/75 pass.
  • cargo clippy -p decdn-node --tests -- -D warnings and cargo fmt -- --check → clean.

🤖 Generated with Claude Code

… rejected

Characterization test for the current limitation that motivates the
self-describing-voucher / concurrent-settlement follow-up (#1697 and the
skip-ahead footguns): a voucher whose cumulative `bytes_delivered` assumes
another same-lane stream's bytes are already settled — sent before that stream
is paid — is rejected.

Two same-lane streams deliver and park at their closing voucher (shared lane
counter still 0). Stream B then pays a skip-ahead voucher signed over
`wire_a + wire_b`. The node reconstructs B's cumulative as `0 + wire_b` (shared
counter plus this stream's own delta, per voucher.rs::verify_voucher), so the
well-formed signature recovers a different address than the lane's pinned
signer and comes back as `VoucherRejected { WrongSigner }`. The lane watermark
stays at zero.

This documents why a client with concurrent same-lane streams must serialize
its voucher signing rather than pay out of order. Enabling skip-ahead
settlement is a deliberate protocol change that must flip this test — with the
footguns (per-hash receipts, `paid <= delivered` clamp, rate re-derivation,
single-signer, coalescing frontier guards) in view.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Copilot AI lite review requested due to automatic review settings August 14, 2026 16:32
@alpergundogdu
alpergundogdu merged commit 515146f into main Aug 14, 2026
26 checks passed
@alpergundogdu
alpergundogdu deleted the claude/skip-ahead-voucher-guard branch August 14, 2026 16:34

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.

Pull request overview

Adds a characterization test in decdn-node’s loopback payment harness to pin the current behavior that “skip-ahead” cumulative vouchers on concurrent same-lane streams are rejected (currently as VoucherRejected { WrongSigner }). This supports future protocol work by locking in the pre-change semantics around lane watermark reconstruction and settlement ordering.

Changes:

  • Add a StalledDelivery::send_cumulative_voucher helper to sign/send an explicit cumulative voucher for negative-path testing.
  • Add skip_ahead_voucher_on_a_concurrent_lane_is_rejected to assert out-of-order (skip-ahead) cumulative payment is rejected and does not advance the lane watermark.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +1937 to +1944
let persisted = fx.store.load_all()?;
if let Some(only) = persisted.first() {
anyhow::ensure!(
only.last_bytes_delivered() == U256::ZERO,
"a rejected skip-ahead voucher must not advance the lane watermark, got {}",
only.last_bytes_delivered(),
);
}
@github-actions

Copy link
Copy Markdown

Coverage report

Total: 80.71% (was 80.70%, ● 0.00%) — 58901/72980 lines

No coverage data for changed Rust files.

History
Commit Total Δ vs base
0e8d3fe (HEAD) 80.71% ● 0.00%

@alpergundogdu

Copy link
Copy Markdown
Contributor Author

Follow-up filed: #1699 (self-describing vouchers). Enabling concurrent same-lane settlement there must flip the skip_ahead_voucher_on_a_concurrent_lane_is_rejected test added here — it becomes an accepted path landing the correct aggregate watermark. The footgun list from this test's doc comment is carried into #1699's design.

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