@aztec/pxe 0.0.1-fake-ceab37513c → 0.0.6-commit.a2d1860fe9

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 (442) hide show
  1. package/README.md +5 -5
  2. package/dest/access_scopes.d.ts +9 -0
  3. package/dest/access_scopes.d.ts.map +1 -0
  4. package/dest/access_scopes.js +6 -0
  5. package/dest/bin/check_oracle_version.d.ts +1 -1
  6. package/dest/bin/check_oracle_version.js +110 -10
  7. package/dest/block_synchronizer/block_synchronizer.d.ts +45 -0
  8. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
  9. package/dest/block_synchronizer/block_synchronizer.js +153 -0
  10. package/dest/block_synchronizer/index.d.ts +2 -0
  11. package/dest/block_synchronizer/index.d.ts.map +1 -0
  12. package/dest/block_synchronizer/index.js +1 -0
  13. package/dest/config/index.d.ts +11 -17
  14. package/dest/config/index.d.ts.map +1 -1
  15. package/dest/config/index.js +27 -16
  16. package/dest/config/package_info.d.ts +1 -1
  17. package/dest/config/package_info.js +1 -1
  18. package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
  19. package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
  20. package/dest/contract_function_simulator/benchmarked_node.js +77 -0
  21. package/dest/contract_function_simulator/contract_function_simulator.d.ts +79 -27
  22. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  23. package/dest/contract_function_simulator/contract_function_simulator.js +287 -87
  24. package/dest/contract_function_simulator/execution_note_cache.d.ts +26 -15
  25. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  26. package/dest/contract_function_simulator/execution_note_cache.js +65 -37
  27. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
  28. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
  29. package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
  30. package/dest/contract_function_simulator/hashed_values_cache.d.ts +2 -2
  31. package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -1
  32. package/dest/contract_function_simulator/index.d.ts +5 -3
  33. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  34. package/dest/contract_function_simulator/index.js +3 -2
  35. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +5 -4
  36. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  37. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +7 -4
  38. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +5 -4
  39. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
  40. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +7 -6
  41. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +3 -3
  42. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  43. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +8 -4
  44. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +7 -4
  45. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  46. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +13 -4
  47. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +16 -0
  48. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
  49. package/dest/contract_function_simulator/noir-structs/utility_context.js +22 -0
  50. package/dest/contract_function_simulator/oracle/index.d.ts +2 -2
  51. package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -1
  52. package/dest/contract_function_simulator/oracle/index.js +1 -1
  53. package/dest/contract_function_simulator/oracle/interfaces.d.ts +107 -0
  54. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
  55. package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
  56. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +2 -2
  57. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  58. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -1
  59. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +14 -8
  60. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
  61. package/dest/contract_function_simulator/oracle/note_packing_utils.js +16 -11
  62. package/dest/contract_function_simulator/oracle/oracle.d.ts +26 -22
  63. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  64. package/dest/contract_function_simulator/oracle/oracle.js +156 -113
  65. package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -27
  66. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  67. package/dest/contract_function_simulator/oracle/private_execution.js +3 -48
  68. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +72 -52
  69. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  70. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +173 -68
  71. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +116 -53
  72. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  73. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +217 -94
  74. package/dest/contract_function_simulator/pick_notes.d.ts +2 -2
  75. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
  76. package/dest/contract_function_simulator/pick_notes.js +1 -1
  77. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +4 -4
  78. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
  79. package/dest/contract_function_simulator/proxied_contract_data_source.js +23 -5
  80. package/dest/contract_logging.d.ts +22 -0
  81. package/dest/contract_logging.d.ts.map +1 -0
  82. package/dest/contract_logging.js +23 -0
  83. package/dest/contract_sync/contract_sync_service.d.ts +43 -0
  84. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
  85. package/dest/contract_sync/contract_sync_service.js +97 -0
  86. package/dest/contract_sync/helpers.d.ts +29 -0
  87. package/dest/contract_sync/helpers.d.ts.map +1 -0
  88. package/dest/contract_sync/helpers.js +55 -0
  89. package/dest/debug/pxe_debug_utils.d.ts +45 -0
  90. package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
  91. package/dest/debug/pxe_debug_utils.js +48 -0
  92. package/dest/entrypoints/client/bundle/index.d.ts +7 -3
  93. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  94. package/dest/entrypoints/client/bundle/index.js +5 -2
  95. package/dest/entrypoints/client/bundle/utils.d.ts +9 -9
  96. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  97. package/dest/entrypoints/client/bundle/utils.js +40 -17
  98. package/dest/entrypoints/client/lazy/index.d.ts +7 -3
  99. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  100. package/dest/entrypoints/client/lazy/index.js +5 -2
  101. package/dest/entrypoints/client/lazy/utils.d.ts +9 -9
  102. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  103. package/dest/entrypoints/client/lazy/utils.js +40 -17
  104. package/dest/entrypoints/pxe_creation_options.d.ts +7 -3
  105. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  106. package/dest/entrypoints/server/index.d.ts +9 -3
  107. package/dest/entrypoints/server/index.d.ts.map +1 -1
  108. package/dest/entrypoints/server/index.js +7 -2
  109. package/dest/entrypoints/server/utils.d.ts +5 -24
  110. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  111. package/dest/entrypoints/server/utils.js +42 -51
  112. package/dest/error_enriching.d.ts +11 -0
  113. package/dest/error_enriching.d.ts.map +1 -0
  114. package/dest/{pxe_service/error_enriching.js → error_enriching.js} +9 -6
  115. package/dest/events/event_service.d.ts +15 -0
  116. package/dest/events/event_service.d.ts.map +1 -0
  117. package/dest/events/event_service.js +44 -0
  118. package/dest/events/index.d.ts +2 -0
  119. package/dest/events/index.d.ts.map +1 -0
  120. package/dest/events/index.js +1 -0
  121. package/dest/events/private_event_filter_validator.d.ts +9 -0
  122. package/dest/events/private_event_filter_validator.d.ts.map +1 -0
  123. package/dest/events/private_event_filter_validator.js +38 -0
  124. package/dest/job_coordinator/job_coordinator.d.ts +75 -0
  125. package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
  126. package/dest/job_coordinator/job_coordinator.js +94 -0
  127. package/dest/logs/log_service.d.ts +29 -0
  128. package/dest/logs/log_service.d.ts.map +1 -0
  129. package/dest/logs/log_service.js +118 -0
  130. package/dest/notes/index.d.ts +2 -0
  131. package/dest/notes/index.d.ts.map +1 -0
  132. package/dest/notes/index.js +1 -0
  133. package/dest/notes/note_service.d.ts +49 -0
  134. package/dest/notes/note_service.d.ts.map +1 -0
  135. package/dest/notes/note_service.js +148 -0
  136. package/dest/notes_filter.d.ts +25 -0
  137. package/dest/notes_filter.d.ts.map +1 -0
  138. package/dest/notes_filter.js +4 -0
  139. package/dest/oracle_version.d.ts +3 -3
  140. package/dest/oracle_version.d.ts.map +1 -1
  141. package/dest/oracle_version.js +4 -3
  142. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
  143. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
  144. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.js +41 -0
  145. package/dest/private_kernel/hints/index.d.ts +3 -3
  146. package/dest/private_kernel/hints/index.d.ts.map +1 -1
  147. package/dest/private_kernel/hints/index.js +2 -2
  148. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +28 -0
  149. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
  150. package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +22 -16
  151. package/dest/private_kernel/index.d.ts +1 -1
  152. package/dest/private_kernel/private_kernel_execution_prover.d.ts +11 -3
  153. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  154. package/dest/private_kernel/private_kernel_execution_prover.js +48 -43
  155. package/dest/private_kernel/private_kernel_oracle.d.ts +26 -25
  156. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  157. package/dest/private_kernel/private_kernel_oracle.js +94 -2
  158. package/dest/pxe.d.ts +250 -0
  159. package/dest/pxe.d.ts.map +1 -0
  160. package/dest/pxe.js +774 -0
  161. package/dest/storage/address_store/address_store.d.ts +11 -0
  162. package/dest/storage/address_store/address_store.d.ts.map +1 -0
  163. package/dest/storage/{address_data_provider/address_data_provider.js → address_store/address_store.js} +13 -15
  164. package/dest/storage/address_store/index.d.ts +2 -0
  165. package/dest/storage/address_store/index.d.ts.map +1 -0
  166. package/dest/storage/address_store/index.js +1 -0
  167. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +17 -0
  168. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
  169. package/dest/storage/{sync_data_provider/sync_data_provider.js → anchor_block_store/anchor_block_store.js} +10 -13
  170. package/dest/storage/anchor_block_store/index.d.ts +2 -0
  171. package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
  172. package/dest/storage/anchor_block_store/index.js +1 -0
  173. package/dest/storage/capsule_store/capsule_store.d.ts +72 -0
  174. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
  175. package/dest/storage/capsule_store/capsule_store.js +253 -0
  176. package/dest/storage/capsule_store/index.d.ts +2 -0
  177. package/dest/storage/capsule_store/index.d.ts.map +1 -0
  178. package/dest/storage/capsule_store/index.js +1 -0
  179. package/dest/storage/contract_store/contract_store.d.ts +93 -0
  180. package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
  181. package/dest/storage/contract_store/contract_store.js +309 -0
  182. package/dest/storage/contract_store/index.d.ts +2 -0
  183. package/dest/storage/contract_store/index.d.ts.map +1 -0
  184. package/dest/storage/contract_store/index.js +1 -0
  185. package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.d.ts +1 -1
  186. package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
  187. package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.js +1 -1
  188. package/dest/storage/index.d.ts +8 -9
  189. package/dest/storage/index.d.ts.map +1 -1
  190. package/dest/storage/index.js +7 -8
  191. package/dest/storage/metadata.d.ts +2 -2
  192. package/dest/storage/metadata.js +1 -1
  193. package/dest/storage/note_store/index.d.ts +3 -0
  194. package/dest/storage/note_store/index.d.ts.map +1 -0
  195. package/dest/storage/note_store/index.js +2 -0
  196. package/dest/storage/note_store/note_store.d.ts +83 -0
  197. package/dest/storage/note_store/note_store.d.ts.map +1 -0
  198. package/dest/storage/note_store/note_store.js +343 -0
  199. package/dest/storage/note_store/stored_note.d.ts +16 -0
  200. package/dest/storage/note_store/stored_note.d.ts.map +1 -0
  201. package/dest/storage/note_store/stored_note.js +43 -0
  202. package/dest/storage/private_event_store/private_event_store.d.ts +91 -0
  203. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
  204. package/dest/storage/private_event_store/private_event_store.js +273 -0
  205. package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
  206. package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
  207. package/dest/storage/private_event_store/stored_private_event.js +56 -0
  208. package/dest/storage/tagging_store/index.d.ts +4 -0
  209. package/dest/storage/tagging_store/index.d.ts.map +1 -0
  210. package/dest/storage/tagging_store/index.js +3 -0
  211. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +28 -0
  212. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
  213. package/dest/storage/tagging_store/recipient_tagging_store.js +111 -0
  214. package/dest/storage/tagging_store/sender_address_book_store.d.ts +14 -0
  215. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -0
  216. package/dest/storage/tagging_store/sender_address_book_store.js +36 -0
  217. package/dest/storage/tagging_store/sender_tagging_store.d.ts +77 -0
  218. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
  219. package/dest/storage/tagging_store/sender_tagging_store.js +348 -0
  220. package/dest/tagging/constants.d.ts +2 -0
  221. package/dest/tagging/constants.d.ts.map +1 -0
  222. package/dest/tagging/constants.js +10 -0
  223. package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
  224. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
  225. package/dest/tagging/get_all_logs_by_tags.js +60 -0
  226. package/dest/tagging/index.d.ts +17 -0
  227. package/dest/tagging/index.d.ts.map +1 -0
  228. package/dest/tagging/index.js +15 -0
  229. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +15 -0
  230. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -0
  231. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +99 -0
  232. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +12 -0
  233. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -0
  234. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +20 -0
  235. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +15 -0
  236. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -0
  237. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +32 -0
  238. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +21 -0
  239. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -0
  240. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +74 -0
  241. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +11 -0
  242. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -0
  243. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +29 -0
  244. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +21 -0
  245. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
  246. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +60 -0
  247. package/package.json +30 -23
  248. package/src/access_scopes.ts +9 -0
  249. package/src/bin/check_oracle_version.ts +135 -10
  250. package/src/block_synchronizer/block_synchronizer.ts +178 -0
  251. package/src/block_synchronizer/index.ts +1 -0
  252. package/src/config/index.ts +32 -32
  253. package/src/config/package_info.ts +1 -1
  254. package/src/contract_function_simulator/benchmarked_node.ts +103 -0
  255. package/src/contract_function_simulator/contract_function_simulator.ts +505 -140
  256. package/src/contract_function_simulator/execution_note_cache.ts +67 -32
  257. package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
  258. package/src/contract_function_simulator/hashed_values_cache.ts +1 -1
  259. package/src/contract_function_simulator/index.ts +4 -2
  260. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +7 -3
  261. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +6 -5
  262. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +10 -5
  263. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +15 -3
  264. package/src/contract_function_simulator/noir-structs/utility_context.ts +23 -0
  265. package/src/contract_function_simulator/oracle/index.ts +1 -1
  266. package/src/contract_function_simulator/oracle/interfaces.ts +185 -0
  267. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +1 -1
  268. package/src/contract_function_simulator/oracle/note_packing_utils.ts +30 -14
  269. package/src/contract_function_simulator/oracle/oracle.ts +197 -110
  270. package/src/contract_function_simulator/oracle/private_execution.ts +4 -78
  271. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +248 -122
  272. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +372 -138
  273. package/src/contract_function_simulator/pick_notes.ts +1 -1
  274. package/src/contract_function_simulator/proxied_contract_data_source.ts +24 -7
  275. package/src/contract_logging.ts +39 -0
  276. package/src/contract_sync/contract_sync_service.ts +152 -0
  277. package/src/contract_sync/helpers.ts +98 -0
  278. package/src/debug/pxe_debug_utils.ts +93 -0
  279. package/src/entrypoints/client/bundle/index.ts +6 -2
  280. package/src/entrypoints/client/bundle/utils.ts +31 -32
  281. package/src/entrypoints/client/lazy/index.ts +6 -2
  282. package/src/entrypoints/client/lazy/utils.ts +31 -32
  283. package/src/entrypoints/pxe_creation_options.ts +6 -2
  284. package/src/entrypoints/server/index.ts +8 -2
  285. package/src/entrypoints/server/utils.ts +39 -91
  286. package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +11 -15
  287. package/src/events/event_service.ts +71 -0
  288. package/src/events/index.ts +1 -0
  289. package/src/events/private_event_filter_validator.ts +46 -0
  290. package/src/job_coordinator/job_coordinator.ts +150 -0
  291. package/src/logs/log_service.ts +208 -0
  292. package/src/notes/index.ts +1 -0
  293. package/src/notes/note_service.ts +196 -0
  294. package/src/notes_filter.ts +26 -0
  295. package/src/oracle_version.ts +4 -3
  296. package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +16 -16
  297. package/src/private_kernel/hints/index.ts +2 -2
  298. package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +44 -37
  299. package/src/private_kernel/private_kernel_execution_prover.ts +64 -55
  300. package/src/private_kernel/private_kernel_oracle.ts +118 -37
  301. package/src/pxe.ts +1137 -0
  302. package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +15 -21
  303. package/src/storage/address_store/index.ts +1 -0
  304. package/src/storage/{sync_data_provider/sync_data_provider.ts → anchor_block_store/anchor_block_store.ts} +10 -17
  305. package/src/storage/anchor_block_store/index.ts +1 -0
  306. package/src/storage/capsule_store/capsule_store.ts +315 -0
  307. package/src/storage/capsule_store/index.ts +1 -0
  308. package/src/storage/contract_store/contract_store.ts +429 -0
  309. package/src/storage/contract_store/index.ts +1 -0
  310. package/src/storage/{contract_data_provider → contract_store}/private_functions_tree.ts +1 -1
  311. package/src/storage/index.ts +7 -8
  312. package/src/storage/metadata.ts +1 -1
  313. package/src/storage/note_store/index.ts +2 -0
  314. package/src/storage/note_store/note_store.ts +418 -0
  315. package/src/storage/note_store/stored_note.ts +48 -0
  316. package/src/storage/private_event_store/private_event_store.ts +384 -0
  317. package/src/storage/private_event_store/stored_private_event.ts +73 -0
  318. package/src/storage/tagging_store/index.ts +3 -0
  319. package/src/storage/tagging_store/recipient_tagging_store.ts +139 -0
  320. package/src/storage/tagging_store/sender_address_book_store.ts +48 -0
  321. package/src/storage/tagging_store/sender_tagging_store.ts +429 -0
  322. package/src/tagging/constants.ts +10 -0
  323. package/src/tagging/get_all_logs_by_tags.ts +92 -0
  324. package/src/tagging/index.ts +19 -0
  325. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +143 -0
  326. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +34 -0
  327. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +49 -0
  328. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +99 -0
  329. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +36 -0
  330. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +84 -0
  331. package/dest/bin/index.d.ts +0 -3
  332. package/dest/bin/index.d.ts.map +0 -1
  333. package/dest/bin/index.js +0 -48
  334. package/dest/contract_function_simulator/execution_data_provider.d.ts +0 -285
  335. package/dest/contract_function_simulator/execution_data_provider.d.ts.map +0 -1
  336. package/dest/contract_function_simulator/execution_data_provider.js +0 -14
  337. package/dest/contract_function_simulator/oracle/typed_oracle.d.ts +0 -87
  338. package/dest/contract_function_simulator/oracle/typed_oracle.d.ts.map +0 -1
  339. package/dest/contract_function_simulator/oracle/typed_oracle.js +0 -146
  340. package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
  341. package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
  342. package/dest/contract_function_simulator/proxied_node.js +0 -27
  343. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +0 -158
  344. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +0 -1
  345. package/dest/contract_function_simulator/pxe_oracle_interface.js +0 -701
  346. package/dest/contract_function_simulator/tagging_utils.d.ts +0 -17
  347. package/dest/contract_function_simulator/tagging_utils.d.ts.map +0 -1
  348. package/dest/contract_function_simulator/tagging_utils.js +0 -23
  349. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
  350. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
  351. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
  352. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
  353. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +0 -41
  354. package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -45
  355. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
  356. package/dest/private_kernel/private_kernel_oracle_impl.js +0 -86
  357. package/dest/pxe_service/error_enriching.d.ts +0 -11
  358. package/dest/pxe_service/error_enriching.d.ts.map +0 -1
  359. package/dest/pxe_service/index.d.ts +0 -3
  360. package/dest/pxe_service/index.d.ts.map +0 -1
  361. package/dest/pxe_service/index.js +0 -2
  362. package/dest/pxe_service/pxe_service.d.ts +0 -101
  363. package/dest/pxe_service/pxe_service.d.ts.map +0 -1
  364. package/dest/pxe_service/pxe_service.js +0 -791
  365. package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -13
  366. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +0 -1
  367. package/dest/storage/address_data_provider/index.d.ts +0 -2
  368. package/dest/storage/address_data_provider/index.d.ts.map +0 -1
  369. package/dest/storage/address_data_provider/index.js +0 -1
  370. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +0 -27
  371. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +0 -1
  372. package/dest/storage/capsule_data_provider/capsule_data_provider.js +0 -122
  373. package/dest/storage/capsule_data_provider/index.d.ts +0 -2
  374. package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
  375. package/dest/storage/capsule_data_provider/index.js +0 -1
  376. package/dest/storage/contract_data_provider/contract_data_provider.d.ts +0 -75
  377. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
  378. package/dest/storage/contract_data_provider/contract_data_provider.js +0 -208
  379. package/dest/storage/contract_data_provider/index.d.ts +0 -2
  380. package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
  381. package/dest/storage/contract_data_provider/index.js +0 -1
  382. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
  383. package/dest/storage/data_provider.d.ts +0 -4
  384. package/dest/storage/data_provider.d.ts.map +0 -1
  385. package/dest/storage/data_provider.js +0 -1
  386. package/dest/storage/note_data_provider/index.d.ts +0 -3
  387. package/dest/storage/note_data_provider/index.d.ts.map +0 -1
  388. package/dest/storage/note_data_provider/index.js +0 -2
  389. package/dest/storage/note_data_provider/note_dao.d.ts +0 -100
  390. package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
  391. package/dest/storage/note_data_provider/note_dao.js +0 -102
  392. package/dest/storage/note_data_provider/note_data_provider.d.ts +0 -20
  393. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
  394. package/dest/storage/note_data_provider/note_data_provider.js +0 -260
  395. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +0 -37
  396. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +0 -1
  397. package/dest/storage/private_event_data_provider/private_event_data_provider.js +0 -96
  398. package/dest/storage/sync_data_provider/index.d.ts +0 -2
  399. package/dest/storage/sync_data_provider/index.d.ts.map +0 -1
  400. package/dest/storage/sync_data_provider/index.js +0 -1
  401. package/dest/storage/sync_data_provider/sync_data_provider.d.ts +0 -12
  402. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +0 -1
  403. package/dest/storage/tagging_data_provider/index.d.ts +0 -2
  404. package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
  405. package/dest/storage/tagging_data_provider/index.js +0 -1
  406. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +0 -18
  407. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +0 -1
  408. package/dest/storage/tagging_data_provider/tagging_data_provider.js +0 -82
  409. package/dest/synchronizer/index.d.ts +0 -2
  410. package/dest/synchronizer/index.d.ts.map +0 -1
  411. package/dest/synchronizer/index.js +0 -1
  412. package/dest/synchronizer/synchronizer.d.ts +0 -35
  413. package/dest/synchronizer/synchronizer.d.ts.map +0 -1
  414. package/dest/synchronizer/synchronizer.js +0 -102
  415. package/dest/test/pxe_test_suite.d.ts +0 -3
  416. package/dest/test/pxe_test_suite.d.ts.map +0 -1
  417. package/dest/test/pxe_test_suite.js +0 -97
  418. package/src/bin/index.ts +0 -62
  419. package/src/contract_function_simulator/execution_data_provider.ts +0 -361
  420. package/src/contract_function_simulator/oracle/typed_oracle.ts +0 -289
  421. package/src/contract_function_simulator/proxied_node.ts +0 -33
  422. package/src/contract_function_simulator/pxe_oracle_interface.ts +0 -1020
  423. package/src/contract_function_simulator/tagging_utils.ts +0 -32
  424. package/src/private_kernel/private_kernel_oracle_impl.ts +0 -132
  425. package/src/pxe_service/index.ts +0 -2
  426. package/src/pxe_service/pxe_service.ts +0 -1139
  427. package/src/storage/address_data_provider/index.ts +0 -1
  428. package/src/storage/capsule_data_provider/capsule_data_provider.ts +0 -157
  429. package/src/storage/capsule_data_provider/index.ts +0 -1
  430. package/src/storage/contract_data_provider/contract_data_provider.ts +0 -300
  431. package/src/storage/contract_data_provider/index.ts +0 -1
  432. package/src/storage/data_provider.ts +0 -3
  433. package/src/storage/note_data_provider/index.ts +0 -2
  434. package/src/storage/note_data_provider/note_dao.ts +0 -154
  435. package/src/storage/note_data_provider/note_data_provider.ts +0 -350
  436. package/src/storage/private_event_data_provider/private_event_data_provider.ts +0 -134
  437. package/src/storage/sync_data_provider/index.ts +0 -1
  438. package/src/storage/tagging_data_provider/index.ts +0 -1
  439. package/src/storage/tagging_data_provider/tagging_data_provider.ts +0 -123
  440. package/src/synchronizer/index.ts +0 -1
  441. package/src/synchronizer/synchronizer.ts +0 -121
  442. package/src/test/pxe_test_suite.ts +0 -113
@@ -1 +0,0 @@
1
- export { AddressDataProvider } from './address_data_provider.js';
@@ -1,157 +0,0 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- import { toArray } from '@aztec/foundation/iterable';
3
- import { type Logger, createLogger } from '@aztec/foundation/log';
4
- import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
5
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
-
7
- import type { DataProvider } from '../data_provider.js';
8
-
9
- export class CapsuleDataProvider implements DataProvider {
10
- #store: AztecAsyncKVStore;
11
-
12
- // Arbitrary data stored by contracts. Key is computed as `${contractAddress}:${key}`
13
- #capsules: AztecAsyncMap<string, Buffer>;
14
-
15
- logger: Logger;
16
-
17
- constructor(store: AztecAsyncKVStore) {
18
- this.#store = store;
19
-
20
- this.#capsules = this.#store.openMap('capsules');
21
-
22
- this.logger = createLogger('pxe:capsule-data-provider');
23
- }
24
-
25
- async storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
26
- await this.#capsules.set(dbSlotToKey(contractAddress, slot), Buffer.concat(capsule.map(value => value.toBuffer())));
27
- }
28
-
29
- async loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
30
- const dataBuffer = await this.#capsules.getAsync(dbSlotToKey(contractAddress, slot));
31
- if (!dataBuffer) {
32
- this.logger.trace(`Data not found for contract ${contractAddress.toString()} and slot ${slot.toString()}`);
33
- return null;
34
- }
35
- const capsule: Fr[] = [];
36
- for (let i = 0; i < dataBuffer.length; i += Fr.SIZE_IN_BYTES) {
37
- capsule.push(Fr.fromBuffer(dataBuffer.subarray(i, i + Fr.SIZE_IN_BYTES)));
38
- }
39
- return capsule;
40
- }
41
-
42
- async deleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void> {
43
- await this.#capsules.delete(dbSlotToKey(contractAddress, slot));
44
- }
45
-
46
- copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number): Promise<void> {
47
- return this.#store.transactionAsync(async () => {
48
- // In order to support overlapping source and destination regions, we need to check the relative positions of source
49
- // and destination. If destination is ahead of source, then by the time we overwrite source elements using forward
50
- // indexes we'll have already read those. On the contrary, if source is ahead of destination we need to use backward
51
- // indexes to avoid reading elements that've been overwritten.
52
-
53
- const indexes = Array.from(Array(numEntries).keys());
54
- if (srcSlot.lt(dstSlot)) {
55
- indexes.reverse();
56
- }
57
-
58
- for (const i of indexes) {
59
- const currentSrcSlot = dbSlotToKey(contractAddress, srcSlot.add(new Fr(i)));
60
- const currentDstSlot = dbSlotToKey(contractAddress, dstSlot.add(new Fr(i)));
61
-
62
- const toCopy = await this.#capsules.getAsync(currentSrcSlot);
63
- if (!toCopy) {
64
- throw new Error(`Attempted to copy empty slot ${currentSrcSlot} for contract ${contractAddress.toString()}`);
65
- }
66
-
67
- await this.#capsules.set(currentDstSlot, toCopy);
68
- }
69
- });
70
- }
71
-
72
- /**
73
- * Appends multiple capsules to a capsule array stored at the base slot.
74
- * The array length is stored at the base slot, and elements are stored in consecutive slots after it.
75
- * All operations are performed in a single transaction.
76
- * @param contractAddress - The contract address that owns the capsule array
77
- * @param baseSlot - The slot where the array length is stored
78
- * @param content - Array of capsule data to append
79
- */
80
- appendToCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][]): Promise<void> {
81
- return this.#store.transactionAsync(async () => {
82
- // Load current length, defaulting to 0 if not found
83
- const lengthData = await this.loadCapsule(contractAddress, baseSlot);
84
- const currentLength = lengthData ? lengthData[0].toNumber() : 0;
85
-
86
- // Store each capsule at consecutive slots after baseSlot + 1 + currentLength
87
- for (let i = 0; i < content.length; i++) {
88
- const nextSlot = arraySlot(baseSlot, currentLength + i);
89
- await this.storeCapsule(contractAddress, nextSlot, content[i]);
90
- }
91
-
92
- // Update length to include all new capsules
93
- const newLength = currentLength + content.length;
94
- await this.storeCapsule(contractAddress, baseSlot, [new Fr(newLength)]);
95
- });
96
- }
97
-
98
- readCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr): Promise<Fr[][]> {
99
- return this.#store.transactionAsync(async () => {
100
- // Load length, defaulting to 0 if not found
101
- const maybeLength = await this.loadCapsule(contractAddress, baseSlot);
102
- const length = maybeLength ? maybeLength[0].toBigInt() : 0n;
103
-
104
- const values: Fr[][] = [];
105
-
106
- // Read each capsule at consecutive slots after baseSlot
107
- for (let i = 0; i < length; i++) {
108
- const currentValue = await this.loadCapsule(contractAddress, arraySlot(baseSlot, i));
109
- if (currentValue == undefined) {
110
- throw new Error(
111
- `Expected non-empty value at capsule array in base slot ${baseSlot} at index ${i} for contract ${contractAddress}`,
112
- );
113
- }
114
-
115
- values.push(currentValue);
116
- }
117
-
118
- return values;
119
- });
120
- }
121
-
122
- setCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][]) {
123
- return this.#store.transactionAsync(async () => {
124
- // Load current length, defaulting to 0 if not found
125
- const maybeLength = await this.loadCapsule(contractAddress, baseSlot);
126
- const originalLength = maybeLength ? maybeLength[0].toNumber() : 0;
127
-
128
- // Set the new length
129
- await this.storeCapsule(contractAddress, baseSlot, [new Fr(content.length)]);
130
-
131
- // Store the new content, possibly overwriting existing values
132
- for (let i = 0; i < content.length; i++) {
133
- await this.storeCapsule(contractAddress, arraySlot(baseSlot, i), content[i]);
134
- }
135
-
136
- // Clear any stragglers
137
- for (let i = content.length; i < originalLength; i++) {
138
- await this.deleteCapsule(contractAddress, arraySlot(baseSlot, i));
139
- }
140
- });
141
- }
142
-
143
- public async getSize() {
144
- return (await toArray(this.#capsules.valuesAsync())).reduce(
145
- (sum, value) => sum + value.length * Fr.SIZE_IN_BYTES,
146
- 0,
147
- );
148
- }
149
- }
150
-
151
- function dbSlotToKey(contractAddress: AztecAddress, slot: Fr): string {
152
- return `${contractAddress.toString()}:${slot.toString()}`;
153
- }
154
-
155
- function arraySlot(baseSlot: Fr, index: number) {
156
- return baseSlot.add(new Fr(1)).add(new Fr(index));
157
- }
@@ -1 +0,0 @@
1
- export { CapsuleDataProvider } from './capsule_data_provider.js';
@@ -1,300 +0,0 @@
1
- import type { Fr } from '@aztec/foundation/fields';
2
- import { toArray } from '@aztec/foundation/iterable';
3
- import type { MembershipWitness } from '@aztec/foundation/trees';
4
- import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
5
- import {
6
- type ContractArtifact,
7
- type FunctionAbi,
8
- type FunctionArtifact,
9
- type FunctionArtifactWithContractName,
10
- type FunctionDebugMetadata,
11
- FunctionSelector,
12
- FunctionType,
13
- contractArtifactFromBuffer,
14
- contractArtifactToBuffer,
15
- getFunctionDebugMetadata,
16
- } from '@aztec/stdlib/abi';
17
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
18
- import {
19
- type ContractClass,
20
- type ContractInstanceWithAddress,
21
- SerializableContractInstance,
22
- getContractClassFromArtifact,
23
- } from '@aztec/stdlib/contract';
24
-
25
- import type { DataProvider } from '../data_provider.js';
26
- import { PrivateFunctionsTree } from './private_functions_tree.js';
27
-
28
- /**
29
- * ContractDataProvider serves as a data manager and retriever for Aztec.nr contracts.
30
- * It provides methods to obtain contract addresses, function ABI, bytecode, and membership witnesses
31
- * from a given contract address and function selector. The class maintains a cache of ContractTree instances
32
- * to efficiently serve the requested data. It interacts with the ContractDatabase and AztecNode to fetch
33
- * the required information and facilitate cryptographic proof generation.
34
- */
35
- export class ContractDataProvider implements DataProvider {
36
- /** Map from contract class id to private function tree. */
37
- // TODO: Update it to be LRU cache so that it doesn't keep all the data all the time.
38
- #privateFunctionTrees: Map<string, PrivateFunctionsTree> = new Map();
39
-
40
- /** Map from contract address to contract class id */
41
- #contractClassIdMap: Map<string, Fr> = new Map();
42
-
43
- #contractArtifacts: AztecAsyncMap<string, Buffer>;
44
- #contractInstances: AztecAsyncMap<string, Buffer>;
45
-
46
- constructor(store: AztecAsyncKVStore) {
47
- this.#contractArtifacts = store.openMap('contract_artifacts');
48
- this.#contractInstances = store.openMap('contracts_instances');
49
- }
50
-
51
- // Setters
52
-
53
- public async addContractArtifact(id: Fr, contract: ContractArtifact): Promise<void> {
54
- const privateFunctions = contract.functions.filter(
55
- functionArtifact => functionArtifact.functionType === FunctionType.PRIVATE,
56
- );
57
-
58
- const privateSelectors = await Promise.all(
59
- privateFunctions.map(async privateFunctionArtifact =>
60
- (
61
- await FunctionSelector.fromNameAndParameters(privateFunctionArtifact.name, privateFunctionArtifact.parameters)
62
- ).toString(),
63
- ),
64
- );
65
-
66
- if (privateSelectors.length !== new Set(privateSelectors).size) {
67
- throw new Error('Repeated function selectors of private functions');
68
- }
69
-
70
- await this.#contractArtifacts.set(id.toString(), contractArtifactToBuffer(contract));
71
- }
72
-
73
- async addContractInstance(contract: ContractInstanceWithAddress): Promise<void> {
74
- this.#contractClassIdMap.set(contract.address.toString(), contract.currentContractClassId);
75
-
76
- await this.#contractInstances.set(
77
- contract.address.toString(),
78
- new SerializableContractInstance(contract).toBuffer(),
79
- );
80
- }
81
-
82
- // Private getters
83
-
84
- async #getContractClassId(contractAddress: AztecAddress): Promise<Fr | undefined> {
85
- if (!this.#contractClassIdMap.has(contractAddress.toString())) {
86
- const instance = await this.getContractInstance(contractAddress);
87
- if (!instance) {
88
- return;
89
- }
90
- this.#contractClassIdMap.set(contractAddress.toString(), instance.currentContractClassId);
91
- }
92
- return this.#contractClassIdMap.get(contractAddress.toString());
93
- }
94
-
95
- /**
96
- * Retrieve or create a ContractTree instance based on the provided class id.
97
- * If an existing tree with the same class id is found in the cache, it will be returned.
98
- * Otherwise, a new ContractTree instance will be created using the contract data from the database
99
- * and added to the cache before returning.
100
- *
101
- * @param classId - The class id of the contract for which the ContractTree is required.
102
- * @returns A ContractTree instance associated with the specified contract address.
103
- * @throws An Error if the contract is not found in the ContractDatabase.
104
- */
105
- async #getPrivateFunctionTreeForClassId(classId: Fr): Promise<PrivateFunctionsTree | undefined> {
106
- if (!this.#privateFunctionTrees.has(classId.toString())) {
107
- const artifact = await this.getContractArtifact(classId);
108
- if (!artifact) {
109
- return;
110
- }
111
- const tree = await PrivateFunctionsTree.create(artifact);
112
- this.#privateFunctionTrees.set(classId.toString(), tree);
113
- }
114
- return this.#privateFunctionTrees.get(classId.toString())!;
115
- }
116
-
117
- async #getContractArtifactByAddress(contractAddress: AztecAddress): Promise<ContractArtifact | undefined> {
118
- const contractClassId = await this.#getContractClassId(contractAddress);
119
- return contractClassId && this.getContractArtifact(contractClassId);
120
- }
121
-
122
- // Public getters
123
-
124
- async getContractsAddresses(): Promise<AztecAddress[]> {
125
- const keys = await toArray(this.#contractInstances.keysAsync());
126
- return keys.map(AztecAddress.fromString);
127
- }
128
-
129
- /** Returns a contract instance for a given address. Throws if not found. */
130
- public async getContractInstance(contractAddress: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
131
- const contract = await this.#contractInstances.getAsync(contractAddress.toString());
132
- return contract && SerializableContractInstance.fromBuffer(contract).withAddress(contractAddress);
133
- }
134
-
135
- public async getContractArtifact(contractClassId: Fr): Promise<ContractArtifact | undefined> {
136
- const contract = await this.#contractArtifacts.getAsync(contractClassId.toString());
137
- // TODO(@spalladino): AztecAsyncMap lies and returns Uint8Arrays instead of Buffers, hence the extra Buffer.from.
138
- return contract && contractArtifactFromBuffer(Buffer.from(contract));
139
- }
140
-
141
- /** Returns a contract class for a given class id. Throws if not found. */
142
- public async getContractClass(contractClassId: Fr): Promise<ContractClass | undefined> {
143
- const artifact = await this.getContractArtifact(contractClassId);
144
- return artifact && getContractClassFromArtifact(artifact);
145
- }
146
-
147
- public async getContract(
148
- address: AztecAddress,
149
- ): Promise<(ContractInstanceWithAddress & ContractArtifact) | undefined> {
150
- const instance = await this.getContractInstance(address);
151
- if (!instance) {
152
- return;
153
- }
154
- const artifact = await this.getContractArtifact(instance.currentContractClassId);
155
- if (!artifact) {
156
- return;
157
- }
158
- return { ...instance, ...artifact };
159
- }
160
-
161
- /**
162
- * Retrieves the artifact of a specified function within a given contract.
163
- * The function is identified by its selector, which is a unique code generated from the function's signature.
164
- * Throws an error if the contract address or function selector are invalid or not found.
165
- *
166
- * @param contractAddress - The AztecAddress representing the contract containing the function.
167
- * @param selector - The function selector.
168
- * @returns The corresponding function's artifact as an object.
169
- */
170
- public async getFunctionArtifact(
171
- contractAddress: AztecAddress,
172
- selector: FunctionSelector,
173
- ): Promise<FunctionArtifactWithContractName | undefined> {
174
- const artifact = await this.#getContractArtifactByAddress(contractAddress);
175
- const fnArtifact = artifact && (await this.#findFunctionArtifactBySelector(artifact, selector));
176
- return fnArtifact && { ...fnArtifact, contractName: artifact.name };
177
- }
178
-
179
- public async getPublicFunctionArtifact(
180
- contractAddress: AztecAddress,
181
- ): Promise<FunctionArtifactWithContractName | undefined> {
182
- const artifact = await this.#getContractArtifactByAddress(contractAddress);
183
- const fnArtifact = artifact && artifact.functions.find(fn => fn.functionType === FunctionType.PUBLIC);
184
- return fnArtifact && { ...fnArtifact, contractName: artifact.name };
185
- }
186
-
187
- /**
188
- * Retrieves the artifact of a specified function within a given contract.
189
- * The function is identified by its name, which is unique within a contract.
190
- * Throws if the contract has not been added to the database.
191
- *
192
- * @param contractAddress - The AztecAddress representing the contract containing the function.
193
- * @param functionName - The name of the function.
194
- * @returns The corresponding function's artifact as an object
195
- */
196
- public async getFunctionArtifactByName(
197
- contractAddress: AztecAddress,
198
- functionName: string,
199
- ): Promise<FunctionArtifact | undefined> {
200
- const artifact = await this.#getContractArtifactByAddress(contractAddress);
201
- return artifact?.functions.find(fn => fn.name === functionName);
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));
210
- }
211
-
212
- /**
213
- * Retrieves the debug metadata of a specified function within a given contract.
214
- * The function is identified by its selector, which is a unique code generated from the function's signature.
215
- * Returns undefined if the debug metadata for the given function is not found.
216
- * Throws if the contract has not been added to the database.
217
- *
218
- * @param contractAddress - The AztecAddress representing the contract containing the function.
219
- * @param selector - The function selector.
220
- * @returns The corresponding function's artifact as an object.
221
- */
222
- public async getFunctionDebugMetadata(
223
- contractAddress: AztecAddress,
224
- selector: FunctionSelector,
225
- ): Promise<FunctionDebugMetadata | undefined> {
226
- const artifact = await this.#getContractArtifactByAddress(contractAddress);
227
- const fnArtifact = artifact && (await this.#findFunctionArtifactBySelector(artifact, selector));
228
- return fnArtifact && getFunctionDebugMetadata(artifact, fnArtifact);
229
- }
230
-
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);
237
- }
238
-
239
- /**
240
- * Retrieve the function membership witness for the given contract class and function selector.
241
- * The function membership witness represents a proof that the function belongs to the specified contract.
242
- * Throws an error if the contract address or function selector is unknown.
243
- *
244
- * @param contractClassId - The id of the class.
245
- * @param selector - The function selector.
246
- * @returns A promise that resolves with the MembershipWitness instance for the specified contract's function.
247
- */
248
- public async getFunctionMembershipWitness(
249
- contractClassId: Fr,
250
- selector: FunctionSelector,
251
- ): Promise<MembershipWitness<5> | undefined> {
252
- const tree = await this.#getPrivateFunctionTreeForClassId(contractClassId);
253
- return tree?.getFunctionMembershipWitness(selector);
254
- }
255
-
256
- public async getDebugContractName(contractAddress: AztecAddress) {
257
- const artifact = await this.#getContractArtifactByAddress(contractAddress);
258
- return artifact?.name;
259
- }
260
-
261
- public async getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector) {
262
- const artifact = await this.#getContractArtifactByAddress(contractAddress);
263
- const fnArtifact = artifact && (await this.#findFunctionAbiBySelector(artifact, selector));
264
- return `${artifact?.name ?? contractAddress}:${fnArtifact?.name ?? selector}`;
265
- }
266
-
267
- public async getSize() {
268
- return (await toArray(this.#contractInstances.valuesAsync()))
269
- .concat(await toArray(this.#contractArtifacts.valuesAsync()))
270
- .reduce((sum, value) => sum + value.length, 0);
271
- }
272
-
273
- async #findFunctionArtifactBySelector(
274
- artifact: ContractArtifact,
275
- selector: FunctionSelector,
276
- ): Promise<FunctionArtifact | undefined> {
277
- const functions = artifact.functions;
278
- for (let i = 0; i < functions.length; i++) {
279
- const fn = functions[i];
280
- const fnSelector = await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters);
281
- if (fnSelector.equals(selector)) {
282
- return fn;
283
- }
284
- }
285
- }
286
-
287
- async #findFunctionAbiBySelector(
288
- artifact: ContractArtifact,
289
- selector: FunctionSelector,
290
- ): Promise<FunctionAbi | undefined> {
291
- const functions = [...artifact.functions, ...(artifact.nonDispatchPublicFunctions ?? [])];
292
- for (let i = 0; i < functions.length; i++) {
293
- const fn = functions[i];
294
- const fnSelector = await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters);
295
- if (fnSelector.equals(selector)) {
296
- return fn;
297
- }
298
- }
299
- }
300
- }
@@ -1 +0,0 @@
1
- export { ContractDataProvider } from './contract_data_provider.js';
@@ -1,3 +0,0 @@
1
- export interface DataProvider {
2
- getSize(): Promise<number>;
3
- }
@@ -1,2 +0,0 @@
1
- export { NoteDao } from './note_dao.js';
2
- export { NoteDataProvider } from './note_data_provider.js';
@@ -1,154 +0,0 @@
1
- import { toBigIntBE } from '@aztec/foundation/bigint-buffer';
2
- import { Fr, Point } from '@aztec/foundation/fields';
3
- import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
4
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
- import { Note } from '@aztec/stdlib/note';
6
- import { TxHash } from '@aztec/stdlib/tx';
7
-
8
- import type { NoteData } from '../../contract_function_simulator/oracle/typed_oracle.js';
9
-
10
- /**
11
- * A Note Data Access Object, representing a note that was committed to the note hash tree, holding all of the
12
- * information required to use it during execution and manage its state.
13
- */
14
- export class NoteDao implements NoteData {
15
- constructor(
16
- // Note information
17
-
18
- /** The packed content of the note, as will be returned in the getNotes oracle. */
19
- public note: Note,
20
- /** The address of the contract that created the note (i.e. the address used by the kernel during siloing). */
21
- public contractAddress: AztecAddress,
22
- /**
23
- * The storage location of the note. This value is not used for anything in PXE, but we do index by storage slot
24
- * since contracts typically make queries based on it.
25
- */
26
- public storageSlot: Fr,
27
- /** The nonce that was injected into the note hash preimage in order to guarantee uniqueness. */
28
- public noteNonce: Fr,
29
-
30
- // Computed values
31
- /**
32
- * The inner hash (non-unique, non-siloed) of the note. Each contract determines how the note is hashed. Can
33
- * be used alongside contractAddress and nonce to compute the uniqueNoteHash and the siloedNoteHash.
34
- */
35
- public noteHash: Fr,
36
- /**
37
- * The nullifier of the note, siloed by contract address.
38
- * Note: Might be set as 0 if the note was added to PXE as nullified.
39
- */
40
- public siloedNullifier: Fr,
41
-
42
- // Metadata
43
- /** The hash of the tx in which this note was created. Knowing the tx hash allows for efficient node queries e.g.
44
- * when searching for txEffects.
45
- */
46
- public txHash: TxHash,
47
- /** The L2 block number in which the tx with this note was included. Used for note management while processing
48
- * reorgs.*/
49
- public l2BlockNumber: number,
50
- /** The L2 block hash in which the tx with this note was included. Used for note management while processing
51
- * reorgs.*/
52
- public l2BlockHash: string,
53
- /** The index of the leaf in the global note hash tree the note is stored at */
54
- public index: bigint,
55
- /**
56
- * The address whose public key was used to encrypt the note log during delivery.
57
- * (This is the x-coordinate of the public key.)
58
- */
59
- public recipient: AztecAddress,
60
- ) {}
61
-
62
- toBuffer(): Buffer {
63
- return serializeToBuffer([
64
- this.note,
65
- this.contractAddress,
66
- this.storageSlot,
67
- this.noteNonce,
68
- this.noteHash,
69
- this.siloedNullifier,
70
- this.txHash,
71
- this.l2BlockNumber,
72
- Fr.fromHexString(this.l2BlockHash),
73
- this.index,
74
- this.recipient,
75
- ]);
76
- }
77
-
78
- static fromBuffer(buffer: Buffer | BufferReader) {
79
- const reader = BufferReader.asReader(buffer);
80
-
81
- const note = Note.fromBuffer(reader);
82
- const contractAddress = AztecAddress.fromBuffer(reader);
83
- const storageSlot = Fr.fromBuffer(reader);
84
- const noteNonce = Fr.fromBuffer(reader);
85
- const noteHash = Fr.fromBuffer(reader);
86
- const siloedNullifier = Fr.fromBuffer(reader);
87
- const txHash = reader.readObject(TxHash);
88
- const l2BlockNumber = reader.readNumber();
89
- const l2BlockHash = Fr.fromBuffer(reader).toString();
90
- const index = toBigIntBE(reader.readBytes(32));
91
- const recipient = AztecAddress.fromBuffer(reader);
92
-
93
- return new NoteDao(
94
- note,
95
- contractAddress,
96
- storageSlot,
97
- noteNonce,
98
- noteHash,
99
- siloedNullifier,
100
- txHash,
101
- l2BlockNumber,
102
- l2BlockHash,
103
- index,
104
- recipient,
105
- );
106
- }
107
-
108
- toString() {
109
- return '0x' + this.toBuffer().toString('hex');
110
- }
111
-
112
- static fromString(str: string) {
113
- const hex = str.replace(/^0x/, '');
114
- return NoteDao.fromBuffer(Buffer.from(hex, 'hex'));
115
- }
116
-
117
- /**
118
- * Returns the size in bytes of the Note Dao.
119
- * @returns - Its size in bytes.
120
- */
121
- public getSize() {
122
- const indexSize = Math.ceil(Math.log2(Number(this.index)));
123
- const noteSize = 4 + this.note.items.length * Fr.SIZE_IN_BYTES;
124
- return noteSize + AztecAddress.SIZE_IN_BYTES + Fr.SIZE_IN_BYTES * 4 + TxHash.SIZE + Point.SIZE_IN_BYTES + indexSize;
125
- }
126
-
127
- static async random({
128
- note = Note.random(),
129
- contractAddress = undefined,
130
- storageSlot = Fr.random(),
131
- noteNonce = Fr.random(),
132
- noteHash = Fr.random(),
133
- siloedNullifier = Fr.random(),
134
- txHash = TxHash.random(),
135
- l2BlockNumber = Math.floor(Math.random() * 1000),
136
- l2BlockHash = Fr.random().toString(),
137
- index = Fr.random().toBigInt(),
138
- recipient = undefined,
139
- }: Partial<NoteDao> = {}) {
140
- return new NoteDao(
141
- note,
142
- contractAddress ?? (await AztecAddress.random()),
143
- storageSlot,
144
- noteNonce,
145
- noteHash,
146
- siloedNullifier,
147
- txHash,
148
- l2BlockNumber,
149
- l2BlockHash,
150
- index,
151
- recipient ?? (await AztecAddress.random()),
152
- );
153
- }
154
- }