@aztec/pxe 0.0.1-commit.993d240 → 0.0.1-commit.9a89641

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 (451) hide show
  1. package/dest/bin/check_oracle_version.d.ts +2 -12
  2. package/dest/bin/check_oracle_version.d.ts.map +1 -1
  3. package/dest/bin/check_oracle_version.js +9 -122
  4. package/dest/bin/index.d.ts +2 -2
  5. package/dest/bin/index.d.ts.map +1 -1
  6. package/dest/bin/index.js +1 -1
  7. package/dest/bin/oracle_version_helpers.d.ts +20 -0
  8. package/dest/bin/oracle_version_helpers.d.ts.map +1 -0
  9. package/dest/bin/oracle_version_helpers.js +25 -0
  10. package/dest/block_synchronizer/block_stream_source.d.ts +5 -5
  11. package/dest/block_synchronizer/block_stream_source.d.ts.map +1 -1
  12. package/dest/block_synchronizer/block_stream_source.js +4 -29
  13. package/dest/block_synchronizer/block_synchronizer.d.ts +17 -15
  14. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  15. package/dest/block_synchronizer/block_synchronizer.js +41 -18
  16. package/dest/config/index.d.ts +2 -1
  17. package/dest/config/index.d.ts.map +1 -1
  18. package/dest/config/index.js +1 -0
  19. package/dest/config/package_info.js +1 -1
  20. package/dest/contract/contract_class_service.d.ts +24 -0
  21. package/dest/contract/contract_class_service.d.ts.map +1 -0
  22. package/dest/contract/contract_class_service.js +36 -0
  23. package/dest/contract/contract_sync_service.d.ts +48 -0
  24. package/dest/contract/contract_sync_service.d.ts.map +1 -0
  25. package/dest/{contract_sync → contract}/contract_sync_service.js +26 -45
  26. package/dest/contract/helpers.d.ts +7 -0
  27. package/dest/contract/helpers.d.ts.map +1 -0
  28. package/dest/contract/helpers.js +20 -0
  29. package/dest/contract/skip_sync_contracts.d.ts +11 -0
  30. package/dest/contract/skip_sync_contracts.d.ts.map +1 -0
  31. package/dest/contract/skip_sync_contracts.js +18 -0
  32. package/dest/contract_function_simulator/anchored_contract_data.d.ts +36 -0
  33. package/dest/contract_function_simulator/anchored_contract_data.d.ts.map +1 -0
  34. package/dest/contract_function_simulator/anchored_contract_data.js +54 -0
  35. package/dest/contract_function_simulator/contract_function_simulator.d.ts +19 -25
  36. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  37. package/dest/contract_function_simulator/contract_function_simulator.js +63 -49
  38. package/dest/contract_function_simulator/execution_note_cache.d.ts +4 -10
  39. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  40. package/dest/contract_function_simulator/execution_note_cache.js +8 -28
  41. package/dest/contract_function_simulator/index.d.ts +24 -6
  42. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  43. package/dest/contract_function_simulator/index.js +9 -4
  44. package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts +8 -27
  45. package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts.map +1 -1
  46. package/dest/contract_function_simulator/noir-structs/bounded_vec.js +8 -23
  47. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts +9 -0
  48. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts.map +1 -0
  49. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.js +1 -0
  50. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts +7 -0
  51. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts.map +1 -0
  52. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.js +1 -0
  53. package/dest/contract_function_simulator/noir-structs/ephemeral_array.d.ts +37 -0
  54. package/dest/contract_function_simulator/noir-structs/ephemeral_array.d.ts.map +1 -0
  55. package/dest/contract_function_simulator/noir-structs/ephemeral_array.js +59 -0
  56. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -2
  57. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  58. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +2 -2
  59. package/dest/contract_function_simulator/noir-structs/fact.d.ts +16 -0
  60. package/dest/contract_function_simulator/noir-structs/fact.d.ts.map +1 -0
  61. package/dest/contract_function_simulator/noir-structs/fact.js +6 -0
  62. package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts +27 -0
  63. package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts.map +1 -0
  64. package/dest/contract_function_simulator/noir-structs/fact_collection.js +31 -0
  65. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +11 -12
  66. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
  67. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +6 -49
  68. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +10 -8
  69. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  70. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -60
  71. package/dest/contract_function_simulator/noir-structs/note_data.d.ts +27 -0
  72. package/dest/contract_function_simulator/noir-structs/note_data.d.ts.map +1 -0
  73. package/dest/contract_function_simulator/noir-structs/note_data.js +3 -0
  74. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -2
  75. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  76. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +3 -3
  77. package/dest/contract_function_simulator/noir-structs/option.d.ts +9 -11
  78. package/dest/contract_function_simulator/noir-structs/option.d.ts.map +1 -1
  79. package/dest/contract_function_simulator/noir-structs/option.js +18 -13
  80. package/dest/contract_function_simulator/noir-structs/origin_block.d.ts +11 -0
  81. package/dest/contract_function_simulator/noir-structs/origin_block.d.ts.map +1 -0
  82. package/dest/contract_function_simulator/noir-structs/origin_block.js +5 -0
  83. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts +11 -0
  84. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts.map +1 -0
  85. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.js +4 -0
  86. package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +8 -0
  87. package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts.map +1 -0
  88. package/dest/contract_function_simulator/noir-structs/provided_secret.js +1 -0
  89. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts +28 -0
  90. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts.map +1 -0
  91. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.js +50 -0
  92. package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts +19 -0
  93. package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts.map +1 -0
  94. package/dest/contract_function_simulator/noir-structs/resolved_tx.js +9 -0
  95. package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts +15 -0
  96. package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts.map +1 -0
  97. package/dest/contract_function_simulator/noir-structs/tx_effect_data.js +5 -0
  98. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +6 -11
  99. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
  100. package/dest/contract_function_simulator/noir-structs/utility_context.js +1 -20
  101. package/dest/contract_function_simulator/oracle/acir_callback.d.ts +21 -0
  102. package/dest/contract_function_simulator/oracle/acir_callback.d.ts.map +1 -0
  103. package/dest/contract_function_simulator/oracle/acir_callback.js +115 -0
  104. package/dest/contract_function_simulator/oracle/index.d.ts +2 -13
  105. package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -1
  106. package/dest/contract_function_simulator/oracle/index.js +1 -1
  107. package/dest/contract_function_simulator/oracle/interfaces.d.ts +15 -114
  108. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  109. package/dest/contract_function_simulator/oracle/interfaces.js +2 -2
  110. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts +39 -0
  111. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts.map +1 -0
  112. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.js +107 -0
  113. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -14
  114. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  115. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -24
  116. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +92 -100
  117. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
  118. package/dest/contract_function_simulator/oracle/oracle_registry.js +296 -479
  119. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +274 -0
  120. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -0
  121. package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +1253 -0
  122. package/dest/contract_function_simulator/oracle/private_execution.d.ts +1 -1
  123. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  124. package/dest/contract_function_simulator/oracle/private_execution.js +2 -3
  125. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +32 -21
  126. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  127. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +152 -49
  128. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +97 -37
  129. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  130. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +376 -138
  131. package/dest/contract_function_simulator/transient_array_service.d.ts +31 -0
  132. package/dest/contract_function_simulator/transient_array_service.d.ts.map +1 -0
  133. package/dest/contract_function_simulator/transient_array_service.js +62 -0
  134. package/dest/debug/pxe_debug_utils.d.ts +2 -2
  135. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  136. package/dest/entrypoints/client/bundle/index.d.ts +2 -1
  137. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  138. package/dest/entrypoints/client/bundle/index.js +1 -0
  139. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  140. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  141. package/dest/entrypoints/client/bundle/utils.js +17 -6
  142. package/dest/entrypoints/client/lazy/index.d.ts +2 -1
  143. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  144. package/dest/entrypoints/client/lazy/index.js +1 -0
  145. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  146. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  147. package/dest/entrypoints/client/lazy/utils.js +17 -6
  148. package/dest/entrypoints/client/store.d.ts +14 -0
  149. package/dest/entrypoints/client/store.d.ts.map +1 -0
  150. package/dest/entrypoints/client/store.js +42 -0
  151. package/dest/entrypoints/pxe_creation_options.d.ts +9 -3
  152. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  153. package/dest/entrypoints/server/index.d.ts +6 -3
  154. package/dest/entrypoints/server/index.d.ts.map +1 -1
  155. package/dest/entrypoints/server/index.js +4 -2
  156. package/dest/entrypoints/server/store.d.ts +18 -0
  157. package/dest/entrypoints/server/store.d.ts.map +1 -0
  158. package/dest/entrypoints/server/store.js +28 -0
  159. package/dest/entrypoints/server/utils.d.ts +1 -1
  160. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  161. package/dest/entrypoints/server/utils.js +16 -4
  162. package/dest/error_enriching.d.ts +5 -3
  163. package/dest/error_enriching.d.ts.map +1 -1
  164. package/dest/error_enriching.js +13 -11
  165. package/dest/events/event_service.d.ts +13 -6
  166. package/dest/events/event_service.d.ts.map +1 -1
  167. package/dest/events/event_service.js +13 -13
  168. package/dest/hooks/execution_hooks.d.ts +31 -11
  169. package/dest/hooks/execution_hooks.d.ts.map +1 -1
  170. package/dest/hooks/execution_hooks.js +3 -3
  171. package/dest/hooks/index.d.ts +4 -3
  172. package/dest/hooks/index.d.ts.map +1 -1
  173. package/dest/hooks/index.js +1 -0
  174. package/dest/hooks/resolve_custom_request.d.ts +23 -0
  175. package/dest/hooks/resolve_custom_request.d.ts.map +1 -0
  176. package/dest/hooks/resolve_custom_request.js +3 -0
  177. package/dest/hooks/resolve_tagging_secret_strategy.d.ts +50 -0
  178. package/dest/hooks/resolve_tagging_secret_strategy.d.ts.map +1 -0
  179. package/dest/hooks/resolve_tagging_secret_strategy.js +3 -0
  180. package/dest/logs/log_service.d.ts +18 -8
  181. package/dest/logs/log_service.d.ts.map +1 -1
  182. package/dest/logs/log_service.js +93 -45
  183. package/dest/messages/tx_resolver_service.d.ts +28 -0
  184. package/dest/messages/tx_resolver_service.d.ts.map +1 -0
  185. package/dest/messages/tx_resolver_service.js +61 -0
  186. package/dest/node/benchmarked_node.d.ts +20 -0
  187. package/dest/node/benchmarked_node.d.ts.map +1 -0
  188. package/dest/node/benchmarked_node.js +94 -0
  189. package/dest/node/caching_aztec_node.d.ts +24 -0
  190. package/dest/node/caching_aztec_node.d.ts.map +1 -0
  191. package/dest/node/caching_aztec_node.js +267 -0
  192. package/dest/notes/note_service.d.ts +13 -7
  193. package/dest/notes/note_service.d.ts.map +1 -1
  194. package/dest/notes/note_service.js +10 -10
  195. package/dest/oracle_version.d.ts +3 -3
  196. package/dest/oracle_version.js +8 -8
  197. package/dest/private_kernel/batch_planner.d.ts +1 -1
  198. package/dest/private_kernel/batch_planner.d.ts.map +1 -1
  199. package/dest/private_kernel/batch_planner.js +1 -1
  200. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +1 -1
  201. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  202. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +6 -2
  203. package/dest/private_kernel/hints/test_utils.js +1 -1
  204. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  205. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  206. package/dest/private_kernel/private_kernel_execution_prover.js +61 -40
  207. package/dest/private_kernel/private_kernel_oracle.d.ts +4 -2
  208. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  209. package/dest/private_kernel/private_kernel_oracle.js +17 -5
  210. package/dest/pxe.d.ts +114 -48
  211. package/dest/pxe.d.ts.map +1 -1
  212. package/dest/pxe.js +251 -148
  213. package/dest/storage/allowed_scopes.d.ts +6 -0
  214. package/dest/storage/allowed_scopes.d.ts.map +1 -0
  215. package/dest/storage/allowed_scopes.js +7 -0
  216. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -6
  217. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
  218. package/dest/storage/anchor_block_store/anchor_block_store.js +8 -6
  219. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +1 -1
  220. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -1
  221. package/dest/storage/backwards_compatibility_tests/schema_tests.js +129 -49
  222. package/dest/storage/capsule_store/capsule_service.d.ts +1 -1
  223. package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -1
  224. package/dest/storage/capsule_store/capsule_service.js +6 -9
  225. package/dest/storage/contract_store/contract_store.d.ts +27 -24
  226. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  227. package/dest/storage/contract_store/contract_store.js +66 -77
  228. package/dest/storage/fact_store/fact_service.d.ts +22 -0
  229. package/dest/storage/fact_store/fact_service.d.ts.map +1 -0
  230. package/dest/storage/fact_store/fact_service.js +45 -0
  231. package/dest/storage/fact_store/fact_store.d.ts +95 -0
  232. package/dest/storage/fact_store/fact_store.d.ts.map +1 -0
  233. package/dest/storage/fact_store/fact_store.js +408 -0
  234. package/dest/storage/fact_store/fact_store_keys.d.ts +34 -0
  235. package/dest/storage/fact_store/fact_store_keys.d.ts.map +1 -0
  236. package/dest/storage/fact_store/fact_store_keys.js +50 -0
  237. package/dest/storage/fact_store/index.d.ts +6 -0
  238. package/dest/storage/fact_store/index.d.ts.map +1 -0
  239. package/dest/storage/fact_store/index.js +4 -0
  240. package/dest/storage/fact_store/origin_state.d.ts +59 -0
  241. package/dest/storage/fact_store/origin_state.d.ts.map +1 -0
  242. package/dest/storage/fact_store/origin_state.js +60 -0
  243. package/dest/storage/fact_store/stored_fact.d.ts +32 -0
  244. package/dest/storage/fact_store/stored_fact.d.ts.map +1 -0
  245. package/dest/storage/fact_store/stored_fact.js +64 -0
  246. package/dest/storage/index.d.ts +3 -2
  247. package/dest/storage/index.d.ts.map +1 -1
  248. package/dest/storage/index.js +2 -1
  249. package/dest/storage/metadata.d.ts +2 -2
  250. package/dest/storage/metadata.d.ts.map +1 -1
  251. package/dest/storage/metadata.js +1 -1
  252. package/dest/storage/note_store/note_store.d.ts +42 -33
  253. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  254. package/dest/storage/note_store/note_store.js +197 -168
  255. package/dest/storage/note_store/stored_note.d.ts +3 -8
  256. package/dest/storage/note_store/stored_note.d.ts.map +1 -1
  257. package/dest/storage/note_store/stored_note.js +4 -20
  258. package/dest/storage/open_pxe_stores.d.ts +5 -3
  259. package/dest/storage/open_pxe_stores.d.ts.map +1 -1
  260. package/dest/storage/open_pxe_stores.js +5 -3
  261. package/dest/storage/private_event_store/private_event_store.d.ts +13 -16
  262. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  263. package/dest/storage/private_event_store/private_event_store.js +40 -43
  264. package/dest/storage/store_identity.d.ts +35 -0
  265. package/dest/storage/store_identity.d.ts.map +1 -0
  266. package/dest/storage/store_identity.js +44 -0
  267. package/dest/storage/tagging_store/index.d.ts +2 -2
  268. package/dest/storage/tagging_store/index.d.ts.map +1 -1
  269. package/dest/storage/tagging_store/index.js +1 -1
  270. package/dest/storage/tagging_store/sender_tagging_store.d.ts +41 -10
  271. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  272. package/dest/storage/tagging_store/sender_tagging_store.js +81 -29
  273. package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts +51 -0
  274. package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts.map +1 -0
  275. package/dest/storage/tagging_store/tagging_secret_sources_store.js +105 -0
  276. package/dest/tagging/constants.d.ts +11 -2
  277. package/dest/tagging/constants.d.ts.map +1 -1
  278. package/dest/tagging/constants.js +38 -10
  279. package/dest/tagging/get_all_logs_by_tags.d.ts +29 -8
  280. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
  281. package/dest/tagging/get_all_logs_by_tags.js +29 -10
  282. package/dest/tagging/index.d.ts +3 -3
  283. package/dest/tagging/index.d.ts.map +1 -1
  284. package/dest/tagging/index.js +2 -2
  285. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +27 -9
  286. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -1
  287. package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +104 -33
  288. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +6 -3
  289. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  290. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +23 -36
  291. package/dest/tagging/sender_sync/utils/classify_pending_txs.d.ts +22 -0
  292. package/dest/tagging/sender_sync/utils/classify_pending_txs.d.ts.map +1 -0
  293. package/dest/tagging/sender_sync/utils/classify_pending_txs.js +61 -0
  294. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +15 -5
  295. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  296. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +36 -35
  297. package/dest/tagging/sender_sync/utils/resolve_pending_txs.d.ts +29 -0
  298. package/dest/tagging/sender_sync/utils/resolve_pending_txs.d.ts.map +1 -0
  299. package/dest/tagging/sender_sync/utils/resolve_pending_txs.js +41 -0
  300. package/dest/tagging/sender_sync/utils/test_utils.d.ts +16 -0
  301. package/dest/tagging/sender_sync/utils/test_utils.d.ts.map +1 -0
  302. package/dest/tagging/sender_sync/utils/test_utils.js +24 -0
  303. package/dest/tagging/testing/tag_query_test_utils.d.ts +6 -0
  304. package/dest/tagging/testing/tag_query_test_utils.d.ts.map +1 -0
  305. package/dest/tagging/testing/tag_query_test_utils.js +10 -0
  306. package/package.json +17 -17
  307. package/src/bin/check_oracle_version.ts +8 -151
  308. package/src/bin/index.ts +1 -1
  309. package/src/bin/oracle_version_helpers.ts +30 -0
  310. package/src/block_synchronizer/block_stream_source.ts +6 -45
  311. package/src/block_synchronizer/block_synchronizer.ts +54 -30
  312. package/src/config/index.ts +1 -0
  313. package/src/config/package_info.ts +1 -1
  314. package/src/contract/contract_class_service.ts +45 -0
  315. package/src/{contract_sync → contract}/contract_sync_service.ts +37 -50
  316. package/src/contract/helpers.ts +35 -0
  317. package/src/contract/skip_sync_contracts.ts +23 -0
  318. package/src/contract_function_simulator/anchored_contract_data.ts +74 -0
  319. package/src/contract_function_simulator/contract_function_simulator.ts +96 -59
  320. package/src/contract_function_simulator/execution_note_cache.ts +8 -29
  321. package/src/contract_function_simulator/index.ts +87 -5
  322. package/src/contract_function_simulator/noir-structs/bounded_vec.ts +12 -24
  323. package/src/contract_function_simulator/noir-structs/contract_class_log_data.ts +9 -0
  324. package/src/contract_function_simulator/noir-structs/embedded_curve_point.ts +4 -0
  325. package/src/contract_function_simulator/noir-structs/ephemeral_array.ts +66 -0
  326. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +3 -3
  327. package/src/contract_function_simulator/noir-structs/fact.ts +13 -0
  328. package/src/contract_function_simulator/noir-structs/fact_collection.ts +64 -0
  329. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +20 -46
  330. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +13 -60
  331. package/src/contract_function_simulator/noir-structs/note_data.ts +27 -0
  332. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +4 -4
  333. package/src/contract_function_simulator/noir-structs/option.ts +17 -11
  334. package/src/contract_function_simulator/noir-structs/origin_block.ts +8 -0
  335. package/src/contract_function_simulator/noir-structs/pending_tagged_log.ts +12 -0
  336. package/src/contract_function_simulator/noir-structs/provided_secret.ts +5 -0
  337. package/src/contract_function_simulator/noir-structs/resolved_tagging_strategy.ts +66 -0
  338. package/src/contract_function_simulator/noir-structs/resolved_tx.ts +19 -0
  339. package/src/contract_function_simulator/noir-structs/tx_effect_data.ts +16 -0
  340. package/src/contract_function_simulator/noir-structs/utility_context.ts +5 -17
  341. package/src/contract_function_simulator/oracle/acir_callback.ts +154 -0
  342. package/src/contract_function_simulator/oracle/index.ts +1 -15
  343. package/src/contract_function_simulator/oracle/interfaces.ts +11 -189
  344. package/src/contract_function_simulator/oracle/legacy_oracle_registry.ts +147 -0
  345. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +6 -21
  346. package/src/contract_function_simulator/oracle/oracle_registry.ts +289 -483
  347. package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +1067 -0
  348. package/src/contract_function_simulator/oracle/private_execution.ts +2 -3
  349. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +190 -61
  350. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +556 -174
  351. package/src/contract_function_simulator/transient_array_service.ts +91 -0
  352. package/src/debug/pxe_debug_utils.ts +1 -1
  353. package/src/entrypoints/client/bundle/index.ts +1 -0
  354. package/src/entrypoints/client/bundle/utils.ts +24 -5
  355. package/src/entrypoints/client/lazy/index.ts +1 -0
  356. package/src/entrypoints/client/lazy/utils.ts +24 -5
  357. package/src/entrypoints/client/store.ts +54 -0
  358. package/src/entrypoints/pxe_creation_options.ts +8 -2
  359. package/src/entrypoints/server/index.ts +6 -2
  360. package/src/entrypoints/server/store.ts +47 -0
  361. package/src/entrypoints/server/utils.ts +31 -9
  362. package/src/error_enriching.ts +27 -11
  363. package/src/events/event_service.ts +24 -14
  364. package/src/hooks/execution_hooks.ts +32 -12
  365. package/src/hooks/index.ts +8 -2
  366. package/src/hooks/resolve_custom_request.ts +24 -0
  367. package/src/hooks/resolve_tagging_secret_strategy.ts +60 -0
  368. package/src/logs/log_service.ts +122 -61
  369. package/src/messages/tx_resolver_service.ts +80 -0
  370. package/src/node/benchmarked_node.ts +140 -0
  371. package/src/node/caching_aztec_node.ts +406 -0
  372. package/src/notes/note_service.ts +20 -14
  373. package/src/oracle_version.ts +8 -8
  374. package/src/private_kernel/batch_planner.ts +0 -1
  375. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +11 -1
  376. package/src/private_kernel/hints/test_utils.ts +1 -1
  377. package/src/private_kernel/private_kernel_execution_prover.ts +112 -56
  378. package/src/private_kernel/private_kernel_oracle.ts +23 -4
  379. package/src/pxe.ts +357 -172
  380. package/src/storage/allowed_scopes.ts +14 -0
  381. package/src/storage/anchor_block_store/anchor_block_store.ts +8 -6
  382. package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +6 -6
  383. package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +1 -1
  384. package/src/storage/backwards_compatibility_tests/__snapshots__/FactStore.json +40 -0
  385. package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +12 -12
  386. package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +9 -15
  387. package/src/storage/backwards_compatibility_tests/__snapshots__/NoteStore.json +24 -4
  388. package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +11 -3
  389. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +12 -4
  390. package/src/storage/backwards_compatibility_tests/__snapshots__/TaggingSecretSourcesStore.json +30 -0
  391. package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +29 -9
  392. package/src/storage/backwards_compatibility_tests/schema_tests.ts +141 -50
  393. package/src/storage/capsule_store/capsule_service.ts +8 -13
  394. package/src/storage/contract_store/contract_store.ts +88 -94
  395. package/src/storage/fact_store/fact_service.ts +69 -0
  396. package/src/storage/fact_store/fact_store.ts +487 -0
  397. package/src/storage/fact_store/fact_store_keys.ts +75 -0
  398. package/src/storage/fact_store/index.ts +15 -0
  399. package/src/storage/fact_store/origin_state.ts +84 -0
  400. package/src/storage/fact_store/stored_fact.ts +80 -0
  401. package/src/storage/index.ts +2 -1
  402. package/src/storage/metadata.ts +1 -1
  403. package/src/storage/note_store/note_store.ts +226 -187
  404. package/src/storage/note_store/stored_note.ts +5 -27
  405. package/src/storage/open_pxe_stores.ts +6 -3
  406. package/src/storage/private_event_store/private_event_store.ts +49 -55
  407. package/src/storage/store_identity.ts +72 -0
  408. package/src/storage/tagging_store/index.ts +1 -1
  409. package/src/storage/tagging_store/sender_tagging_store.ts +113 -41
  410. package/src/storage/tagging_store/tagging_secret_sources_store.ts +138 -0
  411. package/src/tagging/constants.ts +42 -10
  412. package/src/tagging/get_all_logs_by_tags.ts +47 -11
  413. package/src/tagging/index.ts +7 -2
  414. package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +161 -46
  415. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +27 -57
  416. package/src/tagging/sender_sync/utils/classify_pending_txs.ts +91 -0
  417. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +46 -40
  418. package/src/tagging/sender_sync/utils/resolve_pending_txs.ts +64 -0
  419. package/src/tagging/sender_sync/utils/test_utils.ts +46 -0
  420. package/src/tagging/testing/tag_query_test_utils.ts +11 -0
  421. package/dest/contract_function_simulator/benchmarked_node.d.ts +0 -9
  422. package/dest/contract_function_simulator/benchmarked_node.d.ts.map +0 -1
  423. package/dest/contract_function_simulator/benchmarked_node.js +0 -77
  424. package/dest/contract_function_simulator/oracle/oracle.d.ts +0 -89
  425. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +0 -1
  426. package/dest/contract_function_simulator/oracle/oracle.js +0 -552
  427. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +0 -6
  428. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +0 -1
  429. package/dest/contract_function_simulator/proxied_contract_data_source.js +0 -51
  430. package/dest/contract_sync/contract_sync_service.d.ts +0 -42
  431. package/dest/contract_sync/contract_sync_service.d.ts.map +0 -1
  432. package/dest/contract_sync/helpers.d.ts +0 -27
  433. package/dest/contract_sync/helpers.d.ts.map +0 -1
  434. package/dest/contract_sync/helpers.js +0 -53
  435. package/dest/messages/message_context_service.d.ts +0 -17
  436. package/dest/messages/message_context_service.d.ts.map +0 -1
  437. package/dest/messages/message_context_service.js +0 -38
  438. package/dest/storage/tagging_store/sender_address_book_store.d.ts +0 -14
  439. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +0 -1
  440. package/dest/storage/tagging_store/sender_address_book_store.js +0 -36
  441. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +0 -17
  442. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +0 -1
  443. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +0 -60
  444. package/src/contract_function_simulator/benchmarked_node.ts +0 -103
  445. package/src/contract_function_simulator/oracle/oracle.ts +0 -711
  446. package/src/contract_function_simulator/proxied_contract_data_source.ts +0 -60
  447. package/src/contract_sync/helpers.ts +0 -86
  448. package/src/messages/message_context_service.ts +0 -45
  449. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderAddressBookStore.json +0 -16
  450. package/src/storage/tagging_store/sender_address_book_store.ts +0 -48
  451. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +0 -66
package/src/pxe.ts CHANGED
@@ -1,10 +1,12 @@
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
11
  import { type ProtocolContractsProvider, protocolContractNames } from '@aztec/protocol-contracts';
10
12
  import type { CircuitSimulator } from '@aztec/simulator/client';
@@ -12,6 +14,7 @@ import {
12
14
  type ContractArtifact,
13
15
  EventSelector,
14
16
  FunctionCall,
17
+ type FunctionSelector,
15
18
  FunctionType,
16
19
  decodeFunctionSignature,
17
20
  } from '@aztec/stdlib/abi';
@@ -20,18 +23,21 @@ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
20
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,
@@ -54,21 +60,20 @@ import { inspect } from 'util';
54
60
 
55
61
  import { BlockSynchronizer } from './block_synchronizer/index.js';
56
62
  import type { PXEConfig } from './config/index.js';
57
- import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
63
+ import { ContractClassService } from './contract/contract_class_service.js';
64
+ import { ContractSyncService } from './contract/contract_sync_service.js';
58
65
  import {
59
66
  ContractFunctionSimulator,
60
67
  generateSimulatedProvingResult,
61
68
  } from './contract_function_simulator/contract_function_simulator.js';
62
- import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
63
69
  import { displayDebugLogs } from './contract_logging.js';
64
- import { ContractSyncService } from './contract_sync/contract_sync_service.js';
65
- import { readCurrentClassId } from './contract_sync/helpers.js';
66
70
  import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
67
71
  import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
68
72
  import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
69
73
  import type { ExecutionHooks } from './hooks/index.js';
70
74
  import { JobCoordinator } from './job_coordinator/job_coordinator.js';
71
- import { MessageContextService } from './messages/message_context_service.js';
75
+ import { TxResolverService } from './messages/tx_resolver_service.js';
76
+ import { type CachingAztecNode, withCache } from './node/caching_aztec_node.js';
72
77
  import {
73
78
  PrivateKernelExecutionProver,
74
79
  type PrivateKernelExecutionProverConfig,
@@ -78,12 +83,16 @@ 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';
82
88
  import { openPxeStores } from './storage/open_pxe_stores.js';
83
89
  import { PrivateEventStore } from './storage/private_event_store/private_event_store.js';
84
90
  import { RecipientTaggingStore } from './storage/tagging_store/recipient_tagging_store.js';
85
- import { SenderAddressBookStore } from './storage/tagging_store/sender_address_book_store.js';
86
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';
87
96
  import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
88
97
 
89
98
  export type PackedPrivateEvent = InTx & {
@@ -160,6 +169,11 @@ export type PreloadedContractsProvider = {
160
169
  export type PXECreateArgs = {
161
170
  /** The Aztec node to connect to. */
162
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;
163
177
  /** The key-value store for persisting PXE state. */
164
178
  store: AztecAsyncKVStore;
165
179
  /** The prover for generating private kernel proofs. */
@@ -168,7 +182,11 @@ export type PXECreateArgs = {
168
182
  simulator: CircuitSimulator;
169
183
  /** Provider for protocol contract artifacts and instances. */
170
184
  protocolContractsProvider: ProtocolContractsProvider;
171
- /** Provider for the "nice to have" contracts the PXE preloads. */
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
+ */
172
190
  preloadedContractsProvider: PreloadedContractsProvider;
173
191
  /** PXE configuration options. */
174
192
  config: PXEConfig;
@@ -178,27 +196,58 @@ export type PXECreateArgs = {
178
196
  hooks?: ExecutionHooks;
179
197
  };
180
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
+
181
227
  /**
182
228
  * Private eXecution Environment (PXE) is a library used by wallets to simulate private phase of transactions and to
183
229
  * manage private state of users.
184
230
  */
185
231
  export class PXE {
186
232
  private constructor(
187
- private node: AztecNode,
233
+ private node: CachingAztecNode,
234
+ private nodeDebug: AztecNodeDebug | undefined,
188
235
  private db: AztecAsyncKVStore,
189
236
  private blockStateSynchronizer: BlockSynchronizer,
190
237
  private keyStore: KeyStore,
191
238
  private contractStore: ContractStore,
192
239
  private noteStore: NoteStore,
193
240
  private capsuleStore: CapsuleStore,
241
+ private factStore: FactStore,
194
242
  private anchorBlockStore: AnchorBlockStore,
195
243
  private senderTaggingStore: SenderTaggingStore,
196
- private senderAddressBookStore: SenderAddressBookStore,
244
+ private taggingSecretSourcesStore: TaggingSecretSourcesStore,
197
245
  private recipientTaggingStore: RecipientTaggingStore,
198
246
  private addressStore: AddressStore,
199
247
  private privateEventStore: PrivateEventStore,
200
248
  private contractSyncService: ContractSyncService,
201
- private messageContextService: MessageContextService,
249
+ private contractClassService: ContractClassService,
250
+ private txResolver: TxResolverService,
202
251
  private l2TipsStore: L2TipsProvider,
203
252
  private simulator: CircuitSimulator,
204
253
  private proverEnabled: boolean,
@@ -222,6 +271,7 @@ export class PXE {
222
271
  */
223
272
  public static async create({
224
273
  node,
274
+ nodeDebug,
225
275
  store,
226
276
  proofCreator,
227
277
  simulator,
@@ -258,26 +308,34 @@ export class PXE {
258
308
  noteStore,
259
309
  anchorBlockStore,
260
310
  senderTaggingStore,
261
- senderAddressBookStore,
311
+ taggingSecretSourcesStore,
262
312
  recipientTaggingStore,
263
313
  capsuleStore,
264
314
  keyStore,
265
315
  l2TipsStore,
316
+ factStore,
266
317
  } = openPxeStores(store, initialBlockHash);
318
+ // Every PXE consumer reads through this one wrapper, so a read cached by one is served to the rest. Only
319
+ // immutable, hash-pinned reads are cached (the rule lives on `withCache`), which makes it safe regardless of
320
+ // the consumer's anchor block; the block synchronizer wipes it on anchor updates to bound memory.
321
+ const readCachedNode = withCache(node);
322
+ const contractClassService = new ContractClassService(readCachedNode, contractStore);
267
323
  const contractSyncService = new ContractSyncService(
268
- node,
324
+ readCachedNode,
269
325
  contractStore,
326
+ contractClassService,
270
327
  noteStore,
271
328
  createLogger('pxe:contract_sync', bindings),
272
329
  );
273
- const messageContextService = new MessageContextService(node);
330
+ const txResolver = new TxResolverService(readCachedNode);
274
331
 
275
332
  const synchronizer = new BlockSynchronizer(
276
- node,
333
+ readCachedNode,
277
334
  store,
278
335
  anchorBlockStore,
279
336
  noteStore,
280
337
  privateEventStore,
338
+ factStore,
281
339
  l2TipsStore,
282
340
  contractSyncService,
283
341
  config,
@@ -291,6 +349,7 @@ export class PXE {
291
349
  recipientTaggingStore,
292
350
  privateEventStore,
293
351
  noteStore,
352
+ factStore,
294
353
  contractSyncService,
295
354
  ]);
296
355
 
@@ -299,21 +358,24 @@ export class PXE {
299
358
  const jobQueue = new SerialQueue();
300
359
 
301
360
  const pxe = new PXE(
302
- node,
361
+ readCachedNode,
362
+ nodeDebug,
303
363
  store,
304
364
  synchronizer,
305
365
  keyStore,
306
366
  contractStore,
307
367
  noteStore,
308
368
  capsuleStore,
369
+ factStore,
309
370
  anchorBlockStore,
310
371
  senderTaggingStore,
311
- senderAddressBookStore,
372
+ taggingSecretSourcesStore,
312
373
  recipientTaggingStore,
313
374
  addressStore,
314
375
  privateEventStore,
315
376
  contractSyncService,
316
- messageContextService,
377
+ contractClassService,
378
+ txResolver,
317
379
  l2TipsStore,
318
380
  simulator,
319
381
  proverEnabled,
@@ -344,27 +406,52 @@ export class PXE {
344
406
  // Internal methods
345
407
 
346
408
  #getSimulatorForTx(overrides?: { contracts?: ContractOverrides }) {
347
- const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
348
-
349
409
  return new ContractFunctionSimulator({
350
- contractStore: proxyContractStore,
410
+ contractStore: this.contractStore,
411
+ contractClassService: this.contractClassService,
412
+ overrides: overrides?.contracts,
351
413
  noteStore: this.noteStore,
352
414
  keyStore: this.keyStore,
353
415
  addressStore: this.addressStore,
354
- aztecNode: BenchmarkedNodeFactory.create(this.node),
416
+ aztecNode: this.node,
355
417
  l2TipsStore: this.l2TipsStore,
356
418
  senderTaggingStore: this.senderTaggingStore,
357
419
  recipientTaggingStore: this.recipientTaggingStore,
358
- senderAddressBookStore: this.senderAddressBookStore,
420
+ taggingSecretSourcesStore: this.taggingSecretSourcesStore,
359
421
  capsuleStore: this.capsuleStore,
422
+ factStore: this.factStore,
360
423
  privateEventStore: this.privateEventStore,
361
424
  simulator: this.simulator,
362
425
  contractSyncService: this.contractSyncService,
363
- messageContextService: this.messageContextService,
426
+ txResolver: this.txResolver,
364
427
  hooks: this.hooks,
365
428
  });
366
429
  }
367
430
 
431
+ /** Best-effort debug function name for the class `address` runs at `anchorBlockHeader`. Used for log display only. */
432
+ async #getDebugFunctionName(
433
+ address: AztecAddress,
434
+ selector: FunctionSelector,
435
+ anchorBlockHeader: BlockHeader,
436
+ ): Promise<string> {
437
+ try {
438
+ const classId = await this.contractClassService.getCurrentClassId(address, anchorBlockHeader);
439
+ return classId ? await this.contractStore.getDebugFunctionName(classId, selector) : `${address}:${selector}`;
440
+ } catch {
441
+ return `${address}:${selector}`;
442
+ }
443
+ }
444
+
445
+ /** Best-effort debug contract name for the class `address` runs at `anchorBlockHeader`. Used for log display only. */
446
+ async #getDebugContractName(address: AztecAddress, anchorBlockHeader: BlockHeader): Promise<string | undefined> {
447
+ try {
448
+ const classId = await this.contractClassService.getCurrentClassId(address, anchorBlockHeader);
449
+ return classId ? await this.contractStore.getDebugContractName(classId) : undefined;
450
+ } catch {
451
+ return undefined;
452
+ }
453
+ }
454
+
368
455
  #contextualizeError(err: Error, ...context: string[]): Error {
369
456
  let contextStr = '';
370
457
  if (context.length > 0) {
@@ -428,7 +515,14 @@ export class PXE {
428
515
 
429
516
  async #registerPreloadedContracts() {
430
517
  const contracts = await this.preloadedContractsProvider.getPreloadedContracts();
431
- await Promise.all(contracts.map(({ instance, artifact }) => this.registerContract({ instance, artifact })));
518
+ await Promise.all(
519
+ contracts.map(async ({ instance, artifact }) => {
520
+ if (artifact) {
521
+ await this.registerContractClass(artifact);
522
+ }
523
+ await this.registerContract(instance);
524
+ }),
525
+ );
432
526
  this.log.verbose(`Registered preloaded contracts in pxe`, {
433
527
  contracts: contracts.map(({ instance }) => instance.address.toString()),
434
528
  });
@@ -465,8 +559,6 @@ export class PXE {
465
559
  );
466
560
 
467
561
  const result = await contractFunctionSimulator.run(txRequest, {
468
- contractAddress,
469
- selector: functionSelector,
470
562
  anchorBlockHeader,
471
563
  scopes,
472
564
  jobId,
@@ -476,7 +568,7 @@ export class PXE {
476
568
  return result;
477
569
  } catch (err) {
478
570
  if (err instanceof SimulationError) {
479
- await enrichSimulationError(err, this.contractStore, this.log);
571
+ await enrichSimulationError(err, this.contractStore, this.contractClassService, anchorBlockHeader, this.log);
480
572
  }
481
573
  throw err;
482
574
  }
@@ -511,7 +603,8 @@ export class PXE {
511
603
  return { result, offchainEffects };
512
604
  } catch (err) {
513
605
  if (err instanceof SimulationError) {
514
- await enrichSimulationError(err, this.contractStore, this.log);
606
+ const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
607
+ await enrichSimulationError(err, this.contractStore, this.contractClassService, anchorBlockHeader, this.log);
515
608
  }
516
609
  throw err;
517
610
  }
@@ -535,7 +628,14 @@ export class PXE {
535
628
  } catch (err) {
536
629
  if (err instanceof SimulationError) {
537
630
  try {
538
- await enrichPublicSimulationError(err, this.contractStore, this.log);
631
+ const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
632
+ await enrichPublicSimulationError(
633
+ err,
634
+ this.contractStore,
635
+ this.contractClassService,
636
+ anchorBlockHeader,
637
+ this.log,
638
+ );
539
639
  } catch (enrichErr) {
540
640
  this.log.error(`Failed to enrich public simulation error: ${enrichErr}`);
541
641
  }
@@ -562,7 +662,13 @@ export class PXE {
562
662
  anchorBlockHeader: BlockHeader,
563
663
  config: PrivateKernelExecutionProverConfig,
564
664
  ): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
565
- const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHeader);
665
+ const kernelOracle = new PrivateKernelOracle(
666
+ this.contractStore,
667
+ this.contractClassService,
668
+ this.keyStore,
669
+ this.node,
670
+ anchorBlockHeader,
671
+ );
566
672
  const kernelTraceProver = new PrivateKernelExecutionProver(
567
673
  kernelOracle,
568
674
  proofCreator,
@@ -606,11 +712,11 @@ export class PXE {
606
712
  }
607
713
 
608
714
  /**
609
- * Returns the contract instance for a given address, if it's registered in the PXE.
715
+ * Returns the address preimage of the contract instance at a given address, if it's registered in the PXE.
610
716
  * @param address - The contract address.
611
- * @returns The contract instance if found, undefined otherwise.
717
+ * @returns The contract instance address preimage if found, undefined otherwise.
612
718
  */
613
- public getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
719
+ public getContractInstance(address: AztecAddress): Promise<ContractInstancePreimageWithAddress | undefined> {
614
720
  return this.contractStore.getContractInstance(address);
615
721
  }
616
722
 
@@ -624,18 +730,22 @@ export class PXE {
624
730
  }
625
731
 
626
732
  /**
627
- * Registers a user account in PXE given its master encryption private key.
628
- * Once a new account is registered, the PXE will trial-decrypt all published notes on
629
- * the chain and store those that correspond to the registered account. Will do nothing if the
630
- * account is already registered.
733
+ * Registers a user account in PXE.
734
+ *
735
+ * PXE holds the account's four privacy secret keys but only the *public* message-signing and fallback keys: their
736
+ * secret keys are withheld, since PXE is not trusted to hold them.
631
737
  *
632
- * @param secretKey - Secret key of the corresponding user master public key.
738
+ * Does nothing if the account is already registered.
739
+ *
740
+ * The four privacy secret keys can be retrieved later with {@link getAccountSecretKeys}.
741
+ *
742
+ * @param keys - The account's privacy keys: four secret keys plus the message-signing and fallback public keys.
633
743
  * @param partialAddress - The partial address of the account contract corresponding to the account being registered.
634
744
  * @returns The complete address of the account.
635
745
  */
636
- public async registerAccount(secretKey: Fr, partialAddress: PartialAddress): Promise<CompleteAddress> {
746
+ public async registerAccount(keys: AccountPrivacyKeys, partialAddress: PartialAddress): Promise<CompleteAddress> {
637
747
  const accounts = await this.keyStore.getAccounts();
638
- const accountCompleteAddress = await this.keyStore.addAccount(secretKey, partialAddress);
748
+ const accountCompleteAddress = await this.keyStore.addAccount(keys, partialAddress);
639
749
  if (accounts.some(a => a.equals(accountCompleteAddress.address))) {
640
750
  this.log.info(`Account:\n "${accountCompleteAddress.address.toString()}"\n already registered.`);
641
751
  return accountCompleteAddress;
@@ -649,62 +759,189 @@ export class PXE {
649
759
  }
650
760
 
651
761
  /**
652
- * Registers a sender in this PXE.
762
+ * Retrieves the four privacy secret keys PXE holds for a registered account (nullifier-hiding, incoming-viewing,
763
+ * outgoing-viewing, tagging).
653
764
  *
654
- * After registering a new sender, the PXE will sync private logs that are tagged with this sender's address.
655
- * Will do nothing if the address is already registered.
765
+ * These do NOT grant control over an account's assets, e.g. they are insufficient to impersonate the account or to
766
+ * spend notes, but they _do_ guard the account's privacy. Parties that have knowledge of these keys can decrypt all
767
+ * messages sent to the account, discover all of their on-chain activity, including notes, events, etc.
656
768
  *
657
- * @param sender - Address of the sender to register.
658
- * @returns The address of the sender.
659
- * TODO: It's strange that we return the address here and I (benesjan) think we should drop the return value.
769
+ * Security is paramount when handling these keys, which should itself be a very rare occurrence. Other than exporting
770
+ * and then importing an account into a separate PXE/wallet, there is typically no need for a wallet to ever access
771
+ * these keys. Applications should NEVER be given access to them.
772
+ *
773
+ * @throws If the account is not registered.
660
774
  */
661
- public async registerSender(sender: AztecAddress): Promise<AztecAddress> {
662
- if (!(await sender.isValid())) {
663
- throw new Error(
664
- `Address ${sender} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register it as a sender.`,
665
- );
666
- }
775
+ public getAccountSecretKeys(account: AztecAddress): Promise<AccountPrivacySecretKeys> {
776
+ return this.keyStore.getAccountSecretKeys(account);
777
+ }
667
778
 
668
- const accounts = await this.keyStore.getAccounts();
669
- if (accounts.some(a => a.equals(sender))) {
670
- this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
671
- return sender;
779
+ /**
780
+ * Registers a source from which this PXE derives the tagging secrets it scans for to discover incoming private logs.
781
+ * See {@link TaggingSecretSource} for the meaning of each variant. Does nothing if the source is already registered.
782
+ *
783
+ * After a new source is added we clear the cache tracking which contracts have finished syncing, so every contract
784
+ * re-syncs against the new source's logs (whose notes/events could belong to any contract). Already-discovered
785
+ * notes/events are not discarded.
786
+ */
787
+ public async registerTaggingSecretSource(source: TaggingSecretSource): Promise<void> {
788
+ let wasAdded: boolean;
789
+
790
+ switch (source.kind) {
791
+ case 'address-derived':
792
+ wasAdded = await this.#registerSender(source.sender);
793
+ break;
794
+ case 'arbitrary-secret':
795
+ wasAdded = await this.#registerSharedSecret(source.recipient, 'arbitrary-secret', source.secret);
796
+ break;
797
+ case 'handshake':
798
+ wasAdded = await this.#registerSharedSecret(
799
+ source.recipient,
800
+ 'handshake',
801
+ await this.#deriveHandshakeSecret(source.recipient, source.ephPk),
802
+ );
803
+ break;
804
+ default: {
805
+ const _: never = source;
806
+ throw new Error('Unhandled tagging secret source kind');
807
+ }
672
808
  }
673
809
 
674
- const wasAdded = await this.senderAddressBookStore.addSender(sender);
675
-
676
810
  if (wasAdded) {
677
- this.log.info(`Added sender:\n ${sender.toString()}`);
678
- // Wipe the entire sync cache: the new sender's tagged logs could contain notes/events for any contract, so
679
- // all contracts must re-sync to discover them. Queued to avoid wiping while a job is in flight.
811
+ // Queued to avoid wiping while a job is in flight.
680
812
  await this.#putInJobQueue(() => Promise.resolve(this.contractSyncService.wipe()));
681
- } else {
682
- this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
683
813
  }
814
+ }
684
815
 
685
- return sender;
816
+ /**
817
+ * Removes a previously registered tagging secret source, identified by its registered form (see
818
+ * {@link getTaggingSecretSources}). Does nothing if it was not registered.
819
+ */
820
+ public async removeTaggingSecretSource(source: RegisteredTaggingSecretSource): Promise<void> {
821
+ switch (source.kind) {
822
+ case 'address-derived': {
823
+ const { sender } = source;
824
+ const wasRemoved = await this.taggingSecretSourcesStore.removeSender(sender);
825
+ this.log.info(
826
+ wasRemoved
827
+ ? `Removed sender:\n ${sender.toString()}`
828
+ : `Sender:\n "${sender.toString()}"\n not registered in PXE.`,
829
+ );
830
+ break;
831
+ }
832
+ case 'arbitrary-secret':
833
+ case 'handshake': {
834
+ const { kind, recipient, secret } = source;
835
+ const wasRemoved = await this.taggingSecretSourcesStore.removeSharedSecret(recipient, kind, secret);
836
+ this.log.info(
837
+ wasRemoved
838
+ ? `Removed ${kind} shared secret for recipient:\n ${recipient.toString()}`
839
+ : `No ${kind} shared secret registered for recipient:\n ${recipient.toString()}`,
840
+ );
841
+ break;
842
+ }
843
+ default: {
844
+ const _: never = source;
845
+ throw new Error('Unhandled tagging secret source kind');
846
+ }
847
+ }
686
848
  }
687
849
 
688
850
  /**
689
- * Retrieves senders registered in this PXE.
690
- * @returns Senders registered in this PXE.
851
+ * Retrieves the tagging secret sources registered in this PXE, in their registered form. Without a filter it
852
+ * returns every source; pass `{ kind }` to narrow to a single variant. See {@link RegisteredTaggingSecretSource}.
691
853
  */
692
- public getSenders(): Promise<AztecAddress[]> {
693
- return this.senderAddressBookStore.getSenders();
854
+ public getTaggingSecretSources<K extends RegisteredTaggingSecretSource['kind']>(filter: {
855
+ kind: K;
856
+ }): Promise<Extract<RegisteredTaggingSecretSource, { kind: K }>[]>;
857
+ public getTaggingSecretSources(): Promise<RegisteredTaggingSecretSource[]>;
858
+ public async getTaggingSecretSources(filter?: {
859
+ kind?: RegisteredTaggingSecretSource['kind'];
860
+ }): Promise<RegisteredTaggingSecretSource[]> {
861
+ const [senders, secrets] = await Promise.all([
862
+ this.taggingSecretSourcesStore.getSenders(),
863
+ this.taggingSecretSourcesStore.getAllSharedSecrets(),
864
+ ]);
865
+
866
+ const sources: RegisteredTaggingSecretSource[] = [
867
+ ...senders.map((sender): RegisteredTaggingSecretSource => ({ kind: 'address-derived', sender })),
868
+ ...secrets.map(({ recipient, kind, secret }): RegisteredTaggingSecretSource => ({ kind, recipient, secret })),
869
+ ];
870
+
871
+ return filter?.kind ? sources.filter(source => source.kind === filter.kind) : sources;
872
+ }
873
+
874
+ /** Registers a sender, skipping addresses that belong to a local account. Returns whether it was newly added. */
875
+ async #registerSender(address: AztecAddress): Promise<boolean> {
876
+ if (!(await address.isValid())) {
877
+ throw new Error(
878
+ `Address ${address} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register it as a sender.`,
879
+ );
880
+ }
881
+
882
+ const accounts = await this.keyStore.getAccounts();
883
+ if (accounts.some(a => a.equals(address))) {
884
+ this.log.info(`Sender:\n "${address.toString()}"\n already registered.`);
885
+ return false;
886
+ }
887
+
888
+ const wasAdded = await this.taggingSecretSourcesStore.addSender(address);
889
+ this.log.info(
890
+ wasAdded ? `Added sender:\n ${address.toString()}` : `Sender:\n "${address.toString()}"\n already registered.`,
891
+ );
892
+ return wasAdded;
694
893
  }
695
894
 
696
895
  /**
697
- * Removes a sender registered in this PXE.
698
- * @param sender - The address of the sender to remove.
896
+ * Derives the shared secret of a handshake from its ephemeral public key: the raw ECDH secret
897
+ * `S = addressSecret(recipient) * ephPk` with the forgery protection applied,
898
+ * matching the protected secret the registry stores and the derivation the recipient-side scan uses for
899
+ * handshakes discovered onchain. The ephemeral key is reconstructed from its x-coordinate with a positive y,
900
+ * matching how the protocol generates it.
901
+ *
902
+ * @throws If `ephPk` is not the x-coordinate of a Grumpkin curve point, or if `recipient` is not an account of
903
+ * this PXE, since the derivation needs its keys.
699
904
  */
700
- public async removeSender(sender: AztecAddress): Promise<void> {
701
- const wasRemoved = await this.senderAddressBookStore.removeSender(sender);
905
+ async #deriveHandshakeSecret(recipient: AztecAddress, ephPk: Fr): Promise<Point> {
906
+ let ephPkPoint: Point;
907
+ try {
908
+ ephPkPoint = await Point.fromXAndSign(ephPk, true);
909
+ } catch {
910
+ throw new Error(`Ephemeral public key x-coordinate ${ephPk} does not correspond to a Grumpkin curve point.`);
911
+ }
702
912
 
703
- if (wasRemoved) {
704
- this.log.info(`Removed sender:\n ${sender.toString()}`);
705
- } else {
706
- this.log.info(`Sender:\n "${sender.toString()}"\n not registered in PXE.`);
913
+ const completeAddress = await this.addressStore.getCompleteAddress(recipient);
914
+ if (!completeAddress || !(await this.keyStore.hasAccount(recipient))) {
915
+ throw new Error(
916
+ `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.`,
917
+ );
918
+ }
919
+
920
+ const ivskM = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
921
+ const addressSecret = await computeAddressSecret(await completeAddress.getPreaddress(), ivskM);
922
+ const rawSecret = await deriveEcdhSharedSecretPoint(addressSecret, ephPkPoint);
923
+ return protectFromForgery(rawSecret, ephPkPoint, await recipient.toAddressPoint());
924
+ }
925
+
926
+ /** Registers a resolved shared secret scoped to a recipient. Returns whether it was newly added. */
927
+ async #registerSharedSecret(recipient: AztecAddress, kind: SharedSecretKind, secret: Point): Promise<boolean> {
928
+ if (!(await recipient.isValid())) {
929
+ throw new Error(
930
+ `Recipient ${recipient} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register a shared secret for it.`,
931
+ );
932
+ }
933
+
934
+ if (secret.isZero() || !secret.isOnCurve()) {
935
+ throw new Error(`Shared secret ${secret} is not a valid non-zero point on the Grumpkin curve.`);
707
936
  }
937
+
938
+ const wasAdded = await this.taggingSecretSourcesStore.addSharedSecret(recipient, kind, secret);
939
+ this.log.info(
940
+ wasAdded
941
+ ? `Added ${kind} shared secret for recipient:\n ${recipient.toString()}`
942
+ : `${kind} shared secret already registered for recipient:\n ${recipient.toString()}`,
943
+ );
944
+ return wasAdded;
708
945
  }
709
946
 
710
947
  /**
@@ -728,98 +965,33 @@ export class PXE {
728
965
  */
729
966
  public async registerContractClass(artifact: ContractArtifact): Promise<void> {
730
967
  const contractClassId = await this.contractStore.addContractArtifact(artifact);
968
+ // Publishing the artifact's public function signatures to the node is part of "registering a class", so that
969
+ // node-side debugging works regardless of which entrypoint (registerContractClass or registerContract) was used.
970
+ const publicFunctionSignatures = artifact.functions
971
+ .filter(fn => fn.functionType === FunctionType.PUBLIC)
972
+ .map(fn => decodeFunctionSignature(fn.name, fn.parameters));
973
+ if (publicFunctionSignatures.length > 0) {
974
+ await this.nodeDebug?.registerContractFunctionSignatures(publicFunctionSignatures);
975
+ }
731
976
  this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
732
977
  }
733
978
 
734
979
  /**
735
- * Adds deployed contracts to the PXE. Deployed contract information is used to access the
736
- * contract code when simulating local transactions. This is automatically called by aztec.js when
737
- * deploying a contract. Dapps that wish to interact with contracts already deployed should register
738
- * these contracts in their users' PXE through this method.
980
+ * Registers a deployed contract instance so its private state can be synced and its functions simulated. The
981
+ * artifact for the class the instance runs must be registered separately via {@link registerContractClass}, before
982
+ * or after this call; registration performs no validation, so a missing or mismatched artifact only surfaces when
983
+ * the contract is later simulated. This is automatically called by aztec.js when deploying a contract.
739
984
  *
740
- * @param contract - A contract instance to register, with an optional artifact which can be omitted if the contract class has already been registered.
985
+ * @param instance - The address preimage of the contract instance to register. The address is derived from it.
986
+ * @returns The address of the registered instance.
741
987
  */
742
- public async registerContract(contract: { instance: ContractInstanceWithAddress; artifact?: ContractArtifact }) {
743
- const { instance } = contract;
744
- let { artifact } = contract;
745
-
746
- if (artifact) {
747
- // If the user provides an artifact, validate it against the expected class id and register it
748
- const contractClass = await getContractClassFromArtifact(artifact);
749
- if (!contractClass.id.equals(instance.currentContractClassId)) {
750
- throw new Error(
751
- `Artifact does not match expected class id (computed ${contractClass.id} but instance refers to ${instance.currentContractClassId})`,
752
- );
753
- }
754
- const computedAddress = await computeContractAddressFromInstance(instance);
755
- if (!computedAddress.equals(instance.address)) {
756
- throw new Error('Added a contract in which the address does not match the contract instance.');
757
- }
758
-
759
- await this.contractStore.addContractArtifact(artifact, contractClass);
760
-
761
- const publicFunctionSignatures = artifact.functions
762
- .filter(fn => fn.functionType === FunctionType.PUBLIC)
763
- .map(fn => decodeFunctionSignature(fn.name, fn.parameters));
764
- if (publicFunctionSignatures.length > 0) {
765
- await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
766
- }
767
- } else {
768
- // Otherwise, make sure there is an artifact already registered for that class id
769
- artifact = await this.contractStore.getContractArtifact(instance.currentContractClassId);
770
- if (!artifact) {
771
- throw new Error(
772
- `Artifact not found when registering an instance. Contract class: ${instance.currentContractClassId}.`,
773
- );
774
- }
775
- }
776
-
777
- await this.contractStore.addContractInstance(instance);
778
- this.log.info(
779
- `Added contract ${artifact.name} at ${instance.address.toString()} with class ${instance.currentContractClassId}`,
780
- );
781
- }
782
-
783
- /**
784
- * Updates a deployed contract in the PXE. This is used to update the contract artifact when
785
- * an update has happened, so the new code can be used in the simulation of local transactions.
786
- * This is called by aztec.js when instantiating a contract in a given address with a mismatching artifact.
787
- * @param contractAddress - The address of the contract to update.
788
- * @param artifact - The updated artifact for the contract.
789
- * @throws If the artifact's contract class is not found in the PXE or if the contract class is different from
790
- * the current one (current one from the point of view of the node to which the PXE is connected).
791
- */
792
- public updateContract(contractAddress: AztecAddress, artifact: ContractArtifact): Promise<void> {
793
- // We disable concurrently updating contracts to avoid concurrently syncing with the node, or changing a contract's
794
- // class while we're simulating it.
988
+ public registerContract(instance: ContractInstancePreimage): Promise<AztecAddress> {
989
+ // Run inside the job queue so we can't race a concurrent simulation while writing the instance to the store.
795
990
  return this.#putInJobQueue(async () => {
796
- const currentInstance = await this.contractStore.getContractInstance(contractAddress);
797
- if (!currentInstance) {
798
- throw new Error(`Instance not found when updating a contract. Contract address: ${contractAddress}.`);
799
- }
800
- const contractClass = await getContractClassFromArtifact(artifact);
801
- await this.#maybeSync();
802
-
803
- const header = await this.anchorBlockStore.getBlockHeader();
804
-
805
- const currentClassId = await readCurrentClassId(contractAddress, currentInstance, this.node, header);
806
- if (!contractClass.id.equals(currentClassId)) {
807
- throw new Error('Could not update contract to a class different from the current one.');
808
- }
809
-
810
- const publicFunctionSignatures = artifact.functions
811
- .filter(fn => fn.functionType === FunctionType.PUBLIC)
812
- .map(fn => decodeFunctionSignature(fn.name, fn.parameters));
813
- if (publicFunctionSignatures.length > 0) {
814
- await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
815
- }
816
-
817
- currentInstance.currentContractClassId = contractClass.id;
818
- await Promise.all([
819
- this.contractStore.addContractArtifact(artifact, contractClass),
820
- this.contractStore.addContractInstance(currentInstance),
821
- ]);
822
- this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
991
+ const address = await computeContractAddressFromInstance(instance);
992
+ await this.contractStore.addContractInstance({ ...instance, address });
993
+ this.log.info(`Added contract at ${address}`, { address });
994
+ return address;
823
995
  });
824
996
  }
825
997
 
@@ -847,6 +1019,7 @@ export class PXE {
847
1019
  // computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
848
1020
  return this.#putInJobQueue(async jobId => {
849
1021
  const totalTimer = new Timer();
1022
+ const recording = this.node.startRecording();
850
1023
  try {
851
1024
  const syncTimer = new Timer();
852
1025
  await this.#maybeSync();
@@ -894,7 +1067,7 @@ export class PXE {
894
1067
 
895
1068
  const txProvingResult = new TxProvingResult(privateExecutionResult, publicInputs, chonkProof!, {
896
1069
  timings,
897
- nodeRPCCalls: contractFunctionSimulator?.getStats().nodeRPCCalls,
1070
+ nodeRPCCalls: recording.stop(),
898
1071
  });
899
1072
 
900
1073
  // We keep track of which tagging indices we've used in this tx so that we don't repeat them in future txs
@@ -915,6 +1088,9 @@ export class PXE {
915
1088
  return txProvingResult;
916
1089
  } catch (err: any) {
917
1090
  throw this.#contextualizeError(err, inspect(txRequest), inspect(privateExecutionResult));
1091
+ } finally {
1092
+ // Idempotent cleanup for the error and early-exit paths. The success path already stopped the recording.
1093
+ recording.stop();
918
1094
  }
919
1095
  });
920
1096
  }
@@ -932,6 +1108,7 @@ export class PXE {
932
1108
  // We disable concurrent profiles for consistency with simulateTx.
933
1109
  return this.#putInJobQueue(async jobId => {
934
1110
  const totalTimer = new Timer();
1111
+ const recording = this.node.startRecording();
935
1112
  try {
936
1113
  const txInfo = {
937
1114
  origin: txRequest.origin,
@@ -997,10 +1174,12 @@ export class PXE {
997
1174
  total - ((syncTime ?? 0) + (proving ?? 0) + perFunction.reduce((acc, { time }) => acc + time, 0)),
998
1175
  };
999
1176
 
1000
- const simulatorStats = contractFunctionSimulator.getStats();
1001
- return new TxProfileResult(executionSteps, { timings, nodeRPCCalls: simulatorStats.nodeRPCCalls });
1177
+ return new TxProfileResult(executionSteps, { timings, nodeRPCCalls: recording.stop() });
1002
1178
  } catch (err: any) {
1003
1179
  throw this.#contextualizeError(err, inspect(txRequest), `profileMode=${profileMode}`);
1180
+ } finally {
1181
+ // Idempotent cleanup for the error and early-exit paths. The success path already stopped the recording.
1182
+ recording.stop();
1004
1183
  }
1005
1184
  });
1006
1185
  }
@@ -1039,6 +1218,7 @@ export class PXE {
1039
1218
  // to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
1040
1219
  // delete the same read value, or reading values that another simulation is currently modifying).
1041
1220
  return this.#putInJobQueue(async jobId => {
1221
+ const recording = this.node.startRecording();
1042
1222
  try {
1043
1223
  const totalTimer = new Timer();
1044
1224
  const txInfo = {
@@ -1081,7 +1261,7 @@ export class PXE {
1081
1261
  if (skipKernels) {
1082
1262
  ({ publicInputs, executionSteps } = await generateSimulatedProvingResult(
1083
1263
  privateExecutionResult,
1084
- (addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
1264
+ (addr, sel) => this.#getDebugFunctionName(addr, sel, anchorBlockHeader),
1085
1265
  this.node,
1086
1266
  ));
1087
1267
  } else {
@@ -1108,7 +1288,7 @@ export class PXE {
1108
1288
  publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement, overrides);
1109
1289
  publicSimulationTime = publicSimulationTimer.ms();
1110
1290
  if (publicOutput?.debugLogs?.length) {
1111
- await displayDebugLogs(publicOutput.debugLogs, addr => this.contractStore.getDebugContractName(addr));
1291
+ await displayDebugLogs(publicOutput.debugLogs, addr => this.#getDebugContractName(addr, anchorBlockHeader));
1112
1292
  }
1113
1293
  }
1114
1294
 
@@ -1159,10 +1339,9 @@ export class PXE {
1159
1339
  : {}),
1160
1340
  });
1161
1341
 
1162
- const simulatorStats = contractFunctionSimulator.getStats();
1163
1342
  return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(privateSimulationResult, publicOutput, {
1164
1343
  timings,
1165
- nodeRPCCalls: simulatorStats.nodeRPCCalls,
1344
+ nodeRPCCalls: recording.stop(),
1166
1345
  });
1167
1346
  } catch (err: any) {
1168
1347
  throw this.#contextualizeError(
@@ -1172,6 +1351,9 @@ export class PXE {
1172
1351
  `skipTxValidation=${skipTxValidation}`,
1173
1352
  `scopes=${scopes.map(s => s.toString()).join(', ')}`,
1174
1353
  );
1354
+ } finally {
1355
+ // Idempotent cleanup for the error and early-exit paths. The success path already stopped the recording.
1356
+ recording.stop();
1175
1357
  }
1176
1358
  });
1177
1359
  }
@@ -1188,6 +1370,7 @@ export class PXE {
1188
1370
  // to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
1189
1371
  // delete the same read value, or reading values that another execution is currently modifying).
1190
1372
  return this.#putInJobQueue(async jobId => {
1373
+ const recording = this.node.startRecording();
1191
1374
  try {
1192
1375
  const totalTimer = new Timer();
1193
1376
  const syncTimer = new Timer();
@@ -1227,12 +1410,11 @@ export class PXE {
1227
1410
  unaccounted: totalTime - (syncTime + perFunction.reduce((acc, { time }) => acc + time, 0)),
1228
1411
  };
1229
1412
 
1230
- const simulationStats = contractFunctionSimulator.getStats();
1231
1413
  return {
1232
1414
  result: executionResult,
1233
1415
  offchainEffects,
1234
1416
  anchorBlockTimestamp: anchorBlockHeader.globalVariables.timestamp,
1235
- stats: { timings, nodeRPCCalls: simulationStats.nodeRPCCalls },
1417
+ stats: { timings, nodeRPCCalls: recording.stop() },
1236
1418
  };
1237
1419
  } catch (err: any) {
1238
1420
  const { to, name, args } = call;
@@ -1242,6 +1424,9 @@ export class PXE {
1242
1424
  `executeUtility ${to}:${name}(${stringifiedArgs})`,
1243
1425
  `scopes=${scopes.map(s => s.toString()).join(', ')}`,
1244
1426
  );
1427
+ } finally {
1428
+ // Idempotent cleanup for the error and early-exit paths. The success path already stopped the recording.
1429
+ recording.stop();
1245
1430
  }
1246
1431
  });
1247
1432
  }