@aztec/pxe 0.0.0-test.1 → 0.0.1-commit.023c3e5

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 +356 -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 +209 -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 +376 -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 +23 -0
  80. package/dest/contract_sync/index.d.ts.map +1 -0
  81. package/dest/contract_sync/index.js +54 -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 +125 -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 +630 -0
  262. package/src/contract_function_simulator/oracle/private_execution.ts +141 -0
  263. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +699 -0
  264. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +554 -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 +98 -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 +1070 -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,252 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
4
+
5
+ import type { NoteData } from './oracle/interfaces.js';
6
+
7
+ interface PendingNote {
8
+ note: NoteData;
9
+ counter: number;
10
+ noteHashForConsumption: Fr;
11
+ }
12
+
13
+ /**
14
+ * Data that's accessible by all the function calls in an execution.
15
+ */
16
+ export class ExecutionNoteCache {
17
+ /**
18
+ * New notes created in this transaction.
19
+ * They are pushed to this array in the same order as they are emitted.
20
+ */
21
+ private notes: PendingNote[] = [];
22
+ /**
23
+ * This mapping maps from a contract address to the notes in the contract.
24
+ */
25
+ private noteMap: Map<bigint, PendingNote[]> = new Map();
26
+
27
+ /**
28
+ * This maps from a contract address to the nullifiers emitted from the contract.
29
+ * The note which is nullified might be new or not (i.e., was generated in a previous transaction).
30
+ * Note that their value (bigint representation) is used because Frs cannot be looked up in Sets.
31
+ */
32
+ private nullifierMap: Map<bigint, Set<bigint>> = new Map();
33
+
34
+ /**
35
+ * Nullifiers emitted by private calls in this transaction.
36
+ */
37
+ private emittedNullifiers: Set<bigint> = new Set();
38
+
39
+ /**
40
+ * The counter that separates non-revertible side effects (which persist even if the tx reverts) from revertible ones.
41
+ */
42
+ private minRevertibleSideEffectCounter = 0;
43
+
44
+ private inRevertiblePhase = false;
45
+
46
+ /**
47
+ * Whether the protocol nullifier was used for nonce generation.
48
+ * We don't need to use the protocol nullifier if a non-revertible nullifier is emitted.
49
+ */
50
+ private usedProtocolNullifierForNonces: boolean | undefined;
51
+
52
+ constructor(private readonly protocolNullifier: Fr) {}
53
+
54
+ /**
55
+ * Enters the revertible phase of the transaction.
56
+ * @param minRevertibleSideEffectCounter - The counter at which the transaction enters the revertible phase.
57
+ */
58
+ public async setMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: number) {
59
+ if (this.inRevertiblePhase) {
60
+ throw new Error(
61
+ `Cannot enter the revertible phase twice. Current counter: ${minRevertibleSideEffectCounter}. Previous enter counter: ${this.minRevertibleSideEffectCounter}`,
62
+ );
63
+ }
64
+ this.inRevertiblePhase = true;
65
+ this.minRevertibleSideEffectCounter = minRevertibleSideEffectCounter;
66
+
67
+ const nullifiers = this.getEmittedNullifiers();
68
+ // If there are no nullifiers emitted by private calls so far, we use the protocol nullifier as the nonce generator.
69
+ // Note: There could still be nullifiers emitted after the counter is set, but those nullifiers are revertible, so
70
+ // we don't want to use them as the nonce generator.
71
+ this.usedProtocolNullifierForNonces = nullifiers.length === 0;
72
+ const nonceGenerator = this.usedProtocolNullifierForNonces ? this.protocolNullifier : new Fr(nullifiers[0]);
73
+
74
+ // The existing pending notes are all non-revertible.
75
+ // They cannot be squashed by nullifiers emitted after minRevertibleSideEffectCounter is set.
76
+ // Their indexes in the tx are known at this point and won't change. So we can assign a nonce to each one of them.
77
+ // The nonces will be used to create the "unique" note hashes.
78
+ const updatedNotes = await Promise.all(
79
+ this.notes.map(async ({ note, counter }, i) => {
80
+ const noteNonce = await computeNoteHashNonce(nonceGenerator, i);
81
+ const uniqueNoteHash = await computeUniqueNoteHash(
82
+ noteNonce,
83
+ await siloNoteHash(note.contractAddress, note.noteHash),
84
+ );
85
+ return {
86
+ counter,
87
+ note: { ...note, noteNonce },
88
+ noteHashForConsumption: uniqueNoteHash,
89
+ };
90
+ }),
91
+ );
92
+ // Rebuild the data.
93
+ this.notes = [];
94
+ this.noteMap = new Map();
95
+ updatedNotes.forEach(n => this.#addNote(n));
96
+ }
97
+
98
+ public isSideEffectCounterRevertible(sideEffectCounter: number): boolean {
99
+ if (!this.inRevertiblePhase) {
100
+ return false;
101
+ }
102
+ return sideEffectCounter >= this.minRevertibleSideEffectCounter;
103
+ }
104
+
105
+ public finish() {
106
+ // If we never entered the revertible phase, and there are no nullifiers emitted, we need to use the protocol
107
+ // nullifier as the nonce generator.
108
+ if (!this.inRevertiblePhase) {
109
+ this.usedProtocolNullifierForNonces = this.getEmittedNullifiers().length === 0;
110
+ }
111
+ }
112
+
113
+ /**
114
+ * Add a new note to cache.
115
+ * @param note - New note created during execution.
116
+ */
117
+ public addNewNote(note: NoteData, counter: number) {
118
+ const previousNote = this.notes[this.notes.length - 1];
119
+ if (previousNote && previousNote.counter >= counter) {
120
+ throw new Error(
121
+ `Note hash counters must be strictly increasing. Current counter: ${counter}. Previous counter: ${previousNote.counter}.`,
122
+ );
123
+ }
124
+
125
+ this.#addNote({ note, counter, noteHashForConsumption: note.noteHash });
126
+ }
127
+
128
+ /**
129
+ * Add a nullifier to cache. It could be for a db note or a new note created during execution.
130
+ * @param contractAddress - Contract address of the note.
131
+ * @param innerNullifier - Inner nullifier of the note.
132
+ * @param noteHash - A hash of the note. If this value equals 0, it means the note being nullified is from a previous
133
+ * transaction (and thus not a new note).
134
+ */
135
+ public async nullifyNote(contractAddress: AztecAddress, innerNullifier: Fr, noteHash: Fr) {
136
+ const siloedNullifier = (await siloNullifier(contractAddress, innerNullifier)).toBigInt();
137
+ let nullifiedNoteHashCounter: number | undefined = undefined;
138
+ // Find and remove the matching new note and log(s) if the emitted noteHash is not empty.
139
+ if (!noteHash.isEmpty()) {
140
+ const notesInContract = this.noteMap.get(contractAddress.toBigInt()) ?? [];
141
+ const noteIndexToRemove = notesInContract.findIndex(n => n.noteHashForConsumption.equals(noteHash));
142
+ if (noteIndexToRemove === -1) {
143
+ throw new Error('Attempt to remove a pending note that does not exist.');
144
+ }
145
+
146
+ const note = notesInContract.splice(noteIndexToRemove, 1)[0];
147
+ nullifiedNoteHashCounter = note.counter;
148
+ this.noteMap.set(contractAddress.toBigInt(), notesInContract);
149
+ this.notes = this.notes.filter(n => n.counter !== note.counter);
150
+
151
+ // If the note is non revertible and the nullifier was emitted in the revertible phase, both the note hash and the nullifier will be emitted
152
+ if (this.inRevertiblePhase && note.counter < this.minRevertibleSideEffectCounter) {
153
+ this.#recordNullifier(contractAddress, siloedNullifier);
154
+ }
155
+ } else {
156
+ // If the note being nullified comes from a previous tx the nullifier will be emitted.
157
+ this.#recordNullifier(contractAddress, siloedNullifier);
158
+ }
159
+ return nullifiedNoteHashCounter;
160
+ }
161
+
162
+ /**
163
+ * Adds a nullifier to the cache. Note cache needs to track all nullifiers to decide which nullifier to use for note siloing.
164
+ * @param contractAddress - Contract address that emitted the nullifier.
165
+ * @param innerNullifier
166
+ */
167
+ public async nullifierCreated(contractAddress: AztecAddress, innerNullifier: Fr) {
168
+ const siloedNullifier = (await siloNullifier(contractAddress, innerNullifier)).toBigInt();
169
+ this.#recordNullifier(contractAddress, siloedNullifier);
170
+ }
171
+
172
+ /**
173
+ * Return notes created up to current point in execution.
174
+ * If a nullifier for a note in this list is emitted, the note will be deleted.
175
+ * @param contractAddress - Contract address of the notes.
176
+ * @param owner - Owner of the notes. If undefined, returns all notes regardless of owner.
177
+ * @param storageSlot - Storage slot of the notes.
178
+ **/
179
+ public getNotes(contractAddress: AztecAddress, owner: AztecAddress | undefined, storageSlot: Fr) {
180
+ const notes = this.noteMap.get(contractAddress.toBigInt()) ?? [];
181
+ return notes
182
+ .filter(n => owner === undefined || n.note.owner.equals(owner))
183
+ .filter(n => n.note.storageSlot.equals(storageSlot))
184
+ .map(n => n.note);
185
+ }
186
+
187
+ /**
188
+ * Check if a note exists in the newNotes array.
189
+ * @param contractAddress - Contract address of the note.
190
+ * @param storageSlot - Storage slot of the note.
191
+ * @param noteHash - A hash of the note.
192
+ **/
193
+ public checkNoteExists(contractAddress: AztecAddress, noteHash: Fr) {
194
+ const notes = this.noteMap.get(contractAddress.toBigInt()) ?? [];
195
+ return notes.some(n => n.note.noteHash.equals(noteHash));
196
+ }
197
+
198
+ /**
199
+ * Return all nullifiers emitted from a contract.
200
+ * @param contractAddress - Address of the contract.
201
+ */
202
+ public getNullifiers(contractAddress: AztecAddress): Set<bigint> {
203
+ return this.nullifierMap.get(contractAddress.toBigInt()) ?? new Set();
204
+ }
205
+
206
+ #addNote(note: PendingNote) {
207
+ this.notes.push(note);
208
+
209
+ const notes = this.noteMap.get(note.note.contractAddress.toBigInt()) ?? [];
210
+ notes.push(note);
211
+ this.noteMap.set(note.note.contractAddress.toBigInt(), notes);
212
+ }
213
+
214
+ getAllNotes(): PendingNote[] {
215
+ return this.notes;
216
+ }
217
+
218
+ /**
219
+ * @returns All nullifiers emitted by private calls in this transaction.
220
+ */
221
+ getEmittedNullifiers(): Fr[] {
222
+ return [...this.emittedNullifiers].map(n => new Fr(n));
223
+ }
224
+
225
+ /**
226
+ * @returns All nullifiers emitted by private calls in this transaction. If the protocol nullifier was used as the
227
+ * nonce generator, it is injected as the first nullifier.
228
+ */
229
+ getAllNullifiers(): Fr[] {
230
+ if (this.usedProtocolNullifierForNonces === undefined) {
231
+ throw new Error('usedProtocolNullifierForNonces is not set yet. Call finish() to complete the transaction.');
232
+ }
233
+ const allNullifiers = this.getEmittedNullifiers();
234
+ return [...(this.usedProtocolNullifierForNonces ? [this.protocolNullifier] : []), ...allNullifiers];
235
+ }
236
+
237
+ getNonceGenerator(): Fr {
238
+ return this.getAllNullifiers()[0];
239
+ }
240
+
241
+ #recordNullifier(contractAddress: AztecAddress, siloedNullifier: bigint) {
242
+ const nullifiers = this.getNullifiers(contractAddress);
243
+
244
+ if (nullifiers.has(siloedNullifier)) {
245
+ throw new Error(`Duplicate siloed nullifier ${siloedNullifier} emitted by contract ${contractAddress}`);
246
+ }
247
+
248
+ nullifiers.add(siloedNullifier);
249
+ this.nullifierMap.set(contractAddress.toBigInt(), nullifiers);
250
+ this.emittedNullifiers.add(siloedNullifier);
251
+ }
252
+ }
@@ -0,0 +1,32 @@
1
+ import { DirectionalAppTaggingSecret, type PreTag } from '@aztec/stdlib/logs';
2
+
3
+ /**
4
+ * A map that stores the tagging index for a given directional app tagging secret.
5
+ * Note: The directional app tagging secret is unique for a (sender, recipient, contract) tuple while the direction
6
+ * of sender -> recipient matters.
7
+ */
8
+ export class ExecutionTaggingIndexCache {
9
+ private taggingIndexMap: Map<string, number> = new Map();
10
+
11
+ public getLastUsedIndex(secret: DirectionalAppTaggingSecret): number | undefined {
12
+ return this.taggingIndexMap.get(secret.toString());
13
+ }
14
+
15
+ public setLastUsedIndex(secret: DirectionalAppTaggingSecret, index: number) {
16
+ const currentValue = this.taggingIndexMap.get(secret.toString());
17
+ if (currentValue !== undefined && currentValue !== index - 1) {
18
+ throw new Error(`Invalid tagging index update. Current value: ${currentValue}, new value: ${index}`);
19
+ }
20
+ this.taggingIndexMap.set(secret.toString(), index);
21
+ }
22
+
23
+ /**
24
+ * Returns the pre-tags that were used in this execution (and that need to be stored in the db).
25
+ */
26
+ public getUsedPreTags(): PreTag[] {
27
+ return Array.from(this.taggingIndexMap.entries()).map(([secret, index]) => ({
28
+ secret: DirectionalAppTaggingSecret.fromString(secret),
29
+ index,
30
+ }));
31
+ }
32
+ }
@@ -0,0 +1,47 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { HashedValues } from '@aztec/stdlib/tx';
3
+
4
+ /**
5
+ * A cache for hashed values (arguments, returns) during transaction execution.
6
+ */
7
+ export class HashedValuesCache {
8
+ private cache: Map<bigint, Fr[]>;
9
+
10
+ constructor(initialArguments: HashedValues[] = []) {
11
+ this.cache = new Map();
12
+ for (const initialArg of initialArguments) {
13
+ this.cache.set(initialArg.hash.toBigInt(), initialArg.values);
14
+ }
15
+ }
16
+
17
+ /**
18
+ * Creates a new hashed values cache.
19
+ * @param initialArguments - The initial arguments to add to the cache.
20
+ * @returns The new hashed values cache.
21
+ */
22
+ public static create(initialArguments: HashedValues[] = []) {
23
+ return new HashedValuesCache(initialArguments);
24
+ }
25
+
26
+ /**
27
+ * Gets preimage of a hash.
28
+ * @param hash - The hash to get the preimage of.
29
+ * @returns The preimage.
30
+ */
31
+ public getPreimage(hash: Fr): Fr[] | undefined {
32
+ if (hash.isEmpty()) {
33
+ return [];
34
+ } else {
35
+ return this.cache.get(hash.toBigInt());
36
+ }
37
+ }
38
+
39
+ /**
40
+ * Stores values in cache and returns its hash.
41
+ * @param values - The values to store.
42
+ * @returns The hash of the values.
43
+ */
44
+ public store(values: Fr[], hash: Fr) {
45
+ this.cache.set(hash.toBigInt(), values);
46
+ }
47
+ }
@@ -0,0 +1,13 @@
1
+ export { ExecutionNoteCache } from './execution_note_cache.js';
2
+ export { ExecutionTaggingIndexCache } from './execution_tagging_index_cache.js';
3
+ export { HashedValuesCache } from './hashed_values_cache.js';
4
+ export { pickNotes } from './pick_notes.js';
5
+ export type { NoteData, IMiscOracle, IUtilityExecutionOracle, IPrivateExecutionOracle } from './oracle/interfaces.js';
6
+ export { MessageLoadOracleInputs } from './oracle/message_load_oracle_inputs.js';
7
+ export { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
8
+ export { PrivateExecutionOracle } from './oracle/private_execution_oracle.js';
9
+ export { Oracle } from './oracle/oracle.js';
10
+ export { executePrivateFunction, extractPrivateCircuitPublicInputs } from './oracle/private_execution.js';
11
+ export { generateSimulatedProvingResult } from './contract_function_simulator.js';
12
+ export { packAsHintedNote } from './oracle/note_packing_utils.js';
13
+ export { UtilityContext } from './noir-structs/utility_context.js';
@@ -0,0 +1,51 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { FieldReader } from '@aztec/foundation/serialize';
3
+ import { EventSelector } from '@aztec/stdlib/abi';
4
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
+ import { TxHash } from '@aztec/stdlib/tx';
6
+
7
+ // TODO(#14617): should we compute this from constants? This value is aztec-nr specific.
8
+ const MAX_EVENT_SERIALIZED_LEN = 12;
9
+
10
+ /**
11
+ * Intermediate struct used to perform batch event validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
12
+ * expects for values of this type to be stored in a `CapsuleArray`.
13
+ */
14
+ export class EventValidationRequest {
15
+ constructor(
16
+ public contractAddress: AztecAddress,
17
+ public eventTypeId: EventSelector,
18
+ public randomness: Fr,
19
+ public serializedEvent: Fr[],
20
+ public eventCommitment: Fr,
21
+ public txHash: TxHash,
22
+ public recipient: AztecAddress,
23
+ ) {}
24
+
25
+ static fromFields(fields: Fr[] | FieldReader): EventValidationRequest {
26
+ const reader = FieldReader.asReader(fields);
27
+
28
+ const contractAddress = AztecAddress.fromField(reader.readField());
29
+ const eventTypeId = EventSelector.fromField(reader.readField());
30
+
31
+ const randomness = reader.readField();
32
+
33
+ const eventStorage = reader.readFieldArray(MAX_EVENT_SERIALIZED_LEN);
34
+ const eventLen = reader.readField().toNumber();
35
+ const serializedEvent = eventStorage.slice(0, eventLen);
36
+
37
+ const eventCommitment = reader.readField();
38
+ const txHash = TxHash.fromField(reader.readField());
39
+ const recipient = AztecAddress.fromField(reader.readField());
40
+
41
+ return new EventValidationRequest(
42
+ contractAddress,
43
+ eventTypeId,
44
+ randomness,
45
+ serializedEvent,
46
+ eventCommitment,
47
+ txHash,
48
+ recipient,
49
+ );
50
+ }
51
+ }
@@ -0,0 +1,28 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { FieldReader } from '@aztec/foundation/serialize';
3
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
+ import { Tag } from '@aztec/stdlib/logs';
5
+
6
+ /**
7
+ * Intermediate struct used to perform batch log retrieval by PXE. The `utilityBulkRetrieveLogs` oracle expects values of this
8
+ * type to be stored in a `CapsuleArray`.
9
+ */
10
+ export class LogRetrievalRequest {
11
+ constructor(
12
+ public contractAddress: AztecAddress,
13
+ public tag: Tag,
14
+ ) {}
15
+
16
+ toFields(): Fr[] {
17
+ return [this.contractAddress.toField(), this.tag.value];
18
+ }
19
+
20
+ static fromFields(fields: Fr[] | FieldReader): LogRetrievalRequest {
21
+ const reader = FieldReader.asReader(fields);
22
+
23
+ const contractAddress = AztecAddress.fromField(reader.readField());
24
+ const tag = new Tag(reader.readField());
25
+
26
+ return new LogRetrievalRequest(contractAddress, tag);
27
+ }
28
+ }
@@ -0,0 +1,69 @@
1
+ import { MAX_NOTE_HASHES_PER_TX, PRIVATE_LOG_CIPHERTEXT_LEN } from '@aztec/constants';
2
+ import { range } from '@aztec/foundation/array';
3
+ import { Fr } from '@aztec/foundation/curves/bn254';
4
+ import type { TxHash } from '@aztec/stdlib/tx';
5
+
6
+ import { MAX_NOTE_PACKED_LEN } from './note_validation_request.js';
7
+
8
+ const MAX_PUBLIC_LOG_LEN_FOR_NOTE_COMPLETION = MAX_NOTE_PACKED_LEN;
9
+ const MAX_LOG_CONTENT_LEN = Math.max(MAX_PUBLIC_LOG_LEN_FOR_NOTE_COMPLETION, PRIVATE_LOG_CIPHERTEXT_LEN);
10
+
11
+ /**
12
+ * Intermediate struct used to perform batch log retrieval by PXE. The `utilityBulkRetrieveLogs` oracle stores values of this
13
+ * type in a `CapsuleArray`.
14
+ */
15
+ export class LogRetrievalResponse {
16
+ constructor(
17
+ public logPayload: Fr[],
18
+ public txHash: TxHash,
19
+ public uniqueNoteHashesInTx: Fr[],
20
+ public firstNullifierInTx: Fr,
21
+ ) {}
22
+
23
+ toFields(): Fr[] {
24
+ return [
25
+ // We need to trim the payload since public logs can be larger than MAX_LOG_CONTENT_LEN.
26
+ // This is currently not a problem since this class is only used with public logs for note completion.
27
+ ...serializeBoundedVec(this.logPayload.slice(0, MAX_LOG_CONTENT_LEN), MAX_LOG_CONTENT_LEN),
28
+ this.txHash.hash,
29
+ ...serializeBoundedVec(this.uniqueNoteHashesInTx, MAX_NOTE_HASHES_PER_TX),
30
+ this.firstNullifierInTx,
31
+ ];
32
+ }
33
+
34
+ static toEmptyFields(): Fr[] {
35
+ const serializationLen =
36
+ MAX_LOG_CONTENT_LEN +
37
+ 1 /* logPayload BVec */ +
38
+ 1 /* txHash */ +
39
+ MAX_NOTE_HASHES_PER_TX +
40
+ 1 /* uniqueNoteHashesInTx BVec */ +
41
+ 1; /* firstNullifierInTx */
42
+ return range(serializationLen).map(_ => Fr.zero());
43
+ }
44
+
45
+ static toSerializedOption(response: LogRetrievalResponse | null): Fr[] {
46
+ if (response) {
47
+ return [new Fr(1), ...response.toFields()];
48
+ } else {
49
+ return [new Fr(0), ...LogRetrievalResponse.toEmptyFields()];
50
+ }
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Helper function to serialize a bounded vector according to Noir's BoundedVec format
56
+ * @param values - The values to serialize
57
+ * @param maxLength - The maximum length of the bounded vector
58
+ * @returns The serialized bounded vector as Fr[]
59
+ */
60
+ function serializeBoundedVec(values: Fr[], maxLength: number): Fr[] {
61
+ if (values.length > maxLength) {
62
+ throw new Error(`Attempted to serialize ${values} values into a BoundedVec with max length ${maxLength}`);
63
+ }
64
+
65
+ const lengthDiff = maxLength - values.length;
66
+ const zeroPaddingArray = Array(lengthDiff).fill(Fr.ZERO);
67
+ const storage = values.concat(zeroPaddingArray);
68
+ return [...storage, new Fr(values.length)];
69
+ }
@@ -0,0 +1,64 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { FieldReader } from '@aztec/foundation/serialize';
3
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
+ import { TxHash } from '@aztec/stdlib/tx';
5
+
6
+ // TODO(#14617): should we compute this from constants? This value is aztec-nr specific.
7
+ export const MAX_NOTE_PACKED_LEN = 10;
8
+
9
+ /**
10
+ * Intermediate struct used to perform batch note validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
11
+ * expects for values of this type to be stored in a `CapsuleArray`.
12
+ */
13
+ export class NoteValidationRequest {
14
+ constructor(
15
+ public contractAddress: AztecAddress,
16
+ public owner: AztecAddress,
17
+ public storageSlot: Fr,
18
+ public randomness: Fr,
19
+ public noteNonce: Fr,
20
+ public content: Fr[],
21
+ public noteHash: Fr,
22
+ public nullifier: Fr,
23
+ public txHash: TxHash,
24
+ public recipient: AztecAddress,
25
+ ) {}
26
+
27
+ static fromFields(fields: Fr[] | FieldReader): NoteValidationRequest {
28
+ const reader = FieldReader.asReader(fields);
29
+
30
+ const contractAddress = AztecAddress.fromField(reader.readField());
31
+ const owner = AztecAddress.fromField(reader.readField());
32
+ const storageSlot = reader.readField();
33
+ const randomness = reader.readField();
34
+ const noteNonce = reader.readField();
35
+
36
+ const contentStorage = reader.readFieldArray(MAX_NOTE_PACKED_LEN);
37
+ const contentLen = reader.readField().toNumber();
38
+ const content = contentStorage.slice(0, contentLen);
39
+
40
+ const noteHash = reader.readField();
41
+ const nullifier = reader.readField();
42
+ const txHash = TxHash.fromField(reader.readField());
43
+ const recipient = AztecAddress.fromField(reader.readField());
44
+
45
+ if (reader.remainingFields() !== 0) {
46
+ throw new Error(
47
+ `Error converting array of fields to NoteValidationRequest. Hint: check that MAX_NOTE_PACKED_LEN is consistent with private_notes::MAX_NOTE_PACKED_LEN in Aztec-nr.`,
48
+ );
49
+ }
50
+
51
+ return new NoteValidationRequest(
52
+ contractAddress,
53
+ owner,
54
+ storageSlot,
55
+ randomness,
56
+ noteNonce,
57
+ content,
58
+ noteHash,
59
+ nullifier,
60
+ txHash,
61
+ recipient,
62
+ );
63
+ }
64
+ }
@@ -0,0 +1,23 @@
1
+ import { toACVMField } from '@aztec/simulator/client';
2
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import type { BlockHeader } from '@aztec/stdlib/tx';
4
+
5
+ /**
6
+ * TypeScript counterpart of utility_context.nr. Used only as a return value for the utilityGetUtilityContext oracle.
7
+ */
8
+ export class UtilityContext {
9
+ constructor(
10
+ public readonly blockHeader: BlockHeader,
11
+ public readonly contractAddress: AztecAddress,
12
+ ) {}
13
+
14
+ /**
15
+ * Returns a representation of the utility context as expected by intrinsic Noir deserialization.
16
+ * The order of the fields has to be the same as the order of the fields in the utility_context.nr.
17
+ */
18
+ public toNoirRepresentation(): (string | string[])[] {
19
+ // TODO(#12874): remove the stupid as string conversion by modifying ForeignCallOutput type in acvm.js
20
+ const blockHeaderFields = this.blockHeader.toFields().map(toACVMField);
21
+ return [...blockHeaderFields, this.contractAddress.toString() as string];
22
+ }
23
+ }
@@ -0,0 +1,16 @@
1
+ import type { Oracle } from './oracle.js';
2
+
3
+ export * from './oracle.js';
4
+ export * from './interfaces.js';
5
+
6
+ /**
7
+ * A conditional type that takes a type `T` and returns a union of its method names.
8
+ */
9
+ type MethodNames<T> = {
10
+ [K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
11
+ }[keyof T];
12
+
13
+ /**
14
+ * Available oracle function names.
15
+ */
16
+ export type ORACLE_NAMES = MethodNames<Oracle>;