Skip to content

chore: optimize batch account create#55

Merged
stanleyyconsensys merged 9 commits into
mainfrom
feat/batch-accounts
May 12, 2026
Merged

chore: optimize batch account create#55
stanleyyconsensys merged 9 commits into
mainfrom
feat/batch-accounts

Conversation

@stanleyyconsensys
Copy link
Copy Markdown
Collaborator

@stanleyyconsensys stanleyyconsensys commented May 6, 2026

Explanation

This PR introduces a batched/concurrency-limited account creation path to avoid sequential per-index derivation and persistence, and adds a new async batching utility to support that flow in the Snap codebase.

Brenchmark:
23 accounts with optimize batch creation: ~81ms
23 accounts with normal batch creation: ~1200ms

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

...derivedAccount.options,
groupIndex: derivationIndex,
},
};
Copy link
Copy Markdown
Collaborator Author

@stanleyyconsensys stanleyyconsensys May 7, 2026

Choose a reason for hiding this comment

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

we drop groupIndex when create account

as it is no longer use, redundant
and does not match the keyring account structure

and we didnt do migration for now, as the SNAP is still in DEV stage

callback?: (account: StellarKeyringAccount) => Promise<void>,
): Promise<StellarKeyringAccount> {
const accounts = await this.#accountsRepository.getAll();
return this.#createAccountLock.runExclusive(async () => {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

we add lock on both single and multiple account create method, to make sure they are not calling at same time as the best effort to avoid racing condition

@stanleyyconsensys stanleyyconsensys merged commit 58cef90 into main May 12, 2026
10 checks passed
@stanleyyconsensys stanleyyconsensys deleted the feat/batch-accounts branch May 12, 2026 07:07
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