Skip to content

fix: skip account auto-discovery during backup restore (APP-3446)#7256

Closed
janicduplessis wants to merge 1 commit intodevelopfrom
fix/skip-discovery-during-restore
Closed

fix: skip account auto-discovery during backup restore (APP-3446)#7256
janicduplessis wants to merge 1 commit intodevelopfrom
fix/skip-discovery-during-restore

Conversation

@janicduplessis
Copy link
Copy Markdown
Contributor

@janicduplessis janicduplessis commented Mar 24, 2026

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 createWallet when restoring from backup. During restore, each seed phrase triggers sequential hasPreviousTransactions requests (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.info calls:

  1. Backup restore on develop (before fix): shouldAutoDiscover: true and "initializing account auto discovery" log appears → discovery runs during restore
  2. Backup restore on fix branch: shouldAutoDiscover: true but "initializing account auto discovery" does not appear → discovery is correctly skipped, restore completes immediately
  3. Seed phrase import on fix branch: shouldAutoDiscover: true and "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).

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.
@linear
Copy link
Copy Markdown

linear Bot commented Mar 24, 2026

@janicduplessis janicduplessis marked this pull request as ready for review March 24, 2026 13:41
@github-actions
Copy link
Copy Markdown

Launch in simulator or device for 7850f72

@github-actions
Copy link
Copy Markdown

🧪 Flashlight Performance Report (AWS Device Farm)

🔀 Commit: 7850f72

📎 View Artifacts

Metric Current Δ vs Baseline
Time to Interactive (TTI) 5591 ms ⚪ +39.2 ms (+0.7%)
Average FPS 56.68 ⚪ -0.1 (-0.2%)
Average RAM 394.2 MB ⚪ +3.4 MB (+0.9%)

@DanielSinclair
Copy link
Copy Markdown
Contributor

@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.

@DanielSinclair DanielSinclair self-requested a review March 25, 2026 16:51
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/model/wallet.ts
// 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))) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

@janicduplessis janicduplessis marked this pull request as draft April 18, 2026 16:59
@janicduplessis
Copy link
Copy Markdown
Contributor Author

This ended up being needed, there are cases we want to fetch all accounts when retoring backups

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.

2 participants