Skip to content

Commit

Permalink
naming fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Oct 27, 2023
1 parent febe53b commit b725e5c
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 44 deletions.
4 changes: 2 additions & 2 deletions yarn-project/acir-simulator/src/acvm/oracle/oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions yarn-project/acir-simulator/src/acvm/oracle/typed_oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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.');
}

Expand Down Expand Up @@ -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.');
}

Expand Down
20 changes: 6 additions & 14 deletions yarn-project/acir-simulator/src/client/client_execution_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/acir-simulator/src/client/db_oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions yarn-project/acir-simulator/src/client/pick_notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <T extends BasicNoteData>(noteDatas: T[], selects: Select[]): T[] =>
const selectNotes = <T extends ContainsNote>(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 => {
Expand All @@ -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<T extends BasicNoteData>(
export function pickNotes<T extends ContainsNote>(
noteDatas: T[],
{ selects = [], sorts = [], limit = 0, offset = 0 }: GetOptions,
): T[] {
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/acir-simulator/src/client/simulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 3 additions & 10 deletions yarn-project/acir-simulator/src/client/view_data_oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/pxe/src/kernel_prover/kernel_prover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<OutputNoteData[]> {
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/pxe/src/note_processor/note_processor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/pxe/src/note_processor/note_processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/types/src/interfaces/pxe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b725e5c

Please sign in to comment.