Repository navigation
fix(node): redeem a delegated lane when its serve cutoff passes - #2312
Merged
Merged
Conversation
The voucher path refuses a lane once its capability expires within one redeem interval plus the 120 s landing slack. The periodic sweep was the only thing that redeemed the lane's final value, and the timing left it no room: a tick delayed by a receipt wait in the serial redeemer loop fell inside the landing slack and skipped the lane as expired. The redeemer now also sweeps one second after the earliest serve cutoff (expiry - margin) of an owed lane with a finite expiry. The wake is seeded from the lane store at start, taken from each hint, and recomputed from each sweep's scan. The sweep packs every owed lane, so sub-floor lanes that share an expiry and clear the floor together go out in one redeemMany with a full interval plus slack to land. Closes #2233 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Cutoffs can still be missed after restart, transient store failures, or blocking redemption work.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Adds expiry-aware redemption sweeps so delegated lane value is redeemed after serving stops.
Changes:
- Schedules sweeps at capability serve cutoffs.
- Adds restart and aggregate sub-floor redemption tests.
- Updates payment ADR and changelog documentation.
| File | Description |
|---|---|
crates/node/src/payment_settlement.rs |
Implements cutoff scheduling and tests. |
adr/003-payments.md |
Documents cutoff redemption behavior. |
CHANGELOG.md |
Records the delegated-lane fix. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit b88520e in the Show a line coverage summary of the most impacted files.
Updated |
…s at start Review follow-ups for #2233: - The preimage path now applies the voucher path's capability-expiry gate (shared `inside_capability_expiry_margin` in decdn-common). A stream anchored before the margin could otherwise keep extending the claim after the cutoff sweep had read it. - At start, a lane whose cutoff passed while the node was down, and that is not yet inside the landing slack, is swept at once (`startup_cutoff`). Before, the skipped first tick pushed its only sweep past the slack and forfeited it. - A failed lane load keeps every cutoff still ahead and drops only a passed one. - Tests: hint-fed wake, no re-fire after a cutoff sweep, restart with an overdue cutoff, failed load without spin, the self-tick arm, the wake/margin-gate tie, and a loopback reveal refused inside the margin. Each guard was mutation-checked. - Docs: ADR 003/005, appendix-observability, the CapabilityExpired doc and the config margin doc describe the cutoff sweep accurately. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The redeemer keeps the time of its last sweep scan. A lane's cutoff is due at once when it has passed and no scan has run since, whether the node was down at the cutoff or the lane's first hint waited behind redemption work until after it. This one rule replaces startup_cutoff. A scan after the cutoff already read the final claim, so a later hint for that lane schedules nothing. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What
The redeemer now runs its sweep one second after a delegated lane's serve cutoff (
expiry − margin, the point where the voucher path starts to refuse the lane withCapabilityExpired). The lane's value is final there, and the sweep has one redeem interval plus the 120 s landing slack to land before the capability expires.serve_cutoff_wake/next_serve_cutoff: the earliest future wake over owed lanes this node provides with a finite expiry.redeemer_loopgains a thirdselect!arm. The wake is seeded from the lane store at start (restart-safe), taken from each hint (redeem_onereturns the lane's wake), and recomputed from each sweep's own scan. A failed scan keeps every future cutoff and drops a passed one; the tick retries.redeem_sweeptakes the loadedstates, so the loop schedules the next cutoff from the sameload_allit sweeps.commit_one_preimagenow applies the voucher path's expiry-margin check (sharedinside_capability_expiry_marginindecdn-common). Without it, a stream anchored before the margin could keep growing the claim after the cutoff sweep read it.startup_cutoff). Otherwise the skipped first tick pushes its only sweep past the slack.redeemMany; a value still below the floor at the cutoff is not redeemed, as with other dust (refactor(node): drop PaymentPool close monitor; lean on the redeem sweep #1761).Why
The issue's premise is partly stale: #2263 (#2242) already made the node stop accepting vouchers
redeem_interval + 120 sbefore expiry. What remained was the redemption timing. The last voucher lands just beforeexpiry − interval − 120, and only the next tick could redeem it — a tick that had to fire on time to the second. The redeemer loop is serial, and a hint or sweep can sit in a receipt wait for up to 3 min 37 s, so a late tick fell inside the landing slack, skipped the lane as expired, and forfeited the whole tail.Reviewer notes
Option<u64>suffices), and any serve-side change. Shrinking the margin to a constant remains fix(client,node,cli): bar refused pull-through, refuse over-ceiling ranges, heal stale under-fold, hold expiry margins #2263's deferred per-nodeCapabilityExpireditem.unix_nowreadsSystemTime, which paused tokio time does not move. Each uses a one-hour tick so only the cutoff can trigger the sweep. Both fail (time out) with the cutoff sleep stubbed topending().Verification
cargo fmt -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo nextest run -p decdn-node -p decdn-common -p decdn-protocol: 2209/2209 passeddecdn-protocolpublic-api snapshot passesRUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-itemscargo build --bin decdn-node+anvil_settlement_e2e,anvil_bringup_shutdown_e2e(node) andanvil_pool_redeem(e2e): all passedsub_floor_lanes_are_redeemed_together_at_their_serve_cutofffails without the fixCloses #2233
🤖 Generated with Claude Code