@aztec/pxe 0.0.0-test.1 → 0.0.1-commit.0b941701

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 (457) 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 +84 -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 +341 -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 +240 -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 +205 -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 +372 -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 +31 -0
  83. package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
  84. package/dest/debug/pxe_debug_utils.js +38 -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 +27 -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 +9 -9
  95. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  96. package/dest/entrypoints/client/lazy/utils.js +26 -11
  97. package/dest/entrypoints/pxe_creation_options.d.ts +17 -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 +35 -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 +16 -0
  109. package/dest/events/event_service.d.ts.map +1 -0
  110. package/dest/events/event_service.js +45 -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 +74 -0
  118. package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
  119. package/dest/job_coordinator/job_coordinator.js +93 -0
  120. package/dest/logs/log_service.d.ts +27 -0
  121. package/dest/logs/log_service.d.ts.map +1 -0
  122. package/dest/logs/log_service.js +128 -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 +49 -0
  127. package/dest/notes/note_service.d.ts.map +1 -0
  128. package/dest/notes/note_service.js +148 -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 +44 -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 +740 -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} +1 -4
  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 +9 -0
  160. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
  161. package/dest/storage/{sync_data_provider/sync_data_provider.js → anchor_block_store/anchor_block_store.js} +2 -12
  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 +255 -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 +224 -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 +73 -0
  190. package/dest/storage/note_store/note_store.d.ts.map +1 -0
  191. package/dest/storage/note_store/note_store.js +303 -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 +250 -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 +99 -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 +30 -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 +278 -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 +174 -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 +620 -0
  262. package/src/contract_function_simulator/oracle/private_execution.ts +141 -0
  263. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +703 -0
  264. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +548 -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 +49 -0
  269. package/src/entrypoints/client/bundle/index.ts +3 -2
  270. package/src/entrypoints/client/bundle/utils.ts +42 -36
  271. package/src/entrypoints/client/lazy/index.ts +3 -2
  272. package/src/entrypoints/client/lazy/utils.ts +41 -31
  273. package/src/entrypoints/pxe_creation_options.ts +13 -0
  274. package/src/entrypoints/server/index.ts +7 -3
  275. package/src/entrypoints/server/utils.ts +55 -51
  276. package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +40 -39
  277. package/src/events/event_service.ts +73 -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 +149 -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 +197 -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 +430 -0
  290. package/src/private_kernel/private_kernel_oracle.ts +152 -0
  291. package/src/pxe.ts +1062 -0
  292. package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +1 -7
  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} +2 -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 +319 -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 +381 -0
  305. package/src/storage/note_store/stored_note.ts +48 -0
  306. package/src/storage/private_event_store/private_event_store.ts +363 -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 +129 -0
  310. package/src/storage/tagging_store/sender_address_book_store.ts +42 -0
  311. package/src/storage/tagging_store/sender_tagging_store.ts +345 -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/tagging_data_provider/index.d.ts +0 -2
  411. package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
  412. package/dest/storage/tagging_data_provider/index.js +0 -1
  413. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +0 -18
  414. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +0 -1
  415. package/dest/storage/tagging_data_provider/tagging_data_provider.js +0 -65
  416. package/dest/synchronizer/index.d.ts +0 -2
  417. package/dest/synchronizer/index.d.ts.map +0 -1
  418. package/dest/synchronizer/index.js +0 -1
  419. package/dest/synchronizer/synchronizer.d.ts +0 -37
  420. package/dest/synchronizer/synchronizer.d.ts.map +0 -1
  421. package/dest/synchronizer/synchronizer.js +0 -103
  422. package/dest/test/pxe_test_suite.d.ts +0 -3
  423. package/dest/test/pxe_test_suite.d.ts.map +0 -1
  424. package/dest/test/pxe_test_suite.js +0 -97
  425. package/src/bin/index.ts +0 -38
  426. package/src/entrypoints/client/pxe_creation_options.ts +0 -7
  427. package/src/kernel_oracle/index.ts +0 -117
  428. package/src/kernel_prover/hints/index.ts +0 -1
  429. package/src/kernel_prover/index.ts +0 -2
  430. package/src/kernel_prover/kernel_prover.ts +0 -351
  431. package/src/kernel_prover/proving_data_oracle.ts +0 -83
  432. package/src/note_decryption_utils/add_public_values_to_payload.ts +0 -64
  433. package/src/pxe_http/index.ts +0 -1
  434. package/src/pxe_http/pxe_http_server.ts +0 -29
  435. package/src/pxe_oracle_interface/index.ts +0 -925
  436. package/src/pxe_oracle_interface/tagging_utils.ts +0 -32
  437. package/src/pxe_service/index.ts +0 -2
  438. package/src/pxe_service/pxe_service.ts +0 -949
  439. package/src/storage/address_data_provider/index.ts +0 -1
  440. package/src/storage/auth_witness_data_provider/auth_witness_data_provider.ts +0 -34
  441. package/src/storage/auth_witness_data_provider/index.ts +0 -1
  442. package/src/storage/capsule_data_provider/capsule_data_provider.ts +0 -80
  443. package/src/storage/capsule_data_provider/index.ts +0 -1
  444. package/src/storage/contract_data_provider/contract_data_provider.ts +0 -261
  445. package/src/storage/contract_data_provider/index.ts +0 -2
  446. package/src/storage/contract_data_provider/private_functions_tree.ts +0 -131
  447. package/src/storage/data_provider.ts +0 -3
  448. package/src/storage/note_data_provider/index.ts +0 -2
  449. package/src/storage/note_data_provider/note_dao.ts +0 -162
  450. package/src/storage/note_data_provider/note_data_provider.ts +0 -345
  451. package/src/storage/sync_data_provider/index.ts +0 -1
  452. package/src/storage/tagging_data_provider/index.ts +0 -1
  453. package/src/storage/tagging_data_provider/tagging_data_provider.ts +0 -92
  454. package/src/synchronizer/index.ts +0 -1
  455. package/src/synchronizer/synchronizer.ts +0 -121
  456. package/src/test/pxe_test_suite.ts +0 -111
  457. /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,84 @@
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 { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
13
+ import type { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
14
+ import type { ContractStore } from '../storage/contract_store/contract_store.js';
15
+ import type { NoteStore } from '../storage/note_store/note_store.js';
16
+ import type { PrivateEventStore } from '../storage/private_event_store/private_event_store.js';
17
+ import type { RecipientTaggingStore } from '../storage/tagging_store/recipient_tagging_store.js';
18
+ import type { SenderAddressBookStore } from '../storage/tagging_store/sender_address_book_store.js';
19
+ import type { SenderTaggingStore } from '../storage/tagging_store/sender_tagging_store.js';
20
+ /**
21
+ * The contract function simulator.
22
+ */
23
+ export declare class ContractFunctionSimulator {
24
+ private contractStore;
25
+ private noteStore;
26
+ private keyStore;
27
+ private addressStore;
28
+ private aztecNode;
29
+ private anchorBlockStore;
30
+ private senderTaggingStore;
31
+ private recipientTaggingStore;
32
+ private senderAddressBookStore;
33
+ private capsuleStore;
34
+ private privateEventStore;
35
+ private simulator;
36
+ private log;
37
+ constructor(contractStore: ContractStore, noteStore: NoteStore, keyStore: KeyStore, addressStore: AddressStore, aztecNode: AztecNode, anchorBlockStore: AnchorBlockStore, senderTaggingStore: SenderTaggingStore, recipientTaggingStore: RecipientTaggingStore, senderAddressBookStore: SenderAddressBookStore, capsuleStore: CapsuleStore, privateEventStore: PrivateEventStore, simulator: CircuitSimulator);
38
+ /**
39
+ * Runs a private function.
40
+ * @param request - The transaction request.
41
+ * @param entryPointArtifact - The artifact of the entry point function.
42
+ * @param contractAddress - The address of the contract (should match request.origin)
43
+ * @param msgSender - The address calling the function. This can be replaced to simulate a call from another contract
44
+ * or a specific account.
45
+ * @param anchorBlockHeader - The block header to use as base state for this run.
46
+ * @param senderForTags - The address that is used as a tagging sender when emitting private logs. Returned from
47
+ * the `privateGetSenderForTags` oracle.
48
+ * @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
49
+ * @param jobId - The job ID for staged writes.
50
+ * @returns The result of the execution.
51
+ */
52
+ run(request: TxExecutionRequest, contractAddress: AztecAddress, selector: FunctionSelector, msgSender: AztecAddress | undefined, anchorBlockHeader: BlockHeader, senderForTags: AztecAddress | undefined, scopes: AztecAddress[] | undefined, jobId: string): Promise<PrivateExecutionResult>;
53
+ /**
54
+ * Runs a utility function.
55
+ * @param call - The function call to execute.
56
+ * @param authwits - Authentication witnesses required for the function call.
57
+ * @param anchorBlockHeader - The block header to use as base state for this run.
58
+ * @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
59
+ * accounts if not specified.
60
+ * @returns A return value of the utility function in a form as returned by the simulator (Noir fields)
61
+ */
62
+ runUtility(call: FunctionCall, authwits: AuthWitness[], anchorBlockHeader: BlockHeader, scopes: AztecAddress[] | undefined, jobId: string): Promise<Fr[]>;
63
+ /**
64
+ * Returns the execution statistics collected during the simulator run.
65
+ * @returns The execution statistics.
66
+ */
67
+ getStats(): {
68
+ nodeRPCCalls: import("@aztec/stdlib/tx").NodeStats;
69
+ };
70
+ }
71
+ /**
72
+ * Generates the final public inputs of the tail kernel circuit, an empty Chonk proof
73
+ * and the execution steps for a `PrivateExecutionResult` as if it had been
74
+ * processed by the private kernel prover. This skips many of the checks performed by the kernels
75
+ * (allowing state overrides) and is much faster, while still generating a valid
76
+ * output that can be sent to the node for public simulation
77
+ * @param privateExecutionResult - The result of the private execution.
78
+ * @param contractStore - A provider for contract data in order to get function names and debug info.
79
+ * @param minRevertibleSideEffectCounterOverride - Optional override for the min revertible side effect counter.
80
+ * Used by TXE to simulate account contract behavior (setting the counter before app execution).
81
+ * @returns The simulated proving result.
82
+ */
83
+ export declare function generateSimulatedProvingResult(privateExecutionResult: PrivateExecutionResult, contractStore: ContractStore, minRevertibleSideEffectCounterOverride?: number): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>>;
84
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3RfZnVuY3Rpb25fc2ltdWxhdG9yLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3RfZnVuY3Rpb25fc2ltdWxhdG9yL2NvbnRyYWN0X2Z1bmN0aW9uX3NpbXVsYXRvci50cyJdLCJuYW1lcyI6W10sIm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7Ozs7O09BYUc7SUFDVSxHQUFHLENBQ2QsT0FBTyxFQUFFLGtCQUFrQixFQUMzQixlQUFlLEVBQUUsWUFBWSxFQUM3QixRQUFRLEVBQUUsZ0JBQWdCLEVBQzFCLFNBQVMsMEJBQTZDLEVBQ3RELGlCQUFpQixFQUFFLFdBQVcsRUFDOUIsYUFBYSxFQUFFLFlBQVksR0FBRyxTQUFTLEVBQ3ZDLE1BQU0sRUFBRSxZQUFZLEVBQUUsR0FBRyxTQUFTLEVBQ2xDLEtBQUssRUFBRSxNQUFNLEdBQ1osT0FBTyxDQUFDLHNCQUFzQixDQUFDLENBNEdqQztJQUdEOzs7Ozs7OztPQVFHO0lBQ1UsVUFBVSxDQUNyQixJQUFJLEVBQUUsWUFBWSxFQUNsQixRQUFRLEVBQUUsV0FBVyxFQUFFLEVBQ3ZCLGlCQUFpQixFQUFFLFdBQVcsRUFDOUIsTUFBTSxFQUFFLFlBQVksRUFBRSxHQUFHLFNBQVMsRUFDbEMsS0FBSyxFQUFFLE1BQU0sR0FDWixPQUFPLENBQUMsRUFBRSxFQUFFLENBQUMsQ0FzRGY7SUFHRDs7O09BR0c7SUFDSCxRQUFROztNQVVQO0NBQ0Y7QUFZRDs7Ozs7Ozs7Ozs7R0FXRztBQUNILHdCQUFzQiw4QkFBOEIsQ0FDbEQsc0JBQXNCLEVBQUUsc0JBQXNCLEVBQzlDLGFBQWEsRUFBRSxhQUFhLEVBQzVCLHNDQUFzQyxDQUFDLEVBQUUsTUFBTSxHQUM5QyxPQUFPLENBQUMsaUNBQWlDLENBQUMsb0NBQW9DLENBQUMsQ0FBQyxDQXdObEYifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract_function_simulator.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/contract_function_simulator.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAGpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CA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,CAAC,oCAAoC,CAAC,CAAC,CAwNlF"}
@@ -0,0 +1,341 @@
1
+ import { AVM_EMITNOTEHASH_BASE_L2_GAS, AVM_EMITNULLIFIER_BASE_L2_GAS, AVM_SENDL2TOL1MSG_BASE_L2_GAS, DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, FIXED_AVM_STARTUP_L2_GAS, FIXED_DA_GAS, FIXED_L2_GAS, L2_GAS_PER_CONTRACT_CLASS_LOG, L2_GAS_PER_PRIVATE_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 { poseidon2Hash } 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
+ anchorBlockStore;
35
+ senderTaggingStore;
36
+ recipientTaggingStore;
37
+ senderAddressBookStore;
38
+ capsuleStore;
39
+ privateEventStore;
40
+ simulator;
41
+ log;
42
+ constructor(contractStore, noteStore, keyStore, addressStore, aztecNode, anchorBlockStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, simulator){
43
+ this.contractStore = contractStore;
44
+ this.noteStore = noteStore;
45
+ this.keyStore = keyStore;
46
+ this.addressStore = addressStore;
47
+ this.aztecNode = aztecNode;
48
+ this.anchorBlockStore = anchorBlockStore;
49
+ this.senderTaggingStore = senderTaggingStore;
50
+ this.recipientTaggingStore = recipientTaggingStore;
51
+ this.senderAddressBookStore = senderAddressBookStore;
52
+ this.capsuleStore = capsuleStore;
53
+ this.privateEventStore = privateEventStore;
54
+ this.simulator = simulator;
55
+ this.log = createLogger('simulator');
56
+ }
57
+ /**
58
+ * Runs a private function.
59
+ * @param request - The transaction request.
60
+ * @param entryPointArtifact - The artifact of the entry point function.
61
+ * @param contractAddress - The address of the contract (should match request.origin)
62
+ * @param msgSender - The address calling the function. This can be replaced to simulate a call from another contract
63
+ * or a specific account.
64
+ * @param anchorBlockHeader - The block header to use as base state for this run.
65
+ * @param senderForTags - The address that is used as a tagging sender when emitting private logs. Returned from
66
+ * the `privateGetSenderForTags` oracle.
67
+ * @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
68
+ * @param jobId - The job ID for staged writes.
69
+ * @returns The result of the execution.
70
+ */ async run(request, contractAddress, selector, msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE), anchorBlockHeader, senderForTags, scopes, jobId) {
71
+ const simulatorSetupTimer = new Timer();
72
+ const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(contractAddress, selector);
73
+ if (entryPointArtifact.functionType !== FunctionType.PRIVATE) {
74
+ throw new Error(`Cannot run ${entryPointArtifact.functionType} function as private`);
75
+ }
76
+ if (request.origin !== contractAddress) {
77
+ this.log.warn(`Request origin does not match contract address in simulation. Request origin: ${request.origin}, contract address: ${contractAddress}`);
78
+ }
79
+ // reserve the first side effect for the tx hash (inserted by the private kernel)
80
+ const startSideEffectCounter = 2;
81
+ const callContext = new CallContext(msgSender, contractAddress, await FunctionSelector.fromNameAndParameters(entryPointArtifact.name, entryPointArtifact.parameters), entryPointArtifact.isStatic);
82
+ const protocolNullifier = await computeProtocolNullifier(await request.toTxRequest().hash());
83
+ const noteCache = new ExecutionNoteCache(protocolNullifier);
84
+ const taggingIndexCache = new ExecutionTaggingIndexCache();
85
+ const privateExecutionOracle = new PrivateExecutionOracle(request.firstCallArgsHash, request.txContext, callContext, anchorBlockHeader, async (call)=>{
86
+ await this.runUtility(call, [], anchorBlockHeader, scopes, jobId);
87
+ }, request.authWitnesses, request.capsules, HashedValuesCache.create(request.argsOfCalls), noteCache, taggingIndexCache, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.aztecNode, this.anchorBlockStore, this.senderTaggingStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, jobId, 0, startSideEffectCounter, undefined, scopes, senderForTags, this.simulator);
88
+ const setupTime = simulatorSetupTimer.ms();
89
+ try {
90
+ // Note: any nested private function calls are made recursively within this
91
+ // function call. So this execution result is the result of executing _all_
92
+ // private functions of this tx (the results of those executions are contained
93
+ // within executionResult.nestedExecutionResults).
94
+ const executionResult = await executePrivateFunction(this.simulator, privateExecutionOracle, entryPointArtifact, contractAddress, request.functionSelector);
95
+ const simulatorTeardownTimer = new Timer();
96
+ noteCache.finish();
97
+ const firstNullifierHint = noteCache.getNonceGenerator();
98
+ const publicCallRequests = collectNested([
99
+ executionResult
100
+ ], (r)=>r.publicInputs.publicCallRequests.getActiveItems().map((r)=>r.inner).concat(r.publicInputs.publicTeardownCallRequest.isEmpty() ? [] : [
101
+ r.publicInputs.publicTeardownCallRequest
102
+ ]));
103
+ const publicFunctionsCalldata = await Promise.all(publicCallRequests.map(async (r)=>{
104
+ const calldata = await privateExecutionOracle.privateLoadFromExecutionCache(r.calldataHash);
105
+ return new HashedValues(calldata, r.calldataHash);
106
+ }));
107
+ const teardownTime = simulatorTeardownTimer.ms();
108
+ // Add simulator overhead to topmost call in the stack
109
+ if (executionResult.profileResult) {
110
+ executionResult.profileResult.timings.witgen += setupTime + teardownTime;
111
+ }
112
+ // Not to be confused with a PrivateCallExecutionResult. This is a superset
113
+ // of the PrivateCallExecutionResult, containing also firstNullifierHint
114
+ // and publicFunctionsCalldata.
115
+ return new PrivateExecutionResult(executionResult, firstNullifierHint, publicFunctionsCalldata);
116
+ } catch (err) {
117
+ throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
118
+ }
119
+ }
120
+ // docs:start:execute_utility_function
121
+ /**
122
+ * Runs a utility function.
123
+ * @param call - The function call to execute.
124
+ * @param authwits - Authentication witnesses required for the function call.
125
+ * @param anchorBlockHeader - The block header to use as base state for this run.
126
+ * @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
127
+ * accounts if not specified.
128
+ * @returns A return value of the utility function in a form as returned by the simulator (Noir fields)
129
+ */ async runUtility(call, authwits, anchorBlockHeader, scopes, jobId) {
130
+ const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
131
+ if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
132
+ throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
133
+ }
134
+ const oracle = new UtilityExecutionOracle(call.to, authwits, [], anchorBlockHeader, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.aztecNode, this.anchorBlockStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, jobId, undefined, scopes);
135
+ try {
136
+ this.log.verbose(`Executing utility function ${entryPointArtifact.name}`, {
137
+ contract: call.to,
138
+ selector: call.selector
139
+ });
140
+ const initialWitness = toACVMWitness(0, call.args);
141
+ const acirExecutionResult = await this.simulator.executeUserCircuit(initialWitness, entryPointArtifact, new Oracle(oracle).toACIRCallback()).catch((err)=>{
142
+ err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
143
+ throw new ExecutionError(err.message, {
144
+ contractAddress: call.to,
145
+ functionSelector: call.selector
146
+ }, extractCallStack(err, entryPointArtifact.debug), {
147
+ cause: err
148
+ });
149
+ });
150
+ this.log.verbose(`Utility simulation for ${call.to}.${call.selector} completed`);
151
+ return witnessMapToFields(acirExecutionResult.returnWitness);
152
+ } catch (err) {
153
+ throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
154
+ }
155
+ }
156
+ // docs:end:execute_utility_function
157
+ /**
158
+ * Returns the execution statistics collected during the simulator run.
159
+ * @returns The execution statistics.
160
+ */ getStats() {
161
+ const nodeRPCCalls = typeof this.aztecNode.getStats === 'function' ? this.aztecNode.getStats() : {
162
+ perMethod: {},
163
+ roundTrips: {
164
+ roundTrips: 0,
165
+ totalBlockingTime: 0,
166
+ roundTripDurations: [],
167
+ roundTripMethods: []
168
+ }
169
+ };
170
+ return {
171
+ nodeRPCCalls
172
+ };
173
+ }
174
+ }
175
+ class OrderedSideEffect {
176
+ sideEffect;
177
+ counter;
178
+ constructor(sideEffect, counter){
179
+ this.sideEffect = sideEffect;
180
+ this.counter = counter;
181
+ }
182
+ }
183
+ /**
184
+ * Generates the final public inputs of the tail kernel circuit, an empty Chonk proof
185
+ * and the execution steps for a `PrivateExecutionResult` as if it had been
186
+ * processed by the private kernel prover. This skips many of the checks performed by the kernels
187
+ * (allowing state overrides) and is much faster, while still generating a valid
188
+ * output that can be sent to the node for public simulation
189
+ * @param privateExecutionResult - The result of the private execution.
190
+ * @param contractStore - A provider for contract data in order to get function names and debug info.
191
+ * @param minRevertibleSideEffectCounterOverride - Optional override for the min revertible side effect counter.
192
+ * Used by TXE to simulate account contract behavior (setting the counter before app execution).
193
+ * @returns The simulated proving result.
194
+ */ export async function generateSimulatedProvingResult(privateExecutionResult, contractStore, minRevertibleSideEffectCounterOverride) {
195
+ const siloedNoteHashes = [];
196
+ const nullifiers = [];
197
+ const taggedPrivateLogs = [];
198
+ const l2ToL1Messages = [];
199
+ const contractClassLogsHashes = [];
200
+ const publicCallRequests = [];
201
+ const executionSteps = [];
202
+ let publicTeardownCallRequest;
203
+ const executions = [
204
+ privateExecutionResult.entrypoint
205
+ ];
206
+ while(executions.length !== 0){
207
+ const execution = executions.shift();
208
+ executions.unshift(...execution.nestedExecutionResults);
209
+ const { contractAddress } = execution.publicInputs.callContext;
210
+ 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)));
211
+ const nullifiersFromExecution = await Promise.all(execution.publicInputs.nullifiers.getActiveItems().map(async (nullifier)=>new OrderedSideEffect(await siloNullifier(contractAddress, nullifier.value), nullifier.counter)));
212
+ const privateLogsFromExecution = await Promise.all(execution.publicInputs.privateLogs.getActiveItems().map(async (metadata)=>{
213
+ metadata.log.fields[0] = await poseidon2Hash([
214
+ contractAddress,
215
+ metadata.log.fields[0]
216
+ ]);
217
+ return new OrderedSideEffect(metadata.log, metadata.counter);
218
+ }));
219
+ siloedNoteHashes.push(...noteHashesFromExecution);
220
+ taggedPrivateLogs.push(...privateLogsFromExecution);
221
+ nullifiers.push(...nullifiersFromExecution);
222
+ l2ToL1Messages.push(...execution.publicInputs.l2ToL1Msgs.getActiveItems().map((message)=>new OrderedSideEffect(message.message.scope(contractAddress), message.counter)));
223
+ contractClassLogsHashes.push(...execution.publicInputs.contractClassLogsHashes.getActiveItems().map((contractClassLogHash)=>new OrderedSideEffect(contractClassLogHash.logHash.scope(contractAddress), contractClassLogHash.counter)));
224
+ publicCallRequests.push(...execution.publicInputs.publicCallRequests.getActiveItems().map((callRequest)=>new OrderedSideEffect(callRequest.inner, callRequest.counter)));
225
+ if (publicTeardownCallRequest !== undefined && !execution.publicInputs.publicTeardownCallRequest.isEmpty()) {
226
+ throw new Error('Trying to set multiple teardown requests');
227
+ }
228
+ publicTeardownCallRequest = execution.publicInputs.publicTeardownCallRequest.isEmpty() ? publicTeardownCallRequest : execution.publicInputs.publicTeardownCallRequest;
229
+ executionSteps.push({
230
+ functionName: await contractStore.getDebugFunctionName(execution.publicInputs.callContext.contractAddress, execution.publicInputs.callContext.functionSelector),
231
+ timings: execution.profileResult?.timings ?? {
232
+ witgen: 0,
233
+ oracles: {}
234
+ },
235
+ bytecode: execution.acir,
236
+ vk: execution.vk,
237
+ witness: execution.partialWitness
238
+ });
239
+ }
240
+ const constantData = new TxConstantData(privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader, privateExecutionResult.entrypoint.publicInputs.txContext, getVKTreeRoot(), protocolContractsHash);
241
+ const hasPublicCalls = privateExecutionResult.publicFunctionCalldata.length !== 0;
242
+ let inputsForRollup;
243
+ let inputsForPublic;
244
+ let gasUsed;
245
+ const sortByCounter = (a, b)=>a.counter - b.counter;
246
+ const getEffect = (orderedSideEffect)=>orderedSideEffect.sideEffect;
247
+ const isPrivateOnlyTx = privateExecutionResult.publicFunctionCalldata.length === 0;
248
+ const minRevertibleSideEffectCounter = minRevertibleSideEffectCounterOverride ?? getFinalMinRevertibleSideEffectCounter(privateExecutionResult);
249
+ const [nonRevertibleNullifiers, revertibleNullifiers] = splitOrderedSideEffects(nullifiers.sort(sortByCounter), minRevertibleSideEffectCounter);
250
+ const nonceGenerator = privateExecutionResult.firstNullifier;
251
+ if (nonRevertibleNullifiers.length === 0) {
252
+ nonRevertibleNullifiers.push(nonceGenerator);
253
+ } else if (!nonRevertibleNullifiers[0].equals(nonceGenerator)) {
254
+ throw new Error('The first non revertible nullifier should be equal to the nonce generator. This is a bug!');
255
+ }
256
+ if (isPrivateOnlyTx) {
257
+ // We must make the note hashes unique by using the
258
+ // nonce generator and their index in the tx.
259
+ const uniqueNoteHashes = await Promise.all(siloedNoteHashes.sort(sortByCounter).map(async (orderedSideEffect, i)=>{
260
+ const siloedNoteHash = orderedSideEffect.sideEffect;
261
+ const nonce = await computeNoteHashNonce(nonceGenerator, i);
262
+ const uniqueNoteHash = await computeUniqueNoteHash(nonce, siloedNoteHash);
263
+ return uniqueNoteHash;
264
+ }));
265
+ 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));
266
+ gasUsed = meterGasUsed(accumulatedDataForRollup);
267
+ inputsForRollup = new PartialPrivateTailPublicInputsForRollup(accumulatedDataForRollup);
268
+ } else {
269
+ const [nonRevertibleNoteHashes, revertibleNoteHashes] = splitOrderedSideEffects(siloedNoteHashes.sort(sortByCounter), minRevertibleSideEffectCounter);
270
+ const nonRevertibleUniqueNoteHashes = await Promise.all(nonRevertibleNoteHashes.map(async (noteHash, i)=>{
271
+ const nonce = await computeNoteHashNonce(nonceGenerator, i);
272
+ return await computeUniqueNoteHash(nonce, noteHash);
273
+ }));
274
+ const [nonRevertibleL2ToL1Messages, revertibleL2ToL1Messages] = splitOrderedSideEffects(l2ToL1Messages.sort(sortByCounter), minRevertibleSideEffectCounter);
275
+ const [nonRevertibleTaggedPrivateLogs, revertibleTaggedPrivateLogs] = splitOrderedSideEffects(taggedPrivateLogs, minRevertibleSideEffectCounter);
276
+ const [nonRevertibleContractClassLogHashes, revertibleContractClassLogHashes] = splitOrderedSideEffects(contractClassLogsHashes.sort(sortByCounter), minRevertibleSideEffectCounter);
277
+ const [nonRevertiblePublicCallRequests, revertiblePublicCallRequests] = splitOrderedSideEffects(publicCallRequests.sort(sortByCounter), minRevertibleSideEffectCounter);
278
+ 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));
279
+ 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));
280
+ gasUsed = meterGasUsed(revertibleData).add(meterGasUsed(nonRevertibleData));
281
+ if (publicTeardownCallRequest) {
282
+ gasUsed.add(privateExecutionResult.entrypoint.publicInputs.txContext.gasSettings.teardownGasLimits);
283
+ }
284
+ inputsForPublic = new PartialPrivateTailPublicInputsForPublic(nonRevertibleData, revertibleData, publicTeardownCallRequest ?? PublicCallRequest.empty());
285
+ }
286
+ const publicInputs = new PrivateKernelTailCircuitPublicInputs(constantData, /*gasUsed=*/ gasUsed.add(Gas.from({
287
+ l2Gas: FIXED_L2_GAS,
288
+ daGas: FIXED_DA_GAS
289
+ })), /*feePayer=*/ AztecAddress.zero(), /*includeByTimestamp=*/ 0n, hasPublicCalls ? inputsForPublic : undefined, !hasPublicCalls ? inputsForRollup : undefined);
290
+ return {
291
+ publicInputs,
292
+ chonkProof: ChonkProof.empty(),
293
+ executionSteps
294
+ };
295
+ }
296
+ function splitOrderedSideEffects(effects, minRevertibleSideEffectCounter) {
297
+ const revertibleSideEffects = [];
298
+ const nonRevertibleSideEffects = [];
299
+ effects.forEach((effect)=>{
300
+ if (minRevertibleSideEffectCounter === 0 || effect.counter < minRevertibleSideEffectCounter) {
301
+ nonRevertibleSideEffects.push(effect.sideEffect);
302
+ } else {
303
+ revertibleSideEffects.push(effect.sideEffect);
304
+ }
305
+ });
306
+ return [
307
+ nonRevertibleSideEffects,
308
+ revertibleSideEffects
309
+ ];
310
+ }
311
+ function meterGasUsed(data) {
312
+ let meteredDAFields = 0;
313
+ let meteredL2Gas = 0;
314
+ const numNoteHashes = arrayNonEmptyLength(data.noteHashes, (hash)=>hash.isEmpty());
315
+ meteredDAFields += numNoteHashes;
316
+ meteredL2Gas += numNoteHashes * AVM_EMITNOTEHASH_BASE_L2_GAS;
317
+ const numNullifiers = arrayNonEmptyLength(data.nullifiers, (nullifier)=>nullifier.isEmpty());
318
+ meteredDAFields += numNullifiers;
319
+ meteredL2Gas += numNullifiers * AVM_EMITNULLIFIER_BASE_L2_GAS;
320
+ const numL2toL1Messages = arrayNonEmptyLength(data.l2ToL1Msgs, (msg)=>msg.isEmpty());
321
+ meteredDAFields += numL2toL1Messages;
322
+ meteredL2Gas += numL2toL1Messages * AVM_SENDL2TOL1MSG_BASE_L2_GAS;
323
+ const numPrivatelogs = arrayNonEmptyLength(data.privateLogs, (log)=>log.isEmpty());
324
+ // Every private log emits its length as an additional field
325
+ meteredDAFields += data.privateLogs.reduce((acc, log)=>!log.isEmpty() ? acc + log.emittedLength + 1 : acc, 0);
326
+ meteredL2Gas += numPrivatelogs * L2_GAS_PER_PRIVATE_LOG;
327
+ const numContractClassLogs = arrayNonEmptyLength(data.contractClassLogsHashes, (log)=>log.isEmpty());
328
+ // Every contract class log emits its length and contract address as additional fields
329
+ meteredDAFields += data.contractClassLogsHashes.reduce((acc, log)=>!log.isEmpty() ? acc + log.logHash.length + 2 : acc, 0);
330
+ meteredL2Gas += numContractClassLogs * L2_GAS_PER_CONTRACT_CLASS_LOG;
331
+ const meteredDAGas = meteredDAFields * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
332
+ if (data.publicCallRequests) {
333
+ const dataForPublic = data;
334
+ const numPublicCallRequests = arrayNonEmptyLength(dataForPublic.publicCallRequests, (req)=>req.isEmpty());
335
+ meteredL2Gas += numPublicCallRequests * FIXED_AVM_STARTUP_L2_GAS;
336
+ }
337
+ return Gas.from({
338
+ l2Gas: meteredL2Gas,
339
+ daGas: meteredDAGas
340
+ });
341
+ }
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhlY3V0aW9uX25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UVNLDZCQUE2QixDQUFDLGlCQUFpQixFQUFFLE1BQU0sR0FBRyxPQUFPLENBS3ZFO0lBRU0sTUFBTSxTQU1aO0lBRUQ7OztPQUdHO0lBQ0ksVUFBVSxDQUFDLElBQUksRUFBRSxRQUFRLEVBQUUsT0FBTyxFQUFFLE1BQU0sUUFTaEQ7SUFFRDs7Ozs7O09BTUc7SUFDVSxXQUFXLENBQUMsZUFBZSxFQUFFLFlBQVksRUFBRSxjQUFjLEVBQUUsRUFBRSxFQUFFLFFBQVEsRUFBRSxFQUFFLCtCQXlCdkY7SUFFRDs7OztPQUlHO0lBQ1UsZ0JBQWdCLENBQUMsZUFBZSxFQUFFLFlBQVksRUFBRSxjQUFjLEVBQUUsRUFBRSxpQkFHOUU7SUFFRDs7Ozs7O1FBTUk7SUFDRyxRQUFRLENBQUMsZUFBZSxFQUFFLFlBQVksRUFBRSxLQUFLLEVBQUUsWUFBWSxHQUFHLFNBQVMsRUFBRSxXQUFXLEVBQUUsRUFBRSxjQU05RjtJQUVEOzs7OztRQUtJO0lBQ0csZUFBZSxDQUFDLGVBQWUsRUFBRSxZQUFZLEVBQUUsUUFBUSxFQUFFLEVBQUUsV0FHakU7SUFFRDs7O09BR0c7SUFDSSxhQUFhLENBQUMsZUFBZSxFQUFFLFlBQVksR0FBRyxHQUFHLENBQUMsTUFBTSxDQUFDLENBRS9EO0lBVUQsV0FBVyxJQUFJLFdBQVcsRUFBRSxDQUUzQjtJQUVEOztPQUVHO0lBQ0gsb0JBQW9CLElBQUksRUFBRSxFQUFFLENBRTNCO0lBRUQ7OztPQUdHO0lBQ0gsZ0JBQWdCLElBQUksRUFBRSxFQUFFLENBTXZCO0lBRUQsaUJBQWlCLElBQUksRUFBRSxDQUV0QjtDQWFGIn0=
@@ -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,M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