You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Let shutdown cancel long-running shielded wallet operations #6003
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.
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.
Status on v5.1-dev, from the review of #6179 (native-operation admission for the shielded spend wrappers):
platform_wallet_manager_shielded_fund_from_asset_lock, the CoinJoin drain export and the resume export all pass no ChainLock deadline on v5.1-dev (cl_wait: None in rs-platform-wallet-ffi/src/shielded_send.rs), so the "bounded by ~180 s" in the description above does not hold on this branch. The seed is bounded per batch (CL_FALLBACK_TIMEOUT) but runs for tens of minutes.
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.
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.
Activity
QuantumExplorer commentedon Nov 22, 2026
Since #6050,
shieldedResumeFundFromAssetLock(exact-outpoint resume) also holds the manager's native-operation admission, likeshieldedFundFromWalletDrain, soshutdown()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 callsshutdown()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.QuantumExplorer commentedon Nov 23, 2026
Status on
v5.1-dev, from the review of #6179 (native-operation admission for the shielded spend wrappers):platform_wallet_manager_shielded_fund_from_asset_lock, the CoinJoin drain export and the resume export all pass no ChainLock deadline onv5.1-dev(cl_wait: Noneinrs-platform-wallet-ffi/src/shielded_send.rs), so the "bounded by ~180 s" in the description above does not hold on this branch. The seed is bounded per batch (CL_FALLBACK_TIMEOUT) but runs for tens of minutes.shieldedResumeFundFromAssetLockand the wallet-drain funding are already admitted onv5.1-dev, soshutdown()already waits for them without a deadline. If the host stopped SPV first (SwiftExampleApp's SDK rebuild does, andSendViewModelstarts a funding the rebuild's in-flight check does not see, SwiftExampleApp: hold one funding reservation from dispatch to return so an SDK rebuild never stops SPV under a Core funding #6083), that wait never ends.shieldedFundFromAssetLock,shieldedFundFromCoinJoinDrainandseedShieldedPoolNotesunadmitted, as feat(platform-wallet): plan a shielded spend with its exact fee and spend against the plan #5865 left the seed, rather than add three more calls shutdown cannot get out from under. They stay outside the deletion and shutdown fence until the cancellation token proposed here exists.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.
fix(swift-sdk): leave asset-lock funding and pool seeding unadmitted
QuantumExplorer commentedon Nov 24, 2026
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'sshield_guardin Rust, which a Core asset-lock funding holds for its whole run:shieldedShield,shieldedShieldToRecipient,shieldedShieldFromIdentity,shieldedIdentityTopUpFromPoolandabandonShieldedIdentityDebit. 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 anddeleteWalletstays 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:
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.docs(swift-sdk): say when an admitted shield can keep shutdown waiting
chore: merge v5.2-dev into feat/platform-wallet-shielded-spend-plan