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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (397) hide show
  1. package/dest/bin/check_oracle_version.js +8 -23
  2. package/dest/bin/index.d.ts +2 -2
  3. package/dest/bin/index.d.ts.map +1 -1
  4. package/dest/bin/index.js +1 -1
  5. package/dest/bin/oracle_version_helpers.d.ts +16 -8
  6. package/dest/bin/oracle_version_helpers.d.ts.map +1 -1
  7. package/dest/bin/oracle_version_helpers.js +22 -69
  8. package/dest/block_synchronizer/block_stream_source.d.ts +5 -5
  9. package/dest/block_synchronizer/block_stream_source.d.ts.map +1 -1
  10. package/dest/block_synchronizer/block_stream_source.js +4 -29
  11. package/dest/block_synchronizer/block_synchronizer.d.ts +18 -14
  12. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  13. package/dest/block_synchronizer/block_synchronizer.js +54 -18
  14. package/dest/config/index.d.ts +2 -1
  15. package/dest/config/index.d.ts.map +1 -1
  16. package/dest/config/index.js +1 -0
  17. package/dest/contract/contract_class_service.d.ts +31 -0
  18. package/dest/contract/contract_class_service.d.ts.map +1 -0
  19. package/dest/contract/contract_class_service.js +68 -0
  20. package/dest/contract/contract_sync_service.d.ts +48 -0
  21. package/dest/contract/contract_sync_service.d.ts.map +1 -0
  22. package/dest/{contract_sync → contract}/contract_sync_service.js +26 -45
  23. package/dest/contract/helpers.d.ts +7 -0
  24. package/dest/contract/helpers.d.ts.map +1 -0
  25. package/dest/contract/helpers.js +20 -0
  26. package/dest/contract/skip_sync_contracts.d.ts +11 -0
  27. package/dest/contract/skip_sync_contracts.d.ts.map +1 -0
  28. package/dest/contract/skip_sync_contracts.js +18 -0
  29. package/dest/contract_function_simulator/anchored_contract_data.d.ts +36 -0
  30. package/dest/contract_function_simulator/anchored_contract_data.d.ts.map +1 -0
  31. package/dest/contract_function_simulator/anchored_contract_data.js +54 -0
  32. package/dest/contract_function_simulator/aztec_node_read_cache.d.ts +39 -0
  33. package/dest/contract_function_simulator/aztec_node_read_cache.d.ts.map +1 -0
  34. package/dest/contract_function_simulator/aztec_node_read_cache.js +60 -0
  35. package/dest/contract_function_simulator/contract_function_simulator.d.ts +19 -18
  36. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  37. package/dest/contract_function_simulator/contract_function_simulator.js +63 -32
  38. package/dest/contract_function_simulator/execution_note_cache.d.ts +3 -9
  39. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  40. package/dest/contract_function_simulator/execution_note_cache.js +8 -28
  41. package/dest/contract_function_simulator/index.d.ts +19 -10
  42. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  43. package/dest/contract_function_simulator/index.js +6 -9
  44. package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts +8 -27
  45. package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts.map +1 -1
  46. package/dest/contract_function_simulator/noir-structs/bounded_vec.js +8 -23
  47. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts +9 -0
  48. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts.map +1 -0
  49. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.js +1 -0
  50. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts +7 -0
  51. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts.map +1 -0
  52. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.js +1 -0
  53. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
  54. package/dest/contract_function_simulator/noir-structs/fact.d.ts +16 -0
  55. package/dest/contract_function_simulator/noir-structs/fact.d.ts.map +1 -0
  56. package/dest/contract_function_simulator/noir-structs/fact.js +6 -0
  57. package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts +27 -0
  58. package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts.map +1 -0
  59. package/dest/contract_function_simulator/noir-structs/fact_collection.js +31 -0
  60. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +11 -12
  61. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
  62. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +6 -49
  63. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +10 -8
  64. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  65. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -60
  66. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +2 -2
  67. package/dest/contract_function_simulator/noir-structs/option.d.ts +9 -11
  68. package/dest/contract_function_simulator/noir-structs/option.d.ts.map +1 -1
  69. package/dest/contract_function_simulator/noir-structs/option.js +18 -13
  70. package/dest/contract_function_simulator/noir-structs/origin_block.d.ts +11 -0
  71. package/dest/contract_function_simulator/noir-structs/origin_block.d.ts.map +1 -0
  72. package/dest/contract_function_simulator/noir-structs/origin_block.js +5 -0
  73. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts +11 -0
  74. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts.map +1 -0
  75. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.js +4 -0
  76. package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +6 -9
  77. package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts.map +1 -1
  78. package/dest/contract_function_simulator/noir-structs/provided_secret.js +1 -24
  79. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts +28 -0
  80. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts.map +1 -0
  81. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.js +50 -0
  82. package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts +19 -0
  83. package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts.map +1 -0
  84. package/dest/contract_function_simulator/noir-structs/resolved_tx.js +9 -0
  85. package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts +15 -0
  86. package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts.map +1 -0
  87. package/dest/contract_function_simulator/noir-structs/tx_effect_data.js +5 -0
  88. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +6 -11
  89. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
  90. package/dest/contract_function_simulator/noir-structs/utility_context.js +1 -20
  91. package/dest/contract_function_simulator/oracle/acir_callback.d.ts +21 -0
  92. package/dest/contract_function_simulator/oracle/acir_callback.d.ts.map +1 -0
  93. package/dest/contract_function_simulator/oracle/acir_callback.js +115 -0
  94. package/dest/contract_function_simulator/oracle/index.d.ts +2 -13
  95. package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -1
  96. package/dest/contract_function_simulator/oracle/index.js +1 -1
  97. package/dest/contract_function_simulator/oracle/interfaces.d.ts +2 -3
  98. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  99. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts +39 -0
  100. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts.map +1 -0
  101. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.js +107 -0
  102. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -14
  103. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  104. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -24
  105. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +43 -31
  106. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
  107. package/dest/contract_function_simulator/oracle/oracle_registry.js +259 -29
  108. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +180 -45
  109. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -1
  110. package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +1024 -341
  111. package/dest/contract_function_simulator/oracle/private_execution.d.ts +1 -1
  112. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  113. package/dest/contract_function_simulator/oracle/private_execution.js +2 -3
  114. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +21 -8
  115. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  116. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +132 -22
  117. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +77 -34
  118. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  119. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +247 -106
  120. package/dest/contract_function_simulator/transient_array_service.d.ts +31 -0
  121. package/dest/contract_function_simulator/transient_array_service.d.ts.map +1 -0
  122. package/dest/contract_function_simulator/transient_array_service.js +62 -0
  123. package/dest/debug/pxe_debug_utils.d.ts +2 -2
  124. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  125. package/dest/entrypoints/client/bundle/index.d.ts +2 -1
  126. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  127. package/dest/entrypoints/client/bundle/index.js +1 -0
  128. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  129. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  130. package/dest/entrypoints/client/bundle/utils.js +17 -6
  131. package/dest/entrypoints/client/lazy/index.d.ts +2 -1
  132. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  133. package/dest/entrypoints/client/lazy/index.js +1 -0
  134. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  135. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  136. package/dest/entrypoints/client/lazy/utils.js +17 -6
  137. package/dest/entrypoints/client/store.d.ts +14 -0
  138. package/dest/entrypoints/client/store.d.ts.map +1 -0
  139. package/dest/entrypoints/client/store.js +42 -0
  140. package/dest/entrypoints/pxe_creation_options.d.ts +9 -3
  141. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  142. package/dest/entrypoints/server/index.d.ts +6 -3
  143. package/dest/entrypoints/server/index.d.ts.map +1 -1
  144. package/dest/entrypoints/server/index.js +4 -2
  145. package/dest/entrypoints/server/store.d.ts +18 -0
  146. package/dest/entrypoints/server/store.d.ts.map +1 -0
  147. package/dest/entrypoints/server/store.js +28 -0
  148. package/dest/entrypoints/server/utils.d.ts +1 -1
  149. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  150. package/dest/entrypoints/server/utils.js +16 -4
  151. package/dest/error_enriching.d.ts +5 -3
  152. package/dest/error_enriching.d.ts.map +1 -1
  153. package/dest/error_enriching.js +13 -11
  154. package/dest/hooks/execution_hooks.d.ts +31 -11
  155. package/dest/hooks/execution_hooks.d.ts.map +1 -1
  156. package/dest/hooks/execution_hooks.js +3 -3
  157. package/dest/hooks/index.d.ts +4 -3
  158. package/dest/hooks/index.d.ts.map +1 -1
  159. package/dest/hooks/index.js +1 -0
  160. package/dest/hooks/resolve_custom_request.d.ts +23 -0
  161. package/dest/hooks/resolve_custom_request.d.ts.map +1 -0
  162. package/dest/hooks/resolve_custom_request.js +3 -0
  163. package/dest/hooks/resolve_tagging_secret_strategy.d.ts +50 -0
  164. package/dest/hooks/resolve_tagging_secret_strategy.d.ts.map +1 -0
  165. package/dest/hooks/resolve_tagging_secret_strategy.js +3 -0
  166. package/dest/logs/log_service.d.ts +8 -6
  167. package/dest/logs/log_service.d.ts.map +1 -1
  168. package/dest/logs/log_service.js +88 -28
  169. package/dest/messages/tx_resolver_service.d.ts +17 -0
  170. package/dest/messages/tx_resolver_service.d.ts.map +1 -0
  171. package/dest/messages/{message_context_service.js → tx_resolver_service.js} +13 -8
  172. package/dest/notes/note_service.d.ts +1 -1
  173. package/dest/notes/note_service.js +1 -1
  174. package/dest/oracle_version.d.ts +3 -3
  175. package/dest/oracle_version.js +5 -5
  176. package/dest/private_kernel/batch_planner.d.ts +1 -1
  177. package/dest/private_kernel/batch_planner.d.ts.map +1 -1
  178. package/dest/private_kernel/batch_planner.js +1 -1
  179. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +1 -1
  180. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  181. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +6 -2
  182. package/dest/private_kernel/hints/test_utils.js +1 -1
  183. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  184. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  185. package/dest/private_kernel/private_kernel_execution_prover.js +61 -40
  186. package/dest/private_kernel/private_kernel_oracle.d.ts +4 -2
  187. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  188. package/dest/private_kernel/private_kernel_oracle.js +17 -5
  189. package/dest/pxe.d.ts +114 -48
  190. package/dest/pxe.d.ts.map +1 -1
  191. package/dest/pxe.js +225 -139
  192. package/dest/storage/allowed_scopes.d.ts +6 -0
  193. package/dest/storage/allowed_scopes.d.ts.map +1 -0
  194. package/dest/storage/allowed_scopes.js +7 -0
  195. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -6
  196. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
  197. package/dest/storage/anchor_block_store/anchor_block_store.js +8 -6
  198. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +1 -1
  199. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -1
  200. package/dest/storage/backwards_compatibility_tests/schema_tests.js +129 -49
  201. package/dest/storage/capsule_store/capsule_service.d.ts +1 -1
  202. package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -1
  203. package/dest/storage/capsule_store/capsule_service.js +6 -9
  204. package/dest/storage/contract_store/contract_store.d.ts +27 -24
  205. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  206. package/dest/storage/contract_store/contract_store.js +64 -75
  207. package/dest/storage/fact_store/fact_service.d.ts +22 -0
  208. package/dest/storage/fact_store/fact_service.d.ts.map +1 -0
  209. package/dest/storage/fact_store/fact_service.js +45 -0
  210. package/dest/storage/fact_store/fact_store.d.ts +95 -0
  211. package/dest/storage/fact_store/fact_store.d.ts.map +1 -0
  212. package/dest/storage/fact_store/fact_store.js +408 -0
  213. package/dest/storage/fact_store/fact_store_keys.d.ts +34 -0
  214. package/dest/storage/fact_store/fact_store_keys.d.ts.map +1 -0
  215. package/dest/storage/fact_store/fact_store_keys.js +50 -0
  216. package/dest/storage/fact_store/index.d.ts +6 -0
  217. package/dest/storage/fact_store/index.d.ts.map +1 -0
  218. package/dest/storage/fact_store/index.js +4 -0
  219. package/dest/storage/fact_store/origin_state.d.ts +59 -0
  220. package/dest/storage/fact_store/origin_state.d.ts.map +1 -0
  221. package/dest/storage/fact_store/origin_state.js +60 -0
  222. package/dest/storage/fact_store/stored_fact.d.ts +32 -0
  223. package/dest/storage/fact_store/stored_fact.d.ts.map +1 -0
  224. package/dest/storage/fact_store/stored_fact.js +64 -0
  225. package/dest/storage/index.d.ts +3 -2
  226. package/dest/storage/index.d.ts.map +1 -1
  227. package/dest/storage/index.js +2 -1
  228. package/dest/storage/metadata.d.ts +2 -2
  229. package/dest/storage/metadata.d.ts.map +1 -1
  230. package/dest/storage/metadata.js +1 -1
  231. package/dest/storage/note_store/note_store.d.ts +42 -33
  232. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  233. package/dest/storage/note_store/note_store.js +197 -168
  234. package/dest/storage/note_store/stored_note.d.ts +3 -8
  235. package/dest/storage/note_store/stored_note.d.ts.map +1 -1
  236. package/dest/storage/note_store/stored_note.js +4 -20
  237. package/dest/storage/open_pxe_stores.d.ts +5 -3
  238. package/dest/storage/open_pxe_stores.d.ts.map +1 -1
  239. package/dest/storage/open_pxe_stores.js +5 -3
  240. package/dest/storage/private_event_store/private_event_store.d.ts +13 -16
  241. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  242. package/dest/storage/private_event_store/private_event_store.js +40 -43
  243. package/dest/storage/store_identity.d.ts +35 -0
  244. package/dest/storage/store_identity.d.ts.map +1 -0
  245. package/dest/storage/store_identity.js +44 -0
  246. package/dest/storage/tagging_store/index.d.ts +2 -2
  247. package/dest/storage/tagging_store/index.d.ts.map +1 -1
  248. package/dest/storage/tagging_store/index.js +1 -1
  249. package/dest/storage/tagging_store/sender_tagging_store.d.ts +19 -3
  250. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  251. package/dest/storage/tagging_store/sender_tagging_store.js +48 -11
  252. package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts +51 -0
  253. package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts.map +1 -0
  254. package/dest/storage/tagging_store/tagging_secret_sources_store.js +105 -0
  255. package/dest/tagging/constants.d.ts +3 -2
  256. package/dest/tagging/constants.d.ts.map +1 -1
  257. package/dest/tagging/constants.js +28 -10
  258. package/dest/tagging/index.d.ts +2 -2
  259. package/dest/tagging/index.d.ts.map +1 -1
  260. package/dest/tagging/index.js +1 -1
  261. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +26 -8
  262. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -1
  263. package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +95 -20
  264. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +1 -1
  265. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +1 -1
  266. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  267. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +6 -2
  268. package/dest/tagging/testing/tag_query_test_utils.d.ts +6 -0
  269. package/dest/tagging/testing/tag_query_test_utils.d.ts.map +1 -0
  270. package/dest/tagging/testing/tag_query_test_utils.js +10 -0
  271. package/package.json +17 -17
  272. package/src/bin/check_oracle_version.ts +8 -24
  273. package/src/bin/index.ts +1 -1
  274. package/src/bin/oracle_version_helpers.ts +23 -90
  275. package/src/block_synchronizer/block_stream_source.ts +6 -45
  276. package/src/block_synchronizer/block_synchronizer.ts +70 -29
  277. package/src/config/index.ts +1 -0
  278. package/src/contract/contract_class_service.ts +83 -0
  279. package/src/{contract_sync → contract}/contract_sync_service.ts +37 -50
  280. package/src/contract/helpers.ts +35 -0
  281. package/src/contract/skip_sync_contracts.ts +23 -0
  282. package/src/contract_function_simulator/anchored_contract_data.ts +74 -0
  283. package/src/contract_function_simulator/aztec_node_read_cache.ts +89 -0
  284. package/src/contract_function_simulator/contract_function_simulator.ts +96 -42
  285. package/src/contract_function_simulator/execution_note_cache.ts +7 -28
  286. package/src/contract_function_simulator/index.ts +48 -13
  287. package/src/contract_function_simulator/noir-structs/bounded_vec.ts +12 -24
  288. package/src/contract_function_simulator/noir-structs/contract_class_log_data.ts +9 -0
  289. package/src/contract_function_simulator/noir-structs/embedded_curve_point.ts +4 -0
  290. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
  291. package/src/contract_function_simulator/noir-structs/fact.ts +13 -0
  292. package/src/contract_function_simulator/noir-structs/fact_collection.ts +64 -0
  293. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +20 -46
  294. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +13 -60
  295. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +2 -2
  296. package/src/contract_function_simulator/noir-structs/option.ts +17 -11
  297. package/src/contract_function_simulator/noir-structs/origin_block.ts +8 -0
  298. package/src/contract_function_simulator/noir-structs/pending_tagged_log.ts +12 -0
  299. package/src/contract_function_simulator/noir-structs/provided_secret.ts +4 -26
  300. package/src/contract_function_simulator/noir-structs/resolved_tagging_strategy.ts +66 -0
  301. package/src/contract_function_simulator/noir-structs/resolved_tx.ts +19 -0
  302. package/src/contract_function_simulator/noir-structs/tx_effect_data.ts +16 -0
  303. package/src/contract_function_simulator/noir-structs/utility_context.ts +5 -17
  304. package/src/contract_function_simulator/oracle/acir_callback.ts +154 -0
  305. package/src/contract_function_simulator/oracle/index.ts +1 -15
  306. package/src/contract_function_simulator/oracle/interfaces.ts +1 -2
  307. package/src/contract_function_simulator/oracle/legacy_oracle_registry.ts +147 -0
  308. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +6 -21
  309. package/src/contract_function_simulator/oracle/oracle_registry.ts +172 -47
  310. package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +814 -315
  311. package/src/contract_function_simulator/oracle/private_execution.ts +2 -3
  312. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +167 -30
  313. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +399 -135
  314. package/src/contract_function_simulator/transient_array_service.ts +91 -0
  315. package/src/debug/pxe_debug_utils.ts +1 -1
  316. package/src/entrypoints/client/bundle/index.ts +1 -0
  317. package/src/entrypoints/client/bundle/utils.ts +24 -5
  318. package/src/entrypoints/client/lazy/index.ts +1 -0
  319. package/src/entrypoints/client/lazy/utils.ts +24 -5
  320. package/src/entrypoints/client/store.ts +54 -0
  321. package/src/entrypoints/pxe_creation_options.ts +8 -2
  322. package/src/entrypoints/server/index.ts +6 -2
  323. package/src/entrypoints/server/store.ts +47 -0
  324. package/src/entrypoints/server/utils.ts +31 -9
  325. package/src/error_enriching.ts +27 -11
  326. package/src/hooks/execution_hooks.ts +32 -12
  327. package/src/hooks/index.ts +8 -2
  328. package/src/hooks/resolve_custom_request.ts +24 -0
  329. package/src/hooks/resolve_tagging_secret_strategy.ts +60 -0
  330. package/src/logs/log_service.ts +100 -37
  331. package/src/messages/{message_context_service.ts → tx_resolver_service.ts} +16 -9
  332. package/src/notes/note_service.ts +1 -1
  333. package/src/oracle_version.ts +5 -5
  334. package/src/private_kernel/batch_planner.ts +0 -1
  335. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +11 -1
  336. package/src/private_kernel/hints/test_utils.ts +1 -1
  337. package/src/private_kernel/private_kernel_execution_prover.ts +112 -56
  338. package/src/private_kernel/private_kernel_oracle.ts +23 -4
  339. package/src/pxe.ts +328 -159
  340. package/src/storage/allowed_scopes.ts +14 -0
  341. package/src/storage/anchor_block_store/anchor_block_store.ts +8 -6
  342. package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +6 -6
  343. package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +1 -1
  344. package/src/storage/backwards_compatibility_tests/__snapshots__/FactStore.json +40 -0
  345. package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +12 -12
  346. package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +9 -15
  347. package/src/storage/backwards_compatibility_tests/__snapshots__/NoteStore.json +24 -4
  348. package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +11 -3
  349. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +12 -4
  350. package/src/storage/backwards_compatibility_tests/__snapshots__/TaggingSecretSourcesStore.json +30 -0
  351. package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +29 -9
  352. package/src/storage/backwards_compatibility_tests/schema_tests.ts +141 -50
  353. package/src/storage/capsule_store/capsule_service.ts +8 -13
  354. package/src/storage/contract_store/contract_store.ts +86 -93
  355. package/src/storage/fact_store/fact_service.ts +69 -0
  356. package/src/storage/fact_store/fact_store.ts +487 -0
  357. package/src/storage/fact_store/fact_store_keys.ts +75 -0
  358. package/src/storage/fact_store/index.ts +15 -0
  359. package/src/storage/fact_store/origin_state.ts +84 -0
  360. package/src/storage/fact_store/stored_fact.ts +80 -0
  361. package/src/storage/index.ts +2 -1
  362. package/src/storage/metadata.ts +1 -1
  363. package/src/storage/note_store/note_store.ts +226 -187
  364. package/src/storage/note_store/stored_note.ts +5 -27
  365. package/src/storage/open_pxe_stores.ts +6 -3
  366. package/src/storage/private_event_store/private_event_store.ts +49 -55
  367. package/src/storage/store_identity.ts +72 -0
  368. package/src/storage/tagging_store/index.ts +1 -1
  369. package/src/storage/tagging_store/sender_tagging_store.ts +62 -15
  370. package/src/storage/tagging_store/tagging_secret_sources_store.ts +138 -0
  371. package/src/tagging/constants.ts +30 -10
  372. package/src/tagging/index.ts +1 -1
  373. package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +148 -30
  374. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +1 -1
  375. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +6 -2
  376. package/src/tagging/testing/tag_query_test_utils.ts +11 -0
  377. package/dest/contract_function_simulator/oracle/oracle.d.ts +0 -89
  378. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +0 -1
  379. package/dest/contract_function_simulator/oracle/oracle.js +0 -552
  380. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +0 -6
  381. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +0 -1
  382. package/dest/contract_function_simulator/proxied_contract_data_source.js +0 -51
  383. package/dest/contract_sync/contract_sync_service.d.ts +0 -42
  384. package/dest/contract_sync/contract_sync_service.d.ts.map +0 -1
  385. package/dest/contract_sync/helpers.d.ts +0 -27
  386. package/dest/contract_sync/helpers.d.ts.map +0 -1
  387. package/dest/contract_sync/helpers.js +0 -53
  388. package/dest/messages/message_context_service.d.ts +0 -17
  389. package/dest/messages/message_context_service.d.ts.map +0 -1
  390. package/dest/storage/tagging_store/sender_address_book_store.d.ts +0 -14
  391. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +0 -1
  392. package/dest/storage/tagging_store/sender_address_book_store.js +0 -36
  393. package/src/contract_function_simulator/oracle/oracle.ts +0 -711
  394. package/src/contract_function_simulator/proxied_contract_data_source.ts +0 -60
  395. package/src/contract_sync/helpers.ts +0 -86
  396. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderAddressBookStore.json +0 -16
  397. package/src/storage/tagging_store/sender_address_book_store.ts +0 -48
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';
63
+ import { ContractClassService } from './contract/contract_class_service.js';
64
+ import { ContractSyncService } from './contract/contract_sync_service.js';
57
65
  import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
58
66
  import {
59
67
  ContractFunctionSimulator,
60
68
  generateSimulatedProvingResult,
61
69
  } from './contract_function_simulator/contract_function_simulator.js';
62
- import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
63
70
  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
71
  import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
67
72
  import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
68
73
  import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
69
74
  import type { ExecutionHooks } from './hooks/index.js';
70
75
  import { JobCoordinator } from './job_coordinator/job_coordinator.js';
71
- import { MessageContextService } from './messages/message_context_service.js';
76
+ import { TxResolverService } from './messages/tx_resolver_service.js';
72
77
  import {
73
78
  PrivateKernelExecutionProver,
74
79
  type PrivateKernelExecutionProverConfig,
@@ -78,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,6 +196,34 @@ 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.
@@ -185,20 +231,23 @@ export type PXECreateArgs = {
185
231
  export class PXE {
186
232
  private constructor(
187
233
  private node: AztecNode,
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,19 +308,22 @@ 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
+ const contractClassService = new ContractClassService(node, contractStore);
267
319
  const contractSyncService = new ContractSyncService(
268
320
  node,
269
321
  contractStore,
322
+ contractClassService,
270
323
  noteStore,
271
324
  createLogger('pxe:contract_sync', bindings),
272
325
  );
273
- const messageContextService = new MessageContextService(node);
326
+ const txResolver = new TxResolverService(node);
274
327
 
275
328
  const synchronizer = new BlockSynchronizer(
276
329
  node,
@@ -278,8 +331,10 @@ export class PXE {
278
331
  anchorBlockStore,
279
332
  noteStore,
280
333
  privateEventStore,
334
+ factStore,
281
335
  l2TipsStore,
282
336
  contractSyncService,
337
+ contractClassService,
283
338
  config,
284
339
  bindings,
285
340
  );
@@ -291,6 +346,7 @@ export class PXE {
291
346
  recipientTaggingStore,
292
347
  privateEventStore,
293
348
  noteStore,
349
+ factStore,
294
350
  contractSyncService,
295
351
  ]);
296
352
 
@@ -300,20 +356,23 @@ export class PXE {
300
356
 
301
357
  const pxe = new PXE(
302
358
  node,
359
+ nodeDebug,
303
360
  store,
304
361
  synchronizer,
305
362
  keyStore,
306
363
  contractStore,
307
364
  noteStore,
308
365
  capsuleStore,
366
+ factStore,
309
367
  anchorBlockStore,
310
368
  senderTaggingStore,
311
- senderAddressBookStore,
369
+ taggingSecretSourcesStore,
312
370
  recipientTaggingStore,
313
371
  addressStore,
314
372
  privateEventStore,
315
373
  contractSyncService,
316
- messageContextService,
374
+ contractClassService,
375
+ txResolver,
317
376
  l2TipsStore,
318
377
  simulator,
319
378
  proverEnabled,
@@ -344,10 +403,10 @@ export class PXE {
344
403
  // Internal methods
345
404
 
346
405
  #getSimulatorForTx(overrides?: { contracts?: ContractOverrides }) {
347
- const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
348
-
349
406
  return new ContractFunctionSimulator({
350
- contractStore: proxyContractStore,
407
+ contractStore: this.contractStore,
408
+ contractClassService: this.contractClassService,
409
+ overrides: overrides?.contracts,
351
410
  noteStore: this.noteStore,
352
411
  keyStore: this.keyStore,
353
412
  addressStore: this.addressStore,
@@ -355,16 +414,41 @@ export class PXE {
355
414
  l2TipsStore: this.l2TipsStore,
356
415
  senderTaggingStore: this.senderTaggingStore,
357
416
  recipientTaggingStore: this.recipientTaggingStore,
358
- senderAddressBookStore: this.senderAddressBookStore,
417
+ taggingSecretSourcesStore: this.taggingSecretSourcesStore,
359
418
  capsuleStore: this.capsuleStore,
419
+ factStore: this.factStore,
360
420
  privateEventStore: this.privateEventStore,
361
421
  simulator: this.simulator,
362
422
  contractSyncService: this.contractSyncService,
363
- messageContextService: this.messageContextService,
423
+ txResolver: this.txResolver,
364
424
  hooks: this.hooks,
365
425
  });
366
426
  }
367
427
 
428
+ /** Best-effort debug function name for the class `address` runs at `anchorBlockHeader`. Used for log display only. */
429
+ async #getDebugFunctionName(
430
+ address: AztecAddress,
431
+ selector: FunctionSelector,
432
+ anchorBlockHeader: BlockHeader,
433
+ ): Promise<string> {
434
+ try {
435
+ const classId = await this.contractClassService.getCurrentClassId(address, anchorBlockHeader);
436
+ return classId ? await this.contractStore.getDebugFunctionName(classId, selector) : `${address}:${selector}`;
437
+ } catch {
438
+ return `${address}:${selector}`;
439
+ }
440
+ }
441
+
442
+ /** Best-effort debug contract name for the class `address` runs at `anchorBlockHeader`. Used for log display only. */
443
+ async #getDebugContractName(address: AztecAddress, anchorBlockHeader: BlockHeader): Promise<string | undefined> {
444
+ try {
445
+ const classId = await this.contractClassService.getCurrentClassId(address, anchorBlockHeader);
446
+ return classId ? await this.contractStore.getDebugContractName(classId) : undefined;
447
+ } catch {
448
+ return undefined;
449
+ }
450
+ }
451
+
368
452
  #contextualizeError(err: Error, ...context: string[]): Error {
369
453
  let contextStr = '';
370
454
  if (context.length > 0) {
@@ -428,7 +512,14 @@ export class PXE {
428
512
 
429
513
  async #registerPreloadedContracts() {
430
514
  const contracts = await this.preloadedContractsProvider.getPreloadedContracts();
431
- await Promise.all(contracts.map(({ instance, artifact }) => this.registerContract({ instance, artifact })));
515
+ await Promise.all(
516
+ contracts.map(async ({ instance, artifact }) => {
517
+ if (artifact) {
518
+ await this.registerContractClass(artifact);
519
+ }
520
+ await this.registerContract(instance);
521
+ }),
522
+ );
432
523
  this.log.verbose(`Registered preloaded contracts in pxe`, {
433
524
  contracts: contracts.map(({ instance }) => instance.address.toString()),
434
525
  });
@@ -465,8 +556,6 @@ export class PXE {
465
556
  );
466
557
 
467
558
  const result = await contractFunctionSimulator.run(txRequest, {
468
- contractAddress,
469
- selector: functionSelector,
470
559
  anchorBlockHeader,
471
560
  scopes,
472
561
  jobId,
@@ -476,7 +565,7 @@ export class PXE {
476
565
  return result;
477
566
  } catch (err) {
478
567
  if (err instanceof SimulationError) {
479
- await enrichSimulationError(err, this.contractStore, this.log);
568
+ await enrichSimulationError(err, this.contractStore, this.contractClassService, anchorBlockHeader, this.log);
480
569
  }
481
570
  throw err;
482
571
  }
@@ -511,7 +600,8 @@ export class PXE {
511
600
  return { result, offchainEffects };
512
601
  } catch (err) {
513
602
  if (err instanceof SimulationError) {
514
- await enrichSimulationError(err, this.contractStore, this.log);
603
+ const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
604
+ await enrichSimulationError(err, this.contractStore, this.contractClassService, anchorBlockHeader, this.log);
515
605
  }
516
606
  throw err;
517
607
  }
@@ -535,7 +625,14 @@ export class PXE {
535
625
  } catch (err) {
536
626
  if (err instanceof SimulationError) {
537
627
  try {
538
- await enrichPublicSimulationError(err, this.contractStore, this.log);
628
+ const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
629
+ await enrichPublicSimulationError(
630
+ err,
631
+ this.contractStore,
632
+ this.contractClassService,
633
+ anchorBlockHeader,
634
+ this.log,
635
+ );
539
636
  } catch (enrichErr) {
540
637
  this.log.error(`Failed to enrich public simulation error: ${enrichErr}`);
541
638
  }
@@ -562,7 +659,13 @@ export class PXE {
562
659
  anchorBlockHeader: BlockHeader,
563
660
  config: PrivateKernelExecutionProverConfig,
564
661
  ): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
565
- const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHeader);
662
+ const kernelOracle = new PrivateKernelOracle(
663
+ this.contractStore,
664
+ this.contractClassService,
665
+ this.keyStore,
666
+ this.node,
667
+ anchorBlockHeader,
668
+ );
566
669
  const kernelTraceProver = new PrivateKernelExecutionProver(
567
670
  kernelOracle,
568
671
  proofCreator,
@@ -606,11 +709,11 @@ export class PXE {
606
709
  }
607
710
 
608
711
  /**
609
- * Returns the contract instance for a given address, if it's registered in the PXE.
712
+ * Returns the address preimage of the contract instance at a given address, if it's registered in the PXE.
610
713
  * @param address - The contract address.
611
- * @returns The contract instance if found, undefined otherwise.
714
+ * @returns The contract instance address preimage if found, undefined otherwise.
612
715
  */
613
- public getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
716
+ public getContractInstance(address: AztecAddress): Promise<ContractInstancePreimageWithAddress | undefined> {
614
717
  return this.contractStore.getContractInstance(address);
615
718
  }
616
719
 
@@ -624,18 +727,22 @@ export class PXE {
624
727
  }
625
728
 
626
729
  /**
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.
730
+ * Registers a user account in PXE.
731
+ *
732
+ * PXE holds the account's four privacy secret keys but only the *public* message-signing and fallback keys: their
733
+ * secret keys are withheld, since PXE is not trusted to hold them.
631
734
  *
632
- * @param secretKey - Secret key of the corresponding user master public key.
735
+ * Does nothing if the account is already registered.
736
+ *
737
+ * The four privacy secret keys can be retrieved later with {@link getAccountSecretKeys}.
738
+ *
739
+ * @param keys - The account's privacy keys: four secret keys plus the message-signing and fallback public keys.
633
740
  * @param partialAddress - The partial address of the account contract corresponding to the account being registered.
634
741
  * @returns The complete address of the account.
635
742
  */
636
- public async registerAccount(secretKey: Fr, partialAddress: PartialAddress): Promise<CompleteAddress> {
743
+ public async registerAccount(keys: AccountPrivacyKeys, partialAddress: PartialAddress): Promise<CompleteAddress> {
637
744
  const accounts = await this.keyStore.getAccounts();
638
- const accountCompleteAddress = await this.keyStore.addAccount(secretKey, partialAddress);
745
+ const accountCompleteAddress = await this.keyStore.addAccount(keys, partialAddress);
639
746
  if (accounts.some(a => a.equals(accountCompleteAddress.address))) {
640
747
  this.log.info(`Account:\n "${accountCompleteAddress.address.toString()}"\n already registered.`);
641
748
  return accountCompleteAddress;
@@ -649,62 +756,189 @@ export class PXE {
649
756
  }
650
757
 
651
758
  /**
652
- * Registers a sender in this PXE.
759
+ * Retrieves the four privacy secret keys PXE holds for a registered account (nullifier-hiding, incoming-viewing,
760
+ * outgoing-viewing, tagging).
653
761
  *
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.
762
+ * These do NOT grant control over an account's assets, e.g. they are insufficient to impersonate the account or to
763
+ * spend notes, but they _do_ guard the account's privacy. Parties that have knowledge of these keys can decrypt all
764
+ * messages sent to the account, discover all of their on-chain activity, including notes, events, etc.
656
765
  *
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.
766
+ * Security is paramount when handling these keys, which should itself be a very rare occurrence. Other than exporting
767
+ * and then importing an account into a separate PXE/wallet, there is typically no need for a wallet to ever access
768
+ * these keys. Applications should NEVER be given access to them.
769
+ *
770
+ * @throws If the account is not registered.
660
771
  */
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
- }
772
+ public getAccountSecretKeys(account: AztecAddress): Promise<AccountPrivacySecretKeys> {
773
+ return this.keyStore.getAccountSecretKeys(account);
774
+ }
667
775
 
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;
776
+ /**
777
+ * Registers a source from which this PXE derives the tagging secrets it scans for to discover incoming private logs.
778
+ * See {@link TaggingSecretSource} for the meaning of each variant. Does nothing if the source is already registered.
779
+ *
780
+ * After a new source is added we clear the cache tracking which contracts have finished syncing, so every contract
781
+ * re-syncs against the new source's logs (whose notes/events could belong to any contract). Already-discovered
782
+ * notes/events are not discarded.
783
+ */
784
+ public async registerTaggingSecretSource(source: TaggingSecretSource): Promise<void> {
785
+ let wasAdded: boolean;
786
+
787
+ switch (source.kind) {
788
+ case 'address-derived':
789
+ wasAdded = await this.#registerSender(source.sender);
790
+ break;
791
+ case 'arbitrary-secret':
792
+ wasAdded = await this.#registerSharedSecret(source.recipient, 'arbitrary-secret', source.secret);
793
+ break;
794
+ case 'handshake':
795
+ wasAdded = await this.#registerSharedSecret(
796
+ source.recipient,
797
+ 'handshake',
798
+ await this.#deriveHandshakeSecret(source.recipient, source.ephPk),
799
+ );
800
+ break;
801
+ default: {
802
+ const _: never = source;
803
+ throw new Error('Unhandled tagging secret source kind');
804
+ }
672
805
  }
673
806
 
674
- const wasAdded = await this.senderAddressBookStore.addSender(sender);
675
-
676
807
  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.
808
+ // Queued to avoid wiping while a job is in flight.
680
809
  await this.#putInJobQueue(() => Promise.resolve(this.contractSyncService.wipe()));
681
- } else {
682
- this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
683
810
  }
811
+ }
684
812
 
685
- return sender;
813
+ /**
814
+ * Removes a previously registered tagging secret source, identified by its registered form (see
815
+ * {@link getTaggingSecretSources}). Does nothing if it was not registered.
816
+ */
817
+ public async removeTaggingSecretSource(source: RegisteredTaggingSecretSource): Promise<void> {
818
+ switch (source.kind) {
819
+ case 'address-derived': {
820
+ const { sender } = source;
821
+ const wasRemoved = await this.taggingSecretSourcesStore.removeSender(sender);
822
+ this.log.info(
823
+ wasRemoved
824
+ ? `Removed sender:\n ${sender.toString()}`
825
+ : `Sender:\n "${sender.toString()}"\n not registered in PXE.`,
826
+ );
827
+ break;
828
+ }
829
+ case 'arbitrary-secret':
830
+ case 'handshake': {
831
+ const { kind, recipient, secret } = source;
832
+ const wasRemoved = await this.taggingSecretSourcesStore.removeSharedSecret(recipient, kind, secret);
833
+ this.log.info(
834
+ wasRemoved
835
+ ? `Removed ${kind} shared secret for recipient:\n ${recipient.toString()}`
836
+ : `No ${kind} shared secret registered for recipient:\n ${recipient.toString()}`,
837
+ );
838
+ break;
839
+ }
840
+ default: {
841
+ const _: never = source;
842
+ throw new Error('Unhandled tagging secret source kind');
843
+ }
844
+ }
686
845
  }
687
846
 
688
847
  /**
689
- * Retrieves senders registered in this PXE.
690
- * @returns Senders registered in this PXE.
848
+ * Retrieves the tagging secret sources registered in this PXE, in their registered form. Without a filter it
849
+ * returns every source; pass `{ kind }` to narrow to a single variant. See {@link RegisteredTaggingSecretSource}.
691
850
  */
692
- public getSenders(): Promise<AztecAddress[]> {
693
- return this.senderAddressBookStore.getSenders();
851
+ public getTaggingSecretSources<K extends RegisteredTaggingSecretSource['kind']>(filter: {
852
+ kind: K;
853
+ }): Promise<Extract<RegisteredTaggingSecretSource, { kind: K }>[]>;
854
+ public getTaggingSecretSources(): Promise<RegisteredTaggingSecretSource[]>;
855
+ public async getTaggingSecretSources(filter?: {
856
+ kind?: RegisteredTaggingSecretSource['kind'];
857
+ }): Promise<RegisteredTaggingSecretSource[]> {
858
+ const [senders, secrets] = await Promise.all([
859
+ this.taggingSecretSourcesStore.getSenders(),
860
+ this.taggingSecretSourcesStore.getAllSharedSecrets(),
861
+ ]);
862
+
863
+ const sources: RegisteredTaggingSecretSource[] = [
864
+ ...senders.map((sender): RegisteredTaggingSecretSource => ({ kind: 'address-derived', sender })),
865
+ ...secrets.map(({ recipient, kind, secret }): RegisteredTaggingSecretSource => ({ kind, recipient, secret })),
866
+ ];
867
+
868
+ return filter?.kind ? sources.filter(source => source.kind === filter.kind) : sources;
869
+ }
870
+
871
+ /** Registers a sender, skipping addresses that belong to a local account. Returns whether it was newly added. */
872
+ async #registerSender(address: AztecAddress): Promise<boolean> {
873
+ if (!(await address.isValid())) {
874
+ throw new Error(
875
+ `Address ${address} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register it as a sender.`,
876
+ );
877
+ }
878
+
879
+ const accounts = await this.keyStore.getAccounts();
880
+ if (accounts.some(a => a.equals(address))) {
881
+ this.log.info(`Sender:\n "${address.toString()}"\n already registered.`);
882
+ return false;
883
+ }
884
+
885
+ const wasAdded = await this.taggingSecretSourcesStore.addSender(address);
886
+ this.log.info(
887
+ wasAdded ? `Added sender:\n ${address.toString()}` : `Sender:\n "${address.toString()}"\n already registered.`,
888
+ );
889
+ return wasAdded;
694
890
  }
695
891
 
696
892
  /**
697
- * Removes a sender registered in this PXE.
698
- * @param sender - The address of the sender to remove.
893
+ * Derives the shared secret of a handshake from its ephemeral public key: the raw ECDH secret
894
+ * `S = addressSecret(recipient) * ephPk` with the forgery protection applied,
895
+ * matching the protected secret the registry stores and the derivation the recipient-side scan uses for
896
+ * handshakes discovered onchain. The ephemeral key is reconstructed from its x-coordinate with a positive y,
897
+ * matching how the protocol generates it.
898
+ *
899
+ * @throws If `ephPk` is not the x-coordinate of a Grumpkin curve point, or if `recipient` is not an account of
900
+ * this PXE, since the derivation needs its keys.
699
901
  */
700
- public async removeSender(sender: AztecAddress): Promise<void> {
701
- const wasRemoved = await this.senderAddressBookStore.removeSender(sender);
902
+ async #deriveHandshakeSecret(recipient: AztecAddress, ephPk: Fr): Promise<Point> {
903
+ let ephPkPoint: Point;
904
+ try {
905
+ ephPkPoint = await Point.fromXAndSign(ephPk, true);
906
+ } catch {
907
+ throw new Error(`Ephemeral public key x-coordinate ${ephPk} does not correspond to a Grumpkin curve point.`);
908
+ }
702
909
 
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.`);
910
+ const completeAddress = await this.addressStore.getCompleteAddress(recipient);
911
+ if (!completeAddress || !(await this.keyStore.hasAccount(recipient))) {
912
+ throw new Error(
913
+ `Recipient ${recipient} is not an account of this PXE. A handshake's shared secret can only be derived for an account whose keys are held.`,
914
+ );
915
+ }
916
+
917
+ const ivskM = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
918
+ const addressSecret = await computeAddressSecret(await completeAddress.getPreaddress(), ivskM);
919
+ const rawSecret = await deriveEcdhSharedSecretPoint(addressSecret, ephPkPoint);
920
+ return protectFromForgery(rawSecret, ephPkPoint, await recipient.toAddressPoint());
921
+ }
922
+
923
+ /** Registers a resolved shared secret scoped to a recipient. Returns whether it was newly added. */
924
+ async #registerSharedSecret(recipient: AztecAddress, kind: SharedSecretKind, secret: Point): Promise<boolean> {
925
+ if (!(await recipient.isValid())) {
926
+ throw new Error(
927
+ `Recipient ${recipient} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register a shared secret for it.`,
928
+ );
929
+ }
930
+
931
+ if (secret.isZero() || !secret.isOnCurve()) {
932
+ throw new Error(`Shared secret ${secret} is not a valid non-zero point on the Grumpkin curve.`);
707
933
  }
934
+
935
+ const wasAdded = await this.taggingSecretSourcesStore.addSharedSecret(recipient, kind, secret);
936
+ this.log.info(
937
+ wasAdded
938
+ ? `Added ${kind} shared secret for recipient:\n ${recipient.toString()}`
939
+ : `${kind} shared secret already registered for recipient:\n ${recipient.toString()}`,
940
+ );
941
+ return wasAdded;
708
942
  }
709
943
 
710
944
  /**
@@ -728,98 +962,33 @@ export class PXE {
728
962
  */
729
963
  public async registerContractClass(artifact: ContractArtifact): Promise<void> {
730
964
  const contractClassId = await this.contractStore.addContractArtifact(artifact);
965
+ // Publishing the artifact's public function signatures to the node is part of "registering a class", so that
966
+ // node-side debugging works regardless of which entrypoint (registerContractClass or registerContract) was used.
967
+ const publicFunctionSignatures = artifact.functions
968
+ .filter(fn => fn.functionType === FunctionType.PUBLIC)
969
+ .map(fn => decodeFunctionSignature(fn.name, fn.parameters));
970
+ if (publicFunctionSignatures.length > 0) {
971
+ await this.nodeDebug?.registerContractFunctionSignatures(publicFunctionSignatures);
972
+ }
731
973
  this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
732
974
  }
733
975
 
734
976
  /**
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.
977
+ * Registers a deployed contract instance so its private state can be synced and its functions simulated. The
978
+ * artifact for the class the instance runs must be registered separately via {@link registerContractClass}, before
979
+ * or after this call; registration performs no validation, so a missing or mismatched artifact only surfaces when
980
+ * the contract is later simulated. This is automatically called by aztec.js when deploying a contract.
739
981
  *
740
- * @param contract - A contract instance to register, with an optional artifact which can be omitted if the contract class has already been registered.
982
+ * @param instance - The address preimage of the contract instance to register. The address is derived from it.
983
+ * @returns The address of the registered instance.
741
984
  */
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.
985
+ public registerContract(instance: ContractInstancePreimage): Promise<AztecAddress> {
986
+ // Run inside the job queue so we can't race a concurrent simulation while writing the instance to the store.
795
987
  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}`);
988
+ const address = await computeContractAddressFromInstance(instance);
989
+ await this.contractStore.addContractInstance({ ...instance, address });
990
+ this.log.info(`Added contract at ${address}`, { address });
991
+ return address;
823
992
  });
824
993
  }
825
994
 
@@ -1081,7 +1250,7 @@ export class PXE {
1081
1250
  if (skipKernels) {
1082
1251
  ({ publicInputs, executionSteps } = await generateSimulatedProvingResult(
1083
1252
  privateExecutionResult,
1084
- (addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
1253
+ (addr, sel) => this.#getDebugFunctionName(addr, sel, anchorBlockHeader),
1085
1254
  this.node,
1086
1255
  ));
1087
1256
  } else {
@@ -1108,7 +1277,7 @@ export class PXE {
1108
1277
  publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement, overrides);
1109
1278
  publicSimulationTime = publicSimulationTimer.ms();
1110
1279
  if (publicOutput?.debugLogs?.length) {
1111
- await displayDebugLogs(publicOutput.debugLogs, addr => this.contractStore.getDebugContractName(addr));
1280
+ await displayDebugLogs(publicOutput.debugLogs, addr => this.#getDebugContractName(addr, anchorBlockHeader));
1112
1281
  }
1113
1282
  }
1114
1283