Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sklppy88 committed Aug 2, 2024
1 parent e1d88cb commit e08b568
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 19 deletions.
15 changes: 13 additions & 2 deletions yarn-project/circuit-types/src/interfaces/pxe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,12 @@ export interface PXE {
* @throws If the code for the functions executed in this transaction has not been made available via `addContracts`.
* Also throws if simulatePublic is true and public simulation reverts.
*/
simulateTx(txRequest: TxExecutionRequest, simulatePublic: boolean, msgSender?: AztecAddress, scopes?: AztecAddress[]): Promise<SimulatedTx>;
simulateTx(
txRequest: TxExecutionRequest,
simulatePublic: boolean,
msgSender?: AztecAddress,
scopes?: AztecAddress[],
): Promise<SimulatedTx>;

/**
* Sends a transaction to an Aztec node to be broadcasted to the network and mined.
Expand Down Expand Up @@ -285,7 +290,13 @@ export interface PXE {
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will default to all.
* @returns The result of the view function call, structured based on the function ABI.
*/
simulateUnconstrained(functionName: string, args: any[], to: AztecAddress, from?: AztecAddress, scopes?: AztecAddress[]): Promise<any>;
simulateUnconstrained(
functionName: string,
args: any[],
to: AztecAddress,
from?: AztecAddress,
scopes?: AztecAddress[],
): Promise<any>;

/**
* Gets unencrypted logs based on the provided filter.
Expand Down
4 changes: 3 additions & 1 deletion yarn-project/pxe/src/note_processor/note_processor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ describe('Note Processor', () => {
}),
],
[],
account.address,
);
}, 25_000);

Expand All @@ -211,7 +212,7 @@ describe('Note Processor', () => {

expect(addNotesSpy).toHaveBeenCalledTimes(1);
// For outgoing notes, the resulting DAO does not contain index.
expect(addNotesSpy).toHaveBeenCalledWith([], [expect.objectContaining(request.note.payload)]);
expect(addNotesSpy).toHaveBeenCalledWith([], [expect.objectContaining(request.note.payload)], account.address);
}, 25_000);

it('should store multiple notes that belong to us', async () => {
Expand Down Expand Up @@ -249,6 +250,7 @@ describe('Note Processor', () => {
expect.objectContaining(requests[1].note.payload),
expect.objectContaining(requests[4].note.payload),
],
account.address,
);
}, 30_000);

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 @@ -227,7 +227,7 @@ export class NoteProcessor {
const incomingNotes = blocksAndNotes.flatMap(b => b.incomingNotes);
const outgoingNotes = blocksAndNotes.flatMap(b => b.outgoingNotes);
if (incomingNotes.length || outgoingNotes.length) {
await this.db.addNotes(incomingNotes, outgoingNotes);
await this.db.addNotes(incomingNotes, outgoingNotes, this.account);
incomingNotes.forEach(noteDao => {
this.log.verbose(
`Added incoming note for contract ${noteDao.contractAddress} at slot ${
Expand Down
31 changes: 16 additions & 15 deletions yarn-project/pxe/src/synchronizer/synchronizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,26 +343,27 @@ export class Synchronizer {
const { incomingNotes: inNotes, outgoingNotes: outNotes } = await processor.decodeDeferredNotes(deferredNotes);
incomingNotes.push(...inNotes);
outgoingNotes.push(...outNotes);

await this.db.addNotes(inNotes, outNotes, processor.account);

incomingNotes.forEach(noteDao => {
this.log.debug(
`Decoded deferred incoming note for contract ${noteDao.contractAddress} at slot ${
noteDao.storageSlot
} with nullifier ${noteDao.siloedNullifier.toString()}`,
);
});

outgoingNotes.forEach(noteDao => {
this.log.debug(
`Decoded deferred outgoing note for contract ${noteDao.contractAddress} at slot ${noteDao.storageSlot}`,
);
});
}
}

// now drop the deferred notes, and add the decoded notes
await this.db.removeDeferredNotesByContract(contractAddress);
await this.db.addNotes(incomingNotes, outgoingNotes);

incomingNotes.forEach(noteDao => {
this.log.debug(
`Decoded deferred incoming note for contract ${noteDao.contractAddress} at slot ${
noteDao.storageSlot
} with nullifier ${noteDao.siloedNullifier.toString()}`,
);
});

outgoingNotes.forEach(noteDao => {
this.log.debug(
`Decoded deferred outgoing note for contract ${noteDao.contractAddress} at slot ${noteDao.storageSlot}`,
);
});

await this.#removeNullifiedNotes(incomingNotes);
}
Expand Down

0 comments on commit e08b568

Please sign in to comment.