@aztec/pxe 0.0.1-commit.358457c → 0.0.1-commit.3895657bc

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 (71) 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.js +3 -3
  5. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
  6. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  7. package/dest/contract_function_simulator/execution_tagging_index_cache.js +3 -3
  8. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
  9. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +1 -1
  10. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
  11. package/dest/contract_function_simulator/oracle/interfaces.d.ts +44 -44
  12. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  13. package/dest/contract_function_simulator/oracle/oracle.d.ts +44 -44
  14. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  15. package/dest/contract_function_simulator/oracle/oracle.js +132 -89
  16. package/dest/contract_function_simulator/oracle/private_execution.js +1 -1
  17. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +20 -20
  18. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  19. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +36 -36
  20. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +29 -31
  21. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  22. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +32 -38
  23. package/dest/logs/log_service.d.ts +1 -1
  24. package/dest/logs/log_service.d.ts.map +1 -1
  25. package/dest/logs/log_service.js +4 -4
  26. package/dest/oracle_version.d.ts +2 -2
  27. package/dest/oracle_version.js +3 -3
  28. package/dest/pxe.d.ts +3 -2
  29. package/dest/pxe.d.ts.map +1 -1
  30. package/dest/pxe.js +10 -6
  31. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
  32. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  33. package/dest/storage/tagging_store/sender_tagging_store.d.ts +5 -5
  34. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  35. package/dest/storage/tagging_store/sender_tagging_store.js +4 -4
  36. package/dest/tagging/index.d.ts +2 -2
  37. package/dest/tagging/index.d.ts.map +1 -1
  38. package/dest/tagging/index.js +1 -1
  39. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -5
  40. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  41. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +3 -3
  42. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -7
  43. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  44. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +12 -11
  45. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -8
  46. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  47. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +3 -6
  48. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +4 -7
  49. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  50. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +14 -15
  51. package/package.json +16 -16
  52. package/src/config/index.ts +1 -1
  53. package/src/contract_function_simulator/contract_function_simulator.ts +3 -3
  54. package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -5
  55. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
  56. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
  57. package/src/contract_function_simulator/oracle/interfaces.ts +43 -43
  58. package/src/contract_function_simulator/oracle/oracle.ts +135 -107
  59. package/src/contract_function_simulator/oracle/private_execution.ts +1 -1
  60. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +40 -37
  61. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +32 -45
  62. package/src/logs/log_service.ts +10 -5
  63. package/src/oracle_version.ts +3 -3
  64. package/src/pxe.ts +8 -4
  65. package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
  66. package/src/storage/tagging_store/sender_tagging_store.ts +8 -8
  67. package/src/tagging/index.ts +1 -1
  68. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +3 -6
  69. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
  70. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +4 -9
  71. 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,7 +524,7 @@ 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
 
@@ -570,7 +573,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
570
573
  jobId: this.jobId,
571
574
  totalPublicCalldataCount: this.totalPublicCalldataCount,
572
575
  sideEffectCounter,
573
- log: this.log,
576
+ log: this.logger,
574
577
  scopes: this.scopes,
575
578
  senderForTags: this.senderForTags,
576
579
  simulator: this.simulator!,
@@ -624,7 +627,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
624
627
  * @param sideEffectCounter - The side effect counter at the start of the call.
625
628
  * @param isStaticCall - Whether the call is a static call.
626
629
  */
627
- public privateNotifyEnqueuedPublicFunctionCall(
630
+ public notifyEnqueuedPublicFunctionCall(
628
631
  _targetContractAddress: AztecAddress,
629
632
  calldataHash: Fr,
630
633
  _sideEffectCounter: number,
@@ -641,7 +644,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
641
644
  * @param sideEffectCounter - The side effect counter at the start of the call.
642
645
  * @param isStaticCall - Whether the call is a static call.
643
646
  */
644
- public privateNotifySetPublicTeardownFunctionCall(
647
+ public notifySetPublicTeardownFunctionCall(
645
648
  _targetContractAddress: AztecAddress,
646
649
  calldataHash: Fr,
647
650
  _sideEffectCounter: number,
@@ -651,11 +654,11 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
651
654
  return Promise.resolve();
652
655
  }
653
656
 
654
- public privateNotifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: number): Promise<void> {
657
+ public notifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: number): Promise<void> {
655
658
  return this.noteCache.setMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter);
656
659
  }
657
660
 
658
- public privateIsSideEffectCounterRevertible(sideEffectCounter: number): Promise<boolean> {
661
+ public isSideEffectCounterRevertible(sideEffectCounter: number): Promise<boolean> {
659
662
  return Promise.resolve(this.noteCache.isSideEffectCounterRevertible(sideEffectCounter));
660
663
  }
661
664
 
@@ -683,7 +686,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
683
686
  return this.contractStore.getDebugFunctionName(this.contractAddress, this.callContext.functionSelector);
684
687
  }
685
688
 
686
- public utilityEmitOffchainEffect(data: Fr[]): Promise<void> {
689
+ public emitOffchainEffect(data: Fr[]): Promise<void> {
687
690
  this.offchainEffects.push({ data });
688
691
  return Promise.resolve();
689
692
  }
@@ -86,7 +86,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
86
86
  protected readonly capsuleStore: CapsuleStore;
87
87
  protected readonly privateEventStore: PrivateEventStore;
88
88
  protected readonly jobId: string;
89
- protected log: ReturnType<typeof createLogger>;
89
+ protected logger: ReturnType<typeof createLogger>;
90
90
  protected readonly scopes: AccessScopes;
91
91
 
92
92
  constructor(args: UtilityExecutionOracleArgs) {
@@ -104,21 +104,21 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
104
104
  this.capsuleStore = args.capsuleStore;
105
105
  this.privateEventStore = args.privateEventStore;
106
106
  this.jobId = args.jobId;
107
- this.log = args.log ?? createLogger('simulator:client_view_context');
107
+ this.logger = args.log ?? createLogger('simulator:client_view_context');
108
108
  this.scopes = args.scopes;
109
109
  }
110
110
 
111
- public utilityAssertCompatibleOracleVersion(version: number): void {
111
+ public assertCompatibleOracleVersion(version: number): void {
112
112
  if (version !== ORACLE_VERSION) {
113
113
  throw new Error(`Incompatible oracle version. Expected version ${ORACLE_VERSION}, got ${version}.`);
114
114
  }
115
115
  }
116
116
 
117
- public utilityGetRandomField(): Fr {
117
+ public getRandomField(): Fr {
118
118
  return Fr.random();
119
119
  }
120
120
 
121
- public utilityGetUtilityContext(): UtilityContext {
121
+ public getUtilityContext(): UtilityContext {
122
122
  return new UtilityContext(this.anchorBlockHeader, this.contractAddress);
123
123
  }
124
124
 
@@ -129,7 +129,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
129
129
  * @throws If the keys are not registered in the key store.
130
130
  * @throws If scopes are defined and the account is not in the scopes.
131
131
  */
132
- public async utilityGetKeyValidationRequest(pkMHash: Fr): Promise<KeyValidationRequest> {
132
+ public async getKeyValidationRequest(pkMHash: Fr): Promise<KeyValidationRequest> {
133
133
  // If scopes are defined, check that the key belongs to an account in the scopes.
134
134
  if (this.scopes !== 'ALL_SCOPES' && this.scopes.length > 0) {
135
135
  let hasAccess = false;
@@ -152,7 +152,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
152
152
  * @param noteHash - The note hash to find in the note hash tree.
153
153
  * @returns The membership witness containing the leaf index and sibling path
154
154
  */
155
- public utilityGetNoteHashMembershipWitness(
155
+ public getNoteHashMembershipWitness(
156
156
  anchorBlockHash: BlockHash,
157
157
  noteHash: Fr,
158
158
  ): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
@@ -170,7 +170,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
170
170
  * @param blockHash - The block hash to find in the archive tree.
171
171
  * @returns The membership witness containing the leaf index and sibling path
172
172
  */
173
- public utilityGetBlockHashMembershipWitness(
173
+ public getBlockHashMembershipWitness(
174
174
  anchorBlockHash: BlockHash,
175
175
  blockHash: BlockHash,
176
176
  ): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined> {
@@ -183,7 +183,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
183
183
  * @param nullifier - Nullifier we try to find witness for.
184
184
  * @returns The nullifier membership witness (if found).
185
185
  */
186
- public utilityGetNullifierMembershipWitness(
186
+ public getNullifierMembershipWitness(
187
187
  blockHash: BlockHash,
188
188
  nullifier: Fr,
189
189
  ): Promise<NullifierMembershipWitness | undefined> {
@@ -199,7 +199,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
199
199
  * list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
200
200
  * we are trying to prove non-inclusion for.
201
201
  */
202
- public utilityGetLowNullifierMembershipWitness(
202
+ public getLowNullifierMembershipWitness(
203
203
  blockHash: BlockHash,
204
204
  nullifier: Fr,
205
205
  ): Promise<NullifierMembershipWitness | undefined> {
@@ -212,7 +212,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
212
212
  * @param leafSlot - The slot of the public data tree to get the witness for.
213
213
  * @returns - The witness
214
214
  */
215
- public utilityGetPublicDataWitness(blockHash: BlockHash, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
215
+ public getPublicDataWitness(blockHash: BlockHash, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
216
216
  return this.aztecNode.getPublicDataWitness(blockHash, leafSlot);
217
217
  }
218
218
 
@@ -221,7 +221,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
221
221
  * @param blockNumber - The number of a block of which to get the block header.
222
222
  * @returns Block extracted from a block with block number `blockNumber`.
223
223
  */
224
- public async utilityGetBlockHeader(blockNumber: BlockNumber): Promise<BlockHeader | undefined> {
224
+ public async getBlockHeader(blockNumber: BlockNumber): Promise<BlockHeader | undefined> {
225
225
  const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
226
226
  if (blockNumber > anchorBlockNumber) {
227
227
  throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
@@ -236,7 +236,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
236
236
  * @param account - The account address.
237
237
  * @returns A complete address associated with the input address, or `undefined` if not registered.
238
238
  */
239
- public utilityTryGetPublicKeysAndPartialAddress(account: AztecAddress): Promise<CompleteAddress | undefined> {
239
+ public tryGetPublicKeysAndPartialAddress(account: AztecAddress): Promise<CompleteAddress | undefined> {
240
240
  return this.addressStore.getCompleteAddress(account);
241
241
  }
242
242
 
@@ -256,11 +256,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
256
256
  * @param address - Address.
257
257
  * @returns A contract instance.
258
258
  */
259
- public utilityGetContractInstance(address: AztecAddress): Promise<ContractInstance> {
260
- return this.getContractInstance(address);
261
- }
262
-
263
- protected async getContractInstance(address: AztecAddress): Promise<ContractInstance> {
259
+ public async getContractInstance(address: AztecAddress): Promise<ContractInstance> {
264
260
  const instance = await this.contractStore.getContractInstance(address);
265
261
  if (!instance) {
266
262
  throw new Error(`No contract instance found for address ${address.toString()}`);
@@ -274,7 +270,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
274
270
  * @param messageHash - Hash of the message to authenticate.
275
271
  * @returns Authentication witness for the requested message hash.
276
272
  */
277
- public utilityGetAuthWitness(messageHash: Fr): Promise<Fr[] | undefined> {
273
+ public getAuthWitness(messageHash: Fr): Promise<Fr[] | undefined> {
278
274
  return Promise.resolve(this.authWitnesses.find(w => w.requestHash.equals(messageHash))?.witness);
279
275
  }
280
276
 
@@ -300,7 +296,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
300
296
  * @param status - The status of notes to fetch.
301
297
  * @returns Array of note data.
302
298
  */
303
- public async utilityGetNotes(
299
+ public async getNotes(
304
300
  owner: AztecAddress | undefined,
305
301
  storageSlot: Fr,
306
302
  numSelects: number,
@@ -340,7 +336,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
340
336
  * @param innerNullifier - The inner nullifier.
341
337
  * @returns A boolean indicating whether the nullifier exists in the tree or not.
342
338
  */
343
- public async utilityCheckNullifierExists(innerNullifier: Fr) {
339
+ public async checkNullifierExists(innerNullifier: Fr) {
344
340
  const [nullifier, anchorBlockHash] = await Promise.all([
345
341
  siloNullifier(this.contractAddress, innerNullifier!),
346
342
  this.anchorBlockHeader.hash(),
@@ -359,7 +355,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
359
355
  * @dev Contract address and secret are only used to compute the nullifier to get non-nullified messages
360
356
  * @returns The l1 to l2 membership witness (index of message in the tree and sibling path).
361
357
  */
362
- public async utilityGetL1ToL2MembershipWitness(contractAddress: AztecAddress, messageHash: Fr, secret: Fr) {
358
+ public async getL1ToL2MembershipWitness(contractAddress: AztecAddress, messageHash: Fr, secret: Fr) {
363
359
  const [messageIndex, siblingPath] = await getNonNullifiedL1ToL2MessageWitness(
364
360
  this.aztecNode,
365
361
  contractAddress,
@@ -377,7 +373,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
377
373
  * @param startStorageSlot - The starting storage slot.
378
374
  * @param numberOfElements - Number of elements to read from the starting storage slot.
379
375
  */
380
- public async utilityStorageRead(
376
+ public async storageRead(
381
377
  blockHash: BlockHash,
382
378
  contractAddress: AztecAddress,
383
379
  startStorageSlot: Fr,
@@ -391,7 +387,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
391
387
  slots.map(storageSlot => this.aztecNode.getPublicStorageAt(blockHash, contractAddress, storageSlot)),
392
388
  );
393
389
 
394
- this.log.debug(
390
+ this.logger.debug(
395
391
  `Oracle storage read: slots=[${slots.map(slot => slot.toString()).join(', ')}] address=${contractAddress.toString()} values=[${values.join(', ')}]`,
396
392
  );
397
393
 
@@ -414,7 +410,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
414
410
  return this.contractLogger;
415
411
  }
416
412
 
417
- public async utilityLog(level: number, message: string, fields: Fr[]): Promise<void> {
413
+ public async log(level: number, message: string, fields: Fr[]): Promise<void> {
418
414
  if (!LogLevels[level]) {
419
415
  throw new Error(`Invalid log level: ${level}`);
420
416
  }
@@ -422,7 +418,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
422
418
  logContractMessage(logger, LogLevels[level], message, fields);
423
419
  }
424
420
 
425
- public async utilityFetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr) {
421
+ public async fetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr) {
426
422
  const logService = new LogService(
427
423
  this.aztecNode,
428
424
  this.anchorBlockHeader,
@@ -432,7 +428,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
432
428
  this.senderAddressBookStore,
433
429
  this.addressStore,
434
430
  this.jobId,
435
- this.log.getBindings(),
431
+ this.logger.getBindings(),
436
432
  );
437
433
 
438
434
  await logService.fetchTaggedLogs(this.contractAddress, pendingTaggedLogArrayBaseSlot, this.scopes);
@@ -448,7 +444,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
448
444
  * @param noteValidationRequestsArrayBaseSlot - The base slot of capsule array containing note validation requests.
449
445
  * @param eventValidationRequestsArrayBaseSlot - The base slot of capsule array containing event validation requests.
450
446
  */
451
- public async utilityValidateAndStoreEnqueuedNotesAndEvents(
447
+ public async validateAndStoreEnqueuedNotesAndEvents(
452
448
  contractAddress: AztecAddress,
453
449
  noteValidationRequestsArrayBaseSlot: Fr,
454
450
  eventValidationRequestsArrayBaseSlot: Fr,
@@ -504,7 +500,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
504
500
  await this.capsuleStore.setCapsuleArray(contractAddress, eventValidationRequestsArrayBaseSlot, [], this.jobId);
505
501
  }
506
502
 
507
- public async utilityBulkRetrieveLogs(
503
+ public async bulkRetrieveLogs(
508
504
  contractAddress: AztecAddress,
509
505
  logRetrievalRequestsArrayBaseSlot: Fr,
510
506
  logRetrievalResponsesArrayBaseSlot: Fr,
@@ -529,7 +525,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
529
525
  this.senderAddressBookStore,
530
526
  this.addressStore,
531
527
  this.jobId,
532
- this.log.getBindings(),
528
+ this.logger.getBindings(),
533
529
  );
534
530
 
535
531
  const maybeLogRetrievalResponses = await logService.bulkRetrieveLogs(logRetrievalRequests);
@@ -546,7 +542,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
546
542
  );
547
543
  }
548
544
 
549
- public utilityStoreCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
545
+ public storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
550
546
  if (!contractAddress.equals(this.contractAddress)) {
551
547
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
552
548
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
@@ -555,7 +551,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
555
551
  return Promise.resolve();
556
552
  }
557
553
 
558
- public async utilityLoadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
554
+ public async loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
559
555
  if (!contractAddress.equals(this.contractAddress)) {
560
556
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
561
557
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
@@ -567,7 +563,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
567
563
  );
568
564
  }
569
565
 
570
- public utilityDeleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void> {
566
+ public deleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void> {
571
567
  if (!contractAddress.equals(this.contractAddress)) {
572
568
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
573
569
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
@@ -576,12 +572,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
576
572
  return Promise.resolve();
577
573
  }
578
574
 
579
- public utilityCopyCapsule(
580
- contractAddress: AztecAddress,
581
- srcSlot: Fr,
582
- dstSlot: Fr,
583
- numEntries: number,
584
- ): Promise<void> {
575
+ public copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number): Promise<void> {
585
576
  if (!contractAddress.equals(this.contractAddress)) {
586
577
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
587
578
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
@@ -590,7 +581,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
590
581
  }
591
582
 
592
583
  // TODO(#11849): consider replacing this oracle with a pure Noir implementation of aes decryption.
593
- public utilityAes128Decrypt(ciphertext: Buffer, iv: Buffer, symKey: Buffer): Promise<Buffer> {
584
+ public aes128Decrypt(ciphertext: Buffer, iv: Buffer, symKey: Buffer): Promise<Buffer> {
594
585
  const aes128 = new Aes128();
595
586
  return aes128.decryptBufferCBC(ciphertext, iv, symKey);
596
587
  }
@@ -601,11 +592,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
601
592
  * @param ephPk - The ephemeral public key to get the secret for.
602
593
  * @returns The secret for the given address.
603
594
  */
604
- public utilityGetSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point> {
605
- return this.getSharedSecret(address, ephPk);
606
- }
607
-
608
- protected async getSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point> {
595
+ public async getSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point> {
609
596
  // TODO(#12656): return an app-siloed secret
610
597
  const recipientCompleteAddress = await this.getCompleteAddressOrFail(address);
611
598
  const ivskM = await this.keyStore.getMasterSecretKey(
@@ -3,7 +3,13 @@ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundatio
3
3
  import type { KeyStore } from '@aztec/key-store';
4
4
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
5
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
6
- import { DirectionalAppTaggingSecret, PendingTaggedLog, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
6
+ import {
7
+ ExtendedDirectionalAppTaggingSecret,
8
+ PendingTaggedLog,
9
+ SiloedTag,
10
+ Tag,
11
+ TxScopedL2Log,
12
+ } from '@aztec/stdlib/logs';
7
13
  import type { BlockHeader } from '@aztec/stdlib/tx';
8
14
 
9
15
  import type { AccessScopes } from '../access_scopes.js';
@@ -41,7 +47,7 @@ export class LogService {
41
47
  logRetrievalRequests.map(async request => {
42
48
  const [publicLog, privateLog] = await Promise.all([
43
49
  this.#getPublicLogByTag(request.tag, request.contractAddress),
44
- this.#getPrivateLogByTag(await SiloedTag.compute(request.tag, request.contractAddress)),
50
+ this.#getPrivateLogByTag(await SiloedTag.computeFromTagAndApp(request.tag, request.contractAddress)),
45
51
  ]);
46
52
 
47
53
  if (publicLog !== null && privateLog !== null) {
@@ -130,7 +136,6 @@ export class LogService {
130
136
  secrets.map(secret =>
131
137
  loadPrivateLogsForSenderRecipientPair(
132
138
  secret,
133
- contractAddress,
134
139
  this.aztecNode,
135
140
  this.recipientTaggingStore,
136
141
  anchorBlockNumber,
@@ -154,7 +159,7 @@ export class LogService {
154
159
  async #getSecretsForSenders(
155
160
  contractAddress: AztecAddress,
156
161
  recipient: AztecAddress,
157
- ): Promise<DirectionalAppTaggingSecret[]> {
162
+ ): Promise<ExtendedDirectionalAppTaggingSecret[]> {
158
163
  const recipientCompleteAddress = await this.addressStore.getCompleteAddress(recipient);
159
164
  if (!recipientCompleteAddress) {
160
165
  return [];
@@ -172,7 +177,7 @@ export class LogService {
172
177
 
173
178
  return Promise.all(
174
179
  deduplicatedSenders.map(sender => {
175
- return DirectionalAppTaggingSecret.compute(
180
+ return ExtendedDirectionalAppTaggingSecret.compute(
176
181
  recipientCompleteAddress,
177
182
  recipientIvsk,
178
183
  sender,
@@ -2,11 +2,11 @@
2
2
  /// to version the oracle interface to ensure that developers get a reasonable error message if they use incompatible
3
3
  /// versions of Aztec.nr and PXE. The Noir counterpart is in `noir-projects/aztec-nr/aztec/src/oracle/version.nr`.
4
4
  ///
5
- /// @dev Whenever a contract function or Noir test is run, the `utilityAssertCompatibleOracleVersion` oracle is called
5
+ /// @dev Whenever a contract function or Noir test is run, the `aztec_utl_assertCompatibleOracleVersion` oracle is called
6
6
  /// and if the oracle version is incompatible an error is thrown.
7
- export const ORACLE_VERSION = 12;
7
+ export const ORACLE_VERSION = 14;
8
8
 
9
9
  /// This hash is computed as by hashing the Oracle interface and it is used to detect when the Oracle interface changes,
10
10
  /// which in turn implies that you need to update the ORACLE_VERSION constant in this file and in
11
11
  /// `noir-projects/aztec-nr/aztec/src/oracle/version.nr`.
12
- export const ORACLE_INTERFACE_HASH = '666a8a7fc697f72b29dbf0ae7464db269cf5afa019acac8861f814543147dbb4';
12
+ export const ORACLE_INTERFACE_HASH = '9fb918682455c164ce8dd3acb71c751e2b9b2fc48913604069c9ea885fa378ca';
package/src/pxe.ts CHANGED
@@ -145,6 +145,7 @@ export type PXECreateArgs = {
145
145
  export class PXE {
146
146
  private constructor(
147
147
  private node: AztecNode,
148
+ private db: AztecAsyncKVStore,
148
149
  private blockStateSynchronizer: BlockSynchronizer,
149
150
  private keyStore: KeyStore,
150
151
  private contractStore: ContractStore,
@@ -240,6 +241,7 @@ export class PXE {
240
241
 
241
242
  const pxe = new PXE(
242
243
  node,
244
+ store,
243
245
  synchronizer,
244
246
  keyStore,
245
247
  contractStore,
@@ -958,7 +960,8 @@ export class PXE {
958
960
  const validationResult = await this.node.isValidTx(simulatedTx, { isSimulation: true, skipFeeEnforcement });
959
961
  validationTime = validationTimer.ms();
960
962
  if (validationResult.result === 'invalid') {
961
- throw new Error('The simulated transaction is unable to be added to state and is invalid.');
963
+ const reason = validationResult.reason.length > 0 ? ` Reason: ${validationResult.reason.join(', ')}` : '';
964
+ throw new Error(`The simulated transaction is unable to be added to state and is invalid.${reason}`);
962
965
  }
963
966
  }
964
967
 
@@ -1129,9 +1132,10 @@ export class PXE {
1129
1132
  }
1130
1133
 
1131
1134
  /**
1132
- * Stops the PXE's job queue.
1135
+ * Stops the PXE's job queue and closes the backing store.
1133
1136
  */
1134
- public stop(): Promise<void> {
1135
- return this.jobQueue.end();
1137
+ public async stop(): Promise<void> {
1138
+ await this.jobQueue.end();
1139
+ await this.db.close();
1136
1140
  }
1137
1141
  }