@aztec/pxe 0.0.0-test.1 → 0.0.1-commit.b655e406

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 (309) hide show
  1. package/README.md +5 -5
  2. package/dest/bin/check_oracle_version.d.ts +2 -0
  3. package/dest/bin/check_oracle_version.d.ts.map +1 -0
  4. package/dest/bin/check_oracle_version.js +39 -0
  5. package/dest/config/index.d.ts +10 -15
  6. package/dest/config/index.d.ts.map +1 -1
  7. package/dest/config/index.js +11 -20
  8. package/dest/config/package_info.js +1 -1
  9. package/dest/contract_function_simulator/contract_function_simulator.d.ts +56 -0
  10. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -0
  11. package/dest/contract_function_simulator/contract_function_simulator.js +301 -0
  12. package/dest/contract_function_simulator/execution_data_provider.d.ts +274 -0
  13. package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -0
  14. package/dest/contract_function_simulator/execution_data_provider.js +14 -0
  15. package/dest/contract_function_simulator/execution_note_cache.d.ts +93 -0
  16. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -0
  17. package/dest/contract_function_simulator/execution_note_cache.js +183 -0
  18. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
  19. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
  20. package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
  21. package/dest/contract_function_simulator/hashed_values_cache.d.ts +28 -0
  22. package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -0
  23. package/dest/contract_function_simulator/hashed_values_cache.js +36 -0
  24. package/dest/contract_function_simulator/index.d.ts +14 -0
  25. package/dest/contract_function_simulator/index.d.ts.map +1 -0
  26. package/dest/contract_function_simulator/index.js +12 -0
  27. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +20 -0
  28. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -0
  29. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +37 -0
  30. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +15 -0
  31. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -0
  32. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +25 -0
  33. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +17 -0
  34. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -0
  35. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +65 -0
  36. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +22 -0
  37. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -0
  38. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +42 -0
  39. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +22 -0
  40. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
  41. package/dest/contract_function_simulator/noir-structs/utility_context.js +33 -0
  42. package/dest/contract_function_simulator/oracle/index.d.ts +14 -0
  43. package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -0
  44. package/dest/contract_function_simulator/oracle/index.js +2 -0
  45. package/dest/contract_function_simulator/oracle/interfaces.d.ts +97 -0
  46. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
  47. package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
  48. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +19 -0
  49. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -0
  50. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +24 -0
  51. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +22 -0
  52. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -0
  53. package/dest/contract_function_simulator/oracle/note_packing_utils.js +49 -0
  54. package/dest/contract_function_simulator/oracle/oracle.d.ts +57 -0
  55. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -0
  56. package/dest/contract_function_simulator/oracle/oracle.js +328 -0
  57. package/dest/contract_function_simulator/oracle/private_execution.d.ts +48 -0
  58. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -0
  59. package/dest/contract_function_simulator/oracle/private_execution.js +123 -0
  60. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +236 -0
  61. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -0
  62. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +417 -0
  63. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +154 -0
  64. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -0
  65. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +265 -0
  66. package/dest/contract_function_simulator/pick_notes.d.ts +85 -0
  67. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -0
  68. package/dest/contract_function_simulator/pick_notes.js +51 -0
  69. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +6 -0
  70. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -0
  71. package/dest/contract_function_simulator/proxied_contract_data_source.js +62 -0
  72. package/dest/contract_function_simulator/proxied_node.d.ts +9 -0
  73. package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -0
  74. package/dest/contract_function_simulator/proxied_node.js +27 -0
  75. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +122 -0
  76. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -0
  77. package/dest/contract_function_simulator/pxe_oracle_interface.js +701 -0
  78. package/dest/entrypoints/client/bundle/index.d.ts +4 -2
  79. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  80. package/dest/entrypoints/client/bundle/index.js +3 -2
  81. package/dest/entrypoints/client/bundle/utils.d.ts +9 -9
  82. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  83. package/dest/entrypoints/client/bundle/utils.js +18 -12
  84. package/dest/entrypoints/client/lazy/index.d.ts +4 -2
  85. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  86. package/dest/entrypoints/client/lazy/index.js +3 -2
  87. package/dest/entrypoints/client/lazy/utils.d.ts +8 -8
  88. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  89. package/dest/entrypoints/client/lazy/utils.js +17 -11
  90. package/dest/entrypoints/{client/pxe_creation_options.d.ts → pxe_creation_options.d.ts} +4 -1
  91. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -0
  92. package/dest/entrypoints/server/index.d.ts +5 -3
  93. package/dest/entrypoints/server/index.d.ts.map +1 -1
  94. package/dest/entrypoints/server/index.js +4 -3
  95. package/dest/entrypoints/server/utils.d.ts +7 -15
  96. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  97. package/dest/entrypoints/server/utils.js +34 -28
  98. package/dest/{pxe_service/error_enriching.d.ts → error_enriching.d.ts} +1 -1
  99. package/dest/error_enriching.d.ts.map +1 -0
  100. package/dest/{pxe_service/error_enriching.js → error_enriching.js} +26 -18
  101. package/dest/oracle_version.d.ts +3 -0
  102. package/dest/oracle_version.d.ts.map +1 -0
  103. package/dest/oracle_version.js +10 -0
  104. package/dest/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.d.ts +6 -6
  105. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -0
  106. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +271 -0
  107. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +4 -0
  108. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +1 -0
  109. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +41 -0
  110. package/dest/private_kernel/hints/index.d.ts +3 -0
  111. package/dest/private_kernel/hints/index.d.ts.map +1 -0
  112. package/dest/{kernel_prover → private_kernel}/hints/index.js +1 -0
  113. package/dest/private_kernel/index.d.ts +3 -0
  114. package/dest/private_kernel/index.d.ts.map +1 -0
  115. package/dest/private_kernel/index.js +2 -0
  116. package/dest/private_kernel/private_kernel_execution_prover.d.ts +44 -0
  117. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -0
  118. package/dest/private_kernel/private_kernel_execution_prover.js +285 -0
  119. package/dest/{kernel_prover/proving_data_oracle.d.ts → private_kernel/private_kernel_oracle.d.ts} +17 -28
  120. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -0
  121. package/dest/private_kernel/private_kernel_oracle.js +4 -0
  122. package/dest/{kernel_oracle/index.d.ts → private_kernel/private_kernel_oracle_impl.d.ts} +8 -8
  123. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -0
  124. package/dest/{kernel_oracle/index.js → private_kernel/private_kernel_oracle_impl.js} +19 -9
  125. package/dest/pxe.d.ts +233 -0
  126. package/dest/pxe.d.ts.map +1 -0
  127. package/dest/pxe.js +789 -0
  128. package/dest/storage/address_data_provider/address_data_provider.d.ts +1 -3
  129. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +1 -1
  130. package/dest/storage/address_data_provider/address_data_provider.js +0 -3
  131. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +14 -5
  132. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
  133. package/dest/storage/capsule_data_provider/capsule_data_provider.js +85 -24
  134. package/dest/storage/contract_data_provider/contract_data_provider.d.ts +12 -47
  135. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
  136. package/dest/storage/contract_data_provider/contract_data_provider.js +92 -70
  137. package/dest/storage/contract_data_provider/index.d.ts +0 -1
  138. package/dest/storage/contract_data_provider/index.d.ts.map +1 -1
  139. package/dest/storage/contract_data_provider/index.js +0 -1
  140. package/dest/storage/contract_data_provider/private_functions_tree.d.ts +2 -41
  141. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +1 -1
  142. package/dest/storage/contract_data_provider/private_functions_tree.js +9 -61
  143. package/dest/storage/index.d.ts +2 -3
  144. package/dest/storage/index.d.ts.map +1 -1
  145. package/dest/storage/index.js +2 -3
  146. package/dest/storage/metadata.d.ts +2 -0
  147. package/dest/storage/metadata.d.ts.map +1 -0
  148. package/dest/storage/metadata.js +1 -0
  149. package/dest/storage/note_data_provider/note_dao.d.ts +16 -22
  150. package/dest/storage/note_data_provider/note_dao.d.ts.map +1 -1
  151. package/dest/storage/note_data_provider/note_dao.js +16 -20
  152. package/dest/storage/note_data_provider/note_data_provider.d.ts +71 -8
  153. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
  154. package/dest/storage/note_data_provider/note_data_provider.js +133 -74
  155. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +43 -0
  156. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +1 -0
  157. package/dest/storage/private_event_data_provider/private_event_data_provider.js +104 -0
  158. package/dest/storage/sync_data_provider/sync_data_provider.d.ts +2 -4
  159. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +1 -1
  160. package/dest/storage/sync_data_provider/sync_data_provider.js +2 -5
  161. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +28 -6
  162. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +1 -1
  163. package/dest/storage/tagging_data_provider/tagging_data_provider.js +48 -24
  164. package/dest/synchronizer/synchronizer.d.ts +7 -9
  165. package/dest/synchronizer/synchronizer.d.ts.map +1 -1
  166. package/dest/synchronizer/synchronizer.js +17 -19
  167. package/dest/tagging/constants.d.ts +2 -0
  168. package/dest/tagging/constants.d.ts.map +1 -0
  169. package/dest/tagging/constants.js +2 -0
  170. package/dest/tagging/index.d.ts +7 -0
  171. package/dest/tagging/index.d.ts.map +1 -0
  172. package/dest/tagging/index.js +5 -0
  173. package/dest/tagging/siloed_tag.d.ts +14 -0
  174. package/dest/tagging/siloed_tag.d.ts.map +1 -0
  175. package/dest/tagging/siloed_tag.js +20 -0
  176. package/dest/tagging/tag.d.ts +12 -0
  177. package/dest/tagging/tag.d.ts.map +1 -0
  178. package/dest/tagging/tag.js +17 -0
  179. package/dest/tagging/utils.d.ts +18 -0
  180. package/dest/tagging/utils.d.ts.map +1 -0
  181. package/dest/tagging/utils.js +24 -0
  182. package/package.json +34 -32
  183. package/src/bin/check_oracle_version.ts +50 -0
  184. package/src/config/index.ts +20 -33
  185. package/src/config/package_info.ts +1 -1
  186. package/src/contract_function_simulator/contract_function_simulator.ts +548 -0
  187. package/src/contract_function_simulator/execution_data_provider.ts +343 -0
  188. package/src/contract_function_simulator/execution_note_cache.ts +222 -0
  189. package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
  190. package/src/contract_function_simulator/hashed_values_cache.ts +47 -0
  191. package/src/contract_function_simulator/index.ts +13 -0
  192. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +47 -0
  193. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +27 -0
  194. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +69 -0
  195. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +52 -0
  196. package/src/contract_function_simulator/noir-structs/utility_context.ts +42 -0
  197. package/src/contract_function_simulator/oracle/index.ts +16 -0
  198. package/src/contract_function_simulator/oracle/interfaces.ts +160 -0
  199. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +23 -0
  200. package/src/contract_function_simulator/oracle/note_packing_utils.ts +52 -0
  201. package/src/contract_function_simulator/oracle/oracle.ts +575 -0
  202. package/src/contract_function_simulator/oracle/private_execution.ts +207 -0
  203. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +625 -0
  204. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +358 -0
  205. package/src/contract_function_simulator/pick_notes.ts +141 -0
  206. package/src/contract_function_simulator/proxied_contract_data_source.ts +66 -0
  207. package/src/contract_function_simulator/proxied_node.ts +33 -0
  208. package/src/contract_function_simulator/pxe_oracle_interface.ts +1019 -0
  209. package/src/entrypoints/client/bundle/index.ts +4 -2
  210. package/src/entrypoints/client/bundle/utils.ts +36 -36
  211. package/src/entrypoints/client/lazy/index.ts +4 -2
  212. package/src/entrypoints/client/lazy/utils.ts +36 -31
  213. package/src/entrypoints/{client/pxe_creation_options.ts → pxe_creation_options.ts} +4 -1
  214. package/src/entrypoints/server/index.ts +5 -3
  215. package/src/entrypoints/server/utils.ts +69 -47
  216. package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +36 -27
  217. package/src/oracle_version.ts +11 -0
  218. package/src/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.ts +158 -142
  219. package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +58 -0
  220. package/src/{kernel_prover → private_kernel}/hints/index.ts +1 -0
  221. package/src/private_kernel/index.ts +2 -0
  222. package/src/private_kernel/private_kernel_execution_prover.ts +436 -0
  223. package/src/{kernel_prover/proving_data_oracle.ts → private_kernel/private_kernel_oracle.ts} +17 -29
  224. package/src/{kernel_oracle/index.ts → private_kernel/private_kernel_oracle_impl.ts} +30 -15
  225. package/src/pxe.ts +1113 -0
  226. package/src/storage/address_data_provider/address_data_provider.ts +1 -7
  227. package/src/storage/capsule_data_provider/capsule_data_provider.ts +97 -30
  228. package/src/storage/contract_data_provider/contract_data_provider.ts +114 -81
  229. package/src/storage/contract_data_provider/index.ts +0 -1
  230. package/src/storage/contract_data_provider/private_functions_tree.ts +11 -75
  231. package/src/storage/index.ts +2 -4
  232. package/src/storage/metadata.ts +1 -0
  233. package/src/storage/note_data_provider/note_dao.ts +19 -27
  234. package/src/storage/note_data_provider/note_data_provider.ts +161 -113
  235. package/src/storage/private_event_data_provider/private_event_data_provider.ts +148 -0
  236. package/src/storage/sync_data_provider/sync_data_provider.ts +4 -10
  237. package/src/storage/tagging_data_provider/tagging_data_provider.ts +58 -30
  238. package/src/synchronizer/synchronizer.ts +21 -22
  239. package/src/tagging/constants.ts +2 -0
  240. package/src/tagging/index.ts +6 -0
  241. package/src/tagging/siloed_tag.ts +22 -0
  242. package/src/tagging/tag.ts +16 -0
  243. package/src/tagging/utils.ts +31 -0
  244. package/dest/bin/index.d.ts +0 -3
  245. package/dest/bin/index.d.ts.map +0 -1
  246. package/dest/bin/index.js +0 -28
  247. package/dest/entrypoints/client/pxe_creation_options.d.ts.map +0 -1
  248. package/dest/kernel_oracle/index.d.ts.map +0 -1
  249. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
  250. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +0 -270
  251. package/dest/kernel_prover/hints/index.d.ts +0 -2
  252. package/dest/kernel_prover/hints/index.d.ts.map +0 -1
  253. package/dest/kernel_prover/index.d.ts +0 -3
  254. package/dest/kernel_prover/index.d.ts.map +0 -1
  255. package/dest/kernel_prover/index.js +0 -2
  256. package/dest/kernel_prover/kernel_prover.d.ts +0 -38
  257. package/dest/kernel_prover/kernel_prover.d.ts.map +0 -1
  258. package/dest/kernel_prover/kernel_prover.js +0 -217
  259. package/dest/kernel_prover/proving_data_oracle.d.ts.map +0 -1
  260. package/dest/kernel_prover/proving_data_oracle.js +0 -4
  261. package/dest/note_decryption_utils/add_public_values_to_payload.d.ts +0 -11
  262. package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +0 -1
  263. package/dest/note_decryption_utils/add_public_values_to_payload.js +0 -47
  264. package/dest/pxe_http/index.d.ts +0 -2
  265. package/dest/pxe_http/index.d.ts.map +0 -1
  266. package/dest/pxe_http/index.js +0 -1
  267. package/dest/pxe_http/pxe_http_server.d.ts +0 -16
  268. package/dest/pxe_http/pxe_http_server.d.ts.map +0 -1
  269. package/dest/pxe_http/pxe_http_server.js +0 -27
  270. package/dest/pxe_oracle_interface/index.d.ts +0 -159
  271. package/dest/pxe_oracle_interface/index.d.ts.map +0 -1
  272. package/dest/pxe_oracle_interface/index.js +0 -692
  273. package/dest/pxe_oracle_interface/tagging_utils.d.ts +0 -17
  274. package/dest/pxe_oracle_interface/tagging_utils.d.ts.map +0 -1
  275. package/dest/pxe_oracle_interface/tagging_utils.js +0 -23
  276. package/dest/pxe_service/error_enriching.d.ts.map +0 -1
  277. package/dest/pxe_service/index.d.ts +0 -3
  278. package/dest/pxe_service/index.d.ts.map +0 -1
  279. package/dest/pxe_service/index.js +0 -2
  280. package/dest/pxe_service/pxe_service.d.ts +0 -111
  281. package/dest/pxe_service/pxe_service.d.ts.map +0 -1
  282. package/dest/pxe_service/pxe_service.js +0 -664
  283. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts +0 -11
  284. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts.map +0 -1
  285. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.js +0 -20
  286. package/dest/storage/auth_witness_data_provider/index.d.ts +0 -2
  287. package/dest/storage/auth_witness_data_provider/index.d.ts.map +0 -1
  288. package/dest/storage/auth_witness_data_provider/index.js +0 -1
  289. package/dest/storage/data_provider.d.ts +0 -4
  290. package/dest/storage/data_provider.d.ts.map +0 -1
  291. package/dest/storage/data_provider.js +0 -1
  292. package/dest/test/pxe_test_suite.d.ts +0 -3
  293. package/dest/test/pxe_test_suite.d.ts.map +0 -1
  294. package/dest/test/pxe_test_suite.js +0 -97
  295. package/src/bin/index.ts +0 -38
  296. package/src/kernel_prover/index.ts +0 -2
  297. package/src/kernel_prover/kernel_prover.ts +0 -351
  298. package/src/note_decryption_utils/add_public_values_to_payload.ts +0 -64
  299. package/src/pxe_http/index.ts +0 -1
  300. package/src/pxe_http/pxe_http_server.ts +0 -29
  301. package/src/pxe_oracle_interface/index.ts +0 -925
  302. package/src/pxe_oracle_interface/tagging_utils.ts +0 -32
  303. package/src/pxe_service/index.ts +0 -2
  304. package/src/pxe_service/pxe_service.ts +0 -949
  305. package/src/storage/auth_witness_data_provider/auth_witness_data_provider.ts +0 -34
  306. package/src/storage/auth_witness_data_provider/index.ts +0 -1
  307. package/src/storage/data_provider.ts +0 -3
  308. package/src/test/pxe_test_suite.ts +0 -111
  309. /package/dest/entrypoints/{client/pxe_creation_options.js → pxe_creation_options.js} +0 -0
@@ -0,0 +1,154 @@
1
+ import { Fr, Point } from '@aztec/foundation/fields';
2
+ import type { AuthWitness } from '@aztec/stdlib/auth-witness';
3
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
+ import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
5
+ import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
6
+ import type { NoteStatus } from '@aztec/stdlib/note';
7
+ import { type MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
8
+ import type { BlockHeader, Capsule } from '@aztec/stdlib/tx';
9
+ import type { ExecutionDataProvider } from '../execution_data_provider.js';
10
+ import { UtilityContext } from '../noir-structs/utility_context.js';
11
+ import type { IMiscOracle, IUtilityExecutionOracle, NoteData } from './interfaces.js';
12
+ /**
13
+ * The oracle for an execution of utility contract functions.
14
+ */
15
+ export declare class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOracle {
16
+ protected readonly contractAddress: AztecAddress;
17
+ /** List of transient auth witnesses to be used during this simulation */
18
+ protected readonly authWitnesses: AuthWitness[];
19
+ protected readonly capsules: Capsule[];
20
+ protected readonly executionDataProvider: ExecutionDataProvider;
21
+ protected log: import("@aztec/foundation/log").Logger;
22
+ protected readonly scopes?: AztecAddress[] | undefined;
23
+ isMisc: true;
24
+ isUtility: true;
25
+ private aztecNrDebugLog;
26
+ constructor(contractAddress: AztecAddress,
27
+ /** List of transient auth witnesses to be used during this simulation */
28
+ authWitnesses: AuthWitness[], capsules: Capsule[], // TODO(#12425): Rename to transientCapsules
29
+ executionDataProvider: ExecutionDataProvider, log?: import("@aztec/foundation/log").Logger, scopes?: AztecAddress[] | undefined);
30
+ utilityAssertCompatibleOracleVersion(version: number): void;
31
+ utilityGetRandomField(): Fr;
32
+ utilityGetUtilityContext(): Promise<UtilityContext>;
33
+ /**
34
+ * Retrieve keys associated with a specific master public key and app address.
35
+ * @param pkMHash - The master public key hash.
36
+ * @returns A Promise that resolves to nullifier keys.
37
+ * @throws If the keys are not registered in the key store.
38
+ */
39
+ utilityGetKeyValidationRequest(pkMHash: Fr): Promise<KeyValidationRequest>;
40
+ /**
41
+ * Fetches the index and sibling path of a leaf at a given block from a given tree.
42
+ * @param blockNumber - The block number at which to get the membership witness.
43
+ * @param treeId - Id of the tree to get the sibling path from.
44
+ * @param leafValue - The leaf value
45
+ * @returns The index and sibling path concatenated [index, sibling_path]
46
+ */
47
+ utilityGetMembershipWitness(blockNumber: number, treeId: MerkleTreeId, leafValue: Fr): Promise<Fr[]>;
48
+ /**
49
+ * Returns a nullifier membership witness for a given nullifier at a given block.
50
+ * @param blockNumber - The block number at which to get the index.
51
+ * @param nullifier - Nullifier we try to find witness for.
52
+ * @returns The nullifier membership witness (if found).
53
+ */
54
+ utilityGetNullifierMembershipWitness(blockNumber: number, nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
55
+ /**
56
+ * Returns a low nullifier membership witness for a given nullifier at a given block.
57
+ * @param blockNumber - The block number at which to get the index.
58
+ * @param nullifier - Nullifier we try to find the low nullifier witness for.
59
+ * @returns The low nullifier membership witness (if found).
60
+ * @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
61
+ * list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
62
+ * we are trying to prove non-inclusion for.
63
+ */
64
+ utilityGetLowNullifierMembershipWitness(blockNumber: number, nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
65
+ /**
66
+ * Returns a public data tree witness for a given leaf slot at a given block.
67
+ * @param blockNumber - The block number at which to get the index.
68
+ * @param leafSlot - The slot of the public data tree to get the witness for.
69
+ * @returns - The witness
70
+ */
71
+ utilityGetPublicDataWitness(blockNumber: number, leafSlot: Fr): Promise<PublicDataWitness | undefined>;
72
+ /**
73
+ * Fetches a block header of a given block.
74
+ * @param blockNumber - The number of a block of which to get the block header.
75
+ * @returns Block extracted from a block with block number `blockNumber`.
76
+ */
77
+ utilityGetBlockHeader(blockNumber: number): Promise<BlockHeader | undefined>;
78
+ /**
79
+ * Retrieve the complete address associated to a given address.
80
+ * @param account - The account address.
81
+ * @returns A complete address associated with the input address.
82
+ * @throws An error if the account is not registered in the database.
83
+ */
84
+ utilityGetPublicKeysAndPartialAddress(account: AztecAddress): Promise<CompleteAddress>;
85
+ /**
86
+ * Returns a contract instance associated with an address or throws if not found.
87
+ * @param address - Address.
88
+ * @returns A contract instance.
89
+ */
90
+ utilityGetContractInstance(address: AztecAddress): Promise<ContractInstance>;
91
+ /**
92
+ * Returns an auth witness for the given message hash. Checks on the list of transient witnesses
93
+ * for this transaction first, and falls back to the local database if not found.
94
+ * @param messageHash - Hash of the message to authenticate.
95
+ * @returns Authentication witness for the requested message hash.
96
+ */
97
+ utilityGetAuthWitness(messageHash: Fr): Promise<Fr[] | undefined>;
98
+ /**
99
+ * Gets some notes for a contract address and storage slot.
100
+ * Returns a flattened array containing filtered notes.
101
+ *
102
+ * @remarks
103
+ * Check for pending notes with matching slot.
104
+ * Real notes coming from DB will have a leafIndex which
105
+ * represents their index in the note hash tree.
106
+ *
107
+ * @param storageSlot - The storage slot.
108
+ * @param numSelects - The number of valid selects in selectBy and selectValues.
109
+ * @param selectBy - An array of indices of the fields to selects.
110
+ * @param selectValues - The values to match.
111
+ * @param selectComparators - The comparators to use to match values.
112
+ * @param sortBy - An array of indices of the fields to sort.
113
+ * @param sortOrder - The order of the corresponding index in sortBy. (1: DESC, 2: ASC, 0: Do nothing)
114
+ * @param limit - The number of notes to retrieve per query.
115
+ * @param offset - The starting index for pagination.
116
+ * @param status - The status of notes to fetch.
117
+ * @returns Array of note data.
118
+ */
119
+ utilityGetNotes(storageSlot: Fr, numSelects: number, selectByIndexes: number[], selectByOffsets: number[], selectByLengths: number[], selectValues: Fr[], selectComparators: number[], sortByIndexes: number[], sortByOffsets: number[], sortByLengths: number[], sortOrder: number[], limit: number, offset: number, status: NoteStatus): Promise<NoteData[]>;
120
+ /**
121
+ * Check if a nullifier exists in the nullifier tree.
122
+ * @param innerNullifier - The inner nullifier.
123
+ * @returns A boolean indicating whether the nullifier exists in the tree or not.
124
+ */
125
+ utilityCheckNullifierExists(innerNullifier: Fr): Promise<boolean>;
126
+ /**
127
+ * Fetches a message from the executionDataProvider, given its key.
128
+ * @param contractAddress - Address of a contract by which the message was emitted.
129
+ * @param messageHash - Hash of the message.
130
+ * @param secret - Secret used to compute a nullifier.
131
+ * @dev Contract address and secret are only used to compute the nullifier to get non-nullified messages
132
+ * @returns The l1 to l2 membership witness (index of message in the tree and sibling path).
133
+ */
134
+ utilityGetL1ToL2MembershipWitness(contractAddress: AztecAddress, messageHash: Fr, secret: Fr): Promise<import("./message_load_oracle_inputs.js").MessageLoadOracleInputs<36>>;
135
+ /**
136
+ * Read the public storage data.
137
+ * @param contractAddress - The address to read storage from.
138
+ * @param startStorageSlot - The starting storage slot.
139
+ * @param blockNumber - The block number to read storage at.
140
+ * @param numberOfElements - Number of elements to read from the starting storage slot.
141
+ */
142
+ utilityStorageRead(contractAddress: AztecAddress, startStorageSlot: Fr, blockNumber: number, numberOfElements: number): Promise<Fr[]>;
143
+ utilityDebugLog(level: number, message: string, fields: Fr[]): void;
144
+ utilityFetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr): Promise<void>;
145
+ utilityValidateEnqueuedNotesAndEvents(contractAddress: AztecAddress, noteValidationRequestsArrayBaseSlot: Fr, eventValidationRequestsArrayBaseSlot: Fr): Promise<void>;
146
+ utilityBulkRetrieveLogs(contractAddress: AztecAddress, logRetrievalRequestsArrayBaseSlot: Fr, logRetrievalResponsesArrayBaseSlot: Fr): Promise<void>;
147
+ utilityStoreCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void>;
148
+ utilityLoadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null>;
149
+ utilityDeleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void>;
150
+ utilityCopyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number): Promise<void>;
151
+ utilityAes128Decrypt(ciphertext: Buffer, iv: Buffer, symKey: Buffer): Promise<Buffer>;
152
+ utilityGetSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point>;
153
+ }
154
+ //# sourceMappingURL=utility_execution_oracle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utility_execution_oracle.d.ts","sourceRoot":"","sources":["../../../src/contract_function_simulator/oracle/utility_execution_oracle.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,265 @@
1
+ import { Aes128 } from '@aztec/foundation/crypto';
2
+ import { Fr } from '@aztec/foundation/fields';
3
+ import { LogLevels, applyStringFormatting, createLogger } from '@aztec/foundation/log';
4
+ import { siloNullifier } from '@aztec/stdlib/hash';
5
+ import { UtilityContext } from '../noir-structs/utility_context.js';
6
+ import { pickNotes } from '../pick_notes.js';
7
+ /**
8
+ * The oracle for an execution of utility contract functions.
9
+ */ export class UtilityExecutionOracle {
10
+ contractAddress;
11
+ authWitnesses;
12
+ capsules;
13
+ executionDataProvider;
14
+ log;
15
+ scopes;
16
+ isMisc;
17
+ isUtility;
18
+ aztecNrDebugLog;
19
+ constructor(contractAddress, /** List of transient auth witnesses to be used during this simulation */ authWitnesses, capsules, executionDataProvider, log = createLogger('simulator:client_view_context'), scopes){
20
+ this.contractAddress = contractAddress;
21
+ this.authWitnesses = authWitnesses;
22
+ this.capsules = capsules;
23
+ this.executionDataProvider = executionDataProvider;
24
+ this.log = log;
25
+ this.scopes = scopes;
26
+ this.isMisc = true;
27
+ this.isUtility = true;
28
+ this.aztecNrDebugLog = createLogger('aztec-nr:debug_log');
29
+ }
30
+ utilityAssertCompatibleOracleVersion(version) {
31
+ this.executionDataProvider.assertCompatibleOracleVersion(version);
32
+ }
33
+ utilityGetRandomField() {
34
+ return Fr.random();
35
+ }
36
+ async utilityGetUtilityContext() {
37
+ const blockHeader = await this.executionDataProvider.getAnchorBlockHeader();
38
+ return UtilityContext.from({
39
+ blockNumber: blockHeader.globalVariables.blockNumber,
40
+ timestamp: blockHeader.globalVariables.timestamp,
41
+ contractAddress: this.contractAddress,
42
+ version: blockHeader.globalVariables.version,
43
+ chainId: blockHeader.globalVariables.chainId
44
+ });
45
+ }
46
+ /**
47
+ * Retrieve keys associated with a specific master public key and app address.
48
+ * @param pkMHash - The master public key hash.
49
+ * @returns A Promise that resolves to nullifier keys.
50
+ * @throws If the keys are not registered in the key store.
51
+ */ utilityGetKeyValidationRequest(pkMHash) {
52
+ return this.executionDataProvider.getKeyValidationRequest(pkMHash, this.contractAddress);
53
+ }
54
+ /**
55
+ * Fetches the index and sibling path of a leaf at a given block from a given tree.
56
+ * @param blockNumber - The block number at which to get the membership witness.
57
+ * @param treeId - Id of the tree to get the sibling path from.
58
+ * @param leafValue - The leaf value
59
+ * @returns The index and sibling path concatenated [index, sibling_path]
60
+ */ utilityGetMembershipWitness(blockNumber, treeId, leafValue) {
61
+ return this.executionDataProvider.getMembershipWitness(blockNumber, treeId, leafValue);
62
+ }
63
+ /**
64
+ * Returns a nullifier membership witness for a given nullifier at a given block.
65
+ * @param blockNumber - The block number at which to get the index.
66
+ * @param nullifier - Nullifier we try to find witness for.
67
+ * @returns The nullifier membership witness (if found).
68
+ */ async utilityGetNullifierMembershipWitness(blockNumber, nullifier) {
69
+ return await this.executionDataProvider.getNullifierMembershipWitness(blockNumber, nullifier);
70
+ }
71
+ /**
72
+ * Returns a low nullifier membership witness for a given nullifier at a given block.
73
+ * @param blockNumber - The block number at which to get the index.
74
+ * @param nullifier - Nullifier we try to find the low nullifier witness for.
75
+ * @returns The low nullifier membership witness (if found).
76
+ * @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
77
+ * list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
78
+ * we are trying to prove non-inclusion for.
79
+ */ async utilityGetLowNullifierMembershipWitness(blockNumber, nullifier) {
80
+ return await this.executionDataProvider.getLowNullifierMembershipWitness(blockNumber, nullifier);
81
+ }
82
+ /**
83
+ * Returns a public data tree witness for a given leaf slot at a given block.
84
+ * @param blockNumber - The block number at which to get the index.
85
+ * @param leafSlot - The slot of the public data tree to get the witness for.
86
+ * @returns - The witness
87
+ */ async utilityGetPublicDataWitness(blockNumber, leafSlot) {
88
+ return await this.executionDataProvider.getPublicDataWitness(blockNumber, leafSlot);
89
+ }
90
+ /**
91
+ * Fetches a block header of a given block.
92
+ * @param blockNumber - The number of a block of which to get the block header.
93
+ * @returns Block extracted from a block with block number `blockNumber`.
94
+ */ async utilityGetBlockHeader(blockNumber) {
95
+ const block = await this.executionDataProvider.getBlock(blockNumber);
96
+ if (!block) {
97
+ return undefined;
98
+ }
99
+ return block.getBlockHeader();
100
+ }
101
+ /**
102
+ * Retrieve the complete address associated to a given address.
103
+ * @param account - The account address.
104
+ * @returns A complete address associated with the input address.
105
+ * @throws An error if the account is not registered in the database.
106
+ */ utilityGetPublicKeysAndPartialAddress(account) {
107
+ return this.executionDataProvider.getCompleteAddress(account);
108
+ }
109
+ /**
110
+ * Returns a contract instance associated with an address or throws if not found.
111
+ * @param address - Address.
112
+ * @returns A contract instance.
113
+ */ utilityGetContractInstance(address) {
114
+ return this.executionDataProvider.getContractInstance(address);
115
+ }
116
+ /**
117
+ * Returns an auth witness for the given message hash. Checks on the list of transient witnesses
118
+ * for this transaction first, and falls back to the local database if not found.
119
+ * @param messageHash - Hash of the message to authenticate.
120
+ * @returns Authentication witness for the requested message hash.
121
+ */ utilityGetAuthWitness(messageHash) {
122
+ return Promise.resolve(this.authWitnesses.find((w)=>w.requestHash.equals(messageHash))?.witness);
123
+ }
124
+ /**
125
+ * Gets some notes for a contract address and storage slot.
126
+ * Returns a flattened array containing filtered notes.
127
+ *
128
+ * @remarks
129
+ * Check for pending notes with matching slot.
130
+ * Real notes coming from DB will have a leafIndex which
131
+ * represents their index in the note hash tree.
132
+ *
133
+ * @param storageSlot - The storage slot.
134
+ * @param numSelects - The number of valid selects in selectBy and selectValues.
135
+ * @param selectBy - An array of indices of the fields to selects.
136
+ * @param selectValues - The values to match.
137
+ * @param selectComparators - The comparators to use to match values.
138
+ * @param sortBy - An array of indices of the fields to sort.
139
+ * @param sortOrder - The order of the corresponding index in sortBy. (1: DESC, 2: ASC, 0: Do nothing)
140
+ * @param limit - The number of notes to retrieve per query.
141
+ * @param offset - The starting index for pagination.
142
+ * @param status - The status of notes to fetch.
143
+ * @returns Array of note data.
144
+ */ async utilityGetNotes(storageSlot, numSelects, selectByIndexes, selectByOffsets, selectByLengths, selectValues, selectComparators, sortByIndexes, sortByOffsets, sortByLengths, sortOrder, limit, offset, status) {
145
+ const dbNotes = await this.executionDataProvider.getNotes(this.contractAddress, storageSlot, status, this.scopes);
146
+ return pickNotes(dbNotes, {
147
+ selects: selectByIndexes.slice(0, numSelects).map((index, i)=>({
148
+ selector: {
149
+ index,
150
+ offset: selectByOffsets[i],
151
+ length: selectByLengths[i]
152
+ },
153
+ value: selectValues[i],
154
+ comparator: selectComparators[i]
155
+ })),
156
+ sorts: sortByIndexes.map((index, i)=>({
157
+ selector: {
158
+ index,
159
+ offset: sortByOffsets[i],
160
+ length: sortByLengths[i]
161
+ },
162
+ order: sortOrder[i]
163
+ })),
164
+ limit,
165
+ offset
166
+ });
167
+ }
168
+ /**
169
+ * Check if a nullifier exists in the nullifier tree.
170
+ * @param innerNullifier - The inner nullifier.
171
+ * @returns A boolean indicating whether the nullifier exists in the tree or not.
172
+ */ async utilityCheckNullifierExists(innerNullifier) {
173
+ const nullifier = await siloNullifier(this.contractAddress, innerNullifier);
174
+ const index = await this.executionDataProvider.getNullifierIndex(nullifier);
175
+ return index !== undefined;
176
+ }
177
+ /**
178
+ * Fetches a message from the executionDataProvider, given its key.
179
+ * @param contractAddress - Address of a contract by which the message was emitted.
180
+ * @param messageHash - Hash of the message.
181
+ * @param secret - Secret used to compute a nullifier.
182
+ * @dev Contract address and secret are only used to compute the nullifier to get non-nullified messages
183
+ * @returns The l1 to l2 membership witness (index of message in the tree and sibling path).
184
+ */ async utilityGetL1ToL2MembershipWitness(contractAddress, messageHash, secret) {
185
+ return await this.executionDataProvider.getL1ToL2MembershipWitness(contractAddress, messageHash, secret);
186
+ }
187
+ /**
188
+ * Read the public storage data.
189
+ * @param contractAddress - The address to read storage from.
190
+ * @param startStorageSlot - The starting storage slot.
191
+ * @param blockNumber - The block number to read storage at.
192
+ * @param numberOfElements - Number of elements to read from the starting storage slot.
193
+ */ async utilityStorageRead(contractAddress, startStorageSlot, blockNumber, numberOfElements) {
194
+ const values = [];
195
+ for(let i = 0n; i < numberOfElements; i++){
196
+ const storageSlot = new Fr(startStorageSlot.value + i);
197
+ const value = await this.executionDataProvider.getPublicStorageAt(blockNumber, contractAddress, storageSlot);
198
+ this.log.debug(`Oracle storage read: slot=${storageSlot.toString()} address-${contractAddress.toString()} value=${value}`);
199
+ values.push(value);
200
+ }
201
+ return values;
202
+ }
203
+ utilityDebugLog(level, message, fields) {
204
+ if (!LogLevels[level]) {
205
+ throw new Error(`Invalid debug log level: ${level}`);
206
+ }
207
+ const levelName = LogLevels[level];
208
+ this.aztecNrDebugLog[levelName](`${applyStringFormatting(message, fields)}`);
209
+ }
210
+ async utilityFetchTaggedLogs(pendingTaggedLogArrayBaseSlot) {
211
+ await this.executionDataProvider.syncTaggedLogs(this.contractAddress, pendingTaggedLogArrayBaseSlot, this.scopes);
212
+ await this.executionDataProvider.syncNoteNullifiers(this.contractAddress);
213
+ }
214
+ async utilityValidateEnqueuedNotesAndEvents(contractAddress, noteValidationRequestsArrayBaseSlot, eventValidationRequestsArrayBaseSlot) {
215
+ // TODO(#10727): allow other contracts to deliver notes
216
+ if (!this.contractAddress.equals(contractAddress)) {
217
+ throw new Error(`Got a note validation request from ${contractAddress}, expected ${this.contractAddress}`);
218
+ }
219
+ await this.executionDataProvider.validateEnqueuedNotesAndEvents(contractAddress, noteValidationRequestsArrayBaseSlot, eventValidationRequestsArrayBaseSlot);
220
+ }
221
+ async utilityBulkRetrieveLogs(contractAddress, logRetrievalRequestsArrayBaseSlot, logRetrievalResponsesArrayBaseSlot) {
222
+ // TODO(#10727): allow other contracts to process partial notes
223
+ if (!this.contractAddress.equals(contractAddress)) {
224
+ throw new Error(`Got a note validation request from ${contractAddress}, expected ${this.contractAddress}`);
225
+ }
226
+ await this.executionDataProvider.bulkRetrieveLogs(contractAddress, logRetrievalRequestsArrayBaseSlot, logRetrievalResponsesArrayBaseSlot);
227
+ }
228
+ utilityStoreCapsule(contractAddress, slot, capsule) {
229
+ if (!contractAddress.equals(this.contractAddress)) {
230
+ // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
231
+ throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
232
+ }
233
+ return this.executionDataProvider.storeCapsule(this.contractAddress, slot, capsule);
234
+ }
235
+ async utilityLoadCapsule(contractAddress, slot) {
236
+ if (!contractAddress.equals(this.contractAddress)) {
237
+ // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
238
+ throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
239
+ }
240
+ return(// TODO(#12425): On the following line, the pertinent capsule gets overshadowed by the transient one. Tackle this.
241
+ this.capsules.find((c)=>c.contractAddress.equals(contractAddress) && c.storageSlot.equals(slot))?.data ?? await this.executionDataProvider.loadCapsule(this.contractAddress, slot));
242
+ }
243
+ utilityDeleteCapsule(contractAddress, slot) {
244
+ if (!contractAddress.equals(this.contractAddress)) {
245
+ // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
246
+ throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
247
+ }
248
+ return this.executionDataProvider.deleteCapsule(this.contractAddress, slot);
249
+ }
250
+ utilityCopyCapsule(contractAddress, srcSlot, dstSlot, numEntries) {
251
+ if (!contractAddress.equals(this.contractAddress)) {
252
+ // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
253
+ throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
254
+ }
255
+ return this.executionDataProvider.copyCapsule(this.contractAddress, srcSlot, dstSlot, numEntries);
256
+ }
257
+ // TODO(#11849): consider replacing this oracle with a pure Noir implementation of aes decryption.
258
+ utilityAes128Decrypt(ciphertext, iv, symKey) {
259
+ const aes128 = new Aes128();
260
+ return aes128.decryptBufferCBC(ciphertext, iv, symKey);
261
+ }
262
+ utilityGetSharedSecret(address, ephPk) {
263
+ return this.executionDataProvider.getSharedSecret(address, ephPk);
264
+ }
265
+ }
@@ -0,0 +1,85 @@
1
+ import { Fr } from '@aztec/foundation/fields';
2
+ import { Comparator, type Note } from '@aztec/stdlib/note';
3
+ export interface PropertySelector {
4
+ index: number;
5
+ offset: number;
6
+ length: number;
7
+ }
8
+ /**
9
+ * Configuration for selecting values.
10
+ */
11
+ export interface Select {
12
+ /**
13
+ * Selector of the field to select and match.
14
+ */
15
+ selector: PropertySelector;
16
+ /**
17
+ * Required value of the field.
18
+ */
19
+ value: Fr;
20
+ /**
21
+ * The comparator to use
22
+ */
23
+ comparator: Comparator;
24
+ }
25
+ /**
26
+ * The order to sort an array.
27
+ */
28
+ export declare enum SortOrder {
29
+ NADA = 0,
30
+ DESC = 1,
31
+ ASC = 2
32
+ }
33
+ /**
34
+ * Configuration for sorting values.
35
+ */
36
+ export interface Sort {
37
+ /**
38
+ * Selector of the field to sort.
39
+ */
40
+ selector: PropertySelector;
41
+ /**
42
+ * Order to sort the field.
43
+ */
44
+ order: SortOrder;
45
+ }
46
+ /**
47
+ * Options for picking items from an array of BasicNoteData.
48
+ */
49
+ interface GetOptions {
50
+ /**
51
+ * Configurations for selecting items.
52
+ * Default: empty array.
53
+ */
54
+ selects?: Select[];
55
+ /**
56
+ * Configurations for sorting items.
57
+ * Default: empty array.
58
+ */
59
+ sorts?: Sort[];
60
+ /**
61
+ * The number of items to retrieve per query.
62
+ * Default: 0. No limit.
63
+ */
64
+ limit?: number;
65
+ /**
66
+ * The starting index for pagination.
67
+ * Default: 0.
68
+ */
69
+ offset?: number;
70
+ }
71
+ /**
72
+ * Data needed from to perform sort.
73
+ */
74
+ interface ContainsNote {
75
+ /**
76
+ * The note.
77
+ */
78
+ note: Note;
79
+ }
80
+ /**
81
+ * Pick from a note array a number of notes that meet the criteria.
82
+ */
83
+ export declare function pickNotes<T extends ContainsNote>(noteDatas: T[], { selects, sorts, limit, offset }: GetOptions): T[];
84
+ export {};
85
+ //# sourceMappingURL=pick_notes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pick_notes.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/pick_notes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,KAAK,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,QAAQ,EAAE,gBAAgB,CAAC;IAC3B;;OAEG;IACH,KAAK,EAAE,EAAE,CAAC;IACV;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;CACxB;AAED;;GAEG;AACH,oBAAY,SAAS;IACnB,IAAI,IAAI;IACR,IAAI,IAAI;IACR,GAAG,IAAI;CACR;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB;;OAEG;IACH,QAAQ,EAAE,gBAAgB,CAAC;IAC3B;;OAEG;IACH,KAAK,EAAE,SAAS,CAAC;CAClB;AAED;;GAEG;AACH,UAAU,UAAU;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;OAGG;IACH,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,UAAU,YAAY;IACpB;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;CACZ;AA8CD;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,YAAY,EAC9C,SAAS,EAAE,CAAC,EAAE,EACd,EAAE,OAAY,EAAE,KAAU,EAAE,KAAS,EAAE,MAAU,EAAE,EAAE,UAAU,GAC9D,CAAC,EAAE,CAIL"}
@@ -0,0 +1,51 @@
1
+ import { Fr } from '@aztec/foundation/fields';
2
+ import { Comparator } from '@aztec/stdlib/note';
3
+ /**
4
+ * The order to sort an array.
5
+ */ export var SortOrder = /*#__PURE__*/ function(SortOrder) {
6
+ SortOrder[SortOrder["NADA"] = 0] = "NADA";
7
+ SortOrder[SortOrder["DESC"] = 1] = "DESC";
8
+ SortOrder[SortOrder["ASC"] = 2] = "ASC";
9
+ return SortOrder;
10
+ }({});
11
+ const selectPropertyFromPackedNoteContent = (noteData, selector)=>{
12
+ const noteValueBuffer = noteData[selector.index].toBuffer();
13
+ const noteValue = noteValueBuffer.subarray(selector.offset, selector.offset + selector.length);
14
+ return Fr.fromBuffer(noteValue);
15
+ };
16
+ const selectNotes = (noteDatas, selects)=>noteDatas.filter((noteData)=>selects.every(({ selector, value, comparator })=>{
17
+ const noteValueFr = selectPropertyFromPackedNoteContent(noteData.note.items, selector);
18
+ const comparatorSelector = {
19
+ [Comparator.EQ]: ()=>noteValueFr.equals(value),
20
+ [Comparator.NEQ]: ()=>!noteValueFr.equals(value),
21
+ [Comparator.LT]: ()=>noteValueFr.lt(value),
22
+ [Comparator.LTE]: ()=>noteValueFr.lt(value) || noteValueFr.equals(value),
23
+ [Comparator.GT]: ()=>!noteValueFr.lt(value) && !noteValueFr.equals(value),
24
+ [Comparator.GTE]: ()=>!noteValueFr.lt(value)
25
+ };
26
+ return comparatorSelector[comparator]();
27
+ }));
28
+ const sortNotes = (a, b, sorts, level = 0)=>{
29
+ if (sorts[level] === undefined) {
30
+ return 0;
31
+ }
32
+ const { selector, order } = sorts[level];
33
+ if (order === 0) {
34
+ return 0;
35
+ }
36
+ const aValue = selectPropertyFromPackedNoteContent(a, selector);
37
+ const bValue = selectPropertyFromPackedNoteContent(b, selector);
38
+ const dir = order === 1 ? [
39
+ -1,
40
+ 1
41
+ ] : [
42
+ 1,
43
+ -1
44
+ ];
45
+ return aValue.toBigInt() === bValue.toBigInt() ? sortNotes(a, b, sorts, level + 1) : aValue.toBigInt() > bValue.toBigInt() ? dir[0] : dir[1];
46
+ };
47
+ /**
48
+ * Pick from a note array a number of notes that meet the criteria.
49
+ */ export function pickNotes(noteDatas, { selects = [], sorts = [], limit = 0, offset = 0 }) {
50
+ return selectNotes(noteDatas, selects).sort((a, b)=>sortNotes(a.note.items, b.note.items, sorts)).slice(offset, limit ? offset + limit : undefined);
51
+ }
@@ -0,0 +1,6 @@
1
+ import type { ContractOverrides } from '@aztec/stdlib/tx';
2
+ import type { ContractDataProvider } from '../storage/index.js';
3
+ export declare class ProxiedContractDataProviderFactory {
4
+ static create(contractDataProvider: ContractDataProvider, overrides?: ContractOverrides): ContractDataProvider;
5
+ }
6
+ //# sourceMappingURL=proxied_contract_data_source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxied_contract_data_source.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/proxied_contract_data_source.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAOhE,qBAAa,kCAAkC;IAC7C,MAAM,CAAC,MAAM,CAAC,oBAAoB,EAAE,oBAAoB,EAAE,SAAS,CAAC,EAAE,iBAAiB;CAqDxF"}
@@ -0,0 +1,62 @@
1
+ import { FunctionSelector } from '@aztec/stdlib/abi';
2
+ /*
3
+ * Proxy generator for a ContractDataProvider that allows overriding contract instances and artifacts, so
4
+ * the contract function simulator can execute different bytecode on certain addresses. An example use case
5
+ * would be overriding your own account contract so that valid signatures don't have to be provided while simulating.
6
+ */ export class ProxiedContractDataProviderFactory {
7
+ static create(contractDataProvider, overrides) {
8
+ if (!overrides) {
9
+ return contractDataProvider;
10
+ }
11
+ return new Proxy(contractDataProvider, {
12
+ get (target, prop) {
13
+ switch(prop){
14
+ case 'getContractInstance':
15
+ {
16
+ return async (address)=>{
17
+ if (overrides[address.toString()]) {
18
+ const { instance } = overrides[address.toString()];
19
+ instance.address = address;
20
+ const realInstance = await target.getContractInstance(address);
21
+ if (!realInstance) {
22
+ throw new Error(`Contract instance not found for address: ${address}`);
23
+ }
24
+ instance.currentContractClassId = realInstance.currentContractClassId;
25
+ instance.originalContractClassId = realInstance.originalContractClassId;
26
+ return instance;
27
+ } else {
28
+ return target.getContractInstance(address);
29
+ }
30
+ };
31
+ }
32
+ case 'getFunctionArtifact':
33
+ {
34
+ return async (contractAddress, selector)=>{
35
+ if (overrides[contractAddress.toString()]) {
36
+ const { artifact } = overrides[contractAddress.toString()];
37
+ const functions = artifact.functions;
38
+ for(let i = 0; i < functions.length; i++){
39
+ const fn = functions[i];
40
+ const fnSelector = await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters);
41
+ if (fnSelector.equals(selector)) {
42
+ return fn;
43
+ }
44
+ }
45
+ } else {
46
+ return target.getFunctionArtifact(contractAddress, selector);
47
+ }
48
+ };
49
+ }
50
+ default:
51
+ {
52
+ const value = Reflect.get(target, prop);
53
+ if (typeof value === 'function') {
54
+ return value.bind(target);
55
+ }
56
+ return value;
57
+ }
58
+ }
59
+ }
60
+ });
61
+ }
62
+ }
@@ -0,0 +1,9 @@
1
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
2
+ import type { NodeStats } from '@aztec/stdlib/tx';
3
+ export type ProxiedNode = AztecNode & {
4
+ getStats(): NodeStats;
5
+ };
6
+ export declare class ProxiedNodeFactory {
7
+ static create(node: AztecNode): ProxiedNode;
8
+ }
9
+ //# sourceMappingURL=proxied_node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxied_node.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/proxied_node.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAKlD,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG;IAAE,QAAQ,IAAI,SAAS,CAAA;CAAE,CAAC;AAEhE,qBAAa,kBAAkB;IAC7B,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,GAoBrB,WAAW;CAEpB"}