@aztec/pxe 0.0.1-commit.f504929 → 0.0.1-commit.f81dbcf

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 (29) hide show
  1. package/dest/config/package_info.js +1 -1
  2. package/dest/contract_function_simulator/contract_function_simulator.js +3 -3
  3. package/dest/contract_function_simulator/oracle/interfaces.d.ts +49 -45
  4. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  5. package/dest/contract_function_simulator/oracle/oracle.d.ts +44 -44
  6. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  7. package/dest/contract_function_simulator/oracle/oracle.js +89 -132
  8. package/dest/contract_function_simulator/oracle/private_execution.js +1 -1
  9. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +20 -20
  10. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  11. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +38 -30
  12. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +38 -32
  13. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  14. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +48 -35
  15. package/dest/oracle_version.d.ts +2 -2
  16. package/dest/oracle_version.js +3 -3
  17. package/dest/pxe.d.ts +2 -3
  18. package/dest/pxe.d.ts.map +1 -1
  19. package/dest/pxe.js +6 -10
  20. package/package.json +16 -16
  21. package/src/config/package_info.ts +1 -1
  22. package/src/contract_function_simulator/contract_function_simulator.ts +3 -3
  23. package/src/contract_function_simulator/oracle/interfaces.ts +47 -44
  24. package/src/contract_function_simulator/oracle/oracle.ts +107 -135
  25. package/src/contract_function_simulator/oracle/private_execution.ts +1 -1
  26. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +39 -30
  27. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +56 -37
  28. package/src/oracle_version.ts +3 -3
  29. package/src/pxe.ts +4 -8
@@ -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 getSenderForTags(): Promise<AztecAddress | undefined> {
192
+ public privateGetSenderForTags(): 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 setSenderForTags(senderForTags: AztecAddress): Promise<void> {
207
+ public privateSetSenderForTags(senderForTags: AztecAddress): Promise<void> {
208
208
  this.senderForTags = senderForTags;
209
209
  return Promise.resolve();
210
210
  }
@@ -215,7 +215,7 @@ 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 getNextAppTagAsSender(sender: AztecAddress, recipient: AztecAddress): Promise<Tag> {
218
+ public async privateGetNextAppTagAsSender(sender: AztecAddress, recipient: AztecAddress): Promise<Tag> {
219
219
  const extendedSecret = await this.#calculateExtendedDirectionalAppTaggingSecret(
220
220
  this.contractAddress,
221
221
  sender,
@@ -223,7 +223,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
223
223
  );
224
224
 
225
225
  const index = await this.#getIndexToUseForSecret(extendedSecret);
226
- this.logger.debug(
226
+ this.log.debug(
227
227
  `Incrementing tagging index for sender: ${sender}, recipient: ${recipient}, contract: ${this.contractAddress} to ${index}`,
228
228
  );
229
229
  this.taggingIndexCache.setLastUsedIndex(extendedSecret, index);
@@ -277,7 +277,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
277
277
  * @param values - Values to store.
278
278
  * @returns The hash of the values.
279
279
  */
280
- public storeInExecutionCache(values: Fr[], hash: Fr) {
280
+ public privateStoreInExecutionCache(values: Fr[], hash: Fr) {
281
281
  return this.executionCache.store(values, hash);
282
282
  }
283
283
 
@@ -286,7 +286,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
286
286
  * @param hash - Hash of the values.
287
287
  * @returns The values.
288
288
  */
289
- public loadFromExecutionCache(hash: Fr): Promise<Fr[]> {
289
+ public privateLoadFromExecutionCache(hash: Fr): Promise<Fr[]> {
290
290
  const preimage = this.executionCache.getPreimage(hash);
291
291
  if (!preimage) {
292
292
  throw new Error(`Preimage for hash ${hash.toString()} not found in cache`);
@@ -294,12 +294,12 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
294
294
  return Promise.resolve(preimage);
295
295
  }
296
296
 
297
- override async checkNullifierExists(innerNullifier: Fr): Promise<boolean> {
297
+ override async utilityCheckNullifierExists(innerNullifier: Fr): Promise<boolean> {
298
298
  // This oracle must be overridden because while utility execution can only meaningfully check if a nullifier exists
299
299
  // in the synched block, during private execution there's also the possibility of it being pending, i.e. created
300
300
  // in the current transaction.
301
301
 
302
- this.logger.debug(`Checking existence of inner nullifier ${innerNullifier}`, {
302
+ this.log.debug(`Checking existence of inner nullifier ${innerNullifier}`, {
303
303
  contractAddress: this.contractAddress,
304
304
  });
305
305
 
@@ -307,7 +307,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
307
307
 
308
308
  return (
309
309
  this.noteCache.getNullifiers(this.contractAddress).has(nullifier) ||
310
- (await super.checkNullifierExists(innerNullifier))
310
+ (await super.utilityCheckNullifierExists(innerNullifier))
311
311
  );
312
312
  }
313
313
 
@@ -332,7 +332,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
332
332
  * @param status - The status of notes to fetch.
333
333
  * @returns Array of note data.
334
334
  */
335
- public override async getNotes(
335
+ public override async utilityGetNotes(
336
336
  owner: AztecAddress | undefined,
337
337
  storageSlot: Fr,
338
338
  numSelects: number,
@@ -378,7 +378,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
378
378
  offset,
379
379
  });
380
380
 
381
- this.logger.debug(
381
+ this.log.debug(
382
382
  `Returning ${notes.length} notes for ${this.callContext.contractAddress} at ${storageSlot}: ${notes
383
383
  .map(n => `${n.noteNonce.toString()}:[${n.note.items.map(i => i.toString()).join(',')}]`)
384
384
  .join(', ')}`,
@@ -398,7 +398,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
398
398
  * @param noteHash - A hash of the new note.
399
399
  * @returns
400
400
  */
401
- public notifyCreatedNote(
401
+ public privateNotifyCreatedNote(
402
402
  owner: AztecAddress,
403
403
  storageSlot: Fr,
404
404
  randomness: Fr,
@@ -407,7 +407,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
407
407
  noteHash: Fr,
408
408
  counter: number,
409
409
  ) {
410
- this.logger.debug(`Notified of new note with inner hash ${noteHash}`, {
410
+ this.log.debug(`Notified of new note with inner hash ${noteHash}`, {
411
411
  contractAddress: this.callContext.contractAddress,
412
412
  storageSlot,
413
413
  randomness,
@@ -439,7 +439,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
439
439
  * @param innerNullifier - The pending nullifier to add in the list (not yet siloed by contract address).
440
440
  * @param noteHash - A hash of the new note.
441
441
  */
442
- public async notifyNullifiedNote(innerNullifier: Fr, noteHash: Fr, counter: number) {
442
+ public async privateNotifyNullifiedNote(innerNullifier: Fr, noteHash: Fr, counter: number) {
443
443
  const nullifiedNoteHashCounter = await this.noteCache.nullifyNote(
444
444
  this.callContext.contractAddress,
445
445
  innerNullifier,
@@ -456,19 +456,19 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
456
456
  * @param innerNullifier - The pending nullifier to add in the list (not yet siloed by contract address).
457
457
  * @param noteHash - A hash of the new note.
458
458
  */
459
- public notifyCreatedNullifier(innerNullifier: Fr) {
460
- this.logger.debug(`Notified of new inner nullifier ${innerNullifier}`, { contractAddress: this.contractAddress });
459
+ public privateNotifyCreatedNullifier(innerNullifier: Fr) {
460
+ this.log.debug(`Notified of new inner nullifier ${innerNullifier}`, { contractAddress: this.contractAddress });
461
461
  return this.noteCache.nullifierCreated(this.callContext.contractAddress, innerNullifier);
462
462
  }
463
463
 
464
464
  /**
465
- * Check if a nullifier has been emitted in the same transaction, i.e. if notifyCreatedNullifier has been
465
+ * Check if a nullifier has been emitted in the same transaction, i.e. if privateNotifyCreatedNullifier has been
466
466
  * called for this inner nullifier from the contract with the specified address.
467
467
  * @param innerNullifier - The inner nullifier to check.
468
468
  * @param contractAddress - Address of the contract that emitted the nullifier.
469
469
  * @returns A boolean indicating whether the nullifier is pending or not.
470
470
  */
471
- public async isNullifierPending(innerNullifier: Fr, contractAddress: AztecAddress): Promise<boolean> {
471
+ public async privateIsNullifierPending(innerNullifier: Fr, contractAddress: AztecAddress): Promise<boolean> {
472
472
  const siloedNullifier = await siloNullifier(contractAddress, innerNullifier);
473
473
  const isNullifierPending = this.noteCache.getNullifiers(contractAddress).has(siloedNullifier.toBigInt());
474
474
  return Promise.resolve(isNullifierPending);
@@ -481,10 +481,10 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
481
481
  * @param log - The contract class log to be emitted.
482
482
  * @param counter - The contract class log's counter.
483
483
  */
484
- public notifyCreatedContractClassLog(log: ContractClassLog, counter: number) {
484
+ public privateNotifyCreatedContractClassLog(log: ContractClassLog, counter: number) {
485
485
  this.contractClassLogs.push(new CountedContractClassLog(log, counter));
486
486
  const text = log.toBuffer().toString('hex');
487
- this.logger.verbose(
487
+ this.log.verbose(
488
488
  `Emitted log from ContractClassRegistry: "${text.length > 100 ? text.slice(0, 100) + '...' : text}"`,
489
489
  );
490
490
  }
@@ -510,7 +510,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
510
510
  * @param isStaticCall - Whether the call is a static call.
511
511
  * @returns The execution result.
512
512
  */
513
- async callPrivateFunction(
513
+ async privateCallPrivateFunction(
514
514
  targetContractAddress: AztecAddress,
515
515
  functionSelector: FunctionSelector,
516
516
  argsHash: Fr,
@@ -524,19 +524,28 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
524
524
  }
525
525
 
526
526
  const simulatorSetupTimer = new Timer();
527
- this.logger.debug(
527
+ this.log.debug(
528
528
  `Calling private function ${targetContractAddress}:${functionSelector} from ${this.callContext.contractAddress}`,
529
529
  );
530
530
 
531
531
  isStaticCall = isStaticCall || this.callContext.isStaticCall;
532
532
 
533
+ // When scopes are set and the target contract is a registered account (has keys in the keyStore),
534
+ // expand scopes to include it so nested private calls can sync and read the contract's own notes.
535
+ // We only expand for registered accounts because the log service needs the recipient's keys to derive
536
+ // tagging secrets, which are only available for registered accounts.
537
+ const expandedScopes =
538
+ this.scopes !== 'ALL_SCOPES' && (await this.keyStore.hasAccount(targetContractAddress))
539
+ ? [...this.scopes, targetContractAddress]
540
+ : this.scopes;
541
+
533
542
  await this.contractSyncService.ensureContractSynced(
534
543
  targetContractAddress,
535
544
  functionSelector,
536
545
  this.utilityExecutor,
537
546
  this.anchorBlockHeader,
538
547
  this.jobId,
539
- this.scopes,
548
+ expandedScopes,
540
549
  );
541
550
 
542
551
  const targetArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(
@@ -573,8 +582,8 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
573
582
  jobId: this.jobId,
574
583
  totalPublicCalldataCount: this.totalPublicCalldataCount,
575
584
  sideEffectCounter,
576
- log: this.logger,
577
- scopes: this.scopes,
585
+ log: this.log,
586
+ scopes: expandedScopes,
578
587
  senderForTags: this.senderForTags,
579
588
  simulator: this.simulator!,
580
589
  });
@@ -627,7 +636,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
627
636
  * @param sideEffectCounter - The side effect counter at the start of the call.
628
637
  * @param isStaticCall - Whether the call is a static call.
629
638
  */
630
- public notifyEnqueuedPublicFunctionCall(
639
+ public privateNotifyEnqueuedPublicFunctionCall(
631
640
  _targetContractAddress: AztecAddress,
632
641
  calldataHash: Fr,
633
642
  _sideEffectCounter: number,
@@ -644,7 +653,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
644
653
  * @param sideEffectCounter - The side effect counter at the start of the call.
645
654
  * @param isStaticCall - Whether the call is a static call.
646
655
  */
647
- public notifySetPublicTeardownFunctionCall(
656
+ public privateNotifySetPublicTeardownFunctionCall(
648
657
  _targetContractAddress: AztecAddress,
649
658
  calldataHash: Fr,
650
659
  _sideEffectCounter: number,
@@ -654,11 +663,11 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
654
663
  return Promise.resolve();
655
664
  }
656
665
 
657
- public notifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: number): Promise<void> {
666
+ public privateNotifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: number): Promise<void> {
658
667
  return this.noteCache.setMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter);
659
668
  }
660
669
 
661
- public isSideEffectCounterRevertible(sideEffectCounter: number): Promise<boolean> {
670
+ public privateIsSideEffectCounterRevertible(sideEffectCounter: number): Promise<boolean> {
662
671
  return Promise.resolve(this.noteCache.isSideEffectCounterRevertible(sideEffectCounter));
663
672
  }
664
673
 
@@ -686,7 +695,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
686
695
  return this.contractStore.getDebugFunctionName(this.contractAddress, this.callContext.functionSelector);
687
696
  }
688
697
 
689
- public emitOffchainEffect(data: Fr[]): Promise<void> {
698
+ public utilityEmitOffchainEffect(data: Fr[]): Promise<void> {
690
699
  this.offchainEffects.push({ data });
691
700
  return Promise.resolve();
692
701
  }
@@ -9,11 +9,11 @@ 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';
@@ -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 logger: ReturnType<typeof createLogger>;
89
+ protected log: 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.logger = args.log ?? createLogger('simulator:client_view_context');
107
+ this.log = args.log ?? createLogger('simulator:client_view_context');
108
108
  this.scopes = args.scopes;
109
109
  }
110
110
 
111
- public assertCompatibleOracleVersion(version: number): void {
111
+ public utilityAssertCompatibleOracleVersion(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 getRandomField(): Fr {
117
+ public utilityGetRandomField(): Fr {
118
118
  return Fr.random();
119
119
  }
120
120
 
121
- public getUtilityContext(): UtilityContext {
121
+ public utilityGetUtilityContext(): 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 getKeyValidationRequest(pkMHash: Fr): Promise<KeyValidationRequest> {
132
+ public async utilityGetKeyValidationRequest(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 getNoteHashMembershipWitness(
155
+ public utilityGetNoteHashMembershipWitness(
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 getBlockHashMembershipWitness(
173
+ public utilityGetBlockHashMembershipWitness(
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 getNullifierMembershipWitness(
186
+ public utilityGetNullifierMembershipWitness(
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 getLowNullifierMembershipWitness(
202
+ public utilityGetLowNullifierMembershipWitness(
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 getPublicDataWitness(blockHash: BlockHash, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
215
+ public utilityGetPublicDataWitness(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 getBlockHeader(blockNumber: BlockNumber): Promise<BlockHeader | undefined> {
224
+ public async utilityGetBlockHeader(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}`);
@@ -232,12 +232,18 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
232
232
  }
233
233
 
234
234
  /**
235
- * Retrieve the complete address associated to a given address.
235
+ * Retrieve the public keys and partial address associated to a given address.
236
236
  * @param account - The account address.
237
- * @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.
238
238
  */
239
- public tryGetPublicKeysAndPartialAddress(account: AztecAddress): Promise<CompleteAddress | undefined> {
240
- return this.addressStore.getCompleteAddress(account);
239
+ public async utilityTryGetPublicKeysAndPartialAddress(
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 };
241
247
  }
242
248
 
243
249
  protected async getCompleteAddressOrFail(account: AztecAddress): Promise<CompleteAddress> {
@@ -256,7 +262,11 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
256
262
  * @param address - Address.
257
263
  * @returns A contract instance.
258
264
  */
259
- public async getContractInstance(address: AztecAddress): Promise<ContractInstance> {
265
+ public utilityGetContractInstance(address: AztecAddress): Promise<ContractInstance> {
266
+ return this.getContractInstance(address);
267
+ }
268
+
269
+ protected async getContractInstance(address: AztecAddress): Promise<ContractInstance> {
260
270
  const instance = await this.contractStore.getContractInstance(address);
261
271
  if (!instance) {
262
272
  throw new Error(`No contract instance found for address ${address.toString()}`);
@@ -270,7 +280,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
270
280
  * @param messageHash - Hash of the message to authenticate.
271
281
  * @returns Authentication witness for the requested message hash.
272
282
  */
273
- public getAuthWitness(messageHash: Fr): Promise<Fr[] | undefined> {
283
+ public utilityGetAuthWitness(messageHash: Fr): Promise<Fr[] | undefined> {
274
284
  return Promise.resolve(this.authWitnesses.find(w => w.requestHash.equals(messageHash))?.witness);
275
285
  }
276
286
 
@@ -296,7 +306,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
296
306
  * @param status - The status of notes to fetch.
297
307
  * @returns Array of note data.
298
308
  */
299
- public async getNotes(
309
+ public async utilityGetNotes(
300
310
  owner: AztecAddress | undefined,
301
311
  storageSlot: Fr,
302
312
  numSelects: number,
@@ -336,7 +346,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
336
346
  * @param innerNullifier - The inner nullifier.
337
347
  * @returns A boolean indicating whether the nullifier exists in the tree or not.
338
348
  */
339
- public async checkNullifierExists(innerNullifier: Fr) {
349
+ public async utilityCheckNullifierExists(innerNullifier: Fr) {
340
350
  const [nullifier, anchorBlockHash] = await Promise.all([
341
351
  siloNullifier(this.contractAddress, innerNullifier!),
342
352
  this.anchorBlockHeader.hash(),
@@ -355,7 +365,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
355
365
  * @dev Contract address and secret are only used to compute the nullifier to get non-nullified messages
356
366
  * @returns The l1 to l2 membership witness (index of message in the tree and sibling path).
357
367
  */
358
- public async getL1ToL2MembershipWitness(contractAddress: AztecAddress, messageHash: Fr, secret: Fr) {
368
+ public async utilityGetL1ToL2MembershipWitness(contractAddress: AztecAddress, messageHash: Fr, secret: Fr) {
359
369
  const [messageIndex, siblingPath] = await getNonNullifiedL1ToL2MessageWitness(
360
370
  this.aztecNode,
361
371
  contractAddress,
@@ -373,7 +383,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
373
383
  * @param startStorageSlot - The starting storage slot.
374
384
  * @param numberOfElements - Number of elements to read from the starting storage slot.
375
385
  */
376
- public async storageRead(
386
+ public async utilityStorageRead(
377
387
  blockHash: BlockHash,
378
388
  contractAddress: AztecAddress,
379
389
  startStorageSlot: Fr,
@@ -387,7 +397,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
387
397
  slots.map(storageSlot => this.aztecNode.getPublicStorageAt(blockHash, contractAddress, storageSlot)),
388
398
  );
389
399
 
390
- this.logger.debug(
400
+ this.log.debug(
391
401
  `Oracle storage read: slots=[${slots.map(slot => slot.toString()).join(', ')}] address=${contractAddress.toString()} values=[${values.join(', ')}]`,
392
402
  );
393
403
 
@@ -410,7 +420,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
410
420
  return this.contractLogger;
411
421
  }
412
422
 
413
- public async log(level: number, message: string, fields: Fr[]): Promise<void> {
423
+ public async utilityLog(level: number, message: string, fields: Fr[]): Promise<void> {
414
424
  if (!LogLevels[level]) {
415
425
  throw new Error(`Invalid log level: ${level}`);
416
426
  }
@@ -418,7 +428,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
418
428
  logContractMessage(logger, LogLevels[level], message, fields);
419
429
  }
420
430
 
421
- public async fetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr) {
431
+ public async utilityFetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr) {
422
432
  const logService = new LogService(
423
433
  this.aztecNode,
424
434
  this.anchorBlockHeader,
@@ -428,7 +438,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
428
438
  this.senderAddressBookStore,
429
439
  this.addressStore,
430
440
  this.jobId,
431
- this.logger.getBindings(),
441
+ this.log.getBindings(),
432
442
  );
433
443
 
434
444
  await logService.fetchTaggedLogs(this.contractAddress, pendingTaggedLogArrayBaseSlot, this.scopes);
@@ -444,7 +454,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
444
454
  * @param noteValidationRequestsArrayBaseSlot - The base slot of capsule array containing note validation requests.
445
455
  * @param eventValidationRequestsArrayBaseSlot - The base slot of capsule array containing event validation requests.
446
456
  */
447
- public async validateAndStoreEnqueuedNotesAndEvents(
457
+ public async utilityValidateAndStoreEnqueuedNotesAndEvents(
448
458
  contractAddress: AztecAddress,
449
459
  noteValidationRequestsArrayBaseSlot: Fr,
450
460
  eventValidationRequestsArrayBaseSlot: Fr,
@@ -500,7 +510,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
500
510
  await this.capsuleStore.setCapsuleArray(contractAddress, eventValidationRequestsArrayBaseSlot, [], this.jobId);
501
511
  }
502
512
 
503
- public async bulkRetrieveLogs(
513
+ public async utilityBulkRetrieveLogs(
504
514
  contractAddress: AztecAddress,
505
515
  logRetrievalRequestsArrayBaseSlot: Fr,
506
516
  logRetrievalResponsesArrayBaseSlot: Fr,
@@ -525,7 +535,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
525
535
  this.senderAddressBookStore,
526
536
  this.addressStore,
527
537
  this.jobId,
528
- this.logger.getBindings(),
538
+ this.log.getBindings(),
529
539
  );
530
540
 
531
541
  const maybeLogRetrievalResponses = await logService.bulkRetrieveLogs(logRetrievalRequests);
@@ -542,7 +552,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
542
552
  );
543
553
  }
544
554
 
545
- public storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
555
+ public utilityStoreCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
546
556
  if (!contractAddress.equals(this.contractAddress)) {
547
557
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
548
558
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
@@ -551,7 +561,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
551
561
  return Promise.resolve();
552
562
  }
553
563
 
554
- public async loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
564
+ public async utilityLoadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
555
565
  if (!contractAddress.equals(this.contractAddress)) {
556
566
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
557
567
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
@@ -563,7 +573,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
563
573
  );
564
574
  }
565
575
 
566
- public deleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void> {
576
+ public utilityDeleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void> {
567
577
  if (!contractAddress.equals(this.contractAddress)) {
568
578
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
569
579
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
@@ -572,7 +582,12 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
572
582
  return Promise.resolve();
573
583
  }
574
584
 
575
- public copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number): Promise<void> {
585
+ public utilityCopyCapsule(
586
+ contractAddress: AztecAddress,
587
+ srcSlot: Fr,
588
+ dstSlot: Fr,
589
+ numEntries: number,
590
+ ): Promise<void> {
576
591
  if (!contractAddress.equals(this.contractAddress)) {
577
592
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
578
593
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
@@ -581,7 +596,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
581
596
  }
582
597
 
583
598
  // TODO(#11849): consider replacing this oracle with a pure Noir implementation of aes decryption.
584
- public aes128Decrypt(ciphertext: Buffer, iv: Buffer, symKey: Buffer): Promise<Buffer> {
599
+ public utilityAes128Decrypt(ciphertext: Buffer, iv: Buffer, symKey: Buffer): Promise<Buffer> {
585
600
  const aes128 = new Aes128();
586
601
  return aes128.decryptBufferCBC(ciphertext, iv, symKey);
587
602
  }
@@ -592,7 +607,11 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
592
607
  * @param ephPk - The ephemeral public key to get the secret for.
593
608
  * @returns The secret for the given address.
594
609
  */
595
- public async getSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point> {
610
+ public utilityGetSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point> {
611
+ return this.getSharedSecret(address, ephPk);
612
+ }
613
+
614
+ protected async getSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point> {
596
615
  // TODO(#12656): return an app-siloed secret
597
616
  const recipientCompleteAddress = await this.getCompleteAddressOrFail(address);
598
617
  const ivskM = await this.keyStore.getMasterSecretKey(
@@ -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 `aztec_utl_assertCompatibleOracleVersion` oracle is called
5
+ /// @dev Whenever a contract function or Noir test is run, the `utilityAssertCompatibleOracleVersion` oracle is called
6
6
  /// and if the oracle version is incompatible an error is thrown.
7
- export const ORACLE_VERSION = 14;
7
+ export const ORACLE_VERSION = 12;
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 = '9fb918682455c164ce8dd3acb71c751e2b9b2fc48913604069c9ea885fa378ca';
12
+ export const ORACLE_INTERFACE_HASH = '666a8a7fc697f72b29dbf0ae7464db269cf5afa019acac8861f814543147dbb4';
package/src/pxe.ts CHANGED
@@ -145,7 +145,6 @@ export type PXECreateArgs = {
145
145
  export class PXE {
146
146
  private constructor(
147
147
  private node: AztecNode,
148
- private db: AztecAsyncKVStore,
149
148
  private blockStateSynchronizer: BlockSynchronizer,
150
149
  private keyStore: KeyStore,
151
150
  private contractStore: ContractStore,
@@ -241,7 +240,6 @@ export class PXE {
241
240
 
242
241
  const pxe = new PXE(
243
242
  node,
244
- store,
245
243
  synchronizer,
246
244
  keyStore,
247
245
  contractStore,
@@ -960,8 +958,7 @@ export class PXE {
960
958
  const validationResult = await this.node.isValidTx(simulatedTx, { isSimulation: true, skipFeeEnforcement });
961
959
  validationTime = validationTimer.ms();
962
960
  if (validationResult.result === '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}`);
961
+ throw new Error('The simulated transaction is unable to be added to state and is invalid.');
965
962
  }
966
963
  }
967
964
 
@@ -1132,10 +1129,9 @@ export class PXE {
1132
1129
  }
1133
1130
 
1134
1131
  /**
1135
- * Stops the PXE's job queue and closes the backing store.
1132
+ * Stops the PXE's job queue.
1136
1133
  */
1137
- public async stop(): Promise<void> {
1138
- await this.jobQueue.end();
1139
- await this.db.close();
1134
+ public stop(): Promise<void> {
1135
+ return this.jobQueue.end();
1140
1136
  }
1141
1137
  }