@aztec/pxe 0.0.1-commit.b9865e97 → 0.0.1-commit.be03c316

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 (397) hide show
  1. package/dest/bin/check_oracle_version.js +8 -23
  2. package/dest/bin/index.d.ts +2 -2
  3. package/dest/bin/index.d.ts.map +1 -1
  4. package/dest/bin/index.js +1 -1
  5. package/dest/bin/oracle_version_helpers.d.ts +16 -8
  6. package/dest/bin/oracle_version_helpers.d.ts.map +1 -1
  7. package/dest/bin/oracle_version_helpers.js +22 -69
  8. package/dest/block_synchronizer/block_stream_source.d.ts +5 -5
  9. package/dest/block_synchronizer/block_stream_source.d.ts.map +1 -1
  10. package/dest/block_synchronizer/block_stream_source.js +4 -29
  11. package/dest/block_synchronizer/block_synchronizer.d.ts +18 -14
  12. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  13. package/dest/block_synchronizer/block_synchronizer.js +54 -18
  14. package/dest/config/index.d.ts +2 -1
  15. package/dest/config/index.d.ts.map +1 -1
  16. package/dest/config/index.js +1 -0
  17. package/dest/contract/contract_class_service.d.ts +31 -0
  18. package/dest/contract/contract_class_service.d.ts.map +1 -0
  19. package/dest/contract/contract_class_service.js +68 -0
  20. package/dest/contract/contract_sync_service.d.ts +48 -0
  21. package/dest/contract/contract_sync_service.d.ts.map +1 -0
  22. package/dest/{contract_sync → contract}/contract_sync_service.js +26 -45
  23. package/dest/contract/helpers.d.ts +7 -0
  24. package/dest/contract/helpers.d.ts.map +1 -0
  25. package/dest/contract/helpers.js +20 -0
  26. package/dest/contract/skip_sync_contracts.d.ts +11 -0
  27. package/dest/contract/skip_sync_contracts.d.ts.map +1 -0
  28. package/dest/contract/skip_sync_contracts.js +18 -0
  29. package/dest/contract_function_simulator/anchored_contract_data.d.ts +36 -0
  30. package/dest/contract_function_simulator/anchored_contract_data.d.ts.map +1 -0
  31. package/dest/contract_function_simulator/anchored_contract_data.js +54 -0
  32. package/dest/contract_function_simulator/aztec_node_read_cache.d.ts +39 -0
  33. package/dest/contract_function_simulator/aztec_node_read_cache.d.ts.map +1 -0
  34. package/dest/contract_function_simulator/aztec_node_read_cache.js +60 -0
  35. package/dest/contract_function_simulator/contract_function_simulator.d.ts +19 -18
  36. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  37. package/dest/contract_function_simulator/contract_function_simulator.js +63 -32
  38. package/dest/contract_function_simulator/execution_note_cache.d.ts +3 -9
  39. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  40. package/dest/contract_function_simulator/execution_note_cache.js +8 -28
  41. package/dest/contract_function_simulator/index.d.ts +19 -10
  42. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  43. package/dest/contract_function_simulator/index.js +6 -9
  44. package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts +8 -27
  45. package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts.map +1 -1
  46. package/dest/contract_function_simulator/noir-structs/bounded_vec.js +8 -23
  47. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts +9 -0
  48. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts.map +1 -0
  49. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.js +1 -0
  50. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts +7 -0
  51. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts.map +1 -0
  52. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.js +1 -0
  53. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
  54. package/dest/contract_function_simulator/noir-structs/fact.d.ts +16 -0
  55. package/dest/contract_function_simulator/noir-structs/fact.d.ts.map +1 -0
  56. package/dest/contract_function_simulator/noir-structs/fact.js +6 -0
  57. package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts +27 -0
  58. package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts.map +1 -0
  59. package/dest/contract_function_simulator/noir-structs/fact_collection.js +31 -0
  60. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +11 -12
  61. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
  62. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +6 -49
  63. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +10 -8
  64. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  65. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -60
  66. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +2 -2
  67. package/dest/contract_function_simulator/noir-structs/option.d.ts +9 -11
  68. package/dest/contract_function_simulator/noir-structs/option.d.ts.map +1 -1
  69. package/dest/contract_function_simulator/noir-structs/option.js +18 -13
  70. package/dest/contract_function_simulator/noir-structs/origin_block.d.ts +11 -0
  71. package/dest/contract_function_simulator/noir-structs/origin_block.d.ts.map +1 -0
  72. package/dest/contract_function_simulator/noir-structs/origin_block.js +5 -0
  73. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts +11 -0
  74. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts.map +1 -0
  75. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.js +4 -0
  76. package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +6 -9
  77. package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts.map +1 -1
  78. package/dest/contract_function_simulator/noir-structs/provided_secret.js +1 -24
  79. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts +28 -0
  80. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts.map +1 -0
  81. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.js +50 -0
  82. package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts +19 -0
  83. package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts.map +1 -0
  84. package/dest/contract_function_simulator/noir-structs/resolved_tx.js +9 -0
  85. package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts +15 -0
  86. package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts.map +1 -0
  87. package/dest/contract_function_simulator/noir-structs/tx_effect_data.js +5 -0
  88. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +6 -11
  89. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
  90. package/dest/contract_function_simulator/noir-structs/utility_context.js +1 -20
  91. package/dest/contract_function_simulator/oracle/acir_callback.d.ts +21 -0
  92. package/dest/contract_function_simulator/oracle/acir_callback.d.ts.map +1 -0
  93. package/dest/contract_function_simulator/oracle/acir_callback.js +115 -0
  94. package/dest/contract_function_simulator/oracle/index.d.ts +2 -13
  95. package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -1
  96. package/dest/contract_function_simulator/oracle/index.js +1 -1
  97. package/dest/contract_function_simulator/oracle/interfaces.d.ts +2 -3
  98. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  99. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts +39 -0
  100. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts.map +1 -0
  101. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.js +107 -0
  102. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -14
  103. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  104. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -24
  105. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +43 -31
  106. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
  107. package/dest/contract_function_simulator/oracle/oracle_registry.js +259 -29
  108. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +180 -45
  109. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -1
  110. package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +1024 -341
  111. package/dest/contract_function_simulator/oracle/private_execution.d.ts +1 -1
  112. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  113. package/dest/contract_function_simulator/oracle/private_execution.js +2 -3
  114. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +21 -8
  115. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  116. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +132 -22
  117. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +77 -34
  118. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  119. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +247 -106
  120. package/dest/contract_function_simulator/transient_array_service.d.ts +31 -0
  121. package/dest/contract_function_simulator/transient_array_service.d.ts.map +1 -0
  122. package/dest/contract_function_simulator/transient_array_service.js +62 -0
  123. package/dest/debug/pxe_debug_utils.d.ts +2 -2
  124. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  125. package/dest/entrypoints/client/bundle/index.d.ts +2 -1
  126. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  127. package/dest/entrypoints/client/bundle/index.js +1 -0
  128. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  129. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  130. package/dest/entrypoints/client/bundle/utils.js +17 -6
  131. package/dest/entrypoints/client/lazy/index.d.ts +2 -1
  132. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  133. package/dest/entrypoints/client/lazy/index.js +1 -0
  134. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  135. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  136. package/dest/entrypoints/client/lazy/utils.js +17 -6
  137. package/dest/entrypoints/client/store.d.ts +14 -0
  138. package/dest/entrypoints/client/store.d.ts.map +1 -0
  139. package/dest/entrypoints/client/store.js +42 -0
  140. package/dest/entrypoints/pxe_creation_options.d.ts +9 -3
  141. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  142. package/dest/entrypoints/server/index.d.ts +6 -3
  143. package/dest/entrypoints/server/index.d.ts.map +1 -1
  144. package/dest/entrypoints/server/index.js +4 -2
  145. package/dest/entrypoints/server/store.d.ts +18 -0
  146. package/dest/entrypoints/server/store.d.ts.map +1 -0
  147. package/dest/entrypoints/server/store.js +28 -0
  148. package/dest/entrypoints/server/utils.d.ts +1 -1
  149. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  150. package/dest/entrypoints/server/utils.js +16 -4
  151. package/dest/error_enriching.d.ts +5 -3
  152. package/dest/error_enriching.d.ts.map +1 -1
  153. package/dest/error_enriching.js +13 -11
  154. package/dest/hooks/execution_hooks.d.ts +31 -11
  155. package/dest/hooks/execution_hooks.d.ts.map +1 -1
  156. package/dest/hooks/execution_hooks.js +3 -3
  157. package/dest/hooks/index.d.ts +4 -3
  158. package/dest/hooks/index.d.ts.map +1 -1
  159. package/dest/hooks/index.js +1 -0
  160. package/dest/hooks/resolve_custom_request.d.ts +23 -0
  161. package/dest/hooks/resolve_custom_request.d.ts.map +1 -0
  162. package/dest/hooks/resolve_custom_request.js +3 -0
  163. package/dest/hooks/resolve_tagging_secret_strategy.d.ts +50 -0
  164. package/dest/hooks/resolve_tagging_secret_strategy.d.ts.map +1 -0
  165. package/dest/hooks/resolve_tagging_secret_strategy.js +3 -0
  166. package/dest/logs/log_service.d.ts +8 -6
  167. package/dest/logs/log_service.d.ts.map +1 -1
  168. package/dest/logs/log_service.js +88 -28
  169. package/dest/messages/tx_resolver_service.d.ts +17 -0
  170. package/dest/messages/tx_resolver_service.d.ts.map +1 -0
  171. package/dest/messages/{message_context_service.js → tx_resolver_service.js} +13 -8
  172. package/dest/notes/note_service.d.ts +1 -1
  173. package/dest/notes/note_service.js +1 -1
  174. package/dest/oracle_version.d.ts +3 -3
  175. package/dest/oracle_version.js +5 -5
  176. package/dest/private_kernel/batch_planner.d.ts +1 -1
  177. package/dest/private_kernel/batch_planner.d.ts.map +1 -1
  178. package/dest/private_kernel/batch_planner.js +1 -1
  179. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +1 -1
  180. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  181. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +6 -2
  182. package/dest/private_kernel/hints/test_utils.js +1 -1
  183. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  184. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  185. package/dest/private_kernel/private_kernel_execution_prover.js +61 -40
  186. package/dest/private_kernel/private_kernel_oracle.d.ts +4 -2
  187. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  188. package/dest/private_kernel/private_kernel_oracle.js +17 -5
  189. package/dest/pxe.d.ts +114 -48
  190. package/dest/pxe.d.ts.map +1 -1
  191. package/dest/pxe.js +225 -139
  192. package/dest/storage/allowed_scopes.d.ts +6 -0
  193. package/dest/storage/allowed_scopes.d.ts.map +1 -0
  194. package/dest/storage/allowed_scopes.js +7 -0
  195. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -6
  196. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
  197. package/dest/storage/anchor_block_store/anchor_block_store.js +8 -6
  198. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +1 -1
  199. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -1
  200. package/dest/storage/backwards_compatibility_tests/schema_tests.js +129 -49
  201. package/dest/storage/capsule_store/capsule_service.d.ts +1 -1
  202. package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -1
  203. package/dest/storage/capsule_store/capsule_service.js +6 -9
  204. package/dest/storage/contract_store/contract_store.d.ts +27 -24
  205. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  206. package/dest/storage/contract_store/contract_store.js +64 -75
  207. package/dest/storage/fact_store/fact_service.d.ts +22 -0
  208. package/dest/storage/fact_store/fact_service.d.ts.map +1 -0
  209. package/dest/storage/fact_store/fact_service.js +45 -0
  210. package/dest/storage/fact_store/fact_store.d.ts +95 -0
  211. package/dest/storage/fact_store/fact_store.d.ts.map +1 -0
  212. package/dest/storage/fact_store/fact_store.js +408 -0
  213. package/dest/storage/fact_store/fact_store_keys.d.ts +34 -0
  214. package/dest/storage/fact_store/fact_store_keys.d.ts.map +1 -0
  215. package/dest/storage/fact_store/fact_store_keys.js +50 -0
  216. package/dest/storage/fact_store/index.d.ts +6 -0
  217. package/dest/storage/fact_store/index.d.ts.map +1 -0
  218. package/dest/storage/fact_store/index.js +4 -0
  219. package/dest/storage/fact_store/origin_state.d.ts +59 -0
  220. package/dest/storage/fact_store/origin_state.d.ts.map +1 -0
  221. package/dest/storage/fact_store/origin_state.js +60 -0
  222. package/dest/storage/fact_store/stored_fact.d.ts +32 -0
  223. package/dest/storage/fact_store/stored_fact.d.ts.map +1 -0
  224. package/dest/storage/fact_store/stored_fact.js +64 -0
  225. package/dest/storage/index.d.ts +3 -2
  226. package/dest/storage/index.d.ts.map +1 -1
  227. package/dest/storage/index.js +2 -1
  228. package/dest/storage/metadata.d.ts +2 -2
  229. package/dest/storage/metadata.d.ts.map +1 -1
  230. package/dest/storage/metadata.js +1 -1
  231. package/dest/storage/note_store/note_store.d.ts +42 -33
  232. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  233. package/dest/storage/note_store/note_store.js +197 -168
  234. package/dest/storage/note_store/stored_note.d.ts +3 -8
  235. package/dest/storage/note_store/stored_note.d.ts.map +1 -1
  236. package/dest/storage/note_store/stored_note.js +4 -20
  237. package/dest/storage/open_pxe_stores.d.ts +5 -3
  238. package/dest/storage/open_pxe_stores.d.ts.map +1 -1
  239. package/dest/storage/open_pxe_stores.js +5 -3
  240. package/dest/storage/private_event_store/private_event_store.d.ts +13 -16
  241. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  242. package/dest/storage/private_event_store/private_event_store.js +40 -43
  243. package/dest/storage/store_identity.d.ts +35 -0
  244. package/dest/storage/store_identity.d.ts.map +1 -0
  245. package/dest/storage/store_identity.js +44 -0
  246. package/dest/storage/tagging_store/index.d.ts +2 -2
  247. package/dest/storage/tagging_store/index.d.ts.map +1 -1
  248. package/dest/storage/tagging_store/index.js +1 -1
  249. package/dest/storage/tagging_store/sender_tagging_store.d.ts +19 -3
  250. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  251. package/dest/storage/tagging_store/sender_tagging_store.js +48 -11
  252. package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts +51 -0
  253. package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts.map +1 -0
  254. package/dest/storage/tagging_store/tagging_secret_sources_store.js +105 -0
  255. package/dest/tagging/constants.d.ts +3 -2
  256. package/dest/tagging/constants.d.ts.map +1 -1
  257. package/dest/tagging/constants.js +28 -10
  258. package/dest/tagging/index.d.ts +2 -2
  259. package/dest/tagging/index.d.ts.map +1 -1
  260. package/dest/tagging/index.js +1 -1
  261. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +26 -8
  262. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -1
  263. package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +95 -20
  264. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +1 -1
  265. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +1 -1
  266. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  267. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +6 -2
  268. package/dest/tagging/testing/tag_query_test_utils.d.ts +6 -0
  269. package/dest/tagging/testing/tag_query_test_utils.d.ts.map +1 -0
  270. package/dest/tagging/testing/tag_query_test_utils.js +10 -0
  271. package/package.json +17 -17
  272. package/src/bin/check_oracle_version.ts +8 -24
  273. package/src/bin/index.ts +1 -1
  274. package/src/bin/oracle_version_helpers.ts +23 -90
  275. package/src/block_synchronizer/block_stream_source.ts +6 -45
  276. package/src/block_synchronizer/block_synchronizer.ts +70 -29
  277. package/src/config/index.ts +1 -0
  278. package/src/contract/contract_class_service.ts +83 -0
  279. package/src/{contract_sync → contract}/contract_sync_service.ts +37 -50
  280. package/src/contract/helpers.ts +35 -0
  281. package/src/contract/skip_sync_contracts.ts +23 -0
  282. package/src/contract_function_simulator/anchored_contract_data.ts +74 -0
  283. package/src/contract_function_simulator/aztec_node_read_cache.ts +89 -0
  284. package/src/contract_function_simulator/contract_function_simulator.ts +96 -42
  285. package/src/contract_function_simulator/execution_note_cache.ts +7 -28
  286. package/src/contract_function_simulator/index.ts +48 -13
  287. package/src/contract_function_simulator/noir-structs/bounded_vec.ts +12 -24
  288. package/src/contract_function_simulator/noir-structs/contract_class_log_data.ts +9 -0
  289. package/src/contract_function_simulator/noir-structs/embedded_curve_point.ts +4 -0
  290. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
  291. package/src/contract_function_simulator/noir-structs/fact.ts +13 -0
  292. package/src/contract_function_simulator/noir-structs/fact_collection.ts +64 -0
  293. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +20 -46
  294. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +13 -60
  295. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +2 -2
  296. package/src/contract_function_simulator/noir-structs/option.ts +17 -11
  297. package/src/contract_function_simulator/noir-structs/origin_block.ts +8 -0
  298. package/src/contract_function_simulator/noir-structs/pending_tagged_log.ts +12 -0
  299. package/src/contract_function_simulator/noir-structs/provided_secret.ts +4 -26
  300. package/src/contract_function_simulator/noir-structs/resolved_tagging_strategy.ts +66 -0
  301. package/src/contract_function_simulator/noir-structs/resolved_tx.ts +19 -0
  302. package/src/contract_function_simulator/noir-structs/tx_effect_data.ts +16 -0
  303. package/src/contract_function_simulator/noir-structs/utility_context.ts +5 -17
  304. package/src/contract_function_simulator/oracle/acir_callback.ts +154 -0
  305. package/src/contract_function_simulator/oracle/index.ts +1 -15
  306. package/src/contract_function_simulator/oracle/interfaces.ts +1 -2
  307. package/src/contract_function_simulator/oracle/legacy_oracle_registry.ts +147 -0
  308. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +6 -21
  309. package/src/contract_function_simulator/oracle/oracle_registry.ts +172 -47
  310. package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +814 -315
  311. package/src/contract_function_simulator/oracle/private_execution.ts +2 -3
  312. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +167 -30
  313. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +399 -135
  314. package/src/contract_function_simulator/transient_array_service.ts +91 -0
  315. package/src/debug/pxe_debug_utils.ts +1 -1
  316. package/src/entrypoints/client/bundle/index.ts +1 -0
  317. package/src/entrypoints/client/bundle/utils.ts +24 -5
  318. package/src/entrypoints/client/lazy/index.ts +1 -0
  319. package/src/entrypoints/client/lazy/utils.ts +24 -5
  320. package/src/entrypoints/client/store.ts +54 -0
  321. package/src/entrypoints/pxe_creation_options.ts +8 -2
  322. package/src/entrypoints/server/index.ts +6 -2
  323. package/src/entrypoints/server/store.ts +47 -0
  324. package/src/entrypoints/server/utils.ts +31 -9
  325. package/src/error_enriching.ts +27 -11
  326. package/src/hooks/execution_hooks.ts +32 -12
  327. package/src/hooks/index.ts +8 -2
  328. package/src/hooks/resolve_custom_request.ts +24 -0
  329. package/src/hooks/resolve_tagging_secret_strategy.ts +60 -0
  330. package/src/logs/log_service.ts +100 -37
  331. package/src/messages/{message_context_service.ts → tx_resolver_service.ts} +16 -9
  332. package/src/notes/note_service.ts +1 -1
  333. package/src/oracle_version.ts +5 -5
  334. package/src/private_kernel/batch_planner.ts +0 -1
  335. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +11 -1
  336. package/src/private_kernel/hints/test_utils.ts +1 -1
  337. package/src/private_kernel/private_kernel_execution_prover.ts +112 -56
  338. package/src/private_kernel/private_kernel_oracle.ts +23 -4
  339. package/src/pxe.ts +328 -159
  340. package/src/storage/allowed_scopes.ts +14 -0
  341. package/src/storage/anchor_block_store/anchor_block_store.ts +8 -6
  342. package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +6 -6
  343. package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +1 -1
  344. package/src/storage/backwards_compatibility_tests/__snapshots__/FactStore.json +40 -0
  345. package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +12 -12
  346. package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +9 -15
  347. package/src/storage/backwards_compatibility_tests/__snapshots__/NoteStore.json +24 -4
  348. package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +11 -3
  349. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +12 -4
  350. package/src/storage/backwards_compatibility_tests/__snapshots__/TaggingSecretSourcesStore.json +30 -0
  351. package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +29 -9
  352. package/src/storage/backwards_compatibility_tests/schema_tests.ts +141 -50
  353. package/src/storage/capsule_store/capsule_service.ts +8 -13
  354. package/src/storage/contract_store/contract_store.ts +86 -93
  355. package/src/storage/fact_store/fact_service.ts +69 -0
  356. package/src/storage/fact_store/fact_store.ts +487 -0
  357. package/src/storage/fact_store/fact_store_keys.ts +75 -0
  358. package/src/storage/fact_store/index.ts +15 -0
  359. package/src/storage/fact_store/origin_state.ts +84 -0
  360. package/src/storage/fact_store/stored_fact.ts +80 -0
  361. package/src/storage/index.ts +2 -1
  362. package/src/storage/metadata.ts +1 -1
  363. package/src/storage/note_store/note_store.ts +226 -187
  364. package/src/storage/note_store/stored_note.ts +5 -27
  365. package/src/storage/open_pxe_stores.ts +6 -3
  366. package/src/storage/private_event_store/private_event_store.ts +49 -55
  367. package/src/storage/store_identity.ts +72 -0
  368. package/src/storage/tagging_store/index.ts +1 -1
  369. package/src/storage/tagging_store/sender_tagging_store.ts +62 -15
  370. package/src/storage/tagging_store/tagging_secret_sources_store.ts +138 -0
  371. package/src/tagging/constants.ts +30 -10
  372. package/src/tagging/index.ts +1 -1
  373. package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +148 -30
  374. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +1 -1
  375. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +6 -2
  376. package/src/tagging/testing/tag_query_test_utils.ts +11 -0
  377. package/dest/contract_function_simulator/oracle/oracle.d.ts +0 -89
  378. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +0 -1
  379. package/dest/contract_function_simulator/oracle/oracle.js +0 -552
  380. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +0 -6
  381. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +0 -1
  382. package/dest/contract_function_simulator/proxied_contract_data_source.js +0 -51
  383. package/dest/contract_sync/contract_sync_service.d.ts +0 -42
  384. package/dest/contract_sync/contract_sync_service.d.ts.map +0 -1
  385. package/dest/contract_sync/helpers.d.ts +0 -27
  386. package/dest/contract_sync/helpers.d.ts.map +0 -1
  387. package/dest/contract_sync/helpers.js +0 -53
  388. package/dest/messages/message_context_service.d.ts +0 -17
  389. package/dest/messages/message_context_service.d.ts.map +0 -1
  390. package/dest/storage/tagging_store/sender_address_book_store.d.ts +0 -14
  391. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +0 -1
  392. package/dest/storage/tagging_store/sender_address_book_store.js +0 -36
  393. package/src/contract_function_simulator/oracle/oracle.ts +0 -711
  394. package/src/contract_function_simulator/proxied_contract_data_source.ts +0 -60
  395. package/src/contract_sync/helpers.ts +0 -86
  396. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderAddressBookStore.json +0 -16
  397. package/src/storage/tagging_store/sender_address_book_store.ts +0 -48
@@ -3,7 +3,7 @@ import type { BlockNumber } from '@aztec/foundation/branded-types';
3
3
  import { uniqueBy } from '@aztec/foundation/collection';
4
4
  import { Aes128 } from '@aztec/foundation/crypto/aes128';
5
5
  import { Fr } from '@aztec/foundation/curves/bn254';
6
- import type { Point } from '@aztec/foundation/curves/grumpkin';
6
+ import { Point } from '@aztec/foundation/curves/grumpkin';
7
7
  import { LogLevels, type Logger, createLogger } from '@aztec/foundation/log';
8
8
  import { MembershipWitness } from '@aztec/foundation/trees';
9
9
  import type { KeyStore } from '@aztec/key-store';
@@ -15,82 +15,89 @@ import {
15
15
  toACVMWitness,
16
16
  witnessMapToFields,
17
17
  } from '@aztec/simulator/client';
18
+ import { STANDARD_HANDSHAKE_REGISTRY_ADDRESS } from '@aztec/standard-contracts/handshake-registry/constants';
18
19
  import { type FunctionCall, FunctionSelector } from '@aztec/stdlib/abi';
19
20
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
20
21
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
21
22
  import { BlockHash, type L2TipsProvider } from '@aztec/stdlib/block';
22
- import type { CompleteAddress, ContractInstance, PartialAddress } from '@aztec/stdlib/contract';
23
+ import type { CompleteAddress, ContractInstancePreimageWithAddress, PartialAddress } from '@aztec/stdlib/contract';
23
24
  import { siloNullifier } from '@aztec/stdlib/hash';
24
25
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
25
26
  import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
26
27
  import { PublicKeys, computeAddressSecret, hashPublicKey } from '@aztec/stdlib/keys';
27
- import {
28
- AppTaggingSecret,
29
- MessageContext,
30
- type PendingTaggedLog,
31
- deriveAppSiloedSharedSecret,
32
- } from '@aztec/stdlib/logs';
33
- import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
28
+ import { AppTaggingSecret, FlatPublicLogs, appSiloEcdhSharedSecret } from '@aztec/stdlib/logs';
29
+ import { type UnsiloedMessageNullifier, getL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
34
30
  import type { NoteStatus } from '@aztec/stdlib/note';
35
31
  import { MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
36
32
  import {
37
33
  type BlockHeader,
34
+ CallContext,
38
35
  type Capsule,
39
36
  type IndexedTxEffect,
40
37
  type OffchainEffect,
41
- TxEffect,
38
+ type TxEffect,
42
39
  type TxHash,
43
40
  } from '@aztec/stdlib/tx';
44
41
 
42
+ import type { ContractSyncService } from '../../contract/contract_sync_service.js';
45
43
  import { createContractLogger, logContractMessage, stripAztecnrLogPrefix } from '../../contract_logging.js';
46
- import type { ContractSyncService } from '../../contract_sync/contract_sync_service.js';
47
44
  import { EventService } from '../../events/event_service.js';
48
45
  import type { UtilityCallAuthorizationRequest } from '../../hooks/authorize_utility_call.js';
49
46
  import type { ExecutionHooks } from '../../hooks/index.js';
50
47
  import { LogService } from '../../logs/log_service.js';
51
- import { MessageContextService } from '../../messages/message_context_service.js';
48
+ import { TxResolverService } from '../../messages/tx_resolver_service.js';
52
49
  import { NoteService } from '../../notes/note_service.js';
53
50
  import { ORACLE_VERSION_MAJOR } from '../../oracle_version.js';
54
51
  import type { AddressStore } from '../../storage/address_store/address_store.js';
52
+ import { assertAllowedScope } from '../../storage/allowed_scopes.js';
55
53
  import type { CapsuleService } from '../../storage/capsule_store/capsule_service.js';
56
- import type { ContractStore } from '../../storage/contract_store/contract_store.js';
54
+ import { FactCollectionKey, FactCollectionTypeKey, anchoredTipBlockNumbers } from '../../storage/fact_store/index.js';
55
+ import type { FactService, OriginBlock } from '../../storage/fact_store/index.js';
57
56
  import type { NoteStore } from '../../storage/note_store/note_store.js';
58
57
  import type { PrivateEventStore } from '../../storage/private_event_store/private_event_store.js';
59
58
  import type { RecipientTaggingStore } from '../../storage/tagging_store/recipient_tagging_store.js';
60
- import type { SenderAddressBookStore } from '../../storage/tagging_store/sender_address_book_store.js';
59
+ import type { TaggingSecretSourcesStore } from '../../storage/tagging_store/tagging_secret_sources_store.js';
60
+ import type { AnchoredContractData } from '../anchored_contract_data.js';
61
+ import { AztecNodeReadCache } from '../aztec_node_read_cache.js';
61
62
  import { EphemeralArrayService } from '../ephemeral_array_service.js';
62
63
  import { BoundedVec } from '../noir-structs/bounded_vec.js';
64
+ import type { EmbeddedCurvePoint } from '../noir-structs/embedded_curve_point.js';
63
65
  import { EphemeralArray } from '../noir-structs/ephemeral_array.js';
64
66
  import type { EventValidationRequest } from '../noir-structs/event_validation_request.js';
67
+ import { type FactCollection, emptyFactCollection, toNoirFactCollection } from '../noir-structs/fact_collection.js';
65
68
  import type { LogRetrievalRequest } from '../noir-structs/log_retrieval_request.js';
66
69
  import type { LogRetrievalResponse } from '../noir-structs/log_retrieval_response.js';
67
70
  import type { NoteData } from '../noir-structs/note_data.js';
68
71
  import type { NoteValidationRequest } from '../noir-structs/note_validation_request.js';
69
72
  import { Option } from '../noir-structs/option.js';
73
+ import type { PendingTaggedLog } from '../noir-structs/pending_tagged_log.js';
70
74
  import type { ProvidedSecret } from '../noir-structs/provided_secret.js';
71
- import { UtilityContext } from '../noir-structs/utility_context.js';
75
+ import type { ResolvedTx } from '../noir-structs/resolved_tx.js';
76
+ import type { TxEffectData } from '../noir-structs/tx_effect_data.js';
77
+ import type { UtilityContext } from '../noir-structs/utility_context.js';
72
78
  import { pickNotes } from '../pick_notes.js';
79
+ import type { TransientArrayService } from '../transient_array_service.js';
80
+ import { buildACIRCallback } from './acir_callback.js';
73
81
  import type { IMiscOracle, IUtilityExecutionOracle } from './interfaces.js';
74
- import { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
75
- import { Oracle } from './oracle.js';
76
82
 
77
83
  /** Args for UtilityExecutionOracle constructor. */
78
84
  export type UtilityExecutionOracleArgs = {
79
- contractAddress: AztecAddress;
85
+ callContext: CallContext;
80
86
  /** List of transient auth witnesses to be used during this simulation */
81
87
  authWitnesses: AuthWitness[];
82
88
  capsules: Capsule[]; // TODO(#12425): Rename to transientCapsules
83
89
  anchorBlockHeader: BlockHeader;
84
- contractStore: ContractStore;
90
+ anchoredContractData: AnchoredContractData;
85
91
  noteStore: NoteStore;
86
92
  keyStore: KeyStore;
87
93
  addressStore: AddressStore;
88
94
  aztecNode: AztecNode;
89
95
  recipientTaggingStore: RecipientTaggingStore;
90
- senderAddressBookStore: SenderAddressBookStore;
96
+ taggingSecretSourcesStore: TaggingSecretSourcesStore;
91
97
  capsuleService: CapsuleService;
98
+ factService: FactService;
92
99
  privateEventStore: PrivateEventStore;
93
- messageContextService: MessageContextService;
100
+ txResolver: TxResolverService;
94
101
  contractSyncService: ContractSyncService;
95
102
  l2TipsStore: L2TipsProvider;
96
103
  jobId: string;
@@ -100,6 +107,7 @@ export type UtilityExecutionOracleArgs = {
100
107
  hooks?: ExecutionHooks;
101
108
  /** Needed to trigger contract synchronization before nested cross-contract calls. */
102
109
  utilityExecutor: (call: FunctionCall, scopes: AztecAddress[]) => Promise<void>;
110
+ transientArrayService: TransientArrayService;
103
111
  };
104
112
 
105
113
  /**
@@ -113,24 +121,27 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
113
121
  private aztecnrLogger: Logger | undefined;
114
122
  private offchainEffects: OffchainEffect[] = [];
115
123
  private readonly ephemeralArrayService = new EphemeralArrayService();
124
+ protected readonly transientArrayService: TransientArrayService;
125
+ private readonly aztecNodeReadCache: AztecNodeReadCache;
116
126
 
117
127
  // We store oracle version to be able to show a nice error message when an oracle handler is missing.
118
128
  private contractOracleVersion: { major: number; minor: number } | undefined;
119
129
 
120
- protected readonly contractAddress: AztecAddress;
130
+ protected readonly callContext: CallContext;
121
131
  protected readonly authWitnesses: AuthWitness[];
122
132
  protected readonly capsules: Capsule[];
123
133
  protected readonly anchorBlockHeader: BlockHeader;
124
- protected readonly contractStore: ContractStore;
134
+ protected readonly anchoredContractData: AnchoredContractData;
125
135
  protected readonly noteStore: NoteStore;
126
136
  protected readonly keyStore: KeyStore;
127
137
  protected readonly addressStore: AddressStore;
128
138
  protected readonly aztecNode: AztecNode;
129
139
  protected readonly recipientTaggingStore: RecipientTaggingStore;
130
- protected readonly senderAddressBookStore: SenderAddressBookStore;
140
+ protected readonly taggingSecretSourcesStore: TaggingSecretSourcesStore;
131
141
  protected readonly capsuleService: CapsuleService;
142
+ protected readonly factService: FactService;
132
143
  protected readonly privateEventStore: PrivateEventStore;
133
- protected readonly messageContextService: MessageContextService;
144
+ protected readonly txResolver: TxResolverService;
134
145
  protected readonly contractSyncService: ContractSyncService;
135
146
  protected readonly l2TipsStore: L2TipsProvider;
136
147
  protected readonly jobId: string;
@@ -141,20 +152,21 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
141
152
  protected readonly utilityExecutor: (call: FunctionCall, scopes: AztecAddress[]) => Promise<void>;
142
153
 
143
154
  constructor(args: UtilityExecutionOracleArgs) {
144
- this.contractAddress = args.contractAddress;
155
+ this.callContext = args.callContext;
145
156
  this.authWitnesses = args.authWitnesses;
146
157
  this.capsules = args.capsules;
147
158
  this.anchorBlockHeader = args.anchorBlockHeader;
148
- this.contractStore = args.contractStore;
159
+ this.anchoredContractData = args.anchoredContractData;
149
160
  this.noteStore = args.noteStore;
150
161
  this.keyStore = args.keyStore;
151
162
  this.addressStore = args.addressStore;
152
163
  this.aztecNode = args.aztecNode;
153
164
  this.recipientTaggingStore = args.recipientTaggingStore;
154
- this.senderAddressBookStore = args.senderAddressBookStore;
165
+ this.taggingSecretSourcesStore = args.taggingSecretSourcesStore;
155
166
  this.capsuleService = args.capsuleService;
167
+ this.factService = args.factService;
156
168
  this.privateEventStore = args.privateEventStore;
157
- this.messageContextService = args.messageContextService;
169
+ this.txResolver = args.txResolver;
158
170
  this.contractSyncService = args.contractSyncService;
159
171
  this.l2TipsStore = args.l2TipsStore;
160
172
  this.jobId = args.jobId;
@@ -163,6 +175,8 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
163
175
  this.simulator = args.simulator;
164
176
  this.hooks = args.hooks;
165
177
  this.utilityExecutor = args.utilityExecutor;
178
+ this.transientArrayService = args.transientArrayService;
179
+ this.aztecNodeReadCache = new AztecNodeReadCache(args.aztecNode);
166
180
  }
167
181
 
168
182
  public assertCompatibleOracleVersion(major: number, minor: number): void {
@@ -189,17 +203,22 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
189
203
  }
190
204
 
191
205
  public getUtilityContext(): UtilityContext {
192
- return new UtilityContext(this.anchorBlockHeader, this.contractAddress);
206
+ return {
207
+ blockHeader: this.anchorBlockHeader,
208
+ contractAddress: this.callContext.contractAddress,
209
+ msgSender: this.callContext.msgSender,
210
+ };
193
211
  }
194
212
 
195
213
  /**
196
214
  * Retrieve keys associated with a specific master public key and app address.
197
215
  * @param pkMHash - The master public key hash.
216
+ * @param _keyIndex - Sent by the Noir oracle caller but unused here; kept to match the oracle signature.
198
217
  * @returns A Promise that resolves to nullifier keys.
199
218
  * @throws If the keys are not registered in the key store.
200
219
  * @throws If scopes are defined and the account is not in the scopes.
201
220
  */
202
- public async getKeyValidationRequest(pkMHash: Fr): Promise<KeyValidationRequest> {
221
+ public async getKeyValidationRequest(pkMHash: Fr, _keyIndex: Fr): Promise<KeyValidationRequest> {
203
222
  let hasAccess = false;
204
223
  for (let i = 0; i < this.scopes.length && !hasAccess; i++) {
205
224
  if (await this.keyStore.accountHasKey(this.scopes[i], pkMHash)) {
@@ -251,9 +270,25 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
251
270
  // hash at all. If the block hash did not exist by the reference block hash, then the node will not return the
252
271
  // membership witness as there is none.
253
272
  const witness = await this.#queryWithBlockHashNotAfterAnchor(referenceBlockHash, () =>
254
- this.aztecNode.getBlockHashMembershipWitness(referenceBlockHash, blockHash),
273
+ this.aztecNodeReadCache.getBlockHashMembershipWitness(referenceBlockHash, blockHash),
255
274
  );
256
- return witness ? Option.some(witness) : Option.none(MembershipWitness.empty(ARCHIVE_HEIGHT));
275
+ return witness ? Option.some(witness) : Option.none();
276
+ }
277
+
278
+ /** Returns whether each block hash is present in the archive tree at the referenced block. */
279
+ public async areBlockHashesInArchive(
280
+ referenceBlockHash: BlockHash,
281
+ blockHashes: EphemeralArray<BlockHash>,
282
+ ): Promise<EphemeralArray<boolean>> {
283
+ const hashes = blockHashes.readAll(this.ephemeralArrayService);
284
+ const memberships = await this.#queryWithBlockHashNotAfterAnchor(referenceBlockHash, () =>
285
+ Promise.all(
286
+ hashes.map(blockHash =>
287
+ this.aztecNodeReadCache.getBlockHashMembershipWitness(referenceBlockHash, blockHash).then(Boolean),
288
+ ),
289
+ ),
290
+ );
291
+ return EphemeralArray.fromValues(this.ephemeralArrayService, memberships);
257
292
  }
258
293
 
259
294
  /**
@@ -304,7 +339,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
304
339
  */
305
340
  public async getPublicDataWitness(blockHash: BlockHash, leafSlot: Fr): Promise<PublicDataWitness> {
306
341
  const witness = await this.#queryWithBlockHashNotAfterAnchor(blockHash, () =>
307
- this.aztecNode.getPublicDataWitness(blockHash, leafSlot),
342
+ this.aztecNodeReadCache.getPublicDataWitness(blockHash, leafSlot),
308
343
  );
309
344
  if (!witness) {
310
345
  throw new Error(`Public data witness not found for slot ${leafSlot} at block hash ${blockHash.toString()}.`);
@@ -345,7 +380,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
345
380
  ): Promise<Option<{ publicKeys: PublicKeys; partialAddress: PartialAddress }>> {
346
381
  const completeAddress = await this.addressStore.getCompleteAddress(account);
347
382
  if (!completeAddress) {
348
- return Option.none({ publicKeys: PublicKeys.default(), partialAddress: Fr.ZERO });
383
+ return Option.none();
349
384
  }
350
385
  return Option.some({ publicKeys: completeAddress.publicKeys, partialAddress: completeAddress.partialAddress });
351
386
  }
@@ -355,7 +390,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
355
390
  if (!completeAddress) {
356
391
  throw new Error(
357
392
  `No public key registered for address ${account}.
358
- Register it by calling pxe.addAccount(...).\nSee docs for context: https://docs.aztec.network/developers/resources/debugging/aztecnr-errors#simulation-error-no-public-key-registered-for-address-0x0-register-it-by-calling-pxeregisterrecipient-or-pxeregisteraccount`,
393
+ Register it by calling wallet.registerSender(...).\nSee docs for context: https://docs.aztec.network/errors/14`,
359
394
  );
360
395
  }
361
396
  return completeAddress;
@@ -366,8 +401,8 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
366
401
  * @param address - Address.
367
402
  * @returns A contract instance.
368
403
  */
369
- public async getContractInstance(address: AztecAddress): Promise<ContractInstance> {
370
- const instance = await this.contractStore.getContractInstance(address);
404
+ public async getContractInstance(address: AztecAddress): Promise<ContractInstancePreimageWithAddress> {
405
+ const instance = await this.anchoredContractData.getContractInstance(address);
371
406
  if (!instance) {
372
407
  throw new Error(`No contract instance found for address ${address.toString()}`);
373
408
  }
@@ -464,23 +499,21 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
464
499
  }
465
500
 
466
501
  /**
467
- * Returns the membership witness of an un-nullified L1 to L2 message.
468
- * @param contractAddress - Address of a contract by which the message was emitted.
502
+ * Returns the membership witness of an L1 to L2 message.
469
503
  * @param messageHash - Hash of the message.
470
- * @param secret - Secret used to compute a nullifier.
471
- * @dev Contract address and secret are only used to compute the nullifier to get non-nullified messages
504
+ * @param nullifier - When present, the unsiloed nullifier of the message and the address to silo it with. The witness
505
+ * is only returned if the siloed nullifier is absent from the nullifier tree, i.e. the message has not been consumed.
472
506
  * @returns The l1 to l2 membership witness (index of message in the tree and sibling path).
473
507
  */
474
- public async getL1ToL2MembershipWitness(contractAddress: AztecAddress, messageHash: Fr, secret: Fr) {
475
- const [messageIndex, siblingPath] = await getNonNullifiedL1ToL2MessageWitness(
508
+ public async getL1ToL2MembershipWitnessV2(messageHash: Fr, nullifier: Option<UnsiloedMessageNullifier>) {
509
+ const [messageIndex, siblingPath] = await getL1ToL2MessageWitness(
476
510
  this.aztecNode,
477
- contractAddress,
478
511
  messageHash,
479
- secret,
512
+ nullifier.value,
480
513
  await this.anchorBlockHeader.hash(),
481
514
  );
482
515
 
483
- return new MessageLoadOracleInputs(messageIndex, siblingPath);
516
+ return { index: messageIndex, siblingPath };
484
517
  }
485
518
 
486
519
  /**
@@ -497,16 +530,16 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
497
530
  numberOfElements: number,
498
531
  ) {
499
532
  return this.#queryWithBlockHashNotAfterAnchor(blockHash, async () => {
500
- const slots = Array(numberOfElements)
501
- .fill(0)
502
- .map((_, i) => new Fr(startStorageSlot.value + BigInt(i)));
503
-
504
- const values = await Promise.all(
505
- slots.map(storageSlot => this.aztecNode.getPublicStorageAt(blockHash, contractAddress, storageSlot)),
533
+ const values = await this.aztecNodeReadCache.getPublicStorageRange(
534
+ blockHash,
535
+ contractAddress,
536
+ startStorageSlot,
537
+ numberOfElements,
506
538
  );
507
539
 
508
540
  this.logger.debug(
509
- `Oracle storage read: slots=[${slots.map(slot => slot.toString()).join(', ')}] address=${contractAddress.toString()} values=[${values.join(', ')}]`,
541
+ `Oracle storage read: start=${startStorageSlot.toString()} count=${numberOfElements} ` +
542
+ `address=${contractAddress.toString()} values=[${values.join(', ')}]`,
510
543
  );
511
544
 
512
545
  return values;
@@ -522,7 +555,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
522
555
  // to re-use jobId as instanceId here as executions of different PXE jobs are isolated.
523
556
  this.contractLogger = await createContractLogger(
524
557
  this.contractAddress,
525
- addr => this.contractStore.getDebugContractName(addr),
558
+ addr => this.anchoredContractData.getDebugContractName(addr),
526
559
  'user',
527
560
  { instanceId: this.jobId },
528
561
  );
@@ -539,7 +572,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
539
572
  // to re-use jobId as instanceId here as executions of different PXE jobs are isolated.
540
573
  this.aztecnrLogger = await createContractLogger(
541
574
  this.contractAddress,
542
- addr => this.contractStore.getDebugContractName(addr),
575
+ addr => this.anchoredContractData.getDebugContractName(addr),
543
576
  'aztecnr',
544
577
  { instanceId: this.jobId },
545
578
  );
@@ -559,7 +592,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
559
592
  }
560
593
 
561
594
  /** Fetches pending tagged logs into a freshly allocated ephemeral array and returns it. */
562
- public async getPendingTaggedLogs(
595
+ public async getPendingTaggedLogsV2(
563
596
  scope: AztecAddress,
564
597
  providedSecrets: EphemeralArray<ProvidedSecret>,
565
598
  ): Promise<EphemeralArray<PendingTaggedLog>> {
@@ -579,8 +612,9 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
579
612
  this.l2TipsStore,
580
613
  this.keyStore,
581
614
  this.recipientTaggingStore,
582
- this.senderAddressBookStore,
615
+ this.taggingSecretSourcesStore,
583
616
  this.addressStore,
617
+ this.scopes,
584
618
  this.jobId,
585
619
  this.logger.getBindings(),
586
620
  );
@@ -617,7 +651,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
617
651
  ]);
618
652
  }
619
653
 
620
- public async getLogsByTag(
654
+ public async getLogsByTagV2(
621
655
  requests: EphemeralArray<LogRetrievalRequest>,
622
656
  ): Promise<EphemeralArray<EphemeralArray<LogRetrievalResponse>>> {
623
657
  const logRetrievalRequests = requests.readAll(this.ephemeralArrayService);
@@ -633,20 +667,13 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
633
667
  return EphemeralArray.fromValues(this.ephemeralArrayService, innerArrays);
634
668
  }
635
669
 
636
- /** Reads tx hash requests from an ephemeral array, resolves their contexts, and returns the response array. */
637
- public async getMessageContextsByTxHash(
638
- requests: EphemeralArray<Fr>,
639
- ): Promise<EphemeralArray<Option<MessageContext>>> {
670
+ /** Given an array of tx hashes, returns an aligned array of tx info if the tx is available. */
671
+ public async getResolvedTxs(requests: EphemeralArray<Fr>): Promise<EphemeralArray<Option<ResolvedTx>>> {
640
672
  const txHashes = requests.readAll(this.ephemeralArrayService);
641
673
 
642
- const maybeMessageContexts = await this.messageContextService.getMessageContextsByTxHash(
643
- txHashes,
644
- this.anchorBlockHeader.getBlockNumber(),
645
- );
674
+ const resolved = await this.txResolver.resolveTxs(txHashes, this.anchorBlockHeader.getBlockNumber());
646
675
 
647
- const options = maybeMessageContexts.map(mc =>
648
- mc ? Option.some(mc) : Option.none<MessageContext>(MessageContext.empty()),
649
- );
676
+ const options = resolved.map(r => (r ? Option.some(r) : Option.none<ResolvedTx>()));
650
677
  return EphemeralArray.fromValues(this.ephemeralArrayService, options);
651
678
  }
652
679
 
@@ -654,24 +681,34 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
654
681
  * Fetches the effects of a transaction by its hash. Returns null if the tx is not found or is beyond the anchor
655
682
  * block.
656
683
  */
657
- public async getTxEffect(txHash: TxHash): Promise<Option<TxEffect>> {
684
+ public async getTxEffect(txHash: TxHash): Promise<Option<TxEffectData>> {
658
685
  if (txHash.hash.isZero()) {
659
686
  throw new Error('Invalid tx hash passed into aztec_utl_getTxEffect oracle handler');
660
687
  }
661
688
 
662
- const receipt = await this.aztecNode.getTxReceipt(txHash, { includeTxEffect: true });
663
- if (!receipt.isMined() || !receipt.txEffect || receipt.blockNumber > this.anchorBlockHeader.getBlockNumber()) {
664
- return Option.none(TxEffect.empty());
689
+ return await this.#getTxEffectOption(txHash);
690
+ }
691
+
692
+ /** Fetches transaction effects for all hashes, preserving request order. */
693
+ public async getTxEffects(txHashes: EphemeralArray<TxHash>): Promise<EphemeralArray<Option<TxEffectData>>> {
694
+ const hashes = txHashes.readAll(this.ephemeralArrayService);
695
+ const invalidHash = hashes.find(txHash => txHash.hash.isZero());
696
+ if (invalidHash) {
697
+ throw new Error('Invalid tx hash passed into aztec_utl_getTxEffects oracle handler');
665
698
  }
666
699
 
667
- return Option.some(receipt.txEffect);
700
+ const uniqueTxHashes = uniqueBy(hashes, h => h.toString());
701
+ const options = await Promise.all(uniqueTxHashes.map(txHash => this.#getTxEffectOption(txHash)));
702
+ const optionsByHash = new Map(uniqueTxHashes.map((txHash, i) => [txHash.toString(), options[i]]));
703
+
704
+ return EphemeralArray.fromValues(
705
+ this.ephemeralArrayService,
706
+ hashes.map(txHash => optionsByHash.get(txHash.toString())!),
707
+ );
668
708
  }
669
709
 
670
710
  public setCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[], scope: AztecAddress): void {
671
- if (!contractAddress.equals(this.contractAddress)) {
672
- // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
673
- throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
674
- }
711
+ this.#assertOwnContract(contractAddress);
675
712
  this.capsuleService.setCapsule(contractAddress, slot, capsule, this.jobId, scope);
676
713
  }
677
714
 
@@ -681,19 +718,13 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
681
718
  tSize: number,
682
719
  scope: AztecAddress,
683
720
  ): Promise<Option<Fr[]>> {
684
- if (!contractAddress.equals(this.contractAddress)) {
685
- // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
686
- throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
687
- }
721
+ this.#assertOwnContract(contractAddress);
688
722
  const values = await this.capsuleService.getCapsule(contractAddress, slot, this.jobId, scope, this.capsules);
689
- return values ? Option.some(values) : Option.none(new Array(tSize).fill(Fr.ZERO));
723
+ return values ? Option.some(values) : Option.none({ length: tSize });
690
724
  }
691
725
 
692
726
  public deleteCapsule(contractAddress: AztecAddress, slot: Fr, scope: AztecAddress): void {
693
- if (!contractAddress.equals(this.contractAddress)) {
694
- // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
695
- throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
696
- }
727
+ this.#assertOwnContract(contractAddress);
697
728
  this.capsuleService.deleteCapsule(contractAddress, slot, this.jobId, scope);
698
729
  }
699
730
 
@@ -704,11 +735,114 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
704
735
  numEntries: number,
705
736
  scope: AztecAddress,
706
737
  ): Promise<void> {
738
+ this.#assertOwnContract(contractAddress);
739
+ return this.capsuleService.copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, this.jobId, scope);
740
+ }
741
+
742
+ /**
743
+ * Asserts the executing contract may only access its own slice of PXE DB.
744
+ */
745
+ #assertOwnContract(contractAddress: AztecAddress): void {
707
746
  if (!contractAddress.equals(this.contractAddress)) {
708
- // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
709
747
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
710
748
  }
711
- return this.capsuleService.copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, this.jobId, scope);
749
+ }
750
+
751
+ /**
752
+ * Records a fact into a collection. A `Some` origin block makes the fact retractable (pruned on reorg of that
753
+ * block), a `None` origin block makes it non-retractable, surviving reorgs.
754
+ */
755
+ public recordFact(
756
+ contractAddress: AztecAddress,
757
+ scope: AztecAddress,
758
+ factCollectionTypeId: Fr,
759
+ factCollectionId: Fr,
760
+ factTypeId: Fr,
761
+ payload: EphemeralArray<Fr>,
762
+ originBlock: Option<OriginBlock>,
763
+ ): Promise<void> {
764
+ this.#assertOwnContract(contractAddress);
765
+ return this.factService.recordFact(
766
+ new FactCollectionKey(contractAddress, scope, factCollectionTypeId, factCollectionId),
767
+ factTypeId,
768
+ payload.readAll(this.ephemeralArrayService),
769
+ originBlock.isSome() ? originBlock.value : undefined,
770
+ this.jobId,
771
+ );
772
+ }
773
+
774
+ /**
775
+ * Deletes a fact collection, removing all its facts. A no-op if no such collection exists.
776
+ */
777
+ public deleteFactCollection(
778
+ contractAddress: AztecAddress,
779
+ scope: AztecAddress,
780
+ factCollectionTypeId: Fr,
781
+ factCollectionId: Fr,
782
+ ): Promise<void> {
783
+ this.#assertOwnContract(contractAddress);
784
+ return this.factService.deleteFactCollection(
785
+ new FactCollectionKey(contractAddress, scope, factCollectionTypeId, factCollectionId),
786
+ this.jobId,
787
+ );
788
+ }
789
+
790
+ /**
791
+ * Returns a fact collection.
792
+ */
793
+ public async getFactCollection(
794
+ contractAddress: AztecAddress,
795
+ scope: AztecAddress,
796
+ factCollectionTypeId: Fr,
797
+ factCollectionId: Fr,
798
+ ): Promise<Option<FactCollection>> {
799
+ this.#assertOwnContract(contractAddress);
800
+ const tips = anchoredTipBlockNumbers(await this.l2TipsStore.getL2Tips(), this.anchorBlockHeader.getBlockNumber());
801
+ const collection = await this.factService.getFactCollection(
802
+ new FactCollectionKey(contractAddress, scope, factCollectionTypeId, factCollectionId),
803
+ tips,
804
+ this.jobId,
805
+ );
806
+ return collection
807
+ ? Option.some(
808
+ toNoirFactCollection(
809
+ this.ephemeralArrayService,
810
+ contractAddress,
811
+ scope,
812
+ factCollectionTypeId,
813
+ factCollectionId,
814
+ collection.facts,
815
+ ),
816
+ )
817
+ : Option.none(emptyFactCollection(this.ephemeralArrayService));
818
+ }
819
+
820
+ /** Returns every fact collection of `factCollectionTypeId`. */
821
+ public async getFactCollectionsByType(
822
+ contractAddress: AztecAddress,
823
+ scope: AztecAddress,
824
+ factCollectionTypeId: Fr,
825
+ ): Promise<EphemeralArray<FactCollection>> {
826
+ this.#assertOwnContract(contractAddress);
827
+ const tips = anchoredTipBlockNumbers(await this.l2TipsStore.getL2Tips(), this.anchorBlockHeader.getBlockNumber());
828
+ const collections = await this.factService.getFactCollectionsByType(
829
+ new FactCollectionTypeKey(contractAddress, scope, factCollectionTypeId),
830
+ tips,
831
+ this.jobId,
832
+ );
833
+ return EphemeralArray.fromValues(
834
+ this.ephemeralArrayService,
835
+ collections.map(collection =>
836
+ toNoirFactCollection(
837
+ this.ephemeralArrayService,
838
+ collection.key.contractAddress,
839
+ collection.key.scope,
840
+ collection.key.factCollectionTypeId,
841
+ collection.key.factCollectionId,
842
+ collection.facts,
843
+ ),
844
+ ),
845
+ );
712
846
  }
713
847
 
714
848
  /**
@@ -725,16 +859,20 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
725
859
  // TODO(#11849): consider replacing this oracle with a pure Noir implementation of aes decryption.
726
860
  public async decryptAes128(
727
861
  ciphertext: BoundedVec<number>,
728
- iv: Buffer,
729
- symKey: Buffer,
862
+ iv: number[],
863
+ symKey: number[],
730
864
  ): Promise<Option<BoundedVec<number>>> {
731
865
  const capacity = ciphertext.maxLength;
732
866
  try {
733
867
  const aes128 = new Aes128();
734
- const plaintext = await aes128.decryptBufferCBC(Buffer.from(ciphertext.data), iv, symKey);
868
+ const plaintext = await aes128.decryptBufferCBC(
869
+ Buffer.from(ciphertext.data),
870
+ Buffer.from(iv),
871
+ Buffer.from(symKey),
872
+ );
735
873
  return Option.some(BoundedVec.from<number>({ data: [...plaintext], maxLength: capacity }));
736
874
  } catch {
737
- return Option.none(BoundedVec.empty<number>({ maxLength: capacity }));
875
+ return Option.none({ maxLength: capacity });
738
876
  }
739
877
  }
740
878
 
@@ -743,11 +881,13 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
743
881
  * @param address - The recipient address.
744
882
  * @param ephPks - Ephemeral array containing the serialized Points.
745
883
  * @param contractAddress - The contract address for app-siloing (validated against execution context).
746
- * @returns A new ephemeral array containing the computed shared secrets.
884
+ * @returns A new ephemeral array containing the computed shared secrets, or an empty array when the PXE does not
885
+ * hold the keys for `address`.
886
+ * @throws If `address` is not in the execution's allowed scopes.
747
887
  */
748
888
  public async getSharedSecrets(
749
889
  address: AztecAddress,
750
- ephPks: EphemeralArray<Point>,
890
+ ephPks: EphemeralArray<EmbeddedCurvePoint>,
751
891
  contractAddress: AztecAddress,
752
892
  ): Promise<EphemeralArray<Fr>> {
753
893
  if (!contractAddress.equals(this.contractAddress)) {
@@ -755,14 +895,29 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
755
895
  `getSharedSecrets called with contract address ${contractAddress}, expected ${this.contractAddress}`,
756
896
  );
757
897
  }
758
- const recipientCompleteAddress = await this.getCompleteAddressOrFail(address);
898
+
899
+ assertAllowedScope(address, this.scopes);
900
+
901
+ // An address can be in scope without the PXE holding its keys (e.g. syncing a registered but non-owned account),
902
+ // in which case no secrets can be derived and we return an empty array rather than failing.
903
+ const recipientCompleteAddress = await this.addressStore.getCompleteAddress(address);
904
+ if (!recipientCompleteAddress) {
905
+ this.logger.warn(
906
+ `Computing shared secrets for address ${address} whose keys are not held - returning no secrets`,
907
+ {
908
+ address,
909
+ contractAddress: this.contractAddress,
910
+ },
911
+ );
912
+ return EphemeralArray.fromValues<Fr>(this.ephemeralArrayService, []);
913
+ }
759
914
  const ivpkMHash = await hashPublicKey(recipientCompleteAddress.publicKeys.ivpkM);
760
915
  const ivskM = await this.keyStore.getMasterSecretKey(ivpkMHash);
761
916
  const addressSecret = await computeAddressSecret(await recipientCompleteAddress.getPreaddress(), ivskM);
762
917
 
763
918
  const ephPkPoints = ephPks.readAll(this.ephemeralArrayService);
764
919
  const secrets = await Promise.all(
765
- ephPkPoints.map(ephPk => deriveAppSiloedSharedSecret(addressSecret, ephPk, this.contractAddress)),
920
+ ephPkPoints.map(({ x, y }) => appSiloEcdhSharedSecret(addressSecret, new Point(x, y), this.contractAddress)),
766
921
  );
767
922
 
768
923
  return EphemeralArray.fromValues(this.ephemeralArrayService, secrets);
@@ -796,6 +951,34 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
796
951
  this.ephemeralArrayService.clear(slot);
797
952
  }
798
953
 
954
+ public pushTransient(slot: Fr, elements: Fr[]): number {
955
+ return this.transientArrayService.push(this.contractAddress, slot, elements);
956
+ }
957
+
958
+ public popTransient(slot: Fr): Fr[] {
959
+ return this.transientArrayService.pop(this.contractAddress, slot);
960
+ }
961
+
962
+ public getTransient(slot: Fr, index: number): Fr[] {
963
+ return this.transientArrayService.get(this.contractAddress, slot, index);
964
+ }
965
+
966
+ public setTransient(slot: Fr, index: number, elements: Fr[]): void {
967
+ this.transientArrayService.set(this.contractAddress, slot, index, elements);
968
+ }
969
+
970
+ public getTransientLen(slot: Fr): number {
971
+ return this.transientArrayService.len(this.contractAddress, slot);
972
+ }
973
+
974
+ public removeTransient(slot: Fr, index: number): void {
975
+ this.transientArrayService.remove(this.contractAddress, slot, index);
976
+ }
977
+
978
+ public clearTransient(slot: Fr): void {
979
+ this.transientArrayService.clear(this.contractAddress, slot);
980
+ }
981
+
799
982
  public emitOffchainEffect(data: Fr[]): Promise<void> {
800
983
  this.offchainEffects.push({ data, contractAddress: this.contractAddress });
801
984
  return Promise.resolve();
@@ -807,38 +990,53 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
807
990
  functionSelector: FunctionSelector,
808
991
  args: Fr[],
809
992
  ): Promise<Fr[]> {
810
- const targetArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(
993
+ const targetArtifact = await this.anchoredContractData.getFunctionArtifactWithDebugMetadata(
811
994
  targetContractAddress,
812
995
  functionSelector,
813
996
  );
997
+ if (!targetArtifact) {
998
+ throw new Error(
999
+ `Cannot call ${targetContractAddress}:${functionSelector}: the contract is not registered. ` +
1000
+ `Register it via wallet.registerContract(...).`,
1001
+ );
1002
+ }
814
1003
 
815
1004
  if (!targetContractAddress.equals(this.contractAddress)) {
816
- const [callerInstance, targetInstance] = await Promise.all([
817
- this.getContractInstance(this.contractAddress),
818
- this.getContractInstance(targetContractAddress),
819
- ]);
820
- const request: UtilityCallAuthorizationRequest = {
821
- caller: this.contractAddress,
822
- callerClassId: callerInstance.currentContractClassId,
823
- target: targetContractAddress,
824
- targetClassId: targetInstance.currentContractClassId,
825
- functionSelector,
826
- functionName: targetArtifact.name,
827
- args,
828
- callerContext: this.callerContext,
829
- };
830
-
831
- const response = this.hooks
832
- ? await this.hooks.authorizeUtilityCall(request)
833
- : { authorized: false, reason: 'No execution hooks configured' };
834
-
835
- if (!response.authorized) {
836
- const reason = response.reason ? `: ${response.reason}` : '';
837
- throw new Error(
838
- `Cross-contract utility call denied${reason}. ${this.contractAddress} attempted to call ` +
839
- `${targetContractAddress}:${functionSelector} (${targetArtifact.name}). ` +
840
- `See https://docs.aztec.network/errors/11`,
841
- );
1005
+ // Standard handshake registry reads are authorized by default; every other cross-contract call needs the hook.
1006
+ if (!(await isStandardHandshakeRegistryUtilityRead(targetContractAddress, functionSelector))) {
1007
+ const [callerClassId, targetClassId] = await Promise.all([
1008
+ this.anchoredContractData.getCurrentClassId(this.contractAddress),
1009
+ this.anchoredContractData.getCurrentClassId(targetContractAddress),
1010
+ ]);
1011
+ if (!callerClassId || !targetClassId) {
1012
+ throw new Error(
1013
+ `Cannot authorize utility call from ${this.contractAddress} to ${targetContractAddress}: ` +
1014
+ `${!callerClassId ? this.contractAddress : targetContractAddress} is not registered.`,
1015
+ );
1016
+ }
1017
+ const request: UtilityCallAuthorizationRequest = {
1018
+ caller: this.contractAddress,
1019
+ callerClassId,
1020
+ target: targetContractAddress,
1021
+ targetClassId,
1022
+ functionSelector,
1023
+ functionName: targetArtifact.name,
1024
+ args,
1025
+ callerContext: this.callerContext,
1026
+ };
1027
+
1028
+ const response = this.hooks?.authorizeUtilityCall
1029
+ ? await this.hooks.authorizeUtilityCall(request)
1030
+ : { authorized: false, reason: 'No authorizeUtilityCall hook configured' };
1031
+
1032
+ if (!response.authorized) {
1033
+ const reason = response.reason ? `: ${response.reason}` : '';
1034
+ throw new Error(
1035
+ `Cross-contract utility call denied${reason}. ${this.contractAddress} attempted to call ` +
1036
+ `${targetContractAddress}:${functionSelector} (${targetArtifact.name}). ` +
1037
+ `See https://docs.aztec.network/errors/11`,
1038
+ );
1039
+ }
842
1040
  }
843
1041
 
844
1042
  await this.contractSyncService.ensureContractSynced(
@@ -856,20 +1054,26 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
856
1054
  );
857
1055
 
858
1056
  const nestedOracle = new UtilityExecutionOracle({
859
- contractAddress: targetContractAddress,
1057
+ callContext: CallContext.from({
1058
+ msgSender: this.contractAddress,
1059
+ contractAddress: targetContractAddress,
1060
+ functionSelector,
1061
+ isStaticCall: true,
1062
+ }),
860
1063
  authWitnesses: this.authWitnesses,
861
1064
  capsules: this.capsules,
862
1065
  anchorBlockHeader: this.anchorBlockHeader,
863
- contractStore: this.contractStore,
1066
+ anchoredContractData: this.anchoredContractData,
864
1067
  noteStore: this.noteStore,
865
1068
  keyStore: this.keyStore,
866
1069
  addressStore: this.addressStore,
867
1070
  aztecNode: this.aztecNode,
868
1071
  recipientTaggingStore: this.recipientTaggingStore,
869
- senderAddressBookStore: this.senderAddressBookStore,
1072
+ taggingSecretSourcesStore: this.taggingSecretSourcesStore,
870
1073
  capsuleService: this.capsuleService,
1074
+ factService: this.factService,
871
1075
  privateEventStore: this.privateEventStore,
872
- messageContextService: this.messageContextService,
1076
+ txResolver: this.txResolver,
873
1077
  contractSyncService: this.contractSyncService,
874
1078
  l2TipsStore: this.l2TipsStore,
875
1079
  jobId: this.jobId,
@@ -878,12 +1082,13 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
878
1082
  hooks: this.hooks,
879
1083
  utilityExecutor: this.utilityExecutor,
880
1084
  log: this.logger,
1085
+ // Shared across the whole execution tree: nested utility frames inherit the caller's transient-array store.
1086
+ transientArrayService: this.transientArrayService,
881
1087
  });
882
1088
 
883
1089
  const initialWitness = toACVMWitness(0, args);
884
- const acvmCallback = new Oracle(nestedOracle);
885
1090
  const acirExecutionResult = await this.simulator
886
- .executeUserCircuit(initialWitness, targetArtifact, acvmCallback.toACIRCallback())
1091
+ .executeUserCircuit(initialWitness, targetArtifact, buildACIRCallback(nestedOracle))
887
1092
  .catch((err: Error) => {
888
1093
  err.message = resolveAssertionMessageFromError(err, targetArtifact);
889
1094
  throw new ExecutionError(
@@ -908,9 +1113,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
908
1113
  */
909
1114
  async #fetchTxEffects(txHashes: TxHash[]): Promise<Map<string, IndexedTxEffect>> {
910
1115
  const uniqueTxHashes = uniqueBy(txHashes, h => h.toString());
911
- const fetched = await Promise.all(
912
- uniqueTxHashes.map(h => this.aztecNode.getTxReceipt(h, { includeTxEffect: true })),
913
- );
1116
+ const fetched = await Promise.all(uniqueTxHashes.map(h => this.aztecNodeReadCache.getTxReceiptWithEffect(h)));
914
1117
  return new Map(
915
1118
  uniqueTxHashes
916
1119
  .map((h, i): [string, IndexedTxEffect | undefined] => {
@@ -933,6 +1136,27 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
933
1136
  );
934
1137
  }
935
1138
 
1139
+ async #getTxEffectOption(txHash: TxHash): Promise<Option<TxEffectData>> {
1140
+ const receipt = await this.aztecNodeReadCache.getTxReceiptWithEffect(txHash);
1141
+ if (!receipt.isMined() || !receipt.txEffect || receipt.blockNumber > this.anchorBlockHeader.getBlockNumber()) {
1142
+ return Option.none();
1143
+ }
1144
+ return Option.some(this.#toTxEffectData(receipt.txEffect));
1145
+ }
1146
+
1147
+ #toTxEffectData(txEffect: TxEffect): TxEffectData {
1148
+ return {
1149
+ ...txEffect,
1150
+ revertCode: txEffect.revertCode.getCode(),
1151
+ publicLogs: FlatPublicLogs.fromLogs(txEffect.publicLogs),
1152
+ contractClassLogs: txEffect.contractClassLogs.map(log => ({
1153
+ contractAddress: log.contractAddress,
1154
+ fields: log.fields.toFields(),
1155
+ emittedLength: log.emittedLength,
1156
+ })),
1157
+ };
1158
+ }
1159
+
936
1160
  /** Runs a query concurrently with a validation that the block hash is not ahead of the anchor block. */
937
1161
  async #queryWithBlockHashNotAfterAnchor<T>(blockHash: BlockHash, query: () => Promise<T>): Promise<T> {
938
1162
  // Most contracts query state at the "current" block, which is the anchor. Skip the validation when we can.
@@ -944,7 +1168,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
944
1168
  const [response] = await Promise.all([
945
1169
  query(),
946
1170
  (async () => {
947
- const block = await this.aztecNode.getBlock(blockHash);
1171
+ const block = await this.aztecNodeReadCache.getBlock(blockHash);
948
1172
  const header = block?.header;
949
1173
  if (!header) {
950
1174
  throw new Error(`Could not find block header for block hash ${blockHash}`);
@@ -964,4 +1188,44 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
964
1188
  protected get callerContext(): 'private' | 'private view' | 'utility' {
965
1189
  return 'utility';
966
1190
  }
1191
+
1192
+ /** The address of the contract whose function is being executed, from the call context. */
1193
+ protected get contractAddress(): AztecAddress {
1194
+ return this.callContext.contractAddress;
1195
+ }
1196
+ }
1197
+
1198
+ // Registry reads that any contract may issue without an `authorizeUtilityCall` hook. The constrained-delivery
1199
+ // library calls these implicitly for the app, and they are safe to default-authorize: `get_app_siloed_secrets`
1200
+ // siloes every returned secret to `msg_sender`, and `get_non_interactive_handshakes` only exposes ephemeral public
1201
+ // keys, from which the shared secret cannot be derived without the recipient's secret keys.
1202
+ const STANDARD_HANDSHAKE_REGISTRY_DEFAULT_AUTHORIZED_READ_SIGNATURES = [
1203
+ 'get_non_interactive_handshakes((Field),u32)',
1204
+ 'get_app_siloed_secrets((Field),(Field))',
1205
+ ];
1206
+
1207
+ async function doesSelectorHaveSignature(functionSelector: FunctionSelector, signature: string): Promise<boolean> {
1208
+ return functionSelector.equals(await FunctionSelector.fromSignature(signature));
1209
+ }
1210
+
1211
+ /**
1212
+ * Whether a cross-contract utility call targets one of the standard handshake registry's read functions.
1213
+ *
1214
+ * These reads are authorized by PXE for every wallet, without consulting the `authorizeUtilityCall` hook, so that
1215
+ * wallets don't need to know the handshake registry exists in order to deliver and discover messages through it.
1216
+ */
1217
+ async function isStandardHandshakeRegistryUtilityRead(
1218
+ targetContractAddress: AztecAddress,
1219
+ functionSelector: FunctionSelector,
1220
+ ): Promise<boolean> {
1221
+ if (!targetContractAddress.equals(STANDARD_HANDSHAKE_REGISTRY_ADDRESS)) {
1222
+ return false;
1223
+ }
1224
+
1225
+ const matches = await Promise.all(
1226
+ STANDARD_HANDSHAKE_REGISTRY_DEFAULT_AUTHORIZED_READ_SIGNATURES.map(signature =>
1227
+ doesSelectorHaveSignature(functionSelector, signature),
1228
+ ),
1229
+ );
1230
+ return matches.some(Boolean);
967
1231
  }