@aztec/pxe 0.0.1-fake-ceab37513c → 0.0.6-commit.a2d1860fe9

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 (442) hide show
  1. package/README.md +5 -5
  2. package/dest/access_scopes.d.ts +9 -0
  3. package/dest/access_scopes.d.ts.map +1 -0
  4. package/dest/access_scopes.js +6 -0
  5. package/dest/bin/check_oracle_version.d.ts +1 -1
  6. package/dest/bin/check_oracle_version.js +110 -10
  7. package/dest/block_synchronizer/block_synchronizer.d.ts +45 -0
  8. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
  9. package/dest/block_synchronizer/block_synchronizer.js +153 -0
  10. package/dest/block_synchronizer/index.d.ts +2 -0
  11. package/dest/block_synchronizer/index.d.ts.map +1 -0
  12. package/dest/block_synchronizer/index.js +1 -0
  13. package/dest/config/index.d.ts +11 -17
  14. package/dest/config/index.d.ts.map +1 -1
  15. package/dest/config/index.js +27 -16
  16. package/dest/config/package_info.d.ts +1 -1
  17. package/dest/config/package_info.js +1 -1
  18. package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
  19. package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
  20. package/dest/contract_function_simulator/benchmarked_node.js +77 -0
  21. package/dest/contract_function_simulator/contract_function_simulator.d.ts +79 -27
  22. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  23. package/dest/contract_function_simulator/contract_function_simulator.js +287 -87
  24. package/dest/contract_function_simulator/execution_note_cache.d.ts +26 -15
  25. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  26. package/dest/contract_function_simulator/execution_note_cache.js +65 -37
  27. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
  28. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
  29. package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
  30. package/dest/contract_function_simulator/hashed_values_cache.d.ts +2 -2
  31. package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -1
  32. package/dest/contract_function_simulator/index.d.ts +5 -3
  33. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  34. package/dest/contract_function_simulator/index.js +3 -2
  35. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +5 -4
  36. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  37. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +7 -4
  38. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +5 -4
  39. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
  40. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +7 -6
  41. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +3 -3
  42. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  43. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +8 -4
  44. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +7 -4
  45. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  46. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +13 -4
  47. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +16 -0
  48. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
  49. package/dest/contract_function_simulator/noir-structs/utility_context.js +22 -0
  50. package/dest/contract_function_simulator/oracle/index.d.ts +2 -2
  51. package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -1
  52. package/dest/contract_function_simulator/oracle/index.js +1 -1
  53. package/dest/contract_function_simulator/oracle/interfaces.d.ts +107 -0
  54. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
  55. package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
  56. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +2 -2
  57. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  58. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -1
  59. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +14 -8
  60. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
  61. package/dest/contract_function_simulator/oracle/note_packing_utils.js +16 -11
  62. package/dest/contract_function_simulator/oracle/oracle.d.ts +26 -22
  63. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  64. package/dest/contract_function_simulator/oracle/oracle.js +156 -113
  65. package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -27
  66. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  67. package/dest/contract_function_simulator/oracle/private_execution.js +3 -48
  68. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +72 -52
  69. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  70. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +173 -68
  71. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +116 -53
  72. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  73. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +217 -94
  74. package/dest/contract_function_simulator/pick_notes.d.ts +2 -2
  75. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
  76. package/dest/contract_function_simulator/pick_notes.js +1 -1
  77. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +4 -4
  78. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
  79. package/dest/contract_function_simulator/proxied_contract_data_source.js +23 -5
  80. package/dest/contract_logging.d.ts +22 -0
  81. package/dest/contract_logging.d.ts.map +1 -0
  82. package/dest/contract_logging.js +23 -0
  83. package/dest/contract_sync/contract_sync_service.d.ts +43 -0
  84. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
  85. package/dest/contract_sync/contract_sync_service.js +97 -0
  86. package/dest/contract_sync/helpers.d.ts +29 -0
  87. package/dest/contract_sync/helpers.d.ts.map +1 -0
  88. package/dest/contract_sync/helpers.js +55 -0
  89. package/dest/debug/pxe_debug_utils.d.ts +45 -0
  90. package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
  91. package/dest/debug/pxe_debug_utils.js +48 -0
  92. package/dest/entrypoints/client/bundle/index.d.ts +7 -3
  93. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  94. package/dest/entrypoints/client/bundle/index.js +5 -2
  95. package/dest/entrypoints/client/bundle/utils.d.ts +9 -9
  96. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  97. package/dest/entrypoints/client/bundle/utils.js +40 -17
  98. package/dest/entrypoints/client/lazy/index.d.ts +7 -3
  99. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  100. package/dest/entrypoints/client/lazy/index.js +5 -2
  101. package/dest/entrypoints/client/lazy/utils.d.ts +9 -9
  102. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  103. package/dest/entrypoints/client/lazy/utils.js +40 -17
  104. package/dest/entrypoints/pxe_creation_options.d.ts +7 -3
  105. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  106. package/dest/entrypoints/server/index.d.ts +9 -3
  107. package/dest/entrypoints/server/index.d.ts.map +1 -1
  108. package/dest/entrypoints/server/index.js +7 -2
  109. package/dest/entrypoints/server/utils.d.ts +5 -24
  110. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  111. package/dest/entrypoints/server/utils.js +42 -51
  112. package/dest/error_enriching.d.ts +11 -0
  113. package/dest/error_enriching.d.ts.map +1 -0
  114. package/dest/{pxe_service/error_enriching.js → error_enriching.js} +9 -6
  115. package/dest/events/event_service.d.ts +15 -0
  116. package/dest/events/event_service.d.ts.map +1 -0
  117. package/dest/events/event_service.js +44 -0
  118. package/dest/events/index.d.ts +2 -0
  119. package/dest/events/index.d.ts.map +1 -0
  120. package/dest/events/index.js +1 -0
  121. package/dest/events/private_event_filter_validator.d.ts +9 -0
  122. package/dest/events/private_event_filter_validator.d.ts.map +1 -0
  123. package/dest/events/private_event_filter_validator.js +38 -0
  124. package/dest/job_coordinator/job_coordinator.d.ts +75 -0
  125. package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
  126. package/dest/job_coordinator/job_coordinator.js +94 -0
  127. package/dest/logs/log_service.d.ts +29 -0
  128. package/dest/logs/log_service.d.ts.map +1 -0
  129. package/dest/logs/log_service.js +118 -0
  130. package/dest/notes/index.d.ts +2 -0
  131. package/dest/notes/index.d.ts.map +1 -0
  132. package/dest/notes/index.js +1 -0
  133. package/dest/notes/note_service.d.ts +49 -0
  134. package/dest/notes/note_service.d.ts.map +1 -0
  135. package/dest/notes/note_service.js +148 -0
  136. package/dest/notes_filter.d.ts +25 -0
  137. package/dest/notes_filter.d.ts.map +1 -0
  138. package/dest/notes_filter.js +4 -0
  139. package/dest/oracle_version.d.ts +3 -3
  140. package/dest/oracle_version.d.ts.map +1 -1
  141. package/dest/oracle_version.js +4 -3
  142. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
  143. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
  144. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.js +41 -0
  145. package/dest/private_kernel/hints/index.d.ts +3 -3
  146. package/dest/private_kernel/hints/index.d.ts.map +1 -1
  147. package/dest/private_kernel/hints/index.js +2 -2
  148. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +28 -0
  149. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
  150. package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +22 -16
  151. package/dest/private_kernel/index.d.ts +1 -1
  152. package/dest/private_kernel/private_kernel_execution_prover.d.ts +11 -3
  153. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  154. package/dest/private_kernel/private_kernel_execution_prover.js +48 -43
  155. package/dest/private_kernel/private_kernel_oracle.d.ts +26 -25
  156. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  157. package/dest/private_kernel/private_kernel_oracle.js +94 -2
  158. package/dest/pxe.d.ts +250 -0
  159. package/dest/pxe.d.ts.map +1 -0
  160. package/dest/pxe.js +774 -0
  161. package/dest/storage/address_store/address_store.d.ts +11 -0
  162. package/dest/storage/address_store/address_store.d.ts.map +1 -0
  163. package/dest/storage/{address_data_provider/address_data_provider.js → address_store/address_store.js} +13 -15
  164. package/dest/storage/address_store/index.d.ts +2 -0
  165. package/dest/storage/address_store/index.d.ts.map +1 -0
  166. package/dest/storage/address_store/index.js +1 -0
  167. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +17 -0
  168. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
  169. package/dest/storage/{sync_data_provider/sync_data_provider.js → anchor_block_store/anchor_block_store.js} +10 -13
  170. package/dest/storage/anchor_block_store/index.d.ts +2 -0
  171. package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
  172. package/dest/storage/anchor_block_store/index.js +1 -0
  173. package/dest/storage/capsule_store/capsule_store.d.ts +72 -0
  174. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
  175. package/dest/storage/capsule_store/capsule_store.js +253 -0
  176. package/dest/storage/capsule_store/index.d.ts +2 -0
  177. package/dest/storage/capsule_store/index.d.ts.map +1 -0
  178. package/dest/storage/capsule_store/index.js +1 -0
  179. package/dest/storage/contract_store/contract_store.d.ts +93 -0
  180. package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
  181. package/dest/storage/contract_store/contract_store.js +309 -0
  182. package/dest/storage/contract_store/index.d.ts +2 -0
  183. package/dest/storage/contract_store/index.d.ts.map +1 -0
  184. package/dest/storage/contract_store/index.js +1 -0
  185. package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.d.ts +1 -1
  186. package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
  187. package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.js +1 -1
  188. package/dest/storage/index.d.ts +8 -9
  189. package/dest/storage/index.d.ts.map +1 -1
  190. package/dest/storage/index.js +7 -8
  191. package/dest/storage/metadata.d.ts +2 -2
  192. package/dest/storage/metadata.js +1 -1
  193. package/dest/storage/note_store/index.d.ts +3 -0
  194. package/dest/storage/note_store/index.d.ts.map +1 -0
  195. package/dest/storage/note_store/index.js +2 -0
  196. package/dest/storage/note_store/note_store.d.ts +83 -0
  197. package/dest/storage/note_store/note_store.d.ts.map +1 -0
  198. package/dest/storage/note_store/note_store.js +343 -0
  199. package/dest/storage/note_store/stored_note.d.ts +16 -0
  200. package/dest/storage/note_store/stored_note.d.ts.map +1 -0
  201. package/dest/storage/note_store/stored_note.js +43 -0
  202. package/dest/storage/private_event_store/private_event_store.d.ts +91 -0
  203. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
  204. package/dest/storage/private_event_store/private_event_store.js +273 -0
  205. package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
  206. package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
  207. package/dest/storage/private_event_store/stored_private_event.js +56 -0
  208. package/dest/storage/tagging_store/index.d.ts +4 -0
  209. package/dest/storage/tagging_store/index.d.ts.map +1 -0
  210. package/dest/storage/tagging_store/index.js +3 -0
  211. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +28 -0
  212. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
  213. package/dest/storage/tagging_store/recipient_tagging_store.js +111 -0
  214. package/dest/storage/tagging_store/sender_address_book_store.d.ts +14 -0
  215. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -0
  216. package/dest/storage/tagging_store/sender_address_book_store.js +36 -0
  217. package/dest/storage/tagging_store/sender_tagging_store.d.ts +77 -0
  218. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
  219. package/dest/storage/tagging_store/sender_tagging_store.js +348 -0
  220. package/dest/tagging/constants.d.ts +2 -0
  221. package/dest/tagging/constants.d.ts.map +1 -0
  222. package/dest/tagging/constants.js +10 -0
  223. package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
  224. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
  225. package/dest/tagging/get_all_logs_by_tags.js +60 -0
  226. package/dest/tagging/index.d.ts +17 -0
  227. package/dest/tagging/index.d.ts.map +1 -0
  228. package/dest/tagging/index.js +15 -0
  229. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +15 -0
  230. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -0
  231. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +99 -0
  232. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +12 -0
  233. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -0
  234. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +20 -0
  235. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +15 -0
  236. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -0
  237. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +32 -0
  238. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +21 -0
  239. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -0
  240. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +74 -0
  241. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +11 -0
  242. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -0
  243. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +29 -0
  244. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +21 -0
  245. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
  246. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +60 -0
  247. package/package.json +30 -23
  248. package/src/access_scopes.ts +9 -0
  249. package/src/bin/check_oracle_version.ts +135 -10
  250. package/src/block_synchronizer/block_synchronizer.ts +178 -0
  251. package/src/block_synchronizer/index.ts +1 -0
  252. package/src/config/index.ts +32 -32
  253. package/src/config/package_info.ts +1 -1
  254. package/src/contract_function_simulator/benchmarked_node.ts +103 -0
  255. package/src/contract_function_simulator/contract_function_simulator.ts +505 -140
  256. package/src/contract_function_simulator/execution_note_cache.ts +67 -32
  257. package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
  258. package/src/contract_function_simulator/hashed_values_cache.ts +1 -1
  259. package/src/contract_function_simulator/index.ts +4 -2
  260. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +7 -3
  261. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +6 -5
  262. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +10 -5
  263. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +15 -3
  264. package/src/contract_function_simulator/noir-structs/utility_context.ts +23 -0
  265. package/src/contract_function_simulator/oracle/index.ts +1 -1
  266. package/src/contract_function_simulator/oracle/interfaces.ts +185 -0
  267. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +1 -1
  268. package/src/contract_function_simulator/oracle/note_packing_utils.ts +30 -14
  269. package/src/contract_function_simulator/oracle/oracle.ts +197 -110
  270. package/src/contract_function_simulator/oracle/private_execution.ts +4 -78
  271. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +248 -122
  272. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +372 -138
  273. package/src/contract_function_simulator/pick_notes.ts +1 -1
  274. package/src/contract_function_simulator/proxied_contract_data_source.ts +24 -7
  275. package/src/contract_logging.ts +39 -0
  276. package/src/contract_sync/contract_sync_service.ts +152 -0
  277. package/src/contract_sync/helpers.ts +98 -0
  278. package/src/debug/pxe_debug_utils.ts +93 -0
  279. package/src/entrypoints/client/bundle/index.ts +6 -2
  280. package/src/entrypoints/client/bundle/utils.ts +31 -32
  281. package/src/entrypoints/client/lazy/index.ts +6 -2
  282. package/src/entrypoints/client/lazy/utils.ts +31 -32
  283. package/src/entrypoints/pxe_creation_options.ts +6 -2
  284. package/src/entrypoints/server/index.ts +8 -2
  285. package/src/entrypoints/server/utils.ts +39 -91
  286. package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +11 -15
  287. package/src/events/event_service.ts +71 -0
  288. package/src/events/index.ts +1 -0
  289. package/src/events/private_event_filter_validator.ts +46 -0
  290. package/src/job_coordinator/job_coordinator.ts +150 -0
  291. package/src/logs/log_service.ts +208 -0
  292. package/src/notes/index.ts +1 -0
  293. package/src/notes/note_service.ts +196 -0
  294. package/src/notes_filter.ts +26 -0
  295. package/src/oracle_version.ts +4 -3
  296. package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +16 -16
  297. package/src/private_kernel/hints/index.ts +2 -2
  298. package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +44 -37
  299. package/src/private_kernel/private_kernel_execution_prover.ts +64 -55
  300. package/src/private_kernel/private_kernel_oracle.ts +118 -37
  301. package/src/pxe.ts +1137 -0
  302. package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +15 -21
  303. package/src/storage/address_store/index.ts +1 -0
  304. package/src/storage/{sync_data_provider/sync_data_provider.ts → anchor_block_store/anchor_block_store.ts} +10 -17
  305. package/src/storage/anchor_block_store/index.ts +1 -0
  306. package/src/storage/capsule_store/capsule_store.ts +315 -0
  307. package/src/storage/capsule_store/index.ts +1 -0
  308. package/src/storage/contract_store/contract_store.ts +429 -0
  309. package/src/storage/contract_store/index.ts +1 -0
  310. package/src/storage/{contract_data_provider → contract_store}/private_functions_tree.ts +1 -1
  311. package/src/storage/index.ts +7 -8
  312. package/src/storage/metadata.ts +1 -1
  313. package/src/storage/note_store/index.ts +2 -0
  314. package/src/storage/note_store/note_store.ts +418 -0
  315. package/src/storage/note_store/stored_note.ts +48 -0
  316. package/src/storage/private_event_store/private_event_store.ts +384 -0
  317. package/src/storage/private_event_store/stored_private_event.ts +73 -0
  318. package/src/storage/tagging_store/index.ts +3 -0
  319. package/src/storage/tagging_store/recipient_tagging_store.ts +139 -0
  320. package/src/storage/tagging_store/sender_address_book_store.ts +48 -0
  321. package/src/storage/tagging_store/sender_tagging_store.ts +429 -0
  322. package/src/tagging/constants.ts +10 -0
  323. package/src/tagging/get_all_logs_by_tags.ts +92 -0
  324. package/src/tagging/index.ts +19 -0
  325. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +143 -0
  326. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +34 -0
  327. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +49 -0
  328. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +99 -0
  329. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +36 -0
  330. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +84 -0
  331. package/dest/bin/index.d.ts +0 -3
  332. package/dest/bin/index.d.ts.map +0 -1
  333. package/dest/bin/index.js +0 -48
  334. package/dest/contract_function_simulator/execution_data_provider.d.ts +0 -285
  335. package/dest/contract_function_simulator/execution_data_provider.d.ts.map +0 -1
  336. package/dest/contract_function_simulator/execution_data_provider.js +0 -14
  337. package/dest/contract_function_simulator/oracle/typed_oracle.d.ts +0 -87
  338. package/dest/contract_function_simulator/oracle/typed_oracle.d.ts.map +0 -1
  339. package/dest/contract_function_simulator/oracle/typed_oracle.js +0 -146
  340. package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
  341. package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
  342. package/dest/contract_function_simulator/proxied_node.js +0 -27
  343. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +0 -158
  344. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +0 -1
  345. package/dest/contract_function_simulator/pxe_oracle_interface.js +0 -701
  346. package/dest/contract_function_simulator/tagging_utils.d.ts +0 -17
  347. package/dest/contract_function_simulator/tagging_utils.d.ts.map +0 -1
  348. package/dest/contract_function_simulator/tagging_utils.js +0 -23
  349. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
  350. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
  351. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
  352. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
  353. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +0 -41
  354. package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -45
  355. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
  356. package/dest/private_kernel/private_kernel_oracle_impl.js +0 -86
  357. package/dest/pxe_service/error_enriching.d.ts +0 -11
  358. package/dest/pxe_service/error_enriching.d.ts.map +0 -1
  359. package/dest/pxe_service/index.d.ts +0 -3
  360. package/dest/pxe_service/index.d.ts.map +0 -1
  361. package/dest/pxe_service/index.js +0 -2
  362. package/dest/pxe_service/pxe_service.d.ts +0 -101
  363. package/dest/pxe_service/pxe_service.d.ts.map +0 -1
  364. package/dest/pxe_service/pxe_service.js +0 -791
  365. package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -13
  366. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +0 -1
  367. package/dest/storage/address_data_provider/index.d.ts +0 -2
  368. package/dest/storage/address_data_provider/index.d.ts.map +0 -1
  369. package/dest/storage/address_data_provider/index.js +0 -1
  370. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +0 -27
  371. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +0 -1
  372. package/dest/storage/capsule_data_provider/capsule_data_provider.js +0 -122
  373. package/dest/storage/capsule_data_provider/index.d.ts +0 -2
  374. package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
  375. package/dest/storage/capsule_data_provider/index.js +0 -1
  376. package/dest/storage/contract_data_provider/contract_data_provider.d.ts +0 -75
  377. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
  378. package/dest/storage/contract_data_provider/contract_data_provider.js +0 -208
  379. package/dest/storage/contract_data_provider/index.d.ts +0 -2
  380. package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
  381. package/dest/storage/contract_data_provider/index.js +0 -1
  382. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
  383. package/dest/storage/data_provider.d.ts +0 -4
  384. package/dest/storage/data_provider.d.ts.map +0 -1
  385. package/dest/storage/data_provider.js +0 -1
  386. package/dest/storage/note_data_provider/index.d.ts +0 -3
  387. package/dest/storage/note_data_provider/index.d.ts.map +0 -1
  388. package/dest/storage/note_data_provider/index.js +0 -2
  389. package/dest/storage/note_data_provider/note_dao.d.ts +0 -100
  390. package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
  391. package/dest/storage/note_data_provider/note_dao.js +0 -102
  392. package/dest/storage/note_data_provider/note_data_provider.d.ts +0 -20
  393. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
  394. package/dest/storage/note_data_provider/note_data_provider.js +0 -260
  395. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +0 -37
  396. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +0 -1
  397. package/dest/storage/private_event_data_provider/private_event_data_provider.js +0 -96
  398. package/dest/storage/sync_data_provider/index.d.ts +0 -2
  399. package/dest/storage/sync_data_provider/index.d.ts.map +0 -1
  400. package/dest/storage/sync_data_provider/index.js +0 -1
  401. package/dest/storage/sync_data_provider/sync_data_provider.d.ts +0 -12
  402. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +0 -1
  403. package/dest/storage/tagging_data_provider/index.d.ts +0 -2
  404. package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
  405. package/dest/storage/tagging_data_provider/index.js +0 -1
  406. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +0 -18
  407. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +0 -1
  408. package/dest/storage/tagging_data_provider/tagging_data_provider.js +0 -82
  409. package/dest/synchronizer/index.d.ts +0 -2
  410. package/dest/synchronizer/index.d.ts.map +0 -1
  411. package/dest/synchronizer/index.js +0 -1
  412. package/dest/synchronizer/synchronizer.d.ts +0 -35
  413. package/dest/synchronizer/synchronizer.d.ts.map +0 -1
  414. package/dest/synchronizer/synchronizer.js +0 -102
  415. package/dest/test/pxe_test_suite.d.ts +0 -3
  416. package/dest/test/pxe_test_suite.d.ts.map +0 -1
  417. package/dest/test/pxe_test_suite.js +0 -97
  418. package/src/bin/index.ts +0 -62
  419. package/src/contract_function_simulator/execution_data_provider.ts +0 -361
  420. package/src/contract_function_simulator/oracle/typed_oracle.ts +0 -289
  421. package/src/contract_function_simulator/proxied_node.ts +0 -33
  422. package/src/contract_function_simulator/pxe_oracle_interface.ts +0 -1020
  423. package/src/contract_function_simulator/tagging_utils.ts +0 -32
  424. package/src/private_kernel/private_kernel_oracle_impl.ts +0 -132
  425. package/src/pxe_service/index.ts +0 -2
  426. package/src/pxe_service/pxe_service.ts +0 -1139
  427. package/src/storage/address_data_provider/index.ts +0 -1
  428. package/src/storage/capsule_data_provider/capsule_data_provider.ts +0 -157
  429. package/src/storage/capsule_data_provider/index.ts +0 -1
  430. package/src/storage/contract_data_provider/contract_data_provider.ts +0 -300
  431. package/src/storage/contract_data_provider/index.ts +0 -1
  432. package/src/storage/data_provider.ts +0 -3
  433. package/src/storage/note_data_provider/index.ts +0 -2
  434. package/src/storage/note_data_provider/note_dao.ts +0 -154
  435. package/src/storage/note_data_provider/note_data_provider.ts +0 -350
  436. package/src/storage/private_event_data_provider/private_event_data_provider.ts +0 -134
  437. package/src/storage/sync_data_provider/index.ts +0 -1
  438. package/src/storage/tagging_data_provider/index.ts +0 -1
  439. package/src/storage/tagging_data_provider/tagging_data_provider.ts +0 -123
  440. package/src/synchronizer/index.ts +0 -1
  441. package/src/synchronizer/synchronizer.ts +0 -121
  442. package/src/test/pxe_test_suite.ts +0 -113
@@ -1,54 +1,64 @@
1
- import { 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 { padArrayEnd } from '@aztec/foundation/collection';
3
- import { poseidon2Hash } from '@aztec/foundation/crypto';
4
- import { Fr } from '@aztec/foundation/fields';
1
+ import { AVM_EMITNOTEHASH_BASE_L2_GAS, AVM_EMITNULLIFIER_BASE_L2_GAS, AVM_SENDL2TOL1MSG_BASE_L2_GAS, DA_GAS_PER_FIELD, FIXED_AVM_STARTUP_L2_GAS, FIXED_DA_GAS, FIXED_L2_GAS, L2_GAS_PER_CONTRACT_CLASS_LOG, L2_GAS_PER_L2_TO_L1_MSG, L2_GAS_PER_NOTE_HASH, L2_GAS_PER_NULLIFIER, 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_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_PRIVATE_LOGS_PER_TX } from '@aztec/constants';
2
+ import { arrayNonEmptyLength, padArrayEnd } from '@aztec/foundation/collection';
3
+ import { Fr } from '@aztec/foundation/curves/bn254';
5
4
  import { createLogger } from '@aztec/foundation/log';
6
5
  import { Timer } from '@aztec/foundation/timer';
7
6
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
8
- import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
7
+ import { protocolContractsHash } from '@aztec/protocol-contracts';
9
8
  import { ExecutionError, createSimulationError, extractCallStack, resolveAssertionMessageFromError, toACVMWitness, witnessMapToFields } from '@aztec/simulator/client';
10
- import { FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
9
+ import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
11
10
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
12
11
  import { Gas } from '@aztec/stdlib/gas';
13
- import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
14
- import { PartialPrivateTailPublicInputsForPublic, PartialPrivateTailPublicInputsForRollup, PrivateKernelTailCircuitPublicInputs, PrivateToPublicAccumulatedData, PrivateToRollupAccumulatedData, PublicCallRequest, ScopedLogHash } from '@aztec/stdlib/kernel';
12
+ import { computeNoteHashNonce, computeProtocolNullifier, computeSiloedPrivateLogFirstField, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
13
+ import { ClaimedLengthArray, PartialPrivateTailPublicInputsForPublic, PartialPrivateTailPublicInputsForRollup, PrivateKernelTailCircuitPublicInputs, PrivateToPublicAccumulatedData, PrivateToRollupAccumulatedData, PublicCallRequest, ReadRequestActionEnum, ScopedLogHash, ScopedNoteHash, ScopedNullifier, ScopedReadRequest, buildTransientDataHints, getNoteHashReadRequestResetActions, getNullifierReadRequestResetActions } from '@aztec/stdlib/kernel';
15
14
  import { PrivateLog } from '@aztec/stdlib/logs';
16
15
  import { ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
17
- import { ClientIvcProof } from '@aztec/stdlib/proofs';
18
- import { CallContext, HashedValues, PrivateExecutionResult, TxConstantData, collectNested } from '@aztec/stdlib/tx';
16
+ import { ChonkProof } from '@aztec/stdlib/proofs';
17
+ import { CallContext, HashedValues, PrivateExecutionResult, TxConstantData, collectNested, collectNoteHashNullifierCounterMap, getFinalMinRevertibleSideEffectCounter } from '@aztec/stdlib/tx';
19
18
  import { ExecutionNoteCache } from './execution_note_cache.js';
19
+ import { ExecutionTaggingIndexCache } from './execution_tagging_index_cache.js';
20
20
  import { HashedValuesCache } from './hashed_values_cache.js';
21
21
  import { Oracle } from './oracle/oracle.js';
22
- import { executePrivateFunction, verifyCurrentClassId } from './oracle/private_execution.js';
22
+ import { executePrivateFunction } from './oracle/private_execution.js';
23
23
  import { PrivateExecutionOracle } from './oracle/private_execution_oracle.js';
24
24
  import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
25
25
  /**
26
26
  * The contract function simulator.
27
27
  */ export class ContractFunctionSimulator {
28
- executionDataProvider;
29
- simulator;
30
28
  log;
31
- constructor(executionDataProvider, simulator){
32
- this.executionDataProvider = executionDataProvider;
33
- this.simulator = simulator;
29
+ contractStore;
30
+ noteStore;
31
+ keyStore;
32
+ addressStore;
33
+ aztecNode;
34
+ senderTaggingStore;
35
+ recipientTaggingStore;
36
+ senderAddressBookStore;
37
+ capsuleStore;
38
+ privateEventStore;
39
+ simulator;
40
+ contractSyncService;
41
+ constructor(args){
42
+ this.contractStore = args.contractStore;
43
+ this.noteStore = args.noteStore;
44
+ this.keyStore = args.keyStore;
45
+ this.addressStore = args.addressStore;
46
+ this.aztecNode = args.aztecNode;
47
+ this.senderTaggingStore = args.senderTaggingStore;
48
+ this.recipientTaggingStore = args.recipientTaggingStore;
49
+ this.senderAddressBookStore = args.senderAddressBookStore;
50
+ this.capsuleStore = args.capsuleStore;
51
+ this.privateEventStore = args.privateEventStore;
52
+ this.simulator = args.simulator;
53
+ this.contractSyncService = args.contractSyncService;
34
54
  this.log = createLogger('simulator');
35
55
  }
36
56
  /**
37
57
  * Runs a private function.
38
58
  * @param request - The transaction request.
39
- * @param entryPointArtifact - The artifact of the entry point function.
40
- * @param contractAddress - The address of the contract (should match request.origin)
41
- * @param msgSender - The address calling the function. This can be replaced to simulate a call from another contract
42
- * or a specific account.
43
- * @param senderForTags - The address that is used as a tagging sender when emitting private logs. Returned from
44
- * the `privateGetSenderForTags` oracle.
45
- * @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
46
- * @returns The result of the execution.
47
- */ async run(request, contractAddress, selector, msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE), senderForTags, scopes) {
59
+ */ async run(request, { contractAddress, selector, msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE), anchorBlockHeader, senderForTags, scopes, jobId }) {
48
60
  const simulatorSetupTimer = new Timer();
49
- const header = await this.executionDataProvider.getBlockHeader();
50
- await verifyCurrentClassId(contractAddress, this.executionDataProvider);
51
- const entryPointArtifact = await this.executionDataProvider.getFunctionArtifact(contractAddress, selector);
61
+ const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(contractAddress, selector);
52
62
  if (entryPointArtifact.functionType !== FunctionType.PRIVATE) {
53
63
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as private`);
54
64
  }
@@ -56,11 +66,42 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
56
66
  this.log.warn(`Request origin does not match contract address in simulation. Request origin: ${request.origin}, contract address: ${contractAddress}`);
57
67
  }
58
68
  // reserve the first side effect for the tx hash (inserted by the private kernel)
59
- const startSideEffectCounter = 1;
69
+ const startSideEffectCounter = 2;
60
70
  const callContext = new CallContext(msgSender, contractAddress, await FunctionSelector.fromNameAndParameters(entryPointArtifact.name, entryPointArtifact.parameters), entryPointArtifact.isStatic);
61
- const txRequestHash = await request.toTxRequest().hash();
62
- const noteCache = new ExecutionNoteCache(txRequestHash);
63
- const privateExecutionOracle = new PrivateExecutionOracle(request.firstCallArgsHash, request.txContext, callContext, header, request.authWitnesses, request.capsules, HashedValuesCache.create(request.argsOfCalls), noteCache, this.executionDataProvider, this.simulator, 0, startSideEffectCounter, undefined, scopes, senderForTags);
71
+ const protocolNullifier = await computeProtocolNullifier(await request.toTxRequest().hash());
72
+ const noteCache = new ExecutionNoteCache(protocolNullifier);
73
+ const taggingIndexCache = new ExecutionTaggingIndexCache();
74
+ const privateExecutionOracle = new PrivateExecutionOracle({
75
+ argsHash: request.firstCallArgsHash,
76
+ txContext: request.txContext,
77
+ callContext,
78
+ anchorBlockHeader,
79
+ utilityExecutor: async (call, execScopes)=>{
80
+ await this.runUtility(call, [], anchorBlockHeader, execScopes, jobId);
81
+ },
82
+ authWitnesses: request.authWitnesses,
83
+ capsules: request.capsules,
84
+ executionCache: HashedValuesCache.create(request.argsOfCalls),
85
+ noteCache,
86
+ taggingIndexCache,
87
+ contractStore: this.contractStore,
88
+ noteStore: this.noteStore,
89
+ keyStore: this.keyStore,
90
+ addressStore: this.addressStore,
91
+ aztecNode: this.aztecNode,
92
+ senderTaggingStore: this.senderTaggingStore,
93
+ recipientTaggingStore: this.recipientTaggingStore,
94
+ senderAddressBookStore: this.senderAddressBookStore,
95
+ capsuleStore: this.capsuleStore,
96
+ privateEventStore: this.privateEventStore,
97
+ contractSyncService: this.contractSyncService,
98
+ jobId,
99
+ totalPublicCalldataCount: 0,
100
+ sideEffectCounter: startSideEffectCounter,
101
+ scopes,
102
+ senderForTags,
103
+ simulator: this.simulator
104
+ });
64
105
  const setupTime = simulatorSetupTimer.ms();
65
106
  try {
66
107
  // Note: any nested private function calls are made recursively within this
@@ -69,8 +110,8 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
69
110
  // within executionResult.nestedExecutionResults).
70
111
  const executionResult = await executePrivateFunction(this.simulator, privateExecutionOracle, entryPointArtifact, contractAddress, request.functionSelector);
71
112
  const simulatorTeardownTimer = new Timer();
72
- const { usedTxRequestHashForNonces } = noteCache.finish();
73
- const firstNullifierHint = usedTxRequestHashForNonces ? Fr.ZERO : noteCache.getAllNullifiers()[0];
113
+ noteCache.finish();
114
+ const firstNullifierHint = noteCache.getNonceGenerator();
74
115
  const publicCallRequests = collectNested([
75
116
  executionResult
76
117
  ], (r)=>r.publicInputs.publicCallRequests.getActiveItems().map((r)=>r.inner).concat(r.publicInputs.publicTeardownCallRequest.isEmpty() ? [] : [
@@ -98,16 +139,32 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
98
139
  * Runs a utility function.
99
140
  * @param call - The function call to execute.
100
141
  * @param authwits - Authentication witnesses required for the function call.
142
+ * @param anchorBlockHeader - The block header to use as base state for this run.
101
143
  * @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
102
144
  * accounts if not specified.
103
- * @returns A decoded ABI value containing the function's return data.
104
- */ async runUtility(call, authwits, scopes) {
105
- await verifyCurrentClassId(call.to, this.executionDataProvider);
106
- const entryPointArtifact = await this.executionDataProvider.getFunctionArtifact(call.to, call.selector);
145
+ * @returns A return value of the utility function in a form as returned by the simulator (Noir fields)
146
+ */ async runUtility(call, authwits, anchorBlockHeader, scopes, jobId) {
147
+ const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
107
148
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
108
149
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
109
150
  }
110
- const oracle = new UtilityExecutionOracle(call.to, authwits, [], this.executionDataProvider, undefined, scopes);
151
+ const oracle = new UtilityExecutionOracle({
152
+ contractAddress: call.to,
153
+ authWitnesses: authwits,
154
+ capsules: [],
155
+ anchorBlockHeader,
156
+ contractStore: this.contractStore,
157
+ noteStore: this.noteStore,
158
+ keyStore: this.keyStore,
159
+ addressStore: this.addressStore,
160
+ aztecNode: this.aztecNode,
161
+ recipientTaggingStore: this.recipientTaggingStore,
162
+ senderAddressBookStore: this.senderAddressBookStore,
163
+ capsuleStore: this.capsuleStore,
164
+ privateEventStore: this.privateEventStore,
165
+ jobId,
166
+ scopes
167
+ });
111
168
  try {
112
169
  this.log.verbose(`Executing utility function ${entryPointArtifact.name}`, {
113
170
  contract: call.to,
@@ -123,16 +180,29 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
123
180
  cause: err
124
181
  });
125
182
  });
126
- const returnWitness = witnessMapToFields(acirExecutionResult.returnWitness);
127
- this.log.verbose(`Utility simulation for ${call.to}.${call.selector} completed`);
128
- return decodeFromAbi(entryPointArtifact.returnTypes, returnWitness);
183
+ this.log.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
184
+ return witnessMapToFields(acirExecutionResult.returnWitness);
129
185
  } catch (err) {
130
186
  throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
131
187
  }
132
188
  }
133
189
  // docs:end:execute_utility_function
134
- getStats() {
135
- return this.executionDataProvider.getStats();
190
+ /**
191
+ * Returns the execution statistics collected during the simulator run.
192
+ * @returns The execution statistics.
193
+ */ getStats() {
194
+ const nodeRPCCalls = typeof this.aztecNode.getStats === 'function' ? this.aztecNode.getStats() : {
195
+ perMethod: {},
196
+ roundTrips: {
197
+ roundTrips: 0,
198
+ totalBlockingTime: 0,
199
+ roundTripDurations: [],
200
+ roundTripMethods: []
201
+ }
202
+ };
203
+ return {
204
+ nodeRPCCalls
205
+ };
136
206
  }
137
207
  }
138
208
  class OrderedSideEffect {
@@ -144,24 +214,30 @@ class OrderedSideEffect {
144
214
  }
145
215
  }
146
216
  /**
147
- * Generates the final public inputs of the tail kernel circuit, an empty ClientIVC proof
217
+ * Generates the final public inputs of the tail kernel circuit, an empty Chonk proof
148
218
  * and the execution steps for a `PrivateExecutionResult` as if it had been
149
219
  * processed by the private kernel prover. This skips many of the checks performed by the kernels
150
220
  * (allowing state overrides) and is much faster, while still generating a valid
151
221
  * output that can be sent to the node for public simulation
152
222
  * @param privateExecutionResult - The result of the private execution.
153
- * @param nonceGenerator - A nonce generator for note hashes. According to the protocol rules,
154
- * it can either be the first nullifier in the tx or the hash of the initial tx request if there are none.
155
- * @param contractDataProvider - A provider for contract data in order to get function names and debug info.
223
+ * @param debugFunctionNameGetter - A provider for contract data in order to get function names and debug info.
224
+ * @param node - AztecNode for verifying settled read requests against the note hash and nullifier trees.
225
+ * @param minRevertibleSideEffectCounterOverride - Optional override for the min revertible side effect counter.
226
+ * Used by TXE to simulate account contract behavior (setting the counter before app execution).
156
227
  * @returns The simulated proving result.
157
- */ export async function generateSimulatedProvingResult(privateExecutionResult, nonceGenerator, contractDataProvider) {
158
- const siloedNoteHashes = [];
159
- const nullifiers = [];
228
+ */ export async function generateSimulatedProvingResult(privateExecutionResult, debugFunctionNameGetter, node, minRevertibleSideEffectCounterOverride) {
160
229
  const taggedPrivateLogs = [];
161
230
  const l2ToL1Messages = [];
162
231
  const contractClassLogsHashes = [];
163
232
  const publicCallRequests = [];
164
233
  const executionSteps = [];
234
+ // Unsiloed scoped arrays — used for squashing, read request verification,
235
+ // and siloed at the end only for the surviving items
236
+ const scopedNoteHashes = [];
237
+ const scopedNullifiers = [];
238
+ // Read requests for verification
239
+ const noteHashReadRequests = [];
240
+ const nullifierReadRequests = [];
165
241
  let publicTeardownCallRequest;
166
242
  const executions = [
167
243
  privateExecutionResult.entrypoint
@@ -170,18 +246,14 @@ class OrderedSideEffect {
170
246
  const execution = executions.shift();
171
247
  executions.unshift(...execution.nestedExecutionResults);
172
248
  const { contractAddress } = execution.publicInputs.callContext;
173
- 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)));
174
- const nullifiersFromExecution = await Promise.all(execution.publicInputs.nullifiers.getActiveItems().map(async (nullifier)=>new OrderedSideEffect(await siloNullifier(contractAddress, nullifier.value), nullifier.counter)));
175
- const privateLogsFromExecution = await Promise.all(execution.publicInputs.privateLogs.getActiveItems().map(async (metadata)=>{
176
- metadata.log.fields[0] = await poseidon2Hash([
177
- contractAddress,
178
- metadata.log.fields[0]
179
- ]);
180
- return new OrderedSideEffect(metadata.log, metadata.counter);
181
- }));
182
- siloedNoteHashes.push(...noteHashesFromExecution);
183
- taggedPrivateLogs.push(...privateLogsFromExecution);
184
- nullifiers.push(...nullifiersFromExecution);
249
+ scopedNoteHashes.push(...execution.publicInputs.noteHashes.getActiveItems().filter((nh)=>!nh.isEmpty()).map((nh)=>nh.scope(contractAddress)));
250
+ scopedNullifiers.push(...execution.publicInputs.nullifiers.getActiveItems().map((n)=>n.scope(contractAddress)));
251
+ taggedPrivateLogs.push(...await Promise.all(execution.publicInputs.privateLogs.getActiveItems().map(async (metadata)=>{
252
+ metadata.log.fields[0] = await computeSiloedPrivateLogFirstField(contractAddress, metadata.log.fields[0]);
253
+ return new OrderedSideEffect(metadata, metadata.counter);
254
+ })));
255
+ noteHashReadRequests.push(...execution.publicInputs.noteHashReadRequests.getActiveItems());
256
+ nullifierReadRequests.push(...execution.publicInputs.nullifierReadRequests.getActiveItems());
185
257
  l2ToL1Messages.push(...execution.publicInputs.l2ToL1Msgs.getActiveItems().map((message)=>new OrderedSideEffect(message.message.scope(contractAddress), message.counter)));
186
258
  contractClassLogsHashes.push(...execution.publicInputs.contractClassLogsHashes.getActiveItems().map((contractClassLogHash)=>new OrderedSideEffect(contractClassLogHash.logHash.scope(contractAddress), contractClassLogHash.counter)));
187
259
  publicCallRequests.push(...execution.publicInputs.publicCallRequests.getActiveItems().map((callRequest)=>new OrderedSideEffect(callRequest.inner, callRequest.counter)));
@@ -190,7 +262,7 @@ class OrderedSideEffect {
190
262
  }
191
263
  publicTeardownCallRequest = execution.publicInputs.publicTeardownCallRequest.isEmpty() ? publicTeardownCallRequest : execution.publicInputs.publicTeardownCallRequest;
192
264
  executionSteps.push({
193
- functionName: await contractDataProvider.getDebugFunctionName(execution.publicInputs.callContext.contractAddress, execution.publicInputs.callContext.functionSelector),
265
+ functionName: await debugFunctionNameGetter(execution.publicInputs.callContext.contractAddress, execution.publicInputs.callContext.functionSelector),
194
266
  timings: execution.profileResult?.timings ?? {
195
267
  witgen: 0,
196
268
  oracles: {}
@@ -200,46 +272,174 @@ class OrderedSideEffect {
200
272
  witness: execution.partialWitness
201
273
  });
202
274
  }
203
- const constantData = new TxConstantData(privateExecutionResult.entrypoint.publicInputs.historicalHeader, privateExecutionResult.entrypoint.publicInputs.txContext, getVKTreeRoot(), protocolContractTreeRoot);
275
+ const noteHashNullifierCounterMap = collectNoteHashNullifierCounterMap(privateExecutionResult);
276
+ const minRevertibleSideEffectCounter = minRevertibleSideEffectCounterOverride ?? getFinalMinRevertibleSideEffectCounter(privateExecutionResult);
277
+ const scopedNoteHashesCLA = new ClaimedLengthArray(padArrayEnd(scopedNoteHashes, ScopedNoteHash.empty(), MAX_NOTE_HASHES_PER_TX), scopedNoteHashes.length);
278
+ const scopedNullifiersCLA = new ClaimedLengthArray(padArrayEnd(scopedNullifiers, ScopedNullifier.empty(), MAX_NULLIFIERS_PER_TX), scopedNullifiers.length);
279
+ const { filteredNoteHashes, filteredNullifiers, filteredPrivateLogs } = squashTransientSideEffects(taggedPrivateLogs, scopedNoteHashesCLA, scopedNullifiersCLA, noteHashNullifierCounterMap, minRevertibleSideEffectCounter);
280
+ await verifyReadRequests(node, await privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader.hash(), noteHashReadRequests, nullifierReadRequests, scopedNoteHashesCLA, scopedNullifiersCLA);
281
+ const siloedNoteHashes = await Promise.all(filteredNoteHashes.sort((a, b)=>a.counter - b.counter).map(async (nh)=>new OrderedSideEffect(await siloNoteHash(nh.contractAddress, nh.value), nh.counter)));
282
+ const siloedNullifiers = await Promise.all(filteredNullifiers.sort((a, b)=>a.counter - b.counter).map(async (n)=>new OrderedSideEffect(await siloNullifier(n.contractAddress, n.value), n.counter)));
283
+ const constantData = new TxConstantData(privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader, privateExecutionResult.entrypoint.publicInputs.txContext, getVKTreeRoot(), protocolContractsHash);
204
284
  const hasPublicCalls = privateExecutionResult.publicFunctionCalldata.length !== 0;
205
285
  let inputsForRollup;
206
286
  let inputsForPublic;
287
+ let gasUsed;
207
288
  const sortByCounter = (a, b)=>a.counter - b.counter;
208
289
  const getEffect = (orderedSideEffect)=>orderedSideEffect.sideEffect;
209
- const sortedNullifiers = nullifiers.sort(sortByCounter).map(getEffect);
210
- // If the tx generated no nullifiers, the nonce generator (txRequest hash)
211
- // is injected as the first nullifier as per protocol rules.
212
- if (sortedNullifiers.length === 0) {
213
- sortedNullifiers.push(nonceGenerator);
290
+ const isPrivateOnlyTx = privateExecutionResult.publicFunctionCalldata.length === 0;
291
+ const [nonRevertibleNullifiers, revertibleNullifiers] = splitOrderedSideEffects(siloedNullifiers, minRevertibleSideEffectCounter);
292
+ const nonceGenerator = privateExecutionResult.firstNullifier;
293
+ if (nonRevertibleNullifiers.length === 0) {
294
+ nonRevertibleNullifiers.push(nonceGenerator);
295
+ } else if (!nonRevertibleNullifiers[0].equals(nonceGenerator)) {
296
+ throw new Error('The first non revertible nullifier should be equal to the nonce generator. This is a bug!');
214
297
  }
215
- // Private only
216
- if (privateExecutionResult.publicFunctionCalldata.length === 0) {
217
- // In case the tx only contains private functions, we must make the note hashes unique by using the
298
+ if (isPrivateOnlyTx) {
299
+ // We must make the note hashes unique by using the
218
300
  // nonce generator and their index in the tx.
219
- const uniqueNoteHashes = await Promise.all(siloedNoteHashes.sort(sortByCounter).map(async (orderedSideEffect, i)=>{
301
+ const uniqueNoteHashes = await Promise.all(siloedNoteHashes.map(async (orderedSideEffect, i)=>{
220
302
  const siloedNoteHash = orderedSideEffect.sideEffect;
221
303
  const nonce = await computeNoteHashNonce(nonceGenerator, i);
222
304
  const uniqueNoteHash = await computeUniqueNoteHash(nonce, siloedNoteHash);
223
305
  return uniqueNoteHash;
224
306
  }));
225
- const accumulatedDataForRollup = new PrivateToRollupAccumulatedData(padArrayEnd(uniqueNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX), padArrayEnd(sortedNullifiers, 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));
307
+ 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(filteredPrivateLogs.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));
308
+ gasUsed = meterGasUsed(accumulatedDataForRollup, isPrivateOnlyTx);
226
309
  inputsForRollup = new PartialPrivateTailPublicInputsForRollup(accumulatedDataForRollup);
227
310
  } else {
228
- const nonRevertibleData = PrivateToPublicAccumulatedData.empty();
229
- // The nullifier array contains the nonce generator in position 0
230
- // Here we remove it from the revertible data and
231
- // add it as the first non-revertible nullifier (we can't have dupes!)
232
- // This is because public processor will use that first non-revertible nullifier
233
- // as the nonce generator for the note hashes in the revertible part of the tx.
234
- const [firstNullifier] = sortedNullifiers.splice(0, 1);
235
- nonRevertibleData.nullifiers[0] = firstNullifier;
236
- const revertibleData = new PrivateToPublicAccumulatedData(padArrayEnd(siloedNoteHashes.sort(sortByCounter).map(getEffect), Fr.ZERO, MAX_NOTE_HASHES_PER_TX), padArrayEnd(sortedNullifiers, 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), padArrayEnd(publicCallRequests.sort(sortByCounter).map(getEffect), PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX));
311
+ const [nonRevertibleNoteHashes, revertibleNoteHashes] = splitOrderedSideEffects(siloedNoteHashes, minRevertibleSideEffectCounter);
312
+ const nonRevertibleUniqueNoteHashes = await Promise.all(nonRevertibleNoteHashes.map(async (noteHash, i)=>{
313
+ const nonce = await computeNoteHashNonce(nonceGenerator, i);
314
+ return await computeUniqueNoteHash(nonce, noteHash);
315
+ }));
316
+ const [nonRevertibleL2ToL1Messages, revertibleL2ToL1Messages] = splitOrderedSideEffects(l2ToL1Messages.sort(sortByCounter), minRevertibleSideEffectCounter);
317
+ const [nonRevertibleTaggedPrivateLogs, revertibleTaggedPrivateLogs] = splitOrderedSideEffects(filteredPrivateLogs, minRevertibleSideEffectCounter);
318
+ const [nonRevertibleContractClassLogHashes, revertibleContractClassLogHashes] = splitOrderedSideEffects(contractClassLogsHashes.sort(sortByCounter), minRevertibleSideEffectCounter);
319
+ const [nonRevertiblePublicCallRequests, revertiblePublicCallRequests] = splitOrderedSideEffects(publicCallRequests.sort(sortByCounter), minRevertibleSideEffectCounter);
320
+ const nonRevertibleData = new PrivateToPublicAccumulatedData(padArrayEnd(nonRevertibleUniqueNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX), padArrayEnd(nonRevertibleNullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX), padArrayEnd(nonRevertibleL2ToL1Messages, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX), padArrayEnd(nonRevertibleTaggedPrivateLogs, PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX), padArrayEnd(nonRevertibleContractClassLogHashes, ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX), padArrayEnd(nonRevertiblePublicCallRequests, PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX));
321
+ 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));
322
+ gasUsed = meterGasUsed(revertibleData, isPrivateOnlyTx).add(meterGasUsed(nonRevertibleData, isPrivateOnlyTx));
323
+ if (publicTeardownCallRequest) {
324
+ gasUsed = gasUsed.add(privateExecutionResult.entrypoint.publicInputs.txContext.gasSettings.teardownGasLimits);
325
+ }
237
326
  inputsForPublic = new PartialPrivateTailPublicInputsForPublic(nonRevertibleData, revertibleData, publicTeardownCallRequest ?? PublicCallRequest.empty());
238
327
  }
239
- const publicInputs = new PrivateKernelTailCircuitPublicInputs(constantData, /*gasUsed=*/ new Gas(0, 0), /*feePayer=*/ AztecAddress.zero(), /*includeByTimestamp=*/ 0n, hasPublicCalls ? inputsForPublic : undefined, !hasPublicCalls ? inputsForRollup : undefined);
328
+ const publicInputs = new PrivateKernelTailCircuitPublicInputs(constantData, /*gasUsed=*/ gasUsed.add(Gas.from({
329
+ l2Gas: FIXED_L2_GAS,
330
+ daGas: FIXED_DA_GAS
331
+ })), /*feePayer=*/ AztecAddress.zero(), /*expirationTimestamp=*/ 0n, hasPublicCalls ? inputsForPublic : undefined, !hasPublicCalls ? inputsForRollup : undefined);
240
332
  return {
241
333
  publicInputs,
242
- clientIvcProof: ClientIvcProof.empty(),
243
- executionSteps: executionSteps
334
+ chonkProof: ChonkProof.empty(),
335
+ executionSteps
336
+ };
337
+ }
338
+ /**
339
+ * Squashes transient note hashes and nullifiers, mimicking the behavior
340
+ * of the reset kernels. Returns the filtered (surviving) scoped items and private logs.
341
+ */ function squashTransientSideEffects(taggedPrivateLogs, scopedNoteHashesCLA, scopedNullifiersCLA, noteHashNullifierCounterMap, minRevertibleSideEffectCounter) {
342
+ const { numTransientData, hints: transientDataHints } = buildTransientDataHints(scopedNoteHashesCLA, scopedNullifiersCLA, /*futureNoteHashReads=*/ [], /*futureNullifierReads=*/ [], noteHashNullifierCounterMap, minRevertibleSideEffectCounter);
343
+ const squashedNoteHashCounters = new Set();
344
+ const squashedNullifierCounters = new Set();
345
+ for(let i = 0; i < numTransientData; i++){
346
+ const hint = transientDataHints[i];
347
+ squashedNoteHashCounters.add(scopedNoteHashesCLA.array[hint.noteHashIndex].counter);
348
+ squashedNullifierCounters.add(scopedNullifiersCLA.array[hint.nullifierIndex].counter);
349
+ }
350
+ return {
351
+ filteredNoteHashes: scopedNoteHashesCLA.getActiveItems().filter((nh)=>!squashedNoteHashCounters.has(nh.counter)),
352
+ filteredNullifiers: scopedNullifiersCLA.getActiveItems().filter((n)=>!squashedNullifierCounters.has(n.counter)),
353
+ filteredPrivateLogs: taggedPrivateLogs.filter((item)=>!squashedNoteHashCounters.has(item.sideEffect.noteHashCounter)).map((item)=>new OrderedSideEffect(item.sideEffect.log, item.counter))
244
354
  };
245
355
  }
356
+ /**
357
+ * Verifies settled read requests by checking membership in the note hash and nullifier trees
358
+ * at the tx's anchor block, mimicking the behavior of the kernels
359
+ */ async function verifyReadRequests(node, anchorBlockHash, noteHashReadRequests, nullifierReadRequests, scopedNoteHashesCLA, scopedNullifiersCLA) {
360
+ const noteHashReadRequestsCLA = new ClaimedLengthArray(padArrayEnd(noteHashReadRequests, ScopedReadRequest.empty(), MAX_NOTE_HASH_READ_REQUESTS_PER_TX), noteHashReadRequests.length);
361
+ const nullifierReadRequestsCLA = new ClaimedLengthArray(padArrayEnd(nullifierReadRequests, ScopedReadRequest.empty(), MAX_NULLIFIER_READ_REQUESTS_PER_TX), nullifierReadRequests.length);
362
+ const noteHashResetActions = getNoteHashReadRequestResetActions(noteHashReadRequestsCLA, scopedNoteHashesCLA, /*futureNoteHashes=*/ []);
363
+ const nullifierResetActions = getNullifierReadRequestResetActions(nullifierReadRequestsCLA, scopedNullifiersCLA, /*futureNullifiers=*/ []);
364
+ const settledNoteHashReads = [];
365
+ for(let i = 0; i < noteHashResetActions.actions.length; i++){
366
+ if (noteHashResetActions.actions[i] === ReadRequestActionEnum.READ_AS_SETTLED) {
367
+ settledNoteHashReads.push({
368
+ index: i,
369
+ value: noteHashReadRequests[i].value
370
+ });
371
+ }
372
+ }
373
+ const settledNullifierReads = [];
374
+ for(let i = 0; i < nullifierResetActions.actions.length; i++){
375
+ if (nullifierResetActions.actions[i] === ReadRequestActionEnum.READ_AS_SETTLED) {
376
+ settledNullifierReads.push({
377
+ index: i,
378
+ value: nullifierReadRequests[i].value
379
+ });
380
+ }
381
+ }
382
+ const [noteHashWitnesses, nullifierWitnesses] = await Promise.all([
383
+ Promise.all(settledNoteHashReads.map(({ value })=>node.getNoteHashMembershipWitness(anchorBlockHash, value))),
384
+ Promise.all(settledNullifierReads.map(({ value })=>node.getNullifierMembershipWitness(anchorBlockHash, value)))
385
+ ]);
386
+ for(let i = 0; i < settledNoteHashReads.length; i++){
387
+ if (!noteHashWitnesses[i]) {
388
+ throw new Error(`Note hash read request at index ${settledNoteHashReads[i].index} is reading an unknown note hash: ${settledNoteHashReads[i].value}`);
389
+ }
390
+ }
391
+ for(let i = 0; i < settledNullifierReads.length; i++){
392
+ if (!nullifierWitnesses[i]) {
393
+ throw new Error(`Nullifier read request at index ${settledNullifierReads[i].index} is reading an unknown nullifier: ${settledNullifierReads[i].value}`);
394
+ }
395
+ }
396
+ }
397
+ function splitOrderedSideEffects(effects, minRevertibleSideEffectCounter) {
398
+ const revertibleSideEffects = [];
399
+ const nonRevertibleSideEffects = [];
400
+ effects.forEach((effect)=>{
401
+ if (minRevertibleSideEffectCounter === 0 || effect.counter < minRevertibleSideEffectCounter) {
402
+ nonRevertibleSideEffects.push(effect.sideEffect);
403
+ } else {
404
+ revertibleSideEffects.push(effect.sideEffect);
405
+ }
406
+ });
407
+ return [
408
+ nonRevertibleSideEffects,
409
+ revertibleSideEffects
410
+ ];
411
+ }
412
+ function meterGasUsed(data, isPrivateOnlyTx) {
413
+ let meteredDAFields = 0;
414
+ let meteredL2Gas = 0;
415
+ const numNoteHashes = arrayNonEmptyLength(data.noteHashes, (hash)=>hash.isEmpty());
416
+ meteredDAFields += numNoteHashes;
417
+ const noteHashBaseGas = isPrivateOnlyTx ? L2_GAS_PER_NOTE_HASH : AVM_EMITNOTEHASH_BASE_L2_GAS;
418
+ meteredL2Gas += numNoteHashes * noteHashBaseGas;
419
+ const numNullifiers = arrayNonEmptyLength(data.nullifiers, (nullifier)=>nullifier.isEmpty());
420
+ meteredDAFields += numNullifiers;
421
+ const nullifierBaseGas = isPrivateOnlyTx ? L2_GAS_PER_NULLIFIER : AVM_EMITNULLIFIER_BASE_L2_GAS;
422
+ meteredL2Gas += numNullifiers * nullifierBaseGas;
423
+ const numL2toL1Messages = arrayNonEmptyLength(data.l2ToL1Msgs, (msg)=>msg.isEmpty());
424
+ meteredDAFields += numL2toL1Messages;
425
+ const l2ToL1MessageBaseGas = isPrivateOnlyTx ? L2_GAS_PER_L2_TO_L1_MSG : AVM_SENDL2TOL1MSG_BASE_L2_GAS;
426
+ meteredL2Gas += numL2toL1Messages * l2ToL1MessageBaseGas;
427
+ const numPrivatelogs = arrayNonEmptyLength(data.privateLogs, (log)=>log.isEmpty());
428
+ // Every private log emits its length as an additional field
429
+ meteredDAFields += data.privateLogs.reduce((acc, log)=>!log.isEmpty() ? acc + log.emittedLength + 1 : acc, 0);
430
+ meteredL2Gas += numPrivatelogs * L2_GAS_PER_PRIVATE_LOG;
431
+ const numContractClassLogs = arrayNonEmptyLength(data.contractClassLogsHashes, (log)=>log.isEmpty());
432
+ // Every contract class log emits its length and contract address as additional fields
433
+ meteredDAFields += data.contractClassLogsHashes.reduce((acc, log)=>!log.isEmpty() ? acc + log.logHash.length + 2 : acc, 0);
434
+ meteredL2Gas += numContractClassLogs * L2_GAS_PER_CONTRACT_CLASS_LOG;
435
+ const meteredDAGas = meteredDAFields * DA_GAS_PER_FIELD;
436
+ if (data.publicCallRequests) {
437
+ const dataForPublic = data;
438
+ const numPublicCallRequests = arrayNonEmptyLength(dataForPublic.publicCallRequests, (req)=>req.isEmpty());
439
+ meteredL2Gas += numPublicCallRequests * FIXED_AVM_STARTUP_L2_GAS;
440
+ }
441
+ return Gas.from({
442
+ l2Gas: meteredL2Gas,
443
+ daGas: meteredDAGas
444
+ });
445
+ }
@@ -1,6 +1,6 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
- import type { NoteData } from './oracle/typed_oracle.js';
3
+ import type { NoteData } from './oracle/interfaces.js';
4
4
  interface PendingNote {
5
5
  note: NoteData;
6
6
  counter: number;
@@ -11,7 +11,7 @@ interface PendingNote {
11
11
  */
12
12
  export declare class ExecutionNoteCache {
13
13
  #private;
14
- private readonly txRequestHash;
14
+ private readonly protocolNullifier;
15
15
  /**
16
16
  * New notes created in this transaction.
17
17
  * They are pushed to this array in the same order as they are emitted.
@@ -28,25 +28,27 @@ export declare class ExecutionNoteCache {
28
28
  */
29
29
  private nullifierMap;
30
30
  /**
31
- * All nullifiers emitted in this transaction.
31
+ * Nullifiers emitted by private calls in this transaction.
32
+ */
33
+ private emittedNullifiers;
34
+ /**
35
+ * The counter that separates non-revertible side effects (which persist even if the tx reverts) from revertible ones.
32
36
  */
33
- private allNullifiers;
34
37
  private minRevertibleSideEffectCounter;
35
38
  private inRevertiblePhase;
36
39
  /**
37
- * We don't need to use the tx request hash for nonces if another non revertible nullifier is emitted.
38
- * In that case we disable injecting the tx request hash as a nullifier.
40
+ * Whether the protocol nullifier was used for nonce generation.
41
+ * We don't need to use the protocol nullifier if a non-revertible nullifier is emitted.
39
42
  */
40
- private usedTxRequestHashForNonces;
41
- constructor(txRequestHash: Fr);
43
+ private usedProtocolNullifierForNonces;
44
+ constructor(protocolNullifier: Fr);
42
45
  /**
43
46
  * Enters the revertible phase of the transaction.
44
47
  * @param minRevertibleSideEffectCounter - The counter at which the transaction enters the revertible phase.
45
48
  */
46
49
  setMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: number): Promise<void>;
47
- finish(): {
48
- usedTxRequestHashForNonces: boolean;
49
- };
50
+ isSideEffectCounterRevertible(sideEffectCounter: number): boolean;
51
+ finish(): void;
50
52
  /**
51
53
  * Add a new note to cache.
52
54
  * @param note - New note created during execution.
@@ -70,9 +72,10 @@ export declare class ExecutionNoteCache {
70
72
  * Return notes created up to current point in execution.
71
73
  * If a nullifier for a note in this list is emitted, the note will be deleted.
72
74
  * @param contractAddress - Contract address of the notes.
75
+ * @param owner - Owner of the notes. If undefined, returns all notes regardless of owner.
73
76
  * @param storageSlot - Storage slot of the notes.
74
77
  **/
75
- getNotes(contractAddress: AztecAddress, storageSlot: Fr): NoteData[];
78
+ getNotes(contractAddress: AztecAddress, owner: AztecAddress | undefined, storageSlot: Fr): NoteData[];
76
79
  /**
77
80
  * Check if a note exists in the newNotes array.
78
81
  * @param contractAddress - Contract address of the note.
@@ -86,8 +89,16 @@ export declare class ExecutionNoteCache {
86
89
  */
87
90
  getNullifiers(contractAddress: AztecAddress): Set<bigint>;
88
91
  getAllNotes(): PendingNote[];
92
+ /**
93
+ * @returns All nullifiers emitted by private calls in this transaction.
94
+ */
95
+ getEmittedNullifiers(): Fr[];
96
+ /**
97
+ * @returns All nullifiers emitted by private calls in this transaction. If the protocol nullifier was used as the
98
+ * nonce generator, it is injected as the first nullifier.
99
+ */
89
100
  getAllNullifiers(): Fr[];
90
- recordNullifier(contractAddress: AztecAddress, siloedNullifier: Fr): void;
101
+ getNonceGenerator(): Fr;
91
102
  }
92
103
  export {};
93
- //# sourceMappingURL=execution_note_cache.d.ts.map
104
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhlY3V0aW9uX25vdGVfY2FjaGUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb250cmFjdF9mdW5jdGlvbl9zaW11bGF0b3IvZXhlY3V0aW9uX25vdGVfY2FjaGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBR2hFLE9BQU8sS0FBSyxFQUFFLFFBQVEsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBRXZELFVBQVUsV0FBVztJQUNuQixJQUFJLEVBQUUsUUFBUSxDQUFDO0lBQ2YsT0FBTyxFQUFFLE1BQU0sQ0FBQztJQUNoQixzQkFBc0IsRUFBRSxFQUFFLENBQUM7Q0FDNUI7QUFFRDs7R0FFRztBQUNILHFCQUFhLGtCQUFrQjs7SUFvQ2pCLE9BQU8sQ0FBQyxRQUFRLENBQUMsaUJBQWlCO0lBbkM5Qzs7O09BR0c7SUFDSCxPQUFPLENBQUMsS0FBSyxDQUFxQjtJQUNsQzs7T0FFRztJQUNILE9BQU8sQ0FBQyxPQUFPLENBQXlDO0lBRXhEOzs7O09BSUc7SUFDSCxPQUFPLENBQUMsWUFBWSxDQUF1QztJQUUzRDs7T0FFRztJQUNILE9BQU8sQ0FBQyxpQkFBaUIsQ0FBMEI7SUFFbkQ7O09BRUc7SUFDSCxPQUFPLENBQUMsOEJBQThCLENBQUs7SUFFM0MsT0FBTyxDQUFDLGlCQUFpQixDQUFTO0lBRWxDOzs7T0FHRztJQUNILE9BQU8sQ0FBQyw4QkFBOEIsQ0FBc0I7SUFFNUQsWUFBNkIsaUJBQWlCLEVBQUUsRUFBRSxFQUFJO0lBRXREOzs7T0FHRztJQUNVLGlDQUFpQyxDQUFDLDhCQUE4QixFQUFFLE1BQU0saUJBc0NwRjtJQUVNLDZCQUE2QixDQUFDLGlCQUFpQixFQUFFLE1BQU0sR0FBRyxPQUFPLENBS3ZFO0lBRU0sTUFBTSxTQU1aO0lBRUQ7OztPQUdHO0lBQ0ksVUFBVSxDQUFDLElBQUksRUFBRSxRQUFRLEVBQUUsT0FBTyxFQUFFLE1BQU0sUUFTaEQ7SUFFRDs7Ozs7O09BTUc7SUFDVSxXQUFXLENBQUMsZUFBZSxFQUFFLFlBQVksRUFBRSxjQUFjLEVBQUUsRUFBRSxFQUFFLFFBQVEsRUFBRSxFQUFFLCtCQXlCdkY7SUFFRDs7OztPQUlHO0lBQ1UsZ0JBQWdCLENBQUMsZUFBZSxFQUFFLFlBQVksRUFBRSxjQUFjLEVBQUUsRUFBRSxpQkFHOUU7SUFFRDs7Ozs7O1FBTUk7SUFDRyxRQUFRLENBQUMsZUFBZSxFQUFFLFlBQVksRUFBRSxLQUFLLEVBQUUsWUFBWSxHQUFHLFNBQVMsRUFBRSxXQUFXLEVBQUUsRUFBRSxjQU05RjtJQUVEOzs7OztRQUtJO0lBQ0csZUFBZSxDQUFDLGVBQWUsRUFBRSxZQUFZLEVBQUUsUUFBUSxFQUFFLEVBQUUsV0FHakU7SUFFRDs7O09BR0c7SUFDSSxhQUFhLENBQUMsZUFBZSxFQUFFLFlBQVksR0FBRyxHQUFHLENBQUMsTUFBTSxDQUFDLENBRS9EO0lBVUQsV0FBVyxJQUFJLFdBQVcsRUFBRSxDQUUzQjtJQUVEOztPQUVHO0lBQ0gsb0JBQW9CLElBQUksRUFBRSxFQUFFLENBRTNCO0lBRUQ7OztPQUdHO0lBQ0gsZ0JBQWdCLElBQUksRUFBRSxFQUFFLENBTXZCO0lBRUQsaUJBQWlCLElBQUksRUFBRSxDQUV0QjtDQWFGIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"execution_note_cache.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/execution_note_cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzD,UAAU,WAAW;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,sBAAsB,EAAE,EAAE,CAAC;CAC5B;AAED;;GAEG;AACH,qBAAa,kBAAkB;;IAiCjB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAhC1C;;;OAGG;IACH,OAAO,CAAC,KAAK,CAAqB;IAClC;;OAEG;IACH,OAAO,CAAC,OAAO,CAAyC;IAExD;;;;OAIG;IACH,OAAO,CAAC,YAAY,CAAuC;IAE3D;;OAEG;IACH,OAAO,CAAC,aAAa,CAA0B;IAE/C,OAAO,CAAC,8BAA8B,CAAK;IAE3C,OAAO,CAAC,iBAAiB,CAAS;IAElC;;;OAGG;IACH,OAAO,CAAC,0BAA0B,CAAQ;gBAEb,aAAa,EAAE,EAAE;IAE9C;;;OAGG;IACU,iCAAiC,CAAC,8BAA8B,EAAE,MAAM;IAwC9E,MAAM;;;IAWb;;;OAGG;IACI,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM;IAWjD;;;;;;OAMG;IACU,WAAW,CAAC,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE;IA2BxF;;;;OAIG;IACU,gBAAgB,CAAC,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,EAAE;IAK/E;;;;;QAKI;IACG,QAAQ,CAAC,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,EAAE;IAK9D;;;;;QAKI;IACG,eAAe,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE;IAKlE;;;OAGG;IACI,aAAa,CAAC,eAAe,EAAE,YAAY,GAAG,GAAG,CAAC,MAAM,CAAC;IAYhE,WAAW,IAAI,WAAW,EAAE;IAI5B,gBAAgB,IAAI,EAAE,EAAE;IAIxB,eAAe,CAAC,eAAe,EAAE,YAAY,EAAE,eAAe,EAAE,EAAE;CAMnE"}
1
+ {"version":3,"file":"execution_note_cache.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/execution_note_cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEvD,UAAU,WAAW;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,sBAAsB,EAAE,EAAE,CAAC;CAC5B;AAED;;GAEG;AACH,qBAAa,kBAAkB;;IAoCjB,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAnC9C;;;OAGG;IACH,OAAO,CAAC,KAAK,CAAqB;IAClC;;OAEG;IACH,OAAO,CAAC,OAAO,CAAyC;IAExD;;;;OAIG;IACH,OAAO,CAAC,YAAY,CAAuC;IAE3D;;OAEG;IACH,OAAO,CAAC,iBAAiB,CAA0B;IAEnD;;OAEG;IACH,OAAO,CAAC,8BAA8B,CAAK;IAE3C,OAAO,CAAC,iBAAiB,CAAS;IAElC;;;OAGG;IACH,OAAO,CAAC,8BAA8B,CAAsB;IAE5D,YAA6B,iBAAiB,EAAE,EAAE,EAAI;IAEtD;;;OAGG;IACU,iCAAiC,CAAC,8BAA8B,EAAE,MAAM,iBAsCpF;IAEM,6BAA6B,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAKvE;IAEM,MAAM,SAMZ;IAED;;;OAGG;IACI,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,QAShD;IAED;;;;;;OAMG;IACU,WAAW,CAAC,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,+BAyBvF;IAED;;;;OAIG;IACU,gBAAgB,CAAC,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,EAAE,iBAG9E;IAED;;;;;;QAMI;IACG,QAAQ,CAAC,eAAe,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,GAAG,SAAS,EAAE,WAAW,EAAE,EAAE,cAM9F;IAED;;;;;QAKI;IACG,eAAe,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,WAGjE;IAED;;;OAGG;IACI,aAAa,CAAC,eAAe,EAAE,YAAY,GAAG,GAAG,CAAC,MAAM,CAAC,CAE/D;IAUD,WAAW,IAAI,WAAW,EAAE,CAE3B;IAED;;OAEG;IACH,oBAAoB,IAAI,EAAE,EAAE,CAE3B;IAED;;;OAGG;IACH,gBAAgB,IAAI,EAAE,EAAE,CAMvB;IAED,iBAAiB,IAAI,EAAE,CAEtB;CAaF"}