@aztec/pxe 0.0.1-commit.03f7ef2 → 0.0.1-commit.04d373f

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 (488) hide show
  1. package/dest/bin/check_oracle_version.d.ts +12 -2
  2. package/dest/bin/check_oracle_version.d.ts.map +1 -1
  3. package/dest/bin/check_oracle_version.js +32 -26
  4. package/dest/bin/index.d.ts +2 -0
  5. package/dest/bin/index.d.ts.map +1 -0
  6. package/dest/bin/index.js +1 -0
  7. package/dest/block_synchronizer/block_stream_source.d.ts +10 -0
  8. package/dest/block_synchronizer/block_stream_source.d.ts.map +1 -0
  9. package/dest/block_synchronizer/block_stream_source.js +62 -0
  10. package/dest/block_synchronizer/block_synchronizer.d.ts +22 -12
  11. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  12. package/dest/block_synchronizer/block_synchronizer.js +101 -35
  13. package/dest/config/index.d.ts +10 -2
  14. package/dest/config/index.d.ts.map +1 -1
  15. package/dest/config/index.js +17 -2
  16. package/dest/config/package_info.js +1 -1
  17. package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
  18. package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
  19. package/dest/contract_function_simulator/benchmarked_node.js +77 -0
  20. package/dest/contract_function_simulator/contract_function_simulator.d.ts +77 -41
  21. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  22. package/dest/contract_function_simulator/contract_function_simulator.js +251 -96
  23. package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
  24. package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
  25. package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
  26. package/dest/contract_function_simulator/execution_note_cache.d.ts +18 -9
  27. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  28. package/dest/contract_function_simulator/execution_note_cache.js +45 -28
  29. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -11
  30. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  31. package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -15
  32. package/dest/contract_function_simulator/index.d.ts +5 -2
  33. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  34. package/dest/contract_function_simulator/index.js +4 -1
  35. package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts +48 -0
  36. package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts.map +1 -0
  37. package/dest/contract_function_simulator/noir-structs/bounded_vec.js +45 -0
  38. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +6 -7
  39. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  40. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +12 -10
  41. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +13 -3
  42. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
  43. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +35 -4
  44. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
  45. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  46. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +2 -4
  47. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +5 -8
  48. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  49. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +7 -11
  50. package/dest/contract_function_simulator/noir-structs/option.d.ts +61 -0
  51. package/dest/contract_function_simulator/noir-structs/option.d.ts.map +1 -0
  52. package/dest/contract_function_simulator/noir-structs/option.js +62 -0
  53. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
  54. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
  55. package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
  56. package/dest/contract_function_simulator/oracle/interfaces.d.ts +70 -50
  57. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  58. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -1
  59. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  60. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +7 -7
  61. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
  62. package/dest/contract_function_simulator/oracle/note_packing_utils.js +10 -10
  63. package/dest/contract_function_simulator/oracle/oracle.d.ts +74 -43
  64. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  65. package/dest/contract_function_simulator/oracle/oracle.js +471 -264
  66. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +147 -0
  67. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -0
  68. package/dest/contract_function_simulator/oracle/oracle_registry.js +1199 -0
  69. package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -26
  70. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  71. package/dest/contract_function_simulator/oracle/private_execution.js +5 -39
  72. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +74 -100
  73. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  74. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +168 -139
  75. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +169 -90
  76. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  77. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +468 -193
  78. package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
  79. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
  80. package/dest/contract_function_simulator/pick_notes.js +20 -3
  81. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +4 -4
  82. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
  83. package/dest/contract_function_simulator/proxied_contract_data_source.js +39 -68
  84. package/dest/contract_logging.d.ts +27 -0
  85. package/dest/contract_logging.d.ts.map +1 -0
  86. package/dest/contract_logging.js +38 -0
  87. package/dest/contract_sync/contract_sync_service.d.ts +42 -0
  88. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
  89. package/dest/contract_sync/contract_sync_service.js +135 -0
  90. package/dest/contract_sync/helpers.d.ts +27 -0
  91. package/dest/contract_sync/helpers.d.ts.map +1 -0
  92. package/dest/contract_sync/helpers.js +53 -0
  93. package/dest/debug/pxe_debug_utils.d.ts +21 -12
  94. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  95. package/dest/debug/pxe_debug_utils.js +24 -19
  96. package/dest/entrypoints/client/bundle/index.d.ts +3 -1
  97. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  98. package/dest/entrypoints/client/bundle/index.js +2 -0
  99. package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
  100. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  101. package/dest/entrypoints/client/bundle/utils.js +41 -10
  102. package/dest/entrypoints/client/lazy/index.d.ts +3 -1
  103. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  104. package/dest/entrypoints/client/lazy/index.js +2 -0
  105. package/dest/entrypoints/client/lazy/utils.d.ts +3 -3
  106. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  107. package/dest/entrypoints/client/lazy/utils.js +42 -11
  108. package/dest/entrypoints/pxe_creation_options.d.ts +13 -3
  109. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  110. package/dest/entrypoints/pxe_creation_options.js +3 -1
  111. package/dest/entrypoints/server/index.d.ts +6 -2
  112. package/dest/entrypoints/server/index.d.ts.map +1 -1
  113. package/dest/entrypoints/server/index.js +5 -1
  114. package/dest/entrypoints/server/utils.d.ts +4 -3
  115. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  116. package/dest/entrypoints/server/utils.js +49 -18
  117. package/dest/error_enriching.d.ts +4 -4
  118. package/dest/error_enriching.d.ts.map +1 -1
  119. package/dest/error_enriching.js +6 -6
  120. package/dest/events/event_service.d.ts +19 -10
  121. package/dest/events/event_service.d.ts.map +1 -1
  122. package/dest/events/event_service.js +60 -30
  123. package/dest/events/private_event_filter_validator.d.ts +7 -6
  124. package/dest/events/private_event_filter_validator.d.ts.map +1 -1
  125. package/dest/events/private_event_filter_validator.js +20 -6
  126. package/dest/hooks/authorize_utility_call.d.ts +41 -0
  127. package/dest/hooks/authorize_utility_call.d.ts.map +1 -0
  128. package/dest/hooks/authorize_utility_call.js +4 -0
  129. package/dest/hooks/execution_hooks.d.ts +42 -0
  130. package/dest/hooks/execution_hooks.d.ts.map +1 -0
  131. package/dest/hooks/execution_hooks.js +9 -0
  132. package/dest/hooks/index.d.ts +4 -0
  133. package/dest/hooks/index.d.ts.map +1 -0
  134. package/dest/hooks/index.js +1 -0
  135. package/dest/job_coordinator/job_coordinator.d.ts +75 -0
  136. package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
  137. package/dest/job_coordinator/job_coordinator.js +94 -0
  138. package/dest/logs/log_service.d.ts +21 -35
  139. package/dest/logs/log_service.d.ts.map +1 -1
  140. package/dest/logs/log_service.js +144 -215
  141. package/dest/messages/message_context_service.d.ts +17 -0
  142. package/dest/messages/message_context_service.d.ts.map +1 -0
  143. package/dest/messages/message_context_service.js +38 -0
  144. package/dest/notes/note_service.d.ts +34 -12
  145. package/dest/notes/note_service.d.ts.map +1 -1
  146. package/dest/notes/note_service.js +102 -82
  147. package/dest/notes_filter.d.ts +24 -0
  148. package/dest/notes_filter.d.ts.map +1 -0
  149. package/dest/notes_filter.js +4 -0
  150. package/dest/oracle_version.d.ts +4 -3
  151. package/dest/oracle_version.d.ts.map +1 -1
  152. package/dest/oracle_version.js +20 -9
  153. package/dest/private_kernel/batch_planner.d.ts +47 -0
  154. package/dest/private_kernel/batch_planner.d.ts.map +1 -0
  155. package/dest/private_kernel/batch_planner.js +104 -0
  156. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
  157. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
  158. package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
  159. package/dest/private_kernel/hints/index.d.ts +3 -3
  160. package/dest/private_kernel/hints/index.d.ts.map +1 -1
  161. package/dest/private_kernel/hints/index.js +2 -2
  162. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +29 -0
  163. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
  164. package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +142 -75
  165. package/dest/private_kernel/hints/test_utils.d.ts +122 -0
  166. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
  167. package/dest/private_kernel/hints/test_utils.js +202 -0
  168. package/dest/private_kernel/private_kernel_execution_prover.d.ts +7 -2
  169. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  170. package/dest/private_kernel/private_kernel_execution_prover.js +169 -69
  171. package/dest/private_kernel/private_kernel_oracle.d.ts +29 -29
  172. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  173. package/dest/private_kernel/private_kernel_oracle.js +96 -2
  174. package/dest/pxe.d.ts +136 -67
  175. package/dest/pxe.d.ts.map +1 -1
  176. package/dest/pxe.js +314 -231
  177. package/dest/storage/address_store/address_store.d.ts +11 -0
  178. package/dest/storage/address_store/address_store.d.ts.map +1 -0
  179. package/dest/storage/{address_data_provider/address_data_provider.js → address_store/address_store.js} +13 -12
  180. package/dest/storage/address_store/index.d.ts +2 -0
  181. package/dest/storage/address_store/index.d.ts.map +1 -0
  182. package/dest/storage/address_store/index.js +1 -0
  183. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +17 -0
  184. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
  185. package/dest/storage/anchor_block_store/anchor_block_store.js +26 -0
  186. package/dest/storage/anchor_block_store/index.d.ts +2 -0
  187. package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
  188. package/dest/storage/anchor_block_store/index.js +1 -0
  189. package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts +42 -0
  190. package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts.map +1 -0
  191. package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.js +93 -0
  192. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +15 -0
  193. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -0
  194. package/dest/storage/backwards_compatibility_tests/schema_tests.js +591 -0
  195. package/dest/storage/backwards_compatibility_tests/store_spy.d.ts +19 -0
  196. package/dest/storage/backwards_compatibility_tests/store_spy.d.ts.map +1 -0
  197. package/dest/storage/backwards_compatibility_tests/store_spy.js +63 -0
  198. package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
  199. package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
  200. package/dest/storage/capsule_store/capsule_service.js +50 -0
  201. package/dest/storage/capsule_store/capsule_store.d.ts +72 -0
  202. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
  203. package/dest/storage/capsule_store/capsule_store.js +261 -0
  204. package/dest/storage/capsule_store/index.d.ts +3 -0
  205. package/dest/storage/capsule_store/index.d.ts.map +1 -0
  206. package/dest/storage/capsule_store/index.js +2 -0
  207. package/dest/storage/contract_store/contract_store.d.ts +93 -0
  208. package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
  209. package/dest/storage/contract_store/contract_store.js +292 -0
  210. package/dest/storage/contract_store/index.d.ts +2 -0
  211. package/dest/storage/contract_store/index.d.ts.map +1 -0
  212. package/dest/storage/contract_store/index.js +1 -0
  213. package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.d.ts +1 -1
  214. package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
  215. package/dest/storage/index.d.ts +8 -8
  216. package/dest/storage/index.d.ts.map +1 -1
  217. package/dest/storage/index.js +7 -7
  218. package/dest/storage/metadata.d.ts +1 -1
  219. package/dest/storage/metadata.js +1 -1
  220. package/dest/storage/note_store/index.d.ts +3 -0
  221. package/dest/storage/note_store/index.d.ts.map +1 -0
  222. package/dest/storage/note_store/index.js +2 -0
  223. package/dest/storage/note_store/note_store.d.ts +83 -0
  224. package/dest/storage/note_store/note_store.d.ts.map +1 -0
  225. package/dest/storage/note_store/note_store.js +343 -0
  226. package/dest/storage/note_store/stored_note.d.ts +16 -0
  227. package/dest/storage/note_store/stored_note.d.ts.map +1 -0
  228. package/dest/storage/note_store/stored_note.js +43 -0
  229. package/dest/storage/open_pxe_stores.d.ts +33 -0
  230. package/dest/storage/open_pxe_stores.d.ts.map +1 -0
  231. package/dest/storage/open_pxe_stores.js +27 -0
  232. package/dest/storage/private_event_store/private_event_store.d.ts +91 -0
  233. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
  234. package/dest/storage/private_event_store/private_event_store.js +276 -0
  235. package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
  236. package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
  237. package/dest/storage/private_event_store/stored_private_event.js +56 -0
  238. package/dest/storage/tagging_store/index.d.ts +4 -0
  239. package/dest/storage/tagging_store/index.d.ts.map +1 -0
  240. package/dest/storage/tagging_store/index.js +3 -0
  241. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +28 -0
  242. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
  243. package/dest/storage/tagging_store/recipient_tagging_store.js +111 -0
  244. package/dest/storage/tagging_store/sender_address_book_store.d.ts +14 -0
  245. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -0
  246. package/dest/storage/tagging_store/sender_address_book_store.js +36 -0
  247. package/dest/storage/tagging_store/sender_tagging_store.d.ts +78 -0
  248. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
  249. package/dest/storage/tagging_store/sender_tagging_store.js +374 -0
  250. package/dest/tagging/constants.d.ts +2 -2
  251. package/dest/tagging/constants.d.ts.map +1 -1
  252. package/dest/tagging/constants.js +10 -3
  253. package/dest/tagging/get_all_logs_by_tags.d.ts +48 -0
  254. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
  255. package/dest/tagging/get_all_logs_by_tags.js +59 -0
  256. package/dest/tagging/index.d.ts +18 -5
  257. package/dest/tagging/index.d.ts.map +1 -1
  258. package/dest/tagging/index.js +16 -3
  259. package/dest/tagging/persist_sender_tagging_index_ranges.d.ts +29 -0
  260. package/dest/tagging/persist_sender_tagging_index_ranges.d.ts.map +1 -0
  261. package/dest/tagging/persist_sender_tagging_index_ranges.js +42 -0
  262. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +56 -0
  263. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -0
  264. package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +163 -0
  265. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +3 -3
  266. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -1
  267. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
  268. package/dest/tagging/reconcile_tagging_index_ranges.d.ts +36 -0
  269. package/dest/tagging/reconcile_tagging_index_ranges.d.ts.map +1 -0
  270. package/dest/tagging/reconcile_tagging_index_ranges.js +74 -0
  271. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +16 -0
  272. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -0
  273. package/dest/tagging/{sync → sender_sync}/sync_sender_tagging_indexes.js +35 -34
  274. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +17 -0
  275. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -0
  276. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +60 -0
  277. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +19 -0
  278. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
  279. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +72 -0
  280. package/package.json +31 -19
  281. package/src/bin/check_oracle_version.ts +42 -31
  282. package/src/bin/index.ts +1 -0
  283. package/src/block_synchronizer/block_stream_source.ts +81 -0
  284. package/src/block_synchronizer/block_synchronizer.ts +123 -48
  285. package/src/config/index.ts +21 -1
  286. package/src/config/package_info.ts +1 -1
  287. package/src/contract_function_simulator/benchmarked_node.ts +103 -0
  288. package/src/contract_function_simulator/contract_function_simulator.ts +431 -161
  289. package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
  290. package/src/contract_function_simulator/execution_note_cache.ts +44 -25
  291. package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -18
  292. package/src/contract_function_simulator/index.ts +4 -1
  293. package/src/contract_function_simulator/noir-structs/bounded_vec.ts +55 -0
  294. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +15 -10
  295. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +36 -3
  296. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -5
  297. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +6 -11
  298. package/src/contract_function_simulator/noir-structs/option.ts +69 -0
  299. package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
  300. package/src/contract_function_simulator/oracle/interfaces.ts +93 -70
  301. package/src/contract_function_simulator/oracle/note_packing_utils.ts +13 -13
  302. package/src/contract_function_simulator/oracle/oracle.ts +567 -461
  303. package/src/contract_function_simulator/oracle/oracle_registry.ts +904 -0
  304. package/src/contract_function_simulator/oracle/private_execution.ts +5 -73
  305. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +215 -239
  306. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +668 -261
  307. package/src/contract_function_simulator/pick_notes.ts +22 -3
  308. package/src/contract_function_simulator/proxied_contract_data_source.ts +47 -70
  309. package/src/contract_logging.ts +52 -0
  310. package/src/contract_sync/contract_sync_service.ts +189 -0
  311. package/src/contract_sync/helpers.ts +86 -0
  312. package/src/debug/pxe_debug_utils.ts +57 -20
  313. package/src/entrypoints/client/bundle/index.ts +2 -0
  314. package/src/entrypoints/client/bundle/utils.ts +31 -19
  315. package/src/entrypoints/client/lazy/index.ts +2 -0
  316. package/src/entrypoints/client/lazy/utils.ts +33 -21
  317. package/src/entrypoints/pxe_creation_options.ts +18 -2
  318. package/src/entrypoints/server/index.ts +5 -1
  319. package/src/entrypoints/server/utils.ts +46 -45
  320. package/src/error_enriching.ts +7 -15
  321. package/src/events/event_service.ts +83 -41
  322. package/src/events/private_event_filter_validator.ts +24 -6
  323. package/src/hooks/authorize_utility_call.ts +44 -0
  324. package/src/hooks/execution_hooks.ts +48 -0
  325. package/src/hooks/index.ts +7 -0
  326. package/src/job_coordinator/job_coordinator.ts +150 -0
  327. package/src/logs/log_service.ts +181 -313
  328. package/src/messages/message_context_service.ts +45 -0
  329. package/src/notes/note_service.ts +140 -110
  330. package/src/notes_filter.ts +24 -0
  331. package/src/oracle_version.ts +20 -9
  332. package/src/private_kernel/batch_planner.ts +169 -0
  333. package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
  334. package/src/private_kernel/hints/index.ts +2 -2
  335. package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +197 -139
  336. package/src/private_kernel/hints/test_utils.ts +318 -0
  337. package/src/private_kernel/private_kernel_execution_prover.ts +262 -96
  338. package/src/private_kernel/private_kernel_oracle.ts +129 -39
  339. package/src/pxe.ts +552 -310
  340. package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +16 -16
  341. package/src/storage/address_store/index.ts +1 -0
  342. package/src/storage/{anchor_block_data_provider/anchor_block_data_provider.ts → anchor_block_store/anchor_block_store.ts} +10 -2
  343. package/src/storage/anchor_block_store/index.ts +1 -0
  344. package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +22 -0
  345. package/src/storage/backwards_compatibility_tests/__snapshots__/AnchorBlockStore.json +3 -0
  346. package/src/storage/backwards_compatibility_tests/__snapshots__/CapsuleStore.json +16 -0
  347. package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +28 -0
  348. package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +52 -0
  349. package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +46 -0
  350. package/src/storage/backwards_compatibility_tests/__snapshots__/NoteStore.json +36 -0
  351. package/src/storage/backwards_compatibility_tests/__snapshots__/PrivateEventStore.json +44 -0
  352. package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +18 -0
  353. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderAddressBookStore.json +16 -0
  354. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +22 -0
  355. package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +97 -0
  356. package/src/storage/backwards_compatibility_tests/kv_store_snapshot.ts +122 -0
  357. package/src/storage/backwards_compatibility_tests/schema_tests.ts +712 -0
  358. package/src/storage/backwards_compatibility_tests/store_spy.ts +73 -0
  359. package/src/storage/capsule_store/capsule_service.ts +90 -0
  360. package/src/storage/capsule_store/capsule_store.ts +333 -0
  361. package/src/storage/capsule_store/index.ts +2 -0
  362. package/src/storage/contract_store/contract_store.ts +408 -0
  363. package/src/storage/contract_store/index.ts +1 -0
  364. package/src/storage/index.ts +7 -7
  365. package/src/storage/metadata.ts +1 -1
  366. package/src/storage/note_store/index.ts +2 -0
  367. package/src/storage/note_store/note_store.ts +415 -0
  368. package/src/storage/note_store/stored_note.ts +48 -0
  369. package/src/storage/open_pxe_stores.ts +49 -0
  370. package/src/storage/private_event_store/private_event_store.ts +388 -0
  371. package/src/storage/private_event_store/stored_private_event.ts +73 -0
  372. package/src/storage/tagging_store/index.ts +3 -0
  373. package/src/storage/tagging_store/recipient_tagging_store.ts +139 -0
  374. package/src/storage/tagging_store/sender_address_book_store.ts +48 -0
  375. package/src/storage/tagging_store/sender_tagging_store.ts +476 -0
  376. package/src/tagging/constants.ts +10 -3
  377. package/src/tagging/get_all_logs_by_tags.ts +120 -0
  378. package/src/tagging/index.ts +20 -4
  379. package/src/tagging/persist_sender_tagging_index_ranges.ts +57 -0
  380. package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +240 -0
  381. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +4 -4
  382. package/src/tagging/reconcile_tagging_index_ranges.ts +102 -0
  383. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +134 -0
  384. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +66 -0
  385. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +84 -0
  386. package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
  387. package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
  388. package/dest/contract_function_simulator/proxied_node.js +0 -27
  389. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
  390. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
  391. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
  392. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
  393. package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -46
  394. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
  395. package/dest/private_kernel/private_kernel_oracle_impl.js +0 -86
  396. package/dest/public_storage/public_storage_service.d.ts +0 -24
  397. package/dest/public_storage/public_storage_service.d.ts.map +0 -1
  398. package/dest/public_storage/public_storage_service.js +0 -26
  399. package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -11
  400. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +0 -1
  401. package/dest/storage/address_data_provider/index.d.ts +0 -2
  402. package/dest/storage/address_data_provider/index.d.ts.map +0 -1
  403. package/dest/storage/address_data_provider/index.js +0 -1
  404. package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.d.ts +0 -9
  405. package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.d.ts.map +0 -1
  406. package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.js +0 -19
  407. package/dest/storage/anchor_block_data_provider/index.d.ts +0 -2
  408. package/dest/storage/anchor_block_data_provider/index.d.ts.map +0 -1
  409. package/dest/storage/anchor_block_data_provider/index.js +0 -1
  410. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +0 -57
  411. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +0 -1
  412. package/dest/storage/capsule_data_provider/capsule_data_provider.js +0 -146
  413. package/dest/storage/capsule_data_provider/index.d.ts +0 -2
  414. package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
  415. package/dest/storage/capsule_data_provider/index.js +0 -1
  416. package/dest/storage/contract_data_provider/contract_data_provider.d.ts +0 -66
  417. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
  418. package/dest/storage/contract_data_provider/contract_data_provider.js +0 -224
  419. package/dest/storage/contract_data_provider/index.d.ts +0 -2
  420. package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
  421. package/dest/storage/contract_data_provider/index.js +0 -1
  422. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
  423. package/dest/storage/note_data_provider/index.d.ts +0 -3
  424. package/dest/storage/note_data_provider/index.d.ts.map +0 -1
  425. package/dest/storage/note_data_provider/index.js +0 -2
  426. package/dest/storage/note_data_provider/note_data_provider.d.ts +0 -84
  427. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
  428. package/dest/storage/note_data_provider/note_data_provider.js +0 -322
  429. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +0 -51
  430. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +0 -1
  431. package/dest/storage/private_event_data_provider/private_event_data_provider.js +0 -115
  432. package/dest/storage/tagging_data_provider/index.d.ts +0 -3
  433. package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
  434. package/dest/storage/tagging_data_provider/index.js +0 -2
  435. package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.d.ts +0 -31
  436. package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.d.ts.map +0 -1
  437. package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.js +0 -65
  438. package/dest/storage/tagging_data_provider/sender_tagging_data_provider.d.ts +0 -67
  439. package/dest/storage/tagging_data_provider/sender_tagging_data_provider.d.ts.map +0 -1
  440. package/dest/storage/tagging_data_provider/sender_tagging_data_provider.js +0 -196
  441. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +0 -14
  442. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +0 -1
  443. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +0 -99
  444. package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.d.ts +0 -21
  445. package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.d.ts.map +0 -1
  446. package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.js +0 -42
  447. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +0 -14
  448. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +0 -1
  449. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +0 -29
  450. package/dest/tagging/sync/sync_sender_tagging_indexes.d.ts +0 -21
  451. package/dest/tagging/sync/sync_sender_tagging_indexes.d.ts.map +0 -1
  452. package/dest/tagging/sync/utils/get_status_change_of_pending.d.ts +0 -11
  453. package/dest/tagging/sync/utils/get_status_change_of_pending.d.ts.map +0 -1
  454. package/dest/tagging/sync/utils/get_status_change_of_pending.js +0 -32
  455. package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.d.ts +0 -18
  456. package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.d.ts.map +0 -1
  457. package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.js +0 -55
  458. package/dest/tagging/utils.d.ts +0 -18
  459. package/dest/tagging/utils.d.ts.map +0 -1
  460. package/dest/tagging/utils.js +0 -25
  461. package/dest/tree_membership/tree_membership_service.d.ts +0 -52
  462. package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
  463. package/dest/tree_membership/tree_membership_service.js +0 -84
  464. package/src/contract_function_simulator/proxied_node.ts +0 -33
  465. package/src/private_kernel/private_kernel_oracle_impl.ts +0 -133
  466. package/src/public_storage/public_storage_service.ts +0 -33
  467. package/src/storage/address_data_provider/index.ts +0 -1
  468. package/src/storage/anchor_block_data_provider/index.ts +0 -1
  469. package/src/storage/capsule_data_provider/capsule_data_provider.ts +0 -179
  470. package/src/storage/capsule_data_provider/index.ts +0 -1
  471. package/src/storage/contract_data_provider/contract_data_provider.ts +0 -319
  472. package/src/storage/contract_data_provider/index.ts +0 -1
  473. package/src/storage/note_data_provider/index.ts +0 -2
  474. package/src/storage/note_data_provider/note_data_provider.ts +0 -412
  475. package/src/storage/private_event_data_provider/private_event_data_provider.ts +0 -162
  476. package/src/storage/tagging_data_provider/index.ts +0 -2
  477. package/src/storage/tagging_data_provider/recipient_tagging_data_provider.ts +0 -86
  478. package/src/storage/tagging_data_provider/sender_tagging_data_provider.ts +0 -244
  479. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +0 -129
  480. package/src/tagging/recipient_sync/new_recipient_tagging_data_provider.ts +0 -53
  481. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +0 -43
  482. package/src/tagging/sync/sync_sender_tagging_indexes.ts +0 -112
  483. package/src/tagging/sync/utils/get_status_change_of_pending.ts +0 -44
  484. package/src/tagging/sync/utils/load_and_store_new_tagging_indexes.ts +0 -72
  485. package/src/tagging/utils.ts +0 -32
  486. package/src/tree_membership/tree_membership_service.ts +0 -112
  487. /package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.js +0 -0
  488. /package/src/storage/{contract_data_provider → contract_store}/private_functions_tree.ts +0 -0
@@ -0,0 +1,202 @@
1
+ import { MAX_KEY_VALIDATION_REQUESTS_PER_CALL, MAX_KEY_VALIDATION_REQUESTS_PER_TX, MAX_NOTE_HASHES_PER_CALL, MAX_NOTE_HASHES_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIERS_PER_CALL, MAX_NULLIFIERS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_CALL, MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_PRIVATE_LOGS_PER_CALL, MAX_PRIVATE_LOGS_PER_TX } from '@aztec/constants';
2
+ import { makeTuple } from '@aztec/foundation/array';
3
+ import { Fr } from '@aztec/foundation/curves/bn254';
4
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
+ import { ClaimedLengthArray, KeyValidationRequest, KeyValidationRequestAndSeparator, NoteHash, Nullifier, PrivateCircuitPublicInputs, PrivateKernelCircuitPublicInputs, ReadRequest, ScopedKeyValidationRequestAndSeparator, ScopedNoteHash, ScopedNullifier, ScopedReadRequest } from '@aztec/stdlib/kernel';
6
+ import { PrivateLogData, ScopedPrivateLogData } from '@aztec/stdlib/kernel';
7
+ import { PrivateLog } from '@aztec/stdlib/logs';
8
+ import { PrivateCallExecutionResult } from '@aztec/stdlib/tx';
9
+ import { VerificationKeyData } from '@aztec/stdlib/vks';
10
+ const DEFAULT_CONTRACT_ADDRESS = AztecAddress.fromBigInt(987654n);
11
+ /**
12
+ * Builds a ClaimedLengthArray from a list of items, padding to the required size.
13
+ */ function makeClaimed(items, emptyFactory, maxSize) {
14
+ const padded = makeTuple(maxSize, (i)=>items[i] ?? emptyFactory.empty());
15
+ return new ClaimedLengthArray(padded, items.length);
16
+ }
17
+ /** Builder for PrivateKernelCircuitPublicInputs with fluent API for adding side effects. */ export class PrivateKernelCircuitPublicInputsBuilder {
18
+ contractAddress;
19
+ noteHashes;
20
+ nullifiers;
21
+ noteHashReadRequests;
22
+ nullifierReadRequests;
23
+ keyValidationRequests;
24
+ privateLogs;
25
+ nextCounter;
26
+ constructor(contractAddress = DEFAULT_CONTRACT_ADDRESS, startCounter = 1){
27
+ this.contractAddress = contractAddress;
28
+ this.noteHashes = [];
29
+ this.nullifiers = [];
30
+ this.noteHashReadRequests = [];
31
+ this.nullifierReadRequests = [];
32
+ this.keyValidationRequests = [];
33
+ this.privateLogs = [];
34
+ this.nextCounter = startCounter;
35
+ }
36
+ getCounter(sideEffectCounter) {
37
+ if (sideEffectCounter !== undefined) {
38
+ this.nextCounter = sideEffectCounter + 1;
39
+ return sideEffectCounter;
40
+ }
41
+ return this.nextCounter++;
42
+ }
43
+ /** Adds a note hash to the accumulated data. Defaults are generated randomly. */ addNoteHash(opts) {
44
+ const value = opts?.value ?? Fr.random();
45
+ const counter = this.getCounter(opts?.counter);
46
+ const addr = opts?.contractAddress ?? this.contractAddress;
47
+ this.noteHashes.push(new NoteHash(value, counter).scope(addr));
48
+ return this;
49
+ }
50
+ /** Adds a nullifier to the accumulated data. Defaults are generated randomly. */ addNullifier(opts) {
51
+ const value = opts?.value ?? Fr.random();
52
+ const noteHash = opts?.noteHash ?? Fr.ZERO;
53
+ const counter = this.getCounter(opts?.counter);
54
+ const addr = opts?.contractAddress ?? this.contractAddress;
55
+ this.nullifiers.push(new Nullifier(value, noteHash, counter).scope(addr));
56
+ return this;
57
+ }
58
+ /** Adds a pending note hash read request (non-empty contract address, can match a pending note hash). */ addPendingNoteHashReadRequest(opts) {
59
+ const value = opts?.value ?? Fr.random();
60
+ const counter = this.getCounter(opts?.counter);
61
+ const addr = opts?.contractAddress ?? this.contractAddress;
62
+ this.noteHashReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), addr));
63
+ return this;
64
+ }
65
+ /** Adds a settled note hash read request (empty contract address, resolved against the note hash tree). */ addSettledNoteHashReadRequest(opts) {
66
+ const value = opts?.value ?? Fr.random();
67
+ const counter = this.getCounter(opts?.counter);
68
+ this.noteHashReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), AztecAddress.ZERO));
69
+ return this;
70
+ }
71
+ /** Adds a pending nullifier read request (non-empty contract address, can match a pending nullifier). */ addPendingNullifierReadRequest(opts) {
72
+ const value = opts?.value ?? Fr.random();
73
+ const counter = this.getCounter(opts?.counter);
74
+ const addr = opts?.contractAddress ?? this.contractAddress;
75
+ this.nullifierReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), addr));
76
+ return this;
77
+ }
78
+ /** Adds a settled nullifier read request (empty contract address, resolved against the nullifier tree). */ addSettledNullifierReadRequest(opts) {
79
+ const value = opts?.value ?? Fr.random();
80
+ const counter = this.getCounter(opts?.counter);
81
+ this.nullifierReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), AztecAddress.ZERO));
82
+ return this;
83
+ }
84
+ /** Adds a key validation request to validation requests. */ addKeyValidationRequest(opts) {
85
+ const addr = opts?.contractAddress ?? this.contractAddress;
86
+ this.keyValidationRequests.push(new ScopedKeyValidationRequestAndSeparator(new KeyValidationRequestAndSeparator(new KeyValidationRequest(Fr.random(), Fr.random()), Fr.random()), addr));
87
+ return this;
88
+ }
89
+ /** Adds a private log to the accumulated data. Defaults are generated randomly. */ addPrivateLog(opts) {
90
+ const noteHashCounter = opts?.noteHashCounter ?? 0;
91
+ const counter = this.getCounter(opts?.counter);
92
+ const addr = opts?.contractAddress ?? this.contractAddress;
93
+ this.privateLogs.push(new ScopedPrivateLogData(new PrivateLogData(PrivateLog.empty(), noteHashCounter, counter), addr));
94
+ return this;
95
+ }
96
+ /** Builds the PrivateKernelCircuitPublicInputs with all added side effects. */ build() {
97
+ const publicInputs = PrivateKernelCircuitPublicInputs.empty();
98
+ publicInputs.end.noteHashes = makeClaimed(this.noteHashes, ScopedNoteHash, MAX_NOTE_HASHES_PER_TX);
99
+ publicInputs.end.nullifiers = makeClaimed(this.nullifiers, ScopedNullifier, MAX_NULLIFIERS_PER_TX);
100
+ publicInputs.end.privateLogs = makeClaimed(this.privateLogs, ScopedPrivateLogData, MAX_PRIVATE_LOGS_PER_TX);
101
+ publicInputs.validationRequests.noteHashReadRequests = makeClaimed(this.noteHashReadRequests, ScopedReadRequest, MAX_NOTE_HASH_READ_REQUESTS_PER_TX);
102
+ publicInputs.validationRequests.nullifierReadRequests = makeClaimed(this.nullifierReadRequests, ScopedReadRequest, MAX_NULLIFIER_READ_REQUESTS_PER_TX);
103
+ publicInputs.validationRequests.scopedKeyValidationRequestsAndSeparators = makeClaimed(this.keyValidationRequests, ScopedKeyValidationRequestAndSeparator, MAX_KEY_VALIDATION_REQUESTS_PER_TX);
104
+ return publicInputs;
105
+ }
106
+ }
107
+ /** Builder for PrivateCircuitPublicInputs (call-level) with fluent API for adding side effects. */ export class PrivateCircuitPublicInputsBuilder {
108
+ contractAddress;
109
+ noteHashes;
110
+ nullifiers;
111
+ noteHashReadRequests;
112
+ nullifierReadRequests;
113
+ keyValidationRequests;
114
+ privateLogs;
115
+ nextCounter;
116
+ constructor(contractAddress = DEFAULT_CONTRACT_ADDRESS, startCounter = 1){
117
+ this.contractAddress = contractAddress;
118
+ this.noteHashes = [];
119
+ this.nullifiers = [];
120
+ this.noteHashReadRequests = [];
121
+ this.nullifierReadRequests = [];
122
+ this.keyValidationRequests = [];
123
+ this.privateLogs = [];
124
+ this.nextCounter = startCounter;
125
+ }
126
+ getCounter(sideEffectCounter) {
127
+ if (sideEffectCounter !== undefined) {
128
+ this.nextCounter = sideEffectCounter + 1;
129
+ return sideEffectCounter;
130
+ }
131
+ return this.nextCounter++;
132
+ }
133
+ /** Adds a note hash. Defaults are generated randomly. */ addNoteHash(opts) {
134
+ const value = opts?.value ?? Fr.random();
135
+ const counter = this.getCounter(opts?.counter);
136
+ this.noteHashes.push(new NoteHash(value, counter));
137
+ return this;
138
+ }
139
+ /** Adds a nullifier. Defaults are generated randomly. */ addNullifier(opts) {
140
+ const value = opts?.value ?? Fr.random();
141
+ const noteHash = opts?.noteHash ?? Fr.ZERO;
142
+ const counter = this.getCounter(opts?.counter);
143
+ this.nullifiers.push(new Nullifier(value, noteHash, counter));
144
+ return this;
145
+ }
146
+ /** Adds a pending note hash read request (non-empty contract address, can match a pending note hash). */ addPendingNoteHashReadRequest(opts) {
147
+ const value = opts?.value ?? Fr.random();
148
+ const counter = this.getCounter(opts?.counter);
149
+ this.noteHashReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), this.contractAddress));
150
+ return this;
151
+ }
152
+ /** Adds a settled note hash read request (empty contract address, resolved against the note hash tree). */ addSettledNoteHashReadRequest(opts) {
153
+ const value = opts?.value ?? Fr.random();
154
+ const counter = this.getCounter(opts?.counter);
155
+ this.noteHashReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), AztecAddress.ZERO));
156
+ return this;
157
+ }
158
+ /** Adds a pending nullifier read request (non-empty contract address, can match a pending nullifier). */ addPendingNullifierReadRequest(opts) {
159
+ const value = opts?.value ?? Fr.random();
160
+ const counter = this.getCounter(opts?.counter);
161
+ this.nullifierReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), this.contractAddress));
162
+ return this;
163
+ }
164
+ /** Adds a settled nullifier read request (empty contract address, resolved against the nullifier tree). */ addSettledNullifierReadRequest(opts) {
165
+ const value = opts?.value ?? Fr.random();
166
+ const counter = this.getCounter(opts?.counter);
167
+ this.nullifierReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), AztecAddress.ZERO));
168
+ return this;
169
+ }
170
+ /** Adds a key validation request. */ addKeyValidationRequest() {
171
+ this.keyValidationRequests.push(new KeyValidationRequestAndSeparator(new KeyValidationRequest(Fr.random(), Fr.random()), Fr.random()));
172
+ return this;
173
+ }
174
+ /** Adds a private log. Defaults are generated randomly. */ addPrivateLog(opts) {
175
+ const noteHashCounter = opts?.noteHashCounter ?? 0;
176
+ const counter = this.getCounter(opts?.counter);
177
+ this.privateLogs.push(new PrivateLogData(PrivateLog.empty(), noteHashCounter, counter));
178
+ return this;
179
+ }
180
+ /** Builds the PrivateCircuitPublicInputs with all added side effects. */ build() {
181
+ const publicInputs = PrivateCircuitPublicInputs.empty();
182
+ publicInputs.callContext.contractAddress = this.contractAddress;
183
+ publicInputs.noteHashes = makeClaimed(this.noteHashes, NoteHash, MAX_NOTE_HASHES_PER_CALL);
184
+ publicInputs.nullifiers = makeClaimed(this.nullifiers, Nullifier, MAX_NULLIFIERS_PER_CALL);
185
+ publicInputs.privateLogs = makeClaimed(this.privateLogs, PrivateLogData, MAX_PRIVATE_LOGS_PER_CALL);
186
+ publicInputs.noteHashReadRequests = makeClaimed(this.noteHashReadRequests, ScopedReadRequest, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL);
187
+ publicInputs.nullifierReadRequests = makeClaimed(this.nullifierReadRequests, ScopedReadRequest, MAX_NULLIFIER_READ_REQUESTS_PER_CALL);
188
+ publicInputs.keyValidationRequestsAndSeparators = makeClaimed(this.keyValidationRequests, KeyValidationRequestAndSeparator, MAX_KEY_VALIDATION_REQUESTS_PER_CALL);
189
+ return publicInputs;
190
+ }
191
+ }
192
+ /** Wraps a PrivateKernelCircuitPublicInputs in a PrivateKernelSimulateOutput. */ export function makeKernelOutput(publicInputs) {
193
+ return {
194
+ publicInputs: publicInputs ?? PrivateKernelCircuitPublicInputs.empty(),
195
+ verificationKey: VerificationKeyData.empty(),
196
+ outputWitness: new Map(),
197
+ bytecode: Buffer.from([])
198
+ };
199
+ }
200
+ /** Wraps a PrivateCircuitPublicInputs in a PrivateCallExecutionResult. */ export function makeExecutionResult(publicInputs) {
201
+ return new PrivateCallExecutionResult(Buffer.alloc(0), Buffer.alloc(0), new Map(), publicInputs ?? PrivateCircuitPublicInputs.empty(), [], new Map(), [], [], [], [], []);
202
+ }
@@ -1,3 +1,4 @@
1
+ import { type LoggerBindings } from '@aztec/foundation/log';
1
2
  import type { PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
2
3
  import { type PrivateKernelExecutionProofOutput, type PrivateKernelTailCircuitPublicInputs } from '@aztec/stdlib/kernel';
3
4
  import { type PrivateExecutionResult, TxRequest } from '@aztec/stdlib/tx';
@@ -17,8 +18,9 @@ export declare class PrivateKernelExecutionProver {
17
18
  private oracle;
18
19
  private proofCreator;
19
20
  private fakeProofs;
21
+ private maxBatchSize;
20
22
  private log;
21
- constructor(oracle: PrivateKernelOracle, proofCreator: PrivateKernelProver, fakeProofs?: boolean);
23
+ constructor(oracle: PrivateKernelOracle, proofCreator: PrivateKernelProver, fakeProofs?: boolean, bindings?: LoggerBindings, maxBatchSize?: number);
22
24
  /**
23
25
  * Generate a proof for a given transaction request and execution result.
24
26
  * The function iterates through the nested executions in the execution result, creates private call data,
@@ -39,6 +41,9 @@ export declare class PrivateKernelExecutionProver {
39
41
  */
40
42
  private ensurePublicInputsMatch;
41
43
  private getVkData;
44
+ private consumeNextApp;
45
+ private prefetchUpdatedClassIdHints;
42
46
  private createPrivateCallData;
47
+ private runBatchedKernel;
43
48
  }
44
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF0ZV9rZXJuZWxfZXhlY3V0aW9uX3Byb3Zlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3ByaXZhdGVfa2VybmVsL3ByaXZhdGVfa2VybmVsX2V4ZWN1dGlvbl9wcm92ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBUUEsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUMzRSxPQUFPLEVBUUwsS0FBSyxpQ0FBaUMsRUFLdEMsS0FBSyxvQ0FBb0MsRUFFMUMsTUFBTSxzQkFBc0IsQ0FBQztBQUU5QixPQUFPLEVBRUwsS0FBSyxzQkFBc0IsRUFDM0IsU0FBUyxFQUlWLE1BQU0sa0JBQWtCLENBQUM7QUFJMUIsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQztBQVN0RSxNQUFNLFdBQVcsa0NBQWtDO0lBQ2pELFFBQVEsRUFBRSxPQUFPLENBQUM7SUFDbEIsa0JBQWtCLEVBQUUsT0FBTyxDQUFDO0lBQzVCLFdBQVcsRUFBRSxPQUFPLEdBQUcsaUJBQWlCLEdBQUcsTUFBTSxHQUFHLE1BQU0sQ0FBQztDQUM1RDtBQUVEOzs7OztHQUtHO0FBQ0gscUJBQWEsNEJBQTRCO0lBSXJDLE9BQU8sQ0FBQyxNQUFNO0lBQ2QsT0FBTyxDQUFDLFlBQVk7SUFDcEIsT0FBTyxDQUFDLFVBQVU7SUFMcEIsT0FBTyxDQUFDLEdBQUcsQ0FBdUQ7SUFFbEUsWUFDVSxNQUFNLEVBQUUsbUJBQW1CLEVBQzNCLFlBQVksRUFBRSxtQkFBbUIsRUFDakMsVUFBVSxVQUFRLEVBQ3hCO0lBRUo7Ozs7Ozs7Ozs7T0FVRztJQUNHLGdCQUFnQixDQUNwQixTQUFTLEVBQUUsU0FBUyxFQUNwQixlQUFlLEVBQUUsc0JBQXNCLEVBQ3ZDLEVBQUUsUUFBUSxFQUFFLGtCQUFrQixFQUFFLFdBQVcsRUFBRSxHQUFFLGtDQUk5QyxHQUNBLE9BQU8sQ0FBQyxpQ0FBaUMsQ0FBQyxvQ0FBb0MsQ0FBQyxDQUFDLENBcVJsRjtJQUVEOzs7OztPQUtHO0lBQ0gsT0FBTyxDQUFDLHVCQUF1QjtZQW9CakIsU0FBUztZQVNULHFCQUFxQjtDQStCcEMifQ==
49
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF0ZV9rZXJuZWxfZXhlY3V0aW9uX3Byb3Zlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3ByaXZhdGVfa2VybmVsL3ByaXZhdGVfa2VybmVsX2V4ZWN1dGlvbl9wcm92ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBSUEsT0FBTyxFQUFlLEtBQUssY0FBYyxFQUFnQixNQUFNLHVCQUF1QixDQUFDO0FBTXZGLE9BQU8sS0FBSyxFQUFFLG1CQUFtQixFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDM0UsT0FBTyxFQVFMLEtBQUssaUNBQWlDLEVBU3RDLEtBQUssb0NBQW9DLEVBRzFDLE1BQU0sc0JBQXNCLENBQUM7QUFFOUIsT0FBTyxFQUVMLEtBQUssc0JBQXNCLEVBQzNCLFNBQVMsRUFJVixNQUFNLGtCQUFrQixDQUFDO0FBTTFCLE9BQU8sS0FBSyxFQUFFLG1CQUFtQixFQUFFLE1BQU0sNEJBQTRCLENBQUM7QUFTdEUsTUFBTSxXQUFXLGtDQUFrQztJQUNqRCxRQUFRLEVBQUUsT0FBTyxDQUFDO0lBQ2xCLGtCQUFrQixFQUFFLE9BQU8sQ0FBQztJQUM1QixXQUFXLEVBQUUsT0FBTyxHQUFHLGlCQUFpQixHQUFHLE1BQU0sR0FBRyxNQUFNLENBQUM7Q0FDNUQ7QUFFRDs7Ozs7R0FLRztBQUNILHFCQUFhLDRCQUE0QjtJQUlyQyxPQUFPLENBQUMsTUFBTTtJQUNkLE9BQU8sQ0FBQyxZQUFZO0lBQ3BCLE9BQU8sQ0FBQyxVQUFVO0lBRWxCLE9BQU8sQ0FBQyxZQUFZO0lBUHRCLE9BQU8sQ0FBQyxHQUFHLENBQVM7SUFFcEIsWUFDVSxNQUFNLEVBQUUsbUJBQW1CLEVBQzNCLFlBQVksRUFBRSxtQkFBbUIsRUFDakMsVUFBVSxVQUFRLEVBQzFCLFFBQVEsQ0FBQyxFQUFFLGNBQWMsRUFDakIsWUFBWSxHQUFFLE1BQTRCLEVBR25EO0lBRUQ7Ozs7Ozs7Ozs7T0FVRztJQUNHLGdCQUFnQixDQUNwQixTQUFTLEVBQUUsU0FBUyxFQUNwQixlQUFlLEVBQUUsc0JBQXNCLEVBQ3ZDLEVBQUUsUUFBUSxFQUFFLGtCQUFrQixFQUFFLFdBQVcsRUFBRSxHQUFFLGtDQUk5QyxHQUNBLE9BQU8sQ0FBQyxpQ0FBaUMsQ0FBQyxvQ0FBb0MsQ0FBQyxDQUFDLENBb09sRjtJQUVEOzs7OztPQUtHO0lBQ0gsT0FBTyxDQUFDLHVCQUF1QjtZQW9CakIsU0FBUztZQWNULGNBQWM7WUE0QmQsMkJBQTJCO1lBaUIzQixxQkFBcUI7WUF1Q3JCLGdCQUFnQjtDQWdKL0IifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"private_kernel_execution_prover.d.ts","sourceRoot":"","sources":["../../src/private_kernel/private_kernel_execution_prover.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAQL,KAAK,iCAAiC,EAKtC,KAAK,oCAAoC,EAE1C,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAEL,KAAK,sBAAsB,EAC3B,SAAS,EAIV,MAAM,kBAAkB,CAAC;AAI1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAStE,MAAM,WAAW,kCAAkC;IACjD,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,WAAW,EAAE,OAAO,GAAG,iBAAiB,GAAG,MAAM,GAAG,MAAM,CAAC;CAC5D;AAED;;;;;GAKG;AACH,qBAAa,4BAA4B;IAIrC,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,UAAU;IALpB,OAAO,CAAC,GAAG,CAAuD;IAElE,YACU,MAAM,EAAE,mBAAmB,EAC3B,YAAY,EAAE,mBAAmB,EACjC,UAAU,UAAQ,EACxB;IAEJ;;;;;;;;;;OAUG;IACG,gBAAgB,CACpB,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,sBAAsB,EACvC,EAAE,QAAQ,EAAE,kBAAkB,EAAE,WAAW,EAAE,GAAE,kCAI9C,GACA,OAAO,CAAC,iCAAiC,CAAC,oCAAoC,CAAC,CAAC,CAqRlF;IAED;;;;;OAKG;IACH,OAAO,CAAC,uBAAuB;YAoBjB,SAAS;YAST,qBAAqB;CA+BpC"}
1
+ {"version":3,"file":"private_kernel_execution_prover.d.ts","sourceRoot":"","sources":["../../src/private_kernel/private_kernel_execution_prover.ts"],"names":[],"mappings":"AAIA,OAAO,EAAe,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAMvF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAQL,KAAK,iCAAiC,EAStC,KAAK,oCAAoC,EAG1C,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAEL,KAAK,sBAAsB,EAC3B,SAAS,EAIV,MAAM,kBAAkB,CAAC;AAM1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAStE,MAAM,WAAW,kCAAkC;IACjD,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,WAAW,EAAE,OAAO,GAAG,iBAAiB,GAAG,MAAM,GAAG,MAAM,CAAC;CAC5D;AAED;;;;;GAKG;AACH,qBAAa,4BAA4B;IAIrC,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,UAAU;IAElB,OAAO,CAAC,YAAY;IAPtB,OAAO,CAAC,GAAG,CAAS;IAEpB,YACU,MAAM,EAAE,mBAAmB,EAC3B,YAAY,EAAE,mBAAmB,EACjC,UAAU,UAAQ,EAC1B,QAAQ,CAAC,EAAE,cAAc,EACjB,YAAY,GAAE,MAA4B,EAGnD;IAED;;;;;;;;;;OAUG;IACG,gBAAgB,CACpB,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,sBAAsB,EACvC,EAAE,QAAQ,EAAE,kBAAkB,EAAE,WAAW,EAAE,GAAE,kCAI9C,GACA,OAAO,CAAC,iCAAiC,CAAC,oCAAoC,CAAC,CAAC,CAoOlF;IAED;;;;;OAKG;IACH,OAAO,CAAC,uBAAuB;YAoBjB,SAAS;YAcT,cAAc;YA4Bd,2BAA2B;YAiB3B,qBAAqB;YAuCrB,gBAAgB;CAgJ/B"}
@@ -1,3 +1,5 @@
1
+ import { MAX_APPS_PER_KERNEL } from '@aztec/constants';
2
+ import { uniqueBy } from '@aztec/foundation/collection';
1
3
  import { vkAsFieldsMegaHonk } from '@aztec/foundation/crypto/keys';
2
4
  import { Fr } from '@aztec/foundation/curves/bn254';
3
5
  import { createLogger } from '@aztec/foundation/log';
@@ -6,11 +8,13 @@ import { Timer } from '@aztec/foundation/timer';
6
8
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
7
9
  import { ProtocolContractsList } from '@aztec/protocol-contracts';
8
10
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
9
- import { HidingKernelToPublicPrivateInputs, HidingKernelToRollupPrivateInputs, PaddedSideEffectAmounts, PrivateCallData, PrivateKernelCircuitPublicInputs, PrivateKernelData, PrivateKernelInitCircuitPrivateInputs, PrivateKernelInnerCircuitPrivateInputs, PrivateKernelTailCircuitPrivateInputs, PrivateVerificationKeyHints } from '@aztec/stdlib/kernel';
11
+ import { HidingKernelToPublicPrivateInputs, HidingKernelToRollupPrivateInputs, PaddedSideEffectAmounts, PrivateCallData, PrivateKernelCircuitPublicInputs, PrivateKernelData, PrivateKernelInit2CircuitPrivateInputs, PrivateKernelInit3CircuitPrivateInputs, PrivateKernelInitCircuitPrivateInputs, PrivateKernelInner2CircuitPrivateInputs, PrivateKernelInner3CircuitPrivateInputs, PrivateKernelInnerCircuitPrivateInputs, PrivateKernelTailCircuitPrivateInputs, PrivateVerificationKeyHints } from '@aztec/stdlib/kernel';
10
12
  import { ChonkProof } from '@aztec/stdlib/proofs';
11
- import { collectNoteHashLeafIndexMap, collectNoteHashNullifierCounterMap, getFinalMinRevertibleSideEffectCounter } from '@aztec/stdlib/tx';
13
+ import { collectNested, collectNoteHashNullifierCounterMap, getFinalMinRevertibleSideEffectCounter } from '@aztec/stdlib/tx';
12
14
  import { VerificationKeyAsFields, VerificationKeyData, VkData } from '@aztec/stdlib/vks';
13
- import { PrivateKernelResetPrivateInputsBuilder } from './hints/build_private_kernel_reset_private_inputs.js';
15
+ import { BatchPlanner } from './batch_planner.js';
16
+ import { computeTxExpirationTimestamp } from './hints/compute_tx_expiration_timestamp.js';
17
+ import { PrivateKernelResetPrivateInputsBuilder } from './hints/private_kernel_reset_private_inputs_builder.js';
14
18
  const NULL_SIMULATE_OUTPUT = {
15
19
  publicInputs: PrivateKernelCircuitPublicInputs.empty(),
16
20
  verificationKey: VerificationKeyData.empty(),
@@ -26,12 +30,14 @@ const NULL_SIMULATE_OUTPUT = {
26
30
  oracle;
27
31
  proofCreator;
28
32
  fakeProofs;
33
+ maxBatchSize;
29
34
  log;
30
- constructor(oracle, proofCreator, fakeProofs = false){
35
+ constructor(oracle, proofCreator, fakeProofs = false, bindings, maxBatchSize = MAX_APPS_PER_KERNEL){
31
36
  this.oracle = oracle;
32
37
  this.proofCreator = proofCreator;
33
38
  this.fakeProofs = fakeProofs;
34
- this.log = createLogger('pxe:private-kernel-execution-prover');
39
+ this.maxBatchSize = maxBatchSize;
40
+ this.log = createLogger('pxe:private-kernel-execution-prover', bindings);
35
41
  }
36
42
  /**
37
43
  * Generate a proof for a given transaction request and execution result.
@@ -60,16 +66,21 @@ const NULL_SIMULATE_OUTPUT = {
60
66
  let firstIteration = true;
61
67
  let output = NULL_SIMULATE_OUTPUT;
62
68
  const executionSteps = [];
63
- const noteHashLeafIndexMap = collectNoteHashLeafIndexMap(executionResult);
64
69
  const noteHashNullifierCounterMap = collectNoteHashNullifierCounterMap(executionResult);
65
70
  const minRevertibleSideEffectCounter = getFinalMinRevertibleSideEffectCounter(executionResult);
66
71
  const splitCounter = isPrivateOnlyTx ? 0 : minRevertibleSideEffectCounter;
72
+ // Each kernel iteration absorbs up to `maxBatchSize` apps. The planner walks the upcoming
73
+ // apps and decides where the next reset must fall by using an accumulator and
74
+ // reusing the existing single-app `needsReset()` check.
75
+ const planner = new BatchPlanner(noteHashNullifierCounterMap, splitCounter, this.maxBatchSize);
76
+ const updatedClassIdHintsMap = await this.prefetchUpdatedClassIdHints(executionResult);
67
77
  while(executionStack.length){
68
78
  if (!firstIteration) {
69
79
  let resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, executionStack, noteHashNullifierCounterMap, splitCounter);
70
80
  while(resetBuilder.needsReset()){
81
+ // Inner reset: without siloing.
71
82
  const witgenTimer = new Timer();
72
- const privateInputs = await resetBuilder.build(this.oracle, noteHashLeafIndexMap);
83
+ const privateInputs = await resetBuilder.build(this.oracle);
73
84
  output = generateWitnesses ? await this.proofCreator.generateResetOutput(privateInputs) : await this.proofCreator.simulateReset(privateInputs);
74
85
  executionSteps.push({
75
86
  functionName: 'private_kernel_reset',
@@ -83,61 +94,37 @@ const NULL_SIMULATE_OUTPUT = {
83
94
  resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, executionStack, noteHashNullifierCounterMap, splitCounter);
84
95
  }
85
96
  }
86
- const currentExecution = executionStack.pop();
87
- executionStack.push(...[
88
- ...currentExecution.nestedExecutionResults
89
- ].reverse());
90
- const functionName = await this.oracle.getDebugFunctionName(currentExecution.publicInputs.callContext.contractAddress, currentExecution.publicInputs.callContext.functionSelector);
91
- executionSteps.push({
92
- functionName: functionName,
93
- bytecode: currentExecution.acir,
94
- witness: currentExecution.partialWitness,
95
- vk: currentExecution.vk,
96
- timings: {
97
- witgen: currentExecution.profileResult?.timings.witgen ?? 0,
98
- oracles: currentExecution.profileResult?.timings.oracles
99
- }
100
- });
101
- const privateCallData = await this.createPrivateCallData(currentExecution);
102
- if (firstIteration) {
103
- const witgenTimer = new Timer();
104
- const proofInput = new PrivateKernelInitCircuitPrivateInputs(txRequest, getVKTreeRoot(), ProtocolContractsList, privateCallData, isPrivateOnlyTx, executionResult.firstNullifier, minRevertibleSideEffectCounter);
105
- this.log.debug(`Calling private kernel init with isPrivateOnly ${isPrivateOnlyTx} and firstNullifierHint ${proofInput.firstNullifierHint}`);
106
- pushTestData('private-kernel-inputs-init', proofInput);
107
- output = generateWitnesses ? await this.proofCreator.generateInitOutput(proofInput) : await this.proofCreator.simulateInit(proofInput);
108
- executionSteps.push({
109
- functionName: 'private_kernel_init',
110
- bytecode: output.bytecode,
111
- witness: output.outputWitness,
112
- vk: output.verificationKey.keyAsBytes,
113
- timings: {
114
- witgen: witgenTimer.ms()
115
- }
116
- });
117
- } else {
118
- const witgenTimer = new Timer();
119
- const vkData = await this.getVkData(output.verificationKey);
120
- const previousKernelData = new PrivateKernelData(output.publicInputs, vkData);
121
- const proofInput = new PrivateKernelInnerCircuitPrivateInputs(previousKernelData, privateCallData);
122
- pushTestData('private-kernel-inputs-inner', proofInput);
123
- output = generateWitnesses ? await this.proofCreator.generateInnerOutput(proofInput) : await this.proofCreator.simulateInner(proofInput);
124
- executionSteps.push({
125
- functionName: 'private_kernel_inner',
126
- bytecode: output.bytecode,
127
- witness: output.outputWitness,
128
- vk: output.verificationKey.keyAsBytes,
129
- timings: {
130
- witgen: witgenTimer.ms()
131
- }
132
- });
97
+ const batchSize = planner.decideBatchSize(output.publicInputs, executionStack);
98
+ const apps = [];
99
+ for(let i = 0; i < batchSize; i++){
100
+ apps.push(await this.consumeNextApp(executionStack, executionSteps, updatedClassIdHintsMap));
133
101
  }
102
+ output = await this.runBatchedKernel({
103
+ apps,
104
+ firstIteration,
105
+ previousOutput: output,
106
+ txRequest,
107
+ isPrivateOnlyTx,
108
+ firstNullifierHint: executionResult.firstNullifier,
109
+ minRevertibleSideEffectCounter,
110
+ executionSteps,
111
+ generateWitnesses
112
+ });
134
113
  firstIteration = false;
135
114
  }
136
- // Reset.
137
- let resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, [], noteHashNullifierCounterMap, splitCounter);
138
- while(resetBuilder.needsReset()){
115
+ // Final reset: include siloing of note hashes, nullifiers and private logs.
116
+ const finalResetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, [], noteHashNullifierCounterMap, splitCounter);
117
+ if (!finalResetBuilder.needsReset()) {
118
+ // The final reset must be performed exactly once, because each tx has at least one nullifier that requires
119
+ // siloing, and siloing cannot be done multiple times.
120
+ // While, in theory, it might be possible to silo note hashes first and then run another reset to silo nullifiers
121
+ // and/or private logs, we currently don't have standalone dimensions for the arrays that require siloing. As a
122
+ // result, all necessary siloing must be done together in a single reset.
123
+ // Refer to the possible combinations of dimensions in private_kernel_reset_config.json.
124
+ throw new Error('Nothing to reset for the final reset.');
125
+ } else {
139
126
  const witgenTimer = new Timer();
140
- const privateInputs = await resetBuilder.build(this.oracle, noteHashLeafIndexMap);
127
+ const privateInputs = await finalResetBuilder.build(this.oracle);
141
128
  output = generateWitnesses ? await this.proofCreator.generateResetOutput(privateInputs) : await this.proofCreator.simulateReset(privateInputs);
142
129
  executionSteps.push({
143
130
  functionName: 'private_kernel_reset',
@@ -148,7 +135,6 @@ const NULL_SIMULATE_OUTPUT = {
148
135
  witgen: witgenTimer.ms()
149
136
  }
150
137
  });
151
- resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, [], noteHashNullifierCounterMap, splitCounter);
152
138
  }
153
139
  if (output.publicInputs.feePayer.isZero() && skipFeeEnforcement) {
154
140
  if (!skipProofGeneration) {
@@ -162,14 +148,10 @@ const NULL_SIMULATE_OUTPUT = {
162
148
  this.log.debug(`Calling private kernel tail with hwm ${previousKernelData.publicInputs.minRevertibleSideEffectCounter}`);
163
149
  // TODO: Enable padding once we better understand the final amounts to pad to.
164
150
  const paddedSideEffectAmounts = PaddedSideEffectAmounts.empty();
165
- // Use the aggregated includeByTimestamp set throughout the tx execution.
166
- // TODO: Call `computeTxIncludeByTimestamp` to round the value down and reduce precision, improving privacy.
167
- const includeByTimestampUpperBound = previousKernelData.publicInputs.includeByTimestamp;
168
- const anchorBlockTimestamp = previousKernelData.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp;
169
- if (includeByTimestampUpperBound <= anchorBlockTimestamp) {
170
- throw new Error(`Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${includeByTimestampUpperBound}.`);
171
- }
172
- const privateInputs = new PrivateKernelTailCircuitPrivateInputs(previousKernelData, paddedSideEffectAmounts, includeByTimestampUpperBound);
151
+ // Round the aggregated expirationTimestamp down to reduce precision and avoid leaking which private
152
+ // functions were called via their exact expiration offsets.
153
+ const expirationTimestampUpperBound = computeTxExpirationTimestamp(previousKernelData.publicInputs);
154
+ const privateInputs = new PrivateKernelTailCircuitPrivateInputs(previousKernelData, paddedSideEffectAmounts, expirationTimestampUpperBound);
173
155
  const witgenTimer = new Timer();
174
156
  const tailOutput = generateWitnesses ? await this.proofCreator.generateTailOutput(privateInputs) : await this.proofCreator.simulateTail(privateInputs);
175
157
  executionSteps.push({
@@ -262,14 +244,48 @@ const NULL_SIMULATE_OUTPUT = {
262
244
  const previousVkMembershipWitness = await this.oracle.getVkMembershipWitness(verificationKey.keyAsFields);
263
245
  return new VkData(verificationKey, Number(previousVkMembershipWitness.leafIndex), previousVkMembershipWitness.siblingPath);
264
246
  }
265
- async createPrivateCallData({ publicInputs, vk: vkAsBuffer }) {
247
+ /**
248
+ * Pops the next app off the execution stack, pushes its nested calls back on (preserving DFS
249
+ * order), records the app's execution step, and returns its constructed `PrivateCallData`.
250
+ * Caller is responsible for ensuring the stack is non-empty.
251
+ */ async consumeNextApp(executionStack, executionSteps, updatedClassIdHintsMap) {
252
+ const next = executionStack.pop();
253
+ executionStack.push(...[
254
+ ...next.nestedExecutionResults
255
+ ].reverse());
256
+ const functionName = await this.oracle.getDebugFunctionName(next.publicInputs.callContext.contractAddress, next.publicInputs.callContext.functionSelector);
257
+ executionSteps.push({
258
+ functionName: functionName,
259
+ bytecode: next.acir,
260
+ witness: next.partialWitness,
261
+ vk: next.vk,
262
+ timings: {
263
+ witgen: next.profileResult?.timings.witgen ?? 0,
264
+ oracles: next.profileResult?.timings.oracles
265
+ }
266
+ });
267
+ return await this.createPrivateCallData(next, updatedClassIdHintsMap);
268
+ }
269
+ /** Prefetches updated class id hints for all unique contracts in the execution tree in parallel. */ async prefetchUpdatedClassIdHints(executionResult) {
270
+ const allAddresses = collectNested([
271
+ executionResult.entrypoint
272
+ ], (exec)=>[
273
+ exec.publicInputs.callContext.contractAddress
274
+ ]);
275
+ const uniqueAddresses = uniqueBy(allAddresses, (a)=>a.toString());
276
+ return new Map(await Promise.all(uniqueAddresses.map(async (addr)=>[
277
+ addr.toString(),
278
+ await this.oracle.getUpdatedClassIdHints(addr)
279
+ ])));
280
+ }
281
+ async createPrivateCallData({ publicInputs, vk: vkAsBuffer }, updatedClassIdHintsMap) {
266
282
  const { contractAddress, functionSelector } = publicInputs.callContext;
267
283
  const vkAsFields = await vkAsFieldsMegaHonk(vkAsBuffer);
268
284
  const vk = await VerificationKeyAsFields.fromKey(vkAsFields);
269
285
  const { currentContractClassId, publicKeys, saltedInitializationHash } = await this.oracle.getContractAddressPreimage(contractAddress);
270
286
  const functionLeafMembershipWitness = await this.oracle.getFunctionMembershipWitness(currentContractClassId, functionSelector);
271
287
  const { artifactHash: contractClassArtifactHash, publicBytecodeCommitment: contractClassPublicBytecodeCommitment } = await this.oracle.getContractClassIdPreimage(currentContractClassId);
272
- const updatedClassIdHints = await this.oracle.getUpdatedClassIdHints(contractAddress);
288
+ const updatedClassIdHints = updatedClassIdHintsMap.get(contractAddress.toString());
273
289
  return PrivateCallData.from({
274
290
  publicInputs,
275
291
  vk,
@@ -283,4 +299,88 @@ const NULL_SIMULATE_OUTPUT = {
283
299
  })
284
300
  });
285
301
  }
302
+ /**
303
+ * Runs one batched kernel iteration. Picks the right circuit variant based on whether this is
304
+ * the first iteration or a later one and the size of the batch.
305
+ */ async runBatchedKernel(args) {
306
+ const { apps, firstIteration, previousOutput, txRequest, isPrivateOnlyTx, firstNullifierHint, minRevertibleSideEffectCounter, executionSteps, generateWitnesses } = args;
307
+ const witgenTimer = new Timer();
308
+ let output;
309
+ let functionName;
310
+ if (firstIteration) {
311
+ const vkTreeRoot = getVKTreeRoot();
312
+ switch(apps.length){
313
+ case 1:
314
+ {
315
+ const proofInput = new PrivateKernelInitCircuitPrivateInputs(txRequest, vkTreeRoot, ProtocolContractsList, apps[0], isPrivateOnlyTx, firstNullifierHint, minRevertibleSideEffectCounter);
316
+ this.log.debug(`Calling private kernel init with isPrivateOnly ${isPrivateOnlyTx} and firstNullifierHint ${proofInput.firstNullifierHint}`);
317
+ pushTestData('private-kernel-inputs-init', proofInput);
318
+ output = generateWitnesses ? await this.proofCreator.generateInitOutput(proofInput) : await this.proofCreator.simulateInit(proofInput);
319
+ functionName = 'private_kernel_init';
320
+ break;
321
+ }
322
+ case 2:
323
+ {
324
+ const proofInput = new PrivateKernelInit2CircuitPrivateInputs(txRequest, vkTreeRoot, ProtocolContractsList, apps[0], apps[1], isPrivateOnlyTx, firstNullifierHint, minRevertibleSideEffectCounter);
325
+ this.log.debug(`Calling private kernel init_2 with isPrivateOnly ${isPrivateOnlyTx} and firstNullifierHint ${proofInput.firstNullifierHint}`);
326
+ pushTestData('private-kernel-inputs-init-2', proofInput);
327
+ output = generateWitnesses ? await this.proofCreator.generateInit2Output(proofInput) : await this.proofCreator.simulateInit2(proofInput);
328
+ functionName = 'private_kernel_init_2';
329
+ break;
330
+ }
331
+ case 3:
332
+ {
333
+ const proofInput = new PrivateKernelInit3CircuitPrivateInputs(txRequest, vkTreeRoot, ProtocolContractsList, apps[0], apps[1], apps[2], isPrivateOnlyTx, firstNullifierHint, minRevertibleSideEffectCounter);
334
+ this.log.debug(`Calling private kernel init_3 with isPrivateOnly ${isPrivateOnlyTx} and firstNullifierHint ${proofInput.firstNullifierHint}`);
335
+ pushTestData('private-kernel-inputs-init-3', proofInput);
336
+ output = generateWitnesses ? await this.proofCreator.generateInit3Output(proofInput) : await this.proofCreator.simulateInit3(proofInput);
337
+ functionName = 'private_kernel_init_3';
338
+ break;
339
+ }
340
+ default:
341
+ throw new Error(`Unsupported init kernel batch size: ${apps.length}`);
342
+ }
343
+ } else {
344
+ const vkData = await this.getVkData(previousOutput.verificationKey);
345
+ const previousKernelData = new PrivateKernelData(previousOutput.publicInputs, vkData);
346
+ switch(apps.length){
347
+ case 1:
348
+ {
349
+ const proofInput = new PrivateKernelInnerCircuitPrivateInputs(previousKernelData, apps[0]);
350
+ pushTestData('private-kernel-inputs-inner', proofInput);
351
+ output = generateWitnesses ? await this.proofCreator.generateInnerOutput(proofInput) : await this.proofCreator.simulateInner(proofInput);
352
+ functionName = 'private_kernel_inner';
353
+ break;
354
+ }
355
+ case 2:
356
+ {
357
+ const proofInput = new PrivateKernelInner2CircuitPrivateInputs(previousKernelData, apps[0], apps[1]);
358
+ pushTestData('private-kernel-inputs-inner-2', proofInput);
359
+ output = generateWitnesses ? await this.proofCreator.generateInner2Output(proofInput) : await this.proofCreator.simulateInner2(proofInput);
360
+ functionName = 'private_kernel_inner_2';
361
+ break;
362
+ }
363
+ case 3:
364
+ {
365
+ const proofInput = new PrivateKernelInner3CircuitPrivateInputs(previousKernelData, apps[0], apps[1], apps[2]);
366
+ pushTestData('private-kernel-inputs-inner-3', proofInput);
367
+ output = generateWitnesses ? await this.proofCreator.generateInner3Output(proofInput) : await this.proofCreator.simulateInner3(proofInput);
368
+ functionName = 'private_kernel_inner_3';
369
+ break;
370
+ }
371
+ default:
372
+ throw new Error(`Unsupported inner kernel batch size: ${apps.length}`);
373
+ }
374
+ }
375
+ executionSteps.push({
376
+ functionName,
377
+ bytecode: output.bytecode,
378
+ witness: output.outputWitness,
379
+ vk: output.verificationKey.keyAsBytes,
380
+ timings: {
381
+ witgen: witgenTimer.ms()
382
+ }
383
+ });
384
+ return output;
385
+ }
286
386
  }