@aztec/pxe 0.66.0 → 0.67.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dest/bin/index.js +5 -6
  2. package/dest/config/index.d.ts +0 -9
  3. package/dest/config/index.d.ts.map +1 -1
  4. package/dest/config/index.js +1 -17
  5. package/dest/config/package_info.d.ts +5 -0
  6. package/dest/config/package_info.d.ts.map +1 -0
  7. package/dest/config/package_info.js +4 -0
  8. package/dest/contract_data_oracle/index.js +2 -2
  9. package/dest/database/incoming_note_dao.d.ts +1 -1
  10. package/dest/database/incoming_note_dao.d.ts.map +1 -1
  11. package/dest/database/incoming_note_dao.js +2 -2
  12. package/dest/database/kv_pxe_database.d.ts +10 -13
  13. package/dest/database/kv_pxe_database.d.ts.map +1 -1
  14. package/dest/database/kv_pxe_database.js +153 -230
  15. package/dest/database/outgoing_note_dao.js +2 -2
  16. package/dest/database/pxe_database.d.ts +7 -25
  17. package/dest/database/pxe_database.d.ts.map +1 -1
  18. package/dest/database/pxe_database_test_suite.d.ts.map +1 -1
  19. package/dest/database/pxe_database_test_suite.js +18 -59
  20. package/dest/index.d.ts +2 -0
  21. package/dest/index.d.ts.map +1 -1
  22. package/dest/index.js +3 -1
  23. package/dest/kernel_oracle/index.d.ts.map +1 -1
  24. package/dest/kernel_oracle/index.js +3 -3
  25. package/dest/kernel_prover/index.d.ts +1 -0
  26. package/dest/kernel_prover/index.d.ts.map +1 -1
  27. package/dest/kernel_prover/index.js +2 -1
  28. package/dest/kernel_prover/kernel_prover.d.ts +1 -0
  29. package/dest/kernel_prover/kernel_prover.d.ts.map +1 -1
  30. package/dest/kernel_prover/kernel_prover.js +38 -4
  31. package/dest/kernel_prover/test/test_circuit_prover.d.ts.map +1 -1
  32. package/dest/kernel_prover/test/test_circuit_prover.js +4 -4
  33. package/dest/note_decryption_utils/add_public_values_to_payload.js +2 -2
  34. package/dest/note_decryption_utils/brute_force_note_info.d.ts +3 -3
  35. package/dest/note_decryption_utils/brute_force_note_info.d.ts.map +1 -1
  36. package/dest/note_decryption_utils/brute_force_note_info.js +8 -8
  37. package/dest/note_decryption_utils/produce_note_daos.d.ts +3 -6
  38. package/dest/note_decryption_utils/produce_note_daos.d.ts.map +1 -1
  39. package/dest/note_decryption_utils/produce_note_daos.js +5 -19
  40. package/dest/note_decryption_utils/produce_note_daos_for_key.d.ts +1 -1
  41. package/dest/note_decryption_utils/produce_note_daos_for_key.d.ts.map +1 -1
  42. package/dest/pxe_service/error_enriching.d.ts +3 -3
  43. package/dest/pxe_service/error_enriching.d.ts.map +1 -1
  44. package/dest/pxe_service/error_enriching.js +10 -10
  45. package/dest/pxe_service/index.d.ts +0 -1
  46. package/dest/pxe_service/index.d.ts.map +1 -1
  47. package/dest/pxe_service/index.js +1 -2
  48. package/dest/pxe_service/pxe_service.d.ts +2 -16
  49. package/dest/pxe_service/pxe_service.d.ts.map +1 -1
  50. package/dest/pxe_service/pxe_service.js +70 -95
  51. package/dest/pxe_service/test/pxe_test_suite.d.ts.map +1 -1
  52. package/dest/pxe_service/test/pxe_test_suite.js +1 -3
  53. package/dest/simulator/index.d.ts +1 -1
  54. package/dest/simulator/index.d.ts.map +1 -1
  55. package/dest/simulator/index.js +2 -2
  56. package/dest/simulator_oracle/index.d.ts +7 -6
  57. package/dest/simulator_oracle/index.d.ts.map +1 -1
  58. package/dest/simulator_oracle/index.js +59 -42
  59. package/dest/synchronizer/synchronizer.d.ts +10 -40
  60. package/dest/synchronizer/synchronizer.d.ts.map +1 -1
  61. package/dest/synchronizer/synchronizer.js +35 -69
  62. package/dest/{pxe_service → utils}/create_pxe_service.d.ts +1 -1
  63. package/dest/utils/create_pxe_service.d.ts.map +1 -0
  64. package/dest/utils/create_pxe_service.js +49 -0
  65. package/package.json +31 -19
  66. package/src/bin/index.ts +4 -5
  67. package/src/config/index.ts +0 -21
  68. package/src/config/package_info.ts +3 -0
  69. package/src/contract_data_oracle/index.ts +1 -1
  70. package/src/database/incoming_note_dao.ts +2 -2
  71. package/src/database/kv_pxe_database.ts +212 -309
  72. package/src/database/outgoing_note_dao.ts +1 -1
  73. package/src/database/pxe_database.ts +7 -28
  74. package/src/database/pxe_database_test_suite.ts +20 -75
  75. package/src/index.ts +2 -0
  76. package/src/kernel_oracle/index.ts +2 -2
  77. package/src/kernel_prover/index.ts +2 -0
  78. package/src/kernel_prover/kernel_prover.ts +61 -2
  79. package/src/kernel_prover/test/test_circuit_prover.ts +5 -3
  80. package/src/note_decryption_utils/add_public_values_to_payload.ts +1 -1
  81. package/src/note_decryption_utils/brute_force_note_info.ts +9 -9
  82. package/src/note_decryption_utils/produce_note_daos.ts +5 -48
  83. package/src/note_decryption_utils/produce_note_daos_for_key.ts +1 -1
  84. package/src/pxe_service/error_enriching.ts +14 -12
  85. package/src/pxe_service/index.ts +0 -1
  86. package/src/pxe_service/pxe_service.ts +123 -169
  87. package/src/pxe_service/test/pxe_test_suite.ts +0 -3
  88. package/src/simulator/index.ts +1 -1
  89. package/src/simulator_oracle/index.ts +63 -70
  90. package/src/synchronizer/synchronizer.ts +37 -77
  91. package/src/{pxe_service → utils}/create_pxe_service.ts +10 -10
  92. package/dest/pxe_service/create_pxe_service.d.ts.map +0 -1
  93. package/dest/pxe_service/create_pxe_service.js +0 -49
@@ -71,7 +71,7 @@ export class OutgoingNoteDao {
71
71
  this.noteTypeId,
72
72
  this.txHash.buffer,
73
73
  this.l2BlockNumber,
74
- Fr.fromString(this.l2BlockHash),
74
+ Fr.fromHexString(this.l2BlockHash),
75
75
  this.nonce,
76
76
  this.noteHash,
77
77
  this.index,
@@ -1,8 +1,8 @@
1
- import { type InBlock, type IncomingNotesFilter, type OutgoingNotesFilter } from '@aztec/circuit-types';
1
+ import { type InBlock, type IncomingNotesFilter } from '@aztec/circuit-types';
2
2
  import {
3
+ type BlockHeader,
3
4
  type CompleteAddress,
4
5
  type ContractInstanceWithAddress,
5
- type Header,
6
6
  type IndexedTaggingSecret,
7
7
  type PublicKey,
8
8
  } from '@aztec/circuits.js';
@@ -13,7 +13,6 @@ import { type Fr } from '@aztec/foundation/fields';
13
13
  import { type ContractArtifactDatabase } from './contracts/contract_artifact_db.js';
14
14
  import { type ContractInstanceDatabase } from './contracts/contract_instance_db.js';
15
15
  import { type IncomingNoteDao } from './incoming_note_dao.js';
16
- import { type OutgoingNoteDao } from './outgoing_note_dao.js';
17
16
 
18
17
  /**
19
18
  * A database interface that provides methods for retrieving, adding, and removing transactional data related to Aztec
@@ -57,12 +56,6 @@ export interface PxeDatabase extends ContractArtifactDatabase, ContractInstanceD
57
56
  */
58
57
  getIncomingNotes(filter: IncomingNotesFilter): Promise<IncomingNoteDao[]>;
59
58
 
60
- /**
61
- * Gets outgoing notes.
62
- * @returns The outgoing notes.
63
- */
64
- getOutgoingNotes(filter: OutgoingNotesFilter): Promise<OutgoingNoteDao[]>;
65
-
66
59
  /**
67
60
  * Adds a note to DB.
68
61
  * @param note - The note to add.
@@ -83,11 +76,10 @@ export interface PxeDatabase extends ContractArtifactDatabase, ContractInstanceD
83
76
  * which can improve performance when dealing with large numbers of transactions.
84
77
  *
85
78
  * @param incomingNotes - An array of notes which were decrypted as incoming.
86
- * @param outgoingNotes - An array of notes which were decrypted as outgoing.
87
79
  * @param scope - The scope to add the notes under. Currently optional.
88
80
  * @remark - Will create a database for the scope if it does not already exist.
89
81
  */
90
- addNotes(incomingNotes: IncomingNoteDao[], outgoingNotes: OutgoingNoteDao[], scope?: AztecAddress): Promise<void>;
82
+ addNotes(incomingNotes: IncomingNoteDao[], scope?: AztecAddress): Promise<void>;
91
83
 
92
84
  /**
93
85
  * Remove nullified notes associated with the given account and nullifiers.
@@ -102,7 +94,7 @@ export interface PxeDatabase extends ContractArtifactDatabase, ContractInstanceD
102
94
  * Gets the most recently processed block number.
103
95
  * @returns The most recently processed block number or undefined if never synched.
104
96
  */
105
- getBlockNumber(): number | undefined;
97
+ getBlockNumber(): Promise<number | undefined>;
106
98
 
107
99
  /**
108
100
  * Retrieve the stored Block Header from the database.
@@ -115,7 +107,7 @@ export interface PxeDatabase extends ContractArtifactDatabase, ContractInstanceD
115
107
  * @returns The Block Header.
116
108
  * @throws If no block have been processed yet.
117
109
  */
118
- getHeader(): Header;
110
+ getBlockHeader(): Promise<BlockHeader>;
119
111
 
120
112
  /**
121
113
  * Set the latest Block Header.
@@ -124,7 +116,7 @@ export interface PxeDatabase extends ContractArtifactDatabase, ContractInstanceD
124
116
  * @param header - An object containing the most recent block header.
125
117
  * @returns A Promise that resolves when the hash has been successfully updated in the database.
126
118
  */
127
- setHeader(header: Header): Promise<void>;
119
+ setHeader(header: BlockHeader): Promise<void>;
128
120
 
129
121
  /**
130
122
  * Adds contact address to the database.
@@ -137,7 +129,7 @@ export interface PxeDatabase extends ContractArtifactDatabase, ContractInstanceD
137
129
  * Retrieves the list of contact addresses in the address book.
138
130
  * @returns An array of Aztec addresses.
139
131
  */
140
- getContactAddresses(): AztecAddress[];
132
+ getContactAddresses(): Promise<AztecAddress[]>;
141
133
 
142
134
  /**
143
135
  * Removes a contact address from the database.
@@ -168,19 +160,6 @@ export interface PxeDatabase extends ContractArtifactDatabase, ContractInstanceD
168
160
  */
169
161
  getCompleteAddresses(): Promise<CompleteAddress[]>;
170
162
 
171
- /**
172
- * Updates up to which block number we have processed notes for a given public key.
173
- * @param account - The account to set the synched block number for.
174
- * @param blockNumber - The block number to set.
175
- */
176
- setSynchedBlockNumberForAccount(account: AztecAddress, blockNumber: number): Promise<void>;
177
-
178
- /**
179
- * Get the synched block number for a given public key.
180
- * @param account - The account to get the synched block number for.
181
- */
182
- getSynchedBlockNumberForAccount(account: AztecAddress): number | undefined;
183
-
184
163
  /**
185
164
  * Returns the estimated size in bytes of this db.
186
165
  * @returns The estimated size in bytes of this db.
@@ -1,4 +1,4 @@
1
- import { type IncomingNotesFilter, NoteStatus, type OutgoingNotesFilter, randomTxHash } from '@aztec/circuit-types';
1
+ import { type IncomingNotesFilter, NoteStatus, randomTxHash } from '@aztec/circuit-types';
2
2
  import {
3
3
  AztecAddress,
4
4
  CompleteAddress,
@@ -14,7 +14,6 @@ import { BenchmarkingContractArtifact } from '@aztec/noir-contracts.js/Benchmark
14
14
  import { TestContractArtifact } from '@aztec/noir-contracts.js/Test';
15
15
 
16
16
  import { IncomingNoteDao } from './incoming_note_dao.js';
17
- import { OutgoingNoteDao } from './outgoing_note_dao.js';
18
17
  import { type PxeDatabase } from './pxe_database.js';
19
18
 
20
19
  /**
@@ -135,7 +134,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
135
134
  });
136
135
 
137
136
  it.each(filteringTests)('stores notes in bulk and retrieves notes', async (getFilter, getExpected) => {
138
- await database.addNotes(notes, []);
137
+ await database.addNotes(notes);
139
138
  const returnedNotes = await database.getIncomingNotes(getFilter());
140
139
 
141
140
  expect(returnedNotes.sort()).toEqual(getExpected().sort());
@@ -152,7 +151,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
152
151
  });
153
152
 
154
153
  it.each(filteringTests)('retrieves nullified notes', async (getFilter, getExpected) => {
155
- await database.addNotes(notes, []);
154
+ await database.addNotes(notes);
156
155
 
157
156
  // Nullify all notes and use the same filter as other test cases
158
157
  for (const owner of owners) {
@@ -173,7 +172,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
173
172
  });
174
173
 
175
174
  it('skips nullified notes by default or when requesting active', async () => {
176
- await database.addNotes(notes, []);
175
+ await database.addNotes(notes);
177
176
 
178
177
  const notesToNullify = notes.filter(note => note.addressPoint.equals(owners[0].address.toAddressPoint()));
179
178
  const nullifiers = notesToNullify.map(note => ({
@@ -194,7 +193,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
194
193
 
195
194
  it('handles note unnullification', async () => {
196
195
  await database.setHeader(makeHeader(randomInt(1000), 100, 0 /** slot number */));
197
- await database.addNotes(notes, []);
196
+ await database.addNotes(notes);
198
197
 
199
198
  const notesToNullify = notes.filter(note => note.addressPoint.equals(owners[0].address.toAddressPoint()));
200
199
  const nullifiers = notesToNullify.map(note => ({
@@ -213,7 +212,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
213
212
  });
214
213
 
215
214
  it('returns active and nullified notes when requesting either', async () => {
216
- await database.addNotes(notes, []);
215
+ await database.addNotes(notes);
217
216
 
218
217
  const notesToNullify = notes.filter(note => note.addressPoint.equals(owners[0].address.toAddressPoint()));
219
218
  const nullifiers = notesToNullify.map(note => ({
@@ -303,7 +302,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
303
302
  });
304
303
 
305
304
  it('removes notes after a given block', async () => {
306
- await database.addNotes(notes, [], owners[0].address);
305
+ await database.addNotes(notes, owners[0].address);
307
306
 
308
307
  await database.removeNotesAfter(5);
309
308
  const result = await database.getIncomingNotes({ scopes: [owners[0].address] });
@@ -311,80 +310,16 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
311
310
  });
312
311
  });
313
312
 
314
- describe('outgoing notes', () => {
315
- let owners: CompleteAddress[];
316
- let contractAddresses: AztecAddress[];
317
- let storageSlots: Fr[];
318
- let notes: OutgoingNoteDao[];
319
-
320
- const filteringTests: [() => OutgoingNotesFilter, () => OutgoingNoteDao[]][] = [
321
- [() => ({}), () => notes],
322
-
323
- [
324
- () => ({ contractAddress: contractAddresses[0] }),
325
- () => notes.filter(note => note.contractAddress.equals(contractAddresses[0])),
326
- ],
327
- [() => ({ contractAddress: AztecAddress.random() }), () => []],
328
-
329
- [
330
- () => ({ storageSlot: storageSlots[0] }),
331
- () => notes.filter(note => note.storageSlot.equals(storageSlots[0])),
332
- ],
333
- [() => ({ storageSlot: Fr.random() }), () => []],
334
-
335
- [() => ({ txHash: notes[0].txHash }), () => [notes[0]]],
336
- [() => ({ txHash: randomTxHash() }), () => []],
337
-
338
- [
339
- () => ({ owner: owners[0].address }),
340
- () => notes.filter(note => note.ovpkM.equals(owners[0].publicKeys.masterOutgoingViewingPublicKey)),
341
- ],
342
-
343
- [
344
- () => ({ contractAddress: contractAddresses[0], storageSlot: storageSlots[0] }),
345
- () =>
346
- notes.filter(
347
- note => note.contractAddress.equals(contractAddresses[0]) && note.storageSlot.equals(storageSlots[0]),
348
- ),
349
- ],
350
- [() => ({ contractAddress: contractAddresses[0], storageSlot: storageSlots[1] }), () => []],
351
- ];
352
-
353
- beforeEach(async () => {
354
- owners = Array.from({ length: 2 }).map(() => CompleteAddress.random());
355
- contractAddresses = Array.from({ length: 2 }).map(() => AztecAddress.random());
356
- storageSlots = Array.from({ length: 2 }).map(() => Fr.random());
357
-
358
- notes = Array.from({ length: 10 }).map((_, i) =>
359
- OutgoingNoteDao.random({
360
- contractAddress: contractAddresses[i % contractAddresses.length],
361
- storageSlot: storageSlots[i % storageSlots.length],
362
- ovpkM: owners[i % owners.length].publicKeys.masterOutgoingViewingPublicKey,
363
- index: BigInt(i),
364
- }),
365
- );
366
-
367
- for (const owner of owners) {
368
- await database.addCompleteAddress(owner);
369
- }
370
- });
371
-
372
- it.each(filteringTests)('stores notes in bulk and retrieves notes', async (getFilter, getExpected) => {
373
- await database.addNotes([], notes);
374
- await expect(database.getOutgoingNotes(getFilter())).resolves.toEqual(getExpected());
375
- });
376
- });
377
-
378
313
  describe('block header', () => {
379
314
  it('stores and retrieves the block header', async () => {
380
315
  const header = makeHeader(randomInt(1000), INITIAL_L2_BLOCK_NUM, 0 /** slot number */);
381
316
 
382
317
  await database.setHeader(header);
383
- expect(database.getHeader()).toEqual(header);
318
+ await expect(database.getBlockHeader()).resolves.toEqual(header);
384
319
  });
385
320
 
386
- it('rejects getting header if no block set', () => {
387
- expect(() => database.getHeader()).toThrow();
321
+ it('rejects getting header if no block set', async () => {
322
+ await expect(() => database.getBlockHeader()).rejects.toThrow();
388
323
  });
389
324
  });
390
325
 
@@ -423,6 +358,16 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
423
358
  expect(result).toEqual(expect.arrayContaining(addresses));
424
359
  });
425
360
 
361
+ it('returns a single address', async () => {
362
+ const addresses = Array.from({ length: 10 }).map(() => CompleteAddress.random());
363
+ for (const address of addresses) {
364
+ await database.addCompleteAddress(address);
365
+ }
366
+
367
+ const result = await database.getCompleteAddress(addresses[3].address);
368
+ expect(result).toEqual(addresses[3]);
369
+ });
370
+
426
371
  it("returns an empty array if it doesn't have addresses", async () => {
427
372
  expect(await database.getCompleteAddresses()).toEqual([]);
428
373
  });
package/src/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './pxe_service/index.js';
2
2
  export * from './pxe_http/index.js';
3
3
  export * from './config/index.js';
4
+ export * from './utils/create_pxe_service.js';
4
5
 
5
6
  export { Tx, TxHash } from '@aztec/circuit-types';
6
7
 
@@ -12,3 +13,4 @@ export * from '@aztec/key-store';
12
13
  export * from './database/index.js';
13
14
  export { ContractDataOracle } from './contract_data_oracle/index.js';
14
15
  export { PrivateFunctionsTree } from './contract_data_oracle/private_functions_tree.js';
16
+ export { SimulatorOracle } from './simulator_oracle/index.js';
@@ -12,7 +12,7 @@ import {
12
12
  computeContractClassIdPreimage,
13
13
  computeSaltedInitializationHash,
14
14
  } from '@aztec/circuits.js';
15
- import { createDebugLogger } from '@aztec/foundation/log';
15
+ import { createLogger } from '@aztec/foundation/log';
16
16
  import { type Tuple } from '@aztec/foundation/serialize';
17
17
  import { type KeyStore } from '@aztec/key-store';
18
18
  import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types';
@@ -31,7 +31,7 @@ export class KernelOracle implements ProvingDataOracle {
31
31
  private keyStore: KeyStore,
32
32
  private node: AztecNode,
33
33
  private blockNumber: L2BlockNumber = 'latest',
34
- private log = createDebugLogger('aztec:pxe:kernel_oracle'),
34
+ private log = createLogger('pxe:kernel_oracle'),
35
35
  ) {}
36
36
 
37
37
  public async getContractAddressPreimage(address: AztecAddress) {
@@ -1,2 +1,4 @@
1
+ export { TestPrivateKernelProver } from './test/test_circuit_prover.js';
2
+
1
3
  export * from './kernel_prover.js';
2
4
  export * from './proving_data_oracle.js';
@@ -19,6 +19,8 @@ import {
19
19
  PrivateKernelInnerCircuitPrivateInputs,
20
20
  PrivateKernelTailCircuitPrivateInputs,
21
21
  type PrivateKernelTailCircuitPublicInputs,
22
+ type PrivateLog,
23
+ type ScopedPrivateLogData,
22
24
  type TxRequest,
23
25
  VK_TREE_HEIGHT,
24
26
  VerificationKeyAsFields,
@@ -26,7 +28,7 @@ import {
26
28
  import { hashVK } from '@aztec/circuits.js/hash';
27
29
  import { makeTuple } from '@aztec/foundation/array';
28
30
  import { vkAsFieldsMegaHonk } from '@aztec/foundation/crypto';
29
- import { createDebugLogger } from '@aztec/foundation/log';
31
+ import { createLogger } from '@aztec/foundation/log';
30
32
  import { assertLength } from '@aztec/foundation/serialize';
31
33
  import { pushTestData } from '@aztec/foundation/testing';
32
34
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types';
@@ -37,10 +39,48 @@ import {
37
39
  } from '@aztec/protocol-contracts';
38
40
 
39
41
  import { type WitnessMap } from '@noir-lang/types';
42
+ import { strict as assert } from 'assert';
40
43
 
41
44
  import { PrivateKernelResetPrivateInputsBuilder } from './hints/build_private_kernel_reset_private_inputs.js';
42
45
  import { type ProvingDataOracle } from './proving_data_oracle.js';
43
46
 
47
+ // TODO(#10592): Temporary workaround to check that the private logs are correctly split into non-revertible set and revertible set.
48
+ // This should be done in TailToPublicOutputValidator in private kernel tail.
49
+ function checkPrivateLogs(
50
+ privateLogs: ScopedPrivateLogData[],
51
+ nonRevertiblePrivateLogs: PrivateLog[],
52
+ revertiblePrivateLogs: PrivateLog[],
53
+ splitCounter: number,
54
+ ) {
55
+ let numNonRevertible = 0;
56
+ let numRevertible = 0;
57
+ privateLogs
58
+ .filter(privateLog => privateLog.inner.counter !== 0)
59
+ .forEach(privateLog => {
60
+ if (privateLog.inner.counter < splitCounter) {
61
+ assert(
62
+ privateLog.inner.log.toBuffer().equals(nonRevertiblePrivateLogs[numNonRevertible].toBuffer()),
63
+ `mismatch non-revertible private logs at index ${numNonRevertible}`,
64
+ );
65
+ numNonRevertible++;
66
+ } else {
67
+ assert(
68
+ privateLog.inner.log.toBuffer().equals(revertiblePrivateLogs[numRevertible].toBuffer()),
69
+ `mismatch revertible private logs at index ${numRevertible}`,
70
+ );
71
+ numRevertible++;
72
+ }
73
+ });
74
+ assert(
75
+ nonRevertiblePrivateLogs.slice(numNonRevertible).every(l => l.isEmpty()),
76
+ 'Unexpected non-empty private log in non-revertible set.',
77
+ );
78
+ assert(
79
+ revertiblePrivateLogs.slice(numRevertible).every(l => l.isEmpty()),
80
+ 'Unexpected non-empty private log in revertible set.',
81
+ );
82
+ }
83
+
44
84
  const NULL_PROVE_OUTPUT: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs> = {
45
85
  publicInputs: PrivateKernelCircuitPublicInputs.empty(),
46
86
  verificationKey: VerificationKeyAsFields.makeEmpty(CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS),
@@ -55,7 +95,7 @@ const NULL_PROVE_OUTPUT: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicI
55
95
  * constructs private call data based on the execution results.
56
96
  */
57
97
  export class KernelProver {
58
- private log = createDebugLogger('aztec:kernel-prover');
98
+ private log = createLogger('pxe:kernel-prover');
59
99
 
60
100
  constructor(private oracle: ProvingDataOracle, private proofCreator: PrivateKernelProver) {}
61
101
 
@@ -78,6 +118,8 @@ export class KernelProver {
78
118
  profile: boolean = false,
79
119
  dryRun: boolean = false,
80
120
  ): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>> {
121
+ const isPrivateOnlyTx = this.isPrivateOnly(executionResult);
122
+
81
123
  const executionStack = [executionResult];
82
124
  let firstIteration = true;
83
125
 
@@ -153,6 +195,7 @@ export class KernelProver {
153
195
  getVKTreeRoot(),
154
196
  protocolContractTreeRoot,
155
197
  privateCallData,
198
+ isPrivateOnlyTx,
156
199
  );
157
200
  pushTestData('private-kernel-inputs-init', proofInput);
158
201
  output = await this.proofCreator.simulateProofInit(proofInput);
@@ -225,6 +268,12 @@ export class KernelProver {
225
268
 
226
269
  pushTestData('private-kernel-inputs-ordering', privateInputs);
227
270
  const tailOutput = await this.proofCreator.simulateProofTail(privateInputs);
271
+ if (tailOutput.publicInputs.forPublic) {
272
+ const privateLogs = privateInputs.previousKernel.publicInputs.end.privateLogs;
273
+ const nonRevertiblePrivateLogs = tailOutput.publicInputs.forPublic.nonRevertibleAccumulatedData.privateLogs;
274
+ const revertiblePrivateLogs = tailOutput.publicInputs.forPublic.revertibleAccumulatedData.privateLogs;
275
+ checkPrivateLogs(privateLogs, nonRevertiblePrivateLogs, revertiblePrivateLogs, validationRequestsSplitCounter);
276
+ }
228
277
 
229
278
  acirs.push(tailOutput.bytecode);
230
279
  witnessStack.push(tailOutput.outputWitness);
@@ -278,4 +327,14 @@ export class KernelProver {
278
327
  acirHash,
279
328
  });
280
329
  }
330
+
331
+ private isPrivateOnly(executionResult: PrivateExecutionResult): boolean {
332
+ const makesPublicCalls =
333
+ executionResult.enqueuedPublicFunctionCalls.some(enqueuedCall => !enqueuedCall.isEmpty()) ||
334
+ !executionResult.publicTeardownFunctionCall.isEmpty();
335
+ return (
336
+ !makesPublicCalls &&
337
+ executionResult.nestedExecutions.every(nestedExecution => this.isPrivateOnly(nestedExecution))
338
+ );
339
+ }
281
340
  }
@@ -15,7 +15,7 @@ import {
15
15
  type PrivateKernelTailCircuitPublicInputs,
16
16
  VerificationKeyAsFields,
17
17
  } from '@aztec/circuits.js';
18
- import { createDebugLogger } from '@aztec/foundation/log';
18
+ import { createLogger } from '@aztec/foundation/log';
19
19
  import { elapsed } from '@aztec/foundation/timer';
20
20
  import {
21
21
  type ProtocolArtifact,
@@ -35,7 +35,7 @@ import { type WitnessMap } from '@noir-lang/types';
35
35
  * Test Proof Creator executes circuit simulations and provides fake proofs.
36
36
  */
37
37
  export class TestPrivateKernelProver implements PrivateKernelProver {
38
- constructor(private log = createDebugLogger('aztec:test_proof_creator')) {}
38
+ constructor(private log = createLogger('pxe:test_proof_creator')) {}
39
39
 
40
40
  createClientIvcProof(_acirs: Buffer[], _witnessStack: WitnessMap[]): Promise<ClientIvcProof> {
41
41
  return Promise.resolve(ClientIvcProof.empty());
@@ -73,7 +73,9 @@ export class TestPrivateKernelProver implements PrivateKernelProver {
73
73
  privateInputs: PrivateKernelResetCircuitPrivateInputs,
74
74
  ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
75
75
  const variantPrivateInputs = privateInputs.trimToSizes();
76
- const [duration, result] = await elapsed(() => executeReset(variantPrivateInputs, privateInputs.dimensions));
76
+ const [duration, result] = await elapsed(() =>
77
+ executeReset(variantPrivateInputs, privateInputs.dimensions, privateInputs),
78
+ );
77
79
  this.log.debug(`Simulated private kernel reset`, {
78
80
  eventName: 'circuit-simulation',
79
81
  circuitName: 'private-kernel-reset',
@@ -1,5 +1,5 @@
1
1
  import { type L1NotePayload, Note } from '@aztec/circuit-types';
2
- import { ContractNotFoundError } from '@aztec/simulator';
2
+ import { ContractNotFoundError } from '@aztec/simulator/client';
3
3
 
4
4
  import { type PxeDatabase } from '../database/pxe_database.js';
5
5
 
@@ -3,7 +3,7 @@ import { type AztecAddress } from '@aztec/circuits.js';
3
3
  import { computeNoteHashNonce, siloNullifier } from '@aztec/circuits.js/hash';
4
4
  import { type NoteSelector } from '@aztec/foundation/abi';
5
5
  import { Fr } from '@aztec/foundation/fields';
6
- import { type AcirSimulator } from '@aztec/simulator';
6
+ import { type AcirSimulator } from '@aztec/simulator/client';
7
7
 
8
8
  export interface NoteInfo {
9
9
  noteHashIndex: number;
@@ -18,7 +18,7 @@ export interface NoteInfo {
18
18
  * @dev Finds the index in the note hash tree by computing the note hash with different nonce and see which hash for
19
19
  * the current tx matches this value.
20
20
  * @remarks This method assists in identifying spent notes in the note hash tree.
21
- * @param siloedNoteHashes - Note hashes in the tx. One of them should correspond to the note we are looking for
21
+ * @param uniqueNoteHashes - Note hashes in the tx. One of them should correspond to the note we are looking for
22
22
  * @param txHash - Hash of a tx the note was emitted in.
23
23
  * @param contractAddress - Address of the contract the note was emitted in.
24
24
  * @param storageSlot - Storage slot of the note.
@@ -32,7 +32,7 @@ export interface NoteInfo {
32
32
  */
33
33
  export async function bruteForceNoteInfo(
34
34
  simulator: AcirSimulator,
35
- siloedNoteHashes: Fr[],
35
+ uniqueNoteHashes: Fr[],
36
36
  txHash: TxHash,
37
37
  contractAddress: AztecAddress,
38
38
  storageSlot: Fr,
@@ -44,22 +44,22 @@ export async function bruteForceNoteInfo(
44
44
  let noteHashIndex = 0;
45
45
  let nonce: Fr | undefined;
46
46
  let noteHash: Fr | undefined;
47
- let siloedNoteHash: Fr | undefined;
47
+ let uniqueNoteHash: Fr | undefined;
48
48
  let innerNullifier: Fr | undefined;
49
49
  const firstNullifier = Fr.fromBuffer(txHash.toBuffer());
50
50
 
51
- for (; noteHashIndex < siloedNoteHashes.length; ++noteHashIndex) {
51
+ for (; noteHashIndex < uniqueNoteHashes.length; ++noteHashIndex) {
52
52
  if (excludedIndices.has(noteHashIndex)) {
53
53
  continue;
54
54
  }
55
55
 
56
- const siloedNoteHashFromTxEffect = siloedNoteHashes[noteHashIndex];
57
- if (siloedNoteHashFromTxEffect.equals(Fr.ZERO)) {
56
+ const uniqueNoteHashFromTxEffect = uniqueNoteHashes[noteHashIndex];
57
+ if (uniqueNoteHashFromTxEffect.equals(Fr.ZERO)) {
58
58
  break;
59
59
  }
60
60
 
61
61
  const expectedNonce = computeNoteHashNonce(firstNullifier, noteHashIndex);
62
- ({ noteHash, siloedNoteHash, innerNullifier } = await simulator.computeNoteHashAndOptionallyANullifier(
62
+ ({ noteHash, uniqueNoteHash, innerNullifier } = await simulator.computeNoteHashAndOptionallyANullifier(
63
63
  contractAddress,
64
64
  expectedNonce,
65
65
  storageSlot,
@@ -68,7 +68,7 @@ export async function bruteForceNoteInfo(
68
68
  note,
69
69
  ));
70
70
 
71
- if (siloedNoteHashFromTxEffect.equals(siloedNoteHash)) {
71
+ if (uniqueNoteHashFromTxEffect.equals(uniqueNoteHash)) {
72
72
  nonce = expectedNonce;
73
73
  break;
74
74
  }
@@ -1,10 +1,9 @@
1
1
  import { type L1NotePayload, type PublicKey, type TxHash } from '@aztec/circuit-types';
2
2
  import { type Fr } from '@aztec/foundation/fields';
3
3
  import { type Logger } from '@aztec/foundation/log';
4
- import { type AcirSimulator } from '@aztec/simulator';
4
+ import { type AcirSimulator } from '@aztec/simulator/client';
5
5
 
6
6
  import { IncomingNoteDao } from '../database/incoming_note_dao.js';
7
- import { OutgoingNoteDao } from '../database/outgoing_note_dao.js';
8
7
  import { type PxeDatabase } from '../database/pxe_database.js';
9
8
  import { produceNoteDaosForKey } from './produce_note_daos_for_key.js';
10
9
 
@@ -17,7 +16,6 @@ import { produceNoteDaosForKey } from './produce_note_daos_for_key.js';
17
16
  * @param simulator - An instance of AcirSimulator.
18
17
  * @param db - An instance of PxeDatabase.
19
18
  * @param addressPoint - The public counterpart to the address secret, which is used in the decryption of incoming note logs.
20
- * @param ovpkM - The public counterpart to the secret key to be used in the decryption of outgoing note logs.
21
19
  * @param payload - An instance of l1NotePayload.
22
20
  * @param txHash - The hash of the transaction that created the note. Equivalent to the first nullifier of the transaction.
23
21
  * @param noteHashes - New note hashes in this transaction, one of which belongs to this note.
@@ -25,13 +23,12 @@ import { produceNoteDaosForKey } from './produce_note_daos_for_key.js';
25
23
  * @param excludedIndices - Indices that have been assigned a note in the same tx. Notes in a tx can have the same l1NotePayload, we need to find a different index for each replicate.
26
24
  * @param logger - An instance of Logger.
27
25
  * @param unencryptedLogs - Unencrypted logs for the transaction (used to complete partial notes).
28
- * @returns An object containing the incoming, outgoing, and deferred notes.
26
+ * @returns An object containing the incoming notes.
29
27
  */
30
28
  export async function produceNoteDaos(
31
29
  simulator: AcirSimulator,
32
30
  db: PxeDatabase,
33
31
  addressPoint: PublicKey | undefined,
34
- ovpkM: PublicKey | undefined,
35
32
  payload: L1NotePayload,
36
33
  txHash: TxHash,
37
34
  l2BlockNumber: number,
@@ -40,16 +37,12 @@ export async function produceNoteDaos(
40
37
  dataStartIndexForTx: number,
41
38
  excludedIndices: Set<number>,
42
39
  logger: Logger,
43
- ): Promise<{
44
- incomingNote: IncomingNoteDao | undefined;
45
- outgoingNote: OutgoingNoteDao | undefined;
46
- }> {
47
- if (!addressPoint && !ovpkM) {
48
- throw new Error('Both addressPoint and ovpkM are undefined. Cannot create note.');
40
+ ): Promise<{ incomingNote: IncomingNoteDao | undefined }> {
41
+ if (!addressPoint) {
42
+ throw new Error('addressPoint is undefined. Cannot create note.');
49
43
  }
50
44
 
51
45
  let incomingNote: IncomingNoteDao | undefined;
52
- let outgoingNote: OutgoingNoteDao | undefined;
53
46
 
54
47
  if (addressPoint) {
55
48
  incomingNote = await produceNoteDaosForKey(
@@ -68,43 +61,7 @@ export async function produceNoteDaos(
68
61
  );
69
62
  }
70
63
 
71
- if (ovpkM) {
72
- if (incomingNote) {
73
- // Incoming note is defined meaning that this PXE has both the incoming and outgoing keys. We can skip computing
74
- // note hash and note index since we already have them in the incoming note.
75
- outgoingNote = new OutgoingNoteDao(
76
- incomingNote.note,
77
- incomingNote.contractAddress,
78
- incomingNote.storageSlot,
79
- incomingNote.noteTypeId,
80
- incomingNote.txHash,
81
- incomingNote.l2BlockNumber,
82
- incomingNote.l2BlockHash,
83
- incomingNote.nonce,
84
- incomingNote.noteHash,
85
- incomingNote.index,
86
- ovpkM,
87
- );
88
- } else {
89
- outgoingNote = await produceNoteDaosForKey(
90
- simulator,
91
- db,
92
- ovpkM,
93
- payload,
94
- txHash,
95
- l2BlockNumber,
96
- l2BlockHash,
97
- noteHashes,
98
- dataStartIndexForTx,
99
- excludedIndices,
100
- logger,
101
- OutgoingNoteDao.fromPayloadAndNoteInfo,
102
- );
103
- }
104
- }
105
-
106
64
  return {
107
65
  incomingNote,
108
- outgoingNote,
109
66
  };
110
67
  }
@@ -1,7 +1,7 @@
1
1
  import { type L1NotePayload, type Note, type TxHash } from '@aztec/circuit-types';
2
2
  import { type Fr, type PublicKey } from '@aztec/circuits.js';
3
3
  import { type Logger } from '@aztec/foundation/log';
4
- import { type AcirSimulator } from '@aztec/simulator';
4
+ import { type AcirSimulator } from '@aztec/simulator/client';
5
5
 
6
6
  import { type PxeDatabase } from '../database/pxe_database.js';
7
7
  import { getOrderedNoteItems } from './add_public_values_to_payload.js';