Repository navigation
Description
What
The seller redeemer does not look at a lane's capability expiry. Whatever a lane holds unredeemed when its capability expires is lost for good.
Why
PaymentPool pays nothing on a voucher whose capability has expired. _redeemLane returns (0, 0, 0) once block.timestamp >= a.expiry (contracts/src/PaymentPool.sol), and a redeem sent later cannot recover it. On the node side, nothing lines up redemption with that deadline:
- The seller accepts vouchers right up to expiry:
crates/node/src/handlers/client/voucher.rsrejects withCapabilityExpiredonly oncenow >= expiry. So a lane's last accruals land at the deadline itself. - The hint path (
redeem_oneincrates/node/src/payment_settlement.rs) redeems a lane at voucher time only if that single lane clears the per-chunk floor (blockchain.redeem_threshold_micro_usdc, default 1 USDC). - Everything else waits for the self-tick sweep (
blockchain.redeem_interval_secs, default 5 min, capped at 6 h), which packs lanes into chunks. Neitherplan_lanesnorredeem_sweepreadsLaneState::expiry.
So two kinds of value are forfeit when the capability expires before the next sweep:
- The tail of an above-floor lane: what it accrued since its last hint-redeem.
- Lanes that are each below the floor but together clear it: the sweep would have redeemed them in one chunk (ADR 003 § redemption chunking: "a small (dust) lane rides alongside the larger lanes that cleared the floor"), but expiry comes first.
Case 2 can be large. A publisher that uses decdn pool assign to give many clients the same --expiry-at produces many small lanes that all expire at once. No one of them fires a hint.
This is not the dust-forfeit policy from #1761 (ADR 003 § Owner reclaims before a node redeems). That policy covers a lane that never earns enough to be worth its own gas, and its value goes back to the owner at reclaim. This value does clear the floor in aggregate, and it is lost only because redemption misses the deadline. It also happens while the node is running, not only across downtime.
Scope. Only delegated capabilities are exposed. Self-issued capabilities (node buyers, self-funded decdn fetch) use SELF_CAPABILITY_EXPIRY = u64::MAX (crates/client/src/buyer_pool.rs) and never expire.
Possible fixes
These are not decided. Each needs the spec-discipline pass before it goes into ADR 003.
- Expiry-aware sweep. Plan a lane early when
expiry - now <= redeem_interval_secs + margin. Also redeem its chunk at a lower floor, so value that clears the floor across lanes but would miss the deadline gets out. Open question: does a lane that is still sub-floor at expiry stay forfeit (consistent with refactor(node): drop PaymentPool close monitor; lean on the redeem sweep #1761), or is it forced? - Expiry-scheduled hint. When a lane with a finite expiry is registered, schedule one redeem pass at
expiry - margin. This costs less than scanning every sweep, but it needs timer state. - Serve-side margin. Stop accepting a lane's vouchers some margin before expiry so its final value is fixed while it is still redeemable. On its own this still needs the redeem to run inside the margin.
Acceptance
A test in payment_settlement.rs covers several sub-floor lanes whose chunk clears the floor and whose shared capability expires before the next self-tick. It shows they are redeemed before the expiry.
Surfaced while reviewing the redeem-floor docs on #2191.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsDone
Activity
fix(node): gate reveals on the expiry margin and sweep overdue cutoff…