Skip to content

fix(node): report each lane's owed amount in admin lanes - #2588

Merged
thiras merged 1 commit into
mainfrom
fix/admin-lanes-owed
Oct 21, 2026
Merged

thiras merged 1 commit into
mainfrom
fix/admin-lanes-owed

Conversation

@thiras

@thiras thiras commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

What

The admin lanes() view (decdn node lanes) reported each lane's outstanding_micro_usdc from LaneState::last_amount(): the cumulative of the last signed voucher. A hash-chain lane pays with preimages, which move only the verified frontier. So the figure trailed the lane's claim by up to one chain, and it read 0 on a lane's first epoch while the node redeemed it. settlement_eligible read false on the same lanes.

build_lane_snapshots now reports LaneState::owed(): the signed anchor plus the verified frontier. That is the claim the redeemer submits (payment_settlement.rs, pool_store.rs).

The clamp journey in cli_fetch_delegated read the same field, so its accepted <= registered.cap check was 0 <= 40 and could never fail (#2337). It now:

  • requires a non-zero owed figure,
  • checks that figure against the registered cap,
  • waits until the on-chain watermark equals what the node reports owed, re-reading both each round,
  • checks the cap again on the settled figure.

Closes #2337

Reviewer notes

  • The fix itself is the one line in crates/node/src/admin.rs (state.owed()). The rest is tests and docs.
  • Two test fixtures carried a last_amount with no signature, a state no production path creates. owed() reads that state as 0, so both now carry a placeholder signature.
  • Doc corrections found in review, verified against the code:
    • settlement_eligible is a per-lane bar. It does not predict the next redemption: the redeemer gates on the unredeemed value summed per redeemMany. It stays true once reached.
    • The inline comment named a nonexistent withdrawnAmount.
    • The activity clock also ticks on preimages.
    • The e2e helpers blamed an "fsync gap", but load_all reads the in-memory working set.
  • Not changed: the buyer-side BuyerLaneSnapshot.last_amount_micro_usdc. It is the buyer's committed figure, not LaneState.
  • No devops dashboard or alert reads these fields.

Verification

  • cargo nextest run -p decdn-node -E 'test(build_lane_snapshots) | test(lanes_)': 19 passed. Includes a new regression test with a first-epoch lane (anchor 0) and a rolled-over lane (anchor 100 + frontier).
  • cargo nextest run -p decdn-cli --test admin_rpc: 26 passed.
  • cargo nextest run -p decdn-e2e --features anvil-e2e on cli_fetch_delegated (2 passed; the clamp test then passed 5 more runs), plus coalesce_two_clients, node_to_node_coalesce, cli_fetch_multi_source and cli_bundle_pull_multi_source (4 passed, run before their doc-only edits).
  • Mutation: with last_amount() restored, the new unit test fails and the e2e fails on the non-zero guard.
  • Pre-commit hooks passed on the commit.

Always:

  • pre-commit run --all-files: only the commit hooks on changed files ran
  • CARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targets --all-features: ran with -D warnings, clean
  • cargo nextest run: targeted runs only (above); left to CI for the full workspace
  • PR title uses an allowed type and a lowercase subject

Only if touched:

  • User-visible change: CHANGELOG.md entry added under Fixed
  • CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items: clean

🤖 Generated with Claude Code

`build_lane_snapshots` reported `LaneState::last_amount()`, the
cumulative of the last signed voucher, as `outstanding_micro_usdc`. A
hash-chain lane pays with preimages, which move only the verified
frontier, so the figure trailed the lane's claim by up to one chain and
read 0 on a lane's first epoch while the node redeemed it. It now
reports `LaneState::owed()`, the signed anchor plus the verified
frontier: the claim the redeemer submits. `settlement_eligible` follows.

The delegated clamp e2e read the same field, so `accepted <= cap` was
`0 <= 40` and could never fail. It now requires a non-zero owed figure,
checks it against the registered cap, and waits until the on-chain
watermark equals what the node reports owed.

Docs: `settlement_eligible` is a per-lane bar, not a prediction of the
next redemption (the redeemer gates on the unredeemed value per
`redeemMany`), and it stays true once reached; the activity clock counts
preimages; the e2e helpers' "fsync gap" note names the real gap.

Closes #2337

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 21, 2026 20:09
@thiras thiras self-assigned this Oct 21, 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.

🟢 Approval recommended

The narrow reporting correction has focused regression coverage and no identified blocking issues.

No open issues 🎉

What changed in this PR

Fixes #2337 by making the node’s admin lane view include verified hash-chain payments, matching the claim submitted for redemption.

Changes:

  • Reports LaneState::owed() instead of the last signed amount.
  • Adds regression coverage and strengthens delegated-cap settlement assertions.
  • Clarifies cumulative claims, settlement eligibility, and payment activity documentation.
File Description
crates/​node/​src/​admin/​tests.rs Tests first-epoch and rolled-over chain claims; updates fixtures.
crates/​node/​src/​admin.rs Reports owed amounts in lane snapshots.
crates/​e2e/​tests/​node_to_node_coalesce.rs Corrects claim and polling comments.
crates/​e2e/​tests/​coalesce_two_clients.rs Corrects claim and polling comments.
crates/​e2e/​tests/​cli_fetch_multi_source.rs Clarifies polling comments.
crates/​e2e/​tests/​cli_fetch_delegated.rs Checks nonzero claims, registered caps, and exact settlement.
crates/​common/​src/​admin.rs Clarifies lane DTO and RPC documentation.
crates/​cli/​tests/​admin_rpc.rs Adds a signature to the seeded lane fixture.
crates/​cli/​src/​commands/​node.rs Clarifies the activity-clock comment.
CHANGELOG.md Documents the reporting fix.

Review effort: Balanced

@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main a0b82f2 fix/admin-lanes-owed ba6863e +/-
77% 77% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

@thiras
thiras merged commit 772c8f4 into main Oct 21, 2026
35 checks passed
@thiras
thiras deleted the fix/admin-lanes-owed branch October 21, 2026 20:31
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: the clamp journey's accepted-vs-cap check reads a value that stays 0

2 participants