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
platform-wallet: contactInfo update has no expected-revision check, so a stale read overwrites another device's edit #5545
TL;DR: If two devices edit the same DashPay contact's details close together, the later save silently undoes the earlier one. For example, changing only the note on one device can put back an old nickname that was just changed on the other device.
User story
As a DashPay user with more than one device or wallet app, I want a save of a contact's nickname, note or hidden flag to fail visibly when the record changed elsewhere since I opened it, so that I never silently lose an edit made on another device.
Scenario
Base flow
Device A and device B both show contact C with nickname "Bao" and an empty note. On A, the user changes the nickname to "Bao Tran" and saves. Before B syncs, the user changes only the note on B and saves.
Actual behavior
B's save writes nickname "Bao" (its stale read) together with the new note, replacing A's newer document at its current revision. A's nickname change is lost and nothing reports a conflict.
Expected behavior
B's save is refused (or the caller can detect the conflict) because the document it would replace is no longer the revision B read, so B can re-read and merge.
Detailed discussion
set_contact_info_with_external_signer (packages/rs-platform-wallet/src/wallet/identity/network/contact_info.rs, checked on v5.0-dev) takes the complete alias / note / display_hidden set. A caller that edits one field must therefore supply the other fields from an earlier read, which makes every edit a read-modify-write. The method re-fetches the owner's documents, opens each one to find the contact, and builds a Replace at the revision it has just fetched (revision: Some(revision)). Because no revision is taken from the caller, a document published by another device between the caller's read and this fetch is replaced without any conflict signal. Drive's revision check cannot help: the Replace always carries the revision fetched a moment earlier.
Possible solution (either option works):
accept an optional expected_revision (or the expected document id + revision) and return a typed conflict error when the matched document's fetched revision differs; or
take per-field updates (Option<Option<String>> for alias/note, Option<bool> for hidden) and merge them onto the freshly fetched document inside the method, which narrows the window to a single fetch→broadcast.
Related: #5544 (the update path rewrites the oldest matching document while sync shows the newest). A fix for this issue should compare against the same document that #5544's fix chooses.
Downstream: dashpay/dash-evo-tool#1102 records this as a known limitation and does not work around it in the client.
Activity