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

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 (112) 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.d.ts +2 -3
  11. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  12. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +5 -4
  13. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
  14. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  15. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -3
  16. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +2 -4
  17. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  18. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +3 -5
  19. package/dest/contract_function_simulator/oracle/interfaces.d.ts +48 -45
  20. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  21. package/dest/contract_function_simulator/oracle/oracle.d.ts +43 -44
  22. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  23. package/dest/contract_function_simulator/oracle/oracle.js +129 -91
  24. package/dest/contract_function_simulator/oracle/private_execution.js +1 -1
  25. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +20 -34
  26. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  27. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +37 -64
  28. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +36 -34
  29. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  30. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +48 -50
  31. package/dest/contract_logging.d.ts +22 -0
  32. package/dest/contract_logging.d.ts.map +1 -0
  33. package/dest/contract_logging.js +23 -0
  34. package/dest/entrypoints/client/bundle/index.d.ts +2 -1
  35. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  36. package/dest/entrypoints/client/bundle/index.js +1 -0
  37. package/dest/entrypoints/client/lazy/index.d.ts +2 -1
  38. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  39. package/dest/entrypoints/client/lazy/index.js +1 -0
  40. package/dest/logs/log_service.d.ts +1 -1
  41. package/dest/logs/log_service.d.ts.map +1 -1
  42. package/dest/logs/log_service.js +4 -4
  43. package/dest/oracle_version.d.ts +2 -2
  44. package/dest/oracle_version.js +3 -3
  45. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
  46. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  47. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +125 -64
  48. package/dest/private_kernel/hints/test_utils.d.ts +122 -0
  49. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
  50. package/dest/private_kernel/hints/test_utils.js +203 -0
  51. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  52. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  53. package/dest/private_kernel/private_kernel_execution_prover.js +13 -5
  54. package/dest/private_kernel/private_kernel_oracle.d.ts +6 -2
  55. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  56. package/dest/private_kernel/private_kernel_oracle.js +7 -3
  57. package/dest/pxe.d.ts +3 -2
  58. package/dest/pxe.d.ts.map +1 -1
  59. package/dest/pxe.js +24 -16
  60. package/dest/storage/contract_store/contract_store.d.ts +42 -15
  61. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  62. package/dest/storage/contract_store/contract_store.js +140 -64
  63. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
  64. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  65. package/dest/storage/tagging_store/sender_tagging_store.d.ts +5 -5
  66. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  67. package/dest/storage/tagging_store/sender_tagging_store.js +4 -4
  68. package/dest/tagging/index.d.ts +2 -2
  69. package/dest/tagging/index.d.ts.map +1 -1
  70. package/dest/tagging/index.js +1 -1
  71. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -5
  72. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  73. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +3 -3
  74. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -7
  75. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  76. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +12 -11
  77. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -8
  78. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  79. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +3 -6
  80. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +4 -7
  81. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  82. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +14 -15
  83. package/package.json +16 -16
  84. package/src/config/index.ts +1 -1
  85. package/src/contract_function_simulator/contract_function_simulator.ts +15 -16
  86. package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -5
  87. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +8 -5
  88. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -4
  89. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +3 -6
  90. package/src/contract_function_simulator/oracle/interfaces.ts +48 -54
  91. package/src/contract_function_simulator/oracle/oracle.ts +136 -136
  92. package/src/contract_function_simulator/oracle/private_execution.ts +1 -1
  93. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +42 -80
  94. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +55 -59
  95. package/src/contract_logging.ts +39 -0
  96. package/src/entrypoints/client/bundle/index.ts +1 -0
  97. package/src/entrypoints/client/lazy/index.ts +1 -0
  98. package/src/logs/log_service.ts +10 -5
  99. package/src/oracle_version.ts +3 -3
  100. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +157 -110
  101. package/src/private_kernel/hints/test_utils.ts +325 -0
  102. package/src/private_kernel/private_kernel_execution_prover.ts +13 -6
  103. package/src/private_kernel/private_kernel_oracle.ts +7 -7
  104. package/src/pxe.ts +23 -16
  105. package/src/storage/contract_store/contract_store.ts +170 -71
  106. package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
  107. package/src/storage/tagging_store/sender_tagging_store.ts +8 -8
  108. package/src/tagging/index.ts +1 -1
  109. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +3 -6
  110. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
  111. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +4 -9
  112. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +11 -20
@@ -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,10 +450,12 @@ 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,
457
+ maxNotePackedLen: number,
458
+ maxEventSerializedLen: number,
454
459
  ) {
455
460
  // TODO(#10727): allow other contracts to store notes
456
461
  if (!this.contractAddress.equals(contractAddress)) {
@@ -461,11 +466,11 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
461
466
  // faster as we don't need to wait for the network round-trip.
462
467
  const noteValidationRequests = (
463
468
  await this.capsuleStore.readCapsuleArray(contractAddress, noteValidationRequestsArrayBaseSlot, this.jobId)
464
- ).map(NoteValidationRequest.fromFields);
469
+ ).map(fields => NoteValidationRequest.fromFields(fields, maxNotePackedLen));
465
470
 
466
471
  const eventValidationRequests = (
467
472
  await this.capsuleStore.readCapsuleArray(contractAddress, eventValidationRequestsArrayBaseSlot, this.jobId)
468
- ).map(EventValidationRequest.fromFields);
473
+ ).map(fields => EventValidationRequest.fromFields(fields, maxEventSerializedLen));
469
474
 
470
475
  const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockHeader, this.jobId);
471
476
  const noteStorePromises = noteValidationRequests.map(request =>
@@ -503,7 +508,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
503
508
  await this.capsuleStore.setCapsuleArray(contractAddress, eventValidationRequestsArrayBaseSlot, [], this.jobId);
504
509
  }
505
510
 
506
- public async utilityBulkRetrieveLogs(
511
+ public async bulkRetrieveLogs(
507
512
  contractAddress: AztecAddress,
508
513
  logRetrievalRequestsArrayBaseSlot: Fr,
509
514
  logRetrievalResponsesArrayBaseSlot: Fr,
@@ -528,7 +533,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
528
533
  this.senderAddressBookStore,
529
534
  this.addressStore,
530
535
  this.jobId,
531
- this.log.getBindings(),
536
+ this.logger.getBindings(),
532
537
  );
533
538
 
534
539
  const maybeLogRetrievalResponses = await logService.bulkRetrieveLogs(logRetrievalRequests);
@@ -545,7 +550,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
545
550
  );
546
551
  }
547
552
 
548
- public utilityStoreCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
553
+ public storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
549
554
  if (!contractAddress.equals(this.contractAddress)) {
550
555
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
551
556
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
@@ -554,7 +559,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
554
559
  return Promise.resolve();
555
560
  }
556
561
 
557
- public async utilityLoadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
562
+ public async loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
558
563
  if (!contractAddress.equals(this.contractAddress)) {
559
564
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
560
565
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
@@ -566,7 +571,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
566
571
  );
567
572
  }
568
573
 
569
- public utilityDeleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void> {
574
+ public deleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void> {
570
575
  if (!contractAddress.equals(this.contractAddress)) {
571
576
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
572
577
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
@@ -575,12 +580,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
575
580
  return Promise.resolve();
576
581
  }
577
582
 
578
- public utilityCopyCapsule(
579
- contractAddress: AztecAddress,
580
- srcSlot: Fr,
581
- dstSlot: Fr,
582
- numEntries: number,
583
- ): Promise<void> {
583
+ public copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number): Promise<void> {
584
584
  if (!contractAddress.equals(this.contractAddress)) {
585
585
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
586
586
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
@@ -589,7 +589,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
589
589
  }
590
590
 
591
591
  // 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> {
592
+ public aes128Decrypt(ciphertext: Buffer, iv: Buffer, symKey: Buffer): Promise<Buffer> {
593
593
  const aes128 = new Aes128();
594
594
  return aes128.decryptBufferCBC(ciphertext, iv, symKey);
595
595
  }
@@ -600,11 +600,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
600
600
  * @param ephPk - The ephemeral public key to get the secret for.
601
601
  * @returns The secret for the given address.
602
602
  */
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> {
603
+ public async getSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point> {
608
604
  // TODO(#12656): return an app-siloed secret
609
605
  const recipientCompleteAddress = await this.getCompleteAddressOrFail(address);
610
606
  const ivskM = await this.keyStore.getMasterSecretKey(
@@ -0,0 +1,39 @@
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { type LogLevel, type Logger, applyStringFormatting, createLogger } from '@aztec/foundation/log';
3
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
+ import type { DebugLog } from '@aztec/stdlib/logs';
5
+
6
+ /** Resolves a contract address to a human-readable name, if available. */
7
+ export type ContractNameResolver = (address: AztecAddress) => Promise<string | undefined>;
8
+
9
+ /**
10
+ * Creates a logger whose output is prefixed with `contract_log::<name>(<addrAbbrev>)`.
11
+ */
12
+ export async function createContractLogger(
13
+ contractAddress: AztecAddress,
14
+ getContractName: ContractNameResolver,
15
+ options?: { instanceId?: string },
16
+ ): Promise<Logger> {
17
+ const addrAbbrev = contractAddress.toString().slice(0, 10);
18
+ const name = await getContractName(contractAddress);
19
+ const module = name ? `contract_log::${name}(${addrAbbrev})` : `contract_log::Unknown(${addrAbbrev})`;
20
+ return createLogger(module, options);
21
+ }
22
+
23
+ /**
24
+ * Formats and emits a single contract log message through the given logger.
25
+ */
26
+ export function logContractMessage(logger: Logger, level: LogLevel, message: string, fields: Fr[]): void {
27
+ logger[level](applyStringFormatting(message, fields));
28
+ }
29
+
30
+ /**
31
+ * Displays debug logs collected during public function simulation,
32
+ * using the `contract_log::` prefixed logger format.
33
+ */
34
+ export async function displayDebugLogs(debugLogs: DebugLog[], getContractName: ContractNameResolver): Promise<void> {
35
+ for (const log of debugLogs) {
36
+ const logger = await createContractLogger(log.contractAddress, getContractName);
37
+ logContractMessage(logger, log.level, log.message, log.fields);
38
+ }
39
+ }
@@ -3,6 +3,7 @@ export * from '../../../notes_filter.js';
3
3
  export * from '../../../pxe.js';
4
4
  export * from '../../../config/index.js';
5
5
  export * from '../../../error_enriching.js';
6
+ export * from '../../../contract_logging.js';
6
7
  export * from '../../../storage/index.js';
7
8
  export * from './utils.js';
8
9
  export type { PXECreationOptions } from '../../pxe_creation_options.js';
@@ -4,5 +4,6 @@ export * from '../../../pxe.js';
4
4
  export * from '../../../config/index.js';
5
5
  export * from '../../../storage/index.js';
6
6
  export * from '../../../error_enriching.js';
7
+ export * from '../../../contract_logging.js';
7
8
  export * from './utils.js';
8
9
  export { type PXECreationOptions } from '../../pxe_creation_options.js';
@@ -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 = 15;
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 = '32b3efa9e08765a5fad5fba732df263f61ca13e7979e30c1843215914b76b97e';