@aztec/pxe 0.0.1-commit.fffb133c → 0.0.1-dev

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 (309) hide show
  1. package/dest/bin/check_oracle_version.js +5 -5
  2. package/dest/block_synchronizer/block_synchronizer.d.ts +10 -4
  3. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  4. package/dest/block_synchronizer/block_synchronizer.js +30 -6
  5. package/dest/config/package_info.js +1 -1
  6. package/dest/contract_function_simulator/contract_function_simulator.d.ts +66 -31
  7. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  8. package/dest/contract_function_simulator/contract_function_simulator.js +214 -75
  9. package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
  10. package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
  11. package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
  12. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -7
  13. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  14. package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
  15. package/dest/contract_function_simulator/index.d.ts +2 -1
  16. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/index.js +1 -0
  18. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +4 -6
  19. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  20. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +8 -10
  21. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +1 -1
  22. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +1 -1
  23. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
  24. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  25. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +2 -4
  26. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +4 -7
  27. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  28. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +6 -11
  29. package/dest/contract_function_simulator/oracle/interfaces.d.ts +66 -47
  30. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  31. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
  32. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
  33. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +47 -0
  34. package/dest/contract_function_simulator/oracle/oracle.d.ts +78 -44
  35. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  36. package/dest/contract_function_simulator/oracle/oracle.js +363 -114
  37. package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
  38. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +56 -86
  39. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  40. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +123 -98
  41. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +145 -70
  42. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  43. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +435 -145
  44. package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
  45. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
  46. package/dest/contract_function_simulator/pick_notes.js +20 -3
  47. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
  48. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
  49. package/dest/contract_function_simulator/proxied_contract_data_source.js +3 -0
  50. package/dest/contract_logging.d.ts +27 -0
  51. package/dest/contract_logging.d.ts.map +1 -0
  52. package/dest/contract_logging.js +38 -0
  53. package/dest/contract_sync/contract_sync_service.d.ts +45 -0
  54. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
  55. package/dest/contract_sync/contract_sync_service.js +150 -0
  56. package/dest/contract_sync/helpers.d.ts +27 -0
  57. package/dest/contract_sync/helpers.d.ts.map +1 -0
  58. package/dest/contract_sync/{index.js → helpers.js} +16 -17
  59. package/dest/debug/pxe_debug_utils.d.ts +24 -10
  60. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  61. package/dest/debug/pxe_debug_utils.js +28 -18
  62. package/dest/entrypoints/client/bundle/index.d.ts +3 -1
  63. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  64. package/dest/entrypoints/client/bundle/index.js +2 -0
  65. package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
  66. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  67. package/dest/entrypoints/client/bundle/utils.js +24 -9
  68. package/dest/entrypoints/client/lazy/index.d.ts +3 -1
  69. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  70. package/dest/entrypoints/client/lazy/index.js +2 -0
  71. package/dest/entrypoints/client/lazy/utils.d.ts +3 -3
  72. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  73. package/dest/entrypoints/client/lazy/utils.js +25 -10
  74. package/dest/entrypoints/pxe_creation_options.d.ts +8 -2
  75. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  76. package/dest/entrypoints/pxe_creation_options.js +3 -1
  77. package/dest/entrypoints/server/index.d.ts +5 -3
  78. package/dest/entrypoints/server/index.d.ts.map +1 -1
  79. package/dest/entrypoints/server/index.js +4 -2
  80. package/dest/entrypoints/server/utils.d.ts +2 -2
  81. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  82. package/dest/entrypoints/server/utils.js +31 -11
  83. package/dest/events/event_service.d.ts +16 -8
  84. package/dest/events/event_service.d.ts.map +1 -1
  85. package/dest/events/event_service.js +46 -14
  86. package/dest/events/private_event_filter_validator.d.ts +3 -2
  87. package/dest/events/private_event_filter_validator.d.ts.map +1 -1
  88. package/dest/events/private_event_filter_validator.js +15 -0
  89. package/dest/hooks/authorize_utility_call.d.ts +37 -0
  90. package/dest/hooks/authorize_utility_call.d.ts.map +1 -0
  91. package/dest/hooks/authorize_utility_call.js +4 -0
  92. package/dest/hooks/execution_hooks.d.ts +42 -0
  93. package/dest/hooks/execution_hooks.d.ts.map +1 -0
  94. package/dest/hooks/execution_hooks.js +9 -0
  95. package/dest/hooks/index.d.ts +4 -0
  96. package/dest/hooks/index.d.ts.map +1 -0
  97. package/dest/hooks/index.js +1 -0
  98. package/dest/job_coordinator/job_coordinator.d.ts +3 -2
  99. package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
  100. package/dest/job_coordinator/job_coordinator.js +3 -2
  101. package/dest/logs/log_service.d.ts +10 -9
  102. package/dest/logs/log_service.d.ts.map +1 -1
  103. package/dest/logs/log_service.js +50 -85
  104. package/dest/messages/message_context_service.d.ts +17 -0
  105. package/dest/messages/message_context_service.d.ts.map +1 -0
  106. package/dest/messages/message_context_service.js +38 -0
  107. package/dest/notes/note_service.d.ts +29 -8
  108. package/dest/notes/note_service.d.ts.map +1 -1
  109. package/dest/notes/note_service.js +89 -65
  110. package/dest/notes_filter.d.ts +24 -0
  111. package/dest/notes_filter.d.ts.map +1 -0
  112. package/dest/notes_filter.js +4 -0
  113. package/dest/oracle_version.d.ts +4 -3
  114. package/dest/oracle_version.d.ts.map +1 -1
  115. package/dest/oracle_version.js +20 -10
  116. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
  117. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
  118. package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
  119. package/dest/private_kernel/hints/index.d.ts +1 -1
  120. package/dest/private_kernel/hints/index.js +1 -1
  121. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
  122. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  123. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
  124. package/dest/private_kernel/hints/test_utils.d.ts +122 -0
  125. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
  126. package/dest/private_kernel/hints/test_utils.js +203 -0
  127. package/dest/private_kernel/private_kernel_execution_prover.d.ts +4 -2
  128. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  129. package/dest/private_kernel/private_kernel_execution_prover.js +38 -19
  130. package/dest/private_kernel/private_kernel_oracle.d.ts +10 -6
  131. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  132. package/dest/private_kernel/private_kernel_oracle.js +26 -20
  133. package/dest/pxe.d.ts +87 -23
  134. package/dest/pxe.d.ts.map +1 -1
  135. package/dest/pxe.js +178 -119
  136. package/dest/storage/address_store/address_store.d.ts +1 -1
  137. package/dest/storage/address_store/address_store.d.ts.map +1 -1
  138. package/dest/storage/address_store/address_store.js +12 -11
  139. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
  140. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
  141. package/dest/storage/anchor_block_store/anchor_block_store.js +9 -2
  142. package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts +42 -0
  143. package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts.map +1 -0
  144. package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.js +93 -0
  145. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +15 -0
  146. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -0
  147. package/dest/storage/backwards_compatibility_tests/schema_tests.js +588 -0
  148. package/dest/storage/backwards_compatibility_tests/store_spy.d.ts +19 -0
  149. package/dest/storage/backwards_compatibility_tests/store_spy.d.ts.map +1 -0
  150. package/dest/storage/backwards_compatibility_tests/store_spy.js +63 -0
  151. package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
  152. package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
  153. package/dest/storage/capsule_store/capsule_service.js +50 -0
  154. package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
  155. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
  156. package/dest/storage/capsule_store/capsule_store.js +42 -36
  157. package/dest/storage/capsule_store/index.d.ts +2 -1
  158. package/dest/storage/capsule_store/index.d.ts.map +1 -1
  159. package/dest/storage/capsule_store/index.js +1 -0
  160. package/dest/storage/contract_store/contract_store.d.ts +42 -15
  161. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  162. package/dest/storage/contract_store/contract_store.js +160 -73
  163. package/dest/storage/metadata.d.ts +1 -1
  164. package/dest/storage/metadata.js +1 -1
  165. package/dest/storage/note_store/note_store.d.ts +13 -3
  166. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  167. package/dest/storage/note_store/note_store.js +147 -107
  168. package/dest/storage/open_pxe_stores.d.ts +31 -0
  169. package/dest/storage/open_pxe_stores.d.ts.map +1 -0
  170. package/dest/storage/open_pxe_stores.js +26 -0
  171. package/dest/storage/private_event_store/private_event_store.d.ts +1 -1
  172. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  173. package/dest/storage/private_event_store/private_event_store.js +87 -61
  174. package/dest/storage/private_event_store/stored_private_event.d.ts +4 -4
  175. package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -1
  176. package/dest/storage/private_event_store/stored_private_event.js +2 -2
  177. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
  178. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  179. package/dest/storage/tagging_store/recipient_tagging_store.js +31 -19
  180. package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
  181. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
  182. package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
  183. package/dest/storage/tagging_store/sender_tagging_store.d.ts +29 -28
  184. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  185. package/dest/storage/tagging_store/sender_tagging_store.js +233 -137
  186. package/dest/tagging/get_all_logs_by_tags.d.ts +4 -4
  187. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
  188. package/dest/tagging/get_all_logs_by_tags.js +20 -3
  189. package/dest/tagging/index.d.ts +6 -5
  190. package/dest/tagging/index.d.ts.map +1 -1
  191. package/dest/tagging/index.js +4 -3
  192. package/dest/tagging/persist_sender_tagging_index_ranges.d.ts +29 -0
  193. package/dest/tagging/persist_sender_tagging_index_ranges.d.ts.map +1 -0
  194. package/dest/tagging/persist_sender_tagging_index_ranges.js +42 -0
  195. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +56 -0
  196. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -0
  197. package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +158 -0
  198. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
  199. package/dest/tagging/reconcile_tagging_index_ranges.d.ts +36 -0
  200. package/dest/tagging/reconcile_tagging_index_ranges.d.ts.map +1 -0
  201. package/dest/tagging/reconcile_tagging_index_ranges.js +74 -0
  202. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +5 -9
  203. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  204. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +30 -13
  205. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +13 -7
  206. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  207. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +41 -10
  208. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +6 -8
  209. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  210. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +36 -24
  211. package/package.json +26 -16
  212. package/src/bin/check_oracle_version.ts +5 -5
  213. package/src/block_synchronizer/block_synchronizer.ts +45 -21
  214. package/src/config/package_info.ts +1 -1
  215. package/src/contract_function_simulator/contract_function_simulator.ts +389 -134
  216. package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
  217. package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
  218. package/src/contract_function_simulator/index.ts +1 -0
  219. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +9 -9
  220. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
  221. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -5
  222. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +4 -10
  223. package/src/contract_function_simulator/oracle/interfaces.ts +101 -62
  224. package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +104 -0
  225. package/src/contract_function_simulator/oracle/oracle.ts +464 -151
  226. package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
  227. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +152 -191
  228. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +709 -200
  229. package/src/contract_function_simulator/pick_notes.ts +22 -3
  230. package/src/contract_function_simulator/proxied_contract_data_source.ts +8 -1
  231. package/src/contract_logging.ts +52 -0
  232. package/src/contract_sync/contract_sync_service.ts +208 -0
  233. package/src/contract_sync/{index.ts → helpers.ts} +17 -29
  234. package/src/debug/pxe_debug_utils.ts +63 -19
  235. package/src/entrypoints/client/bundle/index.ts +2 -0
  236. package/src/entrypoints/client/bundle/utils.ts +19 -18
  237. package/src/entrypoints/client/lazy/index.ts +2 -0
  238. package/src/entrypoints/client/lazy/utils.ts +20 -18
  239. package/src/entrypoints/pxe_creation_options.ts +13 -1
  240. package/src/entrypoints/server/index.ts +4 -2
  241. package/src/entrypoints/server/utils.ts +25 -29
  242. package/src/events/event_service.ts +70 -24
  243. package/src/events/private_event_filter_validator.ts +21 -1
  244. package/src/hooks/authorize_utility_call.ts +40 -0
  245. package/src/hooks/execution_hooks.ts +48 -0
  246. package/src/hooks/index.ts +7 -0
  247. package/src/job_coordinator/job_coordinator.ts +4 -3
  248. package/src/logs/log_service.ts +88 -141
  249. package/src/messages/message_context_service.ts +45 -0
  250. package/src/notes/note_service.ts +124 -91
  251. package/src/notes_filter.ts +24 -0
  252. package/src/oracle_version.ts +20 -10
  253. package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
  254. package/src/private_kernel/hints/index.ts +1 -1
  255. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
  256. package/src/private_kernel/hints/test_utils.ts +325 -0
  257. package/src/private_kernel/private_kernel_execution_prover.ts +53 -22
  258. package/src/private_kernel/private_kernel_oracle.ts +36 -26
  259. package/src/pxe.ts +351 -168
  260. package/src/storage/address_store/address_store.ts +15 -15
  261. package/src/storage/anchor_block_store/anchor_block_store.ts +9 -1
  262. package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +22 -0
  263. package/src/storage/backwards_compatibility_tests/__snapshots__/AnchorBlockStore.json +3 -0
  264. package/src/storage/backwards_compatibility_tests/__snapshots__/CapsuleStore.json +16 -0
  265. package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +28 -0
  266. package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +52 -0
  267. package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +42 -0
  268. package/src/storage/backwards_compatibility_tests/__snapshots__/NoteStore.json +36 -0
  269. package/src/storage/backwards_compatibility_tests/__snapshots__/PrivateEventStore.json +44 -0
  270. package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +18 -0
  271. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderAddressBookStore.json +16 -0
  272. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +22 -0
  273. package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +97 -0
  274. package/src/storage/backwards_compatibility_tests/kv_store_snapshot.ts +122 -0
  275. package/src/storage/backwards_compatibility_tests/schema_tests.ts +707 -0
  276. package/src/storage/backwards_compatibility_tests/store_spy.ts +73 -0
  277. package/src/storage/capsule_store/capsule_service.ts +90 -0
  278. package/src/storage/capsule_store/capsule_store.ts +52 -34
  279. package/src/storage/capsule_store/index.ts +1 -0
  280. package/src/storage/contract_store/contract_store.ts +193 -81
  281. package/src/storage/metadata.ts +1 -1
  282. package/src/storage/note_store/note_store.ts +166 -132
  283. package/src/storage/open_pxe_stores.ts +47 -0
  284. package/src/storage/private_event_store/private_event_store.ts +106 -81
  285. package/src/storage/private_event_store/stored_private_event.ts +3 -3
  286. package/src/storage/tagging_store/recipient_tagging_store.ts +38 -24
  287. package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
  288. package/src/storage/tagging_store/sender_tagging_store.ts +287 -156
  289. package/src/tagging/get_all_logs_by_tags.ts +35 -7
  290. package/src/tagging/index.ts +5 -4
  291. package/src/tagging/persist_sender_tagging_index_ranges.ts +57 -0
  292. package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +236 -0
  293. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
  294. package/src/tagging/reconcile_tagging_index_ranges.ts +102 -0
  295. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +54 -18
  296. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +44 -14
  297. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +30 -29
  298. package/dest/contract_sync/index.d.ts +0 -23
  299. package/dest/contract_sync/index.d.ts.map +0 -1
  300. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
  301. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
  302. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +0 -15
  303. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +0 -1
  304. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +0 -99
  305. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +0 -15
  306. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +0 -1
  307. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +0 -32
  308. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +0 -143
  309. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +0 -49
@@ -1,6 +1,17 @@
1
+ import {
2
+ ARCHIVE_HEIGHT,
3
+ MAX_CONTRACT_CLASS_LOGS_PER_TX,
4
+ MAX_L2_TO_L1_MSGS_PER_TX,
5
+ MAX_NOTE_HASHES_PER_TX,
6
+ MAX_NULLIFIERS_PER_TX,
7
+ MAX_PRIVATE_LOGS_PER_TX,
8
+ MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
9
+ } from '@aztec/constants';
1
10
  import { BlockNumber } from '@aztec/foundation/branded-types';
11
+ import { padArrayEnd } from '@aztec/foundation/collection';
2
12
  import { Fr } from '@aztec/foundation/curves/bn254';
3
13
  import { Point } from '@aztec/foundation/curves/grumpkin';
14
+ import { MembershipWitness } from '@aztec/foundation/trees';
4
15
  import {
5
16
  type ACIRCallback,
6
17
  type ACVMField,
@@ -11,11 +22,15 @@ import {
11
22
  toACVMField,
12
23
  } from '@aztec/simulator/client';
13
24
  import { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
25
+ import { PublicDataWrite } from '@aztec/stdlib/avm';
14
26
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
15
- import { L2BlockHash } from '@aztec/stdlib/block';
16
- import { ContractClassLog, ContractClassLogFields } from '@aztec/stdlib/logs';
27
+ import { BlockHash } from '@aztec/stdlib/block';
28
+ import { ContractClassLog, ContractClassLogFields, FlatPublicLogs, PrivateLog } from '@aztec/stdlib/logs';
29
+ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
17
30
 
31
+ import { ORACLE_VERSION_MAJOR, ORACLE_VERSION_MINOR } from '../../oracle_version.js';
18
32
  import type { IMiscOracle, IPrivateExecutionOracle, IUtilityExecutionOracle } from './interfaces.js';
33
+ import { buildLegacyOracleCallbacks } from './legacy_oracle_mappings.js';
19
34
  import { packAsHintedNote } from './note_packing_utils.js';
20
35
 
21
36
  export class UnavailableOracleError extends Error {
@@ -26,6 +41,25 @@ export class UnavailableOracleError extends Error {
26
41
 
27
42
  /**
28
43
  * A data source that has all the apis required by Aztec.nr.
44
+ *
45
+ * ## Oracle naming conventions
46
+ *
47
+ * We try to keep oracle naming consistent, please see below the conventions we adhere to.
48
+ *
49
+ * Each oracle method name has the form `aztec_{scope}_{verb}{Object}`, where:
50
+ *
51
+ * - **Scope prefix** indicates the execution context required:
52
+ * - `aztec_prv_` — available only during private function execution.
53
+ * - `aztec_utl_` — available during both utility and private execution.
54
+ *
55
+ * - **Verb** signals the operation's semantics (verb-first, then object):
56
+ * - `get` — read / lookup / get data from oracle into contract.
57
+ * - `does`/`is`/`has` — predicate (returns boolean).
58
+ * - `emit`/`notify` — propagate data from contract to oracle.
59
+ * - `set` — contract driven oracle state mutation (capsules, execution cache, tagging, etc).
60
+ * - `call` — trigger nested execution (control flow).
61
+ * - `assert` — validate a condition, throw on failure.
62
+ * - Standalone verbs (`delete`, `copy`, `decrypt`, `log`, etc) are used when no generic verb fits.
29
63
  */
30
64
  export class Oracle {
31
65
  constructor(private handler: IMiscOracle | IUtilityExecutionOracle | IPrivateExecutionOracle) {}
@@ -69,12 +103,12 @@ export class Oracle {
69
103
  name => !excludedProps.includes(name as (typeof excludedProps)[number]),
70
104
  );
71
105
 
72
- // Validate oracle names - these must be prefixed with either "private" or "utility" to indicate their scope
106
+ // Validate oracle names - these must be prefixed with either "aztec_prv_" or "aztec_utl_" to indicate their scope
73
107
  // and must correspond to a function on the Oracle class.
74
108
  oracleNames.forEach(name => {
75
- if (!name.startsWith('private') && !name.startsWith('utility')) {
109
+ if (!name.startsWith('aztec_prv_') && !name.startsWith('aztec_utl_')) {
76
110
  throw new Error(
77
- `Oracle function "${name}" must be prefixed with either "private" or "utility" to indicate its scope`,
111
+ `Oracle function "${name}" must be prefixed with either "aztec_prv_" or "aztec_utl_" to indicate its scope`,
78
112
  );
79
113
  }
80
114
 
@@ -85,48 +119,110 @@ export class Oracle {
85
119
  });
86
120
 
87
121
  // Build callback object and return it
88
- return oracleNames.reduce((acc, name) => {
122
+ const callback = oracleNames.reduce((acc, name) => {
89
123
  const method = this[name as keyof Omit<Oracle, (typeof excludedProps)[number]>];
90
124
  acc[name] = method.bind(this);
91
125
  return acc;
92
126
  }, {} as ACIRCallback);
127
+
128
+ const allCallbacks = { ...callback, ...buildLegacyOracleCallbacks(this) };
129
+
130
+ // Wrap in a Proxy to intercept access to missing oracle names and provide enhanced error messages when the
131
+ // contract's minor version is higher than the PXE's (i.e. the contract expects oracles that were added in a newer
132
+ // minor version).
133
+ const handler = this.handler;
134
+ return new Proxy(allCallbacks, {
135
+ get(target, prop: string) {
136
+ if (prop in target) {
137
+ return target[prop];
138
+ }
139
+ // Return a function that throws with an enhanced error message if applicable
140
+ return () => {
141
+ type NonOracleFunctionGetContractOracleVersion = {
142
+ nonOracleFunctionGetContractOracleVersion(): { major: number; minor: number } | undefined;
143
+ };
144
+
145
+ let contractVersion = undefined;
146
+ if ('nonOracleFunctionGetContractOracleVersion' in handler) {
147
+ contractVersion = (
148
+ handler as unknown as NonOracleFunctionGetContractOracleVersion
149
+ ).nonOracleFunctionGetContractOracleVersion();
150
+ }
151
+ if (!contractVersion) {
152
+ throw new Error(
153
+ `Oracle '${prop}' not found and the contract's oracle version is unknown (the version check oracle ` +
154
+ `was not called before '${prop}'). This usually means the contract was not compiled with the ` +
155
+ `#[aztec] macro, which injects the version check as the first oracle call in every private/utility ` +
156
+ `external function. If you're using a custom entry point, ensure assert_compatible_oracle_version() ` +
157
+ `is called before any other oracle calls. See https://docs.aztec.network/errors/8`,
158
+ );
159
+ } else if (contractVersion.minor > ORACLE_VERSION_MINOR) {
160
+ throw new Error(
161
+ `Oracle '${prop}' not found.` +
162
+ ` This usually means the contract requires a newer private execution environment than you have.` +
163
+ ` Upgrade your private execution environment to a compatible version. The contract was compiled with` +
164
+ ` Aztec.nr oracle version ${contractVersion.major}.${contractVersion.minor}, but this private` +
165
+ ` execution environment only supports up to ${ORACLE_VERSION_MAJOR}.${ORACLE_VERSION_MINOR}.` +
166
+ ` See https://docs.aztec.network/errors/8`,
167
+ );
168
+ } else {
169
+ throw new Error(
170
+ `Oracle '${prop}' not found.` +
171
+ ` The contract's oracle version (${contractVersion.major}.${contractVersion.minor}) is compatible` +
172
+ ` with this private execution environment (${ORACLE_VERSION_MAJOR}.${ORACLE_VERSION_MINOR}), so all` +
173
+ ` standard oracles should be available. This could mean the contract was compiled against a modified` +
174
+ ` version of Aztec.nr, or that it references an oracle that does not exist.` +
175
+ ` See https://docs.aztec.network/errors/8`,
176
+ );
177
+ }
178
+ };
179
+ },
180
+ });
93
181
  }
94
182
 
95
- utilityAssertCompatibleOracleVersion([version]: ACVMField[]) {
96
- this.handlerAsMisc().utilityAssertCompatibleOracleVersion(Fr.fromString(version).toNumber());
183
+ // eslint-disable-next-line camelcase
184
+ aztec_utl_assertCompatibleOracleVersionV2([major]: ACVMField[], [minor]: ACVMField[]) {
185
+ this.handlerAsMisc().assertCompatibleOracleVersion(
186
+ Fr.fromString(major).toNumber(),
187
+ Fr.fromString(minor).toNumber(),
188
+ );
97
189
  return Promise.resolve([]);
98
190
  }
99
191
 
100
- utilityGetRandomField(): Promise<ACVMField[]> {
101
- const val = this.handlerAsMisc().utilityGetRandomField();
192
+ // eslint-disable-next-line camelcase
193
+ aztec_utl_getRandomField(): Promise<ACVMField[]> {
194
+ const val = this.handlerAsMisc().getRandomField();
102
195
  return Promise.resolve([toACVMField(val)]);
103
196
  }
104
197
 
105
- privateStoreInExecutionCache(values: ACVMField[], [hash]: ACVMField[]): Promise<ACVMField[]> {
106
- this.handlerAsPrivate().privateStoreInExecutionCache(values.map(Fr.fromString), Fr.fromString(hash));
198
+ // eslint-disable-next-line camelcase
199
+ aztec_prv_setHashPreimage(values: ACVMField[], [hash]: ACVMField[]): Promise<ACVMField[]> {
200
+ this.handlerAsPrivate().setHashPreimage(values.map(Fr.fromString), Fr.fromString(hash));
107
201
  return Promise.resolve([]);
108
202
  }
109
203
 
110
- async privateLoadFromExecutionCache([returnsHash]: ACVMField[]): Promise<ACVMField[][]> {
111
- const values = await this.handlerAsPrivate().privateLoadFromExecutionCache(Fr.fromString(returnsHash));
204
+ // eslint-disable-next-line camelcase
205
+ async aztec_prv_getHashPreimage([returnsHash]: ACVMField[]): Promise<ACVMField[][]> {
206
+ const values = await this.handlerAsPrivate().getHashPreimage(Fr.fromString(returnsHash));
112
207
  return [values.map(toACVMField)];
113
208
  }
114
209
 
115
- utilityGetUtilityContext(): Promise<(ACVMField | ACVMField[])[]> {
116
- const context = this.handlerAsUtility().utilityGetUtilityContext();
210
+ // eslint-disable-next-line camelcase
211
+ aztec_utl_getUtilityContext(): Promise<(ACVMField | ACVMField[])[]> {
212
+ const context = this.handlerAsUtility().getUtilityContext();
117
213
  return Promise.resolve(context.toNoirRepresentation());
118
214
  }
119
215
 
120
- async utilityGetKeyValidationRequest([pkMHash]: ACVMField[]): Promise<ACVMField[]> {
121
- const keyValidationRequest = await this.handlerAsUtility().utilityGetKeyValidationRequest(Fr.fromString(pkMHash));
216
+ // eslint-disable-next-line camelcase
217
+ async aztec_utl_getKeyValidationRequest([pkMHash]: ACVMField[]): Promise<ACVMField[]> {
218
+ const keyValidationRequest = await this.handlerAsUtility().getKeyValidationRequest(Fr.fromString(pkMHash));
122
219
 
123
220
  return keyValidationRequest.toFields().map(toACVMField);
124
221
  }
125
222
 
126
- async utilityGetContractInstance([address]: ACVMField[]): Promise<ACVMField[]> {
127
- const instance = await this.handlerAsUtility().utilityGetContractInstance(
128
- AztecAddress.fromField(Fr.fromString(address)),
129
- );
223
+ // eslint-disable-next-line camelcase
224
+ async aztec_utl_getContractInstance([address]: ACVMField[]): Promise<ACVMField[]> {
225
+ const instance = await this.handlerAsUtility().getContractInstance(AztecAddress.fromField(Fr.fromString(address)));
130
226
 
131
227
  return [
132
228
  instance.salt,
@@ -137,45 +233,64 @@ export class Oracle {
137
233
  ].map(toACVMField);
138
234
  }
139
235
 
140
- async utilityGetNoteHashMembershipWitness(
141
- [blockHash]: ACVMField[],
142
- [leafValue]: ACVMField[],
236
+ // eslint-disable-next-line camelcase
237
+ async aztec_utl_getNoteHashMembershipWitness(
238
+ [anchorBlockHash]: ACVMField[],
239
+ [noteHash]: ACVMField[],
143
240
  ): Promise<(ACVMField | ACVMField[])[]> {
144
- const parsedBlockHash = L2BlockHash.fromString(blockHash);
145
- const parsedLeafValue = Fr.fromString(leafValue);
241
+ const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
242
+ const parsedNoteHash = Fr.fromString(noteHash);
146
243
 
147
- const witness = await this.handlerAsUtility().utilityGetNoteHashMembershipWitness(parsedBlockHash, parsedLeafValue);
244
+ const witness = await this.handlerAsUtility().getNoteHashMembershipWitness(parsedAnchorBlockHash, parsedNoteHash);
148
245
  if (!witness) {
149
- throw new Error(`Leaf ${leafValue} not found in the note hash tree at block hash ${parsedBlockHash.toString()}.`);
246
+ throw new Error(
247
+ `Note hash ${noteHash} not found in the note hash tree at anchor block hash ${parsedAnchorBlockHash.toString()}.`,
248
+ );
150
249
  }
151
250
  return witness.toNoirRepresentation();
152
251
  }
153
252
 
154
- async utilityGetArchiveMembershipWitness(
253
+ // TODO(https://linear.app/aztec-labs/issue/F-651): drop this
254
+ // eslint-disable-next-line camelcase
255
+ async aztec_utl_getBlockHashMembershipWitness(
256
+ [anchorBlockHash]: ACVMField[],
155
257
  [blockHash]: ACVMField[],
156
- [leafValue]: ACVMField[],
157
258
  ): Promise<(ACVMField | ACVMField[])[]> {
158
- const parsedBlockHash = L2BlockHash.fromString(blockHash);
159
- const parsedLeafValue = Fr.fromString(leafValue);
259
+ const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
260
+ const parsedBlockHash = BlockHash.fromString(blockHash);
160
261
 
161
- const witness = await this.handlerAsUtility().utilityGetArchiveMembershipWitness(parsedBlockHash, parsedLeafValue);
262
+ const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(parsedAnchorBlockHash, parsedBlockHash);
162
263
  if (!witness) {
163
- throw new Error(`Leaf ${leafValue} not found in the archive tree at block hash ${parsedBlockHash.toString()}.`);
264
+ throw new Error(
265
+ `Block hash ${parsedBlockHash.toString()} not found in the archive tree at anchor block ${parsedAnchorBlockHash.toString()}.`,
266
+ );
164
267
  }
165
268
  return witness.toNoirRepresentation();
166
269
  }
167
270
 
168
- async utilityGetNullifierMembershipWitness(
271
+ // TODO(https://linear.app/aztec-labs/issue/F-651): rename to aztec_utl_getBlockHashMembershipWitness
272
+ // eslint-disable-next-line camelcase
273
+ async aztec_utl_getBlockHashMembershipWitnessV2(
274
+ [anchorBlockHash]: ACVMField[],
275
+ [blockHash]: ACVMField[],
276
+ ): Promise<(ACVMField | ACVMField[])[]> {
277
+ const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
278
+ const parsedBlockHash = BlockHash.fromString(blockHash);
279
+
280
+ const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(parsedAnchorBlockHash, parsedBlockHash);
281
+ const effective = witness ?? MembershipWitness.empty(ARCHIVE_HEIGHT);
282
+ return [toACVMField(witness !== undefined ? 1 : 0), ...effective.toNoirRepresentation()];
283
+ }
284
+
285
+ // eslint-disable-next-line camelcase
286
+ async aztec_utl_getNullifierMembershipWitness(
169
287
  [blockHash]: ACVMField[],
170
288
  [nullifier]: ACVMField[], // nullifier, we try to find the witness for (to prove inclusion)
171
289
  ): Promise<(ACVMField | ACVMField[])[]> {
172
- const parsedBlockHash = L2BlockHash.fromString(blockHash);
290
+ const parsedBlockHash = BlockHash.fromString(blockHash);
173
291
  const parsedNullifier = Fr.fromString(nullifier);
174
292
 
175
- const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(
176
- parsedBlockHash,
177
- parsedNullifier,
178
- );
293
+ const witness = await this.handlerAsUtility().getNullifierMembershipWitness(parsedBlockHash, parsedNullifier);
179
294
  if (!witness) {
180
295
  throw new Error(
181
296
  `Nullifier witness not found for nullifier ${parsedNullifier} at block hash ${parsedBlockHash.toString()}.`,
@@ -184,17 +299,15 @@ export class Oracle {
184
299
  return witness.toNoirRepresentation();
185
300
  }
186
301
 
187
- async utilityGetLowNullifierMembershipWitness(
302
+ // eslint-disable-next-line camelcase
303
+ async aztec_utl_getLowNullifierMembershipWitness(
188
304
  [blockHash]: ACVMField[],
189
305
  [nullifier]: ACVMField[], // nullifier, we try to find the low nullifier witness for (to prove non-inclusion)
190
306
  ): Promise<(ACVMField | ACVMField[])[]> {
191
- const parsedBlockHash = L2BlockHash.fromString(blockHash);
307
+ const parsedBlockHash = BlockHash.fromString(blockHash);
192
308
  const parsedNullifier = Fr.fromString(nullifier);
193
309
 
194
- const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(
195
- parsedBlockHash,
196
- parsedNullifier,
197
- );
310
+ const witness = await this.handlerAsUtility().getLowNullifierMembershipWitness(parsedBlockHash, parsedNullifier);
198
311
  if (!witness) {
199
312
  throw new Error(
200
313
  `Low nullifier witness not found for nullifier ${parsedNullifier} at block hash ${parsedBlockHash.toString()}.`,
@@ -203,14 +316,15 @@ export class Oracle {
203
316
  return witness.toNoirRepresentation();
204
317
  }
205
318
 
206
- async utilityGetPublicDataWitness(
319
+ // eslint-disable-next-line camelcase
320
+ async aztec_utl_getPublicDataWitness(
207
321
  [blockHash]: ACVMField[],
208
322
  [leafSlot]: ACVMField[],
209
323
  ): Promise<(ACVMField | ACVMField[])[]> {
210
- const parsedBlockHash = L2BlockHash.fromString(blockHash);
324
+ const parsedBlockHash = BlockHash.fromString(blockHash);
211
325
  const parsedLeafSlot = Fr.fromString(leafSlot);
212
326
 
213
- const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(parsedBlockHash, parsedLeafSlot);
327
+ const witness = await this.handlerAsUtility().getPublicDataWitness(parsedBlockHash, parsedLeafSlot);
214
328
  if (!witness) {
215
329
  throw new Error(
216
330
  `Public data witness not found for slot ${parsedLeafSlot} at block hash ${parsedBlockHash.toString()}.`,
@@ -219,34 +333,45 @@ export class Oracle {
219
333
  return witness.toNoirRepresentation();
220
334
  }
221
335
 
222
- async utilityGetBlockHeader([blockNumber]: ACVMField[]): Promise<ACVMField[]> {
336
+ // eslint-disable-next-line camelcase
337
+ async aztec_utl_getBlockHeader([blockNumber]: ACVMField[]): Promise<ACVMField[]> {
223
338
  const parsedBlockNumber = Fr.fromString(blockNumber).toNumber();
224
339
 
225
- const header = await this.handlerAsUtility().utilityGetBlockHeader(BlockNumber(parsedBlockNumber));
340
+ const header = await this.handlerAsUtility().getBlockHeader(BlockNumber(parsedBlockNumber));
226
341
  if (!header) {
227
342
  throw new Error(`Block header not found for block ${parsedBlockNumber}.`);
228
343
  }
229
344
  return header.toFields().map(toACVMField);
230
345
  }
231
346
 
232
- async utilityGetAuthWitness([messageHash]: ACVMField[]): Promise<ACVMField[][]> {
347
+ // eslint-disable-next-line camelcase
348
+ async aztec_utl_getAuthWitness([messageHash]: ACVMField[]): Promise<ACVMField[][]> {
233
349
  const messageHashField = Fr.fromString(messageHash);
234
- const witness = await this.handlerAsUtility().utilityGetAuthWitness(messageHashField);
350
+ const witness = await this.handlerAsUtility().getAuthWitness(messageHashField);
235
351
  if (!witness) {
236
352
  throw new Error(`Unknown auth witness for message hash ${messageHashField}`);
237
353
  }
238
354
  return [witness.map(toACVMField)];
239
355
  }
240
356
 
241
- async utilityGetPublicKeysAndPartialAddress([address]: ACVMField[]): Promise<ACVMField[][]> {
357
+ // eslint-disable-next-line camelcase
358
+ async aztec_utl_getPublicKeysAndPartialAddress([address]: ACVMField[]): Promise<(ACVMField | ACVMField[])[]> {
242
359
  const parsedAddress = AztecAddress.fromField(Fr.fromString(address));
243
- const { publicKeys, partialAddress } =
244
- await this.handlerAsUtility().utilityGetPublicKeysAndPartialAddress(parsedAddress);
360
+ const result = await this.handlerAsUtility().getPublicKeysAndPartialAddress(parsedAddress);
245
361
 
246
- return [[...publicKeys.toFields(), partialAddress].map(toACVMField)];
362
+ // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
363
+ // with two fields: `some` (a boolean) and `value` (a field array in this case).
364
+ if (result === undefined) {
365
+ // No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
366
+ return [toACVMField(0), Array(13).fill(toACVMField(0))];
367
+ } else {
368
+ // Data was found so we set `some` to 1 and return it along with `value`.
369
+ return [toACVMField(1), [...result.publicKeys.toFields(), result.partialAddress].map(toACVMField)];
370
+ }
247
371
  }
248
372
 
249
- async utilityGetNotes(
373
+ // eslint-disable-next-line camelcase
374
+ async aztec_utl_getNotes(
250
375
  [ownerSome]: ACVMField[],
251
376
  [ownerValue]: ACVMField[],
252
377
  [storageSlot]: ACVMField[],
@@ -268,7 +393,7 @@ export class Oracle {
268
393
  ): Promise<(ACVMField | ACVMField[])[]> {
269
394
  // Parse Option<AztecAddress>: ownerSome is 0 for None, 1 for Some
270
395
  const owner = Fr.fromString(ownerSome).toNumber() === 1 ? AztecAddress.fromString(ownerValue) : undefined;
271
- const noteDatas = await this.handlerAsUtility().utilityGetNotes(
396
+ const noteDatas = await this.handlerAsUtility().getNotes(
272
397
  owner,
273
398
  Fr.fromString(storageSlot),
274
399
  +numSelects,
@@ -307,7 +432,8 @@ export class Oracle {
307
432
  return arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfACVMFieldArrays, +maxNotes, +packedHintedNoteLength);
308
433
  }
309
434
 
310
- privateNotifyCreatedNote(
435
+ // eslint-disable-next-line camelcase
436
+ aztec_prv_notifyCreatedNote(
311
437
  [owner]: ACVMField[],
312
438
  [storageSlot]: ACVMField[],
313
439
  [randomness]: ACVMField[],
@@ -316,7 +442,7 @@ export class Oracle {
316
442
  [noteHash]: ACVMField[],
317
443
  [counter]: ACVMField[],
318
444
  ): Promise<ACVMField[]> {
319
- this.handlerAsPrivate().privateNotifyCreatedNote(
445
+ this.handlerAsPrivate().notifyCreatedNote(
320
446
  AztecAddress.fromString(owner),
321
447
  Fr.fromString(storageSlot),
322
448
  Fr.fromString(randomness),
@@ -328,43 +454,47 @@ export class Oracle {
328
454
  return Promise.resolve([]);
329
455
  }
330
456
 
331
- async privateNotifyNullifiedNote(
457
+ // eslint-disable-next-line camelcase
458
+ async aztec_prv_notifyNullifiedNote(
332
459
  [innerNullifier]: ACVMField[],
333
460
  [noteHash]: ACVMField[],
334
461
  [counter]: ACVMField[],
335
462
  ): Promise<ACVMField[]> {
336
- await this.handlerAsPrivate().privateNotifyNullifiedNote(
337
- Fr.fromString(innerNullifier),
338
- Fr.fromString(noteHash),
339
- +counter,
340
- );
463
+ await this.handlerAsPrivate().notifyNullifiedNote(Fr.fromString(innerNullifier), Fr.fromString(noteHash), +counter);
341
464
  return [];
342
465
  }
343
466
 
344
- async privateNotifyCreatedNullifier([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
345
- await this.handlerAsPrivate().privateNotifyCreatedNullifier(Fr.fromString(innerNullifier));
467
+ // eslint-disable-next-line camelcase
468
+ async aztec_prv_notifyCreatedNullifier([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
469
+ await this.handlerAsPrivate().notifyCreatedNullifier(Fr.fromString(innerNullifier));
346
470
  return [];
347
471
  }
348
472
 
349
- async privateIsNullifierPending([innerNullifier]: ACVMField[], [contractAddress]: ACVMField[]): Promise<ACVMField[]> {
350
- const isPending = await this.handlerAsPrivate().privateIsNullifierPending(
473
+ // eslint-disable-next-line camelcase
474
+ async aztec_prv_isNullifierPending(
475
+ [innerNullifier]: ACVMField[],
476
+ [contractAddress]: ACVMField[],
477
+ ): Promise<ACVMField[]> {
478
+ const isPending = await this.handlerAsPrivate().isNullifierPending(
351
479
  Fr.fromString(innerNullifier),
352
480
  AztecAddress.fromString(contractAddress),
353
481
  );
354
482
  return [toACVMField(isPending)];
355
483
  }
356
484
 
357
- async utilityCheckNullifierExists([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
358
- const exists = await this.handlerAsUtility().utilityCheckNullifierExists(Fr.fromString(innerNullifier));
485
+ // eslint-disable-next-line camelcase
486
+ async aztec_utl_doesNullifierExist([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
487
+ const exists = await this.handlerAsUtility().doesNullifierExist(Fr.fromString(innerNullifier));
359
488
  return [toACVMField(exists)];
360
489
  }
361
490
 
362
- async utilityGetL1ToL2MembershipWitness(
491
+ // eslint-disable-next-line camelcase
492
+ async aztec_utl_getL1ToL2MembershipWitness(
363
493
  [contractAddress]: ACVMField[],
364
494
  [messageHash]: ACVMField[],
365
495
  [secret]: ACVMField[],
366
496
  ): Promise<(ACVMField | ACVMField[])[]> {
367
- const message = await this.handlerAsUtility().utilityGetL1ToL2MembershipWitness(
497
+ const message = await this.handlerAsUtility().getL1ToL2MembershipWitness(
368
498
  AztecAddress.fromString(contractAddress),
369
499
  Fr.fromString(messageHash),
370
500
  Fr.fromString(secret),
@@ -372,14 +502,15 @@ export class Oracle {
372
502
  return message.toNoirRepresentation();
373
503
  }
374
504
 
375
- async utilityStorageRead(
505
+ // eslint-disable-next-line camelcase
506
+ async aztec_utl_getFromPublicStorage(
376
507
  [blockHash]: ACVMField[],
377
508
  [contractAddress]: ACVMField[],
378
509
  [startStorageSlot]: ACVMField[],
379
510
  [numberOfElements]: ACVMField[],
380
511
  ): Promise<ACVMField[][]> {
381
- const values = await this.handlerAsUtility().utilityStorageRead(
382
- L2BlockHash.fromString(blockHash),
512
+ const values = await this.handlerAsUtility().getFromPublicStorage(
513
+ BlockHash.fromString(blockHash),
383
514
  new AztecAddress(Fr.fromString(contractAddress)),
384
515
  Fr.fromString(startStorageSlot),
385
516
  +numberOfElements,
@@ -387,7 +518,22 @@ export class Oracle {
387
518
  return [values.map(toACVMField)];
388
519
  }
389
520
 
390
- privateNotifyCreatedContractClassLog(
521
+ // eslint-disable-next-line camelcase
522
+ async aztec_utl_callUtilityFunction(
523
+ [contractAddress]: ACVMField[],
524
+ [functionSelector]: ACVMField[],
525
+ args: ACVMField[],
526
+ ): Promise<ACVMField[][]> {
527
+ const result = await this.handlerAsUtility().callUtilityFunction(
528
+ AztecAddress.fromField(Fr.fromString(contractAddress)),
529
+ FunctionSelector.fromField(Fr.fromString(functionSelector)),
530
+ args.map(Fr.fromString),
531
+ );
532
+ return [result.map(toACVMField)];
533
+ }
534
+
535
+ // eslint-disable-next-line camelcase
536
+ aztec_prv_notifyCreatedContractClassLog(
391
537
  [contractAddress]: ACVMField[],
392
538
  message: ACVMField[],
393
539
  [length]: ACVMField[],
@@ -396,11 +542,12 @@ export class Oracle {
396
542
  const logFields = new ContractClassLogFields(message.map(Fr.fromString));
397
543
  const log = new ContractClassLog(new AztecAddress(Fr.fromString(contractAddress)), logFields, +length);
398
544
 
399
- this.handlerAsPrivate().privateNotifyCreatedContractClassLog(log, +counter);
545
+ this.handlerAsPrivate().notifyCreatedContractClassLog(log, +counter);
400
546
  return Promise.resolve([]);
401
547
  }
402
548
 
403
- utilityDebugLog(
549
+ // eslint-disable-next-line camelcase
550
+ async aztec_utl_log(
404
551
  level: ACVMField[],
405
552
  message: ACVMField[],
406
553
  _ignoredFieldsSize: ACVMField[],
@@ -409,20 +556,21 @@ export class Oracle {
409
556
  const levelFr = Fr.fromString(level[0]);
410
557
  const messageStr = message.map(acvmField => String.fromCharCode(Fr.fromString(acvmField).toNumber())).join('');
411
558
  const fieldsFr = fields.map(Fr.fromString);
412
- this.handlerAsMisc().utilityDebugLog(levelFr.toNumber(), messageStr, fieldsFr);
413
- return Promise.resolve([]);
559
+ await this.handlerAsMisc().log(levelFr.toNumber(), messageStr, fieldsFr);
560
+ return [];
414
561
  }
415
562
 
416
563
  // This function's name is directly hardcoded in `circuit_recorder.ts`. Don't forget to update it there if you
417
564
  // change the name here.
418
- async privateCallPrivateFunction(
565
+ // eslint-disable-next-line camelcase
566
+ async aztec_prv_callPrivateFunction(
419
567
  [contractAddress]: ACVMField[],
420
568
  [functionSelector]: ACVMField[],
421
569
  [argsHash]: ACVMField[],
422
570
  [sideEffectCounter]: ACVMField[],
423
571
  [isStaticCall]: ACVMField[],
424
572
  ): Promise<ACVMField[][]> {
425
- const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().privateCallPrivateFunction(
573
+ const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().callPrivateFunction(
426
574
  AztecAddress.fromField(Fr.fromString(contractAddress)),
427
575
  FunctionSelector.fromField(Fr.fromString(functionSelector)),
428
576
  Fr.fromString(argsHash),
@@ -432,113 +580,195 @@ export class Oracle {
432
580
  return [[endSideEffectCounter, returnsHash].map(toACVMField)];
433
581
  }
434
582
 
435
- async privateNotifyEnqueuedPublicFunctionCall(
436
- [contractAddress]: ACVMField[],
437
- [calldataHash]: ACVMField[],
438
- [sideEffectCounter]: ACVMField[],
439
- [isStaticCall]: ACVMField[],
440
- ): Promise<ACVMField[]> {
441
- await this.handlerAsPrivate().privateNotifyEnqueuedPublicFunctionCall(
442
- AztecAddress.fromString(contractAddress),
443
- Fr.fromString(calldataHash),
444
- Fr.fromString(sideEffectCounter).toNumber(),
445
- Fr.fromString(isStaticCall).toBool(),
446
- );
583
+ // eslint-disable-next-line camelcase
584
+ async aztec_prv_assertValidPublicCalldata([calldataHash]: ACVMField[]): Promise<ACVMField[]> {
585
+ await this.handlerAsPrivate().assertValidPublicCalldata(Fr.fromString(calldataHash));
447
586
  return [];
448
587
  }
449
588
 
450
- async privateNotifySetPublicTeardownFunctionCall(
451
- [contractAddress]: ACVMField[],
452
- [calldataHash]: ACVMField[],
453
- [sideEffectCounter]: ACVMField[],
454
- [isStaticCall]: ACVMField[],
455
- ): Promise<ACVMField[]> {
456
- await this.handlerAsPrivate().privateNotifySetPublicTeardownFunctionCall(
457
- AztecAddress.fromString(contractAddress),
458
- Fr.fromString(calldataHash),
459
- Fr.fromString(sideEffectCounter).toNumber(),
460
- Fr.fromString(isStaticCall).toBool(),
461
- );
462
- return [];
463
- }
464
-
465
- async privateNotifySetMinRevertibleSideEffectCounter([minRevertibleSideEffectCounter]: ACVMField[]): Promise<
466
- ACVMField[]
467
- > {
468
- await this.handlerAsPrivate().privateNotifySetMinRevertibleSideEffectCounter(
469
- Fr.fromString(minRevertibleSideEffectCounter).toNumber(),
470
- );
589
+ // eslint-disable-next-line camelcase
590
+ async aztec_prv_notifyRevertiblePhaseStart([minRevertibleSideEffectCounter]: ACVMField[]): Promise<ACVMField[]> {
591
+ await this.handlerAsPrivate().notifyRevertiblePhaseStart(Fr.fromString(minRevertibleSideEffectCounter).toNumber());
471
592
  return Promise.resolve([]);
472
593
  }
473
594
 
474
- async privateIsSideEffectCounterRevertible([sideEffectCounter]: ACVMField[]): Promise<ACVMField[]> {
475
- const isRevertible = await this.handlerAsPrivate().privateIsSideEffectCounterRevertible(
595
+ // eslint-disable-next-line camelcase
596
+ async aztec_prv_isExecutionInRevertiblePhase([sideEffectCounter]: ACVMField[]): Promise<ACVMField[]> {
597
+ const isRevertible = await this.handlerAsPrivate().isExecutionInRevertiblePhase(
476
598
  Fr.fromString(sideEffectCounter).toNumber(),
477
599
  );
478
600
  return Promise.resolve([toACVMField(isRevertible)]);
479
601
  }
480
602
 
481
- async privateGetNextAppTagAsSender([sender]: ACVMField[], [recipient]: ACVMField[]): Promise<ACVMField[]> {
482
- const tag = await this.handlerAsPrivate().privateGetNextAppTagAsSender(
603
+ // eslint-disable-next-line camelcase
604
+ async aztec_prv_getNextAppTagAsSender([sender]: ACVMField[], [recipient]: ACVMField[]): Promise<ACVMField[]> {
605
+ const tag = await this.handlerAsPrivate().getNextAppTagAsSender(
483
606
  AztecAddress.fromString(sender),
484
607
  AztecAddress.fromString(recipient),
485
608
  );
486
609
  return [toACVMField(tag.value)];
487
610
  }
488
611
 
489
- async utilityFetchTaggedLogs([pendingTaggedLogArrayBaseSlot]: ACVMField[]): Promise<ACVMField[]> {
490
- await this.handlerAsUtility().utilityFetchTaggedLogs(Fr.fromString(pendingTaggedLogArrayBaseSlot));
612
+ // eslint-disable-next-line camelcase
613
+ async aztec_utl_getPendingTaggedLogs(
614
+ [pendingTaggedLogArrayBaseSlot]: ACVMField[],
615
+ [scope]: ACVMField[],
616
+ ): Promise<ACVMField[]> {
617
+ await this.handlerAsUtility().getPendingTaggedLogs(
618
+ Fr.fromString(pendingTaggedLogArrayBaseSlot),
619
+ AztecAddress.fromString(scope),
620
+ );
491
621
  return [];
492
622
  }
493
623
 
494
- async utilityValidateAndStoreEnqueuedNotesAndEvents(
624
+ // eslint-disable-next-line camelcase
625
+ async aztec_utl_getPendingTaggedLogs_v2([scope]: ACVMField[]): Promise<ACVMField[]> {
626
+ const slot = await this.handlerAsUtility().getPendingTaggedLogsV2(AztecAddress.fromString(scope));
627
+ return [toACVMField(slot)];
628
+ }
629
+
630
+ // eslint-disable-next-line camelcase
631
+ async aztec_utl_validateAndStoreEnqueuedNotesAndEvents(
495
632
  [contractAddress]: ACVMField[],
496
633
  [noteValidationRequestsArrayBaseSlot]: ACVMField[],
497
634
  [eventValidationRequestsArrayBaseSlot]: ACVMField[],
635
+ [maxNotePackedLen]: ACVMField[],
636
+ [maxEventSerializedLen]: ACVMField[],
637
+ [scope]: ACVMField[],
498
638
  ): Promise<ACVMField[]> {
499
- await this.handlerAsUtility().utilityValidateAndStoreEnqueuedNotesAndEvents(
639
+ await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(
500
640
  AztecAddress.fromString(contractAddress),
501
641
  Fr.fromString(noteValidationRequestsArrayBaseSlot),
502
642
  Fr.fromString(eventValidationRequestsArrayBaseSlot),
643
+ Fr.fromString(maxNotePackedLen).toNumber(),
644
+ Fr.fromString(maxEventSerializedLen).toNumber(),
645
+ AztecAddress.fromString(scope),
503
646
  );
504
647
 
505
648
  return [];
506
649
  }
507
650
 
508
- async utilityBulkRetrieveLogs(
651
+ // eslint-disable-next-line camelcase
652
+ async aztec_utl_validateAndStoreEnqueuedNotesAndEvents_v2(
653
+ [noteValidationRequestsArrayBaseSlot]: ACVMField[],
654
+ [eventValidationRequestsArrayBaseSlot]: ACVMField[],
655
+ [maxNotePackedLen]: ACVMField[],
656
+ [maxEventSerializedLen]: ACVMField[],
657
+ [scope]: ACVMField[],
658
+ ): Promise<ACVMField[]> {
659
+ await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEventsV2(
660
+ Fr.fromString(noteValidationRequestsArrayBaseSlot),
661
+ Fr.fromString(eventValidationRequestsArrayBaseSlot),
662
+ Fr.fromString(maxNotePackedLen).toNumber(),
663
+ Fr.fromString(maxEventSerializedLen).toNumber(),
664
+ AztecAddress.fromString(scope),
665
+ );
666
+ return [];
667
+ }
668
+
669
+ // eslint-disable-next-line camelcase
670
+ async aztec_utl_getLogsByTag(
509
671
  [contractAddress]: ACVMField[],
510
672
  [logRetrievalRequestsArrayBaseSlot]: ACVMField[],
511
673
  [logRetrievalResponsesArrayBaseSlot]: ACVMField[],
674
+ [scope]: ACVMField[],
512
675
  ): Promise<ACVMField[]> {
513
- await this.handlerAsUtility().utilityBulkRetrieveLogs(
676
+ await this.handlerAsUtility().getLogsByTag(
514
677
  AztecAddress.fromString(contractAddress),
515
678
  Fr.fromString(logRetrievalRequestsArrayBaseSlot),
516
679
  Fr.fromString(logRetrievalResponsesArrayBaseSlot),
680
+ AztecAddress.fromString(scope),
517
681
  );
518
682
  return [];
519
683
  }
520
684
 
521
- async utilityStoreCapsule(
685
+ // eslint-disable-next-line camelcase
686
+ async aztec_utl_getMessageContextsByTxHash(
687
+ [contractAddress]: ACVMField[],
688
+ [messageContextRequestsArrayBaseSlot]: ACVMField[],
689
+ [messageContextResponsesArrayBaseSlot]: ACVMField[],
690
+ [scope]: ACVMField[],
691
+ ): Promise<ACVMField[]> {
692
+ await this.handlerAsUtility().getMessageContextsByTxHash(
693
+ AztecAddress.fromString(contractAddress),
694
+ Fr.fromString(messageContextRequestsArrayBaseSlot),
695
+ Fr.fromString(messageContextResponsesArrayBaseSlot),
696
+ AztecAddress.fromString(scope),
697
+ );
698
+ return [];
699
+ }
700
+
701
+ // eslint-disable-next-line camelcase
702
+ async aztec_utl_getLogsByTag_v2([requestArrayBaseSlot]: ACVMField[]): Promise<ACVMField[]> {
703
+ const responseSlot = await this.handlerAsUtility().getLogsByTagV2(Fr.fromString(requestArrayBaseSlot));
704
+ return [toACVMField(responseSlot)];
705
+ }
706
+
707
+ // eslint-disable-next-line camelcase
708
+ async aztec_utl_getMessageContextsByTxHash_v2([requestArrayBaseSlot]: ACVMField[]): Promise<ACVMField[]> {
709
+ const responseSlot = await this.handlerAsUtility().getMessageContextsByTxHashV2(
710
+ Fr.fromString(requestArrayBaseSlot),
711
+ );
712
+ return [toACVMField(responseSlot)];
713
+ }
714
+
715
+ // eslint-disable-next-line camelcase
716
+ async aztec_utl_getTxEffect([txHash]: ACVMField[]): Promise<(ACVMField | ACVMField[])[]> {
717
+ const txEffect = await this.handlerAsUtility().getTxEffect(TxHash.fromField(Fr.fromString(txHash)));
718
+ // The Noir oracle returns `Option<TxEffect>`. ACVM expands this into 12 destination slots: the Option discriminant
719
+ // followed by the 11 leaf slots of `TxEffect` (each scalar is one slot, each top-level array is one slot, and
720
+ // the nested `PublicLogs { length, payload }` splits into two slots).
721
+ const effect = txEffect ?? TxEffect.empty();
722
+ const flatPublicLogs = FlatPublicLogs.fromLogs(effect.publicLogs);
723
+ return [
724
+ toACVMField(txEffect === null ? 0 : 1),
725
+ toACVMField(effect.revertCode.toField()),
726
+ toACVMField(effect.txHash.hash),
727
+ toACVMField(effect.transactionFee),
728
+ padArrayEnd(effect.noteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX).map(toACVMField),
729
+ padArrayEnd(effect.nullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX).map(toACVMField),
730
+ padArrayEnd(effect.l2ToL1Msgs, Fr.ZERO, MAX_L2_TO_L1_MSGS_PER_TX).map(toACVMField),
731
+ padArrayEnd(effect.publicDataWrites, PublicDataWrite.empty(), MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX)
732
+ .flatMap(w => w.toFields())
733
+ .map(toACVMField),
734
+ padArrayEnd(effect.privateLogs, PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX)
735
+ .flatMap(l => l.toFields())
736
+ .map(toACVMField),
737
+ toACVMField(flatPublicLogs.length),
738
+ flatPublicLogs.payload.map(toACVMField),
739
+ padArrayEnd(effect.contractClassLogs, ContractClassLog.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX)
740
+ .flatMap(l => [...l.fields.toFields(), new Fr(l.emittedLength), l.contractAddress.toField()])
741
+ .map(toACVMField),
742
+ ];
743
+ }
744
+
745
+ // eslint-disable-next-line camelcase
746
+ aztec_utl_setCapsule(
522
747
  [contractAddress]: ACVMField[],
523
748
  [slot]: ACVMField[],
524
749
  capsule: ACVMField[],
750
+ [scope]: ACVMField[],
525
751
  ): Promise<ACVMField[]> {
526
- await this.handlerAsUtility().utilityStoreCapsule(
752
+ this.handlerAsUtility().setCapsule(
527
753
  AztecAddress.fromField(Fr.fromString(contractAddress)),
528
754
  Fr.fromString(slot),
529
755
  capsule.map(Fr.fromString),
756
+ AztecAddress.fromField(Fr.fromString(scope)),
530
757
  );
531
- return [];
758
+ return Promise.resolve([]);
532
759
  }
533
760
 
534
- async utilityLoadCapsule(
761
+ // eslint-disable-next-line camelcase
762
+ async aztec_utl_getCapsule(
535
763
  [contractAddress]: ACVMField[],
536
764
  [slot]: ACVMField[],
537
765
  [tSize]: ACVMField[],
766
+ [scope]: ACVMField[],
538
767
  ): Promise<(ACVMField | ACVMField[])[]> {
539
- const values = await this.handlerAsUtility().utilityLoadCapsule(
768
+ const values = await this.handlerAsUtility().getCapsule(
540
769
  AztecAddress.fromField(Fr.fromString(contractAddress)),
541
770
  Fr.fromString(slot),
771
+ AztecAddress.fromField(Fr.fromString(scope)),
542
772
  );
543
773
 
544
774
  // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
@@ -552,30 +782,86 @@ export class Oracle {
552
782
  }
553
783
  }
554
784
 
555
- async utilityDeleteCapsule([contractAddress]: ACVMField[], [slot]: ACVMField[]): Promise<ACVMField[]> {
556
- await this.handlerAsUtility().utilityDeleteCapsule(
785
+ // eslint-disable-next-line camelcase
786
+ aztec_utl_deleteCapsule(
787
+ [contractAddress]: ACVMField[],
788
+ [slot]: ACVMField[],
789
+ [scope]: ACVMField[],
790
+ ): Promise<ACVMField[]> {
791
+ this.handlerAsUtility().deleteCapsule(
557
792
  AztecAddress.fromField(Fr.fromString(contractAddress)),
558
793
  Fr.fromString(slot),
794
+ AztecAddress.fromField(Fr.fromString(scope)),
559
795
  );
560
- return [];
796
+ return Promise.resolve([]);
561
797
  }
562
798
 
563
- async utilityCopyCapsule(
799
+ // eslint-disable-next-line camelcase
800
+ async aztec_utl_copyCapsule(
564
801
  [contractAddress]: ACVMField[],
565
802
  [srcSlot]: ACVMField[],
566
803
  [dstSlot]: ACVMField[],
567
804
  [numEntries]: ACVMField[],
805
+ [scope]: ACVMField[],
568
806
  ): Promise<ACVMField[]> {
569
- await this.handlerAsUtility().utilityCopyCapsule(
807
+ await this.handlerAsUtility().copyCapsule(
570
808
  AztecAddress.fromField(Fr.fromString(contractAddress)),
571
809
  Fr.fromString(srcSlot),
572
810
  Fr.fromString(dstSlot),
573
811
  Fr.fromString(numEntries).toNumber(),
812
+ AztecAddress.fromField(Fr.fromString(scope)),
574
813
  );
575
814
  return [];
576
815
  }
577
816
 
578
- async utilityAes128Decrypt(
817
+ // eslint-disable-next-line camelcase
818
+ aztec_utl_pushEphemeral([slot]: ACVMField[], elements: ACVMField[]): Promise<ACVMField[]> {
819
+ const newLen = this.handlerAsUtility().pushEphemeral(Fr.fromString(slot), elements.map(Fr.fromString));
820
+ return Promise.resolve([toACVMField(newLen)]);
821
+ }
822
+
823
+ // eslint-disable-next-line camelcase
824
+ aztec_utl_popEphemeral([slot]: ACVMField[]): Promise<ACVMField[][]> {
825
+ const element = this.handlerAsUtility().popEphemeral(Fr.fromString(slot));
826
+ return Promise.resolve([element.map(toACVMField)]);
827
+ }
828
+
829
+ // eslint-disable-next-line camelcase
830
+ aztec_utl_getEphemeral([slot]: ACVMField[], [index]: ACVMField[]): Promise<ACVMField[][]> {
831
+ const element = this.handlerAsUtility().getEphemeral(Fr.fromString(slot), Fr.fromString(index).toNumber());
832
+ return Promise.resolve([element.map(toACVMField)]);
833
+ }
834
+
835
+ // eslint-disable-next-line camelcase
836
+ aztec_utl_setEphemeral([slot]: ACVMField[], [index]: ACVMField[], elements: ACVMField[]): Promise<ACVMField[]> {
837
+ this.handlerAsUtility().setEphemeral(
838
+ Fr.fromString(slot),
839
+ Fr.fromString(index).toNumber(),
840
+ elements.map(Fr.fromString),
841
+ );
842
+ return Promise.resolve([]);
843
+ }
844
+
845
+ // eslint-disable-next-line camelcase
846
+ aztec_utl_getEphemeralLen([slot]: ACVMField[]): Promise<ACVMField[]> {
847
+ const len = this.handlerAsUtility().getEphemeralLen(Fr.fromString(slot));
848
+ return Promise.resolve([toACVMField(len)]);
849
+ }
850
+
851
+ // eslint-disable-next-line camelcase
852
+ aztec_utl_removeEphemeral([slot]: ACVMField[], [index]: ACVMField[]): Promise<ACVMField[]> {
853
+ this.handlerAsUtility().removeEphemeral(Fr.fromString(slot), Fr.fromString(index).toNumber());
854
+ return Promise.resolve([]);
855
+ }
856
+
857
+ // eslint-disable-next-line camelcase
858
+ aztec_utl_clearEphemeral([slot]: ACVMField[]): Promise<ACVMField[]> {
859
+ this.handlerAsUtility().clearEphemeral(Fr.fromString(slot));
860
+ return Promise.resolve([]);
861
+ }
862
+
863
+ // eslint-disable-next-line camelcase
864
+ async aztec_utl_decryptAes128(
579
865
  ciphertextBVecStorage: ACVMField[],
580
866
  [ciphertextLength]: ACVMField[],
581
867
  iv: ACVMField[],
@@ -585,36 +871,63 @@ export class Oracle {
585
871
  const ivBuffer = fromUintArray(iv, 8);
586
872
  const symKeyBuffer = fromUintArray(symKey, 8);
587
873
 
588
- const plaintext = await this.handlerAsUtility().utilityAes128Decrypt(ciphertext, ivBuffer, symKeyBuffer);
589
- return bufferToBoundedVec(plaintext, ciphertextBVecStorage.length);
874
+ // Noir Option<BoundedVec> is encoded as [is_some: Field, storage: Field[], length: Field].
875
+ try {
876
+ const plaintext = await this.handlerAsUtility().decryptAes128(ciphertext, ivBuffer, symKeyBuffer);
877
+ const [storage, length] = bufferToBoundedVec(plaintext, ciphertextBVecStorage.length);
878
+ return [toACVMField(1), storage, length];
879
+ } catch {
880
+ const zeroStorage = Array(ciphertextBVecStorage.length).fill(toACVMField(0));
881
+ return [toACVMField(0), zeroStorage, toACVMField(0)];
882
+ }
590
883
  }
591
884
 
592
- async utilityGetSharedSecret(
885
+ // eslint-disable-next-line camelcase
886
+ async aztec_utl_getSharedSecret(
593
887
  [address]: ACVMField[],
594
888
  [ephPKField0]: ACVMField[],
595
889
  [ephPKField1]: ACVMField[],
596
890
  [ephPKField2]: ACVMField[],
891
+ [contractAddress]: ACVMField[],
597
892
  ): Promise<ACVMField[]> {
598
- const secret = await this.handlerAsUtility().utilityGetSharedSecret(
893
+ const secret = await this.handlerAsUtility().getSharedSecret(
599
894
  AztecAddress.fromField(Fr.fromString(address)),
600
895
  Point.fromFields([ephPKField0, ephPKField1, ephPKField2].map(Fr.fromString)),
896
+ AztecAddress.fromField(Fr.fromString(contractAddress)),
601
897
  );
602
- return secret.toFields().map(toACVMField);
898
+ return [toACVMField(secret)];
899
+ }
900
+
901
+ // eslint-disable-next-line camelcase
902
+ aztec_utl_setContractSyncCacheInvalid(
903
+ [contractAddress]: ACVMField[],
904
+ scopes: ACVMField[],
905
+ [scopeCount]: ACVMField[],
906
+ ): Promise<ACVMField[]> {
907
+ const scopeAddresses = scopes.slice(0, +scopeCount).map(s => AztecAddress.fromField(Fr.fromString(s)));
908
+ this.handlerAsUtility().setContractSyncCacheInvalid(
909
+ AztecAddress.fromField(Fr.fromString(contractAddress)),
910
+ scopeAddresses,
911
+ );
912
+ return Promise.resolve([]);
603
913
  }
604
914
 
605
- async utilityEmitOffchainEffect(data: ACVMField[]) {
606
- await this.handlerAsPrivate().utilityEmitOffchainEffect(data.map(Fr.fromString));
915
+ // eslint-disable-next-line camelcase
916
+ async aztec_utl_emitOffchainEffect(data: ACVMField[]) {
917
+ await this.handlerAsUtility().emitOffchainEffect(data.map(Fr.fromString));
607
918
  return [];
608
919
  }
609
920
 
610
- async privateGetSenderForTags(): Promise<ACVMField[]> {
611
- const sender = await this.handlerAsPrivate().privateGetSenderForTags();
921
+ // eslint-disable-next-line camelcase
922
+ async aztec_prv_getSenderForTags(): Promise<ACVMField[]> {
923
+ const sender = await this.handlerAsPrivate().getSenderForTags();
612
924
  // Return [1, address] for Some(address), [0, 0] for None
613
925
  return sender ? [toACVMField(1n), toACVMField(sender)] : [toACVMField(0n), toACVMField(0n)];
614
926
  }
615
927
 
616
- async privateSetSenderForTags([senderForTags]: ACVMField[]): Promise<ACVMField[]> {
617
- await this.handlerAsPrivate().privateSetSenderForTags(AztecAddress.fromField(Fr.fromString(senderForTags)));
928
+ // eslint-disable-next-line camelcase
929
+ async aztec_prv_setSenderForTags([senderForTags]: ACVMField[]): Promise<ACVMField[]> {
930
+ await this.handlerAsPrivate().setSenderForTags(AztecAddress.fromField(Fr.fromString(senderForTags)));
618
931
  return [];
619
932
  }
620
933
  }