@aztec/pxe 0.0.0-test.1 → 0.0.1-commit.24de95ac

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 (309) 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 +39 -0
  5. package/dest/config/index.d.ts +10 -15
  6. package/dest/config/index.d.ts.map +1 -1
  7. package/dest/config/index.js +11 -20
  8. package/dest/config/package_info.js +1 -1
  9. package/dest/contract_function_simulator/contract_function_simulator.d.ts +56 -0
  10. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -0
  11. package/dest/contract_function_simulator/contract_function_simulator.js +301 -0
  12. package/dest/contract_function_simulator/execution_data_provider.d.ts +274 -0
  13. package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -0
  14. package/dest/contract_function_simulator/execution_data_provider.js +14 -0
  15. package/dest/contract_function_simulator/execution_note_cache.d.ts +93 -0
  16. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -0
  17. package/dest/contract_function_simulator/execution_note_cache.js +183 -0
  18. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
  19. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
  20. package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
  21. package/dest/contract_function_simulator/hashed_values_cache.d.ts +28 -0
  22. package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -0
  23. package/dest/contract_function_simulator/hashed_values_cache.js +36 -0
  24. package/dest/contract_function_simulator/index.d.ts +14 -0
  25. package/dest/contract_function_simulator/index.d.ts.map +1 -0
  26. package/dest/contract_function_simulator/index.js +12 -0
  27. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +20 -0
  28. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -0
  29. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +37 -0
  30. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +15 -0
  31. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -0
  32. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +25 -0
  33. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +17 -0
  34. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -0
  35. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +65 -0
  36. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +22 -0
  37. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -0
  38. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +42 -0
  39. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +22 -0
  40. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
  41. package/dest/contract_function_simulator/noir-structs/utility_context.js +33 -0
  42. package/dest/contract_function_simulator/oracle/index.d.ts +14 -0
  43. package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -0
  44. package/dest/contract_function_simulator/oracle/index.js +2 -0
  45. package/dest/contract_function_simulator/oracle/interfaces.d.ts +97 -0
  46. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
  47. package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
  48. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +19 -0
  49. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -0
  50. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +24 -0
  51. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +22 -0
  52. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -0
  53. package/dest/contract_function_simulator/oracle/note_packing_utils.js +49 -0
  54. package/dest/contract_function_simulator/oracle/oracle.d.ts +57 -0
  55. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -0
  56. package/dest/contract_function_simulator/oracle/oracle.js +328 -0
  57. package/dest/contract_function_simulator/oracle/private_execution.d.ts +48 -0
  58. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -0
  59. package/dest/contract_function_simulator/oracle/private_execution.js +123 -0
  60. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +236 -0
  61. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -0
  62. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +417 -0
  63. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +154 -0
  64. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -0
  65. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +265 -0
  66. package/dest/contract_function_simulator/pick_notes.d.ts +85 -0
  67. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -0
  68. package/dest/contract_function_simulator/pick_notes.js +51 -0
  69. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +6 -0
  70. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -0
  71. package/dest/contract_function_simulator/proxied_contract_data_source.js +62 -0
  72. package/dest/contract_function_simulator/proxied_node.d.ts +9 -0
  73. package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -0
  74. package/dest/contract_function_simulator/proxied_node.js +27 -0
  75. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +122 -0
  76. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -0
  77. package/dest/contract_function_simulator/pxe_oracle_interface.js +701 -0
  78. package/dest/entrypoints/client/bundle/index.d.ts +4 -2
  79. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  80. package/dest/entrypoints/client/bundle/index.js +3 -2
  81. package/dest/entrypoints/client/bundle/utils.d.ts +9 -9
  82. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  83. package/dest/entrypoints/client/bundle/utils.js +18 -12
  84. package/dest/entrypoints/client/lazy/index.d.ts +4 -2
  85. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  86. package/dest/entrypoints/client/lazy/index.js +3 -2
  87. package/dest/entrypoints/client/lazy/utils.d.ts +8 -8
  88. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  89. package/dest/entrypoints/client/lazy/utils.js +17 -11
  90. package/dest/entrypoints/{client/pxe_creation_options.d.ts → pxe_creation_options.d.ts} +4 -1
  91. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -0
  92. package/dest/entrypoints/server/index.d.ts +5 -3
  93. package/dest/entrypoints/server/index.d.ts.map +1 -1
  94. package/dest/entrypoints/server/index.js +4 -3
  95. package/dest/entrypoints/server/utils.d.ts +7 -15
  96. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  97. package/dest/entrypoints/server/utils.js +34 -28
  98. package/dest/{pxe_service/error_enriching.d.ts → error_enriching.d.ts} +1 -1
  99. package/dest/error_enriching.d.ts.map +1 -0
  100. package/dest/{pxe_service/error_enriching.js → error_enriching.js} +26 -18
  101. package/dest/oracle_version.d.ts +3 -0
  102. package/dest/oracle_version.d.ts.map +1 -0
  103. package/dest/oracle_version.js +10 -0
  104. package/dest/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.d.ts +6 -6
  105. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -0
  106. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +271 -0
  107. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +4 -0
  108. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +1 -0
  109. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +41 -0
  110. package/dest/private_kernel/hints/index.d.ts +3 -0
  111. package/dest/private_kernel/hints/index.d.ts.map +1 -0
  112. package/dest/{kernel_prover → private_kernel}/hints/index.js +1 -0
  113. package/dest/private_kernel/index.d.ts +3 -0
  114. package/dest/private_kernel/index.d.ts.map +1 -0
  115. package/dest/private_kernel/index.js +2 -0
  116. package/dest/private_kernel/private_kernel_execution_prover.d.ts +44 -0
  117. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -0
  118. package/dest/private_kernel/private_kernel_execution_prover.js +285 -0
  119. package/dest/{kernel_prover/proving_data_oracle.d.ts → private_kernel/private_kernel_oracle.d.ts} +17 -28
  120. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -0
  121. package/dest/private_kernel/private_kernel_oracle.js +4 -0
  122. package/dest/{kernel_oracle/index.d.ts → private_kernel/private_kernel_oracle_impl.d.ts} +8 -8
  123. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -0
  124. package/dest/{kernel_oracle/index.js → private_kernel/private_kernel_oracle_impl.js} +19 -9
  125. package/dest/pxe.d.ts +233 -0
  126. package/dest/pxe.d.ts.map +1 -0
  127. package/dest/pxe.js +789 -0
  128. package/dest/storage/address_data_provider/address_data_provider.d.ts +1 -3
  129. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +1 -1
  130. package/dest/storage/address_data_provider/address_data_provider.js +0 -3
  131. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +14 -5
  132. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
  133. package/dest/storage/capsule_data_provider/capsule_data_provider.js +85 -24
  134. package/dest/storage/contract_data_provider/contract_data_provider.d.ts +12 -47
  135. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
  136. package/dest/storage/contract_data_provider/contract_data_provider.js +92 -70
  137. package/dest/storage/contract_data_provider/index.d.ts +0 -1
  138. package/dest/storage/contract_data_provider/index.d.ts.map +1 -1
  139. package/dest/storage/contract_data_provider/index.js +0 -1
  140. package/dest/storage/contract_data_provider/private_functions_tree.d.ts +2 -41
  141. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +1 -1
  142. package/dest/storage/contract_data_provider/private_functions_tree.js +9 -61
  143. package/dest/storage/index.d.ts +2 -3
  144. package/dest/storage/index.d.ts.map +1 -1
  145. package/dest/storage/index.js +2 -3
  146. package/dest/storage/metadata.d.ts +2 -0
  147. package/dest/storage/metadata.d.ts.map +1 -0
  148. package/dest/storage/metadata.js +1 -0
  149. package/dest/storage/note_data_provider/note_dao.d.ts +16 -22
  150. package/dest/storage/note_data_provider/note_dao.d.ts.map +1 -1
  151. package/dest/storage/note_data_provider/note_dao.js +16 -20
  152. package/dest/storage/note_data_provider/note_data_provider.d.ts +71 -8
  153. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
  154. package/dest/storage/note_data_provider/note_data_provider.js +133 -74
  155. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +43 -0
  156. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +1 -0
  157. package/dest/storage/private_event_data_provider/private_event_data_provider.js +104 -0
  158. package/dest/storage/sync_data_provider/sync_data_provider.d.ts +2 -4
  159. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +1 -1
  160. package/dest/storage/sync_data_provider/sync_data_provider.js +2 -5
  161. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +28 -6
  162. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +1 -1
  163. package/dest/storage/tagging_data_provider/tagging_data_provider.js +48 -24
  164. package/dest/synchronizer/synchronizer.d.ts +7 -9
  165. package/dest/synchronizer/synchronizer.d.ts.map +1 -1
  166. package/dest/synchronizer/synchronizer.js +17 -19
  167. package/dest/tagging/constants.d.ts +2 -0
  168. package/dest/tagging/constants.d.ts.map +1 -0
  169. package/dest/tagging/constants.js +2 -0
  170. package/dest/tagging/index.d.ts +7 -0
  171. package/dest/tagging/index.d.ts.map +1 -0
  172. package/dest/tagging/index.js +5 -0
  173. package/dest/tagging/siloed_tag.d.ts +14 -0
  174. package/dest/tagging/siloed_tag.d.ts.map +1 -0
  175. package/dest/tagging/siloed_tag.js +20 -0
  176. package/dest/tagging/tag.d.ts +12 -0
  177. package/dest/tagging/tag.d.ts.map +1 -0
  178. package/dest/tagging/tag.js +17 -0
  179. package/dest/tagging/utils.d.ts +18 -0
  180. package/dest/tagging/utils.d.ts.map +1 -0
  181. package/dest/tagging/utils.js +24 -0
  182. package/package.json +34 -32
  183. package/src/bin/check_oracle_version.ts +50 -0
  184. package/src/config/index.ts +20 -33
  185. package/src/config/package_info.ts +1 -1
  186. package/src/contract_function_simulator/contract_function_simulator.ts +548 -0
  187. package/src/contract_function_simulator/execution_data_provider.ts +343 -0
  188. package/src/contract_function_simulator/execution_note_cache.ts +222 -0
  189. package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
  190. package/src/contract_function_simulator/hashed_values_cache.ts +47 -0
  191. package/src/contract_function_simulator/index.ts +13 -0
  192. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +47 -0
  193. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +27 -0
  194. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +69 -0
  195. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +52 -0
  196. package/src/contract_function_simulator/noir-structs/utility_context.ts +42 -0
  197. package/src/contract_function_simulator/oracle/index.ts +16 -0
  198. package/src/contract_function_simulator/oracle/interfaces.ts +160 -0
  199. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +23 -0
  200. package/src/contract_function_simulator/oracle/note_packing_utils.ts +52 -0
  201. package/src/contract_function_simulator/oracle/oracle.ts +575 -0
  202. package/src/contract_function_simulator/oracle/private_execution.ts +207 -0
  203. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +625 -0
  204. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +358 -0
  205. package/src/contract_function_simulator/pick_notes.ts +141 -0
  206. package/src/contract_function_simulator/proxied_contract_data_source.ts +66 -0
  207. package/src/contract_function_simulator/proxied_node.ts +33 -0
  208. package/src/contract_function_simulator/pxe_oracle_interface.ts +1019 -0
  209. package/src/entrypoints/client/bundle/index.ts +4 -2
  210. package/src/entrypoints/client/bundle/utils.ts +36 -36
  211. package/src/entrypoints/client/lazy/index.ts +4 -2
  212. package/src/entrypoints/client/lazy/utils.ts +36 -31
  213. package/src/entrypoints/{client/pxe_creation_options.ts → pxe_creation_options.ts} +4 -1
  214. package/src/entrypoints/server/index.ts +5 -3
  215. package/src/entrypoints/server/utils.ts +69 -47
  216. package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +36 -27
  217. package/src/oracle_version.ts +11 -0
  218. package/src/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.ts +158 -142
  219. package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +58 -0
  220. package/src/{kernel_prover → private_kernel}/hints/index.ts +1 -0
  221. package/src/private_kernel/index.ts +2 -0
  222. package/src/private_kernel/private_kernel_execution_prover.ts +436 -0
  223. package/src/{kernel_prover/proving_data_oracle.ts → private_kernel/private_kernel_oracle.ts} +17 -29
  224. package/src/{kernel_oracle/index.ts → private_kernel/private_kernel_oracle_impl.ts} +30 -15
  225. package/src/pxe.ts +1113 -0
  226. package/src/storage/address_data_provider/address_data_provider.ts +1 -7
  227. package/src/storage/capsule_data_provider/capsule_data_provider.ts +97 -30
  228. package/src/storage/contract_data_provider/contract_data_provider.ts +114 -81
  229. package/src/storage/contract_data_provider/index.ts +0 -1
  230. package/src/storage/contract_data_provider/private_functions_tree.ts +11 -75
  231. package/src/storage/index.ts +2 -4
  232. package/src/storage/metadata.ts +1 -0
  233. package/src/storage/note_data_provider/note_dao.ts +19 -27
  234. package/src/storage/note_data_provider/note_data_provider.ts +161 -113
  235. package/src/storage/private_event_data_provider/private_event_data_provider.ts +148 -0
  236. package/src/storage/sync_data_provider/sync_data_provider.ts +4 -10
  237. package/src/storage/tagging_data_provider/tagging_data_provider.ts +58 -30
  238. package/src/synchronizer/synchronizer.ts +21 -22
  239. package/src/tagging/constants.ts +2 -0
  240. package/src/tagging/index.ts +6 -0
  241. package/src/tagging/siloed_tag.ts +22 -0
  242. package/src/tagging/tag.ts +16 -0
  243. package/src/tagging/utils.ts +31 -0
  244. package/dest/bin/index.d.ts +0 -3
  245. package/dest/bin/index.d.ts.map +0 -1
  246. package/dest/bin/index.js +0 -28
  247. package/dest/entrypoints/client/pxe_creation_options.d.ts.map +0 -1
  248. package/dest/kernel_oracle/index.d.ts.map +0 -1
  249. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
  250. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +0 -270
  251. package/dest/kernel_prover/hints/index.d.ts +0 -2
  252. package/dest/kernel_prover/hints/index.d.ts.map +0 -1
  253. package/dest/kernel_prover/index.d.ts +0 -3
  254. package/dest/kernel_prover/index.d.ts.map +0 -1
  255. package/dest/kernel_prover/index.js +0 -2
  256. package/dest/kernel_prover/kernel_prover.d.ts +0 -38
  257. package/dest/kernel_prover/kernel_prover.d.ts.map +0 -1
  258. package/dest/kernel_prover/kernel_prover.js +0 -217
  259. package/dest/kernel_prover/proving_data_oracle.d.ts.map +0 -1
  260. package/dest/kernel_prover/proving_data_oracle.js +0 -4
  261. package/dest/note_decryption_utils/add_public_values_to_payload.d.ts +0 -11
  262. package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +0 -1
  263. package/dest/note_decryption_utils/add_public_values_to_payload.js +0 -47
  264. package/dest/pxe_http/index.d.ts +0 -2
  265. package/dest/pxe_http/index.d.ts.map +0 -1
  266. package/dest/pxe_http/index.js +0 -1
  267. package/dest/pxe_http/pxe_http_server.d.ts +0 -16
  268. package/dest/pxe_http/pxe_http_server.d.ts.map +0 -1
  269. package/dest/pxe_http/pxe_http_server.js +0 -27
  270. package/dest/pxe_oracle_interface/index.d.ts +0 -159
  271. package/dest/pxe_oracle_interface/index.d.ts.map +0 -1
  272. package/dest/pxe_oracle_interface/index.js +0 -692
  273. package/dest/pxe_oracle_interface/tagging_utils.d.ts +0 -17
  274. package/dest/pxe_oracle_interface/tagging_utils.d.ts.map +0 -1
  275. package/dest/pxe_oracle_interface/tagging_utils.js +0 -23
  276. package/dest/pxe_service/error_enriching.d.ts.map +0 -1
  277. package/dest/pxe_service/index.d.ts +0 -3
  278. package/dest/pxe_service/index.d.ts.map +0 -1
  279. package/dest/pxe_service/index.js +0 -2
  280. package/dest/pxe_service/pxe_service.d.ts +0 -111
  281. package/dest/pxe_service/pxe_service.d.ts.map +0 -1
  282. package/dest/pxe_service/pxe_service.js +0 -664
  283. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts +0 -11
  284. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts.map +0 -1
  285. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.js +0 -20
  286. package/dest/storage/auth_witness_data_provider/index.d.ts +0 -2
  287. package/dest/storage/auth_witness_data_provider/index.d.ts.map +0 -1
  288. package/dest/storage/auth_witness_data_provider/index.js +0 -1
  289. package/dest/storage/data_provider.d.ts +0 -4
  290. package/dest/storage/data_provider.d.ts.map +0 -1
  291. package/dest/storage/data_provider.js +0 -1
  292. package/dest/test/pxe_test_suite.d.ts +0 -3
  293. package/dest/test/pxe_test_suite.d.ts.map +0 -1
  294. package/dest/test/pxe_test_suite.js +0 -97
  295. package/src/bin/index.ts +0 -38
  296. package/src/kernel_prover/index.ts +0 -2
  297. package/src/kernel_prover/kernel_prover.ts +0 -351
  298. package/src/note_decryption_utils/add_public_values_to_payload.ts +0 -64
  299. package/src/pxe_http/index.ts +0 -1
  300. package/src/pxe_http/pxe_http_server.ts +0 -29
  301. package/src/pxe_oracle_interface/index.ts +0 -925
  302. package/src/pxe_oracle_interface/tagging_utils.ts +0 -32
  303. package/src/pxe_service/index.ts +0 -2
  304. package/src/pxe_service/pxe_service.ts +0 -949
  305. package/src/storage/auth_witness_data_provider/auth_witness_data_provider.ts +0 -34
  306. package/src/storage/auth_witness_data_provider/index.ts +0 -1
  307. package/src/storage/data_provider.ts +0 -3
  308. package/src/test/pxe_test_suite.ts +0 -111
  309. /package/dest/entrypoints/{client/pxe_creation_options.js → pxe_creation_options.js} +0 -0
@@ -1,13 +1,11 @@
1
1
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
2
2
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
3
  import { CompleteAddress } from '@aztec/stdlib/contract';
4
- import type { DataProvider } from '../data_provider.js';
5
- export declare class AddressDataProvider implements DataProvider {
4
+ export declare class AddressDataProvider {
6
5
  #private;
7
6
  constructor(store: AztecAsyncKVStore);
8
7
  addCompleteAddress(completeAddress: CompleteAddress): Promise<boolean>;
9
8
  getCompleteAddress(account: AztecAddress): Promise<CompleteAddress | undefined>;
10
9
  getCompleteAddresses(): Promise<CompleteAddress[]>;
11
- getSize(): Promise<number>;
12
10
  }
13
11
  //# sourceMappingURL=address_data_provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"address_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/address_data_provider/address_data_provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,qBAAa,mBAAoB,YAAW,YAAY;;gBAK1C,KAAK,EAAE,iBAAiB;IAOpC,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;IAsCtE,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAIzE,oBAAoB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAMlD,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;CAGjC"}
1
+ {"version":3,"file":"address_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/address_data_provider/address_data_provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,mBAAmB;;gBAKlB,KAAK,EAAE,iBAAiB;IAOpC,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;IAsCtE,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAIzE,oBAAoB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;CAKzD"}
@@ -44,7 +44,4 @@ export class AddressDataProvider {
44
44
  async getCompleteAddresses() {
45
45
  return await Promise.all((await toArray(this.#completeAddresses.valuesAsync())).map((v)=>CompleteAddress.fromBuffer(v)));
46
46
  }
47
- async getSize() {
48
- return await this.#completeAddresses.lengthAsync() * CompleteAddress.SIZE_IN_BYTES;
49
- }
50
47
  }
@@ -1,16 +1,25 @@
1
1
  import { Fr } from '@aztec/foundation/fields';
2
- import { type LogFn } from '@aztec/foundation/log';
2
+ import { type Logger } from '@aztec/foundation/log';
3
3
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
4
4
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
- import type { DataProvider } from '../data_provider.js';
6
- export declare class CapsuleDataProvider implements DataProvider {
5
+ export declare class CapsuleDataProvider {
7
6
  #private;
8
- debug: LogFn;
7
+ logger: Logger;
9
8
  constructor(store: AztecAsyncKVStore);
10
9
  storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void>;
11
10
  loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null>;
12
11
  deleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void>;
13
12
  copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number): Promise<void>;
14
- getSize(): Promise<number>;
13
+ /**
14
+ * Appends multiple capsules to a capsule array stored at the base slot.
15
+ * The array length is stored at the base slot, and elements are stored in consecutive slots after it.
16
+ * All operations are performed in a single transaction.
17
+ * @param contractAddress - The contract address that owns the capsule array
18
+ * @param baseSlot - The slot where the array length is stored
19
+ * @param content - Array of capsule data to append
20
+ */
21
+ appendToCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][]): Promise<void>;
22
+ readCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr): Promise<Fr[][]>;
23
+ setCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][]): Promise<void>;
15
24
  }
16
25
  //# sourceMappingURL=capsule_data_provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"capsule_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/capsule_data_provider/capsule_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,KAAK,KAAK,EAAyB,MAAM,uBAAuB,CAAC;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,qBAAa,mBAAoB,YAAW,YAAY;;IAMtD,KAAK,EAAE,KAAK,CAAC;gBAED,KAAK,EAAE,iBAAiB;IAQ9B,YAAY,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAInF,WAAW,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC;IAa1E,aAAa,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrE,WAAW,CAAC,eAA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,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC;IAwB9E,eAAe,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE;CAoB7E"}
@@ -1,15 +1,14 @@
1
1
  import { Fr } from '@aztec/foundation/fields';
2
- import { toArray } from '@aztec/foundation/iterable';
3
- import { createDebugOnlyLogger } from '@aztec/foundation/log';
2
+ import { createLogger } from '@aztec/foundation/log';
4
3
  export class CapsuleDataProvider {
5
4
  #store;
6
5
  // Arbitrary data stored by contracts. Key is computed as `${contractAddress}:${key}`
7
6
  #capsules;
8
- debug;
7
+ logger;
9
8
  constructor(store){
10
9
  this.#store = store;
11
10
  this.#capsules = this.#store.openMap('capsules');
12
- this.debug = createDebugOnlyLogger('pxe:capsule-data-provider');
11
+ this.logger = createLogger('pxe:capsule-data-provider');
13
12
  }
14
13
  async storeCapsule(contractAddress, slot, capsule) {
15
14
  await this.#capsules.set(dbSlotToKey(contractAddress, slot), Buffer.concat(capsule.map((value)=>value.toBuffer())));
@@ -17,7 +16,7 @@ export class CapsuleDataProvider {
17
16
  async loadCapsule(contractAddress, slot) {
18
17
  const dataBuffer = await this.#capsules.getAsync(dbSlotToKey(contractAddress, slot));
19
18
  if (!dataBuffer) {
20
- this.debug(`Data not found for contract ${contractAddress.toString()} and slot ${slot.toString()}`);
19
+ this.logger.trace(`Data not found for contract ${contractAddress.toString()} and slot ${slot.toString()}`);
21
20
  return null;
22
21
  }
23
22
  const capsule = [];
@@ -29,29 +28,91 @@ export class CapsuleDataProvider {
29
28
  async deleteCapsule(contractAddress, slot) {
30
29
  await this.#capsules.delete(dbSlotToKey(contractAddress, slot));
31
30
  }
32
- async copyCapsule(contractAddress, srcSlot, dstSlot, numEntries) {
33
- // In order to support overlapping source and destination regions, we need to check the relative positions of source
34
- // and destination. If destination is ahead of source, then by the time we overwrite source elements using forward
35
- // indexes we'll have already read those. On the contrary, if source is ahead of destination we need to use backward
36
- // indexes to avoid reading elements that've been overwritten.
37
- const indexes = Array.from(Array(numEntries).keys());
38
- if (srcSlot.lt(dstSlot)) {
39
- indexes.reverse();
40
- }
41
- for (const i of indexes){
42
- const currentSrcSlot = dbSlotToKey(contractAddress, srcSlot.add(new Fr(i)));
43
- const currentDstSlot = dbSlotToKey(contractAddress, dstSlot.add(new Fr(i)));
44
- const toCopy = await this.#capsules.getAsync(currentSrcSlot);
45
- if (!toCopy) {
46
- throw new Error(`Attempted to copy empty slot ${currentSrcSlot} for contract ${contractAddress.toString()}`);
31
+ copyCapsule(contractAddress, srcSlot, dstSlot, numEntries) {
32
+ return this.#store.transactionAsync(async ()=>{
33
+ // In order to support overlapping source and destination regions, we need to check the relative positions of source
34
+ // and destination. If destination is ahead of source, then by the time we overwrite source elements using forward
35
+ // indexes we'll have already read those. On the contrary, if source is ahead of destination we need to use backward
36
+ // indexes to avoid reading elements that've been overwritten.
37
+ const indexes = Array.from(Array(numEntries).keys());
38
+ if (srcSlot.lt(dstSlot)) {
39
+ indexes.reverse();
47
40
  }
48
- await this.#capsules.set(currentDstSlot, toCopy);
49
- }
41
+ for (const i of indexes){
42
+ const currentSrcSlot = dbSlotToKey(contractAddress, srcSlot.add(new Fr(i)));
43
+ const currentDstSlot = dbSlotToKey(contractAddress, dstSlot.add(new Fr(i)));
44
+ const toCopy = await this.#capsules.getAsync(currentSrcSlot);
45
+ if (!toCopy) {
46
+ throw new Error(`Attempted to copy empty slot ${currentSrcSlot} for contract ${contractAddress.toString()}`);
47
+ }
48
+ await this.#capsules.set(currentDstSlot, toCopy);
49
+ }
50
+ });
51
+ }
52
+ /**
53
+ * Appends multiple capsules to a capsule array stored at the base slot.
54
+ * The array length is stored at the base slot, and elements are stored in consecutive slots after it.
55
+ * All operations are performed in a single transaction.
56
+ * @param contractAddress - The contract address that owns the capsule array
57
+ * @param baseSlot - The slot where the array length is stored
58
+ * @param content - Array of capsule data to append
59
+ */ appendToCapsuleArray(contractAddress, baseSlot, content) {
60
+ return this.#store.transactionAsync(async ()=>{
61
+ // Load current length, defaulting to 0 if not found
62
+ const lengthData = await this.loadCapsule(contractAddress, baseSlot);
63
+ const currentLength = lengthData ? lengthData[0].toNumber() : 0;
64
+ // Store each capsule at consecutive slots after baseSlot + 1 + currentLength
65
+ for(let i = 0; i < content.length; i++){
66
+ const nextSlot = arraySlot(baseSlot, currentLength + i);
67
+ await this.storeCapsule(contractAddress, nextSlot, content[i]);
68
+ }
69
+ // Update length to include all new capsules
70
+ const newLength = currentLength + content.length;
71
+ await this.storeCapsule(contractAddress, baseSlot, [
72
+ new Fr(newLength)
73
+ ]);
74
+ });
50
75
  }
51
- async getSize() {
52
- return (await toArray(this.#capsules.valuesAsync())).reduce((sum, value)=>sum + value.length * Fr.SIZE_IN_BYTES, 0);
76
+ readCapsuleArray(contractAddress, baseSlot) {
77
+ return this.#store.transactionAsync(async ()=>{
78
+ // Load length, defaulting to 0 if not found
79
+ const maybeLength = await this.loadCapsule(contractAddress, baseSlot);
80
+ const length = maybeLength ? maybeLength[0].toBigInt() : 0n;
81
+ const values = [];
82
+ // Read each capsule at consecutive slots after baseSlot
83
+ for(let i = 0; i < length; i++){
84
+ const currentValue = await this.loadCapsule(contractAddress, arraySlot(baseSlot, i));
85
+ if (currentValue == undefined) {
86
+ throw new Error(`Expected non-empty value at capsule array in base slot ${baseSlot} at index ${i} for contract ${contractAddress}`);
87
+ }
88
+ values.push(currentValue);
89
+ }
90
+ return values;
91
+ });
92
+ }
93
+ setCapsuleArray(contractAddress, baseSlot, content) {
94
+ return this.#store.transactionAsync(async ()=>{
95
+ // Load current length, defaulting to 0 if not found
96
+ const maybeLength = await this.loadCapsule(contractAddress, baseSlot);
97
+ const originalLength = maybeLength ? maybeLength[0].toNumber() : 0;
98
+ // Set the new length
99
+ await this.storeCapsule(contractAddress, baseSlot, [
100
+ new Fr(content.length)
101
+ ]);
102
+ // Store the new content, possibly overwriting existing values
103
+ for(let i = 0; i < content.length; i++){
104
+ await this.storeCapsule(contractAddress, arraySlot(baseSlot, i), content[i]);
105
+ }
106
+ // Clear any stragglers
107
+ for(let i = content.length; i < originalLength; i++){
108
+ await this.deleteCapsule(contractAddress, arraySlot(baseSlot, i));
109
+ }
110
+ });
53
111
  }
54
112
  }
55
113
  function dbSlotToKey(contractAddress, slot) {
56
114
  return `${contractAddress.toString()}:${slot.toString()}`;
57
115
  }
116
+ function arraySlot(baseSlot, index) {
117
+ return baseSlot.add(new Fr(1)).add(new Fr(index));
118
+ }
@@ -1,12 +1,10 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
1
+ import type { FUNCTION_TREE_HEIGHT } from '@aztec/constants';
3
2
  import type { Fr } from '@aztec/foundation/fields';
4
3
  import type { MembershipWitness } from '@aztec/foundation/trees';
5
4
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
6
- import { type ContractArtifact, type FunctionArtifact, type FunctionDebugMetadata, FunctionSelector } from '@aztec/stdlib/abi';
5
+ import { type ContractArtifact, type FunctionAbi, type FunctionArtifact, type FunctionArtifactWithContractName, type FunctionDebugMetadata, FunctionSelector } from '@aztec/stdlib/abi';
7
6
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
8
7
  import { type ContractClass, type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
9
- import type { DataProvider } from '../data_provider.js';
10
8
  /**
11
9
  * ContractDataProvider serves as a data manager and retriever for Aztec.nr contracts.
12
10
  * It provides methods to obtain contract addresses, function ABI, bytecode, and membership witnesses
@@ -14,41 +12,17 @@ import type { DataProvider } from '../data_provider.js';
14
12
  * to efficiently serve the requested data. It interacts with the ContractDatabase and AztecNode to fetch
15
13
  * the required information and facilitate cryptographic proof generation.
16
14
  */
17
- export declare class ContractDataProvider implements DataProvider {
15
+ export declare class ContractDataProvider {
18
16
  #private;
19
- /** Map from contract class id to private function tree. */
20
- private contractClassesCache;
21
17
  constructor(store: AztecAsyncKVStore);
22
18
  addContractArtifact(id: Fr, contract: ContractArtifact): Promise<void>;
23
19
  addContractInstance(contract: ContractInstanceWithAddress): Promise<void>;
24
- /**
25
- * Retrieve or create a ContractTree instance based on the provided class id.
26
- * If an existing tree with the same class id is found in the cache, it will be returned.
27
- * Otherwise, a new ContractTree instance will be created using the contract data from the database
28
- * and added to the cache before returning.
29
- *
30
- * @param classId - The class id of the contract for which the ContractTree is required.
31
- * @returns A ContractTree instance associated with the specified contract address.
32
- * @throws An Error if the contract is not found in the ContractDatabase.
33
- */
34
- private getTreeForClassId;
35
- /**
36
- * Retrieve or create a ContractTree instance based on the provided AztecAddress.
37
- * If an existing tree with the same contract address is found in the cache, it will be returned.
38
- * Otherwise, a new ContractTree instance will be created using the contract data from the database
39
- * and added to the cache before returning.
40
- *
41
- * @param contractAddress - The AztecAddress of the contract for which the ContractTree is required.
42
- * @returns A ContractTree instance associated with the specified contract address.
43
- * @throws An Error if the contract is not found in the ContractDatabase.
44
- */
45
- private getTreeForAddress;
46
20
  getContractsAddresses(): Promise<AztecAddress[]>;
47
21
  /** Returns a contract instance for a given address. Throws if not found. */
48
- getContractInstance(contractAddress: AztecAddress): Promise<ContractInstanceWithAddress>;
49
- getContractArtifact(contractClassId: Fr): Promise<ContractArtifact>;
22
+ getContractInstance(contractAddress: AztecAddress): Promise<ContractInstanceWithAddress | undefined>;
23
+ getContractArtifact(contractClassId: Fr): Promise<ContractArtifact | undefined>;
50
24
  /** Returns a contract class for a given class id. Throws if not found. */
51
- getContractClass(contractClassId: Fr): Promise<ContractClass>;
25
+ getContractClass(contractClassId: Fr): Promise<ContractClass | undefined>;
52
26
  getContract(address: AztecAddress): Promise<(ContractInstanceWithAddress & ContractArtifact) | undefined>;
53
27
  /**
54
28
  * Retrieves the artifact of a specified function within a given contract.
@@ -59,7 +33,8 @@ export declare class ContractDataProvider implements DataProvider {
59
33
  * @param selector - The function selector.
60
34
  * @returns The corresponding function's artifact as an object.
61
35
  */
62
- getFunctionArtifact(contractAddress: AztecAddress, selector: FunctionSelector): Promise<FunctionArtifact>;
36
+ getFunctionArtifact(contractAddress: AztecAddress, selector: FunctionSelector): Promise<FunctionArtifactWithContractName | undefined>;
37
+ getPublicFunctionArtifact(contractAddress: AztecAddress): Promise<FunctionArtifactWithContractName | undefined>;
63
38
  /**
64
39
  * Retrieves the artifact of a specified function within a given contract.
65
40
  * The function is identified by its name, which is unique within a contract.
@@ -70,6 +45,7 @@ export declare class ContractDataProvider implements DataProvider {
70
45
  * @returns The corresponding function's artifact as an object
71
46
  */
72
47
  getFunctionArtifactByName(contractAddress: AztecAddress, functionName: string): Promise<FunctionArtifact | undefined>;
48
+ getFunctionAbi(contractAddress: AztecAddress, selector: FunctionSelector): Promise<FunctionAbi | undefined>;
73
49
  /**
74
50
  * Retrieves the debug metadata of a specified function within a given contract.
75
51
  * The function is identified by its selector, which is a unique code generated from the function's signature.
@@ -81,17 +57,7 @@ export declare class ContractDataProvider implements DataProvider {
81
57
  * @returns The corresponding function's artifact as an object.
82
58
  */
83
59
  getFunctionDebugMetadata(contractAddress: AztecAddress, selector: FunctionSelector): Promise<FunctionDebugMetadata | undefined>;
84
- /**
85
- * Retrieve the bytecode of a specific function in a contract at the given address.
86
- * The returned bytecode is required for executing and verifying the function's behavior
87
- * in the Aztec network. Throws an error if the contract or function cannot be found.
88
- *
89
- * @param contractAddress - The contract's address.
90
- * @param selector - The function selector.
91
- * @returns A Promise that resolves to a Buffer containing the bytecode of the specified function.
92
- * @throws Error if the contract address is unknown or not found.
93
- */
94
- getBytecode(contractAddress: AztecAddress, selector: FunctionSelector): Promise<Buffer>;
60
+ getPublicFunctionDebugMetadata(contractAddress: AztecAddress): Promise<FunctionDebugMetadata | undefined>;
95
61
  /**
96
62
  * Retrieve the function membership witness for the given contract class and function selector.
97
63
  * The function membership witness represents a proof that the function belongs to the specified contract.
@@ -101,9 +67,8 @@ export declare class ContractDataProvider implements DataProvider {
101
67
  * @param selector - The function selector.
102
68
  * @returns A promise that resolves with the MembershipWitness instance for the specified contract's function.
103
69
  */
104
- getFunctionMembershipWitness(contractClassId: Fr, selector: FunctionSelector): Promise<MembershipWitness<5>>;
105
- getDebugContractName(contractAddress: AztecAddress): Promise<string>;
70
+ getFunctionMembershipWitness(contractClassId: Fr, selector: FunctionSelector): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT> | undefined>;
71
+ getDebugContractName(contractAddress: AztecAddress): Promise<string | undefined>;
106
72
  getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string>;
107
- getSize(): Promise<number>;
108
73
  }
109
74
  //# sourceMappingURL=contract_data_provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/contract_data_provider/contract_data_provider.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AAExE,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,gBAAgB,EAKjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,2BAA2B,EAEjC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD;;;;;;GAMG;AACH,qBAAa,oBAAqB,YAAW,YAAY;;IACvD,2DAA2D;IAC3D,OAAO,CAAC,oBAAoB,CAAgD;gBAKhE,KAAK,EAAE,iBAAiB;IAOvB,mBAAmB,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB7E,mBAAmB,CAAC,QAAQ,EAAE,2BAA2B,GAAG,OAAO,CAAC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CAAC,GAAG,SAAS,CAAC;IAYxE;;;;;;;;OAQG;IACU,mBAAmB,CAC9B,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,gCAAgC,GAAG,SAAS,CAAC;IAM3C,yBAAyB,CACpC,eAAe,EAAE,YAAY,GAC5B,OAAO,CAAC,gCAAgC,GAAG,SAAS,CAAC;IAMxD;;;;;;;;OAQG;IACU,yBAAyB,CACpC,eAAe,EAAE,YAAY,EAC7B,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAK3B,cAAc,CACzB,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAKnC;;;;;;;;;OASG;IACU,wBAAwB,CACnC,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IAMhC,8BAA8B,CACzC,eAAe,EAAE,YAAY,GAC5B,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IAM7C;;;;;;;;OAQG;IACU,4BAA4B,CACvC,eAAe,EAAE,EAAE,EACnB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,iBAAiB,CAAC,OAAO,oBAAoB,CAAC,GAAG,SAAS,CAAC;IAKzD,oBAAoB,CAAC,eAAe,EAAE,YAAY;IAKlD,oBAAoB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB;CAiC5F"}
@@ -1,8 +1,7 @@
1
1
  import { toArray } from '@aztec/foundation/iterable';
2
- import { ContractClassNotFoundError, ContractNotFoundError } from '@aztec/simulator/client';
3
2
  import { FunctionSelector, FunctionType, contractArtifactFromBuffer, contractArtifactToBuffer, getFunctionDebugMetadata } from '@aztec/stdlib/abi';
4
3
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
- import { SerializableContractInstance } from '@aztec/stdlib/contract';
4
+ import { SerializableContractInstance, getContractClassFromArtifact } from '@aztec/stdlib/contract';
6
5
  import { PrivateFunctionsTree } from './private_functions_tree.js';
7
6
  /**
8
7
  * ContractDataProvider serves as a data manager and retriever for Aztec.nr contracts.
@@ -11,7 +10,9 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
11
10
  * to efficiently serve the requested data. It interacts with the ContractDatabase and AztecNode to fetch
12
11
  * the required information and facilitate cryptographic proof generation.
13
12
  */ export class ContractDataProvider {
14
- /** Map from contract class id to private function tree. */ contractClassesCache = new Map();
13
+ /** Map from contract class id to private function tree. */ // TODO: Update it to be LRU cache so that it doesn't keep all the data all the time.
14
+ #privateFunctionTrees = new Map();
15
+ /** Map from contract address to contract class id */ #contractClassIdMap = new Map();
15
16
  #contractArtifacts;
16
17
  #contractInstances;
17
18
  constructor(store){
@@ -28,17 +29,19 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
28
29
  await this.#contractArtifacts.set(id.toString(), contractArtifactToBuffer(contract));
29
30
  }
30
31
  async addContractInstance(contract) {
32
+ this.#contractClassIdMap.set(contract.address.toString(), contract.currentContractClassId);
31
33
  await this.#contractInstances.set(contract.address.toString(), new SerializableContractInstance(contract).toBuffer());
32
34
  }
33
35
  // Private getters
34
- async #getContractInstance(address) {
35
- const contract = await this.#contractInstances.getAsync(address.toString());
36
- return contract && SerializableContractInstance.fromBuffer(contract).withAddress(address);
37
- }
38
- async #getContractArtifact(id) {
39
- const contract = await this.#contractArtifacts.getAsync(id.toString());
40
- // TODO(@spalladino): AztecAsyncMap lies and returns Uint8Arrays instead of Buffers, hence the extra Buffer.from.
41
- return contract && contractArtifactFromBuffer(Buffer.from(contract));
36
+ async #getContractClassId(contractAddress) {
37
+ if (!this.#contractClassIdMap.has(contractAddress.toString())) {
38
+ const instance = await this.getContractInstance(contractAddress);
39
+ if (!instance) {
40
+ return;
41
+ }
42
+ this.#contractClassIdMap.set(contractAddress.toString(), instance.currentContractClassId);
43
+ }
44
+ return this.#contractClassIdMap.get(contractAddress.toString());
42
45
  }
43
46
  /**
44
47
  * Retrieve or create a ContractTree instance based on the provided class id.
@@ -49,29 +52,20 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
49
52
  * @param classId - The class id of the contract for which the ContractTree is required.
50
53
  * @returns A ContractTree instance associated with the specified contract address.
51
54
  * @throws An Error if the contract is not found in the ContractDatabase.
52
- */ async getTreeForClassId(classId) {
53
- if (!this.contractClassesCache.has(classId.toString())) {
54
- const artifact = await this.#getContractArtifact(classId);
55
+ */ async #getPrivateFunctionTreeForClassId(classId) {
56
+ if (!this.#privateFunctionTrees.has(classId.toString())) {
57
+ const artifact = await this.getContractArtifact(classId);
55
58
  if (!artifact) {
56
- throw new ContractClassNotFoundError(classId.toString());
59
+ return;
57
60
  }
58
61
  const tree = await PrivateFunctionsTree.create(artifact);
59
- this.contractClassesCache.set(classId.toString(), tree);
62
+ this.#privateFunctionTrees.set(classId.toString(), tree);
60
63
  }
61
- return this.contractClassesCache.get(classId.toString());
64
+ return this.#privateFunctionTrees.get(classId.toString());
62
65
  }
63
- /**
64
- * Retrieve or create a ContractTree instance based on the provided AztecAddress.
65
- * If an existing tree with the same contract address is found in the cache, it will be returned.
66
- * Otherwise, a new ContractTree instance will be created using the contract data from the database
67
- * and added to the cache before returning.
68
- *
69
- * @param contractAddress - The AztecAddress of the contract for which the ContractTree is required.
70
- * @returns A ContractTree instance associated with the specified contract address.
71
- * @throws An Error if the contract is not found in the ContractDatabase.
72
- */ async getTreeForAddress(contractAddress) {
73
- const instance = await this.getContractInstance(contractAddress);
74
- return this.getTreeForClassId(instance.currentContractClassId);
66
+ async #getContractArtifactByAddress(contractAddress) {
67
+ const contractClassId = await this.#getContractClassId(contractAddress);
68
+ return contractClassId && this.getContractArtifact(contractClassId);
75
69
  }
76
70
  // Public getters
77
71
  async getContractsAddresses() {
@@ -79,25 +73,26 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
79
73
  return keys.map(AztecAddress.fromString);
80
74
  }
81
75
  /** Returns a contract instance for a given address. Throws if not found. */ async getContractInstance(contractAddress) {
82
- const instance = await this.#getContractInstance(contractAddress);
83
- if (!instance) {
84
- throw new ContractNotFoundError(contractAddress.toString());
85
- }
86
- return instance;
76
+ const contract = await this.#contractInstances.getAsync(contractAddress.toString());
77
+ return contract && SerializableContractInstance.fromBuffer(contract).withAddress(contractAddress);
87
78
  }
88
79
  async getContractArtifact(contractClassId) {
89
- const tree = await this.getTreeForClassId(contractClassId);
90
- return tree.getArtifact();
80
+ const contract = await this.#contractArtifacts.getAsync(contractClassId.toString());
81
+ // TODO(@spalladino): AztecAsyncMap lies and returns Uint8Arrays instead of Buffers, hence the extra Buffer.from.
82
+ return contract && contractArtifactFromBuffer(Buffer.from(contract));
91
83
  }
92
84
  /** Returns a contract class for a given class id. Throws if not found. */ async getContractClass(contractClassId) {
93
- const tree = await this.getTreeForClassId(contractClassId);
94
- return tree.getContractClass();
85
+ const artifact = await this.getContractArtifact(contractClassId);
86
+ return artifact && getContractClassFromArtifact(artifact);
95
87
  }
96
88
  async getContract(address) {
97
89
  const instance = await this.getContractInstance(address);
98
- const artifact = instance && await this.getContractArtifact(instance?.currentContractClassId);
99
- if (!instance || !artifact) {
100
- return undefined;
90
+ if (!instance) {
91
+ return;
92
+ }
93
+ const artifact = await this.getContractArtifact(instance.currentContractClassId);
94
+ if (!artifact) {
95
+ return;
101
96
  }
102
97
  return {
103
98
  ...instance,
@@ -113,8 +108,20 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
113
108
  * @param selector - The function selector.
114
109
  * @returns The corresponding function's artifact as an object.
115
110
  */ async getFunctionArtifact(contractAddress, selector) {
116
- const tree = await this.getTreeForAddress(contractAddress);
117
- return tree.getFunctionArtifact(selector);
111
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
112
+ const fnArtifact = artifact && await this.#findFunctionArtifactBySelector(artifact, selector);
113
+ return fnArtifact && {
114
+ ...fnArtifact,
115
+ contractName: artifact.name
116
+ };
117
+ }
118
+ async getPublicFunctionArtifact(contractAddress) {
119
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
120
+ const fnArtifact = artifact && artifact.functions.find((fn)=>fn.functionType === FunctionType.PUBLIC);
121
+ return fnArtifact && {
122
+ ...fnArtifact,
123
+ contractName: artifact.name
124
+ };
118
125
  }
119
126
  /**
120
127
  * Retrieves the artifact of a specified function within a given contract.
@@ -125,8 +132,12 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
125
132
  * @param functionName - The name of the function.
126
133
  * @returns The corresponding function's artifact as an object
127
134
  */ async getFunctionArtifactByName(contractAddress, functionName) {
128
- const tree = await this.getTreeForAddress(contractAddress);
129
- return tree.getArtifact().functions.find((f)=>f.name === functionName);
135
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
136
+ return artifact?.functions.find((fn)=>fn.name === functionName);
137
+ }
138
+ async getFunctionAbi(contractAddress, selector) {
139
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
140
+ return artifact && await this.#findFunctionAbiBySelector(artifact, selector);
130
141
  }
131
142
  /**
132
143
  * Retrieves the debug metadata of a specified function within a given contract.
@@ -138,22 +149,14 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
138
149
  * @param selector - The function selector.
139
150
  * @returns The corresponding function's artifact as an object.
140
151
  */ async getFunctionDebugMetadata(contractAddress, selector) {
141
- const tree = await this.getTreeForAddress(contractAddress);
142
- const artifact = await tree.getFunctionArtifact(selector);
143
- return getFunctionDebugMetadata(tree.getArtifact(), artifact);
152
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
153
+ const fnArtifact = artifact && await this.#findFunctionArtifactBySelector(artifact, selector);
154
+ return fnArtifact && getFunctionDebugMetadata(artifact, fnArtifact);
144
155
  }
145
- /**
146
- * Retrieve the bytecode of a specific function in a contract at the given address.
147
- * The returned bytecode is required for executing and verifying the function's behavior
148
- * in the Aztec network. Throws an error if the contract or function cannot be found.
149
- *
150
- * @param contractAddress - The contract's address.
151
- * @param selector - The function selector.
152
- * @returns A Promise that resolves to a Buffer containing the bytecode of the specified function.
153
- * @throws Error if the contract address is unknown or not found.
154
- */ async getBytecode(contractAddress, selector) {
155
- const tree = await this.getTreeForAddress(contractAddress);
156
- return tree.getBytecode(selector);
156
+ async getPublicFunctionDebugMetadata(contractAddress) {
157
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
158
+ const fnArtifact = artifact && artifact.functions.find((fn)=>fn.functionType === FunctionType.PUBLIC);
159
+ return fnArtifact && getFunctionDebugMetadata(artifact, fnArtifact);
157
160
  }
158
161
  /**
159
162
  * Retrieve the function membership witness for the given contract class and function selector.
@@ -164,20 +167,39 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
164
167
  * @param selector - The function selector.
165
168
  * @returns A promise that resolves with the MembershipWitness instance for the specified contract's function.
166
169
  */ async getFunctionMembershipWitness(contractClassId, selector) {
167
- const tree = await this.getTreeForClassId(contractClassId);
168
- return tree.getFunctionMembershipWitness(selector);
170
+ const tree = await this.#getPrivateFunctionTreeForClassId(contractClassId);
171
+ return tree?.getFunctionMembershipWitness(selector);
169
172
  }
170
173
  async getDebugContractName(contractAddress) {
171
- const tree = await this.getTreeForAddress(contractAddress);
172
- return tree.getArtifact().name;
174
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
175
+ return artifact?.name;
173
176
  }
174
177
  async getDebugFunctionName(contractAddress, selector) {
175
- const tree = await this.getTreeForAddress(contractAddress);
176
- const { name: contractName } = tree.getArtifact();
177
- const { name: functionName } = await tree.getFunctionArtifact(selector);
178
- return `${contractName}:${functionName}`;
178
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
179
+ const fnArtifact = artifact && await this.#findFunctionAbiBySelector(artifact, selector);
180
+ return `${artifact?.name ?? contractAddress}:${fnArtifact?.name ?? selector}`;
181
+ }
182
+ async #findFunctionArtifactBySelector(artifact, selector) {
183
+ const functions = artifact.functions;
184
+ for(let i = 0; i < functions.length; i++){
185
+ const fn = functions[i];
186
+ const fnSelector = await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters);
187
+ if (fnSelector.equals(selector)) {
188
+ return fn;
189
+ }
190
+ }
179
191
  }
180
- async getSize() {
181
- return (await toArray(this.#contractInstances.valuesAsync())).concat(await toArray(this.#contractArtifacts.valuesAsync())).reduce((sum, value)=>sum + value.length, 0);
192
+ async #findFunctionAbiBySelector(artifact, selector) {
193
+ const functions = [
194
+ ...artifact.functions,
195
+ ...artifact.nonDispatchPublicFunctions ?? []
196
+ ];
197
+ for(let i = 0; i < functions.length; i++){
198
+ const fn = functions[i];
199
+ const fnSelector = await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters);
200
+ if (fnSelector.equals(selector)) {
201
+ return fn;
202
+ }
203
+ }
182
204
  }
183
205
  }
@@ -1,3 +1,2 @@
1
1
  export { ContractDataProvider } from './contract_data_provider.js';
2
- export { PrivateFunctionsTree } from './private_functions_tree.js';
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/contract_data_provider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/contract_data_provider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC"}
@@ -1,2 +1 @@
1
1
  export { ContractDataProvider } from './contract_data_provider.js';
2
- export { PrivateFunctionsTree } from './private_functions_tree.js';