Skip to content

fix(incentive,node): reject an under-folding voucher with the resume bundle - #2170

Merged
thiras merged 4 commits into
mainfrom
fix/2167-under-fold-reject
Sep 26, 2026
Merged

thiras merged 4 commits into
mainfrom
fix/2167-under-fold-reject

Conversation

@thiras

@thiras thiras commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

What

LaneState::advance_presigned returned PoolError::AmountRegression from two different checks:

  • The ordering check. The amount is at or below the signed watermark. This is a stale voucher or one a sibling already settled, so it is benign.
  • The fold check. A voucher under a different root has an amount above the signed watermark but short of the live chain's claim. This is an under-fold.

verify_voucher treated both cases as already-satisfied and credited 0 bytes. After an under-fold the node waited for a proof the payer never sent, and the stream died at the 10 s VOUCHER_READ_TIMEOUT. On the testnet every small bundle entry routed to an affected node took about 10.9 s.

  • The fold check returns its own PoolError::UnderFold { axis, owed, got }. It now binds both axes of the fold (ADR 003 §Rollover): amount and bytes_delivered. Before, the check covered amount only, so a rollover could pay the whole claim, sign fewer bytes, and retire proved chunks from the lane's byte claim.
  • A voucher at exactly the signed anchor that opens another chain (non-zero root) is also an UnderFold when the live chain has proved reveals. That is where a restarted client opens after its last reveal reached the node but its own send failed. Before, it took the benign arm, and the stream adopted a root the lane refused, so it stalled the same way. With nothing proved, it stays an ordering regression, and adopt_chain takes the new root. A sealed voucher at the anchor stays benign. It is a sibling's closing voucher that arrives after a sibling opened the live chain at the same amount.
  • Concurrent streams on one lane get the same UnderFold bundle. The first reseeds. A later one whose ledger already covers the bundle on both axes retries (Healed::Stale) instead of failing.
  • VoucherRejectReason::UnderFold is a new wire reason, appended at the end and watermark-gated. PoolError::UnderFold maps to it one-to-one (ADR 005 §Mirror obligation). Wire-breaking.
  • The Err(e) arm of verify_voucher rejects it with watermark_bundle_for_reject, which carries verified_index, tip and chunk_price. The client's resumable_watermark reads is_watermark_gated(), and Cumulative::from(&WatermarkBundle) folds the frontier. So the client reseeds and resumes on the same provider with no logic change.
  • ADR 005: enum listing, mirror text, the bundle reasons (now five), and a retry-table row. ADR 003: a reject-table row, and §Rollover now states the honest restart path and the terminal bytes-only case. node_origin::voucher_verdict groups UnderFold with the other drifted-accounting reasons.
  • The node logs the lane error (axis, owed, got) at debug! before it maps it to a wire reason. The client logs a warn! when an UnderFold bundle does not advance its ledger.

Closes #2167

Reviewer notes

Verification

  • cargo fmt -- --check
  • cargo clippy --workspace --all-targets -- -D warnings, plus cargo check --workspace --all-targets --features decdn-e2e/anvil-e2e
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items
  • cargo nextest run --workspace: 4090 passed.
  • honest_concurrent_rollovers_draw_no_voucher_rejection: two concurrent multi-chunk pulls over two rounds with voucher_rejected == 0. A mutation that rejects every rollover over a proved frontier fails it.
  • Public API snapshots: decdn-protocol regenerated (adds the two UnderFold lines); decdn-client unchanged. Both pass.
  • New tests fail without the fix. With the lane change reverted, the node unit test panics and client_under_folding_a_live_chain_reseeds_and_resumes hits its 8 s budget. client_resuming_at_the_anchor_under_a_live_chain_reseeds_and_resumes hit the 8 s budget before the at-anchor fix. The seeded lane has one proved reveal, so lane headroom cannot finish the blob and hide the stall. With the fix both pass in about 0.6 s, with client_declined == 0 and voucher_rejected == 1.
  • contracts/ changed: not applicable
  • User-visible change: CHANGELOG.md entry under Fixed, with the wire-breaking callout
  • Design change: ADR 003 and ADR 005 updated
  • PR title uses an allowed type with a lowercase subject

🤖 Generated with Claude Code

…bundle (#2167)

`advance_presigned` refused an under-folding rollover as
`AmountRegression`, the same variant as a stale sibling voucher.
`verify_voucher` treats every `AmountRegression` as already-satisfied and
credits it 0 bytes. The node then waited for a proof the payer never
sent, and the stream died at the 10s `VOUCHER_READ_TIMEOUT`. On the
testnet every small bundle entry routed to an affected node cost ~10.9s.

The fold check now returns its own `PoolError::UnderFold`. It maps to
the wire `AmountRegression` reason, so the wire format and the client do
not change. `verify_voucher`'s catch-all arm rejects it with the watermark
bundle, which carries the live chain's `verified_index`. The client folds
that frontier, reseeds, and resumes on the same provider, as ADR 003
§Chain length and rollover specifies.

Tests: a `verify_voucher` unit test for the reject-with-bundle and the
benign at-anchor case, and a `client_loopback` test that seeds a live
chain and resumes from above its anchor inside an 8s budget. Both fail
without the fix; the loopback one times out at 8s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 26, 2026 21:24
@thiras thiras added kind:bug Something does not behave as documented rust Dependabot: a Cargo update; use area: labels for Rust code otherwise status:mainnet-blocking Must land before the mainnet deployment area:node decdn-node daemon: runtime, handlers, admin RPC, serve path area:payments Pools, vouchers, redeem, reclaim, staking (incentive crate and chain) labels Sep 26, 2026
@thiras thiras self-assigned this Sep 26, 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

Rollover validation must also protect the live byte frontier to avoid discarding already-proved bytes.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

Fixes under-folding voucher stalls by rejecting with a watermark resume bundle so clients can reseed and resume.

Changes:

  • Adds PoolError::UnderFold while preserving the existing wire reason.
  • Adds under-fold detection and recovery tests.
  • Documents the user-visible fix.

Review findings:

  • Critical: Rollover validation checks only the monetary claim, risking loss of bytes already proved by the live chain.
  • Nit: ADR 005 should document the intentional shared wire-reason mapping.
File Description
crates/​protocol/​src/​client.rs Documents shared rejection semantics.
crates/​node/​tests/​client_loopback.rs Tests end-to-end recovery.
crates/​node/​src/​handlers/​client/​voucher.rs Rejects under-folds with watermark bundles.
crates/​incentive/​src/​lane.rs Detects under-folding rollovers.
crates/​incentive/​src/​client_bridge.rs Maps the new error to the existing wire reason.
CHANGELOG.md Records the fix.

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

Comment thread crates/incentive/src/lane.rs Resolved
@github-code-quality

github-code-quality Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 751e777 in the fix/2167-under-fold-... branch remains at 86%, unchanged from commit 74b13a5 in the main branch.

Show a line coverage summary of the most impacted files.
File main 74b13a5 fix/2167-under-fold-... 751e777 +/-
crates/incentive/src/lane.rs 96% 95% -1%
crates/client/src/lib.rs 93% 93% 0%
crates/node/src...e_origin/mod.rs 92% 92% 0%
crates/protocol/src/client.rs 98% 98% 0%
crates/incentiv...lient_bridge.rs 100% 100% 0%
crates/node/src...ient/voucher.rs 95% 96% +1%

Updated September 26, 2026 23:21 UTC

…and bind the byte axis

Review follow-up on #2167.

- The rollover fold check binds `bytes_delivered` as well as `amount`
  (ADR 003 §Rollover). A different-root voucher that paid the whole
  claim but signed fewer bytes than the live chain proved was adopted.
  It retired the proved chunks from the lane's byte claim. It is now
  refused `UnderFold`. `PoolError::UnderFold { axis, owed, got }` names
  the axis that falls short.
- `VoucherRejectReason::UnderFold` is a new wire reason, appended at the
  end, and watermark-gated. `PoolError::UnderFold` maps to it one-to-one,
  as the ADR 005 mirror obligation requires. The client's reseed path
  reads `is_watermark_gated`, so it heals with no logic change.
  `voucher_verdict` puts it with the other drifted-accounting reasons.
- ADR 005: enum listing, mirror text, bundle reasons (five), and a retry
  row. ADR 003: a reject-table row. The public API snapshot has the new
  variant.
- Tests: lane and node cases for the byte axis. A lane rollover fixture
  that signed `bytes_delivered = 0` now folds its bytes.

Wire-breaking: a peer built before the new variant cannot decode it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras thiras added the kind:docs README, docs/, runbook, rustdoc or ADR prose only label Sep 26, 2026
…an under-fold

Multi-agent review follow-up on #2167.

- A voucher at exactly the signed anchor under a different root (a
  sealed voucher included) took the benign `AmountRegression` arm. When
  the live chain had proved reveals, `adopt_chain` refused the root, the
  stream anchored to it anyway, every later reveal folded nothing, and
  the stream stalled for 10s with no bundle. A restart after a reveal
  whose send failed but reached the node opens exactly there.
  `advance_presigned` now returns `UnderFold` when the live claim is
  above the anchor. With nothing proved, the anchor voucher stays an
  ordering regression and `adopt_chain` takes the new root.
- The client warns when an `UnderFold` bundle does not advance its
  ledger (a bytes-only shortfall) and leaves the rejection terminal.
- `verify_voucher` logs the lane error (axis, owed, got) at `debug!`
  before it maps it to a wire reason.
- Tests: a loopback resume at exactly the anchor, seeded with one proved
  reveal so lane headroom cannot mask the stall (fails at the 8s budget
  without the fix); lane and node cases for the anchor boundary; client
  heal cases for an advancing and a bytes-only `UnderFold`; a
  `voucher_verdict` pin. The node test that called a sealed voucher at
  the anchor benign now checks a same-root re-send.
- Docs: ADR 003 §Rollover states the honest restart path and the
  terminal bytes-only case. ADR 005 fixes the signature-order claim and
  names under-fold in the bundle heading. The protocol, lane, client and
  node_origin docs match.

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

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

🔵 Needs a closer look

It includes a wire-breaking protocol change and has one unresolved documentation nit.

Review effort: Lite
Findings: None

Resolved since last review (1)

…g heals retry

Second multi-agent review follow-up on #2167.

- A sealed closing voucher at the signed anchor is a sibling's close
  that the node reads after a sibling opened the live chain at the same
  amount. The at-anchor under-fold rule now needs a voucher that opens a
  chain (non-zero root). The sealed close stays an ordering regression,
  already satisfied, as on main.
- Concurrent streams on one lane get the same `UnderFold` bundle. The
  first reseeds. A later one whose ledger already covers the bundle on
  both axes now retries (`Healed::Stale`) instead of failing the stream
  and suppressing the upstream. The `warn!` is kept for the real
  bytes-only case.
- Tests: a lane test for the late sealed close; the node at-anchor test
  covers the live-root re-send, the sealed close, and a fresh root; a
  client test for the second sibling heal; a loopback test with two
  concurrent multi-chunk pulls over two rounds that asserts zero voucher
  rejections. That test fails when rollovers over a proved frontier are
  rejected.
- Docs: `UnderFold` is defined at or above the signed anchor in ADR 003,
  ADR 005 and the protocol doc. ADR 003 lists `SpendingCapExhausted`
  among the bundled reasons. ADR 005 groups `UnderFold` with the guards
  that have no on-chain revert and adds the sibling retry to its retry
  row. Doc wording and line widths are fixed across lane, client and
  node_origin.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras
thiras merged commit 1fed204 into main Sep 26, 2026
30 checks passed
@thiras
thiras deleted the fix/2167-under-fold-reject branch September 26, 2026 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:node decdn-node daemon: runtime, handlers, admin RPC, serve path area:payments Pools, vouchers, redeem, reclaim, staking (incentive crate and chain) kind:bug Something does not behave as documented kind:docs README, docs/, runbook, rustdoc or ADR prose only rust Dependabot: a Cargo update; use area: labels for Rust code otherwise status:mainnet-blocking Must land before the mainnet deployment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

node: an under-folding voucher credits 0 bytes instead of rejecting with the resume bundle, stalling the stream 10s

2 participants