Skip to content

fix(node): apply the redeem floor before the pre-redeem watermark read (#2217) - #2226

Merged
alpergundogdu merged 2 commits into
mainfrom
fix/2217-redeem-floor-before-read
Sep 28, 2026
Merged

alpergundogdu merged 2 commits into
mainfrom
fix/2217-redeem-floor-before-read

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Every redeem hint read getWatermarks from the chain before the per-chunk floor ran, so a sub-floor hint cost one eth_call and submitted nothing. Under PayWord every accepted reveal hints the redeemer, so testnet nodes read the chain at many times their voucher rate against the free-plan RPC.

What changed

  • redeem_planned_lanes returns before the chain read when the whole set's cached unredeemed is below the floor. The cached paid watermark can only lag the chain, so the read can only lower unredeemed, and no chunk after the read can hold more than the whole set. The gate is on the total rather than per chunk because a lane the read drops can shrink the chunk count and re-pack lanes from a failing chunk into one that clears. floor == 0 always passes the gate, so the forced close/shutdown paths still read every lane. Fail-open reconcile semantics are unchanged.
  • New counter decdn_preimage_reveals_received_total, incremented when a PayWord reveal advances a lane's chain frontier (the path that hints the redeemer). Registry row in adr/appendix-observability.md, and a "reveals accepted" series on the chain dashboard's voucher panel.
  • The hint itself is unchanged. After this fix a sub-floor hint costs a lane-store read and in-memory planning, with no RPC. Gating the hint in the voucher handler would need the redeem threshold and the paid-watermark cache threaded into ClientHandlerDeps before settlement bootstrap, which is more coupling than the remaining cost justifies.

Tests:

  • a_sub_floor_plan_set_reads_nothing_from_the_chain: the queued getWatermarks response stays unconsumed and both reconcile counters stay at 0.
  • a_set_that_clears_the_floor_in_total_reads_every_lane: a lane whose cached chunk fails the floor is still read when the set clears it in total (the re-pack case).
  • a_zero_floor_still_reads_every_lane: the forced path still reconciles.
  • a_released_preimage_pays_for_a_chunk_and_resumes_delivery now pins one voucher and one reveal counted.

Testnet acceptance

After deploy, rate(decdn_redemption_reconcile_ok_total) should track rate(decdn_pool_redemptions_total), not rate(decdn_vouchers_received_total) or rate(decdn_preimage_reveals_received_total).

Closes #2217

🤖 Generated with Claude Code

#2217)

redeem_planned_lanes read getWatermarks for every planned lane before
chunk_redemptions applied the per-chunk floor, so every redeem hint cost
one eth_call even when nothing cleared the floor. Under PayWord each
accepted reveal hints the redeemer, so testnet nodes ran getWatermarks at
many times their voucher rate against the free-plan RPC.

Chunk on cached values first and return when nothing clears the floor.
Reconcile only the lanes in surviving chunks, then re-chunk. The cached
paid watermark only lags the chain, so the read can only lower
unredeemed. floor == 0 keeps every chunk, so the forced close/shutdown
paths still read every lane.

Add decdn_preimage_reveals_received_total for accepted PayWord reveals,
the other half of the redeemer's hint rate, with its registry row and a
series on the chain dashboard's voucher panel.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 28, 2026 16:12

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

The new pre-reconcile early-return in redeem_planned_lanes can incorrectly skip redemption in cases where reconciliation would drop settled lanes and enable a floor-clearing chunk.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

This PR reduces unnecessary getWatermarks RPC load in the node’s hint-path redemption by attempting to apply the per-chunk redeem floor before performing on-chain watermark reconciliation, and adds observability for accepted PayWord reveals.

Changes:

  • Reordered redeem_planned_lanes to try floor-gating before on-chain watermark reads to avoid eth_call on sub-floor hints.
  • Added decdn_preimage_reveals_received_total and wired it into the voucher handler, observability appendix, and chain dashboard.
  • Extended tests to assert both the new “no chain read under floor” behavior and the new reveal counter behavior.
File Description
monitoring/​dashboard-chain.json Adds a “reveals accepted” series and updates the panel description to distinguish reveals from vouchers.
crates/​node/​tests/​client_loopback.rs Extends the PayWord loopback test to assert the new reveal counter alongside voucher counting.
crates/​node/​src/​payment_settlement.rs Changes redeem planning/reconciliation ordering and adds unit tests around the floor-gating behavior.
crates/​node/​src/​metrics.rs Introduces decdn_preimage_reveals_received_total and records it via the metrics recorder API and tests.
crates/​node/​src/​handlers/​client/​voucher.rs Increments the new reveal counter when a PayWord reveal advances a lane frontier.
adr/​appendix-observability.md Documents the new metric in the observability registry appendix.

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

Comment thread crates/node/src/payment_settlement.rs Resolved
@github-code-quality

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

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit debee73 in the fix/2217-redeem-floo... branch remains at 86%, unchanged from commit aacaf46 in the main branch.

Show a line coverage summary of the most impacted files.
File main aacaf46 fix/2217-redeem-floo... debee73 +/-
crates/incentiv...eth_identity.rs 99% 98% -1%
crates/cache/src/engine.rs 94% 94% 0%
crates/node/src...gin/pull_leg.rs 89% 89% 0%
crates/node/src/metrics.rs 96% 96% 0%
crates/node/src...ient/voucher.rs 96% 96% 0%
crates/node/src...t_settlement.rs 72% 74% +2%

Updated September 28, 2026 16:37 UTC

A lane the read drops can shrink the chunk count and re-pack lanes from a
chunk that failed the floor into one that clears it, so a per-chunk gate
could skip a redeemable set. The whole set's cached unredeemed bounds
every post-read chunk, so the gate compares it to the floor.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alpergundogdu
alpergundogdu merged commit 6f024ba into main Sep 28, 2026
30 checks passed
@alpergundogdu
alpergundogdu deleted the fix/2217-redeem-floor-before-read branch September 28, 2026 16:45
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.

node: pre-redeem getWatermarks runs on every sub-floor hint, flooding the RPC

2 participants