@aztec/pxe 0.0.1-commit.d3ec352c → 0.0.1-commit.e310a4c8

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 (383) hide show
  1. package/dest/bin/check_oracle_version.js +105 -15
  2. package/dest/block_synchronizer/block_synchronizer.d.ts +43 -0
  3. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
  4. package/dest/block_synchronizer/block_synchronizer.js +147 -0
  5. package/dest/block_synchronizer/index.d.ts +2 -0
  6. package/dest/block_synchronizer/index.d.ts.map +1 -0
  7. package/dest/block_synchronizer/index.js +1 -0
  8. package/dest/config/index.d.ts +6 -4
  9. package/dest/config/index.d.ts.map +1 -1
  10. package/dest/config/index.js +17 -0
  11. package/dest/config/package_info.js +1 -1
  12. package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
  13. package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
  14. package/dest/contract_function_simulator/benchmarked_node.js +77 -0
  15. package/dest/contract_function_simulator/contract_function_simulator.d.ts +40 -14
  16. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/contract_function_simulator.js +72 -33
  18. package/dest/contract_function_simulator/execution_note_cache.d.ts +21 -12
  19. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  20. package/dest/contract_function_simulator/execution_note_cache.js +48 -31
  21. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +1 -1
  22. package/dest/contract_function_simulator/execution_tagging_index_cache.js +1 -1
  23. package/dest/contract_function_simulator/hashed_values_cache.d.ts +2 -2
  24. package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -1
  25. package/dest/contract_function_simulator/index.d.ts +2 -2
  26. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  27. package/dest/contract_function_simulator/index.js +1 -1
  28. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +5 -4
  29. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  30. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +6 -3
  31. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +5 -4
  32. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
  33. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +7 -6
  34. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
  35. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  36. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -1
  37. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -3
  38. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  39. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
  40. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
  41. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
  42. package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
  43. package/dest/contract_function_simulator/oracle/interfaces.d.ts +20 -16
  44. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  45. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +4 -2
  46. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  47. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -1
  48. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +11 -7
  49. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
  50. package/dest/contract_function_simulator/oracle/note_packing_utils.js +14 -10
  51. package/dest/contract_function_simulator/oracle/oracle.d.ts +10 -8
  52. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  53. package/dest/contract_function_simulator/oracle/oracle.js +59 -37
  54. package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -28
  55. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  56. package/dest/contract_function_simulator/oracle/private_execution.js +2 -38
  57. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +32 -25
  58. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  59. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +41 -45
  60. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +80 -26
  61. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  62. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +175 -65
  63. package/dest/contract_function_simulator/pick_notes.d.ts +2 -2
  64. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
  65. package/dest/contract_function_simulator/pick_notes.js +1 -1
  66. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +4 -4
  67. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
  68. package/dest/contract_function_simulator/proxied_contract_data_source.js +23 -5
  69. package/dest/contract_sync/index.d.ts +23 -0
  70. package/dest/contract_sync/index.d.ts.map +1 -0
  71. package/dest/contract_sync/index.js +54 -0
  72. package/dest/debug/pxe_debug_utils.d.ts +41 -0
  73. package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
  74. package/dest/debug/pxe_debug_utils.js +47 -0
  75. package/dest/entrypoints/client/bundle/index.d.ts +1 -2
  76. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  77. package/dest/entrypoints/client/bundle/index.js +0 -1
  78. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  79. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  80. package/dest/entrypoints/client/bundle/utils.js +23 -8
  81. package/dest/entrypoints/client/lazy/index.d.ts +1 -2
  82. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  83. package/dest/entrypoints/client/lazy/index.js +0 -1
  84. package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
  85. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  86. package/dest/entrypoints/client/lazy/utils.js +24 -9
  87. package/dest/entrypoints/pxe_creation_options.d.ts +7 -3
  88. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  89. package/dest/entrypoints/server/index.d.ts +4 -2
  90. package/dest/entrypoints/server/index.d.ts.map +1 -1
  91. package/dest/entrypoints/server/index.js +3 -1
  92. package/dest/entrypoints/server/utils.d.ts +1 -1
  93. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  94. package/dest/entrypoints/server/utils.js +30 -15
  95. package/dest/error_enriching.d.ts +4 -4
  96. package/dest/error_enriching.d.ts.map +1 -1
  97. package/dest/error_enriching.js +6 -6
  98. package/dest/events/event_service.d.ts +15 -0
  99. package/dest/events/event_service.d.ts.map +1 -0
  100. package/dest/events/event_service.js +44 -0
  101. package/dest/events/index.d.ts +2 -0
  102. package/dest/events/index.d.ts.map +1 -0
  103. package/dest/events/index.js +1 -0
  104. package/dest/events/private_event_filter_validator.d.ts +9 -0
  105. package/dest/events/private_event_filter_validator.d.ts.map +1 -0
  106. package/dest/events/private_event_filter_validator.js +38 -0
  107. package/dest/job_coordinator/job_coordinator.d.ts +75 -0
  108. package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
  109. package/dest/job_coordinator/job_coordinator.js +94 -0
  110. package/dest/logs/log_service.d.ts +28 -0
  111. package/dest/logs/log_service.d.ts.map +1 -0
  112. package/dest/logs/log_service.js +125 -0
  113. package/dest/notes/index.d.ts +2 -0
  114. package/dest/notes/index.d.ts.map +1 -0
  115. package/dest/notes/index.js +1 -0
  116. package/dest/notes/note_service.d.ts +48 -0
  117. package/dest/notes/note_service.d.ts.map +1 -0
  118. package/dest/notes/note_service.js +147 -0
  119. package/dest/oracle_version.d.ts +3 -3
  120. package/dest/oracle_version.d.ts.map +1 -1
  121. package/dest/oracle_version.js +4 -3
  122. package/dest/private_kernel/hints/index.d.ts +2 -2
  123. package/dest/private_kernel/hints/index.d.ts.map +1 -1
  124. package/dest/private_kernel/hints/index.js +1 -1
  125. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +28 -0
  126. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
  127. package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +13 -7
  128. package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
  129. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  130. package/dest/private_kernel/private_kernel_execution_prover.js +10 -11
  131. package/dest/private_kernel/private_kernel_oracle.d.ts +26 -29
  132. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  133. package/dest/private_kernel/private_kernel_oracle.js +90 -2
  134. package/dest/pxe.d.ts +45 -81
  135. package/dest/pxe.d.ts.map +1 -1
  136. package/dest/pxe.js +188 -217
  137. package/dest/storage/address_store/address_store.d.ts +11 -0
  138. package/dest/storage/address_store/address_store.d.ts.map +1 -0
  139. package/dest/storage/{address_data_provider/address_data_provider.js → address_store/address_store.js} +13 -12
  140. package/dest/storage/address_store/index.d.ts +2 -0
  141. package/dest/storage/address_store/index.d.ts.map +1 -0
  142. package/dest/storage/address_store/index.js +1 -0
  143. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +17 -0
  144. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
  145. package/dest/storage/{sync_data_provider/sync_data_provider.js → anchor_block_store/anchor_block_store.js} +10 -10
  146. package/dest/storage/{sync_data_provider → anchor_block_store}/index.d.ts +2 -2
  147. package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
  148. package/dest/storage/anchor_block_store/index.js +1 -0
  149. package/dest/storage/capsule_store/capsule_store.d.ts +72 -0
  150. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
  151. package/dest/storage/capsule_store/capsule_store.js +253 -0
  152. package/dest/storage/capsule_store/index.d.ts +2 -0
  153. package/dest/storage/capsule_store/index.d.ts.map +1 -0
  154. package/dest/storage/capsule_store/index.js +1 -0
  155. package/dest/storage/{contract_data_provider/contract_data_provider.d.ts → contract_store/contract_store.d.ts} +7 -5
  156. package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
  157. package/dest/storage/{contract_data_provider/contract_data_provider.js → contract_store/contract_store.js} +56 -16
  158. package/dest/storage/contract_store/index.d.ts +2 -0
  159. package/dest/storage/contract_store/index.d.ts.map +1 -0
  160. package/dest/storage/contract_store/index.js +1 -0
  161. package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.d.ts +1 -1
  162. package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
  163. package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.js +1 -1
  164. package/dest/storage/index.d.ts +8 -8
  165. package/dest/storage/index.d.ts.map +1 -1
  166. package/dest/storage/index.js +7 -7
  167. package/dest/storage/metadata.d.ts +1 -1
  168. package/dest/storage/metadata.js +1 -1
  169. package/dest/storage/note_store/index.d.ts +3 -0
  170. package/dest/storage/note_store/index.d.ts.map +1 -0
  171. package/dest/storage/note_store/index.js +2 -0
  172. package/dest/storage/note_store/note_store.d.ts +83 -0
  173. package/dest/storage/note_store/note_store.d.ts.map +1 -0
  174. package/dest/storage/note_store/note_store.js +341 -0
  175. package/dest/storage/note_store/stored_note.d.ts +16 -0
  176. package/dest/storage/note_store/stored_note.d.ts.map +1 -0
  177. package/dest/storage/note_store/stored_note.js +43 -0
  178. package/dest/storage/private_event_store/private_event_store.d.ts +91 -0
  179. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
  180. package/dest/storage/private_event_store/private_event_store.js +273 -0
  181. package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
  182. package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
  183. package/dest/storage/private_event_store/stored_private_event.js +56 -0
  184. package/dest/storage/tagging_store/index.d.ts +4 -0
  185. package/dest/storage/tagging_store/index.d.ts.map +1 -0
  186. package/dest/storage/tagging_store/index.js +3 -0
  187. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +28 -0
  188. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
  189. package/dest/storage/tagging_store/recipient_tagging_store.js +111 -0
  190. package/dest/storage/tagging_store/sender_address_book_store.d.ts +14 -0
  191. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -0
  192. package/dest/storage/tagging_store/sender_address_book_store.js +36 -0
  193. package/dest/storage/tagging_store/sender_tagging_store.d.ts +77 -0
  194. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
  195. package/dest/storage/tagging_store/sender_tagging_store.js +348 -0
  196. package/dest/tagging/constants.d.ts +2 -2
  197. package/dest/tagging/constants.d.ts.map +1 -1
  198. package/dest/tagging/constants.js +10 -2
  199. package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
  200. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
  201. package/dest/tagging/get_all_logs_by_tags.js +46 -0
  202. package/dest/tagging/index.d.ts +16 -6
  203. package/dest/tagging/index.d.ts.map +1 -1
  204. package/dest/tagging/index.js +15 -5
  205. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +15 -0
  206. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -0
  207. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +99 -0
  208. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +12 -0
  209. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -0
  210. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +20 -0
  211. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +15 -0
  212. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -0
  213. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +32 -0
  214. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +21 -0
  215. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -0
  216. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +74 -0
  217. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +11 -0
  218. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -0
  219. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +29 -0
  220. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +21 -0
  221. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
  222. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +60 -0
  223. package/package.json +18 -18
  224. package/src/bin/check_oracle_version.ts +131 -20
  225. package/src/block_synchronizer/block_synchronizer.ts +172 -0
  226. package/src/block_synchronizer/index.ts +1 -0
  227. package/src/config/index.ts +17 -3
  228. package/src/config/package_info.ts +1 -1
  229. package/src/contract_function_simulator/benchmarked_node.ts +103 -0
  230. package/src/contract_function_simulator/contract_function_simulator.ts +114 -34
  231. package/src/contract_function_simulator/execution_note_cache.ts +51 -29
  232. package/src/contract_function_simulator/execution_tagging_index_cache.ts +1 -1
  233. package/src/contract_function_simulator/hashed_values_cache.ts +1 -1
  234. package/src/contract_function_simulator/index.ts +1 -1
  235. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +6 -2
  236. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +6 -5
  237. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -1
  238. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +2 -2
  239. package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
  240. package/src/contract_function_simulator/oracle/interfaces.ts +25 -15
  241. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +1 -1
  242. package/src/contract_function_simulator/oracle/note_packing_utils.ts +27 -13
  243. package/src/contract_function_simulator/oracle/oracle.ts +83 -44
  244. package/src/contract_function_simulator/oracle/private_execution.ts +2 -69
  245. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +120 -59
  246. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +266 -82
  247. package/src/contract_function_simulator/pick_notes.ts +1 -1
  248. package/src/contract_function_simulator/proxied_contract_data_source.ts +24 -7
  249. package/src/contract_sync/index.ts +98 -0
  250. package/src/debug/pxe_debug_utils.ts +63 -0
  251. package/src/entrypoints/client/bundle/index.ts +0 -1
  252. package/src/entrypoints/client/bundle/utils.ts +15 -16
  253. package/src/entrypoints/client/lazy/index.ts +0 -1
  254. package/src/entrypoints/client/lazy/utils.ts +16 -17
  255. package/src/entrypoints/pxe_creation_options.ts +6 -2
  256. package/src/entrypoints/server/index.ts +3 -1
  257. package/src/entrypoints/server/utils.ts +26 -34
  258. package/src/error_enriching.ts +7 -15
  259. package/src/events/event_service.ts +71 -0
  260. package/src/events/index.ts +1 -0
  261. package/src/events/private_event_filter_validator.ts +46 -0
  262. package/src/job_coordinator/job_coordinator.ts +150 -0
  263. package/src/logs/log_service.ts +220 -0
  264. package/src/notes/index.ts +1 -0
  265. package/src/notes/note_service.ts +195 -0
  266. package/src/oracle_version.ts +4 -3
  267. package/src/private_kernel/hints/index.ts +1 -1
  268. package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +34 -23
  269. package/src/private_kernel/private_kernel_execution_prover.ts +13 -12
  270. package/src/private_kernel/private_kernel_oracle.ts +118 -37
  271. package/src/pxe.ts +267 -282
  272. package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +16 -16
  273. package/src/storage/address_store/index.ts +1 -0
  274. package/src/storage/{sync_data_provider/sync_data_provider.ts → anchor_block_store/anchor_block_store.ts} +10 -12
  275. package/src/storage/anchor_block_store/index.ts +1 -0
  276. package/src/storage/capsule_store/capsule_store.ts +315 -0
  277. package/src/storage/capsule_store/index.ts +1 -0
  278. package/src/storage/{contract_data_provider/contract_data_provider.ts → contract_store/contract_store.ts} +67 -14
  279. package/src/storage/contract_store/index.ts +1 -0
  280. package/src/storage/{contract_data_provider → contract_store}/private_functions_tree.ts +1 -1
  281. package/src/storage/index.ts +7 -7
  282. package/src/storage/metadata.ts +1 -1
  283. package/src/storage/note_store/index.ts +2 -0
  284. package/src/storage/note_store/note_store.ts +411 -0
  285. package/src/storage/note_store/stored_note.ts +48 -0
  286. package/src/storage/private_event_store/private_event_store.ts +384 -0
  287. package/src/storage/private_event_store/stored_private_event.ts +73 -0
  288. package/src/storage/tagging_store/index.ts +3 -0
  289. package/src/storage/tagging_store/recipient_tagging_store.ts +139 -0
  290. package/src/storage/tagging_store/sender_address_book_store.ts +48 -0
  291. package/src/storage/tagging_store/sender_tagging_store.ts +429 -0
  292. package/src/tagging/constants.ts +10 -2
  293. package/src/tagging/get_all_logs_by_tags.ts +68 -0
  294. package/src/tagging/index.ts +18 -5
  295. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +143 -0
  296. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +34 -0
  297. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +49 -0
  298. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +99 -0
  299. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +36 -0
  300. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +84 -0
  301. package/dest/contract_function_simulator/execution_data_provider.d.ts +0 -267
  302. package/dest/contract_function_simulator/execution_data_provider.d.ts.map +0 -1
  303. package/dest/contract_function_simulator/execution_data_provider.js +0 -14
  304. package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
  305. package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
  306. package/dest/contract_function_simulator/proxied_node.js +0 -27
  307. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +0 -123
  308. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +0 -1
  309. package/dest/contract_function_simulator/pxe_oracle_interface.js +0 -696
  310. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
  311. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
  312. package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -45
  313. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
  314. package/dest/private_kernel/private_kernel_oracle_impl.js +0 -86
  315. package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -11
  316. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +0 -1
  317. package/dest/storage/address_data_provider/index.d.ts +0 -2
  318. package/dest/storage/address_data_provider/index.d.ts.map +0 -1
  319. package/dest/storage/address_data_provider/index.js +0 -1
  320. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +0 -25
  321. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +0 -1
  322. package/dest/storage/capsule_data_provider/capsule_data_provider.js +0 -118
  323. package/dest/storage/capsule_data_provider/index.d.ts +0 -2
  324. package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
  325. package/dest/storage/capsule_data_provider/index.js +0 -1
  326. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
  327. package/dest/storage/contract_data_provider/index.d.ts +0 -2
  328. package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
  329. package/dest/storage/contract_data_provider/index.js +0 -1
  330. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
  331. package/dest/storage/note_data_provider/index.d.ts +0 -3
  332. package/dest/storage/note_data_provider/index.d.ts.map +0 -1
  333. package/dest/storage/note_data_provider/index.js +0 -2
  334. package/dest/storage/note_data_provider/note_data_provider.d.ts +0 -83
  335. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
  336. package/dest/storage/note_data_provider/note_data_provider.js +0 -314
  337. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +0 -37
  338. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +0 -1
  339. package/dest/storage/private_event_data_provider/private_event_data_provider.js +0 -105
  340. package/dest/storage/sync_data_provider/index.d.ts.map +0 -1
  341. package/dest/storage/sync_data_provider/index.js +0 -1
  342. package/dest/storage/sync_data_provider/sync_data_provider.d.ts +0 -11
  343. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +0 -1
  344. package/dest/storage/tagging_data_provider/index.d.ts +0 -2
  345. package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
  346. package/dest/storage/tagging_data_provider/index.js +0 -1
  347. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +0 -40
  348. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +0 -1
  349. package/dest/storage/tagging_data_provider/tagging_data_provider.js +0 -89
  350. package/dest/synchronizer/index.d.ts +0 -2
  351. package/dest/synchronizer/index.d.ts.map +0 -1
  352. package/dest/synchronizer/index.js +0 -1
  353. package/dest/synchronizer/synchronizer.d.ts +0 -36
  354. package/dest/synchronizer/synchronizer.d.ts.map +0 -1
  355. package/dest/synchronizer/synchronizer.js +0 -102
  356. package/dest/tagging/siloed_tag.d.ts +0 -14
  357. package/dest/tagging/siloed_tag.d.ts.map +0 -1
  358. package/dest/tagging/siloed_tag.js +0 -20
  359. package/dest/tagging/tag.d.ts +0 -12
  360. package/dest/tagging/tag.d.ts.map +0 -1
  361. package/dest/tagging/tag.js +0 -17
  362. package/dest/tagging/utils.d.ts +0 -18
  363. package/dest/tagging/utils.d.ts.map +0 -1
  364. package/dest/tagging/utils.js +0 -24
  365. package/src/contract_function_simulator/execution_data_provider.ts +0 -342
  366. package/src/contract_function_simulator/proxied_node.ts +0 -33
  367. package/src/contract_function_simulator/pxe_oracle_interface.ts +0 -1023
  368. package/src/private_kernel/private_kernel_oracle_impl.ts +0 -132
  369. package/src/storage/address_data_provider/index.ts +0 -1
  370. package/src/storage/capsule_data_provider/capsule_data_provider.ts +0 -147
  371. package/src/storage/capsule_data_provider/index.ts +0 -1
  372. package/src/storage/contract_data_provider/index.ts +0 -1
  373. package/src/storage/note_data_provider/index.ts +0 -2
  374. package/src/storage/note_data_provider/note_data_provider.ts +0 -403
  375. package/src/storage/private_event_data_provider/private_event_data_provider.ts +0 -143
  376. package/src/storage/sync_data_provider/index.ts +0 -1
  377. package/src/storage/tagging_data_provider/index.ts +0 -1
  378. package/src/storage/tagging_data_provider/tagging_data_provider.ts +0 -120
  379. package/src/synchronizer/index.ts +0 -1
  380. package/src/synchronizer/synchronizer.ts +0 -121
  381. package/src/tagging/siloed_tag.ts +0 -22
  382. package/src/tagging/tag.ts +0 -16
  383. package/src/tagging/utils.ts +0 -31
@@ -0,0 +1,9 @@
1
+ import type { PrivateEventFilter } from '@aztec/aztec.js/wallet';
2
+ import { BlockNumber } from '@aztec/foundation/branded-types';
3
+ import type { PrivateEventStoreFilter } from '../storage/private_event_store/private_event_store.js';
4
+ export declare class PrivateEventFilterValidator {
5
+ private lastBlock;
6
+ constructor(lastBlock: BlockNumber);
7
+ validate(filter: PrivateEventFilter): PrivateEventStoreFilter;
8
+ }
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF0ZV9ldmVudF9maWx0ZXJfdmFsaWRhdG9yLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZXZlbnRzL3ByaXZhdGVfZXZlbnRfZmlsdGVyX3ZhbGlkYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBRWpFLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUU5RCxPQUFPLEtBQUssRUFBRSx1QkFBdUIsRUFBRSxNQUFNLHVEQUF1RCxDQUFDO0FBRXJHLHFCQUFhLDJCQUEyQjtJQUMxQixPQUFPLENBQUMsU0FBUztJQUE3QixZQUFvQixTQUFTLEVBQUUsV0FBVyxFQUFJO0lBRTlDLFFBQVEsQ0FBQyxNQUFNLEVBQUUsa0JBQWtCLEdBQUcsdUJBQXVCLENBbUM1RDtDQUNGIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private_event_filter_validator.d.ts","sourceRoot":"","sources":["../../src/events/private_event_filter_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uDAAuD,CAAC;AAErG,qBAAa,2BAA2B;IAC1B,OAAO,CAAC,SAAS;IAA7B,YAAoB,SAAS,EAAE,WAAW,EAAI;IAE9C,QAAQ,CAAC,MAAM,EAAE,kBAAkB,GAAG,uBAAuB,CAmC5D;CACF"}
@@ -0,0 +1,38 @@
1
+ import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
2
+ import { BlockNumber } from '@aztec/foundation/branded-types';
3
+ export class PrivateEventFilterValidator {
4
+ lastBlock;
5
+ constructor(lastBlock){
6
+ this.lastBlock = lastBlock;
7
+ }
8
+ validate(filter) {
9
+ let { fromBlock, toBlock } = filter;
10
+ // Block range filters in Aztec Node are defined as closed-open intervals [fromBlock, toBlock), so
11
+ // we respect that convention here for consistency.
12
+ // We then default to [INITIAL_L2_BLOCK_NUM, latestKnownBlock + 1), ie: by default return events from
13
+ // the first block to the latest known block.
14
+ if (!fromBlock || !toBlock) {
15
+ fromBlock = fromBlock ?? BlockNumber(INITIAL_L2_BLOCK_NUM);
16
+ toBlock = toBlock ?? BlockNumber(this.lastBlock + 1);
17
+ }
18
+ if (filter.scopes.length === 0) {
19
+ throw new Error('At least one scope is required to get private events');
20
+ }
21
+ if (fromBlock < 1) {
22
+ throw new Error('fromBlock must be greater than or equal to 1');
23
+ }
24
+ if (toBlock < 1) {
25
+ throw new Error('toBlock must be greater than or equal to 1');
26
+ }
27
+ if (fromBlock >= toBlock) {
28
+ throw new Error('toBlock must be strictly greater than fromBlock');
29
+ }
30
+ return {
31
+ contractAddress: filter.contractAddress,
32
+ scopes: filter.scopes,
33
+ txHash: filter.txHash,
34
+ toBlock,
35
+ fromBlock
36
+ };
37
+ }
38
+ }
@@ -0,0 +1,75 @@
1
+ import { type LoggerBindings } from '@aztec/foundation/log';
2
+ import type { AztecAsyncKVStore } from '@aztec/kv-store';
3
+ /**
4
+ * Interface that stores must implement to support staged writes.
5
+ */
6
+ export interface StagedStore {
7
+ /** Unique name identifying this store (used for tracking staged stores from JobCoordinator) */
8
+ readonly storeName: string;
9
+ /**
10
+ * Commits staged data to main storage.
11
+ * Should be called within a transaction for atomicity.
12
+ *
13
+ * @param jobId - The job identifier
14
+ */
15
+ commit(jobId: string): Promise<void>;
16
+ /**
17
+ * Discards staged data without committing.
18
+ * Called on abort.
19
+ *
20
+ * @param jobId - The job identifier
21
+ */
22
+ discardStaged(jobId: string): Promise<void>;
23
+ }
24
+ /**
25
+ * JobCoordinator manages job lifecycle and provides crash resilience for PXE operations.
26
+ *
27
+ * It uses a staged writes pattern:
28
+ * 1. When a job begins, a unique job ID is created
29
+ * 2. During the job, all writes go to staging (keyed by job ID)
30
+ * 3. On commit, staging is promoted to main storage
31
+ * 4. On abort, staged data is discarded
32
+ *
33
+ * Note: PXE should only rely on a single JobCoordinator instance, so it can eventually
34
+ * orchestrate concurrent jobs. Right now it doesn't make a difference because we're
35
+ * using a job queue with concurrency=1.
36
+ */
37
+ export declare class JobCoordinator {
38
+ #private;
39
+ private readonly log;
40
+ /** The underlying KV store */
41
+ kvStore: AztecAsyncKVStore;
42
+ constructor(kvStore: AztecAsyncKVStore, bindings?: LoggerBindings);
43
+ /**
44
+ * Registers a staged store.
45
+ * Must be called during initialization for all stores that need staging support.
46
+ */
47
+ registerStore(store: StagedStore): void;
48
+ /**
49
+ * Registers multiple staged stores.
50
+ */
51
+ registerStores(stores: StagedStore[]): void;
52
+ /**
53
+ * Begins a new job and returns a job ID for staged writes.
54
+ *
55
+ * @returns Job ID to pass to store operations
56
+ */
57
+ beginJob(): string;
58
+ /**
59
+ * Commits a job by promoting all staged data to main storage.
60
+ *
61
+ * @param jobId - The job ID returned from beginJob
62
+ */
63
+ commitJob(jobId: string): Promise<void>;
64
+ /**
65
+ * Aborts a job by discarding all staged data.
66
+ *
67
+ * @param jobId - The job ID returned from beginJob
68
+ */
69
+ abortJob(jobId: string): Promise<void>;
70
+ /**
71
+ * Checks if there's a job currently in progress.
72
+ */
73
+ hasJobInProgress(): boolean;
74
+ }
75
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiam9iX2Nvb3JkaW5hdG9yLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvam9iX2Nvb3JkaW5hdG9yL2pvYl9jb29yZGluYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQWUsS0FBSyxjQUFjLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFDdkYsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUV6RDs7R0FFRztBQUNILE1BQU0sV0FBVyxXQUFXO0lBQzFCLCtGQUErRjtJQUMvRixRQUFRLENBQUMsU0FBUyxFQUFFLE1BQU0sQ0FBQztJQUUzQjs7Ozs7T0FLRztJQUNILE1BQU0sQ0FBQyxLQUFLLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUVyQzs7Ozs7T0FLRztJQUNILGFBQWEsQ0FBQyxLQUFLLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQztDQUM3QztBQUVEOzs7Ozs7Ozs7Ozs7R0FZRztBQUNILHFCQUFhLGNBQWM7O0lBQ3pCLE9BQU8sQ0FBQyxRQUFRLENBQUMsR0FBRyxDQUFTO0lBRTdCLDhCQUE4QjtJQUM5QixPQUFPLE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,QAAQ,CAAC,GAAG,CAAS;IAE7B,8BAA8B;IAC9B,OAAO,EAAE,iBAAiB,CAAC;IAK3B,YAAY,OAAO,EAAE,iBAAiB,EAAE,QAAQ,CAAC,EAAE,cAAc,EAGhE;IAED;;;OAGG;IACH,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAMtC;IAED;;OAEG;IACH,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAI1C;IAED;;;;OAIG;IACH,QAAQ,IAAI,MAAM,CAajB;IAED;;;;OAIG;IACG,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAmB5C;IAED;;;;OAIG;IACG,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAc3C;IAED;;OAEG;IACH,gBAAgB,IAAI,OAAO,CAE1B;CACF"}
@@ -0,0 +1,94 @@
1
+ import { randomBytes } from '@aztec/foundation/crypto/random';
2
+ import { createLogger } from '@aztec/foundation/log';
3
+ /**
4
+ * JobCoordinator manages job lifecycle and provides crash resilience for PXE operations.
5
+ *
6
+ * It uses a staged writes pattern:
7
+ * 1. When a job begins, a unique job ID is created
8
+ * 2. During the job, all writes go to staging (keyed by job ID)
9
+ * 3. On commit, staging is promoted to main storage
10
+ * 4. On abort, staged data is discarded
11
+ *
12
+ * Note: PXE should only rely on a single JobCoordinator instance, so it can eventually
13
+ * orchestrate concurrent jobs. Right now it doesn't make a difference because we're
14
+ * using a job queue with concurrency=1.
15
+ */ export class JobCoordinator {
16
+ log;
17
+ /** The underlying KV store */ kvStore;
18
+ #currentJobId;
19
+ #stores = new Map();
20
+ constructor(kvStore, bindings){
21
+ this.kvStore = kvStore;
22
+ this.log = createLogger('pxe:job_coordinator', bindings);
23
+ }
24
+ /**
25
+ * Registers a staged store.
26
+ * Must be called during initialization for all stores that need staging support.
27
+ */ registerStore(store) {
28
+ if (this.#stores.has(store.storeName)) {
29
+ throw new Error(`Store "${store.storeName}" is already registered`);
30
+ }
31
+ this.#stores.set(store.storeName, store);
32
+ this.log.debug(`Registered staged store: ${store.storeName}`);
33
+ }
34
+ /**
35
+ * Registers multiple staged stores.
36
+ */ registerStores(stores) {
37
+ for (const store of stores){
38
+ this.registerStore(store);
39
+ }
40
+ }
41
+ /**
42
+ * Begins a new job and returns a job ID for staged writes.
43
+ *
44
+ * @returns Job ID to pass to store operations
45
+ */ beginJob() {
46
+ if (this.#currentJobId) {
47
+ throw new Error(`Cannot begin job: job ${this.#currentJobId} is already in progress. ` + `This should not happen - ensure jobs are properly committed or aborted.`);
48
+ }
49
+ const jobId = randomBytes(8).toString('hex');
50
+ this.#currentJobId = jobId;
51
+ this.log.debug(`Started job ${jobId}`);
52
+ return jobId;
53
+ }
54
+ /**
55
+ * Commits a job by promoting all staged data to main storage.
56
+ *
57
+ * @param jobId - The job ID returned from beginJob
58
+ */ async commitJob(jobId) {
59
+ if (!this.#currentJobId || this.#currentJobId !== jobId) {
60
+ throw new Error(`Cannot commit job ${jobId}: no matching job in progress. ` + `Current job: ${this.#currentJobId ?? 'none'}`);
61
+ }
62
+ this.log.debug(`Committing job ${jobId}`);
63
+ // Commit all stores atomically in a single transaction.
64
+ // Each store's commit is a no-op if it has no staged data (but that's up to each store to handle).
65
+ await this.kvStore.transactionAsync(async ()=>{
66
+ for (const store of this.#stores.values()){
67
+ await store.commit(jobId);
68
+ }
69
+ });
70
+ this.#currentJobId = undefined;
71
+ this.log.debug(`Job ${jobId} committed successfully`);
72
+ }
73
+ /**
74
+ * Aborts a job by discarding all staged data.
75
+ *
76
+ * @param jobId - The job ID returned from beginJob
77
+ */ async abortJob(jobId) {
78
+ if (!this.#currentJobId || this.#currentJobId !== jobId) {
79
+ // Job may have already been aborted or never started properly
80
+ this.log.warn(`Abort called for job ${jobId} but current job is ${this.#currentJobId ?? 'none'}`);
81
+ }
82
+ this.log.debug(`Aborting job ${jobId}`);
83
+ for (const store of this.#stores.values()){
84
+ await store.discardStaged(jobId);
85
+ }
86
+ this.#currentJobId = undefined;
87
+ this.log.debug(`Job ${jobId} aborted`);
88
+ }
89
+ /**
90
+ * Checks if there's a job currently in progress.
91
+ */ hasJobInProgress() {
92
+ return this.#currentJobId !== undefined;
93
+ }
94
+ }
@@ -0,0 +1,28 @@
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { type LoggerBindings } from '@aztec/foundation/log';
3
+ import type { KeyStore } from '@aztec/key-store';
4
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
+ import type { AztecNode } from '@aztec/stdlib/interfaces/server';
6
+ import type { BlockHeader } from '@aztec/stdlib/tx';
7
+ import type { LogRetrievalRequest } from '../contract_function_simulator/noir-structs/log_retrieval_request.js';
8
+ import { LogRetrievalResponse } from '../contract_function_simulator/noir-structs/log_retrieval_response.js';
9
+ import { AddressStore } from '../storage/address_store/address_store.js';
10
+ import { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
11
+ import type { RecipientTaggingStore } from '../storage/tagging_store/recipient_tagging_store.js';
12
+ import type { SenderAddressBookStore } from '../storage/tagging_store/sender_address_book_store.js';
13
+ export declare class LogService {
14
+ #private;
15
+ private readonly aztecNode;
16
+ private readonly anchorBlockHeader;
17
+ private readonly keyStore;
18
+ private readonly capsuleStore;
19
+ private readonly recipientTaggingStore;
20
+ private readonly senderAddressBookStore;
21
+ private readonly addressStore;
22
+ private readonly jobId;
23
+ private log;
24
+ constructor(aztecNode: AztecNode, anchorBlockHeader: BlockHeader, keyStore: KeyStore, capsuleStore: CapsuleStore, recipientTaggingStore: RecipientTaggingStore, senderAddressBookStore: SenderAddressBookStore, addressStore: AddressStore, jobId: string, bindings?: LoggerBindings);
25
+ bulkRetrieveLogs(logRetrievalRequests: LogRetrievalRequest[]): Promise<(LogRetrievalResponse | null)[]>;
26
+ syncTaggedLogs(contractAddress: AztecAddress, pendingTaggedLogArrayBaseSlot: Fr, scopes?: AztecAddress[]): Promise<void>;
27
+ }
28
+ //# source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BAAoB,GAAG,IAAI,CAAC,EAAE,CAAC,CAiBnH;IAuDY,cAAc,CACzB,eAAe,EAAE,YAAY,EAC7B,6BAA6B,EAAE,EAAE,EACjC,MAAM,CAAC,EAAE,YAAY,EAAE,iBA0CxB;CAgEF"}
@@ -0,0 +1,125 @@
1
+ import { createLogger } from '@aztec/foundation/log';
2
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import { DirectionalAppTaggingSecret, PendingTaggedLog, SiloedTag } from '@aztec/stdlib/logs';
4
+ import { LogRetrievalResponse } from '../contract_function_simulator/noir-structs/log_retrieval_response.js';
5
+ import { getAllPrivateLogsByTags, getAllPublicLogsByTagsFromContract, loadPrivateLogsForSenderRecipientPair } from '../tagging/index.js';
6
+ export class LogService {
7
+ aztecNode;
8
+ anchorBlockHeader;
9
+ keyStore;
10
+ capsuleStore;
11
+ recipientTaggingStore;
12
+ senderAddressBookStore;
13
+ addressStore;
14
+ jobId;
15
+ log;
16
+ constructor(aztecNode, anchorBlockHeader, keyStore, capsuleStore, recipientTaggingStore, senderAddressBookStore, addressStore, jobId, bindings){
17
+ this.aztecNode = aztecNode;
18
+ this.anchorBlockHeader = anchorBlockHeader;
19
+ this.keyStore = keyStore;
20
+ this.capsuleStore = capsuleStore;
21
+ this.recipientTaggingStore = recipientTaggingStore;
22
+ this.senderAddressBookStore = senderAddressBookStore;
23
+ this.addressStore = addressStore;
24
+ this.jobId = jobId;
25
+ this.log = createLogger('pxe:log_service', bindings);
26
+ }
27
+ async bulkRetrieveLogs(logRetrievalRequests) {
28
+ return await Promise.all(logRetrievalRequests.map(async (request)=>{
29
+ const [publicLog, privateLog] = await Promise.all([
30
+ this.#getPublicLogByTag(request.tag, request.contractAddress),
31
+ this.#getPrivateLogByTag(await SiloedTag.compute(request.tag, request.contractAddress))
32
+ ]);
33
+ if (publicLog !== null && privateLog !== null) {
34
+ throw new Error(`Found both a public and private log when searching for tag ${request.tag} from contract ${request.contractAddress}`);
35
+ }
36
+ return publicLog ?? privateLog;
37
+ }));
38
+ }
39
+ async #getPublicLogByTag(tag, contractAddress) {
40
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
41
+ const allLogsPerTag = await getAllPublicLogsByTagsFromContract(this.aztecNode, contractAddress, [
42
+ tag
43
+ ], anchorBlockHash);
44
+ const logsForTag = allLogsPerTag[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
+ }
51
+ const scopedLog = logsForTag[0];
52
+ return new LogRetrievalResponse(scopedLog.logData.slice(1), scopedLog.txHash, scopedLog.noteHashes, scopedLog.firstNullifier);
53
+ }
54
+ async #getPrivateLogByTag(siloedTag) {
55
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
56
+ const allLogsPerTag = await getAllPrivateLogsByTags(this.aztecNode, [
57
+ siloedTag
58
+ ], anchorBlockHash);
59
+ const logsForTag = allLogsPerTag[0];
60
+ if (logsForTag.length === 0) {
61
+ return null;
62
+ } else if (logsForTag.length > 1) {
63
+ // TODO(#11627): handle this case
64
+ throw new Error(`Got ${logsForTag.length} logs for tag ${siloedTag}. getPrivateLogByTag currently only supports a single log per tag`);
65
+ }
66
+ const scopedLog = logsForTag[0];
67
+ return new LogRetrievalResponse(scopedLog.logData.slice(1), scopedLog.txHash, scopedLog.noteHashes, scopedLog.firstNullifier);
68
+ }
69
+ async syncTaggedLogs(contractAddress, pendingTaggedLogArrayBaseSlot, scopes) {
70
+ this.log.verbose('Searching for tagged logs', {
71
+ contract: contractAddress
72
+ });
73
+ // We only load logs from block up to and including the anchor block number
74
+ const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
75
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
76
+ // Determine recipients: use scopes if provided, otherwise get all accounts
77
+ const recipients = scopes && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
78
+ // For each recipient, fetch secrets, load logs, and store them.
79
+ // We run these per-recipient tasks in parallel so that logs are loaded for all recipients concurrently.
80
+ await Promise.all(recipients.map(async (recipient)=>{
81
+ // Get all secrets for this recipient (one per sender)
82
+ const secrets = await this.#getSecretsForSenders(contractAddress, recipient);
83
+ // Load logs for all sender-recipient pairs in parallel
84
+ const logArrays = await Promise.all(secrets.map((secret)=>loadPrivateLogsForSenderRecipientPair(secret, contractAddress, this.aztecNode, this.recipientTaggingStore, anchorBlockNumber, anchorBlockHash, this.jobId)));
85
+ // Flatten all logs from all secrets
86
+ const allLogs = logArrays.flat();
87
+ // Store the logs for this recipient
88
+ if (allLogs.length > 0) {
89
+ await this.#storePendingTaggedLogs(contractAddress, pendingTaggedLogArrayBaseSlot, recipient, allLogs);
90
+ }
91
+ }));
92
+ }
93
+ async #getSecretsForSenders(contractAddress, recipient) {
94
+ const recipientCompleteAddress = await this.#getCompleteAddress(recipient);
95
+ const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
96
+ // We implicitly add all PXE accounts as senders, this helps us decrypt tags on notes that we send to ourselves
97
+ // (recipient = us, sender = us)
98
+ const allSenders = [
99
+ ...await this.senderAddressBookStore.getSenders(),
100
+ ...await this.keyStore.getAccounts()
101
+ ];
102
+ // We deduplicate the senders by adding them to a set and then converting the set back to an array
103
+ const deduplicatedSenders = Array.from(new Set(allSenders.map((sender)=>sender.toString()))).map((sender)=>AztecAddress.fromString(sender));
104
+ return Promise.all(deduplicatedSenders.map((sender)=>{
105
+ return DirectionalAppTaggingSecret.compute(recipientCompleteAddress, recipientIvsk, sender, contractAddress, recipient);
106
+ }));
107
+ }
108
+ #storePendingTaggedLogs(contractAddress, capsuleArrayBaseSlot, recipient, privateLogs) {
109
+ // Build all pending tagged logs from the scoped logs
110
+ const pendingTaggedLogs = privateLogs.map((scopedLog)=>{
111
+ const pendingTaggedLog = new PendingTaggedLog(scopedLog.logData, scopedLog.txHash, scopedLog.noteHashes, scopedLog.firstNullifier, recipient);
112
+ return pendingTaggedLog.toFields();
113
+ });
114
+ // TODO: This looks like it could belong more at the oracle interface level
115
+ return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs, this.jobId);
116
+ }
117
+ async #getCompleteAddress(account) {
118
+ const completeAddress = await this.addressStore.getCompleteAddress(account);
119
+ if (!completeAddress) {
120
+ throw new Error(`No public key registered for address ${account}.
121
+ 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`);
122
+ }
123
+ return completeAddress;
124
+ }
125
+ }
@@ -0,0 +1,2 @@
1
+ export { NoteService } from './note_service.js';
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ub3Rlcy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0sbUJBQW1CLENBQUMifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1 @@
1
+ export { NoteService } from './note_service.js';
@@ -0,0 +1,48 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import { type AztecNode } from '@aztec/stdlib/interfaces/client';
4
+ import { Note, NoteStatus } from '@aztec/stdlib/note';
5
+ import type { BlockHeader, TxHash } from '@aztec/stdlib/tx';
6
+ import type { NoteStore } from '../storage/note_store/note_store.js';
7
+ export declare class NoteService {
8
+ private readonly noteStore;
9
+ private readonly aztecNode;
10
+ private readonly anchorBlockHeader;
11
+ private readonly jobId;
12
+ constructor(noteStore: NoteStore, aztecNode: AztecNode, anchorBlockHeader: BlockHeader, jobId: string);
13
+ /**
14
+ * Retrieves a set of notes stored in the database for a given contract address and storage slot.
15
+ * The query result is paginated using 'limit' and 'offset' values.
16
+ * Returns an object containing an array of note data.
17
+ *
18
+ * @param owner - The owner of the notes. If undefined, returns notes for all known owners.
19
+ * @param status - The status of notes to fetch.
20
+ * @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
21
+ */
22
+ getNotes(contractAddress: AztecAddress, owner: AztecAddress | undefined, storageSlot: Fr, status: NoteStatus, scopes?: AztecAddress[]): Promise<{
23
+ contractAddress: AztecAddress;
24
+ owner: AztecAddress;
25
+ storageSlot: Fr;
26
+ randomness: Fr;
27
+ noteNonce: Fr;
28
+ note: Note;
29
+ noteHash: Fr;
30
+ isPending: boolean;
31
+ siloedNullifier: Fr;
32
+ }[]>;
33
+ /**
34
+ * Looks for nullifiers of active contract notes and marks them as nullified if a nullifier is found.
35
+ *
36
+ * Fetches notes from the NoteStore and checks which nullifiers are present in the
37
+ * onchain nullifier Merkle tree - up to the latest locally synced block. We use the
38
+ * locally synced block instead of querying the chain's 'latest' block to ensure correctness:
39
+ * notes are only marked nullified once their corresponding nullifier has been included in a
40
+ * block up to which the PXE has synced.
41
+ * This allows recent nullifications to be processed even if the node is not an archive node.
42
+ *
43
+ * @param contractAddress - The contract whose notes should be checked and nullified.
44
+ */
45
+ syncNoteNullifiers(contractAddress: AztecAddress): Promise<void>;
46
+ validateAndStoreNote(contractAddress: AztecAddress, owner: AztecAddress, storageSlot: Fr, randomness: Fr, noteNonce: Fr, content: Fr[], noteHash: Fr, nullifier: Fr, txHash: TxHash, recipient: AztecAddress): Promise<void>;
47
+ }
48
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm90ZV9zZXJ2aWNlLmQudHMiLCJzb3V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AAS,EAAE,SAAS,EACpB,iBAAiB,EAAE,WAAW,EAC9B,KAAK,EAAE,MAAM,EAC5B;IAEJ;;;;;;;;OAQG;IACU,QAAQ,CACnB,eAAe,EAAE,YAAY,EAC7B,KAAK,EAAE,YAAY,GAAG,SAAS,EAC/B,WAAW,EAAE,EAAE,EACf,MAAM,EAAE,UAAU,EAClB,MAAM,CAAC,EAAE,YAAY,EAAE;;;;;;;;;;SAyBxB;IAED;;;;;;;;;;;OAWG;IACU,kBAAkB,CAAC,eAAe,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAsC5E;IAEY,oBAAoB,CAC/B,eAAe,EAAE,YAAY,EAC7B,KAAK,EAAE,YAAY,EACnB,WAAW,EAAE,EAAE,EACf,UAAU,EAAE,EAAE,EACd,SAAS,EAAE,EAAE,EACb,OAAO,EAAE,EAAE,EAAE,EACb,QAAQ,EAAE,EAAE,EACZ,SAAS,EAAE,EAAE,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,IAAI,CAAC,CAsEf;CACF"}
@@ -0,0 +1,147 @@
1
+ import { computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
2
+ import { MAX_RPC_LEN } from '@aztec/stdlib/interfaces/client';
3
+ import { Note, NoteDao } from '@aztec/stdlib/note';
4
+ import { MerkleTreeId } from '@aztec/stdlib/trees';
5
+ export class NoteService {
6
+ noteStore;
7
+ aztecNode;
8
+ anchorBlockHeader;
9
+ jobId;
10
+ constructor(noteStore, aztecNode, anchorBlockHeader, jobId){
11
+ this.noteStore = noteStore;
12
+ this.aztecNode = aztecNode;
13
+ this.anchorBlockHeader = anchorBlockHeader;
14
+ this.jobId = jobId;
15
+ }
16
+ /**
17
+ * Retrieves a set of notes stored in the database for a given contract address and storage slot.
18
+ * The query result is paginated using 'limit' and 'offset' values.
19
+ * Returns an object containing an array of note data.
20
+ *
21
+ * @param owner - The owner of the notes. If undefined, returns notes for all known owners.
22
+ * @param status - The status of notes to fetch.
23
+ * @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
24
+ */ async getNotes(contractAddress, owner, storageSlot, status, scopes) {
25
+ const noteDaos = await this.noteStore.getNotes({
26
+ contractAddress,
27
+ owner,
28
+ storageSlot,
29
+ status,
30
+ scopes
31
+ }, this.jobId);
32
+ return noteDaos.map(({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier })=>({
33
+ contractAddress,
34
+ owner,
35
+ storageSlot,
36
+ randomness,
37
+ noteNonce,
38
+ note,
39
+ noteHash,
40
+ isPending: false,
41
+ siloedNullifier
42
+ }));
43
+ }
44
+ /**
45
+ * Looks for nullifiers of active contract notes and marks them as nullified if a nullifier is found.
46
+ *
47
+ * Fetches notes from the NoteStore and checks which nullifiers are present in the
48
+ * onchain nullifier Merkle tree - up to the latest locally synced block. We use the
49
+ * locally synced block instead of querying the chain's 'latest' block to ensure correctness:
50
+ * notes are only marked nullified once their corresponding nullifier has been included in a
51
+ * block up to which the PXE has synced.
52
+ * This allows recent nullifications to be processed even if the node is not an archive node.
53
+ *
54
+ * @param contractAddress - The contract whose notes should be checked and nullified.
55
+ */ async syncNoteNullifiers(contractAddress) {
56
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
57
+ const contractNotes = await this.noteStore.getNotes({
58
+ contractAddress
59
+ }, this.jobId);
60
+ if (contractNotes.length === 0) {
61
+ return;
62
+ }
63
+ const nullifiersToCheck = contractNotes.map((note)=>note.siloedNullifier);
64
+ const nullifierBatches = nullifiersToCheck.reduce((acc, nullifier)=>{
65
+ if (acc[acc.length - 1].length < MAX_RPC_LEN) {
66
+ acc[acc.length - 1].push(nullifier);
67
+ } else {
68
+ acc.push([
69
+ nullifier
70
+ ]);
71
+ }
72
+ return acc;
73
+ }, [
74
+ []
75
+ ]);
76
+ const nullifierIndexes = (await Promise.all(nullifierBatches.map((batch)=>this.aztecNode.findLeavesIndexes(anchorBlockHash, MerkleTreeId.NULLIFIER_TREE, batch)))).flat();
77
+ const foundNullifiers = nullifiersToCheck.map((nullifier, i)=>{
78
+ if (nullifierIndexes[i] !== undefined) {
79
+ return {
80
+ ...nullifierIndexes[i],
81
+ ...{
82
+ data: nullifier
83
+ }
84
+ };
85
+ }
86
+ }).filter((nullifier)=>nullifier !== undefined);
87
+ await this.noteStore.applyNullifiers(foundNullifiers, this.jobId);
88
+ }
89
+ async validateAndStoreNote(contractAddress, owner, storageSlot, randomness, noteNonce, content, noteHash, nullifier, txHash, recipient) {
90
+ // We are going to store the new note in the NoteStore, which will let us later return it via `getNotes`.
91
+ // There's two things we need to check before we do this however:
92
+ // - we must make sure the note does actually exist in the note hash tree
93
+ // - we need to check if the note has already been nullified
94
+ //
95
+ // Failing to do either of the above would result in circuits getting either non-existent notes and failing to
96
+ // produce inclusion proofs for them, or getting nullified notes and producing duplicate nullifiers, both of which
97
+ // are catastrophic failure modes.
98
+ //
99
+ // Note that adding a note and removing it is *not* equivalent to never adding it in the first place. A nullifier
100
+ // emitted in a block that comes after note creation might result in the note being de-nullified by a chain reorg,
101
+ // so we must store both the note hash and nullifier block information.
102
+ // We avoid making node queries at 'latest' since we don't want to process notes or nullifiers that only exist ahead
103
+ // in time of the locally synced state.
104
+ // Note that while this technically results in historical queries, we perform it at the latest locally synced block
105
+ // number which *should* be recent enough to be available, even for non-archive nodes.
106
+ // Also note that the note should never be ahead of the synced block here since `fetchTaggedLogs` only processes
107
+ // logs up to the synced block making this only an additional safety check.
108
+ const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
109
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
110
+ // By computing siloed and unique note hashes ourselves we prevent contracts from interfering with the note storage
111
+ // of other contracts, which would constitute a security breach.
112
+ const uniqueNoteHash = await computeUniqueNoteHash(noteNonce, await siloNoteHash(contractAddress, noteHash));
113
+ const siloedNullifier = await siloNullifier(contractAddress, nullifier);
114
+ const [txEffect, [nullifierIndex]] = await Promise.all([
115
+ this.aztecNode.getTxEffect(txHash),
116
+ this.aztecNode.findLeavesIndexes(anchorBlockHash, MerkleTreeId.NULLIFIER_TREE, [
117
+ siloedNullifier
118
+ ])
119
+ ]);
120
+ if (!txEffect) {
121
+ throw new Error(`Could not find tx effect for tx hash ${txHash}`);
122
+ }
123
+ if (txEffect.l2BlockNumber > anchorBlockNumber) {
124
+ throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${anchorBlockNumber}`);
125
+ }
126
+ // Find the index of the note hash in the noteHashes array to determine note ordering within the tx
127
+ const noteIndexInTx = txEffect.data.noteHashes.findIndex((nh)=>nh.equals(uniqueNoteHash));
128
+ if (noteIndexInTx === -1) {
129
+ throw new Error(`Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present in tx ${txHash}`);
130
+ }
131
+ const noteDao = new NoteDao(new Note(content), contractAddress, owner, storageSlot, randomness, noteNonce, noteHash, siloedNullifier, txHash, txEffect.l2BlockNumber, txEffect.l2BlockHash.toString(), txEffect.txIndexInBlock, noteIndexInTx);
132
+ // The note was found by `recipient`, so we use that as the scope when storing the note.
133
+ await this.noteStore.addNotes([
134
+ noteDao
135
+ ], recipient, this.jobId);
136
+ if (nullifierIndex !== undefined) {
137
+ // We found nullifier index which implies that the note has already been nullified.
138
+ const { data: _, ...blockHashAndNum } = nullifierIndex;
139
+ await this.noteStore.applyNullifiers([
140
+ {
141
+ data: siloedNullifier,
142
+ ...blockHashAndNum
143
+ }
144
+ ], this.jobId);
145
+ }
146
+ }
147
+ }
@@ -1,3 +1,3 @@
1
- export declare const ORACLE_VERSION = 4;
2
- export declare const ORACLE_INTERFACE_HASH = "d1496df59c0b51a481d5ef93f218b5c35ddfce6242da28d60bb5c66386940eac";
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3JhY2xlX3ZlcnNpb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9vcmFjbGVfdmVyc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFNQSxlQUFPLE1BQU0sY0FBYyxJQUFJLENBQUM7QUFJaEMsZUFBTyxNQUFNLHFCQUFxQixxRUFBcUUsQ0FBQyJ9
1
+ export declare const ORACLE_VERSION = 10;
2
+ export declare const ORACLE_INTERFACE_HASH = "a3b284ee5abff0509986d6d2fa78a3e6e2ec212325674de78355c5e70b05784c";
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3JhY2xlX3ZlcnNpb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9vcmFjbGVfdmVyc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFNQSxlQUFPLE1BQU0sY0FBYyxLQUFLLENBQUM7QUFLakMsZUFBTyxNQUFNLHFCQUFxQixxRUFBcUUsQ0FBQyJ9
@@ -1 +1 @@
1
- {"version":3,"file":"oracle_version.d.ts","sourceRoot":"","sources":["../src/oracle_version.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,cAAc,IAAI,CAAC;AAIhC,eAAO,MAAM,qBAAqB,qEAAqE,CAAC"}
1
+ {"version":3,"file":"oracle_version.d.ts","sourceRoot":"","sources":["../src/oracle_version.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,cAAc,KAAK,CAAC;AAKjC,eAAO,MAAM,qBAAqB,qEAAqE,CAAC"}
@@ -4,7 +4,8 @@
4
4
  ///
5
5
  /// @dev Whenever a contract function or Noir test is run, the `utilityAssertCompatibleOracleVersion` oracle is called
6
6
  /// and if the oracle version is incompatible an error is thrown.
7
- export const ORACLE_VERSION = 4;
7
+ export const ORACLE_VERSION = 10;
8
8
  /// This hash is computed as by hashing the Oracle interface and it is used to detect when the Oracle interface changes,
9
- /// which in turn implies that you need to update the ORACLE_VERSION constant.
10
- export const ORACLE_INTERFACE_HASH = 'd1496df59c0b51a481d5ef93f218b5c35ddfce6242da28d60bb5c66386940eac';
9
+ /// which in turn implies that you need to update the ORACLE_VERSION constant in this file and in
10
+ /// `noir-projects/aztec-nr/aztec/src/oracle/version.nr`.
11
+ export const ORACLE_INTERFACE_HASH = 'a3b284ee5abff0509986d6d2fa78a3e6e2ec212325674de78355c5e70b05784c';
@@ -1,3 +1,3 @@
1
- export * from './build_private_kernel_reset_private_inputs.js';
1
+ export * from './private_kernel_reset_private_inputs_builder.js';
2
2
  export * from './compute_tx_include_by_timestamp.js';
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wcml2YXRlX2tlcm5lbC9oaW50cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLGdEQUFnRCxDQUFDO0FBQy9ELGNBQWMsc0NBQXNDLENBQUMifQ==
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wcml2YXRlX2tlcm5lbC9oaW50cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLGtEQUFrRCxDQUFDO0FBQ2pFLGNBQWMsc0NBQXNDLENBQUMifQ==