From 56c5e27ba22046528b0175b0c91c65a4a779c36d Mon Sep 17 00:00:00 2001 From: benesjan Date: Thu, 4 Apr 2024 09:41:52 +0000 Subject: [PATCH 1/4] refactor: nuking L2BlockContext --- .../src/archiver/archiver_store_test_suite.ts | 4 +- .../memory_archiver_store.ts | 30 +++++++-------- yarn-project/circuit-types/src/index.ts | 1 - .../circuit-types/src/l2_block_context.ts | 37 ------------------- yarn-project/p2p/src/client/p2p_client.ts | 14 ++----- .../src/note_processor/note_processor.test.ts | 34 ++++++++--------- .../pxe/src/note_processor/note_processor.ts | 32 +++++++--------- .../pxe/src/synchronizer/synchronizer.ts | 29 ++++++++------- 8 files changed, 63 insertions(+), 118 deletions(-) delete mode 100644 yarn-project/circuit-types/src/l2_block_context.ts diff --git a/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts b/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts index 54d1efe177f..4d0feafa58e 100644 --- a/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts +++ b/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts @@ -1,4 +1,4 @@ -import { InboxLeaf, L2Block, L2BlockContext, LogId, LogType, TxHash } from '@aztec/circuit-types'; +import { InboxLeaf, L2Block, LogId, LogType, TxHash } from '@aztec/circuit-types'; import '@aztec/circuit-types/jest'; import { AztecAddress, Fr, INITIAL_L2_BLOCK_NUM, L1_TO_L2_MSG_SUBTREE_HEIGHT } from '@aztec/circuits.js'; import { @@ -328,7 +328,7 @@ export function describeArchiverDataStore(testName: string, getStore: () => Arch // get random tx const targetBlockIndex = randomInt(numBlocks); const targetTxIndex = randomInt(txsPerBlock); - const targetTxHash = new L2BlockContext(blocks.retrievedData[targetBlockIndex]).getTxHash(targetTxIndex); + const targetTxHash = blocks.retrievedData[targetBlockIndex].body.txEffects[targetTxIndex].txHash; const response = await store.getUnencryptedLogs({ txHash: targetTxHash }); const logs = response.logs; diff --git a/yarn-project/archiver/src/archiver/memory_archiver_store/memory_archiver_store.ts b/yarn-project/archiver/src/archiver/memory_archiver_store/memory_archiver_store.ts index 2273ded7ab5..ccc3698fe7f 100644 --- a/yarn-project/archiver/src/archiver/memory_archiver_store/memory_archiver_store.ts +++ b/yarn-project/archiver/src/archiver/memory_archiver_store/memory_archiver_store.ts @@ -6,7 +6,6 @@ import { type GetUnencryptedLogsResponse, type InboxLeaf, type L2Block, - L2BlockContext, type L2BlockL2Logs, type LogFilter, LogId, @@ -37,7 +36,7 @@ export class MemoryArchiverStore implements ArchiverDataStore { /** * An array containing all the L2 blocks that have been fetched so far. */ - private l2BlockContexts: L2BlockContext[] = []; + private l2Blocks: L2Block[] = []; /** * A mapping of body hash to body @@ -144,7 +143,7 @@ export class MemoryArchiverStore implements ArchiverDataStore { */ public addBlocks(blocks: DataRetrieval): Promise { this.lastL1BlockNewBlocks = blocks.lastProcessedL1BlockNumber; - this.l2BlockContexts.push(...blocks.retrievedData.map(block => new L2BlockContext(block))); + this.l2Blocks.push(...blocks.retrievedData); this.txEffects.push(...blocks.retrievedData.flatMap(b => b.body.txEffects)); return Promise.resolve(true); } @@ -242,12 +241,12 @@ export class MemoryArchiverStore implements ArchiverDataStore { } const fromIndex = Math.max(from - INITIAL_L2_BLOCK_NUM, 0); - if (fromIndex >= this.l2BlockContexts.length) { + if (fromIndex >= this.l2Blocks.length) { return Promise.resolve([]); } const toIndex = fromIndex + limit; - return Promise.resolve(this.l2BlockContexts.slice(fromIndex, toIndex).map(blockContext => blockContext.block)); + return Promise.resolve(this.l2Blocks.slice(fromIndex, toIndex)); } /** @@ -266,12 +265,11 @@ export class MemoryArchiverStore implements ArchiverDataStore { * @returns The requested tx receipt (or undefined if not found). */ public getSettledTxReceipt(txHash: TxHash): Promise { - for (const blockContext of this.l2BlockContexts) { - for (const currentTxHash of blockContext.getTxHashes()) { + for (const block of this.l2Blocks) { + const txHashes = block.body.txEffects.map(txEffect => txEffect.txHash); + for (const currentTxHash of txHashes) { if (currentTxHash.equals(txHash)) { - return Promise.resolve( - new TxReceipt(txHash, TxStatus.MINED, '', blockContext.block.hash().toBuffer(), blockContext.block.number), - ); + return Promise.resolve(new TxReceipt(txHash, TxStatus.MINED, '', block.hash().toBuffer(), block.number)); } } } @@ -364,20 +362,18 @@ export class MemoryArchiverStore implements ArchiverDataStore { const logs: ExtendedUnencryptedL2Log[] = []; for (; fromBlockIndex < toBlockIndex; fromBlockIndex++) { - const blockContext = this.l2BlockContexts[fromBlockIndex]; + const block = this.l2Blocks[fromBlockIndex]; const blockLogs = this.unencryptedLogsPerBlock[fromBlockIndex]; for (; txIndexInBlock < blockLogs.txLogs.length; txIndexInBlock++) { const txLogs = blockLogs.txLogs[txIndexInBlock].unrollLogs(); for (; logIndexInTx < txLogs.length; logIndexInTx++) { const log = txLogs[logIndexInTx]; if ( - (!txHash || blockContext.getTxHash(txIndexInBlock).equals(txHash)) && + (!txHash || block.body.txEffects[txIndexInBlock].txHash.equals(txHash)) && (!contractAddress || log.contractAddress.equals(contractAddress)) && (!selector || log.selector.equals(selector)) ) { - logs.push( - new ExtendedUnencryptedL2Log(new LogId(blockContext.block.number, txIndexInBlock, logIndexInTx), log), - ); + logs.push(new ExtendedUnencryptedL2Log(new LogId(block.number, txIndexInBlock, logIndexInTx), log)); if (logs.length === this.maxLogs) { return Promise.resolve({ logs, @@ -402,10 +398,10 @@ export class MemoryArchiverStore implements ArchiverDataStore { * @returns The number of the latest L2 block processed. */ public getSynchedL2BlockNumber(): Promise { - if (this.l2BlockContexts.length === 0) { + if (this.l2Blocks.length === 0) { return Promise.resolve(INITIAL_L2_BLOCK_NUM - 1); } - return Promise.resolve(this.l2BlockContexts[this.l2BlockContexts.length - 1].block.number); + return Promise.resolve(this.l2Blocks[this.l2Blocks.length - 1].number); } public getSynchPoint(): Promise { diff --git a/yarn-project/circuit-types/src/index.ts b/yarn-project/circuit-types/src/index.ts index 31213c9cb9b..43ecbefb9e6 100644 --- a/yarn-project/circuit-types/src/index.ts +++ b/yarn-project/circuit-types/src/index.ts @@ -4,7 +4,6 @@ export * from './notes/index.js'; export * from './messaging/index.js'; export * from './l2_block.js'; export * from './body.js'; -export * from './l2_block_context.js'; export * from './l2_block_downloader/index.js'; export * from './l2_block_source.js'; export * from './tx_effect.js'; diff --git a/yarn-project/circuit-types/src/l2_block_context.ts b/yarn-project/circuit-types/src/l2_block_context.ts deleted file mode 100644 index c5d16b03171..00000000000 --- a/yarn-project/circuit-types/src/l2_block_context.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { type L2Block } from './l2_block.js'; -import { type TxHash } from './tx/tx_hash.js'; - -/** - * A wrapper around L2 block used to cache results of expensive operations. - */ -export class L2BlockContext { - private txHashes: TxHash[] | undefined; - - constructor( - /** - * The underlying L2 block. - */ - public readonly block: L2Block, - ) {} - - /** - * Returns the tx hash of the tx in the block at the given index. - * @param txIndex - The index of the tx in the block. - * @returns The tx's hash. - */ - public getTxHash(txIndex: number): TxHash { - return this.txHashes ? this.txHashes[txIndex] : this.block.body.txEffects[txIndex].txHash; - } - - /** - * Returns the tx hashes of all txs in the block. - * @returns The tx hashes. - */ - public getTxHashes(): TxHash[] { - // First ensure that all tx hashes are calculated - if (!this.txHashes) { - this.txHashes = this.block.body.txEffects.map(tx => tx.txHash); - } - return this.txHashes; - } -} diff --git a/yarn-project/p2p/src/client/p2p_client.ts b/yarn-project/p2p/src/client/p2p_client.ts index 920efc8ea37..f00df9f9de0 100644 --- a/yarn-project/p2p/src/client/p2p_client.ts +++ b/yarn-project/p2p/src/client/p2p_client.ts @@ -1,11 +1,4 @@ -import { - type L2Block, - L2BlockContext, - L2BlockDownloader, - type L2BlockSource, - type Tx, - type TxHash, -} from '@aztec/circuit-types'; +import { type L2Block, L2BlockDownloader, type L2BlockSource, type Tx, type TxHash } from '@aztec/circuit-types'; import { INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js/constants'; import { createDebugLogger } from '@aztec/foundation/log'; import { type AztecKVStore, type AztecSingleton } from '@aztec/kv-store'; @@ -280,9 +273,8 @@ export class P2PClient implements P2P { * @returns Empty promise. */ private async reconcileTxPool(blocks: L2Block[]): Promise { - for (let i = 0; i < blocks.length; i++) { - const blockContext = new L2BlockContext(blocks[i]); - const txHashes = blockContext.getTxHashes(); + for (const block of blocks) { + const txHashes = block.body.txEffects.map(txEffect => txEffect.txHash); await this.txPool.deleteTxs(txHashes); this.p2pService.settledTxs(txHashes); } diff --git a/yarn-project/pxe/src/note_processor/note_processor.test.ts b/yarn-project/pxe/src/note_processor/note_processor.test.ts index 893e8807bac..ab6345be4b4 100644 --- a/yarn-project/pxe/src/note_processor/note_processor.test.ts +++ b/yarn-project/pxe/src/note_processor/note_processor.test.ts @@ -8,7 +8,6 @@ import { type KeyStore, type L1NotePayload, L2Block, - L2BlockContext, TaggedNote, } from '@aztec/circuit-types'; import { Fr, INITIAL_L2_BLOCK_NUM, MAX_NEW_NOTE_HASHES_PER_TX } from '@aztec/circuits.js'; @@ -87,7 +86,7 @@ describe('Note Processor', () => { throw new Error(`Tx size should be less than ${TXS_PER_BLOCK}.`); } - const blockContexts: L2BlockContext[] = []; + const blocks: L2Block[] = []; const encryptedLogsArr: EncryptedL2BlockL2Logs[] = []; const ownedL1NotePayloads: L1NotePayload[] = []; const numberOfBlocks = prependedBlocks + appendedBlocks + 1; @@ -109,10 +108,9 @@ describe('Note Processor', () => { block.body.txEffects[i].noteHashes = txEffectNotes.map(n => pedersenHash(n.notePayload.note.items)); } - const randomBlockContext = new L2BlockContext(block); - blockContexts.push(randomBlockContext); + blocks.push(block); } - return { blockContexts, encryptedLogsArr, ownedL1NotePayloads }; + return { blocks, encryptedLogsArr, ownedL1NotePayloads }; }; beforeAll(() => { @@ -152,8 +150,8 @@ describe('Note Processor', () => { }); it('should store a note that belongs to us', async () => { - const { blockContexts, encryptedLogsArr, ownedL1NotePayloads } = mockData([[2]]); - await noteProcessor.process(blockContexts, encryptedLogsArr); + const { blocks, encryptedLogsArr, ownedL1NotePayloads } = mockData([[2]]); + await noteProcessor.process(blocks, encryptedLogsArr); expect(addNotesSpy).toHaveBeenCalledTimes(1); expect(addNotesSpy).toHaveBeenCalledWith([ @@ -169,12 +167,12 @@ describe('Note Processor', () => { const appendedBlocks = 1; const thisBlockDataStartIndex = firstBlockDataStartIndex + prependedBlocks * numCommitmentsPerBlock; - const { blockContexts, encryptedLogsArr, ownedL1NotePayloads } = mockData( + const { blocks, encryptedLogsArr, ownedL1NotePayloads } = mockData( [[], [1], [], [0, 2]], prependedBlocks, appendedBlocks, ); - await noteProcessor.process(blockContexts, encryptedLogsArr); + await noteProcessor.process(blocks, encryptedLogsArr); expect(addNotesSpy).toHaveBeenCalledTimes(1); expect(addNotesSpy).toHaveBeenCalledWith([ @@ -197,8 +195,8 @@ describe('Note Processor', () => { }, 30_000); it('should not store notes that do not belong to us', async () => { - const { blockContexts, encryptedLogsArr } = mockData([]); - await noteProcessor.process(blockContexts, encryptedLogsArr); + const { blocks, encryptedLogsArr } = mockData([]); + await noteProcessor.process(blocks, encryptedLogsArr); }); it('should be able to recover two note payloads with containing the same note', async () => { @@ -206,8 +204,8 @@ describe('Note Processor', () => { const note2 = TaggedNote.random(); // L1NotePayload.random(); // All note payloads except one have the same contract address, storage slot, and the actual note. const notes = [note, note, note, note2, note]; - const { blockContexts, encryptedLogsArr, ownedL1NotePayloads } = mockData([[0, 2], [], [0, 1, 3]], 0, 0, notes); - await noteProcessor.process(blockContexts, encryptedLogsArr); + const { blocks, encryptedLogsArr, ownedL1NotePayloads } = mockData([[0, 2], [], [0, 1, 3]], 0, 0, notes); + await noteProcessor.process(blocks, encryptedLogsArr); const addedNoteDaos: NoteDao[] = addNotesSpy.mock.calls[0][0]; expect(addedNoteDaos.map(dao => dao)).toEqual([ @@ -229,14 +227,14 @@ describe('Note Processor', () => { }); it('advances the block number', async () => { - const { blockContexts, encryptedLogsArr } = mockData([[2]]); - await noteProcessor.process(blockContexts, encryptedLogsArr); - expect(noteProcessor.status.syncedToBlock).toEqual(blockContexts.at(-1)?.block.number); + const { blocks, encryptedLogsArr } = mockData([[2]]); + await noteProcessor.process(blocks, encryptedLogsArr); + expect(noteProcessor.status.syncedToBlock).toEqual(blocks.at(-1)?.number); }); it('should restore the last block number processed and ignore the starting block', async () => { - const { blockContexts, encryptedLogsArr } = mockData([[2]]); - await noteProcessor.process(blockContexts, encryptedLogsArr); + const { blocks, encryptedLogsArr } = mockData([[2]]); + await noteProcessor.process(blocks, encryptedLogsArr); const newNoteProcessor = new NoteProcessor( owner.getPublicKey(), diff --git a/yarn-project/pxe/src/note_processor/note_processor.ts b/yarn-project/pxe/src/note_processor/note_processor.ts index d81e7b45cea..42f6c076d21 100644 --- a/yarn-project/pxe/src/note_processor/note_processor.ts +++ b/yarn-project/pxe/src/note_processor/note_processor.ts @@ -3,7 +3,7 @@ import { type EncryptedL2BlockL2Logs, type KeyStore, L1NotePayload, - type L2BlockContext, + type L2Block, TaggedNote, } from '@aztec/circuit-types'; import { type NoteProcessorStats } from '@aztec/circuit-types/stats'; @@ -25,9 +25,9 @@ import { produceNoteDao } from './produce_note_dao.js'; */ interface ProcessedData { /** - * Holds L2 block and a cache of already requested tx hashes. + * Holds L2 block. */ - blockContext: L2BlockContext; + block: L2Block; /** * DAOs of processed notes. */ @@ -87,20 +87,17 @@ export class NoteProcessor { * the transactions and auxiliary data associated with them. * Throws an error if the number of block contexts and encrypted logs do not match. * - * @param l2BlockContexts - An array of L2 block contexts to be processed. + * @param l2Blocks - An array of L2 block contexts to be processed. * @param encryptedL2BlockLogs - An array of encrypted logs associated with the L2 block contexts. * @returns A promise that resolves once the processing is completed. */ - public async process( - l2BlockContexts: L2BlockContext[], - encryptedL2BlockLogs: EncryptedL2BlockL2Logs[], - ): Promise { - if (l2BlockContexts.length !== encryptedL2BlockLogs.length) { + public async process(l2Blocks: L2Block[], encryptedL2BlockLogs: EncryptedL2BlockL2Logs[]): Promise { + if (l2Blocks.length !== encryptedL2BlockLogs.length) { throw new Error( - `Number of blocks and EncryptedLogs is not equal. Received ${l2BlockContexts.length} blocks, ${encryptedL2BlockLogs.length} encrypted logs.`, + `Number of blocks and EncryptedLogs is not equal. Received ${l2Blocks.length} blocks, ${encryptedL2BlockLogs.length} encrypted logs.`, ); } - if (!l2BlockContexts.length) { + if (!l2Blocks.length) { return; } @@ -113,8 +110,7 @@ export class NoteProcessor { for (let blockIndex = 0; blockIndex < encryptedL2BlockLogs.length; ++blockIndex) { this.stats.blocks++; const { txLogs } = encryptedL2BlockLogs[blockIndex]; - const blockContext = l2BlockContexts[blockIndex]; - const block = blockContext.block; + const block = l2Blocks[blockIndex]; const dataStartIndexForBlock = block.header.state.partial.noteHashTree.nextAvailableLeafIndex - block.body.numberOfTxsIncludingPadded * MAX_NEW_NOTE_HASHES_PER_TX; @@ -140,7 +136,7 @@ export class NoteProcessor { if (taggedNote?.notePayload) { const { notePayload: payload } = taggedNote; // We have successfully decrypted the data. - const txHash = blockContext.getTxHash(indexOfTxInABlock); + const txHash = block.body.txEffects[indexOfTxInABlock].txHash; try { const noteDao = await produceNoteDao( this.simulator, @@ -179,7 +175,7 @@ export class NoteProcessor { } blocksAndNotes.push({ - blockContext: l2BlockContexts[blockIndex], + block: l2Blocks[blockIndex], noteDaos, }); } @@ -187,7 +183,7 @@ export class NoteProcessor { await this.processBlocksAndNotes(blocksAndNotes); await this.processDeferredNotes(deferredNoteDaos); - const syncedToBlock = l2BlockContexts[l2BlockContexts.length - 1].block.number; + const syncedToBlock = l2Blocks[l2Blocks.length - 1].number; await this.db.setSynchedBlockNumberForPublicKey(this.publicKey, syncedToBlock); this.log(`Synched block ${syncedToBlock}`); @@ -200,7 +196,7 @@ export class NoteProcessor { * transaction auxiliary data from the database. This function keeps track of new nullifiers * and ensures all other transactions are updated with newly settled block information. * - * @param blocksAndNotes - Array of objects containing L2BlockContexts, user-pertaining transaction indices, and NoteDaos. + * @param blocksAndNotes - Array of objects containing L2 blocks, user-pertaining transaction indices, and NoteDaos. */ private async processBlocksAndNotes(blocksAndNotes: ProcessedData[]) { const noteDaos = blocksAndNotes.flatMap(b => b.noteDaos); @@ -216,7 +212,7 @@ export class NoteProcessor { } const newNullifiers: Fr[] = blocksAndNotes.flatMap(b => - b.blockContext.block.body.txEffects.flatMap(txEffect => txEffect.nullifiers), + b.block.body.txEffects.flatMap(txEffect => txEffect.nullifiers), ); const removedNotes = await this.db.removeNullifiedNotes(newNullifiers, this.publicKey); removedNotes.forEach(noteDao => { diff --git a/yarn-project/pxe/src/synchronizer/synchronizer.ts b/yarn-project/pxe/src/synchronizer/synchronizer.ts index a73bc1416a2..3e46fe81079 100644 --- a/yarn-project/pxe/src/synchronizer/synchronizer.ts +++ b/yarn-project/pxe/src/synchronizer/synchronizer.ts @@ -1,7 +1,7 @@ import { type AztecNode, type KeyStore, - L2BlockContext, + type L2Block, L2BlockL2Logs, MerkleTreeId, type TxHash, @@ -107,17 +107,21 @@ export class Synchronizer { const encryptedLogs = blocks.flatMap(block => block.body.encryptedLogs); - // Wrap blocks in block contexts & only keep those that match our query - const blockContexts = blocks.filter(block => block.number >= from).map(block => new L2BlockContext(block)); + // TODO(benesjan): nuke this check - it's here to verify that the filter is followed + blocks.forEach(block => { + if (block.number < from) { + throw new Error('Unexpected block number'); + } + }); // Update latest tree roots from the most recent block - const latestBlock = blockContexts[blockContexts.length - 1]; + const latestBlock = blocks[blocks.length - 1]; await this.setHeaderFromBlock(latestBlock); const logCount = L2BlockL2Logs.getTotalLogCount(encryptedLogs); this.log(`Forwarding ${logCount} encrypted logs and blocks to ${this.noteProcessors.length} note processors`); for (const noteProcessor of this.noteProcessors) { - await noteProcessor.process(blockContexts, encryptedLogs); + await noteProcessor.process(blocks, encryptedLogs); } return true; } catch (err) { @@ -185,14 +189,12 @@ export class Synchronizer { const encryptedLogs = blocks.flatMap(block => block.body.encryptedLogs); - const blockContexts = blocks.map(block => new L2BlockContext(block)); - const logCount = L2BlockL2Logs.getTotalLogCount(encryptedLogs); this.log(`Forwarding ${logCount} encrypted logs and blocks to note processors in catch up mode`); for (const noteProcessor of catchUpGroup) { // find the index of the first block that the note processor is not yet synced to - const index = blockContexts.findIndex(block => block.block.number > noteProcessor.status.syncedToBlock); + const index = blocks.findIndex(block => block.number > noteProcessor.status.syncedToBlock); if (index === -1) { // Due to the limit, we might not have fetched a new enough block for the note processor. // And since the group is sorted, we break as soon as we find a note processor @@ -202,10 +204,10 @@ export class Synchronizer { this.log.debug( `Catching up note processor ${noteProcessor.publicKey.toString()} by processing ${ - blockContexts.length - index + blocks.length - index } blocks`, ); - await noteProcessor.process(blockContexts.slice(index), encryptedLogs.slice(index)); + await noteProcessor.process(blocks.slice(index), encryptedLogs.slice(index)); if (noteProcessor.status.syncedToBlock === toBlockNumber) { // Note processor caught up, move it to `noteProcessors` from `noteProcessorsToCatchUp`. @@ -231,13 +233,12 @@ export class Synchronizer { } } - private async setHeaderFromBlock(latestBlock: L2BlockContext) { - const { block } = latestBlock; - if (block.number < this.initialSyncBlockNumber) { + private async setHeaderFromBlock(latestBlock: L2Block) { + if (latestBlock.number < this.initialSyncBlockNumber) { return; } - await this.db.setHeader(block.header); + await this.db.setHeader(latestBlock.header); } /** From 4326682169292978e4a1ee8e21e9f7fe7d2c875e Mon Sep 17 00:00:00 2001 From: benesjan Date: Thu, 4 Apr 2024 10:18:28 +0000 Subject: [PATCH 2/4] removing unnecessary check --- yarn-project/pxe/src/synchronizer/synchronizer.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/yarn-project/pxe/src/synchronizer/synchronizer.ts b/yarn-project/pxe/src/synchronizer/synchronizer.ts index 3e46fe81079..a25db92afe9 100644 --- a/yarn-project/pxe/src/synchronizer/synchronizer.ts +++ b/yarn-project/pxe/src/synchronizer/synchronizer.ts @@ -107,13 +107,6 @@ export class Synchronizer { const encryptedLogs = blocks.flatMap(block => block.body.encryptedLogs); - // TODO(benesjan): nuke this check - it's here to verify that the filter is followed - blocks.forEach(block => { - if (block.number < from) { - throw new Error('Unexpected block number'); - } - }); - // Update latest tree roots from the most recent block const latestBlock = blocks[blocks.length - 1]; await this.setHeaderFromBlock(latestBlock); From 9c20774643ce8685a0fc9cd4013244041717e980 Mon Sep 17 00:00:00 2001 From: benesjan Date: Thu, 4 Apr 2024 10:34:52 +0000 Subject: [PATCH 3/4] updated TSdoc --- yarn-project/pxe/src/note_processor/note_processor.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/yarn-project/pxe/src/note_processor/note_processor.ts b/yarn-project/pxe/src/note_processor/note_processor.ts index 42f6c076d21..b301936ad76 100644 --- a/yarn-project/pxe/src/note_processor/note_processor.ts +++ b/yarn-project/pxe/src/note_processor/note_processor.ts @@ -82,13 +82,11 @@ export class NoteProcessor { } /** - * Process the given L2 block contexts and encrypted logs to update the note processor. - * It synchronizes the user's account by decrypting the encrypted logs and processing - * the transactions and auxiliary data associated with them. - * Throws an error if the number of block contexts and encrypted logs do not match. + * Extracts new user-relevant notes from the information contained in the provided L2 blocks and encrypted logs. * - * @param l2Blocks - An array of L2 block contexts to be processed. - * @param encryptedL2BlockLogs - An array of encrypted logs associated with the L2 block contexts. + * @throws If the number of blocks and encrypted logs do not match. + * @param l2Blocks - L2 blocks to be processed. + * @param encryptedL2BlockLogs - Encrypted logs associated with the L2 blocks. * @returns A promise that resolves once the processing is completed. */ public async process(l2Blocks: L2Block[], encryptedL2BlockLogs: EncryptedL2BlockL2Logs[]): Promise { From 1196ebcee63568661c05af8bbd721532db6a6fe9 Mon Sep 17 00:00:00 2001 From: benesjan Date: Thu, 4 Apr 2024 11:56:39 +0000 Subject: [PATCH 4/4] explicitly checking 0 --- yarn-project/pxe/src/note_processor/note_processor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/pxe/src/note_processor/note_processor.ts b/yarn-project/pxe/src/note_processor/note_processor.ts index b301936ad76..dd78fd7fba5 100644 --- a/yarn-project/pxe/src/note_processor/note_processor.ts +++ b/yarn-project/pxe/src/note_processor/note_processor.ts @@ -95,7 +95,7 @@ export class NoteProcessor { `Number of blocks and EncryptedLogs is not equal. Received ${l2Blocks.length} blocks, ${encryptedL2BlockLogs.length} encrypted logs.`, ); } - if (!l2Blocks.length) { + if (l2Blocks.length === 0) { return; }