Repository navigation
fix(node): apply the redeem floor before the pre-redeem watermark read (#2217) - #2226
Conversation
#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]>
There was a problem hiding this comment.
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
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_lanesto try floor-gating before on-chain watermark reads to avoideth_callon sub-floor hints. - Added
decdn_preimage_reveals_received_totaland 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.
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit debee73 in the Show a line coverage summary of the most impacted files.
Updated |
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]>

Summary
Every redeem hint read
getWatermarksfrom the chain before the per-chunk floor ran, so a sub-floor hint cost oneeth_calland 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_lanesreturns before the chain read when the whole set's cachedunredeemedis below the floor. The cached paid watermark can only lag the chain, so the read can only lowerunredeemed, 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 == 0always passes the gate, so the forced close/shutdown paths still read every lane. Fail-open reconcile semantics are unchanged.decdn_preimage_reveals_received_total, incremented when a PayWord reveal advances a lane's chain frontier (the path that hints the redeemer). Registry row inadr/appendix-observability.md, and a "reveals accepted" series on the chain dashboard's voucher panel.ClientHandlerDepsbefore settlement bootstrap, which is more coupling than the remaining cost justifies.Tests:
a_sub_floor_plan_set_reads_nothing_from_the_chain: the queuedgetWatermarksresponse 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_deliverynow pins one voucher and one reveal counted.Testnet acceptance
After deploy,
rate(decdn_redemption_reconcile_ok_total)should trackrate(decdn_pool_redemptions_total), notrate(decdn_vouchers_received_total)orrate(decdn_preimage_reveals_received_total).Closes #2217
🤖 Generated with Claude Code