Skip to content

node: mid-stream signer cap check ignores a resolved pool's pre-restart signer spend #2711

Closed

Description

@thiras

Follow-up to #2709. That PR fixed the same blind spot for the pool-level remaining.

After a restart, the projection seeds a pool it has not folded from one admit-path getPool (ResolvingPoolView::resolve). Since #2709, the seed carries totalRedeemed. The per-signer total is still built only from lanes folded after the seed. PoolProjection::signer_spent therefore starts at 0 for every signer on a resolved pool and counts only the PoolRedeemed events folded after it.

The mid-stream signer cap check, ClientHandler::signer_cap_drained_midstream (crates/node/src/handlers/client/mod.rs), reads that total through ResolvingPoolView::signer_spent_cached, which reads the projection only. On a resolved pool, headroom = held_cap − spent therefore ignores everything the signer spent before the seed. Example:

  • the signer's cap is 1000, and it has spent 900 at other providers before the restart;
  • admission reads getAuthorization, sees 100 of headroom, and admits the stream;
  • other providers then redeem the last 100;
  • the mid-stream check sees a spent that leaves out the 900, so it never stops the stream.

The node delivers bytes that the on-chain redeemMany (min(desired, cap − spent)) will not pay for. The doc on signer_cap_drained_midstream accepts an under-count for an event-opened pool, where the projection misses only the spend before admission. On a resolved pool, the gap is the signer's whole spend before the restart.

Fix direction

The admit path already holds the right baseline. AuthRead caches one getAuthorization read per (pool, signer), and cached_auth brings its spent forward by what the projection has folded since that read (spent + folded_since).

  • Have ResolvingPoolView::signer_spent_cached answer from the cached AuthRead when it holds a Registered read: spent at the read plus folded_since. Fall back to the bare projection only when no read is cached.
  • Check the error direction. folded_since counts a lane's first post-read fold at its full cumulative (no baseline), which over-counts spent near the cap. AuthRead's doc already accepts that for admission; decide whether the mid-stream stop accepts it too, or whether it needs the same baseline / anchor treatment as fix(node): count a resolved pool's on-chain redemptions toward its remaining deposit #2709's pool Snapshot.
  • Rewrite the signer_cap_drained_midstream doc for the new error bound.
  • Test: a resolved pool whose signer spent close to its cap before the seed stops mid-stream once other providers drain the rest.

Activity

  1. added
    kind:security
    prio:medium
    area:node
    area:payments
    on Oct 28, 2026
  2. self-assigned this
    on Oct 28, 2026
  3. moved this from Backlog to In progress in deCDNon Oct 28, 2026
  4. moved this from In progress to Done in deCDNon Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:nodearea:paymentskind:securityprio:medium

Type

No type

Fields

Priority

None yet

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions