Repository navigation
Description
What happens
Since #6178, a spend from the shielded credit pool holds the wallet generation's lifecycle gate, the coordinator's operation admission and the wallet's shielded configuration lock for its whole run (PlatformWallet::admit_shielded_spend). Two consequences are left open on purpose.
1. Removal and Clear wait for a host signer
Three of those spends await a host-supplied Signer inside the guarded span, after the Halo 2 proof: shielded_shield_from_account, shielded_shield_from_identity and shielded_identity_create_from_pool (the builder calls in wallet/shielded/operations.rs). write_dashpay_profile has done the same since it took the gate. So:
- a wallet removal waits for the signature, although
WalletGeneration::teardown_guardused to promise it would not wait for an external signer (its doc now names these four); - a Clear waits too (and will be refused instead once fix(platform-wallet): refuse a shielded Clear while a shielded operation runs #6182 lands). While a waiting Clear is queued on the write-preferring admission, every new shielded operation of every wallet on that coordinator queues behind it.
How long: Swift's KeychainSigner signs without a prompt. Kotlin's identity keys are user-authentication-bound by default, so an identity shield or an identity create can open a biometric prompt after the proof. The FFI signer gives up after SIGN_ASYNC_COMPLETION_TIMEOUT (300 s per signature); a direct Rust caller's signer has no bound. Kotlin removes off the main thread, so this is latency, not a freeze; nothing is corrupted.
2. A shield queued behind asset-lock funding pins both guards
shielded_identity_top_up_from_pool and the two shields take the admission and then wait for shield_guard. shielded_fund_from_asset_lock holds shield_guard for its whole run, including a ChainLock wait with no deadline for user-facing funding. A shield queued behind it holds the gate and the admission for that long, so a removal waits and a Clear waits or is refused. Before #6178 a queued shield held nothing.
Why #6178 did not take the gate after the signature
That is what contact requests do (GatedSigner in wallet/identity/network/contact_requests.rs), but it does not transfer:
- the shield paths hold
shield_guardacross nonce fetch, proof, signature and broadcast, andbind_shieldedtakes the gate, the admission and the configuration lock beforeshield_guard. Taking the gate after the signature would take it whileshield_guardis held: the reverse order, a deadlock against a concurrent bind. Dropping and retaking only the gate around the signature fails the same way once a teardown is queued; - an identity create reserves notes before the proof and the signature, so it would need a bind/Clear epoch check that does not exist;
- swift-sdk/platform-wallet: hold native-op admission and the generation guard across shielded spends #5868 asked for a removed wallet to be "refused before anything is signed".
Proposed
A removal-requested signal on WalletGeneration, raised in remove_wallet before it awaits teardown_guard(), and a signer wrapper for these four paths that selects the signature against it and returns WalletRemovedBeforeSend. Nothing is persisted before the signature in the two shields, so abandoning there is clean; an identity create has to release its reservation. The same signal for a Clear request on the coordinator. For item 2, the shield-class spends select their shield_guard wait against the same signal. No lock order changes.
Related: #6003 (shutdown cannot cancel long finality waits) wants the same kind of signal for the funding itself.
Tests
A signer that never completes, then a removal and a Clear return promptly, for each of the four paths; a shield queued behind a held shield_guard, then a removal returns promptly and the shield reports WalletRemovedBeforeSend.
Activity
QuantumExplorer commentedon Nov 24, 2026
Item 2 (a shield queued behind asset-lock funding pins both guards) is fixed in #6178 itself as of e90d15a: a shield-class spend that finds
shield_guardtaken gives its admission back while it waits and takes it again, with the liveness and binding checks repeated, when its turn comes. This issue is now item 1 only: a removal or a Clear waiting for a host signer.revert(platform-wallet): keep wallet removal waiting for an in-flight…
QuantumExplorer commentedon Nov 24, 2026
One more wait of the same kind, on the 5.2 side in #5934: there,
remove_wallettakes the wallet'sshield_guardafter the teardown gate.shielded_fund_from_asset_lockholdsshield_guardfor its whole run, including a ChainLock wait with no deadline for user-facing funding, so a removal waits for that too, with the gate held exclusively meanwhile.I tried ending it in #5934 with a lock-order change (
shield_guardbefore the gate, removal not takingshield_guard) and reverted it: the funding then outlived the removal and wrote asset-lock rows and submitted its shield after the wallet was gone. The removal signal proposed here covers this case if the funding's proof wait selects against it as well.