@aztec/pxe 3.0.3 → 4.0.0-devnet.1-patch.0

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 (369) hide show
  1. package/dest/bin/check_oracle_version.js +1 -1
  2. package/dest/block_synchronizer/block_synchronizer.d.ts +45 -0
  3. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
  4. package/dest/block_synchronizer/block_synchronizer.js +153 -0
  5. package/dest/block_synchronizer/index.d.ts +2 -0
  6. package/dest/block_synchronizer/index.d.ts.map +1 -0
  7. package/dest/block_synchronizer/index.js +1 -0
  8. package/dest/config/index.d.ts +6 -4
  9. package/dest/config/index.d.ts.map +1 -1
  10. package/dest/config/index.js +17 -0
  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 +41 -13
  16. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/contract_function_simulator.js +73 -32
  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 +1 -1
  22. package/dest/contract_function_simulator/execution_tagging_index_cache.js +1 -1
  23. package/dest/contract_function_simulator/index.d.ts +2 -2
  24. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  25. package/dest/contract_function_simulator/index.js +1 -1
  26. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +4 -3
  27. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  28. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +6 -3
  29. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +4 -3
  30. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
  31. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +7 -6
  32. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +1 -1
  33. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
  34. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
  35. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
  36. package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
  37. package/dest/contract_function_simulator/oracle/interfaces.d.ts +19 -16
  38. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  39. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -1
  40. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  41. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +6 -6
  42. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
  43. package/dest/contract_function_simulator/oracle/note_packing_utils.js +8 -8
  44. package/dest/contract_function_simulator/oracle/oracle.d.ts +11 -9
  45. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  46. package/dest/contract_function_simulator/oracle/oracle.js +70 -47
  47. package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -28
  48. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  49. package/dest/contract_function_simulator/oracle/private_execution.js +1 -37
  50. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +31 -22
  51. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  52. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +39 -43
  53. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +84 -29
  54. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  55. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +198 -71
  56. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +4 -4
  57. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
  58. package/dest/contract_function_simulator/proxied_contract_data_source.js +23 -5
  59. package/dest/contract_sync/contract_sync_service.d.ts +41 -0
  60. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
  61. package/dest/contract_sync/contract_sync_service.js +82 -0
  62. package/dest/contract_sync/helpers.d.ts +28 -0
  63. package/dest/contract_sync/helpers.d.ts.map +1 -0
  64. package/dest/contract_sync/helpers.js +55 -0
  65. package/dest/debug/pxe_debug_utils.d.ts +44 -0
  66. package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
  67. package/dest/debug/pxe_debug_utils.js +48 -0
  68. package/dest/entrypoints/client/bundle/index.d.ts +1 -2
  69. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  70. package/dest/entrypoints/client/bundle/index.js +0 -1
  71. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  72. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  73. package/dest/entrypoints/client/bundle/utils.js +22 -7
  74. package/dest/entrypoints/client/lazy/index.d.ts +1 -2
  75. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  76. package/dest/entrypoints/client/lazy/index.js +0 -1
  77. package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
  78. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  79. package/dest/entrypoints/client/lazy/utils.js +23 -8
  80. package/dest/entrypoints/pxe_creation_options.d.ts +5 -3
  81. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  82. package/dest/entrypoints/server/index.d.ts +4 -2
  83. package/dest/entrypoints/server/index.d.ts.map +1 -1
  84. package/dest/entrypoints/server/index.js +3 -1
  85. package/dest/entrypoints/server/utils.d.ts +1 -1
  86. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  87. package/dest/entrypoints/server/utils.js +30 -15
  88. package/dest/error_enriching.d.ts +4 -4
  89. package/dest/error_enriching.d.ts.map +1 -1
  90. package/dest/error_enriching.js +6 -6
  91. package/dest/events/event_service.d.ts +15 -0
  92. package/dest/events/event_service.d.ts.map +1 -0
  93. package/dest/events/event_service.js +44 -0
  94. package/dest/events/private_event_filter_validator.d.ts +6 -5
  95. package/dest/events/private_event_filter_validator.d.ts.map +1 -1
  96. package/dest/events/private_event_filter_validator.js +5 -6
  97. package/dest/job_coordinator/job_coordinator.d.ts +75 -0
  98. package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
  99. package/dest/job_coordinator/job_coordinator.js +94 -0
  100. package/dest/logs/log_service.d.ts +28 -0
  101. package/dest/logs/log_service.d.ts.map +1 -0
  102. package/dest/logs/log_service.js +123 -0
  103. package/dest/notes/index.d.ts +2 -0
  104. package/dest/notes/index.d.ts.map +1 -0
  105. package/dest/notes/index.js +1 -0
  106. package/dest/notes/note_service.d.ts +48 -0
  107. package/dest/notes/note_service.d.ts.map +1 -0
  108. package/dest/notes/note_service.js +147 -0
  109. package/dest/oracle_version.d.ts +3 -3
  110. package/dest/oracle_version.d.ts.map +1 -1
  111. package/dest/oracle_version.js +4 -3
  112. package/dest/private_kernel/hints/index.d.ts +2 -2
  113. package/dest/private_kernel/hints/index.d.ts.map +1 -1
  114. package/dest/private_kernel/hints/index.js +1 -1
  115. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +28 -0
  116. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
  117. package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +13 -7
  118. package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
  119. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  120. package/dest/private_kernel/private_kernel_execution_prover.js +6 -7
  121. package/dest/private_kernel/private_kernel_oracle.d.ts +24 -28
  122. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  123. package/dest/private_kernel/private_kernel_oracle.js +90 -2
  124. package/dest/pxe.d.ts +44 -69
  125. package/dest/pxe.d.ts.map +1 -1
  126. package/dest/pxe.js +199 -210
  127. package/dest/storage/address_store/address_store.d.ts +11 -0
  128. package/dest/storage/address_store/address_store.d.ts.map +1 -0
  129. package/dest/storage/{address_data_provider/address_data_provider.js → address_store/address_store.js} +13 -12
  130. package/dest/storage/address_store/index.d.ts +2 -0
  131. package/dest/storage/address_store/index.d.ts.map +1 -0
  132. package/dest/storage/address_store/index.js +1 -0
  133. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +17 -0
  134. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
  135. package/dest/storage/{sync_data_provider/sync_data_provider.js → anchor_block_store/anchor_block_store.js} +10 -10
  136. package/dest/storage/{sync_data_provider → anchor_block_store}/index.d.ts +2 -2
  137. package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
  138. package/dest/storage/anchor_block_store/index.js +1 -0
  139. package/dest/storage/capsule_store/capsule_store.d.ts +72 -0
  140. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
  141. package/dest/storage/capsule_store/capsule_store.js +253 -0
  142. package/dest/storage/capsule_store/index.d.ts +2 -0
  143. package/dest/storage/capsule_store/index.d.ts.map +1 -0
  144. package/dest/storage/capsule_store/index.js +1 -0
  145. package/dest/storage/{contract_data_provider/contract_data_provider.d.ts → contract_store/contract_store.d.ts} +6 -4
  146. package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
  147. package/dest/storage/{contract_data_provider/contract_data_provider.js → contract_store/contract_store.js} +56 -16
  148. package/dest/storage/contract_store/index.d.ts +2 -0
  149. package/dest/storage/contract_store/index.d.ts.map +1 -0
  150. package/dest/storage/contract_store/index.js +1 -0
  151. package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.d.ts +1 -1
  152. package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
  153. package/dest/storage/index.d.ts +8 -8
  154. package/dest/storage/index.d.ts.map +1 -1
  155. package/dest/storage/index.js +7 -7
  156. package/dest/storage/metadata.d.ts +1 -1
  157. package/dest/storage/metadata.js +1 -1
  158. package/dest/storage/note_store/index.d.ts +3 -0
  159. package/dest/storage/note_store/index.d.ts.map +1 -0
  160. package/dest/storage/note_store/index.js +2 -0
  161. package/dest/storage/note_store/note_store.d.ts +83 -0
  162. package/dest/storage/note_store/note_store.d.ts.map +1 -0
  163. package/dest/storage/note_store/note_store.js +344 -0
  164. package/dest/storage/note_store/stored_note.d.ts +16 -0
  165. package/dest/storage/note_store/stored_note.d.ts.map +1 -0
  166. package/dest/storage/note_store/stored_note.js +43 -0
  167. package/dest/storage/private_event_store/private_event_store.d.ts +91 -0
  168. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
  169. package/dest/storage/private_event_store/private_event_store.js +273 -0
  170. package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
  171. package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
  172. package/dest/storage/private_event_store/stored_private_event.js +56 -0
  173. package/dest/storage/tagging_store/index.d.ts +4 -0
  174. package/dest/storage/tagging_store/index.d.ts.map +1 -0
  175. package/dest/storage/tagging_store/index.js +3 -0
  176. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +28 -0
  177. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
  178. package/dest/storage/tagging_store/recipient_tagging_store.js +111 -0
  179. package/dest/storage/tagging_store/sender_address_book_store.d.ts +14 -0
  180. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -0
  181. package/dest/storage/tagging_store/sender_address_book_store.js +36 -0
  182. package/dest/storage/tagging_store/sender_tagging_store.d.ts +77 -0
  183. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
  184. package/dest/storage/tagging_store/sender_tagging_store.js +348 -0
  185. package/dest/tagging/constants.d.ts +2 -2
  186. package/dest/tagging/constants.d.ts.map +1 -1
  187. package/dest/tagging/constants.js +10 -2
  188. package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
  189. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
  190. package/dest/tagging/get_all_logs_by_tags.js +46 -0
  191. package/dest/tagging/index.d.ts +16 -6
  192. package/dest/tagging/index.d.ts.map +1 -1
  193. package/dest/tagging/index.js +15 -5
  194. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +15 -0
  195. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -0
  196. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +99 -0
  197. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +12 -0
  198. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -0
  199. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +20 -0
  200. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +15 -0
  201. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -0
  202. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +32 -0
  203. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +21 -0
  204. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -0
  205. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +74 -0
  206. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +11 -0
  207. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -0
  208. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +29 -0
  209. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +21 -0
  210. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
  211. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +60 -0
  212. package/package.json +27 -18
  213. package/src/bin/check_oracle_version.ts +1 -0
  214. package/src/block_synchronizer/block_synchronizer.ts +178 -0
  215. package/src/block_synchronizer/index.ts +1 -0
  216. package/src/config/index.ts +17 -3
  217. package/src/config/package_info.ts +1 -1
  218. package/src/contract_function_simulator/benchmarked_node.ts +103 -0
  219. package/src/contract_function_simulator/contract_function_simulator.ts +116 -33
  220. package/src/contract_function_simulator/execution_note_cache.ts +44 -25
  221. package/src/contract_function_simulator/execution_tagging_index_cache.ts +1 -1
  222. package/src/contract_function_simulator/index.ts +1 -1
  223. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +5 -1
  224. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +5 -4
  225. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
  226. package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
  227. package/src/contract_function_simulator/oracle/interfaces.ts +24 -15
  228. package/src/contract_function_simulator/oracle/note_packing_utils.ts +10 -10
  229. package/src/contract_function_simulator/oracle/oracle.ts +82 -50
  230. package/src/contract_function_simulator/oracle/private_execution.ts +1 -68
  231. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +118 -56
  232. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +289 -87
  233. package/src/contract_function_simulator/proxied_contract_data_source.ts +24 -7
  234. package/src/contract_sync/contract_sync_service.ts +129 -0
  235. package/src/contract_sync/helpers.ts +93 -0
  236. package/src/debug/pxe_debug_utils.ts +91 -0
  237. package/src/entrypoints/client/bundle/index.ts +0 -1
  238. package/src/entrypoints/client/bundle/utils.ts +15 -16
  239. package/src/entrypoints/client/lazy/index.ts +0 -1
  240. package/src/entrypoints/client/lazy/utils.ts +16 -17
  241. package/src/entrypoints/pxe_creation_options.ts +4 -2
  242. package/src/entrypoints/server/index.ts +3 -1
  243. package/src/entrypoints/server/utils.ts +26 -34
  244. package/src/error_enriching.ts +7 -15
  245. package/src/events/event_service.ts +71 -0
  246. package/src/events/private_event_filter_validator.ts +4 -5
  247. package/src/job_coordinator/job_coordinator.ts +150 -0
  248. package/src/logs/log_service.ts +220 -0
  249. package/src/notes/index.ts +1 -0
  250. package/src/notes/note_service.ts +195 -0
  251. package/src/oracle_version.ts +4 -3
  252. package/src/private_kernel/hints/index.ts +1 -1
  253. package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +33 -22
  254. package/src/private_kernel/private_kernel_execution_prover.ts +9 -8
  255. package/src/private_kernel/private_kernel_oracle.ts +116 -36
  256. package/src/pxe.ts +281 -260
  257. package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +16 -16
  258. package/src/storage/address_store/index.ts +1 -0
  259. package/src/storage/{sync_data_provider/sync_data_provider.ts → anchor_block_store/anchor_block_store.ts} +10 -12
  260. package/src/storage/anchor_block_store/index.ts +1 -0
  261. package/src/storage/capsule_store/capsule_store.ts +315 -0
  262. package/src/storage/capsule_store/index.ts +1 -0
  263. package/src/storage/{contract_data_provider/contract_data_provider.ts → contract_store/contract_store.ts} +66 -13
  264. package/src/storage/contract_store/index.ts +1 -0
  265. package/src/storage/index.ts +7 -7
  266. package/src/storage/metadata.ts +1 -1
  267. package/src/storage/note_store/index.ts +2 -0
  268. package/src/storage/note_store/note_store.ts +415 -0
  269. package/src/storage/note_store/stored_note.ts +48 -0
  270. package/src/storage/private_event_store/private_event_store.ts +384 -0
  271. package/src/storage/private_event_store/stored_private_event.ts +73 -0
  272. package/src/storage/tagging_store/index.ts +3 -0
  273. package/src/storage/tagging_store/recipient_tagging_store.ts +139 -0
  274. package/src/storage/tagging_store/sender_address_book_store.ts +48 -0
  275. package/src/storage/tagging_store/sender_tagging_store.ts +429 -0
  276. package/src/tagging/constants.ts +10 -2
  277. package/src/tagging/get_all_logs_by_tags.ts +68 -0
  278. package/src/tagging/index.ts +18 -5
  279. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +143 -0
  280. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +34 -0
  281. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +49 -0
  282. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +99 -0
  283. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +36 -0
  284. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +84 -0
  285. package/dest/contract_function_simulator/execution_data_provider.d.ts +0 -268
  286. package/dest/contract_function_simulator/execution_data_provider.d.ts.map +0 -1
  287. package/dest/contract_function_simulator/execution_data_provider.js +0 -14
  288. package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
  289. package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
  290. package/dest/contract_function_simulator/proxied_node.js +0 -27
  291. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +0 -124
  292. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +0 -1
  293. package/dest/contract_function_simulator/pxe_oracle_interface.js +0 -727
  294. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
  295. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
  296. package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -46
  297. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
  298. package/dest/private_kernel/private_kernel_oracle_impl.js +0 -86
  299. package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -11
  300. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +0 -1
  301. package/dest/storage/address_data_provider/index.d.ts +0 -2
  302. package/dest/storage/address_data_provider/index.d.ts.map +0 -1
  303. package/dest/storage/address_data_provider/index.js +0 -1
  304. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +0 -25
  305. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +0 -1
  306. package/dest/storage/capsule_data_provider/capsule_data_provider.js +0 -118
  307. package/dest/storage/capsule_data_provider/index.d.ts +0 -2
  308. package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
  309. package/dest/storage/capsule_data_provider/index.js +0 -1
  310. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
  311. package/dest/storage/contract_data_provider/index.d.ts +0 -2
  312. package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
  313. package/dest/storage/contract_data_provider/index.js +0 -1
  314. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
  315. package/dest/storage/note_data_provider/index.d.ts +0 -3
  316. package/dest/storage/note_data_provider/index.d.ts.map +0 -1
  317. package/dest/storage/note_data_provider/index.js +0 -2
  318. package/dest/storage/note_data_provider/note_data_provider.d.ts +0 -84
  319. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
  320. package/dest/storage/note_data_provider/note_data_provider.js +0 -322
  321. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +0 -51
  322. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +0 -1
  323. package/dest/storage/private_event_data_provider/private_event_data_provider.js +0 -115
  324. package/dest/storage/sync_data_provider/index.d.ts.map +0 -1
  325. package/dest/storage/sync_data_provider/index.js +0 -1
  326. package/dest/storage/sync_data_provider/sync_data_provider.d.ts +0 -11
  327. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +0 -1
  328. package/dest/storage/tagging_data_provider/index.d.ts +0 -2
  329. package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
  330. package/dest/storage/tagging_data_provider/index.js +0 -1
  331. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +0 -40
  332. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +0 -1
  333. package/dest/storage/tagging_data_provider/tagging_data_provider.js +0 -89
  334. package/dest/synchronizer/index.d.ts +0 -2
  335. package/dest/synchronizer/index.d.ts.map +0 -1
  336. package/dest/synchronizer/index.js +0 -1
  337. package/dest/synchronizer/synchronizer.d.ts +0 -36
  338. package/dest/synchronizer/synchronizer.d.ts.map +0 -1
  339. package/dest/synchronizer/synchronizer.js +0 -102
  340. package/dest/tagging/siloed_tag.d.ts +0 -14
  341. package/dest/tagging/siloed_tag.d.ts.map +0 -1
  342. package/dest/tagging/siloed_tag.js +0 -20
  343. package/dest/tagging/tag.d.ts +0 -12
  344. package/dest/tagging/tag.d.ts.map +0 -1
  345. package/dest/tagging/tag.js +0 -17
  346. package/dest/tagging/utils.d.ts +0 -18
  347. package/dest/tagging/utils.d.ts.map +0 -1
  348. package/dest/tagging/utils.js +0 -24
  349. package/src/contract_function_simulator/execution_data_provider.ts +0 -343
  350. package/src/contract_function_simulator/proxied_node.ts +0 -33
  351. package/src/contract_function_simulator/pxe_oracle_interface.ts +0 -1055
  352. package/src/private_kernel/private_kernel_oracle_impl.ts +0 -133
  353. package/src/storage/address_data_provider/index.ts +0 -1
  354. package/src/storage/capsule_data_provider/capsule_data_provider.ts +0 -147
  355. package/src/storage/capsule_data_provider/index.ts +0 -1
  356. package/src/storage/contract_data_provider/index.ts +0 -1
  357. package/src/storage/note_data_provider/index.ts +0 -2
  358. package/src/storage/note_data_provider/note_data_provider.ts +0 -412
  359. package/src/storage/private_event_data_provider/private_event_data_provider.ts +0 -162
  360. package/src/storage/sync_data_provider/index.ts +0 -1
  361. package/src/storage/tagging_data_provider/index.ts +0 -1
  362. package/src/storage/tagging_data_provider/tagging_data_provider.ts +0 -120
  363. package/src/synchronizer/index.ts +0 -1
  364. package/src/synchronizer/synchronizer.ts +0 -121
  365. package/src/tagging/siloed_tag.ts +0 -22
  366. package/src/tagging/tag.ts +0 -16
  367. package/src/tagging/utils.ts +0 -31
  368. /package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.js +0 -0
  369. /package/src/storage/{contract_data_provider → contract_store}/private_functions_tree.ts +0 -0
@@ -0,0 +1,24 @@
1
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
+ import type { BlockHash } from '@aztec/stdlib/block';
3
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
4
+ import type { SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
5
+ /**
6
+ * Fetches all private logs for the given tags, automatically paginating through all pages.
7
+ * @param aztecNode - The Aztec node to query.
8
+ * @param tags - The siloed tags to search for.
9
+ * @param anchorBlockHash - reference block for the Aztec node query, throws if block is not found there (typically
10
+ * because of reorgs).
11
+ * @returns An array of log arrays, one per tag, containing all logs across all pages.
12
+ */
13
+ export declare function getAllPrivateLogsByTags(aztecNode: AztecNode, tags: SiloedTag[], anchorBlockHash: BlockHash): Promise<TxScopedL2Log[][]>;
14
+ /**
15
+ * Fetches all public logs for the given tags from a contract, automatically paginating through all pages.
16
+ * @param aztecNode - The Aztec node to query.
17
+ * @param contractAddress - The contract address to search logs for.
18
+ * @param tags - The tags to search for.
19
+ * @param anchorBlockHash - reference block for the Aztec node query, throws if block is not found there (typically
20
+ * because of reorgs).
21
+ * @returns An array of log arrays, one per tag, containing all logs across all pages.
22
+ */
23
+ export declare function getAllPublicLogsByTagsFromContract(aztecNode: AztecNode, contractAddress: AztecAddress, tags: Tag[], anchorBlockHash: BlockHash): Promise<TxScopedL2Log[][]>;
24
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0X2FsbF9sb2dzX2J5X3RhZ3MuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90YWdnaW5nL2dldF9hbGxfbG9nc19ieV90YWdzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQ2hFLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBRXJELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ2pFLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxHQUFHLEVBQUUsYUFBYSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUE2QnhFOzs7Ozs7O0dBT0c7QUFDSCx3QkFBZ0IsdUJBQXVCLENBQ3JDLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLElBQUksRUFBRSxTQUFTLEVBQUUsRUFDakIsZUFBZSxFQUFFLFNBQVMsR0FDekIsT0FBTyxDQUFDLGFBQWEsRUFBRSxFQUFFLENBQUMsQ0FFNUI7QUFFRDs7Ozs7Ozs7R0FRRztBQUNILHdCQUFnQixrQ0FBa0MsQ0FDaEQsU0FBUyxFQUFFLFNBQVMsRUFDcEIsZUFBZSxFQUFFLFlBQVksRUFDN0IsSUFBSSxFQUFFLEdBQUcsRUFBRSxFQUNYLGVBQWUsRUFBRSxTQUFTLEdBQ3pCLE9BQU8sQ0FBQyxhQUFhLEVBQUUsRUFBRSxDQUFDLENBSTVCIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get_all_logs_by_tags.d.ts","sourceRoot":"","sources":["../../src/tagging/get_all_logs_by_tags.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AA6BxE;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,SAAS,EAAE,EACjB,eAAe,EAAE,SAAS,GACzB,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAE5B;AAED;;;;;;;;GAQG;AACH,wBAAgB,kCAAkC,CAChD,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,YAAY,EAC7B,IAAI,EAAE,GAAG,EAAE,EACX,eAAe,EAAE,SAAS,GACzB,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAI5B"}
@@ -0,0 +1,46 @@
1
+ import { MAX_LOGS_PER_TAG } from '@aztec/stdlib/interfaces/api-limit';
2
+ /**
3
+ * Generic pagination helper that fetches all pages of results.
4
+ * @param numTags - The number of tags being queried (determines result array size).
5
+ * @param fetchPage - Function that fetches a single page of results given a page number.
6
+ * @returns An array of arrays, one per tag, containing all results across all pages.
7
+ */ async function getAllPages(numTags, fetchPage) {
8
+ const allResultsPerTag = Array.from({
9
+ length: numTags
10
+ }, ()=>[]);
11
+ let page = 0;
12
+ let hasMore = true;
13
+ while(hasMore){
14
+ const resultsPage = await fetchPage(page);
15
+ hasMore = false;
16
+ for(let i = 0; i < resultsPage.length; i++){
17
+ allResultsPerTag[i].push(...resultsPage[i]);
18
+ if (resultsPage[i].length === MAX_LOGS_PER_TAG) {
19
+ hasMore = true;
20
+ }
21
+ }
22
+ page++;
23
+ }
24
+ return allResultsPerTag;
25
+ }
26
+ /**
27
+ * Fetches all private logs for the given tags, automatically paginating through all pages.
28
+ * @param aztecNode - The Aztec node to query.
29
+ * @param tags - The siloed tags to search for.
30
+ * @param anchorBlockHash - reference block for the Aztec node query, throws if block is not found there (typically
31
+ * because of reorgs).
32
+ * @returns An array of log arrays, one per tag, containing all logs across all pages.
33
+ */ export function getAllPrivateLogsByTags(aztecNode, tags, anchorBlockHash) {
34
+ return getAllPages(tags.length, (page)=>aztecNode.getPrivateLogsByTags(tags, page, anchorBlockHash));
35
+ }
36
+ /**
37
+ * Fetches all public logs for the given tags from a contract, automatically paginating through all pages.
38
+ * @param aztecNode - The Aztec node to query.
39
+ * @param contractAddress - The contract address to search logs for.
40
+ * @param tags - The tags to search for.
41
+ * @param anchorBlockHash - reference block for the Aztec node query, throws if block is not found there (typically
42
+ * because of reorgs).
43
+ * @returns An array of log arrays, one per tag, containing all logs across all pages.
44
+ */ export function getAllPublicLogsByTagsFromContract(aztecNode, contractAddress, tags, anchorBlockHash) {
45
+ return getAllPages(tags.length, (page)=>aztecNode.getPublicLogsByTagsFromContract(contractAddress, tags, page, anchorBlockHash));
46
+ }
@@ -1,7 +1,17 @@
1
- export * from './tag.js';
2
- export * from './constants.js';
3
- export * from './siloed_tag.js';
4
- export * from './utils.js';
5
- export { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
1
+ /**
2
+ * This directory contains the sender and recipient synchronization algorithms that use tagging.
3
+ *
4
+ * The objective of the sender sync algorithm is to determine which tags have already been used by a sender, thereby
5
+ * deciding which tag should be used next.
6
+ *
7
+ * The objective of the recipient sync algorithm is to load and process the corresponding logs.
8
+ *
9
+ * @module tagging
10
+ */
11
+ export { loadPrivateLogsForSenderRecipientPair } from './recipient_sync/load_private_logs_for_sender_recipient_pair.js';
12
+ export { syncSenderTaggingIndexes } from './sender_sync/sync_sender_tagging_indexes.js';
13
+ export { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from './constants.js';
14
+ export { getAllPrivateLogsByTags, getAllPublicLogsByTagsFromContract } from './get_all_logs_by_tags.js';
15
+ export { DirectionalAppTaggingSecret, Tag, SiloedTag } from '@aztec/stdlib/logs';
6
16
  export { type PreTag } from '@aztec/stdlib/logs';
7
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90YWdnaW5nL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsVUFBVSxDQUFDO0FBQ3pCLGNBQWMsZ0JBQWdCLENBQUM7QUFDL0IsY0FBYyxpQkFBaUIsQ0FBQztBQUNoQyxjQUFjLFlBQVksQ0FBQztBQUMzQixPQUFPLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUNqRSxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQyJ9
17
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90YWdnaW5nL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7Ozs7R0FTRztBQUVILE9BQU8sRUFBRSxxQ0FBcUMsRUFBRSxNQUFNLGlFQUFpRSxDQUFDO0FBQ3hILE9BQU8sRUFBRSx3QkFBd0IsRUFBRSxNQUFNLDhDQUE4QyxDQUFDO0FBQ3hGLE9BQU8sRUFBRSxzQ0FBc0MsRUFBRSxNQUFNLGdCQUFnQixDQUFDO0FBQ3hFLE9BQU8sRUFBRSx1QkFBdUIsRUFBRSxrQ0FBa0MsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBR3hHLE9BQU8sRUFBRSwyQkFBMkIsRUFBRSxHQUFHLEVBQUUsU0FBUyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDakYsT0FBTyxFQUFFLEtBQUssTUFBTSxFQUFFLE1BQU0sb0JBQW9CLENBQUMifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tagging/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tagging/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,qCAAqC,EAAE,MAAM,iEAAiE,CAAC;AACxH,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,sCAAsC,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,kCAAkC,EAAE,MAAM,2BAA2B,CAAC;AAGxG,OAAO,EAAE,2BAA2B,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC"}
@@ -1,5 +1,15 @@
1
- export * from './tag.js';
2
- export * from './constants.js';
3
- export * from './siloed_tag.js';
4
- export * from './utils.js';
5
- export { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
1
+ /**
2
+ * This directory contains the sender and recipient synchronization algorithms that use tagging.
3
+ *
4
+ * The objective of the sender sync algorithm is to determine which tags have already been used by a sender, thereby
5
+ * deciding which tag should be used next.
6
+ *
7
+ * The objective of the recipient sync algorithm is to load and process the corresponding logs.
8
+ *
9
+ * @module tagging
10
+ */ export { loadPrivateLogsForSenderRecipientPair } from './recipient_sync/load_private_logs_for_sender_recipient_pair.js';
11
+ export { syncSenderTaggingIndexes } from './sender_sync/sync_sender_tagging_indexes.js';
12
+ export { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from './constants.js';
13
+ export { getAllPrivateLogsByTags, getAllPublicLogsByTagsFromContract } from './get_all_logs_by_tags.js';
14
+ // Re-export tagging-related types from stdlib
15
+ export { DirectionalAppTaggingSecret, Tag, SiloedTag } from '@aztec/stdlib/logs';
@@ -0,0 +1,15 @@
1
+ import type { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import type { BlockHash } from '@aztec/stdlib/block';
4
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
5
+ import type { DirectionalAppTaggingSecret, TxScopedL2Log } from '@aztec/stdlib/logs';
6
+ import type { RecipientTaggingStore } from '../../storage/tagging_store/recipient_tagging_store.js';
7
+ /**
8
+ * Loads private logs for `app` and sender-recipient pair defined by `secret` and updates the highest aged and
9
+ * finalized indexes in the db. At most load logs from blocks up to and including `anchorBlockNumber`.
10
+ *
11
+ * @dev This function can be safely executed "in parallel" for other sender-recipient pairs because the data in
12
+ * in the tagging data provider is indexed by the secret and hence completely disjoint.
13
+ */
14
+ export declare function loadPrivateLogsForSenderRecipientPair(secret: DirectionalAppTaggingSecret, app: AztecAddress, aztecNode: AztecNode, taggingStore: RecipientTaggingStore, anchorBlockNumber: BlockNumber, anchorBlockHash: BlockHash, jobId: string): Promise<TxScopedL2Log[]>;
15
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZF9wcml2YXRlX2xvZ3NfZm9yX3NlbmRlcl9yZWNpcGllbnRfcGFpci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3RhZ2dpbmcvcmVjaXBpZW50X3N5bmMvbG9hZF9wcml2YXRlX2xvZ3NfZm9yX3NlbmRlcl9yZWNpcGllbnRfcGFpci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNuRSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNyRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSwyQkFBMkIsRUFBRSxhQUFhLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUVyRixPQUFPLEtBQUssRUFBRSxxQkFBcUIsRUFBRSxNQUFNLHdEQUF3RCxDQUFDO0FBS3BHOzs7Ozs7R0FNRztBQUNILHdCQUFzQixxQ0FBcUMsQ0FDekQsTUFBTSxFQUFFLDJCQUEyQixFQUNuQyxHQUFHLEVBQUUsWUFBWSxFQUNqQixTQUFTLEVBQUUsU0FBUyxFQUNwQixZQUFZLEVBQUUscUJBQXFCLEVBQ25DLGlCQUFpQixFQUFFLFdBQVcsRUFDOUIsZUFBZSxFQUFFLFNBQVMsRUFDMUIsS0FBSyxFQUFFLE1BQU0sR0FDWixPQUFPLENBQUMsYUFBYSxFQUFFLENBQUMsQ0FvSDFCIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load_private_logs_for_sender_recipient_pair.d.ts","sourceRoot":"","sources":["../../../src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,2BAA2B,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAErF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAC;AAKpG;;;;;;GAMG;AACH,wBAAsB,qCAAqC,CACzD,MAAM,EAAE,2BAA2B,EACnC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,qBAAqB,EACnC,iBAAiB,EAAE,WAAW,EAC9B,eAAe,EAAE,SAAS,EAC1B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,aAAa,EAAE,CAAC,CAoH1B"}
@@ -0,0 +1,99 @@
1
+ import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../constants.js';
2
+ import { findHighestIndexes } from './utils/find_highest_indexes.js';
3
+ import { loadLogsForRange } from './utils/load_logs_for_range.js';
4
+ /**
5
+ * Loads private logs for `app` and sender-recipient pair defined by `secret` and updates the highest aged and
6
+ * finalized indexes in the db. At most load logs from blocks up to and including `anchorBlockNumber`.
7
+ *
8
+ * @dev This function can be safely executed "in parallel" for other sender-recipient pairs because the data in
9
+ * in the tagging data provider is indexed by the secret and hence completely disjoint.
10
+ */ export async function loadPrivateLogsForSenderRecipientPair(secret, app, aztecNode, taggingStore, anchorBlockNumber, anchorBlockHash, jobId) {
11
+ // # Explanation of how the algorithm works
12
+ // When we perform the sync we will look at logs that correspond to the tagging index range
13
+ // (highestAgedIndex, highestFinalizedIndex + WINDOW_LEN]
14
+ //
15
+ // highestAgedIndex is the highest index that was used in a tx that is included in a block at least
16
+ // `MAX_INCLUDE_BY_TIMESTAMP_DURATION` seconds ago.
17
+ // highestFinalizedIndex is the highest index that was used in a tx that is included in a finalized block.
18
+ //
19
+ // "(" denotes an open end of the range - the index is not included in the range.
20
+ // "]" denotes a closed end of the range - the index is included in the range.
21
+ //
22
+ // ## Explanation of highestAgedIndex
23
+ //
24
+ // highestAgedIndex is chosen such that for all tagging indexes `i <= highestAgedIndex` we know that no new logs can
25
+ // ever appear.
26
+ //
27
+ // This relies on the "maximum inclusion timestamp" rule enforced by the kernel and rollup circuits:
28
+ // - a transaction's maximum inclusion timestamp is at most `MAX_INCLUDE_BY_TIMESTAMP_DURATION` seconds after
29
+ // the timestamp of its anchor block; and
30
+ // - a rollup only includes transactions whose inclusion timestamp is >= the L2 block's timestamp.
31
+ //
32
+ // Suppose some device used index `I` in a transaction anchored to block `B_N` at time `N`, and that block is now at
33
+ // least `MAX_INCLUDE_BY_TIMESTAMP_DURATION` seconds in the past. Then there is no possibility of any *other* device
34
+ // trying to use an index <= `I` while anchoring to a *newer* block than `B_N` because if we were anchoring to
35
+ // a newer block than `B_N` then we would already have seen the log with index `I` and hence the device would have
36
+ // chosen a larger index.
37
+ // If that *other* device would anchor to a block older than `B_N` then that tx could never be included in a block
38
+ // because it would already have been expired.
39
+ //
40
+ // Therefore, once we see that index `I` has been used in a block that is at least `MAX_INCLUDE_BY_TIMESTAMP_DURATION`
41
+ // seconds old, we can safely stop syncing logs for all indexes <= `I` and set highestAgedIndex = `I`.
42
+ //
43
+ // ## Explanation of the upper bound `highestFinalizedIndex + WINDOW_LEN`
44
+ //
45
+ // When a sender chooses a tagging index, they will select an index that is at most `WINDOW_LEN` greater than
46
+ // the highest finalized index. If that index was already used, they will throw an error. For this reason we
47
+ // don't have to look further than `highestFinalizedIndex + WINDOW_LEN`.
48
+ let finalizedBlockNumber, currentTimestamp;
49
+ {
50
+ const [l2Tips, latestBlockHeader] = await Promise.all([
51
+ aztecNode.getL2Tips(),
52
+ aztecNode.getBlockHeader('latest')
53
+ ]);
54
+ if (!latestBlockHeader) {
55
+ throw new Error('Node failed to return latest block header when syncing logs');
56
+ }
57
+ [finalizedBlockNumber, currentTimestamp] = [
58
+ l2Tips.finalized.block.number,
59
+ latestBlockHeader.globalVariables.timestamp
60
+ ];
61
+ }
62
+ let start, end;
63
+ {
64
+ const currentHighestAgedIndex = await taggingStore.getHighestAgedIndex(secret, jobId);
65
+ const currentHighestFinalizedIndex = await taggingStore.getHighestFinalizedIndex(secret, jobId);
66
+ // We don't want to include the highest aged index so we start from `currentHighestAgedIndex + 1` (or 0 if not set)
67
+ start = currentHighestAgedIndex === undefined ? 0 : currentHighestAgedIndex + 1;
68
+ // The highest index a sender can choose is "highest finalized index + window length" but given that
69
+ // `loadLogsForRange` expects an exclusive `end` we add 1.
70
+ end = (currentHighestFinalizedIndex ?? 0) + UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN + 1;
71
+ }
72
+ const logs = [];
73
+ while(true){
74
+ // Get private logs with their block timestamps and corresponding tagging indexes
75
+ const privateLogsWithIndexes = await loadLogsForRange(secret, app, aztecNode, start, end, anchorBlockNumber, anchorBlockHash);
76
+ if (privateLogsWithIndexes.length === 0) {
77
+ break;
78
+ }
79
+ logs.push(...privateLogsWithIndexes.map(({ log })=>log));
80
+ const { highestAgedIndex, highestFinalizedIndex } = findHighestIndexes(privateLogsWithIndexes, currentTimestamp, finalizedBlockNumber);
81
+ // Store updates in data provider and update local variables
82
+ if (highestAgedIndex !== undefined) {
83
+ await taggingStore.updateHighestAgedIndex(secret, highestAgedIndex, jobId);
84
+ }
85
+ if (highestFinalizedIndex === undefined) {
86
+ break;
87
+ }
88
+ if (highestAgedIndex !== undefined && highestAgedIndex > highestFinalizedIndex) {
89
+ // This is just a sanity check as this should never happen.
90
+ throw new Error('Highest aged index lower than highest finalized index invariant violated');
91
+ }
92
+ await taggingStore.updateHighestFinalizedIndex(secret, highestFinalizedIndex, jobId);
93
+ // For the next iteration we want to look only at indexes for which we have not attempted to load logs yet while
94
+ // ensuring that we do not look further than WINDOW_LEN ahead of the highest finalized index.
95
+ start = end;
96
+ end = highestFinalizedIndex + UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN + 1; // `end` is exclusive so we add 1.
97
+ }
98
+ return logs;
99
+ }
@@ -0,0 +1,12 @@
1
+ import type { TxScopedL2Log } from '@aztec/stdlib/logs';
2
+ /**
3
+ * Finds the highest aged and the highest finalized tagging indexes.
4
+ */
5
+ export declare function findHighestIndexes(privateLogsWithIndexes: Array<{
6
+ log: TxScopedL2Log;
7
+ taggingIndex: number;
8
+ }>, currentTimestamp: bigint, finalizedBlockNumber: number): {
9
+ highestAgedIndex: number | undefined;
10
+ highestFinalizedIndex: number | undefined;
11
+ };
12
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmluZF9oaWdoZXN0X2luZGV4ZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy90YWdnaW5nL3JlY2lwaWVudF9zeW5jL3V0aWxzL2ZpbmRfaGlnaGVzdF9pbmRleGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRXhEOztHQUVHO0FBQ0gsd0JBQWdCLGtCQUFrQixDQUNoQyxzQkFBc0IsRUFBRSxLQUFLLENBQUM7SUFBRSxHQUFHLEVBQUUsYUFBYSxDQUFDO0lBQUMsWUFBWSxFQUFFLE1BQU0sQ0FBQTtDQUFFLENBQUMsRUFDM0UsZ0JBQWdCLEVBQUUsTUFBTSxFQUN4QixvQkFBb0IsRUFBRSxNQUFNLEdBQzNCO0lBQUUsZ0JBQWdCLEVBQUUsTUFBTSxHQUFHLFNBQVMsQ0FBQztJQUFDLHFCQUFxQixFQUFFLE1BQU0sR0FBRyxTQUFTLENBQUE7Q0FBRSxDQXVCckYifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find_highest_indexes.d.ts","sourceRoot":"","sources":["../../../../src/tagging/recipient_sync/utils/find_highest_indexes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,sBAAsB,EAAE,KAAK,CAAC;IAAE,GAAG,EAAE,aAAa,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,EAC3E,gBAAgB,EAAE,MAAM,EACxB,oBAAoB,EAAE,MAAM,GAC3B;IAAE,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,qBAAqB,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAuBrF"}
@@ -0,0 +1,20 @@
1
+ import { MAX_INCLUDE_BY_TIMESTAMP_DURATION } from '@aztec/constants';
2
+ /**
3
+ * Finds the highest aged and the highest finalized tagging indexes.
4
+ */ export function findHighestIndexes(privateLogsWithIndexes, currentTimestamp, finalizedBlockNumber) {
5
+ let highestAgedIndex = undefined;
6
+ let highestFinalizedIndex = undefined;
7
+ for (const { log, taggingIndex } of privateLogsWithIndexes){
8
+ const ageInSeconds = currentTimestamp - log.blockTimestamp;
9
+ if (ageInSeconds >= BigInt(MAX_INCLUDE_BY_TIMESTAMP_DURATION) && (highestAgedIndex === undefined || taggingIndex > highestAgedIndex)) {
10
+ highestAgedIndex = taggingIndex;
11
+ }
12
+ if (log.blockNumber <= finalizedBlockNumber && (highestFinalizedIndex === undefined || taggingIndex > highestFinalizedIndex)) {
13
+ highestFinalizedIndex = taggingIndex;
14
+ }
15
+ }
16
+ return {
17
+ highestAgedIndex,
18
+ highestFinalizedIndex
19
+ };
20
+ }
@@ -0,0 +1,15 @@
1
+ import type { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import type { BlockHash } from '@aztec/stdlib/block';
4
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
5
+ import type { DirectionalAppTaggingSecret, TxScopedL2Log } from '@aztec/stdlib/logs';
6
+ /**
7
+ * Gets private logs with their corresponding block timestamps and tagging indexes for the given index range, `app` and
8
+ * `secret`. At most load logs from blocks up to and including `anchorBlockNumber`. `start` is inclusive and `end` is
9
+ * exclusive.
10
+ */
11
+ export declare function loadLogsForRange(secret: DirectionalAppTaggingSecret, app: AztecAddress, aztecNode: AztecNode, start: number, end: number, anchorBlockNumber: BlockNumber, anchorBlockHash: BlockHash): Promise<Array<{
12
+ log: TxScopedL2Log;
13
+ taggingIndex: number;
14
+ }>>;
15
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZF9sb2dzX2Zvcl9yYW5nZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvcmVjaXBpZW50X3N5bmMvdXRpbHMvbG9hZF9sb2dzX2Zvcl9yYW5nZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNuRSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNyRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSwyQkFBMkIsRUFBVSxhQUFhLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUs3Rjs7OztHQUlHO0FBQ0gsd0JBQXNCLGdCQUFnQixDQUNwQyxNQUFNLEVBQUUsMkJBQTJCLEVBQ25DLEdBQUcsRUFBRSxZQUFZLEVBQ2pCLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLEtBQUssRUFBRSxNQUFNLEVBQ2IsR0FBRyxFQUFFLE1BQU0sRUFDWCxpQkFBaUIsRUFBRSxXQUFXLEVBQzlCLGVBQWUsRUFBRSxTQUFTLEdBQ3pCLE9BQU8sQ0FBQyxLQUFLLENBQUM7SUFBRSxHQUFHLEVBQUUsYUFBYSxDQUFDO0lBQUMsWUFBWSxFQUFFLE1BQU0sQ0FBQTtDQUFFLENBQUMsQ0FBQyxDQTBCOUQifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load_logs_for_range.d.ts","sourceRoot":"","sources":["../../../../src/tagging/recipient_sync/utils/load_logs_for_range.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,2BAA2B,EAAU,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAK7F;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,2BAA2B,EACnC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,iBAAiB,EAAE,WAAW,EAC9B,eAAe,EAAE,SAAS,GACzB,OAAO,CAAC,KAAK,CAAC;IAAE,GAAG,EAAE,aAAa,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CA0B9D"}
@@ -0,0 +1,32 @@
1
+ import { SiloedTag, Tag } from '@aztec/stdlib/logs';
2
+ import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
3
+ /**
4
+ * Gets private logs with their corresponding block timestamps and tagging indexes for the given index range, `app` and
5
+ * `secret`. At most load logs from blocks up to and including `anchorBlockNumber`. `start` is inclusive and `end` is
6
+ * exclusive.
7
+ */ export async function loadLogsForRange(secret, app, aztecNode, start, end, anchorBlockNumber, anchorBlockHash) {
8
+ // Derive tags for the window
9
+ const preTags = Array(end - start).fill(0).map((_, i)=>({
10
+ secret,
11
+ index: start + i
12
+ }));
13
+ const siloedTags = await Promise.all(preTags.map((preTag)=>Tag.compute(preTag))).then((tags)=>Promise.all(tags.map((tag)=>SiloedTag.compute(tag, app))));
14
+ // We use the utility function below to retrieve all logs for the tags across all pages, so we don't need to handle
15
+ // pagination here.
16
+ const logs = await getAllPrivateLogsByTags(aztecNode, siloedTags, anchorBlockHash);
17
+ // Pair logs with their corresponding tagging indexes
18
+ const logsWithIndexes = [];
19
+ for(let i = 0; i < logs.length; i++){
20
+ const logsForTag = logs[i];
21
+ const taggingIndex = preTags[i].index;
22
+ for (const log of logsForTag){
23
+ if (log.blockNumber <= anchorBlockNumber) {
24
+ logsWithIndexes.push({
25
+ log,
26
+ taggingIndex
27
+ });
28
+ }
29
+ }
30
+ }
31
+ return logsWithIndexes;
32
+ }
@@ -0,0 +1,21 @@
1
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
+ import type { BlockHash } from '@aztec/stdlib/block';
3
+ import type { AztecNode } from '@aztec/stdlib/interfaces/server';
4
+ import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
5
+ import type { SenderTaggingStore } from '../../storage/tagging_store/sender_tagging_store.js';
6
+ /**
7
+ * Syncs tagging indexes. This function needs to be called whenever a private log is being sent.
8
+ *
9
+ * @param secret - The secret that's unique for (sender, recipient, contract) tuple while the direction of
10
+ * sender -> recipient matters.
11
+ * @param app - The address of the contract that the logs are tagged for. Needs to be provided because we perform
12
+ * second round of siloing in this function which is necessary because kernels do it as well (they silo first field
13
+ * of the private log which corresponds to the tag).
14
+ * @remarks When syncing the indexes as sender we don't care about the log contents - we only care about the highest
15
+ * pending and highest finalized indexes as that guides the next index choice when sending a log. The next index choice
16
+ * is simply the highest pending index plus one (or finalized if pending is undefined).
17
+ * @dev This function looks for new indexes, adds them to pending, then it checks status of each pending index and
18
+ * updates its status accordingly.
19
+ */
20
+ export declare function syncSenderTaggingIndexes(secret: DirectionalAppTaggingSecret, app: AztecAddress, aztecNode: AztecNode, taggingStore: SenderTaggingStore, anchorBlockHash: BlockHash, jobId: string): Promise<void>;
21
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3luY19zZW5kZXJfdGFnZ2luZ19pbmRleGVzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdGFnZ2luZy9zZW5kZXJfc3luYy9zeW5jX3NlbmRlcl90YWdnaW5nX2luZGV4ZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDckQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakUsT0FBTyxLQUFLLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUV0RSxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHFEQUFxRCxDQUFDO0FBSzlGOzs7Ozs7Ozs7Ozs7O0dBYUc7QUFDSCx3QkFBc0Isd0JBQXdCLENBQzVDLE1BQU0sRUFBRSwyQkFBMkIsRUFDbkMsR0FBRyxFQUFFLFlBQVksRUFDakIsU0FBUyxFQUFFLFNBQVMsRUFDcEIsWUFBWSxFQUFFLGtCQUFrQixFQUNoQyxlQUFlLEVBQUUsU0FBUyxFQUMxQixLQUFLLEVBQUUsTUFBTSxHQUNaLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FtRWYifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync_sender_tagging_indexes.d.ts","sourceRoot":"","sources":["../../../src/tagging/sender_sync/sync_sender_tagging_indexes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AAK9F;;;;;;;;;;;;;GAaG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,2BAA2B,EACnC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,kBAAkB,EAChC,eAAe,EAAE,SAAS,EAC1B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAmEf"}
@@ -0,0 +1,74 @@
1
+ import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../constants.js';
2
+ import { getStatusChangeOfPending } from './utils/get_status_change_of_pending.js';
3
+ import { loadAndStoreNewTaggingIndexes } from './utils/load_and_store_new_tagging_indexes.js';
4
+ /**
5
+ * Syncs tagging indexes. This function needs to be called whenever a private log is being sent.
6
+ *
7
+ * @param secret - The secret that's unique for (sender, recipient, contract) tuple while the direction of
8
+ * sender -> recipient matters.
9
+ * @param app - The address of the contract that the logs are tagged for. Needs to be provided because we perform
10
+ * second round of siloing in this function which is necessary because kernels do it as well (they silo first field
11
+ * of the private log which corresponds to the tag).
12
+ * @remarks When syncing the indexes as sender we don't care about the log contents - we only care about the highest
13
+ * pending and highest finalized indexes as that guides the next index choice when sending a log. The next index choice
14
+ * is simply the highest pending index plus one (or finalized if pending is undefined).
15
+ * @dev This function looks for new indexes, adds them to pending, then it checks status of each pending index and
16
+ * updates its status accordingly.
17
+ */ export async function syncSenderTaggingIndexes(secret, app, aztecNode, taggingStore, anchorBlockHash, jobId) {
18
+ // # Explanation of how syncing works
19
+ //
20
+ // When choosing an index, we select: highest pending index + 1 (or highest finalized index + 1 if no pending).
21
+ // If the chosen index is more than WINDOW_LEN from the highest finalized index, we throw an error. By having this
22
+ // hard limit we give a guarantee to a recipient that he doesn't need to look further than WINDOW_LEN ahead of the
23
+ // highest finalized index.
24
+ //
25
+ // This function synchronizes the finalized and pending indexes by iteratively querying the node for a window of
26
+ // indexes at a time, storing all those indexes as pending, and then checking the status of each pending index to
27
+ // update its finalization status accordingly. If we stumble upon a window with no indexes, we stop the loop.
28
+ //
29
+ // Stopping at that point is safe because of the limit described above - there can never be an index that is more
30
+ // than WINDOW_LEN from the highest finalized index.
31
+ //
32
+ // # Note on performance
33
+ // Each window advance requires two queries (logs + tx status). For example, syncing indexes 0–500 with a window of
34
+ // 100 takes at least 10 round trips (5 windows × 2 queries).
35
+ const finalizedIndex = await taggingStore.getLastFinalizedIndex(secret, jobId);
36
+ let start = finalizedIndex === undefined ? 0 : finalizedIndex + 1;
37
+ let end = start + UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN;
38
+ let previousFinalizedIndex = finalizedIndex;
39
+ let newFinalizedIndex = undefined;
40
+ while(true){
41
+ // Load and store indexes for the current window. These indexes may already exist in the database if txs using
42
+ // them were previously sent from this PXE. Any duplicates are handled by the tagging data provider.
43
+ await loadAndStoreNewTaggingIndexes(secret, app, start, end, aztecNode, taggingStore, anchorBlockHash, jobId);
44
+ // Retrieve all indexes within the current window from storage and update their status accordingly.
45
+ const pendingTxHashes = await taggingStore.getTxHashesOfPendingIndexes(secret, start, end, jobId);
46
+ if (pendingTxHashes.length === 0) {
47
+ break;
48
+ }
49
+ const { txHashesToFinalize, txHashesToDrop } = await getStatusChangeOfPending(pendingTxHashes, aztecNode);
50
+ await taggingStore.dropPendingIndexes(txHashesToDrop, jobId);
51
+ await taggingStore.finalizePendingIndexes(txHashesToFinalize, jobId);
52
+ // We check if the finalized index has been updated.
53
+ newFinalizedIndex = await taggingStore.getLastFinalizedIndex(secret, jobId);
54
+ if (previousFinalizedIndex !== newFinalizedIndex) {
55
+ // A new finalized index was found, so we'll run the loop again. For example:
56
+ // - Previous finalized index: 10
57
+ // - New finalized index: 13
58
+ // - Window length: 10
59
+ //
60
+ // In the last iteration, we processed indexes 11-20. To avoid reprocessing the same logs,
61
+ // we'll only look at the new indexes 21-23:
62
+ //
63
+ // Previous window: [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
64
+ // New window: [21, 22, 23]
65
+ const previousEnd = end;
66
+ // Add 1 because `end` is exclusive and the known finalized index is not included in the window.
67
+ end = newFinalizedIndex + UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN + 1;
68
+ start = previousEnd;
69
+ previousFinalizedIndex = newFinalizedIndex;
70
+ } else {
71
+ break;
72
+ }
73
+ }
74
+ }
@@ -0,0 +1,11 @@
1
+ import type { AztecNode } from '@aztec/stdlib/interfaces/server';
2
+ import { TxHash } from '@aztec/stdlib/tx';
3
+ /**
4
+ * Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized or
5
+ * dropped.
6
+ */
7
+ export declare function getStatusChangeOfPending(pending: TxHash[], aztecNode: AztecNode): Promise<{
8
+ txHashesToFinalize: TxHash[];
9
+ txHashesToDrop: TxHash[];
10
+ }>;
11
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0X3N0YXR1c19jaGFuZ2Vfb2ZfcGVuZGluZy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvc2VuZGVyX3N5bmMvdXRpbHMvZ2V0X3N0YXR1c19jaGFuZ2Vfb2ZfcGVuZGluZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEVBQUUsTUFBTSxFQUFZLE1BQU0sa0JBQWtCLENBQUM7QUFFcEQ7OztHQUdHO0FBQ0gsd0JBQXNCLHdCQUF3QixDQUM1QyxPQUFPLEVBQUUsTUFBTSxFQUFFLEVBQ2pCLFNBQVMsRUFBRSxTQUFTLEdBQ25CLE9BQU8sQ0FBQztJQUFFLGtCQUFrQixFQUFFLE1BQU0sRUFBRSxDQUFDO0lBQUMsY0FBYyxFQUFFLE1BQU0sRUFBRSxDQUFBO0NBQUUsQ0FBQyxDQXlCckUifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get_status_change_of_pending.d.ts","sourceRoot":"","sources":["../../../../src/tagging/sender_sync/utils/get_status_change_of_pending.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAY,MAAM,kBAAkB,CAAC;AAEpD;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC;IAAE,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAyBrE"}
@@ -0,0 +1,29 @@
1
+ import { TxStatus } from '@aztec/stdlib/tx';
2
+ /**
3
+ * Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized or
4
+ * dropped.
5
+ */ export async function getStatusChangeOfPending(pending, aztecNode) {
6
+ // Get receipts for all pending tx hashes.
7
+ const receipts = await Promise.all(pending.map((pendingTxHash)=>aztecNode.getTxReceipt(pendingTxHash)));
8
+ const txHashesToFinalize = [];
9
+ const txHashesToDrop = [];
10
+ for(let i = 0; i < receipts.length; i++){
11
+ const receipt = receipts[i];
12
+ const txHash = pending[i];
13
+ if (receipt.status === TxStatus.FINALIZED && receipt.hasExecutionSucceeded()) {
14
+ // Tx has been included in a block and the corresponding block is finalized --> we mark the indexes as
15
+ // finalized.
16
+ txHashesToFinalize.push(txHash);
17
+ } else if (receipt.isDropped() || receipt.hasExecutionReverted()) {
18
+ // Tx was dropped or reverted --> we drop the corresponding pending indexes.
19
+ // TODO(#17615): Don't drop pending indexes corresponding to non-revertible phases.
20
+ txHashesToDrop.push(txHash);
21
+ } else {
22
+ // Tx is still pending, not yet finalized, or was mined successfully but not yet finalized --> we don't do anything.
23
+ }
24
+ }
25
+ return {
26
+ txHashesToFinalize,
27
+ txHashesToDrop
28
+ };
29
+ }
@@ -0,0 +1,21 @@
1
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
+ import type { BlockHash } from '@aztec/stdlib/block';
3
+ import type { AztecNode } from '@aztec/stdlib/interfaces/server';
4
+ import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
5
+ import type { SenderTaggingStore } from '../../../storage/tagging_store/sender_tagging_store.js';
6
+ /**
7
+ * Loads tagging indexes from the Aztec node and stores them in the tagging data provider.
8
+ * @remarks This function is one of two places by which a pending index can get to the tagging data provider. The other
9
+ * place is when a tx is being sent from this PXE.
10
+ * @param secret - The directional app tagging secret that's unique for (sender, recipient, contract) tuple.
11
+ * @param app - The address of the contract that the logs are tagged for. Used for siloing tags to match
12
+ * kernel circuit behavior.
13
+ * @param start - The starting index (inclusive) of the window to process.
14
+ * @param end - The ending index (exclusive) of the window to process.
15
+ * @param aztecNode - The Aztec node instance to query for logs.
16
+ * @param taggingStore - The data provider to store pending indexes.
17
+ * @param jobId - Job identifier, used to keep writes in-memory until they can be persisted in a data integrity
18
+ * preserving way.
19
+ */
20
+ export declare function loadAndStoreNewTaggingIndexes(secret: DirectionalAppTaggingSecret, app: AztecAddress, start: number, end: number, aztecNode: AztecNode, taggingStore: SenderTaggingStore, anchorBlockHash: BlockHash, jobId: string): Promise<void>;
21
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvc2VuZGVyX3N5bmMvdXRpbHMvbG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNyRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSwyQkFBMkIsRUFBVSxNQUFNLG9CQUFvQixDQUFDO0FBSTlFLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sd0RBQXdELENBQUM7QUFHakc7Ozs7Ozs7Ozs7Ozs7R0FhRztBQUNILHdCQUFzQiw2QkFBNkIsQ0FDakQsTUFBTSxFQUFFLDJCQUEyQixFQUNuQyxHQUFHLEVBQUUsWUFBWSxFQUNqQixLQUFLLEVBQUUsTUFBTSxFQUNiLEdBQUcsRUFBRSxNQUFNLEVBQ1gsU0FBUyxFQUFFLFNBQVMsRUFDcEIsWUFBWSxFQUFFLGtCQUFrQixFQUNoQyxlQUFlLEVBQUUsU0FBUyxFQUMxQixLQUFLLEVBQUUsTUFBTSxpQkFrQmQifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load_and_store_new_tagging_indexes.d.ts","sourceRoot":"","sources":["../../../../src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,2BAA2B,EAAU,MAAM,oBAAoB,CAAC;AAI9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAGjG;;;;;;;;;;;;;GAaG;AACH,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,2BAA2B,EACnC,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,kBAAkB,EAChC,eAAe,EAAE,SAAS,EAC1B,KAAK,EAAE,MAAM,iBAkBd"}
@@ -0,0 +1,60 @@
1
+ import { SiloedTag, Tag } from '@aztec/stdlib/logs';
2
+ import { TxHash } from '@aztec/stdlib/tx';
3
+ import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
4
+ /**
5
+ * Loads tagging indexes from the Aztec node and stores them in the tagging data provider.
6
+ * @remarks This function is one of two places by which a pending index can get to the tagging data provider. The other
7
+ * place is when a tx is being sent from this PXE.
8
+ * @param secret - The directional app tagging secret that's unique for (sender, recipient, contract) tuple.
9
+ * @param app - The address of the contract that the logs are tagged for. Used for siloing tags to match
10
+ * kernel circuit behavior.
11
+ * @param start - The starting index (inclusive) of the window to process.
12
+ * @param end - The ending index (exclusive) of the window to process.
13
+ * @param aztecNode - The Aztec node instance to query for logs.
14
+ * @param taggingStore - The data provider to store pending indexes.
15
+ * @param jobId - Job identifier, used to keep writes in-memory until they can be persisted in a data integrity
16
+ * preserving way.
17
+ */ export async function loadAndStoreNewTaggingIndexes(secret, app, start, end, aztecNode, taggingStore, anchorBlockHash, jobId) {
18
+ // We compute the tags for the current window of indexes
19
+ const preTagsForWindow = Array(end - start).fill(0).map((_, i)=>({
20
+ secret,
21
+ index: start + i
22
+ }));
23
+ const siloedTagsForWindow = await Promise.all(preTagsForWindow.map(async (preTag)=>SiloedTag.compute(await Tag.compute(preTag), app)));
24
+ const txsForTags = await getTxsContainingTags(siloedTagsForWindow, aztecNode, anchorBlockHash);
25
+ const highestIndexMap = getTxHighestIndexMap(txsForTags, preTagsForWindow);
26
+ // Now we iterate over the map, reconstruct the preTags and tx hash and store them in the db.
27
+ for (const [txHashStr, highestIndex] of highestIndexMap.entries()){
28
+ const txHash = TxHash.fromString(txHashStr);
29
+ await taggingStore.storePendingIndexes([
30
+ {
31
+ secret,
32
+ index: highestIndex
33
+ }
34
+ ], txHash, jobId);
35
+ }
36
+ }
37
+ // Returns txs that used the given tags. A tag might have been used in multiple txs and for this reason we return
38
+ // an array for each tag.
39
+ async function getTxsContainingTags(tags, aztecNode, anchorBlockHash) {
40
+ // We use the utility function below to retrieve all logs for the tags across all pages, so we don't need to handle
41
+ // pagination here.
42
+ const allLogs = await getAllPrivateLogsByTags(aztecNode, tags, anchorBlockHash);
43
+ return allLogs.map((logs)=>logs.map((log)=>log.txHash));
44
+ }
45
+ // Returns a map of txHash to the highest index for that txHash.
46
+ function getTxHighestIndexMap(txHashesForTags, preTagsForWindow) {
47
+ if (txHashesForTags.length !== preTagsForWindow.length) {
48
+ throw new Error(`Number of tx hashes arrays does not match number of pre-tags. ${txHashesForTags.length} !== ${preTagsForWindow.length}`);
49
+ }
50
+ const highestIndexMap = new Map();
51
+ for(let i = 0; i < txHashesForTags.length; i++){
52
+ const taggingIndex = preTagsForWindow[i].index;
53
+ const txHashesForTag = txHashesForTags[i];
54
+ for (const txHash of txHashesForTag){
55
+ const key = txHash.toString();
56
+ highestIndexMap.set(key, Math.max(highestIndexMap.get(key) ?? 0, taggingIndex));
57
+ }
58
+ }
59
+ return highestIndexMap;
60
+ }