Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix_: applying removed contacts from backup #5925

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

saledjenic
Copy link
Contributor

Applying removed contact from the backup was removed due to condition.

@status-im-auto
Copy link
Member

status-im-auto commented Oct 7, 2024

Jenkins Builds

Click to see older builds (4)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 8485653 #1 2024-10-07 15:34:54 ~3 min tests-rpc 📄log
✔️ 8485653 #1 2024-10-07 15:35:39 ~4 min linux 📦zip
✔️ 8485653 #1 2024-10-07 15:36:15 ~5 min android 📦aar
✔️ 8485653 #1 2024-10-07 16:04:51 ~33 min tests 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ cf3f847 #2 2024-10-07 19:37:44 ~2 min android 📦aar
✔️ cf3f847 #2 2024-10-07 19:38:16 ~2 min linux 📦zip
✔️ cf3f847 #2 2024-10-07 19:39:12 ~3 min tests-rpc 📄log
✔️ cf3f847 #2 2024-10-07 19:39:25 ~3 min ios 📦zip
✔️ cf3f847 #2 2024-10-07 20:08:44 ~33 min tests 📄log
✔️ 0690be2 #3 2025-01-30 12:32:56 ~3 min ios 📦zip
✔️ 0690be2 #1 2025-01-30 12:33:07 ~3 min macos 📦zip
✔️ 0690be2 #3 2025-01-30 12:34:16 ~5 min linux 📦zip
✔️ 0690be2 #1 2025-01-30 12:34:33 ~5 min macos 📦zip
✔️ 0690be2 #1 2025-01-30 12:34:45 ~5 min windows 📦zip
✔️ 0690be2 #3 2025-01-30 12:35:17 ~6 min android 📦aar
✖️ 0690be2 #3 2025-01-30 12:35:48 ~6 min tests-rpc 📄log
✔️ 0690be2 #3 2025-01-30 13:00:04 ~30 min tests 📄log

Copy link

codecov bot commented Oct 7, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 61.80%. Comparing base (c993c7f) to head (0690be2).

Files with missing lines Patch % Lines
protocol/messenger_handler.go 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5925      +/-   ##
===========================================
- Coverage    61.91%   61.80%   -0.11%     
===========================================
  Files          843      843              
  Lines       111287   111288       +1     
===========================================
- Hits         68903    68783     -120     
- Misses       34449    34528      +79     
- Partials      7935     7977      +42     
Flag Coverage Δ
functional 21.54% <0.00%> (-0.01%) ⬇️
unit 60.31% <50.00%> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
protocol/messenger_handler.go 59.63% <50.00%> (-0.07%) ⬇️

... and 36 files with indirect coverage changes

@@ -583,6 +583,8 @@ func (m *Messenger) handleSyncChats(messageState *ReceivedMessageState, chats []
func (m *Messenger) HandleSyncInstallationContactV2(state *ReceivedMessageState, message *protobuf.SyncInstallationContactV2, statusMessage *v1protocol.StatusMessage) error {
// Ignore own contact installation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is no longer on the right line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, was testing something else and that left. Removed now.

@@ -583,6 +583,8 @@ func (m *Messenger) handleSyncChats(messageState *ReceivedMessageState, chats []
func (m *Messenger) HandleSyncInstallationContactV2(state *ReceivedMessageState, message *protobuf.SyncInstallationContactV2, statusMessage *v1protocol.StatusMessage) error {
// Ignore own contact installation

fromBackup := statusMessage == nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear why having no message means it comes from backups 🤔

Copy link
Contributor Author

@saledjenic saledjenic Oct 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, there are 3 places where this function is called from:

  1. handleBackup (used when applying messages from the backup)
  2. HandleSyncRawMessages (used when local pairing)
  3. dispatchToHandler -> handleSyncInstallationContactV2Protobuf (used when a synced message comes from another (paired) device over the network)

In case of point 3 the code is the same as it was, in case of points 1 and 2 we need to store the contact even it has Removed or Blocked flag set to false.

That's why I used this flag fromPairedDevice := statusMessage != nil to filter out the source from which messages are coming.

So the issue was spotted in status-im/status-mobile#18096 but based on the code the same happens for Removed or Blocked contacts for applying messages from backup and local pairing. That should be fixed now.

@saledjenic saledjenic force-pushed the fix/applying-removed-contact branch from 8485653 to cf3f847 Compare October 7, 2024 19:35
Copy link
Contributor

@osmaczko osmaczko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Could you please elaborate on how this resolves the issue of a deleted contact being restored from backup when it shouldn't? From what I understand, the additional condition enforces the creation of a removed contact in all scenarios except for network syncing. Additionally, a regression test would be extremely helpful.

@saledjenic
Copy link
Contributor Author

@osmaczko have you tested? Are you able to reproduce the issue with these changes?

From what I understand, the additional condition enforces the creation of a removed contact in all scenarios except for network syncing.

Actually that's the thing. When we do a backup, we send all contacts from the db, including those marked as removed/blocked. When we restore from waku or from another device, we actually want to replicate the db as it was when the last backup was done. When a removed contact is about to be added, since it's not in db, thus not found, we just "return" instead of adding it to db. What I did, I let the function "return" if the sync message is coming from paired device over a network, but let it be added to db in case it's coming from restoring from waku or another device.

@churik
Copy link
Member

churik commented Jan 27, 2025

@saledjenic
Sorry for extremely late notice, does it make sense to check it now? we need to rebase then status-go and we'll able to re-check the issue again. Seems the issue got lost in other priorities.

@saledjenic
Copy link
Contributor Author

@churik since this PR is not merged yet, I guess that the issue is still here, you can test the app with and without this change and see. Do you want me to rebase this branch?

@churik
Copy link
Member

churik commented Jan 30, 2025

@saledjenic yes, please

@pavloburykh
Copy link

@saledjenic thanks for the PR. Please take a look at the issues logged in corresponding mobile PR status-im/status-mobile#22011 (comment)

@pavloburykh
Copy link

@saledjenic thanks for the PR. Please take a look at the issues logged in corresponding mobile PR status-im/status-mobile#22011 (comment)

Hey @saledjenic! Pinging you in case you missed the comment. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants