From e58ea956a66f6e9f740564b15f2e720ac77ba3ba Mon Sep 17 00:00:00 2001 From: benesjan Date: Fri, 28 Mar 2025 21:19:57 +0000 Subject: [PATCH 1/8] fix: incorrect blocknumber in syncTaggedLogs --- .../pxe_oracle_interface.test.ts | 16 ++++++++-------- .../pxe_oracle_interface/pxe_oracle_interface.ts | 12 ++++++------ .../src/private/execution_data_provider.ts | 13 ++++--------- .../src/private/private_execution.test.ts | 2 +- .../src/private/private_execution_oracle.ts | 6 +----- .../src/private/unconstrained_execution.test.ts | 2 +- .../private/unconstrained_execution_oracle.ts | 6 +----- 7 files changed, 22 insertions(+), 35 deletions(-) diff --git a/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts b/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts index 17dfaca00b38..e62ebeaa5339 100644 --- a/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts +++ b/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts @@ -164,7 +164,7 @@ describe('PXEOracleInterface', () => { it('should sync tagged logs', async () => { const tagIndex = 0; await generateMockLogs(tagIndex); - const syncedLogs = await pxeOracleInterface.syncTaggedLogs(contractAddress, 3); + const syncedLogs = await pxeOracleInterface.syncTaggedLogs(contractAddress); // We expect to have all logs intended for the recipient, one per sender + 1 with a duplicated tag for the first // one + half of the logs for the second index expect(syncedLogs.get(recipient.address.toString())).toHaveLength(NUM_SENDERS + 1 + NUM_SENDERS / 2); @@ -260,7 +260,7 @@ describe('PXEOracleInterface', () => { it('should sync tagged logs with a sender index offset', async () => { const tagIndex = 5; await generateMockLogs(tagIndex); - const syncedLogs = await pxeOracleInterface.syncTaggedLogs(contractAddress, 3); + const syncedLogs = await pxeOracleInterface.syncTaggedLogs(contractAddress); // We expect to have all logs intended for the recipient, one per sender + 1 with a duplicated tag for the first one + half of the logs for the second index expect(syncedLogs.get(recipient.address.toString())).toHaveLength(NUM_SENDERS + 1 + NUM_SENDERS / 2); @@ -303,7 +303,7 @@ describe('PXEOracleInterface', () => { recipient.address, ); - const syncedLogs = await pxeOracleInterface.syncTaggedLogs(contractAddress, 3); + const syncedLogs = await pxeOracleInterface.syncTaggedLogs(contractAddress); // Even if our index as recipient is higher than what the sender sent, we should be able to find the logs // since the window starts at Math.max(0, 2 - window_size) = 0 @@ -342,7 +342,7 @@ describe('PXEOracleInterface', () => { recipient.address, ); - const syncedLogs = await pxeOracleInterface.syncTaggedLogs(contractAddress, 3); + const syncedLogs = await pxeOracleInterface.syncTaggedLogs(contractAddress); // Only half of the logs should be synced since we start from index 1 = (11 - window_size), the other half should be skipped expect(syncedLogs.get(recipient.address.toString())).toHaveLength(NUM_SENDERS / 2); @@ -374,7 +374,7 @@ describe('PXEOracleInterface', () => { recipient.address, ); - let syncedLogs = await pxeOracleInterface.syncTaggedLogs(contractAddress, 3); + let syncedLogs = await pxeOracleInterface.syncTaggedLogs(contractAddress); // No logs should be synced since we start from index 2 = 12 - window_size expect(syncedLogs.get(recipient.address.toString())).toHaveLength(0); @@ -387,7 +387,7 @@ describe('PXEOracleInterface', () => { // Wipe the database await taggingDataProvider.resetNoteSyncData(); - syncedLogs = await pxeOracleInterface.syncTaggedLogs(contractAddress, 3); + syncedLogs = await pxeOracleInterface.syncTaggedLogs(contractAddress); // First sender should have 2 logs, but keep index 1 since they were built using the same tag // Next 4 senders should also have index 1 = offset + 1 @@ -405,7 +405,7 @@ describe('PXEOracleInterface', () => { it('should not sync tagged logs with a blockNumber > maxBlockNumber', async () => { const tagIndex = 0; await generateMockLogs(tagIndex); - const syncedLogs = await pxeOracleInterface.syncTaggedLogs(contractAddress, 1); + const syncedLogs = await pxeOracleInterface.syncTaggedLogs(contractAddress); // Only NUM_SENDERS + 1 logs should be synched, since the rest have blockNumber > 1 expect(syncedLogs.get(recipient.address.toString())).toHaveLength(NUM_SENDERS + 1); @@ -427,7 +427,7 @@ describe('PXEOracleInterface', () => { aztecNode.getLogsByTags.mockImplementation(tags => { return Promise.resolve(tags.map(tag => logs[tag.toString()] ?? [])); }); - const syncedLogs = await pxeOracleInterface.syncTaggedLogs(contractAddress, 1); + const syncedLogs = await pxeOracleInterface.syncTaggedLogs(contractAddress); // We expect the above log to be discarded, and so none to be synced expect(syncedLogs.get(recipient.address.toString())).toHaveLength(0); diff --git a/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.ts b/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.ts index 07d3d59c64a0..028146ac336f 100644 --- a/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.ts +++ b/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.ts @@ -432,20 +432,20 @@ export class PXEOracleInterface implements ExecutionDataProvider { } /** - * Synchronizes the logs tagged with scoped addresses and all the senders in the address book. - * Returns the unsynched logs and updates the indexes of the secrets used to tag them until there are no more logs - * to sync. + * Synchronizes the logs tagged with scoped addresses and all the senders in the address book. Returns the found logs + * and updates the indexes of the secrets used to tag them until there are no more logs to sync. * @param contractAddress - The address of the contract that the logs are tagged for - * @param recipient - The address of the recipient - * @returns A list of encrypted logs tagged with the recipient's address + * @param scopes - The scoped addresses to sync logs for. If not provided, all accounts in the address book will be synced. + * @returns A map of recipient addresses to a list of encrypted logs. */ public async syncTaggedLogs( contractAddress: AztecAddress, - maxBlockNumber: number, scopes?: AztecAddress[], ): Promise> { this.log.verbose('Searching for tagged logs', { contract: contractAddress }); + const maxBlockNumber = await this.syncDataProvider.getBlockNumber(); + // Ideally this algorithm would be implemented in noir, exposing its building blocks as oracles. // However it is impossible at the moment due to the language not supporting nested slices. // This nesting is necessary because for a given set of tags we don't diff --git a/yarn-project/simulator/src/private/execution_data_provider.ts b/yarn-project/simulator/src/private/execution_data_provider.ts index 0954fd8b74a2..239fe9a3fdce 100644 --- a/yarn-project/simulator/src/private/execution_data_provider.ts +++ b/yarn-project/simulator/src/private/execution_data_provider.ts @@ -226,17 +226,12 @@ export interface ExecutionDataProvider extends CommitmentsDBInterface { ): Promise; /** - * Synchronizes the logs tagged with the recipient's address and all the senders in the address book. - * Returns the unsynched logs and updates the indexes of the secrets used to tag them until there are no more logs to sync. + * Synchronizes the logs tagged with scoped addresses and all the senders in the address book. Returns the found logs + * and updates the indexes of the secrets used to tag them until there are no more logs to sync. * @param contractAddress - The address of the contract that the logs are tagged for - * @param recipient - The address of the recipient - * @returns A list of encrypted logs tagged with the recipient's address + * @returns A map of recipient addresses to a list of encrypted logs. */ - syncTaggedLogs( - contractAddress: AztecAddress, - maxBlockNumber: number, - scopes?: AztecAddress[], - ): Promise>; + syncTaggedLogs(contractAddress: AztecAddress, scopes?: AztecAddress[]): Promise>; /** * Processes the tagged logs returned by syncTaggedLogs by decrypting them and storing them in the database. diff --git a/yarn-project/simulator/src/private/private_execution.test.ts b/yarn-project/simulator/src/private/private_execution.test.ts index 509f259875ce..d4269be1e76b 100644 --- a/yarn-project/simulator/src/private/private_execution.test.ts +++ b/yarn-project/simulator/src/private/private_execution.test.ts @@ -298,7 +298,7 @@ describe('Private Execution test suite', () => { return Promise.resolve(artifact); }); - executionDataProvider.syncTaggedLogs.mockImplementation((_, __, ___) => + executionDataProvider.syncTaggedLogs.mockImplementation((_, __) => Promise.resolve(new Map()), ); executionDataProvider.loadCapsule.mockImplementation((_, __) => Promise.resolve(null)); diff --git a/yarn-project/simulator/src/private/private_execution_oracle.ts b/yarn-project/simulator/src/private/private_execution_oracle.ts index 6f2d7d3f32de..e467e3de0203 100644 --- a/yarn-project/simulator/src/private/private_execution_oracle.ts +++ b/yarn-project/simulator/src/private/private_execution_oracle.ts @@ -501,11 +501,7 @@ export class PrivateExecutionOracle extends UnconstrainedExecutionOracle { } public override async syncNotes() { - const taggedLogsByRecipient = await this.executionDataProvider.syncTaggedLogs( - this.contractAddress, - this.historicalHeader.globalVariables.blockNumber.toNumber(), - this.scopes, - ); + const taggedLogsByRecipient = await this.executionDataProvider.syncTaggedLogs(this.contractAddress, this.scopes); for (const [recipient, taggedLogs] of taggedLogsByRecipient.entries()) { await this.executionDataProvider.processTaggedLogs( this.contractAddress, diff --git a/yarn-project/simulator/src/private/unconstrained_execution.test.ts b/yarn-project/simulator/src/private/unconstrained_execution.test.ts index 7ca325a5ddcf..d93bbe84a69e 100644 --- a/yarn-project/simulator/src/private/unconstrained_execution.test.ts +++ b/yarn-project/simulator/src/private/unconstrained_execution.test.ts @@ -82,7 +82,7 @@ describe('Unconstrained Execution test suite', () => { })), ); - executionDataProvider.syncTaggedLogs.mockImplementation((_, __, ___) => + executionDataProvider.syncTaggedLogs.mockImplementation((_, __) => Promise.resolve(new Map()), ); executionDataProvider.loadCapsule.mockImplementation((_, __) => Promise.resolve(null)); diff --git a/yarn-project/simulator/src/private/unconstrained_execution_oracle.ts b/yarn-project/simulator/src/private/unconstrained_execution_oracle.ts index d14d648b2d18..ea16c4b7ff5f 100644 --- a/yarn-project/simulator/src/private/unconstrained_execution_oracle.ts +++ b/yarn-project/simulator/src/private/unconstrained_execution_oracle.ts @@ -279,11 +279,7 @@ export class UnconstrainedExecutionOracle extends TypedOracle { } public override async syncNotes() { - const taggedLogsByRecipient = await this.executionDataProvider.syncTaggedLogs( - this.contractAddress, - await this.executionDataProvider.getBlockNumber(), - this.scopes, - ); + const taggedLogsByRecipient = await this.executionDataProvider.syncTaggedLogs(this.contractAddress, this.scopes); for (const [recipient, taggedLogs] of taggedLogsByRecipient.entries()) { await this.executionDataProvider.processTaggedLogs( From 83cc65097c06dbcd8bbf83795fde2525bddc0e0e Mon Sep 17 00:00:00 2001 From: benesjan Date: Fri, 28 Mar 2025 21:24:40 +0000 Subject: [PATCH 2/8] fix --- yarn-project/txe/src/oracle/txe_oracle.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/yarn-project/txe/src/oracle/txe_oracle.ts b/yarn-project/txe/src/oracle/txe_oracle.ts index 233224f9b39f..b7157c0cf991 100644 --- a/yarn-project/txe/src/oracle/txe_oracle.ts +++ b/yarn-project/txe/src/oracle/txe_oracle.ts @@ -1083,11 +1083,7 @@ export class TXE implements TypedOracle { } async syncNotes() { - const taggedLogsByRecipient = await this.pxeOracleInterface.syncTaggedLogs( - this.contractAddress, - await this.getBlockNumber(), - undefined, - ); + const taggedLogsByRecipient = await this.pxeOracleInterface.syncTaggedLogs(this.contractAddress, undefined); for (const [recipient, taggedLogs] of taggedLogsByRecipient.entries()) { await this.pxeOracleInterface.processTaggedLogs( From 223d640d8cf4cefb8ec2b9afd7c17156872ce887 Mon Sep 17 00:00:00 2001 From: benesjan Date: Fri, 28 Mar 2025 22:46:10 +0000 Subject: [PATCH 3/8] WIP --- .../pxe_oracle_interface.test.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts b/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts index e62ebeaa5339..2792e59b7639 100644 --- a/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts +++ b/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts @@ -13,7 +13,7 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client'; import { computeAddress, computeAppTaggingSecret, deriveKeys } from '@aztec/stdlib/keys'; import { IndexedTaggingSecret, PrivateLog, PublicLog, TxScopedL2Log } from '@aztec/stdlib/logs'; import { randomContractArtifact, randomContractInstanceWithAddress } from '@aztec/stdlib/testing'; -import { TxEffect, TxHash } from '@aztec/stdlib/tx'; +import { BlockHeader, GlobalVariables, TxEffect, TxHash } from '@aztec/stdlib/tx'; import { jest } from '@jest/globals'; import { type MockProxy, mock } from 'jest-mock-extended'; @@ -73,6 +73,11 @@ describe('PXEOracleInterface', () => { capsuleDataProvider = new CapsuleDataProvider(store); keyStore = new KeyStore(store); simulationProvider = new WASMSimulator(); + + // PXEOracleInterface.syncTagLogFunction(...) syncs log up to the block number up to which PXE synced. We set + // as sufficiently high sync number here to not interfere with the tests. + setSyncedBlockNumber(100); + pxeOracleInterface = new PXEOracleInterface( aztecNode, keyStore, @@ -403,8 +408,12 @@ describe('PXEOracleInterface', () => { }); it('should not sync tagged logs with a blockNumber > maxBlockNumber', async () => { + const maxBlockNumber = 1; const tagIndex = 0; await generateMockLogs(tagIndex); + + setSyncedBlockNumber(maxBlockNumber); + const syncedLogs = await pxeOracleInterface.syncTaggedLogs(contractAddress); // Only NUM_SENDERS + 1 logs should be synched, since the rest have blockNumber > 1 @@ -499,4 +508,12 @@ describe('PXEOracleInterface', () => { ); }, 30_000); }); + + const setSyncedBlockNumber = (blockNumber: number) => { + syncDataProvider.setHeader( + BlockHeader.empty({ + globalVariables: GlobalVariables.empty({ blockNumber: new Fr(blockNumber) }), + }), + ); + }; }); From 1c6904aeac250286e5fbb0598ab2b48acf010e6e Mon Sep 17 00:00:00 2001 From: benesjan Date: Fri, 28 Mar 2025 22:53:29 +0000 Subject: [PATCH 4/8] updated docs --- .../pxe/src/pxe_oracle_interface/pxe_oracle_interface.ts | 3 ++- yarn-project/simulator/src/private/execution_data_provider.ts | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.ts b/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.ts index 028146ac336f..f626220c625d 100644 --- a/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.ts +++ b/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.ts @@ -435,7 +435,8 @@ export class PXEOracleInterface implements ExecutionDataProvider { * Synchronizes the logs tagged with scoped addresses and all the senders in the address book. Returns the found logs * and updates the indexes of the secrets used to tag them until there are no more logs to sync. * @param contractAddress - The address of the contract that the logs are tagged for - * @param scopes - The scoped addresses to sync logs for. If not provided, all accounts in the address book will be synced. + * @param scopes - The scoped addresses to sync logs for. If not provided, all accounts in the address book will be + * synced. * @returns A map of recipient addresses to a list of encrypted logs. */ public async syncTaggedLogs( diff --git a/yarn-project/simulator/src/private/execution_data_provider.ts b/yarn-project/simulator/src/private/execution_data_provider.ts index 239fe9a3fdce..1043ee9f637f 100644 --- a/yarn-project/simulator/src/private/execution_data_provider.ts +++ b/yarn-project/simulator/src/private/execution_data_provider.ts @@ -229,6 +229,8 @@ export interface ExecutionDataProvider extends CommitmentsDBInterface { * Synchronizes the logs tagged with scoped addresses and all the senders in the address book. Returns the found logs * and updates the indexes of the secrets used to tag them until there are no more logs to sync. * @param contractAddress - The address of the contract that the logs are tagged for + * @param scopes - The scoped addresses to sync logs for. If not provided, all accounts in the address book will be + * synced. * @returns A map of recipient addresses to a list of encrypted logs. */ syncTaggedLogs(contractAddress: AztecAddress, scopes?: AztecAddress[]): Promise>; From b6ece746e7d8c0be6ae8f9042cd65bc155844595 Mon Sep 17 00:00:00 2001 From: benesjan Date: Fri, 28 Mar 2025 23:11:35 +0000 Subject: [PATCH 5/8] fix --- .../pxe_oracle_interface/pxe_oracle_interface.test.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts b/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts index 2792e59b7639..3beed90461e5 100644 --- a/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts +++ b/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts @@ -76,7 +76,7 @@ describe('PXEOracleInterface', () => { // PXEOracleInterface.syncTagLogFunction(...) syncs log up to the block number up to which PXE synced. We set // as sufficiently high sync number here to not interfere with the tests. - setSyncedBlockNumber(100); + await setSyncedBlockNumber(100); pxeOracleInterface = new PXEOracleInterface( aztecNode, @@ -409,11 +409,10 @@ describe('PXEOracleInterface', () => { it('should not sync tagged logs with a blockNumber > maxBlockNumber', async () => { const maxBlockNumber = 1; + await setSyncedBlockNumber(maxBlockNumber); + const tagIndex = 0; await generateMockLogs(tagIndex); - - setSyncedBlockNumber(maxBlockNumber); - const syncedLogs = await pxeOracleInterface.syncTaggedLogs(contractAddress); // Only NUM_SENDERS + 1 logs should be synched, since the rest have blockNumber > 1 @@ -510,7 +509,7 @@ describe('PXEOracleInterface', () => { }); const setSyncedBlockNumber = (blockNumber: number) => { - syncDataProvider.setHeader( + return syncDataProvider.setHeader( BlockHeader.empty({ globalVariables: GlobalVariables.empty({ blockNumber: new Fr(blockNumber) }), }), From 57e59bd6981e0d6d44d8932a3db711100ce56429 Mon Sep 17 00:00:00 2001 From: benesjan Date: Fri, 28 Mar 2025 23:26:32 +0000 Subject: [PATCH 6/8] typo fix --- .../pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts b/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts index 3beed90461e5..4712e5c4bc44 100644 --- a/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts +++ b/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts @@ -74,7 +74,7 @@ describe('PXEOracleInterface', () => { keyStore = new KeyStore(store); simulationProvider = new WASMSimulator(); - // PXEOracleInterface.syncTagLogFunction(...) syncs log up to the block number up to which PXE synced. We set + // PXEOracleInterface.syncTaggedLogs(...) function syncs logs up to the block number up to which PXE synced. We set // as sufficiently high sync number here to not interfere with the tests. await setSyncedBlockNumber(100); From f1223748b05bb03b97c180b2bc879f2cabde44db Mon Sep 17 00:00:00 2001 From: benesjan Date: Mon, 31 Mar 2025 20:19:26 +0000 Subject: [PATCH 7/8] defining constants in test --- .../pxe_oracle_interface.test.ts | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts b/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts index 4712e5c4bc44..fcb4bc9c7258 100644 --- a/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts +++ b/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts @@ -59,6 +59,11 @@ describe('PXEOracleInterface', () => { let pxeOracleInterface: PXEOracleInterface; + // The block number of the first log to be emitted. + const MIN_BLOCK_NUMBER_OF_A_LOG = 1; + // The block number of the last log to be emitted. + const MAX_BLOCK_NUMBER_OF_A_LOG = 3; + beforeEach(async () => { const store = await openTmpStore('test'); aztecNode = mock(); @@ -75,8 +80,8 @@ describe('PXEOracleInterface', () => { simulationProvider = new WASMSimulator(); // PXEOracleInterface.syncTaggedLogs(...) function syncs logs up to the block number up to which PXE synced. We set - // as sufficiently high sync number here to not interfere with the tests. - await setSyncedBlockNumber(100); + // the synced block number to that of the last emitted log to receive all the logs by default. + await setSyncedBlockNumber(MAX_BLOCK_NUMBER_OF_A_LOG); pxeOracleInterface = new PXEOracleInterface( aztecNode, @@ -107,8 +112,7 @@ describe('PXEOracleInterface', () => { // Compute the tag as sender (knowledge of preaddress and ivsk) for (const sender of senders) { const tag = await computeSiloedTagForIndex(sender, recipient.address, contractAddress, tagIndex); - const blockNumber = 1; - const log = new TxScopedL2Log(TxHash.random(), 0, 0, blockNumber, PrivateLog.random(tag)); + const log = new TxScopedL2Log(TxHash.random(), 0, 0, MIN_BLOCK_NUMBER_OF_A_LOG, PrivateLog.random(tag)); logs[tag.toString()] = [log]; } // Accumulated logs intended for recipient: NUM_SENDERS @@ -139,8 +143,7 @@ describe('PXEOracleInterface', () => { const partialAddress = Fr.random(); const randomRecipient = await computeAddress(keys.publicKeys, partialAddress); const tag = await computeSiloedTagForIndex(sender, randomRecipient, contractAddress, tagIndex); - const blockNumber = 3; - const log = new TxScopedL2Log(TxHash.random(), 0, 0, blockNumber, PrivateLog.random(tag)); + const log = new TxScopedL2Log(TxHash.random(), 0, 0, MAX_BLOCK_NUMBER_OF_A_LOG, PrivateLog.random(tag)); logs[tag.toString()] = [log]; } // Accumulated logs intended for recipient: NUM_SENDERS + 1 + NUM_SENDERS / 2 @@ -407,15 +410,16 @@ describe('PXEOracleInterface', () => { expect(aztecNode.getLogsByTags.mock.calls.length).toBe(2); }); - it('should not sync tagged logs with a blockNumber > maxBlockNumber', async () => { - const maxBlockNumber = 1; - await setSyncedBlockNumber(maxBlockNumber); + it('should not sync tagged logs with a blockNumber larger than the block number to which PXE is synced', async () => { + // We set the block number to which PXE is synced to a block number in which only the first batch of logs was + // emitted and then we check that we receive logs only from this batch. + await setSyncedBlockNumber(MIN_BLOCK_NUMBER_OF_A_LOG); const tagIndex = 0; await generateMockLogs(tagIndex); const syncedLogs = await pxeOracleInterface.syncTaggedLogs(contractAddress); - // Only NUM_SENDERS + 1 logs should be synched, since the rest have blockNumber > 1 + // Only NUM_SENDERS + 1 logs should be synched, since the rest have blockNumber > MIN_BLOCK_NUMBER_OF_A_LOG expect(syncedLogs.get(recipient.address.toString())).toHaveLength(NUM_SENDERS + 1); }); From 9fca6edf755fedf1290c8d4d5a482cbd25c15330 Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 1 Apr 2025 02:11:55 +0000 Subject: [PATCH 8/8] salad --- .../pxe_oracle_interface/pxe_oracle_interface.test.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts b/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts index fcb4bc9c7258..cb7d69dce9a8 100644 --- a/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts +++ b/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.test.ts @@ -78,11 +78,6 @@ describe('PXEOracleInterface', () => { capsuleDataProvider = new CapsuleDataProvider(store); keyStore = new KeyStore(store); simulationProvider = new WASMSimulator(); - - // PXEOracleInterface.syncTaggedLogs(...) function syncs logs up to the block number up to which PXE synced. We set - // the synced block number to that of the last emitted log to receive all the logs by default. - await setSyncedBlockNumber(MAX_BLOCK_NUMBER_OF_A_LOG); - pxeOracleInterface = new PXEOracleInterface( aztecNode, keyStore, @@ -99,6 +94,10 @@ describe('PXEOracleInterface', () => { // Set up recipient account recipient = await keyStore.addAccount(new Fr(69), Fr.random()); await addressDataProvider.addCompleteAddress(recipient); + + // PXEOracleInterface.syncTaggedLogs(...) function syncs logs up to the block number up to which PXE synced. We set + // the synced block number to that of the last emitted log to receive all the logs by default. + await setSyncedBlockNumber(MAX_BLOCK_NUMBER_OF_A_LOG); }); describe('sync tagged logs', () => {