@aztec/pxe 0.0.1-commit.cd76b27 → 0.0.1-commit.d1cd2107c

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 (105) hide show
  1. package/dest/config/index.d.ts +2 -2
  2. package/dest/config/index.d.ts.map +1 -1
  3. package/dest/config/index.js +1 -1
  4. package/dest/contract_function_simulator/contract_function_simulator.d.ts +1 -1
  5. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  6. package/dest/contract_function_simulator/contract_function_simulator.js +9 -9
  7. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
  8. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  9. package/dest/contract_function_simulator/execution_tagging_index_cache.js +3 -3
  10. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
  11. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +1 -1
  12. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
  13. package/dest/contract_function_simulator/oracle/interfaces.d.ts +49 -45
  14. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  15. package/dest/contract_function_simulator/oracle/oracle.d.ts +44 -44
  16. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/oracle/oracle.js +132 -89
  18. package/dest/contract_function_simulator/oracle/private_execution.js +1 -1
  19. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +20 -20
  20. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  21. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +38 -46
  22. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +36 -34
  23. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  24. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +46 -48
  25. package/dest/contract_logging.d.ts +22 -0
  26. package/dest/contract_logging.d.ts.map +1 -0
  27. package/dest/contract_logging.js +23 -0
  28. package/dest/entrypoints/client/bundle/index.d.ts +2 -1
  29. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  30. package/dest/entrypoints/client/bundle/index.js +1 -0
  31. package/dest/entrypoints/client/lazy/index.d.ts +2 -1
  32. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  33. package/dest/entrypoints/client/lazy/index.js +1 -0
  34. package/dest/logs/log_service.d.ts +1 -1
  35. package/dest/logs/log_service.d.ts.map +1 -1
  36. package/dest/logs/log_service.js +4 -4
  37. package/dest/oracle_version.d.ts +2 -2
  38. package/dest/oracle_version.js +3 -3
  39. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
  40. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  41. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +125 -64
  42. package/dest/private_kernel/hints/test_utils.d.ts +122 -0
  43. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
  44. package/dest/private_kernel/hints/test_utils.js +203 -0
  45. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  46. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  47. package/dest/private_kernel/private_kernel_execution_prover.js +13 -5
  48. package/dest/private_kernel/private_kernel_oracle.d.ts +6 -2
  49. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  50. package/dest/private_kernel/private_kernel_oracle.js +7 -3
  51. package/dest/pxe.d.ts +3 -2
  52. package/dest/pxe.d.ts.map +1 -1
  53. package/dest/pxe.js +24 -16
  54. package/dest/storage/contract_store/contract_store.d.ts +42 -15
  55. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  56. package/dest/storage/contract_store/contract_store.js +140 -64
  57. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
  58. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  59. package/dest/storage/tagging_store/sender_tagging_store.d.ts +5 -5
  60. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  61. package/dest/storage/tagging_store/sender_tagging_store.js +4 -4
  62. package/dest/tagging/index.d.ts +2 -2
  63. package/dest/tagging/index.d.ts.map +1 -1
  64. package/dest/tagging/index.js +1 -1
  65. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -5
  66. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  67. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +3 -3
  68. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -7
  69. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  70. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +12 -11
  71. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -8
  72. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  73. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +3 -6
  74. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +4 -7
  75. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  76. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +14 -15
  77. package/package.json +16 -16
  78. package/src/config/index.ts +1 -1
  79. package/src/contract_function_simulator/contract_function_simulator.ts +15 -16
  80. package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -5
  81. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
  82. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
  83. package/src/contract_function_simulator/oracle/interfaces.ts +47 -44
  84. package/src/contract_function_simulator/oracle/oracle.ts +135 -107
  85. package/src/contract_function_simulator/oracle/private_execution.ts +1 -1
  86. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +42 -48
  87. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +51 -57
  88. package/src/contract_logging.ts +39 -0
  89. package/src/entrypoints/client/bundle/index.ts +1 -0
  90. package/src/entrypoints/client/lazy/index.ts +1 -0
  91. package/src/logs/log_service.ts +10 -5
  92. package/src/oracle_version.ts +3 -3
  93. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +157 -110
  94. package/src/private_kernel/hints/test_utils.ts +325 -0
  95. package/src/private_kernel/private_kernel_execution_prover.ts +13 -6
  96. package/src/private_kernel/private_kernel_oracle.ts +7 -7
  97. package/src/pxe.ts +23 -16
  98. package/src/storage/contract_store/contract_store.ts +170 -71
  99. package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
  100. package/src/storage/tagging_store/sender_tagging_store.ts +8 -8
  101. package/src/tagging/index.ts +1 -1
  102. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +3 -6
  103. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
  104. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +4 -9
  105. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +11 -20
@@ -14,7 +14,7 @@ import {
14
14
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
15
15
  import { siloNullifier } from '@aztec/stdlib/hash';
16
16
  import { PrivateContextInputs } from '@aztec/stdlib/kernel';
17
- import { type ContractClassLog, DirectionalAppTaggingSecret, type PreTag } from '@aztec/stdlib/logs';
17
+ import { type ContractClassLog, ExtendedDirectionalAppTaggingSecret, type PreTag } from '@aztec/stdlib/logs';
18
18
  import { Tag } from '@aztec/stdlib/logs';
19
19
  import { Note, type NoteStatus } from '@aztec/stdlib/note';
20
20
  import {
@@ -189,7 +189,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
189
189
  * The value persists through nested calls, meaning all calls down the stack will use the same
190
190
  * 'senderForTags' value (unless it is replaced).
191
191
  */
192
- public privateGetSenderForTags(): Promise<AztecAddress | undefined> {
192
+ public getSenderForTags(): Promise<AztecAddress | undefined> {
193
193
  return Promise.resolve(this.senderForTags);
194
194
  }
195
195
 
@@ -204,7 +204,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
204
204
  * through nested calls, meaning all calls down the stack will use the same 'senderForTags'
205
205
  * value (unless it is replaced by another call to this setter).
206
206
  */
207
- public privateSetSenderForTags(senderForTags: AztecAddress): Promise<void> {
207
+ public setSenderForTags(senderForTags: AztecAddress): Promise<void> {
208
208
  this.senderForTags = senderForTags;
209
209
  return Promise.resolve();
210
210
  }
@@ -215,26 +215,30 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
215
215
  * @param recipient - The address receiving the log
216
216
  * @returns An app tag to be used in a log.
217
217
  */
218
- public async privateGetNextAppTagAsSender(sender: AztecAddress, recipient: AztecAddress): Promise<Tag> {
219
- const secret = await this.#calculateDirectionalAppTaggingSecret(this.contractAddress, sender, recipient);
218
+ public async getNextAppTagAsSender(sender: AztecAddress, recipient: AztecAddress): Promise<Tag> {
219
+ const extendedSecret = await this.#calculateExtendedDirectionalAppTaggingSecret(
220
+ this.contractAddress,
221
+ sender,
222
+ recipient,
223
+ );
220
224
 
221
- const index = await this.#getIndexToUseForSecret(secret);
222
- this.log.debug(
225
+ const index = await this.#getIndexToUseForSecret(extendedSecret);
226
+ this.logger.debug(
223
227
  `Incrementing tagging index for sender: ${sender}, recipient: ${recipient}, contract: ${this.contractAddress} to ${index}`,
224
228
  );
225
- this.taggingIndexCache.setLastUsedIndex(secret, index);
229
+ this.taggingIndexCache.setLastUsedIndex(extendedSecret, index);
226
230
 
227
- return Tag.compute({ secret, index });
231
+ return Tag.compute({ extendedSecret, index });
228
232
  }
229
233
 
230
- async #calculateDirectionalAppTaggingSecret(
234
+ async #calculateExtendedDirectionalAppTaggingSecret(
231
235
  contractAddress: AztecAddress,
232
236
  sender: AztecAddress,
233
237
  recipient: AztecAddress,
234
238
  ) {
235
239
  const senderCompleteAddress = await this.getCompleteAddressOrFail(sender);
236
240
  const senderIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(sender);
237
- return DirectionalAppTaggingSecret.compute(
241
+ return ExtendedDirectionalAppTaggingSecret.compute(
238
242
  senderCompleteAddress,
239
243
  senderIvsk,
240
244
  recipient,
@@ -243,7 +247,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
243
247
  );
244
248
  }
245
249
 
246
- async #getIndexToUseForSecret(secret: DirectionalAppTaggingSecret): Promise<number> {
250
+ async #getIndexToUseForSecret(secret: ExtendedDirectionalAppTaggingSecret): Promise<number> {
247
251
  // If we have the tagging index in the cache, we use it. If not we obtain it from the execution data provider.
248
252
  const lastUsedIndexInTx = this.taggingIndexCache.getLastUsedIndex(secret);
249
253
 
@@ -255,7 +259,6 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
255
259
  // that'd be wasteful as most tagging secrets are not used in each tx.
256
260
  await syncSenderTaggingIndexes(
257
261
  secret,
258
- this.contractAddress,
259
262
  this.aztecNode,
260
263
  this.senderTaggingStore,
261
264
  await this.anchorBlockHeader.hash(),
@@ -274,7 +277,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
274
277
  * @param values - Values to store.
275
278
  * @returns The hash of the values.
276
279
  */
277
- public privateStoreInExecutionCache(values: Fr[], hash: Fr) {
280
+ public storeInExecutionCache(values: Fr[], hash: Fr) {
278
281
  return this.executionCache.store(values, hash);
279
282
  }
280
283
 
@@ -283,7 +286,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
283
286
  * @param hash - Hash of the values.
284
287
  * @returns The values.
285
288
  */
286
- public privateLoadFromExecutionCache(hash: Fr): Promise<Fr[]> {
289
+ public loadFromExecutionCache(hash: Fr): Promise<Fr[]> {
287
290
  const preimage = this.executionCache.getPreimage(hash);
288
291
  if (!preimage) {
289
292
  throw new Error(`Preimage for hash ${hash.toString()} not found in cache`);
@@ -291,12 +294,12 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
291
294
  return Promise.resolve(preimage);
292
295
  }
293
296
 
294
- override async utilityCheckNullifierExists(innerNullifier: Fr): Promise<boolean> {
297
+ override async checkNullifierExists(innerNullifier: Fr): Promise<boolean> {
295
298
  // This oracle must be overridden because while utility execution can only meaningfully check if a nullifier exists
296
299
  // in the synched block, during private execution there's also the possibility of it being pending, i.e. created
297
300
  // in the current transaction.
298
301
 
299
- this.log.debug(`Checking existence of inner nullifier ${innerNullifier}`, {
302
+ this.logger.debug(`Checking existence of inner nullifier ${innerNullifier}`, {
300
303
  contractAddress: this.contractAddress,
301
304
  });
302
305
 
@@ -304,7 +307,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
304
307
 
305
308
  return (
306
309
  this.noteCache.getNullifiers(this.contractAddress).has(nullifier) ||
307
- (await super.utilityCheckNullifierExists(innerNullifier))
310
+ (await super.checkNullifierExists(innerNullifier))
308
311
  );
309
312
  }
310
313
 
@@ -329,7 +332,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
329
332
  * @param status - The status of notes to fetch.
330
333
  * @returns Array of note data.
331
334
  */
332
- public override async utilityGetNotes(
335
+ public override async getNotes(
333
336
  owner: AztecAddress | undefined,
334
337
  storageSlot: Fr,
335
338
  numSelects: number,
@@ -375,7 +378,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
375
378
  offset,
376
379
  });
377
380
 
378
- this.log.debug(
381
+ this.logger.debug(
379
382
  `Returning ${notes.length} notes for ${this.callContext.contractAddress} at ${storageSlot}: ${notes
380
383
  .map(n => `${n.noteNonce.toString()}:[${n.note.items.map(i => i.toString()).join(',')}]`)
381
384
  .join(', ')}`,
@@ -395,7 +398,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
395
398
  * @param noteHash - A hash of the new note.
396
399
  * @returns
397
400
  */
398
- public privateNotifyCreatedNote(
401
+ public notifyCreatedNote(
399
402
  owner: AztecAddress,
400
403
  storageSlot: Fr,
401
404
  randomness: Fr,
@@ -404,7 +407,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
404
407
  noteHash: Fr,
405
408
  counter: number,
406
409
  ) {
407
- this.log.debug(`Notified of new note with inner hash ${noteHash}`, {
410
+ this.logger.debug(`Notified of new note with inner hash ${noteHash}`, {
408
411
  contractAddress: this.callContext.contractAddress,
409
412
  storageSlot,
410
413
  randomness,
@@ -436,7 +439,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
436
439
  * @param innerNullifier - The pending nullifier to add in the list (not yet siloed by contract address).
437
440
  * @param noteHash - A hash of the new note.
438
441
  */
439
- public async privateNotifyNullifiedNote(innerNullifier: Fr, noteHash: Fr, counter: number) {
442
+ public async notifyNullifiedNote(innerNullifier: Fr, noteHash: Fr, counter: number) {
440
443
  const nullifiedNoteHashCounter = await this.noteCache.nullifyNote(
441
444
  this.callContext.contractAddress,
442
445
  innerNullifier,
@@ -453,19 +456,19 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
453
456
  * @param innerNullifier - The pending nullifier to add in the list (not yet siloed by contract address).
454
457
  * @param noteHash - A hash of the new note.
455
458
  */
456
- public privateNotifyCreatedNullifier(innerNullifier: Fr) {
457
- this.log.debug(`Notified of new inner nullifier ${innerNullifier}`, { contractAddress: this.contractAddress });
459
+ public notifyCreatedNullifier(innerNullifier: Fr) {
460
+ this.logger.debug(`Notified of new inner nullifier ${innerNullifier}`, { contractAddress: this.contractAddress });
458
461
  return this.noteCache.nullifierCreated(this.callContext.contractAddress, innerNullifier);
459
462
  }
460
463
 
461
464
  /**
462
- * Check if a nullifier has been emitted in the same transaction, i.e. if privateNotifyCreatedNullifier has been
465
+ * Check if a nullifier has been emitted in the same transaction, i.e. if notifyCreatedNullifier has been
463
466
  * called for this inner nullifier from the contract with the specified address.
464
467
  * @param innerNullifier - The inner nullifier to check.
465
468
  * @param contractAddress - Address of the contract that emitted the nullifier.
466
469
  * @returns A boolean indicating whether the nullifier is pending or not.
467
470
  */
468
- public async privateIsNullifierPending(innerNullifier: Fr, contractAddress: AztecAddress): Promise<boolean> {
471
+ public async isNullifierPending(innerNullifier: Fr, contractAddress: AztecAddress): Promise<boolean> {
469
472
  const siloedNullifier = await siloNullifier(contractAddress, innerNullifier);
470
473
  const isNullifierPending = this.noteCache.getNullifiers(contractAddress).has(siloedNullifier.toBigInt());
471
474
  return Promise.resolve(isNullifierPending);
@@ -478,10 +481,10 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
478
481
  * @param log - The contract class log to be emitted.
479
482
  * @param counter - The contract class log's counter.
480
483
  */
481
- public privateNotifyCreatedContractClassLog(log: ContractClassLog, counter: number) {
484
+ public notifyCreatedContractClassLog(log: ContractClassLog, counter: number) {
482
485
  this.contractClassLogs.push(new CountedContractClassLog(log, counter));
483
486
  const text = log.toBuffer().toString('hex');
484
- this.log.verbose(
487
+ this.logger.verbose(
485
488
  `Emitted log from ContractClassRegistry: "${text.length > 100 ? text.slice(0, 100) + '...' : text}"`,
486
489
  );
487
490
  }
@@ -507,7 +510,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
507
510
  * @param isStaticCall - Whether the call is a static call.
508
511
  * @returns The execution result.
509
512
  */
510
- async privateCallPrivateFunction(
513
+ async callPrivateFunction(
511
514
  targetContractAddress: AztecAddress,
512
515
  functionSelector: FunctionSelector,
513
516
  argsHash: Fr,
@@ -521,28 +524,19 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
521
524
  }
522
525
 
523
526
  const simulatorSetupTimer = new Timer();
524
- this.log.debug(
527
+ this.logger.debug(
525
528
  `Calling private function ${targetContractAddress}:${functionSelector} from ${this.callContext.contractAddress}`,
526
529
  );
527
530
 
528
531
  isStaticCall = isStaticCall || this.callContext.isStaticCall;
529
532
 
530
- // When scopes are set and the target contract is a registered account (has keys in the keyStore),
531
- // expand scopes to include it so nested private calls can sync and read the contract's own notes.
532
- // We only expand for registered accounts because the log service needs the recipient's keys to derive
533
- // tagging secrets, which are only available for registered accounts.
534
- const expandedScopes =
535
- this.scopes !== 'ALL_SCOPES' && (await this.keyStore.hasAccount(targetContractAddress))
536
- ? [...this.scopes, targetContractAddress]
537
- : this.scopes;
538
-
539
533
  await this.contractSyncService.ensureContractSynced(
540
534
  targetContractAddress,
541
535
  functionSelector,
542
536
  this.utilityExecutor,
543
537
  this.anchorBlockHeader,
544
538
  this.jobId,
545
- expandedScopes,
539
+ this.scopes,
546
540
  );
547
541
 
548
542
  const targetArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(
@@ -579,8 +573,8 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
579
573
  jobId: this.jobId,
580
574
  totalPublicCalldataCount: this.totalPublicCalldataCount,
581
575
  sideEffectCounter,
582
- log: this.log,
583
- scopes: expandedScopes,
576
+ log: this.logger,
577
+ scopes: this.scopes,
584
578
  senderForTags: this.senderForTags,
585
579
  simulator: this.simulator!,
586
580
  });
@@ -633,7 +627,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
633
627
  * @param sideEffectCounter - The side effect counter at the start of the call.
634
628
  * @param isStaticCall - Whether the call is a static call.
635
629
  */
636
- public privateNotifyEnqueuedPublicFunctionCall(
630
+ public notifyEnqueuedPublicFunctionCall(
637
631
  _targetContractAddress: AztecAddress,
638
632
  calldataHash: Fr,
639
633
  _sideEffectCounter: number,
@@ -650,7 +644,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
650
644
  * @param sideEffectCounter - The side effect counter at the start of the call.
651
645
  * @param isStaticCall - Whether the call is a static call.
652
646
  */
653
- public privateNotifySetPublicTeardownFunctionCall(
647
+ public notifySetPublicTeardownFunctionCall(
654
648
  _targetContractAddress: AztecAddress,
655
649
  calldataHash: Fr,
656
650
  _sideEffectCounter: number,
@@ -660,11 +654,11 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
660
654
  return Promise.resolve();
661
655
  }
662
656
 
663
- public privateNotifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: number): Promise<void> {
657
+ public notifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: number): Promise<void> {
664
658
  return this.noteCache.setMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter);
665
659
  }
666
660
 
667
- public privateIsSideEffectCounterRevertible(sideEffectCounter: number): Promise<boolean> {
661
+ public isSideEffectCounterRevertible(sideEffectCounter: number): Promise<boolean> {
668
662
  return Promise.resolve(this.noteCache.isSideEffectCounterRevertible(sideEffectCounter));
669
663
  }
670
664
 
@@ -692,7 +686,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
692
686
  return this.contractStore.getDebugFunctionName(this.contractAddress, this.callContext.functionSelector);
693
687
  }
694
688
 
695
- public utilityEmitOffchainEffect(data: Fr[]): Promise<void> {
689
+ public emitOffchainEffect(data: Fr[]): Promise<void> {
696
690
  this.offchainEffects.push({ data });
697
691
  return Promise.resolve();
698
692
  }
@@ -3,17 +3,17 @@ import type { BlockNumber } from '@aztec/foundation/branded-types';
3
3
  import { Aes128 } from '@aztec/foundation/crypto/aes128';
4
4
  import { Fr } from '@aztec/foundation/curves/bn254';
5
5
  import { Point } from '@aztec/foundation/curves/grumpkin';
6
- import { LogLevels, type Logger, applyStringFormatting, createLogger } from '@aztec/foundation/log';
6
+ import { LogLevels, type Logger, createLogger } from '@aztec/foundation/log';
7
7
  import type { MembershipWitness } from '@aztec/foundation/trees';
8
8
  import type { KeyStore } from '@aztec/key-store';
9
9
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
10
10
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
11
11
  import { BlockHash } from '@aztec/stdlib/block';
12
- import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
12
+ import type { CompleteAddress, ContractInstance, PartialAddress } from '@aztec/stdlib/contract';
13
13
  import { siloNullifier } from '@aztec/stdlib/hash';
14
14
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
15
15
  import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
16
- import { computeAddressSecret } from '@aztec/stdlib/keys';
16
+ import { type PublicKeys, computeAddressSecret } from '@aztec/stdlib/keys';
17
17
  import { deriveEcdhSharedSecret } from '@aztec/stdlib/logs';
18
18
  import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
19
19
  import type { NoteStatus } from '@aztec/stdlib/note';
@@ -21,6 +21,7 @@ import { MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from
21
21
  import type { BlockHeader, Capsule } from '@aztec/stdlib/tx';
22
22
 
23
23
  import type { AccessScopes } from '../../access_scopes.js';
24
+ import { createContractLogger, logContractMessage } from '../../contract_logging.js';
24
25
  import { EventService } from '../../events/event_service.js';
25
26
  import { LogService } from '../../logs/log_service.js';
26
27
  import { NoteService } from '../../notes/note_service.js';
@@ -85,7 +86,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
85
86
  protected readonly capsuleStore: CapsuleStore;
86
87
  protected readonly privateEventStore: PrivateEventStore;
87
88
  protected readonly jobId: string;
88
- protected log: ReturnType<typeof createLogger>;
89
+ protected logger: ReturnType<typeof createLogger>;
89
90
  protected readonly scopes: AccessScopes;
90
91
 
91
92
  constructor(args: UtilityExecutionOracleArgs) {
@@ -103,21 +104,21 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
103
104
  this.capsuleStore = args.capsuleStore;
104
105
  this.privateEventStore = args.privateEventStore;
105
106
  this.jobId = args.jobId;
106
- this.log = args.log ?? createLogger('simulator:client_view_context');
107
+ this.logger = args.log ?? createLogger('simulator:client_view_context');
107
108
  this.scopes = args.scopes;
108
109
  }
109
110
 
110
- public utilityAssertCompatibleOracleVersion(version: number): void {
111
+ public assertCompatibleOracleVersion(version: number): void {
111
112
  if (version !== ORACLE_VERSION) {
112
113
  throw new Error(`Incompatible oracle version. Expected version ${ORACLE_VERSION}, got ${version}.`);
113
114
  }
114
115
  }
115
116
 
116
- public utilityGetRandomField(): Fr {
117
+ public getRandomField(): Fr {
117
118
  return Fr.random();
118
119
  }
119
120
 
120
- public utilityGetUtilityContext(): UtilityContext {
121
+ public getUtilityContext(): UtilityContext {
121
122
  return new UtilityContext(this.anchorBlockHeader, this.contractAddress);
122
123
  }
123
124
 
@@ -128,7 +129,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
128
129
  * @throws If the keys are not registered in the key store.
129
130
  * @throws If scopes are defined and the account is not in the scopes.
130
131
  */
131
- public async utilityGetKeyValidationRequest(pkMHash: Fr): Promise<KeyValidationRequest> {
132
+ public async getKeyValidationRequest(pkMHash: Fr): Promise<KeyValidationRequest> {
132
133
  // If scopes are defined, check that the key belongs to an account in the scopes.
133
134
  if (this.scopes !== 'ALL_SCOPES' && this.scopes.length > 0) {
134
135
  let hasAccess = false;
@@ -151,7 +152,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
151
152
  * @param noteHash - The note hash to find in the note hash tree.
152
153
  * @returns The membership witness containing the leaf index and sibling path
153
154
  */
154
- public utilityGetNoteHashMembershipWitness(
155
+ public getNoteHashMembershipWitness(
155
156
  anchorBlockHash: BlockHash,
156
157
  noteHash: Fr,
157
158
  ): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
@@ -169,7 +170,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
169
170
  * @param blockHash - The block hash to find in the archive tree.
170
171
  * @returns The membership witness containing the leaf index and sibling path
171
172
  */
172
- public utilityGetBlockHashMembershipWitness(
173
+ public getBlockHashMembershipWitness(
173
174
  anchorBlockHash: BlockHash,
174
175
  blockHash: BlockHash,
175
176
  ): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined> {
@@ -182,7 +183,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
182
183
  * @param nullifier - Nullifier we try to find witness for.
183
184
  * @returns The nullifier membership witness (if found).
184
185
  */
185
- public utilityGetNullifierMembershipWitness(
186
+ public getNullifierMembershipWitness(
186
187
  blockHash: BlockHash,
187
188
  nullifier: Fr,
188
189
  ): Promise<NullifierMembershipWitness | undefined> {
@@ -198,7 +199,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
198
199
  * list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
199
200
  * we are trying to prove non-inclusion for.
200
201
  */
201
- public utilityGetLowNullifierMembershipWitness(
202
+ public getLowNullifierMembershipWitness(
202
203
  blockHash: BlockHash,
203
204
  nullifier: Fr,
204
205
  ): Promise<NullifierMembershipWitness | undefined> {
@@ -211,7 +212,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
211
212
  * @param leafSlot - The slot of the public data tree to get the witness for.
212
213
  * @returns - The witness
213
214
  */
214
- public utilityGetPublicDataWitness(blockHash: BlockHash, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
215
+ public getPublicDataWitness(blockHash: BlockHash, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
215
216
  return this.aztecNode.getPublicDataWitness(blockHash, leafSlot);
216
217
  }
217
218
 
@@ -220,7 +221,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
220
221
  * @param blockNumber - The number of a block of which to get the block header.
221
222
  * @returns Block extracted from a block with block number `blockNumber`.
222
223
  */
223
- public async utilityGetBlockHeader(blockNumber: BlockNumber): Promise<BlockHeader | undefined> {
224
+ public async getBlockHeader(blockNumber: BlockNumber): Promise<BlockHeader | undefined> {
224
225
  const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
225
226
  if (blockNumber > anchorBlockNumber) {
226
227
  throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
@@ -231,12 +232,18 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
231
232
  }
232
233
 
233
234
  /**
234
- * Retrieve the complete address associated to a given address.
235
+ * Retrieve the public keys and partial address associated to a given address.
235
236
  * @param account - The account address.
236
- * @returns A complete address associated with the input address, or `undefined` if not registered.
237
+ * @returns The public keys and partial address, or `undefined` if the account is not registered.
237
238
  */
238
- public utilityTryGetPublicKeysAndPartialAddress(account: AztecAddress): Promise<CompleteAddress | undefined> {
239
- return this.addressStore.getCompleteAddress(account);
239
+ public async tryGetPublicKeysAndPartialAddress(
240
+ account: AztecAddress,
241
+ ): Promise<{ publicKeys: PublicKeys; partialAddress: PartialAddress } | undefined> {
242
+ const completeAddress = await this.addressStore.getCompleteAddress(account);
243
+ if (!completeAddress) {
244
+ return undefined;
245
+ }
246
+ return { publicKeys: completeAddress.publicKeys, partialAddress: completeAddress.partialAddress };
240
247
  }
241
248
 
242
249
  protected async getCompleteAddressOrFail(account: AztecAddress): Promise<CompleteAddress> {
@@ -255,11 +262,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
255
262
  * @param address - Address.
256
263
  * @returns A contract instance.
257
264
  */
258
- public utilityGetContractInstance(address: AztecAddress): Promise<ContractInstance> {
259
- return this.getContractInstance(address);
260
- }
261
-
262
- protected async getContractInstance(address: AztecAddress): Promise<ContractInstance> {
265
+ public async getContractInstance(address: AztecAddress): Promise<ContractInstance> {
263
266
  const instance = await this.contractStore.getContractInstance(address);
264
267
  if (!instance) {
265
268
  throw new Error(`No contract instance found for address ${address.toString()}`);
@@ -273,7 +276,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
273
276
  * @param messageHash - Hash of the message to authenticate.
274
277
  * @returns Authentication witness for the requested message hash.
275
278
  */
276
- public utilityGetAuthWitness(messageHash: Fr): Promise<Fr[] | undefined> {
279
+ public getAuthWitness(messageHash: Fr): Promise<Fr[] | undefined> {
277
280
  return Promise.resolve(this.authWitnesses.find(w => w.requestHash.equals(messageHash))?.witness);
278
281
  }
279
282
 
@@ -299,7 +302,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
299
302
  * @param status - The status of notes to fetch.
300
303
  * @returns Array of note data.
301
304
  */
302
- public async utilityGetNotes(
305
+ public async getNotes(
303
306
  owner: AztecAddress | undefined,
304
307
  storageSlot: Fr,
305
308
  numSelects: number,
@@ -339,7 +342,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
339
342
  * @param innerNullifier - The inner nullifier.
340
343
  * @returns A boolean indicating whether the nullifier exists in the tree or not.
341
344
  */
342
- public async utilityCheckNullifierExists(innerNullifier: Fr) {
345
+ public async checkNullifierExists(innerNullifier: Fr) {
343
346
  const [nullifier, anchorBlockHash] = await Promise.all([
344
347
  siloNullifier(this.contractAddress, innerNullifier!),
345
348
  this.anchorBlockHeader.hash(),
@@ -358,7 +361,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
358
361
  * @dev Contract address and secret are only used to compute the nullifier to get non-nullified messages
359
362
  * @returns The l1 to l2 membership witness (index of message in the tree and sibling path).
360
363
  */
361
- public async utilityGetL1ToL2MembershipWitness(contractAddress: AztecAddress, messageHash: Fr, secret: Fr) {
364
+ public async getL1ToL2MembershipWitness(contractAddress: AztecAddress, messageHash: Fr, secret: Fr) {
362
365
  const [messageIndex, siblingPath] = await getNonNullifiedL1ToL2MessageWitness(
363
366
  this.aztecNode,
364
367
  contractAddress,
@@ -376,7 +379,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
376
379
  * @param startStorageSlot - The starting storage slot.
377
380
  * @param numberOfElements - Number of elements to read from the starting storage slot.
378
381
  */
379
- public async utilityStorageRead(
382
+ public async storageRead(
380
383
  blockHash: BlockHash,
381
384
  contractAddress: AztecAddress,
382
385
  startStorageSlot: Fr,
@@ -390,7 +393,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
390
393
  slots.map(storageSlot => this.aztecNode.getPublicStorageAt(blockHash, contractAddress, storageSlot)),
391
394
  );
392
395
 
393
- this.log.debug(
396
+ this.logger.debug(
394
397
  `Oracle storage read: slots=[${slots.map(slot => slot.toString()).join(', ')}] address=${contractAddress.toString()} values=[${values.join(', ')}]`,
395
398
  );
396
399
 
@@ -402,26 +405,26 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
402
405
  */
403
406
  async #getContractLogger(): Promise<Logger> {
404
407
  if (!this.contractLogger) {
405
- const addrAbbrev = this.contractAddress.toString().slice(0, 10);
406
- const name = await this.contractStore.getDebugContractName(this.contractAddress);
407
- const module = name ? `contract_log::${name}(${addrAbbrev})` : `contract_log::${addrAbbrev}`;
408
408
  // Purpose of instanceId is to distinguish logs from different instances of the same component. It makes sense
409
409
  // to re-use jobId as instanceId here as executions of different PXE jobs are isolated.
410
- this.contractLogger = createLogger(module, { instanceId: this.jobId });
410
+ this.contractLogger = await createContractLogger(
411
+ this.contractAddress,
412
+ addr => this.contractStore.getDebugContractName(addr),
413
+ { instanceId: this.jobId },
414
+ );
411
415
  }
412
416
  return this.contractLogger;
413
417
  }
414
418
 
415
- public async utilityLog(level: number, message: string, fields: Fr[]): Promise<void> {
419
+ public async log(level: number, message: string, fields: Fr[]): Promise<void> {
416
420
  if (!LogLevels[level]) {
417
421
  throw new Error(`Invalid log level: ${level}`);
418
422
  }
419
- const levelName = LogLevels[level];
420
423
  const logger = await this.#getContractLogger();
421
- logger[levelName](`${applyStringFormatting(message, fields)}`);
424
+ logContractMessage(logger, LogLevels[level], message, fields);
422
425
  }
423
426
 
424
- public async utilityFetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr) {
427
+ public async fetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr) {
425
428
  const logService = new LogService(
426
429
  this.aztecNode,
427
430
  this.anchorBlockHeader,
@@ -431,7 +434,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
431
434
  this.senderAddressBookStore,
432
435
  this.addressStore,
433
436
  this.jobId,
434
- this.log.getBindings(),
437
+ this.logger.getBindings(),
435
438
  );
436
439
 
437
440
  await logService.fetchTaggedLogs(this.contractAddress, pendingTaggedLogArrayBaseSlot, this.scopes);
@@ -447,7 +450,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
447
450
  * @param noteValidationRequestsArrayBaseSlot - The base slot of capsule array containing note validation requests.
448
451
  * @param eventValidationRequestsArrayBaseSlot - The base slot of capsule array containing event validation requests.
449
452
  */
450
- public async utilityValidateAndStoreEnqueuedNotesAndEvents(
453
+ public async validateAndStoreEnqueuedNotesAndEvents(
451
454
  contractAddress: AztecAddress,
452
455
  noteValidationRequestsArrayBaseSlot: Fr,
453
456
  eventValidationRequestsArrayBaseSlot: Fr,
@@ -503,7 +506,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
503
506
  await this.capsuleStore.setCapsuleArray(contractAddress, eventValidationRequestsArrayBaseSlot, [], this.jobId);
504
507
  }
505
508
 
506
- public async utilityBulkRetrieveLogs(
509
+ public async bulkRetrieveLogs(
507
510
  contractAddress: AztecAddress,
508
511
  logRetrievalRequestsArrayBaseSlot: Fr,
509
512
  logRetrievalResponsesArrayBaseSlot: Fr,
@@ -528,7 +531,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
528
531
  this.senderAddressBookStore,
529
532
  this.addressStore,
530
533
  this.jobId,
531
- this.log.getBindings(),
534
+ this.logger.getBindings(),
532
535
  );
533
536
 
534
537
  const maybeLogRetrievalResponses = await logService.bulkRetrieveLogs(logRetrievalRequests);
@@ -545,7 +548,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
545
548
  );
546
549
  }
547
550
 
548
- public utilityStoreCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
551
+ public storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
549
552
  if (!contractAddress.equals(this.contractAddress)) {
550
553
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
551
554
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
@@ -554,7 +557,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
554
557
  return Promise.resolve();
555
558
  }
556
559
 
557
- public async utilityLoadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
560
+ public async loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
558
561
  if (!contractAddress.equals(this.contractAddress)) {
559
562
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
560
563
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
@@ -566,7 +569,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
566
569
  );
567
570
  }
568
571
 
569
- public utilityDeleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void> {
572
+ public deleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void> {
570
573
  if (!contractAddress.equals(this.contractAddress)) {
571
574
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
572
575
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
@@ -575,12 +578,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
575
578
  return Promise.resolve();
576
579
  }
577
580
 
578
- public utilityCopyCapsule(
579
- contractAddress: AztecAddress,
580
- srcSlot: Fr,
581
- dstSlot: Fr,
582
- numEntries: number,
583
- ): Promise<void> {
581
+ public copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number): Promise<void> {
584
582
  if (!contractAddress.equals(this.contractAddress)) {
585
583
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
586
584
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
@@ -589,7 +587,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
589
587
  }
590
588
 
591
589
  // TODO(#11849): consider replacing this oracle with a pure Noir implementation of aes decryption.
592
- public utilityAes128Decrypt(ciphertext: Buffer, iv: Buffer, symKey: Buffer): Promise<Buffer> {
590
+ public aes128Decrypt(ciphertext: Buffer, iv: Buffer, symKey: Buffer): Promise<Buffer> {
593
591
  const aes128 = new Aes128();
594
592
  return aes128.decryptBufferCBC(ciphertext, iv, symKey);
595
593
  }
@@ -600,11 +598,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
600
598
  * @param ephPk - The ephemeral public key to get the secret for.
601
599
  * @returns The secret for the given address.
602
600
  */
603
- public utilityGetSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point> {
604
- return this.getSharedSecret(address, ephPk);
605
- }
606
-
607
- protected async getSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point> {
601
+ public async getSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point> {
608
602
  // TODO(#12656): return an app-siloed secret
609
603
  const recipientCompleteAddress = await this.getCompleteAddressOrFail(address);
610
604
  const ivskM = await this.keyStore.getMasterSecretKey(