@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,22 +1,23 @@
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_BYTES_PER_FIELD, DA_GAS_PER_BYTE, FIXED_AVM_STARTUP_L2_GAS, FIXED_DA_GAS, FIXED_L2_GAS, L2_GAS_PER_CONTRACT_CLASS_LOG, L2_GAS_PER_PRIVATE_LOG, MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_ENQUEUED_CALLS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_PRIVATE_LOGS_PER_TX } from '@aztec/constants';
2
+ import { arrayNonEmptyLength, padArrayEnd } from '@aztec/foundation/collection';
3
+ import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
4
+ import { Fr } from '@aztec/foundation/curves/bn254';
5
5
  import { createLogger } from '@aztec/foundation/log';
6
6
  import { Timer } from '@aztec/foundation/timer';
7
7
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
8
- import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
8
+ import { protocolContractsHash } from '@aztec/protocol-contracts';
9
9
  import { ExecutionError, createSimulationError, extractCallStack, resolveAssertionMessageFromError, toACVMWitness, witnessMapToFields } from '@aztec/simulator/client';
10
- import { FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
10
+ import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
11
11
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
12
12
  import { Gas } from '@aztec/stdlib/gas';
13
- import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
13
+ import { computeNoteHashNonce, computeProtocolNullifier, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
14
14
  import { PartialPrivateTailPublicInputsForPublic, PartialPrivateTailPublicInputsForRollup, PrivateKernelTailCircuitPublicInputs, PrivateToPublicAccumulatedData, PrivateToRollupAccumulatedData, PublicCallRequest, ScopedLogHash } from '@aztec/stdlib/kernel';
15
15
  import { PrivateLog } from '@aztec/stdlib/logs';
16
16
  import { ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
17
- import { ClientIvcProof } from '@aztec/stdlib/proofs';
18
- import { CallContext, HashedValues, PrivateExecutionResult, TxConstantData, collectNested } from '@aztec/stdlib/tx';
17
+ import { ChonkProof } from '@aztec/stdlib/proofs';
18
+ import { CallContext, HashedValues, PrivateExecutionResult, TxConstantData, collectNested, getFinalMinRevertibleSideEffectCounter } from '@aztec/stdlib/tx';
19
19
  import { ExecutionNoteCache } from './execution_note_cache.js';
20
+ import { ExecutionTaggingIndexCache } from './execution_tagging_index_cache.js';
20
21
  import { HashedValuesCache } from './hashed_values_cache.js';
21
22
  import { Oracle } from './oracle/oracle.js';
22
23
  import { executePrivateFunction, verifyCurrentClassId } from './oracle/private_execution.js';
@@ -25,11 +26,31 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
25
26
  /**
26
27
  * The contract function simulator.
27
28
  */ export class ContractFunctionSimulator {
28
- executionDataProvider;
29
+ contractStore;
30
+ noteStore;
31
+ keyStore;
32
+ addressStore;
33
+ aztecNode;
34
+ anchorBlockStore;
35
+ senderTaggingStore;
36
+ recipientTaggingStore;
37
+ senderAddressBookStore;
38
+ capsuleStore;
39
+ privateEventStore;
29
40
  simulator;
30
41
  log;
31
- constructor(executionDataProvider, simulator){
32
- this.executionDataProvider = executionDataProvider;
42
+ constructor(contractStore, noteStore, keyStore, addressStore, aztecNode, anchorBlockStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, simulator){
43
+ this.contractStore = contractStore;
44
+ this.noteStore = noteStore;
45
+ this.keyStore = keyStore;
46
+ this.addressStore = addressStore;
47
+ this.aztecNode = aztecNode;
48
+ this.anchorBlockStore = anchorBlockStore;
49
+ this.senderTaggingStore = senderTaggingStore;
50
+ this.recipientTaggingStore = recipientTaggingStore;
51
+ this.senderAddressBookStore = senderAddressBookStore;
52
+ this.capsuleStore = capsuleStore;
53
+ this.privateEventStore = privateEventStore;
33
54
  this.simulator = simulator;
34
55
  this.log = createLogger('simulator');
35
56
  }
@@ -40,15 +61,16 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
40
61
  * @param contractAddress - The address of the contract (should match request.origin)
41
62
  * @param msgSender - The address calling the function. This can be replaced to simulate a call from another contract
42
63
  * or a specific account.
64
+ * @param anchorBlockHeader - The block header to use as base state for this run.
43
65
  * @param senderForTags - The address that is used as a tagging sender when emitting private logs. Returned from
44
66
  * the `privateGetSenderForTags` oracle.
45
67
  * @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
46
68
  * @returns The result of the execution.
47
- */ async run(request, contractAddress, selector, msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE), senderForTags, scopes) {
69
+ */ async run(request, contractAddress, selector, msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE), anchorBlockHeader, senderForTags, scopes) {
48
70
  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);
71
+ await this.contractStore.syncPrivateState(contractAddress, selector, (privateSyncCall)=>this.runUtility(privateSyncCall, [], anchorBlockHeader, scopes));
72
+ await verifyCurrentClassId(contractAddress, this.aztecNode, this.contractStore, anchorBlockHeader);
73
+ const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(contractAddress, selector);
52
74
  if (entryPointArtifact.functionType !== FunctionType.PRIVATE) {
53
75
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as private`);
54
76
  }
@@ -56,11 +78,14 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
56
78
  this.log.warn(`Request origin does not match contract address in simulation. Request origin: ${request.origin}, contract address: ${contractAddress}`);
57
79
  }
58
80
  // reserve the first side effect for the tx hash (inserted by the private kernel)
59
- const startSideEffectCounter = 1;
81
+ const startSideEffectCounter = 2;
60
82
  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);
83
+ const protocolNullifier = await computeProtocolNullifier(await request.toTxRequest().hash());
84
+ const noteCache = new ExecutionNoteCache(protocolNullifier);
85
+ const taggingIndexCache = new ExecutionTaggingIndexCache();
86
+ const privateExecutionOracle = new PrivateExecutionOracle(request.firstCallArgsHash, request.txContext, callContext, anchorBlockHeader, async (call)=>{
87
+ await this.runUtility(call, [], anchorBlockHeader, scopes);
88
+ }, request.authWitnesses, request.capsules, HashedValuesCache.create(request.argsOfCalls), noteCache, taggingIndexCache, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.aztecNode, this.anchorBlockStore, this.senderTaggingStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, 0, startSideEffectCounter, undefined, scopes, senderForTags, this.simulator);
64
89
  const setupTime = simulatorSetupTimer.ms();
65
90
  try {
66
91
  // Note: any nested private function calls are made recursively within this
@@ -69,8 +94,8 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
69
94
  // within executionResult.nestedExecutionResults).
70
95
  const executionResult = await executePrivateFunction(this.simulator, privateExecutionOracle, entryPointArtifact, contractAddress, request.functionSelector);
71
96
  const simulatorTeardownTimer = new Timer();
72
- const { usedTxRequestHashForNonces } = noteCache.finish();
73
- const firstNullifierHint = usedTxRequestHashForNonces ? Fr.ZERO : noteCache.getAllNullifiers()[0];
97
+ const { usedProtocolNullifierForNonces } = noteCache.finish();
98
+ const firstNullifierHint = usedProtocolNullifierForNonces ? Fr.ZERO : noteCache.getAllNullifiers()[0];
74
99
  const publicCallRequests = collectNested([
75
100
  executionResult
76
101
  ], (r)=>r.publicInputs.publicCallRequests.getActiveItems().map((r)=>r.inner).concat(r.publicInputs.publicTeardownCallRequest.isEmpty() ? [] : [
@@ -98,16 +123,17 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
98
123
  * Runs a utility function.
99
124
  * @param call - The function call to execute.
100
125
  * @param authwits - Authentication witnesses required for the function call.
126
+ * @param anchorBlockHeader - The block header to use as base state for this run.
101
127
  * @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
102
128
  * 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);
129
+ * @returns A return value of the utility function in a form as returned by the simulator (Noir fields)
130
+ */ async runUtility(call, authwits, anchorBlockHeader, scopes) {
131
+ await verifyCurrentClassId(call.to, this.aztecNode, this.contractStore, anchorBlockHeader);
132
+ const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
107
133
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
108
134
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
109
135
  }
110
- const oracle = new UtilityExecutionOracle(call.to, authwits, [], this.executionDataProvider, undefined, scopes);
136
+ const oracle = new UtilityExecutionOracle(call.to, authwits, [], anchorBlockHeader, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.aztecNode, this.anchorBlockStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, undefined, scopes);
111
137
  try {
112
138
  this.log.verbose(`Executing utility function ${entryPointArtifact.name}`, {
113
139
  contract: call.to,
@@ -123,16 +149,21 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
123
149
  cause: err
124
150
  });
125
151
  });
126
- const returnWitness = witnessMapToFields(acirExecutionResult.returnWitness);
127
152
  this.log.verbose(`Utility simulation for ${call.to}.${call.selector} completed`);
128
- return decodeFromAbi(entryPointArtifact.returnTypes, returnWitness);
153
+ return witnessMapToFields(acirExecutionResult.returnWitness);
129
154
  } catch (err) {
130
155
  throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
131
156
  }
132
157
  }
133
158
  // docs:end:execute_utility_function
134
- getStats() {
135
- return this.executionDataProvider.getStats();
159
+ /**
160
+ * Returns the execution statistics collected during the simulator run.
161
+ * @returns The execution statistics.
162
+ */ getStats() {
163
+ const nodeRPCCalls = typeof this.aztecNode.getStats === 'function' ? this.aztecNode.getStats() : {};
164
+ return {
165
+ nodeRPCCalls
166
+ };
136
167
  }
137
168
  }
138
169
  class OrderedSideEffect {
@@ -144,7 +175,7 @@ class OrderedSideEffect {
144
175
  }
145
176
  }
146
177
  /**
147
- * Generates the final public inputs of the tail kernel circuit, an empty ClientIVC proof
178
+ * Generates the final public inputs of the tail kernel circuit, an empty Chonk proof
148
179
  * and the execution steps for a `PrivateExecutionResult` as if it had been
149
180
  * processed by the private kernel prover. This skips many of the checks performed by the kernels
150
181
  * (allowing state overrides) and is much faster, while still generating a valid
@@ -152,9 +183,9 @@ class OrderedSideEffect {
152
183
  * @param privateExecutionResult - The result of the private execution.
153
184
  * @param nonceGenerator - A nonce generator for note hashes. According to the protocol rules,
154
185
  * 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.
186
+ * @param contractStore - A provider for contract data in order to get function names and debug info.
156
187
  * @returns The simulated proving result.
157
- */ export async function generateSimulatedProvingResult(privateExecutionResult, nonceGenerator, contractDataProvider) {
188
+ */ export async function generateSimulatedProvingResult(privateExecutionResult, nonceGenerator, contractStore) {
158
189
  const siloedNoteHashes = [];
159
190
  const nullifiers = [];
160
191
  const taggedPrivateLogs = [];
@@ -190,7 +221,7 @@ class OrderedSideEffect {
190
221
  }
191
222
  publicTeardownCallRequest = execution.publicInputs.publicTeardownCallRequest.isEmpty() ? publicTeardownCallRequest : execution.publicInputs.publicTeardownCallRequest;
192
223
  executionSteps.push({
193
- functionName: await contractDataProvider.getDebugFunctionName(execution.publicInputs.callContext.contractAddress, execution.publicInputs.callContext.functionSelector),
224
+ functionName: await contractStore.getDebugFunctionName(execution.publicInputs.callContext.contractAddress, execution.publicInputs.callContext.functionSelector),
194
225
  timings: execution.profileResult?.timings ?? {
195
226
  witgen: 0,
196
227
  oracles: {}
@@ -200,21 +231,23 @@ class OrderedSideEffect {
200
231
  witness: execution.partialWitness
201
232
  });
202
233
  }
203
- const constantData = new TxConstantData(privateExecutionResult.entrypoint.publicInputs.historicalHeader, privateExecutionResult.entrypoint.publicInputs.txContext, getVKTreeRoot(), protocolContractTreeRoot);
234
+ const constantData = new TxConstantData(privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader, privateExecutionResult.entrypoint.publicInputs.txContext, getVKTreeRoot(), protocolContractsHash);
204
235
  const hasPublicCalls = privateExecutionResult.publicFunctionCalldata.length !== 0;
205
236
  let inputsForRollup;
206
237
  let inputsForPublic;
238
+ let gasUsed;
207
239
  const sortByCounter = (a, b)=>a.counter - b.counter;
208
240
  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);
241
+ const isPrivateOnlyTx = privateExecutionResult.publicFunctionCalldata.length === 0;
242
+ const minRevertibleSideEffectCounter = getFinalMinRevertibleSideEffectCounter(privateExecutionResult);
243
+ const [nonRevertibleNullifiers, revertibleNullifiers] = splitOrderedSideEffects(nullifiers.sort(sortByCounter), minRevertibleSideEffectCounter);
244
+ if (nonRevertibleNullifiers.length > 0 && !nonRevertibleNullifiers[0].equals(nonceGenerator)) {
245
+ throw new Error('The first non revertible nullifier should be equal to the nonce generator. This is a bug!');
246
+ } else {
247
+ nonRevertibleNullifiers.unshift(nonceGenerator);
214
248
  }
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
249
+ if (isPrivateOnlyTx) {
250
+ // We must make the note hashes unique by using the
218
251
  // nonce generator and their index in the tx.
219
252
  const uniqueNoteHashes = await Promise.all(siloedNoteHashes.sort(sortByCounter).map(async (orderedSideEffect, i)=>{
220
253
  const siloedNoteHash = orderedSideEffect.sideEffect;
@@ -222,24 +255,76 @@ class OrderedSideEffect {
222
255
  const uniqueNoteHash = await computeUniqueNoteHash(nonce, siloedNoteHash);
223
256
  return uniqueNoteHash;
224
257
  }));
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));
258
+ const accumulatedDataForRollup = new PrivateToRollupAccumulatedData(padArrayEnd(uniqueNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX), padArrayEnd(nonRevertibleNullifiers.concat(revertibleNullifiers), Fr.ZERO, MAX_NULLIFIERS_PER_TX), padArrayEnd(l2ToL1Messages.sort(sortByCounter).map(getEffect), ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX), padArrayEnd(taggedPrivateLogs.sort(sortByCounter).map(getEffect), PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX), padArrayEnd(contractClassLogsHashes.sort(sortByCounter).map(getEffect), ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX));
259
+ gasUsed = meterGasUsed(accumulatedDataForRollup);
226
260
  inputsForRollup = new PartialPrivateTailPublicInputsForRollup(accumulatedDataForRollup);
227
261
  } 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));
262
+ const [nonRevertibleNoteHashes, revertibleNoteHashes] = splitOrderedSideEffects(siloedNoteHashes.sort(sortByCounter), minRevertibleSideEffectCounter);
263
+ const [nonRevertibleL2ToL1Messages, revertibleL2ToL1Messages] = splitOrderedSideEffects(l2ToL1Messages.sort(sortByCounter), minRevertibleSideEffectCounter);
264
+ const [nonRevertibleTaggedPrivateLogs, revertibleTaggedPrivateLogs] = splitOrderedSideEffects(taggedPrivateLogs, minRevertibleSideEffectCounter);
265
+ const [nonRevertibleContractClassLogHashes, revertibleContractClassLogHashes] = splitOrderedSideEffects(contractClassLogsHashes.sort(sortByCounter), minRevertibleSideEffectCounter);
266
+ const [nonRevertiblePublicCallRequests, revertiblePublicCallRequests] = splitOrderedSideEffects(publicCallRequests.sort(sortByCounter), minRevertibleSideEffectCounter);
267
+ const nonRevertibleData = new PrivateToPublicAccumulatedData(padArrayEnd(nonRevertibleNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX), padArrayEnd(nonRevertibleNullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX), padArrayEnd(nonRevertibleL2ToL1Messages, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX), padArrayEnd(nonRevertibleTaggedPrivateLogs, PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX), padArrayEnd(nonRevertibleContractClassLogHashes, ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX), padArrayEnd(nonRevertiblePublicCallRequests, PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX));
268
+ 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));
269
+ gasUsed = meterGasUsed(revertibleData).add(meterGasUsed(nonRevertibleData));
270
+ if (publicTeardownCallRequest) {
271
+ gasUsed.add(privateExecutionResult.entrypoint.publicInputs.txContext.gasSettings.teardownGasLimits);
272
+ }
237
273
  inputsForPublic = new PartialPrivateTailPublicInputsForPublic(nonRevertibleData, revertibleData, publicTeardownCallRequest ?? PublicCallRequest.empty());
238
274
  }
239
- const publicInputs = new PrivateKernelTailCircuitPublicInputs(constantData, /*gasUsed=*/ new Gas(0, 0), /*feePayer=*/ AztecAddress.zero(), /*includeByTimestamp=*/ 0n, hasPublicCalls ? inputsForPublic : undefined, !hasPublicCalls ? inputsForRollup : undefined);
275
+ const publicInputs = new PrivateKernelTailCircuitPublicInputs(constantData, /*gasUsed=*/ gasUsed.add(Gas.from({
276
+ l2Gas: FIXED_L2_GAS,
277
+ daGas: FIXED_DA_GAS
278
+ })), /*feePayer=*/ AztecAddress.zero(), /*includeByTimestamp=*/ 0n, hasPublicCalls ? inputsForPublic : undefined, !hasPublicCalls ? inputsForRollup : undefined);
240
279
  return {
241
280
  publicInputs,
242
- clientIvcProof: ClientIvcProof.empty(),
243
- executionSteps: executionSteps
281
+ chonkProof: ChonkProof.empty(),
282
+ executionSteps
244
283
  };
245
284
  }
285
+ function splitOrderedSideEffects(effects, minRevertibleSideEffectCounter) {
286
+ const revertibleSideEffects = [];
287
+ const nonRevertibleSideEffects = [];
288
+ effects.forEach((effect)=>{
289
+ if (effect.counter < minRevertibleSideEffectCounter) {
290
+ nonRevertibleSideEffects.push(effect.sideEffect);
291
+ } else {
292
+ revertibleSideEffects.push(effect.sideEffect);
293
+ }
294
+ });
295
+ return [
296
+ nonRevertibleSideEffects,
297
+ revertibleSideEffects
298
+ ];
299
+ }
300
+ function meterGasUsed(data) {
301
+ let meteredDAFields = 0;
302
+ let meteredL2Gas = 0;
303
+ const numNoteHashes = arrayNonEmptyLength(data.noteHashes, (hash)=>hash.isEmpty());
304
+ meteredDAFields += numNoteHashes;
305
+ meteredL2Gas += numNoteHashes * AVM_EMITNOTEHASH_BASE_L2_GAS;
306
+ const numNullifiers = arrayNonEmptyLength(data.nullifiers, (nullifier)=>nullifier.isEmpty());
307
+ meteredDAFields += numNullifiers;
308
+ meteredL2Gas += numNullifiers * AVM_EMITNULLIFIER_BASE_L2_GAS;
309
+ const numL2toL1Messages = arrayNonEmptyLength(data.l2ToL1Msgs, (msg)=>msg.isEmpty());
310
+ meteredDAFields += numL2toL1Messages;
311
+ meteredL2Gas += numL2toL1Messages * AVM_SENDL2TOL1MSG_BASE_L2_GAS;
312
+ const numPrivatelogs = arrayNonEmptyLength(data.privateLogs, (log)=>log.isEmpty());
313
+ // Every private log emits its length as an additional field
314
+ meteredDAFields += data.privateLogs.reduce((acc, log)=>!log.isEmpty() ? acc + log.emittedLength + 1 : acc, 0);
315
+ meteredL2Gas += numPrivatelogs * L2_GAS_PER_PRIVATE_LOG;
316
+ const numContractClassLogs = arrayNonEmptyLength(data.contractClassLogsHashes, (log)=>log.isEmpty());
317
+ // Every contract class log emits its length and contract address as additional fields
318
+ meteredDAFields += data.contractClassLogsHashes.reduce((acc, log)=>!log.isEmpty() ? acc + log.logHash.length + 2 : acc, 0);
319
+ meteredL2Gas += numContractClassLogs * L2_GAS_PER_CONTRACT_CLASS_LOG;
320
+ const meteredDAGas = meteredDAFields * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
321
+ if (data.publicCallRequests) {
322
+ const dataForPublic = data;
323
+ const numPublicCallRequests = arrayNonEmptyLength(dataForPublic.publicCallRequests, (req)=>req.isEmpty());
324
+ meteredL2Gas += numPublicCallRequests * FIXED_AVM_STARTUP_L2_GAS;
325
+ }
326
+ return Gas.from({
327
+ l2Gas: meteredL2Gas,
328
+ daGas: meteredDAGas
329
+ });
330
+ }
@@ -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.
@@ -37,15 +37,16 @@ export declare class ExecutionNoteCache {
37
37
  * We don't need to use the tx request hash for nonces if another non revertible nullifier is emitted.
38
38
  * In that case we disable injecting the tx request hash as a nullifier.
39
39
  */
40
- private usedTxRequestHashForNonces;
41
- constructor(txRequestHash: Fr);
40
+ private usedProtocolNullifierForNonces;
41
+ constructor(protocolNullifier: Fr);
42
42
  /**
43
43
  * Enters the revertible phase of the transaction.
44
44
  * @param minRevertibleSideEffectCounter - The counter at which the transaction enters the revertible phase.
45
45
  */
46
46
  setMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: number): Promise<void>;
47
+ isSideEffectCounterRevertible(sideEffectCounter: number): boolean;
47
48
  finish(): {
48
- usedTxRequestHashForNonces: boolean;
49
+ usedProtocolNullifierForNonces: boolean;
49
50
  };
50
51
  /**
51
52
  * Add a new note to cache.
@@ -70,9 +71,10 @@ export declare class ExecutionNoteCache {
70
71
  * Return notes created up to current point in execution.
71
72
  * If a nullifier for a note in this list is emitted, the note will be deleted.
72
73
  * @param contractAddress - Contract address of the notes.
74
+ * @param owner - Owner of the notes. If undefined, returns all notes regardless of owner.
73
75
  * @param storageSlot - Storage slot of the notes.
74
76
  **/
75
- getNotes(contractAddress: AztecAddress, storageSlot: Fr): NoteData[];
77
+ getNotes(contractAddress: AztecAddress, owner: AztecAddress | undefined, storageSlot: Fr): NoteData[];
76
78
  /**
77
79
  * Check if a note exists in the newNotes array.
78
80
  * @param contractAddress - Contract address of the note.
@@ -87,7 +89,7 @@ export declare class ExecutionNoteCache {
87
89
  getNullifiers(contractAddress: AztecAddress): Set<bigint>;
88
90
  getAllNotes(): PendingNote[];
89
91
  getAllNullifiers(): Fr[];
90
- recordNullifier(contractAddress: AztecAddress, siloedNullifier: Fr): void;
92
+ recordNullifier(contractAddress: AztecAddress, siloedNullifier: bigint): void;
91
93
  }
92
94
  export {};
93
- //# sourceMappingURL=execution_note_cache.d.ts.map
95
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhlY3V0aW9uX25vdGVfY2FjaGUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb250cmFjdF9mdW5jdGlvbl9zaW11bGF0b3IvZXhlY3V0aW9uX25vdGVfY2FjaGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE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AAe,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,gBAAgB,IAAI,EAAE,EAAE,CAEvB;IAED,eAAe,CAAC,eAAe,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,QAUrE;CACF"}
@@ -1,9 +1,9 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
3
3
  /**
4
4
  * Data that's accessible by all the function calls in an execution.
5
5
  */ export class ExecutionNoteCache {
6
- txRequestHash;
6
+ protocolNullifier;
7
7
  /**
8
8
  * New notes created in this transaction.
9
9
  * They are pushed to this array in the same order as they are emitted.
@@ -24,16 +24,16 @@ import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifie
24
24
  /**
25
25
  * We don't need to use the tx request hash for nonces if another non revertible nullifier is emitted.
26
26
  * In that case we disable injecting the tx request hash as a nullifier.
27
- */ usedTxRequestHashForNonces;
28
- constructor(txRequestHash){
29
- this.txRequestHash = txRequestHash;
27
+ */ usedProtocolNullifierForNonces;
28
+ constructor(protocolNullifier){
29
+ this.protocolNullifier = protocolNullifier;
30
30
  this.notes = [];
31
31
  this.noteMap = new Map();
32
32
  this.nullifierMap = new Map();
33
33
  this.allNullifiers = new Set();
34
34
  this.minRevertibleSideEffectCounter = 0;
35
35
  this.inRevertiblePhase = false;
36
- this.usedTxRequestHashForNonces = true;
36
+ this.usedProtocolNullifierForNonces = true;
37
37
  }
38
38
  /**
39
39
  * Enters the revertible phase of the transaction.
@@ -44,11 +44,11 @@ import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifie
44
44
  }
45
45
  this.inRevertiblePhase = true;
46
46
  this.minRevertibleSideEffectCounter = minRevertibleSideEffectCounter;
47
- let nonceGenerator = this.txRequestHash;
47
+ let nonceGenerator = this.protocolNullifier;
48
48
  const nullifiers = this.getAllNullifiers();
49
49
  if (nullifiers.length > 0) {
50
50
  nonceGenerator = new Fr(nullifiers[0]);
51
- this.usedTxRequestHashForNonces = false;
51
+ this.usedProtocolNullifierForNonces = false;
52
52
  }
53
53
  // The existing pending notes are all non-revertible.
54
54
  // They cannot be squashed by nullifiers emitted after minRevertibleSideEffectCounter is set.
@@ -71,14 +71,21 @@ import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifie
71
71
  this.noteMap = new Map();
72
72
  updatedNotes.forEach((n)=>this.#addNote(n));
73
73
  }
74
+ isSideEffectCounterRevertible(sideEffectCounter) {
75
+ if (!this.inRevertiblePhase) {
76
+ return false;
77
+ }
78
+ return sideEffectCounter >= this.minRevertibleSideEffectCounter;
79
+ }
74
80
  finish() {
75
- // 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.
81
+ // If we never entered the revertible phase, we need to use the protocol nullifier to compute the nonces for the
82
+ // notes if no nullifiers have been emitted.
76
83
  if (!this.inRevertiblePhase) {
77
- this.usedTxRequestHashForNonces = this.getAllNullifiers().length === 0;
84
+ this.usedProtocolNullifierForNonces = this.getAllNullifiers().length === 0;
78
85
  }
79
86
  // If we entered the revertible phase, the nonce generator was decided based on wether or not a nullifier was emitted before entering.
80
87
  return {
81
- usedTxRequestHashForNonces: this.usedTxRequestHashForNonces
88
+ usedProtocolNullifierForNonces: this.usedProtocolNullifierForNonces
82
89
  };
83
90
  }
84
91
  /**
@@ -102,7 +109,7 @@ import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifie
102
109
  * @param noteHash - A hash of the note. If this value equals 0, it means the note being nullified is from a previous
103
110
  * transaction (and thus not a new note).
104
111
  */ async nullifyNote(contractAddress, innerNullifier, noteHash) {
105
- const siloedNullifier = await siloNullifier(contractAddress, innerNullifier);
112
+ const siloedNullifier = (await siloNullifier(contractAddress, innerNullifier)).toBigInt();
106
113
  let nullifiedNoteHashCounter = undefined;
107
114
  // Find and remove the matching new note and log(s) if the emitted noteHash is not empty.
108
115
  if (!noteHash.isEmpty()) {
@@ -130,17 +137,18 @@ import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifie
130
137
  * @param contractAddress - Contract address that emitted the nullifier.
131
138
  * @param innerNullifier
132
139
  */ async nullifierCreated(contractAddress, innerNullifier) {
133
- const siloedNullifier = await siloNullifier(contractAddress, innerNullifier);
140
+ const siloedNullifier = (await siloNullifier(contractAddress, innerNullifier)).toBigInt();
134
141
  this.recordNullifier(contractAddress, siloedNullifier);
135
142
  }
136
143
  /**
137
144
  * Return notes created up to current point in execution.
138
145
  * If a nullifier for a note in this list is emitted, the note will be deleted.
139
146
  * @param contractAddress - Contract address of the notes.
147
+ * @param owner - Owner of the notes. If undefined, returns all notes regardless of owner.
140
148
  * @param storageSlot - Storage slot of the notes.
141
- **/ getNotes(contractAddress, storageSlot) {
149
+ **/ getNotes(contractAddress, owner, storageSlot) {
142
150
  const notes = this.noteMap.get(contractAddress.toBigInt()) ?? [];
143
- return notes.filter((n)=>n.note.storageSlot.equals(storageSlot)).map((n)=>n.note);
151
+ return notes.filter((n)=>owner === undefined || n.note.owner.equals(owner)).filter((n)=>n.note.storageSlot.equals(storageSlot)).map((n)=>n.note);
144
152
  }
145
153
  /**
146
154
  * Check if a note exists in the newNotes array.
@@ -173,8 +181,11 @@ import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifie
173
181
  }
174
182
  recordNullifier(contractAddress, siloedNullifier) {
175
183
  const nullifiers = this.getNullifiers(contractAddress);
176
- nullifiers.add(siloedNullifier.toBigInt());
184
+ if (nullifiers.has(siloedNullifier)) {
185
+ throw new Error(`Duplicate siloed nullifier ${siloedNullifier} emitted by contract ${contractAddress}`);
186
+ }
187
+ nullifiers.add(siloedNullifier);
177
188
  this.nullifierMap.set(contractAddress.toBigInt(), nullifiers);
178
- this.allNullifiers.add(siloedNullifier.toBigInt());
189
+ this.allNullifiers.add(siloedNullifier);
179
190
  }
180
191
  }
@@ -0,0 +1,16 @@
1
+ import { DirectionalAppTaggingSecret, type PreTag } from '@aztec/stdlib/logs';
2
+ /**
3
+ * A map that stores the tagging index for a given directional app tagging secret.
4
+ * Note: The directional app tagging secret is unique for a (sender, recipient, contract) tuple while the direction
5
+ * of sender -> recipient matters.
6
+ */
7
+ export declare class ExecutionTaggingIndexCache {
8
+ private taggingIndexMap;
9
+ getLastUsedIndex(secret: DirectionalAppTaggingSecret): number | undefined;
10
+ setLastUsedIndex(secret: DirectionalAppTaggingSecret, index: number): void;
11
+ /**
12
+ * Returns the pre-tags that were used in this execution (and that need to be stored in the db).
13
+ */
14
+ getUsedPreTags(): PreTag[];
15
+ }
16
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhlY3V0aW9uX3RhZ2dpbmdfaW5kZXhfY2FjaGUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb250cmFjdF9mdW5jdGlvbl9zaW11bGF0b3IvZXhlY3V0aW9uX3RhZ2dpbmdfaW5kZXhfY2FjaGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLDJCQUEyQixFQUFFLEtBQUssTUFBTSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFOUU7Ozs7R0FJRztBQUNILHFCQUFhLDBCQUEwQjtJQUNyQyxPQUFPLENBQUMsZUFBZSxDQUFrQztJQUVsRCxnQkFBZ0IsQ0FBQyxNQUFNLEVBQUUsMkJBQTJCLEdBQUcsTUFBTSxHQUFHLFNBQVMsQ0FFL0U7SUFFTSxnQkFBZ0IsQ0FBQyxNQUFNLEVBQUUsMkJBQTJCLEVBQUUsS0FBSyxFQUFFLE1BQU0sUUFNekU7SUFFRDs7T0FFRztJQUNJLGNBQWMsSUFBSSxNQUFNLEVBQUUsQ0FLaEM7Q0FDRiJ9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution_tagging_index_cache.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/execution_tagging_index_cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE9E;;;;GAIG;AACH,qBAAa,0BAA0B;IACrC,OAAO,CAAC,eAAe,CAAkC;IAElD,gBAAgB,CAAC,MAAM,EAAE,2BAA2B,GAAG,MAAM,GAAG,SAAS,CAE/E;IAEM,gBAAgB,CAAC,MAAM,EAAE,2BAA2B,EAAE,KAAK,EAAE,MAAM,QAMzE;IAED;;OAEG;IACI,cAAc,IAAI,MAAM,EAAE,CAKhC;CACF"}
@@ -0,0 +1,26 @@
1
+ import { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
2
+ /**
3
+ * A map that stores the tagging index for a given directional app tagging secret.
4
+ * Note: The directional app tagging secret is unique for a (sender, recipient, contract) tuple while the direction
5
+ * of sender -> recipient matters.
6
+ */ export class ExecutionTaggingIndexCache {
7
+ taggingIndexMap = new Map();
8
+ getLastUsedIndex(secret) {
9
+ return this.taggingIndexMap.get(secret.toString());
10
+ }
11
+ setLastUsedIndex(secret, index) {
12
+ const currentValue = this.taggingIndexMap.get(secret.toString());
13
+ if (currentValue !== undefined && currentValue !== index - 1) {
14
+ throw new Error(`Invalid tagging index update. Current value: ${currentValue}, new value: ${index}`);
15
+ }
16
+ this.taggingIndexMap.set(secret.toString(), index);
17
+ }
18
+ /**
19
+ * Returns the pre-tags that were used in this execution (and that need to be stored in the db).
20
+ */ getUsedPreTags() {
21
+ return Array.from(this.taggingIndexMap.entries()).map(([secret, index])=>({
22
+ secret: DirectionalAppTaggingSecret.fromString(secret),
23
+ index
24
+ }));
25
+ }
26
+ }
@@ -1,4 +1,4 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { HashedValues } from '@aztec/stdlib/tx';
3
3
  /**
4
4
  * A cache for hashed values (arguments, returns) during transaction execution.
@@ -25,4 +25,4 @@ export declare class HashedValuesCache {
25
25
  */
26
26
  store(values: Fr[], hash: Fr): void;
27
27
  }
28
- //# sourceMappingURL=hashed_values_cache.d.ts.map
28
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGFzaGVkX3ZhbHVlc19jYWNoZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnRyYWN0X2Z1bmN0aW9uX3NpbXVsYXRvci9oYXNoZWRfdmFsdWVzX2NhY2hlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUNwRCxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFaEQ7O0dBRUc7QUFDSCxxQkFBYSxpQkFBaUI7SUFDNUIsT0FBTyxDQUFDLEtBQUssQ0FBb0I7SUFFakMsWUFBWSxnQkFBZ0IsR0FBRSxZQUFZLEVBQU8sRUFLaEQ7SUFFRDs7OztPQUlHO0lBQ0gsT0FBYyxNQUFNLENBQUMsZ0JBQWdCLEdBQUUsWUFBWSxFQUFPLHFCQUV6RDtJQUVEOzs7O09BSUc7SUFDSSxXQUFXLENBQUMsSUFBSSxFQUFFLEVBQUUsR0FBRyxFQUFFLEVBQUUsR0FBRyxTQUFTLENBTTdDO0lBRUQ7Ozs7T0FJRztJQUNJLEtBQUssQ0FBQyxNQUFNLEVBQUUsRUFBRSxFQUFFLEVBQUUsSUFBSSxFQUFFLEVBQUUsUUFFbEM7Q0FDRiJ9
@@ -1 +1 @@
1
- {"version":3,"file":"hashed_values_cache.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/hashed_values_cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,KAAK,CAAoB;gBAErB,gBAAgB,GAAE,YAAY,EAAO;IAOjD;;;;OAIG;WACW,MAAM,CAAC,gBAAgB,GAAE,YAAY,EAAO;IAI1D;;;;OAIG;IACI,WAAW,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE,GAAG,SAAS;IAQ9C;;;;OAIG;IACI,KAAK,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;CAGpC"}
1
+ {"version":3,"file":"hashed_values_cache.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/hashed_values_cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,KAAK,CAAoB;IAEjC,YAAY,gBAAgB,GAAE,YAAY,EAAO,EAKhD;IAED;;;;OAIG;IACH,OAAc,MAAM,CAAC,gBAAgB,GAAE,YAAY,EAAO,qBAEzD;IAED;;;;OAIG;IACI,WAAW,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE,GAAG,SAAS,CAM7C;IAED;;;;OAIG;IACI,KAAK,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,QAElC;CACF"}
@@ -1,7 +1,8 @@
1
1
  export { ExecutionNoteCache } from './execution_note_cache.js';
2
+ export { ExecutionTaggingIndexCache } from './execution_tagging_index_cache.js';
2
3
  export { HashedValuesCache } from './hashed_values_cache.js';
3
4
  export { pickNotes } from './pick_notes.js';
4
- export { type NoteData, TypedOracle } from './oracle/typed_oracle.js';
5
+ export type { NoteData, IMiscOracle, IUtilityExecutionOracle, IPrivateExecutionOracle } from './oracle/interfaces.js';
5
6
  export { MessageLoadOracleInputs } from './oracle/message_load_oracle_inputs.js';
6
7
  export { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
7
8
  export { PrivateExecutionOracle } from './oracle/private_execution_oracle.js';
@@ -9,4 +10,5 @@ export { Oracle } from './oracle/oracle.js';
9
10
  export { executePrivateFunction, extractPrivateCircuitPublicInputs } from './oracle/private_execution.js';
10
11
  export { generateSimulatedProvingResult } from './contract_function_simulator.js';
11
12
  export { packAsRetrievedNote } from './oracle/note_packing_utils.js';
12
- //# sourceMappingURL=index.d.ts.map
13
+ export { UtilityContext } from './noir-structs/utility_context.js';
14
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb250cmFjdF9mdW5jdGlvbl9zaW11bGF0b3IvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDL0QsT0FBTyxFQUFFLDBCQUEwQixFQUFFLE1BQU0sb0NBQW9DLENBQUM7QUFDaEYsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFDN0QsT0FBTyxFQUFFLFNBQVMsRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBQzVDLFlBQVksRUFBRSxRQUFRLEVBQUUsV0FBVyxFQUFFLHVCQUF1QixFQUFFLHVCQUF1QixFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFDdEgsT0FBTyxFQUFFLHVCQUF1QixFQUFFLE1BQU0sd0NBQXdDLENBQUM7QUFDakYsT0FBTyxFQUFFLHNCQUFzQixFQUFFLE1BQU0sc0NBQXNDLENBQUM7QUFDOUUsT0FBTyxFQUFFLHNCQUFzQixFQUFFLE1BQU0sc0NBQXNDLENBQUM7QUFDOUUsT0FBTyxFQUFFLE1BQU0sRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBQzVDLE9BQU8sRUFBRSxzQkFBc0IsRUFBRSxpQ0FBaUMsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBQzFHLE9BQU8sRUFBRSw4QkFBOEIsRUFBRSxNQUFNLGtDQUFrQyxDQUFDO0FBQ2xGLE9BQU8sRUFBRSxtQkFBbUIsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3JFLE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQyJ9
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,KAAK,QAAQ,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,iCAAiC,EAAE,MAAM,+BAA+B,CAAC;AAC1G,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contract_function_simul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