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

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 (322) hide show
  1. package/dest/bin/check_oracle_version.js +105 -15
  2. package/dest/block_synchronizer/block_synchronizer.d.ts +37 -0
  3. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
  4. package/dest/{synchronizer/synchronizer.js → block_synchronizer/block_synchronizer.js} +19 -22
  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 +4 -4
  9. package/dest/config/index.d.ts.map +1 -1
  10. package/dest/contract_function_simulator/contract_function_simulator.d.ts +41 -12
  11. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  12. package/dest/contract_function_simulator/contract_function_simulator.js +49 -19
  13. package/dest/contract_function_simulator/execution_note_cache.d.ts +4 -4
  14. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  15. package/dest/contract_function_simulator/execution_note_cache.js +3 -3
  16. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +1 -1
  17. package/dest/contract_function_simulator/execution_tagging_index_cache.js +1 -1
  18. package/dest/contract_function_simulator/hashed_values_cache.d.ts +2 -2
  19. package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -1
  20. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +2 -2
  21. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  22. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +5 -4
  23. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
  24. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +7 -6
  25. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
  26. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  27. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -1
  28. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +2 -2
  29. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  30. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +2 -2
  31. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
  32. package/dest/contract_function_simulator/noir-structs/utility_context.js +1 -1
  33. package/dest/contract_function_simulator/oracle/interfaces.d.ts +6 -6
  34. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  35. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +2 -2
  36. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  37. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -1
  38. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +7 -3
  39. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
  40. package/dest/contract_function_simulator/oracle/note_packing_utils.js +7 -3
  41. package/dest/contract_function_simulator/oracle/oracle.d.ts +2 -2
  42. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  43. package/dest/contract_function_simulator/oracle/oracle.js +18 -7
  44. package/dest/contract_function_simulator/oracle/private_execution.d.ts +8 -10
  45. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  46. package/dest/contract_function_simulator/oracle/private_execution.js +12 -12
  47. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +25 -11
  48. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  49. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +26 -14
  50. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +51 -11
  51. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  52. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +146 -40
  53. package/dest/contract_function_simulator/pick_notes.d.ts +2 -2
  54. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
  55. package/dest/contract_function_simulator/pick_notes.js +1 -1
  56. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +4 -4
  57. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
  58. package/dest/contract_function_simulator/proxied_contract_data_source.js +23 -5
  59. package/dest/debug/pxe_debug_utils.d.ts +31 -0
  60. package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
  61. package/dest/debug/pxe_debug_utils.js +37 -0
  62. package/dest/entrypoints/client/bundle/index.d.ts +1 -2
  63. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  64. package/dest/entrypoints/client/bundle/index.js +0 -1
  65. package/dest/entrypoints/client/bundle/utils.js +2 -2
  66. package/dest/entrypoints/client/lazy/index.d.ts +1 -2
  67. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  68. package/dest/entrypoints/client/lazy/index.js +0 -1
  69. package/dest/entrypoints/client/lazy/utils.js +2 -2
  70. package/dest/entrypoints/pxe_creation_options.d.ts +3 -1
  71. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  72. package/dest/entrypoints/server/index.d.ts +2 -2
  73. package/dest/entrypoints/server/index.d.ts.map +1 -1
  74. package/dest/entrypoints/server/index.js +1 -1
  75. package/dest/entrypoints/server/utils.js +1 -1
  76. package/dest/error_enriching.d.ts +4 -4
  77. package/dest/error_enriching.d.ts.map +1 -1
  78. package/dest/error_enriching.js +6 -6
  79. package/dest/events/event_service.d.ts +15 -0
  80. package/dest/events/event_service.d.ts.map +1 -0
  81. package/dest/events/event_service.js +47 -0
  82. package/dest/events/index.d.ts +2 -0
  83. package/dest/events/index.d.ts.map +1 -0
  84. package/dest/events/index.js +1 -0
  85. package/dest/events/private_event_filter_validator.d.ts +9 -0
  86. package/dest/events/private_event_filter_validator.d.ts.map +1 -0
  87. package/dest/events/private_event_filter_validator.js +39 -0
  88. package/dest/logs/log_service.d.ts +26 -0
  89. package/dest/logs/log_service.d.ts.map +1 -0
  90. package/dest/logs/log_service.js +120 -0
  91. package/dest/notes/index.d.ts +2 -0
  92. package/dest/notes/index.d.ts.map +1 -0
  93. package/dest/notes/index.js +1 -0
  94. package/dest/notes/note_service.d.ts +48 -0
  95. package/dest/notes/note_service.d.ts.map +1 -0
  96. package/dest/notes/note_service.js +152 -0
  97. package/dest/oracle_version.d.ts +2 -2
  98. package/dest/oracle_version.js +2 -2
  99. package/dest/private_kernel/private_kernel_execution_prover.js +4 -4
  100. package/dest/private_kernel/private_kernel_oracle.d.ts +3 -2
  101. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  102. package/dest/private_kernel/private_kernel_oracle_impl.d.ts +6 -5
  103. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -1
  104. package/dest/private_kernel/private_kernel_oracle_impl.js +7 -7
  105. package/dest/public_storage/public_storage_service.d.ts +24 -0
  106. package/dest/public_storage/public_storage_service.d.ts.map +1 -0
  107. package/dest/public_storage/public_storage_service.js +26 -0
  108. package/dest/pxe.d.ts +38 -46
  109. package/dest/pxe.d.ts.map +1 -1
  110. package/dest/pxe.js +135 -143
  111. package/dest/storage/address_store/address_store.d.ts +11 -0
  112. package/dest/storage/address_store/address_store.d.ts.map +1 -0
  113. package/dest/storage/{address_data_provider/address_data_provider.js → address_store/address_store.js} +1 -1
  114. package/dest/storage/address_store/index.d.ts +2 -0
  115. package/dest/storage/address_store/index.d.ts.map +1 -0
  116. package/dest/storage/address_store/index.js +1 -0
  117. package/dest/storage/{sync_data_provider/sync_data_provider.d.ts → anchor_block_store/anchor_block_store.d.ts} +2 -4
  118. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
  119. package/dest/storage/{sync_data_provider/sync_data_provider.js → anchor_block_store/anchor_block_store.js} +2 -9
  120. package/dest/storage/{sync_data_provider → anchor_block_store}/index.d.ts +2 -2
  121. package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
  122. package/dest/storage/anchor_block_store/index.js +1 -0
  123. package/dest/storage/capsule_store/capsule_store.d.ts +57 -0
  124. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
  125. package/dest/storage/{capsule_data_provider/capsule_data_provider.js → capsule_store/capsule_store.js} +34 -6
  126. package/dest/storage/capsule_store/index.d.ts +2 -0
  127. package/dest/storage/capsule_store/index.d.ts.map +1 -0
  128. package/dest/storage/capsule_store/index.js +1 -0
  129. package/dest/storage/{contract_data_provider/contract_data_provider.d.ts → contract_store/contract_store.d.ts} +8 -5
  130. package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
  131. package/dest/storage/{contract_data_provider/contract_data_provider.js → contract_store/contract_store.js} +46 -3
  132. package/dest/storage/contract_store/index.d.ts +2 -0
  133. package/dest/storage/contract_store/index.d.ts.map +1 -0
  134. package/dest/storage/contract_store/index.js +1 -0
  135. package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.d.ts +1 -1
  136. package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
  137. package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.js +1 -1
  138. package/dest/storage/index.d.ts +8 -8
  139. package/dest/storage/index.d.ts.map +1 -1
  140. package/dest/storage/index.js +7 -7
  141. package/dest/storage/note_store/index.d.ts +3 -0
  142. package/dest/storage/note_store/index.d.ts.map +1 -0
  143. package/dest/storage/note_store/index.js +2 -0
  144. package/dest/storage/{note_data_provider/note_data_provider.d.ts → note_store/note_store.d.ts} +10 -9
  145. package/dest/storage/note_store/note_store.d.ts.map +1 -0
  146. package/dest/storage/{note_data_provider/note_data_provider.js → note_store/note_store.js} +16 -8
  147. package/dest/storage/private_event_store/private_event_store.d.ts +51 -0
  148. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
  149. package/dest/storage/{private_event_data_provider/private_event_data_provider.js → private_event_store/private_event_store.js} +37 -27
  150. package/dest/storage/tagging_store/index.d.ts +4 -0
  151. package/dest/storage/tagging_store/index.d.ts.map +1 -0
  152. package/dest/storage/tagging_store/index.js +3 -0
  153. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +21 -0
  154. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
  155. package/dest/storage/tagging_store/recipient_tagging_store.js +42 -0
  156. package/dest/storage/tagging_store/sender_address_book_store.d.ts +14 -0
  157. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -0
  158. package/dest/storage/tagging_store/sender_address_book_store.js +30 -0
  159. package/dest/storage/tagging_store/sender_tagging_store.d.ts +67 -0
  160. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
  161. package/dest/storage/tagging_store/sender_tagging_store.js +196 -0
  162. package/dest/tagging/index.d.ts +15 -6
  163. package/dest/tagging/index.d.ts.map +1 -1
  164. package/dest/tagging/index.js +23 -5
  165. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +14 -0
  166. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -0
  167. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +99 -0
  168. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +12 -0
  169. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -0
  170. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +20 -0
  171. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +14 -0
  172. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -0
  173. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +29 -0
  174. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +20 -0
  175. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -0
  176. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +74 -0
  177. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +11 -0
  178. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -0
  179. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +32 -0
  180. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +18 -0
  181. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
  182. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +55 -0
  183. package/dest/tree_membership/tree_membership_service.d.ts +52 -0
  184. package/dest/tree_membership/tree_membership_service.d.ts.map +1 -0
  185. package/dest/tree_membership/tree_membership_service.js +84 -0
  186. package/package.json +16 -16
  187. package/src/bin/check_oracle_version.ts +130 -20
  188. package/src/{synchronizer/synchronizer.ts → block_synchronizer/block_synchronizer.ts} +18 -22
  189. package/src/block_synchronizer/index.ts +1 -0
  190. package/src/config/index.ts +3 -3
  191. package/src/contract_function_simulator/contract_function_simulator.ts +86 -17
  192. package/src/contract_function_simulator/execution_note_cache.ts +7 -4
  193. package/src/contract_function_simulator/execution_tagging_index_cache.ts +1 -1
  194. package/src/contract_function_simulator/hashed_values_cache.ts +1 -1
  195. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
  196. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +6 -5
  197. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -1
  198. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
  199. package/src/contract_function_simulator/noir-structs/utility_context.ts +1 -1
  200. package/src/contract_function_simulator/oracle/interfaces.ts +5 -5
  201. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +1 -1
  202. package/src/contract_function_simulator/oracle/note_packing_utils.ts +17 -3
  203. package/src/contract_function_simulator/oracle/oracle.ts +21 -7
  204. package/src/contract_function_simulator/oracle/private_execution.ts +15 -14
  205. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +92 -22
  206. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +213 -49
  207. package/src/contract_function_simulator/pick_notes.ts +1 -1
  208. package/src/contract_function_simulator/proxied_contract_data_source.ts +24 -7
  209. package/src/debug/pxe_debug_utils.ts +48 -0
  210. package/src/entrypoints/client/bundle/index.ts +0 -1
  211. package/src/entrypoints/client/bundle/utils.ts +2 -2
  212. package/src/entrypoints/client/lazy/index.ts +0 -1
  213. package/src/entrypoints/client/lazy/utils.ts +2 -2
  214. package/src/entrypoints/pxe_creation_options.ts +2 -0
  215. package/src/entrypoints/server/index.ts +1 -1
  216. package/src/entrypoints/server/utils.ts +1 -1
  217. package/src/error_enriching.ts +7 -15
  218. package/src/events/event_service.ts +77 -0
  219. package/src/events/index.ts +1 -0
  220. package/src/events/private_event_filter_validator.ts +48 -0
  221. package/src/logs/log_service.ts +202 -0
  222. package/src/notes/index.ts +1 -0
  223. package/src/notes/note_service.ts +200 -0
  224. package/src/oracle_version.ts +2 -2
  225. package/src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts +1 -1
  226. package/src/private_kernel/private_kernel_execution_prover.ts +4 -4
  227. package/src/private_kernel/private_kernel_oracle.ts +2 -1
  228. package/src/private_kernel/private_kernel_oracle_impl.ts +8 -7
  229. package/src/public_storage/public_storage_service.ts +33 -0
  230. package/src/pxe.ts +162 -181
  231. package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +1 -1
  232. package/src/storage/address_store/index.ts +1 -0
  233. package/src/storage/{sync_data_provider/sync_data_provider.ts → anchor_block_store/anchor_block_store.ts} +2 -12
  234. package/src/storage/anchor_block_store/index.ts +1 -0
  235. package/src/storage/{capsule_data_provider/capsule_data_provider.ts → capsule_store/capsule_store.ts} +34 -2
  236. package/src/storage/capsule_store/index.ts +1 -0
  237. package/src/storage/{contract_data_provider/contract_data_provider.ts → contract_store/contract_store.ts} +65 -3
  238. package/src/storage/contract_store/index.ts +1 -0
  239. package/src/storage/{contract_data_provider → contract_store}/private_functions_tree.ts +1 -1
  240. package/src/storage/index.ts +7 -7
  241. package/src/storage/note_store/index.ts +2 -0
  242. package/src/storage/{note_data_provider/note_data_provider.ts → note_store/note_store.ts} +19 -10
  243. package/src/storage/{private_event_data_provider/private_event_data_provider.ts → private_event_store/private_event_store.ts} +60 -41
  244. package/src/storage/tagging_store/index.ts +3 -0
  245. package/src/storage/tagging_store/recipient_tagging_store.ts +53 -0
  246. package/src/storage/tagging_store/sender_address_book_store.ts +42 -0
  247. package/src/storage/tagging_store/sender_tagging_store.ts +244 -0
  248. package/src/tagging/index.ts +27 -5
  249. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +129 -0
  250. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +34 -0
  251. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +43 -0
  252. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +96 -0
  253. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +44 -0
  254. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +72 -0
  255. package/src/tree_membership/tree_membership_service.ts +112 -0
  256. package/dest/contract_function_simulator/execution_data_provider.d.ts +0 -267
  257. package/dest/contract_function_simulator/execution_data_provider.d.ts.map +0 -1
  258. package/dest/contract_function_simulator/execution_data_provider.js +0 -14
  259. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +0 -123
  260. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +0 -1
  261. package/dest/contract_function_simulator/pxe_oracle_interface.js +0 -696
  262. package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -11
  263. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +0 -1
  264. package/dest/storage/address_data_provider/index.d.ts +0 -2
  265. package/dest/storage/address_data_provider/index.d.ts.map +0 -1
  266. package/dest/storage/address_data_provider/index.js +0 -1
  267. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +0 -25
  268. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +0 -1
  269. package/dest/storage/capsule_data_provider/index.d.ts +0 -2
  270. package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
  271. package/dest/storage/capsule_data_provider/index.js +0 -1
  272. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
  273. package/dest/storage/contract_data_provider/index.d.ts +0 -2
  274. package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
  275. package/dest/storage/contract_data_provider/index.js +0 -1
  276. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
  277. package/dest/storage/note_data_provider/index.d.ts +0 -3
  278. package/dest/storage/note_data_provider/index.d.ts.map +0 -1
  279. package/dest/storage/note_data_provider/index.js +0 -2
  280. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
  281. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +0 -37
  282. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +0 -1
  283. package/dest/storage/sync_data_provider/index.d.ts.map +0 -1
  284. package/dest/storage/sync_data_provider/index.js +0 -1
  285. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +0 -1
  286. package/dest/storage/tagging_data_provider/index.d.ts +0 -2
  287. package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
  288. package/dest/storage/tagging_data_provider/index.js +0 -1
  289. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +0 -40
  290. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +0 -1
  291. package/dest/storage/tagging_data_provider/tagging_data_provider.js +0 -89
  292. package/dest/synchronizer/index.d.ts +0 -2
  293. package/dest/synchronizer/index.d.ts.map +0 -1
  294. package/dest/synchronizer/index.js +0 -1
  295. package/dest/synchronizer/synchronizer.d.ts +0 -36
  296. package/dest/synchronizer/synchronizer.d.ts.map +0 -1
  297. package/dest/tagging/constants.d.ts +0 -2
  298. package/dest/tagging/constants.d.ts.map +0 -1
  299. package/dest/tagging/constants.js +0 -2
  300. package/dest/tagging/siloed_tag.d.ts +0 -14
  301. package/dest/tagging/siloed_tag.d.ts.map +0 -1
  302. package/dest/tagging/siloed_tag.js +0 -20
  303. package/dest/tagging/tag.d.ts +0 -12
  304. package/dest/tagging/tag.d.ts.map +0 -1
  305. package/dest/tagging/tag.js +0 -17
  306. package/dest/tagging/utils.d.ts +0 -18
  307. package/dest/tagging/utils.d.ts.map +0 -1
  308. package/dest/tagging/utils.js +0 -24
  309. package/src/contract_function_simulator/execution_data_provider.ts +0 -342
  310. package/src/contract_function_simulator/pxe_oracle_interface.ts +0 -1023
  311. package/src/storage/address_data_provider/index.ts +0 -1
  312. package/src/storage/capsule_data_provider/index.ts +0 -1
  313. package/src/storage/contract_data_provider/index.ts +0 -1
  314. package/src/storage/note_data_provider/index.ts +0 -2
  315. package/src/storage/sync_data_provider/index.ts +0 -1
  316. package/src/storage/tagging_data_provider/index.ts +0 -1
  317. package/src/storage/tagging_data_provider/tagging_data_provider.ts +0 -120
  318. package/src/synchronizer/index.ts +0 -1
  319. package/src/tagging/constants.ts +0 -2
  320. package/src/tagging/siloed_tag.ts +0 -22
  321. package/src/tagging/tag.ts +0 -16
  322. package/src/tagging/utils.ts +0 -31
@@ -3,7 +3,7 @@ import type { AztecAsyncArray, AztecAsyncKVStore, AztecAsyncMap } from '@aztec/k
3
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import { CompleteAddress } from '@aztec/stdlib/contract';
5
5
 
6
- export class AddressDataProvider {
6
+ export class AddressStore {
7
7
  #store: AztecAsyncKVStore;
8
8
  #completeAddresses: AztecAsyncArray<Buffer>;
9
9
  #completeAddressIndex: AztecAsyncMap<string, number>;
@@ -0,0 +1 @@
1
+ export { AddressStore } from './address_store.js';
@@ -1,8 +1,7 @@
1
- import type { BlockNumber } from '@aztec/foundation/branded-types';
2
1
  import type { AztecAsyncKVStore, AztecAsyncSingleton } from '@aztec/kv-store';
3
2
  import { BlockHeader } from '@aztec/stdlib/tx';
4
3
 
5
- export class SyncDataProvider {
4
+ export class AnchorBlockStore {
6
5
  #store: AztecAsyncKVStore;
7
6
  #synchronizedHeader: AztecAsyncSingleton<Buffer>;
8
7
 
@@ -15,19 +14,10 @@ export class SyncDataProvider {
15
14
  await this.#synchronizedHeader.set(header.toBuffer());
16
15
  }
17
16
 
18
- async getBlockNumber(): Promise<BlockNumber> {
19
- const headerBuffer = await this.#synchronizedHeader.getAsync();
20
- if (!headerBuffer) {
21
- throw new Error(`Trying to get block number with a not-yet-synchronized PXE - this should never happen`);
22
- }
23
-
24
- return BlockHeader.fromBuffer(headerBuffer).globalVariables.blockNumber;
25
- }
26
-
27
17
  async getBlockHeader(): Promise<BlockHeader> {
28
18
  const headerBuffer = await this.#synchronizedHeader.getAsync();
29
19
  if (!headerBuffer) {
30
- throw new Error(`Header not set`);
20
+ throw new Error(`Trying to get block header with a not-yet-synchronized PXE - this should never happen`);
31
21
  }
32
22
 
33
23
  return BlockHeader.fromBuffer(headerBuffer);
@@ -0,0 +1 @@
1
+ export { AnchorBlockStore } from './anchor_block_store.js';
@@ -1,9 +1,9 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { type Logger, createLogger } from '@aztec/foundation/log';
3
3
  import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
4
4
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
5
 
6
- export class CapsuleDataProvider {
6
+ export class CapsuleStore {
7
7
  #store: AztecAsyncKVStore;
8
8
 
9
9
  // Arbitrary data stored by contracts. Key is computed as `${contractAddress}:${key}`
@@ -19,10 +19,26 @@ export class CapsuleDataProvider {
19
19
  this.logger = createLogger('pxe:capsule-data-provider');
20
20
  }
21
21
 
22
+ /**
23
+ * Stores arbitrary information in a per-contract non-volatile database, which can later be retrieved with `loadCapsule`.
24
+ * * If data was already stored at this slot, it is overwritten.
25
+ * @param contractAddress - The contract address to scope the data under.
26
+ * @param slot - The slot in the database in which to store the value. Slots need not be contiguous.
27
+ * @param capsule - An array of field elements representing the capsule.
28
+ * @remarks A capsule is a "blob" of data that is passed to the contract through an oracle. It works similarly
29
+ * to public contract storage in that it's indexed by the contract address and storage slot but instead of the global
30
+ * network state it's backed by local PXE db.
31
+ */
22
32
  async storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
23
33
  await this.#capsules.set(dbSlotToKey(contractAddress, slot), Buffer.concat(capsule.map(value => value.toBuffer())));
24
34
  }
25
35
 
36
+ /**
37
+ * Returns data previously stored via `storeCapsule` in the per-contract non-volatile database.
38
+ * @param contractAddress - The contract address under which the data is scoped.
39
+ * @param slot - The slot in the database to read.
40
+ * @returns The stored data or `null` if no data is stored under the slot.
41
+ */
26
42
  async loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
27
43
  const dataBuffer = await this.#capsules.getAsync(dbSlotToKey(contractAddress, slot));
28
44
  if (!dataBuffer) {
@@ -36,10 +52,26 @@ export class CapsuleDataProvider {
36
52
  return capsule;
37
53
  }
38
54
 
55
+ /**
56
+ * Deletes data in the per-contract non-volatile database. Does nothing if no data was present.
57
+ * @param contractAddress - The contract address under which the data is scoped.
58
+ * @param slot - The slot in the database to delete.
59
+ */
39
60
  async deleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void> {
40
61
  await this.#capsules.delete(dbSlotToKey(contractAddress, slot));
41
62
  }
42
63
 
64
+ /**
65
+ * Copies a number of contiguous entries in the per-contract non-volatile database. This allows for efficient data
66
+ * structures by avoiding repeated calls to `loadCapsule` and `storeCapsule`.
67
+ * Supports overlapping source and destination regions (which will result in the overlapped source values being
68
+ * overwritten). All copied slots must exist in the database (i.e. have been stored and not deleted)
69
+ *
70
+ * @param contractAddress - The contract address under which the data is scoped.
71
+ * @param srcSlot - The first slot to copy from.
72
+ * @param dstSlot - The first slot to copy to.
73
+ * @param numEntries - The number of entries to copy.
74
+ */
43
75
  copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number): Promise<void> {
44
76
  return this.#store.transactionAsync(async () => {
45
77
  // In order to support overlapping source and destination regions, we need to check the relative positions of source
@@ -0,0 +1 @@
1
+ export { CapsuleStore } from './capsule_store.js';
@@ -1,18 +1,21 @@
1
1
  import type { FUNCTION_TREE_HEIGHT } from '@aztec/constants';
2
- import type { Fr } from '@aztec/foundation/fields';
2
+ import type { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { toArray } from '@aztec/foundation/iterable';
4
4
  import type { MembershipWitness } from '@aztec/foundation/trees';
5
5
  import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
6
+ import { isProtocolContract } from '@aztec/protocol-contracts';
6
7
  import {
7
8
  type ContractArtifact,
8
9
  type FunctionAbi,
9
10
  type FunctionArtifact,
10
11
  type FunctionArtifactWithContractName,
12
+ FunctionCall,
11
13
  type FunctionDebugMetadata,
12
14
  FunctionSelector,
13
15
  FunctionType,
14
16
  contractArtifactFromBuffer,
15
17
  contractArtifactToBuffer,
18
+ encodeArguments,
16
19
  getFunctionDebugMetadata,
17
20
  } from '@aztec/stdlib/abi';
18
21
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
@@ -26,13 +29,13 @@ import {
26
29
  import { PrivateFunctionsTree } from './private_functions_tree.js';
27
30
 
28
31
  /**
29
- * ContractDataProvider serves as a data manager and retriever for Aztec.nr contracts.
32
+ * ContractStore serves as a data manager and retriever for Aztec.nr contracts.
30
33
  * It provides methods to obtain contract addresses, function ABI, bytecode, and membership witnesses
31
34
  * from a given contract address and function selector. The class maintains a cache of ContractTree instances
32
35
  * to efficiently serve the requested data. It interacts with the ContractDatabase and AztecNode to fetch
33
36
  * the required information and facilitate cryptographic proof generation.
34
37
  */
35
- export class ContractDataProvider {
38
+ export class ContractStore {
36
39
  /** Map from contract class id to private function tree. */
37
40
  // TODO: Update it to be LRU cache so that it doesn't keep all the data all the time.
38
41
  #privateFunctionTrees: Map<string, PrivateFunctionsTree> = new Map();
@@ -176,6 +179,21 @@ export class ContractDataProvider {
176
179
  return fnArtifact && { ...fnArtifact, contractName: artifact.name };
177
180
  }
178
181
 
182
+ public async getFunctionArtifactWithDebugMetadata(
183
+ contractAddress: AztecAddress,
184
+ selector: FunctionSelector,
185
+ ): Promise<FunctionArtifactWithContractName> {
186
+ const artifact = await this.getFunctionArtifact(contractAddress, selector);
187
+ if (!artifact) {
188
+ throw new Error(`Function artifact not found for contract ${contractAddress} and selector ${selector}.`);
189
+ }
190
+ const debug = await this.getFunctionDebugMetadata(contractAddress, selector);
191
+ return {
192
+ ...artifact,
193
+ debug,
194
+ };
195
+ }
196
+
179
197
  public async getPublicFunctionArtifact(
180
198
  contractAddress: AztecAddress,
181
199
  ): Promise<FunctionArtifactWithContractName | undefined> {
@@ -274,4 +292,48 @@ export class ContractDataProvider {
274
292
  }
275
293
  }
276
294
  }
295
+
296
+ public async getFunctionCall(functionName: string, args: any[], to: AztecAddress): Promise<FunctionCall> {
297
+ const contract = await this.getContract(to);
298
+ if (!contract) {
299
+ throw new Error(
300
+ `Unknown contract ${to}: add it to PXE by calling server.addContracts(...).\nSee docs for context: https://docs.aztec.network/developers/resources/debugging/aztecnr-errors#unknown-contract-0x0-add-it-to-pxe-by-calling-serveraddcontracts`,
301
+ );
302
+ }
303
+
304
+ const functionDao = contract.functions.find(f => f.name === functionName);
305
+ if (!functionDao) {
306
+ throw new Error(`Unknown function ${functionName} in contract ${contract.name}.`);
307
+ }
308
+
309
+ return {
310
+ name: functionDao.name,
311
+ args: encodeArguments(functionDao, args),
312
+ selector: await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters),
313
+ type: functionDao.functionType,
314
+ to,
315
+ hideMsgSender: false,
316
+ isStatic: functionDao.isStatic,
317
+ returnTypes: functionDao.returnTypes,
318
+ };
319
+ }
320
+
321
+ // Synchronize target contract data
322
+ public async syncPrivateState(
323
+ contractAddress: AztecAddress,
324
+ functionToInvokeAfterSync: FunctionSelector | null,
325
+ utilityExecutor: (privateSyncCall: FunctionCall) => Promise<any>,
326
+ ) {
327
+ // Protocol contracts don't have private state to sync
328
+ if (!isProtocolContract(contractAddress)) {
329
+ const syncPrivateStateFunctionCall = await this.getFunctionCall('sync_private_state', [], contractAddress);
330
+ if (functionToInvokeAfterSync && functionToInvokeAfterSync.equals(syncPrivateStateFunctionCall.selector)) {
331
+ throw new Error(
332
+ 'Forbidden `sync_private_state` invocation. `sync_private_state` can only be invoked by PXE, manual execution can lead to inconsistencies.',
333
+ );
334
+ }
335
+
336
+ return utilityExecutor(syncPrivateStateFunctionCall);
337
+ }
338
+ }
277
339
  }
@@ -0,0 +1 @@
1
+ export { ContractStore } from './contract_store.js';
@@ -1,5 +1,5 @@
1
1
  import { FUNCTION_TREE_HEIGHT } from '@aztec/constants';
2
- import { Fr } from '@aztec/foundation/fields';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { assertLength } from '@aztec/foundation/serialize';
4
4
  import { MembershipWitness, type MerkleTree } from '@aztec/foundation/trees';
5
5
  import { type ContractArtifact, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
@@ -1,8 +1,8 @@
1
- export * from './address_data_provider/index.js';
2
- export * from './capsule_data_provider/index.js';
3
- export * from './contract_data_provider/index.js';
4
- export * from './note_data_provider/index.js';
5
- export * from './sync_data_provider/index.js';
6
- export * from './tagging_data_provider/index.js';
1
+ export * from './address_store/index.js';
2
+ export * from './capsule_store/index.js';
3
+ export * from './contract_store/index.js';
4
+ export * from './note_store/index.js';
5
+ export * from './anchor_block_store/index.js';
6
+ export * from './tagging_store/index.js';
7
7
  export * from './metadata.js';
8
- export * from './private_event_data_provider/private_event_data_provider.js';
8
+ export * from './private_event_store/private_event_store.js';
@@ -0,0 +1,2 @@
1
+ export { NoteDao } from '@aztec/stdlib/note';
2
+ export { NoteStore } from './note_store.js';
@@ -1,5 +1,5 @@
1
1
  import { toBufferBE } from '@aztec/foundation/bigint-buffer';
2
- import type { Fr } from '@aztec/foundation/fields';
2
+ import type { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { toArray } from '@aztec/foundation/iterable';
4
4
  import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap } from '@aztec/kv-store';
5
5
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
@@ -8,12 +8,12 @@ import { NoteStatus, type NotesFilter } from '@aztec/stdlib/note';
8
8
  import { NoteDao } from '@aztec/stdlib/note';
9
9
 
10
10
  /**
11
- * NoteDataProvider manages the storage and retrieval of notes.
11
+ * NoteStore manages the storage and retrieval of notes.
12
12
  *
13
13
  * Notes can be active or nullified. This class processes new notes, nullifications,
14
14
  * and performs rollback handling in the case of a reorg.
15
15
  **/
16
- export class NoteDataProvider {
16
+ export class NoteStore {
17
17
  #store: AztecAsyncKVStore;
18
18
  #notes: AztecAsyncMap<string, Buffer>;
19
19
  #nullifiedNotes: AztecAsyncMap<string, Buffer>;
@@ -49,16 +49,16 @@ export class NoteDataProvider {
49
49
  }
50
50
 
51
51
  /**
52
- * Creates and initializes a new NoteDataProvider instance.
52
+ * Creates and initializes a new NoteStore instance.
53
53
  *
54
- * This factory method creates a NoteDataProvider and restores any existing
54
+ * This factory method creates a NoteStore and restores any existing
55
55
  * scope-specific indexes from the database.
56
56
  *
57
57
  * @param store - The key-value store to use for persistence
58
- * @returns Promise resolving to a fully initialized NoteDataProvider instance
58
+ * @returns Promise resolving to a fully initialized NoteStore instance
59
59
  */
60
- public static async create(store: AztecAsyncKVStore): Promise<NoteDataProvider> {
61
- const pxeDB = new NoteDataProvider(store);
60
+ public static async create(store: AztecAsyncKVStore): Promise<NoteStore> {
61
+ const pxeDB = new NoteStore(store);
62
62
  for await (const scope of pxeDB.#scopes.keysAsync()) {
63
63
  pxeDB.#notesByContractAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_contract`));
64
64
  pxeDB.#notesByStorageSlotAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_storage_slot`));
@@ -225,7 +225,8 @@ export class NoteDataProvider {
225
225
  *
226
226
  * @param filter - Filter criteria including contractAddress (required), and optional
227
227
  * owner, storageSlot, status, scopes, and siloedNullifier.
228
- * @returns Promise resolving to array of NoteDao objects matching the filter
228
+ * @returns Filtered and deduplicated notes (a note might be present in multiple scopes - we ensure it is only
229
+ * returned once if this is the case)
229
230
  * @throws If filtering by an empty scopes array. Scopes have to be set to undefined or to a non-empty array.
230
231
  */
231
232
  async getNotes(filter: NotesFilter): Promise<NoteDao[]> {
@@ -323,7 +324,15 @@ export class NoteDataProvider {
323
324
  }
324
325
  }
325
326
 
326
- return result;
327
+ // A note might be present in multiple scopes - we ensure it is only returned once
328
+ const deduplicated: NoteDao[] = [];
329
+ for (const note of result) {
330
+ if (!deduplicated.some(existing => existing.equals(note))) {
331
+ deduplicated.push(note);
332
+ }
333
+ }
334
+
335
+ return deduplicated;
327
336
  }
328
337
 
329
338
  /**
@@ -1,35 +1,49 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
3
  import { createLogger } from '@aztec/foundation/log';
3
4
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
4
5
  import type { AztecAsyncArray, AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
5
6
  import type { EventSelector } from '@aztec/stdlib/abi';
6
7
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
7
8
  import { L2BlockHash } from '@aztec/stdlib/block';
8
- import { TxHash } from '@aztec/stdlib/tx';
9
+ import { type InTx, TxHash } from '@aztec/stdlib/tx';
9
10
 
10
- import type { PrivateEvent } from '../../pxe.js';
11
+ import type { PackedPrivateEvent } from '../../pxe.js';
11
12
 
12
- interface PrivateEventEntry {
13
+ export type PrivateEventStoreFilter = {
14
+ contractAddress: AztecAddress;
15
+ fromBlock: number;
16
+ toBlock: number;
17
+ scopes: AztecAddress[];
18
+ txHash?: TxHash;
19
+ };
20
+
21
+ type PrivateEventEntry = {
13
22
  msgContent: Buffer;
14
- blockNumber: number;
15
- blockHash: Buffer;
16
23
  eventCommitmentIndex: number;
24
+ l2BlockNumber: number;
25
+ l2BlockHash: Buffer;
17
26
  txHash: Buffer;
18
- }
27
+ };
28
+
29
+ type PrivateEventMetadata = InTx & {
30
+ contractAddress: AztecAddress;
31
+ scope: AztecAddress;
32
+ };
19
33
 
20
34
  /**
21
35
  * Stores decrypted private event logs.
22
36
  */
23
- export class PrivateEventDataProvider {
37
+ export class PrivateEventStore {
24
38
  #store: AztecAsyncKVStore;
25
39
  /** Array storing the actual private event log entries containing the log content and block number */
26
40
  #eventLogs: AztecAsyncArray<PrivateEventEntry>;
27
- /** Map from contract_address_recipient_eventSelector to array of indices into #eventLogs for efficient lookup */
41
+ /** Map from contract_address_scope_eventSelector to array of indices into #eventLogs for efficient lookup */
28
42
  #eventLogIndex: AztecAsyncMap<string, number[]>;
29
43
  /** Map from eventCommitmentIndex to boolean indicating if log has been seen. */
30
44
  #seenLogs: AztecAsyncMap<number, boolean>;
31
45
 
32
- logger = createLogger('private_event_data_provider');
46
+ logger = createLogger('private_event_store');
33
47
 
34
48
  constructor(store: AztecAsyncKVStore) {
35
49
  this.#store = store;
@@ -38,28 +52,31 @@ export class PrivateEventDataProvider {
38
52
  this.#seenLogs = this.#store.openMap('seen_logs');
39
53
  }
40
54
 
55
+ #keyFor(contractAddress: AztecAddress, scope: AztecAddress, eventSelector: EventSelector): string {
56
+ return `${contractAddress.toString()}_${scope.toString()}_${eventSelector.toString()}`;
57
+ }
58
+
41
59
  /**
42
60
  * Store a private event log.
43
- * @param contractAddress - The address of the contract that emitted the event.
44
- * @param recipient - The recipient of the event.
45
61
  * @param eventSelector - The event selector of the event.
46
62
  * @param msgContent - The content of the event.
47
- * @param txHash - The transaction hash of the event log.
48
63
  * @param eventCommitmentIndex - The index of the event commitment in the nullifier tree.
49
- * @param blockNumber - The block number in which the event was emitted.
64
+ * @param metadata
65
+ * contractAddress - The address of the contract that emitted the event.
66
+ * scope - The address to which the event is scoped.
67
+ * txHash - The transaction hash of the event log.
68
+ * blockNumber - The block number in which the event was emitted.
50
69
  */
51
70
  storePrivateEventLog(
52
- contractAddress: AztecAddress,
53
- recipient: AztecAddress,
54
71
  eventSelector: EventSelector,
55
72
  msgContent: Fr[],
56
- txHash: TxHash,
57
73
  eventCommitmentIndex: number,
58
- blockNumber: number,
59
- blockHash: L2BlockHash,
74
+ metadata: PrivateEventMetadata,
60
75
  ): Promise<void> {
76
+ const { contractAddress, scope, txHash, l2BlockNumber, l2BlockHash } = metadata;
77
+
61
78
  return this.#store.transactionAsync(async () => {
62
- const key = `${contractAddress.toString()}_${recipient.toString()}_${eventSelector.toString()}`;
79
+ const key = this.#keyFor(contractAddress, scope, eventSelector);
63
80
 
64
81
  // Check if this exact log has already been stored using eventCommitmentIndex as unique identifier
65
82
  const hasBeenSeen = await this.#seenLogs.getAsync(eventCommitmentIndex);
@@ -68,13 +85,13 @@ export class PrivateEventDataProvider {
68
85
  return;
69
86
  }
70
87
 
71
- this.logger.verbose('storing private event log', { contractAddress, recipient, msgContent, blockNumber });
88
+ this.logger.verbose('storing private event log', { contractAddress, scope, msgContent, l2BlockNumber });
72
89
 
73
90
  const index = await this.#eventLogs.lengthAsync();
74
91
  await this.#eventLogs.push({
75
92
  msgContent: serializeToBuffer(msgContent),
76
- blockNumber,
77
- blockHash: blockHash.toBuffer(),
93
+ l2BlockNumber,
94
+ l2BlockHash: l2BlockHash.toBuffer(),
78
95
  eventCommitmentIndex,
79
96
  txHash: txHash.toBuffer(),
80
97
  });
@@ -89,29 +106,28 @@ export class PrivateEventDataProvider {
89
106
 
90
107
  /**
91
108
  * Returns the private events given search parameters.
92
- * @param contractAddress - The address of the contract to get events from.
93
- * @param from - The block number to search from.
94
- * @param numBlocks - The amount of blocks to search.
95
- * @param recipients - The addresses that decrypted the logs.
96
109
  * @param eventSelector - The event selector to filter by.
97
- * @returns - The event log contents.
110
+ * @param filter - Filtering criteria:
111
+ * contractAddress: The address of the contract to get events from.
112
+ * fromBlock: The block number to search from (inclusive).
113
+ * toBlock: The block number to search upto (exclusive).
114
+ * scope: - The addresses that decrypted the logs.
115
+ * @returns - The event log contents, augmented with metadata about
116
+ * the transaction and block it the event was included in .
98
117
  */
99
118
  public async getPrivateEvents(
100
- contractAddress: AztecAddress,
101
- from: number,
102
- numBlocks: number,
103
- recipients: AztecAddress[],
104
119
  eventSelector: EventSelector,
105
- ): Promise<PrivateEvent[]> {
106
- const events: Array<{ eventCommitmentIndex: number; event: PrivateEvent }> = [];
120
+ filter: PrivateEventStoreFilter,
121
+ ): Promise<PackedPrivateEvent[]> {
122
+ const events: Array<{ eventCommitmentIndex: number; event: PackedPrivateEvent }> = [];
107
123
 
108
- for (const recipient of recipients) {
109
- const key = `${contractAddress.toString()}_${recipient.toString()}_${eventSelector.toString()}`;
124
+ for (const scope of filter.scopes) {
125
+ const key = this.#keyFor(filter.contractAddress, scope, eventSelector);
110
126
  const indices = (await this.#eventLogIndex.getAsync(key)) || [];
111
127
 
112
128
  for (const index of indices) {
113
129
  const entry = await this.#eventLogs.atAsync(index);
114
- if (!entry || entry.blockNumber < from || entry.blockNumber >= from + numBlocks) {
130
+ if (!entry || entry.l2BlockNumber < filter.fromBlock || entry.l2BlockNumber >= filter.toBlock) {
115
131
  continue;
116
132
  }
117
133
 
@@ -120,16 +136,19 @@ export class PrivateEventDataProvider {
120
136
  const numFields = entry.msgContent.length / Fr.SIZE_IN_BYTES;
121
137
  const msgContent = reader.readArray(numFields, Fr);
122
138
  const txHash = TxHash.fromBuffer(entry.txHash);
123
- const blockHash = L2BlockHash.fromBuffer(entry.blockHash);
139
+ const l2BlockHash = L2BlockHash.fromBuffer(entry.l2BlockHash);
140
+
141
+ if (filter.txHash && !txHash.equals(filter.txHash)) {
142
+ continue;
143
+ }
124
144
 
125
145
  events.push({
126
146
  eventCommitmentIndex: entry.eventCommitmentIndex,
127
147
  event: {
128
148
  packedEvent: msgContent,
129
- blockNumber: entry.blockNumber,
130
- recipient,
149
+ l2BlockNumber: BlockNumber(entry.l2BlockNumber),
131
150
  txHash,
132
- blockHash,
151
+ l2BlockHash,
133
152
  eventSelector,
134
153
  },
135
154
  });
@@ -0,0 +1,3 @@
1
+ export { SenderTaggingStore } from './sender_tagging_store.js';
2
+ export { SenderAddressBookStore } from './sender_address_book_store.js';
3
+ export { RecipientTaggingStore } from './recipient_tagging_store.js';
@@ -0,0 +1,53 @@
1
+ import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
2
+ import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
3
+
4
+ /**
5
+ * Data provider of tagging data used when syncing the logs as a recipient. The sender counterpart of this class
6
+ * is called SenderTaggingStore. We have the providers separate for the sender and recipient because
7
+ * the algorithms are completely disjoint and there is not data reuse between the two.
8
+ *
9
+ * @dev Chain reorgs do not need to be handled here because both the finalized and aged indexes refer to finalized
10
+ * blocks, which by definition cannot be affected by reorgs.
11
+ *
12
+ * TODO(benesjan): Relocate to yarn-project/pxe/src/storage/tagging_store
13
+ */
14
+ export class RecipientTaggingStore {
15
+ #store: AztecAsyncKVStore;
16
+
17
+ #highestAgedIndex: AztecAsyncMap<string, number>;
18
+ #highestFinalizedIndex: AztecAsyncMap<string, number>;
19
+
20
+ constructor(store: AztecAsyncKVStore) {
21
+ this.#store = store;
22
+
23
+ this.#highestAgedIndex = this.#store.openMap('highest_aged_index');
24
+ this.#highestFinalizedIndex = this.#store.openMap('highest_finalized_index');
25
+ }
26
+
27
+ getHighestAgedIndex(secret: DirectionalAppTaggingSecret): Promise<number | undefined> {
28
+ return this.#highestAgedIndex.getAsync(secret.toString());
29
+ }
30
+
31
+ async updateHighestAgedIndex(secret: DirectionalAppTaggingSecret, index: number): Promise<void> {
32
+ const currentIndex = await this.#highestAgedIndex.getAsync(secret.toString());
33
+ if (currentIndex !== undefined && index <= currentIndex) {
34
+ // Log sync should never set a lower highest aged index.
35
+ throw new Error(`New highest aged index (${index}) must be higher than the current one (${currentIndex})`);
36
+ }
37
+ await this.#highestAgedIndex.set(secret.toString(), index);
38
+ }
39
+
40
+ getHighestFinalizedIndex(secret: DirectionalAppTaggingSecret): Promise<number | undefined> {
41
+ return this.#highestFinalizedIndex.getAsync(secret.toString());
42
+ }
43
+
44
+ async updateHighestFinalizedIndex(secret: DirectionalAppTaggingSecret, index: number): Promise<void> {
45
+ const currentIndex = await this.#highestFinalizedIndex.getAsync(secret.toString());
46
+ if (currentIndex !== undefined && index < currentIndex) {
47
+ // Log sync should never set a lower highest finalized index but it can happen that it would try to set the same
48
+ // one because we are loading logs from highest aged index + 1 and not from the highest finalized index.
49
+ throw new Error(`New highest finalized index (${index}) must be higher than the current one (${currentIndex})`);
50
+ }
51
+ await this.#highestFinalizedIndex.set(secret.toString(), index);
52
+ }
53
+ }
@@ -0,0 +1,42 @@
1
+ import { toArray } from '@aztec/foundation/iterable';
2
+ import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
3
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
+
5
+ /**
6
+ * Stores sender addresses. During recipient log synchronization, these senders are used, along with a given recipient,
7
+ * to derive directional app tagging secrets that are then used to sync the logs.
8
+ */
9
+ export class SenderAddressBookStore {
10
+ #store: AztecAsyncKVStore;
11
+ #addressBook: AztecAsyncMap<string, true>;
12
+
13
+ constructor(store: AztecAsyncKVStore) {
14
+ this.#store = store;
15
+
16
+ this.#addressBook = this.#store.openMap('address_book');
17
+ }
18
+
19
+ async addSender(address: AztecAddress): Promise<boolean> {
20
+ if (await this.#addressBook.hasAsync(address.toString())) {
21
+ return false;
22
+ }
23
+
24
+ await this.#addressBook.set(address.toString(), true);
25
+
26
+ return true;
27
+ }
28
+
29
+ async getSenders(): Promise<AztecAddress[]> {
30
+ return (await toArray(this.#addressBook.keysAsync())).map(AztecAddress.fromString);
31
+ }
32
+
33
+ async removeSender(address: AztecAddress): Promise<boolean> {
34
+ if (!(await this.#addressBook.hasAsync(address.toString()))) {
35
+ return false;
36
+ }
37
+
38
+ await this.#addressBook.delete(address.toString());
39
+
40
+ return true;
41
+ }
42
+ }