fix: skip account auto-discovery during backup restore (APP-3446)#7256
fix: skip account auto-discovery during backup restore (APP-3446)#7256janicduplessis wants to merge 1 commit intodevelopfrom
Conversation
During iCloud backup restore, createWallet runs auto-discovery for each seed phrase — sequentially fetching tx history from aha.rainbow.me for each derived address. With many accounts (e.g. 122), this causes hundreds of sequential HTTP requests with no timeout, causing the restore to hang indefinitely on the 'Restoring...' screen. The backup already contains the full list of accounts, so discovery is unnecessary during restore. Skip it when isRestoring is true.
|
🧪 Flashlight Performance Report (AWS Device Farm) 🔀 Commit: 7850f72
|
|
@codex review. Sanity check this fix and review the full codepath for all entrypoints to ensure behavior will not change for non-backup paths. Ensure the assumptions are correct and this information persists across iCloud Backups. Describe clear reproduction steps if an issue is possible. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fbc1fa730d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Initiate auto account discovery for imported wallets via seedphrase | ||
| // or for hardware wallets | ||
| if ((isHDWallet && root && isImported) || (isHardwareWallet && seed)) { | ||
| if (!isRestoring && ((isHDWallet && root && isImported) || (isHardwareWallet && seed))) { |
There was a problem hiding this comment.
Preserve derived accounts during backup restore
This !isRestoring gate removes the only account-expansion path during cloud restore, because restoreSpecificBackupIntoKeychain always calls createWallet(..., isRestoring: true) and createWallet otherwise only adds index 0; in the current restore parser, non-cipher entries only populate seed phrases (src/model/backup.ts:517-519), so iCloud restores can no longer recover additional derived accounts that previously came from this discovery loop. Repro: on iOS, create a mnemonic wallet with funds/activity on account index 1+, make an iCloud cloud backup, reinstall/restore, and compare wallet accounts before vs after this commit—the post-fix restore can end with only the first account (or changed wallet grouping), which is a behavioral regression specific to backup paths.
Useful? React with 👍 / 👎.
|
This ended up being needed, there are cases we want to fetch all accounts when retoring backups |
Fixes APP-3446
What changed (plus any additional context for devs)
User with 122 accounts in Rainbow is unable to restore from iCloud backup. The restore process hangs (20+ seconds in screen recordings) without completing.
Skip account auto-discovery in
createWalletwhen restoring from backup. During restore, each seed phrase triggers sequentialhasPreviousTransactionsrequests (no timeout) to discover derived accounts. With many accounts (122 in this case), this can hang the restore indefinitely.The backup already contains all accounts and keys so discovery is unnecessary.
Screen recordings / screenshots
N/A
What to test
Was not able to reproduce the infinite loading issue, this is a theoretical fix based on code analysis. However, validated that the code path is correctly hit by adding temporary
logger.infocalls:develop(before fix):shouldAutoDiscover: trueand "initializing account auto discovery" log appears → discovery runs during restoreshouldAutoDiscover: truebut "initializing account auto discovery" does not appear → discovery is correctly skipped, restore completes immediatelyshouldAutoDiscover: trueand "initializing account auto discovery" log appears → discovery still works for normal imports (no regression)Tested with Google Drive backup restore (same code path as iCloud).