@aztec/pxe 0.0.1-commit.fffb133c → 0.0.1-dev

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 (309) hide show
  1. package/dest/bin/check_oracle_version.js +5 -5
  2. package/dest/block_synchronizer/block_synchronizer.d.ts +10 -4
  3. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  4. package/dest/block_synchronizer/block_synchronizer.js +30 -6
  5. package/dest/config/package_info.js +1 -1
  6. package/dest/contract_function_simulator/contract_function_simulator.d.ts +66 -31
  7. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  8. package/dest/contract_function_simulator/contract_function_simulator.js +214 -75
  9. package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
  10. package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
  11. package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
  12. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -7
  13. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  14. package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
  15. package/dest/contract_function_simulator/index.d.ts +2 -1
  16. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/index.js +1 -0
  18. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +4 -6
  19. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  20. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +8 -10
  21. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +1 -1
  22. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +1 -1
  23. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
  24. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  25. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +2 -4
  26. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +4 -7
  27. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  28. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +6 -11
  29. package/dest/contract_function_simulator/oracle/interfaces.d.ts +66 -47
  30. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  31. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
  32. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
  33. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +47 -0
  34. package/dest/contract_function_simulator/oracle/oracle.d.ts +78 -44
  35. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  36. package/dest/contract_function_simulator/oracle/oracle.js +363 -114
  37. package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
  38. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +56 -86
  39. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  40. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +123 -98
  41. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +145 -70
  42. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  43. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +435 -145
  44. package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
  45. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
  46. package/dest/contract_function_simulator/pick_notes.js +20 -3
  47. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
  48. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
  49. package/dest/contract_function_simulator/proxied_contract_data_source.js +3 -0
  50. package/dest/contract_logging.d.ts +27 -0
  51. package/dest/contract_logging.d.ts.map +1 -0
  52. package/dest/contract_logging.js +38 -0
  53. package/dest/contract_sync/contract_sync_service.d.ts +45 -0
  54. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
  55. package/dest/contract_sync/contract_sync_service.js +150 -0
  56. package/dest/contract_sync/helpers.d.ts +27 -0
  57. package/dest/contract_sync/helpers.d.ts.map +1 -0
  58. package/dest/contract_sync/{index.js → helpers.js} +16 -17
  59. package/dest/debug/pxe_debug_utils.d.ts +24 -10
  60. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  61. package/dest/debug/pxe_debug_utils.js +28 -18
  62. package/dest/entrypoints/client/bundle/index.d.ts +3 -1
  63. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  64. package/dest/entrypoints/client/bundle/index.js +2 -0
  65. package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
  66. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  67. package/dest/entrypoints/client/bundle/utils.js +24 -9
  68. package/dest/entrypoints/client/lazy/index.d.ts +3 -1
  69. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  70. package/dest/entrypoints/client/lazy/index.js +2 -0
  71. package/dest/entrypoints/client/lazy/utils.d.ts +3 -3
  72. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  73. package/dest/entrypoints/client/lazy/utils.js +25 -10
  74. package/dest/entrypoints/pxe_creation_options.d.ts +8 -2
  75. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  76. package/dest/entrypoints/pxe_creation_options.js +3 -1
  77. package/dest/entrypoints/server/index.d.ts +5 -3
  78. package/dest/entrypoints/server/index.d.ts.map +1 -1
  79. package/dest/entrypoints/server/index.js +4 -2
  80. package/dest/entrypoints/server/utils.d.ts +2 -2
  81. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  82. package/dest/entrypoints/server/utils.js +31 -11
  83. package/dest/events/event_service.d.ts +16 -8
  84. package/dest/events/event_service.d.ts.map +1 -1
  85. package/dest/events/event_service.js +46 -14
  86. package/dest/events/private_event_filter_validator.d.ts +3 -2
  87. package/dest/events/private_event_filter_validator.d.ts.map +1 -1
  88. package/dest/events/private_event_filter_validator.js +15 -0
  89. package/dest/hooks/authorize_utility_call.d.ts +37 -0
  90. package/dest/hooks/authorize_utility_call.d.ts.map +1 -0
  91. package/dest/hooks/authorize_utility_call.js +4 -0
  92. package/dest/hooks/execution_hooks.d.ts +42 -0
  93. package/dest/hooks/execution_hooks.d.ts.map +1 -0
  94. package/dest/hooks/execution_hooks.js +9 -0
  95. package/dest/hooks/index.d.ts +4 -0
  96. package/dest/hooks/index.d.ts.map +1 -0
  97. package/dest/hooks/index.js +1 -0
  98. package/dest/job_coordinator/job_coordinator.d.ts +3 -2
  99. package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
  100. package/dest/job_coordinator/job_coordinator.js +3 -2
  101. package/dest/logs/log_service.d.ts +10 -9
  102. package/dest/logs/log_service.d.ts.map +1 -1
  103. package/dest/logs/log_service.js +50 -85
  104. package/dest/messages/message_context_service.d.ts +17 -0
  105. package/dest/messages/message_context_service.d.ts.map +1 -0
  106. package/dest/messages/message_context_service.js +38 -0
  107. package/dest/notes/note_service.d.ts +29 -8
  108. package/dest/notes/note_service.d.ts.map +1 -1
  109. package/dest/notes/note_service.js +89 -65
  110. package/dest/notes_filter.d.ts +24 -0
  111. package/dest/notes_filter.d.ts.map +1 -0
  112. package/dest/notes_filter.js +4 -0
  113. package/dest/oracle_version.d.ts +4 -3
  114. package/dest/oracle_version.d.ts.map +1 -1
  115. package/dest/oracle_version.js +20 -10
  116. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
  117. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
  118. package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
  119. package/dest/private_kernel/hints/index.d.ts +1 -1
  120. package/dest/private_kernel/hints/index.js +1 -1
  121. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
  122. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  123. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
  124. package/dest/private_kernel/hints/test_utils.d.ts +122 -0
  125. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
  126. package/dest/private_kernel/hints/test_utils.js +203 -0
  127. package/dest/private_kernel/private_kernel_execution_prover.d.ts +4 -2
  128. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  129. package/dest/private_kernel/private_kernel_execution_prover.js +38 -19
  130. package/dest/private_kernel/private_kernel_oracle.d.ts +10 -6
  131. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  132. package/dest/private_kernel/private_kernel_oracle.js +26 -20
  133. package/dest/pxe.d.ts +87 -23
  134. package/dest/pxe.d.ts.map +1 -1
  135. package/dest/pxe.js +178 -119
  136. package/dest/storage/address_store/address_store.d.ts +1 -1
  137. package/dest/storage/address_store/address_store.d.ts.map +1 -1
  138. package/dest/storage/address_store/address_store.js +12 -11
  139. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
  140. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
  141. package/dest/storage/anchor_block_store/anchor_block_store.js +9 -2
  142. package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts +42 -0
  143. package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts.map +1 -0
  144. package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.js +93 -0
  145. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +15 -0
  146. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -0
  147. package/dest/storage/backwards_compatibility_tests/schema_tests.js +588 -0
  148. package/dest/storage/backwards_compatibility_tests/store_spy.d.ts +19 -0
  149. package/dest/storage/backwards_compatibility_tests/store_spy.d.ts.map +1 -0
  150. package/dest/storage/backwards_compatibility_tests/store_spy.js +63 -0
  151. package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
  152. package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
  153. package/dest/storage/capsule_store/capsule_service.js +50 -0
  154. package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
  155. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
  156. package/dest/storage/capsule_store/capsule_store.js +42 -36
  157. package/dest/storage/capsule_store/index.d.ts +2 -1
  158. package/dest/storage/capsule_store/index.d.ts.map +1 -1
  159. package/dest/storage/capsule_store/index.js +1 -0
  160. package/dest/storage/contract_store/contract_store.d.ts +42 -15
  161. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  162. package/dest/storage/contract_store/contract_store.js +160 -73
  163. package/dest/storage/metadata.d.ts +1 -1
  164. package/dest/storage/metadata.js +1 -1
  165. package/dest/storage/note_store/note_store.d.ts +13 -3
  166. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  167. package/dest/storage/note_store/note_store.js +147 -107
  168. package/dest/storage/open_pxe_stores.d.ts +31 -0
  169. package/dest/storage/open_pxe_stores.d.ts.map +1 -0
  170. package/dest/storage/open_pxe_stores.js +26 -0
  171. package/dest/storage/private_event_store/private_event_store.d.ts +1 -1
  172. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  173. package/dest/storage/private_event_store/private_event_store.js +87 -61
  174. package/dest/storage/private_event_store/stored_private_event.d.ts +4 -4
  175. package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -1
  176. package/dest/storage/private_event_store/stored_private_event.js +2 -2
  177. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
  178. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  179. package/dest/storage/tagging_store/recipient_tagging_store.js +31 -19
  180. package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
  181. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
  182. package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
  183. package/dest/storage/tagging_store/sender_tagging_store.d.ts +29 -28
  184. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  185. package/dest/storage/tagging_store/sender_tagging_store.js +233 -137
  186. package/dest/tagging/get_all_logs_by_tags.d.ts +4 -4
  187. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
  188. package/dest/tagging/get_all_logs_by_tags.js +20 -3
  189. package/dest/tagging/index.d.ts +6 -5
  190. package/dest/tagging/index.d.ts.map +1 -1
  191. package/dest/tagging/index.js +4 -3
  192. package/dest/tagging/persist_sender_tagging_index_ranges.d.ts +29 -0
  193. package/dest/tagging/persist_sender_tagging_index_ranges.d.ts.map +1 -0
  194. package/dest/tagging/persist_sender_tagging_index_ranges.js +42 -0
  195. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +56 -0
  196. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -0
  197. package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +158 -0
  198. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
  199. package/dest/tagging/reconcile_tagging_index_ranges.d.ts +36 -0
  200. package/dest/tagging/reconcile_tagging_index_ranges.d.ts.map +1 -0
  201. package/dest/tagging/reconcile_tagging_index_ranges.js +74 -0
  202. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +5 -9
  203. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  204. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +30 -13
  205. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +13 -7
  206. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  207. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +41 -10
  208. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +6 -8
  209. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  210. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +36 -24
  211. package/package.json +26 -16
  212. package/src/bin/check_oracle_version.ts +5 -5
  213. package/src/block_synchronizer/block_synchronizer.ts +45 -21
  214. package/src/config/package_info.ts +1 -1
  215. package/src/contract_function_simulator/contract_function_simulator.ts +389 -134
  216. package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
  217. package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
  218. package/src/contract_function_simulator/index.ts +1 -0
  219. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +9 -9
  220. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
  221. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -5
  222. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +4 -10
  223. package/src/contract_function_simulator/oracle/interfaces.ts +101 -62
  224. package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +104 -0
  225. package/src/contract_function_simulator/oracle/oracle.ts +464 -151
  226. package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
  227. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +152 -191
  228. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +709 -200
  229. package/src/contract_function_simulator/pick_notes.ts +22 -3
  230. package/src/contract_function_simulator/proxied_contract_data_source.ts +8 -1
  231. package/src/contract_logging.ts +52 -0
  232. package/src/contract_sync/contract_sync_service.ts +208 -0
  233. package/src/contract_sync/{index.ts → helpers.ts} +17 -29
  234. package/src/debug/pxe_debug_utils.ts +63 -19
  235. package/src/entrypoints/client/bundle/index.ts +2 -0
  236. package/src/entrypoints/client/bundle/utils.ts +19 -18
  237. package/src/entrypoints/client/lazy/index.ts +2 -0
  238. package/src/entrypoints/client/lazy/utils.ts +20 -18
  239. package/src/entrypoints/pxe_creation_options.ts +13 -1
  240. package/src/entrypoints/server/index.ts +4 -2
  241. package/src/entrypoints/server/utils.ts +25 -29
  242. package/src/events/event_service.ts +70 -24
  243. package/src/events/private_event_filter_validator.ts +21 -1
  244. package/src/hooks/authorize_utility_call.ts +40 -0
  245. package/src/hooks/execution_hooks.ts +48 -0
  246. package/src/hooks/index.ts +7 -0
  247. package/src/job_coordinator/job_coordinator.ts +4 -3
  248. package/src/logs/log_service.ts +88 -141
  249. package/src/messages/message_context_service.ts +45 -0
  250. package/src/notes/note_service.ts +124 -91
  251. package/src/notes_filter.ts +24 -0
  252. package/src/oracle_version.ts +20 -10
  253. package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
  254. package/src/private_kernel/hints/index.ts +1 -1
  255. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
  256. package/src/private_kernel/hints/test_utils.ts +325 -0
  257. package/src/private_kernel/private_kernel_execution_prover.ts +53 -22
  258. package/src/private_kernel/private_kernel_oracle.ts +36 -26
  259. package/src/pxe.ts +351 -168
  260. package/src/storage/address_store/address_store.ts +15 -15
  261. package/src/storage/anchor_block_store/anchor_block_store.ts +9 -1
  262. package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +22 -0
  263. package/src/storage/backwards_compatibility_tests/__snapshots__/AnchorBlockStore.json +3 -0
  264. package/src/storage/backwards_compatibility_tests/__snapshots__/CapsuleStore.json +16 -0
  265. package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +28 -0
  266. package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +52 -0
  267. package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +42 -0
  268. package/src/storage/backwards_compatibility_tests/__snapshots__/NoteStore.json +36 -0
  269. package/src/storage/backwards_compatibility_tests/__snapshots__/PrivateEventStore.json +44 -0
  270. package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +18 -0
  271. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderAddressBookStore.json +16 -0
  272. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +22 -0
  273. package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +97 -0
  274. package/src/storage/backwards_compatibility_tests/kv_store_snapshot.ts +122 -0
  275. package/src/storage/backwards_compatibility_tests/schema_tests.ts +707 -0
  276. package/src/storage/backwards_compatibility_tests/store_spy.ts +73 -0
  277. package/src/storage/capsule_store/capsule_service.ts +90 -0
  278. package/src/storage/capsule_store/capsule_store.ts +52 -34
  279. package/src/storage/capsule_store/index.ts +1 -0
  280. package/src/storage/contract_store/contract_store.ts +193 -81
  281. package/src/storage/metadata.ts +1 -1
  282. package/src/storage/note_store/note_store.ts +166 -132
  283. package/src/storage/open_pxe_stores.ts +47 -0
  284. package/src/storage/private_event_store/private_event_store.ts +106 -81
  285. package/src/storage/private_event_store/stored_private_event.ts +3 -3
  286. package/src/storage/tagging_store/recipient_tagging_store.ts +38 -24
  287. package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
  288. package/src/storage/tagging_store/sender_tagging_store.ts +287 -156
  289. package/src/tagging/get_all_logs_by_tags.ts +35 -7
  290. package/src/tagging/index.ts +5 -4
  291. package/src/tagging/persist_sender_tagging_index_ranges.ts +57 -0
  292. package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +236 -0
  293. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
  294. package/src/tagging/reconcile_tagging_index_ranges.ts +102 -0
  295. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +54 -18
  296. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +44 -14
  297. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +30 -29
  298. package/dest/contract_sync/index.d.ts +0 -23
  299. package/dest/contract_sync/index.d.ts.map +0 -1
  300. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
  301. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
  302. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +0 -15
  303. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +0 -1
  304. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +0 -99
  305. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +0 -15
  306. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +0 -1
  307. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +0 -32
  308. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +0 -143
  309. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +0 -49
@@ -1,22 +1,52 @@
1
1
  import { TxStatus } from '@aztec/stdlib/tx';
2
+ export const EMPTY_STATUS_CHANGE = {
3
+ txHashesToFinalize: [],
4
+ txHashesToDrop: [],
5
+ txHashesWithExecutionReverted: []
6
+ };
7
+ /** Concatenates two status changes field-by-field. */ export function mergeStatusChanges(a, b) {
8
+ return {
9
+ txHashesToFinalize: [
10
+ ...a.txHashesToFinalize,
11
+ ...b.txHashesToFinalize
12
+ ],
13
+ txHashesToDrop: [
14
+ ...a.txHashesToDrop,
15
+ ...b.txHashesToDrop
16
+ ],
17
+ txHashesWithExecutionReverted: [
18
+ ...a.txHashesWithExecutionReverted,
19
+ ...b.txHashesWithExecutionReverted
20
+ ]
21
+ };
22
+ }
2
23
  /**
3
- * Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized or
4
- * dropped.
24
+ * Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized,
25
+ * dropped, or execution-reverted (but mined).
5
26
  */ export async function getStatusChangeOfPending(pending, aztecNode) {
6
27
  // Get receipts for all pending tx hashes.
7
28
  const receipts = await Promise.all(pending.map((pendingTxHash)=>aztecNode.getTxReceipt(pendingTxHash)));
8
29
  const txHashesToFinalize = [];
9
30
  const txHashesToDrop = [];
31
+ const txHashesWithExecutionReverted = [];
10
32
  for(let i = 0; i < receipts.length; i++){
11
33
  const receipt = receipts[i];
12
34
  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.
35
+ if (receipt.status === TxStatus.FINALIZED) {
36
+ // Tx has been included in a block and the corresponding block is finalized
37
+ if (receipt.hasExecutionSucceeded()) {
38
+ // No part of execution reverted - we just finalize all the indexes.
39
+ txHashesToFinalize.push(txHash);
40
+ } else if (receipt.hasExecutionReverted()) {
41
+ // Tx was mined but execution reverted (app logic, teardown, or both). Some logs from the non-revertible
42
+ // phase may still be onchain. We check which tags made it onchain and finalize those; drop the rest.
43
+ txHashesWithExecutionReverted.push(txHash);
44
+ } else {
45
+ // Defensive check - this branch should never be triggered
46
+ throw new Error('Both hasExecutionSucceeded and hasExecutionReverted on the receipt returned false. This should never happen and it implies a bug. Please open an issue.');
47
+ }
48
+ } else if (receipt.isDropped()) {
49
+ // Tx was dropped from the mempool --> we drop the corresponding pending indexes.
20
50
  txHashesToDrop.push(txHash);
21
51
  } else {
22
52
  // Tx is still pending, not yet finalized, or was mined successfully but not yet finalized --> we don't do anything.
@@ -24,6 +54,7 @@ import { TxStatus } from '@aztec/stdlib/tx';
24
54
  }
25
55
  return {
26
56
  txHashesToFinalize,
27
- txHashesToDrop
57
+ txHashesToDrop,
58
+ txHashesWithExecutionReverted
28
59
  };
29
60
  }
@@ -1,21 +1,19 @@
1
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
- import type { L2BlockHash } from '@aztec/stdlib/block';
1
+ import type { BlockHash } from '@aztec/stdlib/block';
3
2
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
4
- import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
3
+ import type { ExtendedDirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
5
4
  import type { SenderTaggingStore } from '../../../storage/tagging_store/sender_tagging_store.js';
6
5
  /**
7
6
  * Loads tagging indexes from the Aztec node and stores them in the tagging data provider.
8
7
  * @remarks This function is one of two places by which a pending index can get to the tagging data provider. The other
9
8
  * 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.
9
+ * @param extendedSecret - The extended directional app tagging secret that's unique for (sender, recipient, app) tuple.
13
10
  * @param start - The starting index (inclusive) of the window to process.
14
11
  * @param end - The ending index (exclusive) of the window to process.
15
12
  * @param aztecNode - The Aztec node instance to query for logs.
16
13
  * @param taggingStore - The data provider to store pending indexes.
14
+ * @param anchorBlockHash - Hash of a block to use as reference block when querying node.
17
15
  * @param jobId - Job identifier, used to keep writes in-memory until they can be persisted in a data integrity
18
16
  * preserving way.
19
17
  */
20
- export declare function loadAndStoreNewTaggingIndexes(secret: DirectionalAppTaggingSecret, app: AztecAddress, start: number, end: number, aztecNode: AztecNode, taggingStore: SenderTaggingStore, anchorBlockHash: L2BlockHash, jobId: string): Promise<void>;
21
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvc2VuZGVyX3N5bmMvdXRpbHMvbG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUN2RCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSwyQkFBMkIsRUFBVSxNQUFNLG9CQUFvQixDQUFDO0FBSTlFLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sd0RBQXdELENBQUM7QUFHakc7Ozs7Ozs7Ozs7Ozs7R0FhRztBQUNILHdCQUFzQiw2QkFBNkIsQ0FDakQsTUFBTSxFQUFFLDJCQUEyQixFQUNuQyxHQUFHLEVBQUUsWUFBWSxFQUNqQixLQUFLLEVBQUUsTUFBTSxFQUNiLEdBQUcsRUFBRSxNQUFNLEVBQ1gsU0FBUyxFQUFFLFNBQVMsRUFDcEIsWUFBWSxFQUFFLGtCQUFrQixFQUNoQyxlQUFlLEVBQUUsV0FBVyxFQUM1QixLQUFLLEVBQUUsTUFBTSxpQkFrQmQifQ==
18
+ export declare function loadAndStoreNewTaggingIndexes(extendedSecret: ExtendedDirectionalAppTaggingSecret, start: number, end: number, aztecNode: AztecNode, taggingStore: SenderTaggingStore, anchorBlockHash: BlockHash, jobId: string): Promise<void>;
19
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvc2VuZGVyX3N5bmMvdXRpbHMvbG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNyRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSxtQ0FBbUMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBSTlFLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sd0RBQXdELENBQUM7QUFHakc7Ozs7Ozs7Ozs7OztHQVlHO0FBQ0gsd0JBQXNCLDZCQUE2QixDQUNqRCxjQUFjLEVBQUUsbUNBQW1DLEVBQ25ELEtBQUssRUFBRSxNQUFNLEVBQ2IsR0FBRyxFQUFFLE1BQU0sRUFDWCxTQUFTLEVBQUUsU0FBUyxFQUNwQixZQUFZLEVBQUUsa0JBQWtCLEVBQ2hDLGVBQWUsRUFBRSxTQUFTLEVBQzFCLEtBQUssRUFBRSxNQUFNLGlCQWdCZCJ9
@@ -1 +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,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,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,WAAW,EAC5B,KAAK,EAAE,MAAM,iBAkBd"}
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,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,oBAAoB,CAAC;AAI9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAGjG;;;;;;;;;;;;GAYG;AACH,wBAAsB,6BAA6B,CACjD,cAAc,EAAE,mCAAmC,EACnD,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,kBAAkB,EAChC,eAAe,EAAE,SAAS,EAC1B,KAAK,EAAE,MAAM,iBAgBd"}
@@ -1,37 +1,39 @@
1
- import { SiloedTag, Tag } from '@aztec/stdlib/logs';
1
+ import { SiloedTag } from '@aztec/stdlib/logs';
2
2
  import { TxHash } from '@aztec/stdlib/tx';
3
3
  import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
4
4
  /**
5
5
  * Loads tagging indexes from the Aztec node and stores them in the tagging data provider.
6
6
  * @remarks This function is one of two places by which a pending index can get to the tagging data provider. The other
7
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.
8
+ * @param extendedSecret - The extended directional app tagging secret that's unique for (sender, recipient, app) tuple.
11
9
  * @param start - The starting index (inclusive) of the window to process.
12
10
  * @param end - The ending index (exclusive) of the window to process.
13
11
  * @param aztecNode - The Aztec node instance to query for logs.
14
12
  * @param taggingStore - The data provider to store pending indexes.
13
+ * @param anchorBlockHash - Hash of a block to use as reference block when querying node.
15
14
  * @param jobId - Job identifier, used to keep writes in-memory until they can be persisted in a data integrity
16
15
  * preserving way.
17
- */ export async function loadAndStoreNewTaggingIndexes(secret, app, start, end, aztecNode, taggingStore, anchorBlockHash, jobId) {
16
+ */ export async function loadAndStoreNewTaggingIndexes(extendedSecret, start, end, aztecNode, taggingStore, anchorBlockHash, jobId) {
18
17
  // We compute the tags for the current window of indexes
19
- const preTagsForWindow = Array(end - start).fill(0).map((_, i)=>({
20
- secret,
18
+ const siloedTagsForWindow = await Promise.all(Array.from({
19
+ length: end - start
20
+ }, (_, i)=>SiloedTag.compute({
21
+ extendedSecret,
21
22
  index: start + i
22
- }));
23
- const siloedTagsForWindow = await Promise.all(preTagsForWindow.map(async (preTag)=>SiloedTag.compute(await Tag.compute(preTag), app)));
23
+ })));
24
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()){
25
+ const txIndexesMap = getTxIndexesMap(txsForTags, start, siloedTagsForWindow.length);
26
+ // Now we iterate over the map, construct the tagging index ranges and store them in the db.
27
+ for (const [txHashStr, indexes] of txIndexesMap.entries()){
28
28
  const txHash = TxHash.fromString(txHashStr);
29
- await taggingStore.storePendingIndexes([
29
+ const ranges = [
30
30
  {
31
- secret,
32
- index: highestIndex
31
+ extendedSecret,
32
+ lowestIndex: Math.min(...indexes),
33
+ highestIndex: Math.max(...indexes)
33
34
  }
34
- ], txHash, jobId);
35
+ ];
36
+ await taggingStore.storePendingIndexes(ranges, txHash, jobId);
35
37
  }
36
38
  }
37
39
  // Returns txs that used the given tags. A tag might have been used in multiple txs and for this reason we return
@@ -42,19 +44,29 @@ async function getTxsContainingTags(tags, aztecNode, anchorBlockHash) {
42
44
  const allLogs = await getAllPrivateLogsByTags(aztecNode, tags, anchorBlockHash);
43
45
  return allLogs.map((logs)=>logs.map((log)=>log.txHash));
44
46
  }
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}`);
47
+ // Returns a map of txHash to all indexes for that txHash.
48
+ function getTxIndexesMap(txHashesForTags, start, count) {
49
+ if (txHashesForTags.length !== count) {
50
+ throw new Error(`Number of tx hashes arrays does not match number of tags. ${txHashesForTags.length} !== ${count}`);
49
51
  }
50
- const highestIndexMap = new Map();
52
+ const indexesMap = new Map();
53
+ // Iterate over indexes
51
54
  for(let i = 0; i < txHashesForTags.length; i++){
52
- const taggingIndex = preTagsForWindow[i].index;
55
+ const taggingIndex = start + i;
53
56
  const txHashesForTag = txHashesForTags[i];
57
+ // iterate over tx hashes that used that index (tag)
54
58
  for (const txHash of txHashesForTag){
55
59
  const key = txHash.toString();
56
- highestIndexMap.set(key, Math.max(highestIndexMap.get(key) ?? 0, taggingIndex));
60
+ const existing = indexesMap.get(key);
61
+ // Add the index to the tx's indexes
62
+ if (existing) {
63
+ existing.push(taggingIndex);
64
+ } else {
65
+ indexesMap.set(key, [
66
+ taggingIndex
67
+ ]);
68
+ }
57
69
  }
58
70
  }
59
- return highestIndexMap;
71
+ return indexesMap;
60
72
  }
package/package.json CHANGED
@@ -1,7 +1,16 @@
1
1
  {
2
2
  "name": "@aztec/pxe",
3
- "version": "0.0.1-commit.fffb133c",
3
+ "version": "0.0.1-dev",
4
4
  "type": "module",
5
+ "typedocOptions": {
6
+ "entryPoints": [
7
+ "./src/entrypoints/server/index.ts",
8
+ "./src/entrypoints/client/lazy/index.ts",
9
+ "./src/config/index.ts"
10
+ ],
11
+ "name": "PXE",
12
+ "tsconfig": "./tsconfig.json"
13
+ },
5
14
  "exports": {
6
15
  "./server": "./dest/entrypoints/server/index.js",
7
16
  "./client/lazy": "./dest/entrypoints/client/lazy/index.js",
@@ -61,19 +70,19 @@
61
70
  ]
62
71
  },
63
72
  "dependencies": {
64
- "@aztec/bb-prover": "0.0.1-commit.fffb133c",
65
- "@aztec/bb.js": "0.0.1-commit.fffb133c",
66
- "@aztec/builder": "0.0.1-commit.fffb133c",
67
- "@aztec/constants": "0.0.1-commit.fffb133c",
68
- "@aztec/ethereum": "0.0.1-commit.fffb133c",
69
- "@aztec/foundation": "0.0.1-commit.fffb133c",
70
- "@aztec/key-store": "0.0.1-commit.fffb133c",
71
- "@aztec/kv-store": "0.0.1-commit.fffb133c",
72
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.fffb133c",
73
- "@aztec/noir-types": "0.0.1-commit.fffb133c",
74
- "@aztec/protocol-contracts": "0.0.1-commit.fffb133c",
75
- "@aztec/simulator": "0.0.1-commit.fffb133c",
76
- "@aztec/stdlib": "0.0.1-commit.fffb133c",
73
+ "@aztec/bb-prover": "0.0.1-dev",
74
+ "@aztec/bb.js": "0.0.1-dev",
75
+ "@aztec/builder": "0.0.1-dev",
76
+ "@aztec/constants": "0.0.1-dev",
77
+ "@aztec/ethereum": "0.0.1-dev",
78
+ "@aztec/foundation": "0.0.1-dev",
79
+ "@aztec/key-store": "0.0.1-dev",
80
+ "@aztec/kv-store": "0.0.1-dev",
81
+ "@aztec/noir-protocol-circuits-types": "0.0.1-dev",
82
+ "@aztec/noir-types": "0.0.1-dev",
83
+ "@aztec/protocol-contracts": "0.0.1-dev",
84
+ "@aztec/simulator": "0.0.1-dev",
85
+ "@aztec/stdlib": "0.0.1-dev",
77
86
  "koa": "^2.16.1",
78
87
  "koa-router": "^13.1.1",
79
88
  "lodash.omit": "^4.5.0",
@@ -82,8 +91,8 @@
82
91
  "viem": "npm:@aztec/viem@2.38.2"
83
92
  },
84
93
  "devDependencies": {
85
- "@aztec/merkle-tree": "0.0.1-commit.fffb133c",
86
- "@aztec/noir-test-contracts.js": "0.0.1-commit.fffb133c",
94
+ "@aztec/merkle-tree": "0.0.1-dev",
95
+ "@aztec/noir-test-contracts.js": "0.0.1-dev",
87
96
  "@jest/globals": "^30.0.0",
88
97
  "@types/jest": "^30.0.0",
89
98
  "@types/lodash.omit": "^4.5.7",
@@ -91,6 +100,7 @@
91
100
  "@types/node": "^22.15.17",
92
101
  "@typescript/native-preview": "7.0.0-dev.20260113.1",
93
102
  "jest": "^30.0.0",
103
+ "jest-file-snapshot": "^0.7.0",
94
104
  "jest-mock-extended": "^4.0.0",
95
105
  "lodash.times": "^4.3.2",
96
106
  "ts-node": "^10.9.1",
@@ -13,10 +13,11 @@ import { ORACLE_INTERFACE_HASH } from '../oracle_version.js';
13
13
  *
14
14
  * The Oracle interface needs to be versioned to ensure compatibility between Aztec.nr and PXE. This function computes
15
15
  * a hash of the Oracle interface and compares it against a known hash. If they don't match, it means the interface has
16
- * changed and the ORACLE_VERSION constant needs to be incremented and the ORACLE_INTERFACE_HASH constant needs to be
17
- * updated.
16
+ * changed and the oracle version needs to be bumped:
17
+ * - If the change is backward-breaking (e.g. removing/renaming an oracle), bump ORACLE_VERSION_MAJOR.
18
+ * - If the change is an oracle addition (non-breaking), bump ORACLE_VERSION_MINOR.
18
19
  *
19
- * TODO(#16581): The following only takes into consideration changes to the oracles defined in Oracle.ts and omits TXE
20
+ * TODO(F-667): The following only takes into consideration changes to the oracles defined in Oracle.ts and omits TXE
20
21
  * oracles. Ensure this checks TXE oracles as well. This hasn't been implemented yet since we don't have a clean TXE
21
22
  * oracle interface like we do in PXE (i.e., there is no single Oracle class that contains only the oracles).
22
23
  */
@@ -26,9 +27,8 @@ function assertOracleInterfaceMatches(): void {
26
27
  // We use keccak256 here just because we already have it in the dependencies.
27
28
  const oracleInterfaceHash = keccak256String(oracleInterfaceSignature);
28
29
  if (oracleInterfaceHash !== ORACLE_INTERFACE_HASH) {
29
- // This check exists only to notify you when you need to update the ORACLE_VERSION constant.
30
30
  throw new Error(
31
- `The Oracle interface has changed, which implies a breaking change in the aztec.nr/PXE oracle interface. Update ORACLE_INTERFACE_HASH to ${oracleInterfaceHash} and bump ORACLE_VERSION in pxe/src/oracle_version.ts.`,
31
+ `The Oracle interface has changed. Update ORACLE_INTERFACE_HASH to ${oracleInterfaceHash} in pxe/src/oracle_version.ts and bump the oracle version (ORACLE_VERSION_MAJOR for breaking changes, ORACLE_VERSION_MINOR for oracle additions).`,
32
32
  );
33
33
  }
34
34
  }
@@ -1,17 +1,14 @@
1
1
  import { BlockNumber } from '@aztec/foundation/branded-types';
2
- import { type Logger, createLogger } from '@aztec/foundation/log';
2
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
3
+ import { SerialQueue } from '@aztec/foundation/queue';
3
4
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
4
5
  import type { L2TipsKVStore } from '@aztec/kv-store/stores';
5
- import {
6
- L2BlockHash,
7
- L2BlockStream,
8
- type L2BlockStreamEvent,
9
- type L2BlockStreamEventHandler,
10
- } from '@aztec/stdlib/block';
6
+ import { BlockHash, L2BlockStream, type L2BlockStreamEvent, type L2BlockStreamEventHandler } from '@aztec/stdlib/block';
11
7
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
12
8
  import type { BlockHeader } from '@aztec/stdlib/tx';
13
9
 
14
10
  import type { BlockSynchronizerConfig } from '../config/index.js';
11
+ import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
15
12
  import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
16
13
  import type { NoteStore } from '../storage/note_store/note_store.js';
17
14
  import type { PrivateEventStore } from '../storage/private_event_store/private_event_store.js';
@@ -24,6 +21,7 @@ import type { PrivateEventStore } from '../storage/private_event_store/private_e
24
21
  export class BlockSynchronizer implements L2BlockStreamEventHandler {
25
22
  private log: Logger;
26
23
  private isSyncing: Promise<void> | undefined;
24
+ private readonly eventQueue = new SerialQueue();
27
25
  protected readonly blockStream: L2BlockStream;
28
26
 
29
27
  constructor(
@@ -33,27 +31,36 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
33
31
  private noteStore: NoteStore,
34
32
  private privateEventStore: PrivateEventStore,
35
33
  private l2TipsStore: L2TipsKVStore,
34
+ private contractSyncService: ContractSyncService,
36
35
  private config: Partial<BlockSynchronizerConfig> = {},
37
- loggerOrSuffix?: string | Logger,
36
+ bindings?: LoggerBindings,
38
37
  ) {
39
- this.log =
40
- !loggerOrSuffix || typeof loggerOrSuffix === 'string'
41
- ? createLogger(loggerOrSuffix ? `pxe:block_synchronizer:${loggerOrSuffix}` : `pxe:block_synchronizer`)
42
- : loggerOrSuffix;
38
+ this.log = createLogger('pxe:block_synchronizer', bindings);
43
39
  this.blockStream = this.createBlockStream(config);
40
+ this.eventQueue.start();
44
41
  }
45
42
 
46
43
  protected createBlockStream(config: Partial<BlockSynchronizerConfig>): L2BlockStream {
47
- return new L2BlockStream(this.node, this.l2TipsStore, this, createLogger('pxe:block_stream'), {
48
- batchSize: config.l2BlockBatchSize,
49
- // Skipping finalized blocks makes us sync much faster - we only need to download blocks other than the latest one
50
- // in order to detect reorgs, and there can be no reorgs on finalized block, making this safe.
51
- skipFinalized: true,
52
- });
44
+ return new L2BlockStream(
45
+ this.node,
46
+ this.l2TipsStore,
47
+ this,
48
+ createLogger('pxe:block_stream', this.log.getBindings()),
49
+ {
50
+ batchSize: config.l2BlockBatchSize,
51
+ // Skipping finalized blocks makes us sync much faster - we only need to download blocks other than the latest one
52
+ // in order to detect reorgs, and there can be no reorgs on finalized block, making this safe.
53
+ skipFinalized: true,
54
+ },
55
+ );
53
56
  }
54
57
 
55
- /** Handle events emitted by the block stream. */
56
- public async handleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void> {
58
+ /** Handle events emitted by the block stream. Serialized to prevent concurrent mutations to anchor state. */
59
+ public handleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void> {
60
+ return this.eventQueue.put(() => this.doHandleBlockStreamEvent(event));
61
+ }
62
+
63
+ private async doHandleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void> {
57
64
  await this.l2TipsStore.handleBlockStreamEvent(event);
58
65
 
59
66
  switch (event.type) {
@@ -77,6 +84,8 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
77
84
  const blockHeader = await this.node.getBlockHeader(BlockNumber(event.block.number));
78
85
  if (blockHeader) {
79
86
  await this.updateAnchorBlockHeader(blockHeader);
87
+ } else {
88
+ this.log.warn(`Block header not found for proven block ${event.block.number}, skipping anchor update`);
80
89
  }
81
90
  }
82
91
  break;
@@ -86,6 +95,8 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
86
95
  const blockHeader = await this.node.getBlockHeader(BlockNumber(event.block.number));
87
96
  if (blockHeader) {
88
97
  await this.updateAnchorBlockHeader(blockHeader);
98
+ } else {
99
+ this.log.warn(`Block header not found for finalized block ${event.block.number}, skipping anchor update`);
89
100
  }
90
101
  }
91
102
  break;
@@ -106,7 +117,7 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
106
117
  // Note that the following is not necessarily the anchor block that will be used in the transaction - if
107
118
  // the chain has already moved past the reorg, we'll also see blocks-added events that will push the anchor
108
119
  // forward.
109
- const newAnchorBlockHeader = await this.node.getBlockHeader(L2BlockHash.fromString(event.block.hash));
120
+ const newAnchorBlockHeader = await this.node.getBlockHeader(BlockHash.fromString(event.block.hash));
110
121
 
111
122
  if (!newAnchorBlockHeader) {
112
123
  throw new Error(
@@ -127,6 +138,10 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
127
138
 
128
139
  /** Updates the anchor block header to the target block */
129
140
  private async updateAnchorBlockHeader(blockHeader: BlockHeader) {
141
+ // Whenever the anchor block header is updated, we need to synchronize the private state of contracts again.
142
+ // Therefore, we clear the contract synchronization cache here such that the sync is re-triggered upon new
143
+ // execution.
144
+ this.contractSyncService.wipe();
130
145
  this.log.verbose(`Updated pxe last block to ${blockHeader.getBlockNumber()}`, blockHeader.toInspect());
131
146
  await this.anchorBlockStore.setHeader(blockHeader);
132
147
  }
@@ -148,6 +163,8 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
148
163
  }
149
164
 
150
165
  this.log.debug(`Syncing PXE with the node`);
166
+ // Capture the promise locally so we always await the exact promise we created, even if this.isSyncing is modified
167
+ // between assignment and await (e.g. due to future refactors introducing a yield point).
151
168
  const isSyncing = this.doSync();
152
169
  this.isSyncing = isSyncing;
153
170
  try {
@@ -157,6 +174,13 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
157
174
  }
158
175
  }
159
176
 
177
+ /** Stops the block synchronizer, waiting for any in-progress sync and queued events to complete. */
178
+ public async stop() {
179
+ await this.isSyncing;
180
+ await this.blockStream.stop();
181
+ await this.eventQueue.end();
182
+ }
183
+
160
184
  private async doSync() {
161
185
  let currentHeader;
162
186
 
@@ -1,3 +1,3 @@
1
1
  export function getPackageInfo() {
2
- return { version: '4.0.0', name: '@aztec/pxe' };
2
+ return { version: '4.4.0', name: '@aztec/pxe' };
3
3
  }