@aztec/pxe 0.66.0 → 0.67.1-devnet

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 (100) 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 +4 -4
  25. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +2 -2
  26. package/dest/kernel_prover/index.d.ts +1 -0
  27. package/dest/kernel_prover/index.d.ts.map +1 -1
  28. package/dest/kernel_prover/index.js +2 -1
  29. package/dest/kernel_prover/kernel_prover.d.ts +1 -0
  30. package/dest/kernel_prover/kernel_prover.d.ts.map +1 -1
  31. package/dest/kernel_prover/kernel_prover.js +42 -5
  32. package/dest/kernel_prover/test/test_circuit_prover.d.ts +1 -2
  33. package/dest/kernel_prover/test/test_circuit_prover.d.ts.map +1 -1
  34. package/dest/kernel_prover/test/test_circuit_prover.js +7 -13
  35. package/dest/note_decryption_utils/add_public_values_to_payload.js +2 -2
  36. package/dest/note_decryption_utils/brute_force_note_info.d.ts +3 -3
  37. package/dest/note_decryption_utils/brute_force_note_info.d.ts.map +1 -1
  38. package/dest/note_decryption_utils/brute_force_note_info.js +8 -8
  39. package/dest/note_decryption_utils/produce_note_daos.d.ts +3 -6
  40. package/dest/note_decryption_utils/produce_note_daos.d.ts.map +1 -1
  41. package/dest/note_decryption_utils/produce_note_daos.js +5 -19
  42. package/dest/note_decryption_utils/produce_note_daos_for_key.d.ts +1 -1
  43. package/dest/note_decryption_utils/produce_note_daos_for_key.d.ts.map +1 -1
  44. package/dest/pxe_service/error_enriching.d.ts +3 -3
  45. package/dest/pxe_service/error_enriching.d.ts.map +1 -1
  46. package/dest/pxe_service/error_enriching.js +10 -10
  47. package/dest/pxe_service/index.d.ts +0 -1
  48. package/dest/pxe_service/index.d.ts.map +1 -1
  49. package/dest/pxe_service/index.js +1 -2
  50. package/dest/pxe_service/pxe_service.d.ts +2 -16
  51. package/dest/pxe_service/pxe_service.d.ts.map +1 -1
  52. package/dest/pxe_service/pxe_service.js +74 -96
  53. package/dest/pxe_service/test/pxe_test_suite.d.ts.map +1 -1
  54. package/dest/pxe_service/test/pxe_test_suite.js +1 -3
  55. package/dest/simulator/index.d.ts +1 -1
  56. package/dest/simulator/index.d.ts.map +1 -1
  57. package/dest/simulator/index.js +2 -2
  58. package/dest/simulator_oracle/index.d.ts +14 -11
  59. package/dest/simulator_oracle/index.d.ts.map +1 -1
  60. package/dest/simulator_oracle/index.js +170 -140
  61. package/dest/simulator_oracle/tagging_utils.d.ts +15 -0
  62. package/dest/simulator_oracle/tagging_utils.d.ts.map +1 -0
  63. package/dest/simulator_oracle/tagging_utils.js +23 -0
  64. package/dest/synchronizer/synchronizer.d.ts +10 -40
  65. package/dest/synchronizer/synchronizer.d.ts.map +1 -1
  66. package/dest/synchronizer/synchronizer.js +35 -69
  67. package/dest/{pxe_service → utils}/create_pxe_service.d.ts +1 -1
  68. package/dest/utils/create_pxe_service.d.ts.map +1 -0
  69. package/dest/utils/create_pxe_service.js +52 -0
  70. package/package.json +31 -19
  71. package/src/bin/index.ts +4 -5
  72. package/src/config/index.ts +0 -21
  73. package/src/config/package_info.ts +3 -0
  74. package/src/contract_data_oracle/index.ts +1 -1
  75. package/src/database/incoming_note_dao.ts +2 -2
  76. package/src/database/kv_pxe_database.ts +214 -309
  77. package/src/database/outgoing_note_dao.ts +1 -1
  78. package/src/database/pxe_database.ts +7 -28
  79. package/src/database/pxe_database_test_suite.ts +20 -75
  80. package/src/index.ts +2 -0
  81. package/src/kernel_oracle/index.ts +3 -3
  82. package/src/kernel_prover/hints/build_private_kernel_reset_private_inputs.ts +1 -1
  83. package/src/kernel_prover/index.ts +2 -0
  84. package/src/kernel_prover/kernel_prover.ts +72 -3
  85. package/src/kernel_prover/test/test_circuit_prover.ts +11 -25
  86. package/src/note_decryption_utils/add_public_values_to_payload.ts +1 -1
  87. package/src/note_decryption_utils/brute_force_note_info.ts +9 -9
  88. package/src/note_decryption_utils/produce_note_daos.ts +5 -48
  89. package/src/note_decryption_utils/produce_note_daos_for_key.ts +1 -1
  90. package/src/pxe_service/error_enriching.ts +14 -12
  91. package/src/pxe_service/index.ts +0 -1
  92. package/src/pxe_service/pxe_service.ts +127 -174
  93. package/src/pxe_service/test/pxe_test_suite.ts +0 -3
  94. package/src/simulator/index.ts +1 -1
  95. package/src/simulator_oracle/index.ts +201 -188
  96. package/src/simulator_oracle/tagging_utils.ts +28 -0
  97. package/src/synchronizer/synchronizer.ts +37 -77
  98. package/src/{pxe_service → utils}/create_pxe_service.ts +16 -13
  99. package/dest/pxe_service/create_pxe_service.d.ts.map +0 -1
  100. package/dest/pxe_service/create_pxe_service.js +0 -49
@@ -12,7 +12,6 @@ import {
12
12
  type L2Block,
13
13
  type LogFilter,
14
14
  MerkleTreeId,
15
- type OutgoingNotesFilter,
16
15
  type PXE,
17
16
  type PXEInfo,
18
17
  type PrivateExecutionResult,
@@ -56,20 +55,18 @@ import {
56
55
  encodeArguments,
57
56
  } from '@aztec/foundation/abi';
58
57
  import { Fr, type Point } from '@aztec/foundation/fields';
59
- import { type DebugLogger, createDebugLogger } from '@aztec/foundation/log';
60
- import { SerialQueue } from '@aztec/foundation/queue';
58
+ import { type Logger, createLogger } from '@aztec/foundation/log';
59
+ import { Timer } from '@aztec/foundation/timer';
61
60
  import { type KeyStore } from '@aztec/key-store';
62
61
  import { type L2TipsStore } from '@aztec/kv-store/stores';
63
- import {
64
- ProtocolContractAddress,
65
- getCanonicalProtocolContract,
66
- protocolContractNames,
67
- } from '@aztec/protocol-contracts';
68
- import { type AcirSimulator } from '@aztec/simulator';
62
+ import { ProtocolContractAddress, protocolContractNames } from '@aztec/protocol-contracts';
63
+ import { getCanonicalProtocolContract } from '@aztec/protocol-contracts/bundle';
64
+ import { type AcirSimulator } from '@aztec/simulator/client';
69
65
 
70
66
  import { inspect } from 'util';
71
67
 
72
- import { type PXEServiceConfig, getPackageInfo } from '../config/index.js';
68
+ import { type PXEServiceConfig } from '../config/index.js';
69
+ import { getPackageInfo } from '../config/package_info.js';
73
70
  import { ContractDataOracle } from '../contract_data_oracle/index.js';
74
71
  import { IncomingNoteDao } from '../database/incoming_note_dao.js';
75
72
  import { type PxeDatabase } from '../database/index.js';
@@ -87,11 +84,8 @@ export class PXEService implements PXE {
87
84
  private synchronizer: Synchronizer;
88
85
  private contractDataOracle: ContractDataOracle;
89
86
  private simulator: AcirSimulator;
90
- private log: DebugLogger;
87
+ private log: Logger;
91
88
  private packageVersion: string;
92
- // serialize synchronizer and calls to proveTx.
93
- // ensures that state is not changed while simulating
94
- private jobQueue = new SerialQueue();
95
89
 
96
90
  constructor(
97
91
  private keyStore: KeyStore,
@@ -102,13 +96,11 @@ export class PXEService implements PXE {
102
96
  config: PXEServiceConfig,
103
97
  logSuffix?: string,
104
98
  ) {
105
- this.log = createDebugLogger(logSuffix ? `aztec:pxe_service_${logSuffix}` : `aztec:pxe_service`);
99
+ this.log = createLogger(logSuffix ? `pxe:service:${logSuffix}` : `pxe:service`);
106
100
  this.synchronizer = new Synchronizer(node, db, tipsStore, config, logSuffix);
107
101
  this.contractDataOracle = new ContractDataOracle(db);
108
102
  this.simulator = getAcirSimulator(db, node, keyStore, this.contractDataOracle);
109
103
  this.packageVersion = getPackageInfo().version;
110
-
111
- this.jobQueue.start();
112
104
  }
113
105
 
114
106
  /**
@@ -116,27 +108,12 @@ export class PXEService implements PXE {
116
108
  *
117
109
  * @returns A promise that resolves when the server has started successfully.
118
110
  */
119
- public async start() {
120
- await this.synchronizer.start();
111
+ public async init() {
121
112
  await this.#registerProtocolContracts();
122
113
  const info = await this.getNodeInfo();
123
114
  this.log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.protocolVersion}`);
124
115
  }
125
116
 
126
- /**
127
- * Stops the PXE Service, halting processing of new transactions and shutting down the synchronizer.
128
- * This function ensures that all ongoing tasks are completed before stopping the server.
129
- * It is useful for gracefully shutting down the server during maintenance or restarts.
130
- *
131
- * @returns A Promise resolving once the server has been stopped successfully.
132
- */
133
- public async stop() {
134
- await this.jobQueue.cancel();
135
- this.log.info('Cancelled Job Queue');
136
- await this.synchronizer.stop();
137
- this.log.info('Stopped Synchronizer');
138
- }
139
-
140
117
  isL1ToL2MessageSynced(l1ToL2Message: Fr): Promise<boolean> {
141
118
  return this.node.isL1ToL2MessageSynced(l1ToL2Message);
142
119
  }
@@ -320,33 +297,6 @@ export class PXEService implements PXE {
320
297
  return Promise.all(extendedNotes);
321
298
  }
322
299
 
323
- public async getOutgoingNotes(filter: OutgoingNotesFilter): Promise<UniqueNote[]> {
324
- const noteDaos = await this.db.getOutgoingNotes(filter);
325
-
326
- const extendedNotes = noteDaos.map(async dao => {
327
- let owner = filter.owner;
328
- if (owner === undefined) {
329
- const completeAddresses = (await this.db.getCompleteAddresses()).find(address =>
330
- address.publicKeys.masterOutgoingViewingPublicKey.equals(dao.ovpkM),
331
- );
332
- if (completeAddresses === undefined) {
333
- throw new Error(`Cannot find complete address for OvpkM ${dao.ovpkM.toString()}`);
334
- }
335
- owner = completeAddresses.address;
336
- }
337
- return new UniqueNote(
338
- dao.note,
339
- owner,
340
- dao.contractAddress,
341
- dao.storageSlot,
342
- dao.noteTypeId,
343
- dao.txHash,
344
- dao.nonce,
345
- );
346
- });
347
- return Promise.all(extendedNotes);
348
- }
349
-
350
300
  public async getL1ToL2MembershipWitness(
351
301
  contractAddress: AztecAddress,
352
302
  messageHash: Fr,
@@ -367,7 +317,7 @@ export class PXEService implements PXE {
367
317
  }
368
318
 
369
319
  for (const nonce of nonces) {
370
- const { noteHash, siloedNoteHash, innerNullifier } = await this.simulator.computeNoteHashAndOptionallyANullifier(
320
+ const { noteHash, uniqueNoteHash, innerNullifier } = await this.simulator.computeNoteHashAndOptionallyANullifier(
371
321
  note.contractAddress,
372
322
  nonce,
373
323
  note.storageSlot,
@@ -376,7 +326,7 @@ export class PXEService implements PXE {
376
326
  note.note,
377
327
  );
378
328
 
379
- const [index] = await this.node.findLeavesIndexes('latest', MerkleTreeId.NOTE_HASH_TREE, [siloedNoteHash]);
329
+ const [index] = await this.node.findLeavesIndexes('latest', MerkleTreeId.NOTE_HASH_TREE, [uniqueNoteHash]);
380
330
  if (index === undefined) {
381
331
  throw new Error('Note does not exist.');
382
332
  }
@@ -416,7 +366,7 @@ export class PXEService implements PXE {
416
366
  }
417
367
 
418
368
  for (const nonce of nonces) {
419
- const { noteHash, siloedNoteHash, innerNullifier } = await this.simulator.computeNoteHashAndOptionallyANullifier(
369
+ const { noteHash, uniqueNoteHash, innerNullifier } = await this.simulator.computeNoteHashAndOptionallyANullifier(
420
370
  note.contractAddress,
421
371
  nonce,
422
372
  note.storageSlot,
@@ -429,7 +379,7 @@ export class PXEService implements PXE {
429
379
  throw new Error('Unexpectedly received non-zero nullifier.');
430
380
  }
431
381
 
432
- const [index] = await this.node.findLeavesIndexes('latest', MerkleTreeId.NOTE_HASH_TREE, [siloedNoteHash]);
382
+ const [index] = await this.node.findLeavesIndexes('latest', MerkleTreeId.NOTE_HASH_TREE, [uniqueNoteHash]);
433
383
  if (index === undefined) {
434
384
  throw new Error('Note does not exist.');
435
385
  }
@@ -475,7 +425,7 @@ export class PXEService implements PXE {
475
425
  }
476
426
 
477
427
  const nonce = computeNoteHashNonce(firstNullifier, i);
478
- const { siloedNoteHash } = await this.simulator.computeNoteHashAndOptionallyANullifier(
428
+ const { uniqueNoteHash } = await this.simulator.computeNoteHashAndOptionallyANullifier(
479
429
  note.contractAddress,
480
430
  nonce,
481
431
  note.storageSlot,
@@ -483,7 +433,7 @@ export class PXEService implements PXE {
483
433
  false,
484
434
  note.note,
485
435
  );
486
- if (hash.equals(siloedNoteHash)) {
436
+ if (hash.equals(uniqueNoteHash)) {
487
437
  nonces.push(nonce);
488
438
  }
489
439
  }
@@ -511,22 +461,16 @@ export class PXEService implements PXE {
511
461
  return result.publicInputs;
512
462
  }
513
463
 
514
- public proveTx(
464
+ public async proveTx(
515
465
  txRequest: TxExecutionRequest,
516
466
  privateExecutionResult: PrivateExecutionResult,
517
467
  ): Promise<TxProvingResult> {
518
- return this.jobQueue
519
- .put(async () => {
520
- const { publicInputs, clientIvcProof } = await this.#prove(
521
- txRequest,
522
- this.proofCreator,
523
- privateExecutionResult,
524
- );
525
- return new TxProvingResult(privateExecutionResult, publicInputs, clientIvcProof!);
526
- })
527
- .catch(err => {
528
- throw this.contextualizeError(err, inspect(txRequest), inspect(privateExecutionResult));
529
- });
468
+ try {
469
+ const { publicInputs, clientIvcProof } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult);
470
+ return new TxProvingResult(privateExecutionResult, publicInputs, clientIvcProof!);
471
+ } catch (err: any) {
472
+ throw this.contextualizeError(err, inspect(txRequest), inspect(privateExecutionResult));
473
+ }
530
474
  }
531
475
 
532
476
  // TODO(#7456) Prevent msgSender being defined here for the first call
@@ -538,59 +482,78 @@ export class PXEService implements PXE {
538
482
  profile: boolean = false,
539
483
  scopes?: AztecAddress[],
540
484
  ): Promise<TxSimulationResult> {
541
- return await this.jobQueue
542
- .put(async () => {
543
- const privateExecutionResult = await this.#executePrivate(txRequest, msgSender, scopes);
544
-
545
- let publicInputs: PrivateKernelTailCircuitPublicInputs;
546
- let profileResult;
547
- if (profile) {
548
- ({ publicInputs, profileResult } = await this.#profileKernelProver(
549
- txRequest,
550
- this.proofCreator,
551
- privateExecutionResult,
552
- ));
553
- } else {
554
- publicInputs = await this.#simulateKernels(txRequest, privateExecutionResult);
555
- }
485
+ try {
486
+ const txInfo = {
487
+ origin: txRequest.origin,
488
+ functionSelector: txRequest.functionSelector,
489
+ simulatePublic,
490
+ msgSender,
491
+ chainId: txRequest.txContext.chainId,
492
+ version: txRequest.txContext.version,
493
+ authWitnesses: txRequest.authWitnesses.map(w => w.requestHash),
494
+ };
495
+ this.log.info(
496
+ `Simulating transaction execution request to ${txRequest.functionSelector} at ${txRequest.origin}`,
497
+ txInfo,
498
+ );
499
+ const timer = new Timer();
500
+ await this.synchronizer.sync();
501
+ const privateExecutionResult = await this.#executePrivate(txRequest, msgSender, scopes);
502
+
503
+ let publicInputs: PrivateKernelTailCircuitPublicInputs;
504
+ let profileResult;
505
+ if (profile) {
506
+ ({ publicInputs, profileResult } = await this.#profileKernelProver(
507
+ txRequest,
508
+ this.proofCreator,
509
+ privateExecutionResult,
510
+ ));
511
+ } else {
512
+ publicInputs = await this.#simulateKernels(txRequest, privateExecutionResult);
513
+ }
556
514
 
557
- const privateSimulationResult = new PrivateSimulationResult(privateExecutionResult, publicInputs);
558
- const simulatedTx = privateSimulationResult.toSimulatedTx();
559
- let publicOutput: PublicSimulationOutput | undefined;
560
- if (simulatePublic) {
561
- publicOutput = await this.#simulatePublicCalls(simulatedTx);
562
- }
515
+ const privateSimulationResult = new PrivateSimulationResult(privateExecutionResult, publicInputs);
516
+ const simulatedTx = privateSimulationResult.toSimulatedTx();
517
+ let publicOutput: PublicSimulationOutput | undefined;
518
+ if (simulatePublic) {
519
+ publicOutput = await this.#simulatePublicCalls(simulatedTx);
520
+ }
563
521
 
564
- if (!skipTxValidation) {
565
- if (!(await this.node.isValidTx(simulatedTx, true))) {
566
- throw new Error('The simulated transaction is unable to be added to state and is invalid.');
567
- }
522
+ if (!skipTxValidation) {
523
+ if (!(await this.node.isValidTx(simulatedTx, true))) {
524
+ throw new Error('The simulated transaction is unable to be added to state and is invalid.');
568
525
  }
526
+ }
569
527
 
570
- // We log only if the msgSender is undefined, as simulating with a different msgSender
571
- // is unlikely to be a real transaction, and likely to be only used to read data.
572
- // Meaning that it will not necessarily have produced a nullifier (and thus have no TxHash)
573
- // If we log, the `getTxHash` function will throw.
574
- if (!msgSender) {
575
- this.log.info(`Executed local simulation for ${simulatedTx.getTxHash()}`);
576
- }
577
- return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(
578
- privateSimulationResult,
579
- publicOutput,
580
- profileResult,
581
- );
582
- })
583
- .catch(err => {
584
- throw this.contextualizeError(
585
- err,
586
- inspect(txRequest),
587
- `simulatePublic=${simulatePublic}`,
588
- `msgSender=${msgSender?.toString() ?? 'undefined'}`,
589
- `skipTxValidation=${skipTxValidation}`,
590
- `profile=${profile}`,
591
- `scopes=${scopes?.map(s => s.toString()).join(', ') ?? 'undefined'}`,
592
- );
528
+ this.log.info(`Simulation completed for ${simulatedTx.tryGetTxHash()} in ${timer.ms()}ms`, {
529
+ txHash: simulatedTx.tryGetTxHash(),
530
+ ...txInfo,
531
+ ...(profileResult ? { gateCounts: profileResult.gateCounts } : {}),
532
+ ...(publicOutput
533
+ ? {
534
+ gasUsed: publicOutput.gasUsed,
535
+ revertCode: publicOutput.txEffect.revertCode.getCode(),
536
+ revertReason: publicOutput.revertReason,
537
+ }
538
+ : {}),
593
539
  });
540
+
541
+ return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(
542
+ privateSimulationResult,
543
+ publicOutput,
544
+ profileResult,
545
+ );
546
+ } catch (err: any) {
547
+ throw this.contextualizeError(
548
+ err,
549
+ inspect(txRequest),
550
+ `simulatePublic=${simulatePublic}`,
551
+ `msgSender=${msgSender?.toString() ?? 'undefined'}`,
552
+ `skipTxValidation=${skipTxValidation}`,
553
+ `profile=${profile}`,
554
+ `scopes=${scopes?.map(s => s.toString()).join(', ') ?? 'undefined'}`,
555
+ );
556
+ }
594
557
  }
595
558
 
596
559
  public async sendTx(tx: Tx): Promise<TxHash> {
@@ -598,7 +561,7 @@ export class PXEService implements PXE {
598
561
  if (await this.node.getTxEffect(txHash)) {
599
562
  throw new Error(`A settled tx with equal hash ${txHash.toString()} exists.`);
600
563
  }
601
- this.log.info(`Sending transaction ${txHash}`);
564
+ this.log.debug(`Sending transaction ${txHash}`);
602
565
  await this.node.sendTx(tx).catch(err => {
603
566
  throw this.contextualizeError(err, inspect(tx));
604
567
  });
@@ -613,24 +576,22 @@ export class PXEService implements PXE {
613
576
  _from?: AztecAddress,
614
577
  scopes?: AztecAddress[],
615
578
  ): Promise<AbiDecoded> {
616
- // all simulations must be serialized w.r.t. the synchronizer
617
- return await this.jobQueue
618
- .put(async () => {
619
- // TODO - Should check if `from` has the permission to call the view function.
620
- const functionCall = await this.#getFunctionCall(functionName, args, to);
621
- const executionResult = await this.#simulateUnconstrained(functionCall, scopes);
622
-
623
- // TODO - Return typed result based on the function artifact.
624
- return executionResult;
625
- })
626
- .catch(err => {
627
- const stringifiedArgs = args.map(arg => arg.toString()).join(', ');
628
- throw this.contextualizeError(
629
- err,
630
- `simulateUnconstrained ${to}:${functionName}(${stringifiedArgs})`,
631
- `scopes=${scopes?.map(s => s.toString()).join(', ') ?? 'undefined'}`,
632
- );
633
- });
579
+ try {
580
+ await this.synchronizer.sync();
581
+ // TODO - Should check if `from` has the permission to call the view function.
582
+ const functionCall = await this.#getFunctionCall(functionName, args, to);
583
+ const executionResult = await this.#simulateUnconstrained(functionCall, scopes);
584
+
585
+ // TODO - Return typed result based on the function artifact.
586
+ return executionResult;
587
+ } catch (err: any) {
588
+ const stringifiedArgs = args.map(arg => arg.toString()).join(', ');
589
+ throw this.contextualizeError(
590
+ err,
591
+ `simulateUnconstrained ${to}:${functionName}(${stringifiedArgs})`,
592
+ `scopes=${scopes?.map(s => s.toString()).join(', ') ?? 'undefined'}`,
593
+ );
594
+ }
634
595
  }
635
596
 
636
597
  public getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
@@ -727,12 +688,14 @@ export class PXEService implements PXE {
727
688
  }
728
689
 
729
690
  async #registerProtocolContracts() {
691
+ const registered: Record<string, string> = {};
730
692
  for (const name of protocolContractNames) {
731
693
  const { address, contractClass, instance, artifact } = getCanonicalProtocolContract(name);
732
694
  await this.db.addContractArtifact(contractClass.id, artifact);
733
695
  await this.db.addContractInstance(instance);
734
- this.log.info(`Added protocol contract ${name} at ${address.toString()}`);
696
+ registered[name] = address.toString();
735
697
  }
698
+ this.log.verbose(`Registered protocol contracts in pxe`, registered);
736
699
  }
737
700
 
738
701
  /**
@@ -764,13 +727,11 @@ export class PXEService implements PXE {
764
727
  scopes?: AztecAddress[],
765
728
  ): Promise<PrivateExecutionResult> {
766
729
  // TODO - Pause syncing while simulating.
767
-
768
730
  const { contractAddress, functionArtifact } = await this.#getSimulationParameters(txRequest);
769
731
 
770
- this.log.debug('Executing simulator...');
771
732
  try {
772
733
  const result = await this.simulator.run(txRequest, functionArtifact, contractAddress, msgSender, scopes);
773
- this.log.verbose(`Simulation completed for ${contractAddress.toString()}:${functionArtifact.name}`);
734
+ this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionArtifact.name}`);
774
735
  return result;
775
736
  } catch (err) {
776
737
  if (err instanceof SimulationError) {
@@ -848,19 +809,14 @@ export class PXEService implements PXE {
848
809
  }
849
810
 
850
811
  /**
851
- * Simulate a transaction, generate a kernel proof, and create a private transaction object.
852
- * The function takes in a transaction request, simulates it, and then generates a kernel proof
853
- * using the simulation result. Finally, it creates a private
854
- * transaction object with the generated proof and public inputs. If a new contract address is provided,
855
- * the function will also include the new contract's public functions in the transaction object.
812
+ * Generate a kernel proof, and create a private kernel output.
813
+ * The function takes in a transaction execution request, and the result of private execution
814
+ * and then generates a kernel proof.
856
815
  *
857
816
  * @param txExecutionRequest - The transaction request to be simulated and proved.
858
817
  * @param proofCreator - The proof creator to use for proving the execution.
859
- * @param msgSender - (Optional) The message sender to use for the simulation.
860
- * @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
861
- * @returns An object that contains:
862
- * A private transaction object containing the proof, public inputs, and encrypted logs.
863
- * The return values of the private execution
818
+ * @param privateExecutionResult - The result of the private execution
819
+ * @returns An object that contains the output of the kernel execution, including the ClientIvcProof if proving is enabled.
864
820
  */
865
821
  async #prove(
866
822
  txExecutionRequest: TxExecutionRequest,
@@ -875,14 +831,6 @@ export class PXEService implements PXE {
875
831
  return await kernelProver.prove(txExecutionRequest.toTxRequest(), privateExecutionResult);
876
832
  }
877
833
 
878
- public async isGlobalStateSynchronized() {
879
- return await this.synchronizer.isGlobalStateSynchronized();
880
- }
881
-
882
- public getSyncStatus() {
883
- return Promise.resolve(this.synchronizer.getSyncStatus());
884
- }
885
-
886
834
  public async isContractClassPubliclyRegistered(id: Fr): Promise<boolean> {
887
835
  return !!(await this.node.getContractClass(id));
888
836
  }
@@ -915,7 +863,7 @@ export class PXEService implements PXE {
915
863
 
916
864
  const vsks = await Promise.all(
917
865
  vpks.map(async vpk => {
918
- const [keyPrefix, account] = this.keyStore.getKeyPrefixAndAccount(vpk);
866
+ const [keyPrefix, account] = await this.keyStore.getKeyPrefixAndAccount(vpk);
919
867
  let secretKey = await this.keyStore.getMasterSecretKey(vpk);
920
868
  if (keyPrefix === 'iv') {
921
869
  const registeredAccount = await this.getRegisteredAccount(account);
@@ -936,7 +884,7 @@ export class PXEService implements PXE {
936
884
  for (const sk of vsks) {
937
885
  // TODO: Verify that the first field of the log is the tag siloed with contract address.
938
886
  // Or use tags to query logs, like we do with notes.
939
- const decryptedEvent = L1EventPayload.decryptAsIncoming(log, sk) ?? L1EventPayload.decryptAsOutgoing(log, sk);
887
+ const decryptedEvent = L1EventPayload.decryptAsIncoming(log, sk);
940
888
  if (decryptedEvent !== undefined) {
941
889
  return [decryptedEvent];
942
890
  }
@@ -1003,10 +951,15 @@ export class PXEService implements PXE {
1003
951
  }
1004
952
 
1005
953
  private contextualizeError(err: Error, ...context: string[]): Error {
1006
- this.log.error(err.name, err);
1007
- this.log.debug('Context:');
1008
- for (const c of context) {
1009
- this.log.debug(c);
954
+ let contextStr = '';
955
+ if (context.length > 0) {
956
+ contextStr = `\nContext:\n${context.join('\n')}`;
957
+ }
958
+ if (err instanceof SimulationError) {
959
+ err.setAztecContext(contextStr);
960
+ } else {
961
+ this.log.error(err.name, err);
962
+ this.log.debug(contextStr);
1010
963
  }
1011
964
  return err;
1012
965
  }
@@ -115,8 +115,5 @@ export const pxeTestSuite = (testName: string, pxeSetup: () => Promise<PXE>) =>
115
115
  expect(typeof nodeInfo.l1ChainId).toEqual('number');
116
116
  expect(nodeInfo.l1ContractAddresses.rollupAddress.toString()).toMatch(/0x[a-fA-F0-9]+/);
117
117
  });
118
-
119
- // Note: Not testing `isGlobalStateSynchronized`, `isAccountStateSynchronized` and `getSyncStatus` as these methods
120
- // only call synchronizer.
121
118
  });
122
119
  };
@@ -1,6 +1,6 @@
1
1
  import { type AztecNode } from '@aztec/circuit-types';
2
2
  import { type KeyStore } from '@aztec/key-store';
3
- import { AcirSimulator } from '@aztec/simulator';
3
+ import { AcirSimulator } from '@aztec/simulator/client';
4
4
 
5
5
  import { ContractDataOracle } from '../contract_data_oracle/index.js';
6
6
  import { type PxeDatabase } from '../database/pxe_database.js';