@aztec/pxe 0.0.1-commit.88e6f9396 → 0.0.1-commit.8c0b8ff

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 (179) hide show
  1. package/dest/bin/check_oracle_version.js +4 -4
  2. package/dest/block_synchronizer/block_synchronizer.d.ts +1 -1
  3. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  4. package/dest/block_synchronizer/block_synchronizer.js +6 -0
  5. package/dest/config/index.d.ts +2 -2
  6. package/dest/config/index.d.ts.map +1 -1
  7. package/dest/config/index.js +1 -1
  8. package/dest/config/package_info.js +1 -1
  9. package/dest/contract_function_simulator/contract_function_simulator.d.ts +6 -4
  10. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  11. package/dest/contract_function_simulator/contract_function_simulator.js +11 -6
  12. package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
  13. package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
  14. package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
  15. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -4
  16. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +3 -6
  18. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +1 -1
  19. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +1 -1
  20. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
  21. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -1
  22. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -4
  23. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  24. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +3 -6
  25. package/dest/contract_function_simulator/oracle/interfaces.d.ts +31 -20
  26. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  27. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +1 -1
  28. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -1
  29. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +28 -23
  30. package/dest/contract_function_simulator/oracle/oracle.d.ts +50 -20
  31. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  32. package/dest/contract_function_simulator/oracle/oracle.js +157 -41
  33. package/dest/contract_function_simulator/oracle/private_execution.js +1 -1
  34. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +7 -8
  35. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  36. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +19 -9
  37. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +56 -39
  38. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  39. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +202 -93
  40. package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
  41. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
  42. package/dest/contract_function_simulator/pick_notes.js +14 -3
  43. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
  44. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
  45. package/dest/contract_function_simulator/proxied_contract_data_source.js +3 -0
  46. package/dest/contract_logging.d.ts +9 -4
  47. package/dest/contract_logging.d.ts.map +1 -1
  48. package/dest/contract_logging.js +21 -6
  49. package/dest/contract_sync/contract_sync_service.d.ts +3 -4
  50. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
  51. package/dest/contract_sync/contract_sync_service.js +37 -35
  52. package/dest/contract_sync/helpers.d.ts +2 -3
  53. package/dest/contract_sync/helpers.d.ts.map +1 -1
  54. package/dest/contract_sync/helpers.js +7 -2
  55. package/dest/debug/pxe_debug_utils.d.ts +3 -3
  56. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  57. package/dest/entrypoints/client/bundle/index.d.ts +1 -2
  58. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  59. package/dest/entrypoints/client/bundle/index.js +0 -1
  60. package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
  61. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  62. package/dest/entrypoints/client/bundle/utils.js +2 -2
  63. package/dest/entrypoints/client/lazy/index.d.ts +1 -2
  64. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  65. package/dest/entrypoints/client/lazy/index.js +0 -1
  66. package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
  67. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  68. package/dest/entrypoints/client/lazy/utils.js +2 -2
  69. package/dest/entrypoints/pxe_creation_options.d.ts +3 -1
  70. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  71. package/dest/entrypoints/pxe_creation_options.js +3 -1
  72. package/dest/entrypoints/server/index.d.ts +2 -3
  73. package/dest/entrypoints/server/index.d.ts.map +1 -1
  74. package/dest/entrypoints/server/index.js +1 -2
  75. package/dest/entrypoints/server/utils.d.ts +2 -2
  76. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  77. package/dest/entrypoints/server/utils.js +2 -2
  78. package/dest/events/event_service.d.ts +3 -2
  79. package/dest/events/event_service.d.ts.map +1 -1
  80. package/dest/events/event_service.js +16 -4
  81. package/dest/events/private_event_filter_validator.d.ts +3 -2
  82. package/dest/events/private_event_filter_validator.d.ts.map +1 -1
  83. package/dest/events/private_event_filter_validator.js +15 -0
  84. package/dest/logs/log_service.d.ts +7 -8
  85. package/dest/logs/log_service.d.ts.map +1 -1
  86. package/dest/logs/log_service.js +27 -37
  87. package/dest/messages/message_context_service.d.ts +3 -3
  88. package/dest/messages/message_context_service.d.ts.map +1 -1
  89. package/dest/messages/message_context_service.js +3 -3
  90. package/dest/notes/note_service.d.ts +4 -5
  91. package/dest/notes/note_service.d.ts.map +1 -1
  92. package/dest/notes/note_service.js +14 -5
  93. package/dest/notes_filter.d.ts +2 -3
  94. package/dest/notes_filter.d.ts.map +1 -1
  95. package/dest/oracle_version.d.ts +4 -3
  96. package/dest/oracle_version.d.ts.map +1 -1
  97. package/dest/oracle_version.js +20 -10
  98. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  99. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  100. package/dest/private_kernel/private_kernel_execution_prover.js +4 -7
  101. package/dest/pxe.d.ts +6 -7
  102. package/dest/pxe.d.ts.map +1 -1
  103. package/dest/pxe.js +17 -12
  104. package/dest/storage/anchor_block_store/anchor_block_store.js +1 -1
  105. package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
  106. package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
  107. package/dest/storage/capsule_store/capsule_service.js +50 -0
  108. package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
  109. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
  110. package/dest/storage/capsule_store/capsule_store.js +36 -28
  111. package/dest/storage/capsule_store/index.d.ts +2 -1
  112. package/dest/storage/capsule_store/index.d.ts.map +1 -1
  113. package/dest/storage/capsule_store/index.js +1 -0
  114. package/dest/storage/contract_store/contract_store.d.ts +1 -1
  115. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  116. package/dest/storage/contract_store/contract_store.js +4 -2
  117. package/dest/storage/metadata.d.ts +1 -1
  118. package/dest/storage/metadata.js +1 -1
  119. package/dest/storage/note_store/note_store.d.ts +1 -1
  120. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  121. package/dest/storage/note_store/note_store.js +2 -2
  122. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +2 -2
  123. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  124. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +1 -15
  125. package/package.json +16 -16
  126. package/src/bin/check_oracle_version.ts +4 -4
  127. package/src/block_synchronizer/block_synchronizer.ts +6 -0
  128. package/src/config/index.ts +1 -1
  129. package/src/config/package_info.ts +1 -1
  130. package/src/contract_function_simulator/contract_function_simulator.ts +14 -9
  131. package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
  132. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -4
  133. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
  134. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -1
  135. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -4
  136. package/src/contract_function_simulator/oracle/interfaces.ts +46 -18
  137. package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +20 -51
  138. package/src/contract_function_simulator/oracle/oracle.ts +222 -36
  139. package/src/contract_function_simulator/oracle/private_execution.ts +1 -1
  140. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +21 -11
  141. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +342 -120
  142. package/src/contract_function_simulator/pick_notes.ts +14 -3
  143. package/src/contract_function_simulator/proxied_contract_data_source.ts +8 -1
  144. package/src/contract_logging.ts +18 -5
  145. package/src/contract_sync/contract_sync_service.ts +64 -69
  146. package/src/contract_sync/helpers.ts +4 -4
  147. package/src/debug/pxe_debug_utils.ts +3 -3
  148. package/src/entrypoints/client/bundle/index.ts +0 -1
  149. package/src/entrypoints/client/bundle/utils.ts +2 -3
  150. package/src/entrypoints/client/lazy/index.ts +0 -1
  151. package/src/entrypoints/client/lazy/utils.ts +2 -3
  152. package/src/entrypoints/pxe_creation_options.ts +7 -0
  153. package/src/entrypoints/server/index.ts +1 -2
  154. package/src/entrypoints/server/utils.ts +2 -3
  155. package/src/events/event_service.ts +17 -4
  156. package/src/events/private_event_filter_validator.ts +21 -1
  157. package/src/logs/log_service.ts +57 -78
  158. package/src/messages/message_context_service.ts +3 -4
  159. package/src/notes/note_service.ts +18 -8
  160. package/src/notes_filter.ts +1 -3
  161. package/src/oracle_version.ts +20 -10
  162. package/src/private_kernel/private_kernel_execution_prover.ts +4 -9
  163. package/src/pxe.ts +24 -16
  164. package/src/storage/anchor_block_store/anchor_block_store.ts +1 -1
  165. package/src/storage/capsule_store/capsule_service.ts +90 -0
  166. package/src/storage/capsule_store/capsule_store.ts +44 -26
  167. package/src/storage/capsule_store/index.ts +1 -0
  168. package/src/storage/contract_store/contract_store.ts +8 -6
  169. package/src/storage/metadata.ts +1 -1
  170. package/src/storage/note_store/note_store.ts +2 -5
  171. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +2 -14
  172. package/dest/access_scopes.d.ts +0 -9
  173. package/dest/access_scopes.d.ts.map +0 -1
  174. package/dest/access_scopes.js +0 -6
  175. package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts +0 -16
  176. package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts.map +0 -1
  177. package/dest/contract_function_simulator/noir-structs/message_tx_context.js +0 -57
  178. package/src/access_scopes.ts +0 -9
  179. package/src/contract_function_simulator/noir-structs/message_tx_context.ts +0 -55
@@ -15,6 +15,7 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
15
15
  import { BlockHash } from '@aztec/stdlib/block';
16
16
  import { ContractClassLog, ContractClassLogFields } from '@aztec/stdlib/logs';
17
17
 
18
+ import { ORACLE_VERSION_MAJOR, ORACLE_VERSION_MINOR } from '../../oracle_version.js';
18
19
  import type { IMiscOracle, IPrivateExecutionOracle, IUtilityExecutionOracle } from './interfaces.js';
19
20
  import { buildLegacyOracleCallbacks } from './legacy_oracle_mappings.js';
20
21
  import { packAsHintedNote } from './note_packing_utils.js';
@@ -27,6 +28,25 @@ export class UnavailableOracleError extends Error {
27
28
 
28
29
  /**
29
30
  * A data source that has all the apis required by Aztec.nr.
31
+ *
32
+ * ## Oracle naming conventions
33
+ *
34
+ * We try to keep oracle naming consistent, please see below the conventions we adhere to.
35
+ *
36
+ * Each oracle method name has the form `aztec_{scope}_{verb}{Object}`, where:
37
+ *
38
+ * - **Scope prefix** indicates the execution context required:
39
+ * - `aztec_prv_` — available only during private function execution.
40
+ * - `aztec_utl_` — available during both utility and private execution.
41
+ *
42
+ * - **Verb** signals the operation's semantics (verb-first, then object):
43
+ * - `get` — read / lookup / get data from oracle into contract.
44
+ * - `does`/`is`/`has` — predicate (returns boolean).
45
+ * - `emit`/`notify` — propagate data from contract to oracle.
46
+ * - `set` — contract driven oracle state mutation (capsules, execution cache, tagging, etc).
47
+ * - `call` — trigger nested execution (control flow).
48
+ * - `assert` — validate a condition, throw on failure.
49
+ * - Standalone verbs (`delete`, `copy`, `decrypt`, `log`, etc) are used when no generic verb fits.
30
50
  */
31
51
  export class Oracle {
32
52
  constructor(private handler: IMiscOracle | IUtilityExecutionOracle | IPrivateExecutionOracle) {}
@@ -92,12 +112,67 @@ export class Oracle {
92
112
  return acc;
93
113
  }, {} as ACIRCallback);
94
114
 
95
- return { ...callback, ...buildLegacyOracleCallbacks(this) };
115
+ const allCallbacks = { ...callback, ...buildLegacyOracleCallbacks(this) };
116
+
117
+ // Wrap in a Proxy to intercept access to missing oracle names and provide enhanced error messages when the
118
+ // contract's minor version is higher than the PXE's (i.e. the contract expects oracles that were added in a newer
119
+ // minor version).
120
+ const handler = this.handler;
121
+ return new Proxy(allCallbacks, {
122
+ get(target, prop: string) {
123
+ if (prop in target) {
124
+ return target[prop];
125
+ }
126
+ // Return a function that throws with an enhanced error message if applicable
127
+ return () => {
128
+ type NonOracleFunctionGetContractOracleVersion = {
129
+ nonOracleFunctionGetContractOracleVersion(): { major: number; minor: number } | undefined;
130
+ };
131
+
132
+ let contractVersion = undefined;
133
+ if ('nonOracleFunctionGetContractOracleVersion' in handler) {
134
+ contractVersion = (
135
+ handler as unknown as NonOracleFunctionGetContractOracleVersion
136
+ ).nonOracleFunctionGetContractOracleVersion();
137
+ }
138
+ if (!contractVersion) {
139
+ throw new Error(
140
+ `Oracle '${prop}' not found and the contract's oracle version is unknown (the version check oracle ` +
141
+ `was not called before '${prop}'). This usually means the contract was not compiled with the ` +
142
+ `#[aztec] macro, which injects the version check as the first oracle call in every private/utility ` +
143
+ `external function. If you're using a custom entry point, ensure assert_compatible_oracle_version() ` +
144
+ `is called before any other oracle calls. See https://docs.aztec.network/errors/8`,
145
+ );
146
+ } else if (contractVersion.minor > ORACLE_VERSION_MINOR) {
147
+ throw new Error(
148
+ `Oracle '${prop}' not found.` +
149
+ ` This usually means the contract requires a newer private execution environment than you have.` +
150
+ ` Upgrade your private execution environment to a compatible version. The contract was compiled with` +
151
+ ` Aztec.nr oracle version ${contractVersion.major}.${contractVersion.minor}, but this private` +
152
+ ` execution environment only supports up to ${ORACLE_VERSION_MAJOR}.${ORACLE_VERSION_MINOR}.` +
153
+ ` See https://docs.aztec.network/errors/8`,
154
+ );
155
+ } else {
156
+ throw new Error(
157
+ `Oracle '${prop}' not found.` +
158
+ ` The contract's oracle version (${contractVersion.major}.${contractVersion.minor}) is compatible` +
159
+ ` with this private execution environment (${ORACLE_VERSION_MAJOR}.${ORACLE_VERSION_MINOR}), so all` +
160
+ ` standard oracles should be available. This could mean the contract was compiled against a modified` +
161
+ ` version of Aztec.nr, or that it references an oracle that does not exist.` +
162
+ ` See https://docs.aztec.network/errors/8`,
163
+ );
164
+ }
165
+ };
166
+ },
167
+ });
96
168
  }
97
169
 
98
170
  // eslint-disable-next-line camelcase
99
- aztec_utl_assertCompatibleOracleVersion([version]: ACVMField[]) {
100
- this.handlerAsMisc().assertCompatibleOracleVersion(Fr.fromString(version).toNumber());
171
+ aztec_utl_assertCompatibleOracleVersionV2([major]: ACVMField[], [minor]: ACVMField[]) {
172
+ this.handlerAsMisc().assertCompatibleOracleVersion(
173
+ Fr.fromString(major).toNumber(),
174
+ Fr.fromString(minor).toNumber(),
175
+ );
101
176
  return Promise.resolve([]);
102
177
  }
103
178
 
@@ -108,14 +183,14 @@ export class Oracle {
108
183
  }
109
184
 
110
185
  // eslint-disable-next-line camelcase
111
- aztec_prv_storeInExecutionCache(values: ACVMField[], [hash]: ACVMField[]): Promise<ACVMField[]> {
112
- this.handlerAsPrivate().storeInExecutionCache(values.map(Fr.fromString), Fr.fromString(hash));
186
+ aztec_prv_setHashPreimage(values: ACVMField[], [hash]: ACVMField[]): Promise<ACVMField[]> {
187
+ this.handlerAsPrivate().setHashPreimage(values.map(Fr.fromString), Fr.fromString(hash));
113
188
  return Promise.resolve([]);
114
189
  }
115
190
 
116
191
  // eslint-disable-next-line camelcase
117
- async aztec_prv_loadFromExecutionCache([returnsHash]: ACVMField[]): Promise<ACVMField[][]> {
118
- const values = await this.handlerAsPrivate().loadFromExecutionCache(Fr.fromString(returnsHash));
192
+ async aztec_prv_getHashPreimage([returnsHash]: ACVMField[]): Promise<ACVMField[][]> {
193
+ const values = await this.handlerAsPrivate().getHashPreimage(Fr.fromString(returnsHash));
119
194
  return [values.map(toACVMField)];
120
195
  }
121
196
 
@@ -252,9 +327,9 @@ export class Oracle {
252
327
  }
253
328
 
254
329
  // eslint-disable-next-line camelcase
255
- async aztec_utl_tryGetPublicKeysAndPartialAddress([address]: ACVMField[]): Promise<(ACVMField | ACVMField[])[]> {
330
+ async aztec_utl_getPublicKeysAndPartialAddress([address]: ACVMField[]): Promise<(ACVMField | ACVMField[])[]> {
256
331
  const parsedAddress = AztecAddress.fromField(Fr.fromString(address));
257
- const result = await this.handlerAsUtility().tryGetPublicKeysAndPartialAddress(parsedAddress);
332
+ const result = await this.handlerAsUtility().getPublicKeysAndPartialAddress(parsedAddress);
258
333
 
259
334
  // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
260
335
  // with two fields: `some` (a boolean) and `value` (a field array in this case).
@@ -380,8 +455,8 @@ export class Oracle {
380
455
  }
381
456
 
382
457
  // eslint-disable-next-line camelcase
383
- async aztec_utl_checkNullifierExists([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
384
- const exists = await this.handlerAsUtility().checkNullifierExists(Fr.fromString(innerNullifier));
458
+ async aztec_utl_doesNullifierExist([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
459
+ const exists = await this.handlerAsUtility().doesNullifierExist(Fr.fromString(innerNullifier));
385
460
  return [toACVMField(exists)];
386
461
  }
387
462
 
@@ -400,13 +475,13 @@ export class Oracle {
400
475
  }
401
476
 
402
477
  // eslint-disable-next-line camelcase
403
- async aztec_utl_storageRead(
478
+ async aztec_utl_getFromPublicStorage(
404
479
  [blockHash]: ACVMField[],
405
480
  [contractAddress]: ACVMField[],
406
481
  [startStorageSlot]: ACVMField[],
407
482
  [numberOfElements]: ACVMField[],
408
483
  ): Promise<ACVMField[][]> {
409
- const values = await this.handlerAsUtility().storageRead(
484
+ const values = await this.handlerAsUtility().getFromPublicStorage(
410
485
  BlockHash.fromString(blockHash),
411
486
  new AztecAddress(Fr.fromString(contractAddress)),
412
487
  Fr.fromString(startStorageSlot),
@@ -464,8 +539,8 @@ export class Oracle {
464
539
  }
465
540
 
466
541
  // eslint-disable-next-line camelcase
467
- async aztec_prv_validatePublicCalldata([calldataHash]: ACVMField[]): Promise<ACVMField[]> {
468
- await this.handlerAsPrivate().validatePublicCalldata(Fr.fromString(calldataHash));
542
+ async aztec_prv_assertValidPublicCalldata([calldataHash]: ACVMField[]): Promise<ACVMField[]> {
543
+ await this.handlerAsPrivate().assertValidPublicCalldata(Fr.fromString(calldataHash));
469
544
  return [];
470
545
  }
471
546
 
@@ -476,8 +551,10 @@ export class Oracle {
476
551
  }
477
552
 
478
553
  // eslint-disable-next-line camelcase
479
- async aztec_prv_inRevertiblePhase([sideEffectCounter]: ACVMField[]): Promise<ACVMField[]> {
480
- const isRevertible = await this.handlerAsPrivate().inRevertiblePhase(Fr.fromString(sideEffectCounter).toNumber());
554
+ async aztec_prv_isExecutionInRevertiblePhase([sideEffectCounter]: ACVMField[]): Promise<ACVMField[]> {
555
+ const isRevertible = await this.handlerAsPrivate().isExecutionInRevertiblePhase(
556
+ Fr.fromString(sideEffectCounter).toNumber(),
557
+ );
481
558
  return Promise.resolve([toACVMField(isRevertible)]);
482
559
  }
483
560
 
@@ -491,11 +568,23 @@ export class Oracle {
491
568
  }
492
569
 
493
570
  // eslint-disable-next-line camelcase
494
- async aztec_utl_fetchTaggedLogs([pendingTaggedLogArrayBaseSlot]: ACVMField[]): Promise<ACVMField[]> {
495
- await this.handlerAsUtility().fetchTaggedLogs(Fr.fromString(pendingTaggedLogArrayBaseSlot));
571
+ async aztec_utl_getPendingTaggedLogs(
572
+ [pendingTaggedLogArrayBaseSlot]: ACVMField[],
573
+ [scope]: ACVMField[],
574
+ ): Promise<ACVMField[]> {
575
+ await this.handlerAsUtility().getPendingTaggedLogs(
576
+ Fr.fromString(pendingTaggedLogArrayBaseSlot),
577
+ AztecAddress.fromString(scope),
578
+ );
496
579
  return [];
497
580
  }
498
581
 
582
+ // eslint-disable-next-line camelcase
583
+ async aztec_utl_getPendingTaggedLogs_v2([scope]: ACVMField[]): Promise<ACVMField[]> {
584
+ const slot = await this.handlerAsUtility().getPendingTaggedLogsV2(AztecAddress.fromString(scope));
585
+ return [toACVMField(slot)];
586
+ }
587
+
499
588
  // eslint-disable-next-line camelcase
500
589
  async aztec_utl_validateAndStoreEnqueuedNotesAndEvents(
501
590
  [contractAddress]: ACVMField[],
@@ -503,6 +592,7 @@ export class Oracle {
503
592
  [eventValidationRequestsArrayBaseSlot]: ACVMField[],
504
593
  [maxNotePackedLen]: ACVMField[],
505
594
  [maxEventSerializedLen]: ACVMField[],
595
+ [scope]: ACVMField[],
506
596
  ): Promise<ACVMField[]> {
507
597
  await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(
508
598
  AztecAddress.fromString(contractAddress),
@@ -510,62 +600,103 @@ export class Oracle {
510
600
  Fr.fromString(eventValidationRequestsArrayBaseSlot),
511
601
  Fr.fromString(maxNotePackedLen).toNumber(),
512
602
  Fr.fromString(maxEventSerializedLen).toNumber(),
603
+ AztecAddress.fromString(scope),
513
604
  );
514
605
 
515
606
  return [];
516
607
  }
517
608
 
518
609
  // eslint-disable-next-line camelcase
519
- async aztec_utl_bulkRetrieveLogs(
610
+ async aztec_utl_validateAndStoreEnqueuedNotesAndEvents_v2(
611
+ [noteValidationRequestsArrayBaseSlot]: ACVMField[],
612
+ [eventValidationRequestsArrayBaseSlot]: ACVMField[],
613
+ [maxNotePackedLen]: ACVMField[],
614
+ [maxEventSerializedLen]: ACVMField[],
615
+ [scope]: ACVMField[],
616
+ ): Promise<ACVMField[]> {
617
+ await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEventsV2(
618
+ Fr.fromString(noteValidationRequestsArrayBaseSlot),
619
+ Fr.fromString(eventValidationRequestsArrayBaseSlot),
620
+ Fr.fromString(maxNotePackedLen).toNumber(),
621
+ Fr.fromString(maxEventSerializedLen).toNumber(),
622
+ AztecAddress.fromString(scope),
623
+ );
624
+ return [];
625
+ }
626
+
627
+ // eslint-disable-next-line camelcase
628
+ async aztec_utl_getLogsByTag(
520
629
  [contractAddress]: ACVMField[],
521
630
  [logRetrievalRequestsArrayBaseSlot]: ACVMField[],
522
631
  [logRetrievalResponsesArrayBaseSlot]: ACVMField[],
632
+ [scope]: ACVMField[],
523
633
  ): Promise<ACVMField[]> {
524
- await this.handlerAsUtility().bulkRetrieveLogs(
634
+ await this.handlerAsUtility().getLogsByTag(
525
635
  AztecAddress.fromString(contractAddress),
526
636
  Fr.fromString(logRetrievalRequestsArrayBaseSlot),
527
637
  Fr.fromString(logRetrievalResponsesArrayBaseSlot),
638
+ AztecAddress.fromString(scope),
528
639
  );
529
640
  return [];
530
641
  }
531
642
 
532
643
  // eslint-disable-next-line camelcase
533
- async aztec_utl_utilityResolveMessageContexts(
644
+ async aztec_utl_getMessageContextsByTxHash(
534
645
  [contractAddress]: ACVMField[],
535
646
  [messageContextRequestsArrayBaseSlot]: ACVMField[],
536
647
  [messageContextResponsesArrayBaseSlot]: ACVMField[],
648
+ [scope]: ACVMField[],
537
649
  ): Promise<ACVMField[]> {
538
- await this.handlerAsUtility().utilityResolveMessageContexts(
650
+ await this.handlerAsUtility().getMessageContextsByTxHash(
539
651
  AztecAddress.fromString(contractAddress),
540
652
  Fr.fromString(messageContextRequestsArrayBaseSlot),
541
653
  Fr.fromString(messageContextResponsesArrayBaseSlot),
654
+ AztecAddress.fromString(scope),
542
655
  );
543
656
  return [];
544
657
  }
545
658
 
546
659
  // eslint-disable-next-line camelcase
547
- async aztec_utl_storeCapsule(
660
+ async aztec_utl_getLogsByTag_v2([requestArrayBaseSlot]: ACVMField[]): Promise<ACVMField[]> {
661
+ const responseSlot = await this.handlerAsUtility().getLogsByTagV2(Fr.fromString(requestArrayBaseSlot));
662
+ return [toACVMField(responseSlot)];
663
+ }
664
+
665
+ // eslint-disable-next-line camelcase
666
+ async aztec_utl_getMessageContextsByTxHash_v2([requestArrayBaseSlot]: ACVMField[]): Promise<ACVMField[]> {
667
+ const responseSlot = await this.handlerAsUtility().getMessageContextsByTxHashV2(
668
+ Fr.fromString(requestArrayBaseSlot),
669
+ );
670
+ return [toACVMField(responseSlot)];
671
+ }
672
+
673
+ // eslint-disable-next-line camelcase
674
+ aztec_utl_setCapsule(
548
675
  [contractAddress]: ACVMField[],
549
676
  [slot]: ACVMField[],
550
677
  capsule: ACVMField[],
678
+ [scope]: ACVMField[],
551
679
  ): Promise<ACVMField[]> {
552
- await this.handlerAsUtility().storeCapsule(
680
+ this.handlerAsUtility().setCapsule(
553
681
  AztecAddress.fromField(Fr.fromString(contractAddress)),
554
682
  Fr.fromString(slot),
555
683
  capsule.map(Fr.fromString),
684
+ AztecAddress.fromField(Fr.fromString(scope)),
556
685
  );
557
- return [];
686
+ return Promise.resolve([]);
558
687
  }
559
688
 
560
689
  // eslint-disable-next-line camelcase
561
- async aztec_utl_loadCapsule(
690
+ async aztec_utl_getCapsule(
562
691
  [contractAddress]: ACVMField[],
563
692
  [slot]: ACVMField[],
564
693
  [tSize]: ACVMField[],
694
+ [scope]: ACVMField[],
565
695
  ): Promise<(ACVMField | ACVMField[])[]> {
566
- const values = await this.handlerAsUtility().loadCapsule(
696
+ const values = await this.handlerAsUtility().getCapsule(
567
697
  AztecAddress.fromField(Fr.fromString(contractAddress)),
568
698
  Fr.fromString(slot),
699
+ AztecAddress.fromField(Fr.fromString(scope)),
569
700
  );
570
701
 
571
702
  // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
@@ -580,12 +711,17 @@ export class Oracle {
580
711
  }
581
712
 
582
713
  // eslint-disable-next-line camelcase
583
- async aztec_utl_deleteCapsule([contractAddress]: ACVMField[], [slot]: ACVMField[]): Promise<ACVMField[]> {
584
- await this.handlerAsUtility().deleteCapsule(
714
+ aztec_utl_deleteCapsule(
715
+ [contractAddress]: ACVMField[],
716
+ [slot]: ACVMField[],
717
+ [scope]: ACVMField[],
718
+ ): Promise<ACVMField[]> {
719
+ this.handlerAsUtility().deleteCapsule(
585
720
  AztecAddress.fromField(Fr.fromString(contractAddress)),
586
721
  Fr.fromString(slot),
722
+ AztecAddress.fromField(Fr.fromString(scope)),
587
723
  );
588
- return [];
724
+ return Promise.resolve([]);
589
725
  }
590
726
 
591
727
  // eslint-disable-next-line camelcase
@@ -594,18 +730,66 @@ export class Oracle {
594
730
  [srcSlot]: ACVMField[],
595
731
  [dstSlot]: ACVMField[],
596
732
  [numEntries]: ACVMField[],
733
+ [scope]: ACVMField[],
597
734
  ): Promise<ACVMField[]> {
598
735
  await this.handlerAsUtility().copyCapsule(
599
736
  AztecAddress.fromField(Fr.fromString(contractAddress)),
600
737
  Fr.fromString(srcSlot),
601
738
  Fr.fromString(dstSlot),
602
739
  Fr.fromString(numEntries).toNumber(),
740
+ AztecAddress.fromField(Fr.fromString(scope)),
603
741
  );
604
742
  return [];
605
743
  }
606
744
 
607
745
  // eslint-disable-next-line camelcase
608
- async aztec_utl_tryAes128Decrypt(
746
+ aztec_utl_pushEphemeral([slot]: ACVMField[], elements: ACVMField[]): Promise<ACVMField[]> {
747
+ const newLen = this.handlerAsUtility().pushEphemeral(Fr.fromString(slot), elements.map(Fr.fromString));
748
+ return Promise.resolve([toACVMField(newLen)]);
749
+ }
750
+
751
+ // eslint-disable-next-line camelcase
752
+ aztec_utl_popEphemeral([slot]: ACVMField[]): Promise<ACVMField[][]> {
753
+ const element = this.handlerAsUtility().popEphemeral(Fr.fromString(slot));
754
+ return Promise.resolve([element.map(toACVMField)]);
755
+ }
756
+
757
+ // eslint-disable-next-line camelcase
758
+ aztec_utl_getEphemeral([slot]: ACVMField[], [index]: ACVMField[]): Promise<ACVMField[][]> {
759
+ const element = this.handlerAsUtility().getEphemeral(Fr.fromString(slot), Fr.fromString(index).toNumber());
760
+ return Promise.resolve([element.map(toACVMField)]);
761
+ }
762
+
763
+ // eslint-disable-next-line camelcase
764
+ aztec_utl_setEphemeral([slot]: ACVMField[], [index]: ACVMField[], elements: ACVMField[]): Promise<ACVMField[]> {
765
+ this.handlerAsUtility().setEphemeral(
766
+ Fr.fromString(slot),
767
+ Fr.fromString(index).toNumber(),
768
+ elements.map(Fr.fromString),
769
+ );
770
+ return Promise.resolve([]);
771
+ }
772
+
773
+ // eslint-disable-next-line camelcase
774
+ aztec_utl_getEphemeralLen([slot]: ACVMField[]): Promise<ACVMField[]> {
775
+ const len = this.handlerAsUtility().getEphemeralLen(Fr.fromString(slot));
776
+ return Promise.resolve([toACVMField(len)]);
777
+ }
778
+
779
+ // eslint-disable-next-line camelcase
780
+ aztec_utl_removeEphemeral([slot]: ACVMField[], [index]: ACVMField[]): Promise<ACVMField[]> {
781
+ this.handlerAsUtility().removeEphemeral(Fr.fromString(slot), Fr.fromString(index).toNumber());
782
+ return Promise.resolve([]);
783
+ }
784
+
785
+ // eslint-disable-next-line camelcase
786
+ aztec_utl_clearEphemeral([slot]: ACVMField[]): Promise<ACVMField[]> {
787
+ this.handlerAsUtility().clearEphemeral(Fr.fromString(slot));
788
+ return Promise.resolve([]);
789
+ }
790
+
791
+ // eslint-disable-next-line camelcase
792
+ async aztec_utl_decryptAes128(
609
793
  ciphertextBVecStorage: ACVMField[],
610
794
  [ciphertextLength]: ACVMField[],
611
795
  iv: ACVMField[],
@@ -617,7 +801,7 @@ export class Oracle {
617
801
 
618
802
  // Noir Option<BoundedVec> is encoded as [is_some: Field, storage: Field[], length: Field].
619
803
  try {
620
- const plaintext = await this.handlerAsUtility().aes128Decrypt(ciphertext, ivBuffer, symKeyBuffer);
804
+ const plaintext = await this.handlerAsUtility().decryptAes128(ciphertext, ivBuffer, symKeyBuffer);
621
805
  const [storage, length] = bufferToBoundedVec(plaintext, ciphertextBVecStorage.length);
622
806
  return [toACVMField(1), storage, length];
623
807
  } catch {
@@ -632,22 +816,24 @@ export class Oracle {
632
816
  [ephPKField0]: ACVMField[],
633
817
  [ephPKField1]: ACVMField[],
634
818
  [ephPKField2]: ACVMField[],
819
+ [contractAddress]: ACVMField[],
635
820
  ): Promise<ACVMField[]> {
636
821
  const secret = await this.handlerAsUtility().getSharedSecret(
637
822
  AztecAddress.fromField(Fr.fromString(address)),
638
823
  Point.fromFields([ephPKField0, ephPKField1, ephPKField2].map(Fr.fromString)),
824
+ AztecAddress.fromField(Fr.fromString(contractAddress)),
639
825
  );
640
- return secret.toFields().map(toACVMField);
826
+ return [toACVMField(secret)];
641
827
  }
642
828
 
643
829
  // eslint-disable-next-line camelcase
644
- aztec_utl_invalidateContractSyncCache(
830
+ aztec_utl_setContractSyncCacheInvalid(
645
831
  [contractAddress]: ACVMField[],
646
832
  scopes: ACVMField[],
647
833
  [scopeCount]: ACVMField[],
648
834
  ): Promise<ACVMField[]> {
649
835
  const scopeAddresses = scopes.slice(0, +scopeCount).map(s => AztecAddress.fromField(Fr.fromString(s)));
650
- this.handlerAsUtility().invalidateContractSyncCache(
836
+ this.handlerAsUtility().setContractSyncCacheInvalid(
651
837
  AztecAddress.fromField(Fr.fromString(contractAddress)),
652
838
  scopeAddresses,
653
839
  );
@@ -76,7 +76,7 @@ export async function executePrivateFunction(
76
76
 
77
77
  const contractClassLogs = privateExecutionOracle.getContractClassLogs();
78
78
 
79
- const rawReturnValues = await privateExecutionOracle.loadFromExecutionCache(publicInputs.returnsHash);
79
+ const rawReturnValues = await privateExecutionOracle.getHashPreimage(publicInputs.returnsHash);
80
80
 
81
81
  const newNotes = privateExecutionOracle.getNewNotes();
82
82
  const noteHashNullifierCounterMap = privateExecutionOracle.getNoteHashNullifierCounterMap();
@@ -25,7 +25,6 @@ import {
25
25
  type TxContext,
26
26
  } from '@aztec/stdlib/tx';
27
27
 
28
- import type { AccessScopes } from '../../access_scopes.js';
29
28
  import { NoteService } from '../../notes/note_service.js';
30
29
  import type { SenderTaggingStore } from '../../storage/tagging_store/sender_tagging_store.js';
31
30
  import { syncSenderTaggingIndexes } from '../../tagging/index.js';
@@ -43,7 +42,7 @@ export type PrivateExecutionOracleArgs = Omit<UtilityExecutionOracleArgs, 'contr
43
42
  txContext: TxContext;
44
43
  callContext: CallContext;
45
44
  /** Needed to trigger contract synchronization before nested calls */
46
- utilityExecutor: (call: FunctionCall, scopes: AccessScopes) => Promise<void>;
45
+ utilityExecutor: (call: FunctionCall, scopes: AztecAddress[]) => Promise<void>;
47
46
  executionCache: HashedValuesCache;
48
47
  noteCache: ExecutionNoteCache;
49
48
  taggingIndexCache: ExecutionTaggingIndexCache;
@@ -76,7 +75,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
76
75
  private readonly argsHash: Fr;
77
76
  private readonly txContext: TxContext;
78
77
  private readonly callContext: CallContext;
79
- private readonly utilityExecutor: (call: FunctionCall, scopes: AccessScopes) => Promise<void>;
78
+ private readonly utilityExecutor: (call: FunctionCall, scopes: AztecAddress[]) => Promise<void>;
80
79
  private readonly executionCache: HashedValuesCache;
81
80
  private readonly noteCache: ExecutionNoteCache;
82
81
  private readonly taggingIndexCache: ExecutionTaggingIndexCache;
@@ -210,6 +209,16 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
210
209
  recipient,
211
210
  );
212
211
 
212
+ if (!extendedSecret) {
213
+ // We'd only fail to compute an extended secret if the recipient is an invalid address. To prevent
214
+ // king-of-the-hill attacks, instead of failing we use a random tag. By including a correct-looking tag in the
215
+ // log, the transaction shape is preserved and no privacy is leaked, even if the tag is bogus.
216
+ this.logger.warn(`Computing a tag for invalid recipient ${recipient} - returning a random tag instead`, {
217
+ contractAddress: this.contractAddress,
218
+ });
219
+ return new Tag(Fr.random());
220
+ }
221
+
213
222
  const index = await this.#getIndexToUseForSecret(extendedSecret);
214
223
  this.logger.debug(
215
224
  `Incrementing tagging index for sender: ${sender}, recipient: ${recipient}, contract: ${this.contractAddress} to ${index}`,
@@ -265,7 +274,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
265
274
  * @param values - Values to store.
266
275
  * @returns The hash of the values.
267
276
  */
268
- public storeInExecutionCache(values: Fr[], hash: Fr) {
277
+ public setHashPreimage(values: Fr[], hash: Fr) {
269
278
  return this.executionCache.store(values, hash);
270
279
  }
271
280
 
@@ -274,7 +283,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
274
283
  * @param hash - Hash of the values.
275
284
  * @returns The values.
276
285
  */
277
- public loadFromExecutionCache(hash: Fr): Promise<Fr[]> {
286
+ public getHashPreimage(hash: Fr): Promise<Fr[]> {
278
287
  const preimage = this.executionCache.getPreimage(hash);
279
288
  if (!preimage) {
280
289
  throw new Error(`Preimage for hash ${hash.toString()} not found in cache`);
@@ -282,7 +291,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
282
291
  return Promise.resolve(preimage);
283
292
  }
284
293
 
285
- override async checkNullifierExists(innerNullifier: Fr): Promise<boolean> {
294
+ override async doesNullifierExist(innerNullifier: Fr): Promise<boolean> {
286
295
  // This oracle must be overridden because while utility execution can only meaningfully check if a nullifier exists
287
296
  // in the synched block, during private execution there's also the possibility of it being pending, i.e. created
288
297
  // in the current transaction.
@@ -295,7 +304,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
295
304
 
296
305
  return (
297
306
  this.noteCache.getNullifiers(this.contractAddress).has(nullifier) ||
298
- (await super.checkNullifierExists(innerNullifier))
307
+ (await super.doesNullifierExist(innerNullifier))
299
308
  );
300
309
  }
301
310
 
@@ -555,17 +564,18 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
555
564
  senderTaggingStore: this.senderTaggingStore,
556
565
  recipientTaggingStore: this.recipientTaggingStore,
557
566
  senderAddressBookStore: this.senderAddressBookStore,
558
- capsuleStore: this.capsuleStore,
567
+ capsuleService: this.capsuleService,
559
568
  privateEventStore: this.privateEventStore,
560
569
  messageContextService: this.messageContextService,
561
570
  contractSyncService: this.contractSyncService,
562
571
  jobId: this.jobId,
563
572
  totalPublicCalldataCount: this.totalPublicCalldataCount,
564
573
  sideEffectCounter,
565
- log: this.logger,
566
574
  scopes: this.scopes,
575
+ log: this.logger,
567
576
  senderForTags: this.senderForTags,
568
577
  simulator: this.simulator!,
578
+ l2TipsStore: this.l2TipsStore,
569
579
  });
570
580
 
571
581
  const setupTime = simulatorSetupTimer.ms();
@@ -598,7 +608,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
598
608
  }
599
609
 
600
610
  /** Validates the calldata preimage exists in the cache and checks cumulative calldata size is within limits. */
601
- public validatePublicCalldata(calldataHash: Fr) {
611
+ public assertValidPublicCalldata(calldataHash: Fr) {
602
612
  const calldata = this.executionCache.getPreimage(calldataHash);
603
613
  if (!calldata) {
604
614
  throw new Error('Calldata for public call not found in cache');
@@ -615,7 +625,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
615
625
  return this.noteCache.setMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter);
616
626
  }
617
627
 
618
- public inRevertiblePhase(sideEffectCounter: number): Promise<boolean> {
628
+ public isExecutionInRevertiblePhase(sideEffectCounter: number): Promise<boolean> {
619
629
  return Promise.resolve(this.noteCache.isSideEffectCounterRevertible(sideEffectCounter));
620
630
  }
621
631