@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,77 @@
1
+ import { Timer } from '@aztec/foundation/timer';
2
+ export class BenchmarkedNodeFactory {
3
+ static create(node) {
4
+ // Per-method call stats
5
+ const perMethod = {};
6
+ // Round trip tracking
7
+ let inFlightCount = 0;
8
+ let currentRoundTripTimer = null;
9
+ let currentRoundTripMethods = [];
10
+ const roundTrips = {
11
+ roundTrips: 0,
12
+ totalBlockingTime: 0,
13
+ roundTripDurations: [],
14
+ roundTripMethods: []
15
+ };
16
+ return new Proxy(node, {
17
+ get (target, prop) {
18
+ if (prop === 'getStats') {
19
+ return ()=>{
20
+ return {
21
+ perMethod,
22
+ roundTrips
23
+ };
24
+ };
25
+ } else {
26
+ return function(...args) {
27
+ // Track per-method stats
28
+ if (!perMethod[prop]) {
29
+ perMethod[prop] = {
30
+ times: []
31
+ };
32
+ }
33
+ // Start of a new round trip batch?
34
+ if (inFlightCount === 0) {
35
+ roundTrips.roundTrips++;
36
+ currentRoundTripTimer = new Timer();
37
+ currentRoundTripMethods = [];
38
+ }
39
+ inFlightCount++;
40
+ currentRoundTripMethods.push(prop);
41
+ const callTimer = new Timer();
42
+ const result = target[prop].apply(target, args);
43
+ // Handle completion - called when the call finishes (after Promise resolves)
44
+ const handleCompletion = ()=>{
45
+ const callTime = callTimer.ms();
46
+ perMethod[prop].times.push(callTime);
47
+ inFlightCount--;
48
+ // End of round trip batch - all concurrent calls completed
49
+ if (inFlightCount === 0 && currentRoundTripTimer) {
50
+ const roundTripTime = currentRoundTripTimer.ms();
51
+ roundTrips.totalBlockingTime += roundTripTime;
52
+ roundTrips.roundTripDurations.push(roundTripTime);
53
+ roundTrips.roundTripMethods.push(currentRoundTripMethods);
54
+ currentRoundTripTimer = null;
55
+ currentRoundTripMethods = [];
56
+ }
57
+ };
58
+ // If the result is a Promise, chain the completion handler
59
+ if (result && typeof result.then === 'function') {
60
+ return result.then((value)=>{
61
+ handleCompletion();
62
+ return value;
63
+ }, (error)=>{
64
+ handleCompletion();
65
+ throw error;
66
+ });
67
+ } else {
68
+ // Synchronous method - handle completion immediately
69
+ handleCompletion();
70
+ return result;
71
+ }
72
+ };
73
+ }
74
+ }
75
+ });
76
+ }
77
+ }
@@ -0,0 +1,82 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import type { KeyStore } from '@aztec/key-store';
3
+ import { type CircuitSimulator } from '@aztec/simulator/client';
4
+ import type { FunctionCall } from '@aztec/stdlib/abi';
5
+ import { FunctionSelector } from '@aztec/stdlib/abi';
6
+ import type { AuthWitness } from '@aztec/stdlib/auth-witness';
7
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
8
+ import type { AztecNode } from '@aztec/stdlib/interfaces/server';
9
+ import { type PrivateKernelExecutionProofOutput, PrivateKernelTailCircuitPublicInputs } from '@aztec/stdlib/kernel';
10
+ import { BlockHeader, PrivateExecutionResult, TxExecutionRequest } from '@aztec/stdlib/tx';
11
+ import type { AddressStore } from '../storage/address_store/address_store.js';
12
+ import type { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
13
+ import type { ContractStore } from '../storage/contract_store/contract_store.js';
14
+ import type { NoteStore } from '../storage/note_store/note_store.js';
15
+ import type { PrivateEventStore } from '../storage/private_event_store/private_event_store.js';
16
+ import type { RecipientTaggingStore } from '../storage/tagging_store/recipient_tagging_store.js';
17
+ import type { SenderAddressBookStore } from '../storage/tagging_store/sender_address_book_store.js';
18
+ import type { SenderTaggingStore } from '../storage/tagging_store/sender_tagging_store.js';
19
+ /**
20
+ * The contract function simulator.
21
+ */
22
+ export declare class ContractFunctionSimulator {
23
+ private contractStore;
24
+ private noteStore;
25
+ private keyStore;
26
+ private addressStore;
27
+ private aztecNode;
28
+ private senderTaggingStore;
29
+ private recipientTaggingStore;
30
+ private senderAddressBookStore;
31
+ private capsuleStore;
32
+ private privateEventStore;
33
+ private simulator;
34
+ private log;
35
+ constructor(contractStore: ContractStore, noteStore: NoteStore, keyStore: KeyStore, addressStore: AddressStore, aztecNode: AztecNode, senderTaggingStore: SenderTaggingStore, recipientTaggingStore: RecipientTaggingStore, senderAddressBookStore: SenderAddressBookStore, capsuleStore: CapsuleStore, privateEventStore: PrivateEventStore, simulator: CircuitSimulator);
36
+ /**
37
+ * Runs a private function.
38
+ * @param request - The transaction request.
39
+ * @param entryPointArtifact - The artifact of the entry point function.
40
+ * @param contractAddress - The address of the contract (should match request.origin)
41
+ * @param msgSender - The address calling the function. This can be replaced to simulate a call from another contract
42
+ * or a specific account.
43
+ * @param anchorBlockHeader - The block header to use as base state for this run.
44
+ * @param senderForTags - The address that is used as a tagging sender when emitting private logs. Returned from
45
+ * the `privateGetSenderForTags` oracle.
46
+ * @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
47
+ * @param jobId - The job ID for staged writes.
48
+ * @returns The result of the execution.
49
+ */
50
+ run(request: TxExecutionRequest, contractAddress: AztecAddress, selector: FunctionSelector, msgSender: AztecAddress | undefined, anchorBlockHeader: BlockHeader, senderForTags: AztecAddress | undefined, scopes: AztecAddress[] | undefined, jobId: string): Promise<PrivateExecutionResult>;
51
+ /**
52
+ * Runs a utility function.
53
+ * @param call - The function call to execute.
54
+ * @param authwits - Authentication witnesses required for the function call.
55
+ * @param anchorBlockHeader - The block header to use as base state for this run.
56
+ * @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
57
+ * accounts if not specified.
58
+ * @returns A return value of the utility function in a form as returned by the simulator (Noir fields)
59
+ */
60
+ runUtility(call: FunctionCall, authwits: AuthWitness[], anchorBlockHeader: BlockHeader, scopes: AztecAddress[] | undefined, jobId: string): Promise<Fr[]>;
61
+ /**
62
+ * Returns the execution statistics collected during the simulator run.
63
+ * @returns The execution statistics.
64
+ */
65
+ getStats(): {
66
+ nodeRPCCalls: import("@aztec/stdlib/tx").NodeStats;
67
+ };
68
+ }
69
+ /**
70
+ * Generates the final public inputs of the tail kernel circuit, an empty Chonk proof
71
+ * and the execution steps for a `PrivateExecutionResult` as if it had been
72
+ * processed by the private kernel prover. This skips many of the checks performed by the kernels
73
+ * (allowing state overrides) and is much faster, while still generating a valid
74
+ * output that can be sent to the node for public simulation
75
+ * @param privateExecutionResult - The result of the private execution.
76
+ * @param contractStore - A provider for contract data in order to get function names and debug info.
77
+ * @param minRevertibleSideEffectCounterOverride - Optional override for the min revertible side effect counter.
78
+ * Used by TXE to simulate account contract behavior (setting the counter before app execution).
79
+ * @returns The simulated proving result.
80
+ */
81
+ export declare function generateSimulatedProvingResult(privateExecutionResult: PrivateExecutionResult, contractStore: ContractStore, minRevertibleSideEffectCounterOverride?: number): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>>;
82
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3RfZnVuY3Rpb25fc2ltdWxhdG9yLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3RfZnVuY3Rpb25fc2ltdWxhdG9yL2NvbnRyYWN0X2Z1bmN0aW9uX3NpbXVsYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFxQkEsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUF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zlCLGFBQWEsRUFBRSxZQUFZLEdBQUcsU0FBUyxFQUN2QyxNQUFNLEVBQUUsWUFBWSxFQUFFLEdBQUcsU0FBUyxFQUNsQyxLQUFLLEVBQUUsTUFBTSxHQUNaLE9BQU8sQ0FBQyxzQkFBc0IsQ0FBQyxDQTJHakM7SUFHRDs7Ozs7Ozs7T0FRRztJQUNVLFVBQVUsQ0FDckIsSUFBSSxFQUFFLFlBQVksRUFDbEIsUUFBUSxFQUFFLFdBQVcsRUFBRSxFQUN2QixpQkFBaUIsRUFBRSxXQUFXLEVBQzlCLE1BQU0sRUFBRSxZQUFZLEVBQUUsR0FBRyxTQUFTLEVBQ2xDLEtBQUssRUFBRSxNQUFNLEdBQ1osT0FBTyxDQUFDLEVBQUUsRUFBRSxDQUFDLENBcURmO0lBR0Q7OztPQUdHO0lBQ0gsUUFBUTs7TUFVUDtDQUNGO0FBWUQ7Ozs7Ozs7Ozs7O0dBV0c7QUFDSCx3QkFBc0IsOEJBQThCLENBQ2xELHNCQUFzQixFQUFFLHNCQUFzQixFQUM5QyxhQUFhLEVBQUUsYUFBYSxFQUM1QixzQ0FBc0MsQ0FBQyxFQUFFLE1BQU0sR0FDOUMsT0FBTyxDQUFDLGlDQUFpQyxDQUFDLG9DQUFvQyxDQUFDLENBQUMsQ0EyTmxGIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract_function_simulator.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/contract_function_simulator.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAGpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EACL,KAAK,gBAAgB,EAOtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAgB,MAAM,mBAAmB,CAAC;AACnE,OAAO,KAAK,EAA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VATE_LOG, MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_ENQUEUED_CALLS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_PRIVATE_LOGS_PER_TX } from '@aztec/constants';
2
+ import { arrayNonEmptyLength, padArrayEnd } from '@aztec/foundation/collection';
3
+ import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto/poseidon';
4
+ import { Fr } from '@aztec/foundation/curves/bn254';
5
+ import { createLogger } from '@aztec/foundation/log';
6
+ import { Timer } from '@aztec/foundation/timer';
7
+ import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
8
+ import { protocolContractsHash } from '@aztec/protocol-contracts';
9
+ import { ExecutionError, createSimulationError, extractCallStack, resolveAssertionMessageFromError, toACVMWitness, witnessMapToFields } from '@aztec/simulator/client';
10
+ import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
11
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
12
+ import { Gas } from '@aztec/stdlib/gas';
13
+ import { computeNoteHashNonce, computeProtocolNullifier, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
14
+ import { PartialPrivateTailPublicInputsForPublic, PartialPrivateTailPublicInputsForRollup, PrivateKernelTailCircuitPublicInputs, PrivateToPublicAccumulatedData, PrivateToRollupAccumulatedData, PublicCallRequest, ScopedLogHash } from '@aztec/stdlib/kernel';
15
+ import { PrivateLog } from '@aztec/stdlib/logs';
16
+ import { ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
17
+ import { ChonkProof } from '@aztec/stdlib/proofs';
18
+ import { CallContext, HashedValues, PrivateExecutionResult, TxConstantData, collectNested, getFinalMinRevertibleSideEffectCounter } from '@aztec/stdlib/tx';
19
+ import { ExecutionNoteCache } from './execution_note_cache.js';
20
+ import { ExecutionTaggingIndexCache } from './execution_tagging_index_cache.js';
21
+ import { HashedValuesCache } from './hashed_values_cache.js';
22
+ import { Oracle } from './oracle/oracle.js';
23
+ import { executePrivateFunction } from './oracle/private_execution.js';
24
+ import { PrivateExecutionOracle } from './oracle/private_execution_oracle.js';
25
+ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
26
+ /**
27
+ * The contract function simulator.
28
+ */ export class ContractFunctionSimulator {
29
+ contractStore;
30
+ noteStore;
31
+ keyStore;
32
+ addressStore;
33
+ aztecNode;
34
+ senderTaggingStore;
35
+ recipientTaggingStore;
36
+ senderAddressBookStore;
37
+ capsuleStore;
38
+ privateEventStore;
39
+ simulator;
40
+ log;
41
+ constructor(contractStore, noteStore, keyStore, addressStore, aztecNode, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, simulator){
42
+ this.contractStore = contractStore;
43
+ this.noteStore = noteStore;
44
+ this.keyStore = keyStore;
45
+ this.addressStore = addressStore;
46
+ this.aztecNode = aztecNode;
47
+ this.senderTaggingStore = senderTaggingStore;
48
+ this.recipientTaggingStore = recipientTaggingStore;
49
+ this.senderAddressBookStore = senderAddressBookStore;
50
+ this.capsuleStore = capsuleStore;
51
+ this.privateEventStore = privateEventStore;
52
+ this.simulator = simulator;
53
+ this.log = createLogger('simulator');
54
+ }
55
+ /**
56
+ * Runs a private function.
57
+ * @param request - The transaction request.
58
+ * @param entryPointArtifact - The artifact of the entry point function.
59
+ * @param contractAddress - The address of the contract (should match request.origin)
60
+ * @param msgSender - The address calling the function. This can be replaced to simulate a call from another contract
61
+ * or a specific account.
62
+ * @param anchorBlockHeader - The block header to use as base state for this run.
63
+ * @param senderForTags - The address that is used as a tagging sender when emitting private logs. Returned from
64
+ * the `privateGetSenderForTags` oracle.
65
+ * @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
66
+ * @param jobId - The job ID for staged writes.
67
+ * @returns The result of the execution.
68
+ */ async run(request, contractAddress, selector, msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE), anchorBlockHeader, senderForTags, scopes, jobId) {
69
+ const simulatorSetupTimer = new Timer();
70
+ const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(contractAddress, selector);
71
+ if (entryPointArtifact.functionType !== FunctionType.PRIVATE) {
72
+ throw new Error(`Cannot run ${entryPointArtifact.functionType} function as private`);
73
+ }
74
+ if (request.origin !== contractAddress) {
75
+ this.log.warn(`Request origin does not match contract address in simulation. Request origin: ${request.origin}, contract address: ${contractAddress}`);
76
+ }
77
+ // reserve the first side effect for the tx hash (inserted by the private kernel)
78
+ const startSideEffectCounter = 2;
79
+ const callContext = new CallContext(msgSender, contractAddress, await FunctionSelector.fromNameAndParameters(entryPointArtifact.name, entryPointArtifact.parameters), entryPointArtifact.isStatic);
80
+ const protocolNullifier = await computeProtocolNullifier(await request.toTxRequest().hash());
81
+ const noteCache = new ExecutionNoteCache(protocolNullifier);
82
+ const taggingIndexCache = new ExecutionTaggingIndexCache();
83
+ const privateExecutionOracle = new PrivateExecutionOracle(request.firstCallArgsHash, request.txContext, callContext, anchorBlockHeader, async (call)=>{
84
+ await this.runUtility(call, [], anchorBlockHeader, scopes, jobId);
85
+ }, request.authWitnesses, request.capsules, HashedValuesCache.create(request.argsOfCalls), noteCache, taggingIndexCache, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.aztecNode, this.senderTaggingStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, jobId, 0, startSideEffectCounter, undefined, scopes, senderForTags, this.simulator);
86
+ const setupTime = simulatorSetupTimer.ms();
87
+ try {
88
+ // Note: any nested private function calls are made recursively within this
89
+ // function call. So this execution result is the result of executing _all_
90
+ // private functions of this tx (the results of those executions are contained
91
+ // within executionResult.nestedExecutionResults).
92
+ const executionResult = await executePrivateFunction(this.simulator, privateExecutionOracle, entryPointArtifact, contractAddress, request.functionSelector);
93
+ const simulatorTeardownTimer = new Timer();
94
+ noteCache.finish();
95
+ const firstNullifierHint = noteCache.getNonceGenerator();
96
+ const publicCallRequests = collectNested([
97
+ executionResult
98
+ ], (r)=>r.publicInputs.publicCallRequests.getActiveItems().map((r)=>r.inner).concat(r.publicInputs.publicTeardownCallRequest.isEmpty() ? [] : [
99
+ r.publicInputs.publicTeardownCallRequest
100
+ ]));
101
+ const publicFunctionsCalldata = await Promise.all(publicCallRequests.map(async (r)=>{
102
+ const calldata = await privateExecutionOracle.privateLoadFromExecutionCache(r.calldataHash);
103
+ return new HashedValues(calldata, r.calldataHash);
104
+ }));
105
+ const teardownTime = simulatorTeardownTimer.ms();
106
+ // Add simulator overhead to topmost call in the stack
107
+ if (executionResult.profileResult) {
108
+ executionResult.profileResult.timings.witgen += setupTime + teardownTime;
109
+ }
110
+ // Not to be confused with a PrivateCallExecutionResult. This is a superset
111
+ // of the PrivateCallExecutionResult, containing also firstNullifierHint
112
+ // and publicFunctionsCalldata.
113
+ return new PrivateExecutionResult(executionResult, firstNullifierHint, publicFunctionsCalldata);
114
+ } catch (err) {
115
+ throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
116
+ }
117
+ }
118
+ // docs:start:execute_utility_function
119
+ /**
120
+ * Runs a utility function.
121
+ * @param call - The function call to execute.
122
+ * @param authwits - Authentication witnesses required for the function call.
123
+ * @param anchorBlockHeader - The block header to use as base state for this run.
124
+ * @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
125
+ * accounts if not specified.
126
+ * @returns A return value of the utility function in a form as returned by the simulator (Noir fields)
127
+ */ async runUtility(call, authwits, anchorBlockHeader, scopes, jobId) {
128
+ const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
129
+ if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
130
+ throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
131
+ }
132
+ const oracle = new UtilityExecutionOracle(call.to, authwits, [], anchorBlockHeader, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.aztecNode, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, jobId, undefined, scopes);
133
+ try {
134
+ this.log.verbose(`Executing utility function ${entryPointArtifact.name}`, {
135
+ contract: call.to,
136
+ selector: call.selector
137
+ });
138
+ const initialWitness = toACVMWitness(0, call.args);
139
+ const acirExecutionResult = await this.simulator.executeUserCircuit(initialWitness, entryPointArtifact, new Oracle(oracle).toACIRCallback()).catch((err)=>{
140
+ err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
141
+ throw new ExecutionError(err.message, {
142
+ contractAddress: call.to,
143
+ functionSelector: call.selector
144
+ }, extractCallStack(err, entryPointArtifact.debug), {
145
+ cause: err
146
+ });
147
+ });
148
+ this.log.verbose(`Utility simulation for ${call.to}.${call.selector} completed`);
149
+ return witnessMapToFields(acirExecutionResult.returnWitness);
150
+ } catch (err) {
151
+ throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
152
+ }
153
+ }
154
+ // docs:end:execute_utility_function
155
+ /**
156
+ * Returns the execution statistics collected during the simulator run.
157
+ * @returns The execution statistics.
158
+ */ getStats() {
159
+ const nodeRPCCalls = typeof this.aztecNode.getStats === 'function' ? this.aztecNode.getStats() : {
160
+ perMethod: {},
161
+ roundTrips: {
162
+ roundTrips: 0,
163
+ totalBlockingTime: 0,
164
+ roundTripDurations: [],
165
+ roundTripMethods: []
166
+ }
167
+ };
168
+ return {
169
+ nodeRPCCalls
170
+ };
171
+ }
172
+ }
173
+ class OrderedSideEffect {
174
+ sideEffect;
175
+ counter;
176
+ constructor(sideEffect, counter){
177
+ this.sideEffect = sideEffect;
178
+ this.counter = counter;
179
+ }
180
+ }
181
+ /**
182
+ * Generates the final public inputs of the tail kernel circuit, an empty Chonk proof
183
+ * and the execution steps for a `PrivateExecutionResult` as if it had been
184
+ * processed by the private kernel prover. This skips many of the checks performed by the kernels
185
+ * (allowing state overrides) and is much faster, while still generating a valid
186
+ * output that can be sent to the node for public simulation
187
+ * @param privateExecutionResult - The result of the private execution.
188
+ * @param contractStore - A provider for contract data in order to get function names and debug info.
189
+ * @param minRevertibleSideEffectCounterOverride - Optional override for the min revertible side effect counter.
190
+ * Used by TXE to simulate account contract behavior (setting the counter before app execution).
191
+ * @returns The simulated proving result.
192
+ */ export async function generateSimulatedProvingResult(privateExecutionResult, contractStore, minRevertibleSideEffectCounterOverride) {
193
+ const siloedNoteHashes = [];
194
+ const nullifiers = [];
195
+ const taggedPrivateLogs = [];
196
+ const l2ToL1Messages = [];
197
+ const contractClassLogsHashes = [];
198
+ const publicCallRequests = [];
199
+ const executionSteps = [];
200
+ let publicTeardownCallRequest;
201
+ const executions = [
202
+ privateExecutionResult.entrypoint
203
+ ];
204
+ while(executions.length !== 0){
205
+ const execution = executions.shift();
206
+ executions.unshift(...execution.nestedExecutionResults);
207
+ const { contractAddress } = execution.publicInputs.callContext;
208
+ const noteHashesFromExecution = await Promise.all(execution.publicInputs.noteHashes.getActiveItems().filter((noteHash)=>!noteHash.isEmpty()).map(async (noteHash)=>new OrderedSideEffect(await siloNoteHash(contractAddress, noteHash.value), noteHash.counter)));
209
+ const nullifiersFromExecution = await Promise.all(execution.publicInputs.nullifiers.getActiveItems().map(async (nullifier)=>new OrderedSideEffect(await siloNullifier(contractAddress, nullifier.value), nullifier.counter)));
210
+ const privateLogsFromExecution = await Promise.all(execution.publicInputs.privateLogs.getActiveItems().map(async (metadata)=>{
211
+ metadata.log.fields[0] = await poseidon2HashWithSeparator([
212
+ contractAddress,
213
+ metadata.log.fields[0]
214
+ ], GeneratorIndex.PRIVATE_LOG_FIRST_FIELD);
215
+ return new OrderedSideEffect(metadata.log, metadata.counter);
216
+ }));
217
+ siloedNoteHashes.push(...noteHashesFromExecution);
218
+ taggedPrivateLogs.push(...privateLogsFromExecution);
219
+ nullifiers.push(...nullifiersFromExecution);
220
+ l2ToL1Messages.push(...execution.publicInputs.l2ToL1Msgs.getActiveItems().map((message)=>new OrderedSideEffect(message.message.scope(contractAddress), message.counter)));
221
+ contractClassLogsHashes.push(...execution.publicInputs.contractClassLogsHashes.getActiveItems().map((contractClassLogHash)=>new OrderedSideEffect(contractClassLogHash.logHash.scope(contractAddress), contractClassLogHash.counter)));
222
+ publicCallRequests.push(...execution.publicInputs.publicCallRequests.getActiveItems().map((callRequest)=>new OrderedSideEffect(callRequest.inner, callRequest.counter)));
223
+ if (publicTeardownCallRequest !== undefined && !execution.publicInputs.publicTeardownCallRequest.isEmpty()) {
224
+ throw new Error('Trying to set multiple teardown requests');
225
+ }
226
+ publicTeardownCallRequest = execution.publicInputs.publicTeardownCallRequest.isEmpty() ? publicTeardownCallRequest : execution.publicInputs.publicTeardownCallRequest;
227
+ executionSteps.push({
228
+ functionName: await contractStore.getDebugFunctionName(execution.publicInputs.callContext.contractAddress, execution.publicInputs.callContext.functionSelector),
229
+ timings: execution.profileResult?.timings ?? {
230
+ witgen: 0,
231
+ oracles: {}
232
+ },
233
+ bytecode: execution.acir,
234
+ vk: execution.vk,
235
+ witness: execution.partialWitness
236
+ });
237
+ }
238
+ const constantData = new TxConstantData(privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader, privateExecutionResult.entrypoint.publicInputs.txContext, getVKTreeRoot(), protocolContractsHash);
239
+ const hasPublicCalls = privateExecutionResult.publicFunctionCalldata.length !== 0;
240
+ let inputsForRollup;
241
+ let inputsForPublic;
242
+ let gasUsed;
243
+ const sortByCounter = (a, b)=>a.counter - b.counter;
244
+ const getEffect = (orderedSideEffect)=>orderedSideEffect.sideEffect;
245
+ const isPrivateOnlyTx = privateExecutionResult.publicFunctionCalldata.length === 0;
246
+ const minRevertibleSideEffectCounter = minRevertibleSideEffectCounterOverride ?? getFinalMinRevertibleSideEffectCounter(privateExecutionResult);
247
+ const [nonRevertibleNullifiers, revertibleNullifiers] = splitOrderedSideEffects(nullifiers.sort(sortByCounter), minRevertibleSideEffectCounter);
248
+ const nonceGenerator = privateExecutionResult.firstNullifier;
249
+ if (nonRevertibleNullifiers.length === 0) {
250
+ nonRevertibleNullifiers.push(nonceGenerator);
251
+ } else if (!nonRevertibleNullifiers[0].equals(nonceGenerator)) {
252
+ throw new Error('The first non revertible nullifier should be equal to the nonce generator. This is a bug!');
253
+ }
254
+ if (isPrivateOnlyTx) {
255
+ // We must make the note hashes unique by using the
256
+ // nonce generator and their index in the tx.
257
+ const uniqueNoteHashes = await Promise.all(siloedNoteHashes.sort(sortByCounter).map(async (orderedSideEffect, i)=>{
258
+ const siloedNoteHash = orderedSideEffect.sideEffect;
259
+ const nonce = await computeNoteHashNonce(nonceGenerator, i);
260
+ const uniqueNoteHash = await computeUniqueNoteHash(nonce, siloedNoteHash);
261
+ return uniqueNoteHash;
262
+ }));
263
+ const accumulatedDataForRollup = new PrivateToRollupAccumulatedData(padArrayEnd(uniqueNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX), padArrayEnd(nonRevertibleNullifiers.concat(revertibleNullifiers), Fr.ZERO, MAX_NULLIFIERS_PER_TX), padArrayEnd(l2ToL1Messages.sort(sortByCounter).map(getEffect), ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX), padArrayEnd(taggedPrivateLogs.sort(sortByCounter).map(getEffect), PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX), padArrayEnd(contractClassLogsHashes.sort(sortByCounter).map(getEffect), ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX));
264
+ gasUsed = meterGasUsed(accumulatedDataForRollup);
265
+ inputsForRollup = new PartialPrivateTailPublicInputsForRollup(accumulatedDataForRollup);
266
+ } else {
267
+ const [nonRevertibleNoteHashes, revertibleNoteHashes] = splitOrderedSideEffects(siloedNoteHashes.sort(sortByCounter), minRevertibleSideEffectCounter);
268
+ const nonRevertibleUniqueNoteHashes = await Promise.all(nonRevertibleNoteHashes.map(async (noteHash, i)=>{
269
+ const nonce = await computeNoteHashNonce(nonceGenerator, i);
270
+ return await computeUniqueNoteHash(nonce, noteHash);
271
+ }));
272
+ const [nonRevertibleL2ToL1Messages, revertibleL2ToL1Messages] = splitOrderedSideEffects(l2ToL1Messages.sort(sortByCounter), minRevertibleSideEffectCounter);
273
+ const [nonRevertibleTaggedPrivateLogs, revertibleTaggedPrivateLogs] = splitOrderedSideEffects(taggedPrivateLogs, minRevertibleSideEffectCounter);
274
+ const [nonRevertibleContractClassLogHashes, revertibleContractClassLogHashes] = splitOrderedSideEffects(contractClassLogsHashes.sort(sortByCounter), minRevertibleSideEffectCounter);
275
+ const [nonRevertiblePublicCallRequests, revertiblePublicCallRequests] = splitOrderedSideEffects(publicCallRequests.sort(sortByCounter), minRevertibleSideEffectCounter);
276
+ const nonRevertibleData = new PrivateToPublicAccumulatedData(padArrayEnd(nonRevertibleUniqueNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX), padArrayEnd(nonRevertibleNullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX), padArrayEnd(nonRevertibleL2ToL1Messages, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX), padArrayEnd(nonRevertibleTaggedPrivateLogs, PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX), padArrayEnd(nonRevertibleContractClassLogHashes, ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX), padArrayEnd(nonRevertiblePublicCallRequests, PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX));
277
+ const revertibleData = new PrivateToPublicAccumulatedData(padArrayEnd(revertibleNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX), padArrayEnd(revertibleNullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX), padArrayEnd(revertibleL2ToL1Messages, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX), padArrayEnd(revertibleTaggedPrivateLogs, PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX), padArrayEnd(revertibleContractClassLogHashes, ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX), padArrayEnd(revertiblePublicCallRequests, PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX));
278
+ gasUsed = meterGasUsed(revertibleData).add(meterGasUsed(nonRevertibleData));
279
+ if (publicTeardownCallRequest) {
280
+ gasUsed.add(privateExecutionResult.entrypoint.publicInputs.txContext.gasSettings.teardownGasLimits);
281
+ }
282
+ inputsForPublic = new PartialPrivateTailPublicInputsForPublic(nonRevertibleData, revertibleData, publicTeardownCallRequest ?? PublicCallRequest.empty());
283
+ }
284
+ const publicInputs = new PrivateKernelTailCircuitPublicInputs(constantData, /*gasUsed=*/ gasUsed.add(Gas.from({
285
+ l2Gas: FIXED_L2_GAS,
286
+ daGas: FIXED_DA_GAS
287
+ })), /*feePayer=*/ AztecAddress.zero(), /*includeByTimestamp=*/ 0n, hasPublicCalls ? inputsForPublic : undefined, !hasPublicCalls ? inputsForRollup : undefined);
288
+ return {
289
+ publicInputs,
290
+ chonkProof: ChonkProof.empty(),
291
+ executionSteps
292
+ };
293
+ }
294
+ function splitOrderedSideEffects(effects, minRevertibleSideEffectCounter) {
295
+ const revertibleSideEffects = [];
296
+ const nonRevertibleSideEffects = [];
297
+ effects.forEach((effect)=>{
298
+ if (minRevertibleSideEffectCounter === 0 || effect.counter < minRevertibleSideEffectCounter) {
299
+ nonRevertibleSideEffects.push(effect.sideEffect);
300
+ } else {
301
+ revertibleSideEffects.push(effect.sideEffect);
302
+ }
303
+ });
304
+ return [
305
+ nonRevertibleSideEffects,
306
+ revertibleSideEffects
307
+ ];
308
+ }
309
+ function meterGasUsed(data) {
310
+ let meteredDAFields = 0;
311
+ let meteredL2Gas = 0;
312
+ const numNoteHashes = arrayNonEmptyLength(data.noteHashes, (hash)=>hash.isEmpty());
313
+ meteredDAFields += numNoteHashes;
314
+ meteredL2Gas += numNoteHashes * AVM_EMITNOTEHASH_BASE_L2_GAS;
315
+ const numNullifiers = arrayNonEmptyLength(data.nullifiers, (nullifier)=>nullifier.isEmpty());
316
+ meteredDAFields += numNullifiers;
317
+ meteredL2Gas += numNullifiers * AVM_EMITNULLIFIER_BASE_L2_GAS;
318
+ const numL2toL1Messages = arrayNonEmptyLength(data.l2ToL1Msgs, (msg)=>msg.isEmpty());
319
+ meteredDAFields += numL2toL1Messages;
320
+ meteredL2Gas += numL2toL1Messages * AVM_SENDL2TOL1MSG_BASE_L2_GAS;
321
+ const numPrivatelogs = arrayNonEmptyLength(data.privateLogs, (log)=>log.isEmpty());
322
+ // Every private log emits its length as an additional field
323
+ meteredDAFields += data.privateLogs.reduce((acc, log)=>!log.isEmpty() ? acc + log.emittedLength + 1 : acc, 0);
324
+ meteredL2Gas += numPrivatelogs * L2_GAS_PER_PRIVATE_LOG;
325
+ const numContractClassLogs = arrayNonEmptyLength(data.contractClassLogsHashes, (log)=>log.isEmpty());
326
+ // Every contract class log emits its length and contract address as additional fields
327
+ meteredDAFields += data.contractClassLogsHashes.reduce((acc, log)=>!log.isEmpty() ? acc + log.logHash.length + 2 : acc, 0);
328
+ meteredL2Gas += numContractClassLogs * L2_GAS_PER_CONTRACT_CLASS_LOG;
329
+ const meteredDAGas = meteredDAFields * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
330
+ if (data.publicCallRequests) {
331
+ const dataForPublic = data;
332
+ const numPublicCallRequests = arrayNonEmptyLength(dataForPublic.publicCallRequests, (req)=>req.isEmpty());
333
+ meteredL2Gas += numPublicCallRequests * FIXED_AVM_STARTUP_L2_GAS;
334
+ }
335
+ return Gas.from({
336
+ l2Gas: meteredL2Gas,
337
+ daGas: meteredDAGas
338
+ });
339
+ }
@@ -0,0 +1,104 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import type { NoteData } from './oracle/interfaces.js';
4
+ interface PendingNote {
5
+ note: NoteData;
6
+ counter: number;
7
+ noteHashForConsumption: Fr;
8
+ }
9
+ /**
10
+ * Data that's accessible by all the function calls in an execution.
11
+ */
12
+ export declare class ExecutionNoteCache {
13
+ #private;
14
+ private readonly protocolNullifier;
15
+ /**
16
+ * New notes created in this transaction.
17
+ * They are pushed to this array in the same order as they are emitted.
18
+ */
19
+ private notes;
20
+ /**
21
+ * This mapping maps from a contract address to the notes in the contract.
22
+ */
23
+ private noteMap;
24
+ /**
25
+ * This maps from a contract address to the nullifiers emitted from the contract.
26
+ * The note which is nullified might be new or not (i.e., was generated in a previous transaction).
27
+ * Note that their value (bigint representation) is used because Frs cannot be looked up in Sets.
28
+ */
29
+ private nullifierMap;
30
+ /**
31
+ * Nullifiers emitted by private calls in this transaction.
32
+ */
33
+ private emittedNullifiers;
34
+ /**
35
+ * The counter that separates non-revertible side effects (which persist even if the tx reverts) from revertible ones.
36
+ */
37
+ private minRevertibleSideEffectCounter;
38
+ private inRevertiblePhase;
39
+ /**
40
+ * Whether the protocol nullifier was used for nonce generation.
41
+ * We don't need to use the protocol nullifier if a non-revertible nullifier is emitted.
42
+ */
43
+ private usedProtocolNullifierForNonces;
44
+ constructor(protocolNullifier: Fr);
45
+ /**
46
+ * Enters the revertible phase of the transaction.
47
+ * @param minRevertibleSideEffectCounter - The counter at which the transaction enters the revertible phase.
48
+ */
49
+ setMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: number): Promise<void>;
50
+ isSideEffectCounterRevertible(sideEffectCounter: number): boolean;
51
+ finish(): void;
52
+ /**
53
+ * Add a new note to cache.
54
+ * @param note - New note created during execution.
55
+ */
56
+ addNewNote(note: NoteData, counter: number): void;
57
+ /**
58
+ * Add a nullifier to cache. It could be for a db note or a new note created during execution.
59
+ * @param contractAddress - Contract address of the note.
60
+ * @param innerNullifier - Inner nullifier of the note.
61
+ * @param noteHash - A hash of the note. If this value equals 0, it means the note being nullified is from a previous
62
+ * transaction (and thus not a new note).
63
+ */
64
+ nullifyNote(contractAddress: AztecAddress, innerNullifier: Fr, noteHash: Fr): Promise<number | undefined>;
65
+ /**
66
+ * Adds a nullifier to the cache. Note cache needs to track all nullifiers to decide which nullifier to use for note siloing.
67
+ * @param contractAddress - Contract address that emitted the nullifier.
68
+ * @param innerNullifier
69
+ */
70
+ nullifierCreated(contractAddress: AztecAddress, innerNullifier: Fr): Promise<void>;
71
+ /**
72
+ * Return notes created up to current point in execution.
73
+ * If a nullifier for a note in this list is emitted, the note will be deleted.
74
+ * @param contractAddress - Contract address of the notes.
75
+ * @param owner - Owner of the notes. If undefined, returns all notes regardless of owner.
76
+ * @param storageSlot - Storage slot of the notes.
77
+ **/
78
+ getNotes(contractAddress: AztecAddress, owner: AztecAddress | undefined, storageSlot: Fr): NoteData[];
79
+ /**
80
+ * Check if a note exists in the newNotes array.
81
+ * @param contractAddress - Contract address of the note.
82
+ * @param storageSlot - Storage slot of the note.
83
+ * @param noteHash - A hash of the note.
84
+ **/
85
+ checkNoteExists(contractAddress: AztecAddress, noteHash: Fr): boolean;
86
+ /**
87
+ * Return all nullifiers emitted from a contract.
88
+ * @param contractAddress - Address of the contract.
89
+ */
90
+ getNullifiers(contractAddress: AztecAddress): Set<bigint>;
91
+ getAllNotes(): PendingNote[];
92
+ /**
93
+ * @returns All nullifiers emitted by private calls in this transaction.
94
+ */
95
+ getEmittedNullifiers(): Fr[];
96
+ /**
97
+ * @returns All nullifiers emitted by private calls in this transaction. If the protocol nullifier was used as the
98
+ * nonce generator, it is injected as the first nullifier.
99
+ */
100
+ getAllNullifiers(): Fr[];
101
+ getNonceGenerator(): Fr;
102
+ }
103
+ export {};
104
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhlY3V0aW9uX25vdGVfY2FjaGUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb250cmFjdF9mdW5jdGlvbl9zaW11bGF0b3IvZXhlY3V0aW9uX25vdGVfY2FjaGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUF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FFLCtCQXlCdkY7SUFFRDs7OztPQUlHO0lBQ1UsZ0JBQWdCLENBQUMsZUFBZSxFQUFFLFlBQVksRUFBRSxjQUFjLEVBQUUsRUFBRSxpQkFHOUU7SUFFRDs7Ozs7O1FBTUk7SUFDRyxRQUFRLENBQUMsZUFBZSxFQUFFLFlBQVksRUFBRSxLQUFLLEVBQUUsWUFBWSxHQUFHLFNBQVMsRUFBRSxXQUFXLEVBQUUsRUFBRSxjQU05RjtJQUVEOzs7OztRQUtJO0lBQ0csZUFBZSxDQUFDLGVBQWUsRUFBRSxZQUFZLEVBQUUsUUFBUSxFQUFFLEVBQUUsV0FHakU7SUFFRDs7O09BR0c7SUFDSSxhQUFhLENBQUMsZUFBZSxFQUFFLFlBQVksR0FBRyxHQUFHLENBQUMsTUFBTSxDQUFDLENBRS9EO0lBVUQsV0FBVyxJQUFJLFdBQVcsRUFBRSxDQUUzQjtJQUVEOztPQUVHO0lBQ0gsb0JBQW9CLElBQUksRUFBRSxFQUFFLENBRTNCO0lBRUQ7OztPQUdHO0lBQ0gsZ0JBQWdCLElBQUksRUFBRSxFQUFFLENBTXZCO0lBRUQsaUJBQWlCLElBQUksRUFBRSxDQUV0QjtDQWFGIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution_note_cache.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/execution_note_cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEvD,UAAU,WAAW;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,sBAAsB,EAAE,EAAE,CAAC;CAC5B;AAED;;GAEG;AACH,qBAAa,kBAAkB;;IAoCjB,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAnC9C;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