@aztec/pxe 0.61.0 → 0.63.0

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 (109) hide show
  1. package/dest/config/index.d.ts +2 -3
  2. package/dest/config/index.d.ts.map +1 -1
  3. package/dest/config/index.js +4 -5
  4. package/dest/contract_data_oracle/index.d.ts +1 -0
  5. package/dest/contract_data_oracle/index.d.ts.map +1 -1
  6. package/dest/contract_data_oracle/index.js +5 -1
  7. package/dest/database/incoming_note_dao.d.ts +4 -4
  8. package/dest/database/incoming_note_dao.d.ts.map +1 -1
  9. package/dest/database/incoming_note_dao.js +6 -6
  10. package/dest/database/kv_pxe_database.d.ts +10 -14
  11. package/dest/database/kv_pxe_database.d.ts.map +1 -1
  12. package/dest/database/kv_pxe_database.js +82 -94
  13. package/dest/database/outgoing_note_dao.d.ts +2 -2
  14. package/dest/database/outgoing_note_dao.d.ts.map +1 -1
  15. package/dest/database/outgoing_note_dao.js +2 -2
  16. package/dest/database/pxe_database.d.ts +42 -20
  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 +11 -11
  20. package/dest/index.d.ts +1 -1
  21. package/dest/index.d.ts.map +1 -1
  22. package/dest/index.js +1 -1
  23. package/dest/kernel_oracle/index.d.ts +3 -3
  24. package/dest/kernel_oracle/index.d.ts.map +1 -1
  25. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -1
  26. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +12 -4
  27. package/dest/kernel_prover/kernel_prover.d.ts +3 -1
  28. package/dest/kernel_prover/kernel_prover.d.ts.map +1 -1
  29. package/dest/kernel_prover/kernel_prover.js +39 -7
  30. package/dest/kernel_prover/test/test_circuit_prover.d.ts +1 -0
  31. package/dest/kernel_prover/test/test_circuit_prover.d.ts.map +1 -1
  32. package/dest/kernel_prover/test/test_circuit_prover.js +5 -1
  33. package/dest/{note_processor/utils → note_decryption_utils}/add_public_values_to_payload.d.ts +1 -1
  34. package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +1 -0
  35. package/dest/{note_processor/utils → note_decryption_utils}/add_public_values_to_payload.js +1 -1
  36. package/dest/note_decryption_utils/brute_force_note_info.d.ts.map +1 -0
  37. package/dest/{note_processor/utils → note_decryption_utils}/brute_force_note_info.js +1 -1
  38. package/dest/note_decryption_utils/index.d.ts.map +1 -0
  39. package/dest/{note_processor/utils → note_decryption_utils}/index.js +1 -1
  40. package/dest/{note_processor/utils → note_decryption_utils}/produce_note_daos.d.ts +6 -9
  41. package/dest/note_decryption_utils/produce_note_daos.d.ts.map +1 -0
  42. package/dest/note_decryption_utils/produce_note_daos.js +47 -0
  43. package/dest/note_decryption_utils/produce_note_daos_for_key.d.ts +8 -0
  44. package/dest/note_decryption_utils/produce_note_daos_for_key.d.ts.map +1 -0
  45. package/dest/note_decryption_utils/produce_note_daos_for_key.js +17 -0
  46. package/dest/pxe_http/pxe_http_server.d.ts +1 -2
  47. package/dest/pxe_http/pxe_http_server.d.ts.map +1 -1
  48. package/dest/pxe_http/pxe_http_server.js +5 -49
  49. package/dest/pxe_service/create_pxe_service.d.ts.map +1 -1
  50. package/dest/pxe_service/create_pxe_service.js +7 -4
  51. package/dest/pxe_service/error_enriching.d.ts.map +1 -1
  52. package/dest/pxe_service/error_enriching.js +7 -6
  53. package/dest/pxe_service/pxe_service.d.ts +13 -19
  54. package/dest/pxe_service/pxe_service.d.ts.map +1 -1
  55. package/dest/pxe_service/pxe_service.js +79 -79
  56. package/dest/pxe_service/test/pxe_test_suite.d.ts.map +1 -1
  57. package/dest/pxe_service/test/pxe_test_suite.js +5 -34
  58. package/dest/simulator_oracle/index.d.ts +32 -10
  59. package/dest/simulator_oracle/index.d.ts.map +1 -1
  60. package/dest/simulator_oracle/index.js +223 -30
  61. package/dest/synchronizer/synchronizer.d.ts +0 -48
  62. package/dest/synchronizer/synchronizer.d.ts.map +1 -1
  63. package/dest/synchronizer/synchronizer.js +3 -201
  64. package/package.json +16 -14
  65. package/src/config/index.ts +4 -7
  66. package/src/contract_data_oracle/index.ts +5 -0
  67. package/src/database/incoming_note_dao.ts +5 -5
  68. package/src/database/kv_pxe_database.ts +95 -106
  69. package/src/database/outgoing_note_dao.ts +3 -3
  70. package/src/database/pxe_database.ts +47 -22
  71. package/src/database/pxe_database_test_suite.ts +12 -20
  72. package/src/index.ts +1 -1
  73. package/src/kernel_prover/hints/build_private_kernel_reset_private_inputs.ts +13 -3
  74. package/src/kernel_prover/kernel_prover.ts +49 -5
  75. package/src/kernel_prover/test/test_circuit_prover.ts +8 -4
  76. package/src/{note_processor/utils → note_decryption_utils}/add_public_values_to_payload.ts +1 -1
  77. package/src/{note_processor/utils → note_decryption_utils}/produce_note_daos.ts +12 -22
  78. package/src/{note_processor/utils → note_decryption_utils}/produce_note_daos_for_key.ts +6 -15
  79. package/src/pxe_http/pxe_http_server.ts +5 -81
  80. package/src/pxe_service/create_pxe_service.ts +9 -3
  81. package/src/pxe_service/error_enriching.ts +12 -5
  82. package/src/pxe_service/pxe_service.ts +102 -113
  83. package/src/pxe_service/test/pxe_test_suite.ts +7 -55
  84. package/src/simulator_oracle/index.ts +322 -23
  85. package/src/synchronizer/synchronizer.ts +3 -253
  86. package/dest/database/deferred_note_dao.d.ts +0 -40
  87. package/dest/database/deferred_note_dao.d.ts.map +0 -1
  88. package/dest/database/deferred_note_dao.js +0 -38
  89. package/dest/note_processor/index.d.ts +0 -2
  90. package/dest/note_processor/index.d.ts.map +0 -1
  91. package/dest/note_processor/index.js +0 -2
  92. package/dest/note_processor/note_processor.d.ts +0 -83
  93. package/dest/note_processor/note_processor.d.ts.map +0 -1
  94. package/dest/note_processor/note_processor.js +0 -230
  95. package/dest/note_processor/utils/add_public_values_to_payload.d.ts.map +0 -1
  96. package/dest/note_processor/utils/brute_force_note_info.d.ts.map +0 -1
  97. package/dest/note_processor/utils/index.d.ts.map +0 -1
  98. package/dest/note_processor/utils/produce_note_daos.d.ts.map +0 -1
  99. package/dest/note_processor/utils/produce_note_daos.js +0 -51
  100. package/dest/note_processor/utils/produce_note_daos_for_key.d.ts +0 -9
  101. package/dest/note_processor/utils/produce_note_daos_for_key.d.ts.map +0 -1
  102. package/dest/note_processor/utils/produce_note_daos_for_key.js +0 -26
  103. package/src/database/deferred_note_dao.ts +0 -47
  104. package/src/note_processor/index.ts +0 -1
  105. package/src/note_processor/note_processor.ts +0 -355
  106. /package/dest/{note_processor/utils → note_decryption_utils}/brute_force_note_info.d.ts +0 -0
  107. /package/dest/{note_processor/utils → note_decryption_utils}/index.d.ts +0 -0
  108. /package/src/{note_processor/utils → note_decryption_utils}/brute_force_note_info.ts +0 -0
  109. /package/src/{note_processor/utils → note_decryption_utils}/index.ts +0 -0
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  type AuthWitness,
3
3
  type AztecNode,
4
- type EventMetadata,
5
- EventType,
4
+ EventMetadata,
5
+ type EventMetadataDefinition,
6
6
  type ExtendedNote,
7
7
  type FunctionCall,
8
8
  type GetUnencryptedLogsResponse,
@@ -31,7 +31,6 @@ import {
31
31
  UniqueNote,
32
32
  getNonNullifiedL1ToL2MessageWitness,
33
33
  } from '@aztec/circuit-types';
34
- import { type NoteProcessorStats } from '@aztec/circuit-types/stats';
35
34
  import {
36
35
  type AztecAddress,
37
36
  type CompleteAddress,
@@ -44,6 +43,7 @@ import {
44
43
  computeAddressSecret,
45
44
  computeContractAddressFromInstance,
46
45
  computeContractClassId,
46
+ computePoint,
47
47
  getContractClassFromArtifact,
48
48
  } from '@aztec/circuits.js';
49
49
  import { computeNoteHashNonce, siloNullifier } from '@aztec/circuits.js/hash';
@@ -89,8 +89,6 @@ export class PXEService implements PXE {
89
89
  // ensures that state is not changed while simulating
90
90
  private jobQueue = new SerialQueue();
91
91
 
92
- private fakeProofCreator = new TestPrivateKernelProver();
93
-
94
92
  constructor(
95
93
  private keyStore: KeyStore,
96
94
  private node: AztecNode,
@@ -116,34 +114,11 @@ export class PXEService implements PXE {
116
114
  public async start() {
117
115
  const { l2BlockPollingIntervalMS } = this.config;
118
116
  await this.synchronizer.start(1, l2BlockPollingIntervalMS);
119
- await this.restoreNoteProcessors();
120
117
  await this.#registerProtocolContracts();
121
118
  const info = await this.getNodeInfo();
122
119
  this.log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.protocolVersion}`);
123
120
  }
124
121
 
125
- private async restoreNoteProcessors() {
126
- const accounts = await this.keyStore.getAccounts();
127
- const publicKeys = accounts.map(async account => await this.keyStore.getMasterIncomingViewingPublicKey(account));
128
- const publicKeysSet = new Set(publicKeys.map(k => k.toString()));
129
-
130
- const registeredAddresses = await this.db.getCompleteAddresses();
131
-
132
- let count = 0;
133
- for (const address of registeredAddresses) {
134
- if (!publicKeysSet.has(address.publicKeys.masterIncomingViewingPublicKey.toString())) {
135
- continue;
136
- }
137
-
138
- count++;
139
- this.synchronizer.addAccount(address, this.keyStore, this.config.l2StartingBlock);
140
- }
141
-
142
- if (count > 0) {
143
- this.log.info(`Restored ${count} accounts`);
144
- }
145
- }
146
-
147
122
  /**
148
123
  * Stops the PXE Service, halting processing of new transactions and shutting down the synchronizer.
149
124
  * This function ensures that all ongoing tasks are completed before stopping the server.
@@ -195,7 +170,6 @@ export class PXEService implements PXE {
195
170
  this.log.info(`Account:\n "${accountCompleteAddress.address.toString()}"\n already registered.`);
196
171
  return accountCompleteAddress;
197
172
  } else {
198
- this.synchronizer.addAccount(accountCompleteAddress, this.keyStore, this.config.l2StartingBlock);
199
173
  this.log.info(`Registered account ${accountCompleteAddress.address.toString()}`);
200
174
  this.log.debug(`Registered account\n ${accountCompleteAddress.toReadableString()}`);
201
175
  }
@@ -204,47 +178,56 @@ export class PXEService implements PXE {
204
178
  return accountCompleteAddress;
205
179
  }
206
180
 
207
- public async getRegisteredAccounts(): Promise<CompleteAddress[]> {
208
- // Get complete addresses of both the recipients and the accounts
209
- const completeAddresses = await this.db.getCompleteAddresses();
210
- // Filter out the addresses not corresponding to accounts
181
+ public async registerContact(address: AztecAddress): Promise<AztecAddress> {
211
182
  const accounts = await this.keyStore.getAccounts();
212
- return completeAddresses.filter(completeAddress =>
213
- accounts.find(address => address.equals(completeAddress.address)),
214
- );
183
+ if (accounts.includes(address)) {
184
+ this.log.info(`Account:\n "${address.toString()}"\n already registered.`);
185
+ return address;
186
+ }
187
+
188
+ const wasAdded = await this.db.addContactAddress(address);
189
+
190
+ if (wasAdded) {
191
+ this.log.info(`Added contact:\n ${address.toString()}`);
192
+ } else {
193
+ this.log.info(`Contact:\n "${address.toString()}"\n already registered.`);
194
+ }
195
+
196
+ return address;
215
197
  }
216
198
 
217
- public async getRegisteredAccount(address: AztecAddress): Promise<CompleteAddress | undefined> {
218
- const result = await this.getRegisteredAccounts();
219
- const account = result.find(r => r.address.equals(address));
220
- return Promise.resolve(account);
199
+ public getContacts(): Promise<AztecAddress[]> {
200
+ const contacts = this.db.getContactAddresses();
201
+
202
+ return Promise.resolve(contacts);
221
203
  }
222
204
 
223
- public async registerRecipient(recipient: CompleteAddress): Promise<void> {
224
- const wasAdded = await this.db.addCompleteAddress(recipient);
205
+ public async removeContact(address: AztecAddress): Promise<void> {
206
+ const wasRemoved = await this.db.removeContactAddress(address);
225
207
 
226
- if (wasAdded) {
227
- this.log.info(`Added recipient:\n ${recipient.toReadableString()}`);
208
+ if (wasRemoved) {
209
+ this.log.info(`Removed contact:\n ${address.toString()}`);
228
210
  } else {
229
- this.log.info(`Recipient:\n "${recipient.toReadableString()}"\n already registered.`);
211
+ this.log.info(`Contact:\n "${address.toString()}"\n not in address book.`);
230
212
  }
213
+
214
+ return Promise.resolve();
231
215
  }
232
216
 
233
- public async getRecipients(): Promise<CompleteAddress[]> {
217
+ public async getRegisteredAccounts(): Promise<CompleteAddress[]> {
234
218
  // Get complete addresses of both the recipients and the accounts
235
219
  const completeAddresses = await this.db.getCompleteAddresses();
236
- // Filter out the addresses corresponding to accounts
220
+ // Filter out the addresses not corresponding to accounts
237
221
  const accounts = await this.keyStore.getAccounts();
238
- const recipients = completeAddresses.filter(
239
- completeAddress => !accounts.find(account => account.equals(completeAddress.address)),
222
+ return completeAddresses.filter(completeAddress =>
223
+ accounts.find(address => address.equals(completeAddress.address)),
240
224
  );
241
- return recipients;
242
225
  }
243
226
 
244
- public async getRecipient(address: AztecAddress): Promise<CompleteAddress | undefined> {
245
- const result = await this.getRecipients();
246
- const recipient = result.find(r => r.address.equals(address));
247
- return Promise.resolve(recipient);
227
+ public async getRegisteredAccount(address: AztecAddress): Promise<CompleteAddress | undefined> {
228
+ const result = await this.getRegisteredAccounts();
229
+ const account = result.find(r => r.address.equals(address));
230
+ return Promise.resolve(account);
248
231
  }
249
232
 
250
233
  public async registerContractClass(artifact: ContractArtifact): Promise<void> {
@@ -286,7 +269,6 @@ export class PXEService implements PXE {
286
269
 
287
270
  this.log.info(`Added contract ${artifact.name} at ${instance.address.toString()}`);
288
271
  await this.db.addContractInstance(instance);
289
- await this.synchronizer.reprocessDeferredNotesForContract(instance.address);
290
272
  }
291
273
 
292
274
  public getContracts(): Promise<AztecAddress[]> {
@@ -306,11 +288,11 @@ export class PXEService implements PXE {
306
288
  const extendedNotes = noteDaos.map(async dao => {
307
289
  let owner = filter.owner;
308
290
  if (owner === undefined) {
309
- const completeAddresses = (await this.db.getCompleteAddresses()).find(address =>
310
- address.publicKeys.masterIncomingViewingPublicKey.equals(dao.ivpkM),
291
+ const completeAddresses = (await this.db.getCompleteAddresses()).find(completeAddress =>
292
+ computePoint(completeAddress.address).equals(dao.addressPoint),
311
293
  );
312
294
  if (completeAddresses === undefined) {
313
- throw new Error(`Cannot find complete address for IvpkM ${dao.ivpkM.toString()}`);
295
+ throw new Error(`Cannot find complete address for addressPoint ${dao.addressPoint.toString()}`);
314
296
  }
315
297
  owner = completeAddresses.address;
316
298
  }
@@ -383,13 +365,15 @@ export class PXEService implements PXE {
383
365
  note.note,
384
366
  );
385
367
 
386
- const index = await this.node.findLeafIndex('latest', MerkleTreeId.NOTE_HASH_TREE, siloedNoteHash);
368
+ const [index] = await this.node.findLeavesIndexes('latest', MerkleTreeId.NOTE_HASH_TREE, [siloedNoteHash]);
387
369
  if (index === undefined) {
388
370
  throw new Error('Note does not exist.');
389
371
  }
390
372
 
391
373
  const siloedNullifier = siloNullifier(note.contractAddress, innerNullifier!);
392
- const nullifierIndex = await this.node.findLeafIndex('latest', MerkleTreeId.NULLIFIER_TREE, siloedNullifier);
374
+ const [nullifierIndex] = await this.node.findLeavesIndexes('latest', MerkleTreeId.NULLIFIER_TREE, [
375
+ siloedNullifier,
376
+ ]);
393
377
  if (nullifierIndex !== undefined) {
394
378
  throw new Error('The note has been destroyed.');
395
379
  }
@@ -405,7 +389,7 @@ export class PXEService implements PXE {
405
389
  noteHash,
406
390
  siloedNullifier,
407
391
  index,
408
- owner.publicKeys.masterIncomingViewingPublicKey,
392
+ computePoint(owner.address),
409
393
  ),
410
394
  scope,
411
395
  );
@@ -413,11 +397,6 @@ export class PXEService implements PXE {
413
397
  }
414
398
 
415
399
  public async addNullifiedNote(note: ExtendedNote) {
416
- const owner = await this.db.getCompleteAddress(note.owner);
417
- if (!owner) {
418
- throw new Error(`Unknown account: ${note.owner.toString()}`);
419
- }
420
-
421
400
  const nonces = await this.#getNoteNonces(note);
422
401
  if (nonces.length === 0) {
423
402
  throw new Error(`Cannot find the note in tx: ${note.txHash}.`);
@@ -437,7 +416,7 @@ export class PXEService implements PXE {
437
416
  throw new Error('Unexpectedly received non-zero nullifier.');
438
417
  }
439
418
 
440
- const index = await this.node.findLeafIndex('latest', MerkleTreeId.NOTE_HASH_TREE, siloedNoteHash);
419
+ const [index] = await this.node.findLeavesIndexes('latest', MerkleTreeId.NOTE_HASH_TREE, [siloedNoteHash]);
441
420
  if (index === undefined) {
442
421
  throw new Error('Note does not exist.');
443
422
  }
@@ -453,7 +432,7 @@ export class PXEService implements PXE {
453
432
  noteHash,
454
433
  Fr.ZERO, // We are not able to derive
455
434
  index,
456
- owner.publicKeys.masterIncomingViewingPublicKey,
435
+ computePoint(note.owner),
457
436
  ),
458
437
  );
459
438
  }
@@ -529,11 +508,24 @@ export class PXEService implements PXE {
529
508
  simulatePublic: boolean,
530
509
  msgSender: AztecAddress | undefined = undefined,
531
510
  skipTxValidation: boolean = false,
511
+ profile: boolean = false,
532
512
  scopes?: AztecAddress[],
533
513
  ): Promise<TxSimulationResult> {
534
514
  return await this.jobQueue.put(async () => {
535
515
  const privateExecutionResult = await this.#executePrivate(txRequest, msgSender, scopes);
536
- const publicInputs = await this.#simulateKernels(txRequest, privateExecutionResult);
516
+
517
+ let publicInputs: PrivateKernelTailCircuitPublicInputs;
518
+ let profileResult;
519
+ if (profile) {
520
+ ({ publicInputs, profileResult } = await this.#profileKernelProver(
521
+ txRequest,
522
+ this.proofCreator,
523
+ privateExecutionResult,
524
+ ));
525
+ } else {
526
+ publicInputs = await this.#simulateKernels(txRequest, privateExecutionResult);
527
+ }
528
+
537
529
  const privateSimulationResult = new PrivateSimulationResult(privateExecutionResult, publicInputs);
538
530
  const simulatedTx = privateSimulationResult.toSimulatedTx();
539
531
  let publicOutput: PublicSimulationOutput | undefined;
@@ -554,7 +546,11 @@ export class PXEService implements PXE {
554
546
  if (!msgSender) {
555
547
  this.log.info(`Executed local simulation for ${simulatedTx.getTxHash()}`);
556
548
  }
557
- return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(privateSimulationResult, publicOutput);
549
+ return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(
550
+ privateSimulationResult,
551
+ publicOutput,
552
+ profileResult,
553
+ );
558
554
  });
559
555
  }
560
556
 
@@ -612,6 +608,15 @@ export class PXEService implements PXE {
612
608
  return this.node.getUnencryptedLogs(filter);
613
609
  }
614
610
 
611
+ /**
612
+ * Gets contract class logs based on the provided filter.
613
+ * @param filter - The filter to apply to the logs.
614
+ * @returns The requested logs.
615
+ */
616
+ public getContractClassLogs(filter: LogFilter): Promise<GetUnencryptedLogsResponse> {
617
+ return this.node.getContractClassLogs(filter);
618
+ }
619
+
615
620
  async #getFunctionCall(functionName: string, args: any[], to: AztecAddress): Promise<FunctionCall> {
616
621
  const contract = await this.db.getContract(to);
617
622
  if (!contract) {
@@ -676,7 +681,6 @@ export class PXEService implements PXE {
676
681
  const { address, contractClass, instance, artifact } = getCanonicalProtocolContract(name);
677
682
  await this.db.addContractArtifact(contractClass.id, artifact);
678
683
  await this.db.addContractInstance(instance);
679
- await this.synchronizer.reprocessDeferredNotesForContract(address);
680
684
  this.log.info(`Added protocol contract ${name} at ${address.toString()}`);
681
685
  }
682
686
  }
@@ -759,18 +763,36 @@ export class PXEService implements PXE {
759
763
  * @param tx - The transaction to be simulated.
760
764
  */
761
765
  async #simulatePublicCalls(tx: Tx) {
766
+ // Simulating public calls can throw if the TX fails in a phase that doesn't allow reverts (setup)
767
+ // Or return as reverted if it fails in a phase that allows reverts (app logic, teardown)
762
768
  try {
763
- return await this.node.simulatePublicCalls(tx);
769
+ const result = await this.node.simulatePublicCalls(tx);
770
+ if (result.revertReason) {
771
+ throw result.revertReason;
772
+ }
773
+ return result;
764
774
  } catch (err) {
765
- // Try to fill in the noir call stack since the PXE may have access to the debug metadata
766
775
  if (err instanceof SimulationError) {
767
776
  await enrichPublicSimulationError(err, this.contractDataOracle, this.db, this.log);
768
777
  }
769
-
770
778
  throw err;
771
779
  }
772
780
  }
773
781
 
782
+ async #profileKernelProver(
783
+ txExecutionRequest: TxExecutionRequest,
784
+ proofCreator: PrivateKernelProver,
785
+ privateExecutionResult: PrivateExecutionResult,
786
+ ): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>> {
787
+ const block = privateExecutionResult.publicInputs.historicalHeader.globalVariables.blockNumber.toNumber();
788
+ const kernelOracle = new KernelOracle(this.contractDataOracle, this.keyStore, this.node, block);
789
+ const kernelProver = new KernelProver(kernelOracle, proofCreator);
790
+
791
+ // Dry run the prover with profiler enabled
792
+ const result = await kernelProver.prove(txExecutionRequest.toTxRequest(), privateExecutionResult, true, true);
793
+ return result;
794
+ }
795
+
774
796
  /**
775
797
  * Simulate a transaction, generate a kernel proof, and create a private transaction object.
776
798
  * The function takes in a transaction request, simulates it, and then generates a kernel proof
@@ -803,18 +825,10 @@ export class PXEService implements PXE {
803
825
  return await this.synchronizer.isGlobalStateSynchronized();
804
826
  }
805
827
 
806
- public async isAccountStateSynchronized(account: AztecAddress) {
807
- return await this.synchronizer.isAccountStateSynchronized(account);
808
- }
809
-
810
828
  public getSyncStatus() {
811
829
  return Promise.resolve(this.synchronizer.getSyncStatus());
812
830
  }
813
831
 
814
- public getSyncStats(): Promise<{ [address: string]: NoteProcessorStats }> {
815
- return Promise.resolve(this.synchronizer.getSyncStats());
816
- }
817
-
818
832
  public async isContractClassPubliclyRegistered(id: Fr): Promise<boolean> {
819
833
  return !!(await this.node.getContractClass(id));
820
834
  }
@@ -824,44 +838,18 @@ export class PXEService implements PXE {
824
838
  }
825
839
 
826
840
  public async isContractInitialized(address: AztecAddress): Promise<boolean> {
827
- const initNullifier = siloNullifier(address, address);
841
+ const initNullifier = siloNullifier(address, address.toField());
828
842
  return !!(await this.node.getNullifierMembershipWitness('latest', initNullifier));
829
843
  }
830
844
 
831
- public getEvents<T>(
832
- type: EventType.Encrypted,
833
- eventMetadata: EventMetadata<T>,
834
- from: number,
835
- limit: number,
836
- vpks: Point[],
837
- ): Promise<T[]>;
838
- public getEvents<T>(
839
- type: EventType.Unencrypted,
840
- eventMetadata: EventMetadata<T>,
841
- from: number,
842
- limit: number,
843
- ): Promise<T[]>;
844
- public getEvents<T>(
845
- type: EventType,
846
- eventMetadata: EventMetadata<T>,
847
- from: number,
848
- limit: number,
849
- vpks: Point[] = [],
850
- ): Promise<T[]> {
851
- if (type.includes(EventType.Encrypted)) {
852
- return this.getEncryptedEvents(from, limit, eventMetadata, vpks);
853
- }
854
-
855
- return this.getUnencryptedEvents(from, limit, eventMetadata);
856
- }
857
-
858
- async getEncryptedEvents<T>(
845
+ public async getEncryptedEvents<T>(
846
+ eventMetadataDef: EventMetadataDefinition,
859
847
  from: number,
860
848
  limit: number,
861
- eventMetadata: EventMetadata<T>,
862
849
  // TODO (#9272): Make this better, we should be able to only pass an address now
863
850
  vpks: Point[],
864
851
  ): Promise<T[]> {
852
+ const eventMetadata = new EventMetadata<T>(eventMetadataDef);
865
853
  if (vpks.length === 0) {
866
854
  throw new Error('Tried to get encrypted events without supplying any viewing public keys');
867
855
  }
@@ -925,7 +913,8 @@ export class PXEService implements PXE {
925
913
  return decodedEvents;
926
914
  }
927
915
 
928
- async getUnencryptedEvents<T>(from: number, limit: number, eventMetadata: EventMetadata<T>): Promise<T[]> {
916
+ async getUnencryptedEvents<T>(eventMetadataDef: EventMetadataDefinition, from: number, limit: number): Promise<T[]> {
917
+ const eventMetadata = new EventMetadata<T>(eventMetadataDef);
929
918
  const { logs: unencryptedLogs } = await this.node.getUnencryptedLogs({
930
919
  fromBlock: from,
931
920
  toBlock: from + limit,
@@ -4,15 +4,9 @@ import {
4
4
  randomContractInstanceWithAddress,
5
5
  randomDeployedContract,
6
6
  } from '@aztec/circuit-types';
7
- import {
8
- AztecAddress,
9
- CompleteAddress,
10
- Fr,
11
- INITIAL_L2_BLOCK_NUM,
12
- Point,
13
- PublicKeys,
14
- getContractClassFromArtifact,
15
- } from '@aztec/circuits.js';
7
+ import { AztecAddress, Fr, INITIAL_L2_BLOCK_NUM, getContractClassFromArtifact } from '@aztec/circuits.js';
8
+
9
+ import omit from 'lodash.omit';
16
10
 
17
11
  export const pxeTestSuite = (testName: string, pxeSetup: () => Promise<PXE>) => {
18
12
  describe(testName, () => {
@@ -29,33 +23,11 @@ export const pxeTestSuite = (testName: string, pxeSetup: () => Promise<PXE>) =>
29
23
 
30
24
  // Check that the account is correctly registered using the getAccounts and getRecipients methods
31
25
  const accounts = await pxe.getRegisteredAccounts();
32
- const recipients = await pxe.getRecipients();
33
26
  expect(accounts).toContainEqual(completeAddress);
34
- expect(recipients).not.toContainEqual(completeAddress);
35
27
 
36
28
  // Check that the account is correctly registered using the getAccount and getRecipient methods
37
29
  const account = await pxe.getRegisteredAccount(completeAddress.address);
38
- const recipient = await pxe.getRecipient(completeAddress.address);
39
30
  expect(account).toEqual(completeAddress);
40
- expect(recipient).toBeUndefined();
41
- });
42
-
43
- it('registers a recipient and returns it as a recipient only and not as an account', async () => {
44
- const completeAddress = CompleteAddress.random();
45
-
46
- await pxe.registerRecipient(completeAddress);
47
-
48
- // Check that the recipient is correctly registered using the getAccounts and getRecipients methods
49
- const accounts = await pxe.getRegisteredAccounts();
50
- const recipients = await pxe.getRecipients();
51
- expect(accounts).not.toContainEqual(completeAddress);
52
- expect(recipients).toContainEqual(completeAddress);
53
-
54
- // Check that the recipient is correctly registered using the getAccount and getRecipient methods
55
- const account = await pxe.getRegisteredAccount(completeAddress.address);
56
- const recipient = await pxe.getRecipient(completeAddress.address);
57
- expect(account).toBeUndefined();
58
- expect(recipient).toEqual(completeAddress);
59
31
  });
60
32
 
61
33
  it('does not throw when registering the same account twice (just ignores the second attempt)', async () => {
@@ -66,28 +38,6 @@ export const pxeTestSuite = (testName: string, pxeSetup: () => Promise<PXE>) =>
66
38
  await pxe.registerAccount(randomSecretKey, randomPartialAddress);
67
39
  });
68
40
 
69
- // Disabled as CompleteAddress constructor now performs preimage validation.
70
- it.skip('cannot register a recipient with the same aztec address but different pub key or partial address', async () => {
71
- const recipient1 = CompleteAddress.random();
72
- const recipient2 = new CompleteAddress(
73
- recipient1.address,
74
- new PublicKeys(Point.random(), Point.random(), Point.random(), Point.random()),
75
- Fr.random(),
76
- );
77
-
78
- await pxe.registerRecipient(recipient1);
79
- await expect(() => pxe.registerRecipient(recipient2)).rejects.toThrow(
80
- `Complete address with aztec address ${recipient1.address}`,
81
- );
82
- });
83
-
84
- it('does not throw when registering the same recipient twice (just ignores the second attempt)', async () => {
85
- const completeAddress = CompleteAddress.random();
86
-
87
- await pxe.registerRecipient(completeAddress);
88
- await pxe.registerRecipient(completeAddress);
89
- });
90
-
91
41
  it('successfully adds a contract', async () => {
92
42
  const contracts = [randomDeployedContract(), randomDeployedContract()];
93
43
  for (const contract of contracts) {
@@ -106,7 +56,9 @@ export const pxeTestSuite = (testName: string, pxeSetup: () => Promise<PXE>) =>
106
56
  const instance = randomContractInstanceWithAddress({ contractClassId });
107
57
 
108
58
  await pxe.registerContractClass(artifact);
109
- expect(await pxe.getContractClass(contractClassId)).toEqual(contractClass);
59
+ expect(await pxe.getContractClass(contractClassId)).toMatchObject(
60
+ omit(contractClass, 'privateFunctionsRoot', 'publicBytecodeCommitment'),
61
+ );
110
62
 
111
63
  await pxe.registerContract({ instance });
112
64
  expect(await pxe.getContractInstance(instance.address)).toEqual(instance);
@@ -121,7 +73,7 @@ export const pxeTestSuite = (testName: string, pxeSetup: () => Promise<PXE>) =>
121
73
  pxe.registerContract({
122
74
  instance: {
123
75
  ...instance,
124
- address: Fr.random(),
76
+ address: AztecAddress.random(),
125
77
  },
126
78
  artifact,
127
79
  }),