@aztec/pxe 0.0.1-commit.9ef841308 → 0.0.1-commit.a5db02d

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 (501) hide show
  1. package/dest/bin/check_oracle_version.js +45 -111
  2. package/dest/bin/index.d.ts +2 -0
  3. package/dest/bin/index.d.ts.map +1 -0
  4. package/dest/bin/index.js +1 -0
  5. package/dest/bin/oracle_version_helpers.d.ts +51 -0
  6. package/dest/bin/oracle_version_helpers.d.ts.map +1 -0
  7. package/dest/bin/oracle_version_helpers.js +254 -0
  8. package/dest/block_synchronizer/block_stream_source.d.ts +10 -0
  9. package/dest/block_synchronizer/block_stream_source.d.ts.map +1 -0
  10. package/dest/block_synchronizer/block_stream_source.js +37 -0
  11. package/dest/block_synchronizer/block_synchronizer.d.ts +23 -15
  12. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  13. package/dest/block_synchronizer/block_synchronizer.js +78 -28
  14. package/dest/config/index.d.ts +8 -1
  15. package/dest/config/index.d.ts.map +1 -1
  16. package/dest/config/index.js +13 -14
  17. package/dest/config/package_info.js +1 -1
  18. package/dest/contract/contract_class_service.d.ts +31 -0
  19. package/dest/contract/contract_class_service.d.ts.map +1 -0
  20. package/dest/contract/contract_class_service.js +68 -0
  21. package/dest/contract/contract_sync_service.d.ts +48 -0
  22. package/dest/contract/contract_sync_service.d.ts.map +1 -0
  23. package/dest/contract/contract_sync_service.js +116 -0
  24. package/dest/contract/helpers.d.ts +7 -0
  25. package/dest/contract/helpers.d.ts.map +1 -0
  26. package/dest/contract/helpers.js +20 -0
  27. package/dest/contract_function_simulator/anchored_contract_data.d.ts +36 -0
  28. package/dest/contract_function_simulator/anchored_contract_data.d.ts.map +1 -0
  29. package/dest/contract_function_simulator/anchored_contract_data.js +54 -0
  30. package/dest/contract_function_simulator/aztec_node_read_cache.d.ts +39 -0
  31. package/dest/contract_function_simulator/aztec_node_read_cache.d.ts.map +1 -0
  32. package/dest/contract_function_simulator/aztec_node_read_cache.js +60 -0
  33. package/dest/contract_function_simulator/contract_function_simulator.d.ts +27 -21
  34. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  35. package/dest/contract_function_simulator/contract_function_simulator.js +83 -42
  36. package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
  37. package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
  38. package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
  39. package/dest/contract_function_simulator/execution_note_cache.d.ts +4 -10
  40. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  41. package/dest/contract_function_simulator/execution_note_cache.js +8 -28
  42. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -9
  43. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  44. package/dest/contract_function_simulator/execution_tagging_index_cache.js +3 -7
  45. package/dest/contract_function_simulator/index.d.ts +26 -6
  46. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  47. package/dest/contract_function_simulator/index.js +12 -4
  48. package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts +29 -0
  49. package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts.map +1 -0
  50. package/dest/contract_function_simulator/noir-structs/bounded_vec.js +30 -0
  51. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts +9 -0
  52. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts.map +1 -0
  53. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.js +1 -0
  54. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts +7 -0
  55. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts.map +1 -0
  56. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.js +1 -0
  57. package/dest/contract_function_simulator/noir-structs/ephemeral_array.d.ts +37 -0
  58. package/dest/contract_function_simulator/noir-structs/ephemeral_array.d.ts.map +1 -0
  59. package/dest/contract_function_simulator/noir-structs/ephemeral_array.js +59 -0
  60. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +4 -3
  61. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  62. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +5 -4
  63. package/dest/contract_function_simulator/noir-structs/fact.d.ts +16 -0
  64. package/dest/contract_function_simulator/noir-structs/fact.d.ts.map +1 -0
  65. package/dest/contract_function_simulator/noir-structs/fact.js +6 -0
  66. package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts +27 -0
  67. package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts.map +1 -0
  68. package/dest/contract_function_simulator/noir-structs/fact_collection.js +31 -0
  69. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +19 -10
  70. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
  71. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +12 -24
  72. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +11 -9
  73. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  74. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +2 -61
  75. package/dest/contract_function_simulator/noir-structs/note_data.d.ts +27 -0
  76. package/dest/contract_function_simulator/noir-structs/note_data.d.ts.map +1 -0
  77. package/dest/contract_function_simulator/noir-structs/note_data.js +3 -0
  78. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +4 -3
  79. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  80. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +6 -5
  81. package/dest/contract_function_simulator/noir-structs/option.d.ts +59 -0
  82. package/dest/contract_function_simulator/noir-structs/option.d.ts.map +1 -0
  83. package/dest/contract_function_simulator/noir-structs/option.js +67 -0
  84. package/dest/contract_function_simulator/noir-structs/origin_block.d.ts +11 -0
  85. package/dest/contract_function_simulator/noir-structs/origin_block.d.ts.map +1 -0
  86. package/dest/contract_function_simulator/noir-structs/origin_block.js +5 -0
  87. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts +11 -0
  88. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts.map +1 -0
  89. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.js +4 -0
  90. package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +8 -0
  91. package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts.map +1 -0
  92. package/dest/contract_function_simulator/noir-structs/provided_secret.js +1 -0
  93. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts +28 -0
  94. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts.map +1 -0
  95. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.js +50 -0
  96. package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts +21 -0
  97. package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts.map +1 -0
  98. package/dest/contract_function_simulator/noir-structs/resolved_tx.js +50 -0
  99. package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts +14 -0
  100. package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts.map +1 -0
  101. package/dest/contract_function_simulator/noir-structs/tx_effect_data.js +5 -0
  102. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +6 -11
  103. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
  104. package/dest/contract_function_simulator/noir-structs/utility_context.js +1 -20
  105. package/dest/contract_function_simulator/oracle/acir_callback.d.ts +21 -0
  106. package/dest/contract_function_simulator/oracle/acir_callback.d.ts.map +1 -0
  107. package/dest/contract_function_simulator/oracle/acir_callback.js +115 -0
  108. package/dest/contract_function_simulator/oracle/index.d.ts +2 -13
  109. package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -1
  110. package/dest/contract_function_simulator/oracle/index.js +1 -1
  111. package/dest/contract_function_simulator/oracle/interfaces.d.ts +15 -103
  112. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  113. package/dest/contract_function_simulator/oracle/interfaces.js +2 -2
  114. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts +39 -0
  115. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts.map +1 -0
  116. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.js +107 -0
  117. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -14
  118. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  119. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -24
  120. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +2 -2
  121. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
  122. package/dest/contract_function_simulator/oracle/note_packing_utils.js +2 -2
  123. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +139 -0
  124. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -0
  125. package/dest/contract_function_simulator/oracle/oracle_registry.js +1016 -0
  126. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +222 -0
  127. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -0
  128. package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +1243 -0
  129. package/dest/contract_function_simulator/oracle/private_execution.d.ts +1 -1
  130. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  131. package/dest/contract_function_simulator/oracle/private_execution.js +2 -3
  132. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +47 -37
  133. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  134. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +184 -55
  135. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +146 -69
  136. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  137. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +484 -180
  138. package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
  139. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
  140. package/dest/contract_function_simulator/pick_notes.js +20 -3
  141. package/dest/contract_function_simulator/transient_array_service.d.ts +31 -0
  142. package/dest/contract_function_simulator/transient_array_service.d.ts.map +1 -0
  143. package/dest/contract_function_simulator/transient_array_service.js +62 -0
  144. package/dest/debug/pxe_debug_utils.d.ts +4 -9
  145. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  146. package/dest/debug/pxe_debug_utils.js +0 -6
  147. package/dest/entrypoints/client/bundle/index.d.ts +2 -2
  148. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  149. package/dest/entrypoints/client/bundle/index.js +1 -1
  150. package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
  151. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  152. package/dest/entrypoints/client/bundle/utils.js +27 -8
  153. package/dest/entrypoints/client/lazy/index.d.ts +2 -2
  154. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  155. package/dest/entrypoints/client/lazy/index.js +1 -1
  156. package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
  157. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  158. package/dest/entrypoints/client/lazy/utils.js +27 -8
  159. package/dest/entrypoints/client/store.d.ts +14 -0
  160. package/dest/entrypoints/client/store.d.ts.map +1 -0
  161. package/dest/entrypoints/client/store.js +28 -0
  162. package/dest/entrypoints/pxe_creation_options.d.ts +16 -2
  163. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  164. package/dest/entrypoints/pxe_creation_options.js +3 -1
  165. package/dest/entrypoints/server/index.d.ts +7 -4
  166. package/dest/entrypoints/server/index.d.ts.map +1 -1
  167. package/dest/entrypoints/server/index.js +5 -3
  168. package/dest/entrypoints/server/store.d.ts +18 -0
  169. package/dest/entrypoints/server/store.d.ts.map +1 -0
  170. package/dest/entrypoints/server/store.js +28 -0
  171. package/dest/entrypoints/server/utils.d.ts +4 -3
  172. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  173. package/dest/entrypoints/server/utils.js +28 -8
  174. package/dest/error_enriching.d.ts +5 -3
  175. package/dest/error_enriching.d.ts.map +1 -1
  176. package/dest/error_enriching.js +13 -11
  177. package/dest/events/event_service.d.ts +13 -5
  178. package/dest/events/event_service.d.ts.map +1 -1
  179. package/dest/events/event_service.js +30 -9
  180. package/dest/events/private_event_filter_validator.d.ts +3 -2
  181. package/dest/events/private_event_filter_validator.d.ts.map +1 -1
  182. package/dest/events/private_event_filter_validator.js +15 -0
  183. package/dest/hooks/authorize_utility_call.d.ts +41 -0
  184. package/dest/hooks/authorize_utility_call.d.ts.map +1 -0
  185. package/dest/hooks/authorize_utility_call.js +4 -0
  186. package/dest/hooks/execution_hooks.d.ts +62 -0
  187. package/dest/hooks/execution_hooks.d.ts.map +1 -0
  188. package/dest/hooks/execution_hooks.js +9 -0
  189. package/dest/hooks/index.d.ts +5 -0
  190. package/dest/hooks/index.d.ts.map +1 -0
  191. package/dest/hooks/index.js +2 -0
  192. package/dest/hooks/resolve_custom_request.d.ts +23 -0
  193. package/dest/hooks/resolve_custom_request.d.ts.map +1 -0
  194. package/dest/hooks/resolve_custom_request.js +3 -0
  195. package/dest/hooks/resolve_tagging_secret_strategy.d.ts +50 -0
  196. package/dest/hooks/resolve_tagging_secret_strategy.d.ts.map +1 -0
  197. package/dest/hooks/resolve_tagging_secret_strategy.js +3 -0
  198. package/dest/logs/log_service.d.ts +14 -11
  199. package/dest/logs/log_service.d.ts.map +1 -1
  200. package/dest/logs/log_service.js +185 -72
  201. package/dest/messages/tx_resolver_service.d.ts +17 -0
  202. package/dest/messages/tx_resolver_service.d.ts.map +1 -0
  203. package/dest/messages/tx_resolver_service.js +55 -0
  204. package/dest/notes/note_service.d.ts +28 -7
  205. package/dest/notes/note_service.d.ts.map +1 -1
  206. package/dest/notes/note_service.js +81 -66
  207. package/dest/notes_filter.d.ts +2 -3
  208. package/dest/notes_filter.d.ts.map +1 -1
  209. package/dest/oracle_version.d.ts +4 -3
  210. package/dest/oracle_version.d.ts.map +1 -1
  211. package/dest/oracle_version.js +20 -10
  212. package/dest/private_kernel/batch_planner.d.ts +47 -0
  213. package/dest/private_kernel/batch_planner.d.ts.map +1 -0
  214. package/dest/private_kernel/batch_planner.js +104 -0
  215. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +1 -1
  216. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  217. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +7 -3
  218. package/dest/private_kernel/hints/test_utils.d.ts +1 -1
  219. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -1
  220. package/dest/private_kernel/hints/test_utils.js +3 -4
  221. package/dest/private_kernel/private_kernel_execution_prover.d.ts +6 -2
  222. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  223. package/dest/private_kernel/private_kernel_execution_prover.js +159 -85
  224. package/dest/private_kernel/private_kernel_oracle.d.ts +12 -10
  225. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  226. package/dest/private_kernel/private_kernel_oracle.js +40 -26
  227. package/dest/pxe.d.ts +167 -55
  228. package/dest/pxe.d.ts.map +1 -1
  229. package/dest/pxe.js +337 -206
  230. package/dest/storage/allowed_scopes.d.ts +6 -0
  231. package/dest/storage/allowed_scopes.d.ts.map +1 -0
  232. package/dest/storage/allowed_scopes.js +7 -0
  233. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -6
  234. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
  235. package/dest/storage/anchor_block_store/anchor_block_store.js +9 -7
  236. package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts +42 -0
  237. package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts.map +1 -0
  238. package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.js +93 -0
  239. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +15 -0
  240. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -0
  241. package/dest/storage/backwards_compatibility_tests/schema_tests.js +671 -0
  242. package/dest/storage/backwards_compatibility_tests/store_spy.d.ts +19 -0
  243. package/dest/storage/backwards_compatibility_tests/store_spy.d.ts.map +1 -0
  244. package/dest/storage/backwards_compatibility_tests/store_spy.js +63 -0
  245. package/dest/storage/capsule_store/capsule_service.d.ts +2 -3
  246. package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -1
  247. package/dest/storage/capsule_store/capsule_service.js +6 -9
  248. package/dest/storage/capsule_store/capsule_store.d.ts +1 -1
  249. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
  250. package/dest/storage/capsule_store/capsule_store.js +8 -5
  251. package/dest/storage/contract_store/contract_store.d.ts +27 -24
  252. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  253. package/dest/storage/contract_store/contract_store.js +70 -98
  254. package/dest/storage/fact_store/fact_service.d.ts +22 -0
  255. package/dest/storage/fact_store/fact_service.d.ts.map +1 -0
  256. package/dest/storage/fact_store/fact_service.js +45 -0
  257. package/dest/storage/fact_store/fact_store.d.ts +95 -0
  258. package/dest/storage/fact_store/fact_store.d.ts.map +1 -0
  259. package/dest/storage/fact_store/fact_store.js +408 -0
  260. package/dest/storage/fact_store/fact_store_keys.d.ts +34 -0
  261. package/dest/storage/fact_store/fact_store_keys.d.ts.map +1 -0
  262. package/dest/storage/fact_store/fact_store_keys.js +50 -0
  263. package/dest/storage/fact_store/index.d.ts +6 -0
  264. package/dest/storage/fact_store/index.d.ts.map +1 -0
  265. package/dest/storage/fact_store/index.js +4 -0
  266. package/dest/storage/fact_store/origin_state.d.ts +57 -0
  267. package/dest/storage/fact_store/origin_state.d.ts.map +1 -0
  268. package/dest/storage/fact_store/origin_state.js +53 -0
  269. package/dest/storage/fact_store/stored_fact.d.ts +32 -0
  270. package/dest/storage/fact_store/stored_fact.d.ts.map +1 -0
  271. package/dest/storage/fact_store/stored_fact.js +64 -0
  272. package/dest/storage/index.d.ts +3 -2
  273. package/dest/storage/index.d.ts.map +1 -1
  274. package/dest/storage/index.js +2 -1
  275. package/dest/storage/metadata.d.ts +2 -2
  276. package/dest/storage/metadata.d.ts.map +1 -1
  277. package/dest/storage/metadata.js +1 -1
  278. package/dest/storage/note_store/note_store.d.ts +42 -33
  279. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  280. package/dest/storage/note_store/note_store.js +199 -170
  281. package/dest/storage/note_store/stored_note.d.ts +3 -8
  282. package/dest/storage/note_store/stored_note.d.ts.map +1 -1
  283. package/dest/storage/note_store/stored_note.js +4 -20
  284. package/dest/storage/open_pxe_stores.d.ts +35 -0
  285. package/dest/storage/open_pxe_stores.d.ts.map +1 -0
  286. package/dest/storage/open_pxe_stores.js +29 -0
  287. package/dest/storage/private_event_store/private_event_store.d.ts +13 -16
  288. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  289. package/dest/storage/private_event_store/private_event_store.js +43 -43
  290. package/dest/storage/private_event_store/stored_private_event.js +1 -1
  291. package/dest/storage/store_identity.d.ts +35 -0
  292. package/dest/storage/store_identity.d.ts.map +1 -0
  293. package/dest/storage/store_identity.js +44 -0
  294. package/dest/storage/tagging_store/index.d.ts +2 -2
  295. package/dest/storage/tagging_store/index.d.ts.map +1 -1
  296. package/dest/storage/tagging_store/index.js +1 -1
  297. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
  298. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  299. package/dest/storage/tagging_store/sender_tagging_store.d.ts +23 -7
  300. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  301. package/dest/storage/tagging_store/sender_tagging_store.js +51 -14
  302. package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts +51 -0
  303. package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts.map +1 -0
  304. package/dest/storage/tagging_store/tagging_secret_sources_store.js +105 -0
  305. package/dest/tagging/constants.d.ts +2 -2
  306. package/dest/tagging/constants.d.ts.map +1 -1
  307. package/dest/tagging/constants.js +18 -9
  308. package/dest/tagging/get_all_logs_by_tags.d.ts +34 -10
  309. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
  310. package/dest/tagging/get_all_logs_by_tags.js +36 -37
  311. package/dest/tagging/index.d.ts +5 -4
  312. package/dest/tagging/index.d.ts.map +1 -1
  313. package/dest/tagging/index.js +4 -3
  314. package/dest/tagging/persist_sender_tagging_index_ranges.d.ts +29 -0
  315. package/dest/tagging/persist_sender_tagging_index_ranges.d.ts.map +1 -0
  316. package/dest/tagging/persist_sender_tagging_index_ranges.js +42 -0
  317. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +69 -0
  318. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -0
  319. package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +203 -0
  320. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +3 -3
  321. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -1
  322. package/dest/tagging/reconcile_tagging_index_ranges.d.ts +36 -0
  323. package/dest/tagging/reconcile_tagging_index_ranges.d.ts.map +1 -0
  324. package/dest/tagging/reconcile_tagging_index_ranges.js +74 -0
  325. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -5
  326. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  327. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +26 -14
  328. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +11 -6
  329. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  330. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +21 -0
  331. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +4 -4
  332. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  333. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +8 -4
  334. package/package.json +20 -17
  335. package/src/bin/check_oracle_version.ts +51 -133
  336. package/src/bin/index.ts +5 -0
  337. package/src/bin/oracle_version_helpers.ts +311 -0
  338. package/src/block_synchronizer/block_stream_source.ts +42 -0
  339. package/src/block_synchronizer/block_synchronizer.ts +96 -39
  340. package/src/config/index.ts +15 -8
  341. package/src/config/package_info.ts +1 -1
  342. package/src/contract/contract_class_service.ts +83 -0
  343. package/src/contract/contract_sync_service.ts +176 -0
  344. package/src/contract/helpers.ts +35 -0
  345. package/src/contract_function_simulator/anchored_contract_data.ts +74 -0
  346. package/src/contract_function_simulator/aztec_node_read_cache.ts +89 -0
  347. package/src/contract_function_simulator/contract_function_simulator.ts +137 -58
  348. package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
  349. package/src/contract_function_simulator/execution_note_cache.ts +8 -29
  350. package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -9
  351. package/src/contract_function_simulator/index.ts +69 -5
  352. package/src/contract_function_simulator/noir-structs/bounded_vec.ts +43 -0
  353. package/src/contract_function_simulator/noir-structs/contract_class_log_data.ts +9 -0
  354. package/src/contract_function_simulator/noir-structs/embedded_curve_point.ts +4 -0
  355. package/src/contract_function_simulator/noir-structs/ephemeral_array.ts +66 -0
  356. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +5 -4
  357. package/src/contract_function_simulator/noir-structs/fact.ts +13 -0
  358. package/src/contract_function_simulator/noir-structs/fact_collection.ts +64 -0
  359. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +27 -20
  360. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +14 -61
  361. package/src/contract_function_simulator/noir-structs/note_data.ts +27 -0
  362. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +6 -5
  363. package/src/contract_function_simulator/noir-structs/option.ts +75 -0
  364. package/src/contract_function_simulator/noir-structs/origin_block.ts +8 -0
  365. package/src/contract_function_simulator/noir-structs/pending_tagged_log.ts +12 -0
  366. package/src/contract_function_simulator/noir-structs/provided_secret.ts +5 -0
  367. package/src/contract_function_simulator/noir-structs/resolved_tagging_strategy.ts +66 -0
  368. package/src/contract_function_simulator/noir-structs/resolved_tx.ts +53 -0
  369. package/src/contract_function_simulator/noir-structs/tx_effect_data.ts +15 -0
  370. package/src/contract_function_simulator/noir-structs/utility_context.ts +5 -17
  371. package/src/contract_function_simulator/oracle/acir_callback.ts +154 -0
  372. package/src/contract_function_simulator/oracle/index.ts +1 -15
  373. package/src/contract_function_simulator/oracle/interfaces.ts +11 -185
  374. package/src/contract_function_simulator/oracle/legacy_oracle_registry.ts +147 -0
  375. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +6 -21
  376. package/src/contract_function_simulator/oracle/note_packing_utils.ts +3 -3
  377. package/src/contract_function_simulator/oracle/oracle_registry.ts +711 -0
  378. package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +964 -0
  379. package/src/contract_function_simulator/oracle/private_execution.ts +2 -3
  380. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +233 -79
  381. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +747 -338
  382. package/src/contract_function_simulator/pick_notes.ts +22 -3
  383. package/src/contract_function_simulator/transient_array_service.ts +91 -0
  384. package/src/debug/pxe_debug_utils.ts +4 -12
  385. package/src/entrypoints/client/bundle/index.ts +1 -1
  386. package/src/entrypoints/client/bundle/utils.ts +32 -8
  387. package/src/entrypoints/client/lazy/index.ts +1 -1
  388. package/src/entrypoints/client/lazy/utils.ts +32 -8
  389. package/src/entrypoints/client/store.ts +38 -0
  390. package/src/entrypoints/pxe_creation_options.ts +21 -1
  391. package/src/entrypoints/server/index.ts +7 -3
  392. package/src/entrypoints/server/store.ts +47 -0
  393. package/src/entrypoints/server/utils.ts +45 -14
  394. package/src/error_enriching.ts +27 -11
  395. package/src/events/event_service.ts +54 -19
  396. package/src/events/private_event_filter_validator.ts +21 -1
  397. package/src/hooks/authorize_utility_call.ts +44 -0
  398. package/src/hooks/execution_hooks.ts +68 -0
  399. package/src/hooks/index.ts +13 -0
  400. package/src/hooks/resolve_custom_request.ts +24 -0
  401. package/src/hooks/resolve_tagging_secret_strategy.ts +60 -0
  402. package/src/logs/log_service.ts +216 -139
  403. package/src/messages/tx_resolver_service.ts +69 -0
  404. package/src/notes/note_service.ts +118 -95
  405. package/src/notes_filter.ts +1 -3
  406. package/src/oracle_version.ts +20 -10
  407. package/src/private_kernel/batch_planner.ts +169 -0
  408. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +12 -2
  409. package/src/private_kernel/hints/test_utils.ts +3 -10
  410. package/src/private_kernel/private_kernel_execution_prover.ts +245 -117
  411. package/src/private_kernel/private_kernel_oracle.ts +58 -29
  412. package/src/pxe.ts +533 -236
  413. package/src/storage/allowed_scopes.ts +14 -0
  414. package/src/storage/anchor_block_store/anchor_block_store.ts +9 -7
  415. package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +22 -0
  416. package/src/storage/backwards_compatibility_tests/__snapshots__/AnchorBlockStore.json +3 -0
  417. package/src/storage/backwards_compatibility_tests/__snapshots__/CapsuleStore.json +16 -0
  418. package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +28 -0
  419. package/src/storage/backwards_compatibility_tests/__snapshots__/FactStore.json +40 -0
  420. package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +52 -0
  421. package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +40 -0
  422. package/src/storage/backwards_compatibility_tests/__snapshots__/NoteStore.json +56 -0
  423. package/src/storage/backwards_compatibility_tests/__snapshots__/PrivateEventStore.json +44 -0
  424. package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +26 -0
  425. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +30 -0
  426. package/src/storage/backwards_compatibility_tests/__snapshots__/TaggingSecretSourcesStore.json +30 -0
  427. package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +117 -0
  428. package/src/storage/backwards_compatibility_tests/kv_store_snapshot.ts +122 -0
  429. package/src/storage/backwards_compatibility_tests/schema_tests.ts +803 -0
  430. package/src/storage/backwards_compatibility_tests/store_spy.ts +73 -0
  431. package/src/storage/capsule_store/capsule_service.ts +8 -14
  432. package/src/storage/capsule_store/capsule_store.ts +15 -5
  433. package/src/storage/contract_store/contract_store.ts +96 -124
  434. package/src/storage/fact_store/fact_service.ts +69 -0
  435. package/src/storage/fact_store/fact_store.ts +487 -0
  436. package/src/storage/fact_store/fact_store_keys.ts +75 -0
  437. package/src/storage/fact_store/index.ts +14 -0
  438. package/src/storage/fact_store/origin_state.ts +75 -0
  439. package/src/storage/fact_store/stored_fact.ts +80 -0
  440. package/src/storage/index.ts +2 -1
  441. package/src/storage/metadata.ts +1 -1
  442. package/src/storage/note_store/note_store.ts +228 -192
  443. package/src/storage/note_store/stored_note.ts +5 -27
  444. package/src/storage/open_pxe_stores.ts +52 -0
  445. package/src/storage/private_event_store/private_event_store.ts +52 -54
  446. package/src/storage/private_event_store/stored_private_event.ts +1 -1
  447. package/src/storage/store_identity.ts +72 -0
  448. package/src/storage/tagging_store/index.ts +1 -1
  449. package/src/storage/tagging_store/recipient_tagging_store.ts +5 -9
  450. package/src/storage/tagging_store/sender_tagging_store.ts +68 -21
  451. package/src/storage/tagging_store/tagging_secret_sources_store.ts +138 -0
  452. package/src/tagging/constants.ts +19 -9
  453. package/src/tagging/get_all_logs_by_tags.ts +78 -50
  454. package/src/tagging/index.ts +4 -3
  455. package/src/tagging/persist_sender_tagging_index_ranges.ts +57 -0
  456. package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +301 -0
  457. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
  458. package/src/tagging/reconcile_tagging_index_ranges.ts +102 -0
  459. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +41 -19
  460. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +23 -8
  461. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +10 -7
  462. package/dest/access_scopes.d.ts +0 -9
  463. package/dest/access_scopes.d.ts.map +0 -1
  464. package/dest/access_scopes.js +0 -6
  465. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +0 -9
  466. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +0 -1
  467. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +0 -38
  468. package/dest/contract_function_simulator/oracle/oracle.d.ts +0 -80
  469. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +0 -1
  470. package/dest/contract_function_simulator/oracle/oracle.js +0 -458
  471. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +0 -6
  472. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +0 -1
  473. package/dest/contract_function_simulator/proxied_contract_data_source.js +0 -80
  474. package/dest/contract_sync/contract_sync_service.d.ts +0 -46
  475. package/dest/contract_sync/contract_sync_service.d.ts.map +0 -1
  476. package/dest/contract_sync/contract_sync_service.js +0 -124
  477. package/dest/contract_sync/helpers.d.ts +0 -29
  478. package/dest/contract_sync/helpers.d.ts.map +0 -1
  479. package/dest/contract_sync/helpers.js +0 -60
  480. package/dest/messages/message_context_service.d.ts +0 -17
  481. package/dest/messages/message_context_service.d.ts.map +0 -1
  482. package/dest/messages/message_context_service.js +0 -36
  483. package/dest/storage/tagging_store/sender_address_book_store.d.ts +0 -14
  484. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +0 -1
  485. package/dest/storage/tagging_store/sender_address_book_store.js +0 -36
  486. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +0 -14
  487. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +0 -1
  488. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +0 -99
  489. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +0 -14
  490. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +0 -1
  491. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +0 -33
  492. package/src/access_scopes.ts +0 -9
  493. package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +0 -98
  494. package/src/contract_function_simulator/oracle/oracle.ts +0 -721
  495. package/src/contract_function_simulator/proxied_contract_data_source.ts +0 -83
  496. package/src/contract_sync/contract_sync_service.ts +0 -192
  497. package/src/contract_sync/helpers.ts +0 -99
  498. package/src/messages/message_context_service.ts +0 -44
  499. package/src/storage/tagging_store/sender_address_book_store.ts +0 -48
  500. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +0 -140
  501. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +0 -44
package/src/pxe.ts CHANGED
@@ -1,37 +1,43 @@
1
1
  import type { PrivateEventFilter } from '@aztec/aztec.js/wallet';
2
2
  import { BlockNumber } from '@aztec/foundation/branded-types';
3
3
  import { Fr } from '@aztec/foundation/curves/bn254';
4
+ import { Point } from '@aztec/foundation/curves/grumpkin';
4
5
  import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
5
6
  import { SerialQueue } from '@aztec/foundation/queue';
6
7
  import { Timer } from '@aztec/foundation/timer';
7
8
  import { KeyStore } from '@aztec/key-store';
9
+ import type { AccountPrivacyKeys, AccountPrivacySecretKeys } from '@aztec/key-store';
8
10
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
9
- import { L2TipsKVStore } from '@aztec/kv-store/stores';
10
11
  import { type ProtocolContractsProvider, protocolContractNames } from '@aztec/protocol-contracts';
11
12
  import type { CircuitSimulator } from '@aztec/simulator/client';
12
13
  import {
13
14
  type ContractArtifact,
14
15
  EventSelector,
15
16
  FunctionCall,
17
+ type FunctionSelector,
16
18
  FunctionType,
17
19
  decodeFunctionSignature,
18
20
  } from '@aztec/stdlib/abi';
19
21
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
20
22
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
23
+ import { GENESIS_BLOCK_HEADER_HASH, type L2TipsProvider } from '@aztec/stdlib/block';
21
24
  import {
22
25
  CompleteAddress,
26
+ type ContractInstancePreimage,
27
+ type ContractInstancePreimageWithAddress,
23
28
  type ContractInstanceWithAddress,
24
29
  type PartialAddress,
25
30
  computeContractAddressFromInstance,
26
- getContractClassFromArtifact,
27
31
  } from '@aztec/stdlib/contract';
28
32
  import { SimulationError } from '@aztec/stdlib/errors';
29
- import type { AztecNode, PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
33
+ import type { AztecNode, AztecNodeDebug, PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
30
34
  import type {
31
35
  PrivateExecutionStep,
32
36
  PrivateKernelExecutionProofOutput,
33
37
  PrivateKernelTailCircuitPublicInputs,
34
38
  } from '@aztec/stdlib/kernel';
39
+ import { computeAddressSecret } from '@aztec/stdlib/keys';
40
+ import { deriveEcdhSharedSecretPoint, protectFromForgery } from '@aztec/stdlib/logs';
35
41
  import {
36
42
  BlockHeader,
37
43
  type ContractOverrides,
@@ -52,23 +58,22 @@ import {
52
58
 
53
59
  import { inspect } from 'util';
54
60
 
55
- import type { AccessScopes } from './access_scopes.js';
56
61
  import { BlockSynchronizer } from './block_synchronizer/index.js';
57
62
  import type { PXEConfig } from './config/index.js';
63
+ import { ContractClassService } from './contract/contract_class_service.js';
64
+ import { ContractSyncService } from './contract/contract_sync_service.js';
58
65
  import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
59
66
  import {
60
67
  ContractFunctionSimulator,
61
68
  generateSimulatedProvingResult,
62
69
  } from './contract_function_simulator/contract_function_simulator.js';
63
- import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
64
70
  import { displayDebugLogs } from './contract_logging.js';
65
- import { ContractSyncService } from './contract_sync/contract_sync_service.js';
66
- import { readCurrentClassId } from './contract_sync/helpers.js';
67
71
  import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
68
72
  import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
69
73
  import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
74
+ import type { ExecutionHooks } from './hooks/index.js';
70
75
  import { JobCoordinator } from './job_coordinator/job_coordinator.js';
71
- import { MessageContextService } from './messages/message_context_service.js';
76
+ import { TxResolverService } from './messages/tx_resolver_service.js';
72
77
  import {
73
78
  PrivateKernelExecutionProver,
74
79
  type PrivateKernelExecutionProverConfig,
@@ -78,17 +83,31 @@ import { AddressStore } from './storage/address_store/address_store.js';
78
83
  import { AnchorBlockStore } from './storage/anchor_block_store/anchor_block_store.js';
79
84
  import { CapsuleStore } from './storage/capsule_store/capsule_store.js';
80
85
  import { ContractStore } from './storage/contract_store/contract_store.js';
86
+ import { FactStore } from './storage/fact_store/index.js';
81
87
  import { NoteStore } from './storage/note_store/note_store.js';
88
+ import { openPxeStores } from './storage/open_pxe_stores.js';
82
89
  import { PrivateEventStore } from './storage/private_event_store/private_event_store.js';
83
90
  import { RecipientTaggingStore } from './storage/tagging_store/recipient_tagging_store.js';
84
- import { SenderAddressBookStore } from './storage/tagging_store/sender_address_book_store.js';
85
91
  import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store.js';
92
+ import {
93
+ type SharedSecretKind,
94
+ TaggingSecretSourcesStore,
95
+ } from './storage/tagging_store/tagging_secret_sources_store.js';
96
+ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
86
97
 
87
98
  export type PackedPrivateEvent = InTx & {
88
99
  packedEvent: Fr[];
89
100
  eventSelector: EventSelector;
90
101
  };
91
102
 
103
+ /** Options for PXE.proveTx. */
104
+ export type ProveTxOpts = {
105
+ /** Addresses whose private state and keys are accessible during private execution. */
106
+ scopes: AztecAddress[];
107
+ /** Sender address used to derive discovery tags for private messages (notes, events, logs) this tx emits. */
108
+ senderForTags?: AztecAddress;
109
+ };
110
+
92
111
  /** Options for PXE.profileTx. */
93
112
  export type ProfileTxOpts = {
94
113
  /** The profiling mode to use. */
@@ -96,7 +115,9 @@ export type ProfileTxOpts = {
96
115
  /** If true, proof generation is skipped during profiling. Defaults to true. */
97
116
  skipProofGeneration?: boolean;
98
117
  /** Addresses whose private state and keys are accessible during private execution. */
99
- scopes: AccessScopes;
118
+ scopes: AztecAddress[];
119
+ /** Sender address used to derive discovery tags for private messages (notes, events, logs) this tx emits. */
120
+ senderForTags?: AztecAddress;
100
121
  };
101
122
 
102
123
  /** Options for PXE.simulateTx. */
@@ -109,10 +130,16 @@ export type SimulateTxOpts = {
109
130
  skipFeeEnforcement?: boolean;
110
131
  /** If true, kernel logic is emulated in TS for simulation */
111
132
  skipKernels?: boolean;
112
- /** State overrides for the simulation, such as contract instances and artifacts. Requires skipKernels: true */
133
+ /**
134
+ * Pre-simulation overrides applied to the ephemeral fork and contract DB. Bundles publicStorage
135
+ * writes (no skipKernels required) and per-address (instance, artifact?) overrides used by both
136
+ * AVM-side public dispatch and PXE-side ACIR private dispatch (requires skipKernels: true).
137
+ */
113
138
  overrides?: SimulationOverrides;
114
139
  /** Addresses whose private state and keys are accessible during private execution */
115
- scopes: AccessScopes;
140
+ scopes: AztecAddress[];
141
+ /** Sender address used to derive discovery tags for private messages (notes, events, logs) this tx emits. */
142
+ senderForTags?: AztecAddress;
116
143
  };
117
144
 
118
145
  /** Options for PXE.executeUtility. */
@@ -120,13 +147,33 @@ export type ExecuteUtilityOpts = {
120
147
  /** The authentication witnesses required for the function call. */
121
148
  authwits?: AuthWitness[];
122
149
  /** The accounts whose notes we can access in this call */
123
- scopes: AccessScopes;
150
+ scopes: AztecAddress[];
151
+ };
152
+
153
+ /**
154
+ * Supplies the set of "nice to have" contracts that every PXE preloads regardless of which wallet
155
+ * drives it. Today this is just the standard multi-call entrypoint: the SDK's self-paid account
156
+ * deploy flow ({@link DeployAccountMethod} with `from = NO_FROM`) routes its payload through it, so a
157
+ * PXE that did not register it would fail contract sync with an opaque "no contract instance" error.
158
+ *
159
+ * Returning a list keeps this extensible: a wallet may supply its own provider that preloads
160
+ * additional contracts. Injected the same way as {@link ProtocolContractsProvider} so the PXE never
161
+ * statically imports the bundled artifacts, keeping the bundle/lazy split intact.
162
+ */
163
+ export type PreloadedContractsProvider = {
164
+ /** Returns the contract instances and artifacts the PXE should preload on startup. */
165
+ getPreloadedContracts: () => Promise<Array<{ instance: ContractInstanceWithAddress; artifact: ContractArtifact }>>;
124
166
  };
125
167
 
126
168
  /** Args for PXE.create. */
127
169
  export type PXECreateArgs = {
128
170
  /** The Aztec node to connect to. */
129
171
  node: AztecNode;
172
+ /**
173
+ * Optional debug API client. When provided, public function signatures are registered with the node so that
174
+ * node-side public-execution stack traces can be named. Skipped when the node does not expose the debug API.
175
+ */
176
+ nodeDebug?: AztecNodeDebug;
130
177
  /** The key-value store for persisting PXE state. */
131
178
  store: AztecAsyncKVStore;
132
179
  /** The prover for generating private kernel proofs. */
@@ -135,12 +182,48 @@ export type PXECreateArgs = {
135
182
  simulator: CircuitSimulator;
136
183
  /** Provider for protocol contract artifacts and instances. */
137
184
  protocolContractsProvider: ProtocolContractsProvider;
185
+ /**
186
+ * Contracts to preload on startup. Injected by the entrypoint with the bundle-or-lazy flavor that
187
+ * matches the runtime (bundle for node/eager browser, lazy for code-split browser), so the PXE
188
+ * never statically imports a standard-contract artifact and the bundle/lazy split stays intact.
189
+ */
190
+ preloadedContractsProvider: PreloadedContractsProvider;
138
191
  /** PXE configuration options. */
139
192
  config: PXEConfig;
140
193
  /** Optional logger instance or string suffix for the logger name. */
141
194
  loggerOrSuffix?: string | Logger;
195
+ /** Optional hooks to observe and influence contract execution. */
196
+ hooks?: ExecutionHooks;
142
197
  };
143
198
 
199
+ /** A source from which PXE derives the tagging secrets it scans for to discover incoming private logs. */
200
+ export type TaggingSecretSource =
201
+ /**
202
+ * Derives a shared secret via ECDH from an external `sender` address against every account registered in this PXE
203
+ * (present and future), so registering one sender applies it to all of them. The address is not secret, so unlike
204
+ * `arbitrary-secret` it can be reused freely across recipients.
205
+ */
206
+ | { kind: 'address-derived'; sender: AztecAddress }
207
+ /**
208
+ * A shared secret point provided directly, scoped to a single recipient. It bypasses ECDH, so it must not be
209
+ * reused across recipients (each would then be able to find the others' tags).
210
+ */
211
+ | { kind: 'arbitrary-secret'; recipient: AztecAddress; secret: Point }
212
+ /**
213
+ * A handshake known by the x-coordinate of its ephemeral public key (the value a recipient learns while authorizing
214
+ * an interactive handshake, which emits no discoverable announcement). The ephemeral key's y-coordinate is always
215
+ * positive by protocol construction, so the x-coordinate alone identifies it.
216
+ */
217
+ | { kind: 'handshake'; recipient: AztecAddress; ephPk: Fr };
218
+
219
+ /**
220
+ * The registered form of a {@link TaggingSecretSource}.
221
+ */
222
+ export type RegisteredTaggingSecretSource =
223
+ | Exclude<TaggingSecretSource, { kind: 'handshake' }>
224
+ /** A handshake's resolved shared secret, derived at registration from the handshake's ephemeral key. */
225
+ | { kind: 'handshake'; recipient: AztecAddress; secret: Point };
226
+
144
227
  /**
145
228
  * Private eXecution Environment (PXE) is a library used by wallets to simulate private phase of transactions and to
146
229
  * manage private state of users.
@@ -148,28 +231,35 @@ export type PXECreateArgs = {
148
231
  export class PXE {
149
232
  private constructor(
150
233
  private node: AztecNode,
234
+ private nodeDebug: AztecNodeDebug | undefined,
151
235
  private db: AztecAsyncKVStore,
152
236
  private blockStateSynchronizer: BlockSynchronizer,
153
237
  private keyStore: KeyStore,
154
238
  private contractStore: ContractStore,
155
239
  private noteStore: NoteStore,
156
240
  private capsuleStore: CapsuleStore,
241
+ private factStore: FactStore,
157
242
  private anchorBlockStore: AnchorBlockStore,
158
243
  private senderTaggingStore: SenderTaggingStore,
159
- private senderAddressBookStore: SenderAddressBookStore,
244
+ private taggingSecretSourcesStore: TaggingSecretSourcesStore,
160
245
  private recipientTaggingStore: RecipientTaggingStore,
161
246
  private addressStore: AddressStore,
162
247
  private privateEventStore: PrivateEventStore,
163
248
  private contractSyncService: ContractSyncService,
164
- private messageContextService: MessageContextService,
249
+ private contractClassService: ContractClassService,
250
+ private txResolver: TxResolverService,
251
+ private l2TipsStore: L2TipsProvider,
165
252
  private simulator: CircuitSimulator,
166
253
  private proverEnabled: boolean,
254
+ private autoSync: boolean,
167
255
  private proofCreator: PrivateKernelProver,
168
256
  private protocolContractsProvider: ProtocolContractsProvider,
257
+ private preloadedContractsProvider: PreloadedContractsProvider,
169
258
  private log: Logger,
170
259
  private jobQueue: SerialQueue,
171
260
  private jobCoordinator: JobCoordinator,
172
261
  public debug: PXEDebugUtils,
262
+ private hooks: ExecutionHooks | undefined,
173
263
  ) {}
174
264
 
175
265
  /**
@@ -181,12 +271,15 @@ export class PXE {
181
271
  */
182
272
  public static async create({
183
273
  node,
274
+ nodeDebug,
184
275
  store,
185
276
  proofCreator,
186
277
  simulator,
187
278
  protocolContractsProvider,
279
+ preloadedContractsProvider,
188
280
  config,
189
281
  loggerOrSuffix,
282
+ hooks,
190
283
  }: PXECreateArgs) {
191
284
  // Extract bindings from the logger, or use empty bindings if a string suffix is provided.
192
285
  const bindings: LoggerBindings | undefined =
@@ -199,26 +292,38 @@ export class PXE {
199
292
 
200
293
  const info = await node.getNodeInfo();
201
294
 
295
+ // Source the genesis block hash from the node so PXE's L2BlockStream agrees with the node's
296
+ // archiver on the dynamic initial header hash. Without this the tip store would fall back to
297
+ // the static `GENESIS_BLOCK_HEADER_HASH` constant, which only matches deployments with the
298
+ // default empty genesis (timestamp 0, no prefilled public data) and diverges otherwise — the
299
+ // sync at block 0 would then get stuck in `areBlockHashesEqualAt` and abort. If the node does
300
+ // not return a genesis block (older node or test fixture) we fall back to the static constant.
301
+ const initialBlockHash = (await node.getBlock(BlockNumber.ZERO))?.hash ?? GENESIS_BLOCK_HEADER_HASH;
302
+
202
303
  const proverEnabled = config.proverEnabled !== undefined ? config.proverEnabled : info.realProofs;
203
- const addressStore = new AddressStore(store);
204
- const privateEventStore = new PrivateEventStore(store);
205
- const contractStore = new ContractStore(store);
206
- const noteStore = new NoteStore(store);
207
- const anchorBlockStore = new AnchorBlockStore(store);
208
- const senderTaggingStore = new SenderTaggingStore(store);
209
- const senderAddressBookStore = new SenderAddressBookStore(store);
210
- const recipientTaggingStore = new RecipientTaggingStore(store);
211
- const capsuleStore = new CapsuleStore(store);
212
- const keyStore = new KeyStore(store);
213
- const tipsStore = new L2TipsKVStore(store, 'pxe');
304
+ const {
305
+ addressStore,
306
+ privateEventStore,
307
+ contractStore,
308
+ noteStore,
309
+ anchorBlockStore,
310
+ senderTaggingStore,
311
+ taggingSecretSourcesStore,
312
+ recipientTaggingStore,
313
+ capsuleStore,
314
+ keyStore,
315
+ l2TipsStore,
316
+ factStore,
317
+ } = openPxeStores(store, initialBlockHash);
318
+ const contractClassService = new ContractClassService(node, contractStore);
214
319
  const contractSyncService = new ContractSyncService(
215
320
  node,
216
321
  contractStore,
322
+ contractClassService,
217
323
  noteStore,
218
- () => keyStore.getAccounts(),
219
324
  createLogger('pxe:contract_sync', bindings),
220
325
  );
221
- const messageContextService = new MessageContextService(node);
326
+ const txResolver = new TxResolverService(node);
222
327
 
223
328
  const synchronizer = new BlockSynchronizer(
224
329
  node,
@@ -226,8 +331,10 @@ export class PXE {
226
331
  anchorBlockStore,
227
332
  noteStore,
228
333
  privateEventStore,
229
- tipsStore,
334
+ factStore,
335
+ l2TipsStore,
230
336
  contractSyncService,
337
+ contractClassService,
231
338
  config,
232
339
  bindings,
233
340
  );
@@ -239,6 +346,7 @@ export class PXE {
239
346
  recipientTaggingStore,
240
347
  privateEventStore,
241
348
  noteStore,
349
+ factStore,
242
350
  contractSyncService,
243
351
  ]);
244
352
 
@@ -248,28 +356,35 @@ export class PXE {
248
356
 
249
357
  const pxe = new PXE(
250
358
  node,
359
+ nodeDebug,
251
360
  store,
252
361
  synchronizer,
253
362
  keyStore,
254
363
  contractStore,
255
364
  noteStore,
256
365
  capsuleStore,
366
+ factStore,
257
367
  anchorBlockStore,
258
368
  senderTaggingStore,
259
- senderAddressBookStore,
369
+ taggingSecretSourcesStore,
260
370
  recipientTaggingStore,
261
371
  addressStore,
262
372
  privateEventStore,
263
373
  contractSyncService,
264
- messageContextService,
374
+ contractClassService,
375
+ txResolver,
376
+ l2TipsStore,
265
377
  simulator,
266
378
  proverEnabled,
379
+ config.autoSync,
267
380
  proofCreator,
268
381
  protocolContractsProvider,
382
+ preloadedContractsProvider,
269
383
  log,
270
384
  jobQueue,
271
385
  jobCoordinator,
272
386
  debugUtils,
387
+ hooks,
273
388
  );
274
389
 
275
390
  debugUtils.setPXEHelpers(
@@ -280,7 +395,7 @@ export class PXE {
280
395
 
281
396
  pxe.jobQueue.start();
282
397
 
283
- await pxe.#registerProtocolContracts();
398
+ await Promise.all([pxe.#registerProtocolContracts(), pxe.#registerPreloadedContracts()]);
284
399
  log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
285
400
  return pxe;
286
401
  }
@@ -288,25 +403,52 @@ export class PXE {
288
403
  // Internal methods
289
404
 
290
405
  #getSimulatorForTx(overrides?: { contracts?: ContractOverrides }) {
291
- const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
292
-
293
406
  return new ContractFunctionSimulator({
294
- contractStore: proxyContractStore,
407
+ contractStore: this.contractStore,
408
+ contractClassService: this.contractClassService,
409
+ overrides: overrides?.contracts,
295
410
  noteStore: this.noteStore,
296
411
  keyStore: this.keyStore,
297
412
  addressStore: this.addressStore,
298
413
  aztecNode: BenchmarkedNodeFactory.create(this.node),
414
+ l2TipsStore: this.l2TipsStore,
299
415
  senderTaggingStore: this.senderTaggingStore,
300
416
  recipientTaggingStore: this.recipientTaggingStore,
301
- senderAddressBookStore: this.senderAddressBookStore,
417
+ taggingSecretSourcesStore: this.taggingSecretSourcesStore,
302
418
  capsuleStore: this.capsuleStore,
419
+ factStore: this.factStore,
303
420
  privateEventStore: this.privateEventStore,
304
421
  simulator: this.simulator,
305
422
  contractSyncService: this.contractSyncService,
306
- messageContextService: this.messageContextService,
423
+ txResolver: this.txResolver,
424
+ hooks: this.hooks,
307
425
  });
308
426
  }
309
427
 
428
+ /** Best-effort debug function name for the class `address` runs at `anchorBlockHeader`. Used for log display only. */
429
+ async #getDebugFunctionName(
430
+ address: AztecAddress,
431
+ selector: FunctionSelector,
432
+ anchorBlockHeader: BlockHeader,
433
+ ): Promise<string> {
434
+ try {
435
+ const classId = await this.contractClassService.getCurrentClassId(address, anchorBlockHeader);
436
+ return classId ? await this.contractStore.getDebugFunctionName(classId, selector) : `${address}:${selector}`;
437
+ } catch {
438
+ return `${address}:${selector}`;
439
+ }
440
+ }
441
+
442
+ /** Best-effort debug contract name for the class `address` runs at `anchorBlockHeader`. Used for log display only. */
443
+ async #getDebugContractName(address: AztecAddress, anchorBlockHeader: BlockHeader): Promise<string | undefined> {
444
+ try {
445
+ const classId = await this.contractClassService.getCurrentClassId(address, anchorBlockHeader);
446
+ return classId ? await this.contractStore.getDebugContractName(classId) : undefined;
447
+ } catch {
448
+ return undefined;
449
+ }
450
+ }
451
+
310
452
  #contextualizeError(err: Error, ...context: string[]): Error {
311
453
  let contextStr = '';
312
454
  if (context.length > 0) {
@@ -354,29 +496,55 @@ export class PXE {
354
496
  }
355
497
 
356
498
  async #registerProtocolContracts() {
357
- const registered: Record<string, string> = {};
358
- for (const name of protocolContractNames) {
359
- const { address, instance, artifact } = await this.protocolContractsProvider.getProtocolContractArtifact(name);
360
- await this.contractStore.addContractArtifact(artifact);
361
- await this.contractStore.addContractInstance(instance);
362
- registered[name] = address.toString();
363
- }
499
+ const registered = Object.fromEntries(
500
+ await Promise.all(
501
+ protocolContractNames.map(async name => {
502
+ const { address, instance, artifact } =
503
+ await this.protocolContractsProvider.getProtocolContractArtifact(name);
504
+ await this.contractStore.addContractArtifact(artifact);
505
+ await this.contractStore.addContractInstance(instance);
506
+ return [name, address.toString()] as const;
507
+ }),
508
+ ),
509
+ );
364
510
  this.log.verbose(`Registered protocol contracts in pxe`, registered);
365
511
  }
366
512
 
513
+ async #registerPreloadedContracts() {
514
+ const contracts = await this.preloadedContractsProvider.getPreloadedContracts();
515
+ await Promise.all(
516
+ contracts.map(async ({ instance, artifact }) => {
517
+ if (artifact) {
518
+ await this.registerContractClass(artifact);
519
+ }
520
+ await this.registerContract(instance);
521
+ }),
522
+ );
523
+ this.log.verbose(`Registered preloaded contracts in pxe`, {
524
+ contracts: contracts.map(({ instance }) => instance.address.toString()),
525
+ });
526
+ }
527
+
367
528
  // Executes the entrypoint private function, as well as all nested private
368
529
  // functions that might arise.
369
- async #executePrivate(
370
- contractFunctionSimulator: ContractFunctionSimulator,
371
- txRequest: TxExecutionRequest,
372
- scopes: AccessScopes,
373
- jobId: string,
374
- ): Promise<PrivateExecutionResult> {
530
+ async #executePrivate({
531
+ contractFunctionSimulator,
532
+ txRequest,
533
+ anchorBlockHeader,
534
+ scopes,
535
+ jobId,
536
+ senderForTags,
537
+ }: {
538
+ contractFunctionSimulator: ContractFunctionSimulator;
539
+ txRequest: TxExecutionRequest;
540
+ anchorBlockHeader: BlockHeader;
541
+ scopes: AztecAddress[];
542
+ jobId: string;
543
+ senderForTags?: AztecAddress;
544
+ }): Promise<PrivateExecutionResult> {
375
545
  const { origin: contractAddress, functionSelector } = txRequest;
376
546
 
377
547
  try {
378
- const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
379
-
380
548
  await this.contractSyncService.ensureContractSynced(
381
549
  contractAddress,
382
550
  functionSelector,
@@ -388,17 +556,16 @@ export class PXE {
388
556
  );
389
557
 
390
558
  const result = await contractFunctionSimulator.run(txRequest, {
391
- contractAddress,
392
- selector: functionSelector,
393
559
  anchorBlockHeader,
394
560
  scopes,
395
561
  jobId,
562
+ senderForTags,
396
563
  });
397
564
  this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
398
565
  return result;
399
566
  } catch (err) {
400
567
  if (err instanceof SimulationError) {
401
- await enrichSimulationError(err, this.contractStore, this.log);
568
+ await enrichSimulationError(err, this.contractStore, this.contractClassService, anchorBlockHeader, this.log);
402
569
  }
403
570
  throw err;
404
571
  }
@@ -418,7 +585,7 @@ export class PXE {
418
585
  contractFunctionSimulator: ContractFunctionSimulator,
419
586
  call: FunctionCall,
420
587
  authWitnesses: AuthWitness[] | undefined,
421
- scopes: AccessScopes,
588
+ scopes: AztecAddress[],
422
589
  jobId: string,
423
590
  ) {
424
591
  try {
@@ -433,7 +600,8 @@ export class PXE {
433
600
  return { result, offchainEffects };
434
601
  } catch (err) {
435
602
  if (err instanceof SimulationError) {
436
- await enrichSimulationError(err, this.contractStore, this.log);
603
+ const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
604
+ await enrichSimulationError(err, this.contractStore, this.contractClassService, anchorBlockHeader, this.log);
437
605
  }
438
606
  throw err;
439
607
  }
@@ -445,11 +613,11 @@ export class PXE {
445
613
  * It can also be used for estimating gas in the future.
446
614
  * @param tx - The transaction to be simulated.
447
615
  */
448
- async #simulatePublicCalls(tx: Tx, skipFeeEnforcement: boolean) {
616
+ async #simulatePublicCalls(tx: Tx, skipFeeEnforcement: boolean, overrides?: SimulationOverrides) {
449
617
  // Simulating public calls can throw if the TX fails in a phase that doesn't allow reverts (setup)
450
618
  // Or return as reverted if it fails in a phase that allows reverts (app logic, teardown)
451
619
  try {
452
- const result = await this.node.simulatePublicCalls(tx, skipFeeEnforcement);
620
+ const result = await this.node.simulatePublicCalls(tx, skipFeeEnforcement, overrides);
453
621
  if (result.revertReason) {
454
622
  throw result.revertReason;
455
623
  }
@@ -457,7 +625,14 @@ export class PXE {
457
625
  } catch (err) {
458
626
  if (err instanceof SimulationError) {
459
627
  try {
460
- await enrichPublicSimulationError(err, this.contractStore, this.log);
628
+ const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
629
+ await enrichPublicSimulationError(
630
+ err,
631
+ this.contractStore,
632
+ this.contractClassService,
633
+ anchorBlockHeader,
634
+ this.log,
635
+ );
461
636
  } catch (enrichErr) {
462
637
  this.log.error(`Failed to enrich public simulation error: ${enrichErr}`);
463
638
  }
@@ -481,11 +656,16 @@ export class PXE {
481
656
  txExecutionRequest: TxExecutionRequest,
482
657
  proofCreator: PrivateKernelProver,
483
658
  privateExecutionResult: PrivateExecutionResult,
659
+ anchorBlockHeader: BlockHeader,
484
660
  config: PrivateKernelExecutionProverConfig,
485
661
  ): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
486
- const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
487
- const anchorBlockHash = await anchorBlockHeader.hash();
488
- const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHash);
662
+ const kernelOracle = new PrivateKernelOracle(
663
+ this.contractStore,
664
+ this.contractClassService,
665
+ this.keyStore,
666
+ this.node,
667
+ anchorBlockHeader,
668
+ );
489
669
  const kernelTraceProver = new PrivateKernelExecutionProver(
490
670
  kernelOracle,
491
671
  proofCreator,
@@ -496,8 +676,28 @@ export class PXE {
496
676
  return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
497
677
  }
498
678
 
679
+ /**
680
+ * Syncs with the node only when `autoSync` is enabled.
681
+ * When `autoSync` is disabled, callers (typically a wallet) are
682
+ * responsible for invoking `pxe.sync()` at the right granularity.
683
+ */
684
+ async #maybeSync(): Promise<void> {
685
+ if (this.autoSync) {
686
+ await this.blockStateSynchronizer.sync();
687
+ }
688
+ }
689
+
499
690
  // Public API
500
691
 
692
+ /**
693
+ * Triggers a sync of PXE state with the node, regardless of the `autoSync` config flag. Use this to
694
+ * batch syncs across composite flows when `autoSync` is disabled (e.g. one sync per simulate+send
695
+ * instead of one per inner PXE call). Serialized through the job queue.
696
+ */
697
+ public sync(): Promise<void> {
698
+ return this.#putInJobQueue(() => this.blockStateSynchronizer.sync());
699
+ }
700
+
501
701
  /**
502
702
  * Returns the block header up to which the PXE has synced.
503
703
  * @returns The synced block header
@@ -509,11 +709,11 @@ export class PXE {
509
709
  }
510
710
 
511
711
  /**
512
- * Returns the contract instance for a given address, if it's registered in the PXE.
712
+ * Returns the address preimage of the contract instance at a given address, if it's registered in the PXE.
513
713
  * @param address - The contract address.
514
- * @returns The contract instance if found, undefined otherwise.
714
+ * @returns The contract instance address preimage if found, undefined otherwise.
515
715
  */
516
- public getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
716
+ public getContractInstance(address: AztecAddress): Promise<ContractInstancePreimageWithAddress | undefined> {
517
717
  return this.contractStore.getContractInstance(address);
518
718
  }
519
719
 
@@ -527,19 +727,23 @@ export class PXE {
527
727
  }
528
728
 
529
729
  /**
530
- * Registers a user account in PXE given its master encryption private key.
531
- * Once a new account is registered, the PXE will trial-decrypt all published notes on
532
- * the chain and store those that correspond to the registered account. Will do nothing if the
533
- * account is already registered.
730
+ * Registers a user account in PXE.
731
+ *
732
+ * PXE holds the account's four privacy secret keys but only the *public* message-signing and fallback keys: their
733
+ * secret keys are withheld, since PXE is not trusted to hold them.
534
734
  *
535
- * @param secretKey - Secret key of the corresponding user master public key.
735
+ * Does nothing if the account is already registered.
736
+ *
737
+ * The four privacy secret keys can be retrieved later with {@link getAccountSecretKeys}.
738
+ *
739
+ * @param keys - The account's privacy keys: four secret keys plus the message-signing and fallback public keys.
536
740
  * @param partialAddress - The partial address of the account contract corresponding to the account being registered.
537
741
  * @returns The complete address of the account.
538
742
  */
539
- public async registerAccount(secretKey: Fr, partialAddress: PartialAddress): Promise<CompleteAddress> {
743
+ public async registerAccount(keys: AccountPrivacyKeys, partialAddress: PartialAddress): Promise<CompleteAddress> {
540
744
  const accounts = await this.keyStore.getAccounts();
541
- const accountCompleteAddress = await this.keyStore.addAccount(secretKey, partialAddress);
542
- if (accounts.includes(accountCompleteAddress.address)) {
745
+ const accountCompleteAddress = await this.keyStore.addAccount(keys, partialAddress);
746
+ if (accounts.some(a => a.equals(accountCompleteAddress.address))) {
543
747
  this.log.info(`Account:\n "${accountCompleteAddress.address.toString()}"\n already registered.`);
544
748
  return accountCompleteAddress;
545
749
  } else {
@@ -552,56 +756,189 @@ export class PXE {
552
756
  }
553
757
 
554
758
  /**
555
- * Registers a sender in this PXE.
759
+ * Retrieves the four privacy secret keys PXE holds for a registered account (nullifier-hiding, incoming-viewing,
760
+ * outgoing-viewing, tagging).
761
+ *
762
+ * These do NOT grant control over an account's assets, e.g. they are insufficient to impersonate the account or to
763
+ * spend notes, but they _do_ guard the account's privacy. Parties that have knowledge of these keys can decrypt all
764
+ * messages sent to the account, discover all of their on-chain activity, including notes, events, etc.
556
765
  *
557
- * After registering a new sender, the PXE will sync private logs that are tagged with this sender's address.
558
- * Will do nothing if the address is already registered.
766
+ * Security is paramount when handling these keys, which should itself be a very rare occurrence. Other than exporting
767
+ * and then importing an account into a separate PXE/wallet, there is typically no need for a wallet to ever access
768
+ * these keys. Applications should NEVER be given access to them.
559
769
  *
560
- * @param sender - Address of the sender to register.
561
- * @returns The address of the sender.
562
- * TODO: It's strange that we return the address here and I (benesjan) think we should drop the return value.
770
+ * @throws If the account is not registered.
563
771
  */
564
- public async registerSender(sender: AztecAddress): Promise<AztecAddress> {
565
- const accounts = await this.keyStore.getAccounts();
566
- if (accounts.includes(sender)) {
567
- this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
568
- return sender;
569
- }
772
+ public getAccountSecretKeys(account: AztecAddress): Promise<AccountPrivacySecretKeys> {
773
+ return this.keyStore.getAccountSecretKeys(account);
774
+ }
570
775
 
571
- const wasAdded = await this.senderAddressBookStore.addSender(sender);
776
+ /**
777
+ * Registers a source from which this PXE derives the tagging secrets it scans for to discover incoming private logs.
778
+ * See {@link TaggingSecretSource} for the meaning of each variant. Does nothing if the source is already registered.
779
+ *
780
+ * After a new source is added we clear the cache tracking which contracts have finished syncing, so every contract
781
+ * re-syncs against the new source's logs (whose notes/events could belong to any contract). Already-discovered
782
+ * notes/events are not discarded.
783
+ */
784
+ public async registerTaggingSecretSource(source: TaggingSecretSource): Promise<void> {
785
+ let wasAdded: boolean;
786
+
787
+ switch (source.kind) {
788
+ case 'address-derived':
789
+ wasAdded = await this.#registerSender(source.sender);
790
+ break;
791
+ case 'arbitrary-secret':
792
+ wasAdded = await this.#registerSharedSecret(source.recipient, 'arbitrary-secret', source.secret);
793
+ break;
794
+ case 'handshake':
795
+ wasAdded = await this.#registerSharedSecret(
796
+ source.recipient,
797
+ 'handshake',
798
+ await this.#deriveHandshakeSecret(source.recipient, source.ephPk),
799
+ );
800
+ break;
801
+ default: {
802
+ const _: never = source;
803
+ throw new Error('Unhandled tagging secret source kind');
804
+ }
805
+ }
572
806
 
573
807
  if (wasAdded) {
574
- this.log.info(`Added sender:\n ${sender.toString()}`);
575
- // Wipe the entire sync cache: the new sender's tagged logs could contain notes/events for any contract, so
576
- // all contracts must re-sync to discover them.
577
- this.contractSyncService.wipe();
578
- } else {
579
- this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
808
+ // Queued to avoid wiping while a job is in flight.
809
+ await this.#putInJobQueue(() => Promise.resolve(this.contractSyncService.wipe()));
580
810
  }
811
+ }
581
812
 
582
- return sender;
813
+ /**
814
+ * Removes a previously registered tagging secret source, identified by its registered form (see
815
+ * {@link getTaggingSecretSources}). Does nothing if it was not registered.
816
+ */
817
+ public async removeTaggingSecretSource(source: RegisteredTaggingSecretSource): Promise<void> {
818
+ switch (source.kind) {
819
+ case 'address-derived': {
820
+ const { sender } = source;
821
+ const wasRemoved = await this.taggingSecretSourcesStore.removeSender(sender);
822
+ this.log.info(
823
+ wasRemoved
824
+ ? `Removed sender:\n ${sender.toString()}`
825
+ : `Sender:\n "${sender.toString()}"\n not registered in PXE.`,
826
+ );
827
+ break;
828
+ }
829
+ case 'arbitrary-secret':
830
+ case 'handshake': {
831
+ const { kind, recipient, secret } = source;
832
+ const wasRemoved = await this.taggingSecretSourcesStore.removeSharedSecret(recipient, kind, secret);
833
+ this.log.info(
834
+ wasRemoved
835
+ ? `Removed ${kind} shared secret for recipient:\n ${recipient.toString()}`
836
+ : `No ${kind} shared secret registered for recipient:\n ${recipient.toString()}`,
837
+ );
838
+ break;
839
+ }
840
+ default: {
841
+ const _: never = source;
842
+ throw new Error('Unhandled tagging secret source kind');
843
+ }
844
+ }
583
845
  }
584
846
 
585
847
  /**
586
- * Retrieves senders registered in this PXE.
587
- * @returns Senders registered in this PXE.
848
+ * Retrieves the tagging secret sources registered in this PXE, in their registered form. Without a filter it
849
+ * returns every source; pass `{ kind }` to narrow to a single variant. See {@link RegisteredTaggingSecretSource}.
588
850
  */
589
- public getSenders(): Promise<AztecAddress[]> {
590
- return this.senderAddressBookStore.getSenders();
851
+ public getTaggingSecretSources<K extends RegisteredTaggingSecretSource['kind']>(filter: {
852
+ kind: K;
853
+ }): Promise<Extract<RegisteredTaggingSecretSource, { kind: K }>[]>;
854
+ public getTaggingSecretSources(): Promise<RegisteredTaggingSecretSource[]>;
855
+ public async getTaggingSecretSources(filter?: {
856
+ kind?: RegisteredTaggingSecretSource['kind'];
857
+ }): Promise<RegisteredTaggingSecretSource[]> {
858
+ const [senders, secrets] = await Promise.all([
859
+ this.taggingSecretSourcesStore.getSenders(),
860
+ this.taggingSecretSourcesStore.getAllSharedSecrets(),
861
+ ]);
862
+
863
+ const sources: RegisteredTaggingSecretSource[] = [
864
+ ...senders.map((sender): RegisteredTaggingSecretSource => ({ kind: 'address-derived', sender })),
865
+ ...secrets.map(({ recipient, kind, secret }): RegisteredTaggingSecretSource => ({ kind, recipient, secret })),
866
+ ];
867
+
868
+ return filter?.kind ? sources.filter(source => source.kind === filter.kind) : sources;
869
+ }
870
+
871
+ /** Registers a sender, skipping addresses that belong to a local account. Returns whether it was newly added. */
872
+ async #registerSender(address: AztecAddress): Promise<boolean> {
873
+ if (!(await address.isValid())) {
874
+ throw new Error(
875
+ `Address ${address} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register it as a sender.`,
876
+ );
877
+ }
878
+
879
+ const accounts = await this.keyStore.getAccounts();
880
+ if (accounts.some(a => a.equals(address))) {
881
+ this.log.info(`Sender:\n "${address.toString()}"\n already registered.`);
882
+ return false;
883
+ }
884
+
885
+ const wasAdded = await this.taggingSecretSourcesStore.addSender(address);
886
+ this.log.info(
887
+ wasAdded ? `Added sender:\n ${address.toString()}` : `Sender:\n "${address.toString()}"\n already registered.`,
888
+ );
889
+ return wasAdded;
591
890
  }
592
891
 
593
892
  /**
594
- * Removes a sender registered in this PXE.
595
- * @param sender - The address of the sender to remove.
893
+ * Derives the shared secret of a handshake from its ephemeral public key: the raw ECDH secret
894
+ * `S = addressSecret(recipient) * ephPk` with the forgery protection applied,
895
+ * matching the protected secret the registry stores and the derivation the recipient-side scan uses for
896
+ * handshakes discovered onchain. The ephemeral key is reconstructed from its x-coordinate with a positive y,
897
+ * matching how the protocol generates it.
898
+ *
899
+ * @throws If `ephPk` is not the x-coordinate of a Grumpkin curve point, or if `recipient` is not an account of
900
+ * this PXE, since the derivation needs its keys.
596
901
  */
597
- public async removeSender(sender: AztecAddress): Promise<void> {
598
- const wasRemoved = await this.senderAddressBookStore.removeSender(sender);
902
+ async #deriveHandshakeSecret(recipient: AztecAddress, ephPk: Fr): Promise<Point> {
903
+ let ephPkPoint: Point;
904
+ try {
905
+ ephPkPoint = await Point.fromXAndSign(ephPk, true);
906
+ } catch {
907
+ throw new Error(`Ephemeral public key x-coordinate ${ephPk} does not correspond to a Grumpkin curve point.`);
908
+ }
599
909
 
600
- if (wasRemoved) {
601
- this.log.info(`Removed sender:\n ${sender.toString()}`);
602
- } else {
603
- this.log.info(`Sender:\n "${sender.toString()}"\n not registered in PXE.`);
910
+ const completeAddress = await this.addressStore.getCompleteAddress(recipient);
911
+ if (!completeAddress || !(await this.keyStore.hasAccount(recipient))) {
912
+ throw new Error(
913
+ `Recipient ${recipient} is not an account of this PXE. A handshake's shared secret can only be derived for an account whose keys are held.`,
914
+ );
604
915
  }
916
+
917
+ const ivskM = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
918
+ const addressSecret = await computeAddressSecret(await completeAddress.getPreaddress(), ivskM);
919
+ const rawSecret = await deriveEcdhSharedSecretPoint(addressSecret, ephPkPoint);
920
+ return protectFromForgery(rawSecret, ephPkPoint, await recipient.toAddressPoint());
921
+ }
922
+
923
+ /** Registers a resolved shared secret scoped to a recipient. Returns whether it was newly added. */
924
+ async #registerSharedSecret(recipient: AztecAddress, kind: SharedSecretKind, secret: Point): Promise<boolean> {
925
+ if (!(await recipient.isValid())) {
926
+ throw new Error(
927
+ `Recipient ${recipient} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register a shared secret for it.`,
928
+ );
929
+ }
930
+
931
+ if (secret.isZero() || !secret.isOnCurve()) {
932
+ throw new Error(`Shared secret ${secret} is not a valid non-zero point on the Grumpkin curve.`);
933
+ }
934
+
935
+ const wasAdded = await this.taggingSecretSourcesStore.addSharedSecret(recipient, kind, secret);
936
+ this.log.info(
937
+ wasAdded
938
+ ? `Added ${kind} shared secret for recipient:\n ${recipient.toString()}`
939
+ : `${kind} shared secret already registered for recipient:\n ${recipient.toString()}`,
940
+ );
941
+ return wasAdded;
605
942
  }
606
943
 
607
944
  /**
@@ -625,94 +962,33 @@ export class PXE {
625
962
  */
626
963
  public async registerContractClass(artifact: ContractArtifact): Promise<void> {
627
964
  const contractClassId = await this.contractStore.addContractArtifact(artifact);
965
+ // Publishing the artifact's public function signatures to the node is part of "registering a class", so that
966
+ // node-side debugging works regardless of which entrypoint (registerContractClass or registerContract) was used.
967
+ const publicFunctionSignatures = artifact.functions
968
+ .filter(fn => fn.functionType === FunctionType.PUBLIC)
969
+ .map(fn => decodeFunctionSignature(fn.name, fn.parameters));
970
+ if (publicFunctionSignatures.length > 0) {
971
+ await this.nodeDebug?.registerContractFunctionSignatures(publicFunctionSignatures);
972
+ }
628
973
  this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
629
974
  }
630
975
 
631
976
  /**
632
- * Adds deployed contracts to the PXE. Deployed contract information is used to access the
633
- * contract code when simulating local transactions. This is automatically called by aztec.js when
634
- * deploying a contract. Dapps that wish to interact with contracts already deployed should register
635
- * these contracts in their users' PXE through this method.
977
+ * Registers a deployed contract instance so its private state can be synced and its functions simulated. The
978
+ * artifact for the class the instance runs must be registered separately via {@link registerContractClass}, before
979
+ * or after this call; registration performs no validation, so a missing or mismatched artifact only surfaces when
980
+ * the contract is later simulated. This is automatically called by aztec.js when deploying a contract.
636
981
  *
637
- * @param contract - A contract instance to register, with an optional artifact which can be omitted if the contract class has already been registered.
982
+ * @param instance - The address preimage of the contract instance to register. The address is derived from it.
983
+ * @returns The address of the registered instance.
638
984
  */
639
- public async registerContract(contract: { instance: ContractInstanceWithAddress; artifact?: ContractArtifact }) {
640
- const { instance } = contract;
641
- let { artifact } = contract;
642
-
643
- if (artifact) {
644
- // If the user provides an artifact, validate it against the expected class id and register it
645
- const contractClass = await getContractClassFromArtifact(artifact);
646
- if (!contractClass.id.equals(instance.currentContractClassId)) {
647
- throw new Error(
648
- `Artifact does not match expected class id (computed ${contractClass.id} but instance refers to ${instance.currentContractClassId})`,
649
- );
650
- }
651
- const computedAddress = await computeContractAddressFromInstance(instance);
652
- if (!computedAddress.equals(instance.address)) {
653
- throw new Error('Added a contract in which the address does not match the contract instance.');
654
- }
655
-
656
- await this.contractStore.addContractArtifact(artifact, contractClass);
657
-
658
- const publicFunctionSignatures = artifact.functions
659
- .filter(fn => fn.functionType === FunctionType.PUBLIC)
660
- .map(fn => decodeFunctionSignature(fn.name, fn.parameters));
661
- await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
662
- } else {
663
- // Otherwise, make sure there is an artifact already registered for that class id
664
- artifact = await this.contractStore.getContractArtifact(instance.currentContractClassId);
665
- if (!artifact) {
666
- throw new Error(
667
- `Artifact not found when registering an instance. Contract class: ${instance.currentContractClassId}.`,
668
- );
669
- }
670
- }
671
-
672
- await this.contractStore.addContractInstance(instance);
673
- this.log.info(
674
- `Added contract ${artifact.name} at ${instance.address.toString()} with class ${instance.currentContractClassId}`,
675
- );
676
- }
677
-
678
- /**
679
- * Updates a deployed contract in the PXE. This is used to update the contract artifact when
680
- * an update has happened, so the new code can be used in the simulation of local transactions.
681
- * This is called by aztec.js when instantiating a contract in a given address with a mismatching artifact.
682
- * @param contractAddress - The address of the contract to update.
683
- * @param artifact - The updated artifact for the contract.
684
- * @throws If the artifact's contract class is not found in the PXE or if the contract class is different from
685
- * the current one (current one from the point of view of the node to which the PXE is connected).
686
- */
687
- public updateContract(contractAddress: AztecAddress, artifact: ContractArtifact): Promise<void> {
688
- // We disable concurrently updating contracts to avoid concurrently syncing with the node, or changing a contract's
689
- // class while we're simulating it.
985
+ public registerContract(instance: ContractInstancePreimage): Promise<AztecAddress> {
986
+ // Run inside the job queue so we can't race a concurrent simulation while writing the instance to the store.
690
987
  return this.#putInJobQueue(async () => {
691
- const currentInstance = await this.contractStore.getContractInstance(contractAddress);
692
- if (!currentInstance) {
693
- throw new Error(`Instance not found when updating a contract. Contract address: ${contractAddress}.`);
694
- }
695
- const contractClass = await getContractClassFromArtifact(artifact);
696
- await this.blockStateSynchronizer.sync();
697
-
698
- const header = await this.anchorBlockStore.getBlockHeader();
699
-
700
- const currentClassId = await readCurrentClassId(contractAddress, currentInstance, this.node, header);
701
- if (!contractClass.id.equals(currentClassId)) {
702
- throw new Error('Could not update contract to a class different from the current one.');
703
- }
704
-
705
- const publicFunctionSignatures = artifact.functions
706
- .filter(fn => fn.functionType === FunctionType.PUBLIC)
707
- .map(fn => decodeFunctionSignature(fn.name, fn.parameters));
708
- await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
709
-
710
- currentInstance.currentContractClassId = contractClass.id;
711
- await Promise.all([
712
- this.contractStore.addContractArtifact(artifact, contractClass),
713
- this.contractStore.addContractInstance(currentInstance),
714
- ]);
715
- this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
988
+ const address = await computeContractAddressFromInstance(instance);
989
+ await this.contractStore.addContractInstance({ ...instance, address });
990
+ this.log.info(`Added contract at ${address}`, { address });
991
+ return address;
716
992
  });
717
993
  }
718
994
 
@@ -734,7 +1010,7 @@ export class PXE {
734
1010
  * @throws If contract code not found, or public simulation reverts.
735
1011
  * Also throws if simulatePublic is true and public simulation reverts.
736
1012
  */
737
- public proveTx(txRequest: TxExecutionRequest, scopes: AztecAddress[]): Promise<TxProvingResult> {
1013
+ public proveTx(txRequest: TxExecutionRequest, { scopes, senderForTags }: ProveTxOpts): Promise<TxProvingResult> {
738
1014
  let privateExecutionResult: PrivateExecutionResult;
739
1015
  // We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
740
1016
  // computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
@@ -742,17 +1018,25 @@ export class PXE {
742
1018
  const totalTimer = new Timer();
743
1019
  try {
744
1020
  const syncTimer = new Timer();
745
- await this.blockStateSynchronizer.sync();
1021
+ await this.#maybeSync();
1022
+ const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
746
1023
  const syncTime = syncTimer.ms();
747
1024
  const contractFunctionSimulator = this.#getSimulatorForTx();
748
- privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
1025
+ privateExecutionResult = await this.#executePrivate({
1026
+ contractFunctionSimulator,
1027
+ txRequest,
1028
+ anchorBlockHeader,
1029
+ scopes,
1030
+ jobId,
1031
+ senderForTags,
1032
+ });
749
1033
 
750
1034
  const {
751
1035
  publicInputs,
752
1036
  chonkProof,
753
1037
  executionSteps,
754
1038
  timings: { proving } = {},
755
- } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
1039
+ } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, anchorBlockHeader, {
756
1040
  simulate: false,
757
1041
  skipFeeEnforcement: false,
758
1042
  profileMode: 'none',
@@ -782,23 +1066,20 @@ export class PXE {
782
1066
  nodeRPCCalls: contractFunctionSimulator?.getStats().nodeRPCCalls,
783
1067
  });
784
1068
 
785
- // While not strictly necessary to store tagging cache contents in the DB since we sync tagging indexes from
786
- // chain before sending new logs, the sync can only see logs already included in blocks. If we send another
787
- // transaction before this one is included in a block from this PXE, and that transaction contains a log with
788
- // a tag derived from the same secret, we would reuse the tag and the transactions would be linked. Hence
789
- // storing the tags here prevents linkage of txs sent from the same PXE.
790
- const taggingIndexRangesUsedInTheTx = privateExecutionResult.entrypoint.taggingIndexRanges;
791
- if (taggingIndexRangesUsedInTheTx.length > 0) {
792
- // TODO(benesjan): The following is an expensive operation. Figure out a way to avoid it.
793
- const txHash = (await txProvingResult.toTx()).txHash;
794
-
795
- await this.senderTaggingStore.storePendingIndexes(taggingIndexRangesUsedInTheTx, txHash, jobId);
796
- this.log.debug(`Stored used tagging index ranges as sender for the tx`, {
797
- taggingIndexRangesUsedInTheTx,
798
- });
799
- } else {
800
- this.log.debug(`No tagging index ranges used in the tx`);
801
- }
1069
+ // We keep track of which tagging indices we've used in this tx so that we don't repeat them in future txs
1070
+ // (which would link them) without having to rely on this tx being mined (and us seeing the indices being used
1071
+ // onchain).
1072
+ // Note that this must happen _after_ proving as it requires the proof's public inputs, from which the kernels
1073
+ // may have removed some logs due to note-nullifier squashing - this may lead to range of tagging indices we've
1074
+ // actually used to being reduced.
1075
+ await persistSenderTaggingIndexRangesForTx(
1076
+ this.senderTaggingStore,
1077
+ privateExecutionResult.entrypoint.taggingIndexRanges,
1078
+ publicInputs,
1079
+ () => txProvingResult.getTxHash(),
1080
+ jobId,
1081
+ this.log,
1082
+ );
802
1083
 
803
1084
  return txProvingResult;
804
1085
  } catch (err: any) {
@@ -815,7 +1096,7 @@ export class PXE {
815
1096
  */
816
1097
  public profileTx(
817
1098
  txRequest: TxExecutionRequest,
818
- { profileMode, skipProofGeneration = true, scopes }: ProfileTxOpts,
1099
+ { profileMode, skipProofGeneration = true, scopes, senderForTags }: ProfileTxOpts,
819
1100
  ): Promise<TxProfileResult> {
820
1101
  // We disable concurrent profiles for consistency with simulateTx.
821
1102
  return this.#putInJobQueue(async jobId => {
@@ -834,16 +1115,25 @@ export class PXE {
834
1115
  txInfo,
835
1116
  );
836
1117
  const syncTimer = new Timer();
837
- await this.blockStateSynchronizer.sync();
1118
+ await this.#maybeSync();
1119
+ const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
838
1120
  const syncTime = syncTimer.ms();
839
1121
 
840
1122
  const contractFunctionSimulator = this.#getSimulatorForTx();
841
- const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
1123
+ const privateExecutionResult = await this.#executePrivate({
1124
+ contractFunctionSimulator,
1125
+ txRequest,
1126
+ anchorBlockHeader,
1127
+ scopes,
1128
+ jobId,
1129
+ senderForTags,
1130
+ });
842
1131
 
843
1132
  const { executionSteps, timings: { proving } = {} } = await this.#prove(
844
1133
  txRequest,
845
1134
  this.proofCreator,
846
1135
  privateExecutionResult,
1136
+ anchorBlockHeader,
847
1137
  {
848
1138
  simulate: skipProofGeneration,
849
1139
  skipFeeEnforcement: false,
@@ -911,6 +1201,7 @@ export class PXE {
911
1201
  skipKernels = true,
912
1202
  overrides,
913
1203
  scopes,
1204
+ senderForTags,
914
1205
  }: SimulateTxOpts,
915
1206
  ): Promise<TxSimulationResult> {
916
1207
  // We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
@@ -932,27 +1223,26 @@ export class PXE {
932
1223
  txInfo,
933
1224
  );
934
1225
  const syncTimer = new Timer();
935
- await this.blockStateSynchronizer.sync();
1226
+ await this.#maybeSync();
1227
+ const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
936
1228
  const syncTime = syncTimer.ms();
937
1229
 
938
- const overriddenContracts = overrides?.contracts ? new Set(Object.keys(overrides.contracts)) : undefined;
939
- const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
940
-
941
- if (hasOverriddenContracts && !skipKernels) {
1230
+ if (overrides?.contracts && Object.keys(overrides.contracts).length > 0 && !skipKernels) {
942
1231
  throw new Error(
943
1232
  'Simulating with overridden contracts is not compatible with kernel execution. Please set skipKernels to true when simulating with overridden contracts.',
944
1233
  );
945
1234
  }
946
1235
  const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
947
1236
 
948
- if (hasOverriddenContracts) {
949
- // Overridden contracts don't have a sync function, so calling sync on them would fail.
950
- // We exclude them so the sync service skips them entirely.
951
- this.contractSyncService.setExcludedFromSync(jobId, overriddenContracts);
952
- }
953
-
954
1237
  // Execution of private functions only; no proving, and no kernel logic.
955
- const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
1238
+ const privateExecutionResult = await this.#executePrivate({
1239
+ contractFunctionSimulator,
1240
+ txRequest,
1241
+ anchorBlockHeader,
1242
+ scopes,
1243
+ jobId,
1244
+ senderForTags,
1245
+ });
956
1246
 
957
1247
  let publicInputs: PrivateKernelTailCircuitPublicInputs | undefined;
958
1248
  let executionSteps: PrivateExecutionStep[] = [];
@@ -960,16 +1250,22 @@ export class PXE {
960
1250
  if (skipKernels) {
961
1251
  ({ publicInputs, executionSteps } = await generateSimulatedProvingResult(
962
1252
  privateExecutionResult,
963
- (addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
1253
+ (addr, sel) => this.#getDebugFunctionName(addr, sel, anchorBlockHeader),
964
1254
  this.node,
965
1255
  ));
966
1256
  } else {
967
1257
  // Kernel logic, plus proving of all private functions and kernels.
968
- ({ publicInputs, executionSteps } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
969
- simulate: true,
970
- skipFeeEnforcement,
971
- profileMode: 'none',
972
- }));
1258
+ ({ publicInputs, executionSteps } = await this.#prove(
1259
+ txRequest,
1260
+ this.proofCreator,
1261
+ privateExecutionResult,
1262
+ anchorBlockHeader,
1263
+ {
1264
+ simulate: true,
1265
+ skipFeeEnforcement,
1266
+ profileMode: 'none',
1267
+ },
1268
+ ));
973
1269
  }
974
1270
 
975
1271
  const privateSimulationResult = new PrivateSimulationResult(privateExecutionResult, publicInputs);
@@ -978,10 +1274,10 @@ export class PXE {
978
1274
  let publicOutput: PublicSimulationOutput | undefined;
979
1275
  if (simulatePublic && publicInputs.forPublic) {
980
1276
  const publicSimulationTimer = new Timer();
981
- publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement);
1277
+ publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement, overrides);
982
1278
  publicSimulationTime = publicSimulationTimer.ms();
983
1279
  if (publicOutput?.debugLogs?.length) {
984
- await displayDebugLogs(publicOutput.debugLogs, addr => this.contractStore.getDebugContractName(addr));
1280
+ await displayDebugLogs(publicOutput.debugLogs, addr => this.#getDebugContractName(addr, anchorBlockHeader));
985
1281
  }
986
1282
  }
987
1283
 
@@ -1043,7 +1339,7 @@ export class PXE {
1043
1339
  inspect(txRequest),
1044
1340
  `simulatePublic=${simulatePublic}`,
1045
1341
  `skipTxValidation=${skipTxValidation}`,
1046
- `scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map(s => s.toString()).join(', ')}`,
1342
+ `scopes=${scopes.map(s => s.toString()).join(', ')}`,
1047
1343
  );
1048
1344
  }
1049
1345
  });
@@ -1055,7 +1351,7 @@ export class PXE {
1055
1351
  */
1056
1352
  public executeUtility(
1057
1353
  call: FunctionCall,
1058
- { authwits, scopes }: ExecuteUtilityOpts = { scopes: 'ALL_SCOPES' },
1354
+ { authwits, scopes }: ExecuteUtilityOpts = { scopes: [] },
1059
1355
  ): Promise<UtilityExecutionResult> {
1060
1356
  // We disable concurrent executions since those might execute oracles which read and write to the PXE stores (e.g.
1061
1357
  // to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
@@ -1064,7 +1360,7 @@ export class PXE {
1064
1360
  try {
1065
1361
  const totalTimer = new Timer();
1066
1362
  const syncTimer = new Timer();
1067
- await this.blockStateSynchronizer.sync();
1363
+ await this.#maybeSync();
1068
1364
  const syncTime = syncTimer.ms();
1069
1365
  const functionTimer = new Timer();
1070
1366
  const contractFunctionSimulator = this.#getSimulatorForTx();
@@ -1113,7 +1409,7 @@ export class PXE {
1113
1409
  throw this.#contextualizeError(
1114
1410
  err,
1115
1411
  `executeUtility ${to}:${name}(${stringifiedArgs})`,
1116
- `scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map(s => s.toString()).join(', ')}`,
1412
+ `scopes=${scopes.map(s => s.toString()).join(', ')}`,
1117
1413
  );
1118
1414
  }
1119
1415
  });
@@ -1139,7 +1435,7 @@ export class PXE {
1139
1435
  let anchorBlockNumber: BlockNumber;
1140
1436
 
1141
1437
  await this.#putInJobQueue(async jobId => {
1142
- await this.blockStateSynchronizer.sync();
1438
+ await this.#maybeSync();
1143
1439
 
1144
1440
  const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
1145
1441
  anchorBlockNumber = anchorBlockHeader.getBlockNumber();
@@ -1172,6 +1468,7 @@ export class PXE {
1172
1468
  */
1173
1469
  public async stop(): Promise<void> {
1174
1470
  await this.jobQueue.end();
1471
+ await this.blockStateSynchronizer.stop();
1175
1472
  await this.db.close();
1176
1473
  }
1177
1474
  }