Skip to content

Commit de92da5

Browse files
mathieuartuccharly
andauthored
feat(multichain-account-service): populate maxConcurrency for BTC and TRX providers (#7052)
## Explanation <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs), highlighting breaking changes as necessary - [ ] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Sets a default maxConcurrency of 3 for Bitcoin and Tron account providers, updates tests and changelogs, and reverts seedless-onboarding-controller to 6.0.0. > > - **Multichain Account Service**: > - **Providers**: Set default `maxConcurrency: 3` in `BtcAccountProvider` and `TrxAccountProvider` constructors (`src/providers/{Btc,Trx}AccountProvider.ts`). > - **Tests**: Make `maxConcurrency` optional and add test asserting default `Infinity` when unspecified (`src/providers/SnapAccountProvider.test.ts`). > - **Changelog**: Document BTC/TRX concurrency limit under `Unreleased` (`packages/multichain-account-service/CHANGELOG.md`). > - **Seedless Onboarding Controller**: > - **Version/Changelog**: Revert to `6.0.0`, remove `6.1.0` section, and update comparison links (`package.json`, `CHANGELOG.md`). > - **Repo**: > - Bump root `package.json` version to `659.0.0`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit ece5cd3. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Charly Chevalier <charly.chevalier@consensys.net>
1 parent 80b9a0f commit de92da5

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

packages/multichain-account-service/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- Limit Bitcoin and Tron providers to 3 concurrent account creations by default when creating multichain account groups ([#7052](https://github.com/MetaMask/core/pull/7052))
13+
1014
## [2.1.0]
1115

1216
### Added

packages/multichain-account-service/src/providers/BtcAccountProvider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class BtcAccountProvider extends SnapAccountProvider {
2828
constructor(
2929
messenger: MultichainAccountServiceMessenger,
3030
config: BtcAccountProviderConfig = {
31+
maxConcurrency: 3,
3132
createAccounts: {
3233
timeoutMs: 3000,
3334
},

packages/multichain-account-service/src/providers/SnapAccountProvider.test.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const TEST_SNAP_ID = 'npm:@metamask/test-snap' as SnapId;
1818
const TEST_ENTROPY_SOURCE = 'test-entropy-source' as EntropySourceId;
1919

2020
// Helper to create a tracked provider that monitors concurrent execution
21-
const createTrackedProvider = (maxConcurrency: number) => {
21+
const createTrackedProvider = (maxConcurrency?: number) => {
2222
const tracker: {
2323
startLog: number[];
2424
endLog: number[];
@@ -67,7 +67,7 @@ const createTrackedProvider = (maxConcurrency: number) => {
6767

6868
const messenger = getMultichainAccountServiceMessenger(getRootMessenger());
6969
const config = {
70-
maxConcurrency,
70+
...(maxConcurrency !== undefined && { maxConcurrency }),
7171
createAccounts: {
7272
timeoutMs: 5000,
7373
},
@@ -197,5 +197,26 @@ describe('SnapAccountProvider', () => {
197197
// With maxConcurrency=1, never more than 1 should run at a time
198198
expect(tracker.maxActiveCount).toBe(1);
199199
});
200+
201+
it('defaults to Infinity when maxConcurrency is not provided', async () => {
202+
const { provider, tracker } = createTrackedProvider();
203+
204+
// Start 4 concurrent calls
205+
const promises = [0, 1, 2, 3].map((index) =>
206+
provider.createAccounts({
207+
entropySource: TEST_ENTROPY_SOURCE,
208+
groupIndex: index,
209+
}),
210+
);
211+
212+
await Promise.all(promises);
213+
214+
// All 4 operations should complete
215+
expect(tracker.startLog).toHaveLength(4);
216+
217+
// Without maxConcurrency specified, should default to Infinity (no throttling)
218+
// So all 4 should have been able to run concurrently
219+
expect(tracker.maxActiveCount).toBe(4);
220+
});
200221
});
201222
});

packages/multichain-account-service/src/providers/TrxAccountProvider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class TrxAccountProvider extends SnapAccountProvider {
2929
constructor(
3030
messenger: MultichainAccountServiceMessenger,
3131
config: TrxAccountProviderConfig = {
32+
maxConcurrency: 3,
3233
discovery: {
3334
timeoutMs: 2000,
3435
maxAttempts: 3,

0 commit comments

Comments
 (0)