@aztec/pxe 5.0.0-private.20260319 → 5.0.0-rc.2

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 (453) hide show
  1. package/dest/bin/check_oracle_version.js +45 -111
  2. package/dest/bin/index.d.ts +2 -0
  3. package/dest/bin/index.d.ts.map +1 -0
  4. package/dest/bin/index.js +1 -0
  5. package/dest/bin/oracle_version_helpers.d.ts +51 -0
  6. package/dest/bin/oracle_version_helpers.d.ts.map +1 -0
  7. package/dest/bin/oracle_version_helpers.js +254 -0
  8. package/dest/block_synchronizer/block_stream_source.d.ts +10 -0
  9. package/dest/block_synchronizer/block_stream_source.d.ts.map +1 -0
  10. package/dest/block_synchronizer/block_stream_source.js +37 -0
  11. package/dest/block_synchronizer/block_synchronizer.d.ts +20 -14
  12. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  13. package/dest/block_synchronizer/block_synchronizer.js +78 -28
  14. package/dest/config/index.d.ts +8 -1
  15. package/dest/config/index.d.ts.map +1 -1
  16. package/dest/config/index.js +13 -14
  17. package/dest/contract_function_simulator/contract_function_simulator.d.ts +19 -19
  18. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  19. package/dest/contract_function_simulator/contract_function_simulator.js +57 -32
  20. package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
  21. package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
  22. package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
  23. package/dest/contract_function_simulator/execution_note_cache.d.ts +2 -2
  24. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  25. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -9
  26. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  27. package/dest/contract_function_simulator/execution_tagging_index_cache.js +3 -7
  28. package/dest/contract_function_simulator/index.d.ts +24 -6
  29. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  30. package/dest/contract_function_simulator/index.js +11 -4
  31. package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts +29 -0
  32. package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts.map +1 -0
  33. package/dest/contract_function_simulator/noir-structs/bounded_vec.js +30 -0
  34. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts +9 -0
  35. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts.map +1 -0
  36. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.js +1 -0
  37. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts +7 -0
  38. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts.map +1 -0
  39. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.js +1 -0
  40. package/dest/contract_function_simulator/noir-structs/ephemeral_array.d.ts +37 -0
  41. package/dest/contract_function_simulator/noir-structs/ephemeral_array.d.ts.map +1 -0
  42. package/dest/contract_function_simulator/noir-structs/ephemeral_array.js +59 -0
  43. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +5 -5
  44. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  45. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +7 -9
  46. package/dest/contract_function_simulator/noir-structs/fact.d.ts +16 -0
  47. package/dest/contract_function_simulator/noir-structs/fact.d.ts.map +1 -0
  48. package/dest/contract_function_simulator/noir-structs/fact.js +6 -0
  49. package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts +27 -0
  50. package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts.map +1 -0
  51. package/dest/contract_function_simulator/noir-structs/fact_collection.js +29 -0
  52. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +19 -10
  53. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
  54. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +12 -24
  55. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +5 -9
  56. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  57. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +2 -61
  58. package/dest/contract_function_simulator/noir-structs/note_data.d.ts +27 -0
  59. package/dest/contract_function_simulator/noir-structs/note_data.d.ts.map +1 -0
  60. package/dest/contract_function_simulator/noir-structs/note_data.js +3 -0
  61. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +5 -5
  62. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  63. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +8 -10
  64. package/dest/contract_function_simulator/noir-structs/option.d.ts +59 -0
  65. package/dest/contract_function_simulator/noir-structs/option.d.ts.map +1 -0
  66. package/dest/contract_function_simulator/noir-structs/option.js +67 -0
  67. package/dest/contract_function_simulator/noir-structs/origin_block.d.ts +11 -0
  68. package/dest/contract_function_simulator/noir-structs/origin_block.d.ts.map +1 -0
  69. package/dest/contract_function_simulator/noir-structs/origin_block.js +5 -0
  70. package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +8 -0
  71. package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts.map +1 -0
  72. package/dest/contract_function_simulator/noir-structs/provided_secret.js +1 -0
  73. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts +21 -0
  74. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts.map +1 -0
  75. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.js +33 -0
  76. package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts +21 -0
  77. package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts.map +1 -0
  78. package/dest/contract_function_simulator/noir-structs/resolved_tx.js +50 -0
  79. package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts +14 -0
  80. package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts.map +1 -0
  81. package/dest/contract_function_simulator/noir-structs/tx_effect_data.js +5 -0
  82. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +6 -11
  83. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
  84. package/dest/contract_function_simulator/noir-structs/utility_context.js +1 -20
  85. package/dest/contract_function_simulator/oracle/acir_callback.d.ts +16 -0
  86. package/dest/contract_function_simulator/oracle/acir_callback.d.ts.map +1 -0
  87. package/dest/contract_function_simulator/oracle/acir_callback.js +71 -0
  88. package/dest/contract_function_simulator/oracle/index.d.ts +2 -13
  89. package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -1
  90. package/dest/contract_function_simulator/oracle/index.js +1 -1
  91. package/dest/contract_function_simulator/oracle/interfaces.d.ts +15 -103
  92. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  93. package/dest/contract_function_simulator/oracle/interfaces.js +2 -2
  94. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -14
  95. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  96. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -24
  97. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +2 -2
  98. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
  99. package/dest/contract_function_simulator/oracle/note_packing_utils.js +2 -2
  100. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +135 -0
  101. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -0
  102. package/dest/contract_function_simulator/oracle/oracle_registry.js +976 -0
  103. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +183 -0
  104. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -0
  105. package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +1222 -0
  106. package/dest/contract_function_simulator/oracle/private_execution.d.ts +1 -1
  107. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  108. package/dest/contract_function_simulator/oracle/private_execution.js +3 -4
  109. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +44 -42
  110. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  111. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +147 -59
  112. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +143 -71
  113. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  114. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +485 -187
  115. package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
  116. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
  117. package/dest/contract_function_simulator/pick_notes.js +20 -3
  118. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
  119. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
  120. package/dest/contract_function_simulator/proxied_contract_data_source.js +35 -64
  121. package/dest/contract_function_simulator/transient_array_service.d.ts +31 -0
  122. package/dest/contract_function_simulator/transient_array_service.d.ts.map +1 -0
  123. package/dest/contract_function_simulator/transient_array_service.js +62 -0
  124. package/dest/contract_logging.d.ts +9 -4
  125. package/dest/contract_logging.d.ts.map +1 -1
  126. package/dest/contract_logging.js +21 -6
  127. package/dest/contract_sync/contract_sync_service.d.ts +11 -9
  128. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
  129. package/dest/contract_sync/contract_sync_service.js +73 -51
  130. package/dest/contract_sync/helpers.d.ts +8 -9
  131. package/dest/contract_sync/helpers.d.ts.map +1 -1
  132. package/dest/contract_sync/helpers.js +23 -30
  133. package/dest/debug/pxe_debug_utils.d.ts +3 -8
  134. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  135. package/dest/debug/pxe_debug_utils.js +0 -6
  136. package/dest/entrypoints/client/bundle/index.d.ts +1 -2
  137. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  138. package/dest/entrypoints/client/bundle/index.js +0 -1
  139. package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
  140. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  141. package/dest/entrypoints/client/bundle/utils.js +18 -5
  142. package/dest/entrypoints/client/lazy/index.d.ts +1 -2
  143. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  144. package/dest/entrypoints/client/lazy/index.js +0 -1
  145. package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
  146. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  147. package/dest/entrypoints/client/lazy/utils.js +18 -5
  148. package/dest/entrypoints/pxe_creation_options.d.ts +16 -2
  149. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  150. package/dest/entrypoints/pxe_creation_options.js +3 -1
  151. package/dest/entrypoints/server/index.d.ts +2 -3
  152. package/dest/entrypoints/server/index.d.ts.map +1 -1
  153. package/dest/entrypoints/server/index.js +1 -2
  154. package/dest/entrypoints/server/utils.d.ts +4 -3
  155. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  156. package/dest/entrypoints/server/utils.js +20 -6
  157. package/dest/error_enriching.js +1 -1
  158. package/dest/events/event_service.d.ts +15 -6
  159. package/dest/events/event_service.d.ts.map +1 -1
  160. package/dest/events/event_service.js +44 -11
  161. package/dest/events/private_event_filter_validator.d.ts +3 -2
  162. package/dest/events/private_event_filter_validator.d.ts.map +1 -1
  163. package/dest/events/private_event_filter_validator.js +15 -0
  164. package/dest/hooks/authorize_utility_call.d.ts +41 -0
  165. package/dest/hooks/authorize_utility_call.d.ts.map +1 -0
  166. package/dest/hooks/authorize_utility_call.js +4 -0
  167. package/dest/hooks/execution_hooks.d.ts +51 -0
  168. package/dest/hooks/execution_hooks.d.ts.map +1 -0
  169. package/dest/hooks/execution_hooks.js +9 -0
  170. package/dest/hooks/index.d.ts +4 -0
  171. package/dest/hooks/index.d.ts.map +1 -0
  172. package/dest/hooks/index.js +1 -0
  173. package/dest/hooks/resolve_tagging_secret_strategy.d.ts +41 -0
  174. package/dest/hooks/resolve_tagging_secret_strategy.d.ts.map +1 -0
  175. package/dest/hooks/resolve_tagging_secret_strategy.js +3 -0
  176. package/dest/logs/log_service.d.ts +12 -12
  177. package/dest/logs/log_service.d.ts.map +1 -1
  178. package/dest/logs/log_service.js +169 -81
  179. package/dest/messages/tx_resolver_service.d.ts +17 -0
  180. package/dest/messages/tx_resolver_service.d.ts.map +1 -0
  181. package/dest/messages/tx_resolver_service.js +55 -0
  182. package/dest/notes/note_service.d.ts +27 -6
  183. package/dest/notes/note_service.d.ts.map +1 -1
  184. package/dest/notes/note_service.js +80 -56
  185. package/dest/notes_filter.d.ts +2 -3
  186. package/dest/notes_filter.d.ts.map +1 -1
  187. package/dest/oracle_version.d.ts +4 -3
  188. package/dest/oracle_version.d.ts.map +1 -1
  189. package/dest/oracle_version.js +20 -10
  190. package/dest/private_kernel/batch_planner.d.ts +47 -0
  191. package/dest/private_kernel/batch_planner.d.ts.map +1 -0
  192. package/dest/private_kernel/batch_planner.js +104 -0
  193. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +1 -1
  194. package/dest/private_kernel/hints/test_utils.d.ts +1 -1
  195. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -1
  196. package/dest/private_kernel/hints/test_utils.js +3 -4
  197. package/dest/private_kernel/private_kernel_execution_prover.d.ts +6 -2
  198. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  199. package/dest/private_kernel/private_kernel_execution_prover.js +152 -59
  200. package/dest/private_kernel/private_kernel_oracle.d.ts +10 -10
  201. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  202. package/dest/private_kernel/private_kernel_oracle.js +24 -22
  203. package/dest/pxe.d.ts +104 -27
  204. package/dest/pxe.d.ts.map +1 -1
  205. package/dest/pxe.js +229 -130
  206. package/dest/storage/allowed_scopes.d.ts +6 -0
  207. package/dest/storage/allowed_scopes.d.ts.map +1 -0
  208. package/dest/storage/allowed_scopes.js +7 -0
  209. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -6
  210. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
  211. package/dest/storage/anchor_block_store/anchor_block_store.js +9 -7
  212. package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts +42 -0
  213. package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts.map +1 -0
  214. package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.js +93 -0
  215. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +15 -0
  216. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -0
  217. package/dest/storage/backwards_compatibility_tests/schema_tests.js +647 -0
  218. package/dest/storage/backwards_compatibility_tests/store_spy.d.ts +19 -0
  219. package/dest/storage/backwards_compatibility_tests/store_spy.d.ts.map +1 -0
  220. package/dest/storage/backwards_compatibility_tests/store_spy.js +63 -0
  221. package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
  222. package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
  223. package/dest/storage/capsule_store/capsule_service.js +47 -0
  224. package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
  225. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
  226. package/dest/storage/capsule_store/capsule_store.js +36 -28
  227. package/dest/storage/capsule_store/index.d.ts +2 -1
  228. package/dest/storage/capsule_store/index.d.ts.map +1 -1
  229. package/dest/storage/capsule_store/index.js +1 -0
  230. package/dest/storage/contract_store/contract_store.d.ts +1 -1
  231. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  232. package/dest/storage/contract_store/contract_store.js +11 -28
  233. package/dest/storage/fact_store/fact_service.d.ts +20 -0
  234. package/dest/storage/fact_store/fact_service.d.ts.map +1 -0
  235. package/dest/storage/fact_store/fact_service.js +30 -0
  236. package/dest/storage/fact_store/fact_store.d.ts +95 -0
  237. package/dest/storage/fact_store/fact_store.d.ts.map +1 -0
  238. package/dest/storage/fact_store/fact_store.js +408 -0
  239. package/dest/storage/fact_store/fact_store_keys.d.ts +34 -0
  240. package/dest/storage/fact_store/fact_store_keys.d.ts.map +1 -0
  241. package/dest/storage/fact_store/fact_store_keys.js +50 -0
  242. package/dest/storage/fact_store/index.d.ts +5 -0
  243. package/dest/storage/fact_store/index.d.ts.map +1 -0
  244. package/dest/storage/fact_store/index.js +3 -0
  245. package/dest/storage/fact_store/stored_fact.d.ts +32 -0
  246. package/dest/storage/fact_store/stored_fact.d.ts.map +1 -0
  247. package/dest/storage/fact_store/stored_fact.js +64 -0
  248. package/dest/storage/index.d.ts +3 -2
  249. package/dest/storage/index.d.ts.map +1 -1
  250. package/dest/storage/index.js +2 -1
  251. package/dest/storage/metadata.d.ts +1 -1
  252. package/dest/storage/metadata.js +1 -1
  253. package/dest/storage/note_store/note_store.d.ts +42 -33
  254. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  255. package/dest/storage/note_store/note_store.js +199 -170
  256. package/dest/storage/note_store/stored_note.d.ts +3 -8
  257. package/dest/storage/note_store/stored_note.d.ts.map +1 -1
  258. package/dest/storage/note_store/stored_note.js +4 -20
  259. package/dest/storage/open_pxe_stores.d.ts +35 -0
  260. package/dest/storage/open_pxe_stores.d.ts.map +1 -0
  261. package/dest/storage/open_pxe_stores.js +29 -0
  262. package/dest/storage/private_event_store/private_event_store.d.ts +13 -16
  263. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  264. package/dest/storage/private_event_store/private_event_store.js +43 -43
  265. package/dest/storage/private_event_store/stored_private_event.js +1 -1
  266. package/dest/storage/tagging_store/index.d.ts +2 -2
  267. package/dest/storage/tagging_store/index.d.ts.map +1 -1
  268. package/dest/storage/tagging_store/index.js +1 -1
  269. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
  270. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  271. package/dest/storage/tagging_store/sender_tagging_store.d.ts +5 -5
  272. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  273. package/dest/storage/tagging_store/sender_tagging_store.js +3 -3
  274. package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts +40 -0
  275. package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts.map +1 -0
  276. package/dest/storage/tagging_store/tagging_secret_sources_store.js +92 -0
  277. package/dest/tagging/get_all_logs_by_tags.d.ts +34 -10
  278. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
  279. package/dest/tagging/get_all_logs_by_tags.js +36 -37
  280. package/dest/tagging/index.d.ts +5 -4
  281. package/dest/tagging/index.d.ts.map +1 -1
  282. package/dest/tagging/index.js +4 -3
  283. package/dest/tagging/persist_sender_tagging_index_ranges.d.ts +29 -0
  284. package/dest/tagging/persist_sender_tagging_index_ranges.d.ts.map +1 -0
  285. package/dest/tagging/persist_sender_tagging_index_ranges.js +42 -0
  286. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +69 -0
  287. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -0
  288. package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +203 -0
  289. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +3 -3
  290. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -1
  291. package/dest/tagging/reconcile_tagging_index_ranges.d.ts +36 -0
  292. package/dest/tagging/reconcile_tagging_index_ranges.d.ts.map +1 -0
  293. package/dest/tagging/reconcile_tagging_index_ranges.js +74 -0
  294. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -5
  295. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  296. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +26 -14
  297. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +11 -6
  298. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  299. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +21 -0
  300. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +4 -4
  301. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  302. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +2 -2
  303. package/package.json +20 -17
  304. package/src/bin/check_oracle_version.ts +51 -133
  305. package/src/bin/index.ts +5 -0
  306. package/src/bin/oracle_version_helpers.ts +311 -0
  307. package/src/block_synchronizer/block_stream_source.ts +42 -0
  308. package/src/block_synchronizer/block_synchronizer.ts +93 -38
  309. package/src/config/index.ts +15 -8
  310. package/src/contract_function_simulator/contract_function_simulator.ts +86 -48
  311. package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
  312. package/src/contract_function_simulator/execution_note_cache.ts +1 -1
  313. package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -9
  314. package/src/contract_function_simulator/index.ts +63 -5
  315. package/src/contract_function_simulator/noir-structs/bounded_vec.ts +43 -0
  316. package/src/contract_function_simulator/noir-structs/contract_class_log_data.ts +9 -0
  317. package/src/contract_function_simulator/noir-structs/embedded_curve_point.ts +4 -0
  318. package/src/contract_function_simulator/noir-structs/ephemeral_array.ts +66 -0
  319. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +5 -7
  320. package/src/contract_function_simulator/noir-structs/fact.ts +13 -0
  321. package/src/contract_function_simulator/noir-structs/fact_collection.ts +59 -0
  322. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +27 -20
  323. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +8 -61
  324. package/src/contract_function_simulator/noir-structs/note_data.ts +27 -0
  325. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +6 -8
  326. package/src/contract_function_simulator/noir-structs/option.ts +75 -0
  327. package/src/contract_function_simulator/noir-structs/origin_block.ts +8 -0
  328. package/src/contract_function_simulator/noir-structs/provided_secret.ts +5 -0
  329. package/src/contract_function_simulator/noir-structs/resolved_tagging_strategy.ts +45 -0
  330. package/src/contract_function_simulator/noir-structs/resolved_tx.ts +53 -0
  331. package/src/contract_function_simulator/noir-structs/tx_effect_data.ts +15 -0
  332. package/src/contract_function_simulator/noir-structs/utility_context.ts +5 -17
  333. package/src/contract_function_simulator/oracle/acir_callback.ts +108 -0
  334. package/src/contract_function_simulator/oracle/index.ts +1 -15
  335. package/src/contract_function_simulator/oracle/interfaces.ts +11 -176
  336. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +6 -21
  337. package/src/contract_function_simulator/oracle/note_packing_utils.ts +3 -3
  338. package/src/contract_function_simulator/oracle/oracle_registry.ts +681 -0
  339. package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +947 -0
  340. package/src/contract_function_simulator/oracle/private_execution.ts +3 -4
  341. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +182 -79
  342. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +743 -295
  343. package/src/contract_function_simulator/pick_notes.ts +22 -3
  344. package/src/contract_function_simulator/proxied_contract_data_source.ts +41 -64
  345. package/src/contract_function_simulator/transient_array_service.ts +91 -0
  346. package/src/contract_logging.ts +18 -5
  347. package/src/contract_sync/contract_sync_service.ts +101 -87
  348. package/src/contract_sync/helpers.ts +24 -43
  349. package/src/debug/pxe_debug_utils.ts +3 -11
  350. package/src/entrypoints/client/bundle/index.ts +0 -1
  351. package/src/entrypoints/client/bundle/utils.ts +17 -5
  352. package/src/entrypoints/client/lazy/index.ts +0 -1
  353. package/src/entrypoints/client/lazy/utils.ts +17 -5
  354. package/src/entrypoints/pxe_creation_options.ts +21 -1
  355. package/src/entrypoints/server/index.ts +1 -2
  356. package/src/entrypoints/server/utils.ts +24 -7
  357. package/src/error_enriching.ts +1 -1
  358. package/src/events/event_service.ts +69 -21
  359. package/src/events/private_event_filter_validator.ts +21 -1
  360. package/src/hooks/authorize_utility_call.ts +44 -0
  361. package/src/hooks/execution_hooks.ts +57 -0
  362. package/src/hooks/index.ts +11 -0
  363. package/src/hooks/resolve_tagging_secret_strategy.ts +46 -0
  364. package/src/logs/log_service.ts +204 -146
  365. package/src/messages/tx_resolver_service.ts +69 -0
  366. package/src/notes/note_service.ts +119 -85
  367. package/src/notes_filter.ts +1 -3
  368. package/src/oracle_version.ts +20 -10
  369. package/src/private_kernel/batch_planner.ts +169 -0
  370. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +1 -1
  371. package/src/private_kernel/hints/test_utils.ts +3 -10
  372. package/src/private_kernel/private_kernel_execution_prover.ts +240 -82
  373. package/src/private_kernel/private_kernel_oracle.ts +35 -25
  374. package/src/pxe.ts +369 -138
  375. package/src/storage/allowed_scopes.ts +14 -0
  376. package/src/storage/anchor_block_store/anchor_block_store.ts +9 -7
  377. package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +22 -0
  378. package/src/storage/backwards_compatibility_tests/__snapshots__/AnchorBlockStore.json +3 -0
  379. package/src/storage/backwards_compatibility_tests/__snapshots__/CapsuleStore.json +16 -0
  380. package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +28 -0
  381. package/src/storage/backwards_compatibility_tests/__snapshots__/FactStore.json +40 -0
  382. package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +52 -0
  383. package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +40 -0
  384. package/src/storage/backwards_compatibility_tests/__snapshots__/NoteStore.json +56 -0
  385. package/src/storage/backwards_compatibility_tests/__snapshots__/PrivateEventStore.json +44 -0
  386. package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +18 -0
  387. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +22 -0
  388. package/src/storage/backwards_compatibility_tests/__snapshots__/TaggingSecretSourcesStore.json +30 -0
  389. package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +117 -0
  390. package/src/storage/backwards_compatibility_tests/kv_store_snapshot.ts +122 -0
  391. package/src/storage/backwards_compatibility_tests/schema_tests.ts +769 -0
  392. package/src/storage/backwards_compatibility_tests/store_spy.ts +73 -0
  393. package/src/storage/capsule_store/capsule_service.ts +85 -0
  394. package/src/storage/capsule_store/capsule_store.ts +44 -26
  395. package/src/storage/capsule_store/index.ts +1 -0
  396. package/src/storage/contract_store/contract_store.ts +16 -37
  397. package/src/storage/fact_store/fact_service.ts +45 -0
  398. package/src/storage/fact_store/fact_store.ts +487 -0
  399. package/src/storage/fact_store/fact_store_keys.ts +75 -0
  400. package/src/storage/fact_store/index.ts +4 -0
  401. package/src/storage/fact_store/stored_fact.ts +80 -0
  402. package/src/storage/index.ts +2 -1
  403. package/src/storage/metadata.ts +1 -1
  404. package/src/storage/note_store/note_store.ts +228 -192
  405. package/src/storage/note_store/stored_note.ts +5 -27
  406. package/src/storage/open_pxe_stores.ts +52 -0
  407. package/src/storage/private_event_store/private_event_store.ts +52 -54
  408. package/src/storage/private_event_store/stored_private_event.ts +1 -1
  409. package/src/storage/tagging_store/index.ts +1 -1
  410. package/src/storage/tagging_store/recipient_tagging_store.ts +5 -9
  411. package/src/storage/tagging_store/sender_tagging_store.ts +6 -6
  412. package/src/storage/tagging_store/tagging_secret_sources_store.ts +117 -0
  413. package/src/tagging/get_all_logs_by_tags.ts +78 -50
  414. package/src/tagging/index.ts +4 -3
  415. package/src/tagging/persist_sender_tagging_index_ranges.ts +57 -0
  416. package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +301 -0
  417. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
  418. package/src/tagging/reconcile_tagging_index_ranges.ts +102 -0
  419. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +41 -19
  420. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +23 -8
  421. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +4 -5
  422. package/dest/access_scopes.d.ts +0 -9
  423. package/dest/access_scopes.d.ts.map +0 -1
  424. package/dest/access_scopes.js +0 -6
  425. package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts +0 -16
  426. package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts.map +0 -1
  427. package/dest/contract_function_simulator/noir-structs/message_tx_context.js +0 -57
  428. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +0 -9
  429. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +0 -1
  430. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +0 -42
  431. package/dest/contract_function_simulator/oracle/oracle.d.ts +0 -61
  432. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +0 -1
  433. package/dest/contract_function_simulator/oracle/oracle.js +0 -437
  434. package/dest/messages/message_context_service.d.ts +0 -17
  435. package/dest/messages/message_context_service.d.ts.map +0 -1
  436. package/dest/messages/message_context_service.js +0 -36
  437. package/dest/storage/tagging_store/sender_address_book_store.d.ts +0 -14
  438. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +0 -1
  439. package/dest/storage/tagging_store/sender_address_book_store.js +0 -36
  440. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +0 -14
  441. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +0 -1
  442. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +0 -99
  443. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +0 -14
  444. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +0 -1
  445. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +0 -33
  446. package/src/access_scopes.ts +0 -9
  447. package/src/contract_function_simulator/noir-structs/message_tx_context.ts +0 -55
  448. package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +0 -135
  449. package/src/contract_function_simulator/oracle/oracle.ts +0 -675
  450. package/src/messages/message_context_service.ts +0 -45
  451. package/src/storage/tagging_store/sender_address_book_store.ts +0 -48
  452. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +0 -140
  453. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +0 -44
@@ -0,0 +1,95 @@
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
+ import type { AztecAsyncKVStore } from '@aztec/kv-store';
3
+ import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
4
+ import { FactCollectionKey, type FactCollectionTypeKey, type OriginBlock } from './fact_store_keys.js';
5
+ import { type Fact } from './stored_fact.js';
6
+ type BlockNum = number;
7
+ /** A fact collection as returned by the store. */
8
+ export type FactCollection = {
9
+ key: FactCollectionKey;
10
+ facts: Fact[];
11
+ };
12
+ /**
13
+ * Stores immutable facts grouped into collections, isolated by contract and scope.
14
+ *
15
+ * A fact collection is a contract-defined bag of facts identified by a {@link FactCollectionKey} (contract, scope,
16
+ * collection type, and id). A fact is a contract-defined immutable, typed datum in a collection. Collections are
17
+ * implicit: one comes into being when its first fact is recorded and ceases to exist once it has no facts left.
18
+ *
19
+ * What makes this store different to, for example, the `CapsuleStore`, is that it is designed to support use cases
20
+ * where resilience to reorgs is needed, via what we call _retractability_.
21
+ *
22
+ * Facts can be retractable or non-retractable. They are retractable if they are associated to an origin block.
23
+ * Retractable facts are removed from the store when their origin block is pruned (typically due to a reorg).
24
+ * Non-retractable facts survive reorgs: they must then be explicitly deleted, so as not to keep consuming resources
25
+ * (storage and compute) indefinitely.
26
+ *
27
+ * Fact collections are isolated by scope.
28
+ *
29
+ * This store is designed to enable Aztec.nr to implement complex workflows such as offchain reception or partial note
30
+ * processing by storing structured data that is guaranteed to exist conditionally to specific blocks being included in
31
+ * the chain, while leaving the complexity of ensuring said guarantees to PXE.
32
+ *
33
+ * A key design driver is that PXE knows nothing about the actual fact contents: it just manages enough metadata to
34
+ * provide the guarantees mentioned above. That way, concepts such as offchain delivery or partial notes are completely
35
+ * defined by Aztec.nr, opening the door to further extension without the need for ad-hoc PXE support.
36
+ *
37
+ * As with most other PXE stores, writes are staged per-job and flushed atomically on commit.
38
+ */
39
+ export declare class FactStore implements StagedStore {
40
+ #private;
41
+ readonly storeName: string;
42
+ logger: import("@aztec/foundation/log").Logger;
43
+ constructor(store: AztecAsyncKVStore);
44
+ /**
45
+ * Records a fact in a collection.
46
+ *
47
+ * The collection is created implicitly on the first fact recorded for its key: recording into an existing collection
48
+ * just adds to it.
49
+ *
50
+ * If `originBlock === undefined`, the fact is non-retractable: it survives reorgs. A defined origin block makes the
51
+ * fact retractable: on a prune below its block, it will be deleted.
52
+ *
53
+ * Idempotent: re-recording an identical fact (same collection, fact type, payload, and origin block) is a no-op.
54
+ * The same payload tied to a different origin block is a distinct fact.
55
+ */
56
+ recordFact(factCollectionKey: FactCollectionKey, factTypeId: Fr, payload: Fr[], originBlock: OriginBlock | undefined, jobId: string): Promise<void>;
57
+ /**
58
+ * Deletes a fact collection: removes every fact under the (scope-qualified) collection key.
59
+ *
60
+ * Idempotent: deleting a collection that does not exist is a no-op.
61
+ */
62
+ deleteFactCollection(factCollectionKey: FactCollectionKey, jobId: string): Promise<void>;
63
+ /**
64
+ * Returns the fact collection for the (scope-qualified) key, or undefined if it has no facts.
65
+ */
66
+ getFactCollection(factCollectionKey: FactCollectionKey, jobId: string): Promise<FactCollection | undefined>;
67
+ /**
68
+ * Returns every fact collection of the given type for the queried scope, each holding its facts.
69
+ */
70
+ getFactCollectionsByType(factCollectionTypeKey: FactCollectionTypeKey, jobId: string): Promise<FactCollection[]>;
71
+ /**
72
+ * Commits all staged operations for the given job to persistent storage.
73
+ *
74
+ * Must be called inside a transaction owned by the caller (JobCoordinator wraps all commits in a single
75
+ * transactionAsync, and IndexedDB does not support nested transactions).
76
+ *
77
+ * DO NOT call `#withJobLock` here: awaiting the lock creates a microtask boundary that causes IndexedDB to
78
+ * auto-commit the outer transaction.
79
+ */
80
+ commit(jobId: string): Promise<void>;
81
+ /** Discards all staged operations for the given job without persisting them. */
82
+ discardStaged(jobId: string): Promise<void>;
83
+ /**
84
+ * Removes every retractable fact originating from blocks over height `toBlock`, across all scopes.
85
+ *
86
+ * Non-retractable facts are untouched. Must run inside a caller-owned transaction (because it needs to share the
87
+ * transaction with other stores and IndexedDB has no nested transactions).
88
+ *
89
+ * Throws if any job is in flight (has accessed the store and not yet committed or discarded), since rolling back
90
+ * mid-job could re-introduce records originating from deleted blocks or change state underneath a job's view.
91
+ */
92
+ rollback(toBlock: BlockNum): Promise<void>;
93
+ }
94
+ export {};
95
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdF9zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3N0b3JhZ2UvZmFjdF9zdG9yZS9mYWN0X3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBR3pELE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFxQyxNQUFNLGlCQUFpQixDQUFDO0FBRTVGLE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLDBDQUEwQyxDQUFDO0FBQzVFLE9BQU8sRUFBRSxpQkFBaUIsRUFBRSxLQUFLLHFCQUFxQixFQUFFLEtBQUssV0FBVyxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDdkcsT0FBTyxFQUFFLEtBQUssSUFBSSxFQUE0QixNQUFNLGtCQUFrQixDQUFDO0FBR3ZFLEtBQUssUUFBUSxHQUFHLE1BQU0sQ0FBQztBQU12QixrREFBa0Q7QUFDbEQsTUFBTSxNQUFNLGNBQWMsR0FBRztJQUFFLEdBQUcsRUFBRSxpQkFBaUIsQ0FBQztJQUFDLEtBQUssRUFBRSxJQUFJLEVBQUUsQ0FBQTtDQUFFLENBQUM7QUFRdkU7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBMEJHO0FBQ0gscUJBQWEsU0FBVSxZQUFXLFdBQVc7O0lBQzNDLFFBQVEsQ0FBQyxTQUFTLEVBQUUsTUFBTSxDQUFVO0lBbUJwQyxNQUFNLHlDQUE4QjtJQUVwQyxZQUFZLEtBQUssRUFBRSxp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,EAC5C,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,cAAc,EAAE,CAAC,CAO3B;IAED;;;;;;;;OAQG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBzC;IAED,gFAAgF;IAChF,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG1C;IAED;;;;;;;;OAQG;IACG,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ/C;CA2RF"}
@@ -0,0 +1,408 @@
1
+ import { createLogger } from '@aztec/foundation/log';
2
+ import { Semaphore } from '@aztec/foundation/queue';
3
+ import { FactCollectionKey } from './fact_store_keys.js';
4
+ import { StoredFact, factKeyStrOf } from './stored_fact.js';
5
+ /**
6
+ * Stores immutable facts grouped into collections, isolated by contract and scope.
7
+ *
8
+ * A fact collection is a contract-defined bag of facts identified by a {@link FactCollectionKey} (contract, scope,
9
+ * collection type, and id). A fact is a contract-defined immutable, typed datum in a collection. Collections are
10
+ * implicit: one comes into being when its first fact is recorded and ceases to exist once it has no facts left.
11
+ *
12
+ * What makes this store different to, for example, the `CapsuleStore`, is that it is designed to support use cases
13
+ * where resilience to reorgs is needed, via what we call _retractability_.
14
+ *
15
+ * Facts can be retractable or non-retractable. They are retractable if they are associated to an origin block.
16
+ * Retractable facts are removed from the store when their origin block is pruned (typically due to a reorg).
17
+ * Non-retractable facts survive reorgs: they must then be explicitly deleted, so as not to keep consuming resources
18
+ * (storage and compute) indefinitely.
19
+ *
20
+ * Fact collections are isolated by scope.
21
+ *
22
+ * This store is designed to enable Aztec.nr to implement complex workflows such as offchain reception or partial note
23
+ * processing by storing structured data that is guaranteed to exist conditionally to specific blocks being included in
24
+ * the chain, while leaving the complexity of ensuring said guarantees to PXE.
25
+ *
26
+ * A key design driver is that PXE knows nothing about the actual fact contents: it just manages enough metadata to
27
+ * provide the guarantees mentioned above. That way, concepts such as offchain delivery or partial notes are completely
28
+ * defined by Aztec.nr, opening the door to further extension without the need for ad-hoc PXE support.
29
+ *
30
+ * As with most other PXE stores, writes are staged per-job and flushed atomically on commit.
31
+ */ export class FactStore {
32
+ storeName = 'fact';
33
+ #store;
34
+ /** Primary index of fact records. */ #facts;
35
+ /** Index for per-collection fact enumeration and by-type collection discovery. */ #factsByCollection;
36
+ /** Index for delete-on-prune of retractable facts (those with an origin block). */ #factsByBlock;
37
+ /** Job uncommitted data */ #opsForJob;
38
+ /** Per-job locks */ #jobLocks;
39
+ logger = createLogger('fact_store');
40
+ constructor(store){
41
+ this.#store = store;
42
+ this.#facts = store.openMap('facts');
43
+ this.#factsByCollection = store.openMultiMap('facts_by_collection');
44
+ this.#factsByBlock = store.openMultiMap('facts_by_block');
45
+ this.#opsForJob = new Map();
46
+ this.#jobLocks = new Map();
47
+ }
48
+ /**
49
+ * Records a fact in a collection.
50
+ *
51
+ * The collection is created implicitly on the first fact recorded for its key: recording into an existing collection
52
+ * just adds to it.
53
+ *
54
+ * If `originBlock === undefined`, the fact is non-retractable: it survives reorgs. A defined origin block makes the
55
+ * fact retractable: on a prune below its block, it will be deleted.
56
+ *
57
+ * Idempotent: re-recording an identical fact (same collection, fact type, payload, and origin block) is a no-op.
58
+ * The same payload tied to a different origin block is a distinct fact.
59
+ */ recordFact(factCollectionKey, factTypeId, payload, originBlock, jobId) {
60
+ return this.#withJobLock(jobId, ()=>{
61
+ this.#stagedOpsFor(jobId).push({
62
+ kind: 'recordFact',
63
+ fact: new StoredFact(factCollectionKey, factTypeId, payload, originBlock)
64
+ });
65
+ return Promise.resolve();
66
+ });
67
+ }
68
+ /**
69
+ * Deletes a fact collection: removes every fact under the (scope-qualified) collection key.
70
+ *
71
+ * Idempotent: deleting a collection that does not exist is a no-op.
72
+ */ deleteFactCollection(factCollectionKey, jobId) {
73
+ return this.#withJobLock(jobId, ()=>{
74
+ this.#stagedOpsFor(jobId).push({
75
+ kind: 'deleteFactCollection',
76
+ key: factCollectionKey
77
+ });
78
+ return Promise.resolve();
79
+ });
80
+ }
81
+ /**
82
+ * Returns the fact collection for the (scope-qualified) key, or undefined if it has no facts.
83
+ */ async getFactCollection(factCollectionKey, jobId) {
84
+ const collectionKey = factCollectionKey.toString();
85
+ const committed = await this.#store.transactionAsync(()=>this.#readCollectionsFromDb([
86
+ factCollectionKey
87
+ ]));
88
+ const collection = this.#foldStagedOps(committed, jobId).get(collectionKey);
89
+ if (!collection) {
90
+ return undefined;
91
+ }
92
+ const facts = [
93
+ ...collection.facts.values()
94
+ ];
95
+ return facts.length > 0 ? {
96
+ key: factCollectionKey,
97
+ facts
98
+ } : undefined;
99
+ }
100
+ /**
101
+ * Returns every fact collection of the given type for the queried scope, each holding its facts.
102
+ */ async getFactCollectionsByType(factCollectionTypeKey, jobId) {
103
+ const typeKey = factCollectionTypeKey.toString();
104
+ const committed = await this.#readCollectionsFromDbByType(typeKey);
105
+ return Array.from(this.#foldStagedOps(committed, jobId, typeKey).values()).map((collection)=>({
106
+ key: collection.key,
107
+ facts: [
108
+ ...collection.facts.values()
109
+ ]
110
+ })).filter((collection)=>collection.facts.length > 0);
111
+ }
112
+ /**
113
+ * Commits all staged operations for the given job to persistent storage.
114
+ *
115
+ * Must be called inside a transaction owned by the caller (JobCoordinator wraps all commits in a single
116
+ * transactionAsync, and IndexedDB does not support nested transactions).
117
+ *
118
+ * DO NOT call `#withJobLock` here: awaiting the lock creates a microtask boundary that causes IndexedDB to
119
+ * auto-commit the outer transaction.
120
+ */ async commit(jobId) {
121
+ for (const op of this.#stagedOpsFor(jobId)){
122
+ switch(op.kind){
123
+ case 'recordFact':
124
+ await this.#commitFact(op.fact);
125
+ break;
126
+ case 'deleteFactCollection':
127
+ await this.#deleteCollection(op.key.toString());
128
+ break;
129
+ default:
130
+ {
131
+ const _exhaustive = op;
132
+ throw new Error(`Unhandled FactStore staged op kind: ${JSON.stringify(_exhaustive)}`);
133
+ }
134
+ }
135
+ }
136
+ this.#clearJobData(jobId);
137
+ }
138
+ /** Discards all staged operations for the given job without persisting them. */ discardStaged(jobId) {
139
+ this.#clearJobData(jobId);
140
+ return Promise.resolve();
141
+ }
142
+ /**
143
+ * Removes every retractable fact originating from blocks over height `toBlock`, across all scopes.
144
+ *
145
+ * Non-retractable facts are untouched. Must run inside a caller-owned transaction (because it needs to share the
146
+ * transaction with other stores and IndexedDB has no nested transactions).
147
+ *
148
+ * Throws if any job is in flight (has accessed the store and not yet committed or discarded), since rolling back
149
+ * mid-job could re-introduce records originating from deleted blocks or change state underneath a job's view.
150
+ */ async rollback(toBlock) {
151
+ if (this.#opsForJob.size > 0) {
152
+ throw new Error('PXE fact store rollback is not allowed while jobs are running');
153
+ }
154
+ const removedFacts = await this.#retractFacts(toBlock);
155
+ this.logger.verbose('rolled back fact store', {
156
+ removedFacts,
157
+ toBlock
158
+ });
159
+ }
160
+ /**
161
+ * Deletes retractable facts originating above `toBlock`, returning the number of by-block entries scanned.
162
+ * Retraction is scope-agnostic: a reorg invalidates a fact regardless of which scope's collection it belongs to.
163
+ *
164
+ * Requires to be run in a transactionAsync context.
165
+ */ async #retractFacts(toBlock) {
166
+ // Snapshot the orphaned fact keys before mutating so we never delete from the cursor we are iterating, kicking off
167
+ // each fact-body read during the scan so a DB request stays pending across the cursor-to-delete boundary (a drained
168
+ // cursor with no read in flight would let the transaction auto-commit before the deletes).
169
+ const factReads = new Map();
170
+ for await (const [, factKey] of this.#factsByBlock.entriesAsync({
171
+ start: toBlock + 1
172
+ })){
173
+ factReads.set(factKey, this.#facts.getAsync(factKey));
174
+ }
175
+ await Promise.all(Array.from(factReads, async ([factKey, read])=>{
176
+ const buf = await read;
177
+ if (!buf) {
178
+ // The by-block index just yielded this factKey, so a missing primary record means the indexes are out of
179
+ // sync. Log as this should be unreachable unless there is a bug.
180
+ this.logger.warn('Skipping retraction of a fact missing from the primary store: by-block index is stale', {
181
+ factKey
182
+ });
183
+ return;
184
+ }
185
+ await this.#deleteFact(factKey, StoredFact.fromBuffer(buf));
186
+ }));
187
+ return factReads.size;
188
+ }
189
+ /**
190
+ * Reads the given collections (their facts) by key into a Map keyed by collection key, skipping
191
+ * keys with no committed facts.
192
+ *
193
+ * Reads are not wrapped in a transaction: the caller owns the transaction boundary.
194
+ */ async #readCollectionsFromDb(keys) {
195
+ const result = new Map();
196
+ for (const key of keys){
197
+ const collection = await this.#loadCommittedCollection(key);
198
+ if (collection) {
199
+ result.set(key.toString(), collection);
200
+ }
201
+ }
202
+ return result;
203
+ }
204
+ #readCollectionsFromDbByType(typeKey) {
205
+ return this.#store.transactionAsync(async ()=>{
206
+ const factReadsByCollection = new Map();
207
+ for await (const [collectionKey, factKey] of this.#factsByCollection.entriesAsync({
208
+ start: `${typeKey}:`,
209
+ end: `${typeKey};`
210
+ })){
211
+ let reads = factReadsByCollection.get(collectionKey);
212
+ if (!reads) {
213
+ reads = new Map();
214
+ factReadsByCollection.set(collectionKey, reads);
215
+ }
216
+ reads.set(factKey, this.#facts.getAsync(factKey));
217
+ }
218
+ const result = new Map();
219
+ for (const [collectionKey, reads] of factReadsByCollection){
220
+ const collection = await this.#assembleCollection(FactCollectionKey.fromString(collectionKey), reads);
221
+ result.set(collectionKey, collection);
222
+ }
223
+ return result;
224
+ });
225
+ }
226
+ async #loadCommittedCollection(collectionKey) {
227
+ // Kick off each fact read while iterating the index so a DB request is always pending. Draining the cursor and only
228
+ // then reading the facts one `await` at a time would let the IndexedDB transaction auto-commit at the boundary
229
+ // (IndexedDB auto-commits once control returns to the event loop with no pending request), throwing mid-read on the
230
+ // browser backend.
231
+ const factReads = new Map();
232
+ for await (const factKey of this.#factsByCollection.getValuesAsync(collectionKey.toString())){
233
+ factReads.set(factKey, this.#facts.getAsync(factKey));
234
+ }
235
+ if (factReads.size === 0) {
236
+ return undefined;
237
+ }
238
+ return this.#assembleCollection(collectionKey, factReads);
239
+ }
240
+ /**
241
+ * Assemble a collection's facts from a set of in-flight DB reads.
242
+ */ async #assembleCollection(collectionKey, reads) {
243
+ const factKeys = [
244
+ ...reads.keys()
245
+ ];
246
+ const bufs = await Promise.all(reads.values());
247
+ // Await-free tail: deserialize. No DB ops from here on.
248
+ const facts = new Map();
249
+ for(let i = 0; i < factKeys.length; i++){
250
+ const factKey = factKeys[i];
251
+ const buf = bufs[i];
252
+ if (!buf) {
253
+ // Defensive: a #factsByCollection entry must always reference a live #facts entry. A missing one means the
254
+ // indexes are corrupt.
255
+ throw new Error(`Fact not found for factKey ${factKey}`);
256
+ }
257
+ const stored = StoredFact.fromBuffer(buf);
258
+ if (stored.factCollectionKey.toString() !== collectionKey.toString()) {
259
+ // Defensive: every read fact must belong to the collection being assembled. A mismatch means the indexes are
260
+ // corrupt.
261
+ throw new Error(`Fact ${factKey} does not belong to collection ${collectionKey}`);
262
+ }
263
+ facts.set(factKey, stored.toFact());
264
+ }
265
+ return {
266
+ key: collectionKey,
267
+ facts
268
+ };
269
+ }
270
+ /**
271
+ * Assembles the current view of a collection of collections together with their facts, combining the committed with
272
+ * staged data.
273
+ *
274
+ * When `typeKey` is given, staged records of other types are ignored, so the result holds only that type.
275
+ */ #foldStagedOps(committed, jobId, typeKey) {
276
+ const result = new Map();
277
+ // Copy to avoid mutating the contents of `committed`.
278
+ for (const [collectionKey, { key, facts }] of committed){
279
+ result.set(collectionKey, {
280
+ key,
281
+ facts: new Map(facts)
282
+ });
283
+ }
284
+ for (const op of this.#stagedOpsFor(jobId)){
285
+ switch(op.kind){
286
+ case 'recordFact':
287
+ this.#foldRecordFact(result, op, typeKey);
288
+ break;
289
+ case 'deleteFactCollection':
290
+ this.#foldDeleteFactCollection(result, op);
291
+ break;
292
+ default:
293
+ {
294
+ const _exhaustive = op;
295
+ throw new Error(`Unhandled FactStore staged op kind: ${JSON.stringify(_exhaustive)}`);
296
+ }
297
+ }
298
+ }
299
+ return result;
300
+ }
301
+ /**
302
+ * Folds a staged `recordFact` op into view.
303
+ *
304
+ * When `typeKey` is given, an op of another type is ignored, keeping the view limited to that type.
305
+ */ #foldRecordFact(result, op, typeKey) {
306
+ const key = op.fact.factCollectionKey;
307
+ // Type filter doesn't match, nothing to do with this fact
308
+ if (typeKey !== undefined && key.factCollectionTypeKey().toString() !== typeKey) {
309
+ return;
310
+ }
311
+ const collectionKey = key.toString();
312
+ let collection = result.get(collectionKey);
313
+ // Collection didn't exist before this point, the created fact brings it into existence
314
+ if (!collection) {
315
+ collection = {
316
+ key,
317
+ facts: new Map()
318
+ };
319
+ result.set(collectionKey, collection);
320
+ }
321
+ const fKey = factKeyStrOf(op.fact);
322
+ if (!collection.facts.has(fKey)) {
323
+ collection.facts.set(fKey, op.fact.toFact());
324
+ }
325
+ }
326
+ /**
327
+ * Folds a staged `deleteFactCollection` op into the view: the scope-qualified collection is removed outright.
328
+ */ #foldDeleteFactCollection(result, op) {
329
+ result.delete(op.key.toString());
330
+ }
331
+ /**
332
+ * Writes a fact to persistent storage. Idempotent: an identical fact (same scope-qualified key) is left untouched.
333
+ */ async #commitFact(fact) {
334
+ const factKey = factKeyStrOf(fact);
335
+ if (await this.#facts.hasAsync(factKey)) {
336
+ this.logger.debug(`Ignoring already recorded fact`, {
337
+ factKey
338
+ });
339
+ return;
340
+ }
341
+ await this.#facts.set(factKey, fact.toBuffer());
342
+ await this.#factsByCollection.set(fact.factCollectionKey.toString(), factKey);
343
+ if (fact.originBlock !== undefined) {
344
+ await this.#factsByBlock.set(fact.originBlock.blockNumber, factKey);
345
+ }
346
+ }
347
+ /**
348
+ * Deletes every fact under the (scope-qualified) collection key.
349
+ *
350
+ * Caller must wrap in a transaction.
351
+ */ async #deleteCollection(collectionKey) {
352
+ // Snapshot the fact index before mutating so we never delete from the cursor we are iterating, kicking off each
353
+ // fact-body read during the scan so a DB request stays pending across the cursor-to-mutation boundary (a drained
354
+ // cursor with no read in flight would let the transaction auto-commit before the deletes).
355
+ const factReads = new Map();
356
+ for await (const factKey of this.#factsByCollection.getValuesAsync(collectionKey)){
357
+ factReads.set(factKey, this.#facts.getAsync(factKey));
358
+ }
359
+ await Promise.all(Array.from(factReads, async ([factKey, read])=>{
360
+ const buf = await read;
361
+ if (!buf) {
362
+ // A #factsByCollection entry must always reference a live #facts entry, a missing one means the indexes are
363
+ // corrupt.
364
+ throw new Error(`Fact not found for factKey ${factKey}`);
365
+ }
366
+ await this.#deleteFact(factKey, StoredFact.fromBuffer(buf));
367
+ }));
368
+ }
369
+ /**
370
+ * Deletes a fact from the primary store and all its indexes (`#factsByCollection`, plus `#factsByBlock` if
371
+ * retractable).
372
+ *
373
+ * Caller must wrap in a transaction.
374
+ */ async #deleteFact(factKey, fact) {
375
+ await this.#facts.delete(factKey);
376
+ await this.#factsByCollection.deleteValue(fact.factCollectionKey.toString(), factKey);
377
+ if (fact.originBlock !== undefined) {
378
+ await this.#factsByBlock.deleteValue(fact.originBlock.blockNumber, factKey);
379
+ }
380
+ }
381
+ /**
382
+ * Returns the job's staged-ops array, creating it on first access.
383
+ * */ #stagedOpsFor(jobId) {
384
+ let ops = this.#opsForJob.get(jobId);
385
+ if (ops === undefined) {
386
+ ops = [];
387
+ this.#opsForJob.set(jobId, ops);
388
+ }
389
+ return ops;
390
+ }
391
+ #clearJobData(jobId) {
392
+ this.#opsForJob.delete(jobId);
393
+ this.#jobLocks.delete(jobId);
394
+ }
395
+ async #withJobLock(jobId, fn) {
396
+ let lock = this.#jobLocks.get(jobId);
397
+ if (!lock) {
398
+ lock = new Semaphore(1);
399
+ this.#jobLocks.set(jobId, lock);
400
+ }
401
+ await lock.acquire();
402
+ try {
403
+ return await fn();
404
+ } finally{
405
+ lock.release();
406
+ }
407
+ }
408
+ }
@@ -0,0 +1,34 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import type { FieldsOf } from '@aztec/foundation/types';
3
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
+ /**
5
+ * The block a retractable fact originates from.
6
+ */
7
+ export type OriginBlock = {
8
+ blockNumber: number;
9
+ blockHash: Fr;
10
+ };
11
+ /** Identifies all fact collections of one type within a contract, for one scope. */
12
+ export declare class FactCollectionTypeKey {
13
+ readonly contractAddress: AztecAddress;
14
+ readonly scope: AztecAddress;
15
+ readonly factCollectionTypeId: Fr;
16
+ constructor(contractAddress: AztecAddress, scope: AztecAddress, factCollectionTypeId: Fr);
17
+ static from(fields: FieldsOf<FactCollectionTypeKey>): FactCollectionTypeKey;
18
+ toString(): string;
19
+ }
20
+ /** Uniquely identifies a single fact collection, isolated by scope; all its facts share this key. */
21
+ export declare class FactCollectionKey {
22
+ readonly contractAddress: AztecAddress;
23
+ readonly scope: AztecAddress;
24
+ readonly factCollectionTypeId: Fr;
25
+ readonly factCollectionId: Fr;
26
+ constructor(contractAddress: AztecAddress, scope: AztecAddress, factCollectionTypeId: Fr, factCollectionId: Fr);
27
+ static from(fields: FieldsOf<FactCollectionKey>): FactCollectionKey;
28
+ /** Inverse of toString */
29
+ static fromString(str: string): FactCollectionKey;
30
+ /** The key grouping this collection with the other collections of its type within the same contract and scope. */
31
+ factCollectionTypeKey(): FactCollectionTypeKey;
32
+ toString(): string;
33
+ }
34
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdF9zdG9yZV9rZXlzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc3RvcmFnZS9mYWN0X3N0b3JlL2ZhY3Rfc3RvcmVfa2V5cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsUUFBUSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFDeEQsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBRTNEOztHQUVHO0FBQ0gsTUFBTSxNQUFNLFdBQVcsR0FBRztJQUFFLFdBQVcsRUFBRSxNQUFNLENBQUM7SUFBQyxTQUFTLEVBQUUsR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ec/stdlib/aztec-address';
3
+ /** Facts are always tied to a real scope; the zero address is not a valid fact scope. */ function assertNonZeroScope(scope) {
4
+ if (scope.equals(AztecAddress.ZERO)) {
5
+ throw new Error('scope must not be the zero address');
6
+ }
7
+ }
8
+ /** Identifies all fact collections of one type within a contract, for one scope. */ export class FactCollectionTypeKey {
9
+ contractAddress;
10
+ scope;
11
+ factCollectionTypeId;
12
+ constructor(contractAddress, scope, factCollectionTypeId){
13
+ this.contractAddress = contractAddress;
14
+ this.scope = scope;
15
+ this.factCollectionTypeId = factCollectionTypeId;
16
+ assertNonZeroScope(scope);
17
+ }
18
+ static from(fields) {
19
+ return new FactCollectionTypeKey(fields.contractAddress, fields.scope, fields.factCollectionTypeId);
20
+ }
21
+ toString() {
22
+ return `${this.contractAddress}:${this.scope}:${this.factCollectionTypeId}`;
23
+ }
24
+ }
25
+ /** Uniquely identifies a single fact collection, isolated by scope; all its facts share this key. */ export class FactCollectionKey {
26
+ contractAddress;
27
+ scope;
28
+ factCollectionTypeId;
29
+ factCollectionId;
30
+ constructor(contractAddress, scope, factCollectionTypeId, factCollectionId){
31
+ this.contractAddress = contractAddress;
32
+ this.scope = scope;
33
+ this.factCollectionTypeId = factCollectionTypeId;
34
+ this.factCollectionId = factCollectionId;
35
+ assertNonZeroScope(scope);
36
+ }
37
+ static from(fields) {
38
+ return new FactCollectionKey(fields.contractAddress, fields.scope, fields.factCollectionTypeId, fields.factCollectionId);
39
+ }
40
+ /** Inverse of toString */ static fromString(str) {
41
+ const [contractAddress, scope, factCollectionTypeId, factCollectionId] = str.split(':');
42
+ return new FactCollectionKey(AztecAddress.fromStringUnsafe(contractAddress), AztecAddress.fromStringUnsafe(scope), Fr.fromString(factCollectionTypeId), Fr.fromString(factCollectionId));
43
+ }
44
+ /** The key grouping this collection with the other collections of its type within the same contract and scope. */ factCollectionTypeKey() {
45
+ return new FactCollectionTypeKey(this.contractAddress, this.scope, this.factCollectionTypeId);
46
+ }
47
+ toString() {
48
+ return `${this.contractAddress}:${this.scope}:${this.factCollectionTypeId}:${this.factCollectionId}`;
49
+ }
50
+ }
@@ -0,0 +1,5 @@
1
+ export { FactStore, type FactCollection } from './fact_store.js';
2
+ export { FactService } from './fact_service.js';
3
+ export { FactCollectionKey, FactCollectionTypeKey, type OriginBlock } from './fact_store_keys.js';
4
+ export type { Fact } from './stored_fact.js';
5
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL2ZhY3Rfc3RvcmUvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFNBQVMsRUFBRSxLQUFLLGNBQWMsRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBQ2pFLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUNoRCxPQUFPLEVBQUUsaUJBQWlCLEVBQUUscUJBQXFCLEVBQUUsS0FBSyxXQUFXLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUNsRyxZQUFZLEVBQUUsSUFBSSxFQUFFLE1BQU0sa0JBQWtCLENBQUMifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/fact_store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAClG,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { FactStore } from './fact_store.js';
2
+ export { FactService } from './fact_service.js';
3
+ export { FactCollectionKey, FactCollectionTypeKey } from './fact_store_keys.js';
@@ -0,0 +1,32 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { BufferReader } from '@aztec/foundation/serialize';
3
+ import { FactCollectionKey, type OriginBlock } from './fact_store_keys.js';
4
+ /** A fact as returned by the fact store. */
5
+ export type Fact = {
6
+ factTypeId: Fr;
7
+ payload: Fr[];
8
+ originBlock: OriginBlock | undefined;
9
+ };
10
+ /**
11
+ * A single immutable fact belonging to a fact collection.
12
+ */
13
+ export declare class StoredFact {
14
+ readonly factCollectionKey: FactCollectionKey;
15
+ readonly factTypeId: Fr;
16
+ readonly payload: Fr[];
17
+ readonly originBlock: OriginBlock | undefined;
18
+ constructor(factCollectionKey: FactCollectionKey, factTypeId: Fr, payload: Fr[], originBlock: OriginBlock | undefined);
19
+ /** Whether this fact is deleted on block pruning (true) or survives reorgs (false). */
20
+ get isRetractable(): boolean;
21
+ /** Stable digest of the payload, used for fact idempotency. */
22
+ payloadHash(): Fr;
23
+ /** Returns the externally facing view of this fact. */
24
+ toFact(): Fact;
25
+ toBuffer(): Buffer;
26
+ static fromBuffer(buffer: Buffer | BufferReader): StoredFact;
27
+ }
28
+ /**
29
+ * Builds the serialized key that identifies a fact in the store.
30
+ */
31
+ export declare function factKeyStrOf(fact: StoredFact): string;
32
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmVkX2ZhY3QuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL2ZhY3Rfc3RvcmUvc3RvcmVkX2ZhY3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sRUFBRSxZQUFZLEVBQXFCLE1BQU0sNkJBQTZCLENBQUM7QUFHOUUsT0FBTyxFQUFFLGlCQ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