@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
@@ -0,0 +1,92 @@
1
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
+ import type { BlockHash } from '@aztec/stdlib/block';
3
+ import { MAX_LOGS_PER_TAG, MAX_RPC_LEN } from '@aztec/stdlib/interfaces/api-limit';
4
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
5
+ import type { SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
6
+
7
+ /**
8
+ * Generic pagination helper that fetches all pages of results.
9
+ * @param numTags - The number of tags being queried (determines result array size).
10
+ * @param fetchPage - Function that fetches a single page of results given a page number.
11
+ * @returns An array of arrays, one per tag, containing all results across all pages.
12
+ */
13
+ async function getAllPages<T>(numTags: number, fetchPage: (page: number) => Promise<T[][]>): Promise<T[][]> {
14
+ const allResultsPerTag: T[][] = Array.from({ length: numTags }, () => []);
15
+ let page = 0;
16
+ let hasMore = true;
17
+
18
+ while (hasMore) {
19
+ const resultsPage = await fetchPage(page);
20
+ hasMore = false;
21
+
22
+ for (let i = 0; i < resultsPage.length; i++) {
23
+ allResultsPerTag[i].push(...resultsPage[i]);
24
+ if (resultsPage[i].length === MAX_LOGS_PER_TAG) {
25
+ hasMore = true;
26
+ }
27
+ }
28
+ page++;
29
+ }
30
+
31
+ return allResultsPerTag;
32
+ }
33
+
34
+ /**
35
+ * Splits tags into chunks of MAX_RPC_LEN, fetches logs for each chunk using getAllPages, then stitches the results
36
+ * back into a single array preserving the original tag order.
37
+ */
38
+ async function getAllPagesInBatches<Tag, T>(
39
+ tags: Tag[],
40
+ fetchAllPagesForBatch: (batch: Tag[]) => Promise<T[][]>,
41
+ ): Promise<T[][]> {
42
+ if (tags.length <= MAX_RPC_LEN) {
43
+ return fetchAllPagesForBatch(tags);
44
+ }
45
+
46
+ const batches: Tag[][] = [];
47
+ for (let i = 0; i < tags.length; i += MAX_RPC_LEN) {
48
+ batches.push(tags.slice(i, i + MAX_RPC_LEN));
49
+ }
50
+ const batchResults = await Promise.all(batches.map(fetchAllPagesForBatch));
51
+ return batchResults.flat();
52
+ }
53
+
54
+ /**
55
+ * Fetches all private logs for the given tags, automatically paginating through all pages.
56
+ * @param aztecNode - The Aztec node to query.
57
+ * @param tags - The siloed tags to search for.
58
+ * @param anchorBlockHash - reference block for the Aztec node query, throws if block is not found there (typically
59
+ * because of reorgs).
60
+ * @returns An array of log arrays, one per tag, containing all logs across all pages.
61
+ */
62
+ export function getAllPrivateLogsByTags(
63
+ aztecNode: AztecNode,
64
+ tags: SiloedTag[],
65
+ anchorBlockHash: BlockHash,
66
+ ): Promise<TxScopedL2Log[][]> {
67
+ return getAllPagesInBatches(tags, batch =>
68
+ getAllPages(batch.length, page => aztecNode.getPrivateLogsByTags(batch, page, anchorBlockHash)),
69
+ );
70
+ }
71
+
72
+ /**
73
+ * Fetches all public logs for the given tags from a contract, automatically paginating through all pages.
74
+ * @param aztecNode - The Aztec node to query.
75
+ * @param contractAddress - The contract address to search logs for.
76
+ * @param tags - The tags to search for.
77
+ * @param anchorBlockHash - reference block for the Aztec node query, throws if block is not found there (typically
78
+ * because of reorgs).
79
+ * @returns An array of log arrays, one per tag, containing all logs across all pages.
80
+ */
81
+ export function getAllPublicLogsByTagsFromContract(
82
+ aztecNode: AztecNode,
83
+ contractAddress: AztecAddress,
84
+ tags: Tag[],
85
+ anchorBlockHash: BlockHash,
86
+ ): Promise<TxScopedL2Log[][]> {
87
+ return getAllPagesInBatches(tags, batch =>
88
+ getAllPages(batch.length, page =>
89
+ aztecNode.getPublicLogsByTagsFromContract(contractAddress, batch, page, anchorBlockHash),
90
+ ),
91
+ );
92
+ }
@@ -12,7 +12,8 @@
12
12
  export { loadPrivateLogsForSenderRecipientPair } from './recipient_sync/load_private_logs_for_sender_recipient_pair.js';
13
13
  export { syncSenderTaggingIndexes } from './sender_sync/sync_sender_tagging_indexes.js';
14
14
  export { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from './constants.js';
15
+ export { getAllPrivateLogsByTags, getAllPublicLogsByTagsFromContract } from './get_all_logs_by_tags.js';
15
16
 
16
17
  // Re-export tagging-related types from stdlib
17
- export { DirectionalAppTaggingSecret, Tag, SiloedTag } from '@aztec/stdlib/logs';
18
- export { type PreTag } from '@aztec/stdlib/logs';
18
+ export { ExtendedDirectionalAppTaggingSecret, Tag, SiloedTag } from '@aztec/stdlib/logs';
19
+ export { type PreTag, type TaggingIndexRange } from '@aztec/stdlib/logs';
@@ -1,7 +1,7 @@
1
1
  import type { BlockNumber } from '@aztec/foundation/branded-types';
2
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
+ import type { BlockHash } from '@aztec/stdlib/block';
3
3
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
4
- import type { DirectionalAppTaggingSecret, TxScopedL2Log } from '@aztec/stdlib/logs';
4
+ import type { ExtendedDirectionalAppTaggingSecret, TxScopedL2Log } from '@aztec/stdlib/logs';
5
5
 
6
6
  import type { RecipientTaggingStore } from '../../storage/tagging_store/recipient_tagging_store.js';
7
7
  import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../constants.js';
@@ -9,25 +9,26 @@ import { findHighestIndexes } from './utils/find_highest_indexes.js';
9
9
  import { loadLogsForRange } from './utils/load_logs_for_range.js';
10
10
 
11
11
  /**
12
- * Loads private logs for `app` and sender-recipient pair defined by `secret` and updates the highest aged and
12
+ * Loads private logs for the app-sender-recipient triplet defined by `secret` and updates the highest aged and
13
13
  * finalized indexes in the db. At most load logs from blocks up to and including `anchorBlockNumber`.
14
14
  *
15
15
  * @dev This function can be safely executed "in parallel" for other sender-recipient pairs because the data in
16
16
  * in the tagging data provider is indexed by the secret and hence completely disjoint.
17
17
  */
18
18
  export async function loadPrivateLogsForSenderRecipientPair(
19
- secret: DirectionalAppTaggingSecret,
20
- app: AztecAddress,
19
+ secret: ExtendedDirectionalAppTaggingSecret,
21
20
  aztecNode: AztecNode,
22
21
  taggingStore: RecipientTaggingStore,
23
22
  anchorBlockNumber: BlockNumber,
23
+ anchorBlockHash: BlockHash,
24
+ jobId: string,
24
25
  ): Promise<TxScopedL2Log[]> {
25
26
  // # Explanation of how the algorithm works
26
27
  // When we perform the sync we will look at logs that correspond to the tagging index range
27
28
  // (highestAgedIndex, highestFinalizedIndex + WINDOW_LEN]
28
29
  //
29
30
  // highestAgedIndex is the highest index that was used in a tx that is included in a block at least
30
- // `MAX_INCLUDE_BY_TIMESTAMP_DURATION` seconds ago.
31
+ // `MAX_TX_LIFETIME` seconds ago.
31
32
  // highestFinalizedIndex is the highest index that was used in a tx that is included in a finalized block.
32
33
  //
33
34
  // "(" denotes an open end of the range - the index is not included in the range.
@@ -39,19 +40,19 @@ export async function loadPrivateLogsForSenderRecipientPair(
39
40
  // ever appear.
40
41
  //
41
42
  // This relies on the "maximum inclusion timestamp" rule enforced by the kernel and rollup circuits:
42
- // - a transaction's maximum inclusion timestamp is at most `MAX_INCLUDE_BY_TIMESTAMP_DURATION` seconds after
43
+ // - a transaction's maximum inclusion timestamp is at most `MAX_TX_LIFETIME` seconds after
43
44
  // the timestamp of its anchor block; and
44
45
  // - a rollup only includes transactions whose inclusion timestamp is >= the L2 block's timestamp.
45
46
  //
46
47
  // Suppose some device used index `I` in a transaction anchored to block `B_N` at time `N`, and that block is now at
47
- // least `MAX_INCLUDE_BY_TIMESTAMP_DURATION` seconds in the past. Then there is no possibility of any *other* device
48
+ // least `MAX_TX_LIFETIME` seconds in the past. Then there is no possibility of any *other* device
48
49
  // trying to use an index <= `I` while anchoring to a *newer* block than `B_N` because if we were anchoring to
49
50
  // a newer block than `B_N` then we would already have seen the log with index `I` and hence the device would have
50
51
  // chosen a larger index.
51
52
  // If that *other* device would anchor to a block older than `B_N` then that tx could never be included in a block
52
53
  // because it would already have been expired.
53
54
  //
54
- // Therefore, once we see that index `I` has been used in a block that is at least `MAX_INCLUDE_BY_TIMESTAMP_DURATION`
55
+ // Therefore, once we see that index `I` has been used in a block that is at least `MAX_TX_LIFETIME`
55
56
  // seconds old, we can safely stop syncing logs for all indexes <= `I` and set highestAgedIndex = `I`.
56
57
  //
57
58
  // ## Explanation of the upper bound `highestFinalizedIndex + WINDOW_LEN`
@@ -76,8 +77,8 @@ export async function loadPrivateLogsForSenderRecipientPair(
76
77
 
77
78
  let start: number, end: number;
78
79
  {
79
- const currentHighestAgedIndex = await taggingStore.getHighestAgedIndex(secret);
80
- const currentHighestFinalizedIndex = await taggingStore.getHighestFinalizedIndex(secret);
80
+ const currentHighestAgedIndex = await taggingStore.getHighestAgedIndex(secret, jobId);
81
+ const currentHighestFinalizedIndex = await taggingStore.getHighestFinalizedIndex(secret, jobId);
81
82
 
82
83
  // We don't want to include the highest aged index so we start from `currentHighestAgedIndex + 1` (or 0 if not set)
83
84
  start = currentHighestAgedIndex === undefined ? 0 : currentHighestAgedIndex + 1;
@@ -91,7 +92,14 @@ export async function loadPrivateLogsForSenderRecipientPair(
91
92
 
92
93
  while (true) {
93
94
  // Get private logs with their block timestamps and corresponding tagging indexes
94
- const privateLogsWithIndexes = await loadLogsForRange(secret, app, aztecNode, start, end, anchorBlockNumber);
95
+ const privateLogsWithIndexes = await loadLogsForRange(
96
+ secret,
97
+ aztecNode,
98
+ start,
99
+ end,
100
+ anchorBlockNumber,
101
+ anchorBlockHash,
102
+ );
95
103
 
96
104
  if (privateLogsWithIndexes.length === 0) {
97
105
  break;
@@ -107,7 +115,7 @@ export async function loadPrivateLogsForSenderRecipientPair(
107
115
 
108
116
  // Store updates in data provider and update local variables
109
117
  if (highestAgedIndex !== undefined) {
110
- await taggingStore.updateHighestAgedIndex(secret, highestAgedIndex);
118
+ await taggingStore.updateHighestAgedIndex(secret, highestAgedIndex, jobId);
111
119
  }
112
120
 
113
121
  if (highestFinalizedIndex === undefined) {
@@ -120,7 +128,7 @@ export async function loadPrivateLogsForSenderRecipientPair(
120
128
  throw new Error('Highest aged index lower than highest finalized index invariant violated');
121
129
  }
122
130
 
123
- await taggingStore.updateHighestFinalizedIndex(secret, highestFinalizedIndex);
131
+ await taggingStore.updateHighestFinalizedIndex(secret, highestFinalizedIndex, jobId);
124
132
 
125
133
  // For the next iteration we want to look only at indexes for which we have not attempted to load logs yet while
126
134
  // ensuring that we do not look further than WINDOW_LEN ahead of the highest finalized index.
@@ -1,4 +1,4 @@
1
- import { MAX_INCLUDE_BY_TIMESTAMP_DURATION } from '@aztec/constants';
1
+ import { MAX_TX_LIFETIME } from '@aztec/constants';
2
2
  import type { TxScopedL2Log } from '@aztec/stdlib/logs';
3
3
 
4
4
  /**
@@ -16,7 +16,7 @@ export function findHighestIndexes(
16
16
  const ageInSeconds = currentTimestamp - log.blockTimestamp;
17
17
 
18
18
  if (
19
- ageInSeconds >= BigInt(MAX_INCLUDE_BY_TIMESTAMP_DURATION) &&
19
+ ageInSeconds >= BigInt(MAX_TX_LIFETIME) &&
20
20
  (highestAgedIndex === undefined || taggingIndex > highestAgedIndex)
21
21
  ) {
22
22
  highestAgedIndex = taggingIndex;
@@ -1,37 +1,38 @@
1
1
  import type { BlockNumber } from '@aztec/foundation/branded-types';
2
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
+ import type { BlockHash } from '@aztec/stdlib/block';
3
3
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
4
- import type { DirectionalAppTaggingSecret, PreTag, TxScopedL2Log } from '@aztec/stdlib/logs';
5
- import { SiloedTag, Tag } from '@aztec/stdlib/logs';
4
+ import type { ExtendedDirectionalAppTaggingSecret, TxScopedL2Log } from '@aztec/stdlib/logs';
5
+ import { SiloedTag } from '@aztec/stdlib/logs';
6
+
7
+ import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
6
8
 
7
9
  /**
8
- * Gets private logs with their corresponding block timestamps and tagging indexes for the given index range, `app` and
9
- * `secret`. At most load logs from blocks up to and including `anchorBlockNumber`. `start` is inclusive and `end` is
10
- * exclusive.
10
+ * Gets private logs with their corresponding block timestamps and tagging indexes for the given index range and
11
+ * `extendedSecret`. At most load logs from blocks up to and including `anchorBlockNumber`. `start` is inclusive and
12
+ * `end` is exclusive.
11
13
  */
12
14
  export async function loadLogsForRange(
13
- secret: DirectionalAppTaggingSecret,
14
- app: AztecAddress,
15
+ extendedSecret: ExtendedDirectionalAppTaggingSecret,
15
16
  aztecNode: AztecNode,
16
17
  start: number,
17
18
  end: number,
18
19
  anchorBlockNumber: BlockNumber,
20
+ anchorBlockHash: BlockHash,
19
21
  ): Promise<Array<{ log: TxScopedL2Log; taggingIndex: number }>> {
20
- // Derive tags for the window
21
- const preTags: PreTag[] = Array(end - start)
22
- .fill(0)
23
- .map((_, i) => ({ secret, index: start + i }));
24
- const siloedTags = await Promise.all(preTags.map(preTag => Tag.compute(preTag))).then(tags =>
25
- Promise.all(tags.map(tag => SiloedTag.compute(tag, app))),
22
+ // Derive siloed tags for the window
23
+ const siloedTags = await Promise.all(
24
+ Array.from({ length: end - start }, (_, i) => SiloedTag.compute({ extendedSecret, index: start + i })),
26
25
  );
27
26
 
28
- const logs = await aztecNode.getPrivateLogsByTags(siloedTags);
27
+ // We use the utility function below to retrieve all logs for the tags across all pages, so we don't need to handle
28
+ // pagination here.
29
+ const logs = await getAllPrivateLogsByTags(aztecNode, siloedTags, anchorBlockHash);
29
30
 
30
31
  // Pair logs with their corresponding tagging indexes
31
32
  const logsWithIndexes: Array<{ log: TxScopedL2Log; taggingIndex: number }> = [];
32
33
  for (let i = 0; i < logs.length; i++) {
33
34
  const logsForTag = logs[i];
34
- const taggingIndex = preTags[i].index;
35
+ const taggingIndex = start + i;
35
36
  for (const log of logsForTag) {
36
37
  if (log.blockNumber <= anchorBlockNumber) {
37
38
  logsWithIndexes.push({ log, taggingIndex });
@@ -1,6 +1,6 @@
1
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
1
+ import type { BlockHash } from '@aztec/stdlib/block';
2
2
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
3
- import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
3
+ import type { ExtendedDirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
4
4
 
5
5
  import type { SenderTaggingStore } from '../../storage/tagging_store/sender_tagging_store.js';
6
6
  import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../constants.js';
@@ -10,11 +10,8 @@ import { loadAndStoreNewTaggingIndexes } from './utils/load_and_store_new_taggin
10
10
  /**
11
11
  * Syncs tagging indexes. This function needs to be called whenever a private log is being sent.
12
12
  *
13
- * @param secret - The secret that's unique for (sender, recipient, contract) tuple while the direction of
13
+ * @param secret - The secret that's unique for (sender, recipient, app) tuple while the direction of
14
14
  * sender -> recipient matters.
15
- * @param app - The address of the contract that the logs are tagged for. Needs to be provided because we perform
16
- * second round of siloing in this function which is necessary because kernels do it as well (they silo first field
17
- * of the private log which corresponds to the tag).
18
15
  * @remarks When syncing the indexes as sender we don't care about the log contents - we only care about the highest
19
16
  * pending and highest finalized indexes as that guides the next index choice when sending a log. The next index choice
20
17
  * is simply the highest pending index plus one (or finalized if pending is undefined).
@@ -22,10 +19,11 @@ import { loadAndStoreNewTaggingIndexes } from './utils/load_and_store_new_taggin
22
19
  * updates its status accordingly.
23
20
  */
24
21
  export async function syncSenderTaggingIndexes(
25
- secret: DirectionalAppTaggingSecret,
26
- app: AztecAddress,
22
+ secret: ExtendedDirectionalAppTaggingSecret,
27
23
  aztecNode: AztecNode,
28
24
  taggingStore: SenderTaggingStore,
25
+ anchorBlockHash: BlockHash,
26
+ jobId: string,
29
27
  ): Promise<void> {
30
28
  // # Explanation of how syncing works
31
29
  //
@@ -45,7 +43,7 @@ export async function syncSenderTaggingIndexes(
45
43
  // Each window advance requires two queries (logs + tx status). For example, syncing indexes 0–500 with a window of
46
44
  // 100 takes at least 10 round trips (5 windows × 2 queries).
47
45
 
48
- const finalizedIndex = await taggingStore.getLastFinalizedIndex(secret);
46
+ const finalizedIndex = await taggingStore.getLastFinalizedIndex(secret, jobId);
49
47
 
50
48
  let start = finalizedIndex === undefined ? 0 : finalizedIndex + 1;
51
49
  let end = start + UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN;
@@ -56,21 +54,39 @@ export async function syncSenderTaggingIndexes(
56
54
  while (true) {
57
55
  // Load and store indexes for the current window. These indexes may already exist in the database if txs using
58
56
  // them were previously sent from this PXE. Any duplicates are handled by the tagging data provider.
59
- await loadAndStoreNewTaggingIndexes(secret, app, start, end, aztecNode, taggingStore);
57
+ await loadAndStoreNewTaggingIndexes(secret, start, end, aztecNode, taggingStore, anchorBlockHash, jobId);
60
58
 
61
59
  // Retrieve all indexes within the current window from storage and update their status accordingly.
62
- const pendingTxHashes = await taggingStore.getTxHashesOfPendingIndexes(secret, start, end);
60
+ const pendingTxHashes = await taggingStore.getTxHashesOfPendingIndexes(secret, start, end, jobId);
63
61
  if (pendingTxHashes.length === 0) {
64
62
  break;
65
63
  }
66
64
 
67
- const { txHashesToFinalize, txHashesToDrop } = await getStatusChangeOfPending(pendingTxHashes, aztecNode);
65
+ const { txHashesToFinalize, txHashesToDrop, txHashesWithExecutionReverted } = await getStatusChangeOfPending(
66
+ pendingTxHashes,
67
+ aztecNode,
68
+ );
68
69
 
69
- await taggingStore.dropPendingIndexes(txHashesToDrop);
70
- await taggingStore.finalizePendingIndexes(txHashesToFinalize);
70
+ await taggingStore.dropPendingIndexes(txHashesToDrop, jobId);
71
+ await taggingStore.finalizePendingIndexes(txHashesToFinalize, jobId);
72
+
73
+ if (txHashesWithExecutionReverted.length > 0) {
74
+ const indexedTxEffects = await Promise.all(
75
+ txHashesWithExecutionReverted.map(txHash => aztecNode.getTxEffect(txHash)),
76
+ );
77
+ for (const indexedTxEffect of indexedTxEffects) {
78
+ if (indexedTxEffect === undefined) {
79
+ throw new Error(
80
+ 'TxEffect not found for execution-reverted tx. This is either a bug or a reorg has occurred.',
81
+ );
82
+ }
83
+
84
+ await taggingStore.finalizePendingIndexesOfAPartiallyRevertedTx(indexedTxEffect.data, jobId);
85
+ }
86
+ }
71
87
 
72
88
  // We check if the finalized index has been updated.
73
- newFinalizedIndex = await taggingStore.getLastFinalizedIndex(secret);
89
+ newFinalizedIndex = await taggingStore.getLastFinalizedIndex(secret, jobId);
74
90
  if (previousFinalizedIndex !== newFinalizedIndex) {
75
91
  // A new finalized index was found, so we'll run the loop again. For example:
76
92
  // - Previous finalized index: 10
@@ -2,47 +2,50 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/server';
2
2
  import { TxHash, TxStatus } from '@aztec/stdlib/tx';
3
3
 
4
4
  /**
5
- * Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized or
6
- * dropped.
5
+ * Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized,
6
+ * dropped, or execution-reverted (but mined).
7
7
  */
8
8
  export async function getStatusChangeOfPending(
9
9
  pending: TxHash[],
10
10
  aztecNode: AztecNode,
11
- ): Promise<{ txHashesToFinalize: TxHash[]; txHashesToDrop: TxHash[] }> {
12
- // Get receipts for all pending tx hashes and the finalized block number.
13
- const [receipts, tips] = await Promise.all([
14
- Promise.all(pending.map(pendingTxHash => aztecNode.getTxReceipt(pendingTxHash))),
15
- aztecNode.getL2Tips(),
16
- ]);
11
+ ): Promise<{
12
+ txHashesToFinalize: TxHash[];
13
+ txHashesToDrop: TxHash[];
14
+ txHashesWithExecutionReverted: TxHash[];
15
+ }> {
16
+ // Get receipts for all pending tx hashes.
17
+ const receipts = await Promise.all(pending.map(pendingTxHash => aztecNode.getTxReceipt(pendingTxHash)));
17
18
 
18
19
  const txHashesToFinalize: TxHash[] = [];
19
20
  const txHashesToDrop: TxHash[] = [];
21
+ const txHashesWithExecutionReverted: TxHash[] = [];
20
22
 
21
23
  for (let i = 0; i < receipts.length; i++) {
22
24
  const receipt = receipts[i];
23
25
  const txHash = pending[i];
24
26
 
25
- if (
26
- receipt.status === TxStatus.SUCCESS &&
27
- receipt.blockNumber &&
28
- receipt.blockNumber <= tips.finalized.block.number
29
- ) {
30
- // Tx has been included in a block and the corresponding block is finalized --> we mark the indexes as
31
- // finalized.
32
- txHashesToFinalize.push(txHash);
33
- } else if (
34
- receipt.status === TxStatus.DROPPED ||
35
- receipt.status === TxStatus.APP_LOGIC_REVERTED ||
36
- receipt.status === TxStatus.TEARDOWN_REVERTED ||
37
- receipt.status === TxStatus.BOTH_REVERTED
38
- ) {
39
- // Tx was dropped or reverted --> we drop the corresponding pending indexes.
40
- // TODO(#17615): Don't drop pending indexes corresponding to non-revertible phases.
27
+ if (receipt.status === TxStatus.FINALIZED) {
28
+ // Tx has been included in a block and the corresponding block is finalized
29
+ if (receipt.hasExecutionSucceeded()) {
30
+ // No part of execution reverted - we just finalize all the indexes.
31
+ txHashesToFinalize.push(txHash);
32
+ } else if (receipt.hasExecutionReverted()) {
33
+ // Tx was mined but execution reverted (app logic, teardown, or both). Some logs from the non-revertible
34
+ // phase may still be onchain. We check which tags made it onchain and finalize those; drop the rest.
35
+ txHashesWithExecutionReverted.push(txHash);
36
+ } else {
37
+ // Defensive check - this branch should never be triggered
38
+ throw new Error(
39
+ 'Both hasExecutionSucceeded and hasExecutionReverted on the receipt returned false. This should never happen and it implies a bug. Please open an issue.',
40
+ );
41
+ }
42
+ } else if (receipt.isDropped()) {
43
+ // Tx was dropped from the mempool --> we drop the corresponding pending indexes.
41
44
  txHashesToDrop.push(txHash);
42
45
  } else {
43
- // Tx is still pending or the corresponding block is not yet finalized --> we don't do anything.
46
+ // Tx is still pending, not yet finalized, or was mined successfully but not yet finalized --> we don't do anything.
44
47
  }
45
48
  }
46
49
 
47
- return { txHashesToFinalize, txHashesToDrop };
50
+ return { txHashesToFinalize, txHashesToDrop, txHashesWithExecutionReverted };
48
51
  }
@@ -1,72 +1,85 @@
1
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
1
+ import type { BlockHash } from '@aztec/stdlib/block';
2
2
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
3
- import type { DirectionalAppTaggingSecret, PreTag } from '@aztec/stdlib/logs';
4
- import { SiloedTag, Tag } from '@aztec/stdlib/logs';
3
+ import type { ExtendedDirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
4
+ import { SiloedTag } from '@aztec/stdlib/logs';
5
5
  import { TxHash } from '@aztec/stdlib/tx';
6
6
 
7
7
  import type { SenderTaggingStore } from '../../../storage/tagging_store/sender_tagging_store.js';
8
+ import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
8
9
 
9
10
  /**
10
11
  * Loads tagging indexes from the Aztec node and stores them in the tagging data provider.
11
12
  * @remarks This function is one of two places by which a pending index can get to the tagging data provider. The other
12
13
  * place is when a tx is being sent from this PXE.
13
- * @param secret - The directional app tagging secret that's unique for (sender, recipient, contract) tuple.
14
- * @param app - The address of the contract that the logs are tagged for. Used for siloing tags to match
15
- * kernel circuit behavior.
14
+ * @param extendedSecret - The extended directional app tagging secret that's unique for (sender, recipient, app) tuple.
16
15
  * @param start - The starting index (inclusive) of the window to process.
17
16
  * @param end - The ending index (exclusive) of the window to process.
18
17
  * @param aztecNode - The Aztec node instance to query for logs.
19
18
  * @param taggingStore - The data provider to store pending indexes.
19
+ * @param anchorBlockHash - Hash of a block to use as reference block when querying node.
20
+ * @param jobId - Job identifier, used to keep writes in-memory until they can be persisted in a data integrity
21
+ * preserving way.
20
22
  */
21
23
  export async function loadAndStoreNewTaggingIndexes(
22
- secret: DirectionalAppTaggingSecret,
23
- app: AztecAddress,
24
+ extendedSecret: ExtendedDirectionalAppTaggingSecret,
24
25
  start: number,
25
26
  end: number,
26
27
  aztecNode: AztecNode,
27
28
  taggingStore: SenderTaggingStore,
29
+ anchorBlockHash: BlockHash,
30
+ jobId: string,
28
31
  ) {
29
32
  // We compute the tags for the current window of indexes
30
- const preTagsForWindow: PreTag[] = Array(end - start)
31
- .fill(0)
32
- .map((_, i) => ({ secret, index: start + i }));
33
33
  const siloedTagsForWindow = await Promise.all(
34
- preTagsForWindow.map(async preTag => SiloedTag.compute(await Tag.compute(preTag), app)),
34
+ Array.from({ length: end - start }, (_, i) => SiloedTag.compute({ extendedSecret, index: start + i })),
35
35
  );
36
36
 
37
- const txsForTags = await getTxsContainingTags(siloedTagsForWindow, aztecNode);
38
- const highestIndexMap = getTxHighestIndexMap(txsForTags, preTagsForWindow);
37
+ const txsForTags = await getTxsContainingTags(siloedTagsForWindow, aztecNode, anchorBlockHash);
38
+ const txIndexesMap = getTxIndexesMap(txsForTags, start, siloedTagsForWindow.length);
39
39
 
40
- // Now we iterate over the map, reconstruct the preTags and tx hash and store them in the db.
41
- for (const [txHashStr, highestIndex] of highestIndexMap.entries()) {
40
+ // Now we iterate over the map, construct the tagging index ranges and store them in the db.
41
+ for (const [txHashStr, indexes] of txIndexesMap.entries()) {
42
42
  const txHash = TxHash.fromString(txHashStr);
43
- await taggingStore.storePendingIndexes([{ secret, index: highestIndex }], txHash);
43
+ const ranges = [{ extendedSecret, lowestIndex: Math.min(...indexes), highestIndex: Math.max(...indexes) }];
44
+ await taggingStore.storePendingIndexes(ranges, txHash, jobId);
44
45
  }
45
46
  }
46
47
 
47
48
  // Returns txs that used the given tags. A tag might have been used in multiple txs and for this reason we return
48
49
  // an array for each tag.
49
- async function getTxsContainingTags(tags: SiloedTag[], aztecNode: AztecNode): Promise<TxHash[][]> {
50
- const allLogs = await aztecNode.getPrivateLogsByTags(tags);
50
+ async function getTxsContainingTags(
51
+ tags: SiloedTag[],
52
+ aztecNode: AztecNode,
53
+ anchorBlockHash: BlockHash,
54
+ ): Promise<TxHash[][]> {
55
+ // We use the utility function below to retrieve all logs for the tags across all pages, so we don't need to handle
56
+ // pagination here.
57
+ const allLogs = await getAllPrivateLogsByTags(aztecNode, tags, anchorBlockHash);
51
58
  return allLogs.map(logs => logs.map(log => log.txHash));
52
59
  }
53
60
 
54
- // Returns a map of txHash to the highest index for that txHash.
55
- function getTxHighestIndexMap(txHashesForTags: TxHash[][], preTagsForWindow: PreTag[]): Map<string, number> {
56
- if (txHashesForTags.length !== preTagsForWindow.length) {
57
- throw new Error(
58
- `Number of tx hashes arrays does not match number of pre-tags. ${txHashesForTags.length} !== ${preTagsForWindow.length}`,
59
- );
61
+ // Returns a map of txHash to all indexes for that txHash.
62
+ function getTxIndexesMap(txHashesForTags: TxHash[][], start: number, count: number): Map<string, number[]> {
63
+ if (txHashesForTags.length !== count) {
64
+ throw new Error(`Number of tx hashes arrays does not match number of tags. ${txHashesForTags.length} !== ${count}`);
60
65
  }
61
66
 
62
- const highestIndexMap = new Map<string, number>();
67
+ const indexesMap = new Map<string, number[]>();
68
+ // Iterate over indexes
63
69
  for (let i = 0; i < txHashesForTags.length; i++) {
64
- const taggingIndex = preTagsForWindow[i].index;
70
+ const taggingIndex = start + i;
65
71
  const txHashesForTag = txHashesForTags[i];
72
+ // iterate over tx hashes that used that index (tag)
66
73
  for (const txHash of txHashesForTag) {
67
74
  const key = txHash.toString();
68
- highestIndexMap.set(key, Math.max(highestIndexMap.get(key) ?? 0, taggingIndex));
75
+ const existing = indexesMap.get(key);
76
+ // Add the index to the tx's indexes
77
+ if (existing) {
78
+ existing.push(taggingIndex);
79
+ } else {
80
+ indexesMap.set(key, [taggingIndex]);
81
+ }
69
82
  }
70
83
  }
71
- return highestIndexMap;
84
+ return indexesMap;
72
85
  }
@@ -1,9 +0,0 @@
1
- import type { AztecNode } from '@aztec/stdlib/interfaces/client';
2
- import type { NodeStats } from '@aztec/stdlib/tx';
3
- export type ProxiedNode = AztecNode & {
4
- getStats(): NodeStats;
5
- };
6
- export declare class ProxiedNodeFactory {
7
- static create(node: AztecNode): ProxiedNode;
8
- }
9
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJveGllZF9ub2RlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3RfZnVuY3Rpb25fc2ltdWxhdG9yL3Byb3hpZWRfbm9kZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUtsRCxNQUFNLE1BQU0sV0FBVyxHQUFHLFNBQVMsR0FBRztJQUFFLFFBQVEsSUFBSSxTQUFTLENBQUE7Q0FBRSxDQUFDO0FBRWhFLHFCQUFhLGtCQUFrQjtJQUM3QixNQUFNLENBQUMsTUFBTSxDQUFDLElBQUksRUFBRSxTQUFTLGVBcUI1QjtDQUNGIn0=
@@ -1 +0,0 @@
1
- {"version":3,"file":"proxied_node.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/proxied_node.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAKlD,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG;IAAE,QAAQ,IAAI,SAAS,CAAA;CAAE,CAAC;AAEhE,qBAAa,kBAAkB;IAC7B,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,eAqB5B;CACF"}
@@ -1,27 +0,0 @@
1
- import { Timer } from '@aztec/foundation/timer';
2
- export class ProxiedNodeFactory {
3
- static create(node) {
4
- const stats = {};
5
- return new Proxy(node, {
6
- get (target, prop) {
7
- if (prop === 'getStats') {
8
- return ()=>{
9
- return stats;
10
- };
11
- } else {
12
- return async function(...args) {
13
- if (!stats[prop]) {
14
- stats[prop] = {
15
- times: []
16
- };
17
- }
18
- const timer = new Timer();
19
- const result = await target[prop].apply(target, args);
20
- stats[prop].times.push(timer.ms());
21
- return result;
22
- };
23
- }
24
- }
25
- });
26
- }
27
- }
@@ -1,28 +0,0 @@
1
- import { type PrivateKernelCircuitPublicInputs, PrivateKernelResetCircuitPrivateInputs, type PrivateKernelSimulateOutput } from '@aztec/stdlib/kernel';
2
- import { type PrivateCallExecutionResult } from '@aztec/stdlib/tx';
3
- import type { PrivateKernelOracle } from '../private_kernel_oracle.js';
4
- export declare class PrivateKernelResetPrivateInputsBuilder {
5
- private previousKernelOutput;
6
- private executionStack;
7
- private noteHashNullifierCounterMap;
8
- private splitCounter;
9
- private previousKernel;
10
- private nextIteration?;
11
- private noteHashResetActions;
12
- private nullifierResetActions;
13
- private numTransientData?;
14
- private transientDataSquashingHints;
15
- private requestedDimensions;
16
- constructor(previousKernelOutput: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>, executionStack: PrivateCallExecutionResult[], noteHashNullifierCounterMap: Map<number, number>, splitCounter: number);
17
- needsReset(): boolean;
18
- build(oracle: PrivateKernelOracle): Promise<PrivateKernelResetCircuitPrivateInputs>;
19
- private reduceReadRequestActions;
20
- private needsResetNoteHashReadRequests;
21
- private needsResetNullifierReadRequests;
22
- private needsResetNullifierKeys;
23
- private needsResetTransientData;
24
- private needsSiloNoteHashes;
25
- private needsSiloNullifiers;
26
- private needsSiloPrivateLogs;
27
- }
28
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVpbGRfcHJpdmF0ZV9rZXJuZWxfcmVzZXRfcHJpdmF0ZV9pbnB1dHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wcml2YXRlX2tlcm5lbC9oaW50cy9idWlsZF9wcml2YXRlX2tlcm5lbF9yZXNldF9wcml2YXRlX2lucHV0cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFlQSxPQUFPLEVBS0wsS0FBSyxnQ0FBZ0MsRUFFckMsc0NBQXNDLEVBR3RDLEtBQUssMkJBQTJCLEVBZWpDLE1BQU0sc0JBQXNCLENBQUM7QUFDOUIsT0FBTyxFQUFFLEtBQUssMEJBQTBCLEVBQWlCLE1BQU0sa0JBQWtCLENBQUM7QUFHbEYsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQTRDdkUscUJBQWEsc0NBQXNDO0lBWS9DLE9BQU8sQ0FBQyxvQkFBb0I7SUFDNUIsT0FBTyxDQUFDLGNBQWM7SUFDdEIsT0FBTyxDQUFDLDJCQUEyQjtJQUNuQyxPQUFPLENBQUMsWUFBWTtJQWR0QixPQUFPLENBQUMsY0FBYyxDQUFtQztJQUV6RCxPQUFPLENBQUMsYUFBYSxDQUFDLENBQTZCO0lBRW5ELE9BQU8sQ0FBQyxvQkFBb0IsQ0FBcUU7SUFDakcsT0FBTyxDQUFDLHFCQUFxQixDQUFxRTtJQUNsRyxPQUFPLENBQUMsZ0JBQWdCLENBQUMsQ0FBUztJQUNsQyxPQUFPLENBQUMsMkJBQTJCLENBQWtFO0lBQ3JHLE9BQU8sQ0FBQyxtQkFBbUIsQ0FBK0I7SUFFMUQsWUFDVSxvQkFBb0IsRUFBRSwyQkFBMkIsQ0FBQyxnQ0FBZ0MsQ0FBQyxFQUNuRixjQUFjLEVBQUUsMEJBQTBCLEVBQUUsRUFDNUMsMkJBQTJCLEVBQUUsR0FBRyxDQUFDLE1BQU0sRUFBRSxNQUFNLENBQUMsRUFDaEQsWUFBWSxFQUFFLE1BQU0sRUFXN0I7SUFFRCxVQUFVLElBQUksT0FBTyxDQXNCcEI7SUFFSyxLQUFLLENBQUMsTUFBTSxFQUFFLG1CQUFtQixtREFtRXRDO0lBRUQsT0FBTyxDQUFDLHdCQUF3QjtJQTJCaEMsT0FBTyxDQUFDLDhCQUE4QjtJQXVEdEMsT0FBTyxDQUFDLCtCQUErQjtJQXVEdkMsT0FBTyxDQUFDLHVCQUF1QjtJQWEvQixPQUFPLENBQUMsdUJBQXVCO0lBc0UvQixPQUFPLENBQUMsbUJBQW1CO0lBYzNCLE9BQU8sQ0FBQyxtQkFBbUI7SUFrQjNCLE9BQU8sQ0FBQyxvQkFBb0I7Q0FxQjdCIn0=