@aztec/pxe 0.0.0-test.1 → 0.0.1-commit.24de95ac

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 (309) 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 +10 -15
  6. package/dest/config/index.d.ts.map +1 -1
  7. package/dest/config/index.js +11 -20
  8. package/dest/config/package_info.js +1 -1
  9. package/dest/contract_function_simulator/contract_function_simulator.d.ts +56 -0
  10. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -0
  11. package/dest/contract_function_simulator/contract_function_simulator.js +301 -0
  12. package/dest/contract_function_simulator/execution_data_provider.d.ts +274 -0
  13. package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -0
  14. package/dest/contract_function_simulator/execution_data_provider.js +14 -0
  15. package/dest/contract_function_simulator/execution_note_cache.d.ts +93 -0
  16. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -0
  17. package/dest/contract_function_simulator/execution_note_cache.js +183 -0
  18. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
  19. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
  20. package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
  21. package/dest/contract_function_simulator/hashed_values_cache.d.ts +28 -0
  22. package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -0
  23. package/dest/contract_function_simulator/hashed_values_cache.js +36 -0
  24. package/dest/contract_function_simulator/index.d.ts +14 -0
  25. package/dest/contract_function_simulator/index.d.ts.map +1 -0
  26. package/dest/contract_function_simulator/index.js +12 -0
  27. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +20 -0
  28. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -0
  29. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +37 -0
  30. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +15 -0
  31. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -0
  32. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +25 -0
  33. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +17 -0
  34. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -0
  35. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +65 -0
  36. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +22 -0
  37. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -0
  38. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +42 -0
  39. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +22 -0
  40. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
  41. package/dest/contract_function_simulator/noir-structs/utility_context.js +33 -0
  42. package/dest/contract_function_simulator/oracle/index.d.ts +14 -0
  43. package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -0
  44. package/dest/contract_function_simulator/oracle/index.js +2 -0
  45. package/dest/contract_function_simulator/oracle/interfaces.d.ts +97 -0
  46. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
  47. package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
  48. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +19 -0
  49. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -0
  50. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +24 -0
  51. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +22 -0
  52. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -0
  53. package/dest/contract_function_simulator/oracle/note_packing_utils.js +49 -0
  54. package/dest/contract_function_simulator/oracle/oracle.d.ts +57 -0
  55. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -0
  56. package/dest/contract_function_simulator/oracle/oracle.js +328 -0
  57. package/dest/contract_function_simulator/oracle/private_execution.d.ts +48 -0
  58. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -0
  59. package/dest/contract_function_simulator/oracle/private_execution.js +123 -0
  60. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +236 -0
  61. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -0
  62. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +417 -0
  63. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +154 -0
  64. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -0
  65. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +265 -0
  66. package/dest/contract_function_simulator/pick_notes.d.ts +85 -0
  67. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -0
  68. package/dest/contract_function_simulator/pick_notes.js +51 -0
  69. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +6 -0
  70. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -0
  71. package/dest/contract_function_simulator/proxied_contract_data_source.js +62 -0
  72. package/dest/contract_function_simulator/proxied_node.d.ts +9 -0
  73. package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -0
  74. package/dest/contract_function_simulator/proxied_node.js +27 -0
  75. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +122 -0
  76. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -0
  77. package/dest/contract_function_simulator/pxe_oracle_interface.js +701 -0
  78. package/dest/entrypoints/client/bundle/index.d.ts +4 -2
  79. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  80. package/dest/entrypoints/client/bundle/index.js +3 -2
  81. package/dest/entrypoints/client/bundle/utils.d.ts +9 -9
  82. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  83. package/dest/entrypoints/client/bundle/utils.js +18 -12
  84. package/dest/entrypoints/client/lazy/index.d.ts +4 -2
  85. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  86. package/dest/entrypoints/client/lazy/index.js +3 -2
  87. package/dest/entrypoints/client/lazy/utils.d.ts +8 -8
  88. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  89. package/dest/entrypoints/client/lazy/utils.js +17 -11
  90. package/dest/entrypoints/{client/pxe_creation_options.d.ts → pxe_creation_options.d.ts} +4 -1
  91. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -0
  92. package/dest/entrypoints/server/index.d.ts +5 -3
  93. package/dest/entrypoints/server/index.d.ts.map +1 -1
  94. package/dest/entrypoints/server/index.js +4 -3
  95. package/dest/entrypoints/server/utils.d.ts +7 -15
  96. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  97. package/dest/entrypoints/server/utils.js +34 -28
  98. package/dest/{pxe_service/error_enriching.d.ts → error_enriching.d.ts} +1 -1
  99. package/dest/error_enriching.d.ts.map +1 -0
  100. package/dest/{pxe_service/error_enriching.js → error_enriching.js} +26 -18
  101. package/dest/oracle_version.d.ts +3 -0
  102. package/dest/oracle_version.d.ts.map +1 -0
  103. package/dest/oracle_version.js +10 -0
  104. package/dest/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.d.ts +6 -6
  105. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -0
  106. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +271 -0
  107. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +4 -0
  108. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +1 -0
  109. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +41 -0
  110. package/dest/private_kernel/hints/index.d.ts +3 -0
  111. package/dest/private_kernel/hints/index.d.ts.map +1 -0
  112. package/dest/{kernel_prover → private_kernel}/hints/index.js +1 -0
  113. package/dest/private_kernel/index.d.ts +3 -0
  114. package/dest/private_kernel/index.d.ts.map +1 -0
  115. package/dest/private_kernel/index.js +2 -0
  116. package/dest/private_kernel/private_kernel_execution_prover.d.ts +44 -0
  117. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -0
  118. package/dest/private_kernel/private_kernel_execution_prover.js +285 -0
  119. package/dest/{kernel_prover/proving_data_oracle.d.ts → private_kernel/private_kernel_oracle.d.ts} +17 -28
  120. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -0
  121. package/dest/private_kernel/private_kernel_oracle.js +4 -0
  122. package/dest/{kernel_oracle/index.d.ts → private_kernel/private_kernel_oracle_impl.d.ts} +8 -8
  123. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -0
  124. package/dest/{kernel_oracle/index.js → private_kernel/private_kernel_oracle_impl.js} +19 -9
  125. package/dest/pxe.d.ts +233 -0
  126. package/dest/pxe.d.ts.map +1 -0
  127. package/dest/pxe.js +789 -0
  128. package/dest/storage/address_data_provider/address_data_provider.d.ts +1 -3
  129. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +1 -1
  130. package/dest/storage/address_data_provider/address_data_provider.js +0 -3
  131. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +14 -5
  132. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
  133. package/dest/storage/capsule_data_provider/capsule_data_provider.js +85 -24
  134. package/dest/storage/contract_data_provider/contract_data_provider.d.ts +12 -47
  135. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
  136. package/dest/storage/contract_data_provider/contract_data_provider.js +92 -70
  137. package/dest/storage/contract_data_provider/index.d.ts +0 -1
  138. package/dest/storage/contract_data_provider/index.d.ts.map +1 -1
  139. package/dest/storage/contract_data_provider/index.js +0 -1
  140. package/dest/storage/contract_data_provider/private_functions_tree.d.ts +2 -41
  141. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +1 -1
  142. package/dest/storage/contract_data_provider/private_functions_tree.js +9 -61
  143. package/dest/storage/index.d.ts +2 -3
  144. package/dest/storage/index.d.ts.map +1 -1
  145. package/dest/storage/index.js +2 -3
  146. package/dest/storage/metadata.d.ts +2 -0
  147. package/dest/storage/metadata.d.ts.map +1 -0
  148. package/dest/storage/metadata.js +1 -0
  149. package/dest/storage/note_data_provider/note_dao.d.ts +16 -22
  150. package/dest/storage/note_data_provider/note_dao.d.ts.map +1 -1
  151. package/dest/storage/note_data_provider/note_dao.js +16 -20
  152. package/dest/storage/note_data_provider/note_data_provider.d.ts +71 -8
  153. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
  154. package/dest/storage/note_data_provider/note_data_provider.js +133 -74
  155. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +43 -0
  156. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +1 -0
  157. package/dest/storage/private_event_data_provider/private_event_data_provider.js +104 -0
  158. package/dest/storage/sync_data_provider/sync_data_provider.d.ts +2 -4
  159. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +1 -1
  160. package/dest/storage/sync_data_provider/sync_data_provider.js +2 -5
  161. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +28 -6
  162. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +1 -1
  163. package/dest/storage/tagging_data_provider/tagging_data_provider.js +48 -24
  164. package/dest/synchronizer/synchronizer.d.ts +7 -9
  165. package/dest/synchronizer/synchronizer.d.ts.map +1 -1
  166. package/dest/synchronizer/synchronizer.js +17 -19
  167. package/dest/tagging/constants.d.ts +2 -0
  168. package/dest/tagging/constants.d.ts.map +1 -0
  169. package/dest/tagging/constants.js +2 -0
  170. package/dest/tagging/index.d.ts +7 -0
  171. package/dest/tagging/index.d.ts.map +1 -0
  172. package/dest/tagging/index.js +5 -0
  173. package/dest/tagging/siloed_tag.d.ts +14 -0
  174. package/dest/tagging/siloed_tag.d.ts.map +1 -0
  175. package/dest/tagging/siloed_tag.js +20 -0
  176. package/dest/tagging/tag.d.ts +12 -0
  177. package/dest/tagging/tag.d.ts.map +1 -0
  178. package/dest/tagging/tag.js +17 -0
  179. package/dest/tagging/utils.d.ts +18 -0
  180. package/dest/tagging/utils.d.ts.map +1 -0
  181. package/dest/tagging/utils.js +24 -0
  182. package/package.json +34 -32
  183. package/src/bin/check_oracle_version.ts +50 -0
  184. package/src/config/index.ts +20 -33
  185. package/src/config/package_info.ts +1 -1
  186. package/src/contract_function_simulator/contract_function_simulator.ts +548 -0
  187. package/src/contract_function_simulator/execution_data_provider.ts +343 -0
  188. package/src/contract_function_simulator/execution_note_cache.ts +222 -0
  189. package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
  190. package/src/contract_function_simulator/hashed_values_cache.ts +47 -0
  191. package/src/contract_function_simulator/index.ts +13 -0
  192. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +47 -0
  193. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +27 -0
  194. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +69 -0
  195. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +52 -0
  196. package/src/contract_function_simulator/noir-structs/utility_context.ts +42 -0
  197. package/src/contract_function_simulator/oracle/index.ts +16 -0
  198. package/src/contract_function_simulator/oracle/interfaces.ts +160 -0
  199. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +23 -0
  200. package/src/contract_function_simulator/oracle/note_packing_utils.ts +52 -0
  201. package/src/contract_function_simulator/oracle/oracle.ts +575 -0
  202. package/src/contract_function_simulator/oracle/private_execution.ts +207 -0
  203. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +625 -0
  204. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +358 -0
  205. package/src/contract_function_simulator/pick_notes.ts +141 -0
  206. package/src/contract_function_simulator/proxied_contract_data_source.ts +66 -0
  207. package/src/contract_function_simulator/proxied_node.ts +33 -0
  208. package/src/contract_function_simulator/pxe_oracle_interface.ts +1019 -0
  209. package/src/entrypoints/client/bundle/index.ts +4 -2
  210. package/src/entrypoints/client/bundle/utils.ts +36 -36
  211. package/src/entrypoints/client/lazy/index.ts +4 -2
  212. package/src/entrypoints/client/lazy/utils.ts +36 -31
  213. package/src/entrypoints/{client/pxe_creation_options.ts → pxe_creation_options.ts} +4 -1
  214. package/src/entrypoints/server/index.ts +5 -3
  215. package/src/entrypoints/server/utils.ts +69 -47
  216. package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +36 -27
  217. package/src/oracle_version.ts +11 -0
  218. package/src/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.ts +158 -142
  219. package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +58 -0
  220. package/src/{kernel_prover → private_kernel}/hints/index.ts +1 -0
  221. package/src/private_kernel/index.ts +2 -0
  222. package/src/private_kernel/private_kernel_execution_prover.ts +436 -0
  223. package/src/{kernel_prover/proving_data_oracle.ts → private_kernel/private_kernel_oracle.ts} +17 -29
  224. package/src/{kernel_oracle/index.ts → private_kernel/private_kernel_oracle_impl.ts} +30 -15
  225. package/src/pxe.ts +1113 -0
  226. package/src/storage/address_data_provider/address_data_provider.ts +1 -7
  227. package/src/storage/capsule_data_provider/capsule_data_provider.ts +97 -30
  228. package/src/storage/contract_data_provider/contract_data_provider.ts +114 -81
  229. package/src/storage/contract_data_provider/index.ts +0 -1
  230. package/src/storage/contract_data_provider/private_functions_tree.ts +11 -75
  231. package/src/storage/index.ts +2 -4
  232. package/src/storage/metadata.ts +1 -0
  233. package/src/storage/note_data_provider/note_dao.ts +19 -27
  234. package/src/storage/note_data_provider/note_data_provider.ts +161 -113
  235. package/src/storage/private_event_data_provider/private_event_data_provider.ts +148 -0
  236. package/src/storage/sync_data_provider/sync_data_provider.ts +4 -10
  237. package/src/storage/tagging_data_provider/tagging_data_provider.ts +58 -30
  238. package/src/synchronizer/synchronizer.ts +21 -22
  239. package/src/tagging/constants.ts +2 -0
  240. package/src/tagging/index.ts +6 -0
  241. package/src/tagging/siloed_tag.ts +22 -0
  242. package/src/tagging/tag.ts +16 -0
  243. package/src/tagging/utils.ts +31 -0
  244. package/dest/bin/index.d.ts +0 -3
  245. package/dest/bin/index.d.ts.map +0 -1
  246. package/dest/bin/index.js +0 -28
  247. package/dest/entrypoints/client/pxe_creation_options.d.ts.map +0 -1
  248. package/dest/kernel_oracle/index.d.ts.map +0 -1
  249. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
  250. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +0 -270
  251. package/dest/kernel_prover/hints/index.d.ts +0 -2
  252. package/dest/kernel_prover/hints/index.d.ts.map +0 -1
  253. package/dest/kernel_prover/index.d.ts +0 -3
  254. package/dest/kernel_prover/index.d.ts.map +0 -1
  255. package/dest/kernel_prover/index.js +0 -2
  256. package/dest/kernel_prover/kernel_prover.d.ts +0 -38
  257. package/dest/kernel_prover/kernel_prover.d.ts.map +0 -1
  258. package/dest/kernel_prover/kernel_prover.js +0 -217
  259. package/dest/kernel_prover/proving_data_oracle.d.ts.map +0 -1
  260. package/dest/kernel_prover/proving_data_oracle.js +0 -4
  261. package/dest/note_decryption_utils/add_public_values_to_payload.d.ts +0 -11
  262. package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +0 -1
  263. package/dest/note_decryption_utils/add_public_values_to_payload.js +0 -47
  264. package/dest/pxe_http/index.d.ts +0 -2
  265. package/dest/pxe_http/index.d.ts.map +0 -1
  266. package/dest/pxe_http/index.js +0 -1
  267. package/dest/pxe_http/pxe_http_server.d.ts +0 -16
  268. package/dest/pxe_http/pxe_http_server.d.ts.map +0 -1
  269. package/dest/pxe_http/pxe_http_server.js +0 -27
  270. package/dest/pxe_oracle_interface/index.d.ts +0 -159
  271. package/dest/pxe_oracle_interface/index.d.ts.map +0 -1
  272. package/dest/pxe_oracle_interface/index.js +0 -692
  273. package/dest/pxe_oracle_interface/tagging_utils.d.ts +0 -17
  274. package/dest/pxe_oracle_interface/tagging_utils.d.ts.map +0 -1
  275. package/dest/pxe_oracle_interface/tagging_utils.js +0 -23
  276. package/dest/pxe_service/error_enriching.d.ts.map +0 -1
  277. package/dest/pxe_service/index.d.ts +0 -3
  278. package/dest/pxe_service/index.d.ts.map +0 -1
  279. package/dest/pxe_service/index.js +0 -2
  280. package/dest/pxe_service/pxe_service.d.ts +0 -111
  281. package/dest/pxe_service/pxe_service.d.ts.map +0 -1
  282. package/dest/pxe_service/pxe_service.js +0 -664
  283. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts +0 -11
  284. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts.map +0 -1
  285. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.js +0 -20
  286. package/dest/storage/auth_witness_data_provider/index.d.ts +0 -2
  287. package/dest/storage/auth_witness_data_provider/index.d.ts.map +0 -1
  288. package/dest/storage/auth_witness_data_provider/index.js +0 -1
  289. package/dest/storage/data_provider.d.ts +0 -4
  290. package/dest/storage/data_provider.d.ts.map +0 -1
  291. package/dest/storage/data_provider.js +0 -1
  292. package/dest/test/pxe_test_suite.d.ts +0 -3
  293. package/dest/test/pxe_test_suite.d.ts.map +0 -1
  294. package/dest/test/pxe_test_suite.js +0 -97
  295. package/src/bin/index.ts +0 -38
  296. package/src/kernel_prover/index.ts +0 -2
  297. package/src/kernel_prover/kernel_prover.ts +0 -351
  298. package/src/note_decryption_utils/add_public_values_to_payload.ts +0 -64
  299. package/src/pxe_http/index.ts +0 -1
  300. package/src/pxe_http/pxe_http_server.ts +0 -29
  301. package/src/pxe_oracle_interface/index.ts +0 -925
  302. package/src/pxe_oracle_interface/tagging_utils.ts +0 -32
  303. package/src/pxe_service/index.ts +0 -2
  304. package/src/pxe_service/pxe_service.ts +0 -949
  305. package/src/storage/auth_witness_data_provider/auth_witness_data_provider.ts +0 -34
  306. package/src/storage/auth_witness_data_provider/index.ts +0 -1
  307. package/src/storage/data_provider.ts +0 -3
  308. package/src/test/pxe_test_suite.ts +0 -111
  309. /package/dest/entrypoints/{client/pxe_creation_options.js → pxe_creation_options.js} +0 -0
@@ -1,4 +1,3 @@
1
- import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
2
1
  import {
3
2
  type ConfigMappingsType,
4
3
  booleanConfigHelper,
@@ -8,7 +7,6 @@ import {
8
7
  } from '@aztec/foundation/config';
9
8
  import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
10
9
  import { type ChainConfig, chainConfigMappings } from '@aztec/stdlib/config';
11
- import type { Network } from '@aztec/stdlib/network';
12
10
 
13
11
  export { getPackageInfo } from './package_info.js';
14
12
 
@@ -28,32 +26,29 @@ export interface KernelProverConfig {
28
26
  /** Whether we are running with real proofs */
29
27
  proverEnabled?: boolean;
30
28
  }
29
+
31
30
  /**
32
- * Configuration settings for the PXE.
31
+ * Configuration settings for the synchronizer.
33
32
  */
34
- export interface PXEConfig {
35
- /** L2 block to start scanning from for new accounts */
36
- l2StartingBlock: number;
33
+ export interface SynchronizerConfig {
34
+ /** Maximum amount of blocks to pull from the stream in one request when synchronizing */
35
+ l2BlockBatchSize: number;
37
36
  }
38
37
 
39
- export type PXEServiceConfig = PXEConfig & KernelProverConfig & BBProverConfig & DataStoreConfig & ChainConfig;
38
+ export type PXEConfig = KernelProverConfig & BBProverConfig & DataStoreConfig & ChainConfig & SynchronizerConfig;
40
39
 
41
40
  export type CliPXEOptions = {
42
- /** External Aztec network to connect to. e.g. devnet */
43
- network?: Network;
44
- /** API Key required by the external network's node */
45
- apiKey?: string;
46
41
  /** Custom Aztec Node URL to connect to */
47
42
  nodeUrl?: string;
48
43
  };
49
44
 
50
- export const pxeConfigMappings: ConfigMappingsType<PXEServiceConfig> = {
45
+ export const pxeConfigMappings: ConfigMappingsType<PXEConfig> = {
51
46
  ...dataConfigMappings,
52
47
  ...chainConfigMappings,
53
- l2StartingBlock: {
54
- env: 'PXE_L2_STARTING_BLOCK',
55
- ...numberConfigHelper(INITIAL_L2_BLOCK_NUM),
56
- description: 'L2 block to start scanning from for new accounts',
48
+ l2BlockBatchSize: {
49
+ env: 'PXE_L2_BLOCK_BATCH_SIZE',
50
+ ...numberConfigHelper(50),
51
+ description: 'Maximum amount of blocks to pull from the stream in one request when synchronizing',
57
52
  },
58
53
  bbBinaryPath: {
59
54
  env: 'BB_BINARY_PATH',
@@ -71,34 +66,25 @@ export const pxeConfigMappings: ConfigMappingsType<PXEServiceConfig> = {
71
66
  proverEnabled: {
72
67
  env: 'PXE_PROVER_ENABLED',
73
68
  description: 'Enable real proofs',
74
- ...booleanConfigHelper(),
69
+ ...booleanConfigHelper(true),
75
70
  },
76
71
  };
77
72
 
78
73
  /**
79
- * Creates an instance of PXEServiceConfig out of environment variables using sensible defaults for integration testing if not set.
74
+ * Creates an instance of PXEConfig out of environment variables using sensible defaults for integration testing if not set.
80
75
  */
81
- export function getPXEServiceConfig(): PXEServiceConfig {
82
- return getConfigFromMappings<PXEServiceConfig>(pxeConfigMappings);
76
+ export function getPXEConfig(): PXEConfig {
77
+ return getConfigFromMappings<PXEConfig>(pxeConfigMappings);
83
78
  }
84
79
 
85
80
  export const pxeCliConfigMappings: ConfigMappingsType<CliPXEOptions> = {
86
- network: {
87
- env: 'NETWORK',
88
- parseEnv: (val: string) => val as Network,
89
- description: 'External Aztec network to connect to. e.g. devnet',
90
- },
91
- apiKey: {
92
- env: 'API_KEY',
93
- description: "API Key required by the external network's node",
94
- },
95
81
  nodeUrl: {
96
82
  env: 'AZTEC_NODE_URL',
97
83
  description: 'Custom Aztec Node URL to connect to',
98
84
  },
99
85
  };
100
86
 
101
- export const allPxeConfigMappings: ConfigMappingsType<CliPXEOptions & PXEServiceConfig> = {
87
+ export const allPxeConfigMappings: ConfigMappingsType<CliPXEOptions & PXEConfig> = {
102
88
  ...pxeConfigMappings,
103
89
  ...pxeCliConfigMappings,
104
90
  ...dataConfigMappings,
@@ -107,18 +93,19 @@ export const allPxeConfigMappings: ConfigMappingsType<CliPXEOptions & PXEService
107
93
  parseEnv: (val: string) => parseBooleanEnv(val) || !!process.env.NETWORK,
108
94
  description: 'Enable real proofs',
109
95
  isBoolean: true,
96
+ defaultValue: true,
110
97
  },
111
98
  };
112
99
 
113
100
  /**
114
101
  * Creates an instance of CliPxeOptions out of environment variables
115
102
  */
116
- export function getCliPXEOptions(): CliPXEOptions & PXEServiceConfig {
117
- const pxeConfig = getPXEServiceConfig();
103
+ export function getCliPXEOptions(): CliPXEOptions & PXEConfig {
104
+ const pxeConfig = getPXEConfig();
118
105
  const cliOptions = getConfigFromMappings<CliPXEOptions>(pxeCliConfigMappings);
119
106
  return {
120
107
  ...pxeConfig,
121
108
  ...cliOptions,
122
- proverEnabled: pxeConfig.proverEnabled || !!cliOptions.network,
109
+ proverEnabled: pxeConfig.proverEnabled,
123
110
  };
124
111
  }
@@ -1,3 +1,3 @@
1
1
  export function getPackageInfo() {
2
- return { version: '0.1.0', name: '@aztec/pxe' };
2
+ return { version: '3.0.0', name: '@aztec/pxe' };
3
3
  }
@@ -0,0 +1,548 @@
1
+ import {
2
+ AVM_EMITNOTEHASH_BASE_L2_GAS,
3
+ AVM_EMITNULLIFIER_BASE_L2_GAS,
4
+ AVM_SENDL2TOL1MSG_BASE_L2_GAS,
5
+ DA_BYTES_PER_FIELD,
6
+ DA_GAS_PER_BYTE,
7
+ FIXED_AVM_STARTUP_L2_GAS,
8
+ FIXED_DA_GAS,
9
+ FIXED_L2_GAS,
10
+ L2_GAS_PER_CONTRACT_CLASS_LOG,
11
+ L2_GAS_PER_PRIVATE_LOG,
12
+ MAX_CONTRACT_CLASS_LOGS_PER_TX,
13
+ MAX_ENQUEUED_CALLS_PER_TX,
14
+ MAX_L2_TO_L1_MSGS_PER_TX,
15
+ MAX_NOTE_HASHES_PER_TX,
16
+ MAX_NULLIFIERS_PER_TX,
17
+ MAX_PRIVATE_LOGS_PER_TX,
18
+ } from '@aztec/constants';
19
+ import { arrayNonEmptyLength, padArrayEnd } from '@aztec/foundation/collection';
20
+ import { poseidon2Hash } from '@aztec/foundation/crypto';
21
+ import { Fr } from '@aztec/foundation/fields';
22
+ import { type Logger, createLogger } from '@aztec/foundation/log';
23
+ import { Timer } from '@aztec/foundation/timer';
24
+ import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
25
+ import { protocolContractsHash } from '@aztec/protocol-contracts';
26
+ import {
27
+ type CircuitSimulator,
28
+ ExecutionError,
29
+ createSimulationError,
30
+ extractCallStack,
31
+ resolveAssertionMessageFromError,
32
+ toACVMWitness,
33
+ witnessMapToFields,
34
+ } from '@aztec/simulator/client';
35
+ import type { AbiDecoded, FunctionCall } from '@aztec/stdlib/abi';
36
+ import { FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
37
+ import type { AuthWitness } from '@aztec/stdlib/auth-witness';
38
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
39
+ import { Gas } from '@aztec/stdlib/gas';
40
+ import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
41
+ import {
42
+ PartialPrivateTailPublicInputsForPublic,
43
+ PartialPrivateTailPublicInputsForRollup,
44
+ type PrivateExecutionStep,
45
+ type PrivateKernelExecutionProofOutput,
46
+ PrivateKernelTailCircuitPublicInputs,
47
+ PrivateToPublicAccumulatedData,
48
+ PrivateToRollupAccumulatedData,
49
+ PublicCallRequest,
50
+ ScopedLogHash,
51
+ } from '@aztec/stdlib/kernel';
52
+ import { PrivateLog } from '@aztec/stdlib/logs';
53
+ import { ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
54
+ import { ChonkProof } from '@aztec/stdlib/proofs';
55
+ import {
56
+ CallContext,
57
+ HashedValues,
58
+ PrivateExecutionResult,
59
+ TxConstantData,
60
+ TxExecutionRequest,
61
+ collectNested,
62
+ getFinalMinRevertibleSideEffectCounter,
63
+ } from '@aztec/stdlib/tx';
64
+
65
+ import type { ContractDataProvider } from '../storage/index.js';
66
+ import type { ExecutionDataProvider } from './execution_data_provider.js';
67
+ import { ExecutionNoteCache } from './execution_note_cache.js';
68
+ import { ExecutionTaggingIndexCache } from './execution_tagging_index_cache.js';
69
+ import { HashedValuesCache } from './hashed_values_cache.js';
70
+ import { Oracle } from './oracle/oracle.js';
71
+ import { executePrivateFunction, verifyCurrentClassId } from './oracle/private_execution.js';
72
+ import { PrivateExecutionOracle } from './oracle/private_execution_oracle.js';
73
+ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
74
+
75
+ /**
76
+ * The contract function simulator.
77
+ */
78
+ export class ContractFunctionSimulator {
79
+ private log: Logger;
80
+
81
+ constructor(
82
+ private executionDataProvider: ExecutionDataProvider,
83
+ private simulator: CircuitSimulator,
84
+ ) {
85
+ this.log = createLogger('simulator');
86
+ }
87
+
88
+ /**
89
+ * Runs a private function.
90
+ * @param request - The transaction request.
91
+ * @param entryPointArtifact - The artifact of the entry point function.
92
+ * @param contractAddress - The address of the contract (should match request.origin)
93
+ * @param msgSender - The address calling the function. This can be replaced to simulate a call from another contract
94
+ * or a specific account.
95
+ * @param senderForTags - The address that is used as a tagging sender when emitting private logs. Returned from
96
+ * the `privateGetSenderForTags` oracle.
97
+ * @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
98
+ * @returns The result of the execution.
99
+ */
100
+ public async run(
101
+ request: TxExecutionRequest,
102
+ contractAddress: AztecAddress,
103
+ selector: FunctionSelector,
104
+ msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE),
105
+ senderForTags?: AztecAddress,
106
+ scopes?: AztecAddress[],
107
+ ): Promise<PrivateExecutionResult> {
108
+ const simulatorSetupTimer = new Timer();
109
+ const anchorBlockHeader = await this.executionDataProvider.getAnchorBlockHeader();
110
+
111
+ await verifyCurrentClassId(contractAddress, this.executionDataProvider);
112
+
113
+ const entryPointArtifact = await this.executionDataProvider.getFunctionArtifact(contractAddress, selector);
114
+
115
+ if (entryPointArtifact.functionType !== FunctionType.PRIVATE) {
116
+ throw new Error(`Cannot run ${entryPointArtifact.functionType} function as private`);
117
+ }
118
+
119
+ if (request.origin !== contractAddress) {
120
+ this.log.warn(
121
+ `Request origin does not match contract address in simulation. Request origin: ${request.origin}, contract address: ${contractAddress}`,
122
+ );
123
+ }
124
+
125
+ // reserve the first side effect for the tx hash (inserted by the private kernel)
126
+ const startSideEffectCounter = 1;
127
+
128
+ const callContext = new CallContext(
129
+ msgSender,
130
+ contractAddress,
131
+ await FunctionSelector.fromNameAndParameters(entryPointArtifact.name, entryPointArtifact.parameters),
132
+ entryPointArtifact.isStatic,
133
+ );
134
+
135
+ const txRequestHash = await request.toTxRequest().hash();
136
+ const noteCache = new ExecutionNoteCache(txRequestHash);
137
+ const taggingIndexCache = new ExecutionTaggingIndexCache();
138
+
139
+ const privateExecutionOracle = new PrivateExecutionOracle(
140
+ request.firstCallArgsHash,
141
+ request.txContext,
142
+ callContext,
143
+ anchorBlockHeader,
144
+ request.authWitnesses,
145
+ request.capsules,
146
+ HashedValuesCache.create(request.argsOfCalls),
147
+ noteCache,
148
+ taggingIndexCache,
149
+ this.executionDataProvider,
150
+ 0, // totalPublicArgsCount
151
+ startSideEffectCounter,
152
+ undefined, // log
153
+ scopes,
154
+ senderForTags,
155
+ this.simulator,
156
+ );
157
+
158
+ const setupTime = simulatorSetupTimer.ms();
159
+
160
+ try {
161
+ // Note: any nested private function calls are made recursively within this
162
+ // function call. So this execution result is the result of executing _all_
163
+ // private functions of this tx (the results of those executions are contained
164
+ // within executionResult.nestedExecutionResults).
165
+ const executionResult = await executePrivateFunction(
166
+ this.simulator,
167
+ privateExecutionOracle,
168
+ entryPointArtifact,
169
+ contractAddress,
170
+ request.functionSelector,
171
+ );
172
+ const simulatorTeardownTimer = new Timer();
173
+ const { usedTxRequestHashForNonces } = noteCache.finish();
174
+ const firstNullifierHint = usedTxRequestHashForNonces ? Fr.ZERO : noteCache.getAllNullifiers()[0];
175
+
176
+ const publicCallRequests = collectNested([executionResult], r =>
177
+ r.publicInputs.publicCallRequests
178
+ .getActiveItems()
179
+ .map(r => r.inner)
180
+ .concat(r.publicInputs.publicTeardownCallRequest.isEmpty() ? [] : [r.publicInputs.publicTeardownCallRequest]),
181
+ );
182
+ const publicFunctionsCalldata = await Promise.all(
183
+ publicCallRequests.map(async r => {
184
+ const calldata = await privateExecutionOracle.privateLoadFromExecutionCache(r.calldataHash);
185
+ return new HashedValues(calldata, r.calldataHash);
186
+ }),
187
+ );
188
+
189
+ const teardownTime = simulatorTeardownTimer.ms();
190
+
191
+ // Add simulator overhead to topmost call in the stack
192
+ if (executionResult.profileResult) {
193
+ executionResult.profileResult.timings.witgen += setupTime + teardownTime;
194
+ }
195
+
196
+ // Not to be confused with a PrivateCallExecutionResult. This is a superset
197
+ // of the PrivateCallExecutionResult, containing also firstNullifierHint
198
+ // and publicFunctionsCalldata.
199
+ return new PrivateExecutionResult(executionResult, firstNullifierHint, publicFunctionsCalldata);
200
+ } catch (err) {
201
+ throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
202
+ }
203
+ }
204
+
205
+ // docs:start:execute_utility_function
206
+ /**
207
+ * Runs a utility function.
208
+ * @param call - The function call to execute.
209
+ * @param authwits - Authentication witnesses required for the function call.
210
+ * @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
211
+ * accounts if not specified.
212
+ * @returns A decoded ABI value containing the function's return data.
213
+ */
214
+ public async runUtility(call: FunctionCall, authwits: AuthWitness[], scopes?: AztecAddress[]): Promise<AbiDecoded> {
215
+ await verifyCurrentClassId(call.to, this.executionDataProvider);
216
+
217
+ const entryPointArtifact = await this.executionDataProvider.getFunctionArtifact(call.to, call.selector);
218
+
219
+ if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
220
+ throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
221
+ }
222
+
223
+ const oracle = new UtilityExecutionOracle(call.to, authwits, [], this.executionDataProvider, undefined, scopes);
224
+
225
+ try {
226
+ this.log.verbose(`Executing utility function ${entryPointArtifact.name}`, {
227
+ contract: call.to,
228
+ selector: call.selector,
229
+ });
230
+
231
+ const initialWitness = toACVMWitness(0, call.args);
232
+ const acirExecutionResult = await this.simulator
233
+ .executeUserCircuit(initialWitness, entryPointArtifact, new Oracle(oracle).toACIRCallback())
234
+ .catch((err: Error) => {
235
+ err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
236
+ throw new ExecutionError(
237
+ err.message,
238
+ {
239
+ contractAddress: call.to,
240
+ functionSelector: call.selector,
241
+ },
242
+ extractCallStack(err, entryPointArtifact.debug),
243
+ { cause: err },
244
+ );
245
+ });
246
+
247
+ const returnWitness = witnessMapToFields(acirExecutionResult.returnWitness);
248
+ this.log.verbose(`Utility simulation for ${call.to}.${call.selector} completed`);
249
+ return decodeFromAbi(entryPointArtifact.returnTypes, returnWitness);
250
+ } catch (err) {
251
+ throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
252
+ }
253
+ }
254
+ // docs:end:execute_utility_function
255
+
256
+ getStats() {
257
+ return this.executionDataProvider.getStats();
258
+ }
259
+ }
260
+
261
+ class OrderedSideEffect<T> {
262
+ sideEffect: T;
263
+ counter: number;
264
+
265
+ constructor(sideEffect: T, counter: number) {
266
+ this.sideEffect = sideEffect;
267
+ this.counter = counter;
268
+ }
269
+ }
270
+
271
+ /**
272
+ * Generates the final public inputs of the tail kernel circuit, an empty Chonk proof
273
+ * and the execution steps for a `PrivateExecutionResult` as if it had been
274
+ * processed by the private kernel prover. This skips many of the checks performed by the kernels
275
+ * (allowing state overrides) and is much faster, while still generating a valid
276
+ * output that can be sent to the node for public simulation
277
+ * @param privateExecutionResult - The result of the private execution.
278
+ * @param nonceGenerator - A nonce generator for note hashes. According to the protocol rules,
279
+ * it can either be the first nullifier in the tx or the hash of the initial tx request if there are none.
280
+ * @param contractDataProvider - A provider for contract data in order to get function names and debug info.
281
+ * @returns The simulated proving result.
282
+ */
283
+ export async function generateSimulatedProvingResult(
284
+ privateExecutionResult: PrivateExecutionResult,
285
+ nonceGenerator: Fr,
286
+ contractDataProvider: ContractDataProvider,
287
+ ): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
288
+ const siloedNoteHashes: OrderedSideEffect<Fr>[] = [];
289
+ const nullifiers: OrderedSideEffect<Fr>[] = [];
290
+ const taggedPrivateLogs: OrderedSideEffect<PrivateLog>[] = [];
291
+ const l2ToL1Messages: OrderedSideEffect<ScopedL2ToL1Message>[] = [];
292
+ const contractClassLogsHashes: OrderedSideEffect<ScopedLogHash>[] = [];
293
+ const publicCallRequests: OrderedSideEffect<PublicCallRequest>[] = [];
294
+ const executionSteps: PrivateExecutionStep[] = [];
295
+
296
+ let publicTeardownCallRequest;
297
+
298
+ const executions = [privateExecutionResult.entrypoint];
299
+
300
+ while (executions.length !== 0) {
301
+ const execution = executions.shift()!;
302
+ executions.unshift(...execution!.nestedExecutionResults);
303
+
304
+ const { contractAddress } = execution.publicInputs.callContext;
305
+
306
+ const noteHashesFromExecution = await Promise.all(
307
+ execution.publicInputs.noteHashes
308
+ .getActiveItems()
309
+ .filter(noteHash => !noteHash.isEmpty())
310
+ .map(
311
+ async noteHash =>
312
+ new OrderedSideEffect(await siloNoteHash(contractAddress, noteHash.value), noteHash.counter),
313
+ ),
314
+ );
315
+
316
+ const nullifiersFromExecution = await Promise.all(
317
+ execution.publicInputs.nullifiers
318
+ .getActiveItems()
319
+ .map(
320
+ async nullifier =>
321
+ new OrderedSideEffect(await siloNullifier(contractAddress, nullifier.value), nullifier.counter),
322
+ ),
323
+ );
324
+
325
+ const privateLogsFromExecution = await Promise.all(
326
+ execution.publicInputs.privateLogs.getActiveItems().map(async metadata => {
327
+ metadata.log.fields[0] = await poseidon2Hash([contractAddress, metadata.log.fields[0]]);
328
+ return new OrderedSideEffect(metadata.log, metadata.counter);
329
+ }),
330
+ );
331
+
332
+ siloedNoteHashes.push(...noteHashesFromExecution);
333
+ taggedPrivateLogs.push(...privateLogsFromExecution);
334
+ nullifiers.push(...nullifiersFromExecution);
335
+ l2ToL1Messages.push(
336
+ ...execution.publicInputs.l2ToL1Msgs
337
+ .getActiveItems()
338
+ .map(message => new OrderedSideEffect(message.message.scope(contractAddress), message.counter)),
339
+ );
340
+ contractClassLogsHashes.push(
341
+ ...execution.publicInputs.contractClassLogsHashes
342
+ .getActiveItems()
343
+ .map(
344
+ contractClassLogHash =>
345
+ new OrderedSideEffect(contractClassLogHash.logHash.scope(contractAddress), contractClassLogHash.counter),
346
+ ),
347
+ );
348
+ publicCallRequests.push(
349
+ ...execution.publicInputs.publicCallRequests
350
+ .getActiveItems()
351
+ .map(callRequest => new OrderedSideEffect(callRequest.inner, callRequest.counter)),
352
+ );
353
+
354
+ if (publicTeardownCallRequest !== undefined && !execution.publicInputs.publicTeardownCallRequest.isEmpty()) {
355
+ throw new Error('Trying to set multiple teardown requests');
356
+ }
357
+
358
+ publicTeardownCallRequest = execution.publicInputs.publicTeardownCallRequest.isEmpty()
359
+ ? publicTeardownCallRequest
360
+ : execution.publicInputs.publicTeardownCallRequest;
361
+
362
+ executionSteps.push({
363
+ functionName: await contractDataProvider.getDebugFunctionName(
364
+ execution.publicInputs.callContext.contractAddress,
365
+ execution.publicInputs.callContext.functionSelector,
366
+ ),
367
+ timings: execution.profileResult?.timings ?? { witgen: 0, oracles: {} },
368
+ bytecode: execution.acir,
369
+ vk: execution.vk,
370
+ witness: execution.partialWitness,
371
+ });
372
+ }
373
+
374
+ const constantData = new TxConstantData(
375
+ privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader,
376
+ privateExecutionResult.entrypoint.publicInputs.txContext,
377
+ getVKTreeRoot(),
378
+ protocolContractsHash,
379
+ );
380
+
381
+ const hasPublicCalls = privateExecutionResult.publicFunctionCalldata.length !== 0;
382
+ let inputsForRollup;
383
+ let inputsForPublic;
384
+ let gasUsed;
385
+
386
+ const sortByCounter = <T>(a: OrderedSideEffect<T>, b: OrderedSideEffect<T>) => a.counter - b.counter;
387
+ const getEffect = <T>(orderedSideEffect: OrderedSideEffect<T>) => orderedSideEffect.sideEffect;
388
+
389
+ const isPrivateOnlyTx = privateExecutionResult.publicFunctionCalldata.length === 0;
390
+ const minRevertibleSideEffectCounter = getFinalMinRevertibleSideEffectCounter(privateExecutionResult);
391
+
392
+ const [nonRevertibleNullifiers, revertibleNullifiers] = splitOrderedSideEffects(
393
+ nullifiers.sort(sortByCounter),
394
+ minRevertibleSideEffectCounter,
395
+ );
396
+ if (nonRevertibleNullifiers.length > 0 && !nonRevertibleNullifiers[0].equals(nonceGenerator)) {
397
+ throw new Error('The first non revertible nullifier should be equal to the nonce generator. This is a bug!');
398
+ } else {
399
+ nonRevertibleNullifiers.unshift(nonceGenerator);
400
+ }
401
+
402
+ if (isPrivateOnlyTx) {
403
+ // We must make the note hashes unique by using the
404
+ // nonce generator and their index in the tx.
405
+ const uniqueNoteHashes = await Promise.all(
406
+ siloedNoteHashes.sort(sortByCounter).map(async (orderedSideEffect, i) => {
407
+ const siloedNoteHash = orderedSideEffect.sideEffect;
408
+ const nonce = await computeNoteHashNonce(nonceGenerator, i);
409
+ const uniqueNoteHash = await computeUniqueNoteHash(nonce, siloedNoteHash);
410
+ return uniqueNoteHash;
411
+ }),
412
+ );
413
+ const accumulatedDataForRollup = new PrivateToRollupAccumulatedData(
414
+ padArrayEnd(uniqueNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX),
415
+ padArrayEnd(nonRevertibleNullifiers.concat(revertibleNullifiers), Fr.ZERO, MAX_NULLIFIERS_PER_TX),
416
+ padArrayEnd(
417
+ l2ToL1Messages.sort(sortByCounter).map(getEffect),
418
+ ScopedL2ToL1Message.empty(),
419
+ MAX_L2_TO_L1_MSGS_PER_TX,
420
+ ),
421
+ padArrayEnd(taggedPrivateLogs.sort(sortByCounter).map(getEffect), PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX),
422
+ padArrayEnd(
423
+ contractClassLogsHashes.sort(sortByCounter).map(getEffect),
424
+ ScopedLogHash.empty(),
425
+ MAX_CONTRACT_CLASS_LOGS_PER_TX,
426
+ ),
427
+ );
428
+ gasUsed = meterGasUsed(accumulatedDataForRollup);
429
+ inputsForRollup = new PartialPrivateTailPublicInputsForRollup(accumulatedDataForRollup);
430
+ } else {
431
+ const [nonRevertibleNoteHashes, revertibleNoteHashes] = splitOrderedSideEffects(
432
+ siloedNoteHashes.sort(sortByCounter),
433
+ minRevertibleSideEffectCounter,
434
+ );
435
+ const [nonRevertibleL2ToL1Messages, revertibleL2ToL1Messages] = splitOrderedSideEffects(
436
+ l2ToL1Messages.sort(sortByCounter),
437
+ minRevertibleSideEffectCounter,
438
+ );
439
+ const [nonRevertibleTaggedPrivateLogs, revertibleTaggedPrivateLogs] = splitOrderedSideEffects(
440
+ taggedPrivateLogs,
441
+ minRevertibleSideEffectCounter,
442
+ );
443
+ const [nonRevertibleContractClassLogHashes, revertibleContractClassLogHashes] = splitOrderedSideEffects(
444
+ contractClassLogsHashes.sort(sortByCounter),
445
+ minRevertibleSideEffectCounter,
446
+ );
447
+ const [nonRevertiblePublicCallRequests, revertiblePublicCallRequests] = splitOrderedSideEffects(
448
+ publicCallRequests.sort(sortByCounter),
449
+ minRevertibleSideEffectCounter,
450
+ );
451
+
452
+ const nonRevertibleData = new PrivateToPublicAccumulatedData(
453
+ padArrayEnd(nonRevertibleNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX),
454
+ padArrayEnd(nonRevertibleNullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX),
455
+ padArrayEnd(nonRevertibleL2ToL1Messages, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX),
456
+ padArrayEnd(nonRevertibleTaggedPrivateLogs, PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX),
457
+ padArrayEnd(nonRevertibleContractClassLogHashes, ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX),
458
+ padArrayEnd(nonRevertiblePublicCallRequests, PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX),
459
+ );
460
+
461
+ const revertibleData = new PrivateToPublicAccumulatedData(
462
+ padArrayEnd(revertibleNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX),
463
+ padArrayEnd(revertibleNullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX),
464
+ padArrayEnd(revertibleL2ToL1Messages, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX),
465
+ padArrayEnd(revertibleTaggedPrivateLogs, PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX),
466
+ padArrayEnd(revertibleContractClassLogHashes, ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX),
467
+ padArrayEnd(revertiblePublicCallRequests, PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX),
468
+ );
469
+ gasUsed = meterGasUsed(revertibleData).add(meterGasUsed(nonRevertibleData));
470
+ if (publicTeardownCallRequest) {
471
+ gasUsed.add(privateExecutionResult.entrypoint.publicInputs.txContext.gasSettings.teardownGasLimits);
472
+ }
473
+
474
+ inputsForPublic = new PartialPrivateTailPublicInputsForPublic(
475
+ nonRevertibleData,
476
+ revertibleData,
477
+ publicTeardownCallRequest ?? PublicCallRequest.empty(),
478
+ );
479
+ }
480
+
481
+ const publicInputs = new PrivateKernelTailCircuitPublicInputs(
482
+ constantData,
483
+ /*gasUsed=*/ gasUsed.add(Gas.from({ l2Gas: FIXED_L2_GAS, daGas: FIXED_DA_GAS })),
484
+ /*feePayer=*/ AztecAddress.zero(),
485
+ /*includeByTimestamp=*/ 0n,
486
+ hasPublicCalls ? inputsForPublic : undefined,
487
+ !hasPublicCalls ? inputsForRollup : undefined,
488
+ );
489
+
490
+ return {
491
+ publicInputs,
492
+ chonkProof: ChonkProof.empty(),
493
+ executionSteps,
494
+ };
495
+ }
496
+
497
+ function splitOrderedSideEffects<T>(effects: OrderedSideEffect<T>[], minRevertibleSideEffectCounter: number) {
498
+ const revertibleSideEffects: T[] = [];
499
+ const nonRevertibleSideEffects: T[] = [];
500
+ effects.forEach(effect => {
501
+ if (effect.counter < minRevertibleSideEffectCounter) {
502
+ nonRevertibleSideEffects.push(effect.sideEffect);
503
+ } else {
504
+ revertibleSideEffects.push(effect.sideEffect);
505
+ }
506
+ });
507
+ return [nonRevertibleSideEffects, revertibleSideEffects];
508
+ }
509
+
510
+ function meterGasUsed(data: PrivateToRollupAccumulatedData | PrivateToPublicAccumulatedData) {
511
+ let meteredDAFields = 0;
512
+ let meteredL2Gas = 0;
513
+
514
+ const numNoteHashes = arrayNonEmptyLength(data.noteHashes, hash => hash.isEmpty());
515
+ meteredDAFields += numNoteHashes;
516
+ meteredL2Gas += numNoteHashes * AVM_EMITNOTEHASH_BASE_L2_GAS;
517
+
518
+ const numNullifiers = arrayNonEmptyLength(data.nullifiers, nullifier => nullifier.isEmpty());
519
+ meteredDAFields += numNullifiers;
520
+ meteredL2Gas += numNullifiers * AVM_EMITNULLIFIER_BASE_L2_GAS;
521
+
522
+ const numL2toL1Messages = arrayNonEmptyLength(data.l2ToL1Msgs, msg => msg.isEmpty());
523
+ meteredDAFields += numL2toL1Messages;
524
+ meteredL2Gas += numL2toL1Messages * AVM_SENDL2TOL1MSG_BASE_L2_GAS;
525
+
526
+ const numPrivatelogs = arrayNonEmptyLength(data.privateLogs, log => log.isEmpty());
527
+ // Every private log emits its length as an additional field
528
+ meteredDAFields += data.privateLogs.reduce((acc, log) => (!log.isEmpty() ? acc + log.emittedLength + 1 : acc), 0);
529
+ meteredL2Gas += numPrivatelogs * L2_GAS_PER_PRIVATE_LOG;
530
+
531
+ const numContractClassLogs = arrayNonEmptyLength(data.contractClassLogsHashes, log => log.isEmpty());
532
+ // Every contract class log emits its length and contract address as additional fields
533
+ meteredDAFields += data.contractClassLogsHashes.reduce(
534
+ (acc, log) => (!log.isEmpty() ? acc + log.logHash.length + 2 : acc),
535
+ 0,
536
+ );
537
+ meteredL2Gas += numContractClassLogs * L2_GAS_PER_CONTRACT_CLASS_LOG;
538
+
539
+ const meteredDAGas = meteredDAFields * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
540
+
541
+ if ((data as PrivateToPublicAccumulatedData).publicCallRequests) {
542
+ const dataForPublic = data as PrivateToPublicAccumulatedData;
543
+
544
+ const numPublicCallRequests = arrayNonEmptyLength(dataForPublic.publicCallRequests, req => req.isEmpty());
545
+ meteredL2Gas += numPublicCallRequests * FIXED_AVM_STARTUP_L2_GAS;
546
+ }
547
+ return Gas.from({ l2Gas: meteredL2Gas, daGas: meteredDAGas });
548
+ }