Repository navigation
Description
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
spentthat 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_cachedanswer from the cachedAuthReadwhen it holds aRegisteredread:spentat the read plusfolded_since. Fall back to the bare projection only when no read is cached. - Check the error direction.
folded_sincecounts a lane's first post-read fold at its full cumulative (no baseline), which over-countsspentnear 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 poolSnapshot. - Rewrite the
signer_cap_drained_midstreamdoc 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.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsDone
Activity