@aztec/pxe 0.0.1-commit.0c875d939 → 0.0.1-commit.10bd49492

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 (156) 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/config/package_info.js +1 -1
  5. package/dest/contract_function_simulator/contract_function_simulator.d.ts +4 -1
  6. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  7. package/dest/contract_function_simulator/contract_function_simulator.js +16 -12
  8. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -7
  9. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  10. package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
  11. package/dest/contract_function_simulator/index.d.ts +2 -1
  12. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  13. package/dest/contract_function_simulator/index.js +1 -0
  14. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +2 -3
  15. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  16. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +5 -4
  17. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
  18. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  19. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -3
  20. package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts +16 -0
  21. package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts.map +1 -0
  22. package/dest/contract_function_simulator/noir-structs/message_tx_context.js +57 -0
  23. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +2 -4
  24. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  25. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +3 -5
  26. package/dest/contract_function_simulator/oracle/interfaces.d.ts +49 -45
  27. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  28. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
  29. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
  30. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +52 -0
  31. package/dest/contract_function_simulator/oracle/oracle.d.ts +44 -44
  32. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  33. package/dest/contract_function_simulator/oracle/oracle.js +141 -93
  34. package/dest/contract_function_simulator/oracle/private_execution.js +3 -3
  35. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +23 -37
  36. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  37. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +41 -67
  38. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +40 -34
  39. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  40. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +83 -50
  41. package/dest/contract_logging.d.ts +22 -0
  42. package/dest/contract_logging.d.ts.map +1 -0
  43. package/dest/contract_logging.js +23 -0
  44. package/dest/debug/pxe_debug_utils.d.ts +2 -2
  45. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  46. package/dest/debug/pxe_debug_utils.js +4 -4
  47. package/dest/entrypoints/client/bundle/index.d.ts +2 -1
  48. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  49. package/dest/entrypoints/client/bundle/index.js +1 -0
  50. package/dest/entrypoints/client/lazy/index.d.ts +2 -1
  51. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  52. package/dest/entrypoints/client/lazy/index.js +1 -0
  53. package/dest/logs/log_service.d.ts +1 -1
  54. package/dest/logs/log_service.d.ts.map +1 -1
  55. package/dest/logs/log_service.js +4 -4
  56. package/dest/messages/message_context_service.d.ts +17 -0
  57. package/dest/messages/message_context_service.d.ts.map +1 -0
  58. package/dest/messages/message_context_service.js +36 -0
  59. package/dest/oracle_version.d.ts +2 -2
  60. package/dest/oracle_version.js +3 -3
  61. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
  62. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
  63. package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
  64. package/dest/private_kernel/hints/index.d.ts +1 -1
  65. package/dest/private_kernel/hints/index.js +1 -1
  66. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
  67. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  68. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
  69. package/dest/private_kernel/hints/test_utils.d.ts +122 -0
  70. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
  71. package/dest/private_kernel/hints/test_utils.js +203 -0
  72. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  73. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  74. package/dest/private_kernel/private_kernel_execution_prover.js +19 -11
  75. package/dest/private_kernel/private_kernel_oracle.d.ts +6 -2
  76. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  77. package/dest/private_kernel/private_kernel_oracle.js +7 -3
  78. package/dest/pxe.d.ts +9 -7
  79. package/dest/pxe.d.ts.map +1 -1
  80. package/dest/pxe.js +49 -36
  81. package/dest/storage/contract_store/contract_store.d.ts +42 -15
  82. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  83. package/dest/storage/contract_store/contract_store.js +140 -64
  84. package/dest/storage/metadata.d.ts +1 -1
  85. package/dest/storage/metadata.js +1 -1
  86. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
  87. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  88. package/dest/storage/tagging_store/sender_tagging_store.d.ts +29 -28
  89. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  90. package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
  91. package/dest/tagging/get_all_logs_by_tags.d.ts +1 -1
  92. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
  93. package/dest/tagging/get_all_logs_by_tags.js +17 -3
  94. package/dest/tagging/index.d.ts +3 -3
  95. package/dest/tagging/index.d.ts.map +1 -1
  96. package/dest/tagging/index.js +1 -1
  97. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -5
  98. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  99. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +7 -7
  100. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
  101. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -7
  102. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  103. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +12 -11
  104. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -8
  105. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  106. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +13 -7
  107. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
  108. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  109. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +20 -10
  110. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -7
  111. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  112. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +36 -24
  113. package/package.json +16 -16
  114. package/src/config/index.ts +1 -1
  115. package/src/config/package_info.ts +1 -1
  116. package/src/contract_function_simulator/contract_function_simulator.ts +25 -21
  117. package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
  118. package/src/contract_function_simulator/index.ts +1 -0
  119. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +8 -5
  120. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -4
  121. package/src/contract_function_simulator/noir-structs/message_tx_context.ts +55 -0
  122. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +3 -6
  123. package/src/contract_function_simulator/oracle/interfaces.ts +53 -54
  124. package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +77 -0
  125. package/src/contract_function_simulator/oracle/oracle.ts +154 -137
  126. package/src/contract_function_simulator/oracle/private_execution.ts +3 -3
  127. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +46 -83
  128. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +117 -59
  129. package/src/contract_logging.ts +39 -0
  130. package/src/debug/pxe_debug_utils.ts +4 -4
  131. package/src/entrypoints/client/bundle/index.ts +1 -0
  132. package/src/entrypoints/client/lazy/index.ts +1 -0
  133. package/src/logs/log_service.ts +10 -5
  134. package/src/messages/message_context_service.ts +45 -0
  135. package/src/oracle_version.ts +3 -3
  136. package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
  137. package/src/private_kernel/hints/index.ts +1 -1
  138. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
  139. package/src/private_kernel/hints/test_utils.ts +325 -0
  140. package/src/private_kernel/private_kernel_execution_prover.ts +19 -12
  141. package/src/private_kernel/private_kernel_oracle.ts +7 -7
  142. package/src/pxe.ts +53 -40
  143. package/src/storage/contract_store/contract_store.ts +170 -71
  144. package/src/storage/metadata.ts +1 -1
  145. package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
  146. package/src/storage/tagging_store/sender_tagging_store.ts +185 -138
  147. package/src/tagging/get_all_logs_by_tags.ts +28 -4
  148. package/src/tagging/index.ts +2 -2
  149. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +7 -10
  150. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
  151. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
  152. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +23 -10
  153. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
  154. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +27 -26
  155. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
  156. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
@@ -3,17 +3,18 @@ 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
+ import { isProtocolContract } from '@aztec/protocol-contracts';
9
10
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
10
11
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
11
12
  import { BlockHash } from '@aztec/stdlib/block';
12
- import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
13
+ import type { CompleteAddress, ContractInstance, PartialAddress } from '@aztec/stdlib/contract';
13
14
  import { siloNullifier } from '@aztec/stdlib/hash';
14
15
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
15
16
  import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
16
- import { computeAddressSecret } from '@aztec/stdlib/keys';
17
+ import { type PublicKeys, computeAddressSecret } from '@aztec/stdlib/keys';
17
18
  import { deriveEcdhSharedSecret } from '@aztec/stdlib/logs';
18
19
  import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
19
20
  import type { NoteStatus } from '@aztec/stdlib/note';
@@ -21,8 +22,10 @@ import { MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from
21
22
  import type { BlockHeader, Capsule } from '@aztec/stdlib/tx';
22
23
 
23
24
  import type { AccessScopes } from '../../access_scopes.js';
25
+ import { createContractLogger, logContractMessage } from '../../contract_logging.js';
24
26
  import { EventService } from '../../events/event_service.js';
25
27
  import { LogService } from '../../logs/log_service.js';
28
+ import { MessageContextService } from '../../messages/message_context_service.js';
26
29
  import { NoteService } from '../../notes/note_service.js';
27
30
  import { ORACLE_VERSION } from '../../oracle_version.js';
28
31
  import type { AddressStore } from '../../storage/address_store/address_store.js';
@@ -35,6 +38,7 @@ import type { SenderAddressBookStore } from '../../storage/tagging_store/sender_
35
38
  import { EventValidationRequest } from '../noir-structs/event_validation_request.js';
36
39
  import { LogRetrievalRequest } from '../noir-structs/log_retrieval_request.js';
37
40
  import { LogRetrievalResponse } from '../noir-structs/log_retrieval_response.js';
41
+ import { MessageTxContext } from '../noir-structs/message_tx_context.js';
38
42
  import { NoteValidationRequest } from '../noir-structs/note_validation_request.js';
39
43
  import { UtilityContext } from '../noir-structs/utility_context.js';
40
44
  import { pickNotes } from '../pick_notes.js';
@@ -57,6 +61,7 @@ export type UtilityExecutionOracleArgs = {
57
61
  senderAddressBookStore: SenderAddressBookStore;
58
62
  capsuleStore: CapsuleStore;
59
63
  privateEventStore: PrivateEventStore;
64
+ messageContextService: MessageContextService;
60
65
  jobId: string;
61
66
  log?: ReturnType<typeof createLogger>;
62
67
  scopes: AccessScopes;
@@ -84,8 +89,9 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
84
89
  protected readonly senderAddressBookStore: SenderAddressBookStore;
85
90
  protected readonly capsuleStore: CapsuleStore;
86
91
  protected readonly privateEventStore: PrivateEventStore;
92
+ protected readonly messageContextService: MessageContextService;
87
93
  protected readonly jobId: string;
88
- protected log: ReturnType<typeof createLogger>;
94
+ protected logger: ReturnType<typeof createLogger>;
89
95
  protected readonly scopes: AccessScopes;
90
96
 
91
97
  constructor(args: UtilityExecutionOracleArgs) {
@@ -102,22 +108,38 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
102
108
  this.senderAddressBookStore = args.senderAddressBookStore;
103
109
  this.capsuleStore = args.capsuleStore;
104
110
  this.privateEventStore = args.privateEventStore;
111
+ this.messageContextService = args.messageContextService;
105
112
  this.jobId = args.jobId;
106
- this.log = args.log ?? createLogger('simulator:client_view_context');
113
+ this.logger = args.log ?? createLogger('simulator:client_view_context');
107
114
  this.scopes = args.scopes;
108
115
  }
109
116
 
110
- public utilityAssertCompatibleOracleVersion(version: number): void {
117
+ public assertCompatibleOracleVersion(version: number): void {
118
+ // TODO(F-416): Remove this hack on v5 when protocol contracts are redeployed.
119
+ // Protocol contracts/canonical contracts shipped with committed bytecode that cannot be changed. Assert they use
120
+ // the expected pinned version or the current one. We want to allow for both the pinned and the current versions
121
+ // because we want this code to work with both the pinned and unpinned version since some branches do not have the
122
+ // pinned contracts (like e.g. next)
123
+ const LEGACY_ORACLE_VERSION = 12;
124
+ if (isProtocolContract(this.contractAddress)) {
125
+ if (version !== LEGACY_ORACLE_VERSION && version !== ORACLE_VERSION) {
126
+ throw new Error(
127
+ `Expected legacy oracle version ${LEGACY_ORACLE_VERSION} or current oracle version ${ORACLE_VERSION} for alpha payload contract at ${this.contractAddress}, got ${version}.`,
128
+ );
129
+ }
130
+ return;
131
+ }
132
+
111
133
  if (version !== ORACLE_VERSION) {
112
134
  throw new Error(`Incompatible oracle version. Expected version ${ORACLE_VERSION}, got ${version}.`);
113
135
  }
114
136
  }
115
137
 
116
- public utilityGetRandomField(): Fr {
138
+ public getRandomField(): Fr {
117
139
  return Fr.random();
118
140
  }
119
141
 
120
- public utilityGetUtilityContext(): UtilityContext {
142
+ public getUtilityContext(): UtilityContext {
121
143
  return new UtilityContext(this.anchorBlockHeader, this.contractAddress);
122
144
  }
123
145
 
@@ -128,7 +150,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
128
150
  * @throws If the keys are not registered in the key store.
129
151
  * @throws If scopes are defined and the account is not in the scopes.
130
152
  */
131
- public async utilityGetKeyValidationRequest(pkMHash: Fr): Promise<KeyValidationRequest> {
153
+ public async getKeyValidationRequest(pkMHash: Fr): Promise<KeyValidationRequest> {
132
154
  // If scopes are defined, check that the key belongs to an account in the scopes.
133
155
  if (this.scopes !== 'ALL_SCOPES' && this.scopes.length > 0) {
134
156
  let hasAccess = false;
@@ -151,7 +173,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
151
173
  * @param noteHash - The note hash to find in the note hash tree.
152
174
  * @returns The membership witness containing the leaf index and sibling path
153
175
  */
154
- public utilityGetNoteHashMembershipWitness(
176
+ public getNoteHashMembershipWitness(
155
177
  anchorBlockHash: BlockHash,
156
178
  noteHash: Fr,
157
179
  ): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
@@ -169,7 +191,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
169
191
  * @param blockHash - The block hash to find in the archive tree.
170
192
  * @returns The membership witness containing the leaf index and sibling path
171
193
  */
172
- public utilityGetBlockHashMembershipWitness(
194
+ public getBlockHashMembershipWitness(
173
195
  anchorBlockHash: BlockHash,
174
196
  blockHash: BlockHash,
175
197
  ): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined> {
@@ -182,7 +204,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
182
204
  * @param nullifier - Nullifier we try to find witness for.
183
205
  * @returns The nullifier membership witness (if found).
184
206
  */
185
- public utilityGetNullifierMembershipWitness(
207
+ public getNullifierMembershipWitness(
186
208
  blockHash: BlockHash,
187
209
  nullifier: Fr,
188
210
  ): Promise<NullifierMembershipWitness | undefined> {
@@ -198,7 +220,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
198
220
  * list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
199
221
  * we are trying to prove non-inclusion for.
200
222
  */
201
- public utilityGetLowNullifierMembershipWitness(
223
+ public getLowNullifierMembershipWitness(
202
224
  blockHash: BlockHash,
203
225
  nullifier: Fr,
204
226
  ): Promise<NullifierMembershipWitness | undefined> {
@@ -211,7 +233,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
211
233
  * @param leafSlot - The slot of the public data tree to get the witness for.
212
234
  * @returns - The witness
213
235
  */
214
- public utilityGetPublicDataWitness(blockHash: BlockHash, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
236
+ public getPublicDataWitness(blockHash: BlockHash, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
215
237
  return this.aztecNode.getPublicDataWitness(blockHash, leafSlot);
216
238
  }
217
239
 
@@ -220,7 +242,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
220
242
  * @param blockNumber - The number of a block of which to get the block header.
221
243
  * @returns Block extracted from a block with block number `blockNumber`.
222
244
  */
223
- public async utilityGetBlockHeader(blockNumber: BlockNumber): Promise<BlockHeader | undefined> {
245
+ public async getBlockHeader(blockNumber: BlockNumber): Promise<BlockHeader | undefined> {
224
246
  const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
225
247
  if (blockNumber > anchorBlockNumber) {
226
248
  throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
@@ -231,12 +253,18 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
231
253
  }
232
254
 
233
255
  /**
234
- * Retrieve the complete address associated to a given address.
256
+ * Retrieve the public keys and partial address associated to a given address.
235
257
  * @param account - The account address.
236
- * @returns A complete address associated with the input address, or `undefined` if not registered.
258
+ * @returns The public keys and partial address, or `undefined` if the account is not registered.
237
259
  */
238
- public utilityTryGetPublicKeysAndPartialAddress(account: AztecAddress): Promise<CompleteAddress | undefined> {
239
- return this.addressStore.getCompleteAddress(account);
260
+ public async tryGetPublicKeysAndPartialAddress(
261
+ account: AztecAddress,
262
+ ): Promise<{ publicKeys: PublicKeys; partialAddress: PartialAddress } | undefined> {
263
+ const completeAddress = await this.addressStore.getCompleteAddress(account);
264
+ if (!completeAddress) {
265
+ return undefined;
266
+ }
267
+ return { publicKeys: completeAddress.publicKeys, partialAddress: completeAddress.partialAddress };
240
268
  }
241
269
 
242
270
  protected async getCompleteAddressOrFail(account: AztecAddress): Promise<CompleteAddress> {
@@ -255,11 +283,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
255
283
  * @param address - Address.
256
284
  * @returns A contract instance.
257
285
  */
258
- public utilityGetContractInstance(address: AztecAddress): Promise<ContractInstance> {
259
- return this.getContractInstance(address);
260
- }
261
-
262
- protected async getContractInstance(address: AztecAddress): Promise<ContractInstance> {
286
+ public async getContractInstance(address: AztecAddress): Promise<ContractInstance> {
263
287
  const instance = await this.contractStore.getContractInstance(address);
264
288
  if (!instance) {
265
289
  throw new Error(`No contract instance found for address ${address.toString()}`);
@@ -273,7 +297,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
273
297
  * @param messageHash - Hash of the message to authenticate.
274
298
  * @returns Authentication witness for the requested message hash.
275
299
  */
276
- public utilityGetAuthWitness(messageHash: Fr): Promise<Fr[] | undefined> {
300
+ public getAuthWitness(messageHash: Fr): Promise<Fr[] | undefined> {
277
301
  return Promise.resolve(this.authWitnesses.find(w => w.requestHash.equals(messageHash))?.witness);
278
302
  }
279
303
 
@@ -299,7 +323,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
299
323
  * @param status - The status of notes to fetch.
300
324
  * @returns Array of note data.
301
325
  */
302
- public async utilityGetNotes(
326
+ public async getNotes(
303
327
  owner: AztecAddress | undefined,
304
328
  storageSlot: Fr,
305
329
  numSelects: number,
@@ -339,7 +363,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
339
363
  * @param innerNullifier - The inner nullifier.
340
364
  * @returns A boolean indicating whether the nullifier exists in the tree or not.
341
365
  */
342
- public async utilityCheckNullifierExists(innerNullifier: Fr) {
366
+ public async checkNullifierExists(innerNullifier: Fr) {
343
367
  const [nullifier, anchorBlockHash] = await Promise.all([
344
368
  siloNullifier(this.contractAddress, innerNullifier!),
345
369
  this.anchorBlockHeader.hash(),
@@ -358,7 +382,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
358
382
  * @dev Contract address and secret are only used to compute the nullifier to get non-nullified messages
359
383
  * @returns The l1 to l2 membership witness (index of message in the tree and sibling path).
360
384
  */
361
- public async utilityGetL1ToL2MembershipWitness(contractAddress: AztecAddress, messageHash: Fr, secret: Fr) {
385
+ public async getL1ToL2MembershipWitness(contractAddress: AztecAddress, messageHash: Fr, secret: Fr) {
362
386
  const [messageIndex, siblingPath] = await getNonNullifiedL1ToL2MessageWitness(
363
387
  this.aztecNode,
364
388
  contractAddress,
@@ -376,7 +400,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
376
400
  * @param startStorageSlot - The starting storage slot.
377
401
  * @param numberOfElements - Number of elements to read from the starting storage slot.
378
402
  */
379
- public async utilityStorageRead(
403
+ public async storageRead(
380
404
  blockHash: BlockHash,
381
405
  contractAddress: AztecAddress,
382
406
  startStorageSlot: Fr,
@@ -390,7 +414,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
390
414
  slots.map(storageSlot => this.aztecNode.getPublicStorageAt(blockHash, contractAddress, storageSlot)),
391
415
  );
392
416
 
393
- this.log.debug(
417
+ this.logger.debug(
394
418
  `Oracle storage read: slots=[${slots.map(slot => slot.toString()).join(', ')}] address=${contractAddress.toString()} values=[${values.join(', ')}]`,
395
419
  );
396
420
 
@@ -402,26 +426,26 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
402
426
  */
403
427
  async #getContractLogger(): Promise<Logger> {
404
428
  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
429
  // Purpose of instanceId is to distinguish logs from different instances of the same component. It makes sense
409
430
  // to re-use jobId as instanceId here as executions of different PXE jobs are isolated.
410
- this.contractLogger = createLogger(module, { instanceId: this.jobId });
431
+ this.contractLogger = await createContractLogger(
432
+ this.contractAddress,
433
+ addr => this.contractStore.getDebugContractName(addr),
434
+ { instanceId: this.jobId },
435
+ );
411
436
  }
412
437
  return this.contractLogger;
413
438
  }
414
439
 
415
- public async utilityLog(level: number, message: string, fields: Fr[]): Promise<void> {
440
+ public async log(level: number, message: string, fields: Fr[]): Promise<void> {
416
441
  if (!LogLevels[level]) {
417
442
  throw new Error(`Invalid log level: ${level}`);
418
443
  }
419
- const levelName = LogLevels[level];
420
444
  const logger = await this.#getContractLogger();
421
- logger[levelName](`${applyStringFormatting(message, fields)}`);
445
+ logContractMessage(logger, LogLevels[level], message, fields);
422
446
  }
423
447
 
424
- public async utilityFetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr) {
448
+ public async fetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr) {
425
449
  const logService = new LogService(
426
450
  this.aztecNode,
427
451
  this.anchorBlockHeader,
@@ -431,7 +455,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
431
455
  this.senderAddressBookStore,
432
456
  this.addressStore,
433
457
  this.jobId,
434
- this.log.getBindings(),
458
+ this.logger.getBindings(),
435
459
  );
436
460
 
437
461
  await logService.fetchTaggedLogs(this.contractAddress, pendingTaggedLogArrayBaseSlot, this.scopes);
@@ -447,10 +471,12 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
447
471
  * @param noteValidationRequestsArrayBaseSlot - The base slot of capsule array containing note validation requests.
448
472
  * @param eventValidationRequestsArrayBaseSlot - The base slot of capsule array containing event validation requests.
449
473
  */
450
- public async utilityValidateAndStoreEnqueuedNotesAndEvents(
474
+ public async validateAndStoreEnqueuedNotesAndEvents(
451
475
  contractAddress: AztecAddress,
452
476
  noteValidationRequestsArrayBaseSlot: Fr,
453
477
  eventValidationRequestsArrayBaseSlot: Fr,
478
+ maxNotePackedLen: number,
479
+ maxEventSerializedLen: number,
454
480
  ) {
455
481
  // TODO(#10727): allow other contracts to store notes
456
482
  if (!this.contractAddress.equals(contractAddress)) {
@@ -461,11 +487,11 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
461
487
  // faster as we don't need to wait for the network round-trip.
462
488
  const noteValidationRequests = (
463
489
  await this.capsuleStore.readCapsuleArray(contractAddress, noteValidationRequestsArrayBaseSlot, this.jobId)
464
- ).map(NoteValidationRequest.fromFields);
490
+ ).map(fields => NoteValidationRequest.fromFields(fields, maxNotePackedLen));
465
491
 
466
492
  const eventValidationRequests = (
467
493
  await this.capsuleStore.readCapsuleArray(contractAddress, eventValidationRequestsArrayBaseSlot, this.jobId)
468
- ).map(EventValidationRequest.fromFields);
494
+ ).map(fields => EventValidationRequest.fromFields(fields, maxEventSerializedLen));
469
495
 
470
496
  const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockHeader, this.jobId);
471
497
  const noteStorePromises = noteValidationRequests.map(request =>
@@ -503,7 +529,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
503
529
  await this.capsuleStore.setCapsuleArray(contractAddress, eventValidationRequestsArrayBaseSlot, [], this.jobId);
504
530
  }
505
531
 
506
- public async utilityBulkRetrieveLogs(
532
+ public async bulkRetrieveLogs(
507
533
  contractAddress: AztecAddress,
508
534
  logRetrievalRequestsArrayBaseSlot: Fr,
509
535
  logRetrievalResponsesArrayBaseSlot: Fr,
@@ -528,7 +554,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
528
554
  this.senderAddressBookStore,
529
555
  this.addressStore,
530
556
  this.jobId,
531
- this.log.getBindings(),
557
+ this.logger.getBindings(),
532
558
  );
533
559
 
534
560
  const maybeLogRetrievalResponses = await logService.bulkRetrieveLogs(logRetrievalRequests);
@@ -545,7 +571,48 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
545
571
  );
546
572
  }
547
573
 
548
- public utilityStoreCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
574
+ public async utilityResolveMessageContexts(
575
+ contractAddress: AztecAddress,
576
+ messageContextRequestsArrayBaseSlot: Fr,
577
+ messageContextResponsesArrayBaseSlot: Fr,
578
+ ) {
579
+ try {
580
+ if (!this.contractAddress.equals(contractAddress)) {
581
+ throw new Error(`Got a message context request from ${contractAddress}, expected ${this.contractAddress}`);
582
+ }
583
+ const requestCapsules = await this.capsuleStore.readCapsuleArray(
584
+ contractAddress,
585
+ messageContextRequestsArrayBaseSlot,
586
+ this.jobId,
587
+ );
588
+
589
+ const txHashes = requestCapsules.map((fields, i) => {
590
+ if (fields.length !== 1) {
591
+ throw new Error(
592
+ `Malformed message context request at index ${i}: expected 1 field (tx hash), got ${fields.length}`,
593
+ );
594
+ }
595
+ return fields[0];
596
+ });
597
+
598
+ const maybeMessageContexts = await this.messageContextService.resolveMessageContexts(
599
+ txHashes,
600
+ this.anchorBlockHeader.getBlockNumber(),
601
+ );
602
+
603
+ // Leave response in response capsule array.
604
+ await this.capsuleStore.setCapsuleArray(
605
+ contractAddress,
606
+ messageContextResponsesArrayBaseSlot,
607
+ maybeMessageContexts.map(MessageTxContext.toSerializedOption),
608
+ this.jobId,
609
+ );
610
+ } finally {
611
+ await this.capsuleStore.setCapsuleArray(contractAddress, messageContextRequestsArrayBaseSlot, [], this.jobId);
612
+ }
613
+ }
614
+
615
+ public storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
549
616
  if (!contractAddress.equals(this.contractAddress)) {
550
617
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
551
618
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
@@ -554,7 +621,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
554
621
  return Promise.resolve();
555
622
  }
556
623
 
557
- public async utilityLoadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
624
+ public async loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
558
625
  if (!contractAddress.equals(this.contractAddress)) {
559
626
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
560
627
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
@@ -566,7 +633,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
566
633
  );
567
634
  }
568
635
 
569
- public utilityDeleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void> {
636
+ public deleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void> {
570
637
  if (!contractAddress.equals(this.contractAddress)) {
571
638
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
572
639
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
@@ -575,12 +642,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
575
642
  return Promise.resolve();
576
643
  }
577
644
 
578
- public utilityCopyCapsule(
579
- contractAddress: AztecAddress,
580
- srcSlot: Fr,
581
- dstSlot: Fr,
582
- numEntries: number,
583
- ): Promise<void> {
645
+ public copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number): Promise<void> {
584
646
  if (!contractAddress.equals(this.contractAddress)) {
585
647
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
586
648
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
@@ -589,7 +651,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
589
651
  }
590
652
 
591
653
  // 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> {
654
+ public aes128Decrypt(ciphertext: Buffer, iv: Buffer, symKey: Buffer): Promise<Buffer> {
593
655
  const aes128 = new Aes128();
594
656
  return aes128.decryptBufferCBC(ciphertext, iv, symKey);
595
657
  }
@@ -600,11 +662,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
600
662
  * @param ephPk - The ephemeral public key to get the secret for.
601
663
  * @returns The secret for the given address.
602
664
  */
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> {
665
+ public async getSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point> {
608
666
  // TODO(#12656): return an app-siloed secret
609
667
  const recipientCompleteAddress = await this.getCompleteAddressOrFail(address);
610
668
  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
+ }
@@ -18,7 +18,7 @@ import type { NoteStore } from '../storage/note_store/note_store.js';
18
18
  export class PXEDebugUtils {
19
19
  #putJobInQueue!: <T>(job: (jobId: string) => Promise<T>) => Promise<T>;
20
20
  #getSimulatorForTx!: (overrides?: { contracts?: ContractOverrides }) => ContractFunctionSimulator;
21
- #simulateUtility!: (
21
+ #executeUtility!: (
22
22
  contractFunctionSimulator: ContractFunctionSimulator,
23
23
  call: FunctionCall,
24
24
  authWitnesses: AuthWitness[] | undefined,
@@ -37,7 +37,7 @@ export class PXEDebugUtils {
37
37
  public setPXEHelpers(
38
38
  putJobInQueue: <T>(job: (jobId: string) => Promise<T>) => Promise<T>,
39
39
  getSimulatorForTx: (overrides?: { contracts?: ContractOverrides }) => ContractFunctionSimulator,
40
- simulateUtility: (
40
+ executeUtility: (
41
41
  contractFunctionSimulator: ContractFunctionSimulator,
42
42
  call: FunctionCall,
43
43
  authWitnesses: AuthWitness[] | undefined,
@@ -47,7 +47,7 @@ export class PXEDebugUtils {
47
47
  ) {
48
48
  this.#putJobInQueue = putJobInQueue;
49
49
  this.#getSimulatorForTx = getSimulatorForTx;
50
- this.#simulateUtility = simulateUtility;
50
+ this.#executeUtility = executeUtility;
51
51
  }
52
52
 
53
53
  /**
@@ -73,7 +73,7 @@ export class PXEDebugUtils {
73
73
  filter.contractAddress,
74
74
  null,
75
75
  async (privateSyncCall, execScopes) =>
76
- await this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
76
+ await this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
77
77
  anchorBlockHeader,
78
78
  jobId,
79
79
  filter.scopes,
@@ -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,
@@ -0,0 +1,45 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import type { AztecNode } from '@aztec/stdlib/interfaces/server';
3
+ import { TxHash } from '@aztec/stdlib/tx';
4
+
5
+ import { MessageTxContext } from '../contract_function_simulator/noir-structs/message_tx_context.js';
6
+
7
+ /** Resolves transaction hashes into the context needed to process messages. */
8
+ export class MessageContextService {
9
+ constructor(private readonly aztecNode: AztecNode) {}
10
+
11
+ /**
12
+ * Resolves a list of tx hashes into their message contexts.
13
+ *
14
+ * For each tx hash, looks up the corresponding tx effect and extracts the note hashes and first nullifier needed to
15
+ * process messages that originated from that transaction. Returns `null` for tx hashes that are zero, not yet
16
+ * available, or in blocks beyond the anchor block.
17
+ */
18
+ resolveMessageContexts(txHashes: Fr[], anchorBlockNumber: number): Promise<(MessageTxContext | null)[]> {
19
+ // TODO: optimize, we might be hitting the node to get the same txHash repeatedly
20
+ return Promise.all(
21
+ txHashes.map(async txHashField => {
22
+ // A zero tx hash indicates a tx-less offchain message (e.g. one not tied to any onchain transaction).
23
+ // These messages don't have a transaction context to resolve, so we return null.
24
+ if (txHashField.isZero()) {
25
+ return null;
26
+ }
27
+
28
+ const txHash = TxHash.fromField(txHashField);
29
+ const txEffect = await this.aztecNode.getTxEffect(txHash);
30
+ if (!txEffect || txEffect.l2BlockNumber > anchorBlockNumber) {
31
+ return null;
32
+ }
33
+
34
+ // Every tx has at least one nullifier (the first nullifier derived from the tx hash). Hitting this condition
35
+ // would mean a buggy node, but since we need to access data.nullifiers[0], the defensive check does no harm.
36
+ const data = txEffect.data;
37
+ if (data.nullifiers.length === 0) {
38
+ throw new Error(`Tx effect for ${txHash} has no nullifiers`);
39
+ }
40
+
41
+ return new MessageTxContext(data.txHash, data.noteHashes, data.nullifiers[0]);
42
+ }),
43
+ );
44
+ }
45
+ }
@@ -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 = 16;
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 = '73ccb2a24bc9fe7514108be9ff98d7ca8734bc316fb7c1ec4329d1d32f412a55';