Repository navigation
Description
Expected Behavior
When a wallet-owned identity loses a DPNS name (sold, transferred or deleted outside the wallet), the local owned-name list drops it, and the marketplace sweep still classifies the departure (sale / transfer / deletion, history, sale-triggered balance refresh). This holds across restarts and failed sweep passes. A stale snapshot from the previous owner never changes the new owner's state.
Current Behavior
The DPNS marketplace sweep discovers departures only from ManagedIdentity.dpns_names and the session-scoped dpns_name_states (departure_candidates, sync_dpns_marketplace). dpns_name_states starts empty on every load (manager/load.rs). The owned-name list is therefore both the current-ownership record and the only durable departure trigger, and no choice for username fetches keeps both correct:
- Prune on a complete username fetch. Ownership is right, but a label pruned before the next sweep loses its only trigger. An in-memory pending-departure queue was tried in fix(sdk): keep the chosen DPNS name across wallet sync #4978 (78b0e0e); it does not survive a restart or a failed resolution.
- Keep labels for wallet-owned identities (fix(sdk): keep the chosen DPNS name across wallet sync #4978 as merged,
apply_fetched_dpns_names). Departures stay with the sweep, but:- A complete
refresh_dpns_names()(loading.rs) with an empty result leaves the departed name in the list while marketplace sync is not running (DpnsSyncManageris not auto-started), and later snapshots keep advertising it as owned. - After an external A→B transfer, B's username sync rebinds the name row to B. Any later snapshot of A (for example a balance refresh) still carries the name, so the Swift persister rebinds the row back to A and clears B's
mainDpnsName(rebind branch). The erased selection cannot be reconstructed.
- A complete
Possible Solution
Separate the two concerns:
- Departure work becomes durable. Persist pending departures alongside the ownership snapshot, e.g. a changeset /
IdentityEntryfield carried through FFI and restored on load. The sweep acknowledges an entry only after its reconciliation is durably applied, and keeps failed entries for later passes without blocking others. - Username fetches prune freely once departures are durable. A complete fetch then updates current ownership for wallet-owned identities too, and stale snapshots stop carrying departed names.
- Rebinds become reversible. Clear another identity's selection only on confirmed departure evidence, not on a snapshot rebind; otherwise keep the selection and let read-time ownership (
ownedMainDpnsName) hide it.
Steps to Reproduce (for bugs)
Found by code review of #4978 (review at c8ce2d8), not reproduced on a network. The review's scenarios:
- Wallet-owned identity holds
alice;aliceleaves it externally; callrefresh_dpns_names()with marketplace sync not started.dpns_namesstill containsalice. - Identities A and B in one wallet;
alicetransfers A→B externally; B's username sync runs; the user selectsalicefor B; a balance refresh for A emits a snapshot. The row rebinds to A and B's selection is cleared.
Context
Follow-up to #4978 (chosen DPNS name lost on every relaunch, support ticket 32382). The ticket's scenario is fixed and verified there. This issue covers ownership and departure edge cases the review surfaced, which need a durable departure store rather than another trade-off inside that PR.
Your Environment
platform v4.3-dev with #4978 (c8ce2d8b24), rs-platform-wallet + swift-sdk; testnet.
Activity
QuantumExplorer commentedon Nov 22, 2026
Two more cases on the same shared sync paths, found reviewing #6055 (giving up a DPNS name). That PR does not change these paths, and transfer and purchase share both cases:
sync_dpns_namesfetches outside the DPNS operation gate and merges under the manager lock. A fetch that read the old ownership and merges after a confirmed give-up, transfer or purchase re-adds the label for a wallet-owned identity (merge-only). It heals only when a later marketplace sweep classifies it again.sync_dpns_marketplaceremoves the label, then callsrecord_dpns_name_states, which updates memory and only logs a failed store. If that store fails, the durable row is left with stale marketplace columns, and no label is left to trigger another pass. The give-up path in feat(platform-wallet): delete or tombstone a DPNS name from the wallet and the iOS app #6055 stores the row removal first and drops the label last, and the sweep could do the same.QuantumExplorer commentedon Nov 22, 2026
The durable DPNS row lookup (
PlatformWalletPersistence::get_dpns_name_state) returns one row per owner and normalized label, and its key has no parent domain. When an identity holdsOwnedrows for one label under more than one parent, any caller that needs the rows of a single name can reach only the top row. That includes the give-up cleanup added in #6055 and the sync departure path'sprevious_document_id_for. An older row of the same name that exists only in durable storage is then never removed.The label is kept in that case, so nothing is lost, but the older row stays
Ownedin storage. A second top-level parent can only be created by the DPNS contract owner, so this is rare.A fix needs a lookup that returns every row of the label, or one that takes the parent, in the trait, the SQLite backend and the FFI read slot this issue already asks for. Found in review of #6055.