Repository navigation
Description
Framing
On real networks, block time tracks wall-clock time closely. The main problem is not which clock a check reads. It is that checks near a deadline or an expiry leave no safety margin.
For a "still before the deadline/expiry" check, even the chain's head block timestamp is optimistic. A transaction lands in a later block than the head it was checked against, so its block.timestamp is at or after the head's. A check that passes on head time can still fail on-chain.
The "after the deadline" direction is different. pool reclaim now compares against the head block timestamp (#2238), and for that direction this is the safe choice: if the head is past the deadline, the inclusion block is too.
Line numbers are for main at 74e2cd4.
Findings
1. HIGH: node voucher acceptance has no expiry margin
crates/node/src/handlers/client/voucher.rs:380 accepts a voucher (and serves its bytes) while coarse_clock.unix_seconds() < expiry. On-chain, PaymentPool.sol:878 pays (0, 0, 0) once block.timestamp >= expiry. A voucher accepted just before capability expiry but redeemed after it pays 0, even with a perfect clock: the redemption lands later than the acceptance. The node delivers bytes it can never be paid for.
Fix: add a margin. Either stop accepting vouchers within a margin of expiry, or redeem vouchers accepted near expiry immediately. The local clock plus a margin is fine here; this is the per-voucher hot path, so no chain read per voucher.
2. MEDIUM: the redeemer planner has no deadline margin and redeems expired capabilities
crates/node/src/payment_settlement.rs:1416 (plan_lanes, now = unix_now()) and :1205 (pool_is_redeemable: Closing { deadline } => now < deadline):
- There is no margin before a
Closingpool's dispute deadline. A redemption planned just before it can land after it, revert withPoolClosed(PaymentPool.sol:593), and waste gas. - The planner does not skip lanes whose capability has expired. It redeems their vouchers for 0 and wastes gas.
Fix: hold a margin before the deadline, and skip lanes whose capability is past expiry, or within a margin of it.
3. LOW: decdn pool assign validates expiry against a possibly skewed local clock
crates/cli/src/commands/pool.rs:839 (resolve_expiry: expiry > now) and :889 (assign: now = unix_now()?). On a machine whose clock is skewed, assign can issue a capability that is already expired on-chain, or refuse a valid near-future one. --expiry-secs also shifts the capability's lifetime by the skew. This is rare in practice.
Found while reviewing #2238.
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsDone
Activity
fix(client,node): drop the claim-bounded end gate, order pull-through…
fix(client,cli,node): let a pull-through bar expire, time out the ass…