@aztec/pxe 0.0.1-commit.24de95ac → 0.0.1-commit.3469e52

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 (374) hide show
  1. package/dest/bin/check_oracle_version.d.ts +1 -1
  2. package/dest/bin/check_oracle_version.js +105 -15
  3. package/dest/block_synchronizer/block_synchronizer.d.ts +41 -0
  4. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
  5. package/dest/{synchronizer/synchronizer.js → block_synchronizer/block_synchronizer.js} +36 -30
  6. package/dest/block_synchronizer/index.d.ts +2 -0
  7. package/dest/block_synchronizer/index.d.ts.map +1 -0
  8. package/dest/block_synchronizer/index.js +1 -0
  9. package/dest/config/index.d.ts +4 -12
  10. package/dest/config/index.d.ts.map +1 -1
  11. package/dest/config/index.js +7 -13
  12. package/dest/config/package_info.d.ts +1 -1
  13. package/dest/config/package_info.js +1 -1
  14. package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
  15. package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
  16. package/dest/contract_function_simulator/benchmarked_node.js +77 -0
  17. package/dest/contract_function_simulator/contract_function_simulator.d.ts +44 -16
  18. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  19. package/dest/contract_function_simulator/contract_function_simulator.js +80 -37
  20. package/dest/contract_function_simulator/execution_note_cache.d.ts +25 -14
  21. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  22. package/dest/contract_function_simulator/execution_note_cache.js +59 -34
  23. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +2 -2
  24. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  25. package/dest/contract_function_simulator/execution_tagging_index_cache.js +1 -1
  26. package/dest/contract_function_simulator/hashed_values_cache.d.ts +2 -2
  27. package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -1
  28. package/dest/contract_function_simulator/index.d.ts +2 -2
  29. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  30. package/dest/contract_function_simulator/index.js +1 -1
  31. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +4 -3
  32. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  33. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +5 -2
  34. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +5 -4
  35. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
  36. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +7 -6
  37. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +3 -3
  38. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  39. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -1
  40. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +6 -4
  41. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  42. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +12 -3
  43. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
  44. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
  45. package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
  46. package/dest/contract_function_simulator/oracle/index.d.ts +1 -1
  47. package/dest/contract_function_simulator/oracle/interfaces.d.ts +22 -15
  48. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  49. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +2 -2
  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 +14 -8
  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 +16 -11
  55. package/dest/contract_function_simulator/oracle/oracle.d.ts +10 -9
  56. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  57. package/dest/contract_function_simulator/oracle/oracle.js +51 -33
  58. package/dest/contract_function_simulator/oracle/private_execution.d.ts +10 -15
  59. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  60. package/dest/contract_function_simulator/oracle/private_execution.js +19 -18
  61. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +29 -33
  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 +46 -48
  64. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +65 -22
  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 +163 -54
  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/debug/pxe_debug_utils.d.ts +31 -0
  74. package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
  75. package/dest/debug/pxe_debug_utils.js +37 -0
  76. package/dest/entrypoints/client/bundle/index.d.ts +1 -2
  77. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  78. package/dest/entrypoints/client/bundle/index.js +0 -1
  79. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  80. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  81. package/dest/entrypoints/client/bundle/utils.js +13 -4
  82. package/dest/entrypoints/client/lazy/index.d.ts +1 -2
  83. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  84. package/dest/entrypoints/client/lazy/index.js +0 -1
  85. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  86. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  87. package/dest/entrypoints/client/lazy/utils.js +13 -4
  88. package/dest/entrypoints/pxe_creation_options.d.ts +5 -2
  89. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  90. package/dest/entrypoints/server/index.d.ts +3 -2
  91. package/dest/entrypoints/server/index.d.ts.map +1 -1
  92. package/dest/entrypoints/server/index.js +2 -1
  93. package/dest/entrypoints/server/utils.d.ts +1 -1
  94. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  95. package/dest/entrypoints/server/utils.js +13 -20
  96. package/dest/error_enriching.d.ts +4 -4
  97. package/dest/error_enriching.d.ts.map +1 -1
  98. package/dest/error_enriching.js +6 -6
  99. package/dest/events/event_service.d.ts +16 -0
  100. package/dest/events/event_service.d.ts.map +1 -0
  101. package/dest/events/event_service.js +45 -0
  102. package/dest/events/index.d.ts +2 -0
  103. package/dest/events/index.d.ts.map +1 -0
  104. package/dest/events/index.js +1 -0
  105. package/dest/events/private_event_filter_validator.d.ts +9 -0
  106. package/dest/events/private_event_filter_validator.d.ts.map +1 -0
  107. package/dest/events/private_event_filter_validator.js +38 -0
  108. package/dest/job_coordinator/job_coordinator.d.ts +74 -0
  109. package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
  110. package/dest/job_coordinator/job_coordinator.js +93 -0
  111. package/dest/logs/log_service.d.ts +27 -0
  112. package/dest/logs/log_service.d.ts.map +1 -0
  113. package/dest/logs/log_service.js +122 -0
  114. package/dest/notes/index.d.ts +2 -0
  115. package/dest/notes/index.d.ts.map +1 -0
  116. package/dest/notes/index.js +1 -0
  117. package/dest/notes/note_service.d.ts +48 -0
  118. package/dest/notes/note_service.d.ts.map +1 -0
  119. package/dest/notes/note_service.js +147 -0
  120. package/dest/oracle_version.d.ts +3 -3
  121. package/dest/oracle_version.js +2 -2
  122. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +1 -1
  123. package/dest/private_kernel/hints/index.d.ts +2 -2
  124. package/dest/private_kernel/hints/index.d.ts.map +1 -1
  125. package/dest/private_kernel/hints/index.js +1 -1
  126. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +28 -0
  127. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
  128. package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +19 -13
  129. package/dest/private_kernel/index.d.ts +1 -1
  130. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  131. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  132. package/dest/private_kernel/private_kernel_execution_prover.js +15 -15
  133. package/dest/private_kernel/private_kernel_oracle.d.ts +26 -29
  134. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  135. package/dest/private_kernel/private_kernel_oracle.js +90 -2
  136. package/dest/pxe.d.ts +54 -83
  137. package/dest/pxe.d.ts.map +1 -1
  138. package/dest/pxe.js +189 -240
  139. package/dest/storage/address_store/address_store.d.ts +11 -0
  140. package/dest/storage/address_store/address_store.d.ts.map +1 -0
  141. package/dest/storage/{address_data_provider/address_data_provider.js → address_store/address_store.js} +1 -1
  142. package/dest/storage/address_store/index.d.ts +2 -0
  143. package/dest/storage/address_store/index.d.ts.map +1 -0
  144. package/dest/storage/address_store/index.js +1 -0
  145. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -0
  146. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
  147. package/dest/storage/{sync_data_provider/sync_data_provider.js → anchor_block_store/anchor_block_store.js} +2 -9
  148. package/dest/storage/anchor_block_store/index.d.ts +2 -0
  149. package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
  150. package/dest/storage/anchor_block_store/index.js +1 -0
  151. package/dest/storage/capsule_store/capsule_store.d.ts +72 -0
  152. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
  153. package/dest/storage/capsule_store/capsule_store.js +255 -0
  154. package/dest/storage/capsule_store/index.d.ts +2 -0
  155. package/dest/storage/capsule_store/index.d.ts.map +1 -0
  156. package/dest/storage/capsule_store/index.js +1 -0
  157. package/dest/storage/{contract_data_provider/contract_data_provider.d.ts → contract_store/contract_store.d.ts} +8 -15
  158. package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
  159. package/dest/storage/{contract_data_provider/contract_data_provider.js → contract_store/contract_store.js} +46 -15
  160. package/dest/storage/contract_store/index.d.ts +2 -0
  161. package/dest/storage/contract_store/index.d.ts.map +1 -0
  162. package/dest/storage/contract_store/index.js +1 -0
  163. package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.d.ts +1 -1
  164. package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
  165. package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.js +1 -1
  166. package/dest/storage/index.d.ts +8 -8
  167. package/dest/storage/index.d.ts.map +1 -1
  168. package/dest/storage/index.js +7 -7
  169. package/dest/storage/metadata.d.ts +1 -1
  170. package/dest/storage/note_store/index.d.ts +3 -0
  171. package/dest/storage/note_store/index.d.ts.map +1 -0
  172. package/dest/storage/note_store/index.js +2 -0
  173. package/dest/storage/{note_data_provider/note_data_provider.d.ts → note_store/note_store.d.ts} +19 -17
  174. package/dest/storage/note_store/note_store.d.ts.map +1 -0
  175. package/dest/storage/{note_data_provider/note_data_provider.js → note_store/note_store.js} +115 -106
  176. package/dest/storage/private_event_store/private_event_store.d.ts +78 -0
  177. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
  178. package/dest/storage/private_event_store/private_event_store.js +222 -0
  179. package/dest/storage/tagging_store/index.d.ts +4 -0
  180. package/dest/storage/tagging_store/index.d.ts.map +1 -0
  181. package/dest/storage/tagging_store/index.js +3 -0
  182. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +28 -0
  183. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
  184. package/dest/storage/tagging_store/recipient_tagging_store.js +99 -0
  185. package/dest/storage/tagging_store/sender_address_book_store.d.ts +14 -0
  186. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -0
  187. package/dest/storage/tagging_store/sender_address_book_store.js +30 -0
  188. package/dest/storage/tagging_store/sender_tagging_store.d.ts +77 -0
  189. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
  190. package/dest/storage/tagging_store/sender_tagging_store.js +278 -0
  191. package/dest/tagging/constants.d.ts +2 -2
  192. package/dest/tagging/constants.d.ts.map +1 -1
  193. package/dest/tagging/constants.js +10 -2
  194. package/dest/tagging/index.d.ts +15 -6
  195. package/dest/tagging/index.d.ts.map +1 -1
  196. package/dest/tagging/index.js +14 -5
  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 +20 -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 +57 -0
  215. package/dest/tree_membership/tree_membership_service.d.ts +50 -0
  216. package/dest/tree_membership/tree_membership_service.d.ts.map +1 -0
  217. package/dest/tree_membership/tree_membership_service.js +75 -0
  218. package/package.json +20 -19
  219. package/src/bin/check_oracle_version.ts +130 -20
  220. package/src/{synchronizer/synchronizer.ts → block_synchronizer/block_synchronizer.ts} +45 -30
  221. package/src/block_synchronizer/index.ts +1 -0
  222. package/src/config/index.ts +10 -25
  223. package/src/config/package_info.ts +1 -1
  224. package/src/contract_function_simulator/benchmarked_node.ts +103 -0
  225. package/src/contract_function_simulator/contract_function_simulator.ts +132 -39
  226. package/src/contract_function_simulator/execution_note_cache.ts +58 -28
  227. package/src/contract_function_simulator/execution_tagging_index_cache.ts +1 -1
  228. package/src/contract_function_simulator/hashed_values_cache.ts +1 -1
  229. package/src/contract_function_simulator/index.ts +1 -1
  230. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +5 -1
  231. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +6 -5
  232. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -2
  233. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +14 -2
  234. package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
  235. package/src/contract_function_simulator/oracle/interfaces.ts +29 -13
  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 +30 -14
  238. package/src/contract_function_simulator/oracle/oracle.ts +62 -30
  239. package/src/contract_function_simulator/oracle/private_execution.ts +22 -29
  240. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +111 -59
  241. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +238 -56
  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 +0 -1
  246. package/src/entrypoints/client/bundle/utils.ts +10 -4
  247. package/src/entrypoints/client/lazy/index.ts +0 -1
  248. package/src/entrypoints/client/lazy/utils.ts +10 -5
  249. package/src/entrypoints/pxe_creation_options.ts +4 -1
  250. package/src/entrypoints/server/index.ts +2 -1
  251. package/src/entrypoints/server/utils.ts +13 -31
  252. package/src/error_enriching.ts +7 -15
  253. package/src/events/event_service.ts +73 -0
  254. package/src/events/index.ts +1 -0
  255. package/src/events/private_event_filter_validator.ts +46 -0
  256. package/src/job_coordinator/job_coordinator.ts +149 -0
  257. package/src/logs/log_service.ts +204 -0
  258. package/src/notes/index.ts +1 -0
  259. package/src/notes/note_service.ts +194 -0
  260. package/src/oracle_version.ts +2 -2
  261. package/src/private_kernel/hints/index.ts +1 -1
  262. package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +38 -31
  263. package/src/private_kernel/private_kernel_execution_prover.ts +15 -21
  264. package/src/private_kernel/private_kernel_oracle.ts +118 -37
  265. package/src/pxe.ts +238 -312
  266. package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +1 -1
  267. package/src/storage/address_store/index.ts +1 -0
  268. package/src/storage/{sync_data_provider/sync_data_provider.ts → anchor_block_store/anchor_block_store.ts} +2 -11
  269. package/src/storage/anchor_block_store/index.ts +1 -0
  270. package/src/storage/capsule_store/capsule_store.ts +315 -0
  271. package/src/storage/capsule_store/index.ts +1 -0
  272. package/src/storage/{contract_data_provider/contract_data_provider.ts → contract_store/contract_store.ts} +65 -20
  273. package/src/storage/contract_store/index.ts +1 -0
  274. package/src/storage/{contract_data_provider → contract_store}/private_functions_tree.ts +1 -1
  275. package/src/storage/index.ts +7 -7
  276. package/src/storage/note_store/index.ts +2 -0
  277. package/src/storage/{note_data_provider/note_data_provider.ts → note_store/note_store.ts} +131 -109
  278. package/src/storage/private_event_store/private_event_store.ts +324 -0
  279. package/src/storage/tagging_store/index.ts +3 -0
  280. package/src/storage/tagging_store/recipient_tagging_store.ts +129 -0
  281. package/src/storage/tagging_store/sender_address_book_store.ts +42 -0
  282. package/src/storage/tagging_store/sender_tagging_store.ts +345 -0
  283. package/src/tagging/constants.ts +10 -2
  284. package/src/tagging/index.ts +17 -5
  285. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +133 -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 +97 -0
  289. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +48 -0
  290. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +75 -0
  291. package/src/tree_membership/tree_membership_service.ts +97 -0
  292. package/dest/contract_function_simulator/execution_data_provider.d.ts +0 -274
  293. package/dest/contract_function_simulator/execution_data_provider.d.ts.map +0 -1
  294. package/dest/contract_function_simulator/execution_data_provider.js +0 -14
  295. package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
  296. package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
  297. package/dest/contract_function_simulator/proxied_node.js +0 -27
  298. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +0 -122
  299. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +0 -1
  300. package/dest/contract_function_simulator/pxe_oracle_interface.js +0 -701
  301. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
  302. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
  303. package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -45
  304. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
  305. package/dest/private_kernel/private_kernel_oracle_impl.js +0 -86
  306. package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -11
  307. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +0 -1
  308. package/dest/storage/address_data_provider/index.d.ts +0 -2
  309. package/dest/storage/address_data_provider/index.d.ts.map +0 -1
  310. package/dest/storage/address_data_provider/index.js +0 -1
  311. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +0 -25
  312. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +0 -1
  313. package/dest/storage/capsule_data_provider/capsule_data_provider.js +0 -118
  314. package/dest/storage/capsule_data_provider/index.d.ts +0 -2
  315. package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
  316. package/dest/storage/capsule_data_provider/index.js +0 -1
  317. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
  318. package/dest/storage/contract_data_provider/index.d.ts +0 -2
  319. package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
  320. package/dest/storage/contract_data_provider/index.js +0 -1
  321. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
  322. package/dest/storage/note_data_provider/index.d.ts +0 -3
  323. package/dest/storage/note_data_provider/index.d.ts.map +0 -1
  324. package/dest/storage/note_data_provider/index.js +0 -2
  325. package/dest/storage/note_data_provider/note_dao.d.ts +0 -100
  326. package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
  327. package/dest/storage/note_data_provider/note_dao.js +0 -102
  328. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
  329. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +0 -43
  330. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +0 -1
  331. package/dest/storage/private_event_data_provider/private_event_data_provider.js +0 -104
  332. package/dest/storage/sync_data_provider/index.d.ts +0 -2
  333. package/dest/storage/sync_data_provider/index.d.ts.map +0 -1
  334. package/dest/storage/sync_data_provider/index.js +0 -1
  335. package/dest/storage/sync_data_provider/sync_data_provider.d.ts +0 -10
  336. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +0 -1
  337. package/dest/storage/tagging_data_provider/index.d.ts +0 -2
  338. package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
  339. package/dest/storage/tagging_data_provider/index.js +0 -1
  340. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +0 -40
  341. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +0 -1
  342. package/dest/storage/tagging_data_provider/tagging_data_provider.js +0 -89
  343. package/dest/synchronizer/index.d.ts +0 -2
  344. package/dest/synchronizer/index.d.ts.map +0 -1
  345. package/dest/synchronizer/index.js +0 -1
  346. package/dest/synchronizer/synchronizer.d.ts +0 -35
  347. package/dest/synchronizer/synchronizer.d.ts.map +0 -1
  348. package/dest/tagging/siloed_tag.d.ts +0 -14
  349. package/dest/tagging/siloed_tag.d.ts.map +0 -1
  350. package/dest/tagging/siloed_tag.js +0 -20
  351. package/dest/tagging/tag.d.ts +0 -12
  352. package/dest/tagging/tag.d.ts.map +0 -1
  353. package/dest/tagging/tag.js +0 -17
  354. package/dest/tagging/utils.d.ts +0 -18
  355. package/dest/tagging/utils.d.ts.map +0 -1
  356. package/dest/tagging/utils.js +0 -24
  357. package/src/contract_function_simulator/execution_data_provider.ts +0 -343
  358. package/src/contract_function_simulator/proxied_node.ts +0 -33
  359. package/src/contract_function_simulator/pxe_oracle_interface.ts +0 -1019
  360. package/src/private_kernel/private_kernel_oracle_impl.ts +0 -132
  361. package/src/storage/address_data_provider/index.ts +0 -1
  362. package/src/storage/capsule_data_provider/capsule_data_provider.ts +0 -147
  363. package/src/storage/capsule_data_provider/index.ts +0 -1
  364. package/src/storage/contract_data_provider/index.ts +0 -1
  365. package/src/storage/note_data_provider/index.ts +0 -2
  366. package/src/storage/note_data_provider/note_dao.ts +0 -154
  367. package/src/storage/private_event_data_provider/private_event_data_provider.ts +0 -148
  368. package/src/storage/sync_data_provider/index.ts +0 -1
  369. package/src/storage/tagging_data_provider/index.ts +0 -1
  370. package/src/storage/tagging_data_provider/tagging_data_provider.ts +0 -120
  371. package/src/synchronizer/index.ts +0 -1
  372. package/src/tagging/siloed_tag.ts +0 -22
  373. package/src/tagging/tag.ts +0 -16
  374. package/src/tagging/utils.ts +0 -31
@@ -0,0 +1,194 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import type { DataInBlock } from '@aztec/stdlib/block';
4
+ import { L2BlockHash } from '@aztec/stdlib/block';
5
+ import { computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
6
+ import { type AztecNode, MAX_RPC_LEN } from '@aztec/stdlib/interfaces/client';
7
+ import { Note, NoteDao, NoteStatus } from '@aztec/stdlib/note';
8
+ import { MerkleTreeId } from '@aztec/stdlib/trees';
9
+ import type { TxHash } from '@aztec/stdlib/tx';
10
+
11
+ import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
12
+ import type { NoteStore } from '../storage/note_store/note_store.js';
13
+
14
+ export class NoteService {
15
+ constructor(
16
+ private readonly noteStore: NoteStore,
17
+ private readonly aztecNode: AztecNode,
18
+ private readonly anchorBlockStore: AnchorBlockStore,
19
+ ) {}
20
+
21
+ /**
22
+ * Retrieves a set of notes stored in the database for a given contract address and storage slot.
23
+ * The query result is paginated using 'limit' and 'offset' values.
24
+ * Returns an object containing an array of note data.
25
+ *
26
+ * @param owner - The owner of the notes. If undefined, returns notes for all known owners.
27
+ * @param status - The status of notes to fetch.
28
+ * @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
29
+ */
30
+ public async getNotes(
31
+ contractAddress: AztecAddress,
32
+ owner: AztecAddress | undefined,
33
+ storageSlot: Fr,
34
+ status: NoteStatus,
35
+ scopes?: AztecAddress[],
36
+ ) {
37
+ const noteDaos = await this.noteStore.getNotes({
38
+ contractAddress,
39
+ owner,
40
+ storageSlot,
41
+ status,
42
+ scopes,
43
+ });
44
+ return noteDaos.map(
45
+ ({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier }) => ({
46
+ contractAddress,
47
+ owner,
48
+ storageSlot,
49
+ randomness,
50
+ noteNonce,
51
+ note,
52
+ noteHash,
53
+ isPending: false, // Note service deals only with settled notes
54
+ siloedNullifier,
55
+ }),
56
+ );
57
+ }
58
+
59
+ /**
60
+ * Looks for nullifiers of active contract notes and marks them as nullified if a nullifier is found.
61
+ *
62
+ * Fetches notes from the NoteStore and checks which nullifiers are present in the
63
+ * onchain nullifier Merkle tree - up to the latest locally synced block. We use the
64
+ * locally synced block instead of querying the chain's 'latest' block to ensure correctness:
65
+ * notes are only marked nullified once their corresponding nullifier has been included in a
66
+ * block up to which the PXE has synced.
67
+ * This allows recent nullifications to be processed even if the node is not an archive node.
68
+ *
69
+ * @param contractAddress - The contract whose notes should be checked and nullified.
70
+ */
71
+ public async syncNoteNullifiers(contractAddress: AztecAddress): Promise<void> {
72
+ const anchorBlockHash = L2BlockHash.fromField(await (await this.anchorBlockStore.getBlockHeader()).hash());
73
+
74
+ const contractNotes = await this.noteStore.getNotes({ contractAddress });
75
+
76
+ if (contractNotes.length === 0) {
77
+ return;
78
+ }
79
+
80
+ const nullifiersToCheck = contractNotes.map(note => note.siloedNullifier);
81
+ const nullifierBatches = nullifiersToCheck.reduce(
82
+ (acc, nullifier) => {
83
+ if (acc[acc.length - 1].length < MAX_RPC_LEN) {
84
+ acc[acc.length - 1].push(nullifier);
85
+ } else {
86
+ acc.push([nullifier]);
87
+ }
88
+ return acc;
89
+ },
90
+ [[]] as Fr[][],
91
+ );
92
+ const nullifierIndexes = (
93
+ await Promise.all(
94
+ nullifierBatches.map(batch =>
95
+ this.aztecNode.findLeavesIndexes(anchorBlockHash, MerkleTreeId.NULLIFIER_TREE, batch),
96
+ ),
97
+ )
98
+ ).flat();
99
+
100
+ const foundNullifiers = nullifiersToCheck
101
+ .map((nullifier, i) => {
102
+ if (nullifierIndexes[i] !== undefined) {
103
+ return { ...nullifierIndexes[i], ...{ data: nullifier } } as DataInBlock<Fr>;
104
+ }
105
+ })
106
+ .filter(nullifier => nullifier !== undefined) as DataInBlock<Fr>[];
107
+
108
+ await this.noteStore.applyNullifiers(foundNullifiers);
109
+ }
110
+
111
+ public async storeNote(
112
+ contractAddress: AztecAddress,
113
+ owner: AztecAddress,
114
+ storageSlot: Fr,
115
+ randomness: Fr,
116
+ noteNonce: Fr,
117
+ content: Fr[],
118
+ noteHash: Fr,
119
+ nullifier: Fr,
120
+ txHash: TxHash,
121
+ recipient: AztecAddress,
122
+ ): Promise<void> {
123
+ // We are going to store the new note in the NoteStore, which will let us later return it via `getNotes`.
124
+ // There's two things we need to check before we do this however:
125
+ // - we must make sure the note does actually exist in the note hash tree
126
+ // - we need to check if the note has already been nullified
127
+ //
128
+ // Failing to do either of the above would result in circuits getting either non-existent notes and failing to
129
+ // produce inclusion proofs for them, or getting nullified notes and producing duplicate nullifiers, both of which
130
+ // are catastrophic failure modes.
131
+ //
132
+ // Note that adding a note and removing it is *not* equivalent to never adding it in the first place. A nullifier
133
+ // emitted in a block that comes after note creation might result in the note being de-nullified by a chain reorg,
134
+ // so we must store both the note hash and nullifier block information.
135
+
136
+ // We avoid making node queries at 'latest' since we don't want to process notes or nullifiers that only exist ahead
137
+ // in time of the locally synced state.
138
+ // Note that while this technically results in historical queries, we perform it at the latest locally synced block
139
+ // number which *should* be recent enough to be available, even for non-archive nodes.
140
+ // Also note that the note should never be ahead of the synced block here since `fetchTaggedLogs` only processes
141
+ // logs up to the synced block making this only an additional safety check.
142
+ const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
143
+ const anchorBlockNumber = anchorBlockHeader.getBlockNumber();
144
+ const anchorBlockHash = L2BlockHash.fromField(await anchorBlockHeader.hash());
145
+
146
+ // By computing siloed and unique note hashes ourselves we prevent contracts from interfering with the note storage
147
+ // of other contracts, which would constitute a security breach.
148
+ const uniqueNoteHash = await computeUniqueNoteHash(noteNonce, await siloNoteHash(contractAddress, noteHash));
149
+ const siloedNullifier = await siloNullifier(contractAddress, nullifier);
150
+
151
+ const [txEffect, [nullifierIndex]] = await Promise.all([
152
+ this.aztecNode.getTxEffect(txHash),
153
+ this.aztecNode.findLeavesIndexes(anchorBlockHash, MerkleTreeId.NULLIFIER_TREE, [siloedNullifier]),
154
+ ]);
155
+ if (!txEffect) {
156
+ throw new Error(`Could not find tx effect for tx hash ${txHash}`);
157
+ }
158
+
159
+ if (txEffect.l2BlockNumber > anchorBlockNumber) {
160
+ throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${anchorBlockNumber}`);
161
+ }
162
+
163
+ // Find the index of the note hash in the noteHashes array to determine note ordering within the tx
164
+ const noteIndexInTx = txEffect.data.noteHashes.findIndex(nh => nh.equals(uniqueNoteHash));
165
+ if (noteIndexInTx === -1) {
166
+ throw new Error(`Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present in tx ${txHash}`);
167
+ }
168
+
169
+ const noteDao = new NoteDao(
170
+ new Note(content),
171
+ contractAddress,
172
+ owner,
173
+ storageSlot,
174
+ randomness,
175
+ noteNonce,
176
+ noteHash,
177
+ siloedNullifier,
178
+ txHash,
179
+ txEffect.l2BlockNumber,
180
+ txEffect.l2BlockHash.toString(),
181
+ txEffect.txIndexInBlock,
182
+ noteIndexInTx,
183
+ );
184
+
185
+ // The note was found by `recipient`, so we use that as the scope when storing the note.
186
+ await this.noteStore.addNotes([noteDao], recipient);
187
+
188
+ if (nullifierIndex !== undefined) {
189
+ // We found nullifier index which implies that the note has already been nullified.
190
+ const { data: _, ...blockHashAndNum } = nullifierIndex;
191
+ await this.noteStore.applyNullifiers([{ data: siloedNullifier, ...blockHashAndNum }]);
192
+ }
193
+ }
194
+ }
@@ -4,8 +4,8 @@
4
4
  ///
5
5
  /// @dev Whenever a contract function or Noir test is run, the `utilityAssertCompatibleOracleVersion` oracle is called
6
6
  /// and if the oracle version is incompatible an error is thrown.
7
- export const ORACLE_VERSION = 3;
7
+ export const ORACLE_VERSION = 6;
8
8
 
9
9
  /// This hash is computed as by hashing the Oracle interface and it is used to detect when the Oracle interface changes,
10
10
  /// which in turn implies that you need to update the ORACLE_VERSION constant.
11
- export const ORACLE_INTERFACE_HASH = 'f9168ceb5a2227c148c5021ebffd4e2ca0da99885b87c5be3ee5ac0d8dd3d67c';
11
+ export const ORACLE_INTERFACE_HASH = '8fb18d1fa560c4844b22c55a3e79c32ffcb71ded9ac409911470ee0296a84d72';
@@ -1,2 +1,2 @@
1
- export * from './build_private_kernel_reset_private_inputs.js';
1
+ export * from './private_kernel_reset_private_inputs_builder.js';
2
2
  export * from './compute_tx_include_by_timestamp.js';
@@ -9,7 +9,7 @@ import {
9
9
  } from '@aztec/constants';
10
10
  import { makeTuple } from '@aztec/foundation/array';
11
11
  import { padArrayEnd } from '@aztec/foundation/collection';
12
- import type { Fr } from '@aztec/foundation/fields';
12
+ import type { Fr } from '@aztec/foundation/curves/bn254';
13
13
  import { type Tuple, assertLength } from '@aztec/foundation/serialize';
14
14
  import { MembershipWitness } from '@aztec/foundation/trees';
15
15
  import { privateKernelResetDimensionsConfig } from '@aztec/noir-protocol-circuits-types/client';
@@ -24,7 +24,6 @@ import {
24
24
  PrivateKernelResetDimensions,
25
25
  PrivateKernelResetHints,
26
26
  type PrivateKernelSimulateOutput,
27
- type ReadRequest,
28
27
  ReadRequestActionEnum,
29
28
  ReadRequestResetActions,
30
29
  type ScopedKeyValidationRequestAndGenerator,
@@ -47,12 +46,10 @@ import type { PrivateKernelOracle } from '../private_kernel_oracle.js';
47
46
 
48
47
  function collectNestedReadRequests<N extends number>(
49
48
  executionStack: PrivateCallExecutionResult[],
50
- extractReadRequests: (execution: PrivateCallExecutionResult) => ClaimedLengthArray<ReadRequest, N>,
49
+ extractReadRequests: (execution: PrivateCallExecutionResult) => ClaimedLengthArray<ScopedReadRequest, N>,
51
50
  ): ScopedReadRequest[] {
52
51
  return collectNested(executionStack, executionResult => {
53
- return extractReadRequests(executionResult)
54
- .getActiveItems()
55
- .map(readRequest => new ScopedReadRequest(readRequest, executionResult.publicInputs.callContext.contractAddress));
52
+ return extractReadRequests(executionResult).getActiveItems();
56
53
  });
57
54
  }
58
55
 
@@ -104,7 +101,7 @@ export class PrivateKernelResetPrivateInputsBuilder {
104
101
  private previousKernelOutput: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>,
105
102
  private executionStack: PrivateCallExecutionResult[],
106
103
  private noteHashNullifierCounterMap: Map<number, number>,
107
- private validationRequestsSplitCounter: number,
104
+ private splitCounter: number,
108
105
  ) {
109
106
  this.previousKernel = previousKernelOutput.publicInputs;
110
107
  this.requestedDimensions = PrivateKernelResetDimensions.empty();
@@ -141,7 +138,7 @@ export class PrivateKernelResetPrivateInputsBuilder {
141
138
  }
142
139
  }
143
140
 
144
- async build(oracle: PrivateKernelOracle, noteHashLeafIndexMap: Map<bigint, bigint>) {
141
+ async build(oracle: PrivateKernelOracle) {
145
142
  if (privateKernelResetDimensionNames.every(name => !this.requestedDimensions[name])) {
146
143
  throw new Error('Reset is not required.');
147
144
  }
@@ -160,16 +157,6 @@ export class PrivateKernelResetPrivateInputsBuilder {
160
157
  allowRemainder,
161
158
  );
162
159
 
163
- const previousVkMembershipWitness = await oracle.getVkMembershipWitness(
164
- this.previousKernelOutput.verificationKey.keyAsFields,
165
- );
166
- const vkData = new VkData(
167
- this.previousKernelOutput.verificationKey,
168
- Number(previousVkMembershipWitness.leafIndex),
169
- previousVkMembershipWitness.siblingPath,
170
- );
171
- const previousKernelData = new PrivateKernelData(this.previousKernelOutput.publicInputs, vkData);
172
-
173
160
  this.reduceReadRequestActions(
174
161
  this.noteHashResetActions,
175
162
  dimensions.NOTE_HASH_PENDING_READ,
@@ -181,32 +168,52 @@ export class PrivateKernelResetPrivateInputsBuilder {
181
168
  dimensions.NULLIFIER_SETTLED_READ,
182
169
  );
183
170
 
184
- // TODO: Enable padding when we have a better idea what are the final amounts we should pad to.
185
- const paddedSideEffects = PaddedSideEffects.empty();
186
-
187
- return new PrivateKernelResetCircuitPrivateInputs(
188
- previousKernelData,
189
- paddedSideEffects,
190
- new PrivateKernelResetHints(
191
- await buildNoteHashReadRequestHintsFromResetActions(
171
+ // Execute all the expensive node querying operations in parallel.
172
+ const [previousVkMembershipWitness, noteHashReadRequestHints, nullifierReadRequestHints, keyValidationHints] =
173
+ await Promise.all([
174
+ oracle.getVkMembershipWitness(this.previousKernelOutput.verificationKey.keyAsFields),
175
+ buildNoteHashReadRequestHintsFromResetActions<
176
+ typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX,
177
+ typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX
178
+ >(
192
179
  oracle,
193
180
  this.previousKernel.validationRequests.noteHashReadRequests,
194
181
  this.previousKernel.end.noteHashes,
195
182
  this.noteHashResetActions,
196
- noteHashLeafIndexMap,
197
183
  ),
198
- await buildNullifierReadRequestHintsFromResetActions(
184
+ buildNullifierReadRequestHintsFromResetActions<
185
+ typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX,
186
+ typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX
187
+ >(
199
188
  { getNullifierMembershipWitness: getNullifierMembershipWitnessResolver(oracle) },
200
189
  this.previousKernel.validationRequests.nullifierReadRequests,
201
190
  this.nullifierResetActions,
202
191
  ),
203
- await getMasterSecretKeysAndAppKeyGenerators(
192
+ getMasterSecretKeysAndAppKeyGenerators(
204
193
  this.previousKernel.validationRequests.scopedKeyValidationRequestsAndGenerators,
205
194
  dimensions.KEY_VALIDATION,
206
195
  oracle,
207
196
  ),
197
+ ]);
198
+
199
+ const vkData = new VkData(
200
+ this.previousKernelOutput.verificationKey,
201
+ Number(previousVkMembershipWitness.leafIndex),
202
+ previousVkMembershipWitness.siblingPath,
203
+ );
204
+ const previousKernelData = new PrivateKernelData(this.previousKernelOutput.publicInputs, vkData);
205
+
206
+ // TODO: Enable padding when we have a better idea what are the final amounts we should pad to.
207
+ const paddedSideEffects = PaddedSideEffects.empty();
208
+
209
+ return new PrivateKernelResetCircuitPrivateInputs(
210
+ previousKernelData,
211
+ paddedSideEffects,
212
+ new PrivateKernelResetHints(
213
+ noteHashReadRequestHints,
214
+ nullifierReadRequestHints,
215
+ keyValidationHints,
208
216
  this.transientDataSquashingHints,
209
- this.validationRequestsSplitCounter,
210
217
  ),
211
218
  dimensions,
212
219
  );
@@ -403,7 +410,7 @@ export class PrivateKernelResetPrivateInputsBuilder {
403
410
  futureNoteHashReads,
404
411
  futureNullifierReads,
405
412
  this.noteHashNullifierCounterMap,
406
- this.validationRequestsSplitCounter,
413
+ this.splitCounter,
407
414
  );
408
415
 
409
416
  if (this.nextIteration && !numTransientData) {
@@ -1,5 +1,5 @@
1
- import { vkAsFieldsMegaHonk } from '@aztec/foundation/crypto';
2
- import { Fr } from '@aztec/foundation/fields';
1
+ import { vkAsFieldsMegaHonk } from '@aztec/foundation/crypto/keys';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import { pushTestData } from '@aztec/foundation/testing';
5
5
  import { Timer } from '@aztec/foundation/timer';
@@ -28,13 +28,12 @@ import {
28
28
  type PrivateCallExecutionResult,
29
29
  type PrivateExecutionResult,
30
30
  TxRequest,
31
- collectNoteHashLeafIndexMap,
32
31
  collectNoteHashNullifierCounterMap,
33
32
  getFinalMinRevertibleSideEffectCounter,
34
33
  } from '@aztec/stdlib/tx';
35
34
  import { VerificationKeyAsFields, VerificationKeyData, VkData } from '@aztec/stdlib/vks';
36
35
 
37
- import { PrivateKernelResetPrivateInputsBuilder } from './hints/build_private_kernel_reset_private_inputs.js';
36
+ import { PrivateKernelResetPrivateInputsBuilder } from './hints/private_kernel_reset_private_inputs_builder.js';
38
37
  import type { PrivateKernelOracle } from './private_kernel_oracle.js';
39
38
 
40
39
  const NULL_SIMULATE_OUTPUT: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs> = {
@@ -101,11 +100,9 @@ export class PrivateKernelExecutionProver {
101
100
 
102
101
  const executionSteps: PrivateExecutionStep[] = [];
103
102
 
104
- const noteHashLeafIndexMap = collectNoteHashLeafIndexMap(executionResult);
105
103
  const noteHashNullifierCounterMap = collectNoteHashNullifierCounterMap(executionResult);
106
- const validationRequestsSplitCounter = isPrivateOnlyTx
107
- ? 0
108
- : getFinalMinRevertibleSideEffectCounter(executionResult);
104
+ const minRevertibleSideEffectCounter = getFinalMinRevertibleSideEffectCounter(executionResult);
105
+ const splitCounter = isPrivateOnlyTx ? 0 : minRevertibleSideEffectCounter;
109
106
 
110
107
  while (executionStack.length) {
111
108
  if (!firstIteration) {
@@ -113,11 +110,11 @@ export class PrivateKernelExecutionProver {
113
110
  output,
114
111
  executionStack,
115
112
  noteHashNullifierCounterMap,
116
- validationRequestsSplitCounter,
113
+ splitCounter,
117
114
  );
118
115
  while (resetBuilder.needsReset()) {
119
116
  const witgenTimer = new Timer();
120
- const privateInputs = await resetBuilder.build(this.oracle, noteHashLeafIndexMap);
117
+ const privateInputs = await resetBuilder.build(this.oracle);
121
118
  output = generateWitnesses
122
119
  ? await this.proofCreator.generateResetOutput(privateInputs)
123
120
  : await this.proofCreator.simulateReset(privateInputs);
@@ -134,7 +131,7 @@ export class PrivateKernelExecutionProver {
134
131
  output,
135
132
  executionStack,
136
133
  noteHashNullifierCounterMap,
137
- validationRequestsSplitCounter,
134
+ splitCounter,
138
135
  );
139
136
  }
140
137
  }
@@ -171,6 +168,7 @@ export class PrivateKernelExecutionProver {
171
168
  privateCallData,
172
169
  isPrivateOnlyTx,
173
170
  executionResult.firstNullifier,
171
+ minRevertibleSideEffectCounter,
174
172
  );
175
173
  this.log.debug(
176
174
  `Calling private kernel init with isPrivateOnly ${isPrivateOnlyTx} and firstNullifierHint ${proofInput.firstNullifierHint}`,
@@ -220,11 +218,11 @@ export class PrivateKernelExecutionProver {
220
218
  output,
221
219
  [],
222
220
  noteHashNullifierCounterMap,
223
- validationRequestsSplitCounter,
221
+ splitCounter,
224
222
  );
225
223
  while (resetBuilder.needsReset()) {
226
224
  const witgenTimer = new Timer();
227
- const privateInputs = await resetBuilder.build(this.oracle, noteHashLeafIndexMap);
225
+ const privateInputs = await resetBuilder.build(this.oracle);
228
226
  output = generateWitnesses
229
227
  ? await this.proofCreator.generateResetOutput(privateInputs)
230
228
  : await this.proofCreator.simulateReset(privateInputs);
@@ -239,12 +237,7 @@ export class PrivateKernelExecutionProver {
239
237
  },
240
238
  });
241
239
 
242
- resetBuilder = new PrivateKernelResetPrivateInputsBuilder(
243
- output,
244
- [],
245
- noteHashNullifierCounterMap,
246
- validationRequestsSplitCounter,
247
- );
240
+ resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, [], noteHashNullifierCounterMap, splitCounter);
248
241
  }
249
242
 
250
243
  if (output.publicInputs.feePayer.isZero() && skipFeeEnforcement) {
@@ -295,8 +288,8 @@ export class PrivateKernelExecutionProver {
295
288
  },
296
289
  });
297
290
 
298
- // Hiding circuit is only executed if we are generating witnesses.
299
- // For simulation, we can end with the tail, since the hiding circuit will simply return the same tail output.
291
+ // Hiding kernel is only executed if we are generating witnesses.
292
+ // For simulation, we can end with the tail, since the Hiding kernel will simply return the same tail output.
300
293
  if (generateWitnesses) {
301
294
  const previousKernelVkData = await this.getVkData(tailOutput.verificationKey);
302
295
 
@@ -420,6 +413,7 @@ export class PrivateKernelExecutionProver {
420
413
  await this.oracle.getContractClassIdPreimage(currentContractClassId);
421
414
 
422
415
  const updatedClassIdHints = await this.oracle.getUpdatedClassIdHints(contractAddress);
416
+
423
417
  return PrivateCallData.from({
424
418
  publicInputs,
425
419
  vk,
@@ -1,71 +1,152 @@
1
- import { FUNCTION_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
2
- import type { Fr, GrumpkinScalar, Point } from '@aztec/foundation/fields';
1
+ import { FUNCTION_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
2
+ import type { Fr } from '@aztec/foundation/curves/bn254';
3
+ import type { GrumpkinScalar, Point } from '@aztec/foundation/curves/grumpkin';
3
4
  import { MembershipWitness } from '@aztec/foundation/trees';
5
+ import type { KeyStore } from '@aztec/key-store';
6
+ import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vk-tree';
7
+ import { ProtocolContractAddress } from '@aztec/protocol-contracts';
4
8
  import type { FunctionSelector } from '@aztec/stdlib/abi';
5
9
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
10
+ import { L2BlockHash } from '@aztec/stdlib/block';
11
+ import {
12
+ type ContractInstanceWithAddress,
13
+ computeContractClassIdPreimage,
14
+ computeSaltedInitializationHash,
15
+ } from '@aztec/stdlib/contract';
16
+ import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
17
+ import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
18
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
6
19
  import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
7
- import type { PublicKeys } from '@aztec/stdlib/keys';
8
20
  import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
9
21
  import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
10
22
 
23
+ import type { ContractStore } from '../storage/contract_store/contract_store.js';
24
+
11
25
  /**
12
26
  * Provides functionality needed by the private kernel for interacting with our state trees.
13
- * This is either PrivateKernelOracleImpl, or a mocked test implementation.
14
27
  */
15
- export interface PrivateKernelOracle {
28
+ export class PrivateKernelOracle {
29
+ constructor(
30
+ private contractStore: ContractStore,
31
+ private keyStore: KeyStore,
32
+ private node: AztecNode,
33
+ private blockHash: L2BlockHash,
34
+ ) {}
35
+
16
36
  /** Retrieves the preimage of a contract address from the registered contract instances db. */
17
- getContractAddressPreimage(address: AztecAddress): Promise<{
18
- saltedInitializationHash: Fr;
19
- publicKeys: PublicKeys;
20
- currentContractClassId: Fr;
21
- originalContractClassId: Fr;
22
- }>;
37
+ public async getContractAddressPreimage(
38
+ address: AztecAddress,
39
+ ): Promise<ContractInstanceWithAddress & { saltedInitializationHash: Fr }> {
40
+ const instance = await this.contractStore.getContractInstance(address);
41
+ if (!instance) {
42
+ throw new Error(`Contract instance not found when getting address preimage. Contract address: ${address}.`);
43
+ }
44
+ return {
45
+ saltedInitializationHash: await computeSaltedInitializationHash(instance),
46
+ ...instance,
47
+ };
48
+ }
23
49
 
24
50
  /** Retrieves the preimage of a contract class id from the contract classes db. */
25
- getContractClassIdPreimage(
26
- contractClassId: Fr,
27
- ): Promise<{ artifactHash: Fr; publicBytecodeCommitment: Fr; privateFunctionsRoot: Fr }>;
51
+ public async getContractClassIdPreimage(contractClassId: Fr) {
52
+ const contractClass = await this.contractStore.getContractClass(contractClassId);
53
+ if (!contractClass) {
54
+ throw new Error(`Contract class not found when getting class id preimage. Class id: ${contractClassId}.`);
55
+ }
56
+ return computeContractClassIdPreimage(contractClass);
57
+ }
28
58
 
29
- /**
30
- * Returns a membership witness with the sibling path and leaf index in our private functions tree.
31
- */
32
- getFunctionMembershipWitness(
59
+ /** Returns a membership witness with the sibling path and leaf index in our private functions tree. */
60
+ public async getFunctionMembershipWitness(
33
61
  contractClassId: Fr,
34
62
  selector: FunctionSelector,
35
- ): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT>>;
63
+ ): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT>> {
64
+ const membershipWitness = await this.contractStore.getFunctionMembershipWitness(contractClassId, selector);
65
+ if (!membershipWitness) {
66
+ throw new Error(
67
+ `Membership witness not found for contract class id ${contractClassId} and selector ${selector}.`,
68
+ );
69
+ }
70
+ return membershipWitness;
71
+ }
36
72
 
37
73
  /**
38
74
  * Returns a membership witness with the sibling path and leaf index in our protocol VK indexed merkle tree.
39
75
  * Used to validate the previous kernel's verification key.
40
76
  */
41
- getVkMembershipWitness(vk: VerificationKeyAsFields): Promise<MembershipWitness<typeof VK_TREE_HEIGHT>>;
77
+ public getVkMembershipWitness(vk: VerificationKeyAsFields): Promise<MembershipWitness<typeof VK_TREE_HEIGHT>> {
78
+ const leafIndex = getVKIndex(vk);
79
+ return Promise.resolve(new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)));
80
+ }
42
81
 
43
- /**
44
- * Returns a membership witness with the sibling path and leaf index in our private function indexed merkle tree.
45
- */ getNoteHashMembershipWitness(leafIndex: bigint): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>>;
82
+ /** Returns a membership witness with the sibling path and leaf index in our note hash tree. */
83
+ getNoteHashMembershipWitness(noteHash: Fr): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
84
+ return this.node.getNoteHashMembershipWitness(this.blockHash, noteHash);
85
+ }
46
86
 
47
- /**
48
- * Returns a membership witness with the sibling path and leaf index in our nullifier indexed merkle tree.
49
- */
50
- getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
51
- /**
52
- * Returns the root of our note hash merkle tree.
53
- */
54
- getNoteHashTreeRoot(): Promise<Fr>;
87
+ /** Returns a membership witness with the sibling path and leaf index in our nullifier indexed merkle tree. */
88
+ getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitness | undefined> {
89
+ return this.node.getNullifierMembershipWitness(this.blockHash, nullifier);
90
+ }
91
+
92
+ /** Returns the root of our note hash merkle tree. */
93
+ async getNoteHashTreeRoot(): Promise<Fr> {
94
+ const header = await this.node.getBlockHeader(this.blockHash);
95
+ if (!header) {
96
+ throw new Error(`No block header found for block hash ${this.blockHash}`);
97
+ }
98
+ return header.state.partial.noteHashTree.root;
99
+ }
55
100
 
56
101
  /**
57
102
  * Retrieves the sk_m corresponding to the pk_m.
58
103
  * @throws If the provided public key is not associated with any of the registered accounts.
59
- * @param pkM - The master public key to get secret key for.
104
+ * @param masterPublicKey - The master public key to get secret key for.
60
105
  * @returns A Promise that resolves to sk_m.
61
106
  * @dev Used when feeding the sk_m to the kernel circuit for keys verification.
62
107
  */
63
- getMasterSecretKey(masterPublicKey: Point): Promise<GrumpkinScalar>;
108
+ public getMasterSecretKey(masterPublicKey: Point): Promise<GrumpkinScalar> {
109
+ return this.keyStore.getMasterSecretKey(masterPublicKey);
110
+ }
64
111
 
65
112
  /** Use debug data to get the function name corresponding to a selector. */
66
- getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
113
+ public getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
114
+ return this.contractStore.getDebugFunctionName(contractAddress, selector);
115
+ }
116
+
117
+ /**
118
+ * Returns a membership witness and leaf index to our public data indexed merkle tree,
119
+ * along with an associated DelayedPublicMutable containing the class ID to update.
120
+ */
121
+ public async getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints> {
122
+ const { delayedPublicMutableSlot, delayedPublicMutableHashSlot } =
123
+ await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
124
+
125
+ const hashLeafSlot = await computePublicDataTreeLeafSlot(
126
+ ProtocolContractAddress.ContractInstanceRegistry,
127
+ delayedPublicMutableHashSlot,
128
+ );
129
+ const updatedClassIdWitness = await this.node.getPublicDataWitness(this.blockHash, hashLeafSlot);
130
+
131
+ if (!updatedClassIdWitness) {
132
+ throw new Error(`No public data tree witness found for ${hashLeafSlot}`);
133
+ }
134
+
135
+ const readStorage = (storageSlot: Fr) =>
136
+ this.node.getPublicStorageAt(this.blockHash, ProtocolContractAddress.ContractInstanceRegistry, storageSlot);
137
+ const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(
138
+ delayedPublicMutableSlot,
139
+ readStorage,
140
+ );
67
141
 
68
- /** Returns a membership witness and leaf index to our public data indexed merkle tree,
69
- * along with an associated DelayedPublicMutable containing the class ID to update. */
70
- getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints>;
142
+ return new UpdatedClassIdHints(
143
+ new MembershipWitness(
144
+ PUBLIC_DATA_TREE_HEIGHT,
145
+ updatedClassIdWitness.index,
146
+ updatedClassIdWitness.siblingPath.toTuple(),
147
+ ),
148
+ updatedClassIdWitness.leafPreimage,
149
+ delayedPublicMutableValues,
150
+ );
151
+ }
71
152
  }