Skip to content
Merged
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 @@ -325,7 +325,7 @@ describe('Private Execution test suite', () => {
// on the input.
aztecNode.getPrivateLogsByTags.mockImplementation((tags: SiloedTag[]) => Promise.resolve(tags.map(() => [])));

// Mock getL2Tips and getBlockHeader for loadPrivateLogsForSenderRecipientPair
// Mock getL2Tips and getBlockHeader for syncTaggedPrivateLogs
l2TipsStore.getL2Tips.mockResolvedValue(makeL2Tips(anchorBlockHeader.globalVariables.blockNumber));

// TODO: refactor. Maybe it's worth stubbing a key store
Expand Down
38 changes: 12 additions & 26 deletions yarn-project/pxe/src/logs/log_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type { SenderAddressBookStore } from '../storage/tagging_store/sender_add
import {
getAllPrivateLogsByTags,
getAllPublicLogsByTagsFromContract,
loadPrivateLogsForSenderRecipientPair,
syncTaggedPrivateLogs,
} from '../tagging/index.js';

export class LogService {
Expand Down Expand Up @@ -116,37 +116,23 @@ export class LogService {
public async fetchTaggedLogs(contractAddress: AztecAddress, recipient: AztecAddress): Promise<PendingTaggedLog[]> {
this.log.verbose(`Fetching tagged logs for ${contractAddress.toString()}`);

// We only load logs from block up to and including the anchor block number
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
const anchorBlockHash = await this.anchorBlockHeader.hash();

const l2Tips = await this.l2TipsStore.getL2Tips();
const currentTimestamp = this.anchorBlockHeader.globalVariables.timestamp;
// Get all secrets for this recipient (one per sender)
const secrets = await this.#getSecretsForSenders(contractAddress, recipient);

// Load logs for all sender-recipient pairs in parallel
const logArrays = await Promise.all(
secrets.map(secret =>
loadPrivateLogsForSenderRecipientPair(
secret,
this.aztecNode,
this.recipientTaggingStore,
anchorBlockNumber,
anchorBlockHash,
currentTimestamp,
l2Tips.finalized.block.number,
this.jobId,
),
),
const logs = await syncTaggedPrivateLogs(
secrets,
this.aztecNode,
this.recipientTaggingStore,
this.anchorBlockHeader,
l2Tips.finalized.block.number,
this.jobId,
);

return logArrays
.flat()
.map(
scopedLog =>
new PendingTaggedLog(scopedLog.logData, scopedLog.txHash, scopedLog.noteHashes, scopedLog.firstNullifier),
);
return logs.map(
scopedLog =>
new PendingTaggedLog(scopedLog.logData, scopedLog.txHash, scopedLog.noteHashes, scopedLog.firstNullifier),
);
}

async #getSecretsForSenders(
Expand Down
4 changes: 4 additions & 0 deletions yarn-project/pxe/src/tagging/get_all_logs_by_tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ async function getAllPagesInBatches<Tag, T>(
tags: Tag[],
fetchAllPagesForBatch: (batch: Tag[]) => Promise<T[][]>,
): Promise<T[][]> {
if (tags.length === 0) {
return [];
}

if (tags.length <= MAX_RPC_LEN) {
return fetchAllPagesForBatch(tags);
}
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/pxe/src/tagging/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
* The objective of the sender sync algorithm is to determine which tags have already been used by a sender, thereby
* deciding which tag should be used next.
*
* The objective of the recipient sync algorithm is to load and process the corresponding logs.
* The objective of the recipient sync algorithm is to fetch and sync the corresponding logs.
*
* @module tagging
*/

export { loadPrivateLogsForSenderRecipientPair } from './recipient_sync/load_private_logs_for_sender_recipient_pair.js';
export { syncTaggedPrivateLogs } from './recipient_sync/sync_tagged_private_logs.js';
export { syncSenderTaggingIndexes } from './sender_sync/sync_sender_tagging_indexes.js';
export { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from './constants.js';
export { getAllPrivateLogsByTags, getAllPublicLogsByTagsFromContract } from './get_all_logs_by_tags.js';
Expand Down

This file was deleted.

Loading
Loading