@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/dest/pxe.js CHANGED
@@ -1,26 +1,28 @@
1
1
  import { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import { Point } from '@aztec/foundation/curves/grumpkin';
2
3
  import { createLogger } from '@aztec/foundation/log';
3
4
  import { SerialQueue } from '@aztec/foundation/queue';
4
5
  import { Timer } from '@aztec/foundation/timer';
5
6
  import { protocolContractNames } from '@aztec/protocol-contracts';
6
7
  import { FunctionType, decodeFunctionSignature } from '@aztec/stdlib/abi';
7
8
  import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/stdlib/block';
8
- import { computeContractAddressFromInstance, getContractClassFromArtifact } from '@aztec/stdlib/contract';
9
+ import { computeContractAddressFromInstance } from '@aztec/stdlib/contract';
9
10
  import { SimulationError } from '@aztec/stdlib/errors';
11
+ import { computeAddressSecret } from '@aztec/stdlib/keys';
12
+ import { deriveEcdhSharedSecretPoint, protectFromForgery } from '@aztec/stdlib/logs';
10
13
  import { PrivateSimulationResult, TxProfileResult, TxProvingResult, TxSimulationResult } from '@aztec/stdlib/tx';
11
14
  import { inspect } from 'util';
12
15
  import { BlockSynchronizer } from './block_synchronizer/index.js';
13
- import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
16
+ import { ContractClassService } from './contract/contract_class_service.js';
17
+ import { ContractSyncService } from './contract/contract_sync_service.js';
14
18
  import { ContractFunctionSimulator, generateSimulatedProvingResult } from './contract_function_simulator/contract_function_simulator.js';
15
- import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
16
19
  import { displayDebugLogs } from './contract_logging.js';
17
- import { ContractSyncService } from './contract_sync/contract_sync_service.js';
18
- import { readCurrentClassId } from './contract_sync/helpers.js';
19
20
  import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
20
21
  import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
21
22
  import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
22
23
  import { JobCoordinator } from './job_coordinator/job_coordinator.js';
23
- import { MessageContextService } from './messages/message_context_service.js';
24
+ import { TxResolverService } from './messages/tx_resolver_service.js';
25
+ import { withCache } from './node/caching_aztec_node.js';
24
26
  import { PrivateKernelExecutionProver } from './private_kernel/private_kernel_execution_prover.js';
25
27
  import { PrivateKernelOracle } from './private_kernel/private_kernel_oracle.js';
26
28
  import { openPxeStores } from './storage/open_pxe_stores.js';
@@ -30,20 +32,23 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
30
32
  * manage private state of users.
31
33
  */ export class PXE {
32
34
  node;
35
+ nodeDebug;
33
36
  db;
34
37
  blockStateSynchronizer;
35
38
  keyStore;
36
39
  contractStore;
37
40
  noteStore;
38
41
  capsuleStore;
42
+ factStore;
39
43
  anchorBlockStore;
40
44
  senderTaggingStore;
41
- senderAddressBookStore;
45
+ taggingSecretSourcesStore;
42
46
  recipientTaggingStore;
43
47
  addressStore;
44
48
  privateEventStore;
45
49
  contractSyncService;
46
- messageContextService;
50
+ contractClassService;
51
+ txResolver;
47
52
  l2TipsStore;
48
53
  simulator;
49
54
  proverEnabled;
@@ -56,22 +61,25 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
56
61
  jobCoordinator;
57
62
  debug;
58
63
  hooks;
59
- constructor(node, db, blockStateSynchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, messageContextService, l2TipsStore, simulator, proverEnabled, autoSync, proofCreator, protocolContractsProvider, preloadedContractsProvider, log, jobQueue, jobCoordinator, debug, hooks){
64
+ constructor(node, nodeDebug, db, blockStateSynchronizer, keyStore, contractStore, noteStore, capsuleStore, factStore, anchorBlockStore, senderTaggingStore, taggingSecretSourcesStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, contractClassService, txResolver, l2TipsStore, simulator, proverEnabled, autoSync, proofCreator, protocolContractsProvider, preloadedContractsProvider, log, jobQueue, jobCoordinator, debug, hooks){
60
65
  this.node = node;
66
+ this.nodeDebug = nodeDebug;
61
67
  this.db = db;
62
68
  this.blockStateSynchronizer = blockStateSynchronizer;
63
69
  this.keyStore = keyStore;
64
70
  this.contractStore = contractStore;
65
71
  this.noteStore = noteStore;
66
72
  this.capsuleStore = capsuleStore;
73
+ this.factStore = factStore;
67
74
  this.anchorBlockStore = anchorBlockStore;
68
75
  this.senderTaggingStore = senderTaggingStore;
69
- this.senderAddressBookStore = senderAddressBookStore;
76
+ this.taggingSecretSourcesStore = taggingSecretSourcesStore;
70
77
  this.recipientTaggingStore = recipientTaggingStore;
71
78
  this.addressStore = addressStore;
72
79
  this.privateEventStore = privateEventStore;
73
80
  this.contractSyncService = contractSyncService;
74
- this.messageContextService = messageContextService;
81
+ this.contractClassService = contractClassService;
82
+ this.txResolver = txResolver;
75
83
  this.l2TipsStore = l2TipsStore;
76
84
  this.simulator = simulator;
77
85
  this.proverEnabled = proverEnabled;
@@ -91,7 +99,7 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
91
99
  * can be contacted.
92
100
  *
93
101
  * @returns A promise that resolves PXE is ready to be used.
94
- */ static async create({ node, store, proofCreator, simulator, protocolContractsProvider, preloadedContractsProvider, config, loggerOrSuffix, hooks }) {
102
+ */ static async create({ node, nodeDebug, store, proofCreator, simulator, protocolContractsProvider, preloadedContractsProvider, config, loggerOrSuffix, hooks }) {
95
103
  // Extract bindings from the logger, or use empty bindings if a string suffix is provided.
96
104
  const bindings = loggerOrSuffix && typeof loggerOrSuffix !== 'string' ? loggerOrSuffix.getBindings() : undefined;
97
105
  const log = !loggerOrSuffix || typeof loggerOrSuffix === 'string' ? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`) : loggerOrSuffix;
@@ -104,10 +112,15 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
104
112
  // not return a genesis block (older node or test fixture) we fall back to the static constant.
105
113
  const initialBlockHash = (await node.getBlock(BlockNumber.ZERO))?.hash ?? GENESIS_BLOCK_HEADER_HASH;
106
114
  const proverEnabled = config.proverEnabled !== undefined ? config.proverEnabled : info.realProofs;
107
- const { addressStore, privateEventStore, contractStore, noteStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, capsuleStore, keyStore, l2TipsStore } = openPxeStores(store, initialBlockHash);
108
- const contractSyncService = new ContractSyncService(node, contractStore, noteStore, createLogger('pxe:contract_sync', bindings));
109
- const messageContextService = new MessageContextService(node);
110
- const synchronizer = new BlockSynchronizer(node, store, anchorBlockStore, noteStore, privateEventStore, l2TipsStore, contractSyncService, config, bindings);
115
+ const { addressStore, privateEventStore, contractStore, noteStore, anchorBlockStore, senderTaggingStore, taggingSecretSourcesStore, recipientTaggingStore, capsuleStore, keyStore, l2TipsStore, factStore } = openPxeStores(store, initialBlockHash);
116
+ // Every PXE consumer reads through this one wrapper, so a read cached by one is served to the rest. Only
117
+ // immutable, hash-pinned reads are cached (the rule lives on `withCache`), which makes it safe regardless of
118
+ // the consumer's anchor block; the block synchronizer wipes it on anchor updates to bound memory.
119
+ const readCachedNode = withCache(node);
120
+ const contractClassService = new ContractClassService(readCachedNode, contractStore);
121
+ const contractSyncService = new ContractSyncService(readCachedNode, contractStore, contractClassService, noteStore, createLogger('pxe:contract_sync', bindings));
122
+ const txResolver = new TxResolverService(readCachedNode);
123
+ const synchronizer = new BlockSynchronizer(readCachedNode, store, anchorBlockStore, noteStore, privateEventStore, factStore, l2TipsStore, contractSyncService, config, bindings);
111
124
  const jobCoordinator = new JobCoordinator(store, bindings);
112
125
  jobCoordinator.registerStores([
113
126
  capsuleStore,
@@ -115,11 +128,12 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
115
128
  recipientTaggingStore,
116
129
  privateEventStore,
117
130
  noteStore,
131
+ factStore,
118
132
  contractSyncService
119
133
  ]);
120
134
  const debugUtils = new PXEDebugUtils(contractSyncService, noteStore, synchronizer, anchorBlockStore);
121
135
  const jobQueue = new SerialQueue();
122
- const pxe = new PXE(node, store, synchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, messageContextService, l2TipsStore, simulator, proverEnabled, config.autoSync, proofCreator, protocolContractsProvider, preloadedContractsProvider, log, jobQueue, jobCoordinator, debugUtils, hooks);
136
+ const pxe = new PXE(readCachedNode, nodeDebug, store, synchronizer, keyStore, contractStore, noteStore, capsuleStore, factStore, anchorBlockStore, senderTaggingStore, taggingSecretSourcesStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, contractClassService, txResolver, l2TipsStore, simulator, proverEnabled, config.autoSync, proofCreator, protocolContractsProvider, preloadedContractsProvider, log, jobQueue, jobCoordinator, debugUtils, hooks);
123
137
  debugUtils.setPXEHelpers(pxe.#putInJobQueue.bind(pxe), pxe.#getSimulatorForTx.bind(pxe), pxe.#executeUtility.bind(pxe));
124
138
  pxe.jobQueue.start();
125
139
  await Promise.all([
@@ -131,25 +145,43 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
131
145
  }
132
146
  // Internal methods
133
147
  #getSimulatorForTx(overrides) {
134
- const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
135
148
  return new ContractFunctionSimulator({
136
- contractStore: proxyContractStore,
149
+ contractStore: this.contractStore,
150
+ contractClassService: this.contractClassService,
151
+ overrides: overrides?.contracts,
137
152
  noteStore: this.noteStore,
138
153
  keyStore: this.keyStore,
139
154
  addressStore: this.addressStore,
140
- aztecNode: BenchmarkedNodeFactory.create(this.node),
155
+ aztecNode: this.node,
141
156
  l2TipsStore: this.l2TipsStore,
142
157
  senderTaggingStore: this.senderTaggingStore,
143
158
  recipientTaggingStore: this.recipientTaggingStore,
144
- senderAddressBookStore: this.senderAddressBookStore,
159
+ taggingSecretSourcesStore: this.taggingSecretSourcesStore,
145
160
  capsuleStore: this.capsuleStore,
161
+ factStore: this.factStore,
146
162
  privateEventStore: this.privateEventStore,
147
163
  simulator: this.simulator,
148
164
  contractSyncService: this.contractSyncService,
149
- messageContextService: this.messageContextService,
165
+ txResolver: this.txResolver,
150
166
  hooks: this.hooks
151
167
  });
152
168
  }
169
+ /** Best-effort debug function name for the class `address` runs at `anchorBlockHeader`. Used for log display only. */ async #getDebugFunctionName(address, selector, anchorBlockHeader) {
170
+ try {
171
+ const classId = await this.contractClassService.getCurrentClassId(address, anchorBlockHeader);
172
+ return classId ? await this.contractStore.getDebugFunctionName(classId, selector) : `${address}:${selector}`;
173
+ } catch {
174
+ return `${address}:${selector}`;
175
+ }
176
+ }
177
+ /** Best-effort debug contract name for the class `address` runs at `anchorBlockHeader`. Used for log display only. */ async #getDebugContractName(address, anchorBlockHeader) {
178
+ try {
179
+ const classId = await this.contractClassService.getCurrentClassId(address, anchorBlockHeader);
180
+ return classId ? await this.contractStore.getDebugContractName(classId) : undefined;
181
+ } catch {
182
+ return undefined;
183
+ }
184
+ }
153
185
  #contextualizeError(err, ...context) {
154
186
  let contextStr = '';
155
187
  if (context.length > 0) {
@@ -202,10 +234,12 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
202
234
  }
203
235
  async #registerPreloadedContracts() {
204
236
  const contracts = await this.preloadedContractsProvider.getPreloadedContracts();
205
- await Promise.all(contracts.map(({ instance, artifact })=>this.registerContract({
206
- instance,
207
- artifact
208
- })));
237
+ await Promise.all(contracts.map(async ({ instance, artifact })=>{
238
+ if (artifact) {
239
+ await this.registerContractClass(artifact);
240
+ }
241
+ await this.registerContract(instance);
242
+ }));
209
243
  this.log.verbose(`Registered preloaded contracts in pxe`, {
210
244
  contracts: contracts.map(({ instance })=>instance.address.toString())
211
245
  });
@@ -217,8 +251,6 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
217
251
  try {
218
252
  await this.contractSyncService.ensureContractSynced(contractAddress, functionSelector, (privateSyncCall, execScopes)=>this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, scopes);
219
253
  const result = await contractFunctionSimulator.run(txRequest, {
220
- contractAddress,
221
- selector: functionSelector,
222
254
  anchorBlockHeader,
223
255
  scopes,
224
256
  jobId,
@@ -228,7 +260,7 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
228
260
  return result;
229
261
  } catch (err) {
230
262
  if (err instanceof SimulationError) {
231
- await enrichSimulationError(err, this.contractStore, this.log);
263
+ await enrichSimulationError(err, this.contractStore, this.contractClassService, anchorBlockHeader, this.log);
232
264
  }
233
265
  throw err;
234
266
  }
@@ -252,7 +284,8 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
252
284
  };
253
285
  } catch (err) {
254
286
  if (err instanceof SimulationError) {
255
- await enrichSimulationError(err, this.contractStore, this.log);
287
+ const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
288
+ await enrichSimulationError(err, this.contractStore, this.contractClassService, anchorBlockHeader, this.log);
256
289
  }
257
290
  throw err;
258
291
  }
@@ -274,7 +307,8 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
274
307
  } catch (err) {
275
308
  if (err instanceof SimulationError) {
276
309
  try {
277
- await enrichPublicSimulationError(err, this.contractStore, this.log);
310
+ const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
311
+ await enrichPublicSimulationError(err, this.contractStore, this.contractClassService, anchorBlockHeader, this.log);
278
312
  } catch (enrichErr) {
279
313
  this.log.error(`Failed to enrich public simulation error: ${enrichErr}`);
280
314
  }
@@ -293,7 +327,7 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
293
327
  * @param config - The configuration for the kernel execution prover.
294
328
  * @returns An object that contains the output of the kernel execution, including the ChonkProof if proving is enabled.
295
329
  */ async #prove(txExecutionRequest, proofCreator, privateExecutionResult, anchorBlockHeader, config) {
296
- const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHeader);
330
+ const kernelOracle = new PrivateKernelOracle(this.contractStore, this.contractClassService, this.keyStore, this.node, anchorBlockHeader);
297
331
  const kernelTraceProver = new PrivateKernelExecutionProver(kernelOracle, proofCreator, !this.proverEnabled, this.log.getBindings());
298
332
  this.log.debug(`Executing kernel trace prover (${JSON.stringify(config)})...`);
299
333
  return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
@@ -324,9 +358,9 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
324
358
  });
325
359
  }
326
360
  /**
327
- * Returns the contract instance for a given address, if it's registered in the PXE.
361
+ * Returns the address preimage of the contract instance at a given address, if it's registered in the PXE.
328
362
  * @param address - The contract address.
329
- * @returns The contract instance if found, undefined otherwise.
363
+ * @returns The contract instance address preimage if found, undefined otherwise.
330
364
  */ getContractInstance(address) {
331
365
  return this.contractStore.getContractInstance(address);
332
366
  }
@@ -338,17 +372,21 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
338
372
  return await this.contractStore.getContractArtifact(id);
339
373
  }
340
374
  /**
341
- * Registers a user account in PXE given its master encryption private key.
342
- * Once a new account is registered, the PXE will trial-decrypt all published notes on
343
- * the chain and store those that correspond to the registered account. Will do nothing if the
344
- * account is already registered.
375
+ * Registers a user account in PXE.
376
+ *
377
+ * PXE holds the account's four privacy secret keys but only the *public* message-signing and fallback keys: their
378
+ * secret keys are withheld, since PXE is not trusted to hold them.
379
+ *
380
+ * Does nothing if the account is already registered.
345
381
  *
346
- * @param secretKey - Secret key of the corresponding user master public key.
382
+ * The four privacy secret keys can be retrieved later with {@link getAccountSecretKeys}.
383
+ *
384
+ * @param keys - The account's privacy keys: four secret keys plus the message-signing and fallback public keys.
347
385
  * @param partialAddress - The partial address of the account contract corresponding to the account being registered.
348
386
  * @returns The complete address of the account.
349
- */ async registerAccount(secretKey, partialAddress) {
387
+ */ async registerAccount(keys, partialAddress) {
350
388
  const accounts = await this.keyStore.getAccounts();
351
- const accountCompleteAddress = await this.keyStore.addAccount(secretKey, partialAddress);
389
+ const accountCompleteAddress = await this.keyStore.addAccount(keys, partialAddress);
352
390
  if (accounts.some((a)=>a.equals(accountCompleteAddress.address))) {
353
391
  this.log.info(`Account:\n "${accountCompleteAddress.address.toString()}"\n already registered.`);
354
392
  return accountCompleteAddress;
@@ -360,50 +398,144 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
360
398
  return accountCompleteAddress;
361
399
  }
362
400
  /**
363
- * Registers a sender in this PXE.
401
+ * Retrieves the four privacy secret keys PXE holds for a registered account (nullifier-hiding, incoming-viewing,
402
+ * outgoing-viewing, tagging).
364
403
  *
365
- * After registering a new sender, the PXE will sync private logs that are tagged with this sender's address.
366
- * Will do nothing if the address is already registered.
404
+ * These do NOT grant control over an account's assets, e.g. they are insufficient to impersonate the account or to
405
+ * spend notes, but they _do_ guard the account's privacy. Parties that have knowledge of these keys can decrypt all
406
+ * messages sent to the account, discover all of their on-chain activity, including notes, events, etc.
367
407
  *
368
- * @param sender - Address of the sender to register.
369
- * @returns The address of the sender.
370
- * TODO: It's strange that we return the address here and I (benesjan) think we should drop the return value.
371
- */ async registerSender(sender) {
372
- if (!await sender.isValid()) {
373
- throw new Error(`Address ${sender} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register it as a sender.`);
374
- }
375
- const accounts = await this.keyStore.getAccounts();
376
- if (accounts.some((a)=>a.equals(sender))) {
377
- this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
378
- return sender;
408
+ * Security is paramount when handling these keys, which should itself be a very rare occurrence. Other than exporting
409
+ * and then importing an account into a separate PXE/wallet, there is typically no need for a wallet to ever access
410
+ * these keys. Applications should NEVER be given access to them.
411
+ *
412
+ * @throws If the account is not registered.
413
+ */ getAccountSecretKeys(account) {
414
+ return this.keyStore.getAccountSecretKeys(account);
415
+ }
416
+ /**
417
+ * Registers a source from which this PXE derives the tagging secrets it scans for to discover incoming private logs.
418
+ * See {@link TaggingSecretSource} for the meaning of each variant. Does nothing if the source is already registered.
419
+ *
420
+ * After a new source is added we clear the cache tracking which contracts have finished syncing, so every contract
421
+ * re-syncs against the new source's logs (whose notes/events could belong to any contract). Already-discovered
422
+ * notes/events are not discarded.
423
+ */ async registerTaggingSecretSource(source) {
424
+ let wasAdded;
425
+ switch(source.kind){
426
+ case 'address-derived':
427
+ wasAdded = await this.#registerSender(source.sender);
428
+ break;
429
+ case 'arbitrary-secret':
430
+ wasAdded = await this.#registerSharedSecret(source.recipient, 'arbitrary-secret', source.secret);
431
+ break;
432
+ case 'handshake':
433
+ wasAdded = await this.#registerSharedSecret(source.recipient, 'handshake', await this.#deriveHandshakeSecret(source.recipient, source.ephPk));
434
+ break;
435
+ default:
436
+ {
437
+ const _ = source;
438
+ throw new Error('Unhandled tagging secret source kind');
439
+ }
379
440
  }
380
- const wasAdded = await this.senderAddressBookStore.addSender(sender);
381
441
  if (wasAdded) {
382
- this.log.info(`Added sender:\n ${sender.toString()}`);
383
- // Wipe the entire sync cache: the new sender's tagged logs could contain notes/events for any contract, so
384
- // all contracts must re-sync to discover them. Queued to avoid wiping while a job is in flight.
442
+ // Queued to avoid wiping while a job is in flight.
385
443
  await this.#putInJobQueue(()=>Promise.resolve(this.contractSyncService.wipe()));
386
- } else {
387
- this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
388
444
  }
389
- return sender;
390
445
  }
391
446
  /**
392
- * Retrieves senders registered in this PXE.
393
- * @returns Senders registered in this PXE.
394
- */ getSenders() {
395
- return this.senderAddressBookStore.getSenders();
447
+ * Removes a previously registered tagging secret source, identified by its registered form (see
448
+ * {@link getTaggingSecretSources}). Does nothing if it was not registered.
449
+ */ async removeTaggingSecretSource(source) {
450
+ switch(source.kind){
451
+ case 'address-derived':
452
+ {
453
+ const { sender } = source;
454
+ const wasRemoved = await this.taggingSecretSourcesStore.removeSender(sender);
455
+ this.log.info(wasRemoved ? `Removed sender:\n ${sender.toString()}` : `Sender:\n "${sender.toString()}"\n not registered in PXE.`);
456
+ break;
457
+ }
458
+ case 'arbitrary-secret':
459
+ case 'handshake':
460
+ {
461
+ const { kind, recipient, secret } = source;
462
+ const wasRemoved = await this.taggingSecretSourcesStore.removeSharedSecret(recipient, kind, secret);
463
+ this.log.info(wasRemoved ? `Removed ${kind} shared secret for recipient:\n ${recipient.toString()}` : `No ${kind} shared secret registered for recipient:\n ${recipient.toString()}`);
464
+ break;
465
+ }
466
+ default:
467
+ {
468
+ const _ = source;
469
+ throw new Error('Unhandled tagging secret source kind');
470
+ }
471
+ }
472
+ }
473
+ async getTaggingSecretSources(filter) {
474
+ const [senders, secrets] = await Promise.all([
475
+ this.taggingSecretSourcesStore.getSenders(),
476
+ this.taggingSecretSourcesStore.getAllSharedSecrets()
477
+ ]);
478
+ const sources = [
479
+ ...senders.map((sender)=>({
480
+ kind: 'address-derived',
481
+ sender
482
+ })),
483
+ ...secrets.map(({ recipient, kind, secret })=>({
484
+ kind,
485
+ recipient,
486
+ secret
487
+ }))
488
+ ];
489
+ return filter?.kind ? sources.filter((source)=>source.kind === filter.kind) : sources;
490
+ }
491
+ /** Registers a sender, skipping addresses that belong to a local account. Returns whether it was newly added. */ async #registerSender(address) {
492
+ if (!await address.isValid()) {
493
+ throw new Error(`Address ${address} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register it as a sender.`);
494
+ }
495
+ const accounts = await this.keyStore.getAccounts();
496
+ if (accounts.some((a)=>a.equals(address))) {
497
+ this.log.info(`Sender:\n "${address.toString()}"\n already registered.`);
498
+ return false;
499
+ }
500
+ const wasAdded = await this.taggingSecretSourcesStore.addSender(address);
501
+ this.log.info(wasAdded ? `Added sender:\n ${address.toString()}` : `Sender:\n "${address.toString()}"\n already registered.`);
502
+ return wasAdded;
396
503
  }
397
504
  /**
398
- * Removes a sender registered in this PXE.
399
- * @param sender - The address of the sender to remove.
400
- */ async removeSender(sender) {
401
- const wasRemoved = await this.senderAddressBookStore.removeSender(sender);
402
- if (wasRemoved) {
403
- this.log.info(`Removed sender:\n ${sender.toString()}`);
404
- } else {
405
- this.log.info(`Sender:\n "${sender.toString()}"\n not registered in PXE.`);
505
+ * Derives the shared secret of a handshake from its ephemeral public key: the raw ECDH secret
506
+ * `S = addressSecret(recipient) * ephPk` with the forgery protection applied,
507
+ * matching the protected secret the registry stores and the derivation the recipient-side scan uses for
508
+ * handshakes discovered onchain. The ephemeral key is reconstructed from its x-coordinate with a positive y,
509
+ * matching how the protocol generates it.
510
+ *
511
+ * @throws If `ephPk` is not the x-coordinate of a Grumpkin curve point, or if `recipient` is not an account of
512
+ * this PXE, since the derivation needs its keys.
513
+ */ async #deriveHandshakeSecret(recipient, ephPk) {
514
+ let ephPkPoint;
515
+ try {
516
+ ephPkPoint = await Point.fromXAndSign(ephPk, true);
517
+ } catch {
518
+ throw new Error(`Ephemeral public key x-coordinate ${ephPk} does not correspond to a Grumpkin curve point.`);
519
+ }
520
+ const completeAddress = await this.addressStore.getCompleteAddress(recipient);
521
+ if (!completeAddress || !await this.keyStore.hasAccount(recipient)) {
522
+ throw new Error(`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.`);
406
523
  }
524
+ const ivskM = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
525
+ const addressSecret = await computeAddressSecret(await completeAddress.getPreaddress(), ivskM);
526
+ const rawSecret = await deriveEcdhSharedSecretPoint(addressSecret, ephPkPoint);
527
+ return protectFromForgery(rawSecret, ephPkPoint, await recipient.toAddressPoint());
528
+ }
529
+ /** Registers a resolved shared secret scoped to a recipient. Returns whether it was newly added. */ async #registerSharedSecret(recipient, kind, secret) {
530
+ if (!await recipient.isValid()) {
531
+ throw new Error(`Recipient ${recipient} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register a shared secret for it.`);
532
+ }
533
+ if (secret.isZero() || !secret.isOnCurve()) {
534
+ throw new Error(`Shared secret ${secret} is not a valid non-zero point on the Grumpkin curve.`);
535
+ }
536
+ const wasAdded = await this.taggingSecretSourcesStore.addSharedSecret(recipient, kind, secret);
537
+ this.log.info(wasAdded ? `Added ${kind} shared secret for recipient:\n ${recipient.toString()}` : `${kind} shared secret already registered for recipient:\n ${recipient.toString()}`);
538
+ return wasAdded;
407
539
  }
408
540
  /**
409
541
  * Retrieves the user accounts registered on this PXE.
@@ -421,76 +553,34 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
421
553
  * @param artifact - The build artifact for the contract class.
422
554
  */ async registerContractClass(artifact) {
423
555
  const contractClassId = await this.contractStore.addContractArtifact(artifact);
556
+ // Publishing the artifact's public function signatures to the node is part of "registering a class", so that
557
+ // node-side debugging works regardless of which entrypoint (registerContractClass or registerContract) was used.
558
+ const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
559
+ if (publicFunctionSignatures.length > 0) {
560
+ await this.nodeDebug?.registerContractFunctionSignatures(publicFunctionSignatures);
561
+ }
424
562
  this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
425
563
  }
426
564
  /**
427
- * Adds deployed contracts to the PXE. Deployed contract information is used to access the
428
- * contract code when simulating local transactions. This is automatically called by aztec.js when
429
- * deploying a contract. Dapps that wish to interact with contracts already deployed should register
430
- * these contracts in their users' PXE through this method.
565
+ * Registers a deployed contract instance so its private state can be synced and its functions simulated. The
566
+ * artifact for the class the instance runs must be registered separately via {@link registerContractClass}, before
567
+ * or after this call; registration performs no validation, so a missing or mismatched artifact only surfaces when
568
+ * the contract is later simulated. This is automatically called by aztec.js when deploying a contract.
431
569
  *
432
- * @param contract - A contract instance to register, with an optional artifact which can be omitted if the contract class has already been registered.
433
- */ async registerContract(contract) {
434
- const { instance } = contract;
435
- let { artifact } = contract;
436
- if (artifact) {
437
- // If the user provides an artifact, validate it against the expected class id and register it
438
- const contractClass = await getContractClassFromArtifact(artifact);
439
- if (!contractClass.id.equals(instance.currentContractClassId)) {
440
- throw new Error(`Artifact does not match expected class id (computed ${contractClass.id} but instance refers to ${instance.currentContractClassId})`);
441
- }
442
- const computedAddress = await computeContractAddressFromInstance(instance);
443
- if (!computedAddress.equals(instance.address)) {
444
- throw new Error('Added a contract in which the address does not match the contract instance.');
445
- }
446
- await this.contractStore.addContractArtifact(artifact, contractClass);
447
- const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
448
- if (publicFunctionSignatures.length > 0) {
449
- await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
450
- }
451
- } else {
452
- // Otherwise, make sure there is an artifact already registered for that class id
453
- artifact = await this.contractStore.getContractArtifact(instance.currentContractClassId);
454
- if (!artifact) {
455
- throw new Error(`Artifact not found when registering an instance. Contract class: ${instance.currentContractClassId}.`);
456
- }
457
- }
458
- await this.contractStore.addContractInstance(instance);
459
- this.log.info(`Added contract ${artifact.name} at ${instance.address.toString()} with class ${instance.currentContractClassId}`);
460
- }
461
- /**
462
- * Updates a deployed contract in the PXE. This is used to update the contract artifact when
463
- * an update has happened, so the new code can be used in the simulation of local transactions.
464
- * This is called by aztec.js when instantiating a contract in a given address with a mismatching artifact.
465
- * @param contractAddress - The address of the contract to update.
466
- * @param artifact - The updated artifact for the contract.
467
- * @throws If the artifact's contract class is not found in the PXE or if the contract class is different from
468
- * the current one (current one from the point of view of the node to which the PXE is connected).
469
- */ updateContract(contractAddress, artifact) {
470
- // We disable concurrently updating contracts to avoid concurrently syncing with the node, or changing a contract's
471
- // class while we're simulating it.
570
+ * @param instance - The address preimage of the contract instance to register. The address is derived from it.
571
+ * @returns The address of the registered instance.
572
+ */ registerContract(instance) {
573
+ // Run inside the job queue so we can't race a concurrent simulation while writing the instance to the store.
472
574
  return this.#putInJobQueue(async ()=>{
473
- const currentInstance = await this.contractStore.getContractInstance(contractAddress);
474
- if (!currentInstance) {
475
- throw new Error(`Instance not found when updating a contract. Contract address: ${contractAddress}.`);
476
- }
477
- const contractClass = await getContractClassFromArtifact(artifact);
478
- await this.#maybeSync();
479
- const header = await this.anchorBlockStore.getBlockHeader();
480
- const currentClassId = await readCurrentClassId(contractAddress, currentInstance, this.node, header);
481
- if (!contractClass.id.equals(currentClassId)) {
482
- throw new Error('Could not update contract to a class different from the current one.');
483
- }
484
- const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
485
- if (publicFunctionSignatures.length > 0) {
486
- await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
487
- }
488
- currentInstance.currentContractClassId = contractClass.id;
489
- await Promise.all([
490
- this.contractStore.addContractArtifact(artifact, contractClass),
491
- this.contractStore.addContractInstance(currentInstance)
492
- ]);
493
- this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
575
+ const address = await computeContractAddressFromInstance(instance);
576
+ await this.contractStore.addContractInstance({
577
+ ...instance,
578
+ address
579
+ });
580
+ this.log.info(`Added contract at ${address}`, {
581
+ address
582
+ });
583
+ return address;
494
584
  });
495
585
  }
496
586
  /**
@@ -514,6 +604,7 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
514
604
  // computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
515
605
  return this.#putInJobQueue(async (jobId)=>{
516
606
  const totalTimer = new Timer();
607
+ const recording = this.node.startRecording();
517
608
  try {
518
609
  const syncTimer = new Timer();
519
610
  await this.#maybeSync();
@@ -551,7 +642,7 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
551
642
  });
552
643
  const txProvingResult = new TxProvingResult(privateExecutionResult, publicInputs, chonkProof, {
553
644
  timings,
554
- nodeRPCCalls: contractFunctionSimulator?.getStats().nodeRPCCalls
645
+ nodeRPCCalls: recording.stop()
555
646
  });
556
647
  // We keep track of which tagging indices we've used in this tx so that we don't repeat them in future txs
557
648
  // (which would link them) without having to rely on this tx being mined (and us seeing the indices being used
@@ -563,6 +654,9 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
563
654
  return txProvingResult;
564
655
  } catch (err) {
565
656
  throw this.#contextualizeError(err, inspect(txRequest), inspect(privateExecutionResult));
657
+ } finally{
658
+ // Idempotent cleanup for the error and early-exit paths. The success path already stopped the recording.
659
+ recording.stop();
566
660
  }
567
661
  });
568
662
  }
@@ -575,6 +669,7 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
575
669
  // We disable concurrent profiles for consistency with simulateTx.
576
670
  return this.#putInJobQueue(async (jobId)=>{
577
671
  const totalTimer = new Timer();
672
+ const recording = this.node.startRecording();
578
673
  try {
579
674
  const txInfo = {
580
675
  origin: txRequest.origin,
@@ -621,13 +716,15 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
621
716
  perFunction,
622
717
  unaccounted: total - ((syncTime ?? 0) + (proving ?? 0) + perFunction.reduce((acc, { time })=>acc + time, 0))
623
718
  };
624
- const simulatorStats = contractFunctionSimulator.getStats();
625
719
  return new TxProfileResult(executionSteps, {
626
720
  timings,
627
- nodeRPCCalls: simulatorStats.nodeRPCCalls
721
+ nodeRPCCalls: recording.stop()
628
722
  });
629
723
  } catch (err) {
630
724
  throw this.#contextualizeError(err, inspect(txRequest), `profileMode=${profileMode}`);
725
+ } finally{
726
+ // Idempotent cleanup for the error and early-exit paths. The success path already stopped the recording.
727
+ recording.stop();
631
728
  }
632
729
  });
633
730
  }
@@ -653,6 +750,7 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
653
750
  // to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
654
751
  // delete the same read value, or reading values that another simulation is currently modifying).
655
752
  return this.#putInJobQueue(async (jobId)=>{
753
+ const recording = this.node.startRecording();
656
754
  try {
657
755
  const totalTimer = new Timer();
658
756
  const txInfo = {
@@ -684,7 +782,7 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
684
782
  let publicInputs;
685
783
  let executionSteps = [];
686
784
  if (skipKernels) {
687
- ({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, (addr, sel)=>this.contractStore.getDebugFunctionName(addr, sel), this.node));
785
+ ({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, (addr, sel)=>this.#getDebugFunctionName(addr, sel, anchorBlockHeader), this.node));
688
786
  } else {
689
787
  // Kernel logic, plus proving of all private functions and kernels.
690
788
  ({ publicInputs, executionSteps } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, anchorBlockHeader, {
@@ -702,7 +800,7 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
702
800
  publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement, overrides);
703
801
  publicSimulationTime = publicSimulationTimer.ms();
704
802
  if (publicOutput?.debugLogs?.length) {
705
- await displayDebugLogs(publicOutput.debugLogs, (addr)=>this.contractStore.getDebugContractName(addr));
803
+ await displayDebugLogs(publicOutput.debugLogs, (addr)=>this.#getDebugContractName(addr, anchorBlockHeader));
706
804
  }
707
805
  }
708
806
  let validationTime;
@@ -742,13 +840,15 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
742
840
  revertReason: publicOutput.revertReason
743
841
  } : {}
744
842
  });
745
- const simulatorStats = contractFunctionSimulator.getStats();
746
843
  return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(privateSimulationResult, publicOutput, {
747
844
  timings,
748
- nodeRPCCalls: simulatorStats.nodeRPCCalls
845
+ nodeRPCCalls: recording.stop()
749
846
  });
750
847
  } catch (err) {
751
848
  throw this.#contextualizeError(err, inspect(txRequest), `simulatePublic=${simulatePublic}`, `skipTxValidation=${skipTxValidation}`, `scopes=${scopes.map((s)=>s.toString()).join(', ')}`);
849
+ } finally{
850
+ // Idempotent cleanup for the error and early-exit paths. The success path already stopped the recording.
851
+ recording.stop();
752
852
  }
753
853
  });
754
854
  }
@@ -762,6 +862,7 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
762
862
  // to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
763
863
  // delete the same read value, or reading values that another execution is currently modifying).
764
864
  return this.#putInJobQueue(async (jobId)=>{
865
+ const recording = this.node.startRecording();
765
866
  try {
766
867
  const totalTimer = new Timer();
767
868
  const syncTimer = new Timer();
@@ -786,20 +887,22 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
786
887
  perFunction,
787
888
  unaccounted: totalTime - (syncTime + perFunction.reduce((acc, { time })=>acc + time, 0))
788
889
  };
789
- const simulationStats = contractFunctionSimulator.getStats();
790
890
  return {
791
891
  result: executionResult,
792
892
  offchainEffects,
793
893
  anchorBlockTimestamp: anchorBlockHeader.globalVariables.timestamp,
794
894
  stats: {
795
895
  timings,
796
- nodeRPCCalls: simulationStats.nodeRPCCalls
896
+ nodeRPCCalls: recording.stop()
797
897
  }
798
898
  };
799
899
  } catch (err) {
800
900
  const { to, name, args } = call;
801
901
  const stringifiedArgs = args.map((arg)=>arg.toString()).join(', ');
802
902
  throw this.#contextualizeError(err, `executeUtility ${to}:${name}(${stringifiedArgs})`, `scopes=${scopes.map((s)=>s.toString()).join(', ')}`);
903
+ } finally{
904
+ // Idempotent cleanup for the error and early-exit paths. The success path already stopped the recording.
905
+ recording.stop();
803
906
  }
804
907
  });
805
908
  }