Skip to content

An own-profile refresh that started before a profile write can overwrite it in the wallet's cache #6165

Backlog

Description

@QuantumExplorer

What happens

DashPayView::sync_profiles (packages/rs-platform-wallet/src/wallet/identity/network/profile.rs) fetches the wallet identities' profiles, then takes the wallet lock and stores every fetched profile that differs from the cached one.

A profile write (write_dashpay_profile) stores the profile Platform proved for the write. Nothing orders the two:

  1. A background refresh fetches the profile and reads the document as it was before the write.
  2. The write lands and the wallet caches the new profile.
  3. The refresh takes the lock, sees its (older) result differs from the cache, and stores it.

The cache and the host's persisted row now hold the profile from before the write, until a later refresh succeeds. Any field can be affected. It matters most for a payment address: one the user just removed shows as published again, or a replaced one shows its old value.

The lock serializes the two assignments but says nothing about which read is newer.

Possible fix

Keep, per identity, the proved height (or the document revision) of the profile the cache holds, and have the refresh skip a result that is older than what the cache holds. The profile document's $revision is already in both the fetched document and the write's result, so comparing revisions needs no new query.

A test: a refresh paused after its fetch, a confirmed write that removes a field while another remains, then the refresh released; the cache must keep the written profile.

This predates profile payment addresses. Raised by the review of #6094: #6094 (comment)

Activity

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