Skip to content

Commit 33ab122

Browse files
committed
all recipients in parallel
1 parent 5a0a1b5 commit 33ab122

File tree

1 file changed

+26
-23
lines changed

1 file changed

+26
-23
lines changed

yarn-project/pxe/src/contract_function_simulator/pxe_oracle_interface.ts

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -321,32 +321,35 @@ export class PXEOracleInterface implements ExecutionDataProvider {
321321
// Determine recipients: use scopes if provided, otherwise get all accounts
322322
const recipients = scopes && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
323323

324-
// Process each recipient
325-
for (const recipient of recipients) {
326-
// Get all secrets for this recipient (one per sender)
327-
const secrets = await this.#getSecretsForSenders(contractAddress, recipient);
328-
329-
// Load logs for all sender-recipient pairs in parallel
330-
const logArrays = await Promise.all(
331-
secrets.map(secret =>
332-
loadPrivateLogsForSenderRecipientPair(
333-
secret,
334-
contractAddress,
335-
this.aztecNode,
336-
this.newRecipientTaggingDataProvider,
337-
anchorBlockNumber,
324+
// For each recipient, fetch secrets, load logs, and store them.
325+
// We run these per-recipient tasks in parallel so that logs are loaded for all recipients concurrently.
326+
await Promise.all(
327+
recipients.map(async recipient => {
328+
// Get all secrets for this recipient (one per sender)
329+
const secrets = await this.#getSecretsForSenders(contractAddress, recipient);
330+
331+
// Load logs for all sender-recipient pairs in parallel
332+
const logArrays = await Promise.all(
333+
secrets.map(secret =>
334+
loadPrivateLogsForSenderRecipientPair(
335+
secret,
336+
contractAddress,
337+
this.aztecNode,
338+
this.newRecipientTaggingDataProvider,
339+
anchorBlockNumber,
340+
),
338341
),
339-
),
340-
);
342+
);
341343

342-
// Flatten all logs from all secrets
343-
const allLogs = logArrays.flat();
344+
// Flatten all logs from all secrets
345+
const allLogs = logArrays.flat();
344346

345-
// Store the logs for this recipient
346-
if (allLogs.length > 0) {
347-
await this.#storePendingTaggedLogs(contractAddress, pendingTaggedLogArrayBaseSlot, recipient, allLogs);
348-
}
349-
}
347+
// Store the logs for this recipient
348+
if (allLogs.length > 0) {
349+
await this.#storePendingTaggedLogs(contractAddress, pendingTaggedLogArrayBaseSlot, recipient, allLogs);
350+
}
351+
}),
352+
);
350353
}
351354

352355
async #storePendingTaggedLogs(

0 commit comments

Comments
 (0)