@aztec/pxe 0.0.0-test.0 → 0.0.1-commit.03f7ef2

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 (402) hide show
  1. package/README.md +5 -5
  2. package/dest/bin/check_oracle_version.d.ts +2 -0
  3. package/dest/bin/check_oracle_version.d.ts.map +1 -0
  4. package/dest/bin/check_oracle_version.js +129 -0
  5. package/dest/block_synchronizer/block_synchronizer.d.ts +39 -0
  6. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
  7. package/dest/{synchronizer/synchronizer.js → block_synchronizer/block_synchronizer.js} +36 -32
  8. package/dest/block_synchronizer/index.d.ts +2 -0
  9. package/dest/block_synchronizer/index.d.ts.map +1 -0
  10. package/dest/block_synchronizer/index.js +1 -0
  11. package/dest/config/index.d.ts +11 -24
  12. package/dest/config/index.d.ts.map +1 -1
  13. package/dest/config/index.js +18 -33
  14. package/dest/config/package_info.d.ts +1 -1
  15. package/dest/config/package_info.js +1 -1
  16. package/dest/contract_function_simulator/contract_function_simulator.d.ts +83 -0
  17. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -0
  18. package/dest/contract_function_simulator/contract_function_simulator.js +325 -0
  19. package/dest/contract_function_simulator/execution_note_cache.d.ts +95 -0
  20. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -0
  21. package/dest/contract_function_simulator/execution_note_cache.js +191 -0
  22. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
  23. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
  24. package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
  25. package/dest/contract_function_simulator/hashed_values_cache.d.ts +28 -0
  26. package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -0
  27. package/dest/contract_function_simulator/hashed_values_cache.js +36 -0
  28. package/dest/contract_function_simulator/index.d.ts +14 -0
  29. package/dest/contract_function_simulator/index.d.ts.map +1 -0
  30. package/dest/contract_function_simulator/index.js +12 -0
  31. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +20 -0
  32. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -0
  33. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +37 -0
  34. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +16 -0
  35. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -0
  36. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +26 -0
  37. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +17 -0
  38. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -0
  39. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +65 -0
  40. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +24 -0
  41. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -0
  42. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +51 -0
  43. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +22 -0
  44. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
  45. package/dest/contract_function_simulator/noir-structs/utility_context.js +33 -0
  46. package/dest/contract_function_simulator/oracle/index.d.ts +14 -0
  47. package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -0
  48. package/dest/contract_function_simulator/oracle/index.js +2 -0
  49. package/dest/contract_function_simulator/oracle/interfaces.d.ts +103 -0
  50. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
  51. package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
  52. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +17 -0
  53. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -0
  54. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +24 -0
  55. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +28 -0
  56. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -0
  57. package/dest/contract_function_simulator/oracle/note_packing_utils.js +54 -0
  58. package/dest/contract_function_simulator/oracle/oracle.d.ts +58 -0
  59. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -0
  60. package/dest/contract_function_simulator/oracle/oracle.js +345 -0
  61. package/dest/contract_function_simulator/oracle/private_execution.d.ts +47 -0
  62. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -0
  63. package/dest/contract_function_simulator/oracle/private_execution.js +123 -0
  64. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +240 -0
  65. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -0
  66. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +439 -0
  67. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +195 -0
  68. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -0
  69. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +372 -0
  70. package/dest/contract_function_simulator/pick_notes.d.ts +85 -0
  71. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -0
  72. package/dest/contract_function_simulator/pick_notes.js +51 -0
  73. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +6 -0
  74. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -0
  75. package/dest/contract_function_simulator/proxied_contract_data_source.js +80 -0
  76. package/dest/contract_function_simulator/proxied_node.d.ts +9 -0
  77. package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -0
  78. package/dest/contract_function_simulator/proxied_node.js +27 -0
  79. package/dest/debug/pxe_debug_utils.d.ts +31 -0
  80. package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
  81. package/dest/debug/pxe_debug_utils.js +37 -0
  82. package/dest/entrypoints/client/bundle/index.d.ts +4 -3
  83. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  84. package/dest/entrypoints/client/bundle/index.js +2 -2
  85. package/dest/entrypoints/client/bundle/utils.d.ts +10 -10
  86. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  87. package/dest/entrypoints/client/bundle/utils.js +18 -12
  88. package/dest/entrypoints/client/lazy/index.d.ts +4 -3
  89. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  90. package/dest/entrypoints/client/lazy/index.js +2 -2
  91. package/dest/entrypoints/client/lazy/utils.d.ts +9 -9
  92. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  93. package/dest/entrypoints/client/lazy/utils.js +17 -11
  94. package/dest/entrypoints/pxe_creation_options.d.ts +16 -0
  95. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -0
  96. package/dest/entrypoints/server/index.d.ts +6 -4
  97. package/dest/entrypoints/server/index.d.ts.map +1 -1
  98. package/dest/entrypoints/server/index.js +4 -3
  99. package/dest/entrypoints/server/utils.d.ts +8 -16
  100. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  101. package/dest/entrypoints/server/utils.js +31 -36
  102. package/dest/error_enriching.d.ts +11 -0
  103. package/dest/error_enriching.d.ts.map +1 -0
  104. package/dest/{pxe_service/error_enriching.js → error_enriching.js} +26 -18
  105. package/dest/events/event_service.d.ts +15 -0
  106. package/dest/events/event_service.d.ts.map +1 -0
  107. package/dest/events/event_service.js +47 -0
  108. package/dest/events/index.d.ts +2 -0
  109. package/dest/events/index.d.ts.map +1 -0
  110. package/dest/events/index.js +1 -0
  111. package/dest/events/private_event_filter_validator.d.ts +9 -0
  112. package/dest/events/private_event_filter_validator.d.ts.map +1 -0
  113. package/dest/events/private_event_filter_validator.js +39 -0
  114. package/dest/logs/log_service.d.ts +43 -0
  115. package/dest/logs/log_service.d.ts.map +1 -0
  116. package/dest/logs/log_service.js +239 -0
  117. package/dest/notes/index.d.ts +2 -0
  118. package/dest/notes/index.d.ts.map +1 -0
  119. package/dest/notes/index.js +1 -0
  120. package/dest/notes/note_service.d.ts +48 -0
  121. package/dest/notes/note_service.d.ts.map +1 -0
  122. package/dest/notes/note_service.js +152 -0
  123. package/dest/oracle_version.d.ts +3 -0
  124. package/dest/oracle_version.d.ts.map +1 -0
  125. package/dest/oracle_version.js +10 -0
  126. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +28 -0
  127. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -0
  128. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +271 -0
  129. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +4 -0
  130. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +1 -0
  131. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +41 -0
  132. package/dest/private_kernel/hints/index.d.ts +3 -0
  133. package/dest/private_kernel/hints/index.d.ts.map +1 -0
  134. package/dest/{kernel_prover → private_kernel}/hints/index.js +1 -0
  135. package/dest/private_kernel/index.d.ts +3 -0
  136. package/dest/private_kernel/index.d.ts.map +1 -0
  137. package/dest/private_kernel/index.js +2 -0
  138. package/dest/private_kernel/private_kernel_execution_prover.d.ts +44 -0
  139. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -0
  140. package/dest/private_kernel/private_kernel_execution_prover.js +286 -0
  141. package/dest/private_kernel/private_kernel_oracle.d.ts +63 -0
  142. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -0
  143. package/dest/private_kernel/private_kernel_oracle.js +4 -0
  144. package/dest/private_kernel/private_kernel_oracle_impl.d.ts +46 -0
  145. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -0
  146. package/dest/{kernel_oracle/index.js → private_kernel/private_kernel_oracle_impl.js} +19 -9
  147. package/dest/public_storage/public_storage_service.d.ts +24 -0
  148. package/dest/public_storage/public_storage_service.d.ts.map +1 -0
  149. package/dest/public_storage/public_storage_service.js +26 -0
  150. package/dest/pxe.d.ts +231 -0
  151. package/dest/pxe.d.ts.map +1 -0
  152. package/dest/pxe.js +756 -0
  153. package/dest/storage/address_data_provider/address_data_provider.d.ts +2 -4
  154. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +1 -1
  155. package/dest/storage/address_data_provider/address_data_provider.js +0 -3
  156. package/dest/storage/address_data_provider/index.d.ts +1 -1
  157. package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.d.ts +9 -0
  158. package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.d.ts.map +1 -0
  159. package/dest/storage/{sync_data_provider/sync_data_provider.js → anchor_block_data_provider/anchor_block_data_provider.js} +2 -12
  160. package/dest/storage/anchor_block_data_provider/index.d.ts +2 -0
  161. package/dest/storage/anchor_block_data_provider/index.d.ts.map +1 -0
  162. package/dest/storage/anchor_block_data_provider/index.js +1 -0
  163. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +48 -7
  164. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
  165. package/dest/storage/capsule_data_provider/capsule_data_provider.js +117 -28
  166. package/dest/storage/capsule_data_provider/index.d.ts +1 -1
  167. package/dest/storage/contract_data_provider/contract_data_provider.d.ts +16 -59
  168. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
  169. package/dest/storage/contract_data_provider/contract_data_provider.js +121 -80
  170. package/dest/storage/contract_data_provider/index.d.ts +1 -2
  171. package/dest/storage/contract_data_provider/index.d.ts.map +1 -1
  172. package/dest/storage/contract_data_provider/index.js +0 -1
  173. package/dest/storage/contract_data_provider/private_functions_tree.d.ts +3 -42
  174. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +1 -1
  175. package/dest/storage/contract_data_provider/private_functions_tree.js +10 -62
  176. package/dest/storage/index.d.ts +4 -5
  177. package/dest/storage/index.d.ts.map +1 -1
  178. package/dest/storage/index.js +3 -4
  179. package/dest/storage/metadata.d.ts +2 -0
  180. package/dest/storage/metadata.d.ts.map +1 -0
  181. package/dest/storage/metadata.js +1 -0
  182. package/dest/storage/note_data_provider/index.d.ts +2 -2
  183. package/dest/storage/note_data_provider/index.d.ts.map +1 -1
  184. package/dest/storage/note_data_provider/index.js +1 -1
  185. package/dest/storage/note_data_provider/note_data_provider.d.ts +75 -11
  186. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
  187. package/dest/storage/note_data_provider/note_data_provider.js +155 -82
  188. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +51 -0
  189. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +1 -0
  190. package/dest/storage/private_event_data_provider/private_event_data_provider.js +115 -0
  191. package/dest/storage/tagging_data_provider/index.d.ts +3 -2
  192. package/dest/storage/tagging_data_provider/index.d.ts.map +1 -1
  193. package/dest/storage/tagging_data_provider/index.js +2 -1
  194. package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.d.ts +31 -0
  195. package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.d.ts.map +1 -0
  196. package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.js +65 -0
  197. package/dest/storage/tagging_data_provider/sender_tagging_data_provider.d.ts +67 -0
  198. package/dest/storage/tagging_data_provider/sender_tagging_data_provider.d.ts.map +1 -0
  199. package/dest/storage/tagging_data_provider/sender_tagging_data_provider.js +196 -0
  200. package/dest/tagging/constants.d.ts +2 -0
  201. package/dest/tagging/constants.d.ts.map +1 -0
  202. package/dest/tagging/constants.js +3 -0
  203. package/dest/tagging/index.d.ts +5 -0
  204. package/dest/tagging/index.d.ts.map +1 -0
  205. package/dest/tagging/index.js +3 -0
  206. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +14 -0
  207. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -0
  208. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +99 -0
  209. package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.d.ts +21 -0
  210. package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.d.ts.map +1 -0
  211. package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.js +42 -0
  212. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +12 -0
  213. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -0
  214. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +20 -0
  215. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +14 -0
  216. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -0
  217. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +29 -0
  218. package/dest/tagging/sync/sync_sender_tagging_indexes.d.ts +21 -0
  219. package/dest/tagging/sync/sync_sender_tagging_indexes.d.ts.map +1 -0
  220. package/dest/tagging/sync/sync_sender_tagging_indexes.js +89 -0
  221. package/dest/tagging/sync/utils/get_status_change_of_pending.d.ts +11 -0
  222. package/dest/tagging/sync/utils/get_status_change_of_pending.d.ts.map +1 -0
  223. package/dest/tagging/sync/utils/get_status_change_of_pending.js +32 -0
  224. package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.d.ts +18 -0
  225. package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
  226. package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.js +55 -0
  227. package/dest/tagging/utils.d.ts +18 -0
  228. package/dest/tagging/utils.d.ts.map +1 -0
  229. package/dest/tagging/utils.js +25 -0
  230. package/dest/tree_membership/tree_membership_service.d.ts +52 -0
  231. package/dest/tree_membership/tree_membership_service.d.ts.map +1 -0
  232. package/dest/tree_membership/tree_membership_service.js +84 -0
  233. package/package.json +37 -34
  234. package/src/bin/check_oracle_version.ts +160 -0
  235. package/src/{synchronizer/synchronizer.ts → block_synchronizer/block_synchronizer.ts} +39 -35
  236. package/src/block_synchronizer/index.ts +1 -0
  237. package/src/config/index.ts +27 -55
  238. package/src/config/package_info.ts +1 -1
  239. package/src/contract_function_simulator/contract_function_simulator.ts +618 -0
  240. package/src/contract_function_simulator/execution_note_cache.ts +233 -0
  241. package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
  242. package/src/contract_function_simulator/hashed_values_cache.ts +47 -0
  243. package/src/contract_function_simulator/index.ts +13 -0
  244. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +47 -0
  245. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +28 -0
  246. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +69 -0
  247. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +64 -0
  248. package/src/contract_function_simulator/noir-structs/utility_context.ts +42 -0
  249. package/src/contract_function_simulator/oracle/index.ts +16 -0
  250. package/src/contract_function_simulator/oracle/interfaces.ts +175 -0
  251. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +23 -0
  252. package/src/contract_function_simulator/oracle/note_packing_utils.ts +68 -0
  253. package/src/contract_function_simulator/oracle/oracle.ts +605 -0
  254. package/src/contract_function_simulator/oracle/private_execution.ts +209 -0
  255. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +704 -0
  256. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +532 -0
  257. package/src/contract_function_simulator/pick_notes.ts +141 -0
  258. package/src/contract_function_simulator/proxied_contract_data_source.ts +83 -0
  259. package/src/contract_function_simulator/proxied_node.ts +33 -0
  260. package/src/debug/pxe_debug_utils.ts +48 -0
  261. package/src/entrypoints/client/bundle/index.ts +3 -2
  262. package/src/entrypoints/client/bundle/utils.ts +36 -36
  263. package/src/entrypoints/client/lazy/index.ts +3 -2
  264. package/src/entrypoints/client/lazy/utils.ts +36 -31
  265. package/src/entrypoints/pxe_creation_options.ts +12 -0
  266. package/src/entrypoints/server/index.ts +5 -3
  267. package/src/entrypoints/server/utils.ts +59 -51
  268. package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +36 -27
  269. package/src/events/event_service.ts +77 -0
  270. package/src/events/index.ts +1 -0
  271. package/src/events/private_event_filter_validator.ts +48 -0
  272. package/src/logs/log_service.ts +364 -0
  273. package/src/notes/index.ts +1 -0
  274. package/src/notes/note_service.ts +200 -0
  275. package/src/oracle_version.ts +11 -0
  276. package/src/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.ts +159 -147
  277. package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +58 -0
  278. package/src/{kernel_prover → private_kernel}/hints/index.ts +1 -0
  279. package/src/private_kernel/index.ts +2 -0
  280. package/src/private_kernel/private_kernel_execution_prover.ts +432 -0
  281. package/src/{kernel_prover/proving_data_oracle.ts → private_kernel/private_kernel_oracle.ts} +19 -30
  282. package/src/{kernel_oracle/index.ts → private_kernel/private_kernel_oracle_impl.ts} +33 -17
  283. package/src/public_storage/public_storage_service.ts +33 -0
  284. package/src/pxe.ts +1063 -0
  285. package/src/storage/address_data_provider/address_data_provider.ts +1 -7
  286. package/src/storage/{sync_data_provider/sync_data_provider.ts → anchor_block_data_provider/anchor_block_data_provider.ts} +2 -17
  287. package/src/storage/anchor_block_data_provider/index.ts +1 -0
  288. package/src/storage/capsule_data_provider/capsule_data_provider.ts +130 -31
  289. package/src/storage/contract_data_provider/contract_data_provider.ts +152 -94
  290. package/src/storage/contract_data_provider/index.ts +0 -1
  291. package/src/storage/contract_data_provider/private_functions_tree.ts +12 -76
  292. package/src/storage/index.ts +3 -5
  293. package/src/storage/metadata.ts +1 -0
  294. package/src/storage/note_data_provider/index.ts +1 -1
  295. package/src/storage/note_data_provider/note_data_provider.ts +188 -121
  296. package/src/storage/private_event_data_provider/private_event_data_provider.ts +162 -0
  297. package/src/storage/tagging_data_provider/index.ts +2 -1
  298. package/src/storage/tagging_data_provider/recipient_tagging_data_provider.ts +86 -0
  299. package/src/storage/tagging_data_provider/sender_tagging_data_provider.ts +244 -0
  300. package/src/tagging/constants.ts +3 -0
  301. package/src/tagging/index.ts +4 -0
  302. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +129 -0
  303. package/src/tagging/recipient_sync/new_recipient_tagging_data_provider.ts +53 -0
  304. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +34 -0
  305. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +43 -0
  306. package/src/tagging/sync/sync_sender_tagging_indexes.ts +112 -0
  307. package/src/tagging/sync/utils/get_status_change_of_pending.ts +44 -0
  308. package/src/tagging/sync/utils/load_and_store_new_tagging_indexes.ts +72 -0
  309. package/src/tagging/utils.ts +32 -0
  310. package/src/tree_membership/tree_membership_service.ts +112 -0
  311. package/dest/bin/index.d.ts +0 -3
  312. package/dest/bin/index.d.ts.map +0 -1
  313. package/dest/bin/index.js +0 -28
  314. package/dest/entrypoints/client/pxe_creation_options.d.ts +0 -11
  315. package/dest/entrypoints/client/pxe_creation_options.d.ts.map +0 -1
  316. package/dest/kernel_oracle/index.d.ts +0 -45
  317. package/dest/kernel_oracle/index.d.ts.map +0 -1
  318. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
  319. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
  320. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +0 -270
  321. package/dest/kernel_prover/hints/index.d.ts +0 -2
  322. package/dest/kernel_prover/hints/index.d.ts.map +0 -1
  323. package/dest/kernel_prover/index.d.ts +0 -3
  324. package/dest/kernel_prover/index.d.ts.map +0 -1
  325. package/dest/kernel_prover/index.js +0 -2
  326. package/dest/kernel_prover/kernel_prover.d.ts +0 -38
  327. package/dest/kernel_prover/kernel_prover.d.ts.map +0 -1
  328. package/dest/kernel_prover/kernel_prover.js +0 -217
  329. package/dest/kernel_prover/proving_data_oracle.d.ts +0 -73
  330. package/dest/kernel_prover/proving_data_oracle.d.ts.map +0 -1
  331. package/dest/kernel_prover/proving_data_oracle.js +0 -4
  332. package/dest/note_decryption_utils/add_public_values_to_payload.d.ts +0 -11
  333. package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +0 -1
  334. package/dest/note_decryption_utils/add_public_values_to_payload.js +0 -47
  335. package/dest/pxe_http/index.d.ts +0 -2
  336. package/dest/pxe_http/index.d.ts.map +0 -1
  337. package/dest/pxe_http/index.js +0 -1
  338. package/dest/pxe_http/pxe_http_server.d.ts +0 -16
  339. package/dest/pxe_http/pxe_http_server.d.ts.map +0 -1
  340. package/dest/pxe_http/pxe_http_server.js +0 -27
  341. package/dest/pxe_oracle_interface/index.d.ts +0 -159
  342. package/dest/pxe_oracle_interface/index.d.ts.map +0 -1
  343. package/dest/pxe_oracle_interface/index.js +0 -692
  344. package/dest/pxe_oracle_interface/tagging_utils.d.ts +0 -17
  345. package/dest/pxe_oracle_interface/tagging_utils.d.ts.map +0 -1
  346. package/dest/pxe_oracle_interface/tagging_utils.js +0 -23
  347. package/dest/pxe_service/error_enriching.d.ts +0 -11
  348. package/dest/pxe_service/error_enriching.d.ts.map +0 -1
  349. package/dest/pxe_service/index.d.ts +0 -3
  350. package/dest/pxe_service/index.d.ts.map +0 -1
  351. package/dest/pxe_service/index.js +0 -2
  352. package/dest/pxe_service/pxe_service.d.ts +0 -111
  353. package/dest/pxe_service/pxe_service.d.ts.map +0 -1
  354. package/dest/pxe_service/pxe_service.js +0 -664
  355. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts +0 -11
  356. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts.map +0 -1
  357. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.js +0 -20
  358. package/dest/storage/auth_witness_data_provider/index.d.ts +0 -2
  359. package/dest/storage/auth_witness_data_provider/index.d.ts.map +0 -1
  360. package/dest/storage/auth_witness_data_provider/index.js +0 -1
  361. package/dest/storage/data_provider.d.ts +0 -4
  362. package/dest/storage/data_provider.d.ts.map +0 -1
  363. package/dest/storage/data_provider.js +0 -1
  364. package/dest/storage/note_data_provider/note_dao.d.ts +0 -106
  365. package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
  366. package/dest/storage/note_data_provider/note_dao.js +0 -106
  367. package/dest/storage/sync_data_provider/index.d.ts +0 -2
  368. package/dest/storage/sync_data_provider/index.d.ts.map +0 -1
  369. package/dest/storage/sync_data_provider/index.js +0 -1
  370. package/dest/storage/sync_data_provider/sync_data_provider.d.ts +0 -12
  371. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +0 -1
  372. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +0 -18
  373. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +0 -1
  374. package/dest/storage/tagging_data_provider/tagging_data_provider.js +0 -65
  375. package/dest/synchronizer/index.d.ts +0 -2
  376. package/dest/synchronizer/index.d.ts.map +0 -1
  377. package/dest/synchronizer/index.js +0 -1
  378. package/dest/synchronizer/synchronizer.d.ts +0 -37
  379. package/dest/synchronizer/synchronizer.d.ts.map +0 -1
  380. package/dest/test/pxe_test_suite.d.ts +0 -3
  381. package/dest/test/pxe_test_suite.d.ts.map +0 -1
  382. package/dest/test/pxe_test_suite.js +0 -97
  383. package/src/bin/index.ts +0 -38
  384. package/src/entrypoints/client/pxe_creation_options.ts +0 -7
  385. package/src/kernel_prover/index.ts +0 -2
  386. package/src/kernel_prover/kernel_prover.ts +0 -351
  387. package/src/note_decryption_utils/add_public_values_to_payload.ts +0 -64
  388. package/src/pxe_http/index.ts +0 -1
  389. package/src/pxe_http/pxe_http_server.ts +0 -29
  390. package/src/pxe_oracle_interface/index.ts +0 -925
  391. package/src/pxe_oracle_interface/tagging_utils.ts +0 -32
  392. package/src/pxe_service/index.ts +0 -2
  393. package/src/pxe_service/pxe_service.ts +0 -949
  394. package/src/storage/auth_witness_data_provider/auth_witness_data_provider.ts +0 -34
  395. package/src/storage/auth_witness_data_provider/index.ts +0 -1
  396. package/src/storage/data_provider.ts +0 -3
  397. package/src/storage/note_data_provider/note_dao.ts +0 -162
  398. package/src/storage/sync_data_provider/index.ts +0 -1
  399. package/src/storage/tagging_data_provider/tagging_data_provider.ts +0 -92
  400. package/src/synchronizer/index.ts +0 -1
  401. package/src/test/pxe_test_suite.ts +0 -111
  402. /package/dest/entrypoints/{client/pxe_creation_options.js → pxe_creation_options.js} +0 -0
@@ -3,9 +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
- import type { DataProvider } from '../data_provider.js';
7
-
8
- export class AddressDataProvider implements DataProvider {
6
+ export class AddressDataProvider {
9
7
  #store: AztecAsyncKVStore;
10
8
  #completeAddresses: AztecAsyncArray<Buffer>;
11
9
  #completeAddressIndex: AztecAsyncMap<string, number>;
@@ -64,8 +62,4 @@ export class AddressDataProvider implements DataProvider {
64
62
  (await toArray(this.#completeAddresses.valuesAsync())).map(v => CompleteAddress.fromBuffer(v)),
65
63
  );
66
64
  }
67
-
68
- async getSize(): Promise<number> {
69
- return (await this.#completeAddresses.lengthAsync()) * CompleteAddress.SIZE_IN_BYTES;
70
- }
71
65
  }
@@ -1,9 +1,7 @@
1
1
  import type { AztecAsyncKVStore, AztecAsyncSingleton } from '@aztec/kv-store';
2
2
  import { BlockHeader } from '@aztec/stdlib/tx';
3
3
 
4
- import type { DataProvider } from '../data_provider.js';
5
-
6
- export class SyncDataProvider implements DataProvider {
4
+ export class AnchorBlockDataProvider {
7
5
  #store: AztecAsyncKVStore;
8
6
  #synchronizedHeader: AztecAsyncSingleton<Buffer>;
9
7
 
@@ -16,25 +14,12 @@ export class SyncDataProvider implements DataProvider {
16
14
  await this.#synchronizedHeader.set(header.toBuffer());
17
15
  }
18
16
 
19
- async getBlockNumber(): Promise<number | undefined> {
20
- const headerBuffer = await this.#synchronizedHeader.getAsync();
21
- if (!headerBuffer) {
22
- return undefined;
23
- }
24
-
25
- return Number(BlockHeader.fromBuffer(headerBuffer).globalVariables.blockNumber.toBigInt());
26
- }
27
-
28
17
  async getBlockHeader(): Promise<BlockHeader> {
29
18
  const headerBuffer = await this.#synchronizedHeader.getAsync();
30
19
  if (!headerBuffer) {
31
- 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`);
32
21
  }
33
22
 
34
23
  return BlockHeader.fromBuffer(headerBuffer);
35
24
  }
36
-
37
- async getSize(): Promise<number> {
38
- return (await this.#synchronizedHeader.getAsync())?.length ?? 0;
39
- }
40
25
  }
@@ -0,0 +1 @@
1
+ export { AnchorBlockDataProvider } from './anchor_block_data_provider.js';
@@ -1,35 +1,48 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- import { toArray } from '@aztec/foundation/iterable';
3
- import { type LogFn, createDebugOnlyLogger } from '@aztec/foundation/log';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { type Logger, createLogger } from '@aztec/foundation/log';
4
3
  import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
5
4
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
5
 
7
- import type { DataProvider } from '../data_provider.js';
8
-
9
- export class CapsuleDataProvider implements DataProvider {
6
+ export class CapsuleDataProvider {
10
7
  #store: AztecAsyncKVStore;
11
8
 
12
9
  // Arbitrary data stored by contracts. Key is computed as `${contractAddress}:${key}`
13
10
  #capsules: AztecAsyncMap<string, Buffer>;
14
11
 
15
- debug: LogFn;
12
+ logger: Logger;
16
13
 
17
14
  constructor(store: AztecAsyncKVStore) {
18
15
  this.#store = store;
19
16
 
20
17
  this.#capsules = this.#store.openMap('capsules');
21
18
 
22
- this.debug = createDebugOnlyLogger('pxe:capsule-data-provider');
19
+ this.logger = createLogger('pxe:capsule-data-provider');
23
20
  }
24
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
+ */
25
32
  async storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
26
33
  await this.#capsules.set(dbSlotToKey(contractAddress, slot), Buffer.concat(capsule.map(value => value.toBuffer())));
27
34
  }
28
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
+ */
29
42
  async loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
30
43
  const dataBuffer = await this.#capsules.getAsync(dbSlotToKey(contractAddress, slot));
31
44
  if (!dataBuffer) {
32
- this.debug(`Data not found for contract ${contractAddress.toString()} and slot ${slot.toString()}`);
45
+ this.logger.trace(`Data not found for contract ${contractAddress.toString()} and slot ${slot.toString()}`);
33
46
  return null;
34
47
  }
35
48
  const capsule: Fr[] = [];
@@ -39,42 +52,128 @@ export class CapsuleDataProvider implements DataProvider {
39
52
  return capsule;
40
53
  }
41
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
+ */
42
60
  async deleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void> {
43
61
  await this.#capsules.delete(dbSlotToKey(contractAddress, slot));
44
62
  }
45
63
 
46
- async copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number): Promise<void> {
47
- // In order to support overlapping source and destination regions, we need to check the relative positions of source
48
- // and destination. If destination is ahead of source, then by the time we overwrite source elements using forward
49
- // indexes we'll have already read those. On the contrary, if source is ahead of destination we need to use backward
50
- // indexes to avoid reading elements that've been overwritten.
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
+ */
75
+ copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number): Promise<void> {
76
+ return this.#store.transactionAsync(async () => {
77
+ // In order to support overlapping source and destination regions, we need to check the relative positions of source
78
+ // and destination. If destination is ahead of source, then by the time we overwrite source elements using forward
79
+ // indexes we'll have already read those. On the contrary, if source is ahead of destination we need to use backward
80
+ // indexes to avoid reading elements that've been overwritten.
81
+
82
+ const indexes = Array.from(Array(numEntries).keys());
83
+ if (srcSlot.lt(dstSlot)) {
84
+ indexes.reverse();
85
+ }
51
86
 
52
- const indexes = Array.from(Array(numEntries).keys());
53
- if (srcSlot.lt(dstSlot)) {
54
- indexes.reverse();
55
- }
87
+ for (const i of indexes) {
88
+ const currentSrcSlot = dbSlotToKey(contractAddress, srcSlot.add(new Fr(i)));
89
+ const currentDstSlot = dbSlotToKey(contractAddress, dstSlot.add(new Fr(i)));
56
90
 
57
- for (const i of indexes) {
58
- const currentSrcSlot = dbSlotToKey(contractAddress, srcSlot.add(new Fr(i)));
59
- const currentDstSlot = dbSlotToKey(contractAddress, dstSlot.add(new Fr(i)));
91
+ const toCopy = await this.#capsules.getAsync(currentSrcSlot);
92
+ if (!toCopy) {
93
+ throw new Error(`Attempted to copy empty slot ${currentSrcSlot} for contract ${contractAddress.toString()}`);
94
+ }
60
95
 
61
- const toCopy = await this.#capsules.getAsync(currentSrcSlot);
62
- if (!toCopy) {
63
- throw new Error(`Attempted to copy empty slot ${currentSrcSlot} for contract ${contractAddress.toString()}`);
96
+ await this.#capsules.set(currentDstSlot, toCopy);
64
97
  }
98
+ });
99
+ }
65
100
 
66
- await this.#capsules.set(currentDstSlot, toCopy);
67
- }
101
+ /**
102
+ * Appends multiple capsules to a capsule array stored at the base slot.
103
+ * The array length is stored at the base slot, and elements are stored in consecutive slots after it.
104
+ * All operations are performed in a single transaction.
105
+ * @param contractAddress - The contract address that owns the capsule array
106
+ * @param baseSlot - The slot where the array length is stored
107
+ * @param content - Array of capsule data to append
108
+ */
109
+ appendToCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][]): Promise<void> {
110
+ return this.#store.transactionAsync(async () => {
111
+ // Load current length, defaulting to 0 if not found
112
+ const lengthData = await this.loadCapsule(contractAddress, baseSlot);
113
+ const currentLength = lengthData ? lengthData[0].toNumber() : 0;
114
+
115
+ // Store each capsule at consecutive slots after baseSlot + 1 + currentLength
116
+ for (let i = 0; i < content.length; i++) {
117
+ const nextSlot = arraySlot(baseSlot, currentLength + i);
118
+ await this.storeCapsule(contractAddress, nextSlot, content[i]);
119
+ }
120
+
121
+ // Update length to include all new capsules
122
+ const newLength = currentLength + content.length;
123
+ await this.storeCapsule(contractAddress, baseSlot, [new Fr(newLength)]);
124
+ });
68
125
  }
69
126
 
70
- public async getSize() {
71
- return (await toArray(this.#capsules.valuesAsync())).reduce(
72
- (sum, value) => sum + value.length * Fr.SIZE_IN_BYTES,
73
- 0,
74
- );
127
+ readCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr): Promise<Fr[][]> {
128
+ return this.#store.transactionAsync(async () => {
129
+ // Load length, defaulting to 0 if not found
130
+ const maybeLength = await this.loadCapsule(contractAddress, baseSlot);
131
+ const length = maybeLength ? maybeLength[0].toBigInt() : 0n;
132
+
133
+ const values: Fr[][] = [];
134
+
135
+ // Read each capsule at consecutive slots after baseSlot
136
+ for (let i = 0; i < length; i++) {
137
+ const currentValue = await this.loadCapsule(contractAddress, arraySlot(baseSlot, i));
138
+ if (currentValue == undefined) {
139
+ throw new Error(
140
+ `Expected non-empty value at capsule array in base slot ${baseSlot} at index ${i} for contract ${contractAddress}`,
141
+ );
142
+ }
143
+
144
+ values.push(currentValue);
145
+ }
146
+
147
+ return values;
148
+ });
149
+ }
150
+
151
+ setCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][]) {
152
+ return this.#store.transactionAsync(async () => {
153
+ // Load current length, defaulting to 0 if not found
154
+ const maybeLength = await this.loadCapsule(contractAddress, baseSlot);
155
+ const originalLength = maybeLength ? maybeLength[0].toNumber() : 0;
156
+
157
+ // Set the new length
158
+ await this.storeCapsule(contractAddress, baseSlot, [new Fr(content.length)]);
159
+
160
+ // Store the new content, possibly overwriting existing values
161
+ for (let i = 0; i < content.length; i++) {
162
+ await this.storeCapsule(contractAddress, arraySlot(baseSlot, i), content[i]);
163
+ }
164
+
165
+ // Clear any stragglers
166
+ for (let i = content.length; i < originalLength; i++) {
167
+ await this.deleteCapsule(contractAddress, arraySlot(baseSlot, i));
168
+ }
169
+ });
75
170
  }
76
171
  }
77
172
 
78
173
  function dbSlotToKey(contractAddress: AztecAddress, slot: Fr): string {
79
174
  return `${contractAddress.toString()}:${slot.toString()}`;
80
175
  }
176
+
177
+ function arraySlot(baseSlot: Fr, index: number) {
178
+ return baseSlot.add(new Fr(1)).add(new Fr(index));
179
+ }
@@ -1,16 +1,20 @@
1
- import type { Fr } from '@aztec/foundation/fields';
1
+ import type { FUNCTION_TREE_HEIGHT } from '@aztec/constants';
2
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
3
  import { toArray } from '@aztec/foundation/iterable';
3
4
  import type { MembershipWitness } from '@aztec/foundation/trees';
4
5
  import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
5
- import { ContractClassNotFoundError, ContractNotFoundError } from '@aztec/simulator/client';
6
6
  import {
7
7
  type ContractArtifact,
8
+ type FunctionAbi,
8
9
  type FunctionArtifact,
10
+ type FunctionArtifactWithContractName,
11
+ FunctionCall,
9
12
  type FunctionDebugMetadata,
10
13
  FunctionSelector,
11
14
  FunctionType,
12
15
  contractArtifactFromBuffer,
13
16
  contractArtifactToBuffer,
17
+ encodeArguments,
14
18
  getFunctionDebugMetadata,
15
19
  } from '@aztec/stdlib/abi';
16
20
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
@@ -18,9 +22,9 @@ import {
18
22
  type ContractClass,
19
23
  type ContractInstanceWithAddress,
20
24
  SerializableContractInstance,
25
+ getContractClassFromArtifact,
21
26
  } from '@aztec/stdlib/contract';
22
27
 
23
- import type { DataProvider } from '../data_provider.js';
24
28
  import { PrivateFunctionsTree } from './private_functions_tree.js';
25
29
 
26
30
  /**
@@ -30,9 +34,13 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
30
34
  * to efficiently serve the requested data. It interacts with the ContractDatabase and AztecNode to fetch
31
35
  * the required information and facilitate cryptographic proof generation.
32
36
  */
33
- export class ContractDataProvider implements DataProvider {
37
+ export class ContractDataProvider {
34
38
  /** Map from contract class id to private function tree. */
35
- private contractClassesCache: Map<string, PrivateFunctionsTree> = new Map();
39
+ // TODO: Update it to be LRU cache so that it doesn't keep all the data all the time.
40
+ #privateFunctionTrees: Map<string, PrivateFunctionsTree> = new Map();
41
+
42
+ /** Map from contract address to contract class id */
43
+ #contractClassIdMap: Map<string, Fr> = new Map();
36
44
 
37
45
  #contractArtifacts: AztecAsyncMap<string, Buffer>;
38
46
  #contractInstances: AztecAsyncMap<string, Buffer>;
@@ -65,6 +73,8 @@ export class ContractDataProvider implements DataProvider {
65
73
  }
66
74
 
67
75
  async addContractInstance(contract: ContractInstanceWithAddress): Promise<void> {
76
+ this.#contractClassIdMap.set(contract.address.toString(), contract.currentContractClassId);
77
+
68
78
  await this.#contractInstances.set(
69
79
  contract.address.toString(),
70
80
  new SerializableContractInstance(contract).toBuffer(),
@@ -73,15 +83,15 @@ export class ContractDataProvider implements DataProvider {
73
83
 
74
84
  // Private getters
75
85
 
76
- async #getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
77
- const contract = await this.#contractInstances.getAsync(address.toString());
78
- return contract && SerializableContractInstance.fromBuffer(contract).withAddress(address);
79
- }
80
-
81
- async #getContractArtifact(id: Fr): Promise<ContractArtifact | undefined> {
82
- const contract = await this.#contractArtifacts.getAsync(id.toString());
83
- // TODO(@spalladino): AztecAsyncMap lies and returns Uint8Arrays instead of Buffers, hence the extra Buffer.from.
84
- return contract && contractArtifactFromBuffer(Buffer.from(contract));
86
+ async #getContractClassId(contractAddress: AztecAddress): Promise<Fr | undefined> {
87
+ if (!this.#contractClassIdMap.has(contractAddress.toString())) {
88
+ const instance = await this.getContractInstance(contractAddress);
89
+ if (!instance) {
90
+ return;
91
+ }
92
+ this.#contractClassIdMap.set(contractAddress.toString(), instance.currentContractClassId);
93
+ }
94
+ return this.#contractClassIdMap.get(contractAddress.toString());
85
95
  }
86
96
 
87
97
  /**
@@ -94,31 +104,21 @@ export class ContractDataProvider implements DataProvider {
94
104
  * @returns A ContractTree instance associated with the specified contract address.
95
105
  * @throws An Error if the contract is not found in the ContractDatabase.
96
106
  */
97
- private async getTreeForClassId(classId: Fr): Promise<PrivateFunctionsTree> {
98
- if (!this.contractClassesCache.has(classId.toString())) {
99
- const artifact = await this.#getContractArtifact(classId);
107
+ async #getPrivateFunctionTreeForClassId(classId: Fr): Promise<PrivateFunctionsTree | undefined> {
108
+ if (!this.#privateFunctionTrees.has(classId.toString())) {
109
+ const artifact = await this.getContractArtifact(classId);
100
110
  if (!artifact) {
101
- throw new ContractClassNotFoundError(classId.toString());
111
+ return;
102
112
  }
103
113
  const tree = await PrivateFunctionsTree.create(artifact);
104
- this.contractClassesCache.set(classId.toString(), tree);
114
+ this.#privateFunctionTrees.set(classId.toString(), tree);
105
115
  }
106
- return this.contractClassesCache.get(classId.toString())!;
116
+ return this.#privateFunctionTrees.get(classId.toString())!;
107
117
  }
108
118
 
109
- /**
110
- * Retrieve or create a ContractTree instance based on the provided AztecAddress.
111
- * If an existing tree with the same contract address is found in the cache, it will be returned.
112
- * Otherwise, a new ContractTree instance will be created using the contract data from the database
113
- * and added to the cache before returning.
114
- *
115
- * @param contractAddress - The AztecAddress of the contract for which the ContractTree is required.
116
- * @returns A ContractTree instance associated with the specified contract address.
117
- * @throws An Error if the contract is not found in the ContractDatabase.
118
- */
119
- private async getTreeForAddress(contractAddress: AztecAddress): Promise<PrivateFunctionsTree> {
120
- const instance = await this.getContractInstance(contractAddress);
121
- return this.getTreeForClassId(instance.currentContractClassId);
119
+ async #getContractArtifactByAddress(contractAddress: AztecAddress): Promise<ContractArtifact | undefined> {
120
+ const contractClassId = await this.#getContractClassId(contractAddress);
121
+ return contractClassId && this.getContractArtifact(contractClassId);
122
122
  }
123
123
 
124
124
  // Public getters
@@ -129,32 +129,33 @@ export class ContractDataProvider implements DataProvider {
129
129
  }
130
130
 
131
131
  /** Returns a contract instance for a given address. Throws if not found. */
132
- public async getContractInstance(contractAddress: AztecAddress): Promise<ContractInstanceWithAddress> {
133
- const instance = await this.#getContractInstance(contractAddress);
134
- if (!instance) {
135
- throw new ContractNotFoundError(contractAddress.toString());
136
- }
137
- return instance;
132
+ public async getContractInstance(contractAddress: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
133
+ const contract = await this.#contractInstances.getAsync(contractAddress.toString());
134
+ return contract && SerializableContractInstance.fromBuffer(contract).withAddress(contractAddress);
138
135
  }
139
136
 
140
- public async getContractArtifact(contractClassId: Fr): Promise<ContractArtifact> {
141
- const tree = await this.getTreeForClassId(contractClassId);
142
- return tree.getArtifact();
137
+ public async getContractArtifact(contractClassId: Fr): Promise<ContractArtifact | undefined> {
138
+ const contract = await this.#contractArtifacts.getAsync(contractClassId.toString());
139
+ // TODO(@spalladino): AztecAsyncMap lies and returns Uint8Arrays instead of Buffers, hence the extra Buffer.from.
140
+ return contract && contractArtifactFromBuffer(Buffer.from(contract));
143
141
  }
144
142
 
145
143
  /** Returns a contract class for a given class id. Throws if not found. */
146
- public async getContractClass(contractClassId: Fr): Promise<ContractClass> {
147
- const tree = await this.getTreeForClassId(contractClassId);
148
- return tree.getContractClass();
144
+ public async getContractClass(contractClassId: Fr): Promise<ContractClass | undefined> {
145
+ const artifact = await this.getContractArtifact(contractClassId);
146
+ return artifact && getContractClassFromArtifact(artifact);
149
147
  }
150
148
 
151
149
  public async getContract(
152
150
  address: AztecAddress,
153
151
  ): Promise<(ContractInstanceWithAddress & ContractArtifact) | undefined> {
154
152
  const instance = await this.getContractInstance(address);
155
- const artifact = instance && (await this.getContractArtifact(instance?.currentContractClassId));
156
- if (!instance || !artifact) {
157
- return undefined;
153
+ if (!instance) {
154
+ return;
155
+ }
156
+ const artifact = await this.getContractArtifact(instance.currentContractClassId);
157
+ if (!artifact) {
158
+ return;
158
159
  }
159
160
  return { ...instance, ...artifact };
160
161
  }
@@ -168,26 +169,44 @@ export class ContractDataProvider implements DataProvider {
168
169
  * @param selector - The function selector.
169
170
  * @returns The corresponding function's artifact as an object.
170
171
  */
171
- public async getFunctionArtifact(contractAddress: AztecAddress, selector: FunctionSelector) {
172
- const tree = await this.getTreeForAddress(contractAddress);
173
- return tree.getFunctionArtifact(selector);
172
+ public async getFunctionArtifact(
173
+ contractAddress: AztecAddress,
174
+ selector: FunctionSelector,
175
+ ): Promise<FunctionArtifactWithContractName | undefined> {
176
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
177
+ const fnArtifact = artifact && (await this.#findFunctionArtifactBySelector(artifact, selector));
178
+ return fnArtifact && { ...fnArtifact, contractName: artifact.name };
174
179
  }
175
180
 
176
- /**
177
- * Retrieves the artifact of a specified function within a given contract.
178
- * The function is identified by its name, which is unique within a contract.
179
- * Throws if the contract has not been added to the database.
180
- *
181
- * @param contractAddress - The AztecAddress representing the contract containing the function.
182
- * @param functionName - The name of the function.
183
- * @returns The corresponding function's artifact as an object
184
- */
185
- public async getFunctionArtifactByName(
181
+ public async getFunctionArtifactWithDebugMetadata(
186
182
  contractAddress: AztecAddress,
187
- functionName: string,
188
- ): Promise<FunctionArtifact | undefined> {
189
- const tree = await this.getTreeForAddress(contractAddress);
190
- return tree.getArtifact().functions.find(f => f.name === functionName);
183
+ selector: FunctionSelector,
184
+ ): Promise<FunctionArtifactWithContractName> {
185
+ const artifact = await this.getFunctionArtifact(contractAddress, selector);
186
+ if (!artifact) {
187
+ throw new Error(`Function artifact not found for contract ${contractAddress} and selector ${selector}.`);
188
+ }
189
+ const debug = await this.getFunctionDebugMetadata(contractAddress, selector);
190
+ return {
191
+ ...artifact,
192
+ debug,
193
+ };
194
+ }
195
+
196
+ public async getPublicFunctionArtifact(
197
+ contractAddress: AztecAddress,
198
+ ): Promise<FunctionArtifactWithContractName | undefined> {
199
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
200
+ const fnArtifact = artifact && artifact.functions.find(fn => fn.functionType === FunctionType.PUBLIC);
201
+ return fnArtifact && { ...fnArtifact, contractName: artifact.name };
202
+ }
203
+
204
+ public async getFunctionAbi(
205
+ contractAddress: AztecAddress,
206
+ selector: FunctionSelector,
207
+ ): Promise<FunctionAbi | undefined> {
208
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
209
+ return artifact && (await this.#findFunctionAbiBySelector(artifact, selector));
191
210
  }
192
211
 
193
212
  /**
@@ -204,24 +223,17 @@ export class ContractDataProvider implements DataProvider {
204
223
  contractAddress: AztecAddress,
205
224
  selector: FunctionSelector,
206
225
  ): Promise<FunctionDebugMetadata | undefined> {
207
- const tree = await this.getTreeForAddress(contractAddress);
208
- const artifact = await tree.getFunctionArtifact(selector);
209
- return getFunctionDebugMetadata(tree.getArtifact(), artifact);
226
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
227
+ const fnArtifact = artifact && (await this.#findFunctionArtifactBySelector(artifact, selector));
228
+ return fnArtifact && getFunctionDebugMetadata(artifact, fnArtifact);
210
229
  }
211
230
 
212
- /**
213
- * Retrieve the bytecode of a specific function in a contract at the given address.
214
- * The returned bytecode is required for executing and verifying the function's behavior
215
- * in the Aztec network. Throws an error if the contract or function cannot be found.
216
- *
217
- * @param contractAddress - The contract's address.
218
- * @param selector - The function selector.
219
- * @returns A Promise that resolves to a Buffer containing the bytecode of the specified function.
220
- * @throws Error if the contract address is unknown or not found.
221
- */
222
- public async getBytecode(contractAddress: AztecAddress, selector: FunctionSelector) {
223
- const tree = await this.getTreeForAddress(contractAddress);
224
- return tree.getBytecode(selector);
231
+ public async getPublicFunctionDebugMetadata(
232
+ contractAddress: AztecAddress,
233
+ ): Promise<FunctionDebugMetadata | undefined> {
234
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
235
+ const fnArtifact = artifact && artifact.functions.find(fn => fn.functionType === FunctionType.PUBLIC);
236
+ return fnArtifact && getFunctionDebugMetadata(artifact, fnArtifact);
225
237
  }
226
238
 
227
239
  /**
@@ -236,26 +248,72 @@ export class ContractDataProvider implements DataProvider {
236
248
  public async getFunctionMembershipWitness(
237
249
  contractClassId: Fr,
238
250
  selector: FunctionSelector,
239
- ): Promise<MembershipWitness<5>> {
240
- const tree = await this.getTreeForClassId(contractClassId);
241
- return tree.getFunctionMembershipWitness(selector);
251
+ ): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT> | undefined> {
252
+ const tree = await this.#getPrivateFunctionTreeForClassId(contractClassId);
253
+ return tree?.getFunctionMembershipWitness(selector);
242
254
  }
243
255
 
244
256
  public async getDebugContractName(contractAddress: AztecAddress) {
245
- const tree = await this.getTreeForAddress(contractAddress);
246
- return tree.getArtifact().name;
257
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
258
+ return artifact?.name;
247
259
  }
248
260
 
249
261
  public async getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector) {
250
- const tree = await this.getTreeForAddress(contractAddress);
251
- const { name: contractName } = tree.getArtifact();
252
- const { name: functionName } = await tree.getFunctionArtifact(selector);
253
- return `${contractName}:${functionName}`;
262
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
263
+ const fnArtifact = artifact && (await this.#findFunctionAbiBySelector(artifact, selector));
264
+ return `${artifact?.name ?? contractAddress}:${fnArtifact?.name ?? selector}`;
254
265
  }
255
266
 
256
- public async getSize() {
257
- return (await toArray(this.#contractInstances.valuesAsync()))
258
- .concat(await toArray(this.#contractArtifacts.valuesAsync()))
259
- .reduce((sum, value) => sum + value.length, 0);
267
+ async #findFunctionArtifactBySelector(
268
+ artifact: ContractArtifact,
269
+ selector: FunctionSelector,
270
+ ): Promise<FunctionArtifact | undefined> {
271
+ const functions = artifact.functions;
272
+ for (let i = 0; i < functions.length; i++) {
273
+ const fn = functions[i];
274
+ const fnSelector = await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters);
275
+ if (fnSelector.equals(selector)) {
276
+ return fn;
277
+ }
278
+ }
279
+ }
280
+
281
+ async #findFunctionAbiBySelector(
282
+ artifact: ContractArtifact,
283
+ selector: FunctionSelector,
284
+ ): Promise<FunctionAbi | undefined> {
285
+ const functions = [...artifact.functions, ...(artifact.nonDispatchPublicFunctions ?? [])];
286
+ for (let i = 0; i < functions.length; i++) {
287
+ const fn = functions[i];
288
+ const fnSelector = await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters);
289
+ if (fnSelector.equals(selector)) {
290
+ return fn;
291
+ }
292
+ }
293
+ }
294
+
295
+ public async getFunctionCall(functionName: string, args: any[], to: AztecAddress): Promise<FunctionCall> {
296
+ const contract = await this.getContract(to);
297
+ if (!contract) {
298
+ throw new Error(
299
+ `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`,
300
+ );
301
+ }
302
+
303
+ const functionDao = contract.functions.find(f => f.name === functionName);
304
+ if (!functionDao) {
305
+ throw new Error(`Unknown function ${functionName} in contract ${contract.name}.`);
306
+ }
307
+
308
+ return {
309
+ name: functionDao.name,
310
+ args: encodeArguments(functionDao, args),
311
+ selector: await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters),
312
+ type: functionDao.functionType,
313
+ to,
314
+ hideMsgSender: false,
315
+ isStatic: functionDao.isStatic,
316
+ returnTypes: functionDao.returnTypes,
317
+ };
260
318
  }
261
319
  }
@@ -1,2 +1 @@
1
1
  export { ContractDataProvider } from './contract_data_provider.js';
2
- export { PrivateFunctionsTree } from './private_functions_tree.js';