@aztec/pxe 4.0.0-nightly.20250907 → 4.0.0-nightly.20260107

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 (379) hide show
  1. package/README.md +5 -5
  2. package/dest/bin/check_oracle_version.d.ts +1 -1
  3. package/dest/bin/check_oracle_version.js +110 -10
  4. package/dest/block_synchronizer/block_synchronizer.d.ts +39 -0
  5. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
  6. package/dest/{synchronizer/synchronizer.js → block_synchronizer/block_synchronizer.js} +23 -23
  7. package/dest/block_synchronizer/index.d.ts +2 -0
  8. package/dest/block_synchronizer/index.d.ts.map +1 -0
  9. package/dest/block_synchronizer/index.js +1 -0
  10. package/dest/config/index.d.ts +9 -17
  11. package/dest/config/index.d.ts.map +1 -1
  12. package/dest/config/index.js +10 -16
  13. package/dest/config/package_info.d.ts +1 -1
  14. package/dest/config/package_info.js +1 -1
  15. package/dest/contract_function_simulator/contract_function_simulator.d.ts +44 -15
  16. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/contract_function_simulator.js +142 -57
  18. package/dest/contract_function_simulator/execution_note_cache.d.ts +11 -9
  19. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  20. package/dest/contract_function_simulator/execution_note_cache.js +28 -17
  21. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
  22. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
  23. package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
  24. package/dest/contract_function_simulator/hashed_values_cache.d.ts +2 -2
  25. package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -1
  26. package/dest/contract_function_simulator/index.d.ts +4 -2
  27. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  28. package/dest/contract_function_simulator/index.js +2 -1
  29. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +2 -2
  30. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  31. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +5 -4
  32. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
  33. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +7 -6
  34. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +3 -3
  35. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  36. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +8 -4
  37. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +6 -3
  38. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  39. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +12 -3
  40. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +22 -0
  41. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
  42. package/dest/contract_function_simulator/noir-structs/utility_context.js +33 -0
  43. package/dest/contract_function_simulator/oracle/index.d.ts +2 -2
  44. package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -1
  45. package/dest/contract_function_simulator/oracle/index.js +1 -1
  46. package/dest/contract_function_simulator/oracle/interfaces.d.ts +103 -0
  47. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
  48. package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
  49. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +2 -4
  50. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  51. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -1
  52. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +10 -4
  53. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
  54. package/dest/contract_function_simulator/oracle/note_packing_utils.js +10 -5
  55. package/dest/contract_function_simulator/oracle/oracle.d.ts +17 -15
  56. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  57. package/dest/contract_function_simulator/oracle/oracle.js +101 -81
  58. package/dest/contract_function_simulator/oracle/private_execution.d.ts +11 -12
  59. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  60. package/dest/contract_function_simulator/oracle/private_execution.js +15 -24
  61. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +51 -25
  62. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  63. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +103 -27
  64. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +65 -36
  65. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  66. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +171 -69
  67. package/dest/contract_function_simulator/pick_notes.d.ts +2 -2
  68. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
  69. package/dest/contract_function_simulator/pick_notes.js +1 -1
  70. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +4 -4
  71. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
  72. package/dest/contract_function_simulator/proxied_contract_data_source.js +23 -5
  73. package/dest/contract_function_simulator/proxied_node.d.ts +1 -1
  74. package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -1
  75. package/dest/debug/pxe_debug_utils.d.ts +31 -0
  76. package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
  77. package/dest/debug/pxe_debug_utils.js +37 -0
  78. package/dest/entrypoints/client/bundle/index.d.ts +4 -3
  79. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  80. package/dest/entrypoints/client/bundle/index.js +2 -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 +21 -12
  84. package/dest/entrypoints/client/lazy/index.d.ts +4 -3
  85. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  86. package/dest/entrypoints/client/lazy/index.js +2 -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 +20 -11
  90. package/dest/entrypoints/pxe_creation_options.d.ts +5 -2
  91. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  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 +3 -2
  95. package/dest/entrypoints/server/utils.d.ts +5 -24
  96. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  97. package/dest/entrypoints/server/utils.js +17 -45
  98. package/dest/error_enriching.d.ts +11 -0
  99. package/dest/error_enriching.d.ts.map +1 -0
  100. package/dest/{pxe_service/error_enriching.js → error_enriching.js} +9 -6
  101. package/dest/events/event_service.d.ts +15 -0
  102. package/dest/events/event_service.d.ts.map +1 -0
  103. package/dest/events/event_service.js +47 -0
  104. package/dest/events/index.d.ts +2 -0
  105. package/dest/events/index.d.ts.map +1 -0
  106. package/dest/events/index.js +1 -0
  107. package/dest/events/private_event_filter_validator.d.ts +9 -0
  108. package/dest/events/private_event_filter_validator.d.ts.map +1 -0
  109. package/dest/events/private_event_filter_validator.js +39 -0
  110. package/dest/logs/log_service.d.ts +26 -0
  111. package/dest/logs/log_service.d.ts.map +1 -0
  112. package/dest/logs/log_service.js +120 -0
  113. package/dest/notes/index.d.ts +2 -0
  114. package/dest/notes/index.d.ts.map +1 -0
  115. package/dest/notes/index.js +1 -0
  116. package/dest/notes/note_service.d.ts +48 -0
  117. package/dest/notes/note_service.d.ts.map +1 -0
  118. package/dest/notes/note_service.js +152 -0
  119. package/dest/oracle_version.d.ts +3 -3
  120. package/dest/oracle_version.js +2 -2
  121. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +3 -3
  122. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -1
  123. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +7 -7
  124. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +1 -1
  125. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +6 -6
  126. package/dest/private_kernel/hints/index.d.ts +1 -1
  127. package/dest/private_kernel/index.d.ts +1 -1
  128. package/dest/private_kernel/private_kernel_execution_prover.d.ts +9 -2
  129. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  130. package/dest/private_kernel/private_kernel_execution_prover.js +38 -32
  131. package/dest/private_kernel/private_kernel_oracle.d.ts +3 -2
  132. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  133. package/dest/private_kernel/private_kernel_oracle_impl.d.ts +10 -9
  134. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -1
  135. package/dest/private_kernel/private_kernel_oracle_impl.js +7 -7
  136. package/dest/public_storage/public_storage_service.d.ts +24 -0
  137. package/dest/public_storage/public_storage_service.d.ts.map +1 -0
  138. package/dest/public_storage/public_storage_service.js +26 -0
  139. package/dest/pxe.d.ts +232 -0
  140. package/dest/pxe.d.ts.map +1 -0
  141. package/dest/{pxe_service/pxe_service.js → pxe.js} +299 -324
  142. package/dest/storage/address_store/address_store.d.ts +11 -0
  143. package/dest/storage/address_store/address_store.d.ts.map +1 -0
  144. package/dest/storage/{address_data_provider/address_data_provider.js → address_store/address_store.js} +1 -4
  145. package/dest/storage/address_store/index.d.ts +2 -0
  146. package/dest/storage/address_store/index.d.ts.map +1 -0
  147. package/dest/storage/address_store/index.js +1 -0
  148. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -0
  149. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
  150. package/dest/storage/{sync_data_provider/sync_data_provider.js → anchor_block_store/anchor_block_store.js} +2 -12
  151. package/dest/storage/anchor_block_store/index.d.ts +2 -0
  152. package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
  153. package/dest/storage/anchor_block_store/index.js +1 -0
  154. package/dest/storage/capsule_store/capsule_store.d.ts +57 -0
  155. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
  156. package/dest/storage/{capsule_data_provider/capsule_data_provider.js → capsule_store/capsule_store.js} +34 -10
  157. package/dest/storage/capsule_store/index.d.ts +2 -0
  158. package/dest/storage/capsule_store/index.d.ts.map +1 -0
  159. package/dest/storage/capsule_store/index.js +1 -0
  160. package/dest/storage/{contract_data_provider/contract_data_provider.d.ts → contract_store/contract_store.d.ts} +10 -18
  161. package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
  162. package/dest/storage/{contract_data_provider/contract_data_provider.js → contract_store/contract_store.js} +46 -18
  163. package/dest/storage/contract_store/index.d.ts +2 -0
  164. package/dest/storage/contract_store/index.d.ts.map +1 -0
  165. package/dest/storage/contract_store/index.js +1 -0
  166. package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.d.ts +1 -1
  167. package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
  168. package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.js +1 -1
  169. package/dest/storage/index.d.ts +8 -9
  170. package/dest/storage/index.d.ts.map +1 -1
  171. package/dest/storage/index.js +7 -8
  172. package/dest/storage/metadata.d.ts +1 -1
  173. package/dest/storage/note_store/index.d.ts +3 -0
  174. package/dest/storage/note_store/index.d.ts.map +1 -0
  175. package/dest/storage/note_store/index.js +2 -0
  176. package/dest/storage/note_store/note_store.d.ts +84 -0
  177. package/dest/storage/note_store/note_store.d.ts.map +1 -0
  178. package/dest/storage/{note_data_provider/note_data_provider.js → note_store/note_store.js} +144 -82
  179. package/dest/storage/private_event_store/private_event_store.d.ts +56 -0
  180. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
  181. package/dest/storage/private_event_store/private_event_store.js +157 -0
  182. package/dest/storage/tagging_store/index.d.ts +4 -0
  183. package/dest/storage/tagging_store/index.d.ts.map +1 -0
  184. package/dest/storage/tagging_store/index.js +3 -0
  185. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +21 -0
  186. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
  187. package/dest/storage/tagging_store/recipient_tagging_store.js +42 -0
  188. package/dest/storage/tagging_store/sender_address_book_store.d.ts +14 -0
  189. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -0
  190. package/dest/storage/tagging_store/sender_address_book_store.js +30 -0
  191. package/dest/storage/tagging_store/sender_tagging_store.d.ts +67 -0
  192. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
  193. package/dest/storage/tagging_store/sender_tagging_store.js +196 -0
  194. package/dest/tagging/index.d.ts +16 -0
  195. package/dest/tagging/index.d.ts.map +1 -0
  196. package/dest/tagging/index.js +23 -0
  197. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +14 -0
  198. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -0
  199. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +99 -0
  200. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +12 -0
  201. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -0
  202. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +20 -0
  203. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +14 -0
  204. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -0
  205. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +29 -0
  206. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +20 -0
  207. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -0
  208. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +74 -0
  209. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +11 -0
  210. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -0
  211. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +32 -0
  212. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +18 -0
  213. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
  214. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +55 -0
  215. package/dest/tree_membership/tree_membership_service.d.ts +52 -0
  216. package/dest/tree_membership/tree_membership_service.d.ts.map +1 -0
  217. package/dest/tree_membership/tree_membership_service.js +84 -0
  218. package/package.json +22 -24
  219. package/src/bin/check_oracle_version.ts +134 -10
  220. package/src/{synchronizer/synchronizer.ts → block_synchronizer/block_synchronizer.ts} +22 -23
  221. package/src/block_synchronizer/index.ts +1 -0
  222. package/src/config/index.ts +18 -32
  223. package/src/config/package_info.ts +1 -1
  224. package/src/contract_function_simulator/contract_function_simulator.ts +233 -75
  225. package/src/contract_function_simulator/execution_note_cache.ts +33 -17
  226. package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
  227. package/src/contract_function_simulator/hashed_values_cache.ts +1 -1
  228. package/src/contract_function_simulator/index.ts +3 -1
  229. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
  230. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +6 -5
  231. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +10 -5
  232. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +14 -2
  233. package/src/contract_function_simulator/noir-structs/utility_context.ts +42 -0
  234. package/src/contract_function_simulator/oracle/index.ts +1 -1
  235. package/src/contract_function_simulator/oracle/interfaces.ts +175 -0
  236. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +1 -1
  237. package/src/contract_function_simulator/oracle/note_packing_utils.ts +21 -5
  238. package/src/contract_function_simulator/oracle/oracle.ts +135 -80
  239. package/src/contract_function_simulator/oracle/private_execution.ts +22 -28
  240. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +200 -56
  241. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +260 -109
  242. package/src/contract_function_simulator/pick_notes.ts +1 -1
  243. package/src/contract_function_simulator/proxied_contract_data_source.ts +24 -7
  244. package/src/debug/pxe_debug_utils.ts +48 -0
  245. package/src/entrypoints/client/bundle/index.ts +3 -2
  246. package/src/entrypoints/client/bundle/utils.ts +21 -23
  247. package/src/entrypoints/client/lazy/index.ts +3 -2
  248. package/src/entrypoints/client/lazy/utils.ts +20 -23
  249. package/src/entrypoints/pxe_creation_options.ts +4 -1
  250. package/src/entrypoints/server/index.ts +4 -2
  251. package/src/entrypoints/server/utils.ts +20 -68
  252. package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +11 -15
  253. package/src/events/event_service.ts +77 -0
  254. package/src/events/index.ts +1 -0
  255. package/src/events/private_event_filter_validator.ts +48 -0
  256. package/src/logs/log_service.ts +202 -0
  257. package/src/notes/index.ts +1 -0
  258. package/src/notes/note_service.ts +200 -0
  259. package/src/oracle_version.ts +2 -2
  260. package/src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts +5 -9
  261. package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +6 -6
  262. package/src/private_kernel/private_kernel_execution_prover.ts +51 -43
  263. package/src/private_kernel/private_kernel_oracle.ts +2 -1
  264. package/src/private_kernel/private_kernel_oracle_impl.ts +10 -9
  265. package/src/public_storage/public_storage_service.ts +33 -0
  266. package/src/{pxe_service/pxe_service.ts → pxe.ts} +349 -410
  267. package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +1 -7
  268. package/src/storage/address_store/index.ts +1 -0
  269. package/src/storage/{sync_data_provider/sync_data_provider.ts → anchor_block_store/anchor_block_store.ts} +2 -17
  270. package/src/storage/anchor_block_store/index.ts +1 -0
  271. package/src/storage/{capsule_data_provider/capsule_data_provider.ts → capsule_store/capsule_store.ts} +34 -12
  272. package/src/storage/capsule_store/index.ts +1 -0
  273. package/src/storage/{contract_data_provider/contract_data_provider.ts → contract_store/contract_store.ts} +67 -28
  274. package/src/storage/contract_store/index.ts +1 -0
  275. package/src/storage/{contract_data_provider → contract_store}/private_functions_tree.ts +1 -1
  276. package/src/storage/index.ts +7 -8
  277. package/src/storage/note_store/index.ts +2 -0
  278. package/src/storage/{note_data_provider/note_data_provider.ts → note_store/note_store.ts} +173 -111
  279. package/src/storage/private_event_store/private_event_store.ts +213 -0
  280. package/src/storage/tagging_store/index.ts +3 -0
  281. package/src/storage/tagging_store/recipient_tagging_store.ts +53 -0
  282. package/src/storage/tagging_store/sender_address_book_store.ts +42 -0
  283. package/src/storage/tagging_store/sender_tagging_store.ts +244 -0
  284. package/src/tagging/index.ts +28 -0
  285. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +129 -0
  286. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +34 -0
  287. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +43 -0
  288. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +96 -0
  289. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +44 -0
  290. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +72 -0
  291. package/src/tree_membership/tree_membership_service.ts +112 -0
  292. package/dest/bin/index.d.ts +0 -3
  293. package/dest/bin/index.d.ts.map +0 -1
  294. package/dest/bin/index.js +0 -48
  295. package/dest/contract_function_simulator/execution_data_provider.d.ts +0 -285
  296. package/dest/contract_function_simulator/execution_data_provider.d.ts.map +0 -1
  297. package/dest/contract_function_simulator/execution_data_provider.js +0 -14
  298. package/dest/contract_function_simulator/oracle/typed_oracle.d.ts +0 -87
  299. package/dest/contract_function_simulator/oracle/typed_oracle.d.ts.map +0 -1
  300. package/dest/contract_function_simulator/oracle/typed_oracle.js +0 -146
  301. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +0 -158
  302. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +0 -1
  303. package/dest/contract_function_simulator/pxe_oracle_interface.js +0 -701
  304. package/dest/contract_function_simulator/tagging_utils.d.ts +0 -17
  305. package/dest/contract_function_simulator/tagging_utils.d.ts.map +0 -1
  306. package/dest/contract_function_simulator/tagging_utils.js +0 -23
  307. package/dest/pxe_service/error_enriching.d.ts +0 -11
  308. package/dest/pxe_service/error_enriching.d.ts.map +0 -1
  309. package/dest/pxe_service/index.d.ts +0 -3
  310. package/dest/pxe_service/index.d.ts.map +0 -1
  311. package/dest/pxe_service/index.js +0 -2
  312. package/dest/pxe_service/pxe_service.d.ts +0 -100
  313. package/dest/pxe_service/pxe_service.d.ts.map +0 -1
  314. package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -13
  315. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +0 -1
  316. package/dest/storage/address_data_provider/index.d.ts +0 -2
  317. package/dest/storage/address_data_provider/index.d.ts.map +0 -1
  318. package/dest/storage/address_data_provider/index.js +0 -1
  319. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +0 -27
  320. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +0 -1
  321. package/dest/storage/capsule_data_provider/index.d.ts +0 -2
  322. package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
  323. package/dest/storage/capsule_data_provider/index.js +0 -1
  324. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
  325. package/dest/storage/contract_data_provider/index.d.ts +0 -2
  326. package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
  327. package/dest/storage/contract_data_provider/index.js +0 -1
  328. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
  329. package/dest/storage/data_provider.d.ts +0 -4
  330. package/dest/storage/data_provider.d.ts.map +0 -1
  331. package/dest/storage/data_provider.js +0 -1
  332. package/dest/storage/note_data_provider/index.d.ts +0 -3
  333. package/dest/storage/note_data_provider/index.d.ts.map +0 -1
  334. package/dest/storage/note_data_provider/index.js +0 -2
  335. package/dest/storage/note_data_provider/note_dao.d.ts +0 -100
  336. package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
  337. package/dest/storage/note_data_provider/note_dao.js +0 -102
  338. package/dest/storage/note_data_provider/note_data_provider.d.ts +0 -20
  339. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
  340. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +0 -37
  341. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +0 -1
  342. package/dest/storage/private_event_data_provider/private_event_data_provider.js +0 -96
  343. package/dest/storage/sync_data_provider/index.d.ts +0 -2
  344. package/dest/storage/sync_data_provider/index.d.ts.map +0 -1
  345. package/dest/storage/sync_data_provider/index.js +0 -1
  346. package/dest/storage/sync_data_provider/sync_data_provider.d.ts +0 -12
  347. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +0 -1
  348. package/dest/storage/tagging_data_provider/index.d.ts +0 -2
  349. package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
  350. package/dest/storage/tagging_data_provider/index.js +0 -1
  351. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +0 -18
  352. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +0 -1
  353. package/dest/storage/tagging_data_provider/tagging_data_provider.js +0 -82
  354. package/dest/synchronizer/index.d.ts +0 -2
  355. package/dest/synchronizer/index.d.ts.map +0 -1
  356. package/dest/synchronizer/index.js +0 -1
  357. package/dest/synchronizer/synchronizer.d.ts +0 -35
  358. package/dest/synchronizer/synchronizer.d.ts.map +0 -1
  359. package/dest/test/pxe_test_suite.d.ts +0 -3
  360. package/dest/test/pxe_test_suite.d.ts.map +0 -1
  361. package/dest/test/pxe_test_suite.js +0 -97
  362. package/src/bin/index.ts +0 -62
  363. package/src/contract_function_simulator/execution_data_provider.ts +0 -361
  364. package/src/contract_function_simulator/oracle/typed_oracle.ts +0 -289
  365. package/src/contract_function_simulator/pxe_oracle_interface.ts +0 -1020
  366. package/src/contract_function_simulator/tagging_utils.ts +0 -32
  367. package/src/pxe_service/index.ts +0 -2
  368. package/src/storage/address_data_provider/index.ts +0 -1
  369. package/src/storage/capsule_data_provider/index.ts +0 -1
  370. package/src/storage/contract_data_provider/index.ts +0 -1
  371. package/src/storage/data_provider.ts +0 -3
  372. package/src/storage/note_data_provider/index.ts +0 -2
  373. package/src/storage/note_data_provider/note_dao.ts +0 -154
  374. package/src/storage/private_event_data_provider/private_event_data_provider.ts +0 -134
  375. package/src/storage/sync_data_provider/index.ts +0 -1
  376. package/src/storage/tagging_data_provider/index.ts +0 -1
  377. package/src/storage/tagging_data_provider/tagging_data_provider.ts +0 -123
  378. package/src/synchronizer/index.ts +0 -1
  379. package/src/test/pxe_test_suite.ts +0 -113
@@ -1,4 +1,14 @@
1
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,
2
12
  MAX_CONTRACT_CLASS_LOGS_PER_TX,
3
13
  MAX_ENQUEUED_CALLS_PER_TX,
4
14
  MAX_L2_TO_L1_MSGS_PER_TX,
@@ -6,13 +16,14 @@ import {
6
16
  MAX_NULLIFIERS_PER_TX,
7
17
  MAX_PRIVATE_LOGS_PER_TX,
8
18
  } from '@aztec/constants';
9
- import { padArrayEnd } from '@aztec/foundation/collection';
10
- import { poseidon2Hash } from '@aztec/foundation/crypto';
11
- import { Fr } from '@aztec/foundation/fields';
19
+ import { arrayNonEmptyLength, padArrayEnd } from '@aztec/foundation/collection';
20
+ import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
21
+ import { Fr } from '@aztec/foundation/curves/bn254';
12
22
  import { type Logger, createLogger } from '@aztec/foundation/log';
13
23
  import { Timer } from '@aztec/foundation/timer';
24
+ import type { KeyStore } from '@aztec/key-store';
14
25
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
15
- import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
26
+ import { protocolContractsHash } from '@aztec/protocol-contracts';
16
27
  import {
17
28
  type CircuitSimulator,
18
29
  ExecutionError,
@@ -22,12 +33,19 @@ import {
22
33
  toACVMWitness,
23
34
  witnessMapToFields,
24
35
  } from '@aztec/simulator/client';
25
- import type { AbiDecoded, FunctionCall } from '@aztec/stdlib/abi';
26
- import { FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
36
+ import type { FunctionCall } from '@aztec/stdlib/abi';
37
+ import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
27
38
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
28
39
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
29
40
  import { Gas } from '@aztec/stdlib/gas';
30
- import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
41
+ import {
42
+ computeNoteHashNonce,
43
+ computeProtocolNullifier,
44
+ computeUniqueNoteHash,
45
+ siloNoteHash,
46
+ siloNullifier,
47
+ } from '@aztec/stdlib/hash';
48
+ import type { AztecNode } from '@aztec/stdlib/interfaces/server';
31
49
  import {
32
50
  PartialPrivateTailPublicInputsForPublic,
33
51
  PartialPrivateTailPublicInputsForRollup,
@@ -41,24 +59,35 @@ import {
41
59
  } from '@aztec/stdlib/kernel';
42
60
  import { PrivateLog } from '@aztec/stdlib/logs';
43
61
  import { ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
44
- import { ClientIvcProof } from '@aztec/stdlib/proofs';
62
+ import { ChonkProof } from '@aztec/stdlib/proofs';
45
63
  import {
64
+ BlockHeader,
46
65
  CallContext,
47
66
  HashedValues,
48
67
  PrivateExecutionResult,
49
68
  TxConstantData,
50
69
  TxExecutionRequest,
51
70
  collectNested,
71
+ getFinalMinRevertibleSideEffectCounter,
52
72
  } from '@aztec/stdlib/tx';
53
73
 
54
- import type { ContractDataProvider } from '../storage/index.js';
55
- import type { ExecutionDataProvider } from './execution_data_provider.js';
74
+ import type { AddressStore } from '../storage/address_store/address_store.js';
75
+ import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
76
+ import type { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
77
+ import type { ContractStore } from '../storage/contract_store/contract_store.js';
78
+ import type { NoteStore } from '../storage/note_store/note_store.js';
79
+ import type { PrivateEventStore } from '../storage/private_event_store/private_event_store.js';
80
+ import type { RecipientTaggingStore } from '../storage/tagging_store/recipient_tagging_store.js';
81
+ import type { SenderAddressBookStore } from '../storage/tagging_store/sender_address_book_store.js';
82
+ import type { SenderTaggingStore } from '../storage/tagging_store/sender_tagging_store.js';
56
83
  import { ExecutionNoteCache } from './execution_note_cache.js';
84
+ import { ExecutionTaggingIndexCache } from './execution_tagging_index_cache.js';
57
85
  import { HashedValuesCache } from './hashed_values_cache.js';
58
86
  import { Oracle } from './oracle/oracle.js';
59
87
  import { executePrivateFunction, verifyCurrentClassId } from './oracle/private_execution.js';
60
88
  import { PrivateExecutionOracle } from './oracle/private_execution_oracle.js';
61
89
  import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
90
+ import type { ProxiedNode } from './proxied_node.js';
62
91
 
63
92
  /**
64
93
  * The contract function simulator.
@@ -67,7 +96,17 @@ export class ContractFunctionSimulator {
67
96
  private log: Logger;
68
97
 
69
98
  constructor(
70
- private executionDataProvider: ExecutionDataProvider,
99
+ private contractStore: ContractStore,
100
+ private noteStore: NoteStore,
101
+ private keyStore: KeyStore,
102
+ private addressStore: AddressStore,
103
+ private aztecNode: AztecNode,
104
+ private anchorBlockStore: AnchorBlockStore,
105
+ private senderTaggingStore: SenderTaggingStore,
106
+ private recipientTaggingStore: RecipientTaggingStore,
107
+ private senderAddressBookStore: SenderAddressBookStore,
108
+ private capsuleStore: CapsuleStore,
109
+ private privateEventStore: PrivateEventStore,
71
110
  private simulator: CircuitSimulator,
72
111
  ) {
73
112
  this.log = createLogger('simulator');
@@ -80,6 +119,7 @@ export class ContractFunctionSimulator {
80
119
  * @param contractAddress - The address of the contract (should match request.origin)
81
120
  * @param msgSender - The address calling the function. This can be replaced to simulate a call from another contract
82
121
  * or a specific account.
122
+ * @param anchorBlockHeader - The block header to use as base state for this run.
83
123
  * @param senderForTags - The address that is used as a tagging sender when emitting private logs. Returned from
84
124
  * the `privateGetSenderForTags` oracle.
85
125
  * @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
@@ -90,15 +130,19 @@ export class ContractFunctionSimulator {
90
130
  contractAddress: AztecAddress,
91
131
  selector: FunctionSelector,
92
132
  msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE),
133
+ anchorBlockHeader: BlockHeader,
93
134
  senderForTags?: AztecAddress,
94
135
  scopes?: AztecAddress[],
95
136
  ): Promise<PrivateExecutionResult> {
96
137
  const simulatorSetupTimer = new Timer();
97
- const header = await this.executionDataProvider.getBlockHeader();
98
138
 
99
- await verifyCurrentClassId(contractAddress, this.executionDataProvider);
139
+ await this.contractStore.syncPrivateState(contractAddress, selector, privateSyncCall =>
140
+ this.runUtility(privateSyncCall, [], anchorBlockHeader, scopes),
141
+ );
142
+
143
+ await verifyCurrentClassId(contractAddress, this.aztecNode, this.contractStore, anchorBlockHeader);
100
144
 
101
- const entryPointArtifact = await this.executionDataProvider.getFunctionArtifact(contractAddress, selector);
145
+ const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(contractAddress, selector);
102
146
 
103
147
  if (entryPointArtifact.functionType !== FunctionType.PRIVATE) {
104
148
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as private`);
@@ -111,7 +155,7 @@ export class ContractFunctionSimulator {
111
155
  }
112
156
 
113
157
  // reserve the first side effect for the tx hash (inserted by the private kernel)
114
- const startSideEffectCounter = 1;
158
+ const startSideEffectCounter = 2;
115
159
 
116
160
  const callContext = new CallContext(
117
161
  msgSender,
@@ -120,25 +164,40 @@ export class ContractFunctionSimulator {
120
164
  entryPointArtifact.isStatic,
121
165
  );
122
166
 
123
- const txRequestHash = await request.toTxRequest().hash();
124
- const noteCache = new ExecutionNoteCache(txRequestHash);
167
+ const protocolNullifier = await computeProtocolNullifier(await request.toTxRequest().hash());
168
+ const noteCache = new ExecutionNoteCache(protocolNullifier);
169
+ const taggingIndexCache = new ExecutionTaggingIndexCache();
125
170
 
126
171
  const privateExecutionOracle = new PrivateExecutionOracle(
127
172
  request.firstCallArgsHash,
128
173
  request.txContext,
129
174
  callContext,
130
- header,
175
+ anchorBlockHeader,
176
+ async call => {
177
+ await this.runUtility(call, [], anchorBlockHeader, scopes);
178
+ },
131
179
  request.authWitnesses,
132
180
  request.capsules,
133
181
  HashedValuesCache.create(request.argsOfCalls),
134
182
  noteCache,
135
- this.executionDataProvider,
136
- this.simulator,
183
+ taggingIndexCache,
184
+ this.contractStore,
185
+ this.noteStore,
186
+ this.keyStore,
187
+ this.addressStore,
188
+ this.aztecNode,
189
+ this.anchorBlockStore,
190
+ this.senderTaggingStore,
191
+ this.recipientTaggingStore,
192
+ this.senderAddressBookStore,
193
+ this.capsuleStore,
194
+ this.privateEventStore,
137
195
  0, // totalPublicArgsCount
138
196
  startSideEffectCounter,
139
197
  undefined, // log
140
198
  scopes,
141
199
  senderForTags,
200
+ this.simulator,
142
201
  );
143
202
 
144
203
  const setupTime = simulatorSetupTimer.ms();
@@ -156,8 +215,8 @@ export class ContractFunctionSimulator {
156
215
  request.functionSelector,
157
216
  );
158
217
  const simulatorTeardownTimer = new Timer();
159
- const { usedTxRequestHashForNonces } = noteCache.finish();
160
- const firstNullifierHint = usedTxRequestHashForNonces ? Fr.ZERO : noteCache.getAllNullifiers()[0];
218
+ const { usedProtocolNullifierForNonces } = noteCache.finish();
219
+ const firstNullifierHint = usedProtocolNullifierForNonces ? Fr.ZERO : noteCache.getAllNullifiers()[0];
161
220
 
162
221
  const publicCallRequests = collectNested([executionResult], r =>
163
222
  r.publicInputs.publicCallRequests
@@ -193,20 +252,43 @@ export class ContractFunctionSimulator {
193
252
  * Runs a utility function.
194
253
  * @param call - The function call to execute.
195
254
  * @param authwits - Authentication witnesses required for the function call.
255
+ * @param anchorBlockHeader - The block header to use as base state for this run.
196
256
  * @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
197
257
  * accounts if not specified.
198
- * @returns A decoded ABI value containing the function's return data.
258
+ * @returns A return value of the utility function in a form as returned by the simulator (Noir fields)
199
259
  */
200
- public async runUtility(call: FunctionCall, authwits: AuthWitness[], scopes?: AztecAddress[]): Promise<AbiDecoded> {
201
- await verifyCurrentClassId(call.to, this.executionDataProvider);
260
+ public async runUtility(
261
+ call: FunctionCall,
262
+ authwits: AuthWitness[],
263
+ anchorBlockHeader: BlockHeader,
264
+ scopes?: AztecAddress[],
265
+ ): Promise<Fr[]> {
266
+ await verifyCurrentClassId(call.to, this.aztecNode, this.contractStore, anchorBlockHeader);
202
267
 
203
- const entryPointArtifact = await this.executionDataProvider.getFunctionArtifact(call.to, call.selector);
268
+ const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
204
269
 
205
270
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
206
271
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
207
272
  }
208
273
 
209
- const oracle = new UtilityExecutionOracle(call.to, authwits, [], this.executionDataProvider, undefined, scopes);
274
+ const oracle = new UtilityExecutionOracle(
275
+ call.to,
276
+ authwits,
277
+ [],
278
+ anchorBlockHeader,
279
+ this.contractStore,
280
+ this.noteStore,
281
+ this.keyStore,
282
+ this.addressStore,
283
+ this.aztecNode,
284
+ this.anchorBlockStore,
285
+ this.recipientTaggingStore,
286
+ this.senderAddressBookStore,
287
+ this.capsuleStore,
288
+ this.privateEventStore,
289
+ undefined,
290
+ scopes,
291
+ );
210
292
 
211
293
  try {
212
294
  this.log.verbose(`Executing utility function ${entryPointArtifact.name}`, {
@@ -230,17 +312,23 @@ export class ContractFunctionSimulator {
230
312
  );
231
313
  });
232
314
 
233
- const returnWitness = witnessMapToFields(acirExecutionResult.returnWitness);
234
315
  this.log.verbose(`Utility simulation for ${call.to}.${call.selector} completed`);
235
- return decodeFromAbi(entryPointArtifact.returnTypes, returnWitness);
316
+ return witnessMapToFields(acirExecutionResult.returnWitness);
236
317
  } catch (err) {
237
318
  throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
238
319
  }
239
320
  }
240
321
  // docs:end:execute_utility_function
241
322
 
323
+ /**
324
+ * Returns the execution statistics collected during the simulator run.
325
+ * @returns The execution statistics.
326
+ */
242
327
  getStats() {
243
- return this.executionDataProvider.getStats();
328
+ const nodeRPCCalls =
329
+ typeof (this.aztecNode as ProxiedNode).getStats === 'function' ? (this.aztecNode as ProxiedNode).getStats() : {};
330
+
331
+ return { nodeRPCCalls };
244
332
  }
245
333
  }
246
334
 
@@ -255,7 +343,7 @@ class OrderedSideEffect<T> {
255
343
  }
256
344
 
257
345
  /**
258
- * Generates the final public inputs of the tail kernel circuit, an empty ClientIVC proof
346
+ * Generates the final public inputs of the tail kernel circuit, an empty Chonk proof
259
347
  * and the execution steps for a `PrivateExecutionResult` as if it had been
260
348
  * processed by the private kernel prover. This skips many of the checks performed by the kernels
261
349
  * (allowing state overrides) and is much faster, while still generating a valid
@@ -263,13 +351,13 @@ class OrderedSideEffect<T> {
263
351
  * @param privateExecutionResult - The result of the private execution.
264
352
  * @param nonceGenerator - A nonce generator for note hashes. According to the protocol rules,
265
353
  * it can either be the first nullifier in the tx or the hash of the initial tx request if there are none.
266
- * @param contractDataProvider - A provider for contract data in order to get function names and debug info.
354
+ * @param contractStore - A provider for contract data in order to get function names and debug info.
267
355
  * @returns The simulated proving result.
268
356
  */
269
357
  export async function generateSimulatedProvingResult(
270
358
  privateExecutionResult: PrivateExecutionResult,
271
359
  nonceGenerator: Fr,
272
- contractDataProvider: ContractDataProvider,
360
+ contractStore: ContractStore,
273
361
  ): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
274
362
  const siloedNoteHashes: OrderedSideEffect<Fr>[] = [];
275
363
  const nullifiers: OrderedSideEffect<Fr>[] = [];
@@ -346,7 +434,7 @@ export async function generateSimulatedProvingResult(
346
434
  : execution.publicInputs.publicTeardownCallRequest;
347
435
 
348
436
  executionSteps.push({
349
- functionName: await contractDataProvider.getDebugFunctionName(
437
+ functionName: await contractStore.getDebugFunctionName(
350
438
  execution.publicInputs.callContext.contractAddress,
351
439
  execution.publicInputs.callContext.functionSelector,
352
440
  ),
@@ -358,30 +446,35 @@ export async function generateSimulatedProvingResult(
358
446
  }
359
447
 
360
448
  const constantData = new TxConstantData(
361
- privateExecutionResult.entrypoint.publicInputs.historicalHeader,
449
+ privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader,
362
450
  privateExecutionResult.entrypoint.publicInputs.txContext,
363
451
  getVKTreeRoot(),
364
- protocolContractTreeRoot,
452
+ protocolContractsHash,
365
453
  );
366
454
 
367
455
  const hasPublicCalls = privateExecutionResult.publicFunctionCalldata.length !== 0;
368
456
  let inputsForRollup;
369
457
  let inputsForPublic;
458
+ let gasUsed;
370
459
 
371
460
  const sortByCounter = <T>(a: OrderedSideEffect<T>, b: OrderedSideEffect<T>) => a.counter - b.counter;
372
461
  const getEffect = <T>(orderedSideEffect: OrderedSideEffect<T>) => orderedSideEffect.sideEffect;
373
462
 
374
- const sortedNullifiers = nullifiers.sort(sortByCounter).map(getEffect);
463
+ const isPrivateOnlyTx = privateExecutionResult.publicFunctionCalldata.length === 0;
464
+ const minRevertibleSideEffectCounter = getFinalMinRevertibleSideEffectCounter(privateExecutionResult);
375
465
 
376
- // If the tx generated no nullifiers, the nonce generator (txRequest hash)
377
- // is injected as the first nullifier as per protocol rules.
378
- if (sortedNullifiers.length === 0) {
379
- sortedNullifiers.push(nonceGenerator);
466
+ const [nonRevertibleNullifiers, revertibleNullifiers] = splitOrderedSideEffects(
467
+ nullifiers.sort(sortByCounter),
468
+ minRevertibleSideEffectCounter,
469
+ );
470
+ if (nonRevertibleNullifiers.length > 0 && !nonRevertibleNullifiers[0].equals(nonceGenerator)) {
471
+ throw new Error('The first non revertible nullifier should be equal to the nonce generator. This is a bug!');
472
+ } else {
473
+ nonRevertibleNullifiers.unshift(nonceGenerator);
380
474
  }
381
475
 
382
- // Private only
383
- if (privateExecutionResult.publicFunctionCalldata.length === 0) {
384
- // In case the tx only contains private functions, we must make the note hashes unique by using the
476
+ if (isPrivateOnlyTx) {
477
+ // We must make the note hashes unique by using the
385
478
  // nonce generator and their index in the tx.
386
479
  const uniqueNoteHashes = await Promise.all(
387
480
  siloedNoteHashes.sort(sortByCounter).map(async (orderedSideEffect, i) => {
@@ -393,7 +486,7 @@ export async function generateSimulatedProvingResult(
393
486
  );
394
487
  const accumulatedDataForRollup = new PrivateToRollupAccumulatedData(
395
488
  padArrayEnd(uniqueNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX),
396
- padArrayEnd(sortedNullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX),
489
+ padArrayEnd(nonRevertibleNullifiers.concat(revertibleNullifiers), Fr.ZERO, MAX_NULLIFIERS_PER_TX),
397
490
  padArrayEnd(
398
491
  l2ToL1Messages.sort(sortByCounter).map(getEffect),
399
492
  ScopedL2ToL1Message.empty(),
@@ -406,39 +499,51 @@ export async function generateSimulatedProvingResult(
406
499
  MAX_CONTRACT_CLASS_LOGS_PER_TX,
407
500
  ),
408
501
  );
409
-
502
+ gasUsed = meterGasUsed(accumulatedDataForRollup);
410
503
  inputsForRollup = new PartialPrivateTailPublicInputsForRollup(accumulatedDataForRollup);
411
504
  } else {
412
- const nonRevertibleData = PrivateToPublicAccumulatedData.empty();
505
+ const [nonRevertibleNoteHashes, revertibleNoteHashes] = splitOrderedSideEffects(
506
+ siloedNoteHashes.sort(sortByCounter),
507
+ minRevertibleSideEffectCounter,
508
+ );
509
+ const [nonRevertibleL2ToL1Messages, revertibleL2ToL1Messages] = splitOrderedSideEffects(
510
+ l2ToL1Messages.sort(sortByCounter),
511
+ minRevertibleSideEffectCounter,
512
+ );
513
+ const [nonRevertibleTaggedPrivateLogs, revertibleTaggedPrivateLogs] = splitOrderedSideEffects(
514
+ taggedPrivateLogs,
515
+ minRevertibleSideEffectCounter,
516
+ );
517
+ const [nonRevertibleContractClassLogHashes, revertibleContractClassLogHashes] = splitOrderedSideEffects(
518
+ contractClassLogsHashes.sort(sortByCounter),
519
+ minRevertibleSideEffectCounter,
520
+ );
521
+ const [nonRevertiblePublicCallRequests, revertiblePublicCallRequests] = splitOrderedSideEffects(
522
+ publicCallRequests.sort(sortByCounter),
523
+ minRevertibleSideEffectCounter,
524
+ );
413
525
 
414
- // The nullifier array contains the nonce generator in position 0
415
- // Here we remove it from the revertible data and
416
- // add it as the first non-revertible nullifier (we can't have dupes!)
417
- // This is because public processor will use that first non-revertible nullifier
418
- // as the nonce generator for the note hashes in the revertible part of the tx.
419
- const [firstNullifier] = sortedNullifiers.splice(0, 1);
420
- nonRevertibleData.nullifiers[0] = firstNullifier;
526
+ const nonRevertibleData = new PrivateToPublicAccumulatedData(
527
+ padArrayEnd(nonRevertibleNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX),
528
+ padArrayEnd(nonRevertibleNullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX),
529
+ padArrayEnd(nonRevertibleL2ToL1Messages, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX),
530
+ padArrayEnd(nonRevertibleTaggedPrivateLogs, PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX),
531
+ padArrayEnd(nonRevertibleContractClassLogHashes, ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX),
532
+ padArrayEnd(nonRevertiblePublicCallRequests, PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX),
533
+ );
421
534
 
422
535
  const revertibleData = new PrivateToPublicAccumulatedData(
423
- padArrayEnd(siloedNoteHashes.sort(sortByCounter).map(getEffect), Fr.ZERO, MAX_NOTE_HASHES_PER_TX),
424
- padArrayEnd(sortedNullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX),
425
- padArrayEnd(
426
- l2ToL1Messages.sort(sortByCounter).map(getEffect),
427
- ScopedL2ToL1Message.empty(),
428
- MAX_L2_TO_L1_MSGS_PER_TX,
429
- ),
430
- padArrayEnd(taggedPrivateLogs.sort(sortByCounter).map(getEffect), PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX),
431
- padArrayEnd(
432
- contractClassLogsHashes.sort(sortByCounter).map(getEffect),
433
- ScopedLogHash.empty(),
434
- MAX_CONTRACT_CLASS_LOGS_PER_TX,
435
- ),
436
- padArrayEnd(
437
- publicCallRequests.sort(sortByCounter).map(getEffect),
438
- PublicCallRequest.empty(),
439
- MAX_ENQUEUED_CALLS_PER_TX,
440
- ),
536
+ padArrayEnd(revertibleNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX),
537
+ padArrayEnd(revertibleNullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX),
538
+ padArrayEnd(revertibleL2ToL1Messages, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX),
539
+ padArrayEnd(revertibleTaggedPrivateLogs, PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX),
540
+ padArrayEnd(revertibleContractClassLogHashes, ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX),
541
+ padArrayEnd(revertiblePublicCallRequests, PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX),
441
542
  );
543
+ gasUsed = meterGasUsed(revertibleData).add(meterGasUsed(nonRevertibleData));
544
+ if (publicTeardownCallRequest) {
545
+ gasUsed.add(privateExecutionResult.entrypoint.publicInputs.txContext.gasSettings.teardownGasLimits);
546
+ }
442
547
 
443
548
  inputsForPublic = new PartialPrivateTailPublicInputsForPublic(
444
549
  nonRevertibleData,
@@ -449,7 +554,7 @@ export async function generateSimulatedProvingResult(
449
554
 
450
555
  const publicInputs = new PrivateKernelTailCircuitPublicInputs(
451
556
  constantData,
452
- /*gasUsed=*/ new Gas(0, 0),
557
+ /*gasUsed=*/ gasUsed.add(Gas.from({ l2Gas: FIXED_L2_GAS, daGas: FIXED_DA_GAS })),
453
558
  /*feePayer=*/ AztecAddress.zero(),
454
559
  /*includeByTimestamp=*/ 0n,
455
560
  hasPublicCalls ? inputsForPublic : undefined,
@@ -458,7 +563,60 @@ export async function generateSimulatedProvingResult(
458
563
 
459
564
  return {
460
565
  publicInputs,
461
- clientIvcProof: ClientIvcProof.empty(),
462
- executionSteps: executionSteps,
566
+ chonkProof: ChonkProof.empty(),
567
+ executionSteps,
463
568
  };
464
569
  }
570
+
571
+ function splitOrderedSideEffects<T>(effects: OrderedSideEffect<T>[], minRevertibleSideEffectCounter: number) {
572
+ const revertibleSideEffects: T[] = [];
573
+ const nonRevertibleSideEffects: T[] = [];
574
+ effects.forEach(effect => {
575
+ if (effect.counter < minRevertibleSideEffectCounter) {
576
+ nonRevertibleSideEffects.push(effect.sideEffect);
577
+ } else {
578
+ revertibleSideEffects.push(effect.sideEffect);
579
+ }
580
+ });
581
+ return [nonRevertibleSideEffects, revertibleSideEffects];
582
+ }
583
+
584
+ function meterGasUsed(data: PrivateToRollupAccumulatedData | PrivateToPublicAccumulatedData) {
585
+ let meteredDAFields = 0;
586
+ let meteredL2Gas = 0;
587
+
588
+ const numNoteHashes = arrayNonEmptyLength(data.noteHashes, hash => hash.isEmpty());
589
+ meteredDAFields += numNoteHashes;
590
+ meteredL2Gas += numNoteHashes * AVM_EMITNOTEHASH_BASE_L2_GAS;
591
+
592
+ const numNullifiers = arrayNonEmptyLength(data.nullifiers, nullifier => nullifier.isEmpty());
593
+ meteredDAFields += numNullifiers;
594
+ meteredL2Gas += numNullifiers * AVM_EMITNULLIFIER_BASE_L2_GAS;
595
+
596
+ const numL2toL1Messages = arrayNonEmptyLength(data.l2ToL1Msgs, msg => msg.isEmpty());
597
+ meteredDAFields += numL2toL1Messages;
598
+ meteredL2Gas += numL2toL1Messages * AVM_SENDL2TOL1MSG_BASE_L2_GAS;
599
+
600
+ const numPrivatelogs = arrayNonEmptyLength(data.privateLogs, log => log.isEmpty());
601
+ // Every private log emits its length as an additional field
602
+ meteredDAFields += data.privateLogs.reduce((acc, log) => (!log.isEmpty() ? acc + log.emittedLength + 1 : acc), 0);
603
+ meteredL2Gas += numPrivatelogs * L2_GAS_PER_PRIVATE_LOG;
604
+
605
+ const numContractClassLogs = arrayNonEmptyLength(data.contractClassLogsHashes, log => log.isEmpty());
606
+ // Every contract class log emits its length and contract address as additional fields
607
+ meteredDAFields += data.contractClassLogsHashes.reduce(
608
+ (acc, log) => (!log.isEmpty() ? acc + log.logHash.length + 2 : acc),
609
+ 0,
610
+ );
611
+ meteredL2Gas += numContractClassLogs * L2_GAS_PER_CONTRACT_CLASS_LOG;
612
+
613
+ const meteredDAGas = meteredDAFields * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
614
+
615
+ if ((data as PrivateToPublicAccumulatedData).publicCallRequests) {
616
+ const dataForPublic = data as PrivateToPublicAccumulatedData;
617
+
618
+ const numPublicCallRequests = arrayNonEmptyLength(dataForPublic.publicCallRequests, req => req.isEmpty());
619
+ meteredL2Gas += numPublicCallRequests * FIXED_AVM_STARTUP_L2_GAS;
620
+ }
621
+ return Gas.from({ l2Gas: meteredL2Gas, daGas: meteredDAGas });
622
+ }
@@ -1,8 +1,8 @@
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
3
  import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
4
4
 
5
- import type { NoteData } from './oracle/typed_oracle.js';
5
+ import type { NoteData } from './oracle/interfaces.js';
6
6
 
7
7
  interface PendingNote {
8
8
  note: NoteData;
@@ -44,9 +44,9 @@ export class ExecutionNoteCache {
44
44
  * We don't need to use the tx request hash for nonces if another non revertible nullifier is emitted.
45
45
  * In that case we disable injecting the tx request hash as a nullifier.
46
46
  */
47
- private usedTxRequestHashForNonces = true;
47
+ private usedProtocolNullifierForNonces = true;
48
48
 
49
- constructor(private readonly txRequestHash: Fr) {}
49
+ constructor(private readonly protocolNullifier: Fr) {}
50
50
 
51
51
  /**
52
52
  * Enters the revertible phase of the transaction.
@@ -60,12 +60,11 @@ export class ExecutionNoteCache {
60
60
  }
61
61
  this.inRevertiblePhase = true;
62
62
  this.minRevertibleSideEffectCounter = minRevertibleSideEffectCounter;
63
-
64
- let nonceGenerator = this.txRequestHash;
63
+ let nonceGenerator = this.protocolNullifier;
65
64
  const nullifiers = this.getAllNullifiers();
66
65
  if (nullifiers.length > 0) {
67
66
  nonceGenerator = new Fr(nullifiers[0]);
68
- this.usedTxRequestHashForNonces = false;
67
+ this.usedProtocolNullifierForNonces = false;
69
68
  }
70
69
 
71
70
  // The existing pending notes are all non-revertible.
@@ -92,14 +91,22 @@ export class ExecutionNoteCache {
92
91
  updatedNotes.forEach(n => this.#addNote(n));
93
92
  }
94
93
 
94
+ public isSideEffectCounterRevertible(sideEffectCounter: number): boolean {
95
+ if (!this.inRevertiblePhase) {
96
+ return false;
97
+ }
98
+ return sideEffectCounter >= this.minRevertibleSideEffectCounter;
99
+ }
100
+
95
101
  public finish() {
96
- // If we never entered the revertible phase, we need to use the tx request hash as a nonce for the notes if no nullifiers have been emitted.
102
+ // If we never entered the revertible phase, we need to use the protocol nullifier to compute the nonces for the
103
+ // notes if no nullifiers have been emitted.
97
104
  if (!this.inRevertiblePhase) {
98
- this.usedTxRequestHashForNonces = this.getAllNullifiers().length === 0;
105
+ this.usedProtocolNullifierForNonces = this.getAllNullifiers().length === 0;
99
106
  }
100
107
  // If we entered the revertible phase, the nonce generator was decided based on wether or not a nullifier was emitted before entering.
101
108
  return {
102
- usedTxRequestHashForNonces: this.usedTxRequestHashForNonces,
109
+ usedProtocolNullifierForNonces: this.usedProtocolNullifierForNonces,
103
110
  };
104
111
  }
105
112
 
@@ -126,7 +133,7 @@ export class ExecutionNoteCache {
126
133
  * transaction (and thus not a new note).
127
134
  */
128
135
  public async nullifyNote(contractAddress: AztecAddress, innerNullifier: Fr, noteHash: Fr) {
129
- const siloedNullifier = await siloNullifier(contractAddress, innerNullifier);
136
+ const siloedNullifier = (await siloNullifier(contractAddress, innerNullifier)).toBigInt();
130
137
  let nullifiedNoteHashCounter: number | undefined = undefined;
131
138
  // Find and remove the matching new note and log(s) if the emitted noteHash is not empty.
132
139
  if (!noteHash.isEmpty()) {
@@ -158,7 +165,7 @@ export class ExecutionNoteCache {
158
165
  * @param innerNullifier
159
166
  */
160
167
  public async nullifierCreated(contractAddress: AztecAddress, innerNullifier: Fr) {
161
- const siloedNullifier = await siloNullifier(contractAddress, innerNullifier);
168
+ const siloedNullifier = (await siloNullifier(contractAddress, innerNullifier)).toBigInt();
162
169
  this.recordNullifier(contractAddress, siloedNullifier);
163
170
  }
164
171
 
@@ -166,11 +173,15 @@ export class ExecutionNoteCache {
166
173
  * Return notes created up to current point in execution.
167
174
  * If a nullifier for a note in this list is emitted, the note will be deleted.
168
175
  * @param contractAddress - Contract address of the notes.
176
+ * @param owner - Owner of the notes. If undefined, returns all notes regardless of owner.
169
177
  * @param storageSlot - Storage slot of the notes.
170
178
  **/
171
- public getNotes(contractAddress: AztecAddress, storageSlot: Fr) {
179
+ public getNotes(contractAddress: AztecAddress, owner: AztecAddress | undefined, storageSlot: Fr) {
172
180
  const notes = this.noteMap.get(contractAddress.toBigInt()) ?? [];
173
- return notes.filter(n => n.note.storageSlot.equals(storageSlot)).map(n => n.note);
181
+ return notes
182
+ .filter(n => owner === undefined || n.note.owner.equals(owner))
183
+ .filter(n => n.note.storageSlot.equals(storageSlot))
184
+ .map(n => n.note);
174
185
  }
175
186
 
176
187
  /**
@@ -208,10 +219,15 @@ export class ExecutionNoteCache {
208
219
  return [...this.allNullifiers].map(n => new Fr(n));
209
220
  }
210
221
 
211
- recordNullifier(contractAddress: AztecAddress, siloedNullifier: Fr) {
222
+ recordNullifier(contractAddress: AztecAddress, siloedNullifier: bigint) {
212
223
  const nullifiers = this.getNullifiers(contractAddress);
213
- nullifiers.add(siloedNullifier.toBigInt());
224
+
225
+ if (nullifiers.has(siloedNullifier)) {
226
+ throw new Error(`Duplicate siloed nullifier ${siloedNullifier} emitted by contract ${contractAddress}`);
227
+ }
228
+
229
+ nullifiers.add(siloedNullifier);
214
230
  this.nullifierMap.set(contractAddress.toBigInt(), nullifiers);
215
- this.allNullifiers.add(siloedNullifier.toBigInt());
231
+ this.allNullifiers.add(siloedNullifier);
216
232
  }
217
233
  }
@@ -0,0 +1,32 @@
1
+ import { DirectionalAppTaggingSecret, type PreTag } from '@aztec/stdlib/logs';
2
+
3
+ /**
4
+ * A map that stores the tagging index for a given directional app tagging secret.
5
+ * Note: The directional app tagging secret is unique for a (sender, recipient, contract) tuple while the direction
6
+ * of sender -> recipient matters.
7
+ */
8
+ export class ExecutionTaggingIndexCache {
9
+ private taggingIndexMap: Map<string, number> = new Map();
10
+
11
+ public getLastUsedIndex(secret: DirectionalAppTaggingSecret): number | undefined {
12
+ return this.taggingIndexMap.get(secret.toString());
13
+ }
14
+
15
+ public setLastUsedIndex(secret: DirectionalAppTaggingSecret, index: number) {
16
+ const currentValue = this.taggingIndexMap.get(secret.toString());
17
+ if (currentValue !== undefined && currentValue !== index - 1) {
18
+ throw new Error(`Invalid tagging index update. Current value: ${currentValue}, new value: ${index}`);
19
+ }
20
+ this.taggingIndexMap.set(secret.toString(), index);
21
+ }
22
+
23
+ /**
24
+ * Returns the pre-tags that were used in this execution (and that need to be stored in the db).
25
+ */
26
+ public getUsedPreTags(): PreTag[] {
27
+ return Array.from(this.taggingIndexMap.entries()).map(([secret, index]) => ({
28
+ secret: DirectionalAppTaggingSecret.fromString(secret),
29
+ index,
30
+ }));
31
+ }
32
+ }