Repository navigation
test(payments): pin that a skip-ahead voucher on a concurrent lane is rejected - #1698
Conversation
… 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]>
There was a problem hiding this comment.
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_voucherhelper to sign/send an explicit cumulative voucher for negative-path testing. - Add
skip_ahead_voucher_on_a_concurrent_lane_is_rejectedto 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.
| 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(), | ||
| ); | ||
| } |
Coverage reportTotal: 80.71% (was 80.70%, ● 0.00%) — 58901/72980 lines No coverage data for changed Rust files. History
|
|
Follow-up filed: #1699 (self-describing vouchers). Enabling concurrent same-lane settlement there must flip the |
What
A characterization test that locks in today's behaviour before anyone starts on concurrent (skip-ahead) settlement: a voucher whose cumulative
bytes_deliveredassumes 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 as0 + 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 asVoucherRejected { 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:
paid ≤ deliveredclamp (window underflow),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 warningsandcargo fmt -- --check→ clean.🤖 Generated with Claude Code