core icon indicating copy to clipboard operation
core copied to clipboard

chore: batch account creation

Open Nodonisko opened this issue 2 months ago • 0 comments

Explanation

This batches some calls during account creation after SRP import. It reduced time it took from ~35s to ~9s on my device for SRP with ~250 accounts.

I am not sure if this is worth merging because of https://github.com/MetaMask/core/pull/6654

Screenshot 2025-12-12 at 18 38 26 Screenshot 2025-12-12 at 18 38 01

References

Checklist

  • [ ] I've updated the test suite for new or updated code as appropriate
  • [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • [ ] I've communicated my changes to consumers by updating changelogs for packages I've changed
  • [ ] I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

[!NOTE] Batches EVM account discovery/creation and debounces wallet/group syncs to cut redundant vault updates during large imports.

  • MultichainAccountService:
    • Add debounced sync pipeline (50ms) using #pendingWalletSyncs and #pendingGroupSyncs; replace immediate wallet.sync()/group.sync() on account add with queued flush via #scheduleSync() and #flushSyncs().
  • MultichainAccountWallet:
    • Optimize discovery: detect contiguous active EVM accounts, then batch-create them and skip sequential EVM discovery; update maxGroupIndex accordingly.
  • EvmAccountProvider:
    • Add findActiveAccountCount (checks activity via eth_getTransactionCount), bulkCreateAccounts (single keyring write), and internal #createAccountsBatch helper; expose address/tx-count helpers for discovery flow.

Written by Cursor Bugbot for commit a9466cfd37cfb6846c54faa148528c48febf3300. This will update automatically on new commits. Configure here.

Nodonisko avatar Dec 12 '25 17:12 Nodonisko