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 63e1197 commit 8ec7517
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
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 8ec7517

Please sign in to comment.