@aztec/simulator 0.0.0-test.1 → 0.0.1-commit.24de95ac

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 (466) hide show
  1. package/README.md +6 -0
  2. package/dest/client.d.ts +5 -3
  3. package/dest/client.d.ts.map +1 -1
  4. package/dest/client.js +4 -2
  5. package/dest/common/errors.d.ts +4 -7
  6. package/dest/common/errors.d.ts.map +1 -1
  7. package/dest/common/errors.js +51 -32
  8. package/dest/common/index.d.ts +0 -1
  9. package/dest/common/index.d.ts.map +1 -1
  10. package/dest/common/index.js +0 -1
  11. package/dest/private/acvm/acvm.d.ts +11 -5
  12. package/dest/private/acvm/acvm.d.ts.map +1 -1
  13. package/dest/private/acvm/acvm.js +10 -16
  14. package/dest/private/acvm/acvm_types.d.ts +1 -1
  15. package/dest/private/acvm/acvm_types.d.ts.map +1 -1
  16. package/dest/private/acvm/deserialize.d.ts +17 -18
  17. package/dest/private/acvm/deserialize.d.ts.map +1 -1
  18. package/dest/private/acvm/deserialize.js +31 -23
  19. package/dest/private/acvm/index.d.ts +0 -1
  20. package/dest/private/acvm/index.d.ts.map +1 -1
  21. package/dest/private/acvm/index.js +0 -1
  22. package/dest/private/acvm/serialize.d.ts +19 -2
  23. package/dest/private/acvm/serialize.d.ts.map +1 -1
  24. package/dest/private/acvm/serialize.js +53 -0
  25. package/dest/private/{providers/acvm_native.d.ts → acvm_native.d.ts} +9 -10
  26. package/dest/private/acvm_native.d.ts.map +1 -0
  27. package/dest/private/{providers/acvm_native.js → acvm_native.js} +26 -20
  28. package/dest/private/acvm_wasm.d.ts +15 -0
  29. package/dest/private/acvm_wasm.d.ts.map +1 -0
  30. package/dest/private/{providers/acvm_wasm.js → acvm_wasm.js} +22 -19
  31. package/dest/private/acvm_wasm_with_blobs.d.ts +20 -0
  32. package/dest/private/acvm_wasm_with_blobs.d.ts.map +1 -0
  33. package/dest/private/acvm_wasm_with_blobs.js +35 -0
  34. package/dest/private/circuit_recording/circuit_recorder.d.ts +108 -0
  35. package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -0
  36. package/dest/private/circuit_recording/circuit_recorder.js +209 -0
  37. package/dest/private/circuit_recording/file_circuit_recorder.d.ts +31 -0
  38. package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -0
  39. package/dest/private/circuit_recording/file_circuit_recorder.js +135 -0
  40. package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +5 -0
  41. package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -0
  42. package/dest/private/circuit_recording/memory_circuit_recorder.js +9 -0
  43. package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts +21 -0
  44. package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts.map +1 -0
  45. package/dest/private/circuit_recording/simulator_recorder_wrapper.js +44 -0
  46. package/dest/private/circuit_simulator.d.ts +35 -0
  47. package/dest/private/circuit_simulator.d.ts.map +1 -0
  48. package/dest/private/circuit_simulator.js +43 -0
  49. package/dest/private/factory.d.ts +12 -0
  50. package/dest/private/factory.d.ts.map +1 -0
  51. package/dest/private/{providers/factory.js → factory.js} +2 -2
  52. package/dest/public/avm/avm_context.d.ts +5 -5
  53. package/dest/public/avm/avm_context.d.ts.map +1 -1
  54. package/dest/public/avm/avm_contract_call_result.d.ts +4 -2
  55. package/dest/public/avm/avm_contract_call_result.d.ts.map +1 -1
  56. package/dest/public/avm/avm_contract_call_result.js +11 -7
  57. package/dest/public/avm/avm_execution_environment.d.ts +3 -1
  58. package/dest/public/avm/avm_execution_environment.d.ts.map +1 -1
  59. package/dest/public/avm/avm_execution_environment.js +7 -2
  60. package/dest/public/avm/avm_gas.d.ts +4 -20
  61. package/dest/public/avm/avm_gas.d.ts.map +1 -1
  62. package/dest/public/avm/avm_gas.js +27 -35
  63. package/dest/public/avm/avm_machine_state.d.ts +2 -0
  64. package/dest/public/avm/avm_machine_state.d.ts.map +1 -1
  65. package/dest/public/avm/avm_machine_state.js +2 -0
  66. package/dest/public/avm/avm_memory_types.d.ts +98 -87
  67. package/dest/public/avm/avm_memory_types.d.ts.map +1 -1
  68. package/dest/public/avm/avm_memory_types.js +17 -6
  69. package/dest/public/avm/avm_simulator.d.ts +4 -5
  70. package/dest/public/avm/avm_simulator.d.ts.map +1 -1
  71. package/dest/public/avm/avm_simulator.js +23 -35
  72. package/dest/public/avm/avm_simulator_interface.d.ts +9 -0
  73. package/dest/public/avm/avm_simulator_interface.d.ts.map +1 -0
  74. package/dest/public/avm/avm_simulator_interface.js +3 -0
  75. package/dest/public/avm/errors.d.ts +6 -30
  76. package/dest/public/avm/errors.d.ts.map +1 -1
  77. package/dest/public/avm/errors.js +7 -57
  78. package/dest/public/avm/fixtures/avm_simulation_tester.d.ts +5 -4
  79. package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -1
  80. package/dest/public/avm/fixtures/avm_simulation_tester.js +12 -14
  81. package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +6 -4
  82. package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -1
  83. package/dest/public/avm/fixtures/base_avm_simulation_tester.js +37 -14
  84. package/dest/public/avm/fixtures/initializers.d.ts +43 -0
  85. package/dest/public/avm/fixtures/initializers.d.ts.map +1 -0
  86. package/dest/public/avm/fixtures/initializers.js +42 -0
  87. package/dest/public/avm/fixtures/utils.d.ts +38 -0
  88. package/dest/public/avm/fixtures/utils.d.ts.map +1 -0
  89. package/dest/public/avm/fixtures/utils.js +95 -0
  90. package/dest/public/avm/index.d.ts +0 -2
  91. package/dest/public/avm/index.d.ts.map +1 -1
  92. package/dest/public/avm/index.js +0 -2
  93. package/dest/public/avm/opcodes/accrued_substate.d.ts +2 -2
  94. package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
  95. package/dest/public/avm/opcodes/accrued_substate.js +28 -25
  96. package/dest/public/avm/opcodes/addressing_mode.d.ts +11 -7
  97. package/dest/public/avm/opcodes/addressing_mode.d.ts.map +1 -1
  98. package/dest/public/avm/opcodes/addressing_mode.js +46 -26
  99. package/dest/public/avm/opcodes/arithmetic.d.ts +11 -1
  100. package/dest/public/avm/opcodes/arithmetic.d.ts.map +1 -1
  101. package/dest/public/avm/opcodes/arithmetic.js +16 -2
  102. package/dest/public/avm/opcodes/bitwise.d.ts +5 -13
  103. package/dest/public/avm/opcodes/bitwise.d.ts.map +1 -1
  104. package/dest/public/avm/opcodes/bitwise.js +19 -26
  105. package/dest/public/avm/opcodes/comparators.d.ts.map +1 -1
  106. package/dest/public/avm/opcodes/comparators.js +3 -3
  107. package/dest/public/avm/opcodes/contract.d.ts +1 -2
  108. package/dest/public/avm/opcodes/contract.d.ts.map +1 -1
  109. package/dest/public/avm/opcodes/contract.js +9 -10
  110. package/dest/public/avm/opcodes/control_flow.d.ts.map +1 -1
  111. package/dest/public/avm/opcodes/control_flow.js +10 -8
  112. package/dest/public/avm/opcodes/conversion.d.ts +1 -0
  113. package/dest/public/avm/opcodes/conversion.d.ts.map +1 -1
  114. package/dest/public/avm/opcodes/conversion.js +267 -3
  115. package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -1
  116. package/dest/public/avm/opcodes/ec_add.js +6 -6
  117. package/dest/public/avm/opcodes/environment_getters.d.ts +2 -2
  118. package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -1
  119. package/dest/public/avm/opcodes/environment_getters.js +17 -19
  120. package/dest/public/avm/opcodes/external_calls.d.ts +8 -7
  121. package/dest/public/avm/opcodes/external_calls.d.ts.map +1 -1
  122. package/dest/public/avm/opcodes/external_calls.js +39 -34
  123. package/dest/public/avm/opcodes/hashing.d.ts.map +1 -1
  124. package/dest/public/avm/opcodes/hashing.js +6 -6
  125. package/dest/public/avm/opcodes/instruction.d.ts +14 -10
  126. package/dest/public/avm/opcodes/instruction.d.ts.map +1 -1
  127. package/dest/public/avm/opcodes/instruction.js +23 -19
  128. package/dest/public/avm/opcodes/memory.d.ts +4 -4
  129. package/dest/public/avm/opcodes/memory.d.ts.map +1 -1
  130. package/dest/public/avm/opcodes/memory.js +37 -33
  131. package/dest/public/avm/opcodes/misc.d.ts +2 -1
  132. package/dest/public/avm/opcodes/misc.d.ts.map +1 -1
  133. package/dest/public/avm/opcodes/misc.js +41 -16
  134. package/dest/public/avm/opcodes/storage.d.ts.map +1 -1
  135. package/dest/public/avm/opcodes/storage.js +7 -5
  136. package/dest/public/avm/revert_reason.d.ts +18 -0
  137. package/dest/public/avm/revert_reason.d.ts.map +1 -0
  138. package/dest/public/avm/revert_reason.js +38 -0
  139. package/dest/public/avm/serialization/buffer_cursor.d.ts +0 -2
  140. package/dest/public/avm/serialization/buffer_cursor.d.ts.map +1 -1
  141. package/dest/public/avm/serialization/bytecode_serialization.d.ts +2 -6
  142. package/dest/public/avm/serialization/bytecode_serialization.d.ts.map +1 -1
  143. package/dest/public/avm/serialization/bytecode_serialization.js +70 -69
  144. package/dest/public/avm/serialization/instruction_serialization.d.ts +13 -4
  145. package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -1
  146. package/dest/public/avm/serialization/instruction_serialization.js +70 -35
  147. package/dest/public/avm/test_utils.d.ts +10 -13
  148. package/dest/public/avm/test_utils.d.ts.map +1 -1
  149. package/dest/public/avm/test_utils.js +16 -24
  150. package/dest/public/db_interfaces.d.ts +56 -0
  151. package/dest/public/db_interfaces.d.ts.map +1 -0
  152. package/dest/public/db_interfaces.js +3 -0
  153. package/dest/public/debug_fn_name.d.ts +5 -0
  154. package/dest/public/debug_fn_name.d.ts.map +1 -0
  155. package/dest/public/debug_fn_name.js +9 -0
  156. package/dest/public/executor_metrics.d.ts +10 -3
  157. package/dest/public/executor_metrics.d.ts.map +1 -1
  158. package/dest/public/executor_metrics.js +37 -6
  159. package/dest/public/executor_metrics_interface.d.ts +9 -0
  160. package/dest/public/executor_metrics_interface.d.ts.map +1 -0
  161. package/dest/public/executor_metrics_interface.js +1 -0
  162. package/dest/public/fixtures/amm_test.d.ts +10 -0
  163. package/dest/public/fixtures/amm_test.d.ts.map +1 -0
  164. package/dest/public/fixtures/amm_test.js +213 -0
  165. package/dest/public/fixtures/bulk_test.d.ts +6 -0
  166. package/dest/public/fixtures/bulk_test.d.ts.map +1 -0
  167. package/dest/public/fixtures/bulk_test.js +326 -0
  168. package/dest/public/fixtures/custom_bytecode_tester.d.ts +12 -0
  169. package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -0
  170. package/dest/public/fixtures/custom_bytecode_tester.js +29 -0
  171. package/dest/public/fixtures/custom_bytecode_tests.d.ts +9 -0
  172. package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -0
  173. package/dest/public/fixtures/custom_bytecode_tests.js +109 -0
  174. package/dest/public/fixtures/index.d.ts +7 -0
  175. package/dest/public/fixtures/index.d.ts.map +1 -1
  176. package/dest/public/fixtures/index.js +7 -0
  177. package/dest/public/fixtures/minimal_public_tx.d.ts +10 -0
  178. package/dest/public/fixtures/minimal_public_tx.d.ts.map +1 -0
  179. package/dest/public/fixtures/minimal_public_tx.js +29 -0
  180. package/dest/public/fixtures/public_tx_simulation_tester.d.ts +35 -13
  181. package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
  182. package/dest/public/fixtures/public_tx_simulation_tester.js +96 -71
  183. package/dest/public/{avm/fixtures → fixtures}/simple_contract_data_source.d.ts +6 -6
  184. package/dest/public/fixtures/simple_contract_data_source.d.ts.map +1 -0
  185. package/dest/public/{avm/fixtures → fixtures}/simple_contract_data_source.js +31 -10
  186. package/dest/public/fixtures/token_test.d.ts +8 -0
  187. package/dest/public/fixtures/token_test.d.ts.map +1 -0
  188. package/dest/public/fixtures/token_test.js +95 -0
  189. package/dest/public/fixtures/utils.d.ts +16 -3
  190. package/dest/public/fixtures/utils.d.ts.map +1 -1
  191. package/dest/public/fixtures/utils.js +100 -58
  192. package/dest/public/hinting_db_sources.d.ts +70 -0
  193. package/dest/public/hinting_db_sources.d.ts.map +1 -0
  194. package/dest/public/hinting_db_sources.js +297 -0
  195. package/dest/public/index.d.ts +4 -8
  196. package/dest/public/index.d.ts.map +1 -1
  197. package/dest/public/index.js +4 -7
  198. package/dest/public/public_db_sources.d.ts +30 -39
  199. package/dest/public/public_db_sources.d.ts.map +1 -1
  200. package/dest/public/public_db_sources.js +151 -67
  201. package/dest/public/public_errors.d.ts +12 -0
  202. package/dest/public/public_errors.d.ts.map +1 -0
  203. package/dest/public/public_errors.js +13 -0
  204. package/dest/public/public_processor/guarded_merkle_tree.d.ts +49 -0
  205. package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -0
  206. package/dest/public/public_processor/guarded_merkle_tree.js +108 -0
  207. package/dest/public/public_processor/public_processor.d.ts +25 -30
  208. package/dest/public/public_processor/public_processor.d.ts.map +1 -1
  209. package/dest/public/public_processor/public_processor.js +141 -96
  210. package/dest/public/public_processor/public_processor_metrics.d.ts +2 -2
  211. package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
  212. package/dest/public/public_processor/public_processor_metrics.js +1 -1
  213. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +41 -0
  214. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +1 -0
  215. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +89 -0
  216. package/dest/public/public_tx_simulator/index.d.ts +4 -0
  217. package/dest/public/public_tx_simulator/index.d.ts.map +1 -0
  218. package/dest/public/public_tx_simulator/index.js +2 -0
  219. package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +24 -0
  220. package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts.map +1 -0
  221. package/dest/public/public_tx_simulator/measured_public_tx_simulator.js +51 -0
  222. package/dest/public/public_tx_simulator/public_tx_context.d.ts +19 -29
  223. package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
  224. package/dest/public/public_tx_simulator/public_tx_context.js +63 -91
  225. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +45 -47
  226. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
  227. package/dest/public/public_tx_simulator/public_tx_simulator.js +209 -184
  228. package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts +9 -0
  229. package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts.map +1 -0
  230. package/dest/public/public_tx_simulator/public_tx_simulator_interface.js +1 -0
  231. package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts +21 -0
  232. package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts.map +1 -0
  233. package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.js +39 -0
  234. package/dest/public/side_effect_errors.d.ts +41 -1
  235. package/dest/public/side_effect_errors.d.ts.map +1 -1
  236. package/dest/public/side_effect_errors.js +70 -1
  237. package/dest/public/side_effect_trace.d.ts +20 -65
  238. package/dest/public/side_effect_trace.d.ts.map +1 -1
  239. package/dest/public/side_effect_trace.js +71 -121
  240. package/dest/public/side_effect_trace_interface.d.ts +11 -22
  241. package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
  242. package/dest/public/state_manager/index.d.ts +2 -0
  243. package/dest/public/state_manager/index.d.ts.map +1 -0
  244. package/dest/public/state_manager/index.js +1 -0
  245. package/dest/public/{avm/journal → state_manager}/nullifiers.d.ts +2 -5
  246. package/dest/public/state_manager/nullifiers.d.ts.map +1 -0
  247. package/dest/public/{avm/journal → state_manager}/nullifiers.js +3 -8
  248. package/dest/public/{avm/journal → state_manager}/public_storage.d.ts +2 -2
  249. package/dest/public/state_manager/public_storage.d.ts.map +1 -0
  250. package/dest/public/{avm/journal/journal.d.ts → state_manager/state_manager.d.ts} +42 -85
  251. package/dest/public/state_manager/state_manager.d.ts.map +1 -0
  252. package/dest/public/state_manager/state_manager.js +391 -0
  253. package/dest/public/test_executor_metrics.d.ts +54 -0
  254. package/dest/public/test_executor_metrics.d.ts.map +1 -0
  255. package/dest/public/test_executor_metrics.js +306 -0
  256. package/dest/public/unique_class_ids.d.ts.map +1 -1
  257. package/dest/public/utils.d.ts +2 -4
  258. package/dest/public/utils.d.ts.map +1 -1
  259. package/dest/public/utils.js +4 -21
  260. package/dest/server.d.ts +6 -3
  261. package/dest/server.d.ts.map +1 -1
  262. package/dest/server.js +5 -2
  263. package/dest/testing.d.ts +2 -0
  264. package/dest/testing.d.ts.map +1 -0
  265. package/dest/testing.js +1 -0
  266. package/package.json +36 -31
  267. package/src/client.ts +5 -3
  268. package/src/common/errors.ts +79 -44
  269. package/src/common/index.ts +0 -1
  270. package/src/private/acvm/acvm.ts +17 -32
  271. package/src/private/acvm/acvm_types.ts +1 -1
  272. package/src/private/acvm/deserialize.ts +35 -29
  273. package/src/private/acvm/index.ts +0 -1
  274. package/src/private/acvm/serialize.ts +63 -0
  275. package/src/private/{providers/acvm_native.ts → acvm_native.ts} +47 -24
  276. package/src/private/acvm_wasm.ts +72 -0
  277. package/src/private/acvm_wasm_with_blobs.ts +54 -0
  278. package/src/private/circuit_recording/circuit_recorder.ts +260 -0
  279. package/src/private/circuit_recording/file_circuit_recorder.ts +158 -0
  280. package/src/private/circuit_recording/memory_circuit_recorder.ts +11 -0
  281. package/src/private/circuit_recording/simulator_recorder_wrapper.ts +91 -0
  282. package/src/private/circuit_simulator.ts +90 -0
  283. package/src/private/{providers/factory.ts → factory.ts} +6 -6
  284. package/src/public/avm/avm_context.ts +4 -4
  285. package/src/public/avm/avm_contract_call_result.ts +17 -5
  286. package/src/public/avm/avm_execution_environment.ts +10 -1
  287. package/src/public/avm/avm_gas.ts +23 -35
  288. package/src/public/avm/avm_machine_state.ts +5 -0
  289. package/src/public/avm/avm_memory_types.ts +19 -6
  290. package/src/public/avm/avm_simulator.ts +44 -54
  291. package/src/public/avm/avm_simulator_interface.ts +8 -0
  292. package/src/public/avm/errors.ts +8 -77
  293. package/src/public/avm/fixtures/avm_simulation_tester.ts +23 -20
  294. package/src/public/avm/fixtures/base_avm_simulation_tester.ts +45 -12
  295. package/src/public/avm/fixtures/initializers.ts +104 -0
  296. package/src/public/avm/fixtures/utils.ts +150 -0
  297. package/src/public/avm/index.ts +0 -2
  298. package/src/public/avm/opcodes/accrued_substate.ts +64 -29
  299. package/src/public/avm/opcodes/addressing_mode.ts +56 -32
  300. package/src/public/avm/opcodes/arithmetic.ts +24 -2
  301. package/src/public/avm/opcodes/bitwise.ts +33 -29
  302. package/src/public/avm/opcodes/comparators.ts +6 -3
  303. package/src/public/avm/opcodes/contract.ts +10 -7
  304. package/src/public/avm/opcodes/control_flow.ts +19 -10
  305. package/src/public/avm/opcodes/conversion.ts +27 -3
  306. package/src/public/avm/opcodes/ec_add.ts +9 -6
  307. package/src/public/avm/opcodes/environment_getters.ts +27 -22
  308. package/src/public/avm/opcodes/external_calls.ts +61 -29
  309. package/src/public/avm/opcodes/hashing.ts +28 -8
  310. package/src/public/avm/opcodes/instruction.ts +31 -21
  311. package/src/public/avm/opcodes/memory.ts +71 -32
  312. package/src/public/avm/opcodes/misc.ts +60 -18
  313. package/src/public/avm/opcodes/storage.ts +22 -6
  314. package/src/public/avm/revert_reason.ts +55 -0
  315. package/src/public/avm/serialization/buffer_cursor.ts +4 -1
  316. package/src/public/avm/serialization/bytecode_serialization.ts +72 -74
  317. package/src/public/avm/serialization/instruction_serialization.ts +75 -34
  318. package/src/public/avm/test_utils.ts +24 -41
  319. package/src/public/db_interfaces.ts +61 -0
  320. package/src/{common → public}/debug_fn_name.ts +7 -7
  321. package/src/public/executor_metrics.ts +55 -6
  322. package/src/public/executor_metrics_interface.ts +14 -0
  323. package/src/public/fixtures/amm_test.ts +331 -0
  324. package/src/public/fixtures/bulk_test.ts +169 -0
  325. package/src/public/fixtures/custom_bytecode_tester.ts +49 -0
  326. package/src/public/fixtures/custom_bytecode_tests.ts +135 -0
  327. package/src/public/fixtures/index.ts +7 -0
  328. package/src/public/fixtures/minimal_public_tx.ts +36 -0
  329. package/src/public/fixtures/public_tx_simulation_tester.ts +158 -113
  330. package/src/public/{avm/fixtures → fixtures}/simple_contract_data_source.ts +36 -18
  331. package/src/public/fixtures/token_test.ts +140 -0
  332. package/src/public/fixtures/utils.ts +141 -68
  333. package/src/public/hinting_db_sources.ts +505 -0
  334. package/src/public/index.ts +9 -8
  335. package/src/public/public_db_sources.ts +196 -97
  336. package/src/public/public_errors.ts +14 -0
  337. package/src/public/public_processor/guarded_merkle_tree.ts +153 -0
  338. package/src/public/public_processor/public_processor.ts +191 -153
  339. package/src/public/public_processor/public_processor_metrics.ts +2 -2
  340. package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +128 -0
  341. package/src/public/public_tx_simulator/index.ts +3 -0
  342. package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +109 -0
  343. package/src/public/public_tx_simulator/public_tx_context.ts +160 -193
  344. package/src/public/public_tx_simulator/public_tx_simulator.ts +294 -220
  345. package/src/public/public_tx_simulator/public_tx_simulator_interface.ts +11 -0
  346. package/src/public/public_tx_simulator/telemetry_public_tx_simulator.ts +63 -0
  347. package/src/public/side_effect_errors.ts +91 -1
  348. package/src/public/side_effect_trace.ts +94 -320
  349. package/src/public/side_effect_trace_interface.ts +10 -58
  350. package/src/public/state_manager/index.ts +1 -0
  351. package/src/public/{avm/journal → state_manager}/nullifiers.ts +5 -11
  352. package/src/public/{avm/journal → state_manager}/public_storage.ts +2 -2
  353. package/src/public/state_manager/state_manager.ts +560 -0
  354. package/src/public/test_executor_metrics.ts +395 -0
  355. package/src/public/utils.ts +5 -21
  356. package/src/server.ts +6 -3
  357. package/src/testing.ts +1 -0
  358. package/dest/common/db_interfaces.d.ts +0 -80
  359. package/dest/common/db_interfaces.d.ts.map +0 -1
  360. package/dest/common/db_interfaces.js +0 -1
  361. package/dest/common/debug_fn_name.d.ts +0 -5
  362. package/dest/common/debug_fn_name.d.ts.map +0 -1
  363. package/dest/common/debug_fn_name.js +0 -6
  364. package/dest/common/message_load_oracle_inputs.d.ts +0 -15
  365. package/dest/common/message_load_oracle_inputs.d.ts.map +0 -1
  366. package/dest/common/message_load_oracle_inputs.js +0 -15
  367. package/dest/private/acvm/oracle/index.d.ts +0 -14
  368. package/dest/private/acvm/oracle/index.d.ts.map +0 -1
  369. package/dest/private/acvm/oracle/index.js +0 -2
  370. package/dest/private/acvm/oracle/oracle.d.ts +0 -49
  371. package/dest/private/acvm/oracle/oracle.d.ts.map +0 -1
  372. package/dest/private/acvm/oracle/oracle.js +0 -263
  373. package/dest/private/acvm/oracle/typed_oracle.d.ts +0 -83
  374. package/dest/private/acvm/oracle/typed_oracle.d.ts.map +0 -1
  375. package/dest/private/acvm/oracle/typed_oracle.js +0 -132
  376. package/dest/private/execution_data_provider.d.ts +0 -261
  377. package/dest/private/execution_data_provider.d.ts.map +0 -1
  378. package/dest/private/execution_data_provider.js +0 -14
  379. package/dest/private/execution_note_cache.d.ts +0 -93
  380. package/dest/private/execution_note_cache.d.ts.map +0 -1
  381. package/dest/private/execution_note_cache.js +0 -180
  382. package/dest/private/hashed_values_cache.d.ts +0 -28
  383. package/dest/private/hashed_values_cache.d.ts.map +0 -1
  384. package/dest/private/hashed_values_cache.js +0 -46
  385. package/dest/private/index.d.ts +0 -13
  386. package/dest/private/index.d.ts.map +0 -1
  387. package/dest/private/index.js +0 -12
  388. package/dest/private/pick_notes.d.ts +0 -85
  389. package/dest/private/pick_notes.d.ts.map +0 -1
  390. package/dest/private/pick_notes.js +0 -51
  391. package/dest/private/private_execution.d.ts +0 -25
  392. package/dest/private/private_execution.d.ts.map +0 -1
  393. package/dest/private/private_execution.js +0 -92
  394. package/dest/private/private_execution_oracle.d.ts +0 -215
  395. package/dest/private/private_execution_oracle.d.ts.map +0 -1
  396. package/dest/private/private_execution_oracle.js +0 -382
  397. package/dest/private/providers/acvm_native.d.ts.map +0 -1
  398. package/dest/private/providers/acvm_wasm.d.ts +0 -15
  399. package/dest/private/providers/acvm_wasm.d.ts.map +0 -1
  400. package/dest/private/providers/acvm_wasm_with_blobs.d.ts +0 -19
  401. package/dest/private/providers/acvm_wasm_with_blobs.d.ts.map +0 -1
  402. package/dest/private/providers/acvm_wasm_with_blobs.js +0 -32
  403. package/dest/private/providers/factory.d.ts +0 -12
  404. package/dest/private/providers/factory.d.ts.map +0 -1
  405. package/dest/private/providers/simulation_provider.d.ts +0 -19
  406. package/dest/private/providers/simulation_provider.d.ts.map +0 -1
  407. package/dest/private/providers/simulation_provider.js +0 -24
  408. package/dest/private/simulator.d.ts +0 -34
  409. package/dest/private/simulator.d.ts.map +0 -1
  410. package/dest/private/simulator.js +0 -76
  411. package/dest/private/unconstrained_execution.d.ts +0 -10
  412. package/dest/private/unconstrained_execution.d.ts.map +0 -1
  413. package/dest/private/unconstrained_execution.js +0 -27
  414. package/dest/private/unconstrained_execution_oracle.d.ts +0 -161
  415. package/dest/private/unconstrained_execution_oracle.d.ts.map +0 -1
  416. package/dest/private/unconstrained_execution_oracle.js +0 -258
  417. package/dest/public/avm/bytecode_utils.d.ts +0 -5
  418. package/dest/public/avm/bytecode_utils.d.ts.map +0 -1
  419. package/dest/public/avm/bytecode_utils.js +0 -17
  420. package/dest/public/avm/fixtures/index.d.ts +0 -84
  421. package/dest/public/avm/fixtures/index.d.ts.map +0 -1
  422. package/dest/public/avm/fixtures/index.js +0 -175
  423. package/dest/public/avm/fixtures/simple_contract_data_source.d.ts.map +0 -1
  424. package/dest/public/avm/journal/index.d.ts +0 -2
  425. package/dest/public/avm/journal/index.d.ts.map +0 -1
  426. package/dest/public/avm/journal/index.js +0 -1
  427. package/dest/public/avm/journal/journal.d.ts.map +0 -1
  428. package/dest/public/avm/journal/journal.js +0 -486
  429. package/dest/public/avm/journal/nullifiers.d.ts.map +0 -1
  430. package/dest/public/avm/journal/public_storage.d.ts.map +0 -1
  431. package/dest/public/bytecode_errors.d.ts +0 -4
  432. package/dest/public/bytecode_errors.d.ts.map +0 -1
  433. package/dest/public/bytecode_errors.js +0 -6
  434. package/dest/public/execution.d.ts +0 -108
  435. package/dest/public/execution.d.ts.map +0 -1
  436. package/dest/public/execution.js +0 -9
  437. package/dest/test/utils.d.ts +0 -13
  438. package/dest/test/utils.d.ts.map +0 -1
  439. package/dest/test/utils.js +0 -22
  440. package/src/common/db_interfaces.ts +0 -94
  441. package/src/common/message_load_oracle_inputs.ts +0 -15
  442. package/src/private/acvm/oracle/index.ts +0 -16
  443. package/src/private/acvm/oracle/oracle.ts +0 -455
  444. package/src/private/acvm/oracle/typed_oracle.ts +0 -259
  445. package/src/private/execution_data_provider.ts +0 -323
  446. package/src/private/execution_note_cache.ts +0 -217
  447. package/src/private/hashed_values_cache.ts +0 -55
  448. package/src/private/index.ts +0 -16
  449. package/src/private/pick_notes.ts +0 -141
  450. package/src/private/private_execution.ts +0 -151
  451. package/src/private/private_execution_oracle.ts +0 -614
  452. package/src/private/providers/acvm_wasm.ts +0 -63
  453. package/src/private/providers/acvm_wasm_with_blobs.ts +0 -50
  454. package/src/private/providers/simulation_provider.ts +0 -45
  455. package/src/private/simulator.ts +0 -147
  456. package/src/private/unconstrained_execution.ts +0 -50
  457. package/src/private/unconstrained_execution_oracle.ts +0 -373
  458. package/src/public/avm/bytecode_utils.ts +0 -17
  459. package/src/public/avm/fixtures/index.ts +0 -296
  460. package/src/public/avm/journal/index.ts +0 -1
  461. package/src/public/avm/journal/journal.ts +0 -742
  462. package/src/public/avm/opcodes/.eslintrc.cjs +0 -8
  463. package/src/public/bytecode_errors.ts +0 -6
  464. package/src/public/execution.ts +0 -140
  465. package/src/test/utils.ts +0 -36
  466. /package/dest/public/{avm/journal → state_manager}/public_storage.js +0 -0
package/README.md CHANGED
@@ -47,3 +47,9 @@ Same steps as any other library. They are detailed [here](../README.md#developme
47
47
  ### Testing
48
48
 
49
49
  Same steps as any other library. They are detailed [here](../README.md#tests)
50
+
51
+ ### Benchmarking
52
+
53
+ ```
54
+ LOG_LEVEL=info yarn test src/public/public_tx_simulator/apps_tests/bench.test.ts
55
+ ```
package/dest/client.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- export * from './private/index.js';
2
- export { WASMSimulator } from './private/providers/acvm_wasm.js';
3
- export { type SimulationProvider } from './private/providers/simulation_provider.js';
1
+ export * from './private/acvm/index.js';
2
+ export { WASMSimulator } from './private/acvm_wasm.js';
3
+ export { SimulatorRecorderWrapper } from './private/circuit_recording/simulator_recorder_wrapper.js';
4
+ export { MemoryCircuitRecorder } from './private/circuit_recording/memory_circuit_recorder.js';
5
+ export { type CircuitSimulator, type DecodedError } from './private/circuit_simulator.js';
4
6
  export * from './common/index.js';
5
7
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AACrF,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,2DAA2D,CAAC;AACrG,OAAO,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAC;AAC/F,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC1F,cAAc,mBAAmB,CAAC"}
package/dest/client.js CHANGED
@@ -1,3 +1,5 @@
1
- export * from './private/index.js';
2
- export { WASMSimulator } from './private/providers/acvm_wasm.js';
1
+ export * from './private/acvm/index.js';
2
+ export { WASMSimulator } from './private/acvm_wasm.js';
3
+ export { SimulatorRecorderWrapper } from './private/circuit_recording/simulator_recorder_wrapper.js';
4
+ export { MemoryCircuitRecorder } from './private/circuit_recording/memory_circuit_recorder.js';
3
5
  export * from './common/index.js';
@@ -1,7 +1,7 @@
1
1
  import type { Fr } from '@aztec/foundation/fields';
2
- import type { BrilligFunctionId, FunctionAbi, FunctionDebugMetadata, OpcodeLocation } from '@aztec/stdlib/abi';
2
+ import type { RawAssertionPayload } from '@aztec/noir-acvm_js';
3
+ import type { BrilligFunctionId, DebugFileMap, DebugInfo, FunctionAbi, OpcodeLocation } from '@aztec/stdlib/abi';
3
4
  import { type FailingFunction, type NoirCallStack, SimulationError, type SourceCodeLocation } from '@aztec/stdlib/errors';
4
- import type { RawAssertionPayload } from '@noir-lang/acvm_js';
5
5
  /**
6
6
  * An error that occurred during the execution of a function.
7
7
  * @param message - the error message
@@ -42,12 +42,9 @@ export declare function traverseCauseChain(error: Error, callback: (error: Error
42
42
  */
43
43
  export declare function createSimulationError(error: Error, revertData?: Fr[]): SimulationError;
44
44
  /**
45
- * Extracts the source code locations for an array of opcode locations
46
- * @param opcodeLocations - The opcode locations that caused the error.
47
- * @param debug - The debug metadata of the function.
48
- * @returns The source code locations.
45
+ * Resolves the source code locations from an array of opcode locations
49
46
  */
50
- export declare function resolveOpcodeLocations(opcodeLocations: OpcodeLocation[], debug: FunctionDebugMetadata, brilligFunctionId?: BrilligFunctionId): SourceCodeLocation[];
47
+ export declare function resolveOpcodeLocations(opcodeLocations: OpcodeLocation[], debug: DebugInfo, files: DebugFileMap, brilligFunctionId?: BrilligFunctionId): SourceCodeLocation[];
51
48
  export declare function resolveAssertionMessage(errorPayload: RawAssertionPayload, abi: FunctionAbi): string | undefined;
52
49
  export declare function resolveAssertionMessageFromRevertData(revertData: Fr[], abi: FunctionAbi): string | undefined;
53
50
  export declare function resolveAssertionMessageFromError(err: Error, abi: FunctionAbi): string;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/common/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/G,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,eAAe,EACf,KAAK,kBAAkB,EACxB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAG9D;;;;;;;GAOG;AACH,qBAAa,cAAe,SAAQ,KAAK;IAGrC;;OAEG;IACI,eAAe,EAAE,eAAe;IACvC;;OAEG;IACI,aAAa,CAAC;gBARrB,OAAO,EAAE,MAAM;IACf;;OAEG;IACI,eAAe,EAAE,eAAe;IACvC;;OAEG;IACI,aAAa,CAAC,2BAAe,EACpC,OAAO,CAAC,EAAE,YAAY;CAIzB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,QAUhF;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,eAAe,CAgBtF;AAuDD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,cAAc,EAAE,EACjC,KAAK,EAAE,qBAAqB,EAC5B,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,kBAAkB,EAAE,CAItB;AAED,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,mBAAmB,EAAE,GAAG,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAW/G;AAED,wBAAgB,qCAAqC,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAc5G;AAED,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,WAAW,GAAG,MAAM,CAMrF"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/common/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,WAAW,EAEX,cAAc,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,eAAe,EACf,KAAK,kBAAkB,EACxB,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;GAOG;AACH,qBAAa,cAAe,SAAQ,KAAK;IAGrC;;OAEG;IACI,eAAe,EAAE,eAAe;IACvC;;OAEG;IACI,aAAa,CAAC,EAAE,aAAa;gBARpC,OAAO,EAAE,MAAM;IACf;;OAEG;IACI,eAAe,EAAE,eAAe;IACvC;;OAEG;IACI,aAAa,CAAC,EAAE,aAAa,YAAA,EACpC,OAAO,CAAC,EAAE,YAAY;CAIzB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,QAUhF;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,eAAe,CAgBtF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,cAAc,EAAE,EACjC,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,YAAY,EACnB,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,kBAAkB,EAAE,CAkBtB;AAwED,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,mBAAmB,EAAE,GAAG,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAW/G;AAED,wBAAgB,qCAAqC,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAc5G;AAED,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,WAAW,GAAG,MAAM,CAMrF"}
@@ -1,6 +1,6 @@
1
1
  import { jsonStringify } from '@aztec/foundation/json-rpc';
2
+ import { abiDecodeError } from '@aztec/noir-noirc_abi';
2
3
  import { SimulationError } from '@aztec/stdlib/errors';
3
- import { abiDecodeError } from '@noir-lang/noirc_abi';
4
4
  /**
5
5
  * An error that occurred during the execution of a function.
6
6
  * @param message - the error message
@@ -56,30 +56,27 @@ import { abiDecodeError } from '@noir-lang/noirc_abi';
56
56
  });
57
57
  }
58
58
  /**
59
- * Extracts a brillig location from an opcode location.
60
- * @param opcodeLocation - The opcode location to extract from. It should be in the format `acirLocation.brilligLocation` or `acirLocation`.
61
- * @returns The brillig location if the opcode location contains one.
62
- */ function extractBrilligLocation(opcodeLocation) {
63
- const splitted = opcodeLocation.split('.');
64
- if (splitted.length === 2) {
65
- return splitted[1];
66
- }
67
- return undefined;
68
- }
69
- /**
70
- * Extracts the call stack from the location of a failing opcode and the debug metadata.
71
- * One opcode can point to multiple calls due to inlining.
72
- */ function getSourceCodeLocationsFromOpcodeLocation(opcodeLocation, debug, brilligFunctionId) {
73
- const { debugSymbols, files } = debug;
74
- let callStack = debugSymbols.locations[opcodeLocation] || [];
75
- if (callStack.length === 0) {
76
- const brilligLocation = extractBrilligLocation(opcodeLocation);
77
- if (brilligFunctionId !== undefined && brilligLocation !== undefined) {
78
- callStack = debugSymbols.brillig_locations[brilligFunctionId][brilligLocation] || [];
59
+ * Resolves the source code locations from an array of opcode locations
60
+ */ export function resolveOpcodeLocations(opcodeLocations, debug, files, brilligFunctionId) {
61
+ let locations = opcodeLocations.flatMap((opcodeLocation)=>getSourceCodeLocationsFromOpcodeLocation(opcodeLocation, debug, files, brilligFunctionId));
62
+ // Adds the acir call stack if the last location is a brillig opcode
63
+ if (locations.length > 0) {
64
+ const decomposedOpcodeLocation = opcodeLocations[opcodeLocations.length - 1].split('.');
65
+ if (decomposedOpcodeLocation.length === 2) {
66
+ const acirCallstackId = debug.acir_locations[decomposedOpcodeLocation[0]];
67
+ if (acirCallstackId !== undefined) {
68
+ const callStack = debug.location_tree.locations[acirCallstackId];
69
+ const acirCallstack = getCallStackFromLocationNode(callStack, debug.location_tree.locations, files);
70
+ locations = acirCallstack.concat(locations);
71
+ }
79
72
  }
80
73
  }
81
- return callStack.map((call)=>{
82
- const { file: fileId, span } = call;
74
+ return locations;
75
+ }
76
+ function getCallStackFromLocationNode(callStack, locationTree, files) {
77
+ const result = [];
78
+ while(callStack.parent !== null){
79
+ const { file: fileId, span } = callStack.value;
83
80
  const { path, source } = files[fileId];
84
81
  const locationText = source.substring(span.start, span.end);
85
82
  const precedingText = source.substring(0, span.start);
@@ -87,22 +84,44 @@ import { abiDecodeError } from '@noir-lang/noirc_abi';
87
84
  // Lines and columns in stacks are one indexed.
88
85
  const line = previousLines.length;
89
86
  const column = previousLines[previousLines.length - 1].length + 1;
90
- return {
87
+ // Unshift since we are exploring child nodes first
88
+ result.unshift({
91
89
  filePath: path,
92
90
  line,
93
91
  column,
94
92
  fileSource: source,
95
93
  locationText
96
- };
97
- });
94
+ });
95
+ callStack = locationTree[callStack.parent];
96
+ }
97
+ return result;
98
98
  }
99
99
  /**
100
- * Extracts the source code locations for an array of opcode locations
101
- * @param opcodeLocations - The opcode locations that caused the error.
102
- * @param debug - The debug metadata of the function.
103
- * @returns The source code locations.
104
- */ export function resolveOpcodeLocations(opcodeLocations, debug, brilligFunctionId) {
105
- return opcodeLocations.flatMap((opcodeLocation)=>getSourceCodeLocationsFromOpcodeLocation(opcodeLocation, debug, brilligFunctionId));
100
+ * Extracts the call stack from the location of a failing opcode and the debug metadata.
101
+ * One opcode can point to multiple calls due to inlining.
102
+ */ function getSourceCodeLocationsFromOpcodeLocation(opcodeLocation, debug, files, brilligFunctionId) {
103
+ let callStackID = debug.acir_locations[opcodeLocation];
104
+ const brilligLocation = extractBrilligLocation(opcodeLocation);
105
+ if (brilligFunctionId !== undefined && brilligLocation !== undefined) {
106
+ callStackID = debug.brillig_locations[brilligFunctionId][brilligLocation];
107
+ if (callStackID === undefined) {
108
+ return [];
109
+ }
110
+ }
111
+ if (callStackID === undefined) {
112
+ return [];
113
+ }
114
+ const callStack = debug.location_tree.locations[callStackID];
115
+ return getCallStackFromLocationNode(callStack, debug.location_tree.locations, files);
116
+ }
117
+ /**
118
+ * Extracts a brillig location from an opcode location.
119
+ */ function extractBrilligLocation(opcodeLocation) {
120
+ const splitted = opcodeLocation.split('.');
121
+ if (splitted.length === 2) {
122
+ return splitted[1];
123
+ }
124
+ return undefined;
106
125
  }
107
126
  export function resolveAssertionMessage(errorPayload, abi) {
108
127
  const decoded = abiDecodeError({
@@ -1,4 +1,3 @@
1
1
  export * from './errors.js';
2
2
  export * from './stats/index.js';
3
- export * from './message_load_oracle_inputs.js';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iCAAiC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC"}
@@ -1,3 +1,2 @@
1
1
  export * from './errors.js';
2
2
  export * from './stats/index.js';
3
- export * from './message_load_oracle_inputs.js';
@@ -1,14 +1,14 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
1
+ import { type ExecutionError, type ForeignCallInput, type ForeignCallOutput } from '@aztec/noir-acvm_js';
3
2
  import type { FunctionDebugMetadata } from '@aztec/stdlib/abi';
4
3
  import type { NoirCallStack } from '@aztec/stdlib/errors';
5
- import { type ExecutionError, type ForeignCallInput, type ForeignCallOutput } from '@noir-lang/acvm_js';
6
4
  import type { ACVMWitness } from './acvm_types.js';
7
- import type { ORACLE_NAMES } from './oracle/index.js';
8
5
  /**
9
6
  * The callback interface for the ACIR.
10
7
  */
11
- export type ACIRCallback = Record<ORACLE_NAMES, (...args: ForeignCallInput[]) => void | Promise<void> | ForeignCallOutput | ForeignCallOutput[] | Promise<ForeignCallOutput> | Promise<ForeignCallOutput[]>>;
8
+ export type ACIRCallback = Record<string, (...args: ForeignCallInput[]) => Promise<ForeignCallOutput[]>>;
9
+ export type ACIRCallbackStats = {
10
+ times: number[];
11
+ };
12
12
  /**
13
13
  * The result of executing an ACIR.
14
14
  */
@@ -20,9 +20,15 @@ export interface ACIRExecutionResult {
20
20
  */
21
21
  partialWitness: ACVMWitness;
22
22
  returnWitness: ACVMWitness;
23
+ oracles?: Record<string, ACIRCallbackStats>;
23
24
  }
24
25
  /**
25
26
  * The function call that executes an ACIR.
27
+ * @param acir - The ACIR circuit bytecode to execute.
28
+ * @param initialWitness - The initial witness map defining all of the inputs to `circuit`.
29
+ * @param callback - A callback to process any foreign calls from the circuit.
30
+ * @returns The solved witness calculated by executing the circuit on the provided inputs, as well as the return
31
+ * witness indices as specified by the circuit.
26
32
  */
27
33
  export declare function acvm(acir: Buffer, initialWitness: ACVMWitness, callback: ACIRCallback): Promise<ACIRExecutionResult>;
28
34
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"acvm.d.ts","sourceRoot":"","sources":["../../../src/private/acvm/acvm.ts"],"names":[],"mappings":";;AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAEvB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAC/B,YAAY,EACZ,CACE,GAAG,IAAI,EAAE,gBAAgB,EAAE,KAEzB,IAAI,GACJ,OAAO,CAAC,IAAI,CAAC,GACb,iBAAiB,GACjB,iBAAiB,EAAE,GACnB,OAAO,CAAC,iBAAiB,CAAC,GAC1B,OAAO,CAAC,iBAAiB,EAAE,CAAC,CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,cAAc,EAAE,WAAW,CAAC;IAC5B,aAAa,EAAE,WAAW,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAsB,IAAI,CACxB,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,WAAW,EAC3B,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,mBAAmB,CAAC,CAkD9B;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,KAAK,GAAG,cAAc,EAC7B,KAAK,CAAC,EAAE,qBAAqB,GAC5B,aAAa,GAAG,SAAS,CAc3B"}
1
+ {"version":3,"file":"acvm.d.ts","sourceRoot":"","sources":["../../../src/private/acvm/acvm.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAEvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,gBAAgB,EAAE,KAAK,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC;AAEzG,MAAM,MAAM,iBAAiB,GAAG;IAAE,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,cAAc,EAAE,WAAW,CAAC;IAC5B,aAAa,EAAE,WAAW,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CAC7C;AAED;;;;;;;GAOG;AACH,wBAAsB,IAAI,CACxB,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,WAAW,EAC3B,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,mBAAmB,CAAC,CAwC9B;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,KAAK,GAAG,cAAc,EAC7B,KAAK,CAAC,EAAE,qBAAqB,GAC5B,aAAa,GAAG,SAAS,CAc3B"}
@@ -1,29 +1,23 @@
1
1
  import { createLogger } from '@aztec/foundation/log';
2
- import { executeCircuitWithReturnWitness } from '@noir-lang/acvm_js';
2
+ import { executeCircuitWithReturnWitness } from '@aztec/noir-acvm_js';
3
3
  import { resolveOpcodeLocations, traverseCauseChain } from '../../common/errors.js';
4
4
  /**
5
5
  * The function call that executes an ACIR.
6
+ * @param acir - The ACIR circuit bytecode to execute.
7
+ * @param initialWitness - The initial witness map defining all of the inputs to `circuit`.
8
+ * @param callback - A callback to process any foreign calls from the circuit.
9
+ * @returns The solved witness calculated by executing the circuit on the provided inputs, as well as the return
10
+ * witness indices as specified by the circuit.
6
11
  */ export async function acvm(acir, initialWitness, callback) {
7
12
  const logger = createLogger('simulator:acvm');
8
- const solvedAndReturnWitness = await executeCircuitWithReturnWitness(acir, initialWitness, async (name, args)=>{
13
+ const solvedAndReturnWitness = await executeCircuitWithReturnWitness(acir, initialWitness, (name, args)=>{
9
14
  try {
10
15
  logger.debug(`Oracle callback ${name}`);
11
16
  const oracleFunction = callback[name];
12
17
  if (!oracleFunction) {
13
18
  throw new Error(`Oracle callback ${name} not found`);
14
19
  }
15
- const result = await oracleFunction.call(callback, ...args);
16
- if (typeof result === 'undefined') {
17
- return [];
18
- } else if (result instanceof Array && !result.every((item)=>typeof item === 'string')) {
19
- // We are dealing with a nested array which means that we do not need it wrap it in another array as to have
20
- // the nested array structure it is already "wrapped".
21
- return result;
22
- } else {
23
- return [
24
- result
25
- ];
26
- }
20
+ return oracleFunction.call(callback, ...args);
27
21
  } catch (err) {
28
22
  let typedError;
29
23
  if (err instanceof Error) {
@@ -63,8 +57,8 @@ import { resolveOpcodeLocations, traverseCauseChain } from '../../common/errors.
63
57
  return callStack;
64
58
  }
65
59
  try {
66
- return resolveOpcodeLocations(callStack, debug, brilligFunctionId);
67
- } catch (err) {
60
+ return resolveOpcodeLocations(callStack, debug.debugSymbols, debug.files, brilligFunctionId);
61
+ } catch {
68
62
  return callStack;
69
63
  }
70
64
  }
@@ -1,4 +1,4 @@
1
- import type { WitnessMap } from '@noir-lang/acvm_js';
1
+ import type { WitnessMap } from '@aztec/noir-acvm_js';
2
2
  /**
3
3
  * ACVMField
4
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"acvm_types.d.ts","sourceRoot":"","sources":["../../../src/private/acvm/acvm_types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC"}
1
+ {"version":3,"file":"acvm_types.d.ts","sourceRoot":"","sources":["../../../src/private/acvm/acvm_types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC"}
@@ -1,23 +1,5 @@
1
1
  import { Fr } from '@aztec/foundation/fields';
2
2
  import type { ACVMField, ACVMWitness } from './acvm_types.js';
3
- /**
4
- * Converts an ACVM field to a Fr.
5
- * @param field - The ACVM field to convert.
6
- * @returns The Fr.
7
- */
8
- export declare function fromACVMField(field: ACVMField): Fr;
9
- /**
10
- * Converts a field to a number.
11
- * @param fr - The field to convert.
12
- * @returns The number.
13
- * TODO(#4102): Nuke this once block number is big int.
14
- */
15
- export declare function frToNumber(fr: Fr): number;
16
- /**
17
- * Converts a field to a boolean.
18
- * @param fr - The field to convert.
19
- */
20
- export declare function frToBoolean(fr: Fr): boolean;
21
3
  /**
22
4
  * Converts a Noir BoundedVec of Fields into an Fr array. Note that BoundedVecs are structs, and therefore translated as
23
5
  * two separate ACVMField values (an array and a single field).
@@ -27,10 +9,27 @@ export declare function frToBoolean(fr: Fr): boolean;
27
9
  * @returns An array with the same content as the Noir version. Elements past the length are discarded.
28
10
  */
29
11
  export declare function fromBoundedVec(storage: ACVMField[], length: ACVMField): Fr[];
12
+ /**
13
+ * Converts a Noir BoundedVec of unsigned integers into a Buffer. Note that BoundedVecs are structs, and therefore
14
+ * translated as two separate ACVMField values (an array and a single field).
15
+ *
16
+ * @param storage The array with the BoundedVec's storage (i.e. BoundedVec::storage())
17
+ * @param length The length of the BoundedVec (i.e. BoundedVec::len())
18
+ * @param uintBitSize If it's an array of Noir u8's, put `8`, etc.
19
+ * @returns A buffer containing the unsigned integers tightly packed
20
+ */
21
+ export declare function fromUintBoundedVec(storage: ACVMField[], length: ACVMField, uintBitSize: number): Buffer;
30
22
  /**
31
23
  * Transforms a witness map to its field elements.
32
24
  * @param witness - The witness to extract from.
33
25
  * @returns The return values.
34
26
  */
35
27
  export declare function witnessMapToFields(witness: ACVMWitness): Fr[];
28
+ /**
29
+ * Converts an array of Noir unsigned integers to a single tightly-packed buffer.
30
+ * @param uintBitSize If it's an array of Noir u8's, put `8`, etc.
31
+ * @returns A buffer where each byte is correctly represented as a single byte in the buffer.
32
+ * Copy of the function in txe/src/util/encoding.ts.
33
+ */
34
+ export declare function fromUintArray(obj: ACVMField[], uintBitSize: number): Buffer;
36
35
  //# sourceMappingURL=deserialize.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deserialize.d.ts","sourceRoot":"","sources":["../../../src/private/acvm/deserialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9D;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,EAAE,CAElD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,MAAM,CAEzC;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAE3C;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,SAAS,GAAG,EAAE,EAAE,CAE5E;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,EAAE,EAAE,CAG7D"}
1
+ {"version":3,"file":"deserialize.d.ts","sourceRoot":"","sources":["../../../src/private/acvm/deserialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9D;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,SAAS,GAAG,EAAE,EAAE,CAE5E;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAOvG;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,EAAE,EAAE,CAG7D;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAM3E"}
@@ -1,25 +1,5 @@
1
1
  import { Fr } from '@aztec/foundation/fields';
2
- /**
3
- * Converts an ACVM field to a Fr.
4
- * @param field - The ACVM field to convert.
5
- * @returns The Fr.
6
- */ export function fromACVMField(field) {
7
- return Fr.fromBuffer(Buffer.from(field.slice(2), 'hex'));
8
- }
9
- /**
10
- * Converts a field to a number.
11
- * @param fr - The field to convert.
12
- * @returns The number.
13
- * TODO(#4102): Nuke this once block number is big int.
14
- */ export function frToNumber(fr) {
15
- return Number(fr.value);
16
- }
17
- /**
18
- * Converts a field to a boolean.
19
- * @param fr - The field to convert.
20
- */ export function frToBoolean(fr) {
21
- return fr.toBigInt() === BigInt(1);
22
- }
2
+ import { hexToBuffer } from '@aztec/foundation/string';
23
3
  /**
24
4
  * Converts a Noir BoundedVec of Fields into an Fr array. Note that BoundedVecs are structs, and therefore translated as
25
5
  * two separate ACVMField values (an array and a single field).
@@ -28,7 +8,23 @@ import { Fr } from '@aztec/foundation/fields';
28
8
  * @param length The length of the BoundedVec (i.e. BoundedVec::len())
29
9
  * @returns An array with the same content as the Noir version. Elements past the length are discarded.
30
10
  */ export function fromBoundedVec(storage, length) {
31
- return storage.slice(0, frToNumber(fromACVMField(length))).map(fromACVMField);
11
+ return storage.slice(0, Fr.fromString(length).toNumber()).map(Fr.fromString);
12
+ }
13
+ /**
14
+ * Converts a Noir BoundedVec of unsigned integers into a Buffer. Note that BoundedVecs are structs, and therefore
15
+ * translated as two separate ACVMField values (an array and a single field).
16
+ *
17
+ * @param storage The array with the BoundedVec's storage (i.e. BoundedVec::storage())
18
+ * @param length The length of the BoundedVec (i.e. BoundedVec::len())
19
+ * @param uintBitSize If it's an array of Noir u8's, put `8`, etc.
20
+ * @returns A buffer containing the unsigned integers tightly packed
21
+ */ export function fromUintBoundedVec(storage, length, uintBitSize) {
22
+ if (uintBitSize % 8 !== 0) {
23
+ throw new Error(`u${uintBitSize} is not a supported type in Noir`);
24
+ }
25
+ const uintByteSize = uintBitSize / 8;
26
+ const boundedStorage = storage.slice(0, Fr.fromString(length).toNumber());
27
+ return Buffer.concat(boundedStorage.map((str)=>hexToBuffer(str).subarray(-uintByteSize)));
32
28
  }
33
29
  /**
34
30
  * Transforms a witness map to its field elements.
@@ -38,5 +34,17 @@ import { Fr } from '@aztec/foundation/fields';
38
34
  const sortedKeys = [
39
35
  ...witness.keys()
40
36
  ].sort((a, b)=>a - b);
41
- return sortedKeys.map((key)=>witness.get(key)).map(fromACVMField);
37
+ return sortedKeys.map((key)=>witness.get(key)).map(Fr.fromString);
38
+ }
39
+ /**
40
+ * Converts an array of Noir unsigned integers to a single tightly-packed buffer.
41
+ * @param uintBitSize If it's an array of Noir u8's, put `8`, etc.
42
+ * @returns A buffer where each byte is correctly represented as a single byte in the buffer.
43
+ * Copy of the function in txe/src/util/encoding.ts.
44
+ */ export function fromUintArray(obj, uintBitSize) {
45
+ if (uintBitSize % 8 !== 0) {
46
+ throw new Error(`u${uintBitSize} is not a supported type in Noir`);
47
+ }
48
+ const uintByteSize = uintBitSize / 8;
49
+ return Buffer.concat(obj.map((str)=>hexToBuffer(str).slice(-uintByteSize)));
42
50
  }
@@ -1,6 +1,5 @@
1
1
  export { extractCallStack, type ACIRCallback, type ACIRExecutionResult } from './acvm.js';
2
2
  export * from './acvm_types.js';
3
3
  export * from './deserialize.js';
4
- export * from './oracle/index.js';
5
4
  export * from './serialize.js';
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/private/acvm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAC1F,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/private/acvm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAC1F,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
@@ -1,5 +1,4 @@
1
1
  export { extractCallStack } from './acvm.js';
2
2
  export * from './acvm_types.js';
3
3
  export * from './deserialize.js';
4
- export * from './oracle/index.js';
5
4
  export * from './serialize.js';
@@ -1,5 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
1
  import type { EthAddress } from '@aztec/foundation/eth-address';
4
2
  import { Fr } from '@aztec/foundation/fields';
5
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
@@ -21,4 +19,23 @@ export declare function toACVMFieldSingleOrArray(value: Fr | Fr[]): string | str
21
19
  * @returns The witness.
22
20
  */
23
21
  export declare function toACVMWitness(witnessStartIndex: number, fields: Parameters<typeof toACVMField>[0][]): Map<number, string>;
22
+ export declare function bufferToU8Array(buffer: Buffer): ACVMField[];
23
+ export declare function bufferToBoundedVec(buffer: Buffer, maxLen: number): [ACVMField[], ACVMField];
24
+ /**
25
+ * Converts a ForeignCallArray into a tuple which represents a nr BoundedVec.
26
+ * If the input array is shorter than the maxLen, it pads the result with zeros,
27
+ * so that nr can correctly coerce this result into a BoundedVec.
28
+ * @param bVecStorage - The array underlying the BoundedVec.
29
+ * @param maxLen - the max length of the BoundedVec.
30
+ * @returns a tuple representing a BoundedVec.
31
+ */
32
+ export declare function arrayToBoundedVec(bVecStorage: ACVMField[], maxLen: number): [ACVMField[], ACVMField];
33
+ /**
34
+ * Converts an array of arrays representing Noir BoundedVec of nested arrays into its Noir serialized form.
35
+ * @param bVecStorage - The array underlying the BoundedVec.
36
+ * @param maxLen - The max length of the BoundedVec (max num of the nested arrays in the BoundedVec).
37
+ * @param nestedArrayLength - The length of the nested arrays (each nested array has to have the same length).
38
+ * @returns Serialized BoundedVec following Noir intrinsic serialization.
39
+ */
40
+ export declare function arrayOfArraysToBoundedVecOfArrays(bVecStorage: ACVMField[][], maxLen: number, nestedArrayLength: number): [ACVMField[], ACVMField];
24
41
  //# sourceMappingURL=serialize.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../src/private/acvm/serialize.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAgBjD;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,YAAY,GAAG,UAAU,GAAG,EAAE,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GACrF,SAAS,CAYX;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,qBAExD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,iBAAiB,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,uBAKnG"}
1
+ {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../src/private/acvm/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAgBjD;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,YAAY,GAAG,UAAU,GAAG,EAAE,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GACrF,SAAS,CAYX;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,qBAExD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,iBAAiB,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,uBAKnG;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,CAE3D;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,SAAS,EAAE,EAAE,SAAS,CAAC,CAG3F;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,SAAS,EAAE,EAAE,SAAS,CAAC,CASpG;AAED;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAC/C,WAAW,EAAE,SAAS,EAAE,EAAE,EAC1B,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,MAAM,GACxB,CAAC,SAAS,EAAE,EAAE,SAAS,CAAC,CAsB1B"}
@@ -44,3 +44,56 @@ import { Fr } from '@aztec/foundation/fields';
44
44
  return witness;
45
45
  }, new Map());
46
46
  }
47
+ export function bufferToU8Array(buffer) {
48
+ return Array.from(buffer).map((byte)=>toACVMField(BigInt(byte)));
49
+ }
50
+ export function bufferToBoundedVec(buffer, maxLen) {
51
+ const u8Array = bufferToU8Array(buffer);
52
+ return arrayToBoundedVec(u8Array, maxLen);
53
+ }
54
+ /**
55
+ * Converts a ForeignCallArray into a tuple which represents a nr BoundedVec.
56
+ * If the input array is shorter than the maxLen, it pads the result with zeros,
57
+ * so that nr can correctly coerce this result into a BoundedVec.
58
+ * @param bVecStorage - The array underlying the BoundedVec.
59
+ * @param maxLen - the max length of the BoundedVec.
60
+ * @returns a tuple representing a BoundedVec.
61
+ */ export function arrayToBoundedVec(bVecStorage, maxLen) {
62
+ if (bVecStorage.length > maxLen) {
63
+ throw new Error(`Array of length ${bVecStorage.length} larger than maxLen ${maxLen}`);
64
+ }
65
+ const lengthDiff = maxLen - bVecStorage.length;
66
+ const zeroPaddingArray = Array(lengthDiff).fill(toACVMField(BigInt(0)));
67
+ const storage = bVecStorage.concat(zeroPaddingArray);
68
+ const len = toACVMField(BigInt(bVecStorage.length));
69
+ return [
70
+ storage,
71
+ len
72
+ ];
73
+ }
74
+ /**
75
+ * Converts an array of arrays representing Noir BoundedVec of nested arrays into its Noir serialized form.
76
+ * @param bVecStorage - The array underlying the BoundedVec.
77
+ * @param maxLen - The max length of the BoundedVec (max num of the nested arrays in the BoundedVec).
78
+ * @param nestedArrayLength - The length of the nested arrays (each nested array has to have the same length).
79
+ * @returns Serialized BoundedVec following Noir intrinsic serialization.
80
+ */ export function arrayOfArraysToBoundedVecOfArrays(bVecStorage, maxLen, nestedArrayLength) {
81
+ if (bVecStorage.length > maxLen) {
82
+ throw new Error(`Array of length ${bVecStorage.length} larger than maxLen ${maxLen}`);
83
+ }
84
+ // Check that all nested arrays have length nestedArrayLength
85
+ if (!bVecStorage.every((nestedArray)=>nestedArray.length === nestedArrayLength)) {
86
+ throw new Error(`Nested array length passed in from Noir does not correspond to the length obtained in TS: ${nestedArrayLength} !== ${bVecStorage[0].length}`);
87
+ }
88
+ // Flatten the array of arrays
89
+ const flattenedStorage = bVecStorage.flat();
90
+ // Calculate and add padding
91
+ const numFieldsToPad = maxLen * nestedArrayLength - flattenedStorage.length;
92
+ const flattenedStorageWithPadding = flattenedStorage.concat(Array(numFieldsToPad).fill(toACVMField(BigInt(0))));
93
+ // Return flattened array with padding and length
94
+ const len = toACVMField(BigInt(bVecStorage.length));
95
+ return [
96
+ flattenedStorageWithPadding,
97
+ len
98
+ ];
99
+ }
@@ -1,10 +1,9 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- import type { NoirCompiledCircuit } from '@aztec/stdlib/noir';
4
- import type { WitnessMap } from '@noir-lang/types';
5
- import type { ACIRCallback, ACIRExecutionResult } from '../acvm/acvm.js';
6
- import type { ACVMWitness } from '../acvm/acvm_types.js';
7
- import type { SimulationProvider } from './simulation_provider.js';
1
+ import type { ForeignCallHandler, WitnessMap } from '@aztec/noir-acvm_js';
2
+ import type { FunctionArtifactWithContractName } from '@aztec/stdlib/abi';
3
+ import type { NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
4
+ import type { ACIRCallback, ACIRExecutionResult } from './acvm/acvm.js';
5
+ import type { ACVMWitness } from './acvm/acvm_types.js';
6
+ import type { CircuitSimulator } from './circuit_simulator.js';
8
7
  export declare enum ACVM_RESULT {
9
8
  SUCCESS = 0,
10
9
  FAILURE = 1
@@ -29,12 +28,12 @@ export type ACVMResult = ACVMSuccess | ACVMFailure;
29
28
  * @returns The completed partial witness outputted from the circuit
30
29
  */
31
30
  export declare function executeNativeCircuit(inputWitness: WitnessMap, bytecode: Buffer, workingDirectory: string, pathToAcvm: string, outputFilename?: string): Promise<ACVMResult>;
32
- export declare class NativeACVMSimulator implements SimulationProvider {
31
+ export declare class NativeACVMSimulator implements CircuitSimulator {
33
32
  private workingDirectory;
34
33
  private pathToAcvm;
35
34
  private witnessFilename?;
36
35
  constructor(workingDirectory: string, pathToAcvm: string, witnessFilename?: string | undefined);
37
- executeProtocolCircuit(input: WitnessMap, compiledCircuit: NoirCompiledCircuit): Promise<WitnessMap>;
38
- executeUserCircuit(_acir: Buffer, _initialWitness: ACVMWitness, _callback: ACIRCallback): Promise<ACIRExecutionResult>;
36
+ executeProtocolCircuit(input: ACVMWitness, artifact: NoirCompiledCircuitWithName, callback: ForeignCallHandler | undefined): Promise<ACVMSuccess>;
37
+ executeUserCircuit(_input: ACVMWitness, _artifact: FunctionArtifactWithContractName, _callback: ACIRCallback): Promise<ACIRExecutionResult>;
39
38
  }
40
39
  //# sourceMappingURL=acvm_native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acvm_native.d.ts","sourceRoot":"","sources":["../../src/private/acvm_native.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAKtE,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI/D,oBAAY,WAAW;IACrB,OAAO,IAAA;IACP,OAAO,IAAA;CACR;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,WAAW,CAAC;AAmBnD;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,UAAU,EACxB,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,EACxB,UAAU,EAAE,MAAM,EAClB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,UAAU,CAAC,CA8ErB;AAED,qBAAa,mBAAoB,YAAW,gBAAgB;IAExD,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,eAAe,CAAC;gBAFhB,gBAAgB,EAAE,MAAM,EACxB,UAAU,EAAE,MAAM,EAClB,eAAe,CAAC,EAAE,MAAM,YAAA;IAG5B,sBAAsB,CAC1B,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,2BAA2B,EACrC,QAAQ,EAAE,kBAAkB,GAAG,SAAS,GACvC,OAAO,CAAC,WAAW,CAAC;IA6BvB,kBAAkB,CAChB,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,gCAAgC,EAC3C,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,mBAAmB,CAAC;CAGhC"}