@aztec/pxe 0.0.1-commit.6d3c34e → 0.0.1-commit.7035c9bd6

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 (286) hide show
  1. package/dest/access_scopes.d.ts +9 -0
  2. package/dest/access_scopes.d.ts.map +1 -0
  3. package/dest/access_scopes.js +6 -0
  4. package/dest/bin/check_oracle_version.js +1 -1
  5. package/dest/block_synchronizer/block_synchronizer.d.ts +11 -5
  6. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  7. package/dest/block_synchronizer/block_synchronizer.js +72 -21
  8. package/dest/config/index.d.ts +4 -2
  9. package/dest/config/index.d.ts.map +1 -1
  10. package/dest/config/index.js +18 -1
  11. package/dest/config/package_info.js +1 -1
  12. package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
  13. package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
  14. package/dest/contract_function_simulator/benchmarked_node.js +77 -0
  15. package/dest/contract_function_simulator/contract_function_simulator.d.ts +64 -36
  16. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/contract_function_simulator.js +224 -88
  18. package/dest/contract_function_simulator/execution_note_cache.d.ts +18 -9
  19. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  20. package/dest/contract_function_simulator/execution_note_cache.js +45 -28
  21. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -7
  22. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  23. package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
  24. package/dest/contract_function_simulator/index.d.ts +3 -2
  25. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  26. package/dest/contract_function_simulator/index.js +2 -1
  27. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -4
  28. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  29. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +6 -5
  30. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
  31. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  32. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -3
  33. package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts +16 -0
  34. package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts.map +1 -0
  35. package/dest/contract_function_simulator/noir-structs/message_tx_context.js +57 -0
  36. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -5
  37. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  38. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +4 -6
  39. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
  40. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
  41. package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
  42. package/dest/contract_function_simulator/oracle/interfaces.d.ts +56 -47
  43. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  44. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
  45. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
  46. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +42 -0
  47. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -1
  48. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  49. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +6 -6
  50. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
  51. package/dest/contract_function_simulator/oracle/note_packing_utils.js +8 -8
  52. package/dest/contract_function_simulator/oracle/oracle.d.ts +45 -42
  53. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  54. package/dest/contract_function_simulator/oracle/oracle.js +209 -117
  55. package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -26
  56. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  57. package/dest/contract_function_simulator/oracle/private_execution.js +5 -38
  58. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +60 -76
  59. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  60. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +113 -88
  61. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +107 -56
  62. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  63. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +214 -137
  64. package/dest/contract_logging.d.ts +22 -0
  65. package/dest/contract_logging.d.ts.map +1 -0
  66. package/dest/contract_logging.js +23 -0
  67. package/dest/contract_sync/contract_sync_service.d.ts +45 -0
  68. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
  69. package/dest/contract_sync/contract_sync_service.js +114 -0
  70. package/dest/contract_sync/helpers.d.ts +29 -0
  71. package/dest/contract_sync/helpers.d.ts.map +1 -0
  72. package/dest/contract_sync/helpers.js +55 -0
  73. package/dest/debug/pxe_debug_utils.d.ts +24 -10
  74. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  75. package/dest/debug/pxe_debug_utils.js +28 -17
  76. package/dest/entrypoints/client/bundle/index.d.ts +4 -1
  77. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  78. package/dest/entrypoints/client/bundle/index.js +3 -0
  79. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  80. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  81. package/dest/entrypoints/client/bundle/utils.js +21 -7
  82. package/dest/entrypoints/client/lazy/index.d.ts +4 -1
  83. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  84. package/dest/entrypoints/client/lazy/index.js +3 -0
  85. package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
  86. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  87. package/dest/entrypoints/client/lazy/utils.js +22 -8
  88. package/dest/entrypoints/pxe_creation_options.d.ts +3 -2
  89. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  90. package/dest/entrypoints/server/index.d.ts +5 -1
  91. package/dest/entrypoints/server/index.d.ts.map +1 -1
  92. package/dest/entrypoints/server/index.js +4 -0
  93. package/dest/entrypoints/server/utils.d.ts +1 -1
  94. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  95. package/dest/entrypoints/server/utils.js +28 -9
  96. package/dest/events/event_service.d.ts +6 -6
  97. package/dest/events/event_service.d.ts.map +1 -1
  98. package/dest/events/event_service.js +19 -22
  99. package/dest/events/private_event_filter_validator.d.ts +5 -5
  100. package/dest/events/private_event_filter_validator.d.ts.map +1 -1
  101. package/dest/events/private_event_filter_validator.js +5 -6
  102. package/dest/job_coordinator/job_coordinator.d.ts +3 -2
  103. package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
  104. package/dest/job_coordinator/job_coordinator.js +3 -2
  105. package/dest/logs/log_service.d.ts +8 -5
  106. package/dest/logs/log_service.d.ts.map +1 -1
  107. package/dest/logs/log_service.js +31 -33
  108. package/dest/messages/message_context_service.d.ts +17 -0
  109. package/dest/messages/message_context_service.d.ts.map +1 -0
  110. package/dest/messages/message_context_service.js +36 -0
  111. package/dest/notes/note_service.d.ts +10 -9
  112. package/dest/notes/note_service.d.ts.map +1 -1
  113. package/dest/notes/note_service.js +34 -38
  114. package/dest/notes_filter.d.ts +25 -0
  115. package/dest/notes_filter.d.ts.map +1 -0
  116. package/dest/notes_filter.js +4 -0
  117. package/dest/oracle_version.d.ts +3 -3
  118. package/dest/oracle_version.d.ts.map +1 -1
  119. package/dest/oracle_version.js +5 -4
  120. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
  121. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
  122. package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
  123. package/dest/private_kernel/hints/index.d.ts +3 -3
  124. package/dest/private_kernel/hints/index.d.ts.map +1 -1
  125. package/dest/private_kernel/hints/index.js +2 -2
  126. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +29 -0
  127. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
  128. package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +140 -73
  129. package/dest/private_kernel/hints/test_utils.d.ts +122 -0
  130. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
  131. package/dest/private_kernel/hints/test_utils.js +203 -0
  132. package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
  133. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  134. package/dest/private_kernel/private_kernel_execution_prover.js +22 -14
  135. package/dest/private_kernel/private_kernel_oracle.d.ts +23 -24
  136. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  137. package/dest/private_kernel/private_kernel_oracle.js +94 -2
  138. package/dest/pxe.d.ts +80 -59
  139. package/dest/pxe.d.ts.map +1 -1
  140. package/dest/pxe.js +155 -145
  141. package/dest/storage/address_store/address_store.d.ts +1 -1
  142. package/dest/storage/address_store/address_store.d.ts.map +1 -1
  143. package/dest/storage/address_store/address_store.js +12 -11
  144. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
  145. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
  146. package/dest/storage/anchor_block_store/anchor_block_store.js +8 -1
  147. package/dest/storage/capsule_store/capsule_store.d.ts +24 -9
  148. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
  149. package/dest/storage/capsule_store/capsule_store.js +130 -23
  150. package/dest/storage/contract_store/contract_store.d.ts +42 -16
  151. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  152. package/dest/storage/contract_store/contract_store.js +157 -84
  153. package/dest/storage/metadata.d.ts +1 -1
  154. package/dest/storage/metadata.js +1 -1
  155. package/dest/storage/note_store/note_store.d.ts +50 -51
  156. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  157. package/dest/storage/note_store/note_store.js +284 -263
  158. package/dest/storage/note_store/stored_note.d.ts +16 -0
  159. package/dest/storage/note_store/stored_note.d.ts.map +1 -0
  160. package/dest/storage/note_store/stored_note.js +43 -0
  161. package/dest/storage/private_event_store/private_event_store.d.ts +43 -8
  162. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  163. package/dest/storage/private_event_store/private_event_store.js +226 -111
  164. package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
  165. package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
  166. package/dest/storage/private_event_store/stored_private_event.js +56 -0
  167. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +16 -9
  168. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  169. package/dest/storage/tagging_store/recipient_tagging_store.js +88 -19
  170. package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
  171. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
  172. package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
  173. package/dest/storage/tagging_store/sender_tagging_store.d.ts +43 -32
  174. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  175. package/dest/storage/tagging_store/sender_tagging_store.js +300 -122
  176. package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
  177. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
  178. package/dest/tagging/get_all_logs_by_tags.js +60 -0
  179. package/dest/tagging/index.d.ts +4 -3
  180. package/dest/tagging/index.d.ts.map +1 -1
  181. package/dest/tagging/index.js +2 -1
  182. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +5 -5
  183. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  184. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +11 -11
  185. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
  186. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +7 -7
  187. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  188. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +16 -12
  189. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +5 -8
  190. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  191. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +18 -12
  192. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
  193. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  194. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +23 -16
  195. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +8 -7
  196. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  197. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +44 -27
  198. package/package.json +27 -18
  199. package/src/access_scopes.ts +9 -0
  200. package/src/bin/check_oracle_version.ts +1 -0
  201. package/src/block_synchronizer/block_synchronizer.ts +91 -33
  202. package/src/config/index.ts +15 -1
  203. package/src/config/package_info.ts +1 -1
  204. package/src/contract_function_simulator/benchmarked_node.ts +103 -0
  205. package/src/contract_function_simulator/contract_function_simulator.ts +386 -153
  206. package/src/contract_function_simulator/execution_note_cache.ts +44 -25
  207. package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
  208. package/src/contract_function_simulator/index.ts +2 -1
  209. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +9 -6
  210. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -4
  211. package/src/contract_function_simulator/noir-structs/message_tx_context.ts +55 -0
  212. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +4 -7
  213. package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
  214. package/src/contract_function_simulator/oracle/interfaces.ts +69 -59
  215. package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +135 -0
  216. package/src/contract_function_simulator/oracle/note_packing_utils.ts +10 -10
  217. package/src/contract_function_simulator/oracle/oracle.ts +235 -165
  218. package/src/contract_function_simulator/oracle/private_execution.ts +5 -71
  219. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +153 -184
  220. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +318 -154
  221. package/src/contract_logging.ts +39 -0
  222. package/src/contract_sync/contract_sync_service.ts +181 -0
  223. package/src/contract_sync/helpers.ts +98 -0
  224. package/src/debug/pxe_debug_utils.ts +63 -18
  225. package/src/entrypoints/client/bundle/index.ts +3 -0
  226. package/src/entrypoints/client/bundle/utils.ts +16 -15
  227. package/src/entrypoints/client/lazy/index.ts +3 -0
  228. package/src/entrypoints/client/lazy/utils.ts +17 -15
  229. package/src/entrypoints/pxe_creation_options.ts +2 -1
  230. package/src/entrypoints/server/index.ts +4 -0
  231. package/src/entrypoints/server/utils.ts +22 -26
  232. package/src/events/event_service.ts +17 -25
  233. package/src/events/private_event_filter_validator.ts +3 -5
  234. package/src/job_coordinator/job_coordinator.ts +4 -3
  235. package/src/logs/log_service.ts +51 -40
  236. package/src/messages/message_context_service.ts +45 -0
  237. package/src/notes/note_service.ts +41 -45
  238. package/src/notes_filter.ts +26 -0
  239. package/src/oracle_version.ts +5 -4
  240. package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
  241. package/src/private_kernel/hints/index.ts +2 -2
  242. package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +195 -136
  243. package/src/private_kernel/hints/test_utils.ts +325 -0
  244. package/src/private_kernel/private_kernel_execution_prover.ts +26 -16
  245. package/src/private_kernel/private_kernel_oracle.ts +116 -37
  246. package/src/pxe.ts +286 -223
  247. package/src/storage/address_store/address_store.ts +15 -15
  248. package/src/storage/anchor_block_store/anchor_block_store.ts +8 -0
  249. package/src/storage/capsule_store/capsule_store.ts +159 -23
  250. package/src/storage/contract_store/contract_store.ts +186 -96
  251. package/src/storage/metadata.ts +1 -1
  252. package/src/storage/note_store/note_store.ts +326 -320
  253. package/src/storage/note_store/stored_note.ts +48 -0
  254. package/src/storage/private_event_store/private_event_store.ts +292 -124
  255. package/src/storage/private_event_store/stored_private_event.ts +73 -0
  256. package/src/storage/tagging_store/recipient_tagging_store.ts +111 -21
  257. package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
  258. package/src/storage/tagging_store/sender_tagging_store.ts +366 -134
  259. package/src/tagging/get_all_logs_by_tags.ts +92 -0
  260. package/src/tagging/index.ts +3 -2
  261. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +22 -14
  262. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
  263. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +17 -16
  264. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +31 -15
  265. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +29 -26
  266. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +42 -29
  267. package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
  268. package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
  269. package/dest/contract_function_simulator/proxied_node.js +0 -27
  270. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
  271. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
  272. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
  273. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
  274. package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -46
  275. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
  276. package/dest/private_kernel/private_kernel_oracle_impl.js +0 -85
  277. package/dest/public_storage/public_storage_service.d.ts +0 -24
  278. package/dest/public_storage/public_storage_service.d.ts.map +0 -1
  279. package/dest/public_storage/public_storage_service.js +0 -26
  280. package/dest/tree_membership/tree_membership_service.d.ts +0 -52
  281. package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
  282. package/dest/tree_membership/tree_membership_service.js +0 -84
  283. package/src/contract_function_simulator/proxied_node.ts +0 -33
  284. package/src/private_kernel/private_kernel_oracle_impl.ts +0 -127
  285. package/src/public_storage/public_storage_service.ts +0 -33
  286. package/src/tree_membership/tree_membership_service.ts +0 -112
@@ -1,5 +1,6 @@
1
1
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
2
- import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
2
+ import type { ExtendedDirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
3
+ import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
3
4
  /**
4
5
  * Data provider of tagging data used when syncing the logs as a recipient. The sender counterpart of this class
5
6
  * is called SenderTaggingStore. We have the providers separate for the sender and recipient because
@@ -7,15 +8,21 @@ import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
7
8
  *
8
9
  * @dev Chain reorgs do not need to be handled here because both the finalized and aged indexes refer to finalized
9
10
  * blocks, which by definition cannot be affected by reorgs.
10
- *
11
- * TODO(benesjan): Relocate to yarn-project/pxe/src/storage/tagging_store
12
11
  */
13
- export declare class RecipientTaggingStore {
12
+ export declare class RecipientTaggingStore implements StagedStore {
14
13
  #private;
14
+ storeName: string;
15
15
  constructor(store: AztecAsyncKVStore);
16
- getHighestAgedIndex(secret: DirectionalAppTaggingSecret): Promise<number | undefined>;
17
- updateHighestAgedIndex(secret: DirectionalAppTaggingSecret, index: number): Promise<void>;
18
- getHighestFinalizedIndex(secret: DirectionalAppTaggingSecret): Promise<number | undefined>;
19
- updateHighestFinalizedIndex(secret: DirectionalAppTaggingSecret, index: number): Promise<void>;
16
+ /**
17
+ * Writes all job-specific in-memory data to persistent storage.
18
+ *
19
+ * @remark This method must run in a DB transaction context. It's designed to be called from JobCoordinator#commitJob.
20
+ */
21
+ commit(jobId: string): Promise<void>;
22
+ discardStaged(jobId: string): Promise<void>;
23
+ getHighestAgedIndex(secret: ExtendedDirectionalAppTaggingSecret, jobId: string): Promise<number | undefined>;
24
+ updateHighestAgedIndex(secret: ExtendedDirectionalAppTaggingSecret, index: number, jobId: string): Promise<void>;
25
+ getHighestFinalizedIndex(secret: ExtendedDirectionalAppTaggingSecret, jobId: string): Promise<number | undefined>;
26
+ updateHighestFinalizedIndex(secret: ExtendedDirectionalAppTaggingSecret, index: number, jobId: string): Promise<void>;
20
27
  }
21
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVjaXBpZW50X3RhZ2dpbmdfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL3RhZ2dpbmdfc3RvcmUvcmVjaXBpZW50X3RhZ2dpbmdfc3RvcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQWlCLE1BQU0saUJBQWlCLENBQUM7QUFDeEUsT0FBTyxLQUFLLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUV0RTs7Ozs7Ozs7O0dBU0c7QUFDSCxxQkFBYSxxQkFBcUI7O0lBTWhDLFlBQVksS0FBSyxFQUFFLGlCQUFpQixFQUtuQztJQUVELG1CQUFtQixDQUFDLE1BQU0sRUFBRSwyQkFBMkIsR0FBRyxPQUFPLENBQUMsTUFBTSxHQUFHLFNBQVMsQ0FBQyxDQUVwRjtJQUVLLHNCQUFzQixDQUFDLE1BQU0sRUFBRSwyQkFBMkIsRUFBRSxLQUFLLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ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,2BAA2B,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQnG;CACF"}
1
+ {"version":3,"file":"recipient_tagging_store.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_store/recipient_tagging_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,oBAAoB,CAAC;AAE9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAE5E;;;;;;;GAOG;AACH,qBAAa,qBAAsB,YAAW,WAAW;;IACvD,SAAS,EAAE,MAAM,CAAuB;IAaxC,YAAY,KAAK,EAAE,iBAAiB,EAQnC;IA4CD;;;;OAIG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBzC;IAED,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI1C;IAED,mBAAmB,CAAC,MAAM,EAAE,mCAAmC,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAE3G;IAED,sBAAsB,CAAC,MAAM,EAAE,mCAAmC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAS/G;IAED,wBAAwB,CAAC,MAAM,EAAE,mCAAmC,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAEhH;IAED,2BAA2B,CACzB,MAAM,EAAE,mCAAmC,EAC3C,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAUf;CACF"}
@@ -5,38 +5,107 @@
5
5
  *
6
6
  * @dev Chain reorgs do not need to be handled here because both the finalized and aged indexes refer to finalized
7
7
  * blocks, which by definition cannot be affected by reorgs.
8
- *
9
- * TODO(benesjan): Relocate to yarn-project/pxe/src/storage/tagging_store
10
8
  */ export class RecipientTaggingStore {
9
+ storeName = 'recipient_tagging';
11
10
  #store;
12
11
  #highestAgedIndex;
13
12
  #highestFinalizedIndex;
13
+ // jobId => secret => number
14
+ #highestAgedIndexForJob;
15
+ // jobId => secret => number
16
+ #highestFinalizedIndexForJob;
14
17
  constructor(store){
15
18
  this.#store = store;
16
19
  this.#highestAgedIndex = this.#store.openMap('highest_aged_index');
17
20
  this.#highestFinalizedIndex = this.#store.openMap('highest_finalized_index');
21
+ this.#highestAgedIndexForJob = new Map();
22
+ this.#highestFinalizedIndexForJob = new Map();
23
+ }
24
+ #getHighestAgedIndexForJob(jobId) {
25
+ let highestAgedIndexForJob = this.#highestAgedIndexForJob.get(jobId);
26
+ if (!highestAgedIndexForJob) {
27
+ highestAgedIndexForJob = new Map();
28
+ this.#highestAgedIndexForJob.set(jobId, highestAgedIndexForJob);
29
+ }
30
+ return highestAgedIndexForJob;
18
31
  }
19
- getHighestAgedIndex(secret) {
20
- return this.#highestAgedIndex.getAsync(secret.toString());
32
+ async #readHighestAgedIndex(jobId, secret) {
33
+ // Always issue DB read to keep IndexedDB transaction alive (they auto-commit when a new micro-task starts and there
34
+ // are no pending read requests). The staged value still takes precedence if it exists.
35
+ const dbValue = await this.#highestAgedIndex.getAsync(secret);
36
+ const staged = this.#getHighestAgedIndexForJob(jobId).get(secret);
37
+ return staged ?? dbValue;
21
38
  }
22
- async updateHighestAgedIndex(secret, index) {
23
- const currentIndex = await this.#highestAgedIndex.getAsync(secret.toString());
24
- if (currentIndex !== undefined && index <= currentIndex) {
25
- // Log sync should never set a lower highest aged index.
26
- throw new Error(`New highest aged index (${index}) must be higher than the current one (${currentIndex})`);
39
+ #writeHighestAgedIndex(jobId, secret, index) {
40
+ this.#getHighestAgedIndexForJob(jobId).set(secret, index);
41
+ }
42
+ #getHighestFinalizedIndexForJob(jobId) {
43
+ let jobStagedHighestFinalizedIndex = this.#highestFinalizedIndexForJob.get(jobId);
44
+ if (!jobStagedHighestFinalizedIndex) {
45
+ jobStagedHighestFinalizedIndex = new Map();
46
+ this.#highestFinalizedIndexForJob.set(jobId, jobStagedHighestFinalizedIndex);
27
47
  }
28
- await this.#highestAgedIndex.set(secret.toString(), index);
48
+ return jobStagedHighestFinalizedIndex;
49
+ }
50
+ async #readHighestFinalizedIndex(jobId, secret) {
51
+ // Always issue DB read to keep IndexedDB transaction alive (they auto-commit when a new micro-task starts and there
52
+ // are no pending read requests). The staged value still takes precedence if it exists.
53
+ const dbValue = await this.#highestFinalizedIndex.getAsync(secret);
54
+ const staged = this.#getHighestFinalizedIndexForJob(jobId).get(secret);
55
+ return staged ?? dbValue;
29
56
  }
30
- getHighestFinalizedIndex(secret) {
31
- return this.#highestFinalizedIndex.getAsync(secret.toString());
57
+ #writeHighestFinalizedIndex(jobId, secret, index) {
58
+ this.#getHighestFinalizedIndexForJob(jobId).set(secret, index);
32
59
  }
33
- async updateHighestFinalizedIndex(secret, index) {
34
- const currentIndex = await this.#highestFinalizedIndex.getAsync(secret.toString());
35
- if (currentIndex !== undefined && index < currentIndex) {
36
- // Log sync should never set a lower highest finalized index but it can happen that it would try to set the same
37
- // one because we are loading logs from highest aged index + 1 and not from the highest finalized index.
38
- throw new Error(`New highest finalized index (${index}) must be higher than the current one (${currentIndex})`);
60
+ /**
61
+ * Writes all job-specific in-memory data to persistent storage.
62
+ *
63
+ * @remark This method must run in a DB transaction context. It's designed to be called from JobCoordinator#commitJob.
64
+ */ async commit(jobId) {
65
+ const highestAgedIndexForJob = this.#highestAgedIndexForJob.get(jobId);
66
+ if (highestAgedIndexForJob) {
67
+ for (const [secret, index] of highestAgedIndexForJob.entries()){
68
+ await this.#highestAgedIndex.set(secret, index);
69
+ }
70
+ }
71
+ const highestFinalizedIndexForJob = this.#highestFinalizedIndexForJob.get(jobId);
72
+ if (highestFinalizedIndexForJob) {
73
+ for (const [secret, index] of highestFinalizedIndexForJob.entries()){
74
+ await this.#highestFinalizedIndex.set(secret, index);
75
+ }
39
76
  }
40
- await this.#highestFinalizedIndex.set(secret.toString(), index);
77
+ return this.discardStaged(jobId);
78
+ }
79
+ discardStaged(jobId) {
80
+ this.#highestAgedIndexForJob.delete(jobId);
81
+ this.#highestFinalizedIndexForJob.delete(jobId);
82
+ return Promise.resolve();
83
+ }
84
+ getHighestAgedIndex(secret, jobId) {
85
+ return this.#store.transactionAsync(()=>this.#readHighestAgedIndex(jobId, secret.toString()));
86
+ }
87
+ updateHighestAgedIndex(secret, index, jobId) {
88
+ return this.#store.transactionAsync(async ()=>{
89
+ const currentIndex = await this.#readHighestAgedIndex(jobId, secret.toString());
90
+ if (currentIndex !== undefined && index <= currentIndex) {
91
+ // Log sync should never set a lower highest aged index.
92
+ throw new Error(`New highest aged index (${index}) must be higher than the current one (${currentIndex})`);
93
+ }
94
+ this.#writeHighestAgedIndex(jobId, secret.toString(), index);
95
+ });
96
+ }
97
+ getHighestFinalizedIndex(secret, jobId) {
98
+ return this.#store.transactionAsync(()=>this.#readHighestFinalizedIndex(jobId, secret.toString()));
99
+ }
100
+ updateHighestFinalizedIndex(secret, index, jobId) {
101
+ return this.#store.transactionAsync(async ()=>{
102
+ const currentIndex = await this.#readHighestFinalizedIndex(jobId, secret.toString());
103
+ if (currentIndex !== undefined && index < currentIndex) {
104
+ // Log sync should never set a lower highest finalized index but it can happen that it would try to set the same
105
+ // one because we are loading logs from highest aged index + 1 and not from the highest finalized index.
106
+ throw new Error(`New highest finalized index (${index}) must be higher than the current one (${currentIndex})`);
107
+ }
108
+ this.#writeHighestFinalizedIndex(jobId, secret.toString(), index);
109
+ });
41
110
  }
42
111
  }
@@ -11,4 +11,4 @@ export declare class SenderAddressBookStore {
11
11
  getSenders(): Promise<AztecAddress[]>;
12
12
  removeSender(address: AztecAddress): Promise<boolean>;
13
13
  }
14
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VuZGVyX2FkZHJ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SWpDLFlBQVksS0FBSyxFQUFFLGlCQUFpQixFQUluQztJQUVELFNBQVMsQ0FBQyxPQUFPLEVBQUUsWUFBWSxHQUFHLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FVakQ7SUFFRCxVQUFVLElBQUksT0FBTyxDQUFDLFlBQVksRUFBRSxDQUFDLENBSXBDO0lBRUQsWUFBWSxDQUFDLE9BQU8sRUFBRSxZQUFZLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQVVwRDtDQUNGIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"sender_address_book_store.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_store/sender_address_book_store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D;;;GAGG;AACH,qBAAa,sBAAsB;;IAIjC,YAAY,KAAK,EAAE,iBAAiB,EAInC;IAEK,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAQvD;IAEK,UAAU,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAE1C;IAEK,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAQ1D;CACF"}
1
+ {"version":3,"file":"sender_address_book_store.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_store/sender_address_book_store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D;;;GAGG;AACH,qBAAa,sBAAsB;;IAIjC,YAAY,KAAK,EAAE,iBAAiB,EAInC;IAED,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAUjD;IAED,UAAU,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAIpC;IAED,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAUpD;CACF"}
@@ -10,21 +10,27 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
10
10
  this.#store = store;
11
11
  this.#addressBook = this.#store.openMap('address_book');
12
12
  }
13
- async addSender(address) {
14
- if (await this.#addressBook.hasAsync(address.toString())) {
15
- return false;
16
- }
17
- await this.#addressBook.set(address.toString(), true);
18
- return true;
13
+ addSender(address) {
14
+ return this.#store.transactionAsync(async ()=>{
15
+ if (await this.#addressBook.hasAsync(address.toString())) {
16
+ return false;
17
+ }
18
+ await this.#addressBook.set(address.toString(), true);
19
+ return true;
20
+ });
19
21
  }
20
- async getSenders() {
21
- return (await toArray(this.#addressBook.keysAsync())).map(AztecAddress.fromString);
22
+ getSenders() {
23
+ return this.#store.transactionAsync(async ()=>{
24
+ return (await toArray(this.#addressBook.keysAsync())).map(AztecAddress.fromString);
25
+ });
22
26
  }
23
- async removeSender(address) {
24
- if (!await this.#addressBook.hasAsync(address.toString())) {
25
- return false;
26
- }
27
- await this.#addressBook.delete(address.toString());
28
- return true;
27
+ removeSender(address) {
28
+ return this.#store.transactionAsync(async ()=>{
29
+ if (!await this.#addressBook.hasAsync(address.toString())) {
30
+ return false;
31
+ }
32
+ await this.#addressBook.delete(address.toString());
33
+ return true;
34
+ });
29
35
  }
30
36
  }
@@ -1,67 +1,78 @@
1
1
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
2
- import type { DirectionalAppTaggingSecret, PreTag } from '@aztec/stdlib/logs';
3
- import { TxHash } from '@aztec/stdlib/tx';
2
+ import { ExtendedDirectionalAppTaggingSecret, type TaggingIndexRange } from '@aztec/stdlib/logs';
3
+ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
4
+ import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
4
5
  /**
5
6
  * Data provider of tagging data used when syncing the sender tagging indexes. The recipient counterpart of this class
6
- * is called RecipientTaggingStore. We have the providers separate for the sender and recipient because
7
+ * is called RecipientTaggingStore. We have the data stores separate for sender and recipient because
7
8
  * the algorithms are completely disjoint and there is not data reuse between the two.
8
9
  */
9
- export declare class SenderTaggingStore {
10
+ export declare class SenderTaggingStore implements StagedStore {
10
11
  #private;
12
+ readonly storeName = "sender_tagging";
11
13
  constructor(store: AztecAsyncKVStore);
12
14
  /**
13
- * Stores pending indexes.
14
- * @remarks Ignores the index if the same preTag + txHash combination already exists in the db with the same index.
15
- * This is expected to happen because whenever we start sync we start from the last finalized index and we can have
16
- * pending indexes already stored from previous syncs.
17
- * @param preTags - The pre-tags containing the directional app tagging secrets and the indexes that are to be
18
- * stored in the db.
19
- * @param txHash - The tx in which the pretags were used in private logs.
20
- * @throws If any two pre-tags contain the same directional app tagging secret. This is enforced because we care
21
- * only about the highest index for a given secret that was used in the tx. Hence this check is a good way to catch
22
- * bugs.
23
- * @throws If the newly stored pending index is further than window length from the highest finalized index for the
24
- * same secret. This is enforced in order to give a guarantee to a recipient that he doesn't need to look further than
25
- * window length ahead of the highest finalized index.
26
- * @throws If a secret + txHash pair already exists in the db with a different index value. It should never happen
27
- * that we would attempt to store a different index for a given secret-txHash pair because we always store just the
28
- * highest index for a given secret-txHash pair. Hence this is a good way to catch bugs.
29
- * @throws If the newly stored pending index is lower than or equal to the last finalized index for the same secret.
30
- * This is enforced because this should never happen if the syncing is done correctly as we look for logs from higher
31
- * indexes than finalized ones.
15
+ * Writes all job-specific in-memory data to persistent storage.
16
+ *
17
+ * @remark This method must run in a DB transaction context. It's designed to be called from JobCoordinator#commitJob.
32
18
  */
33
- storePendingIndexes(preTags: PreTag[], txHash: TxHash): Promise<void>;
19
+ commit(jobId: string): Promise<void>;
20
+ discardStaged(jobId: string): Promise<void>;
34
21
  /**
35
- * Returns the transaction hashes of all pending transactions that contain indexes within a specified range
36
- * for a given directional app tagging secret.
22
+ * Stores pending index ranges.
23
+ * @remarks If the same (secret, txHash) pair already exists in the db with an equal range, it's a no-op. This is
24
+ * expected to happen because whenever we start sync we start from the last finalized index and we can have pending
25
+ * ranges already stored from previous syncs. If the ranges differ, it throws an error as that indicates a bug.
26
+ * @param ranges - The tagging index ranges containing the directional app tagging secrets and the index ranges that are
27
+ * to be stored in the db.
28
+ * @param txHash - The tx in which the tagging indexes were used in private logs.
29
+ * @param jobId - job context for staged writes to this store. See `JobCoordinator` for more details.
30
+ * @throws If the highestIndex is further than window length from the highest finalized index for the same secret.
31
+ * @throws If the lowestIndex is lower than or equal to the last finalized index for the same secret.
32
+ * @throws If a different range already exists for the same (secret, txHash) pair.
33
+ */
34
+ storePendingIndexes(ranges: TaggingIndexRange[], txHash: TxHash, jobId: string): Promise<void>;
35
+ /**
36
+ * Returns the transaction hashes of all pending transactions that contain highest indexes within a specified range
37
+ * for a given directional app tagging secret. We check based on the highest indexes only as that is the relevant
38
+ * information for the caller of this function.
37
39
  * @param secret - The directional app tagging secret to query pending indexes for.
38
40
  * @param startIndex - The lower bound of the index range (inclusive).
39
41
  * @param endIndex - The upper bound of the index range (exclusive).
40
42
  * @returns An array of unique transaction hashes for pending transactions that contain indexes in the range
41
43
  * [startIndex, endIndex). Returns an empty array if no pending indexes exist in the range.
42
44
  */
43
- getTxHashesOfPendingIndexes(secret: DirectionalAppTaggingSecret, startIndex: number, endIndex: number): Promise<TxHash[]>;
45
+ getTxHashesOfPendingIndexes(secret: ExtendedDirectionalAppTaggingSecret, startIndex: number, endIndex: number, jobId: string): Promise<TxHash[]>;
44
46
  /**
45
47
  * Returns the last (highest) finalized index for a given secret.
46
48
  * @param secret - The secret to get the last finalized index for.
47
49
  * @returns The last (highest) finalized index for the given secret.
48
50
  */
49
- getLastFinalizedIndex(secret: DirectionalAppTaggingSecret): Promise<number | undefined>;
51
+ getLastFinalizedIndex(secret: ExtendedDirectionalAppTaggingSecret, jobId: string): Promise<number | undefined>;
50
52
  /**
51
53
  * Returns the last used index for a given directional app tagging secret, considering both finalized and pending
52
54
  * indexes.
53
55
  * @param secret - The directional app tagging secret to query the last used index for.
54
56
  * @returns The last used index.
55
57
  */
56
- getLastUsedIndex(secret: DirectionalAppTaggingSecret): Promise<number | undefined>;
58
+ getLastUsedIndex(secret: ExtendedDirectionalAppTaggingSecret, jobId: string): Promise<number | undefined>;
57
59
  /**
58
60
  * Drops all pending indexes corresponding to the given transaction hashes.
59
61
  */
60
- dropPendingIndexes(txHashes: TxHash[]): Promise<void>;
62
+ dropPendingIndexes(txHashes: TxHash[], jobId: string): Promise<void>;
61
63
  /**
62
64
  * Updates pending indexes corresponding to the given transaction hashes to be finalized and prunes any lower pending
63
65
  * indexes.
64
66
  */
65
- finalizePendingIndexes(txHashes: TxHash[]): Promise<void>;
67
+ finalizePendingIndexes(txHashes: TxHash[], jobId: string): Promise<void>;
68
+ /**
69
+ * Handles finalization of pending indexes for a transaction whose execution was partially reverted.
70
+ * Recomputes the siloed tags for each pending index of the given tx and checks which ones appear in the
71
+ * TxEffect's private logs (i.e., which ones made it onchain). Those that survived are finalized; those that
72
+ * didn't are dropped.
73
+ * @param txEffect - The tx effect of the partially reverted transaction.
74
+ * @param jobId - job context for staged writes to this store. See `JobCoordinator` for more details.
75
+ */
76
+ finalizePendingIndexesOfAPartiallyRevertedTx(txEffect: TxEffect, jobId: string): Promise<void>;
66
77
  }
67
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VuZGVyX3RhZ2dpbmdfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL3RhZ2dpbmdfc3RvcmUvc2VuZGVyX3RhZ2dpbmdfc3RvcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQWlCLE1BQU0saUJBQWlCLENBQUM7QUFDeEUsT0FBTyxLQUFLLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSxFQUFFLE1BQU0sb0JBQ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