@aztec/pxe 0.0.1-commit.2f68f620 → 0.0.1-commit.3100065

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 (350) hide show
  1. package/dest/bin/check_oracle_version.js +10 -20
  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 +26 -1
  6. package/dest/bin/oracle_version_helpers.d.ts.map +1 -1
  7. package/dest/bin/oracle_version_helpers.js +162 -1
  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/config/package_info.js +1 -1
  18. package/dest/contract/contract_class_service.d.ts +31 -0
  19. package/dest/contract/contract_class_service.d.ts.map +1 -0
  20. package/dest/contract/contract_class_service.js +68 -0
  21. package/dest/contract/contract_sync_service.d.ts +48 -0
  22. package/dest/contract/contract_sync_service.d.ts.map +1 -0
  23. package/dest/{contract_sync → contract}/contract_sync_service.js +26 -45
  24. package/dest/contract/helpers.d.ts +7 -0
  25. package/dest/contract/helpers.d.ts.map +1 -0
  26. package/dest/contract/helpers.js +20 -0
  27. package/dest/contract_function_simulator/anchored_contract_data.d.ts +36 -0
  28. package/dest/contract_function_simulator/anchored_contract_data.d.ts.map +1 -0
  29. package/dest/contract_function_simulator/anchored_contract_data.js +54 -0
  30. package/dest/contract_function_simulator/aztec_node_read_cache.d.ts +39 -0
  31. package/dest/contract_function_simulator/aztec_node_read_cache.d.ts.map +1 -0
  32. package/dest/contract_function_simulator/aztec_node_read_cache.js +60 -0
  33. package/dest/contract_function_simulator/contract_function_simulator.d.ts +19 -18
  34. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  35. package/dest/contract_function_simulator/contract_function_simulator.js +64 -35
  36. package/dest/contract_function_simulator/execution_note_cache.d.ts +3 -9
  37. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  38. package/dest/contract_function_simulator/execution_note_cache.js +8 -28
  39. package/dest/contract_function_simulator/index.d.ts +19 -10
  40. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  41. package/dest/contract_function_simulator/index.js +7 -9
  42. package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts +8 -27
  43. package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts.map +1 -1
  44. package/dest/contract_function_simulator/noir-structs/bounded_vec.js +8 -23
  45. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts +9 -0
  46. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts.map +1 -0
  47. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.js +1 -0
  48. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts +7 -0
  49. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts.map +1 -0
  50. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.js +1 -0
  51. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
  52. package/dest/contract_function_simulator/noir-structs/fact.d.ts +16 -0
  53. package/dest/contract_function_simulator/noir-structs/fact.d.ts.map +1 -0
  54. package/dest/contract_function_simulator/noir-structs/fact.js +6 -0
  55. package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts +27 -0
  56. package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts.map +1 -0
  57. package/dest/contract_function_simulator/noir-structs/fact_collection.js +31 -0
  58. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +11 -12
  59. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
  60. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +6 -49
  61. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +10 -8
  62. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  63. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -60
  64. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +2 -2
  65. package/dest/contract_function_simulator/noir-structs/option.d.ts +9 -11
  66. package/dest/contract_function_simulator/noir-structs/option.d.ts.map +1 -1
  67. package/dest/contract_function_simulator/noir-structs/option.js +18 -13
  68. package/dest/contract_function_simulator/noir-structs/origin_block.d.ts +11 -0
  69. package/dest/contract_function_simulator/noir-structs/origin_block.d.ts.map +1 -0
  70. package/dest/contract_function_simulator/noir-structs/origin_block.js +5 -0
  71. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts +11 -0
  72. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts.map +1 -0
  73. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.js +4 -0
  74. package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +6 -9
  75. package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts.map +1 -1
  76. package/dest/contract_function_simulator/noir-structs/provided_secret.js +1 -24
  77. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts +28 -0
  78. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts.map +1 -0
  79. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.js +50 -0
  80. package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts +21 -0
  81. package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts.map +1 -0
  82. package/dest/contract_function_simulator/noir-structs/resolved_tx.js +50 -0
  83. package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts +14 -0
  84. package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts.map +1 -0
  85. package/dest/contract_function_simulator/noir-structs/tx_effect_data.js +5 -0
  86. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +6 -11
  87. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
  88. package/dest/contract_function_simulator/noir-structs/utility_context.js +1 -20
  89. package/dest/contract_function_simulator/oracle/acir_callback.d.ts +21 -0
  90. package/dest/contract_function_simulator/oracle/acir_callback.d.ts.map +1 -0
  91. package/dest/contract_function_simulator/oracle/acir_callback.js +115 -0
  92. package/dest/contract_function_simulator/oracle/index.d.ts +2 -13
  93. package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -1
  94. package/dest/contract_function_simulator/oracle/index.js +1 -1
  95. package/dest/contract_function_simulator/oracle/interfaces.d.ts +2 -3
  96. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  97. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts +39 -0
  98. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts.map +1 -0
  99. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.js +107 -0
  100. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -14
  101. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  102. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -24
  103. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +41 -30
  104. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
  105. package/dest/contract_function_simulator/oracle/oracle_registry.js +248 -27
  106. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +123 -40
  107. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -1
  108. package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +947 -264
  109. package/dest/contract_function_simulator/oracle/private_execution.d.ts +1 -1
  110. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  111. package/dest/contract_function_simulator/oracle/private_execution.js +2 -3
  112. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +21 -8
  113. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  114. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +128 -17
  115. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +73 -33
  116. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  117. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +220 -104
  118. package/dest/contract_function_simulator/transient_array_service.d.ts +31 -0
  119. package/dest/contract_function_simulator/transient_array_service.d.ts.map +1 -0
  120. package/dest/contract_function_simulator/transient_array_service.js +62 -0
  121. package/dest/debug/pxe_debug_utils.d.ts +2 -2
  122. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  123. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  124. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  125. package/dest/entrypoints/client/bundle/utils.js +8 -3
  126. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  127. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  128. package/dest/entrypoints/client/lazy/utils.js +8 -3
  129. package/dest/entrypoints/pxe_creation_options.d.ts +9 -3
  130. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  131. package/dest/entrypoints/server/index.d.ts +5 -3
  132. package/dest/entrypoints/server/index.d.ts.map +1 -1
  133. package/dest/entrypoints/server/index.js +3 -2
  134. package/dest/entrypoints/server/utils.d.ts +1 -1
  135. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  136. package/dest/entrypoints/server/utils.js +8 -2
  137. package/dest/error_enriching.d.ts +5 -3
  138. package/dest/error_enriching.d.ts.map +1 -1
  139. package/dest/error_enriching.js +13 -11
  140. package/dest/hooks/execution_hooks.d.ts +31 -11
  141. package/dest/hooks/execution_hooks.d.ts.map +1 -1
  142. package/dest/hooks/execution_hooks.js +3 -3
  143. package/dest/hooks/index.d.ts +4 -3
  144. package/dest/hooks/index.d.ts.map +1 -1
  145. package/dest/hooks/index.js +1 -0
  146. package/dest/hooks/resolve_custom_request.d.ts +23 -0
  147. package/dest/hooks/resolve_custom_request.d.ts.map +1 -0
  148. package/dest/hooks/resolve_custom_request.js +3 -0
  149. package/dest/hooks/resolve_tagging_secret_strategy.d.ts +50 -0
  150. package/dest/hooks/resolve_tagging_secret_strategy.d.ts.map +1 -0
  151. package/dest/hooks/resolve_tagging_secret_strategy.js +3 -0
  152. package/dest/logs/log_service.d.ts +7 -6
  153. package/dest/logs/log_service.d.ts.map +1 -1
  154. package/dest/logs/log_service.js +79 -28
  155. package/dest/messages/tx_resolver_service.d.ts +17 -0
  156. package/dest/messages/tx_resolver_service.d.ts.map +1 -0
  157. package/dest/messages/{message_context_service.js → tx_resolver_service.js} +8 -8
  158. package/dest/oracle_version.d.ts +3 -3
  159. package/dest/oracle_version.js +5 -5
  160. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +1 -1
  161. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  162. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +6 -2
  163. package/dest/private_kernel/hints/test_utils.js +1 -1
  164. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  165. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  166. package/dest/private_kernel/private_kernel_execution_prover.js +17 -36
  167. package/dest/private_kernel/private_kernel_oracle.d.ts +4 -2
  168. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  169. package/dest/private_kernel/private_kernel_oracle.js +17 -5
  170. package/dest/pxe.d.ts +114 -48
  171. package/dest/pxe.d.ts.map +1 -1
  172. package/dest/pxe.js +222 -139
  173. package/dest/storage/allowed_scopes.d.ts +6 -0
  174. package/dest/storage/allowed_scopes.d.ts.map +1 -0
  175. package/dest/storage/allowed_scopes.js +7 -0
  176. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -6
  177. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
  178. package/dest/storage/anchor_block_store/anchor_block_store.js +8 -6
  179. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +1 -1
  180. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -1
  181. package/dest/storage/backwards_compatibility_tests/schema_tests.js +129 -49
  182. package/dest/storage/capsule_store/capsule_service.d.ts +1 -1
  183. package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -1
  184. package/dest/storage/capsule_store/capsule_service.js +6 -9
  185. package/dest/storage/contract_store/contract_store.d.ts +27 -24
  186. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  187. package/dest/storage/contract_store/contract_store.js +64 -75
  188. package/dest/storage/fact_store/fact_service.d.ts +22 -0
  189. package/dest/storage/fact_store/fact_service.d.ts.map +1 -0
  190. package/dest/storage/fact_store/fact_service.js +45 -0
  191. package/dest/storage/fact_store/fact_store.d.ts +95 -0
  192. package/dest/storage/fact_store/fact_store.d.ts.map +1 -0
  193. package/dest/storage/fact_store/fact_store.js +408 -0
  194. package/dest/storage/fact_store/fact_store_keys.d.ts +34 -0
  195. package/dest/storage/fact_store/fact_store_keys.d.ts.map +1 -0
  196. package/dest/storage/fact_store/fact_store_keys.js +50 -0
  197. package/dest/storage/fact_store/index.d.ts +6 -0
  198. package/dest/storage/fact_store/index.d.ts.map +1 -0
  199. package/dest/storage/fact_store/index.js +4 -0
  200. package/dest/storage/fact_store/origin_state.d.ts +57 -0
  201. package/dest/storage/fact_store/origin_state.d.ts.map +1 -0
  202. package/dest/storage/fact_store/origin_state.js +53 -0
  203. package/dest/storage/fact_store/stored_fact.d.ts +32 -0
  204. package/dest/storage/fact_store/stored_fact.d.ts.map +1 -0
  205. package/dest/storage/fact_store/stored_fact.js +64 -0
  206. package/dest/storage/index.d.ts +3 -2
  207. package/dest/storage/index.d.ts.map +1 -1
  208. package/dest/storage/index.js +2 -1
  209. package/dest/storage/metadata.d.ts +2 -2
  210. package/dest/storage/metadata.d.ts.map +1 -1
  211. package/dest/storage/metadata.js +1 -1
  212. package/dest/storage/note_store/note_store.d.ts +42 -33
  213. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  214. package/dest/storage/note_store/note_store.js +197 -168
  215. package/dest/storage/note_store/stored_note.d.ts +3 -8
  216. package/dest/storage/note_store/stored_note.d.ts.map +1 -1
  217. package/dest/storage/note_store/stored_note.js +4 -20
  218. package/dest/storage/open_pxe_stores.d.ts +5 -3
  219. package/dest/storage/open_pxe_stores.d.ts.map +1 -1
  220. package/dest/storage/open_pxe_stores.js +5 -3
  221. package/dest/storage/private_event_store/private_event_store.d.ts +13 -16
  222. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  223. package/dest/storage/private_event_store/private_event_store.js +40 -43
  224. package/dest/storage/tagging_store/index.d.ts +2 -2
  225. package/dest/storage/tagging_store/index.d.ts.map +1 -1
  226. package/dest/storage/tagging_store/index.js +1 -1
  227. package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts +51 -0
  228. package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts.map +1 -0
  229. package/dest/storage/tagging_store/tagging_secret_sources_store.js +105 -0
  230. package/dest/tagging/constants.d.ts +2 -2
  231. package/dest/tagging/constants.d.ts.map +1 -1
  232. package/dest/tagging/constants.js +18 -9
  233. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +21 -8
  234. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -1
  235. package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +56 -16
  236. package/package.json +17 -17
  237. package/src/bin/check_oracle_version.ts +10 -19
  238. package/src/bin/index.ts +5 -1
  239. package/src/bin/oracle_version_helpers.ts +190 -0
  240. package/src/block_synchronizer/block_stream_source.ts +6 -45
  241. package/src/block_synchronizer/block_synchronizer.ts +70 -29
  242. package/src/config/index.ts +1 -0
  243. package/src/config/package_info.ts +1 -1
  244. package/src/contract/contract_class_service.ts +83 -0
  245. package/src/{contract_sync → contract}/contract_sync_service.ts +37 -50
  246. package/src/contract/helpers.ts +35 -0
  247. package/src/contract_function_simulator/anchored_contract_data.ts +74 -0
  248. package/src/contract_function_simulator/aztec_node_read_cache.ts +89 -0
  249. package/src/contract_function_simulator/contract_function_simulator.ts +97 -45
  250. package/src/contract_function_simulator/execution_note_cache.ts +7 -28
  251. package/src/contract_function_simulator/index.ts +26 -11
  252. package/src/contract_function_simulator/noir-structs/bounded_vec.ts +12 -24
  253. package/src/contract_function_simulator/noir-structs/contract_class_log_data.ts +9 -0
  254. package/src/contract_function_simulator/noir-structs/embedded_curve_point.ts +4 -0
  255. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
  256. package/src/contract_function_simulator/noir-structs/fact.ts +13 -0
  257. package/src/contract_function_simulator/noir-structs/fact_collection.ts +64 -0
  258. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +20 -46
  259. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +13 -60
  260. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +2 -2
  261. package/src/contract_function_simulator/noir-structs/option.ts +17 -11
  262. package/src/contract_function_simulator/noir-structs/origin_block.ts +8 -0
  263. package/src/contract_function_simulator/noir-structs/pending_tagged_log.ts +12 -0
  264. package/src/contract_function_simulator/noir-structs/provided_secret.ts +4 -26
  265. package/src/contract_function_simulator/noir-structs/resolved_tagging_strategy.ts +66 -0
  266. package/src/contract_function_simulator/noir-structs/resolved_tx.ts +53 -0
  267. package/src/contract_function_simulator/noir-structs/tx_effect_data.ts +15 -0
  268. package/src/contract_function_simulator/noir-structs/utility_context.ts +5 -17
  269. package/src/contract_function_simulator/oracle/acir_callback.ts +154 -0
  270. package/src/contract_function_simulator/oracle/index.ts +1 -15
  271. package/src/contract_function_simulator/oracle/interfaces.ts +1 -2
  272. package/src/contract_function_simulator/oracle/legacy_oracle_registry.ts +147 -0
  273. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +6 -21
  274. package/src/contract_function_simulator/oracle/oracle_registry.ts +162 -41
  275. package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +659 -248
  276. package/src/contract_function_simulator/oracle/private_execution.ts +2 -3
  277. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +156 -24
  278. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +357 -131
  279. package/src/contract_function_simulator/transient_array_service.ts +91 -0
  280. package/src/debug/pxe_debug_utils.ts +1 -1
  281. package/src/entrypoints/client/bundle/utils.ts +10 -3
  282. package/src/entrypoints/client/lazy/utils.ts +10 -3
  283. package/src/entrypoints/pxe_creation_options.ts +8 -2
  284. package/src/entrypoints/server/index.ts +5 -2
  285. package/src/entrypoints/server/utils.ts +10 -2
  286. package/src/error_enriching.ts +27 -11
  287. package/src/hooks/execution_hooks.ts +32 -12
  288. package/src/hooks/index.ts +8 -2
  289. package/src/hooks/resolve_custom_request.ts +24 -0
  290. package/src/hooks/resolve_tagging_secret_strategy.ts +60 -0
  291. package/src/logs/log_service.ts +91 -37
  292. package/src/messages/{message_context_service.ts → tx_resolver_service.ts} +16 -9
  293. package/src/oracle_version.ts +5 -5
  294. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +11 -1
  295. package/src/private_kernel/hints/test_utils.ts +1 -1
  296. package/src/private_kernel/private_kernel_execution_prover.ts +22 -52
  297. package/src/private_kernel/private_kernel_oracle.ts +23 -4
  298. package/src/pxe.ts +325 -159
  299. package/src/storage/allowed_scopes.ts +14 -0
  300. package/src/storage/anchor_block_store/anchor_block_store.ts +8 -6
  301. package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +6 -6
  302. package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +1 -1
  303. package/src/storage/backwards_compatibility_tests/__snapshots__/FactStore.json +40 -0
  304. package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +12 -12
  305. package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +9 -15
  306. package/src/storage/backwards_compatibility_tests/__snapshots__/NoteStore.json +24 -4
  307. package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +11 -3
  308. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +12 -4
  309. package/src/storage/backwards_compatibility_tests/__snapshots__/TaggingSecretSourcesStore.json +30 -0
  310. package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +29 -9
  311. package/src/storage/backwards_compatibility_tests/schema_tests.ts +141 -50
  312. package/src/storage/capsule_store/capsule_service.ts +8 -13
  313. package/src/storage/contract_store/contract_store.ts +86 -93
  314. package/src/storage/fact_store/fact_service.ts +69 -0
  315. package/src/storage/fact_store/fact_store.ts +487 -0
  316. package/src/storage/fact_store/fact_store_keys.ts +75 -0
  317. package/src/storage/fact_store/index.ts +14 -0
  318. package/src/storage/fact_store/origin_state.ts +75 -0
  319. package/src/storage/fact_store/stored_fact.ts +80 -0
  320. package/src/storage/index.ts +2 -1
  321. package/src/storage/metadata.ts +1 -1
  322. package/src/storage/note_store/note_store.ts +226 -187
  323. package/src/storage/note_store/stored_note.ts +5 -27
  324. package/src/storage/open_pxe_stores.ts +6 -3
  325. package/src/storage/private_event_store/private_event_store.ts +49 -55
  326. package/src/storage/tagging_store/index.ts +1 -1
  327. package/src/storage/tagging_store/tagging_secret_sources_store.ts +138 -0
  328. package/src/tagging/constants.ts +19 -9
  329. package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +77 -16
  330. package/dest/contract_function_simulator/oracle/oracle.d.ts +0 -89
  331. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +0 -1
  332. package/dest/contract_function_simulator/oracle/oracle.js +0 -552
  333. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +0 -6
  334. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +0 -1
  335. package/dest/contract_function_simulator/proxied_contract_data_source.js +0 -51
  336. package/dest/contract_sync/contract_sync_service.d.ts +0 -42
  337. package/dest/contract_sync/contract_sync_service.d.ts.map +0 -1
  338. package/dest/contract_sync/helpers.d.ts +0 -27
  339. package/dest/contract_sync/helpers.d.ts.map +0 -1
  340. package/dest/contract_sync/helpers.js +0 -53
  341. package/dest/messages/message_context_service.d.ts +0 -17
  342. package/dest/messages/message_context_service.d.ts.map +0 -1
  343. package/dest/storage/tagging_store/sender_address_book_store.d.ts +0 -14
  344. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +0 -1
  345. package/dest/storage/tagging_store/sender_address_book_store.js +0 -36
  346. package/src/contract_function_simulator/oracle/oracle.ts +0 -711
  347. package/src/contract_function_simulator/proxied_contract_data_source.ts +0 -60
  348. package/src/contract_sync/helpers.ts +0 -86
  349. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderAddressBookStore.json +0 -16
  350. package/src/storage/tagging_store/sender_address_book_store.ts +0 -48
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/pxe",
3
- "version": "0.0.1-commit.2f68f620",
3
+ "version": "0.0.1-commit.3100065",
4
4
  "type": "module",
5
5
  "typedocOptions": {
6
6
  "entryPoints": [
@@ -71,20 +71,20 @@
71
71
  ]
72
72
  },
73
73
  "dependencies": {
74
- "@aztec/bb-prover": "0.0.1-commit.2f68f620",
75
- "@aztec/bb.js": "0.0.1-commit.2f68f620",
76
- "@aztec/builder": "0.0.1-commit.2f68f620",
77
- "@aztec/constants": "0.0.1-commit.2f68f620",
78
- "@aztec/ethereum": "0.0.1-commit.2f68f620",
79
- "@aztec/foundation": "0.0.1-commit.2f68f620",
80
- "@aztec/key-store": "0.0.1-commit.2f68f620",
81
- "@aztec/kv-store": "0.0.1-commit.2f68f620",
82
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.2f68f620",
83
- "@aztec/noir-types": "0.0.1-commit.2f68f620",
84
- "@aztec/protocol-contracts": "0.0.1-commit.2f68f620",
85
- "@aztec/simulator": "0.0.1-commit.2f68f620",
86
- "@aztec/standard-contracts": "0.0.1-commit.2f68f620",
87
- "@aztec/stdlib": "0.0.1-commit.2f68f620",
74
+ "@aztec/bb-prover": "0.0.1-commit.3100065",
75
+ "@aztec/bb.js": "0.0.1-commit.3100065",
76
+ "@aztec/builder": "0.0.1-commit.3100065",
77
+ "@aztec/constants": "0.0.1-commit.3100065",
78
+ "@aztec/ethereum": "0.0.1-commit.3100065",
79
+ "@aztec/foundation": "0.0.1-commit.3100065",
80
+ "@aztec/key-store": "0.0.1-commit.3100065",
81
+ "@aztec/kv-store": "0.0.1-commit.3100065",
82
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.3100065",
83
+ "@aztec/noir-types": "0.0.1-commit.3100065",
84
+ "@aztec/protocol-contracts": "0.0.1-commit.3100065",
85
+ "@aztec/simulator": "0.0.1-commit.3100065",
86
+ "@aztec/standard-contracts": "0.0.1-commit.3100065",
87
+ "@aztec/stdlib": "0.0.1-commit.3100065",
88
88
  "koa": "^2.16.1",
89
89
  "koa-router": "^13.1.1",
90
90
  "lodash.omit": "^4.5.0",
@@ -93,8 +93,8 @@
93
93
  "viem": "npm:@aztec/viem@2.38.2"
94
94
  },
95
95
  "devDependencies": {
96
- "@aztec/noir-test-contracts.js": "0.0.1-commit.2f68f620",
97
- "@aztec/world-state": "0.0.1-commit.2f68f620",
96
+ "@aztec/noir-test-contracts.js": "0.0.1-commit.3100065",
97
+ "@aztec/world-state": "0.0.1-commit.3100065",
98
98
  "@jest/globals": "^30.0.0",
99
99
  "@types/jest": "^30.0.0",
100
100
  "@types/lodash.omit": "^4.5.7",
@@ -4,36 +4,27 @@ import { dirname, join } from 'path';
4
4
  import { fileURLToPath } from 'url';
5
5
 
6
6
  import { ORACLE_INTERFACE_HASH, ORACLE_VERSION_MAJOR } from '../oracle_version.js';
7
- import { getOracleInterfaceSignature, readNumericGlobal } from './oracle_version_helpers.js';
7
+ import { getOracleRegistrySignature, readNumericGlobal } from './oracle_version_helpers.js';
8
8
 
9
9
  /**
10
10
  * Verifies that the Oracle interface matches the expected interface hash.
11
11
  *
12
12
  * The Oracle interface needs to be versioned to ensure compatibility between Aztec.nr and PXE. This function computes
13
- * a hash of the Oracle interface and compares it against a known hash. If they don't match, it means the interface has
14
- * changed and the oracle version needs to be bumped:
15
- * - If the change is backward-breaking (e.g. removing/renaming an oracle), bump ORACLE_VERSION_MAJOR.
13
+ * a hash of the `ORACLE_REGISTRY` declaration (where each oracle's parameter names, parameter types, and return type
14
+ * live) and compares it against a known hash. If they don't match, it means the interface has changed and the oracle
15
+ * version needs to be bumped:
16
+ * - If the change is backward-breaking (e.g. removing/renaming an oracle, or changing its params/return), bump
17
+ * ORACLE_VERSION_MAJOR.
16
18
  * - If the change is an oracle addition (non-breaking), bump ORACLE_VERSION_MINOR.
17
19
  */
18
20
  function assertOracleInterfaceMatches(): void {
19
- const excludedProps = [
20
- 'handler',
21
- 'constructor',
22
- 'toACIRCallback',
23
- 'handlerAsMisc',
24
- 'handlerAsUtility',
25
- 'handlerAsPrivate',
26
- ];
27
-
28
- // Get the path to Oracle.ts source file
29
- // The script runs from dest/bin/ after compilation, so we need to go up to the package root
30
- // then into src/ to find the source file
21
+ // The script runs from dest/bin/ after compilation, so we go up to the package root then into src/ to find
22
+ // the source file.
31
23
  const currentDir = dirname(fileURLToPath(import.meta.url));
32
- // Go up from dest/bin/ or src/bin/ to the package root (pxe/), then into src/
33
24
  const packageRoot = dirname(dirname(currentDir)); // Go up from bin/ to pxe/
34
- const oracleSourcePath = join(packageRoot, 'src/contract_function_simulator/oracle/oracle.ts');
25
+ const registrySourcePath = join(packageRoot, 'src/contract_function_simulator/oracle/oracle_registry.ts');
35
26
 
36
- const oracleInterfaceSignature = getOracleInterfaceSignature(oracleSourcePath, ['Oracle'], excludedProps);
27
+ const oracleInterfaceSignature = getOracleRegistrySignature(registrySourcePath, 'ORACLE_REGISTRY');
37
28
 
38
29
  // We use keccak256 here just because we already have it in the dependencies.
39
30
  const oracleInterfaceHash = keccak256String(oracleInterfaceSignature);
package/src/bin/index.ts CHANGED
@@ -1 +1,5 @@
1
- export { getOracleInterfaceSignature, readNumericGlobal } from './oracle_version_helpers.js';
1
+ export {
2
+ getOracleInterfaceSignature,
3
+ getOracleRegistrySignature,
4
+ readNumericGlobal,
5
+ } from './oracle_version_helpers.js';
@@ -60,6 +60,58 @@ export function getOracleInterfaceSignature(sourcePath: string, targets: string[
60
60
  return methodSignatures.join('');
61
61
  }
62
62
 
63
+ /**
64
+ * Extracts a deterministic signature string from an oracle registry object literal (e.g. PXE's `ORACLE_REGISTRY`).
65
+ *
66
+ * Reads the registry declaration where each oracle's wire ABI lives: the ordered parameter names with their
67
+ * `TypeMapping` expressions and the return type. The resulting hash is sensitive to parameter, type, and return
68
+ * changes, not just oracle additions and removals.
69
+ *
70
+ * Type expressions are captured as their source text (e.g. `OPTION(AZTEC_ADDRESS)`, `BOUNDED_VEC(NOTE)`), so the
71
+ * signature tracks the composition of types. However, if the internal serialization logic of a `TypeMapping` constant
72
+ * (e.g. `FIELD`) changes without the constant being renamed, the hash will not change.
73
+ *
74
+ * @example
75
+ * // Given a registry like:
76
+ * // export const ORACLE_REGISTRY = {
77
+ * // aztec_utl_foo: makeEntry({ params: [{ name: 'a', type: U32 }], returnType: BOOL }),
78
+ * // aztec_prv_bar: makeEntry(),
79
+ * // } satisfies Record<string, OracleRegistryEntry>;
80
+ * //
81
+ * // Returns (sorted, newline-joined):
82
+ * // "aztec_prv_bar(): void\naztec_utl_foo(a: U32): BOOL"
83
+ *
84
+ * @param sourcePath - Absolute path to the TypeScript source file declaring the registry.
85
+ * @param registryName - Name of the registry constant to read (e.g. `ORACLE_REGISTRY`).
86
+ */
87
+ export function getOracleRegistrySignature(sourcePath: string, registryName: string): string {
88
+ const sourceCode = readFileSync(sourcePath, 'utf-8');
89
+ const sourceFile = ts.createSourceFile(sourcePath, sourceCode, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
90
+
91
+ const registry = findObjectLiteral(sourceFile, registryName);
92
+ if (!registry) {
93
+ throw new Error(`Could not find oracle registry '${registryName}' in ${sourcePath}.`);
94
+ }
95
+
96
+ const oracleSignatures = registry.properties.map(property => {
97
+ if (!ts.isPropertyAssignment(property)) {
98
+ throw new Error(
99
+ `Unexpected member in oracle registry '${registryName}': ${property.getText(sourceFile)}. Spread elements ` +
100
+ `are not supported.`,
101
+ );
102
+ }
103
+
104
+ const oracleName = getPropertyName(property.name, sourceFile);
105
+ const { params, returnType } = extractRegistryEntry(property.initializer, sourceFile);
106
+ const paramSignatures = params.map(param => `${param.name}: ${param.type}`);
107
+ return `${oracleName}(${paramSignatures.join(', ')}): ${returnType}`;
108
+ });
109
+
110
+ oracleSignatures.sort();
111
+
112
+ return oracleSignatures.join('\n');
113
+ }
114
+
63
115
  /**
64
116
  * Reads an integer-valued global constant from a Noir or TypeScript source file.
65
117
  *
@@ -112,6 +164,7 @@ function extractParameterName(param: ts.ParameterDeclaration, sourceFile: ts.Sou
112
164
  return (name as ts.Node).getText(sourceFile);
113
165
  }
114
166
 
167
+ /** Returns the source text of a type annotation, or `'void'` if absent. */
115
168
  function extractTypeString(typeNode: ts.TypeNode | undefined, sourceFile: ts.SourceFile): string {
116
169
  if (!typeNode) {
117
170
  return 'void';
@@ -119,3 +172,140 @@ function extractTypeString(typeNode: ts.TypeNode | undefined, sourceFile: ts.Sou
119
172
 
120
173
  return typeNode.getText(sourceFile).replace(/\s+/g, ' ').trim();
121
174
  }
175
+
176
+ /**
177
+ * Finds a top-level object-literal-valued constant by name, unwrapping `satisfies`/`as`/parenthesized wrappers.
178
+ *
179
+ * @example
180
+ * // `const REGISTRY = { ... } satisfies Record<string, Entry>` => the `{ ... }` ObjectLiteralExpression
181
+ */
182
+ function findObjectLiteral(sourceFile: ts.SourceFile, name: string): ts.ObjectLiteralExpression | undefined {
183
+ let result: ts.ObjectLiteralExpression | undefined;
184
+
185
+ function visit(node: ts.Node) {
186
+ if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.name.text === name && node.initializer) {
187
+ result = unwrapObjectLiteral(node.initializer);
188
+ }
189
+ ts.forEachChild(node, visit);
190
+ }
191
+
192
+ visit(sourceFile);
193
+ return result;
194
+ }
195
+
196
+ /** Peels `satisfies`, `as`, and parenthesized wrappers off an expression to reach the underlying object literal. */
197
+ function unwrapObjectLiteral(node: ts.Expression): ts.ObjectLiteralExpression | undefined {
198
+ let current = node;
199
+ while (ts.isSatisfiesExpression(current) || ts.isAsExpression(current) || ts.isParenthesizedExpression(current)) {
200
+ current = current.expression;
201
+ }
202
+ return ts.isObjectLiteralExpression(current) ? current : undefined;
203
+ }
204
+
205
+ /**
206
+ * Extracts the ordered `params` (names + type expressions) and `returnType` from a `makeEntry({ ... })` call.
207
+ *
208
+ * @example
209
+ * // makeEntry({ params: [{ name: 'a', type: OPTION(FIELD) }], returnType: BOOL })
210
+ * // => { params: [{ name: 'a', type: 'OPTION(FIELD)' }], returnType: 'BOOL' }
211
+ * //
212
+ * // makeEntry()
213
+ * // => { params: [], returnType: 'void' }
214
+ */
215
+ function extractRegistryEntry(
216
+ initializer: ts.Expression,
217
+ sourceFile: ts.SourceFile,
218
+ ): { params: { name: string; type: string }[]; returnType: string } {
219
+ if (!ts.isCallExpression(initializer)) {
220
+ throw new Error(`Expected a makeEntry(...) call but got: ${initializer.getText(sourceFile)}`);
221
+ }
222
+
223
+ const [arg] = initializer.arguments;
224
+ if (arg === undefined) {
225
+ return { params: [], returnType: 'void' };
226
+ }
227
+ if (!ts.isObjectLiteralExpression(arg)) {
228
+ throw new Error(`Expected a makeEntry object argument but got: ${arg.getText(sourceFile)}`);
229
+ }
230
+
231
+ let params: { name: string; type: string }[] = [];
232
+ let returnType = 'void';
233
+
234
+ arg.properties.forEach(property => {
235
+ if (!ts.isPropertyAssignment(property)) {
236
+ throw new Error(`Unexpected makeEntry property: ${property.getText(sourceFile)}`);
237
+ }
238
+ const key = getPropertyName(property.name, sourceFile);
239
+ if (key === 'params') {
240
+ params = extractRegistryParams(property.initializer, sourceFile);
241
+ } else if (key === 'returnType') {
242
+ returnType = normalizeExpressionText(property.initializer, sourceFile);
243
+ } else {
244
+ throw new Error(`Unexpected makeEntry property '${key}'.`);
245
+ }
246
+ });
247
+
248
+ return { params, returnType };
249
+ }
250
+
251
+ /**
252
+ * Extracts `{ name, type }` pairs from the `params` array literal inside a `makeEntry` call.
253
+ */
254
+ function extractRegistryParams(
255
+ initializer: ts.Expression,
256
+ sourceFile: ts.SourceFile,
257
+ ): { name: string; type: string }[] {
258
+ if (!ts.isArrayLiteralExpression(initializer)) {
259
+ throw new Error(`Expected a params array but got: ${initializer.getText(sourceFile)}`);
260
+ }
261
+
262
+ return initializer.elements.map(element => {
263
+ if (!ts.isObjectLiteralExpression(element)) {
264
+ throw new Error(`Expected a param object but got: ${element.getText(sourceFile)}`);
265
+ }
266
+
267
+ let name: string | undefined;
268
+ let type: string | undefined;
269
+ element.properties.forEach(property => {
270
+ if (!ts.isPropertyAssignment(property)) {
271
+ throw new Error(`Unexpected param property: ${property.getText(sourceFile)}`);
272
+ }
273
+ const key = getPropertyName(property.name, sourceFile);
274
+ if (key === 'name') {
275
+ if (!ts.isStringLiteralLike(property.initializer)) {
276
+ throw new Error(`Expected a string literal param name but got: ${property.initializer.getText(sourceFile)}`);
277
+ }
278
+ name = property.initializer.text;
279
+ } else if (key === 'type') {
280
+ type = normalizeExpressionText(property.initializer, sourceFile);
281
+ } else {
282
+ throw new Error(`Unexpected param property '${key}'.`);
283
+ }
284
+ });
285
+
286
+ if (name === undefined || type === undefined) {
287
+ throw new Error(`Param missing 'name' or 'type': ${element.getText(sourceFile)}`);
288
+ }
289
+ return { name, type };
290
+ });
291
+ }
292
+
293
+ /** Returns the text of an identifier or string-literal property name, throwing on computed or numeric names. */
294
+ function getPropertyName(name: ts.PropertyName, sourceFile: ts.SourceFile): string {
295
+ if (ts.isIdentifier(name) || ts.isStringLiteralLike(name)) {
296
+ return name.text;
297
+ }
298
+ throw new Error(`Unsupported property name: ${name.getText(sourceFile)}`);
299
+ }
300
+
301
+ /**
302
+ * Returns the source text of an expression with all whitespace stripped for format-insensitive comparison.
303
+ *
304
+ * @example
305
+ * // `OPTION(\n AZTEC_ADDRESS\n)` => `"OPTION(AZTEC_ADDRESS)"`
306
+ */
307
+ function normalizeExpressionText(node: ts.Expression, sourceFile: ts.SourceFile): string {
308
+ // Type expressions are TypeMapping references and calls (identifiers, parentheses, commas, numbers) with no
309
+ // meaningful whitespace, so we strip it entirely to keep the signature stable across reformatting.
310
+ return node.getText(sourceFile).replace(/\s+/g, '');
311
+ }
@@ -1,29 +1,17 @@
1
- import { Fr } from '@aztec/foundation/curves/bn254';
2
- import {
3
- type BlockData,
4
- type BlockQuery,
5
- type BlocksQuery,
6
- type CheckpointsQuery,
7
- L2Block,
8
- type L2BlockSource,
9
- } from '@aztec/stdlib/block';
10
- import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
1
+ import { type BlockData, type BlockQuery, type BlocksQuery, L2Block, type L2BlockSource } from '@aztec/stdlib/block';
11
2
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
12
3
 
13
4
  /**
14
5
  * Lifts an {@link AztecNode} RPC client into the shape {@link L2BlockStream} expects.
15
- * `getBlocks` requests transaction bodies so that real `L2Block` instances can be constructed;
16
- * `getCheckpoints` requests blocks + L1 info + attestations so that `PublishedCheckpoint`
17
- * instances are fully populated.
6
+ * `getBlocks` requests transaction bodies so that real `L2Block` instances can be constructed. The stream no
7
+ * longer fetches checkpoint payloads (the `chain-checkpointed` event is a thin tip event), so `getCheckpoints`
8
+ * is not part of the lifted shape.
18
9
  */
19
10
  export function blockStreamSourceFromAztecNode(
20
11
  node: AztecNode,
21
- ): Pick<L2BlockSource, 'getBlocks' | 'getBlockData' | 'getL2Tips' | 'getCheckpoints'> {
12
+ ): Pick<L2BlockSource, 'getBlocks' | 'getBlockData' | 'getL2Tips'> {
22
13
  return {
23
- getL2Tips: async () => {
24
- const tips = await node.getChainTips();
25
- return { ...tips, proposedCheckpoint: tips.checkpointed };
26
- },
14
+ getL2Tips: () => node.getChainTips(),
27
15
 
28
16
  async getBlockData(query: BlockQuery): Promise<BlockData | undefined> {
29
17
  const response = await node.getBlock(query);
@@ -50,32 +38,5 @@ export function blockStreamSourceFromAztecNode(
50
38
  const responses = await node.getBlocks(query.from, query.limit, { includeTransactions: true });
51
39
  return responses.map(r => new L2Block(r.archive, r.header, r.body!, r.checkpointNumber, r.indexWithinCheckpoint));
52
40
  },
53
-
54
- async getCheckpoints(query: CheckpointsQuery): Promise<PublishedCheckpoint[]> {
55
- if (!('from' in query)) {
56
- throw new Error('getCheckpoints with epoch query not supported via AztecNode RPC');
57
- }
58
- const { from, limit } = query;
59
- const responses = await node.getCheckpoints(from, limit, {
60
- includeBlocks: true,
61
- includeTransactions: true,
62
- includeL1PublishInfo: true,
63
- includeAttestations: true,
64
- });
65
- return responses.map(r => {
66
- const checkpoint = new Checkpoint(
67
- r.archive,
68
- r.header,
69
- r.blocks!.map(b => new L2Block(b.archive, b.header, b.body!, b.checkpointNumber, b.indexWithinCheckpoint)),
70
- r.number,
71
- r.feeAssetPriceModifier,
72
- );
73
- const l1 =
74
- r.l1?.published === true
75
- ? new L1PublishedData(r.l1.blockNumber, r.l1.timestamp, r.l1.blockHash)
76
- : new L1PublishedData(0n, 0n, Fr.ZERO.toString());
77
- return new PublishedCheckpoint(checkpoint, l1, r.attestations ?? []);
78
- });
79
- },
80
41
  };
81
42
  }
@@ -8,9 +8,11 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
8
8
  import type { BlockHeader } from '@aztec/stdlib/tx';
9
9
 
10
10
  import type { BlockSynchronizerConfig } from '../config/index.js';
11
- import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
12
- import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
13
- import type { NoteStore } from '../storage/note_store/note_store.js';
11
+ import type { ContractClassService } from '../contract/contract_class_service.js';
12
+ import type { ContractSyncService } from '../contract/contract_sync_service.js';
13
+ import type { AnchorBlockStore } from '../storage/anchor_block_store/index.js';
14
+ import type { FactStore } from '../storage/fact_store/fact_store.js';
15
+ import type { NoteStore } from '../storage/note_store/index.js';
14
16
  import type { PrivateEventStore } from '../storage/private_event_store/private_event_store.js';
15
17
  import { blockStreamSourceFromAztecNode } from './block_stream_source.js';
16
18
 
@@ -26,32 +28,33 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
26
28
  protected readonly blockStream: L2BlockStream;
27
29
 
28
30
  constructor(
29
- private node: AztecNode,
30
- private store: AztecAsyncKVStore,
31
- private anchorBlockStore: AnchorBlockStore,
32
- private noteStore: NoteStore,
33
- private privateEventStore: PrivateEventStore,
34
- private l2TipsStore: L2TipsKVStore,
35
- private contractSyncService: ContractSyncService,
36
- private config: Partial<BlockSynchronizerConfig> = {},
31
+ private readonly node: AztecNode,
32
+ private readonly store: AztecAsyncKVStore,
33
+ private readonly anchorBlockStore: AnchorBlockStore,
34
+ private readonly noteStore: NoteStore,
35
+ private readonly privateEventStore: PrivateEventStore,
36
+ private readonly factStore: FactStore,
37
+ private readonly l2TipsStore: L2TipsKVStore,
38
+ private readonly contractSyncService: ContractSyncService,
39
+ private readonly contractClassService: ContractClassService,
40
+ private readonly config: Partial<BlockSynchronizerConfig> = {},
37
41
  bindings?: LoggerBindings,
38
42
  ) {
39
43
  this.log = createLogger('pxe:block_synchronizer', bindings);
40
- this.blockStream = this.createBlockStream(config);
44
+ this.blockStream = this.createBlockStream();
41
45
  this.eventQueue.start();
42
46
  }
43
47
 
44
- protected createBlockStream(config: Partial<BlockSynchronizerConfig>): L2BlockStream {
48
+ protected createBlockStream(): L2BlockStream {
45
49
  return new L2BlockStream(
46
50
  blockStreamSourceFromAztecNode(this.node),
47
51
  this.l2TipsStore,
48
52
  this,
49
53
  createLogger('pxe:block_stream', this.log.getBindings()),
50
54
  {
51
- batchSize: config.l2BlockBatchSize,
52
- // Skipping finalized blocks makes us sync much faster - we only need to download blocks other than the latest one
53
- // in order to detect reorgs, and there can be no reorgs on finalized block, making this safe.
54
- skipFinalized: true,
55
+ // PXE only tracks chain tips (it anchors on tip events and never replays payloads), so the stream runs
56
+ // in tips-only mode: no block downloads, just the tip events that move the anchor and detect reorgs.
57
+ tipsOnly: true,
55
58
  },
56
59
  );
57
60
  }
@@ -62,21 +65,43 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
62
65
  }
63
66
 
64
67
  private async doHandleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void> {
65
- await this.l2TipsStore.handleBlockStreamEvent(event);
66
-
67
68
  switch (event.type) {
68
- case 'blocks-added': {
69
+ case 'chain-proposed': {
69
70
  if (this.config.syncChainTip === undefined || this.config.syncChainTip === 'proposed') {
70
- const lastBlock = event.blocks.at(-1)!;
71
- await this.updateAnchorBlockHeader(lastBlock.header);
71
+ // Fetch the proposed tip header by hash. By-hash is safer than by-number against a same-height reorg.
72
+ const block = await this.node.getBlockData(BlockHash.fromString(event.block.hash));
73
+ if (!block) {
74
+ // The node served a proposed tip whose block data it cannot return — a node inconsistency, since the
75
+ // stream events and the block data come from the same node (same reasoning as the chain-pruned throw
76
+ // below). Throwing here propagates before the tips-store cursor advances, so the cursor stays put and the
77
+ // next sync re-emits chain-proposed (at-least-once). Were we to warn-and-skip, the cursor would advance and
78
+ // a quiet chain would never re-emit, leaving the anchor stale indefinitely.
79
+ throw new Error(
80
+ `Block header for proposed block ${event.block.number} and hash ${event.block.hash} not found. This ` +
81
+ `likely indicates a bug in the node, as we receive block stream events and fetch block headers from ` +
82
+ `the same node.`,
83
+ );
84
+ }
85
+ await this.updateAnchorBlockHeader(block.header);
72
86
  }
73
87
  break;
74
88
  }
89
+ // Never emitted in tips-only mode; PXE anchors on chain-proposed instead. Kept for union exhaustiveness.
90
+ case 'blocks-added':
91
+ break;
75
92
  case 'chain-checkpointed': {
76
93
  if (this.config.syncChainTip === 'checkpointed') {
77
- // Get the last block header from the checkpoint
78
- const lastBlock = event.checkpoint.checkpoint.blocks.at(-1)!;
79
- await this.updateAnchorBlockHeader(lastBlock.header);
94
+ // Fetch the checkpointed tip header by hash. By-hash is safer than by-number against a
95
+ // same-height reorg; a missing result means the block was reorged out between the event
96
+ // and this fetch, so we skip the anchor update and let a later event correct it.
97
+ const block = await this.node.getBlockData(BlockHash.fromString(event.block.hash));
98
+ if (block) {
99
+ await this.updateAnchorBlockHeader(block.header);
100
+ } else {
101
+ this.log.warn(
102
+ `Block header not found for checkpointed block ${event.block.number}, skipping anchor update`,
103
+ );
104
+ }
80
105
  }
81
106
  break;
82
107
  }
@@ -110,10 +135,10 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
110
135
  `Ignoring prune event to block ${event.block.number} greater than current anchor block ${currentAnchorBlockNumber}`,
111
136
  { pruneEvent: event, currentAnchorBlockHeader: currentAnchorBlockHeader.toInspect() },
112
137
  );
113
- return;
138
+ break;
114
139
  }
115
140
 
116
- this.log.warn(`Pruning data after block ${event.block.number} due to reorg`);
141
+ this.log.warn(`Pruning data after block ${event.block.number} due to reorg`, { pruneBlock: event.block });
117
142
 
118
143
  // Note that the following is not necessarily the anchor block that will be used in the transaction - if
119
144
  // the chain has already moved past the reorg, we'll also see blocks-added events that will push the anchor
@@ -129,13 +154,23 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
129
154
 
130
155
  // Operations are wrapped in a single transaction to ensure atomicity.
131
156
  await this.store.transactionAsync(async () => {
132
- await this.noteStore.rollback(event.block.number, currentAnchorBlockNumber);
133
- await this.privateEventStore.rollback(event.block.number, currentAnchorBlockNumber);
157
+ await this.noteStore.rollback(event.block.number);
158
+ await this.privateEventStore.rollback(event.block.number);
159
+ await this.factStore.rollback(event.block.number);
134
160
  await this.updateAnchorBlockHeader(newAnchorBlockHeader);
135
161
  });
136
162
  break;
137
163
  }
164
+ default: {
165
+ const _: never = event;
166
+ break;
167
+ }
138
168
  }
169
+
170
+ // Advance the tips store cursor only after the anchor update / prune rollback above succeeds. If that work
171
+ // throws, the cursor stays put and the stream re-emits this event on the next sync pass (at-least-once),
172
+ // matching the prover-node's handle-first/tips-last ordering. The SerialQueue makes this reorder safe.
173
+ await this.l2TipsStore.handleBlockStreamEvent(event);
139
174
  }
140
175
 
141
176
  /** Updates the anchor block header to the target block */
@@ -144,6 +179,12 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
144
179
  // Therefore, we clear the contract synchronization cache here such that the sync is re-triggered upon new
145
180
  // execution.
146
181
  this.contractSyncService.wipe();
182
+
183
+ // The contract class service keeps a per-block cache - since updating our anchor means it is very unlikely we'd
184
+ // ever re-simulate at past anchors, we wipe its cache to prevent runaway memory growth on very long-lived PXE
185
+ // instances.
186
+ this.contractClassService.wipe();
187
+
147
188
  this.log.verbose(`Updated pxe last block to ${blockHeader.getBlockNumber()}`, blockHeader.toInspect());
148
189
  await this.anchorBlockStore.setHeader(blockHeader);
149
190
  }
@@ -10,6 +10,7 @@ import { type ChainConfig, chainConfigMappings } from '@aztec/stdlib/config';
10
10
  import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
11
11
 
12
12
  export { getPackageInfo } from './package_info.js';
13
+ export * from '../hooks/index.js';
13
14
 
14
15
  /**
15
16
  * Configuration settings for the prover factory
@@ -1,3 +1,3 @@
1
1
  export function getPackageInfo() {
2
- return { version: '6.0.0', name: '@aztec/pxe' };
2
+ return { version: '5.0.0', name: '@aztec/pxe' };
3
3
  }
@@ -0,0 +1,83 @@
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { isProtocolContract } from '@aztec/protocol-contracts';
3
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
5
+ import type { BlockHeader } from '@aztec/stdlib/tx';
6
+
7
+ import type { ContractStore } from '../storage/contract_store/contract_store.js';
8
+
9
+ /**
10
+ * Resolves the contract class id that an address runs at a given anchor block, as tracked by the chain.
11
+ *
12
+ * PXE does not store a contract's current class id: it is mutable, chain-derived state that changes when a contract is
13
+ * upgraded and can be undone by a reorg. Instead this service asks the node for the current class at an anchor block,
14
+ * falling back to a local instance if no upgrades were scheduled.
15
+ */
16
+ export class ContractClassService {
17
+ /**
18
+ * Class ids are cached per `(address, anchorHash)`. This avoid unnecessary network roundtrips in scenarios where
19
+ * multiple executions are done on the same anchor block (e.g. simulation followed by witgen), or when the same
20
+ * contract is invoked multiple times in an execution (e.g. authwit checks).
21
+ * It also means the callers don't need to worry about caching this service's return values, simplifying callsites.
22
+ */
23
+ #cache: Map<string, Promise<Fr | undefined>> = new Map();
24
+
25
+ constructor(
26
+ private node: AztecNode,
27
+ private contractStore: ContractStore,
28
+ ) {}
29
+
30
+ /**
31
+ * Returns the class id that corresponds to `address` as of `anchorBlockHeader`, or `undefined` if no instance is
32
+ * registered for `address`. A missing instance is an absence the caller decides how to handle, not an error; genuine
33
+ * failures (e.g. the node being unreachable) still throw.
34
+ */
35
+ async getCurrentClassId(address: AztecAddress, anchorBlockHeader: BlockHeader): Promise<Fr | undefined> {
36
+ // Protocol contracts are not in the registry and cannot be upgraded, so their original class is always current.
37
+ // Short-circuiting avoids a node round-trip.
38
+ if (isProtocolContract(address)) {
39
+ const instance = await this.contractStore.getContractInstance(address);
40
+ return instance?.originalContractClassId;
41
+ }
42
+
43
+ const key = `${address.toString()}:${(await anchorBlockHeader.hash()).toString()}`;
44
+ let promise = this.#cache.get(key);
45
+ if (!promise) {
46
+ promise = (async () => {
47
+ // The node resolves the current class from the same scheduled value change the AVM enforces against the public
48
+ // data tree. If the contract was upgraded the node returns a non-undefined instance; an undefined result means
49
+ // no upgrade happened (or the node has no record of it, e.g. it was never publicly deployed), so the original
50
+ // class is current.
51
+
52
+ const nodeInstance = await this.node.getContract(address, await anchorBlockHeader.hash());
53
+
54
+ if (nodeInstance) {
55
+ return nodeInstance.currentContractClassId;
56
+ } else {
57
+ return (await this.contractStore.getContractInstance(address))?.originalContractClassId;
58
+ }
59
+ })().catch(err => {
60
+ this.#cache.delete(key);
61
+ throw err;
62
+ });
63
+ this.#cache.set(key, promise);
64
+ }
65
+
66
+ const classId = await promise;
67
+ if (classId === undefined) {
68
+ // Don't memoize a missing instance: it may be registered later in this PXE (e.g. via contract sync
69
+ // mid-execution), and a cached miss would then hide it. Only successful resolutions stay cached.
70
+ this.#cache.delete(key);
71
+ }
72
+ return classId;
73
+ }
74
+
75
+ /**
76
+ * Clears the cache.
77
+ *
78
+ * This is not required for correctness, only to limit how much memory the cache uses. The cache is resilient against
79
+ * reorgs etc. as it is based on block hashes, not block numbers. */
80
+ wipe(): void {
81
+ this.#cache.clear();
82
+ }
83
+ }