Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export const createMultichainAccountGroupsBatch = async (
profileId: ProfileId,
analyticsAction: BackupAndSyncAnalyticsAction,
): Promise<void> => {
console.log(`[PERFORMANCE DEBUG] createMultichainAccountGroupsBatch - Creating ${maxGroupIndex + 1} account groups (batch) for entropy source: ${entropySourceId}`);
console.log(`[PERFORMANCE DEBUG] createMultichainAccountGroupsBatch - Max group index: ${maxGroupIndex}`);
console.log(`[PERFORMANCE DEBUG] createMultichainAccountGroupsBatch - Context: ${JSON.stringify(context)}`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

JSON.stringify(context) will throw on circular references

High Severity

JSON.stringify(context) will throw a TypeError: Converting circular structure to JSON because BackupAndSyncContext contains controller: this (the full AccountTreeController instance) and messenger (a complex event system), which almost certainly have circular references. This unhandled error will crash createMultichainAccountGroupsBatch before any account groups are created.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a89313e. Configure here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Debug console.log statements committed to production code

Medium Severity

Multiple [PERFORMANCE DEBUG] console.log statements are added across production library code in a published npm package. These are clearly temporary debugging statements (prefixed with [PERFORMANCE DEBUG]), and will generate noisy output for all consumers. Some also serialize potentially sensitive data like options and context objects via JSON.stringify.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a89313e. Configure here.


const numberOfAccountGroupsToCreate = maxGroupIndex + 1; // maxGroupIndex is zero-based, so we add 1 to get the count.
backupAndSyncLogger(
`Creating ${numberOfAccountGroupsToCreate} account groups (batch) for entropy source: ${entropySourceId}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,10 +675,16 @@ export class MultichainAccountService {
toGroupIndex: number;
entropySource: EntropySourceId;
}): Promise<MultichainAccountGroup<Bip44Account<KeyringAccount>>[]> {
return await this.#getWallet(entropySource).createMultichainAccountGroups(
console.log(`[PERFORMANCE DEBUG] MultichainAccountService - Creating multichain account groups from ${fromGroupIndex} to ${toGroupIndex} for entropy source: ${entropySource}`);
const start = performance.now();
const result = await this.#getWallet(entropySource).createMultichainAccountGroups(
{ from: fromGroupIndex, to: toGroupIndex },
{ waitForAllProvidersToFinishCreatingAccounts: false },
{ waitForAllProvidersToFinishCreatingAccounts: true },
Comment thread
gantunesr marked this conversation as resolved.
);
const end = performance.now();
console.log(`[PERFORMANCE DEBUG] MultichainAccountService - Time taken to create multichain account groups: ${end - start}ms`);
console.log(`[PERFORMANCE DEBUG] MultichainAccountService - Result: ${result.length} groups created`);
return result;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ export class MultichainAccountWallet<
const results = await Promise.allSettled(
providers.map(async (provider) => {
const providerName = provider.getName();
console.log(`[PERFORMANCE DEBUG] MultichainAccountWallet - Execution of buildGroupStateForRange. Start accounts creation for provider: ${providerName} from ${from} to ${to}`);
const accounts = await this.#createAccountsRangeForProvider(
provider,
from,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,18 @@ export abstract class SnapAccountProvider extends BaseBip44AccountProvider {
if (options.type === `${AccountCreationType.Bip44DeriveIndexRange}`) {
if (batched) {
// Batch account creations.
console.log(`[PERFORMANCE DEBUG] SnapAccountProvider ${this.getName()} (createAccountsV2) - Batching account creations with options: ${JSON.stringify(options)}`);
const start = performance.now();
snapAccounts = await createAccountsV2(options);
const end = performance.now();
console.log(`[PERFORMANCE DEBUG] SnapAccountProvider ${this.getName()} (createAccountsV2) - Time taken to create accounts between ${options.range.from} and ${options.range.to}: ${end - start} ms`);
console.log(`[PERFORMANCE DEBUG] SnapAccountProvider ${this.getName()} (createAccountsV2) - Result: ${snapAccounts.length} accounts created`);
} else {
console.log(`[PERFORMANCE DEBUG] SnapAccountProvider ${this.getName()} (createAccountV1) - Creating accounts one by one with options: ${JSON.stringify(options)}`);
const { range } = options;

// Create accounts one by one.
const start = performance.now();
for (
let groupIndex = range.from;
groupIndex <= range.to;
Expand All @@ -401,6 +408,9 @@ export abstract class SnapAccountProvider extends BaseBip44AccountProvider {

snapAccounts.push(snapAccount);
}
const end = performance.now();
console.log(`[PERFORMANCE DEBUG] SnapAccountProvider ${this.getName()} (createAccountV1) - Time taken to create accounts: ${end - start} ms`);
console.log(`[PERFORMANCE DEBUG] SnapAccountProvider ${this.getName()} (createAccountV1) - Result: ${snapAccounts.length} accounts created`);
}

// Group indices are sequential, so we just need the starting index.
Expand Down Expand Up @@ -439,6 +449,7 @@ export abstract class SnapAccountProvider extends BaseBip44AccountProvider {
async createAccounts(
options: CreateAccountOptions,
): Promise<Bip44Account<KeyringAccount>[]> {
console.log(`[PERFORMANCE DEBUG] SnapAccountProvider ${this.getName()} - Creating accounts with options: ${JSON.stringify(options)}`);
assertCreateAccountOptionIsSupported(options, [
`${AccountCreationType.Bip44DeriveIndex}`,
`${AccountCreationType.Bip44DeriveIndexRange}`,
Expand Down
Loading