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
swift-sdk: ManagedPlatformWallet identity writes run without native-operation admission, so a manager replacement can overlap their store writes #6082
Found while reviewing #6054. Pre-existing: it applies to every identity write on ManagedPlatformWallet, not only the calls #6054 adds.
Problem:PlatformWalletManager drains admitted native operations before shutdown (admitNativeOp / finishNativeOp), but only manager-level entry points take part (create, load, SPV, private contact requests). The ManagedPlatformWallet identity writes do not, for example:
refreshIdentityBalance and refreshIdentity;
updateIdentity and both updateIdentityKeyLimits variants;
transferCredits, transferCreditsToAddresses, withdrawCredits and topUpFromAddresses;
registerDpnsName and updateDashPayProfile.
When the app replaces its manager (WalletManagerStore.activate, for example on an SDK rebuild for the same network), the old manager's shutdown can finish while such a call is still in flight. That call keeps the old wallet alive, passes its own generation check, and can then write to the shared SwiftData store after the replacement manager has restored and updated the same rows.
Example: an old refresh proves a key cap of 1,500 and commits after the replacement has already stored 2,000. persistIdentityKeys assigns the incoming cap, so the stored and cold-restored cap go backwards.
Fix: admit these calls through their owning manager. Reject new calls once shutdown starts, and hold admission until the call's persistence round has finished, as #6060 asks for the shielded spend wrappers.
Drain cost: admitting a network call (a proved refresh, a broadcast-and-wait) makes shutdown() wait for that call. WalletManagerStore.activate awaits shutdown() on an SDK rebuild, and its own doc says the wait is unbounded. Weigh that before admitting long calls.
Alternative: once shutdown has drained, fence the old manager's PlatformWalletPersistenceHandler so later store callbacks are refused on its serial queue. That covers every writer in one place and needs no reference from a wallet to its manager. (ManagedPlatformWallet holds only handle and walletId; admitNativeOp is a @MainActor internal of PlatformWalletManager.)
Calls feat: raise an identity key's budget or expiry from SwiftExampleApp #6054 adds:refreshIdentity (run automatically when the Update Limits sheet opens) and updateIdentityKeyLimits(asReviewed:) join the shipped updateIdentityKeyLimits and updateIdentity (Disable Key) as writers of the same key rows. The worst case is a stale displayed or cold-restored cap, which the next proved refresh heals. It never feeds signing: the sheet refreshes with a proof on open, and Rust signs only the reviewed preview.
Activity
QuantumExplorer commentedon Nov 22, 2026
Notes from #6054's review:
shutdown()wait for that call.WalletManagerStore.activateawaitsshutdown()on an SDK rebuild, and its own doc says the wait is unbounded. Weigh that before admitting long calls.PlatformWalletPersistenceHandlerso later store callbacks are refused on its serial queue. That covers every writer in one place and needs no reference from a wallet to its manager. (ManagedPlatformWalletholds onlyhandleandwalletId;admitNativeOpis a@MainActorinternal ofPlatformWalletManager.)refreshIdentity(run automatically when the Update Limits sheet opens) andupdateIdentityKeyLimits(asReviewed:)join the shippedupdateIdentityKeyLimitsandupdateIdentity(Disable Key) as writers of the same key rows. The worst case is a stale displayed or cold-restored cap, which the next proved refresh heals. It never feeds signing: the sheet refreshes with a proof on open, and Rust signs only the reviewed preview.