@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
@@ -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>;
@@ -43,23 +43,23 @@ export class AddressDataProvider {
43
43
  });
44
44
  }
45
45
 
46
- async #getCompleteAddress(address: AztecAddress): Promise<CompleteAddress | undefined> {
47
- const index = await this.#completeAddressIndex.getAsync(address.toString());
48
- if (index === undefined) {
49
- return undefined;
50
- }
51
-
52
- const value = await this.#completeAddresses.atAsync(index);
53
- return value ? await CompleteAddress.fromBuffer(value) : undefined;
54
- }
55
-
56
46
  getCompleteAddress(account: AztecAddress): Promise<CompleteAddress | undefined> {
57
- return this.#getCompleteAddress(account);
47
+ return this.#store.transactionAsync(async () => {
48
+ const index = await this.#completeAddressIndex.getAsync(account.toString());
49
+ if (index === undefined) {
50
+ return undefined;
51
+ }
52
+
53
+ const value = await this.#completeAddresses.atAsync(index);
54
+ return value ? await CompleteAddress.fromBuffer(value) : undefined;
55
+ });
58
56
  }
59
57
 
60
- async getCompleteAddresses(): Promise<CompleteAddress[]> {
61
- return await Promise.all(
62
- (await toArray(this.#completeAddresses.valuesAsync())).map(v => CompleteAddress.fromBuffer(v)),
63
- );
58
+ getCompleteAddresses(): Promise<CompleteAddress[]> {
59
+ return this.#store.transactionAsync(async () => {
60
+ return await Promise.all(
61
+ (await toArray(this.#completeAddresses.valuesAsync())).map(v => CompleteAddress.fromBuffer(v)),
62
+ );
63
+ });
64
64
  }
65
65
  }
@@ -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
 
@@ -11,23 +10,22 @@ export class SyncDataProvider {
11
10
  this.#synchronizedHeader = this.#store.openSingleton('header');
12
11
  }
13
12
 
13
+ /**
14
+ * Sets the currently synchronized block
15
+ *
16
+ * Important: this method is only called from BlockSynchronizer, and since we need it to run atomically with other
17
+ * stores in the case of a reorg, it MUST NOT be wrapped in a `transactionAsync` call. Doing so would result in a
18
+ * deadlock when the backend is IndexedDB, because `transactionAsync` is not designed to support reentrancy.
19
+ *
20
+ */
14
21
  async setHeader(header: BlockHeader): Promise<void> {
15
22
  await this.#synchronizedHeader.set(header.toBuffer());
16
23
  }
17
24
 
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
25
  async getBlockHeader(): Promise<BlockHeader> {
28
26
  const headerBuffer = await this.#synchronizedHeader.getAsync();
29
27
  if (!headerBuffer) {
30
- throw new Error(`Header not set`);
28
+ throw new Error(`Trying to get block header with a not-yet-synchronized PXE - this should never happen`);
31
29
  }
32
30
 
33
31
  return BlockHeader.fromBuffer(headerBuffer);
@@ -0,0 +1 @@
1
+ export { AnchorBlockStore } from './anchor_block_store.js';
@@ -0,0 +1,315 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { type Logger, createLogger } from '@aztec/foundation/log';
3
+ import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
4
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
+
6
+ import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
7
+
8
+ export class CapsuleStore implements StagedStore {
9
+ readonly storeName = 'capsule';
10
+
11
+ #store: AztecAsyncKVStore;
12
+
13
+ // Arbitrary data stored by contracts. Key is computed as `${contractAddress}:${key}`
14
+ #capsules: AztecAsyncMap<string, Buffer>;
15
+
16
+ // jobId => `${contractAddress}:${key}` => capsule data
17
+ // when `#stagedCapsules.get('some-job-id').get('${some-contract-address:some-key') === null`,
18
+ // it signals that the capsule was deleted during the job, so it needs to be deleted on commit
19
+ #stagedCapsules: Map<string, Map<string, Buffer | null>>;
20
+
21
+ logger: Logger;
22
+
23
+ constructor(store: AztecAsyncKVStore) {
24
+ this.#store = store;
25
+
26
+ this.#capsules = this.#store.openMap('capsules');
27
+
28
+ this.#stagedCapsules = new Map();
29
+
30
+ this.logger = createLogger('pxe:capsule-data-provider');
31
+ }
32
+
33
+ /**
34
+ * Given a job denoted by `jobId`, it returns the
35
+ * capsules that said job has interacted with.
36
+ *
37
+ * Capsules that haven't been committed to persistence KV storage
38
+ * are kept in-memory in `#stagedCapsules`, this method provides a convenient
39
+ * way to access that in-memory collection of data.
40
+ *
41
+ * @param jobId
42
+ * @returns
43
+ */
44
+ #getJobStagedCapsules(jobId: string): Map<string, Buffer | null> {
45
+ let jobStagedCapsules = this.#stagedCapsules.get(jobId);
46
+ if (!jobStagedCapsules) {
47
+ jobStagedCapsules = new Map();
48
+ this.#stagedCapsules.set(jobId, jobStagedCapsules);
49
+ }
50
+ return jobStagedCapsules;
51
+ }
52
+
53
+ /**
54
+ * Reads a capsule's slot from the staged version of the data associated to the given jobId.
55
+ *
56
+ * If it is not there, it reads it from the KV store.
57
+ */
58
+ async #getFromStage(jobId: string, dbSlotKey: string): Promise<Buffer | null | undefined> {
59
+ const jobStagedCapsules = this.#getJobStagedCapsules(jobId);
60
+ const staged: Buffer | null | undefined = jobStagedCapsules.get(dbSlotKey);
61
+
62
+ // Always issue DB read to keep IndexedDB transaction alive, even if the value is in the job staged data. This
63
+ // keeps IndexedDB transactions alive (they auto-commit when a new micro-task starts and there are no pending read
64
+ // requests). The staged value still takes precedence if it exists (including null for deletions).
65
+ const dbValue = await this.#loadCapsuleFromDb(dbSlotKey);
66
+
67
+ return staged !== undefined ? staged : dbValue;
68
+ }
69
+
70
+ /**
71
+ * Writes a capsule to the stage of a job.
72
+ */
73
+ #setOnStage(jobId: string, dbSlotKey: string, capsuleData: Buffer) {
74
+ this.#getJobStagedCapsules(jobId).set(dbSlotKey, capsuleData);
75
+ }
76
+
77
+ /**
78
+ * Deletes a capsule on the stage of a job. Note the capsule will still
79
+ * exist in storage until the job is committed.
80
+ */
81
+ #deleteOnStage(jobId: string, dbSlotKey: string) {
82
+ this.#getJobStagedCapsules(jobId).set(dbSlotKey, null);
83
+ }
84
+
85
+ async #loadCapsuleFromDb(dbSlotKey: string): Promise<Buffer | null> {
86
+ const dataBuffer = await this.#capsules.getAsync(dbSlotKey);
87
+ if (!dataBuffer) {
88
+ return null;
89
+ }
90
+
91
+ return dataBuffer;
92
+ }
93
+
94
+ /**
95
+ * Commits staged data to main storage.
96
+ * Called by JobCoordinator when a job completes successfully.
97
+ * Note: JobCoordinator wraps all commits in a single transaction, so we don't
98
+ * need our own transactionAsync here (and using one would deadlock on IndexedDB).
99
+ * @param jobId - The jobId identifying which staged data to commit
100
+ */
101
+ async commit(jobId: string): Promise<void> {
102
+ const jobStagedCapsules = this.#getJobStagedCapsules(jobId);
103
+
104
+ for (const [key, value] of jobStagedCapsules) {
105
+ // In the write stage, we represent deleted capsules with null
106
+ // (as opposed to undefined, which denotes there was never a capsule there to begin with).
107
+ // So we delete from actual KV store here.
108
+ if (value === null) {
109
+ await this.#capsules.delete(key);
110
+ } else {
111
+ await this.#capsules.set(key, value);
112
+ }
113
+ }
114
+
115
+ this.#stagedCapsules.delete(jobId);
116
+ }
117
+
118
+ /**
119
+ * Discards staged data without committing.
120
+ */
121
+ discardStaged(jobId: string): Promise<void> {
122
+ this.#stagedCapsules.delete(jobId);
123
+ return Promise.resolve();
124
+ }
125
+
126
+ /**
127
+ * Stores arbitrary information in a per-contract non-volatile database, which can later be retrieved with `loadCapsule`.
128
+ * * If data was already stored at this slot, it is overwritten.
129
+ * @param contractAddress - The contract address to scope the data under.
130
+ * @param slot - The slot in the database in which to store the value. Slots need not be contiguous.
131
+ * @param capsule - An array of field elements representing the capsule.
132
+ * @param jobId - The context in which this store will be visible until PXE decides to persist it to underlying KV store
133
+ * @remarks A capsule is a "blob" of data that is passed to the contract through an oracle. It works similarly
134
+ * to public contract storage in that it's indexed by the contract address and storage slot but instead of the global
135
+ * network state it's backed by local PXE db.
136
+ */
137
+ storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[], jobId: string) {
138
+ const dbSlotKey = dbSlotToKey(contractAddress, slot);
139
+
140
+ // A store overrides any pre-existing data on the slot
141
+ this.#setOnStage(jobId, dbSlotKey, Buffer.concat(capsule.map(value => value.toBuffer())));
142
+ }
143
+
144
+ /**
145
+ * Returns data previously stored via `storeCapsule` in the per-contract non-volatile database.
146
+ * @param contractAddress - The contract address under which the data is scoped.
147
+ * @param slot - The slot in the database to read.
148
+ * @returns The stored data or `null` if no data is stored under the slot.
149
+ */
150
+ async loadCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string): Promise<Fr[] | null> {
151
+ const dataBuffer = await this.#getFromStage(jobId, dbSlotToKey(contractAddress, slot));
152
+ if (!dataBuffer) {
153
+ this.logger.trace(`Data not found for contract ${contractAddress.toString()} and slot ${slot.toString()}`);
154
+ return null;
155
+ }
156
+ const capsule: Fr[] = [];
157
+ for (let i = 0; i < dataBuffer.length; i += Fr.SIZE_IN_BYTES) {
158
+ capsule.push(Fr.fromBuffer(dataBuffer.subarray(i, i + Fr.SIZE_IN_BYTES)));
159
+ }
160
+ return capsule;
161
+ }
162
+
163
+ /**
164
+ * Deletes data in the per-contract non-volatile database. Does nothing if no data was present.
165
+ * @param contractAddress - The contract address under which the data is scoped.
166
+ * @param slot - The slot in the database to delete.
167
+ */
168
+ deleteCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string) {
169
+ // When we commit this, we will interpret null as a deletion, so we'll propagate the delete to the KV store
170
+ this.#deleteOnStage(jobId, dbSlotToKey(contractAddress, slot));
171
+ }
172
+
173
+ /**
174
+ * Copies a number of contiguous entries in the per-contract non-volatile database. This allows for efficient data
175
+ * structures by avoiding repeated calls to `loadCapsule` and `storeCapsule`.
176
+ * Supports overlapping source and destination regions (which will result in the overlapped source values being
177
+ * overwritten). All copied slots must exist in the database (i.e. have been stored and not deleted)
178
+ *
179
+ * @param contractAddress - The contract address under which the data is scoped.
180
+ * @param srcSlot - The first slot to copy from.
181
+ * @param dstSlot - The first slot to copy to.
182
+ * @param numEntries - The number of entries to copy.
183
+ */
184
+ copyCapsule(
185
+ contractAddress: AztecAddress,
186
+ srcSlot: Fr,
187
+ dstSlot: Fr,
188
+ numEntries: number,
189
+ jobId: string,
190
+ ): Promise<void> {
191
+ // This transactional context gives us "copy atomicity":
192
+ // there shouldn't be concurrent writes to what's being copied here.
193
+ // Equally important: this in practice is expected to perform thousands of DB operations
194
+ // and not using a transaction here would heavily impact performance.
195
+ return this.#store.transactionAsync(async () => {
196
+ // In order to support overlapping source and destination regions, we need to check the relative positions of source
197
+ // and destination. If destination is ahead of source, then by the time we overwrite source elements using forward
198
+ // indexes we'll have already read those. On the contrary, if source is ahead of destination we need to use backward
199
+ // indexes to avoid reading elements that've been overwritten.
200
+ const indexes = Array.from(Array(numEntries).keys());
201
+ if (srcSlot.lt(dstSlot)) {
202
+ indexes.reverse();
203
+ }
204
+
205
+ for (const i of indexes) {
206
+ const currentSrcSlot = dbSlotToKey(contractAddress, srcSlot.add(new Fr(i)));
207
+ const currentDstSlot = dbSlotToKey(contractAddress, dstSlot.add(new Fr(i)));
208
+
209
+ const toCopy = await this.#getFromStage(jobId, currentSrcSlot);
210
+ if (!toCopy) {
211
+ throw new Error(`Attempted to copy empty slot ${currentSrcSlot} for contract ${contractAddress.toString()}`);
212
+ }
213
+
214
+ this.#setOnStage(jobId, currentDstSlot, toCopy);
215
+ }
216
+ });
217
+ }
218
+
219
+ /**
220
+ * Appends multiple capsules to a capsule array stored at the base slot.
221
+ * The array length is stored at the base slot, and elements are stored in consecutive slots after it.
222
+ * All operations are performed in a single transaction.
223
+ * @param contractAddress - The contract address that owns the capsule array
224
+ * @param baseSlot - The slot where the array length is stored
225
+ * @param content - Array of capsule data to append
226
+ */
227
+ appendToCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string): Promise<void> {
228
+ // We wrap this in a transaction to serialize concurrent calls from Promise.all.
229
+ // Without this, concurrent appends to the same array could race: both read length=0,
230
+ // both write at the same slots, one overwrites the other.
231
+ // Equally important: this in practice is expected to perform thousands of DB operations
232
+ // and not using a transaction here would heavily impact performance.
233
+ return this.#store.transactionAsync(async () => {
234
+ // Load current length, defaulting to 0 if not found
235
+ const lengthData = await this.loadCapsule(contractAddress, baseSlot, jobId);
236
+ const currentLength = lengthData ? lengthData[0].toNumber() : 0;
237
+
238
+ // Store each capsule at consecutive slots after baseSlot + 1 + currentLength
239
+ for (let i = 0; i < content.length; i++) {
240
+ const nextSlot = arraySlot(baseSlot, currentLength + i);
241
+ this.storeCapsule(contractAddress, nextSlot, content[i], jobId);
242
+ }
243
+
244
+ // Update length to include all new capsules
245
+ const newLength = currentLength + content.length;
246
+ this.storeCapsule(contractAddress, baseSlot, [new Fr(newLength)], jobId);
247
+ });
248
+ }
249
+
250
+ readCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, jobId: string): Promise<Fr[][]> {
251
+ // I'm leaving this transactional context here though because I'm assuming this
252
+ // gives us "read array atomicity": there shouldn't be concurrent writes to what's being copied
253
+ // here.
254
+ // This is one point we should revisit in the future if we want to relax the concurrency
255
+ // of jobs: different calls running concurrently on the same contract may cause trouble.
256
+ return this.#store.transactionAsync(async () => {
257
+ // Load length, defaulting to 0 if not found
258
+ const maybeLength = await this.loadCapsule(contractAddress, baseSlot, jobId);
259
+ const length = maybeLength ? maybeLength[0].toBigInt() : 0n;
260
+
261
+ const values: Fr[][] = [];
262
+
263
+ // Read each capsule at consecutive slots after baseSlot
264
+ for (let i = 0; i < length; i++) {
265
+ const currentValue = await this.loadCapsule(contractAddress, arraySlot(baseSlot, i), jobId);
266
+ if (currentValue == undefined) {
267
+ throw new Error(
268
+ `Expected non-empty value at capsule array in base slot ${baseSlot} at index ${i} for contract ${contractAddress}`,
269
+ );
270
+ }
271
+
272
+ values.push(currentValue);
273
+ }
274
+
275
+ return values;
276
+ });
277
+ }
278
+
279
+ setCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string) {
280
+ // This transactional context in theory isn't so critical now because we aren't
281
+ // writing to DB so if there's exceptions midway and it blows up, no visible impact
282
+ // to persistent storage will happen.
283
+ // I'm leaving this transactional context here though because I'm assuming this
284
+ // gives us "write array atomicity": there shouldn't be concurrent writes to what's being copied
285
+ // here.
286
+ // This is one point we should revisit in the future if we want to relax the concurrency
287
+ // of jobs: different calls running concurrently on the same contract may cause trouble.
288
+ return this.#store.transactionAsync(async () => {
289
+ // Load current length, defaulting to 0 if not found
290
+ const maybeLength = await this.loadCapsule(contractAddress, baseSlot, jobId);
291
+ const originalLength = maybeLength ? maybeLength[0].toNumber() : 0;
292
+
293
+ // Set the new length
294
+ this.storeCapsule(contractAddress, baseSlot, [new Fr(content.length)], jobId);
295
+
296
+ // Store the new content, possibly overwriting existing values
297
+ for (let i = 0; i < content.length; i++) {
298
+ this.storeCapsule(contractAddress, arraySlot(baseSlot, i), content[i], jobId);
299
+ }
300
+
301
+ // Clear any stragglers
302
+ for (let i = content.length; i < originalLength; i++) {
303
+ this.deleteCapsule(contractAddress, arraySlot(baseSlot, i), jobId);
304
+ }
305
+ });
306
+ }
307
+ }
308
+
309
+ function dbSlotToKey(contractAddress: AztecAddress, slot: Fr): string {
310
+ return `${contractAddress.toString()}:${slot.toString()}`;
311
+ }
312
+
313
+ function arraySlot(baseSlot: Fr, index: number) {
314
+ return baseSlot.add(new Fr(1)).add(new Fr(index));
315
+ }
@@ -0,0 +1 @@
1
+ export { CapsuleStore } from './capsule_store.js';
@@ -1,5 +1,5 @@
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';
@@ -8,11 +8,13 @@ import {
8
8
  type FunctionAbi,
9
9
  type FunctionArtifact,
10
10
  type FunctionArtifactWithContractName,
11
+ FunctionCall,
11
12
  type FunctionDebugMetadata,
12
13
  FunctionSelector,
13
14
  FunctionType,
14
15
  contractArtifactFromBuffer,
15
16
  contractArtifactToBuffer,
17
+ encodeArguments,
16
18
  getFunctionDebugMetadata,
17
19
  } from '@aztec/stdlib/abi';
18
20
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
@@ -26,13 +28,13 @@ import {
26
28
  import { PrivateFunctionsTree } from './private_functions_tree.js';
27
29
 
28
30
  /**
29
- * ContractDataProvider serves as a data manager and retriever for Aztec.nr contracts.
31
+ * ContractStore serves as a data manager and retriever for Aztec.nr contracts.
30
32
  * It provides methods to obtain contract addresses, function ABI, bytecode, and membership witnesses
31
33
  * from a given contract address and function selector. The class maintains a cache of ContractTree instances
32
34
  * to efficiently serve the requested data. It interacts with the ContractDatabase and AztecNode to fetch
33
35
  * the required information and facilitate cryptographic proof generation.
34
36
  */
35
- export class ContractDataProvider {
37
+ export class ContractStore {
36
38
  /** Map from contract class id to private function tree. */
37
39
  // TODO: Update it to be LRU cache so that it doesn't keep all the data all the time.
38
40
  #privateFunctionTrees: Map<string, PrivateFunctionsTree> = new Map();
@@ -40,10 +42,12 @@ export class ContractDataProvider {
40
42
  /** Map from contract address to contract class id */
41
43
  #contractClassIdMap: Map<string, Fr> = new Map();
42
44
 
45
+ #store: AztecAsyncKVStore;
43
46
  #contractArtifacts: AztecAsyncMap<string, Buffer>;
44
47
  #contractInstances: AztecAsyncMap<string, Buffer>;
45
48
 
46
49
  constructor(store: AztecAsyncKVStore) {
50
+ this.#store = store;
47
51
  this.#contractArtifacts = store.openMap('contract_artifacts');
48
52
  this.#contractInstances = store.openMap('contracts_instances');
49
53
  }
@@ -51,6 +55,7 @@ export class ContractDataProvider {
51
55
  // Setters
52
56
 
53
57
  public async addContractArtifact(id: Fr, contract: ContractArtifact): Promise<void> {
58
+ // Validation outside transactionAsync - these are not DB operations
54
59
  const privateFunctions = contract.functions.filter(
55
60
  functionArtifact => functionArtifact.functionType === FunctionType.PRIVATE,
56
61
  );
@@ -67,7 +72,9 @@ export class ContractDataProvider {
67
72
  throw new Error('Repeated function selectors of private functions');
68
73
  }
69
74
 
70
- await this.#contractArtifacts.set(id.toString(), contractArtifactToBuffer(contract));
75
+ await this.#store.transactionAsync(() =>
76
+ this.#contractArtifacts.set(id.toString(), contractArtifactToBuffer(contract)),
77
+ );
71
78
  }
72
79
 
73
80
  async addContractInstance(contract: ContractInstanceWithAddress): Promise<void> {
@@ -121,21 +128,27 @@ export class ContractDataProvider {
121
128
 
122
129
  // Public getters
123
130
 
124
- async getContractsAddresses(): Promise<AztecAddress[]> {
125
- const keys = await toArray(this.#contractInstances.keysAsync());
126
- return keys.map(AztecAddress.fromString);
131
+ getContractsAddresses(): Promise<AztecAddress[]> {
132
+ return this.#store.transactionAsync(async () => {
133
+ const keys = await toArray(this.#contractInstances.keysAsync());
134
+ return keys.map(AztecAddress.fromString);
135
+ });
127
136
  }
128
137
 
129
138
  /** Returns a contract instance for a given address. Throws if not found. */
130
- public async getContractInstance(contractAddress: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
131
- const contract = await this.#contractInstances.getAsync(contractAddress.toString());
132
- return contract && SerializableContractInstance.fromBuffer(contract).withAddress(contractAddress);
139
+ public getContractInstance(contractAddress: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
140
+ return this.#store.transactionAsync(async () => {
141
+ const contract = await this.#contractInstances.getAsync(contractAddress.toString());
142
+ return contract && SerializableContractInstance.fromBuffer(contract).withAddress(contractAddress);
143
+ });
133
144
  }
134
145
 
135
- public async getContractArtifact(contractClassId: Fr): Promise<ContractArtifact | undefined> {
136
- const contract = await this.#contractArtifacts.getAsync(contractClassId.toString());
137
- // TODO(@spalladino): AztecAsyncMap lies and returns Uint8Arrays instead of Buffers, hence the extra Buffer.from.
138
- return contract && contractArtifactFromBuffer(Buffer.from(contract));
146
+ public getContractArtifact(contractClassId: Fr): Promise<ContractArtifact | undefined> {
147
+ return this.#store.transactionAsync(async () => {
148
+ const contract = await this.#contractArtifacts.getAsync(contractClassId.toString());
149
+ // TODO(@spalladino): AztecAsyncMap lies and returns Uint8Arrays instead of Buffers, hence the extra Buffer.from.
150
+ return contract && contractArtifactFromBuffer(Buffer.from(contract));
151
+ });
139
152
  }
140
153
 
141
154
  /** Returns a contract class for a given class id. Throws if not found. */
@@ -176,6 +189,21 @@ export class ContractDataProvider {
176
189
  return fnArtifact && { ...fnArtifact, contractName: artifact.name };
177
190
  }
178
191
 
192
+ public async getFunctionArtifactWithDebugMetadata(
193
+ contractAddress: AztecAddress,
194
+ selector: FunctionSelector,
195
+ ): Promise<FunctionArtifactWithContractName> {
196
+ const artifact = await this.getFunctionArtifact(contractAddress, selector);
197
+ if (!artifact) {
198
+ throw new Error(`Function artifact not found for contract ${contractAddress} and selector ${selector}.`);
199
+ }
200
+ const debug = await this.getFunctionDebugMetadata(contractAddress, selector);
201
+ return {
202
+ ...artifact,
203
+ debug,
204
+ };
205
+ }
206
+
179
207
  public async getPublicFunctionArtifact(
180
208
  contractAddress: AztecAddress,
181
209
  ): Promise<FunctionArtifactWithContractName | undefined> {
@@ -274,4 +302,29 @@ export class ContractDataProvider {
274
302
  }
275
303
  }
276
304
  }
305
+
306
+ public async getFunctionCall(functionName: string, args: any[], to: AztecAddress): Promise<FunctionCall> {
307
+ const contract = await this.getContract(to);
308
+ if (!contract) {
309
+ throw new Error(
310
+ `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`,
311
+ );
312
+ }
313
+
314
+ const functionDao = contract.functions.find(f => f.name === functionName);
315
+ if (!functionDao) {
316
+ throw new Error(`Unknown function ${functionName} in contract ${contract.name}.`);
317
+ }
318
+
319
+ return {
320
+ name: functionDao.name,
321
+ args: encodeArguments(functionDao, args),
322
+ selector: await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters),
323
+ type: functionDao.functionType,
324
+ to,
325
+ hideMsgSender: false,
326
+ isStatic: functionDao.isStatic,
327
+ returnTypes: functionDao.returnTypes,
328
+ };
329
+ }
277
330
  }
@@ -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';
@@ -1 +1 @@
1
- export const PXE_DATA_SCHEMA_VERSION = 2;
1
+ export const PXE_DATA_SCHEMA_VERSION = 3;
@@ -0,0 +1,2 @@
1
+ export { NoteDao } from '@aztec/stdlib/note';
2
+ export { NoteStore } from './note_store.js';