@aztec/pxe 0.0.1-commit.03f7ef2 → 0.0.1-commit.04d373f

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 (488) hide show
  1. package/dest/bin/check_oracle_version.d.ts +12 -2
  2. package/dest/bin/check_oracle_version.d.ts.map +1 -1
  3. package/dest/bin/check_oracle_version.js +32 -26
  4. package/dest/bin/index.d.ts +2 -0
  5. package/dest/bin/index.d.ts.map +1 -0
  6. package/dest/bin/index.js +1 -0
  7. package/dest/block_synchronizer/block_stream_source.d.ts +10 -0
  8. package/dest/block_synchronizer/block_stream_source.d.ts.map +1 -0
  9. package/dest/block_synchronizer/block_stream_source.js +62 -0
  10. package/dest/block_synchronizer/block_synchronizer.d.ts +22 -12
  11. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  12. package/dest/block_synchronizer/block_synchronizer.js +101 -35
  13. package/dest/config/index.d.ts +10 -2
  14. package/dest/config/index.d.ts.map +1 -1
  15. package/dest/config/index.js +17 -2
  16. package/dest/config/package_info.js +1 -1
  17. package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
  18. package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
  19. package/dest/contract_function_simulator/benchmarked_node.js +77 -0
  20. package/dest/contract_function_simulator/contract_function_simulator.d.ts +77 -41
  21. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  22. package/dest/contract_function_simulator/contract_function_simulator.js +251 -96
  23. package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
  24. package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
  25. package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
  26. package/dest/contract_function_simulator/execution_note_cache.d.ts +18 -9
  27. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  28. package/dest/contract_function_simulator/execution_note_cache.js +45 -28
  29. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -11
  30. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  31. package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -15
  32. package/dest/contract_function_simulator/index.d.ts +5 -2
  33. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  34. package/dest/contract_function_simulator/index.js +4 -1
  35. package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts +48 -0
  36. package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts.map +1 -0
  37. package/dest/contract_function_simulator/noir-structs/bounded_vec.js +45 -0
  38. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +6 -7
  39. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  40. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +12 -10
  41. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +13 -3
  42. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
  43. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +35 -4
  44. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
  45. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  46. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +2 -4
  47. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +5 -8
  48. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  49. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +7 -11
  50. package/dest/contract_function_simulator/noir-structs/option.d.ts +61 -0
  51. package/dest/contract_function_simulator/noir-structs/option.d.ts.map +1 -0
  52. package/dest/contract_function_simulator/noir-structs/option.js +62 -0
  53. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
  54. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
  55. package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
  56. package/dest/contract_function_simulator/oracle/interfaces.d.ts +70 -50
  57. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  58. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -1
  59. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  60. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +7 -7
  61. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
  62. package/dest/contract_function_simulator/oracle/note_packing_utils.js +10 -10
  63. package/dest/contract_function_simulator/oracle/oracle.d.ts +74 -43
  64. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  65. package/dest/contract_function_simulator/oracle/oracle.js +471 -264
  66. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +147 -0
  67. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -0
  68. package/dest/contract_function_simulator/oracle/oracle_registry.js +1199 -0
  69. package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -26
  70. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  71. package/dest/contract_function_simulator/oracle/private_execution.js +5 -39
  72. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +74 -100
  73. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  74. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +168 -139
  75. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +169 -90
  76. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  77. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +468 -193
  78. package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
  79. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
  80. package/dest/contract_function_simulator/pick_notes.js +20 -3
  81. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +4 -4
  82. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
  83. package/dest/contract_function_simulator/proxied_contract_data_source.js +39 -68
  84. package/dest/contract_logging.d.ts +27 -0
  85. package/dest/contract_logging.d.ts.map +1 -0
  86. package/dest/contract_logging.js +38 -0
  87. package/dest/contract_sync/contract_sync_service.d.ts +42 -0
  88. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
  89. package/dest/contract_sync/contract_sync_service.js +135 -0
  90. package/dest/contract_sync/helpers.d.ts +27 -0
  91. package/dest/contract_sync/helpers.d.ts.map +1 -0
  92. package/dest/contract_sync/helpers.js +53 -0
  93. package/dest/debug/pxe_debug_utils.d.ts +21 -12
  94. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  95. package/dest/debug/pxe_debug_utils.js +24 -19
  96. package/dest/entrypoints/client/bundle/index.d.ts +3 -1
  97. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  98. package/dest/entrypoints/client/bundle/index.js +2 -0
  99. package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
  100. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  101. package/dest/entrypoints/client/bundle/utils.js +41 -10
  102. package/dest/entrypoints/client/lazy/index.d.ts +3 -1
  103. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  104. package/dest/entrypoints/client/lazy/index.js +2 -0
  105. package/dest/entrypoints/client/lazy/utils.d.ts +3 -3
  106. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  107. package/dest/entrypoints/client/lazy/utils.js +42 -11
  108. package/dest/entrypoints/pxe_creation_options.d.ts +13 -3
  109. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  110. package/dest/entrypoints/pxe_creation_options.js +3 -1
  111. package/dest/entrypoints/server/index.d.ts +6 -2
  112. package/dest/entrypoints/server/index.d.ts.map +1 -1
  113. package/dest/entrypoints/server/index.js +5 -1
  114. package/dest/entrypoints/server/utils.d.ts +4 -3
  115. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  116. package/dest/entrypoints/server/utils.js +49 -18
  117. package/dest/error_enriching.d.ts +4 -4
  118. package/dest/error_enriching.d.ts.map +1 -1
  119. package/dest/error_enriching.js +6 -6
  120. package/dest/events/event_service.d.ts +19 -10
  121. package/dest/events/event_service.d.ts.map +1 -1
  122. package/dest/events/event_service.js +60 -30
  123. package/dest/events/private_event_filter_validator.d.ts +7 -6
  124. package/dest/events/private_event_filter_validator.d.ts.map +1 -1
  125. package/dest/events/private_event_filter_validator.js +20 -6
  126. package/dest/hooks/authorize_utility_call.d.ts +41 -0
  127. package/dest/hooks/authorize_utility_call.d.ts.map +1 -0
  128. package/dest/hooks/authorize_utility_call.js +4 -0
  129. package/dest/hooks/execution_hooks.d.ts +42 -0
  130. package/dest/hooks/execution_hooks.d.ts.map +1 -0
  131. package/dest/hooks/execution_hooks.js +9 -0
  132. package/dest/hooks/index.d.ts +4 -0
  133. package/dest/hooks/index.d.ts.map +1 -0
  134. package/dest/hooks/index.js +1 -0
  135. package/dest/job_coordinator/job_coordinator.d.ts +75 -0
  136. package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
  137. package/dest/job_coordinator/job_coordinator.js +94 -0
  138. package/dest/logs/log_service.d.ts +21 -35
  139. package/dest/logs/log_service.d.ts.map +1 -1
  140. package/dest/logs/log_service.js +144 -215
  141. package/dest/messages/message_context_service.d.ts +17 -0
  142. package/dest/messages/message_context_service.d.ts.map +1 -0
  143. package/dest/messages/message_context_service.js +38 -0
  144. package/dest/notes/note_service.d.ts +34 -12
  145. package/dest/notes/note_service.d.ts.map +1 -1
  146. package/dest/notes/note_service.js +102 -82
  147. package/dest/notes_filter.d.ts +24 -0
  148. package/dest/notes_filter.d.ts.map +1 -0
  149. package/dest/notes_filter.js +4 -0
  150. package/dest/oracle_version.d.ts +4 -3
  151. package/dest/oracle_version.d.ts.map +1 -1
  152. package/dest/oracle_version.js +20 -9
  153. package/dest/private_kernel/batch_planner.d.ts +47 -0
  154. package/dest/private_kernel/batch_planner.d.ts.map +1 -0
  155. package/dest/private_kernel/batch_planner.js +104 -0
  156. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
  157. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
  158. package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
  159. package/dest/private_kernel/hints/index.d.ts +3 -3
  160. package/dest/private_kernel/hints/index.d.ts.map +1 -1
  161. package/dest/private_kernel/hints/index.js +2 -2
  162. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +29 -0
  163. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
  164. package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +142 -75
  165. package/dest/private_kernel/hints/test_utils.d.ts +122 -0
  166. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
  167. package/dest/private_kernel/hints/test_utils.js +202 -0
  168. package/dest/private_kernel/private_kernel_execution_prover.d.ts +7 -2
  169. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  170. package/dest/private_kernel/private_kernel_execution_prover.js +169 -69
  171. package/dest/private_kernel/private_kernel_oracle.d.ts +29 -29
  172. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  173. package/dest/private_kernel/private_kernel_oracle.js +96 -2
  174. package/dest/pxe.d.ts +136 -67
  175. package/dest/pxe.d.ts.map +1 -1
  176. package/dest/pxe.js +314 -231
  177. package/dest/storage/address_store/address_store.d.ts +11 -0
  178. package/dest/storage/address_store/address_store.d.ts.map +1 -0
  179. package/dest/storage/{address_data_provider/address_data_provider.js → address_store/address_store.js} +13 -12
  180. package/dest/storage/address_store/index.d.ts +2 -0
  181. package/dest/storage/address_store/index.d.ts.map +1 -0
  182. package/dest/storage/address_store/index.js +1 -0
  183. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +17 -0
  184. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
  185. package/dest/storage/anchor_block_store/anchor_block_store.js +26 -0
  186. package/dest/storage/anchor_block_store/index.d.ts +2 -0
  187. package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
  188. package/dest/storage/anchor_block_store/index.js +1 -0
  189. package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts +42 -0
  190. package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts.map +1 -0
  191. package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.js +93 -0
  192. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +15 -0
  193. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -0
  194. package/dest/storage/backwards_compatibility_tests/schema_tests.js +591 -0
  195. package/dest/storage/backwards_compatibility_tests/store_spy.d.ts +19 -0
  196. package/dest/storage/backwards_compatibility_tests/store_spy.d.ts.map +1 -0
  197. package/dest/storage/backwards_compatibility_tests/store_spy.js +63 -0
  198. package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
  199. package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
  200. package/dest/storage/capsule_store/capsule_service.js +50 -0
  201. package/dest/storage/capsule_store/capsule_store.d.ts +72 -0
  202. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
  203. package/dest/storage/capsule_store/capsule_store.js +261 -0
  204. package/dest/storage/capsule_store/index.d.ts +3 -0
  205. package/dest/storage/capsule_store/index.d.ts.map +1 -0
  206. package/dest/storage/capsule_store/index.js +2 -0
  207. package/dest/storage/contract_store/contract_store.d.ts +93 -0
  208. package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
  209. package/dest/storage/contract_store/contract_store.js +292 -0
  210. package/dest/storage/contract_store/index.d.ts +2 -0
  211. package/dest/storage/contract_store/index.d.ts.map +1 -0
  212. package/dest/storage/contract_store/index.js +1 -0
  213. package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.d.ts +1 -1
  214. package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
  215. package/dest/storage/index.d.ts +8 -8
  216. package/dest/storage/index.d.ts.map +1 -1
  217. package/dest/storage/index.js +7 -7
  218. package/dest/storage/metadata.d.ts +1 -1
  219. package/dest/storage/metadata.js +1 -1
  220. package/dest/storage/note_store/index.d.ts +3 -0
  221. package/dest/storage/note_store/index.d.ts.map +1 -0
  222. package/dest/storage/note_store/index.js +2 -0
  223. package/dest/storage/note_store/note_store.d.ts +83 -0
  224. package/dest/storage/note_store/note_store.d.ts.map +1 -0
  225. package/dest/storage/note_store/note_store.js +343 -0
  226. package/dest/storage/note_store/stored_note.d.ts +16 -0
  227. package/dest/storage/note_store/stored_note.d.ts.map +1 -0
  228. package/dest/storage/note_store/stored_note.js +43 -0
  229. package/dest/storage/open_pxe_stores.d.ts +33 -0
  230. package/dest/storage/open_pxe_stores.d.ts.map +1 -0
  231. package/dest/storage/open_pxe_stores.js +27 -0
  232. package/dest/storage/private_event_store/private_event_store.d.ts +91 -0
  233. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
  234. package/dest/storage/private_event_store/private_event_store.js +276 -0
  235. package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
  236. package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
  237. package/dest/storage/private_event_store/stored_private_event.js +56 -0
  238. package/dest/storage/tagging_store/index.d.ts +4 -0
  239. package/dest/storage/tagging_store/index.d.ts.map +1 -0
  240. package/dest/storage/tagging_store/index.js +3 -0
  241. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +28 -0
  242. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
  243. package/dest/storage/tagging_store/recipient_tagging_store.js +111 -0
  244. package/dest/storage/tagging_store/sender_address_book_store.d.ts +14 -0
  245. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -0
  246. package/dest/storage/tagging_store/sender_address_book_store.js +36 -0
  247. package/dest/storage/tagging_store/sender_tagging_store.d.ts +78 -0
  248. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
  249. package/dest/storage/tagging_store/sender_tagging_store.js +374 -0
  250. package/dest/tagging/constants.d.ts +2 -2
  251. package/dest/tagging/constants.d.ts.map +1 -1
  252. package/dest/tagging/constants.js +10 -3
  253. package/dest/tagging/get_all_logs_by_tags.d.ts +48 -0
  254. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
  255. package/dest/tagging/get_all_logs_by_tags.js +59 -0
  256. package/dest/tagging/index.d.ts +18 -5
  257. package/dest/tagging/index.d.ts.map +1 -1
  258. package/dest/tagging/index.js +16 -3
  259. package/dest/tagging/persist_sender_tagging_index_ranges.d.ts +29 -0
  260. package/dest/tagging/persist_sender_tagging_index_ranges.d.ts.map +1 -0
  261. package/dest/tagging/persist_sender_tagging_index_ranges.js +42 -0
  262. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +56 -0
  263. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -0
  264. package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +163 -0
  265. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +3 -3
  266. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -1
  267. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
  268. package/dest/tagging/reconcile_tagging_index_ranges.d.ts +36 -0
  269. package/dest/tagging/reconcile_tagging_index_ranges.d.ts.map +1 -0
  270. package/dest/tagging/reconcile_tagging_index_ranges.js +74 -0
  271. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +16 -0
  272. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -0
  273. package/dest/tagging/{sync → sender_sync}/sync_sender_tagging_indexes.js +35 -34
  274. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +17 -0
  275. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -0
  276. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +60 -0
  277. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +19 -0
  278. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
  279. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +72 -0
  280. package/package.json +31 -19
  281. package/src/bin/check_oracle_version.ts +42 -31
  282. package/src/bin/index.ts +1 -0
  283. package/src/block_synchronizer/block_stream_source.ts +81 -0
  284. package/src/block_synchronizer/block_synchronizer.ts +123 -48
  285. package/src/config/index.ts +21 -1
  286. package/src/config/package_info.ts +1 -1
  287. package/src/contract_function_simulator/benchmarked_node.ts +103 -0
  288. package/src/contract_function_simulator/contract_function_simulator.ts +431 -161
  289. package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
  290. package/src/contract_function_simulator/execution_note_cache.ts +44 -25
  291. package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -18
  292. package/src/contract_function_simulator/index.ts +4 -1
  293. package/src/contract_function_simulator/noir-structs/bounded_vec.ts +55 -0
  294. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +15 -10
  295. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +36 -3
  296. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -5
  297. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +6 -11
  298. package/src/contract_function_simulator/noir-structs/option.ts +69 -0
  299. package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
  300. package/src/contract_function_simulator/oracle/interfaces.ts +93 -70
  301. package/src/contract_function_simulator/oracle/note_packing_utils.ts +13 -13
  302. package/src/contract_function_simulator/oracle/oracle.ts +567 -461
  303. package/src/contract_function_simulator/oracle/oracle_registry.ts +904 -0
  304. package/src/contract_function_simulator/oracle/private_execution.ts +5 -73
  305. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +215 -239
  306. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +668 -261
  307. package/src/contract_function_simulator/pick_notes.ts +22 -3
  308. package/src/contract_function_simulator/proxied_contract_data_source.ts +47 -70
  309. package/src/contract_logging.ts +52 -0
  310. package/src/contract_sync/contract_sync_service.ts +189 -0
  311. package/src/contract_sync/helpers.ts +86 -0
  312. package/src/debug/pxe_debug_utils.ts +57 -20
  313. package/src/entrypoints/client/bundle/index.ts +2 -0
  314. package/src/entrypoints/client/bundle/utils.ts +31 -19
  315. package/src/entrypoints/client/lazy/index.ts +2 -0
  316. package/src/entrypoints/client/lazy/utils.ts +33 -21
  317. package/src/entrypoints/pxe_creation_options.ts +18 -2
  318. package/src/entrypoints/server/index.ts +5 -1
  319. package/src/entrypoints/server/utils.ts +46 -45
  320. package/src/error_enriching.ts +7 -15
  321. package/src/events/event_service.ts +83 -41
  322. package/src/events/private_event_filter_validator.ts +24 -6
  323. package/src/hooks/authorize_utility_call.ts +44 -0
  324. package/src/hooks/execution_hooks.ts +48 -0
  325. package/src/hooks/index.ts +7 -0
  326. package/src/job_coordinator/job_coordinator.ts +150 -0
  327. package/src/logs/log_service.ts +181 -313
  328. package/src/messages/message_context_service.ts +45 -0
  329. package/src/notes/note_service.ts +140 -110
  330. package/src/notes_filter.ts +24 -0
  331. package/src/oracle_version.ts +20 -9
  332. package/src/private_kernel/batch_planner.ts +169 -0
  333. package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
  334. package/src/private_kernel/hints/index.ts +2 -2
  335. package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +197 -139
  336. package/src/private_kernel/hints/test_utils.ts +318 -0
  337. package/src/private_kernel/private_kernel_execution_prover.ts +262 -96
  338. package/src/private_kernel/private_kernel_oracle.ts +129 -39
  339. package/src/pxe.ts +552 -310
  340. package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +16 -16
  341. package/src/storage/address_store/index.ts +1 -0
  342. package/src/storage/{anchor_block_data_provider/anchor_block_data_provider.ts → anchor_block_store/anchor_block_store.ts} +10 -2
  343. package/src/storage/anchor_block_store/index.ts +1 -0
  344. package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +22 -0
  345. package/src/storage/backwards_compatibility_tests/__snapshots__/AnchorBlockStore.json +3 -0
  346. package/src/storage/backwards_compatibility_tests/__snapshots__/CapsuleStore.json +16 -0
  347. package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +28 -0
  348. package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +52 -0
  349. package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +46 -0
  350. package/src/storage/backwards_compatibility_tests/__snapshots__/NoteStore.json +36 -0
  351. package/src/storage/backwards_compatibility_tests/__snapshots__/PrivateEventStore.json +44 -0
  352. package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +18 -0
  353. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderAddressBookStore.json +16 -0
  354. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +22 -0
  355. package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +97 -0
  356. package/src/storage/backwards_compatibility_tests/kv_store_snapshot.ts +122 -0
  357. package/src/storage/backwards_compatibility_tests/schema_tests.ts +712 -0
  358. package/src/storage/backwards_compatibility_tests/store_spy.ts +73 -0
  359. package/src/storage/capsule_store/capsule_service.ts +90 -0
  360. package/src/storage/capsule_store/capsule_store.ts +333 -0
  361. package/src/storage/capsule_store/index.ts +2 -0
  362. package/src/storage/contract_store/contract_store.ts +408 -0
  363. package/src/storage/contract_store/index.ts +1 -0
  364. package/src/storage/index.ts +7 -7
  365. package/src/storage/metadata.ts +1 -1
  366. package/src/storage/note_store/index.ts +2 -0
  367. package/src/storage/note_store/note_store.ts +415 -0
  368. package/src/storage/note_store/stored_note.ts +48 -0
  369. package/src/storage/open_pxe_stores.ts +49 -0
  370. package/src/storage/private_event_store/private_event_store.ts +388 -0
  371. package/src/storage/private_event_store/stored_private_event.ts +73 -0
  372. package/src/storage/tagging_store/index.ts +3 -0
  373. package/src/storage/tagging_store/recipient_tagging_store.ts +139 -0
  374. package/src/storage/tagging_store/sender_address_book_store.ts +48 -0
  375. package/src/storage/tagging_store/sender_tagging_store.ts +476 -0
  376. package/src/tagging/constants.ts +10 -3
  377. package/src/tagging/get_all_logs_by_tags.ts +120 -0
  378. package/src/tagging/index.ts +20 -4
  379. package/src/tagging/persist_sender_tagging_index_ranges.ts +57 -0
  380. package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +240 -0
  381. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +4 -4
  382. package/src/tagging/reconcile_tagging_index_ranges.ts +102 -0
  383. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +134 -0
  384. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +66 -0
  385. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +84 -0
  386. package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
  387. package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
  388. package/dest/contract_function_simulator/proxied_node.js +0 -27
  389. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
  390. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
  391. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
  392. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
  393. package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -46
  394. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
  395. package/dest/private_kernel/private_kernel_oracle_impl.js +0 -86
  396. package/dest/public_storage/public_storage_service.d.ts +0 -24
  397. package/dest/public_storage/public_storage_service.d.ts.map +0 -1
  398. package/dest/public_storage/public_storage_service.js +0 -26
  399. package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -11
  400. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +0 -1
  401. package/dest/storage/address_data_provider/index.d.ts +0 -2
  402. package/dest/storage/address_data_provider/index.d.ts.map +0 -1
  403. package/dest/storage/address_data_provider/index.js +0 -1
  404. package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.d.ts +0 -9
  405. package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.d.ts.map +0 -1
  406. package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.js +0 -19
  407. package/dest/storage/anchor_block_data_provider/index.d.ts +0 -2
  408. package/dest/storage/anchor_block_data_provider/index.d.ts.map +0 -1
  409. package/dest/storage/anchor_block_data_provider/index.js +0 -1
  410. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +0 -57
  411. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +0 -1
  412. package/dest/storage/capsule_data_provider/capsule_data_provider.js +0 -146
  413. package/dest/storage/capsule_data_provider/index.d.ts +0 -2
  414. package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
  415. package/dest/storage/capsule_data_provider/index.js +0 -1
  416. package/dest/storage/contract_data_provider/contract_data_provider.d.ts +0 -66
  417. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
  418. package/dest/storage/contract_data_provider/contract_data_provider.js +0 -224
  419. package/dest/storage/contract_data_provider/index.d.ts +0 -2
  420. package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
  421. package/dest/storage/contract_data_provider/index.js +0 -1
  422. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
  423. package/dest/storage/note_data_provider/index.d.ts +0 -3
  424. package/dest/storage/note_data_provider/index.d.ts.map +0 -1
  425. package/dest/storage/note_data_provider/index.js +0 -2
  426. package/dest/storage/note_data_provider/note_data_provider.d.ts +0 -84
  427. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
  428. package/dest/storage/note_data_provider/note_data_provider.js +0 -322
  429. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +0 -51
  430. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +0 -1
  431. package/dest/storage/private_event_data_provider/private_event_data_provider.js +0 -115
  432. package/dest/storage/tagging_data_provider/index.d.ts +0 -3
  433. package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
  434. package/dest/storage/tagging_data_provider/index.js +0 -2
  435. package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.d.ts +0 -31
  436. package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.d.ts.map +0 -1
  437. package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.js +0 -65
  438. package/dest/storage/tagging_data_provider/sender_tagging_data_provider.d.ts +0 -67
  439. package/dest/storage/tagging_data_provider/sender_tagging_data_provider.d.ts.map +0 -1
  440. package/dest/storage/tagging_data_provider/sender_tagging_data_provider.js +0 -196
  441. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +0 -14
  442. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +0 -1
  443. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +0 -99
  444. package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.d.ts +0 -21
  445. package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.d.ts.map +0 -1
  446. package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.js +0 -42
  447. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +0 -14
  448. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +0 -1
  449. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +0 -29
  450. package/dest/tagging/sync/sync_sender_tagging_indexes.d.ts +0 -21
  451. package/dest/tagging/sync/sync_sender_tagging_indexes.d.ts.map +0 -1
  452. package/dest/tagging/sync/utils/get_status_change_of_pending.d.ts +0 -11
  453. package/dest/tagging/sync/utils/get_status_change_of_pending.d.ts.map +0 -1
  454. package/dest/tagging/sync/utils/get_status_change_of_pending.js +0 -32
  455. package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.d.ts +0 -18
  456. package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.d.ts.map +0 -1
  457. package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.js +0 -55
  458. package/dest/tagging/utils.d.ts +0 -18
  459. package/dest/tagging/utils.d.ts.map +0 -1
  460. package/dest/tagging/utils.js +0 -25
  461. package/dest/tree_membership/tree_membership_service.d.ts +0 -52
  462. package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
  463. package/dest/tree_membership/tree_membership_service.js +0 -84
  464. package/src/contract_function_simulator/proxied_node.ts +0 -33
  465. package/src/private_kernel/private_kernel_oracle_impl.ts +0 -133
  466. package/src/public_storage/public_storage_service.ts +0 -33
  467. package/src/storage/address_data_provider/index.ts +0 -1
  468. package/src/storage/anchor_block_data_provider/index.ts +0 -1
  469. package/src/storage/capsule_data_provider/capsule_data_provider.ts +0 -179
  470. package/src/storage/capsule_data_provider/index.ts +0 -1
  471. package/src/storage/contract_data_provider/contract_data_provider.ts +0 -319
  472. package/src/storage/contract_data_provider/index.ts +0 -1
  473. package/src/storage/note_data_provider/index.ts +0 -2
  474. package/src/storage/note_data_provider/note_data_provider.ts +0 -412
  475. package/src/storage/private_event_data_provider/private_event_data_provider.ts +0 -162
  476. package/src/storage/tagging_data_provider/index.ts +0 -2
  477. package/src/storage/tagging_data_provider/recipient_tagging_data_provider.ts +0 -86
  478. package/src/storage/tagging_data_provider/sender_tagging_data_provider.ts +0 -244
  479. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +0 -129
  480. package/src/tagging/recipient_sync/new_recipient_tagging_data_provider.ts +0 -53
  481. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +0 -43
  482. package/src/tagging/sync/sync_sender_tagging_indexes.ts +0 -112
  483. package/src/tagging/sync/utils/get_status_change_of_pending.ts +0 -44
  484. package/src/tagging/sync/utils/load_and_store_new_tagging_indexes.ts +0 -72
  485. package/src/tagging/utils.ts +0 -32
  486. package/src/tree_membership/tree_membership_service.ts +0 -112
  487. /package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.js +0 -0
  488. /package/src/storage/{contract_data_provider → contract_store}/private_functions_tree.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"log_service.d.ts","sourceRoot":"","sources":["../../src/logs/log_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EACL,2BAA2B,EAE3B,oBAAoB,EACpB,mBAAmB,EACnB,SAAS,EACT,GAAG,EAEJ,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sEAAsE,CAAC;AAChH,OAAO,EAAE,oBAAoB,EAAE,MAAM,uEAAuE,CAAC;AAC7G,OAAO,EAAE,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;AAChG,OAAO,EAAE,uBAAuB,EAAE,MAAM,qEAAqE,CAAC;AAC9G,OAAO,EAAE,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;AAChG,OAAO,EAAE,4BAA4B,EAAE,MAAM,qEAAqE,CAAC;AAInH,qBAAa,UAAU;;IAEnB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,uBAAuB;IACxC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IACpC,OAAO,CAAC,QAAQ,CAAC,4BAA4B;IAC7C,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IANtC,YACmB,SAAS,EAAE,SAAS,EACpB,uBAAuB,EAAE,uBAAuB,EAChD,QAAQ,EAAE,QAAQ,EAClB,mBAAmB,EAAE,mBAAmB,EACxC,4BAA4B,EAAE,4BAA4B,EAC1D,mBAAmB,EAAE,mBAAmB,EACv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,CAAC;AAC7G,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AACzE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qDAAqD,CAAC;AACjG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uDAAuD,CAAC;AAWpG,qBAAa,UAAU;;IAInB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IACtC,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IACvC,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK;IAVxB,OAAO,CAAC,GAAG,CAAS;IAEpB,YACmB,SAAS,EAAE,SAAS,EACpB,iBAAiB,EAAE,WAAW,EAC9B,WAAW,EAAE,cAAc,EAC3B,QAAQ,EAAE,QAAQ,EAClB,qBAAqB,EAAE,qBAAqB,EAC5C,sBAAsB,EAAE,sBAAsB,EAC9C,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,MAAM,EAC9B,QAAQ,CAAC,EAAE,cAAc,EAG1B;IAED,wGAAwG;IAC3F,cAAc,CACzB,eAAe,EAAE,YAAY,EAC7B,oBAAoB,EAAE,mBAAmB,EAAE,GAC1C,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAsBnC;IAkGY,eAAe,CAAC,eAAe,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAwBhH;CAuCF"}
@@ -1,239 +1,168 @@
1
- import { DirectionalAppTaggingSecret, PendingTaggedLog, PrivateLogWithTxData, PublicLogWithTxData, SiloedTag, Tag } from '@aztec/stdlib/logs';
1
+ import { createLogger } from '@aztec/foundation/log';
2
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import { AppTaggingSecret, PendingTaggedLog, SiloedTag } from '@aztec/stdlib/logs';
4
+ import { LogSource } from '../contract_function_simulator/noir-structs/log_retrieval_request.js';
2
5
  import { LogRetrievalResponse } from '../contract_function_simulator/noir-structs/log_retrieval_response.js';
3
- import { WINDOW_HALF_SIZE } from '../tagging/constants.js';
4
- import { getInitialIndexesMap, getPreTagsForTheWindow } from '../tagging/utils.js';
6
+ import { getAllPrivateLogsByTags, getAllPublicLogsByTagsFromContract, syncTaggedPrivateLogs } from '../tagging/index.js';
7
+ const rangeKey = (fromBlock, toBlock)=>`${fromBlock ?? ''}-${toBlock ?? ''}`;
5
8
  export class LogService {
6
9
  aztecNode;
7
- anchorBlockDataProvider;
10
+ anchorBlockHeader;
11
+ l2TipsStore;
8
12
  keyStore;
9
- capsuleDataProvider;
10
- recipientTaggingDataProvider;
11
- addressDataProvider;
12
- constructor(aztecNode, anchorBlockDataProvider, keyStore, capsuleDataProvider, recipientTaggingDataProvider, addressDataProvider){
13
+ recipientTaggingStore;
14
+ senderAddressBookStore;
15
+ addressStore;
16
+ jobId;
17
+ log;
18
+ constructor(aztecNode, anchorBlockHeader, l2TipsStore, keyStore, recipientTaggingStore, senderAddressBookStore, addressStore, jobId, bindings){
13
19
  this.aztecNode = aztecNode;
14
- this.anchorBlockDataProvider = anchorBlockDataProvider;
20
+ this.anchorBlockHeader = anchorBlockHeader;
21
+ this.l2TipsStore = l2TipsStore;
15
22
  this.keyStore = keyStore;
16
- this.capsuleDataProvider = capsuleDataProvider;
17
- this.recipientTaggingDataProvider = recipientTaggingDataProvider;
18
- this.addressDataProvider = addressDataProvider;
23
+ this.recipientTaggingStore = recipientTaggingStore;
24
+ this.senderAddressBookStore = senderAddressBookStore;
25
+ this.addressStore = addressStore;
26
+ this.jobId = jobId;
27
+ this.log = createLogger('pxe:log_service', bindings);
19
28
  }
20
- async bulkRetrieveLogs(logRetrievalRequests) {
21
- return await Promise.all(logRetrievalRequests.map(async (request)=>{
22
- // TODO(F-231): remove these internal functions and have node endpoints that do this instead
23
- const [publicLog, privateLog] = await Promise.all([
24
- this.getPublicLogByTag(request.tag, request.contractAddress),
25
- this.getPrivateLogByTag(await SiloedTag.compute(request.tag, request.contractAddress))
26
- ]);
27
- if (publicLog !== null) {
28
- if (privateLog !== null) {
29
- throw new Error(`Found both a public and private log when searching for tag ${request.tag} from contract ${request.contractAddress}`);
30
- }
31
- return new LogRetrievalResponse(publicLog.logPayload, publicLog.txHash, publicLog.uniqueNoteHashesInTx, publicLog.firstNullifierInTx);
32
- } else if (privateLog !== null) {
33
- return new LogRetrievalResponse(privateLog.logPayload, privateLog.txHash, privateLog.uniqueNoteHashesInTx, privateLog.firstNullifierInTx);
34
- } else {
35
- return null;
29
+ /** Fetches all logs matching each request's tag, returning an array of log arrays (one per request). */ async fetchLogsByTag(contractAddress, logRetrievalRequests) {
30
+ for (const request of logRetrievalRequests){
31
+ if (!contractAddress.equals(request.contractAddress)) {
32
+ throw new Error(`Got a log retrieval request from ${request.contractAddress}, expected ${contractAddress}`);
36
33
  }
37
- }));
38
- }
39
- // TODO(F-231): delete this function and implement this behavior in the node instead
40
- async getPublicLogByTag(tag, contractAddress) {
41
- const logs = await this.aztecNode.getPublicLogsByTagsFromContract(contractAddress, [
42
- tag
43
- ]);
44
- const logsForTag = logs[0];
45
- if (logsForTag.length == 0) {
46
- return null;
47
- } else if (logsForTag.length > 1) {
48
- // TODO(#11627): handle this case
49
- throw new Error(`Got ${logsForTag.length} logs for tag ${tag} and contract ${contractAddress.toString()}. getPublicLogByTag currently only supports a single log per tag`);
50
34
  }
51
- const scopedLog = logsForTag[0];
52
- // getLogsByTag doesn't have all of the information that we need (notably note hashes and the first nullifier), so
53
- // we need to make a second call to the node for `getTxEffect`.
54
- // TODO(#9789): bundle this information in the `getLogsByTag` call.
55
- const txEffect = await this.aztecNode.getTxEffect(scopedLog.txHash);
56
- if (txEffect == undefined) {
57
- throw new Error(`Unexpected: failed to retrieve tx effects for tx ${scopedLog.txHash} which is known to exist`);
35
+ if (logRetrievalRequests.length === 0) {
36
+ return [];
58
37
  }
59
- return new PublicLogWithTxData(scopedLog.log.getEmittedFieldsWithoutTag(), scopedLog.txHash, txEffect.data.noteHashes, txEffect.data.nullifiers[0]);
60
- }
61
- // TODO(F-231): delete this function and implement this behavior in the node instead
62
- async getPrivateLogByTag(siloedTag) {
63
- const logs = await this.aztecNode.getPrivateLogsByTags([
64
- siloedTag
38
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
39
+ const [publicLogsPerRequest, privateLogsPerRequest] = await Promise.all([
40
+ this.#fetchPublicLogs(contractAddress, logRetrievalRequests, anchorBlockHash),
41
+ this.#fetchPrivateLogs(logRetrievalRequests, anchorBlockHash)
65
42
  ]);
66
- const logsForTag = logs[0];
67
- if (logsForTag.length == 0) {
68
- return null;
69
- } else if (logsForTag.length > 1) {
70
- // TODO(#11627): handle this case
71
- throw new Error(`Got ${logsForTag.length} logs for tag ${siloedTag}. getPrivateLogByTag currently only supports a single log per tag`);
72
- }
73
- const scopedLog = logsForTag[0];
74
- // getLogsByTag doesn't have all of the information that we need (notably note hashes and the first nullifier), so
75
- // we need to make a second call to the node for `getTxEffect`.
76
- // TODO(#9789): bundle this information in the `getLogsByTag` call.
77
- const txEffect = await this.aztecNode.getTxEffect(scopedLog.txHash);
78
- if (txEffect == undefined) {
79
- throw new Error(`Unexpected: failed to retrieve tx effects for tx ${scopedLog.txHash} which is known to exist`);
43
+ return logRetrievalRequests.map((_request, i)=>[
44
+ ...publicLogsPerRequest[i].map(LogService.#toLogRetrievalResponse),
45
+ ...privateLogsPerRequest[i].map(LogService.#toLogRetrievalResponse)
46
+ ]);
47
+ }
48
+ async #fetchPublicLogs(contractAddress, requests, anchorBlockHash) {
49
+ const indices = requests.flatMap((r, i)=>r.source !== LogSource.PRIVATE ? [
50
+ i
51
+ ] : []);
52
+ if (indices.length === 0) {
53
+ return requests.map(()=>[]);
80
54
  }
81
- return new PrivateLogWithTxData(scopedLog.log.getEmittedFieldsWithoutTag(), scopedLog.txHash, txEffect.data.noteHashes, txEffect.data.nullifiers[0]);
55
+ const resultsPerRequest = requests.map(()=>[]);
56
+ const groups = LogService.#groupByRange(indices.map((i)=>({
57
+ index: i,
58
+ request: requests[i]
59
+ })));
60
+ await Promise.all(Array.from(groups.values()).map(async (group)=>{
61
+ const tags = group.entries.map((e)=>e.request.tag);
62
+ const results = await getAllPublicLogsByTagsFromContract(this.aztecNode, contractAddress, tags, anchorBlockHash, {
63
+ fromBlock: group.fromBlock,
64
+ toBlock: group.toBlock,
65
+ includeEffects: true
66
+ });
67
+ group.entries.forEach((entry, i)=>{
68
+ resultsPerRequest[entry.index] = results[i];
69
+ });
70
+ }));
71
+ return resultsPerRequest;
82
72
  }
83
- // TODO(#17775): Replace this implementation of this function with one implementing an approach similar
84
- // to syncSenderTaggingIndexes. Not done yet due to re-prioritization to devex and this doesn't directly affect
85
- // devex.
86
- async syncTaggedLogs(contractAddress, pendingTaggedLogArrayBaseSlot, scopes) {
87
- const maxBlockNumber = (await this.anchorBlockDataProvider.getBlockHeader()).getBlockNumber();
88
- // Ideally this algorithm would be implemented in noir, exposing its building blocks as oracles.
89
- // However it is impossible at the moment due to the language not supporting nested slices.
90
- // This nesting is necessary because for a given set of tags we don't
91
- // know how many logs we will get back. Furthermore, these logs are of undetermined
92
- // length, since we don't really know the note they correspond to until we decrypt them.
93
- const recipients = scopes ? scopes : await this.keyStore.getAccounts();
94
- for (const recipient of recipients){
95
- // Get all the secrets for the recipient and sender pairs (#9365)
96
- const indexedSecrets = await this.getLastUsedTaggingIndexesForSenders(contractAddress, recipient);
97
- // We fetch logs for a window of indexes in a range:
98
- // <latest_log_index - WINDOW_HALF_SIZE, latest_log_index + WINDOW_HALF_SIZE>.
99
- //
100
- // We use this window approach because it could happen that a sender might have messed up and inadvertently
101
- // incremented their index without us getting any logs (for example, in case of a revert). If we stopped looking
102
- // for logs the first time we don't receive any logs for a tag, we might never receive anything from that sender again.
103
- // Also there's a possibility that we have advanced our index, but the sender has reused it, so we might have missed
104
- // some logs. For these reasons, we have to look both back and ahead of the stored index.
105
- let secretsAndWindows = indexedSecrets.map((indexedSecret)=>{
106
- if (indexedSecret.index === undefined) {
107
- return {
108
- secret: indexedSecret.secret,
109
- leftMostIndex: 0,
110
- rightMostIndex: WINDOW_HALF_SIZE
111
- };
112
- } else {
113
- return {
114
- secret: indexedSecret.secret,
115
- leftMostIndex: Math.max(0, indexedSecret.index - WINDOW_HALF_SIZE),
116
- rightMostIndex: indexedSecret.index + WINDOW_HALF_SIZE
117
- };
118
- }
73
+ async #fetchPrivateLogs(requests, anchorBlockHash) {
74
+ const indices = requests.flatMap((r, i)=>r.source !== LogSource.PUBLIC ? [
75
+ i
76
+ ] : []);
77
+ if (indices.length === 0) {
78
+ return requests.map(()=>[]);
79
+ }
80
+ const resultsPerRequest = requests.map(()=>[]);
81
+ const groups = LogService.#groupByRange(indices.map((i)=>({
82
+ index: i,
83
+ request: requests[i]
84
+ })));
85
+ await Promise.all(Array.from(groups.values()).map(async (group)=>{
86
+ const siloedTags = await Promise.all(group.entries.map((e)=>SiloedTag.computeFromTagAndApp(e.request.tag, e.request.contractAddress)));
87
+ const results = await getAllPrivateLogsByTags(this.aztecNode, siloedTags, anchorBlockHash, {
88
+ fromBlock: group.fromBlock,
89
+ toBlock: group.toBlock,
90
+ includeEffects: true
91
+ });
92
+ group.entries.forEach((entry, i)=>{
93
+ resultsPerRequest[entry.index] = results[i];
119
94
  });
120
- // As we iterate we store the largest index we have seen for a given secret to later on store it in the db.
121
- const newLargestIndexMapToStore = {};
122
- // The initial/unmodified indexes of the secrets stored in a key-value map where key is the directional app
123
- // tagging secret.
124
- const initialIndexesMap = getInitialIndexesMap(indexedSecrets);
125
- while(secretsAndWindows.length > 0){
126
- const preTagsForTheWholeWindow = getPreTagsForTheWindow(secretsAndWindows);
127
- const tagsForTheWholeWindow = await Promise.all(preTagsForTheWholeWindow.map(async (preTag)=>{
128
- return SiloedTag.compute(await Tag.compute(preTag), contractAddress);
129
- }));
130
- // We store the new largest indexes we find in the iteration in the following map to later on construct
131
- // a new set of secrets and windows to fetch logs for.
132
- const newLargestIndexMapForIteration = {};
133
- // Fetch the private logs for the tags and iterate over them
134
- const logsByTags = await this.aztecNode.getPrivateLogsByTags(tagsForTheWholeWindow);
135
- for(let logIndex = 0; logIndex < logsByTags.length; logIndex++){
136
- const logsByTag = logsByTags[logIndex];
137
- if (logsByTag.length > 0) {
138
- // We filter out the logs that are newer than the anchor block number of the tx currently being constructed
139
- const filteredLogsByBlockNumber = logsByTag.filter((l)=>l.blockNumber <= maxBlockNumber);
140
- // We store the logs in capsules (to later be obtained in Noir)
141
- await this.#storePendingTaggedLogs(contractAddress, pendingTaggedLogArrayBaseSlot, recipient, filteredLogsByBlockNumber);
142
- // We retrieve the pre-tag corresponding to the log as I need that to evaluate whether
143
- // a new largest index have been found.
144
- const preTagCorrespondingToLog = preTagsForTheWholeWindow[logIndex];
145
- const initialIndex = initialIndexesMap[preTagCorrespondingToLog.secret.toString()];
146
- if (preTagCorrespondingToLog.index >= initialIndex && (newLargestIndexMapForIteration[preTagCorrespondingToLog.secret.toString()] === undefined || preTagCorrespondingToLog.index >= newLargestIndexMapForIteration[preTagCorrespondingToLog.secret.toString()])) {
147
- // We have found a new largest index so we store it for later processing (storing it in the db + fetching
148
- // the difference of the window sets of current and the next iteration)
149
- newLargestIndexMapForIteration[preTagCorrespondingToLog.secret.toString()] = preTagCorrespondingToLog.index + 1;
150
- }
151
- }
152
- }
153
- // Now based on the new largest indexes we found, we will construct a new secrets and windows set to fetch logs
154
- // for. Note that it's very unlikely that a new log from the current window would appear between the iterations
155
- // so we fetch the logs only for the difference of the window sets.
156
- const newSecretsAndWindows = [];
157
- for (const [directionalAppTaggingSecret, newIndex] of Object.entries(newLargestIndexMapForIteration)){
158
- const maybeIndexedSecret = indexedSecrets.find((indexedSecret)=>indexedSecret.secret.toString() === directionalAppTaggingSecret);
159
- if (maybeIndexedSecret) {
160
- newSecretsAndWindows.push({
161
- secret: maybeIndexedSecret.secret,
162
- // We set the left most index to the new index to avoid fetching the same logs again
163
- leftMostIndex: newIndex,
164
- rightMostIndex: newIndex + WINDOW_HALF_SIZE
165
- });
166
- // We store the new largest index in the map to later store it in the db.
167
- newLargestIndexMapToStore[directionalAppTaggingSecret] = newIndex;
168
- } else {
169
- throw new Error(`Secret not found for directionalAppTaggingSecret ${directionalAppTaggingSecret}. This is a bug as it should never happen!`);
170
- }
171
- }
172
- // Now we set the new secrets and windows and proceed to the next iteration.
173
- secretsAndWindows = newSecretsAndWindows;
95
+ }));
96
+ return resultsPerRequest;
97
+ }
98
+ /**
99
+ * Groups requests by their (fromBlock, toBlock) range so each distinct range becomes a single node call with
100
+ * the range pushed down into the query (no in-memory filter).
101
+ */ static #groupByRange(entries) {
102
+ const groups = new Map();
103
+ for (const entry of entries){
104
+ const key = rangeKey(entry.request.fromBlock, entry.request.toBlock);
105
+ const existing = groups.get(key);
106
+ if (existing) {
107
+ existing.entries.push(entry);
108
+ } else {
109
+ groups.set(key, {
110
+ fromBlock: entry.request.fromBlock,
111
+ toBlock: entry.request.toBlock,
112
+ entries: [
113
+ entry
114
+ ]
115
+ });
174
116
  }
175
- // At this point we have processed all the logs for the recipient so we store the last used indexes in the db.
176
- // newLargestIndexMapToStore contains "next" indexes to look for (one past the last found), so subtract 1 to get
177
- // last used.
178
- await this.recipientTaggingDataProvider.setLastUsedIndexes(Object.entries(newLargestIndexMapToStore).map(([directionalAppTaggingSecret, index])=>({
179
- secret: DirectionalAppTaggingSecret.fromString(directionalAppTaggingSecret),
180
- index: index - 1
181
- })));
182
117
  }
118
+ return groups;
183
119
  }
184
- /**
185
- * Returns the last used tagging indexes along with the directional app tagging secrets for a given recipient and all
186
- * the senders in the address book.
187
- * This method should be exposed as an oracle call to allow aztec.nr to perform the orchestration
188
- * of the syncTaggedLogs and processTaggedLogs methods. However, it is not possible to do so at the moment,
189
- * so we're keeping it private for now.
190
- * @param contractAddress - The contract address to silo the secret for
191
- * @param recipient - The address receiving the notes
192
- * @returns A list of directional app tagging secrets along with the last used tagging indexes. If the corresponding
193
- * secret was never used, the index is undefined.
194
- * TODO(#17775): The naming here is broken as the function name does not reflect the return type. Make sure this gets
195
- * fixed when implementing the linked issue.
196
- */ async getLastUsedTaggingIndexesForSenders(contractAddress, recipient) {
197
- const recipientCompleteAddress = await this.#getCompleteAddress(recipient);
198
- const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
199
- // We implicitly add all PXE accounts as senders, this helps us decrypt tags on notes that we send to ourselves
200
- // (recipient = us, sender = us)
201
- const senders = [
202
- ...await this.recipientTaggingDataProvider.getSenderAddresses(),
203
- ...await this.keyStore.getAccounts()
204
- ].filter((address, index, self)=>index === self.findIndex((otherAddress)=>otherAddress.equals(address)));
205
- const secrets = await Promise.all(senders.map((contact)=>{
206
- return DirectionalAppTaggingSecret.compute(recipientCompleteAddress, recipientIvsk, contact, contractAddress, recipient);
207
- }));
208
- const indexes = await this.recipientTaggingDataProvider.getLastUsedIndexes(secrets);
209
- if (indexes.length !== secrets.length) {
210
- throw new Error('Indexes and directional app tagging secrets have different lengths');
120
+ static #toLogRetrievalResponse(log) {
121
+ // includeEffects: true was used, so noteHashes and nullifiers are populated. Every tx has at least one nullifier
122
+ // (the first nullifier derived from the tx hash); empty here would indicate a buggy node.
123
+ const noteHashes = log.noteHashes;
124
+ const nullifiers = log.nullifiers;
125
+ if (nullifiers.length === 0) {
126
+ throw new Error(`Log for tx ${log.txHash} returned no nullifiers from the node`);
211
127
  }
212
- return secrets.map((secret, i)=>({
213
- secret,
214
- index: indexes[i]
215
- }));
128
+ return new LogRetrievalResponse(log.logData.slice(1), log.txHash, noteHashes, nullifiers[0]);
216
129
  }
217
- async #storePendingTaggedLogs(contractAddress, capsuleArrayBaseSlot, recipient, privateLogs) {
218
- // Build all pending tagged logs upfront with their tx effects
219
- const pendingTaggedLogs = await Promise.all(privateLogs.map(async (scopedLog)=>{
220
- // TODO(#9789): get these effects along with the log
221
- const txEffect = await this.aztecNode.getTxEffect(scopedLog.txHash);
222
- if (!txEffect) {
223
- throw new Error(`Could not find tx effect for tx hash ${scopedLog.txHash}`);
130
+ async fetchTaggedLogs(contractAddress, recipient) {
131
+ this.log.verbose(`Fetching tagged logs for ${contractAddress.toString()}`);
132
+ const l2Tips = await this.l2TipsStore.getL2Tips();
133
+ // Get all secrets for this recipient (one per sender)
134
+ const secrets = await this.#getSecretsForSenders(contractAddress, recipient);
135
+ const logs = await syncTaggedPrivateLogs(secrets, this.aztecNode, this.recipientTaggingStore, this.anchorBlockHeader, l2Tips.finalized.block.number, this.jobId);
136
+ return logs.map((log)=>{
137
+ const noteHashes = log.noteHashes;
138
+ const nullifiers = log.nullifiers;
139
+ if (nullifiers.length === 0) {
140
+ throw new Error(`Log for tx ${log.txHash} returned no nullifiers from the node`);
224
141
  }
225
- const pendingTaggedLog = new PendingTaggedLog(scopedLog.log.fields, scopedLog.txHash, txEffect.data.noteHashes, txEffect.data.nullifiers[0], recipient);
226
- return pendingTaggedLog.toFields();
227
- }));
228
- // TODO: This looks like it could belong more at the oracle interface level
229
- return this.capsuleDataProvider.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs);
142
+ return new PendingTaggedLog(log.logData, log.txHash, noteHashes, nullifiers[0]);
143
+ });
230
144
  }
231
- async #getCompleteAddress(account) {
232
- const completeAddress = await this.addressDataProvider.getCompleteAddress(account);
233
- if (!completeAddress) {
234
- throw new Error(`No public key registered for address ${account}.
235
- Register it by calling pxe.addAccount(...).\nSee docs for context: https://docs.aztec.network/developers/resources/debugging/aztecnr-errors#simulation-error-no-public-key-registered-for-address-0x0-register-it-by-calling-pxeregisterrecipient-or-pxeregisteraccount`);
145
+ async #getSecretsForSenders(contractAddress, recipient) {
146
+ const recipientCompleteAddress = await this.addressStore.getCompleteAddress(recipient);
147
+ if (!recipientCompleteAddress) {
148
+ return [];
236
149
  }
237
- return completeAddress;
150
+ const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
151
+ // We implicitly add all PXE accounts as senders, this helps us find tagged logs with messages that are sent to a
152
+ // local account (recipient = us, sender = us)
153
+ const allSenders = [
154
+ ...await this.senderAddressBookStore.getSenders(),
155
+ ...await this.keyStore.getAccounts()
156
+ ];
157
+ // We deduplicate the senders by adding them to a set and then converting the set back to an array
158
+ const deduplicatedSenders = Array.from(new Set(allSenders.map((sender)=>sender.toString()))).map((sender)=>AztecAddress.fromString(sender));
159
+ return Promise.all(deduplicatedSenders.map(async (sender)=>{
160
+ const secret = await AppTaggingSecret.computeUnconstrained(recipientCompleteAddress, recipientIvsk, sender, contractAddress, recipient);
161
+ if (!secret) {
162
+ // Note that all senders originate from either the SenderAddressBookStore or the KeyStore.
163
+ throw new Error(`Failed to compute a tagging secret for sender ${sender} - this implies this is an invalid address, which should not happen as they have been previously registered in PXE.`);
164
+ }
165
+ return secret;
166
+ }));
238
167
  }
239
168
  }
@@ -0,0 +1,17 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import type { AztecNode } from '@aztec/stdlib/interfaces/server';
3
+ import { MessageContext } from '@aztec/stdlib/logs';
4
+ /** Resolves transaction hashes into the context needed to process messages. */
5
+ export declare class MessageContextService {
6
+ private readonly aztecNode;
7
+ constructor(aztecNode: AztecNode);
8
+ /**
9
+ * Resolves a list of tx hashes into their message contexts.
10
+ *
11
+ * For each tx hash, looks up the corresponding tx effect and extracts the note hashes and first nullifier needed to
12
+ * process messages that originated from that transaction. Returns `null` for tx hashes that are zero, not yet
13
+ * available, or in blocks beyond the anchor block.
14
+ */
15
+ getMessageContextsByTxHash(txHashes: Fr[], anchorBlockNumber: number): Promise<(MessageContext | null)[]>;
16
+ }
17
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVzc2FnZV9jb250ZXh0X3NlcnZpY2UuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3V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"}
@@ -0,0 +1,38 @@
1
+ import { uniqueBy } from '@aztec/foundation/collection';
2
+ import { MessageContext } from '@aztec/stdlib/logs';
3
+ import { TxHash } from '@aztec/stdlib/tx';
4
+ /** Resolves transaction hashes into the context needed to process messages. */ export class MessageContextService {
5
+ aztecNode;
6
+ constructor(aztecNode){
7
+ this.aztecNode = aztecNode;
8
+ }
9
+ /**
10
+ * Resolves a list of tx hashes into their message contexts.
11
+ *
12
+ * For each tx hash, looks up the corresponding tx effect and extracts the note hashes and first nullifier needed to
13
+ * process messages that originated from that transaction. Returns `null` for tx hashes that are zero, not yet
14
+ * available, or in blocks beyond the anchor block.
15
+ */ async getMessageContextsByTxHash(txHashes, anchorBlockNumber) {
16
+ const nonZeroTxHashes = txHashes.filter((h)=>!h.isZero()).map((h)=>TxHash.fromField(h));
17
+ const uniqueTxHashes = uniqueBy(nonZeroTxHashes, (h)=>h.toString());
18
+ const fetched = await Promise.all(uniqueTxHashes.map((h)=>this.aztecNode.getTxEffect(h)));
19
+ const txEffects = new Map(uniqueTxHashes.map((h, i)=>[
20
+ h.toString(),
21
+ fetched[i]
22
+ ]).filter((entry)=>entry[1] !== undefined));
23
+ return txHashes.map((txHashField)=>{
24
+ const txHash = TxHash.fromField(txHashField);
25
+ const txEffect = txEffects.get(txHash.toString());
26
+ if (!txEffect || txEffect.l2BlockNumber > anchorBlockNumber) {
27
+ return null;
28
+ }
29
+ // Every tx has at least one nullifier (the first nullifier derived from the tx hash). Hitting this condition
30
+ // would mean a buggy node, but since we need to access data.nullifiers[0], the defensive check does no harm.
31
+ const data = txEffect.data;
32
+ if (data.nullifiers.length === 0) {
33
+ throw new Error(`Tx effect for ${txHash} has no nullifiers`);
34
+ }
35
+ return new MessageContext(data.txHash, data.noteHashes, data.nullifiers[0]);
36
+ });
37
+ }
38
+ }
@@ -2,14 +2,16 @@ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
3
  import { type AztecNode } from '@aztec/stdlib/interfaces/client';
4
4
  import { Note, NoteStatus } from '@aztec/stdlib/note';
5
- import type { TxHash } from '@aztec/stdlib/tx';
6
- import type { AnchorBlockDataProvider } from '../storage/anchor_block_data_provider/anchor_block_data_provider.js';
7
- import type { NoteDataProvider } from '../storage/note_data_provider/note_data_provider.js';
5
+ import type { BlockHeader, IndexedTxEffect } from '@aztec/stdlib/tx';
6
+ import type { NoteValidationRequest } from '../contract_function_simulator/noir-structs/note_validation_request.js';
7
+ import type { NoteStore } from '../storage/note_store/note_store.js';
8
8
  export declare class NoteService {
9
- private readonly noteDataProvider;
9
+ #private;
10
+ private readonly noteStore;
10
11
  private readonly aztecNode;
11
- private readonly anchorBlockDataProvider;
12
- constructor(noteDataProvider: NoteDataProvider, aztecNode: AztecNode, anchorBlockDataProvider: AnchorBlockDataProvider);
12
+ private readonly anchorBlockHeader;
13
+ private readonly jobId;
14
+ constructor(noteStore: NoteStore, aztecNode: AztecNode, anchorBlockHeader: BlockHeader, jobId: string);
13
15
  /**
14
16
  * Retrieves a set of notes stored in the database for a given contract address and storage slot.
15
17
  * The query result is paginated using 'limit' and 'offset' values.
@@ -19,7 +21,7 @@ export declare class NoteService {
19
21
  * @param status - The status of notes to fetch.
20
22
  * @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
21
23
  */
22
- getNotes(contractAddress: AztecAddress, owner: AztecAddress | undefined, storageSlot: Fr, status: NoteStatus, scopes?: AztecAddress[]): Promise<{
24
+ getNotes(contractAddress: AztecAddress, owner: AztecAddress | undefined, storageSlot: Fr, status: NoteStatus, scopes: AztecAddress[]): Promise<{
23
25
  contractAddress: AztecAddress;
24
26
  owner: AztecAddress;
25
27
  storageSlot: Fr;
@@ -27,13 +29,13 @@ export declare class NoteService {
27
29
  noteNonce: Fr;
28
30
  note: Note;
29
31
  noteHash: Fr;
32
+ isPending: boolean;
30
33
  siloedNullifier: Fr;
31
- index: bigint;
32
34
  }[]>;
33
35
  /**
34
36
  * Looks for nullifiers of active contract notes and marks them as nullified if a nullifier is found.
35
37
  *
36
- * Fetches notes from the NoteDataProvider and checks which nullifiers are present in the
38
+ * Fetches notes from the NoteStore and checks which nullifiers are present in the
37
39
  * onchain nullifier Merkle tree - up to the latest locally synced block. We use the
38
40
  * locally synced block instead of querying the chain's 'latest' block to ensure correctness:
39
41
  * notes are only marked nullified once their corresponding nullifier has been included in a
@@ -42,7 +44,27 @@ export declare class NoteService {
42
44
  *
43
45
  * @param contractAddress - The contract whose notes should be checked and nullified.
44
46
  */
45
- syncNoteNullifiers(contractAddress: AztecAddress): Promise<void>;
46
- deliverNote(contractAddress: AztecAddress, owner: AztecAddress, storageSlot: Fr, randomness: Fr, noteNonce: Fr, content: Fr[], noteHash: Fr, nullifier: Fr, txHash: TxHash, recipient: AztecAddress): Promise<void>;
47
+ syncNoteNullifiers(contractAddress: AztecAddress, scopes: AztecAddress[]): Promise<void>;
48
+ /**
49
+ * Validates and stores a batch of notes against pre-fetched tx effects.
50
+ *
51
+ * For each request we must verify that:
52
+ * - the note actually exists in the corresponding tx effect (and thus in the note hash tree), and
53
+ * - the note has not already been nullified.
54
+ *
55
+ * Failing to do either would result in circuits getting either non-existent notes and failing to produce inclusion
56
+ * proofs for them, or getting nullified notes and producing duplicate nullifiers, both of which are catastrophic
57
+ * failure modes.
58
+ *
59
+ * Note that adding a note and removing it is *not* equivalent to never adding it in the first place. A nullifier
60
+ * emitted in a block that comes after note creation might result in the note being de-nullified by a chain reorg,
61
+ * so we must store both the note hash and nullifier block information.
62
+ *
63
+ * @param requests - The notes to validate and store.
64
+ * @param scope - The scope under which the notes are being stored.
65
+ * @param txEffects - Pre-fetched tx effects keyed by `TxHash.toString()`. Must contain entries for every request's
66
+ * txHash; missing entries are treated as a node bug and cause an error.
67
+ */
68
+ validateAndStoreNotes(requests: NoteValidationRequest[], scope: AztecAddress, txEffects: Map<string, IndexedTxEffect>): Promise<void>;
47
69
  }
48
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJza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