@aztec/pxe 0.0.0-test.1 → 0.0.1-commit.0208eb9

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 (458) hide show
  1. package/README.md +5 -5
  2. package/dest/bin/check_oracle_version.d.ts +2 -0
  3. package/dest/bin/check_oracle_version.d.ts.map +1 -0
  4. package/dest/bin/check_oracle_version.js +129 -0
  5. package/dest/block_synchronizer/block_synchronizer.d.ts +43 -0
  6. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
  7. package/dest/block_synchronizer/block_synchronizer.js +147 -0
  8. package/dest/block_synchronizer/index.d.ts +2 -0
  9. package/dest/block_synchronizer/index.d.ts.map +1 -0
  10. package/dest/block_synchronizer/index.js +1 -0
  11. package/dest/config/index.d.ts +13 -24
  12. package/dest/config/index.d.ts.map +1 -1
  13. package/dest/config/index.js +35 -33
  14. package/dest/config/package_info.d.ts +1 -1
  15. package/dest/config/package_info.js +1 -1
  16. package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
  17. package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
  18. package/dest/contract_function_simulator/benchmarked_node.js +77 -0
  19. package/dest/contract_function_simulator/contract_function_simulator.d.ts +82 -0
  20. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -0
  21. package/dest/contract_function_simulator/contract_function_simulator.js +339 -0
  22. package/dest/contract_function_simulator/execution_note_cache.d.ts +104 -0
  23. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -0
  24. package/dest/contract_function_simulator/execution_note_cache.js +208 -0
  25. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
  26. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
  27. package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
  28. package/dest/contract_function_simulator/hashed_values_cache.d.ts +28 -0
  29. package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -0
  30. package/dest/contract_function_simulator/hashed_values_cache.js +36 -0
  31. package/dest/contract_function_simulator/index.d.ts +14 -0
  32. package/dest/contract_function_simulator/index.d.ts.map +1 -0
  33. package/dest/contract_function_simulator/index.js +12 -0
  34. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +21 -0
  35. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -0
  36. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +40 -0
  37. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +16 -0
  38. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -0
  39. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +26 -0
  40. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +17 -0
  41. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -0
  42. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +65 -0
  43. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +24 -0
  44. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -0
  45. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +51 -0
  46. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +16 -0
  47. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
  48. package/dest/contract_function_simulator/noir-structs/utility_context.js +22 -0
  49. package/dest/contract_function_simulator/oracle/index.d.ts +14 -0
  50. package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -0
  51. package/dest/contract_function_simulator/oracle/index.js +2 -0
  52. package/dest/contract_function_simulator/oracle/interfaces.d.ts +107 -0
  53. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
  54. package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
  55. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +19 -0
  56. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -0
  57. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +24 -0
  58. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +28 -0
  59. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -0
  60. package/dest/contract_function_simulator/oracle/note_packing_utils.js +54 -0
  61. package/dest/contract_function_simulator/oracle/oracle.d.ts +60 -0
  62. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -0
  63. package/dest/contract_function_simulator/oracle/oracle.js +368 -0
  64. package/dest/contract_function_simulator/oracle/private_execution.d.ts +23 -0
  65. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -0
  66. package/dest/contract_function_simulator/oracle/private_execution.js +87 -0
  67. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +239 -0
  68. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -0
  69. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +426 -0
  70. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +208 -0
  71. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -0
  72. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +367 -0
  73. package/dest/contract_function_simulator/pick_notes.d.ts +85 -0
  74. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -0
  75. package/dest/contract_function_simulator/pick_notes.js +51 -0
  76. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +6 -0
  77. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -0
  78. package/dest/contract_function_simulator/proxied_contract_data_source.js +80 -0
  79. package/dest/contract_sync/index.d.ts +24 -0
  80. package/dest/contract_sync/index.d.ts.map +1 -0
  81. package/dest/contract_sync/index.js +61 -0
  82. package/dest/debug/pxe_debug_utils.d.ts +41 -0
  83. package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
  84. package/dest/debug/pxe_debug_utils.js +47 -0
  85. package/dest/entrypoints/client/bundle/index.d.ts +4 -3
  86. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  87. package/dest/entrypoints/client/bundle/index.js +2 -2
  88. package/dest/entrypoints/client/bundle/utils.d.ts +10 -10
  89. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  90. package/dest/entrypoints/client/bundle/utils.js +33 -12
  91. package/dest/entrypoints/client/lazy/index.d.ts +4 -3
  92. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  93. package/dest/entrypoints/client/lazy/index.js +2 -2
  94. package/dest/entrypoints/client/lazy/utils.d.ts +10 -10
  95. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  96. package/dest/entrypoints/client/lazy/utils.js +33 -12
  97. package/dest/entrypoints/pxe_creation_options.d.ts +18 -0
  98. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -0
  99. package/dest/entrypoints/server/index.d.ts +8 -4
  100. package/dest/entrypoints/server/index.d.ts.map +1 -1
  101. package/dest/entrypoints/server/index.js +6 -3
  102. package/dest/entrypoints/server/utils.d.ts +8 -16
  103. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  104. package/dest/entrypoints/server/utils.js +46 -36
  105. package/dest/error_enriching.d.ts +11 -0
  106. package/dest/error_enriching.d.ts.map +1 -0
  107. package/dest/{pxe_service/error_enriching.js → error_enriching.js} +30 -22
  108. package/dest/events/event_service.d.ts +15 -0
  109. package/dest/events/event_service.d.ts.map +1 -0
  110. package/dest/events/event_service.js +44 -0
  111. package/dest/events/index.d.ts +2 -0
  112. package/dest/events/index.d.ts.map +1 -0
  113. package/dest/events/index.js +1 -0
  114. package/dest/events/private_event_filter_validator.d.ts +9 -0
  115. package/dest/events/private_event_filter_validator.d.ts.map +1 -0
  116. package/dest/events/private_event_filter_validator.js +38 -0
  117. package/dest/job_coordinator/job_coordinator.d.ts +75 -0
  118. package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
  119. package/dest/job_coordinator/job_coordinator.js +94 -0
  120. package/dest/logs/log_service.d.ts +28 -0
  121. package/dest/logs/log_service.d.ts.map +1 -0
  122. package/dest/logs/log_service.js +123 -0
  123. package/dest/notes/index.d.ts +2 -0
  124. package/dest/notes/index.d.ts.map +1 -0
  125. package/dest/notes/index.js +1 -0
  126. package/dest/notes/note_service.d.ts +48 -0
  127. package/dest/notes/note_service.d.ts.map +1 -0
  128. package/dest/notes/note_service.js +147 -0
  129. package/dest/oracle_version.d.ts +3 -0
  130. package/dest/oracle_version.d.ts.map +1 -0
  131. package/dest/oracle_version.js +11 -0
  132. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +4 -0
  133. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +1 -0
  134. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +41 -0
  135. package/dest/private_kernel/hints/index.d.ts +3 -0
  136. package/dest/private_kernel/hints/index.d.ts.map +1 -0
  137. package/dest/private_kernel/hints/index.js +2 -0
  138. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +28 -0
  139. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
  140. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +277 -0
  141. package/dest/private_kernel/index.d.ts +3 -0
  142. package/dest/private_kernel/index.d.ts.map +1 -0
  143. package/dest/private_kernel/index.js +2 -0
  144. package/dest/private_kernel/private_kernel_execution_prover.d.ts +45 -0
  145. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -0
  146. package/dest/private_kernel/private_kernel_execution_prover.js +285 -0
  147. package/dest/private_kernel/private_kernel_oracle.d.ts +59 -0
  148. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -0
  149. package/dest/private_kernel/private_kernel_oracle.js +92 -0
  150. package/dest/pxe.d.ts +204 -0
  151. package/dest/pxe.d.ts.map +1 -0
  152. package/dest/pxe.js +742 -0
  153. package/dest/storage/address_store/address_store.d.ts +11 -0
  154. package/dest/storage/address_store/address_store.d.ts.map +1 -0
  155. package/dest/storage/{address_data_provider/address_data_provider.js → address_store/address_store.js} +13 -15
  156. package/dest/storage/address_store/index.d.ts +2 -0
  157. package/dest/storage/address_store/index.d.ts.map +1 -0
  158. package/dest/storage/address_store/index.js +1 -0
  159. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +17 -0
  160. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
  161. package/dest/storage/anchor_block_store/anchor_block_store.js +26 -0
  162. package/dest/storage/anchor_block_store/index.d.ts +2 -0
  163. package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
  164. package/dest/storage/anchor_block_store/index.js +1 -0
  165. package/dest/storage/capsule_store/capsule_store.d.ts +72 -0
  166. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
  167. package/dest/storage/capsule_store/capsule_store.js +253 -0
  168. package/dest/storage/capsule_store/index.d.ts +2 -0
  169. package/dest/storage/capsule_store/index.d.ts.map +1 -0
  170. package/dest/storage/capsule_store/index.js +1 -0
  171. package/dest/storage/contract_store/contract_store.d.ts +66 -0
  172. package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
  173. package/dest/storage/contract_store/contract_store.js +233 -0
  174. package/dest/storage/contract_store/index.d.ts +2 -0
  175. package/dest/storage/contract_store/index.d.ts.map +1 -0
  176. package/dest/storage/contract_store/index.js +1 -0
  177. package/dest/storage/contract_store/private_functions_tree.d.ts +27 -0
  178. package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
  179. package/dest/storage/contract_store/private_functions_tree.js +47 -0
  180. package/dest/storage/index.d.ts +9 -10
  181. package/dest/storage/index.d.ts.map +1 -1
  182. package/dest/storage/index.js +8 -9
  183. package/dest/storage/metadata.d.ts +2 -0
  184. package/dest/storage/metadata.d.ts.map +1 -0
  185. package/dest/storage/metadata.js +1 -0
  186. package/dest/storage/note_store/index.d.ts +3 -0
  187. package/dest/storage/note_store/index.d.ts.map +1 -0
  188. package/dest/storage/note_store/index.js +2 -0
  189. package/dest/storage/note_store/note_store.d.ts +83 -0
  190. package/dest/storage/note_store/note_store.d.ts.map +1 -0
  191. package/dest/storage/note_store/note_store.js +341 -0
  192. package/dest/storage/note_store/stored_note.d.ts +16 -0
  193. package/dest/storage/note_store/stored_note.d.ts.map +1 -0
  194. package/dest/storage/note_store/stored_note.js +43 -0
  195. package/dest/storage/private_event_store/private_event_store.d.ts +91 -0
  196. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
  197. package/dest/storage/private_event_store/private_event_store.js +273 -0
  198. package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
  199. package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
  200. package/dest/storage/private_event_store/stored_private_event.js +56 -0
  201. package/dest/storage/tagging_store/index.d.ts +4 -0
  202. package/dest/storage/tagging_store/index.d.ts.map +1 -0
  203. package/dest/storage/tagging_store/index.js +3 -0
  204. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +28 -0
  205. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
  206. package/dest/storage/tagging_store/recipient_tagging_store.js +111 -0
  207. package/dest/storage/tagging_store/sender_address_book_store.d.ts +14 -0
  208. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -0
  209. package/dest/storage/tagging_store/sender_address_book_store.js +36 -0
  210. package/dest/storage/tagging_store/sender_tagging_store.d.ts +77 -0
  211. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
  212. package/dest/storage/tagging_store/sender_tagging_store.js +348 -0
  213. package/dest/tagging/constants.d.ts +2 -0
  214. package/dest/tagging/constants.d.ts.map +1 -0
  215. package/dest/tagging/constants.js +10 -0
  216. package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
  217. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
  218. package/dest/tagging/get_all_logs_by_tags.js +46 -0
  219. package/dest/tagging/index.d.ts +17 -0
  220. package/dest/tagging/index.d.ts.map +1 -0
  221. package/dest/tagging/index.js +15 -0
  222. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +15 -0
  223. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -0
  224. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +99 -0
  225. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +12 -0
  226. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -0
  227. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +20 -0
  228. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +15 -0
  229. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -0
  230. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +32 -0
  231. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +21 -0
  232. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -0
  233. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +74 -0
  234. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +11 -0
  235. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -0
  236. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +29 -0
  237. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +21 -0
  238. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
  239. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +60 -0
  240. package/package.json +37 -34
  241. package/src/bin/check_oracle_version.ts +161 -0
  242. package/src/block_synchronizer/block_synchronizer.ts +172 -0
  243. package/src/block_synchronizer/index.ts +1 -0
  244. package/src/config/index.ts +41 -55
  245. package/src/config/package_info.ts +1 -1
  246. package/src/contract_function_simulator/benchmarked_node.ts +103 -0
  247. package/src/contract_function_simulator/contract_function_simulator.ts +633 -0
  248. package/src/contract_function_simulator/execution_note_cache.ts +252 -0
  249. package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
  250. package/src/contract_function_simulator/hashed_values_cache.ts +47 -0
  251. package/src/contract_function_simulator/index.ts +13 -0
  252. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +51 -0
  253. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +28 -0
  254. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +69 -0
  255. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +64 -0
  256. package/src/contract_function_simulator/noir-structs/utility_context.ts +23 -0
  257. package/src/contract_function_simulator/oracle/index.ts +16 -0
  258. package/src/contract_function_simulator/oracle/interfaces.ts +185 -0
  259. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +23 -0
  260. package/src/contract_function_simulator/oracle/note_packing_utils.ts +68 -0
  261. package/src/contract_function_simulator/oracle/oracle.ts +637 -0
  262. package/src/contract_function_simulator/oracle/private_execution.ts +141 -0
  263. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +701 -0
  264. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +544 -0
  265. package/src/contract_function_simulator/pick_notes.ts +141 -0
  266. package/src/contract_function_simulator/proxied_contract_data_source.ts +83 -0
  267. package/src/contract_sync/index.ts +119 -0
  268. package/src/debug/pxe_debug_utils.ts +63 -0
  269. package/src/entrypoints/client/bundle/index.ts +3 -2
  270. package/src/entrypoints/client/bundle/utils.ts +35 -36
  271. package/src/entrypoints/client/lazy/index.ts +3 -2
  272. package/src/entrypoints/client/lazy/utils.ts +36 -32
  273. package/src/entrypoints/pxe_creation_options.ts +14 -0
  274. package/src/entrypoints/server/index.ts +7 -3
  275. package/src/entrypoints/server/utils.ts +52 -52
  276. package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +40 -39
  277. package/src/events/event_service.ts +71 -0
  278. package/src/events/index.ts +1 -0
  279. package/src/events/private_event_filter_validator.ts +46 -0
  280. package/src/job_coordinator/job_coordinator.ts +150 -0
  281. package/src/logs/log_service.ts +220 -0
  282. package/src/notes/index.ts +1 -0
  283. package/src/notes/note_service.ts +195 -0
  284. package/src/oracle_version.ts +12 -0
  285. package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +58 -0
  286. package/src/private_kernel/hints/index.ts +2 -0
  287. package/src/{kernel_prover/hints/build_private_kernel_reset_private_inputs.ts → private_kernel/hints/private_kernel_reset_private_inputs_builder.ts} +179 -156
  288. package/src/private_kernel/index.ts +2 -0
  289. package/src/private_kernel/private_kernel_execution_prover.ts +433 -0
  290. package/src/private_kernel/private_kernel_oracle.ts +152 -0
  291. package/src/pxe.ts +1076 -0
  292. package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +15 -21
  293. package/src/storage/address_store/index.ts +1 -0
  294. package/src/storage/{sync_data_provider/sync_data_provider.ts → anchor_block_store/anchor_block_store.ts} +10 -17
  295. package/src/storage/anchor_block_store/index.ts +1 -0
  296. package/src/storage/capsule_store/capsule_store.ts +315 -0
  297. package/src/storage/capsule_store/index.ts +1 -0
  298. package/src/storage/contract_store/contract_store.ts +330 -0
  299. package/src/storage/contract_store/index.ts +1 -0
  300. package/src/storage/contract_store/private_functions_tree.ts +67 -0
  301. package/src/storage/index.ts +8 -10
  302. package/src/storage/metadata.ts +1 -0
  303. package/src/storage/note_store/index.ts +2 -0
  304. package/src/storage/note_store/note_store.ts +411 -0
  305. package/src/storage/note_store/stored_note.ts +48 -0
  306. package/src/storage/private_event_store/private_event_store.ts +384 -0
  307. package/src/storage/private_event_store/stored_private_event.ts +73 -0
  308. package/src/storage/tagging_store/index.ts +3 -0
  309. package/src/storage/tagging_store/recipient_tagging_store.ts +139 -0
  310. package/src/storage/tagging_store/sender_address_book_store.ts +48 -0
  311. package/src/storage/tagging_store/sender_tagging_store.ts +429 -0
  312. package/src/tagging/constants.ts +10 -0
  313. package/src/tagging/get_all_logs_by_tags.ts +68 -0
  314. package/src/tagging/index.ts +19 -0
  315. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +143 -0
  316. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +34 -0
  317. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +49 -0
  318. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +99 -0
  319. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +36 -0
  320. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +84 -0
  321. package/dest/bin/index.d.ts +0 -3
  322. package/dest/bin/index.d.ts.map +0 -1
  323. package/dest/bin/index.js +0 -28
  324. package/dest/entrypoints/client/pxe_creation_options.d.ts +0 -11
  325. package/dest/entrypoints/client/pxe_creation_options.d.ts.map +0 -1
  326. package/dest/kernel_oracle/index.d.ts +0 -45
  327. package/dest/kernel_oracle/index.d.ts.map +0 -1
  328. package/dest/kernel_oracle/index.js +0 -76
  329. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
  330. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
  331. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +0 -270
  332. package/dest/kernel_prover/hints/index.d.ts +0 -2
  333. package/dest/kernel_prover/hints/index.d.ts.map +0 -1
  334. package/dest/kernel_prover/hints/index.js +0 -1
  335. package/dest/kernel_prover/index.d.ts +0 -3
  336. package/dest/kernel_prover/index.d.ts.map +0 -1
  337. package/dest/kernel_prover/index.js +0 -2
  338. package/dest/kernel_prover/kernel_prover.d.ts +0 -38
  339. package/dest/kernel_prover/kernel_prover.d.ts.map +0 -1
  340. package/dest/kernel_prover/kernel_prover.js +0 -217
  341. package/dest/kernel_prover/proving_data_oracle.d.ts +0 -73
  342. package/dest/kernel_prover/proving_data_oracle.d.ts.map +0 -1
  343. package/dest/kernel_prover/proving_data_oracle.js +0 -4
  344. package/dest/note_decryption_utils/add_public_values_to_payload.d.ts +0 -11
  345. package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +0 -1
  346. package/dest/note_decryption_utils/add_public_values_to_payload.js +0 -47
  347. package/dest/pxe_http/index.d.ts +0 -2
  348. package/dest/pxe_http/index.d.ts.map +0 -1
  349. package/dest/pxe_http/index.js +0 -1
  350. package/dest/pxe_http/pxe_http_server.d.ts +0 -16
  351. package/dest/pxe_http/pxe_http_server.d.ts.map +0 -1
  352. package/dest/pxe_http/pxe_http_server.js +0 -27
  353. package/dest/pxe_oracle_interface/index.d.ts +0 -159
  354. package/dest/pxe_oracle_interface/index.d.ts.map +0 -1
  355. package/dest/pxe_oracle_interface/index.js +0 -692
  356. package/dest/pxe_oracle_interface/tagging_utils.d.ts +0 -17
  357. package/dest/pxe_oracle_interface/tagging_utils.d.ts.map +0 -1
  358. package/dest/pxe_oracle_interface/tagging_utils.js +0 -23
  359. package/dest/pxe_service/error_enriching.d.ts +0 -11
  360. package/dest/pxe_service/error_enriching.d.ts.map +0 -1
  361. package/dest/pxe_service/index.d.ts +0 -3
  362. package/dest/pxe_service/index.d.ts.map +0 -1
  363. package/dest/pxe_service/index.js +0 -2
  364. package/dest/pxe_service/pxe_service.d.ts +0 -111
  365. package/dest/pxe_service/pxe_service.d.ts.map +0 -1
  366. package/dest/pxe_service/pxe_service.js +0 -664
  367. package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -13
  368. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +0 -1
  369. package/dest/storage/address_data_provider/index.d.ts +0 -2
  370. package/dest/storage/address_data_provider/index.d.ts.map +0 -1
  371. package/dest/storage/address_data_provider/index.js +0 -1
  372. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts +0 -11
  373. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts.map +0 -1
  374. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.js +0 -20
  375. package/dest/storage/auth_witness_data_provider/index.d.ts +0 -2
  376. package/dest/storage/auth_witness_data_provider/index.d.ts.map +0 -1
  377. package/dest/storage/auth_witness_data_provider/index.js +0 -1
  378. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +0 -16
  379. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +0 -1
  380. package/dest/storage/capsule_data_provider/capsule_data_provider.js +0 -57
  381. package/dest/storage/capsule_data_provider/index.d.ts +0 -2
  382. package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
  383. package/dest/storage/capsule_data_provider/index.js +0 -1
  384. package/dest/storage/contract_data_provider/contract_data_provider.d.ts +0 -109
  385. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
  386. package/dest/storage/contract_data_provider/contract_data_provider.js +0 -183
  387. package/dest/storage/contract_data_provider/index.d.ts +0 -3
  388. package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
  389. package/dest/storage/contract_data_provider/index.js +0 -2
  390. package/dest/storage/contract_data_provider/private_functions_tree.d.ts +0 -66
  391. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
  392. package/dest/storage/contract_data_provider/private_functions_tree.js +0 -99
  393. package/dest/storage/data_provider.d.ts +0 -4
  394. package/dest/storage/data_provider.d.ts.map +0 -1
  395. package/dest/storage/data_provider.js +0 -1
  396. package/dest/storage/note_data_provider/index.d.ts +0 -3
  397. package/dest/storage/note_data_provider/index.d.ts.map +0 -1
  398. package/dest/storage/note_data_provider/index.js +0 -2
  399. package/dest/storage/note_data_provider/note_dao.d.ts +0 -106
  400. package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
  401. package/dest/storage/note_data_provider/note_dao.js +0 -106
  402. package/dest/storage/note_data_provider/note_data_provider.d.ts +0 -20
  403. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
  404. package/dest/storage/note_data_provider/note_data_provider.js +0 -249
  405. package/dest/storage/sync_data_provider/index.d.ts +0 -2
  406. package/dest/storage/sync_data_provider/index.d.ts.map +0 -1
  407. package/dest/storage/sync_data_provider/index.js +0 -1
  408. package/dest/storage/sync_data_provider/sync_data_provider.d.ts +0 -12
  409. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +0 -1
  410. package/dest/storage/sync_data_provider/sync_data_provider.js +0 -29
  411. package/dest/storage/tagging_data_provider/index.d.ts +0 -2
  412. package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
  413. package/dest/storage/tagging_data_provider/index.js +0 -1
  414. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +0 -18
  415. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +0 -1
  416. package/dest/storage/tagging_data_provider/tagging_data_provider.js +0 -65
  417. package/dest/synchronizer/index.d.ts +0 -2
  418. package/dest/synchronizer/index.d.ts.map +0 -1
  419. package/dest/synchronizer/index.js +0 -1
  420. package/dest/synchronizer/synchronizer.d.ts +0 -37
  421. package/dest/synchronizer/synchronizer.d.ts.map +0 -1
  422. package/dest/synchronizer/synchronizer.js +0 -103
  423. package/dest/test/pxe_test_suite.d.ts +0 -3
  424. package/dest/test/pxe_test_suite.d.ts.map +0 -1
  425. package/dest/test/pxe_test_suite.js +0 -97
  426. package/src/bin/index.ts +0 -38
  427. package/src/entrypoints/client/pxe_creation_options.ts +0 -7
  428. package/src/kernel_oracle/index.ts +0 -117
  429. package/src/kernel_prover/hints/index.ts +0 -1
  430. package/src/kernel_prover/index.ts +0 -2
  431. package/src/kernel_prover/kernel_prover.ts +0 -351
  432. package/src/kernel_prover/proving_data_oracle.ts +0 -83
  433. package/src/note_decryption_utils/add_public_values_to_payload.ts +0 -64
  434. package/src/pxe_http/index.ts +0 -1
  435. package/src/pxe_http/pxe_http_server.ts +0 -29
  436. package/src/pxe_oracle_interface/index.ts +0 -925
  437. package/src/pxe_oracle_interface/tagging_utils.ts +0 -32
  438. package/src/pxe_service/index.ts +0 -2
  439. package/src/pxe_service/pxe_service.ts +0 -949
  440. package/src/storage/address_data_provider/index.ts +0 -1
  441. package/src/storage/auth_witness_data_provider/auth_witness_data_provider.ts +0 -34
  442. package/src/storage/auth_witness_data_provider/index.ts +0 -1
  443. package/src/storage/capsule_data_provider/capsule_data_provider.ts +0 -80
  444. package/src/storage/capsule_data_provider/index.ts +0 -1
  445. package/src/storage/contract_data_provider/contract_data_provider.ts +0 -261
  446. package/src/storage/contract_data_provider/index.ts +0 -2
  447. package/src/storage/contract_data_provider/private_functions_tree.ts +0 -131
  448. package/src/storage/data_provider.ts +0 -3
  449. package/src/storage/note_data_provider/index.ts +0 -2
  450. package/src/storage/note_data_provider/note_dao.ts +0 -162
  451. package/src/storage/note_data_provider/note_data_provider.ts +0 -345
  452. package/src/storage/sync_data_provider/index.ts +0 -1
  453. package/src/storage/tagging_data_provider/index.ts +0 -1
  454. package/src/storage/tagging_data_provider/tagging_data_provider.ts +0 -92
  455. package/src/synchronizer/index.ts +0 -1
  456. package/src/synchronizer/synchronizer.ts +0 -121
  457. package/src/test/pxe_test_suite.ts +0 -111
  458. /package/dest/entrypoints/{client/pxe_creation_options.js → pxe_creation_options.js} +0 -0
@@ -0,0 +1,544 @@
1
+ import type { ARCHIVE_HEIGHT, NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
2
+ import type { BlockNumber } from '@aztec/foundation/branded-types';
3
+ import { Aes128 } from '@aztec/foundation/crypto/aes128';
4
+ import { Fr } from '@aztec/foundation/curves/bn254';
5
+ import { Point } from '@aztec/foundation/curves/grumpkin';
6
+ import { LogLevels, applyStringFormatting, createLogger } from '@aztec/foundation/log';
7
+ import type { MembershipWitness } from '@aztec/foundation/trees';
8
+ import type { KeyStore } from '@aztec/key-store';
9
+ import type { AuthWitness } from '@aztec/stdlib/auth-witness';
10
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
11
+ import { BlockHash } from '@aztec/stdlib/block';
12
+ import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
13
+ import { siloNullifier } from '@aztec/stdlib/hash';
14
+ import type { AztecNode } from '@aztec/stdlib/interfaces/server';
15
+ import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
16
+ import { computeAddressSecret } from '@aztec/stdlib/keys';
17
+ import { deriveEcdhSharedSecret } from '@aztec/stdlib/logs';
18
+ import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
19
+ import type { NoteStatus } from '@aztec/stdlib/note';
20
+ import { MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
21
+ import type { BlockHeader, Capsule } from '@aztec/stdlib/tx';
22
+
23
+ import { EventService } from '../../events/event_service.js';
24
+ import { LogService } from '../../logs/log_service.js';
25
+ import { NoteService } from '../../notes/note_service.js';
26
+ import { ORACLE_VERSION } from '../../oracle_version.js';
27
+ import type { AddressStore } from '../../storage/address_store/address_store.js';
28
+ import type { CapsuleStore } from '../../storage/capsule_store/capsule_store.js';
29
+ import type { ContractStore } from '../../storage/contract_store/contract_store.js';
30
+ import type { NoteStore } from '../../storage/note_store/note_store.js';
31
+ import type { PrivateEventStore } from '../../storage/private_event_store/private_event_store.js';
32
+ import type { RecipientTaggingStore } from '../../storage/tagging_store/recipient_tagging_store.js';
33
+ import type { SenderAddressBookStore } from '../../storage/tagging_store/sender_address_book_store.js';
34
+ import { EventValidationRequest } from '../noir-structs/event_validation_request.js';
35
+ import { LogRetrievalRequest } from '../noir-structs/log_retrieval_request.js';
36
+ import { LogRetrievalResponse } from '../noir-structs/log_retrieval_response.js';
37
+ import { NoteValidationRequest } from '../noir-structs/note_validation_request.js';
38
+ import { UtilityContext } from '../noir-structs/utility_context.js';
39
+ import { pickNotes } from '../pick_notes.js';
40
+ import type { IMiscOracle, IUtilityExecutionOracle, NoteData } from './interfaces.js';
41
+ import { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
42
+
43
+ /**
44
+ * The oracle for an execution of utility contract functions.
45
+ */
46
+ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOracle {
47
+ isMisc = true as const;
48
+ isUtility = true as const;
49
+
50
+ private aztecNrDebugLog = createLogger('aztec-nr:debug_log');
51
+
52
+ constructor(
53
+ protected readonly contractAddress: AztecAddress,
54
+ /** List of transient auth witnesses to be used during this simulation */
55
+ protected readonly authWitnesses: AuthWitness[],
56
+ protected readonly capsules: Capsule[], // TODO(#12425): Rename to transientCapsules
57
+ protected readonly anchorBlockHeader: BlockHeader,
58
+ protected readonly contractStore: ContractStore,
59
+ protected readonly noteStore: NoteStore,
60
+ protected readonly keyStore: KeyStore,
61
+ protected readonly addressStore: AddressStore,
62
+ protected readonly aztecNode: AztecNode,
63
+ protected readonly recipientTaggingStore: RecipientTaggingStore,
64
+ protected readonly senderAddressBookStore: SenderAddressBookStore,
65
+ protected readonly capsuleStore: CapsuleStore,
66
+ protected readonly privateEventStore: PrivateEventStore,
67
+ protected readonly jobId: string,
68
+ protected log = createLogger('simulator:client_view_context'),
69
+ protected readonly scopes?: AztecAddress[],
70
+ ) {}
71
+
72
+ public utilityAssertCompatibleOracleVersion(version: number): void {
73
+ if (version !== ORACLE_VERSION) {
74
+ throw new Error(`Incompatible oracle version. Expected version ${ORACLE_VERSION}, got ${version}.`);
75
+ }
76
+ }
77
+
78
+ public utilityGetRandomField(): Fr {
79
+ return Fr.random();
80
+ }
81
+
82
+ public utilityGetUtilityContext(): UtilityContext {
83
+ return new UtilityContext(this.anchorBlockHeader, this.contractAddress);
84
+ }
85
+
86
+ /**
87
+ * Retrieve keys associated with a specific master public key and app address.
88
+ * @param pkMHash - The master public key hash.
89
+ * @returns A Promise that resolves to nullifier keys.
90
+ * @throws If the keys are not registered in the key store.
91
+ */
92
+ public utilityGetKeyValidationRequest(pkMHash: Fr): Promise<KeyValidationRequest> {
93
+ return this.keyStore.getKeyValidationRequest(pkMHash, this.contractAddress);
94
+ }
95
+
96
+ /**
97
+ * Fetches the index and sibling path of a leaf at a given block from the note hash tree.
98
+ * @param anchorBlockHash - The hash of a block that contains the note hash tree root in which to find the membership
99
+ * witness.
100
+ * @param noteHash - The note hash to find in the note hash tree.
101
+ * @returns The membership witness containing the leaf index and sibling path
102
+ */
103
+ public utilityGetNoteHashMembershipWitness(
104
+ anchorBlockHash: BlockHash,
105
+ noteHash: Fr,
106
+ ): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
107
+ return this.aztecNode.getNoteHashMembershipWitness(anchorBlockHash, noteHash);
108
+ }
109
+
110
+ /**
111
+ * Fetches the index and sibling path of a block hash in the archive tree.
112
+ *
113
+ * Block hashes are the leaves of the archive tree. Each time a new block is added to the chain,
114
+ * its block hash is appended as a new leaf to the archive tree.
115
+ *
116
+ * @param anchorBlockHash - The hash of a block that contains the archive tree root in which to find the membership
117
+ * witness.
118
+ * @param blockHash - The block hash to find in the archive tree.
119
+ * @returns The membership witness containing the leaf index and sibling path
120
+ */
121
+ public utilityGetBlockHashMembershipWitness(
122
+ anchorBlockHash: BlockHash,
123
+ blockHash: BlockHash,
124
+ ): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined> {
125
+ return this.aztecNode.getBlockHashMembershipWitness(anchorBlockHash, blockHash);
126
+ }
127
+
128
+ /**
129
+ * Returns a nullifier membership witness for a given nullifier at a given block.
130
+ * @param blockHash - The block hash at which to get the index.
131
+ * @param nullifier - Nullifier we try to find witness for.
132
+ * @returns The nullifier membership witness (if found).
133
+ */
134
+ public utilityGetNullifierMembershipWitness(
135
+ blockHash: BlockHash,
136
+ nullifier: Fr,
137
+ ): Promise<NullifierMembershipWitness | undefined> {
138
+ return this.aztecNode.getNullifierMembershipWitness(blockHash, nullifier);
139
+ }
140
+
141
+ /**
142
+ * Returns a low nullifier membership witness for a given nullifier at a given block.
143
+ * @param blockHash - The block hash at which to get the index.
144
+ * @param nullifier - Nullifier we try to find the low nullifier witness for.
145
+ * @returns The low nullifier membership witness (if found).
146
+ * @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
147
+ * list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
148
+ * we are trying to prove non-inclusion for.
149
+ */
150
+ public utilityGetLowNullifierMembershipWitness(
151
+ blockHash: BlockHash,
152
+ nullifier: Fr,
153
+ ): Promise<NullifierMembershipWitness | undefined> {
154
+ return this.aztecNode.getLowNullifierMembershipWitness(blockHash, nullifier);
155
+ }
156
+
157
+ /**
158
+ * Returns a public data tree witness for a given leaf slot at a given block.
159
+ * @param blockHash - The block hash at which to get the index.
160
+ * @param leafSlot - The slot of the public data tree to get the witness for.
161
+ * @returns - The witness
162
+ */
163
+ public utilityGetPublicDataWitness(blockHash: BlockHash, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
164
+ return this.aztecNode.getPublicDataWitness(blockHash, leafSlot);
165
+ }
166
+
167
+ /**
168
+ * Fetches a block header of a given block.
169
+ * @param blockNumber - The number of a block of which to get the block header.
170
+ * @returns Block extracted from a block with block number `blockNumber`.
171
+ */
172
+ public async utilityGetBlockHeader(blockNumber: BlockNumber): Promise<BlockHeader | undefined> {
173
+ const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
174
+ if (blockNumber > anchorBlockNumber) {
175
+ throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
176
+ }
177
+
178
+ const block = await this.aztecNode.getBlock(blockNumber);
179
+ return block?.header;
180
+ }
181
+
182
+ /**
183
+ * Retrieve the complete address associated to a given address.
184
+ * @param account - The account address.
185
+ * @returns A complete address associated with the input address, or `undefined` if not registered.
186
+ */
187
+ public utilityTryGetPublicKeysAndPartialAddress(account: AztecAddress): Promise<CompleteAddress | undefined> {
188
+ return this.addressStore.getCompleteAddress(account);
189
+ }
190
+
191
+ protected async getCompleteAddressOrFail(account: AztecAddress): Promise<CompleteAddress> {
192
+ const completeAddress = await this.addressStore.getCompleteAddress(account);
193
+ if (!completeAddress) {
194
+ throw new Error(
195
+ `No public key registered for address ${account}.
196
+ Register it by calling pxe.addAccount(...).\nSee docs for context: https://docs.aztec.network/developers/resources/debugging/aztecnr-errors#simulation-error-no-public-key-registered-for-address-0x0-register-it-by-calling-pxeregisterrecipient-or-pxeregisteraccount`,
197
+ );
198
+ }
199
+ return completeAddress;
200
+ }
201
+
202
+ /**
203
+ * Returns a contract instance associated with an address or throws if not found.
204
+ * @param address - Address.
205
+ * @returns A contract instance.
206
+ */
207
+ public utilityGetContractInstance(address: AztecAddress): Promise<ContractInstance> {
208
+ return this.getContractInstance(address);
209
+ }
210
+
211
+ protected async getContractInstance(address: AztecAddress): Promise<ContractInstance> {
212
+ const instance = await this.contractStore.getContractInstance(address);
213
+ if (!instance) {
214
+ throw new Error(`No contract instance found for address ${address.toString()}`);
215
+ }
216
+ return instance;
217
+ }
218
+
219
+ /**
220
+ * Returns an auth witness for the given message hash. Checks on the list of transient witnesses
221
+ * for this transaction first, and falls back to the local database if not found.
222
+ * @param messageHash - Hash of the message to authenticate.
223
+ * @returns Authentication witness for the requested message hash.
224
+ */
225
+ public utilityGetAuthWitness(messageHash: Fr): Promise<Fr[] | undefined> {
226
+ return Promise.resolve(this.authWitnesses.find(w => w.requestHash.equals(messageHash))?.witness);
227
+ }
228
+
229
+ /**
230
+ * Gets some notes for a contract address and storage slot.
231
+ * Returns a flattened array containing filtered notes.
232
+ *
233
+ * @remarks
234
+ * Check for pending notes with matching slot.
235
+ * Real notes coming from DB will have a leafIndex which
236
+ * represents their index in the note hash tree.
237
+ *
238
+ * @param owner - The owner of the notes. If undefined, returns notes for all owners.
239
+ * @param storageSlot - The storage slot.
240
+ * @param numSelects - The number of valid selects in selectBy and selectValues.
241
+ * @param selectBy - An array of indices of the fields to selects.
242
+ * @param selectValues - The values to match.
243
+ * @param selectComparators - The comparators to use to match values.
244
+ * @param sortBy - An array of indices of the fields to sort.
245
+ * @param sortOrder - The order of the corresponding index in sortBy. (1: DESC, 2: ASC, 0: Do nothing)
246
+ * @param limit - The number of notes to retrieve per query.
247
+ * @param offset - The starting index for pagination.
248
+ * @param status - The status of notes to fetch.
249
+ * @returns Array of note data.
250
+ */
251
+ public async utilityGetNotes(
252
+ owner: AztecAddress | undefined,
253
+ storageSlot: Fr,
254
+ numSelects: number,
255
+ selectByIndexes: number[],
256
+ selectByOffsets: number[],
257
+ selectByLengths: number[],
258
+ selectValues: Fr[],
259
+ selectComparators: number[],
260
+ sortByIndexes: number[],
261
+ sortByOffsets: number[],
262
+ sortByLengths: number[],
263
+ sortOrder: number[],
264
+ limit: number,
265
+ offset: number,
266
+ status: NoteStatus,
267
+ ): Promise<NoteData[]> {
268
+ const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockHeader, this.jobId);
269
+
270
+ const dbNotes = await noteService.getNotes(this.contractAddress, owner, storageSlot, status, this.scopes);
271
+ return pickNotes<NoteData>(dbNotes, {
272
+ selects: selectByIndexes.slice(0, numSelects).map((index, i) => ({
273
+ selector: { index, offset: selectByOffsets[i], length: selectByLengths[i] },
274
+ value: selectValues[i],
275
+ comparator: selectComparators[i],
276
+ })),
277
+ sorts: sortByIndexes.map((index, i) => ({
278
+ selector: { index, offset: sortByOffsets[i], length: sortByLengths[i] },
279
+ order: sortOrder[i],
280
+ })),
281
+ limit,
282
+ offset,
283
+ });
284
+ }
285
+
286
+ /**
287
+ * Check if a nullifier exists in the nullifier tree.
288
+ * @param innerNullifier - The inner nullifier.
289
+ * @returns A boolean indicating whether the nullifier exists in the tree or not.
290
+ */
291
+ public async utilityCheckNullifierExists(innerNullifier: Fr) {
292
+ const nullifier = await siloNullifier(this.contractAddress, innerNullifier!);
293
+ const [leafIndex] = await this.aztecNode.findLeavesIndexes('latest', MerkleTreeId.NULLIFIER_TREE, [nullifier]);
294
+ return leafIndex?.data !== undefined;
295
+ }
296
+
297
+ /**
298
+ * Fetches a message from the executionStore, given its key.
299
+ * @param contractAddress - Address of a contract by which the message was emitted.
300
+ * @param messageHash - Hash of the message.
301
+ * @param secret - Secret used to compute a nullifier.
302
+ * @dev Contract address and secret are only used to compute the nullifier to get non-nullified messages
303
+ * @returns The l1 to l2 membership witness (index of message in the tree and sibling path).
304
+ */
305
+ public async utilityGetL1ToL2MembershipWitness(contractAddress: AztecAddress, messageHash: Fr, secret: Fr) {
306
+ const [messageIndex, siblingPath] = await getNonNullifiedL1ToL2MessageWitness(
307
+ this.aztecNode,
308
+ contractAddress,
309
+ messageHash,
310
+ secret,
311
+ );
312
+
313
+ return new MessageLoadOracleInputs(messageIndex, siblingPath);
314
+ }
315
+
316
+ /**
317
+ * Read the public storage data.
318
+ * @param blockHash - The block hash to read storage at.
319
+ * @param contractAddress - The address to read storage from.
320
+ * @param startStorageSlot - The starting storage slot.
321
+ * @param numberOfElements - Number of elements to read from the starting storage slot.
322
+ */
323
+ public async utilityStorageRead(
324
+ blockHash: BlockHash,
325
+ contractAddress: AztecAddress,
326
+ startStorageSlot: Fr,
327
+ numberOfElements: number,
328
+ ) {
329
+ const slots = Array(numberOfElements)
330
+ .fill(0)
331
+ .map((_, i) => new Fr(startStorageSlot.value + BigInt(i)));
332
+
333
+ const values = await Promise.all(
334
+ slots.map(storageSlot => this.aztecNode.getPublicStorageAt(blockHash, contractAddress, storageSlot)),
335
+ );
336
+
337
+ this.log.debug(
338
+ `Oracle storage read: slots=[${slots.map(slot => slot.toString()).join(', ')}] address=${contractAddress.toString()} values=[${values.join(', ')}]`,
339
+ );
340
+
341
+ return values;
342
+ }
343
+
344
+ public utilityDebugLog(level: number, message: string, fields: Fr[]): void {
345
+ if (!LogLevels[level]) {
346
+ throw new Error(`Invalid debug log level: ${level}`);
347
+ }
348
+ const levelName = LogLevels[level];
349
+ this.aztecNrDebugLog[levelName](`${applyStringFormatting(message, fields)}`);
350
+ }
351
+
352
+ public async utilityFetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr) {
353
+ const logService = new LogService(
354
+ this.aztecNode,
355
+ this.anchorBlockHeader,
356
+ this.keyStore,
357
+ this.capsuleStore,
358
+ this.recipientTaggingStore,
359
+ this.senderAddressBookStore,
360
+ this.addressStore,
361
+ this.jobId,
362
+ this.log.getBindings(),
363
+ );
364
+
365
+ await logService.fetchTaggedLogs(this.contractAddress, pendingTaggedLogArrayBaseSlot, this.scopes);
366
+ }
367
+
368
+ /**
369
+ * Validates all note and event validation requests enqueued via `enqueue_note_for_validation` and
370
+ * `enqueue_event_for_validation`, inserting them into the note database and event store respectively, making them
371
+ * queryable via `get_notes` and `getPrivateEvents`.
372
+ *
373
+ * This automatically clears both validation request queues, so no further work needs to be done by the caller.
374
+ * @param contractAddress - The address of the contract that the logs are tagged for.
375
+ * @param noteValidationRequestsArrayBaseSlot - The base slot of capsule array containing note validation requests.
376
+ * @param eventValidationRequestsArrayBaseSlot - The base slot of capsule array containing event validation requests.
377
+ */
378
+ public async utilityValidateAndStoreEnqueuedNotesAndEvents(
379
+ contractAddress: AztecAddress,
380
+ noteValidationRequestsArrayBaseSlot: Fr,
381
+ eventValidationRequestsArrayBaseSlot: Fr,
382
+ ) {
383
+ // TODO(#10727): allow other contracts to store notes
384
+ if (!this.contractAddress.equals(contractAddress)) {
385
+ throw new Error(`Got a note validation request from ${contractAddress}, expected ${this.contractAddress}`);
386
+ }
387
+
388
+ // We read all note and event validation requests and process them all concurrently. This makes the process much
389
+ // faster as we don't need to wait for the network round-trip.
390
+ const noteValidationRequests = (
391
+ await this.capsuleStore.readCapsuleArray(contractAddress, noteValidationRequestsArrayBaseSlot, this.jobId)
392
+ ).map(NoteValidationRequest.fromFields);
393
+
394
+ const eventValidationRequests = (
395
+ await this.capsuleStore.readCapsuleArray(contractAddress, eventValidationRequestsArrayBaseSlot, this.jobId)
396
+ ).map(EventValidationRequest.fromFields);
397
+
398
+ const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockHeader, this.jobId);
399
+ const noteStorePromises = noteValidationRequests.map(request =>
400
+ noteService.validateAndStoreNote(
401
+ request.contractAddress,
402
+ request.owner,
403
+ request.storageSlot,
404
+ request.randomness,
405
+ request.noteNonce,
406
+ request.content,
407
+ request.noteHash,
408
+ request.nullifier,
409
+ request.txHash,
410
+ request.recipient,
411
+ ),
412
+ );
413
+
414
+ const eventService = new EventService(this.anchorBlockHeader, this.aztecNode, this.privateEventStore, this.jobId);
415
+ const eventStorePromises = eventValidationRequests.map(request =>
416
+ eventService.validateAndStoreEvent(
417
+ request.contractAddress,
418
+ request.eventTypeId,
419
+ request.randomness,
420
+ request.serializedEvent,
421
+ request.eventCommitment,
422
+ request.txHash,
423
+ request.recipient,
424
+ ),
425
+ );
426
+
427
+ await Promise.all([...noteStorePromises, ...eventStorePromises]);
428
+
429
+ // Requests are cleared once we're done.
430
+ await this.capsuleStore.setCapsuleArray(contractAddress, noteValidationRequestsArrayBaseSlot, [], this.jobId);
431
+ await this.capsuleStore.setCapsuleArray(contractAddress, eventValidationRequestsArrayBaseSlot, [], this.jobId);
432
+ }
433
+
434
+ public async utilityBulkRetrieveLogs(
435
+ contractAddress: AztecAddress,
436
+ logRetrievalRequestsArrayBaseSlot: Fr,
437
+ logRetrievalResponsesArrayBaseSlot: Fr,
438
+ ) {
439
+ // TODO(#10727): allow other contracts to process partial notes
440
+ if (!this.contractAddress.equals(contractAddress)) {
441
+ throw new Error(`Got a note validation request from ${contractAddress}, expected ${this.contractAddress}`);
442
+ }
443
+
444
+ // We read all log retrieval requests and process them all concurrently. This makes the process much faster as we
445
+ // don't need to wait for the network round-trip.
446
+ const logRetrievalRequests = (
447
+ await this.capsuleStore.readCapsuleArray(contractAddress, logRetrievalRequestsArrayBaseSlot, this.jobId)
448
+ ).map(LogRetrievalRequest.fromFields);
449
+
450
+ const logService = new LogService(
451
+ this.aztecNode,
452
+ this.anchorBlockHeader,
453
+ this.keyStore,
454
+ this.capsuleStore,
455
+ this.recipientTaggingStore,
456
+ this.senderAddressBookStore,
457
+ this.addressStore,
458
+ this.jobId,
459
+ this.log.getBindings(),
460
+ );
461
+
462
+ const maybeLogRetrievalResponses = await logService.bulkRetrieveLogs(logRetrievalRequests);
463
+
464
+ // Requests are cleared once we're done.
465
+ await this.capsuleStore.setCapsuleArray(contractAddress, logRetrievalRequestsArrayBaseSlot, [], this.jobId);
466
+
467
+ // The responses are stored as Option<LogRetrievalResponse> in a second CapsuleArray.
468
+ await this.capsuleStore.setCapsuleArray(
469
+ contractAddress,
470
+ logRetrievalResponsesArrayBaseSlot,
471
+ maybeLogRetrievalResponses.map(LogRetrievalResponse.toSerializedOption),
472
+ this.jobId,
473
+ );
474
+ }
475
+
476
+ public utilityStoreCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
477
+ if (!contractAddress.equals(this.contractAddress)) {
478
+ // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
479
+ throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
480
+ }
481
+ this.capsuleStore.storeCapsule(this.contractAddress, slot, capsule, this.jobId);
482
+ return Promise.resolve();
483
+ }
484
+
485
+ public async utilityLoadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
486
+ if (!contractAddress.equals(this.contractAddress)) {
487
+ // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
488
+ throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
489
+ }
490
+ return (
491
+ // TODO(#12425): On the following line, the pertinent capsule gets overshadowed by the transient one. Tackle this.
492
+ this.capsules.find(c => c.contractAddress.equals(contractAddress) && c.storageSlot.equals(slot))?.data ??
493
+ (await this.capsuleStore.loadCapsule(this.contractAddress, slot, this.jobId))
494
+ );
495
+ }
496
+
497
+ public utilityDeleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void> {
498
+ if (!contractAddress.equals(this.contractAddress)) {
499
+ // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
500
+ throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
501
+ }
502
+ this.capsuleStore.deleteCapsule(this.contractAddress, slot, this.jobId);
503
+ return Promise.resolve();
504
+ }
505
+
506
+ public utilityCopyCapsule(
507
+ contractAddress: AztecAddress,
508
+ srcSlot: Fr,
509
+ dstSlot: Fr,
510
+ numEntries: number,
511
+ ): Promise<void> {
512
+ if (!contractAddress.equals(this.contractAddress)) {
513
+ // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
514
+ throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
515
+ }
516
+ return this.capsuleStore.copyCapsule(this.contractAddress, srcSlot, dstSlot, numEntries, this.jobId);
517
+ }
518
+
519
+ // TODO(#11849): consider replacing this oracle with a pure Noir implementation of aes decryption.
520
+ public utilityAes128Decrypt(ciphertext: Buffer, iv: Buffer, symKey: Buffer): Promise<Buffer> {
521
+ const aes128 = new Aes128();
522
+ return aes128.decryptBufferCBC(ciphertext, iv, symKey);
523
+ }
524
+
525
+ /**
526
+ * Retrieves the shared secret for a given address and ephemeral public key.
527
+ * @param address - The address to get the secret for.
528
+ * @param ephPk - The ephemeral public key to get the secret for.
529
+ * @returns The secret for the given address.
530
+ */
531
+ public utilityGetSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point> {
532
+ return this.getSharedSecret(address, ephPk);
533
+ }
534
+
535
+ protected async getSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point> {
536
+ // TODO(#12656): return an app-siloed secret
537
+ const recipientCompleteAddress = await this.getCompleteAddressOrFail(address);
538
+ const ivskM = await this.keyStore.getMasterSecretKey(
539
+ recipientCompleteAddress.publicKeys.masterIncomingViewingPublicKey,
540
+ );
541
+ const addressSecret = await computeAddressSecret(await recipientCompleteAddress.getPreaddress(), ivskM);
542
+ return deriveEcdhSharedSecret(addressSecret, ephPk);
543
+ }
544
+ }
@@ -0,0 +1,141 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { Comparator, type Note } from '@aztec/stdlib/note';
3
+
4
+ export interface PropertySelector {
5
+ index: number;
6
+ offset: number;
7
+ length: number;
8
+ }
9
+
10
+ /**
11
+ * Configuration for selecting values.
12
+ */
13
+ export interface Select {
14
+ /**
15
+ * Selector of the field to select and match.
16
+ */
17
+ selector: PropertySelector;
18
+ /**
19
+ * Required value of the field.
20
+ */
21
+ value: Fr;
22
+ /**
23
+ * The comparator to use
24
+ */
25
+ comparator: Comparator;
26
+ }
27
+
28
+ /**
29
+ * The order to sort an array.
30
+ */
31
+ export enum SortOrder {
32
+ NADA = 0,
33
+ DESC = 1,
34
+ ASC = 2,
35
+ }
36
+
37
+ /**
38
+ * Configuration for sorting values.
39
+ */
40
+ export interface Sort {
41
+ /**
42
+ * Selector of the field to sort.
43
+ */
44
+ selector: PropertySelector;
45
+ /**
46
+ * Order to sort the field.
47
+ */
48
+ order: SortOrder;
49
+ }
50
+
51
+ /**
52
+ * Options for picking items from an array of BasicNoteData.
53
+ */
54
+ interface GetOptions {
55
+ /**
56
+ * Configurations for selecting items.
57
+ * Default: empty array.
58
+ */
59
+ selects?: Select[];
60
+ /**
61
+ * Configurations for sorting items.
62
+ * Default: empty array.
63
+ */
64
+ sorts?: Sort[];
65
+ /**
66
+ * The number of items to retrieve per query.
67
+ * Default: 0. No limit.
68
+ */
69
+ limit?: number;
70
+ /**
71
+ * The starting index for pagination.
72
+ * Default: 0.
73
+ */
74
+ offset?: number;
75
+ }
76
+
77
+ /**
78
+ * Data needed from to perform sort.
79
+ */
80
+ interface ContainsNote {
81
+ /**
82
+ * The note.
83
+ */
84
+ note: Note;
85
+ }
86
+
87
+ const selectPropertyFromPackedNoteContent = (noteData: Fr[], selector: PropertySelector): Fr => {
88
+ const noteValueBuffer = noteData[selector.index].toBuffer();
89
+ const noteValue = noteValueBuffer.subarray(selector.offset, selector.offset + selector.length);
90
+ return Fr.fromBuffer(noteValue);
91
+ };
92
+
93
+ const selectNotes = <T extends ContainsNote>(noteDatas: T[], selects: Select[]): T[] =>
94
+ noteDatas.filter(noteData =>
95
+ selects.every(({ selector, value, comparator }) => {
96
+ const noteValueFr = selectPropertyFromPackedNoteContent(noteData.note.items, selector);
97
+ const comparatorSelector = {
98
+ [Comparator.EQ]: () => noteValueFr.equals(value),
99
+ [Comparator.NEQ]: () => !noteValueFr.equals(value),
100
+ [Comparator.LT]: () => noteValueFr.lt(value),
101
+ [Comparator.LTE]: () => noteValueFr.lt(value) || noteValueFr.equals(value),
102
+ [Comparator.GT]: () => !noteValueFr.lt(value) && !noteValueFr.equals(value),
103
+ [Comparator.GTE]: () => !noteValueFr.lt(value),
104
+ };
105
+
106
+ return comparatorSelector[comparator]();
107
+ }),
108
+ );
109
+
110
+ const sortNotes = (a: Fr[], b: Fr[], sorts: Sort[], level = 0): number => {
111
+ if (sorts[level] === undefined) {
112
+ return 0;
113
+ }
114
+
115
+ const { selector, order } = sorts[level];
116
+ if (order === (0 as SortOrder)) {
117
+ return 0;
118
+ }
119
+
120
+ const aValue = selectPropertyFromPackedNoteContent(a, selector);
121
+ const bValue = selectPropertyFromPackedNoteContent(b, selector);
122
+
123
+ const dir = order === (1 as SortOrder) ? [-1, 1] : [1, -1];
124
+ return aValue.toBigInt() === bValue.toBigInt()
125
+ ? sortNotes(a, b, sorts, level + 1)
126
+ : aValue.toBigInt() > bValue.toBigInt()
127
+ ? dir[0]
128
+ : dir[1];
129
+ };
130
+
131
+ /**
132
+ * Pick from a note array a number of notes that meet the criteria.
133
+ */
134
+ export function pickNotes<T extends ContainsNote>(
135
+ noteDatas: T[],
136
+ { selects = [], sorts = [], limit = 0, offset = 0 }: GetOptions,
137
+ ): T[] {
138
+ return selectNotes(noteDatas, selects)
139
+ .sort((a, b) => sortNotes(a.note.items, b.note.items, sorts))
140
+ .slice(offset, limit ? offset + limit : undefined);
141
+ }