Skip to content

fix(backup)_: do not show the backup notifi backup during normal fetch #6550

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

Merged
merged 1 commit into from
May 13, 2025

Conversation

jrainville
Copy link
Member

Fixes status-im/status-desktop#17555

We were adding the Notification of the back ups by accident when creating a normal account (not restored), because I added the code to create the notification in the RequestAllHistoricMessages function as well, even though the Messenger already does it. So for normal restores, it probably tried to add it twice, though they have the same ID, so it wasn't noticed

@status-im-auto
Copy link
Member

status-im-auto commented Apr 23, 2025

Jenkins Builds

Click to see older builds (24)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 01ba971 #1 2025-04-23 16:14:51 ~3 min android 📦aar
✔️ 01ba971 #1 2025-04-23 16:15:00 ~3 min ios 📦zip
✔️ 01ba971 #1 2025-04-23 16:16:26 ~4 min macos 📦zip
✔️ 01ba971 #1 2025-04-23 16:17:04 ~5 min macos 📦zip
✔️ 01ba971 #1 2025-04-23 16:17:55 ~6 min linux 📦zip
✔️ 01ba971 #1 2025-04-23 16:18:23 ~6 min windows 📦zip
✔️ 01ba971 #1 2025-04-23 16:22:07 ~10 min tests-rpc 📄log
✔️ 01ba971 #1 2025-04-23 16:47:41 ~35 min tests 📄log
✔️ 5427ecc #2 2025-05-05 15:48:29 ~3 min ios 📦zip
✔️ 5427ecc #2 2025-05-05 15:49:20 ~4 min macos 📦zip
✔️ 5427ecc #2 2025-05-05 15:50:24 ~5 min linux 📦zip
✔️ 5427ecc #2 2025-05-05 15:50:36 ~5 min android 📦aar
✔️ 5427ecc #2 2025-05-05 15:50:48 ~5 min macos 📦zip
✔️ 5427ecc #2 2025-05-05 15:51:18 ~5 min windows 📦zip
✔️ 5427ecc #2 2025-05-05 15:56:49 ~11 min tests-rpc 📄log
✔️ 5427ecc #2 2025-05-05 16:23:04 ~37 min tests 📄log
✔️ a0e93c8 #3 2025-05-08 15:16:34 ~3 min ios 📦zip
✔️ a0e93c8 #3 2025-05-08 15:16:39 ~3 min android 📦aar
✔️ a0e93c8 #3 2025-05-08 15:18:45 ~5 min macos 📦zip
✔️ a0e93c8 #3 2025-05-08 15:18:55 ~5 min windows 📦zip
✔️ a0e93c8 #3 2025-05-08 15:19:17 ~5 min macos 📦zip
✔️ a0e93c8 #3 2025-05-08 15:19:55 ~6 min linux 📦zip
✔️ a0e93c8 #3 2025-05-08 15:23:24 ~9 min tests-rpc 📄log
✔️ a0e93c8 #3 2025-05-08 15:48:47 ~35 min tests 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 9cb6526 #4 2025-05-12 15:39:19 ~3 min android 📦aar
✔️ 9cb6526 #4 2025-05-12 15:41:11 ~4 min windows 📦zip
✔️ 9cb6526 #4 2025-05-12 15:41:31 ~5 min macos 📦zip
✔️ 9cb6526 #4 2025-05-12 15:41:57 ~5 min ios 📦zip
✔️ 9cb6526 #4 2025-05-12 15:42:07 ~5 min linux 📦zip
✔️ 9cb6526 #4 2025-05-12 15:43:49 ~7 min macos 📦zip
✖️ 9cb6526 #4 2025-05-12 15:47:52 ~11 min tests-rpc 📄log
✔️ 9cb6526 #4 2025-05-12 16:12:37 ~36 min tests 📄log
✔️ 9cb6526 #5 2025-05-12 17:13:44 ~9 min tests-rpc 📄log
✔️ 44782a2 #5 2025-05-13 15:28:09 ~2 min android 📦aar
✔️ 44782a2 #5 2025-05-13 15:28:21 ~3 min ios 📦zip
✔️ 44782a2 #5 2025-05-13 15:29:53 ~4 min macos 📦zip
✔️ 44782a2 #5 2025-05-13 15:30:54 ~5 min linux 📦zip
✔️ 44782a2 #5 2025-05-13 15:30:55 ~5 min macos 📦zip
✔️ 44782a2 #5 2025-05-13 15:31:51 ~6 min windows 📦zip
✔️ 44782a2 #6 2025-05-13 15:36:23 ~10 min tests-rpc 📄log
✔️ 44782a2 #5 2025-05-13 16:01:45 ~36 min tests 📄log

@@ -127,6 +127,10 @@ func (m *Messenger) handleBackup(state *ReceivedMessageState, message *protobuf.
}

func (m *Messenger) updateBackupFetchProgress(message *protobuf.Backup, response *wakusync.WakuBackedUpDataResponse, state *ReceivedMessageState) error {
if m.backedUpFetchingStatus == nil {
return nil
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Im not sure this is needed. I don't think we had any crashes, but I just realized that on normal app runs (way after the actual restore), this code could still run and it's better to guard against any crashes.

@@ -324,11 +324,6 @@ func (m *Messenger) RequestAllHistoricMessages(forceFetchingBackup, withRetries

allResponses := &MessengerResponse{}
if forceFetchingBackup || !backupFetched {
Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if we should add the if m.processBackedupMessages here too. What happens here is that even though we are not restoring the account, we end up doing a full backup fetch anyway for no reason?

I did not touch it right now just in case it would cause a regression, but I don't see the point of doing a full (30 days) fetch of backups if we created an account from scratch. Let me know if I'm missing something. The person that added that code was Andrea 4 years ago 😅

Also, if processBackedupMessages is false, we don,t even handle the backups:

func (m *Messenger) HandleBackup(state *ReceivedMessageState, message *protobuf.Backup, statusMessage *v1protocol.StatusMessage) error {
	if !m.processBackedupMessages {
		return nil
	}

cc @status-im/status-go-guild

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it makes much sense to fetch backups for newly created accounts. Adding this condition seems reasonable to me and definitely better than removing backup fetching tracking.

Copy link
Collaborator

@igor-sirotin igor-sirotin May 9, 2025

Choose a reason for hiding this comment

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

I think you're right, the messages will be skipped in HandleBackup. But to me the issue is actually HandleBackup, not here.

If I would call RequestAllHistoricMessages with forceFetchingBackup = true, I'd expect backup to be fetched and the messages to be processed.

I'd keep as is for now, we should carefully refactor the way backup is handled.

Copy link
Collaborator

@igor-sirotin igor-sirotin May 9, 2025

Choose a reason for hiding this comment

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

So I think:

  1. either the condition should be forceFetchingBackup || (!backupFetched && m.processBackedupMessages
    both here and in HandleBackup (which will bring some weird dependencies between those functions)

  2. or we remove forceFetchingBackup option completely
    I think it's only called from desktop in asyncFetchWakuBackupMessagesTask. Which I think is bound to the explicit button in settings and is only used (if used) for testing.

I'd prefer (2), as it would remove the code, not add it 😄

cc @osmaczko @jrainville

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's only called from desktop in asyncFetchWakuBackupMessagesTask. Which I think is bound to the explicit button in settings and is only used (if used) for testing.

It is indeed only used in Desktop, in the backupSyncingComponent in the ActivityCenterPopup of all places.

I'll dig some more to understand why we added this force fetch, but I'm very tempted to just remove it as you proposed

Copy link
Member Author

Choose a reason for hiding this comment

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

Source of the code

Ok I found it. It's used to force the re-fecth of everything in the onboarding.

So when re-importing from the seed phrase, we fetch everything. In the old onboarding, we waited on the page until everything was fetched, now we do it in the background.
In both cases, the user can click Retry if something didn't get fetched.

It at least confirms that it's only used in the case were were are re-importing an old account, ie processBackedupMessages is gonna be set to true.

Remaining problem

However, I just realized that removing the forceFetchingBackup param won't help us in this case, because RequestAllHistoricMessages gets called during the normal flow of the app too (like going back from sleep).

So at somepoint, we'll end up doing the full history fetch anyway.

Possible solutions

I guess we have two options:
a. we could set BackupFetched to true for accounts created from scratch
b. just add the processBackedupMessages like in @igor-sirotin 's option 1.

I think option b is the simpler one, but it does feel weird that BackupFetched will stay false for the whole life of that account.
We could also rename it to fetchAndProcessBackedupMessages so that it's clearer that it's not just about not parsing them, because it's weird to think that we might want to fetch backups but never process them (useless request and computation)

cc @igor-sirotin @osmaczko

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, setting BackupFetched to true for new accounts sounds good to me for now.
@osmaczko wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, setting BackupFetched to true for new accounts sounds good to me for now. @osmaczko wdyt?

Not ideal, because it is untrue, the backup will never be fetched for new accounts.. but it is good enough for now indeed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated the code to do as you guys proposed. I put it in the same commit by accident, but it's still pretty small so it shouldn't be an issue

Copy link

codecov bot commented Apr 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.46%. Comparing base (5163085) to head (44782a2).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #6550      +/-   ##
===========================================
- Coverage    60.52%   60.46%   -0.07%     
===========================================
  Files          833      833              
  Lines       104367   104370       +3     
===========================================
- Hits         63171    63110      -61     
- Misses       33650    33709      +59     
- Partials      7546     7551       +5     
Flag Coverage Δ
functional 25.53% <75.00%> (-0.10%) ⬇️
unit 58.33% <100.00%> (-0.07%) ⬇️

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

Files with missing lines Coverage Δ
api/geth_backend.go 55.00% <100.00%> (+0.05%) ⬆️
multiaccounts/settings/database.go 69.64% <100.00%> (-0.92%) ⬇️
multiaccounts/settings/structs.go 92.85% <ø> (ø)
protocol/messenger_backup_handler.go 56.41% <100.00%> (+0.28%) ⬆️
protocol/messenger_mailserver.go 45.26% <ø> (-2.57%) ⬇️

... and 43 files with indirect coverage changes

@jrainville jrainville force-pushed the fix/wrong-backup-fetching-notification branch 2 times, most recently from 5427ecc to a0e93c8 Compare May 8, 2025 15:13
@jrainville
Copy link
Member Author

@igor-sirotin @osmaczko @seanstrom friendly reminder to review

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.

I would go with m.processBackedupMessages.

@@ -324,11 +324,6 @@ func (m *Messenger) RequestAllHistoricMessages(forceFetchingBackup, withRetries

allResponses := &MessengerResponse{}
if forceFetchingBackup || !backupFetched {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it makes much sense to fetch backups for newly created accounts. Adding this condition seems reasonable to me and definitely better than removing backup fetching tracking.

@@ -324,11 +324,6 @@ func (m *Messenger) RequestAllHistoricMessages(forceFetchingBackup, withRetries

allResponses := &MessengerResponse{}
if forceFetchingBackup || !backupFetched {
Copy link
Collaborator

@igor-sirotin igor-sirotin May 9, 2025

Choose a reason for hiding this comment

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

I think you're right, the messages will be skipped in HandleBackup. But to me the issue is actually HandleBackup, not here.

If I would call RequestAllHistoricMessages with forceFetchingBackup = true, I'd expect backup to be fetched and the messages to be processed.

I'd keep as is for now, we should carefully refactor the way backup is handled.

@jrainville jrainville force-pushed the fix/wrong-backup-fetching-notification branch from a0e93c8 to 9cb6526 Compare May 12, 2025 15:36
Fixes status-im/status-desktop#17555

We were adding the Notification of the back ups by accident when creating a normal account (not restored), because I added the code to create the notification in the `RequestAllHistoricMessages` function as well, even though the Messenger already does it. So for normal restores, it probably tried to add it twice, though they have the same ID, so it wasn't noticed
@jrainville jrainville force-pushed the fix/wrong-backup-fetching-notification branch from 9cb6526 to 44782a2 Compare May 13, 2025 15:25
@jrainville jrainville merged commit 30989a8 into develop May 13, 2025
21 checks passed
@jrainville jrainville deleted the fix/wrong-backup-fetching-notification branch May 13, 2025 17:15
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.

Fetching profile details notification shown after account creation
4 participants