From b725e5cac5b1453b6c58bc7f150be89320ec19e5 Mon Sep 17 00:00:00 2001 From: benesjan Date: Fri, 27 Oct 2023 08:41:40 +0000 Subject: [PATCH] naming fixes --- .../acir-simulator/src/acvm/oracle/oracle.ts | 4 ++-- .../src/acvm/oracle/typed_oracle.ts | 8 ++++---- .../src/client/client_execution_context.ts | 20 ++++++------------- .../acir-simulator/src/client/db_oracle.ts | 2 +- .../acir-simulator/src/client/pick_notes.ts | 10 +++++----- .../acir-simulator/src/client/simulator.ts | 4 ++-- .../src/client/view_data_oracle.ts | 13 +++--------- .../pxe/src/kernel_prover/kernel_prover.ts | 4 ++-- .../src/note_processor/note_processor.test.ts | 4 ++-- .../pxe/src/note_processor/note_processor.ts | 2 +- yarn-project/types/src/interfaces/pxe.ts | 2 +- 11 files changed, 29 insertions(+), 44 deletions(-) diff --git a/yarn-project/acir-simulator/src/acvm/oracle/oracle.ts b/yarn-project/acir-simulator/src/acvm/oracle/oracle.ts index 2720c1b027b0..08944796c0cc 100644 --- a/yarn-project/acir-simulator/src/acvm/oracle/oracle.ts +++ b/yarn-project/acir-simulator/src/acvm/oracle/oracle.ts @@ -148,14 +148,14 @@ export class Oracle { [storageSlot]: ACVMField[], [publicKeyX]: ACVMField[], [publicKeyY]: ACVMField[], - preimage: ACVMField[], + log: ACVMField[], ): ACVMField { const publicKey = new Point(fromACVMField(publicKeyX), fromACVMField(publicKeyY)); this.typedOracle.emitEncryptedLog( AztecAddress.fromString(contractAddress), Fr.fromString(storageSlot), publicKey, - preimage.map(fromACVMField), + log.map(fromACVMField), ); return toACVMField(0); } diff --git a/yarn-project/acir-simulator/src/acvm/oracle/typed_oracle.ts b/yarn-project/acir-simulator/src/acvm/oracle/typed_oracle.ts index b3e22d8161d6..a864471a722f 100644 --- a/yarn-project/acir-simulator/src/acvm/oracle/typed_oracle.ts +++ b/yarn-project/acir-simulator/src/acvm/oracle/typed_oracle.ts @@ -9,14 +9,14 @@ import { CompleteAddress, Note, PublicKey, UnencryptedL2Log } from '@aztec/types * Information about a note needed during execution. */ export interface NoteData { + /** The note. */ + note: Note; /** The contract address of the note. */ contractAddress: AztecAddress; /** The storage slot of the note. */ storageSlot: Fr; /** The nonce of the note. */ nonce: Fr; - /** The preimage of the note */ - note: Note; /** The inner note hash of the note. */ innerNoteHash: Fr; /** The corresponding nullifier of the note. Undefined for pending notes. */ @@ -93,7 +93,7 @@ export abstract class TypedOracle { throw new Error('Not available.'); } - notifyCreatedNote(_storageSlot: Fr, _preimage: Fr[], _innerNoteHash: Fr): void { + notifyCreatedNote(_storageSlot: Fr, _note: Fr[], _innerNoteHash: Fr): void { throw new Error('Not available.'); } @@ -121,7 +121,7 @@ export abstract class TypedOracle { throw new Error('Not available.'); } - emitEncryptedLog(_contractAddress: AztecAddress, _storageSlot: Fr, _publicKey: PublicKey, _preimage: Fr[]): void { + emitEncryptedLog(_contractAddress: AztecAddress, _storageSlot: Fr, _publicKey: PublicKey, _log: Fr[]): void { throw new Error('Not available.'); } diff --git a/yarn-project/acir-simulator/src/client/client_execution_context.ts b/yarn-project/acir-simulator/src/client/client_execution_context.ts index 1f1d6775d14f..5236304a716c 100644 --- a/yarn-project/acir-simulator/src/client/client_execution_context.ts +++ b/yarn-project/acir-simulator/src/client/client_execution_context.ts @@ -176,16 +176,13 @@ export class ClientExecutionContext extends ViewDataOracle { } /** - * Gets some notes for a contract address and storage slot. - * Returns a flattened array containing real-note-count and note preimages. + * Gets some notes for a storage slot. * * @remarks - * - * Check for pending notes with matching address/slot. + * Check for pending notes with matching slot. * Real notes coming from DB will have a leafIndex which * represents their index in the note hash tree. * - * @param contractAddress - The contract address. * @param storageSlot - The storage slot. * @param numSelects - The number of valid selects in selectBy and selectValues. * @param selectBy - An array of indices of the fields to selects. @@ -194,12 +191,7 @@ export class ClientExecutionContext extends ViewDataOracle { * @param sortOrder - The order of the corresponding index in sortBy. (1: DESC, 2: ASC, 0: Do nothing) * @param limit - The number of notes to retrieve per query. * @param offset - The starting index for pagination. - * @param returnSize - The return size. - * @returns Flattened array of ACVMFields (format expected by Noir/ACVM) containing: - * count - number of real (non-padding) notes retrieved, - * contractAddress - the contract address, - * preimages - the real note preimages retrieved, and - * paddedZeros - zeros to ensure an array with length returnSize expected by Noir circuit + * @returns Array of note data. */ public async getNotes( storageSlot: Fr, @@ -286,10 +278,10 @@ export class ClientExecutionContext extends ViewDataOracle { * @param contractAddress - The contract address of the note. * @param storageSlot - The storage slot the note is at. * @param publicKey - The public key of the account that can decrypt the log. - * @param preimage - The preimage of the note. + * @param log - The log contents. */ - public emitEncryptedLog(contractAddress: AztecAddress, storageSlot: Fr, publicKey: Point, preimage: Fr[]) { - const note = new Note(preimage); + public emitEncryptedLog(contractAddress: AztecAddress, storageSlot: Fr, publicKey: Point, log: Fr[]) { + const note = new Note(log); const l1NotePayload = new L1NotePayload(note, contractAddress, storageSlot); const encryptedNote = l1NotePayload.toEncryptedBuffer(publicKey, this.curve); this.encryptedLogs.push(encryptedNote); diff --git a/yarn-project/acir-simulator/src/client/db_oracle.ts b/yarn-project/acir-simulator/src/client/db_oracle.ts index da9233c5453a..729c181385d0 100644 --- a/yarn-project/acir-simulator/src/client/db_oracle.ts +++ b/yarn-project/acir-simulator/src/client/db_oracle.ts @@ -50,7 +50,7 @@ export interface DBOracle extends CommitmentsDB { /** * Retrieves a set of notes stored in the database for a given contract address and storage slot. * The query result is paginated using 'limit' and 'offset' values. - * Returns an object containing an array of note data, including preimage, nonce, and index for each note. + * Returns an object containing an array of note data. * * @param contractAddress - The AztecAddress instance representing the contract address. * @param storageSlot - The Fr instance representing the storage slot of the notes. diff --git a/yarn-project/acir-simulator/src/client/pick_notes.ts b/yarn-project/acir-simulator/src/client/pick_notes.ts index cd95fa93eaaf..ca4bbaf1576b 100644 --- a/yarn-project/acir-simulator/src/client/pick_notes.ts +++ b/yarn-project/acir-simulator/src/client/pick_notes.ts @@ -65,16 +65,16 @@ interface GetOptions { } /** - * Basic data needed from a note to perform sort. + * Data needed from to perform sort. */ -interface BasicNoteData { +interface ContainsNote { /** - * Preimage of a note. + * The note. */ note: Note; } -const selectNotes = (noteDatas: T[], selects: Select[]): T[] => +const selectNotes = (noteDatas: T[], selects: Select[]): T[] => noteDatas.filter(noteData => selects.every(({ index, value }) => noteData.note.items[index]?.equals(value))); const sortNotes = (a: Fr[], b: Fr[], sorts: Sort[], level = 0): number => { @@ -94,7 +94,7 @@ const sortNotes = (a: Fr[], b: Fr[], sorts: Sort[], level = 0): number => { /** * Pick from a note array a number of notes that meet the criteria. */ -export function pickNotes( +export function pickNotes( noteDatas: T[], { selects = [], sorts = [], limit = 0, offset = 0 }: GetOptions, ): T[] { diff --git a/yarn-project/acir-simulator/src/client/simulator.ts b/yarn-project/acir-simulator/src/client/simulator.ts index 54463ddb5dde..a412e7b3e1d2 100644 --- a/yarn-project/acir-simulator/src/client/simulator.ts +++ b/yarn-project/acir-simulator/src/client/simulator.ts @@ -176,8 +176,8 @@ export class AcirSimulator { ); } - const preimageLen = (artifact.parameters[3].type as ArrayType).length; - const extendedNoteItems = note.items.concat(Array(preimageLen - note.length).fill(Fr.ZERO)); + const noteItemsLength = (artifact.parameters[3].type as ArrayType).length; + const extendedNoteItems = note.items.concat(Array(noteItemsLength - note.length).fill(Fr.ZERO)); const execRequest: FunctionCall = { to: AztecAddress.ZERO, diff --git a/yarn-project/acir-simulator/src/client/view_data_oracle.ts b/yarn-project/acir-simulator/src/client/view_data_oracle.ts index 55e1aff0206c..53a47c04ff0a 100644 --- a/yarn-project/acir-simulator/src/client/view_data_oracle.ts +++ b/yarn-project/acir-simulator/src/client/view_data_oracle.ts @@ -57,16 +57,13 @@ export class ViewDataOracle extends TypedOracle { } /** - * Gets some notes for a contract address and storage slot. - * Returns a flattened array containing real-note-count and note preimages. + * Gets some notes for a storage slot. * * @remarks - * - * Check for pending notes with matching address/slot. + * Check for pending notes with matching slot. * Real notes coming from DB will have a leafIndex which * represents their index in the note hash tree. * - * @param contractAddress - The contract address. * @param storageSlot - The storage slot. * @param numSelects - The number of valid selects in selectBy and selectValues. * @param selectBy - An array of indices of the fields to selects. @@ -75,11 +72,7 @@ export class ViewDataOracle extends TypedOracle { * @param sortOrder - The order of the corresponding index in sortBy. (1: DESC, 2: ASC, 0: Do nothing) * @param limit - The number of notes to retrieve per query. * @param offset - The starting index for pagination. - * @returns Flattened array of ACVMFields (format expected by Noir/ACVM) containing: - * count - number of real (non-padding) notes retrieved, - * contractAddress - the contract address, - * preimages - the real note preimages retrieved, and - * paddedZeros - zeros to ensure an array with length returnSize expected by Noir circuit + * @returns Array of note data. */ public async getNotes( storageSlot: Fr, diff --git a/yarn-project/pxe/src/kernel_prover/kernel_prover.ts b/yarn-project/pxe/src/kernel_prover/kernel_prover.ts index a5b7b36fb0c3..96e2d49e47c7 100644 --- a/yarn-project/pxe/src/kernel_prover/kernel_prover.ts +++ b/yarn-project/pxe/src/kernel_prover/kernel_prover.ts @@ -231,11 +231,11 @@ export class KernelProver { /** * Retrieves the new output notes for a given execution result. - * The function maps over the new note preimages and associates them with their corresponding + * The function maps over the new notes and associates them with their corresponding * commitments in the public inputs of the execution result. It also includes the contract address * from the call context of the public inputs. * - * @param executionResult - The execution result object containing note preimages and public inputs. + * @param executionResult - The execution result object containing notes and public inputs. * @returns An array of OutputNoteData objects, each representing an output note with its associated data. */ private async getNewNotes(executionResult: ExecutionResult): Promise { 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 f40468a05dae..d9582d82cd62 100644 --- a/yarn-project/pxe/src/note_processor/note_processor.test.ts +++ b/yarn-project/pxe/src/note_processor/note_processor.test.ts @@ -202,10 +202,10 @@ describe('Note Processor', () => { await noteProcessor.process(blockContexts, encryptedLogsArr); }); - it('should be able to recover two notes with the same preimage', async () => { + it('should be able to recover two note payloads with containing the same note', async () => { const note = L1NotePayload.random(); const note2 = L1NotePayload.random(); - // All notes expect one have the same contract address, storage slot, and preimage. + // 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); diff --git a/yarn-project/pxe/src/note_processor/note_processor.ts b/yarn-project/pxe/src/note_processor/note_processor.ts index 40b2220641c7..1cea76bc7a3f 100644 --- a/yarn-project/pxe/src/note_processor/note_processor.ts +++ b/yarn-project/pxe/src/note_processor/note_processor.ts @@ -187,7 +187,7 @@ export class NoteProcessor { * commitment for the current tx matches this value. * Compute the nullifier for a given transaction auxiliary data. * The nullifier is calculated using the private key of the account, - * contract address, and note preimage associated with the l1NotePayload. + * contract address, and the note associated with the l1NotePayload. * This method assists in identifying spent commitments in the private state. * @param commitments - Commitments in the tx. One of them should be the note's commitment. * @param firstNullifier - First nullifier in the tx. diff --git a/yarn-project/types/src/interfaces/pxe.ts b/yarn-project/types/src/interfaces/pxe.ts index 4489811e88c5..d0c698bf1a14 100644 --- a/yarn-project/types/src/interfaces/pxe.ts +++ b/yarn-project/types/src/interfaces/pxe.ts @@ -174,7 +174,7 @@ export interface PXE { * @param storageSlot - The storage slot of the note. * @param note - The note to add. * @param txHash - The tx hash of the tx containing the note. - * @param nonce - The nonce of the note. If undefined, will look for the first index that matches the preimage. + * @param nonce - The nonce of the note. If undefined, will look for the first index that matches the note. */ addNote( account: AztecAddress,