@aztec/pxe 0.0.0-test.1 → 0.0.1-commit.5476d83

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 (328) 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 +39 -0
  5. package/dest/config/index.d.ts +11 -24
  6. package/dest/config/index.d.ts.map +1 -1
  7. package/dest/config/index.js +18 -33
  8. package/dest/config/package_info.d.ts +1 -1
  9. package/dest/config/package_info.js +1 -1
  10. package/dest/contract_function_simulator/contract_function_simulator.d.ts +56 -0
  11. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -0
  12. package/dest/contract_function_simulator/contract_function_simulator.js +300 -0
  13. package/dest/contract_function_simulator/execution_data_provider.d.ts +265 -0
  14. package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -0
  15. package/dest/contract_function_simulator/execution_data_provider.js +14 -0
  16. package/dest/contract_function_simulator/execution_note_cache.d.ts +94 -0
  17. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -0
  18. package/dest/contract_function_simulator/execution_note_cache.js +190 -0
  19. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
  20. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
  21. package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
  22. package/dest/contract_function_simulator/hashed_values_cache.d.ts +28 -0
  23. package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -0
  24. package/dest/contract_function_simulator/hashed_values_cache.js +36 -0
  25. package/dest/contract_function_simulator/index.d.ts +14 -0
  26. package/dest/contract_function_simulator/index.d.ts.map +1 -0
  27. package/dest/contract_function_simulator/index.js +12 -0
  28. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +20 -0
  29. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -0
  30. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +37 -0
  31. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +15 -0
  32. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -0
  33. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +25 -0
  34. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +17 -0
  35. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -0
  36. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +65 -0
  37. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +23 -0
  38. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -0
  39. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +48 -0
  40. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +22 -0
  41. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
  42. package/dest/contract_function_simulator/noir-structs/utility_context.js +33 -0
  43. package/dest/contract_function_simulator/oracle/index.d.ts +14 -0
  44. package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -0
  45. package/dest/contract_function_simulator/oracle/index.js +2 -0
  46. package/dest/contract_function_simulator/oracle/interfaces.d.ts +100 -0
  47. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
  48. package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
  49. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +17 -0
  50. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -0
  51. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +24 -0
  52. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +24 -0
  53. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -0
  54. package/dest/contract_function_simulator/oracle/note_packing_utils.js +50 -0
  55. package/dest/contract_function_simulator/oracle/oracle.d.ts +58 -0
  56. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -0
  57. package/dest/contract_function_simulator/oracle/oracle.js +333 -0
  58. package/dest/contract_function_simulator/oracle/private_execution.d.ts +48 -0
  59. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -0
  60. package/dest/contract_function_simulator/oracle/private_execution.js +123 -0
  61. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +231 -0
  62. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -0
  63. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +428 -0
  64. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +153 -0
  65. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -0
  66. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +265 -0
  67. package/dest/contract_function_simulator/pick_notes.d.ts +85 -0
  68. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -0
  69. package/dest/contract_function_simulator/pick_notes.js +51 -0
  70. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +6 -0
  71. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -0
  72. package/dest/contract_function_simulator/proxied_contract_data_source.js +62 -0
  73. package/dest/contract_function_simulator/proxied_node.d.ts +9 -0
  74. package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -0
  75. package/dest/contract_function_simulator/proxied_node.js +27 -0
  76. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +122 -0
  77. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -0
  78. package/dest/contract_function_simulator/pxe_oracle_interface.js +694 -0
  79. package/dest/entrypoints/client/bundle/index.d.ts +5 -3
  80. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  81. package/dest/entrypoints/client/bundle/index.js +3 -2
  82. package/dest/entrypoints/client/bundle/utils.d.ts +10 -10
  83. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  84. package/dest/entrypoints/client/bundle/utils.js +18 -12
  85. package/dest/entrypoints/client/lazy/index.d.ts +5 -3
  86. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  87. package/dest/entrypoints/client/lazy/index.js +3 -2
  88. package/dest/entrypoints/client/lazy/utils.d.ts +9 -9
  89. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  90. package/dest/entrypoints/client/lazy/utils.js +17 -11
  91. package/dest/entrypoints/pxe_creation_options.d.ts +14 -0
  92. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -0
  93. package/dest/entrypoints/server/index.d.ts +6 -4
  94. package/dest/entrypoints/server/index.d.ts.map +1 -1
  95. package/dest/entrypoints/server/index.js +4 -3
  96. package/dest/entrypoints/server/utils.d.ts +8 -16
  97. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  98. package/dest/entrypoints/server/utils.js +30 -35
  99. package/dest/error_enriching.d.ts +11 -0
  100. package/dest/error_enriching.d.ts.map +1 -0
  101. package/dest/{pxe_service/error_enriching.js → error_enriching.js} +26 -18
  102. package/dest/oracle_version.d.ts +3 -0
  103. package/dest/oracle_version.d.ts.map +1 -0
  104. package/dest/oracle_version.js +10 -0
  105. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +28 -0
  106. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -0
  107. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +271 -0
  108. package/dest/private_kernel/hints/compute_side_effect_uniqueness_hints.d.ts +3 -0
  109. package/dest/private_kernel/hints/compute_side_effect_uniqueness_hints.d.ts.map +1 -0
  110. package/dest/private_kernel/hints/compute_side_effect_uniqueness_hints.js +48 -0
  111. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +4 -0
  112. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +1 -0
  113. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +41 -0
  114. package/dest/private_kernel/hints/index.d.ts +3 -0
  115. package/dest/private_kernel/hints/index.d.ts.map +1 -0
  116. package/dest/{kernel_prover → private_kernel}/hints/index.js +1 -0
  117. package/dest/private_kernel/index.d.ts +3 -0
  118. package/dest/private_kernel/index.d.ts.map +1 -0
  119. package/dest/private_kernel/index.js +2 -0
  120. package/dest/private_kernel/private_kernel_execution_prover.d.ts +44 -0
  121. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -0
  122. package/dest/private_kernel/private_kernel_execution_prover.js +289 -0
  123. package/dest/private_kernel/private_kernel_oracle.d.ts +62 -0
  124. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -0
  125. package/dest/private_kernel/private_kernel_oracle.js +4 -0
  126. package/dest/private_kernel/private_kernel_oracle_impl.d.ts +45 -0
  127. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -0
  128. package/dest/{kernel_oracle/index.js → private_kernel/private_kernel_oracle_impl.js} +19 -9
  129. package/dest/pxe.d.ts +240 -0
  130. package/dest/pxe.d.ts.map +1 -0
  131. package/dest/pxe.js +771 -0
  132. package/dest/storage/address_data_provider/address_data_provider.d.ts +2 -4
  133. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +1 -1
  134. package/dest/storage/address_data_provider/address_data_provider.js +0 -3
  135. package/dest/storage/address_data_provider/index.d.ts +1 -1
  136. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +15 -6
  137. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
  138. package/dest/storage/capsule_data_provider/capsule_data_provider.js +85 -24
  139. package/dest/storage/capsule_data_provider/index.d.ts +1 -1
  140. package/dest/storage/contract_data_provider/contract_data_provider.d.ts +13 -58
  141. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
  142. package/dest/storage/contract_data_provider/contract_data_provider.js +89 -79
  143. package/dest/storage/contract_data_provider/index.d.ts +1 -2
  144. package/dest/storage/contract_data_provider/index.d.ts.map +1 -1
  145. package/dest/storage/contract_data_provider/index.js +0 -1
  146. package/dest/storage/contract_data_provider/private_functions_tree.d.ts +3 -42
  147. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +1 -1
  148. package/dest/storage/contract_data_provider/private_functions_tree.js +9 -61
  149. package/dest/storage/index.d.ts +3 -4
  150. package/dest/storage/index.d.ts.map +1 -1
  151. package/dest/storage/index.js +2 -3
  152. package/dest/storage/metadata.d.ts +2 -0
  153. package/dest/storage/metadata.d.ts.map +1 -0
  154. package/dest/storage/metadata.js +1 -0
  155. package/dest/storage/note_data_provider/index.d.ts +2 -2
  156. package/dest/storage/note_data_provider/index.d.ts.map +1 -1
  157. package/dest/storage/note_data_provider/index.js +1 -1
  158. package/dest/storage/note_data_provider/note_data_provider.d.ts +73 -10
  159. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
  160. package/dest/storage/note_data_provider/note_data_provider.js +145 -83
  161. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +37 -0
  162. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +1 -0
  163. package/dest/storage/private_event_data_provider/private_event_data_provider.js +105 -0
  164. package/dest/storage/sync_data_provider/index.d.ts +1 -1
  165. package/dest/storage/sync_data_provider/sync_data_provider.d.ts +3 -5
  166. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +1 -1
  167. package/dest/storage/sync_data_provider/sync_data_provider.js +2 -5
  168. package/dest/storage/tagging_data_provider/index.d.ts +1 -1
  169. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +29 -7
  170. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +1 -1
  171. package/dest/storage/tagging_data_provider/tagging_data_provider.js +48 -24
  172. package/dest/synchronizer/index.d.ts +1 -1
  173. package/dest/synchronizer/synchronizer.d.ts +8 -10
  174. package/dest/synchronizer/synchronizer.d.ts.map +1 -1
  175. package/dest/synchronizer/synchronizer.js +17 -19
  176. package/dest/tagging/constants.d.ts +2 -0
  177. package/dest/tagging/constants.d.ts.map +1 -0
  178. package/dest/tagging/constants.js +2 -0
  179. package/dest/tagging/index.d.ts +7 -0
  180. package/dest/tagging/index.d.ts.map +1 -0
  181. package/dest/tagging/index.js +5 -0
  182. package/dest/tagging/siloed_tag.d.ts +14 -0
  183. package/dest/tagging/siloed_tag.d.ts.map +1 -0
  184. package/dest/tagging/siloed_tag.js +20 -0
  185. package/dest/tagging/tag.d.ts +12 -0
  186. package/dest/tagging/tag.d.ts.map +1 -0
  187. package/dest/tagging/tag.js +17 -0
  188. package/dest/tagging/utils.d.ts +18 -0
  189. package/dest/tagging/utils.d.ts.map +1 -0
  190. package/dest/tagging/utils.js +24 -0
  191. package/package.json +37 -34
  192. package/src/bin/check_oracle_version.ts +50 -0
  193. package/src/config/index.ts +27 -55
  194. package/src/config/package_info.ts +1 -1
  195. package/src/contract_function_simulator/contract_function_simulator.ts +553 -0
  196. package/src/contract_function_simulator/execution_data_provider.ts +333 -0
  197. package/src/contract_function_simulator/execution_note_cache.ts +229 -0
  198. package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
  199. package/src/contract_function_simulator/hashed_values_cache.ts +47 -0
  200. package/src/contract_function_simulator/index.ts +13 -0
  201. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +47 -0
  202. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +27 -0
  203. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +69 -0
  204. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +61 -0
  205. package/src/contract_function_simulator/noir-structs/utility_context.ts +42 -0
  206. package/src/contract_function_simulator/oracle/index.ts +16 -0
  207. package/src/contract_function_simulator/oracle/interfaces.ts +170 -0
  208. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +23 -0
  209. package/src/contract_function_simulator/oracle/note_packing_utils.ts +54 -0
  210. package/src/contract_function_simulator/oracle/oracle.ts +583 -0
  211. package/src/contract_function_simulator/oracle/private_execution.ts +207 -0
  212. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +633 -0
  213. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +358 -0
  214. package/src/contract_function_simulator/pick_notes.ts +141 -0
  215. package/src/contract_function_simulator/proxied_contract_data_source.ts +66 -0
  216. package/src/contract_function_simulator/proxied_node.ts +33 -0
  217. package/src/contract_function_simulator/pxe_oracle_interface.ts +1008 -0
  218. package/src/entrypoints/client/bundle/index.ts +4 -2
  219. package/src/entrypoints/client/bundle/utils.ts +36 -36
  220. package/src/entrypoints/client/lazy/index.ts +4 -2
  221. package/src/entrypoints/client/lazy/utils.ts +36 -31
  222. package/src/entrypoints/{client/pxe_creation_options.ts → pxe_creation_options.ts} +4 -1
  223. package/src/entrypoints/server/index.ts +5 -3
  224. package/src/entrypoints/server/utils.ts +58 -50
  225. package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +36 -27
  226. package/src/oracle_version.ts +11 -0
  227. package/src/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.ts +158 -146
  228. package/src/private_kernel/hints/compute_side_effect_uniqueness_hints.ts +173 -0
  229. package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +58 -0
  230. package/src/{kernel_prover → private_kernel}/hints/index.ts +1 -0
  231. package/src/private_kernel/index.ts +2 -0
  232. package/src/private_kernel/private_kernel_execution_prover.ts +436 -0
  233. package/src/{kernel_prover/proving_data_oracle.ts → private_kernel/private_kernel_oracle.ts} +17 -29
  234. package/src/{kernel_oracle/index.ts → private_kernel/private_kernel_oracle_impl.ts} +30 -15
  235. package/src/pxe.ts +1085 -0
  236. package/src/storage/address_data_provider/address_data_provider.ts +1 -7
  237. package/src/storage/capsule_data_provider/capsule_data_provider.ts +97 -30
  238. package/src/storage/contract_data_provider/contract_data_provider.ts +109 -93
  239. package/src/storage/contract_data_provider/index.ts +0 -1
  240. package/src/storage/contract_data_provider/private_functions_tree.ts +11 -75
  241. package/src/storage/index.ts +2 -4
  242. package/src/storage/metadata.ts +1 -0
  243. package/src/storage/note_data_provider/index.ts +1 -1
  244. package/src/storage/note_data_provider/note_data_provider.ts +176 -122
  245. package/src/storage/private_event_data_provider/private_event_data_provider.ts +143 -0
  246. package/src/storage/sync_data_provider/sync_data_provider.ts +4 -10
  247. package/src/storage/tagging_data_provider/tagging_data_provider.ts +58 -30
  248. package/src/synchronizer/synchronizer.ts +21 -22
  249. package/src/tagging/constants.ts +2 -0
  250. package/src/tagging/index.ts +6 -0
  251. package/src/tagging/siloed_tag.ts +22 -0
  252. package/src/tagging/tag.ts +16 -0
  253. package/src/tagging/utils.ts +31 -0
  254. package/dest/bin/index.d.ts +0 -3
  255. package/dest/bin/index.d.ts.map +0 -1
  256. package/dest/bin/index.js +0 -28
  257. package/dest/entrypoints/client/pxe_creation_options.d.ts +0 -11
  258. package/dest/entrypoints/client/pxe_creation_options.d.ts.map +0 -1
  259. package/dest/kernel_oracle/index.d.ts +0 -45
  260. package/dest/kernel_oracle/index.d.ts.map +0 -1
  261. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
  262. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
  263. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +0 -270
  264. package/dest/kernel_prover/hints/index.d.ts +0 -2
  265. package/dest/kernel_prover/hints/index.d.ts.map +0 -1
  266. package/dest/kernel_prover/index.d.ts +0 -3
  267. package/dest/kernel_prover/index.d.ts.map +0 -1
  268. package/dest/kernel_prover/index.js +0 -2
  269. package/dest/kernel_prover/kernel_prover.d.ts +0 -38
  270. package/dest/kernel_prover/kernel_prover.d.ts.map +0 -1
  271. package/dest/kernel_prover/kernel_prover.js +0 -217
  272. package/dest/kernel_prover/proving_data_oracle.d.ts +0 -73
  273. package/dest/kernel_prover/proving_data_oracle.d.ts.map +0 -1
  274. package/dest/kernel_prover/proving_data_oracle.js +0 -4
  275. package/dest/note_decryption_utils/add_public_values_to_payload.d.ts +0 -11
  276. package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +0 -1
  277. package/dest/note_decryption_utils/add_public_values_to_payload.js +0 -47
  278. package/dest/pxe_http/index.d.ts +0 -2
  279. package/dest/pxe_http/index.d.ts.map +0 -1
  280. package/dest/pxe_http/index.js +0 -1
  281. package/dest/pxe_http/pxe_http_server.d.ts +0 -16
  282. package/dest/pxe_http/pxe_http_server.d.ts.map +0 -1
  283. package/dest/pxe_http/pxe_http_server.js +0 -27
  284. package/dest/pxe_oracle_interface/index.d.ts +0 -159
  285. package/dest/pxe_oracle_interface/index.d.ts.map +0 -1
  286. package/dest/pxe_oracle_interface/index.js +0 -692
  287. package/dest/pxe_oracle_interface/tagging_utils.d.ts +0 -17
  288. package/dest/pxe_oracle_interface/tagging_utils.d.ts.map +0 -1
  289. package/dest/pxe_oracle_interface/tagging_utils.js +0 -23
  290. package/dest/pxe_service/error_enriching.d.ts +0 -11
  291. package/dest/pxe_service/error_enriching.d.ts.map +0 -1
  292. package/dest/pxe_service/index.d.ts +0 -3
  293. package/dest/pxe_service/index.d.ts.map +0 -1
  294. package/dest/pxe_service/index.js +0 -2
  295. package/dest/pxe_service/pxe_service.d.ts +0 -111
  296. package/dest/pxe_service/pxe_service.d.ts.map +0 -1
  297. package/dest/pxe_service/pxe_service.js +0 -664
  298. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts +0 -11
  299. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts.map +0 -1
  300. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.js +0 -20
  301. package/dest/storage/auth_witness_data_provider/index.d.ts +0 -2
  302. package/dest/storage/auth_witness_data_provider/index.d.ts.map +0 -1
  303. package/dest/storage/auth_witness_data_provider/index.js +0 -1
  304. package/dest/storage/data_provider.d.ts +0 -4
  305. package/dest/storage/data_provider.d.ts.map +0 -1
  306. package/dest/storage/data_provider.js +0 -1
  307. package/dest/storage/note_data_provider/note_dao.d.ts +0 -106
  308. package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
  309. package/dest/storage/note_data_provider/note_dao.js +0 -106
  310. package/dest/test/pxe_test_suite.d.ts +0 -3
  311. package/dest/test/pxe_test_suite.d.ts.map +0 -1
  312. package/dest/test/pxe_test_suite.js +0 -97
  313. package/src/bin/index.ts +0 -38
  314. package/src/kernel_prover/index.ts +0 -2
  315. package/src/kernel_prover/kernel_prover.ts +0 -351
  316. package/src/note_decryption_utils/add_public_values_to_payload.ts +0 -64
  317. package/src/pxe_http/index.ts +0 -1
  318. package/src/pxe_http/pxe_http_server.ts +0 -29
  319. package/src/pxe_oracle_interface/index.ts +0 -925
  320. package/src/pxe_oracle_interface/tagging_utils.ts +0 -32
  321. package/src/pxe_service/index.ts +0 -2
  322. package/src/pxe_service/pxe_service.ts +0 -949
  323. package/src/storage/auth_witness_data_provider/auth_witness_data_provider.ts +0 -34
  324. package/src/storage/auth_witness_data_provider/index.ts +0 -1
  325. package/src/storage/data_provider.ts +0 -3
  326. package/src/storage/note_data_provider/note_dao.ts +0 -162
  327. package/src/test/pxe_test_suite.ts +0 -111
  328. /package/dest/entrypoints/{client/pxe_creation_options.js → pxe_creation_options.js} +0 -0
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
- # PXE Service & PXE
1
+ # PXE & PXE
2
2
 
3
- `PXE Service` (pronounced "pixie service") is a server-side software that provides a set of apis for interacting with the Aztec network. It acts as a bridge between the network and client applications by exposing methods to manage accounts, deploy contracts, create transactions, and retrieve public and account-specific information. It provides a secure environment for the execution of sensitive operations, ensuring private information and decrypted data are not accessible to unauthorized applications. The PXE Service is a critical component of the Aztec network, and its security and reliability are essential to the overall trustworthiness of user's data.
3
+ `PXE` (pronounced "pixie service") is a server-side software that provides a set of apis for interacting with the Aztec network. It acts as a bridge between the network and client applications by exposing methods to manage accounts, deploy contracts, create transactions, and retrieve public and account-specific information. It provides a secure environment for the execution of sensitive operations, ensuring private information and decrypted data are not accessible to unauthorized applications. The PXE is a critical component of the Aztec network, and its security and reliability are essential to the overall trustworthiness of user's data.
4
4
 
5
- `PXE` is the interface the PXE Service and every client-side instance implement. Various implementations of the client-side can exist, including those for different platforms such as mobile apps and web browsers. It is a relay between the dApps and the actual PXE Service.
5
+ `PXE` is the interface the PXE and every client-side instance implement. Various implementations of the client-side can exist, including those for different platforms such as mobile apps and web browsers. It is a relay between the dApps and the actual PXE.
6
6
 
7
- ### Main Components in an PXE Service
7
+ ### Main Components in an PXE
8
8
 
9
9
  - [Simulator](../simulator/)
10
10
  - [Key Store](../key-store/)
11
11
  - [Account State](./src/account_state/account_state.ts): It coordinates other components to synchronize and decrypt data, simulate transactions, and generate kernel proofs, for a specific account.
12
12
 
13
- ![Pixie](./pixie.png)
13
+ ![Pixie](./pixie.png)
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hlY2tfb3JhY2xlX3ZlcnNpb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iaW4vY2hlY2tfb3JhY2xlX3ZlcnNpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check_oracle_version.d.ts","sourceRoot":"","sources":["../../src/bin/check_oracle_version.ts"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
1
+ import { keccak256String } from '@aztec/foundation/crypto';
2
+ import { Oracle } from '../contract_function_simulator/oracle/oracle.js';
3
+ import { ORACLE_INTERFACE_HASH } from '../oracle_version.js';
4
+ /**
5
+ * Verifies that the Oracle interface matches the expected interface hash.
6
+ *
7
+ * The Oracle interface needs to be versioned to ensure compatibility between Aztec.nr and PXE. This function computes
8
+ * a hash of the Oracle interface and compares it against a known hash. If they don't match, it means the interface has
9
+ * changed and the ORACLE_VERSION constant needs to be incremented and the ORACLE_INTERFACE_HASH constant needs to be
10
+ * updated.
11
+ *
12
+ * TODO(#16581): The following only takes into consideration changes to the oracles defined in Oracle.ts and omits TXE
13
+ * oracles. Ensure this checks TXE oracles as well. This hasn't been implemented yet since we don't have a clean TXE
14
+ * oracle interface like we do in PXE (i.e., there is no single Oracle class that contains only the oracles).
15
+ */ function assertOracleInterfaceMatches() {
16
+ const excludedProps = [
17
+ 'handler',
18
+ 'constructor',
19
+ 'toACIRCallback',
20
+ 'handlerAsMisc',
21
+ 'handlerAsUtility',
22
+ 'handlerAsPrivate'
23
+ ];
24
+ // Create a hashable representation of the oracle interface by concatenating its method names. Return values are
25
+ // excluded from the hash calculation since they are typically arrays of fields and I didn't manage to reliably
26
+ // stringify them.
27
+ // TODO(#16581): we're only checking the functions implemented by the Oracle object, which is really an ACVM
28
+ // translator, akin to TXE's RPC translator. This is correct in that it is ultimately the foreign interface that
29
+ // matters, but incorrect in that it does not take into consideration TXE's extended interface. An improvement would
30
+ // be to check RPCTranslator from TXE, though that still seems a bit fragile.
31
+ const oracleInterfaceMethodNames = Object.getOwnPropertyNames(Oracle.prototype).filter((name)=>!excludedProps.includes(name)).sort().join('');
32
+ // We use keccak256 here just because we already have it in the dependencies.
33
+ const oracleInterfaceHash = keccak256String(oracleInterfaceMethodNames);
34
+ if (oracleInterfaceHash !== ORACLE_INTERFACE_HASH) {
35
+ // This check exists only to notify you when you need to update the ORACLE_VERSION constant.
36
+ throw new Error(`The Oracle interface has changed, which implies a breaking change in the aztec.nr/PXE oracle interface. Update ORACLE_INTERFACE_HASH to ${oracleInterfaceHash} and bump ORACLE_VERSION in pxe/src/oracle_version.ts.`);
37
+ }
38
+ }
39
+ assertOracleInterfaceMatches();
@@ -1,16 +1,7 @@
1
1
  import { type ConfigMappingsType } from '@aztec/foundation/config';
2
2
  import { type DataStoreConfig } from '@aztec/kv-store/config';
3
3
  import { type ChainConfig } from '@aztec/stdlib/config';
4
- import type { Network } from '@aztec/stdlib/network';
5
4
  export { getPackageInfo } from './package_info.js';
6
- /**
7
- * Temporary configuration until WASM can be used instead of native
8
- */
9
- export interface BBProverConfig {
10
- bbWorkingDirectory?: string;
11
- bbBinaryPath?: string;
12
- bbSkipCleanup?: boolean;
13
- }
14
5
  /**
15
6
  * Configuration settings for the prover factory
16
7
  */
@@ -19,30 +10,26 @@ export interface KernelProverConfig {
19
10
  proverEnabled?: boolean;
20
11
  }
21
12
  /**
22
- * Configuration settings for the PXE.
13
+ * Configuration settings for the synchronizer.
23
14
  */
24
- export interface PXEConfig {
25
- /** L2 block to start scanning from for new accounts */
26
- l2StartingBlock: number;
15
+ export interface SynchronizerConfig {
16
+ /** Maximum amount of blocks to pull from the stream in one request when synchronizing */
17
+ l2BlockBatchSize: number;
27
18
  }
28
- export type PXEServiceConfig = PXEConfig & KernelProverConfig & BBProverConfig & DataStoreConfig & ChainConfig;
19
+ export type PXEConfig = KernelProverConfig & DataStoreConfig & ChainConfig & SynchronizerConfig;
29
20
  export type CliPXEOptions = {
30
- /** External Aztec network to connect to. e.g. devnet */
31
- network?: Network;
32
- /** API Key required by the external network's node */
33
- apiKey?: string;
34
21
  /** Custom Aztec Node URL to connect to */
35
22
  nodeUrl?: string;
36
23
  };
37
- export declare const pxeConfigMappings: ConfigMappingsType<PXEServiceConfig>;
24
+ export declare const pxeConfigMappings: ConfigMappingsType<PXEConfig>;
38
25
  /**
39
- * Creates an instance of PXEServiceConfig out of environment variables using sensible defaults for integration testing if not set.
26
+ * Creates an instance of PXEConfig out of environment variables using sensible defaults for integration testing if not set.
40
27
  */
41
- export declare function getPXEServiceConfig(): PXEServiceConfig;
28
+ export declare function getPXEConfig(): PXEConfig;
42
29
  export declare const pxeCliConfigMappings: ConfigMappingsType<CliPXEOptions>;
43
- export declare const allPxeConfigMappings: ConfigMappingsType<CliPXEOptions & PXEServiceConfig>;
30
+ export declare const allPxeConfigMappings: ConfigMappingsType<CliPXEOptions & PXEConfig>;
44
31
  /**
45
32
  * Creates an instance of CliPxeOptions out of environment variables
46
33
  */
47
- export declare function getCliPXEOptions(): CliPXEOptions & PXEServiceConfig;
48
- //# sourceMappingURL=index.d.ts.map
34
+ export declare function getCliPXEOptions(): CliPXEOptions & PXEConfig;
35
+ //# sourceMappingURL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AgB,gBAAgB,IAAI,aAAa,GAAG,SAAS,CAQ5D"}
@@ -1,4 +1,3 @@
1
- import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
2
1
  import { booleanConfigHelper, getConfigFromMappings, numberConfigHelper, parseBooleanEnv } from '@aztec/foundation/config';
3
2
  import { dataConfigMappings } from '@aztec/kv-store/config';
4
3
  import { chainConfigMappings } from '@aztec/stdlib/config';
@@ -6,45 +5,30 @@ export { getPackageInfo } from './package_info.js';
6
5
  export const pxeConfigMappings = {
7
6
  ...dataConfigMappings,
8
7
  ...chainConfigMappings,
9
- l2StartingBlock: {
10
- env: 'PXE_L2_STARTING_BLOCK',
11
- ...numberConfigHelper(INITIAL_L2_BLOCK_NUM),
12
- description: 'L2 block to start scanning from for new accounts'
13
- },
14
- bbBinaryPath: {
15
- env: 'BB_BINARY_PATH',
16
- description: 'Path to the BB binary'
17
- },
18
- bbWorkingDirectory: {
19
- env: 'BB_WORKING_DIRECTORY',
20
- description: 'Working directory for the BB binary'
21
- },
22
- bbSkipCleanup: {
23
- env: 'BB_SKIP_CLEANUP',
24
- description: 'True to skip cleanup of temporary files for debugging purposes',
25
- ...booleanConfigHelper()
8
+ l2BlockBatchSize: {
9
+ env: 'PXE_L2_BLOCK_BATCH_SIZE',
10
+ ...numberConfigHelper(50),
11
+ description: 'Maximum amount of blocks to pull from the stream in one request when synchronizing'
26
12
  },
13
+ // TODO: We're losing this feature in moving to bb.js api.
14
+ // Reimplement it as a setting that dumps the msgpack data on the bb.js backend if needed.
15
+ // bbSkipCleanup: {
16
+ // env: 'BB_SKIP_CLEANUP',
17
+ // description: 'True to skip cleanup of temporary files for debugging purposes',
18
+ // ...booleanConfigHelper(),
19
+ // },
27
20
  proverEnabled: {
28
21
  env: 'PXE_PROVER_ENABLED',
29
22
  description: 'Enable real proofs',
30
- ...booleanConfigHelper()
23
+ ...booleanConfigHelper(true)
31
24
  }
32
25
  };
33
26
  /**
34
- * Creates an instance of PXEServiceConfig out of environment variables using sensible defaults for integration testing if not set.
35
- */ export function getPXEServiceConfig() {
27
+ * Creates an instance of PXEConfig out of environment variables using sensible defaults for integration testing if not set.
28
+ */ export function getPXEConfig() {
36
29
  return getConfigFromMappings(pxeConfigMappings);
37
30
  }
38
31
  export const pxeCliConfigMappings = {
39
- network: {
40
- env: 'NETWORK',
41
- parseEnv: (val)=>val,
42
- description: 'External Aztec network to connect to. e.g. devnet'
43
- },
44
- apiKey: {
45
- env: 'API_KEY',
46
- description: "API Key required by the external network's node"
47
- },
48
32
  nodeUrl: {
49
33
  env: 'AZTEC_NODE_URL',
50
34
  description: 'Custom Aztec Node URL to connect to'
@@ -58,17 +42,18 @@ export const allPxeConfigMappings = {
58
42
  env: 'PXE_PROVER_ENABLED',
59
43
  parseEnv: (val)=>parseBooleanEnv(val) || !!process.env.NETWORK,
60
44
  description: 'Enable real proofs',
61
- isBoolean: true
45
+ isBoolean: true,
46
+ defaultValue: true
62
47
  }
63
48
  };
64
49
  /**
65
50
  * Creates an instance of CliPxeOptions out of environment variables
66
51
  */ export function getCliPXEOptions() {
67
- const pxeConfig = getPXEServiceConfig();
52
+ const pxeConfig = getPXEConfig();
68
53
  const cliOptions = getConfigFromMappings(pxeCliConfigMappings);
69
54
  return {
70
55
  ...pxeConfig,
71
56
  ...cliOptions,
72
- proverEnabled: pxeConfig.proverEnabled || !!cliOptions.network
57
+ proverEnabled: pxeConfig.proverEnabled
73
58
  };
74
59
  }
@@ -2,4 +2,4 @@ export declare function getPackageInfo(): {
2
2
  version: string;
3
3
  name: string;
4
4
  };
5
- //# sourceMappingURL=package_info.d.ts.map
5
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFja2FnZV9pbmZvLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29uZmlnL3BhY2thZ2VfaW5mby50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSx3QkFBZ0IsY0FBYzs7O0VBRTdCIn0=
@@ -1,6 +1,6 @@
1
1
  export function getPackageInfo() {
2
2
  return {
3
- version: '0.1.0',
3
+ version: '3.0.0',
4
4
  name: '@aztec/pxe'
5
5
  };
6
6
  }
@@ -0,0 +1,56 @@
1
+ import { Fr } from '@aztec/foundation/fields';
2
+ import { type CircuitSimulator } from '@aztec/simulator/client';
3
+ import type { FunctionCall } from '@aztec/stdlib/abi';
4
+ import { FunctionSelector } from '@aztec/stdlib/abi';
5
+ import type { AuthWitness } from '@aztec/stdlib/auth-witness';
6
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
7
+ import { type PrivateKernelExecutionProofOutput, PrivateKernelTailCircuitPublicInputs } from '@aztec/stdlib/kernel';
8
+ import { PrivateExecutionResult, TxExecutionRequest } from '@aztec/stdlib/tx';
9
+ import type { ContractDataProvider } from '../storage/index.js';
10
+ import type { ExecutionDataProvider } from './execution_data_provider.js';
11
+ /**
12
+ * The contract function simulator.
13
+ */
14
+ export declare class ContractFunctionSimulator {
15
+ private executionDataProvider;
16
+ private simulator;
17
+ private log;
18
+ constructor(executionDataProvider: ExecutionDataProvider, simulator: CircuitSimulator);
19
+ /**
20
+ * Runs a private function.
21
+ * @param request - The transaction request.
22
+ * @param entryPointArtifact - The artifact of the entry point function.
23
+ * @param contractAddress - The address of the contract (should match request.origin)
24
+ * @param msgSender - The address calling the function. This can be replaced to simulate a call from another contract
25
+ * or a specific account.
26
+ * @param senderForTags - The address that is used as a tagging sender when emitting private logs. Returned from
27
+ * the `privateGetSenderForTags` oracle.
28
+ * @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
29
+ * @returns The result of the execution.
30
+ */
31
+ run(request: TxExecutionRequest, contractAddress: AztecAddress, selector: FunctionSelector, msgSender?: AztecAddress, senderForTags?: AztecAddress, scopes?: AztecAddress[]): Promise<PrivateExecutionResult>;
32
+ /**
33
+ * Runs a utility function.
34
+ * @param call - The function call to execute.
35
+ * @param authwits - Authentication witnesses required for the function call.
36
+ * @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
37
+ * accounts if not specified.
38
+ * @returns A return value of the utility function in a form as returned by the simulator (Noir fields)
39
+ */
40
+ runUtility(call: FunctionCall, authwits: AuthWitness[], scopes?: AztecAddress[]): Promise<Fr[]>;
41
+ getStats(): import("./execution_data_provider.js").ExecutionStats;
42
+ }
43
+ /**
44
+ * Generates the final public inputs of the tail kernel circuit, an empty Chonk proof
45
+ * and the execution steps for a `PrivateExecutionResult` as if it had been
46
+ * processed by the private kernel prover. This skips many of the checks performed by the kernels
47
+ * (allowing state overrides) and is much faster, while still generating a valid
48
+ * output that can be sent to the node for public simulation
49
+ * @param privateExecutionResult - The result of the private execution.
50
+ * @param nonceGenerator - A nonce generator for note hashes. According to the protocol rules,
51
+ * it can either be the first nullifier in the tx or the hash of the initial tx request if there are none.
52
+ * @param contractDataProvider - A provider for contract data in order to get function names and debug info.
53
+ * @returns The simulated proving result.
54
+ */
55
+ export declare function generateSimulatedProvingResult(privateExecutionResult: PrivateExecutionResult, nonceGenerator: Fr, contractDataProvider: ContractDataProvider): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>>;
56
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3RfZnVuY3Rpb25fc2ltdWxhdG9yLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3RfZnVuY3Rpb25fc2ltdWxhdG9yL2NvbnRyYWN0X2Z1bmN0aW9uX3NpbXVsYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFvQkEsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBSzlDLE9BQU8sRUFDTCxLQUFLLGdCQUFnQixFQU90QixNQUFNLHlCQUF5QixDQUFDO0FBQ2pDLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFN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FlBQVksRUFBRSxRQUFRLEVBQUUsV0FBVyxFQUFFLEVBQUUsTUFBTSxDQUFDLEVBQUUsWUFBWSxFQUFFLEdBQUcsT0FBTyxDQUFDLEVBQUUsRUFBRSxDQUFDLENBc0MzRztJQUdELFFBQVEsMERBRVA7Q0FDRjtBQVlEOzs7Ozs7Ozs7OztHQVdHO0FBQ0gsd0JBQXNCLDhCQUE4QixDQUNsRCxzQkFBc0IsRUFBRSxzQkFBc0IsRUFDOUMsY0FBYyxFQUFFLEVBQUUsRUFDbEIsb0JBQW9CLEVBQUUsb0JBQW9CLEdBQ3pDLE9BQU8sQ0FBQyxpQ0FBaUMsQ0FBQyxvQ0FBb0MsQ0FBQyxDQUFDLENBZ05sRiJ9
@@ -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,0BAA0B,CAAC;AAK9C,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,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAS3D,OAAO,EAIL,KAAK,iCAAiC,EACtC,oCAAoC,EAKrC,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAGL,sBAAsB,EAEtB,kBAAkB,EAGnB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAS1E;;GAEG;AACH,qBAAa,yBAAyB;IAIlC,OAAO,CAAC,qBAAqB;IAC7B,OAAO,CAAC,SAAS;IAJnB,OAAO,CAAC,GAAG,CAAS;IAEpB,YACU,qBAAqB,EAAE,qBAAqB,EAC5C,SAAS,EAAE,gBAAgB,EAGpC;IAED;;;;;;;;;;;OAWG;IACU,GAAG,CACd,OAAO,EAAE,kBAAkB,EAC3B,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,eAA6C,EACtD,aAAa,CAAC,EAAE,YAAY,EAC5B,MAAM,CAAC,EAAE,YAAY,EAAE,GACtB,OAAO,CAAC,sBAAsB,CAAC,CAgGjC;IAGD;;;;;;;OAOG;IACU,UAAU,CAAC,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,EAAE,EAAE,CAAC,CAsC3G;IAGD,QAAQ,0DAEP;CACF;AAYD;;;;;;;;;;;GAWG;AACH,wBAAsB,8BAA8B,CAClD,sBAAsB,EAAE,sBAAsB,EAC9C,cAAc,EAAE,EAAE,EAClB,oBAAoB,EAAE,oBAAoB,GACzC,OAAO,CAAC,iCAAiC,CAAC,oCAAoC,CAAC,CAAC,CAgNlF"}
@@ -0,0 +1,300 @@
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';
4
+ import { Fr } from '@aztec/foundation/fields';
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, verifyCurrentClassId } 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
+ executionDataProvider;
30
+ simulator;
31
+ log;
32
+ constructor(executionDataProvider, simulator){
33
+ this.executionDataProvider = executionDataProvider;
34
+ this.simulator = simulator;
35
+ this.log = createLogger('simulator');
36
+ }
37
+ /**
38
+ * Runs a private function.
39
+ * @param request - The transaction request.
40
+ * @param entryPointArtifact - The artifact of the entry point function.
41
+ * @param contractAddress - The address of the contract (should match request.origin)
42
+ * @param msgSender - The address calling the function. This can be replaced to simulate a call from another contract
43
+ * or a specific account.
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
+ * @returns The result of the execution.
48
+ */ async run(request, contractAddress, selector, msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE), senderForTags, scopes) {
49
+ const simulatorSetupTimer = new Timer();
50
+ const anchorBlockHeader = await this.executionDataProvider.getAnchorBlockHeader();
51
+ await verifyCurrentClassId(contractAddress, this.executionDataProvider);
52
+ const entryPointArtifact = await this.executionDataProvider.getFunctionArtifact(contractAddress, selector);
53
+ if (entryPointArtifact.functionType !== FunctionType.PRIVATE) {
54
+ throw new Error(`Cannot run ${entryPointArtifact.functionType} function as private`);
55
+ }
56
+ if (request.origin !== contractAddress) {
57
+ this.log.warn(`Request origin does not match contract address in simulation. Request origin: ${request.origin}, contract address: ${contractAddress}`);
58
+ }
59
+ // reserve the first side effect for the tx hash (inserted by the private kernel)
60
+ const startSideEffectCounter = 2;
61
+ const callContext = new CallContext(msgSender, contractAddress, await FunctionSelector.fromNameAndParameters(entryPointArtifact.name, entryPointArtifact.parameters), entryPointArtifact.isStatic);
62
+ const protocolNullifier = await computeProtocolNullifier(await request.toTxRequest().hash());
63
+ const noteCache = new ExecutionNoteCache(protocolNullifier);
64
+ const taggingIndexCache = new ExecutionTaggingIndexCache();
65
+ const privateExecutionOracle = new PrivateExecutionOracle(request.firstCallArgsHash, request.txContext, callContext, anchorBlockHeader, request.authWitnesses, request.capsules, HashedValuesCache.create(request.argsOfCalls), noteCache, taggingIndexCache, this.executionDataProvider, 0, startSideEffectCounter, undefined, scopes, senderForTags, this.simulator);
66
+ const setupTime = simulatorSetupTimer.ms();
67
+ try {
68
+ // Note: any nested private function calls are made recursively within this
69
+ // function call. So this execution result is the result of executing _all_
70
+ // private functions of this tx (the results of those executions are contained
71
+ // within executionResult.nestedExecutionResults).
72
+ const executionResult = await executePrivateFunction(this.simulator, privateExecutionOracle, entryPointArtifact, contractAddress, request.functionSelector);
73
+ const simulatorTeardownTimer = new Timer();
74
+ const { usedProtocolNullifierForNonces } = noteCache.finish();
75
+ const firstNullifierHint = usedProtocolNullifierForNonces ? Fr.ZERO : noteCache.getAllNullifiers()[0];
76
+ const publicCallRequests = collectNested([
77
+ executionResult
78
+ ], (r)=>r.publicInputs.publicCallRequests.getActiveItems().map((r)=>r.inner).concat(r.publicInputs.publicTeardownCallRequest.isEmpty() ? [] : [
79
+ r.publicInputs.publicTeardownCallRequest
80
+ ]));
81
+ const publicFunctionsCalldata = await Promise.all(publicCallRequests.map(async (r)=>{
82
+ const calldata = await privateExecutionOracle.privateLoadFromExecutionCache(r.calldataHash);
83
+ return new HashedValues(calldata, r.calldataHash);
84
+ }));
85
+ const teardownTime = simulatorTeardownTimer.ms();
86
+ // Add simulator overhead to topmost call in the stack
87
+ if (executionResult.profileResult) {
88
+ executionResult.profileResult.timings.witgen += setupTime + teardownTime;
89
+ }
90
+ // Not to be confused with a PrivateCallExecutionResult. This is a superset
91
+ // of the PrivateCallExecutionResult, containing also firstNullifierHint
92
+ // and publicFunctionsCalldata.
93
+ return new PrivateExecutionResult(executionResult, firstNullifierHint, publicFunctionsCalldata);
94
+ } catch (err) {
95
+ throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
96
+ }
97
+ }
98
+ // docs:start:execute_utility_function
99
+ /**
100
+ * Runs a utility function.
101
+ * @param call - The function call to execute.
102
+ * @param authwits - Authentication witnesses required for the function call.
103
+ * @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
104
+ * accounts if not specified.
105
+ * @returns A return value of the utility function in a form as returned by the simulator (Noir fields)
106
+ */ async runUtility(call, authwits, scopes) {
107
+ await verifyCurrentClassId(call.to, this.executionDataProvider);
108
+ const entryPointArtifact = await this.executionDataProvider.getFunctionArtifact(call.to, call.selector);
109
+ if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
110
+ throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
111
+ }
112
+ const oracle = new UtilityExecutionOracle(call.to, authwits, [], this.executionDataProvider, undefined, scopes);
113
+ try {
114
+ this.log.verbose(`Executing utility function ${entryPointArtifact.name}`, {
115
+ contract: call.to,
116
+ selector: call.selector
117
+ });
118
+ const initialWitness = toACVMWitness(0, call.args);
119
+ const acirExecutionResult = await this.simulator.executeUserCircuit(initialWitness, entryPointArtifact, new Oracle(oracle).toACIRCallback()).catch((err)=>{
120
+ err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
121
+ throw new ExecutionError(err.message, {
122
+ contractAddress: call.to,
123
+ functionSelector: call.selector
124
+ }, extractCallStack(err, entryPointArtifact.debug), {
125
+ cause: err
126
+ });
127
+ });
128
+ this.log.verbose(`Utility simulation for ${call.to}.${call.selector} completed`);
129
+ return witnessMapToFields(acirExecutionResult.returnWitness);
130
+ } catch (err) {
131
+ throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
132
+ }
133
+ }
134
+ // docs:end:execute_utility_function
135
+ getStats() {
136
+ return this.executionDataProvider.getStats();
137
+ }
138
+ }
139
+ class OrderedSideEffect {
140
+ sideEffect;
141
+ counter;
142
+ constructor(sideEffect, counter){
143
+ this.sideEffect = sideEffect;
144
+ this.counter = counter;
145
+ }
146
+ }
147
+ /**
148
+ * Generates the final public inputs of the tail kernel circuit, an empty Chonk proof
149
+ * and the execution steps for a `PrivateExecutionResult` as if it had been
150
+ * processed by the private kernel prover. This skips many of the checks performed by the kernels
151
+ * (allowing state overrides) and is much faster, while still generating a valid
152
+ * output that can be sent to the node for public simulation
153
+ * @param privateExecutionResult - The result of the private execution.
154
+ * @param nonceGenerator - A nonce generator for note hashes. According to the protocol rules,
155
+ * it can either be the first nullifier in the tx or the hash of the initial tx request if there are none.
156
+ * @param contractDataProvider - A provider for contract data in order to get function names and debug info.
157
+ * @returns The simulated proving result.
158
+ */ export async function generateSimulatedProvingResult(privateExecutionResult, nonceGenerator, contractDataProvider) {
159
+ const siloedNoteHashes = [];
160
+ const nullifiers = [];
161
+ const taggedPrivateLogs = [];
162
+ const l2ToL1Messages = [];
163
+ const contractClassLogsHashes = [];
164
+ const publicCallRequests = [];
165
+ const executionSteps = [];
166
+ let publicTeardownCallRequest;
167
+ const executions = [
168
+ privateExecutionResult.entrypoint
169
+ ];
170
+ while(executions.length !== 0){
171
+ const execution = executions.shift();
172
+ executions.unshift(...execution.nestedExecutionResults);
173
+ const { contractAddress } = execution.publicInputs.callContext;
174
+ 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)));
175
+ const nullifiersFromExecution = await Promise.all(execution.publicInputs.nullifiers.getActiveItems().map(async (nullifier)=>new OrderedSideEffect(await siloNullifier(contractAddress, nullifier.value), nullifier.counter)));
176
+ const privateLogsFromExecution = await Promise.all(execution.publicInputs.privateLogs.getActiveItems().map(async (metadata)=>{
177
+ metadata.log.fields[0] = await poseidon2Hash([
178
+ contractAddress,
179
+ metadata.log.fields[0]
180
+ ]);
181
+ return new OrderedSideEffect(metadata.log, metadata.counter);
182
+ }));
183
+ siloedNoteHashes.push(...noteHashesFromExecution);
184
+ taggedPrivateLogs.push(...privateLogsFromExecution);
185
+ nullifiers.push(...nullifiersFromExecution);
186
+ l2ToL1Messages.push(...execution.publicInputs.l2ToL1Msgs.getActiveItems().map((message)=>new OrderedSideEffect(message.message.scope(contractAddress), message.counter)));
187
+ contractClassLogsHashes.push(...execution.publicInputs.contractClassLogsHashes.getActiveItems().map((contractClassLogHash)=>new OrderedSideEffect(contractClassLogHash.logHash.scope(contractAddress), contractClassLogHash.counter)));
188
+ publicCallRequests.push(...execution.publicInputs.publicCallRequests.getActiveItems().map((callRequest)=>new OrderedSideEffect(callRequest.inner, callRequest.counter)));
189
+ if (publicTeardownCallRequest !== undefined && !execution.publicInputs.publicTeardownCallRequest.isEmpty()) {
190
+ throw new Error('Trying to set multiple teardown requests');
191
+ }
192
+ publicTeardownCallRequest = execution.publicInputs.publicTeardownCallRequest.isEmpty() ? publicTeardownCallRequest : execution.publicInputs.publicTeardownCallRequest;
193
+ executionSteps.push({
194
+ functionName: await contractDataProvider.getDebugFunctionName(execution.publicInputs.callContext.contractAddress, execution.publicInputs.callContext.functionSelector),
195
+ timings: execution.profileResult?.timings ?? {
196
+ witgen: 0,
197
+ oracles: {}
198
+ },
199
+ bytecode: execution.acir,
200
+ vk: execution.vk,
201
+ witness: execution.partialWitness
202
+ });
203
+ }
204
+ const constantData = new TxConstantData(privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader, privateExecutionResult.entrypoint.publicInputs.txContext, getVKTreeRoot(), protocolContractsHash);
205
+ const hasPublicCalls = privateExecutionResult.publicFunctionCalldata.length !== 0;
206
+ let inputsForRollup;
207
+ let inputsForPublic;
208
+ let gasUsed;
209
+ const sortByCounter = (a, b)=>a.counter - b.counter;
210
+ const getEffect = (orderedSideEffect)=>orderedSideEffect.sideEffect;
211
+ const isPrivateOnlyTx = privateExecutionResult.publicFunctionCalldata.length === 0;
212
+ const minRevertibleSideEffectCounter = getFinalMinRevertibleSideEffectCounter(privateExecutionResult);
213
+ const [nonRevertibleNullifiers, revertibleNullifiers] = splitOrderedSideEffects(nullifiers.sort(sortByCounter), minRevertibleSideEffectCounter);
214
+ if (nonRevertibleNullifiers.length > 0 && !nonRevertibleNullifiers[0].equals(nonceGenerator)) {
215
+ throw new Error('The first non revertible nullifier should be equal to the nonce generator. This is a bug!');
216
+ } else {
217
+ nonRevertibleNullifiers.unshift(nonceGenerator);
218
+ }
219
+ if (isPrivateOnlyTx) {
220
+ // We must make the note hashes unique by using the
221
+ // nonce generator and their index in the tx.
222
+ const uniqueNoteHashes = await Promise.all(siloedNoteHashes.sort(sortByCounter).map(async (orderedSideEffect, i)=>{
223
+ const siloedNoteHash = orderedSideEffect.sideEffect;
224
+ const nonce = await computeNoteHashNonce(nonceGenerator, i);
225
+ const uniqueNoteHash = await computeUniqueNoteHash(nonce, siloedNoteHash);
226
+ return uniqueNoteHash;
227
+ }));
228
+ 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));
229
+ gasUsed = meterGasUsed(accumulatedDataForRollup);
230
+ inputsForRollup = new PartialPrivateTailPublicInputsForRollup(accumulatedDataForRollup);
231
+ } else {
232
+ const [nonRevertibleNoteHashes, revertibleNoteHashes] = splitOrderedSideEffects(siloedNoteHashes.sort(sortByCounter), minRevertibleSideEffectCounter);
233
+ const [nonRevertibleL2ToL1Messages, revertibleL2ToL1Messages] = splitOrderedSideEffects(l2ToL1Messages.sort(sortByCounter), minRevertibleSideEffectCounter);
234
+ const [nonRevertibleTaggedPrivateLogs, revertibleTaggedPrivateLogs] = splitOrderedSideEffects(taggedPrivateLogs, minRevertibleSideEffectCounter);
235
+ const [nonRevertibleContractClassLogHashes, revertibleContractClassLogHashes] = splitOrderedSideEffects(contractClassLogsHashes.sort(sortByCounter), minRevertibleSideEffectCounter);
236
+ const [nonRevertiblePublicCallRequests, revertiblePublicCallRequests] = splitOrderedSideEffects(publicCallRequests.sort(sortByCounter), minRevertibleSideEffectCounter);
237
+ const nonRevertibleData = new PrivateToPublicAccumulatedData(padArrayEnd(nonRevertibleNoteHashes, 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));
238
+ 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));
239
+ gasUsed = meterGasUsed(revertibleData).add(meterGasUsed(nonRevertibleData));
240
+ if (publicTeardownCallRequest) {
241
+ gasUsed.add(privateExecutionResult.entrypoint.publicInputs.txContext.gasSettings.teardownGasLimits);
242
+ }
243
+ inputsForPublic = new PartialPrivateTailPublicInputsForPublic(nonRevertibleData, revertibleData, publicTeardownCallRequest ?? PublicCallRequest.empty());
244
+ }
245
+ const publicInputs = new PrivateKernelTailCircuitPublicInputs(constantData, /*gasUsed=*/ gasUsed.add(Gas.from({
246
+ l2Gas: FIXED_L2_GAS,
247
+ daGas: FIXED_DA_GAS
248
+ })), /*feePayer=*/ AztecAddress.zero(), /*includeByTimestamp=*/ 0n, hasPublicCalls ? inputsForPublic : undefined, !hasPublicCalls ? inputsForRollup : undefined);
249
+ return {
250
+ publicInputs,
251
+ chonkProof: ChonkProof.empty(),
252
+ executionSteps
253
+ };
254
+ }
255
+ function splitOrderedSideEffects(effects, minRevertibleSideEffectCounter) {
256
+ const revertibleSideEffects = [];
257
+ const nonRevertibleSideEffects = [];
258
+ effects.forEach((effect)=>{
259
+ if (effect.counter < minRevertibleSideEffectCounter) {
260
+ nonRevertibleSideEffects.push(effect.sideEffect);
261
+ } else {
262
+ revertibleSideEffects.push(effect.sideEffect);
263
+ }
264
+ });
265
+ return [
266
+ nonRevertibleSideEffects,
267
+ revertibleSideEffects
268
+ ];
269
+ }
270
+ function meterGasUsed(data) {
271
+ let meteredDAFields = 0;
272
+ let meteredL2Gas = 0;
273
+ const numNoteHashes = arrayNonEmptyLength(data.noteHashes, (hash)=>hash.isEmpty());
274
+ meteredDAFields += numNoteHashes;
275
+ meteredL2Gas += numNoteHashes * AVM_EMITNOTEHASH_BASE_L2_GAS;
276
+ const numNullifiers = arrayNonEmptyLength(data.nullifiers, (nullifier)=>nullifier.isEmpty());
277
+ meteredDAFields += numNullifiers;
278
+ meteredL2Gas += numNullifiers * AVM_EMITNULLIFIER_BASE_L2_GAS;
279
+ const numL2toL1Messages = arrayNonEmptyLength(data.l2ToL1Msgs, (msg)=>msg.isEmpty());
280
+ meteredDAFields += numL2toL1Messages;
281
+ meteredL2Gas += numL2toL1Messages * AVM_SENDL2TOL1MSG_BASE_L2_GAS;
282
+ const numPrivatelogs = arrayNonEmptyLength(data.privateLogs, (log)=>log.isEmpty());
283
+ // Every private log emits its length as an additional field
284
+ meteredDAFields += data.privateLogs.reduce((acc, log)=>!log.isEmpty() ? acc + log.emittedLength + 1 : acc, 0);
285
+ meteredL2Gas += numPrivatelogs * L2_GAS_PER_PRIVATE_LOG;
286
+ const numContractClassLogs = arrayNonEmptyLength(data.contractClassLogsHashes, (log)=>log.isEmpty());
287
+ // Every contract class log emits its length and contract address as additional fields
288
+ meteredDAFields += data.contractClassLogsHashes.reduce((acc, log)=>!log.isEmpty() ? acc + log.logHash.length + 2 : acc, 0);
289
+ meteredL2Gas += numContractClassLogs * L2_GAS_PER_CONTRACT_CLASS_LOG;
290
+ const meteredDAGas = meteredDAFields * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
291
+ if (data.publicCallRequests) {
292
+ const dataForPublic = data;
293
+ const numPublicCallRequests = arrayNonEmptyLength(dataForPublic.publicCallRequests, (req)=>req.isEmpty());
294
+ meteredL2Gas += numPublicCallRequests * FIXED_AVM_STARTUP_L2_GAS;
295
+ }
296
+ return Gas.from({
297
+ l2Gas: meteredL2Gas,
298
+ daGas: meteredDAGas
299
+ });
300
+ }