Skip to content

Let shutdown cancel long-running shielded wallet operations #6003

Open

Description

@romchornyi

Follow-up from #5865. PlatformWalletManager.shutdown() waits for every admitted native operation with no timeout and no cancellation. Long Rust loops never watch for shutdown: seedShieldedPoolNotes (about 40 batches, each up to 3 × (180 s ChainLock fallback + 60 s pause)) and the asset-lock fundings that wait for InstantSend/ChainLock finality. #5865 admits the fundings (bounded by ~180 s) and leaves the seed unadmitted so shutdown is not held for tens of minutes, which leaves the seed outside the deletion fence.

Proposal: a cancellation token raised by shutdown (and wallet deletion) that the seed loop and the finality waits check between steps, so every long operation can be admitted without holding teardown.

🤖 Generated with Claude Code

Activity

  1. QuantumExplorer commented on Nov 22, 2026

    @QuantumExplorer
    Member

    Since #6050, shieldedResumeFundFromAssetLock (exact-outpoint resume) also holds the manager's native-operation admission, like shieldedFundFromWalletDrain, so shutdown() waits for it. Its ChainLock wait has no deadline (cl_wait: None), so a host that stops SPV during a resume parked on a ChainLock and then calls shutdown() waits forever. The cancellation token here should cover the exact-outpoint resume too, and a cancelled resume must leave the tracked lock (and any drain operation on it) pending, never consumed or removed.

  2. QuantumExplorer commented on Nov 23, 2026

    @QuantumExplorer
    Member

    Status on v5.1-dev, from the review of #6179 (native-operation admission for the shielded spend wrappers):

    So this issue is now the blocker for admitting those three, and its fix should cover the two calls that are already admitted: shutdown raises the token before it drains, the finality wait returns a pending result with the tracked outpoint intact, and the seed stops at a batch boundary.

  3. QuantumExplorer commented on Nov 24, 2026

    @QuantumExplorer
    Member

    One more case this issue has to carry, from the re-review of #6179.

    Leaving the fresh fundings unadmitted does not keep shutdown() clear of their ChainLock wait. Five payment wrappers that #6179 does admit take the wallet's shield_guard in Rust, which a Core asset-lock funding holds for its whole run: shieldedShield, shieldedShieldToRecipient, shieldedShieldFromIdentity, shieldedIdentityTopUpFromPool and abandonShieldedIdentityDebit. One of them started while a funding is pending on the same wallet queues behind it, and since it is admitted, shutdown() waits for it and deleteWallet stays refused. If the host stopped SPV first, no ChainLock arrives and shutdown never returns. (prepareShieldedIdentityAddress, admitted on the base, reaches the same guard through its bind.)

    So the cancellation signal proposed here has to:

    • reach the fresh fundings and the CoinJoin drain too, although Swift does not admit them, and not only the calls shutdown is draining;
    • be raised by Swift shutdown() before its admission drain, not after. Cancelling the funding releases the guard, and the queued payment then finishes in bounded time.

    Test to add: a shield queued behind a funding parked in the ChainLock wait, with SPV stopped; shutdown() returns.

    #6179 documents the case on the five wrappers and on shutdown() and otherwise leaves it to this issue. #6189 (a removal or Clear interrupting a queued shield) uses a signal raised by removal and Clear, which shutdown calls neither of, so it does not cover this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions