Skip to content

payments: let a cooperative close reconcile when the client's watermark lags the node's #1495

Closed

Description

@thiras

Split out of #1122 item 4. The other three items of that issue are addressed (see the comment there); this one needs a wire change and was deliberately kept out of the memory/resume batch.

Problem

decdn channel coop-close hard-errors when the node's declared state exceeds the client's persisted record:

Error: provider over-claimed: waiver (1792, 182, 187522216) exceeds authorized (1162, 119, 121461928)

That guard is correct and load-bearing — without it a provider could inflate the payout toward the full deposit — but it has no reconciliation branch. A client whose watermark legitimately lags (it signed vouchers it did not durably persist before an unclean exit) has no way to settle, and the channel plus its deposit are stranded.

Why the existing self-heal does not cover it

#1481 added exactly the right primitive on the fetch path: a watermark-gated VoucherRejected carries a WatermarkBundle containing the client's own last-accepted voucher signature, so the client verifies the higher watermark against its own key and reseeds. It is non-terminal — mark_cooperative_close_signed is only called from the coop-close handler (crates/node/src/handlers/client/voucher.rs:575), never from the reject path.

Coop-close cannot use it, because CooperativeCloseAuth (crates/protocol/src/client.rs:671) carries only the provider's waiver signature:

pub struct CooperativeCloseAuth {
    pub channel_id: [u8; 32],
    pub amount: [u8; 32],
    pub nonce: [u8; 32],
    pub bytes_delivered: [u8; 32],
    /// Provider's EOA secp256k1 EIP-712 `CooperativeClose` signature
    pub signature: Vec<u8>,
}

There is nothing in it the client can check against its own key, so prepare_close (crates/client-pull/src/cooperative_close.rs:212) can only refuse. Signing the provider's claim on trust instead would remove the drain guard.

Proposal

Carry the client's own last-accepted voucher signature alongside the waiver, and reconcile on over-claim exactly as the fetch path does.

  • The node already holds it — guard.state is the same source WatermarkBundle.last_signature is built from (crates/node/src/handlers/client/voucher.rs:582) — it just is not sent.
  • Client side: on over-claim, verify last_signature recovers to our own voucher-signing address over the declared amount/nonce/bytes_delivered; if it does, advance the local watermark and settle at the true state; if not, keep today's refusal. resumable_watermark (crates/client-pull/src/lib.rs) is the existing shape of that check and should be reused rather than reimplemented.

Scope notes

  • Wire-breaking. Adding a field to a postcard-serialized message is not backward compatible; needs the ADR 005 message-layout treatment and a CHANGELOG wire-breaking callout. Operators cannot hot-upgrade across it.
  • Touches crates/protocol, crates/node/src/handlers/client/voucher.rs, crates/client-pull/src/cooperative_close.rs.
  • Worth an e2e: desync the client's watermark, then coop-close and assert it settles at the node's state rather than erroring.

Current severity

Lower than when #1122 was filed, but not zero. Any fetch on the channel now heals the watermark (#1481, plus the streaming path's own reseed loop), so reaching this dead-end requires a desync and the user never fetching again on that channel before closing.

Activity

  1. added
    rust
    on Jul 28, 2026
  2. added
    kind:bug
    prio:medium
    kind:test
    on Jul 28, 2026
  3. self-assigned this
    on Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:bugkind:testprio:mediumrust

Type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions