Skip to content

fix(node,client): heal a stale payer by lane headroom, not the stream count - #2175

Merged
thiras merged 3 commits into
mainfrom
fix/stale-proof-headroom-2171-2173
Sep 27, 2026
Merged

thiras merged 3 commits into
mainfrom
fix/stale-proof-headroom-2171-2173

Conversation

@thiras

@thiras thiras commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Two credit-accounting bugs from the #2170 review, fixed together because the #2173 rule depends on the #2171 fix.

  • node: a reloaded lane re-credits its proved chain frontier as free stream headroom #2171: a reloaded lane credits its whole claim (owed_bytes() = signed bytes + proved chain frontier), not only the signed bytes. Before this, each restart handed streams up to a chain of free headroom. That headroom also hid stalls.
  • node: a sub-anchor voucher under a new root stalls a multi-stream lane with no resume bundle #2173: a stale proof must be paid in full from lane headroom. A stale proof is a voucher at or below the signed anchor that pays its chunk, or a reveal that folds nothing. If headroom falls short, the node rejects it AmountRegression with the watermark bundle and credits nothing.
    • An honest lagging sibling always finds its chunk in headroom. The proof that passed it folded its payment, and no metering voucher takes a whole chunk.
    • A restarted payer that lost vouchers finds nothing.
    • This replaces the active_streams <= 1 gate on the feat(client-pull): persisted peer knowledge base for probe-less client fetch #1946 resume bundle. That gate let a restarted payer beside a live sibling stall until VOUCHER_READ_TIMEOUT, and it could tear down an honest sibling. The stream counter and LaneSlot are removed.
  • At-anchor stall (also on main): a restarted payer that re-signs the node's exact watermark for a same-size transfer is now treated as stale and heals, where it used to wait out the timeout.
  • Divergence rule: a voucher at the signed amount with different bytes, fewer or more, is BytesRegression.
  • Client:
    • PoolLedger::meter checks the stream's anchored root under the issuance lock and returns Metered::Moved when a sibling rolled the lane. The stream also records the root its own voucher signed, not one re-read after the send. Both races let a reveal go out under a root the node never matched to that stream.
    • An AmountRegression bundle that the ledger already covers retries (Healed::Stale), as UnderFold does, so concurrent legs of one ledger all heal.
  • ADRs: ADR 003 §Concurrent Streams / §Voucher ordering / §Off-chain persistence and the ADR 005 reject table are updated.

Test plan

  • cargo nextest run -p decdn-node -p decdn-incentive -p decdn-client -p decdn-cli: 2894/2894
  • clippy -D warnings --all-targets, cargo doc -D warnings, pre-commit
  • New loopback tests, each confirmed to fail on the old code or under a mutation:
  • Unit tests: hydration credits the full claim, credit_stale, fewer-bytes divergence, Metered::Moved, sibling AmountRegression → Stale
  • Honest-sibling guards still green: a_sibling_roll_does_not_take_a_retired_reveals_credit, lower_voucher_after_higher_sibling_is_already_satisfied, a_below_frontier_reveal_is_credited_from_lane_headroom, honest_concurrent_rollovers_draw_no_voucher_rejection
  • Two node_origin_pull tests flake under load at the same rate on main (23/90) and on this branch (24/90). Tracked in test(node): two node_origin_pull tests flake under load on main #2174.

Closes #2171
Closes #2173

🤖 Generated with Claude Code

thiras and others added 2 commits September 27, 2026 03:04
… count

A reloaded lane now counts its whole claim, the signed bytes plus the
proved chain frontier, as already credited (#2171). Crediting only the
signed half handed each restart up to a chain of free headroom, which
also masked the stall below.

A stale proof must pay its chunk in full from lane headroom (#2173). An
honest lagging sibling always finds its chunk there, because the proof
that superseded it folded the payment and a metering voucher takes no
whole chunk. A restarted payer that lost vouchers finds nothing. The node
decides at the proof that pays the chunk: a sealed or closing voucher
below the anchor, or a reveal that folds nothing. On a short headroom it
rejects AmountRegression with the watermark bundle and commits no credit.

This replaces the active_streams <= 1 gate on the #1946 resume bundle.
The gate let a restarted payer beside a live sibling stall until
VOUCHER_READ_TIMEOUT, and it tore down an honest sibling whose peer
stream had already ended. The per-lane stream counter and LaneSlot had
no other reader and are removed.

A voucher at the signed amount with fewer bytes is now a BytesRegression
too, not only one with more bytes.

The client treats an AmountRegression whose bundle its ledger already
covers as healed by a sibling stream, and retries, as it does for
UnderFold.

Closes #2171
Closes #2173

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review follow-ups to the stale-proof heal.

Client: PoolLedger::meter takes the stream's anchored root and returns
Metered::Moved, sending nothing, when a sibling rolled the lane between
the stream's anchor and the tick. The stream also records the root its
own Open/Roll/closing voucher signed, not a post-send re-read that can
already name a sibling's newer chain. Either race released a reveal the
node placed against the wrong root, which folded nothing.

Node: a voucher AT the signed anchor that pays its chunk is stale too. A
restarted payer that re-signs the node's own watermark for a same-size
transfer otherwise waited out VOUCHER_READ_TIMEOUT, on main as well.
The stale reject logs the lane and the credit figures, at warn when no
bundle can be built.

Client heal logs say whether a sibling reseeded first or the ledger is
already past the bundle. New end-to-end tests cover the voucher-path
reject (sub-chunk transfer, one and two transfers behind) and a
concurrent range set healing on one ledger. Stale LaneSlot references,
the removed multi-stream exception in fetch.rs, and the ADR 003/005
wording (ignored/refuses nothing, strict-below, reveal bundles) are
brought in line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 27, 2026 01:35
@thiras thiras self-assigned this Sep 27, 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

Regenerate the public API snapshot and preserve the signed root during ambiguous voucher-write recovery.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

Fixes stale payer recovery using lane headroom and prevents client streams from using superseded chain roots.

Changes:

  • Credits hydrated lanes from their full proved claim.
  • Rejects underfunded stale proofs and supports watermark healing.
  • Adds concurrent root tracking and updates tests and protocol documentation.
File Summary
crates/​node/​tests/​client_loopback.rs Adds stale-payer and concurrent recovery tests.
crates/​node/​src/​node_origin/​mod.rs Updates voucher retry documentation.
crates/​node/​src/​handlers/​client/​voucher.rs Implements stale-proof headroom validation.
crates/​node/​src/​handlers/​client/​mod.rs Hydrates full claims and removes stream counting.
crates/​node/​src/​handlers/​client/​dispatch.rs Removes lane-slot admission tracking.
crates/​node/​src/​handlers/​client/​delivery.rs Updates reservation documentation.
crates/​client/​src/​lib.rs Adds root tracking and stale healing; ambiguous-write recovery still risks recording the wrong root.
crates/​client/​src/​ledger.rs Detects moved roots; the public API snapshot requires regeneration.
crates/​cli/​src/​commands/​fetch.rs Updates watermark-resume documentation.
adr/​005-protocol.md Updates rejection and recovery semantics.
adr/​003-payments.md Documents stale-proof accounting and rollover behavior.

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

Comment thread crates/client/src/ledger.rs Resolved
The public API snapshot carries the anchored-root argument of
PoolLedger::meter and the Metered::Moved variant.

The write-failure recovery no longer re-reads the lane's chain root into
the stream's anchor after a StreamEnd: the stream has ended, nothing
meters on it again, and the re-read could name a sibling's newer chain.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-code-quality

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

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 5671746 in the fix/stale-proof-head... branch remains at 86%, unchanged from commit 1fed204 in the main branch.

Show a line coverage summary of the most impacted files.
File main 1fed204 fix/stale-proof-head... 5671746 +/-
crates/cache/src/engine.rs 94% 94% 0%
crates/node/src...ent/dispatch.rs 82% 82% 0%
crates/protocol/src/framing.rs 97% 97% 0%
crates/client/src/scheduler.rs 95% 95% 0%
crates/client/src/ledger.rs 99% 99% 0%
crates/node/src...ient/voucher.rs 96% 96% 0%
crates/client/src/lib.rs 93% 93% 0%
crates/node/src...gin/pull_leg.rs 89% 90% +1%
crates/node/src...s/client/mod.rs 95% 96% +1%
crates/incentiv...eth_identity.rs 98% 99% +1%

Updated September 27, 2026 01:55 UTC

@thiras
thiras merged commit e862222 into main Sep 27, 2026
30 checks passed
@thiras
thiras deleted the fix/stale-proof-headroom-2171-2173 branch September 27, 2026 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants