@aztec/pxe 0.0.1-commit.d431d1c → 0.0.1-commit.d939eb5aa

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 (269) hide show
  1. package/dest/bin/check_oracle_version.js +5 -5
  2. package/dest/block_synchronizer/block_synchronizer.d.ts +9 -5
  3. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  4. package/dest/block_synchronizer/block_synchronizer.js +68 -16
  5. package/dest/config/index.d.ts +4 -2
  6. package/dest/config/index.d.ts.map +1 -1
  7. package/dest/config/index.js +12 -2
  8. package/dest/config/package_info.js +1 -1
  9. package/dest/contract_function_simulator/contract_function_simulator.d.ts +63 -31
  10. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  11. package/dest/contract_function_simulator/contract_function_simulator.js +206 -78
  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/execution_tagging_index_cache.d.ts +7 -7
  16. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
  18. package/dest/contract_function_simulator/index.d.ts +2 -1
  19. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  20. package/dest/contract_function_simulator/index.js +1 -0
  21. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +5 -7
  22. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  23. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +9 -11
  24. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +1 -1
  25. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +1 -1
  26. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
  27. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  28. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +2 -4
  29. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +5 -8
  30. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  31. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +7 -12
  32. package/dest/contract_function_simulator/oracle/interfaces.d.ts +65 -46
  33. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  34. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
  35. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
  36. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +47 -0
  37. package/dest/contract_function_simulator/oracle/oracle.d.ts +75 -42
  38. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  39. package/dest/contract_function_simulator/oracle/oracle.js +319 -112
  40. package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -22
  41. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  42. package/dest/contract_function_simulator/oracle/private_execution.js +5 -40
  43. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +59 -77
  44. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  45. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +120 -86
  46. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +134 -67
  47. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  48. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +337 -151
  49. package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
  50. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
  51. package/dest/contract_function_simulator/pick_notes.js +9 -2
  52. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
  53. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
  54. package/dest/contract_function_simulator/proxied_contract_data_source.js +3 -0
  55. package/dest/contract_logging.d.ts +27 -0
  56. package/dest/contract_logging.d.ts.map +1 -0
  57. package/dest/contract_logging.js +38 -0
  58. package/dest/contract_sync/contract_sync_service.d.ts +44 -0
  59. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
  60. package/dest/contract_sync/contract_sync_service.js +116 -0
  61. package/dest/contract_sync/helpers.d.ts +28 -0
  62. package/dest/contract_sync/helpers.d.ts.map +1 -0
  63. package/dest/contract_sync/helpers.js +60 -0
  64. package/dest/debug/pxe_debug_utils.d.ts +24 -10
  65. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  66. package/dest/debug/pxe_debug_utils.js +28 -17
  67. package/dest/entrypoints/client/bundle/index.d.ts +3 -1
  68. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  69. package/dest/entrypoints/client/bundle/index.js +2 -0
  70. package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
  71. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  72. package/dest/entrypoints/client/bundle/utils.js +23 -9
  73. package/dest/entrypoints/client/lazy/index.d.ts +3 -1
  74. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  75. package/dest/entrypoints/client/lazy/index.js +2 -0
  76. package/dest/entrypoints/client/lazy/utils.d.ts +3 -3
  77. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  78. package/dest/entrypoints/client/lazy/utils.js +24 -10
  79. package/dest/entrypoints/pxe_creation_options.d.ts +5 -2
  80. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  81. package/dest/entrypoints/pxe_creation_options.js +3 -1
  82. package/dest/entrypoints/server/index.d.ts +4 -2
  83. package/dest/entrypoints/server/index.d.ts.map +1 -1
  84. package/dest/entrypoints/server/index.js +3 -1
  85. package/dest/entrypoints/server/utils.d.ts +2 -2
  86. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  87. package/dest/entrypoints/server/utils.js +30 -11
  88. package/dest/events/event_service.d.ts +6 -6
  89. package/dest/events/event_service.d.ts.map +1 -1
  90. package/dest/events/event_service.js +21 -10
  91. package/dest/events/private_event_filter_validator.d.ts +3 -2
  92. package/dest/events/private_event_filter_validator.d.ts.map +1 -1
  93. package/dest/events/private_event_filter_validator.js +15 -0
  94. package/dest/job_coordinator/job_coordinator.d.ts +3 -2
  95. package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
  96. package/dest/job_coordinator/job_coordinator.js +3 -2
  97. package/dest/logs/log_service.d.ts +10 -9
  98. package/dest/logs/log_service.d.ts.map +1 -1
  99. package/dest/logs/log_service.js +50 -64
  100. package/dest/messages/message_context_service.d.ts +17 -0
  101. package/dest/messages/message_context_service.d.ts.map +1 -0
  102. package/dest/messages/message_context_service.js +36 -0
  103. package/dest/notes/note_service.d.ts +8 -8
  104. package/dest/notes/note_service.d.ts.map +1 -1
  105. package/dest/notes/note_service.js +29 -19
  106. package/dest/notes_filter.d.ts +24 -0
  107. package/dest/notes_filter.d.ts.map +1 -0
  108. package/dest/notes_filter.js +4 -0
  109. package/dest/oracle_version.d.ts +4 -3
  110. package/dest/oracle_version.d.ts.map +1 -1
  111. package/dest/oracle_version.js +20 -9
  112. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
  113. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
  114. package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
  115. package/dest/private_kernel/hints/index.d.ts +1 -1
  116. package/dest/private_kernel/hints/index.js +1 -1
  117. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
  118. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  119. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
  120. package/dest/private_kernel/hints/test_utils.d.ts +122 -0
  121. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
  122. package/dest/private_kernel/hints/test_utils.js +203 -0
  123. package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
  124. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  125. package/dest/private_kernel/private_kernel_execution_prover.js +20 -15
  126. package/dest/private_kernel/private_kernel_oracle.d.ts +8 -4
  127. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  128. package/dest/private_kernel/private_kernel_oracle.js +7 -3
  129. package/dest/pxe.d.ts +74 -24
  130. package/dest/pxe.d.ts.map +1 -1
  131. package/dest/pxe.js +142 -80
  132. package/dest/storage/address_store/address_store.d.ts +1 -1
  133. package/dest/storage/address_store/address_store.d.ts.map +1 -1
  134. package/dest/storage/address_store/address_store.js +12 -11
  135. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
  136. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
  137. package/dest/storage/anchor_block_store/anchor_block_store.js +8 -1
  138. package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
  139. package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
  140. package/dest/storage/capsule_store/capsule_service.js +50 -0
  141. package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
  142. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
  143. package/dest/storage/capsule_store/capsule_store.js +39 -36
  144. package/dest/storage/capsule_store/index.d.ts +2 -1
  145. package/dest/storage/capsule_store/index.d.ts.map +1 -1
  146. package/dest/storage/capsule_store/index.js +1 -0
  147. package/dest/storage/contract_store/contract_store.d.ts +42 -16
  148. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  149. package/dest/storage/contract_store/contract_store.js +157 -84
  150. package/dest/storage/metadata.d.ts +1 -1
  151. package/dest/storage/metadata.js +1 -1
  152. package/dest/storage/note_store/note_store.d.ts +47 -49
  153. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  154. package/dest/storage/note_store/note_store.js +278 -252
  155. package/dest/storage/note_store/stored_note.d.ts +16 -0
  156. package/dest/storage/note_store/stored_note.d.ts.map +1 -0
  157. package/dest/storage/note_store/stored_note.js +43 -0
  158. package/dest/storage/private_event_store/private_event_store.d.ts +17 -4
  159. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  160. package/dest/storage/private_event_store/private_event_store.js +198 -147
  161. package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
  162. package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
  163. package/dest/storage/private_event_store/stored_private_event.js +56 -0
  164. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
  165. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  166. package/dest/storage/tagging_store/recipient_tagging_store.js +31 -19
  167. package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
  168. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
  169. package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
  170. package/dest/storage/tagging_store/sender_tagging_store.d.ts +29 -28
  171. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  172. package/dest/storage/tagging_store/sender_tagging_store.js +233 -137
  173. package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
  174. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
  175. package/dest/tagging/get_all_logs_by_tags.js +60 -0
  176. package/dest/tagging/index.d.ts +4 -3
  177. package/dest/tagging/index.d.ts.map +1 -1
  178. package/dest/tagging/index.js +2 -1
  179. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +5 -5
  180. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  181. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +7 -21
  182. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
  183. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +7 -7
  184. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  185. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +16 -12
  186. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +5 -8
  187. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  188. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +13 -7
  189. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
  190. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  191. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +23 -16
  192. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +6 -7
  193. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  194. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +42 -27
  195. package/package.json +25 -16
  196. package/src/bin/check_oracle_version.ts +5 -4
  197. package/src/block_synchronizer/block_synchronizer.ts +82 -33
  198. package/src/config/index.ts +9 -1
  199. package/src/config/package_info.ts +1 -1
  200. package/src/contract_function_simulator/contract_function_simulator.ts +366 -142
  201. package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
  202. package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
  203. package/src/contract_function_simulator/index.ts +1 -0
  204. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +10 -10
  205. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
  206. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -5
  207. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +5 -11
  208. package/src/contract_function_simulator/oracle/interfaces.ts +95 -58
  209. package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +104 -0
  210. package/src/contract_function_simulator/oracle/oracle.ts +404 -150
  211. package/src/contract_function_simulator/oracle/private_execution.ts +5 -64
  212. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +160 -182
  213. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +564 -182
  214. package/src/contract_function_simulator/pick_notes.ts +9 -2
  215. package/src/contract_function_simulator/proxied_contract_data_source.ts +8 -1
  216. package/src/contract_logging.ts +52 -0
  217. package/src/contract_sync/contract_sync_service.ts +176 -0
  218. package/src/contract_sync/helpers.ts +98 -0
  219. package/src/debug/pxe_debug_utils.ts +63 -18
  220. package/src/entrypoints/client/bundle/index.ts +2 -0
  221. package/src/entrypoints/client/bundle/utils.ts +18 -18
  222. package/src/entrypoints/client/lazy/index.ts +2 -0
  223. package/src/entrypoints/client/lazy/utils.ts +19 -18
  224. package/src/entrypoints/pxe_creation_options.ts +9 -1
  225. package/src/entrypoints/server/index.ts +3 -1
  226. package/src/entrypoints/server/utils.ts +24 -29
  227. package/src/events/event_service.ts +22 -11
  228. package/src/events/private_event_filter_validator.ts +21 -1
  229. package/src/job_coordinator/job_coordinator.ts +4 -3
  230. package/src/logs/log_service.ts +93 -105
  231. package/src/messages/message_context_service.ts +44 -0
  232. package/src/notes/note_service.ts +38 -26
  233. package/src/notes_filter.ts +24 -0
  234. package/src/oracle_version.ts +20 -9
  235. package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
  236. package/src/private_kernel/hints/index.ts +1 -1
  237. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
  238. package/src/private_kernel/hints/test_utils.ts +325 -0
  239. package/src/private_kernel/private_kernel_execution_prover.ts +24 -19
  240. package/src/private_kernel/private_kernel_oracle.ts +9 -9
  241. package/src/pxe.ts +272 -126
  242. package/src/storage/address_store/address_store.ts +15 -15
  243. package/src/storage/anchor_block_store/anchor_block_store.ts +8 -0
  244. package/src/storage/capsule_store/capsule_service.ts +90 -0
  245. package/src/storage/capsule_store/capsule_store.ts +42 -34
  246. package/src/storage/capsule_store/index.ts +1 -0
  247. package/src/storage/contract_store/contract_store.ts +186 -96
  248. package/src/storage/metadata.ts +1 -1
  249. package/src/storage/note_store/note_store.ts +318 -318
  250. package/src/storage/note_store/stored_note.ts +48 -0
  251. package/src/storage/private_event_store/private_event_store.ts +250 -190
  252. package/src/storage/private_event_store/stored_private_event.ts +73 -0
  253. package/src/storage/tagging_store/recipient_tagging_store.ts +38 -24
  254. package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
  255. package/src/storage/tagging_store/sender_tagging_store.ts +287 -156
  256. package/src/tagging/get_all_logs_by_tags.ts +92 -0
  257. package/src/tagging/index.ts +3 -2
  258. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +19 -24
  259. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
  260. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +17 -16
  261. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +25 -10
  262. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +29 -26
  263. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +39 -29
  264. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
  265. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
  266. package/dest/tree_membership/tree_membership_service.d.ts +0 -50
  267. package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
  268. package/dest/tree_membership/tree_membership_service.js +0 -75
  269. package/src/tree_membership/tree_membership_service.ts +0 -97
@@ -12,11 +12,12 @@ import {
12
12
  } from '@aztec/simulator/client';
13
13
  import { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
14
14
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
15
- import { L2BlockHash } from '@aztec/stdlib/block';
15
+ import { BlockHash } from '@aztec/stdlib/block';
16
16
  import { ContractClassLog, ContractClassLogFields } from '@aztec/stdlib/logs';
17
- import { MerkleTreeId } from '@aztec/stdlib/trees';
18
17
 
18
+ import { ORACLE_VERSION_MAJOR, ORACLE_VERSION_MINOR } from '../../oracle_version.js';
19
19
  import type { IMiscOracle, IPrivateExecutionOracle, IUtilityExecutionOracle } from './interfaces.js';
20
+ import { buildLegacyOracleCallbacks } from './legacy_oracle_mappings.js';
20
21
  import { packAsHintedNote } from './note_packing_utils.js';
21
22
 
22
23
  export class UnavailableOracleError extends Error {
@@ -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) {}
@@ -70,12 +90,12 @@ export class Oracle {
70
90
  name => !excludedProps.includes(name as (typeof excludedProps)[number]),
71
91
  );
72
92
 
73
- // Validate oracle names - these must be prefixed with either "private" or "utility" to indicate their scope
93
+ // Validate oracle names - these must be prefixed with either "aztec_prv_" or "aztec_utl_" to indicate their scope
74
94
  // and must correspond to a function on the Oracle class.
75
95
  oracleNames.forEach(name => {
76
- if (!name.startsWith('private') && !name.startsWith('utility')) {
96
+ if (!name.startsWith('aztec_prv_') && !name.startsWith('aztec_utl_')) {
77
97
  throw new Error(
78
- `Oracle function "${name}" must be prefixed with either "private" or "utility" to indicate its scope`,
98
+ `Oracle function "${name}" must be prefixed with either "aztec_prv_" or "aztec_utl_" to indicate its scope`,
79
99
  );
80
100
  }
81
101
 
@@ -86,48 +106,110 @@ export class Oracle {
86
106
  });
87
107
 
88
108
  // Build callback object and return it
89
- return oracleNames.reduce((acc, name) => {
109
+ const callback = oracleNames.reduce((acc, name) => {
90
110
  const method = this[name as keyof Omit<Oracle, (typeof excludedProps)[number]>];
91
111
  acc[name] = method.bind(this);
92
112
  return acc;
93
113
  }, {} as ACIRCallback);
114
+
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
+ });
94
168
  }
95
169
 
96
- utilityAssertCompatibleOracleVersion([version]: ACVMField[]) {
97
- this.handlerAsMisc().utilityAssertCompatibleOracleVersion(Fr.fromString(version).toNumber());
170
+ // eslint-disable-next-line camelcase
171
+ aztec_utl_assertCompatibleOracleVersionV2([major]: ACVMField[], [minor]: ACVMField[]) {
172
+ this.handlerAsMisc().assertCompatibleOracleVersion(
173
+ Fr.fromString(major).toNumber(),
174
+ Fr.fromString(minor).toNumber(),
175
+ );
98
176
  return Promise.resolve([]);
99
177
  }
100
178
 
101
- utilityGetRandomField(): Promise<ACVMField[]> {
102
- const val = this.handlerAsMisc().utilityGetRandomField();
179
+ // eslint-disable-next-line camelcase
180
+ aztec_utl_getRandomField(): Promise<ACVMField[]> {
181
+ const val = this.handlerAsMisc().getRandomField();
103
182
  return Promise.resolve([toACVMField(val)]);
104
183
  }
105
184
 
106
- privateStoreInExecutionCache(values: ACVMField[], [hash]: ACVMField[]): Promise<ACVMField[]> {
107
- this.handlerAsPrivate().privateStoreInExecutionCache(values.map(Fr.fromString), Fr.fromString(hash));
185
+ // eslint-disable-next-line camelcase
186
+ aztec_prv_setHashPreimage(values: ACVMField[], [hash]: ACVMField[]): Promise<ACVMField[]> {
187
+ this.handlerAsPrivate().setHashPreimage(values.map(Fr.fromString), Fr.fromString(hash));
108
188
  return Promise.resolve([]);
109
189
  }
110
190
 
111
- async privateLoadFromExecutionCache([returnsHash]: ACVMField[]): Promise<ACVMField[][]> {
112
- const values = await this.handlerAsPrivate().privateLoadFromExecutionCache(Fr.fromString(returnsHash));
191
+ // eslint-disable-next-line camelcase
192
+ async aztec_prv_getHashPreimage([returnsHash]: ACVMField[]): Promise<ACVMField[][]> {
193
+ const values = await this.handlerAsPrivate().getHashPreimage(Fr.fromString(returnsHash));
113
194
  return [values.map(toACVMField)];
114
195
  }
115
196
 
116
- utilityGetUtilityContext(): Promise<(ACVMField | ACVMField[])[]> {
117
- const context = this.handlerAsUtility().utilityGetUtilityContext();
197
+ // eslint-disable-next-line camelcase
198
+ aztec_utl_getUtilityContext(): Promise<(ACVMField | ACVMField[])[]> {
199
+ const context = this.handlerAsUtility().getUtilityContext();
118
200
  return Promise.resolve(context.toNoirRepresentation());
119
201
  }
120
202
 
121
- async utilityGetKeyValidationRequest([pkMHash]: ACVMField[]): Promise<ACVMField[]> {
122
- const keyValidationRequest = await this.handlerAsUtility().utilityGetKeyValidationRequest(Fr.fromString(pkMHash));
203
+ // eslint-disable-next-line camelcase
204
+ async aztec_utl_getKeyValidationRequest([pkMHash]: ACVMField[]): Promise<ACVMField[]> {
205
+ const keyValidationRequest = await this.handlerAsUtility().getKeyValidationRequest(Fr.fromString(pkMHash));
123
206
 
124
207
  return keyValidationRequest.toFields().map(toACVMField);
125
208
  }
126
209
 
127
- async utilityGetContractInstance([address]: ACVMField[]): Promise<ACVMField[]> {
128
- const instance = await this.handlerAsUtility().utilityGetContractInstance(
129
- AztecAddress.fromField(Fr.fromString(address)),
130
- );
210
+ // eslint-disable-next-line camelcase
211
+ async aztec_utl_getContractInstance([address]: ACVMField[]): Promise<ACVMField[]> {
212
+ const instance = await this.handlerAsUtility().getContractInstance(AztecAddress.fromField(Fr.fromString(address)));
131
213
 
132
214
  return [
133
215
  instance.salt,
@@ -138,39 +220,49 @@ export class Oracle {
138
220
  ].map(toACVMField);
139
221
  }
140
222
 
141
- async utilityGetMembershipWitness(
223
+ // eslint-disable-next-line camelcase
224
+ async aztec_utl_getNoteHashMembershipWitness(
225
+ [anchorBlockHash]: ACVMField[],
226
+ [noteHash]: ACVMField[],
227
+ ): Promise<(ACVMField | ACVMField[])[]> {
228
+ const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
229
+ const parsedNoteHash = Fr.fromString(noteHash);
230
+
231
+ const witness = await this.handlerAsUtility().getNoteHashMembershipWitness(parsedAnchorBlockHash, parsedNoteHash);
232
+ if (!witness) {
233
+ throw new Error(
234
+ `Note hash ${noteHash} not found in the note hash tree at anchor block hash ${parsedAnchorBlockHash.toString()}.`,
235
+ );
236
+ }
237
+ return witness.toNoirRepresentation();
238
+ }
239
+
240
+ // eslint-disable-next-line camelcase
241
+ async aztec_utl_getBlockHashMembershipWitness(
242
+ [anchorBlockHash]: ACVMField[],
142
243
  [blockHash]: ACVMField[],
143
- [treeId]: ACVMField[],
144
- [leafValue]: ACVMField[],
145
244
  ): Promise<(ACVMField | ACVMField[])[]> {
146
- const parsedBlockHash = L2BlockHash.fromString(blockHash);
147
- const parsedTreeId = Fr.fromString(treeId).toNumber();
148
- const parsedLeafValue = Fr.fromString(leafValue);
149
-
150
- const witness = await this.handlerAsUtility().utilityGetMembershipWitness(
151
- parsedBlockHash,
152
- parsedTreeId,
153
- parsedLeafValue,
154
- );
245
+ const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
246
+ const parsedBlockHash = BlockHash.fromString(blockHash);
247
+
248
+ const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(parsedAnchorBlockHash, parsedBlockHash);
155
249
  if (!witness) {
156
250
  throw new Error(
157
- `Leaf ${leafValue} not found in the tree ${MerkleTreeId[parsedTreeId]} at block hash ${parsedBlockHash.toString()}.`,
251
+ `Block hash ${parsedBlockHash.toString()} not found in the archive tree at anchor block ${parsedAnchorBlockHash.toString()}.`,
158
252
  );
159
253
  }
160
- return [toACVMField(witness[0]), witness.slice(1).map(toACVMField)];
254
+ return witness.toNoirRepresentation();
161
255
  }
162
256
 
163
- async utilityGetNullifierMembershipWitness(
257
+ // eslint-disable-next-line camelcase
258
+ async aztec_utl_getNullifierMembershipWitness(
164
259
  [blockHash]: ACVMField[],
165
260
  [nullifier]: ACVMField[], // nullifier, we try to find the witness for (to prove inclusion)
166
261
  ): Promise<(ACVMField | ACVMField[])[]> {
167
- const parsedBlockHash = L2BlockHash.fromString(blockHash);
262
+ const parsedBlockHash = BlockHash.fromString(blockHash);
168
263
  const parsedNullifier = Fr.fromString(nullifier);
169
264
 
170
- const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(
171
- parsedBlockHash,
172
- parsedNullifier,
173
- );
265
+ const witness = await this.handlerAsUtility().getNullifierMembershipWitness(parsedBlockHash, parsedNullifier);
174
266
  if (!witness) {
175
267
  throw new Error(
176
268
  `Nullifier witness not found for nullifier ${parsedNullifier} at block hash ${parsedBlockHash.toString()}.`,
@@ -179,17 +271,15 @@ export class Oracle {
179
271
  return witness.toNoirRepresentation();
180
272
  }
181
273
 
182
- async utilityGetLowNullifierMembershipWitness(
274
+ // eslint-disable-next-line camelcase
275
+ async aztec_utl_getLowNullifierMembershipWitness(
183
276
  [blockHash]: ACVMField[],
184
277
  [nullifier]: ACVMField[], // nullifier, we try to find the low nullifier witness for (to prove non-inclusion)
185
278
  ): Promise<(ACVMField | ACVMField[])[]> {
186
- const parsedBlockHash = L2BlockHash.fromString(blockHash);
279
+ const parsedBlockHash = BlockHash.fromString(blockHash);
187
280
  const parsedNullifier = Fr.fromString(nullifier);
188
281
 
189
- const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(
190
- parsedBlockHash,
191
- parsedNullifier,
192
- );
282
+ const witness = await this.handlerAsUtility().getLowNullifierMembershipWitness(parsedBlockHash, parsedNullifier);
193
283
  if (!witness) {
194
284
  throw new Error(
195
285
  `Low nullifier witness not found for nullifier ${parsedNullifier} at block hash ${parsedBlockHash.toString()}.`,
@@ -198,14 +288,15 @@ export class Oracle {
198
288
  return witness.toNoirRepresentation();
199
289
  }
200
290
 
201
- async utilityGetPublicDataWitness(
291
+ // eslint-disable-next-line camelcase
292
+ async aztec_utl_getPublicDataWitness(
202
293
  [blockHash]: ACVMField[],
203
294
  [leafSlot]: ACVMField[],
204
295
  ): Promise<(ACVMField | ACVMField[])[]> {
205
- const parsedBlockHash = L2BlockHash.fromString(blockHash);
296
+ const parsedBlockHash = BlockHash.fromString(blockHash);
206
297
  const parsedLeafSlot = Fr.fromString(leafSlot);
207
298
 
208
- const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(parsedBlockHash, parsedLeafSlot);
299
+ const witness = await this.handlerAsUtility().getPublicDataWitness(parsedBlockHash, parsedLeafSlot);
209
300
  if (!witness) {
210
301
  throw new Error(
211
302
  `Public data witness not found for slot ${parsedLeafSlot} at block hash ${parsedBlockHash.toString()}.`,
@@ -214,34 +305,45 @@ export class Oracle {
214
305
  return witness.toNoirRepresentation();
215
306
  }
216
307
 
217
- async utilityGetBlockHeader([blockNumber]: ACVMField[]): Promise<ACVMField[]> {
308
+ // eslint-disable-next-line camelcase
309
+ async aztec_utl_getBlockHeader([blockNumber]: ACVMField[]): Promise<ACVMField[]> {
218
310
  const parsedBlockNumber = Fr.fromString(blockNumber).toNumber();
219
311
 
220
- const header = await this.handlerAsUtility().utilityGetBlockHeader(BlockNumber(parsedBlockNumber));
312
+ const header = await this.handlerAsUtility().getBlockHeader(BlockNumber(parsedBlockNumber));
221
313
  if (!header) {
222
314
  throw new Error(`Block header not found for block ${parsedBlockNumber}.`);
223
315
  }
224
316
  return header.toFields().map(toACVMField);
225
317
  }
226
318
 
227
- async utilityGetAuthWitness([messageHash]: ACVMField[]): Promise<ACVMField[][]> {
319
+ // eslint-disable-next-line camelcase
320
+ async aztec_utl_getAuthWitness([messageHash]: ACVMField[]): Promise<ACVMField[][]> {
228
321
  const messageHashField = Fr.fromString(messageHash);
229
- const witness = await this.handlerAsUtility().utilityGetAuthWitness(messageHashField);
322
+ const witness = await this.handlerAsUtility().getAuthWitness(messageHashField);
230
323
  if (!witness) {
231
324
  throw new Error(`Unknown auth witness for message hash ${messageHashField}`);
232
325
  }
233
326
  return [witness.map(toACVMField)];
234
327
  }
235
328
 
236
- async utilityGetPublicKeysAndPartialAddress([address]: ACVMField[]): Promise<ACVMField[][]> {
329
+ // eslint-disable-next-line camelcase
330
+ async aztec_utl_getPublicKeysAndPartialAddress([address]: ACVMField[]): Promise<(ACVMField | ACVMField[])[]> {
237
331
  const parsedAddress = AztecAddress.fromField(Fr.fromString(address));
238
- const { publicKeys, partialAddress } =
239
- await this.handlerAsUtility().utilityGetPublicKeysAndPartialAddress(parsedAddress);
332
+ const result = await this.handlerAsUtility().getPublicKeysAndPartialAddress(parsedAddress);
240
333
 
241
- return [[...publicKeys.toFields(), partialAddress].map(toACVMField)];
334
+ // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
335
+ // with two fields: `some` (a boolean) and `value` (a field array in this case).
336
+ if (result === undefined) {
337
+ // No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
338
+ return [toACVMField(0), Array(13).fill(toACVMField(0))];
339
+ } else {
340
+ // Data was found so we set `some` to 1 and return it along with `value`.
341
+ return [toACVMField(1), [...result.publicKeys.toFields(), result.partialAddress].map(toACVMField)];
342
+ }
242
343
  }
243
344
 
244
- async utilityGetNotes(
345
+ // eslint-disable-next-line camelcase
346
+ async aztec_utl_getNotes(
245
347
  [ownerSome]: ACVMField[],
246
348
  [ownerValue]: ACVMField[],
247
349
  [storageSlot]: ACVMField[],
@@ -263,7 +365,7 @@ export class Oracle {
263
365
  ): Promise<(ACVMField | ACVMField[])[]> {
264
366
  // Parse Option<AztecAddress>: ownerSome is 0 for None, 1 for Some
265
367
  const owner = Fr.fromString(ownerSome).toNumber() === 1 ? AztecAddress.fromString(ownerValue) : undefined;
266
- const noteDatas = await this.handlerAsUtility().utilityGetNotes(
368
+ const noteDatas = await this.handlerAsUtility().getNotes(
267
369
  owner,
268
370
  Fr.fromString(storageSlot),
269
371
  +numSelects,
@@ -302,7 +404,8 @@ export class Oracle {
302
404
  return arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfACVMFieldArrays, +maxNotes, +packedHintedNoteLength);
303
405
  }
304
406
 
305
- privateNotifyCreatedNote(
407
+ // eslint-disable-next-line camelcase
408
+ aztec_prv_notifyCreatedNote(
306
409
  [owner]: ACVMField[],
307
410
  [storageSlot]: ACVMField[],
308
411
  [randomness]: ACVMField[],
@@ -311,7 +414,7 @@ export class Oracle {
311
414
  [noteHash]: ACVMField[],
312
415
  [counter]: ACVMField[],
313
416
  ): Promise<ACVMField[]> {
314
- this.handlerAsPrivate().privateNotifyCreatedNote(
417
+ this.handlerAsPrivate().notifyCreatedNote(
315
418
  AztecAddress.fromString(owner),
316
419
  Fr.fromString(storageSlot),
317
420
  Fr.fromString(randomness),
@@ -323,35 +426,47 @@ export class Oracle {
323
426
  return Promise.resolve([]);
324
427
  }
325
428
 
326
- async privateNotifyNullifiedNote(
429
+ // eslint-disable-next-line camelcase
430
+ async aztec_prv_notifyNullifiedNote(
327
431
  [innerNullifier]: ACVMField[],
328
432
  [noteHash]: ACVMField[],
329
433
  [counter]: ACVMField[],
330
434
  ): Promise<ACVMField[]> {
331
- await this.handlerAsPrivate().privateNotifyNullifiedNote(
332
- Fr.fromString(innerNullifier),
333
- Fr.fromString(noteHash),
334
- +counter,
335
- );
435
+ await this.handlerAsPrivate().notifyNullifiedNote(Fr.fromString(innerNullifier), Fr.fromString(noteHash), +counter);
336
436
  return [];
337
437
  }
338
438
 
339
- async privateNotifyCreatedNullifier([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
340
- await this.handlerAsPrivate().privateNotifyCreatedNullifier(Fr.fromString(innerNullifier));
439
+ // eslint-disable-next-line camelcase
440
+ async aztec_prv_notifyCreatedNullifier([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
441
+ await this.handlerAsPrivate().notifyCreatedNullifier(Fr.fromString(innerNullifier));
341
442
  return [];
342
443
  }
343
444
 
344
- async utilityCheckNullifierExists([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
345
- const exists = await this.handlerAsUtility().utilityCheckNullifierExists(Fr.fromString(innerNullifier));
445
+ // eslint-disable-next-line camelcase
446
+ async aztec_prv_isNullifierPending(
447
+ [innerNullifier]: ACVMField[],
448
+ [contractAddress]: ACVMField[],
449
+ ): Promise<ACVMField[]> {
450
+ const isPending = await this.handlerAsPrivate().isNullifierPending(
451
+ Fr.fromString(innerNullifier),
452
+ AztecAddress.fromString(contractAddress),
453
+ );
454
+ return [toACVMField(isPending)];
455
+ }
456
+
457
+ // eslint-disable-next-line camelcase
458
+ async aztec_utl_doesNullifierExist([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
459
+ const exists = await this.handlerAsUtility().doesNullifierExist(Fr.fromString(innerNullifier));
346
460
  return [toACVMField(exists)];
347
461
  }
348
462
 
349
- async utilityGetL1ToL2MembershipWitness(
463
+ // eslint-disable-next-line camelcase
464
+ async aztec_utl_getL1ToL2MembershipWitness(
350
465
  [contractAddress]: ACVMField[],
351
466
  [messageHash]: ACVMField[],
352
467
  [secret]: ACVMField[],
353
468
  ): Promise<(ACVMField | ACVMField[])[]> {
354
- const message = await this.handlerAsUtility().utilityGetL1ToL2MembershipWitness(
469
+ const message = await this.handlerAsUtility().getL1ToL2MembershipWitness(
355
470
  AztecAddress.fromString(contractAddress),
356
471
  Fr.fromString(messageHash),
357
472
  Fr.fromString(secret),
@@ -359,14 +474,15 @@ export class Oracle {
359
474
  return message.toNoirRepresentation();
360
475
  }
361
476
 
362
- async utilityStorageRead(
477
+ // eslint-disable-next-line camelcase
478
+ async aztec_utl_getFromPublicStorage(
363
479
  [blockHash]: ACVMField[],
364
480
  [contractAddress]: ACVMField[],
365
481
  [startStorageSlot]: ACVMField[],
366
482
  [numberOfElements]: ACVMField[],
367
483
  ): Promise<ACVMField[][]> {
368
- const values = await this.handlerAsUtility().utilityStorageRead(
369
- L2BlockHash.fromString(blockHash),
484
+ const values = await this.handlerAsUtility().getFromPublicStorage(
485
+ BlockHash.fromString(blockHash),
370
486
  new AztecAddress(Fr.fromString(contractAddress)),
371
487
  Fr.fromString(startStorageSlot),
372
488
  +numberOfElements,
@@ -374,7 +490,8 @@ export class Oracle {
374
490
  return [values.map(toACVMField)];
375
491
  }
376
492
 
377
- privateNotifyCreatedContractClassLog(
493
+ // eslint-disable-next-line camelcase
494
+ aztec_prv_notifyCreatedContractClassLog(
378
495
  [contractAddress]: ACVMField[],
379
496
  message: ACVMField[],
380
497
  [length]: ACVMField[],
@@ -383,11 +500,12 @@ export class Oracle {
383
500
  const logFields = new ContractClassLogFields(message.map(Fr.fromString));
384
501
  const log = new ContractClassLog(new AztecAddress(Fr.fromString(contractAddress)), logFields, +length);
385
502
 
386
- this.handlerAsPrivate().privateNotifyCreatedContractClassLog(log, +counter);
503
+ this.handlerAsPrivate().notifyCreatedContractClassLog(log, +counter);
387
504
  return Promise.resolve([]);
388
505
  }
389
506
 
390
- utilityDebugLog(
507
+ // eslint-disable-next-line camelcase
508
+ async aztec_utl_log(
391
509
  level: ACVMField[],
392
510
  message: ACVMField[],
393
511
  _ignoredFieldsSize: ACVMField[],
@@ -396,20 +514,21 @@ export class Oracle {
396
514
  const levelFr = Fr.fromString(level[0]);
397
515
  const messageStr = message.map(acvmField => String.fromCharCode(Fr.fromString(acvmField).toNumber())).join('');
398
516
  const fieldsFr = fields.map(Fr.fromString);
399
- this.handlerAsMisc().utilityDebugLog(levelFr.toNumber(), messageStr, fieldsFr);
400
- return Promise.resolve([]);
517
+ await this.handlerAsMisc().log(levelFr.toNumber(), messageStr, fieldsFr);
518
+ return [];
401
519
  }
402
520
 
403
521
  // This function's name is directly hardcoded in `circuit_recorder.ts`. Don't forget to update it there if you
404
522
  // change the name here.
405
- async privateCallPrivateFunction(
523
+ // eslint-disable-next-line camelcase
524
+ async aztec_prv_callPrivateFunction(
406
525
  [contractAddress]: ACVMField[],
407
526
  [functionSelector]: ACVMField[],
408
527
  [argsHash]: ACVMField[],
409
528
  [sideEffectCounter]: ACVMField[],
410
529
  [isStaticCall]: ACVMField[],
411
530
  ): Promise<ACVMField[][]> {
412
- const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().privateCallPrivateFunction(
531
+ const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().callPrivateFunction(
413
532
  AztecAddress.fromField(Fr.fromString(contractAddress)),
414
533
  FunctionSelector.fromField(Fr.fromString(functionSelector)),
415
534
  Fr.fromString(argsHash),
@@ -419,113 +538,165 @@ export class Oracle {
419
538
  return [[endSideEffectCounter, returnsHash].map(toACVMField)];
420
539
  }
421
540
 
422
- async privateNotifyEnqueuedPublicFunctionCall(
423
- [contractAddress]: ACVMField[],
424
- [calldataHash]: ACVMField[],
425
- [sideEffectCounter]: ACVMField[],
426
- [isStaticCall]: ACVMField[],
427
- ): Promise<ACVMField[]> {
428
- await this.handlerAsPrivate().privateNotifyEnqueuedPublicFunctionCall(
429
- AztecAddress.fromString(contractAddress),
430
- Fr.fromString(calldataHash),
431
- Fr.fromString(sideEffectCounter).toNumber(),
432
- Fr.fromString(isStaticCall).toBool(),
433
- );
434
- return [];
435
- }
436
-
437
- async privateNotifySetPublicTeardownFunctionCall(
438
- [contractAddress]: ACVMField[],
439
- [calldataHash]: ACVMField[],
440
- [sideEffectCounter]: ACVMField[],
441
- [isStaticCall]: ACVMField[],
442
- ): Promise<ACVMField[]> {
443
- await this.handlerAsPrivate().privateNotifySetPublicTeardownFunctionCall(
444
- AztecAddress.fromString(contractAddress),
445
- Fr.fromString(calldataHash),
446
- Fr.fromString(sideEffectCounter).toNumber(),
447
- Fr.fromString(isStaticCall).toBool(),
448
- );
541
+ // eslint-disable-next-line camelcase
542
+ async aztec_prv_assertValidPublicCalldata([calldataHash]: ACVMField[]): Promise<ACVMField[]> {
543
+ await this.handlerAsPrivate().assertValidPublicCalldata(Fr.fromString(calldataHash));
449
544
  return [];
450
545
  }
451
546
 
452
- async privateNotifySetMinRevertibleSideEffectCounter([minRevertibleSideEffectCounter]: ACVMField[]): Promise<
453
- ACVMField[]
454
- > {
455
- await this.handlerAsPrivate().privateNotifySetMinRevertibleSideEffectCounter(
456
- Fr.fromString(minRevertibleSideEffectCounter).toNumber(),
457
- );
547
+ // eslint-disable-next-line camelcase
548
+ async aztec_prv_notifyRevertiblePhaseStart([minRevertibleSideEffectCounter]: ACVMField[]): Promise<ACVMField[]> {
549
+ await this.handlerAsPrivate().notifyRevertiblePhaseStart(Fr.fromString(minRevertibleSideEffectCounter).toNumber());
458
550
  return Promise.resolve([]);
459
551
  }
460
552
 
461
- async privateIsSideEffectCounterRevertible([sideEffectCounter]: ACVMField[]): Promise<ACVMField[]> {
462
- const isRevertible = await this.handlerAsPrivate().privateIsSideEffectCounterRevertible(
553
+ // eslint-disable-next-line camelcase
554
+ async aztec_prv_isExecutionInRevertiblePhase([sideEffectCounter]: ACVMField[]): Promise<ACVMField[]> {
555
+ const isRevertible = await this.handlerAsPrivate().isExecutionInRevertiblePhase(
463
556
  Fr.fromString(sideEffectCounter).toNumber(),
464
557
  );
465
558
  return Promise.resolve([toACVMField(isRevertible)]);
466
559
  }
467
560
 
468
- async privateGetNextAppTagAsSender([sender]: ACVMField[], [recipient]: ACVMField[]): Promise<ACVMField[]> {
469
- const tag = await this.handlerAsPrivate().privateGetNextAppTagAsSender(
561
+ // eslint-disable-next-line camelcase
562
+ async aztec_prv_getNextAppTagAsSender([sender]: ACVMField[], [recipient]: ACVMField[]): Promise<ACVMField[]> {
563
+ const tag = await this.handlerAsPrivate().getNextAppTagAsSender(
470
564
  AztecAddress.fromString(sender),
471
565
  AztecAddress.fromString(recipient),
472
566
  );
473
567
  return [toACVMField(tag.value)];
474
568
  }
475
569
 
476
- async utilityFetchTaggedLogs([pendingTaggedLogArrayBaseSlot]: ACVMField[]): Promise<ACVMField[]> {
477
- await this.handlerAsUtility().utilityFetchTaggedLogs(Fr.fromString(pendingTaggedLogArrayBaseSlot));
570
+ // eslint-disable-next-line camelcase
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
+ );
478
579
  return [];
479
580
  }
480
581
 
481
- async utilityValidateEnqueuedNotesAndEvents(
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
+
588
+ // eslint-disable-next-line camelcase
589
+ async aztec_utl_validateAndStoreEnqueuedNotesAndEvents(
482
590
  [contractAddress]: ACVMField[],
483
591
  [noteValidationRequestsArrayBaseSlot]: ACVMField[],
484
592
  [eventValidationRequestsArrayBaseSlot]: ACVMField[],
593
+ [maxNotePackedLen]: ACVMField[],
594
+ [maxEventSerializedLen]: ACVMField[],
595
+ [scope]: ACVMField[],
485
596
  ): Promise<ACVMField[]> {
486
- await this.handlerAsUtility().utilityValidateEnqueuedNotesAndEvents(
597
+ await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(
487
598
  AztecAddress.fromString(contractAddress),
488
599
  Fr.fromString(noteValidationRequestsArrayBaseSlot),
489
600
  Fr.fromString(eventValidationRequestsArrayBaseSlot),
601
+ Fr.fromString(maxNotePackedLen).toNumber(),
602
+ Fr.fromString(maxEventSerializedLen).toNumber(),
603
+ AztecAddress.fromString(scope),
490
604
  );
491
605
 
492
606
  return [];
493
607
  }
494
608
 
495
- async utilityBulkRetrieveLogs(
609
+ // eslint-disable-next-line camelcase
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(
496
629
  [contractAddress]: ACVMField[],
497
630
  [logRetrievalRequestsArrayBaseSlot]: ACVMField[],
498
631
  [logRetrievalResponsesArrayBaseSlot]: ACVMField[],
632
+ [scope]: ACVMField[],
499
633
  ): Promise<ACVMField[]> {
500
- await this.handlerAsUtility().utilityBulkRetrieveLogs(
634
+ await this.handlerAsUtility().getLogsByTag(
501
635
  AztecAddress.fromString(contractAddress),
502
636
  Fr.fromString(logRetrievalRequestsArrayBaseSlot),
503
637
  Fr.fromString(logRetrievalResponsesArrayBaseSlot),
638
+ AztecAddress.fromString(scope),
639
+ );
640
+ return [];
641
+ }
642
+
643
+ // eslint-disable-next-line camelcase
644
+ async aztec_utl_getMessageContextsByTxHash(
645
+ [contractAddress]: ACVMField[],
646
+ [messageContextRequestsArrayBaseSlot]: ACVMField[],
647
+ [messageContextResponsesArrayBaseSlot]: ACVMField[],
648
+ [scope]: ACVMField[],
649
+ ): Promise<ACVMField[]> {
650
+ await this.handlerAsUtility().getMessageContextsByTxHash(
651
+ AztecAddress.fromString(contractAddress),
652
+ Fr.fromString(messageContextRequestsArrayBaseSlot),
653
+ Fr.fromString(messageContextResponsesArrayBaseSlot),
654
+ AztecAddress.fromString(scope),
504
655
  );
505
656
  return [];
506
657
  }
507
658
 
508
- async utilityStoreCapsule(
659
+ // eslint-disable-next-line camelcase
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(
509
675
  [contractAddress]: ACVMField[],
510
676
  [slot]: ACVMField[],
511
677
  capsule: ACVMField[],
678
+ [scope]: ACVMField[],
512
679
  ): Promise<ACVMField[]> {
513
- await this.handlerAsUtility().utilityStoreCapsule(
680
+ this.handlerAsUtility().setCapsule(
514
681
  AztecAddress.fromField(Fr.fromString(contractAddress)),
515
682
  Fr.fromString(slot),
516
683
  capsule.map(Fr.fromString),
684
+ AztecAddress.fromField(Fr.fromString(scope)),
517
685
  );
518
- return [];
686
+ return Promise.resolve([]);
519
687
  }
520
688
 
521
- async utilityLoadCapsule(
689
+ // eslint-disable-next-line camelcase
690
+ async aztec_utl_getCapsule(
522
691
  [contractAddress]: ACVMField[],
523
692
  [slot]: ACVMField[],
524
693
  [tSize]: ACVMField[],
694
+ [scope]: ACVMField[],
525
695
  ): Promise<(ACVMField | ACVMField[])[]> {
526
- const values = await this.handlerAsUtility().utilityLoadCapsule(
696
+ const values = await this.handlerAsUtility().getCapsule(
527
697
  AztecAddress.fromField(Fr.fromString(contractAddress)),
528
698
  Fr.fromString(slot),
699
+ AztecAddress.fromField(Fr.fromString(scope)),
529
700
  );
530
701
 
531
702
  // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
@@ -539,30 +710,86 @@ export class Oracle {
539
710
  }
540
711
  }
541
712
 
542
- async utilityDeleteCapsule([contractAddress]: ACVMField[], [slot]: ACVMField[]): Promise<ACVMField[]> {
543
- await this.handlerAsUtility().utilityDeleteCapsule(
713
+ // eslint-disable-next-line camelcase
714
+ aztec_utl_deleteCapsule(
715
+ [contractAddress]: ACVMField[],
716
+ [slot]: ACVMField[],
717
+ [scope]: ACVMField[],
718
+ ): Promise<ACVMField[]> {
719
+ this.handlerAsUtility().deleteCapsule(
544
720
  AztecAddress.fromField(Fr.fromString(contractAddress)),
545
721
  Fr.fromString(slot),
722
+ AztecAddress.fromField(Fr.fromString(scope)),
546
723
  );
547
- return [];
724
+ return Promise.resolve([]);
548
725
  }
549
726
 
550
- async utilityCopyCapsule(
727
+ // eslint-disable-next-line camelcase
728
+ async aztec_utl_copyCapsule(
551
729
  [contractAddress]: ACVMField[],
552
730
  [srcSlot]: ACVMField[],
553
731
  [dstSlot]: ACVMField[],
554
732
  [numEntries]: ACVMField[],
733
+ [scope]: ACVMField[],
555
734
  ): Promise<ACVMField[]> {
556
- await this.handlerAsUtility().utilityCopyCapsule(
735
+ await this.handlerAsUtility().copyCapsule(
557
736
  AztecAddress.fromField(Fr.fromString(contractAddress)),
558
737
  Fr.fromString(srcSlot),
559
738
  Fr.fromString(dstSlot),
560
739
  Fr.fromString(numEntries).toNumber(),
740
+ AztecAddress.fromField(Fr.fromString(scope)),
561
741
  );
562
742
  return [];
563
743
  }
564
744
 
565
- async utilityAes128Decrypt(
745
+ // eslint-disable-next-line camelcase
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(
566
793
  ciphertextBVecStorage: ACVMField[],
567
794
  [ciphertextLength]: ACVMField[],
568
795
  iv: ACVMField[],
@@ -572,36 +799,63 @@ export class Oracle {
572
799
  const ivBuffer = fromUintArray(iv, 8);
573
800
  const symKeyBuffer = fromUintArray(symKey, 8);
574
801
 
575
- const plaintext = await this.handlerAsUtility().utilityAes128Decrypt(ciphertext, ivBuffer, symKeyBuffer);
576
- return bufferToBoundedVec(plaintext, ciphertextBVecStorage.length);
802
+ // Noir Option<BoundedVec> is encoded as [is_some: Field, storage: Field[], length: Field].
803
+ try {
804
+ const plaintext = await this.handlerAsUtility().decryptAes128(ciphertext, ivBuffer, symKeyBuffer);
805
+ const [storage, length] = bufferToBoundedVec(plaintext, ciphertextBVecStorage.length);
806
+ return [toACVMField(1), storage, length];
807
+ } catch {
808
+ const zeroStorage = Array(ciphertextBVecStorage.length).fill(toACVMField(0));
809
+ return [toACVMField(0), zeroStorage, toACVMField(0)];
810
+ }
577
811
  }
578
812
 
579
- async utilityGetSharedSecret(
813
+ // eslint-disable-next-line camelcase
814
+ async aztec_utl_getSharedSecret(
580
815
  [address]: ACVMField[],
581
816
  [ephPKField0]: ACVMField[],
582
817
  [ephPKField1]: ACVMField[],
583
818
  [ephPKField2]: ACVMField[],
819
+ [contractAddress]: ACVMField[],
584
820
  ): Promise<ACVMField[]> {
585
- const secret = await this.handlerAsUtility().utilityGetSharedSecret(
821
+ const secret = await this.handlerAsUtility().getSharedSecret(
586
822
  AztecAddress.fromField(Fr.fromString(address)),
587
823
  Point.fromFields([ephPKField0, ephPKField1, ephPKField2].map(Fr.fromString)),
824
+ AztecAddress.fromField(Fr.fromString(contractAddress)),
588
825
  );
589
- return secret.toFields().map(toACVMField);
826
+ return [toACVMField(secret)];
827
+ }
828
+
829
+ // eslint-disable-next-line camelcase
830
+ aztec_utl_setContractSyncCacheInvalid(
831
+ [contractAddress]: ACVMField[],
832
+ scopes: ACVMField[],
833
+ [scopeCount]: ACVMField[],
834
+ ): Promise<ACVMField[]> {
835
+ const scopeAddresses = scopes.slice(0, +scopeCount).map(s => AztecAddress.fromField(Fr.fromString(s)));
836
+ this.handlerAsUtility().setContractSyncCacheInvalid(
837
+ AztecAddress.fromField(Fr.fromString(contractAddress)),
838
+ scopeAddresses,
839
+ );
840
+ return Promise.resolve([]);
590
841
  }
591
842
 
592
- async utilityEmitOffchainEffect(data: ACVMField[]) {
593
- await this.handlerAsPrivate().utilityEmitOffchainEffect(data.map(Fr.fromString));
843
+ // eslint-disable-next-line camelcase
844
+ async aztec_utl_emitOffchainEffect(data: ACVMField[]) {
845
+ await this.handlerAsUtility().emitOffchainEffect(data.map(Fr.fromString));
594
846
  return [];
595
847
  }
596
848
 
597
- async privateGetSenderForTags(): Promise<ACVMField[]> {
598
- const sender = await this.handlerAsPrivate().privateGetSenderForTags();
849
+ // eslint-disable-next-line camelcase
850
+ async aztec_prv_getSenderForTags(): Promise<ACVMField[]> {
851
+ const sender = await this.handlerAsPrivate().getSenderForTags();
599
852
  // Return [1, address] for Some(address), [0, 0] for None
600
853
  return sender ? [toACVMField(1n), toACVMField(sender)] : [toACVMField(0n), toACVMField(0n)];
601
854
  }
602
855
 
603
- async privateSetSenderForTags([senderForTags]: ACVMField[]): Promise<ACVMField[]> {
604
- await this.handlerAsPrivate().privateSetSenderForTags(AztecAddress.fromField(Fr.fromString(senderForTags)));
856
+ // eslint-disable-next-line camelcase
857
+ async aztec_prv_setSenderForTags([senderForTags]: ACVMField[]): Promise<ACVMField[]> {
858
+ await this.handlerAsPrivate().setSenderForTags(AztecAddress.fromField(Fr.fromString(senderForTags)));
605
859
  return [];
606
860
  }
607
861
  }