@aztec/simulator 0.0.1-commit.c31f2472 → 0.0.1-commit.c52d6e7

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 (350) hide show
  1. package/README.md +4 -4
  2. package/dest/client.d.ts +1 -3
  3. package/dest/client.d.ts.map +1 -1
  4. package/dest/client.js +0 -2
  5. package/dest/private/acvm_wasm.d.ts +1 -1
  6. package/dest/private/acvm_wasm.d.ts.map +1 -1
  7. package/dest/private/acvm_wasm.js +3 -1
  8. package/dest/private/circuit_recording/circuit_recorder.d.ts +36 -23
  9. package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -1
  10. package/dest/private/circuit_recording/circuit_recorder.js +65 -69
  11. package/dest/private/circuit_recording/file_circuit_recorder.d.ts +7 -19
  12. package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
  13. package/dest/private/circuit_recording/file_circuit_recorder.js +38 -42
  14. package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts +1 -1
  15. package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts.map +1 -1
  16. package/dest/private/circuit_recording/simulator_recorder_wrapper.js +11 -14
  17. package/dest/public/avm/testing/account_proof_fetcher.d.ts +2 -0
  18. package/dest/public/avm/testing/account_proof_fetcher.d.ts.map +1 -0
  19. package/dest/public/avm/testing/account_proof_fetcher.js +152 -0
  20. package/dest/public/avm/{fixtures → testing}/base_avm_simulation_tester.d.ts +2 -1
  21. package/dest/public/avm/testing/base_avm_simulation_tester.d.ts.map +1 -0
  22. package/dest/public/avm/{fixtures → testing}/base_avm_simulation_tester.js +18 -3
  23. package/dest/public/avm/testing/utils.d.ts +32 -0
  24. package/dest/public/avm/testing/utils.d.ts.map +1 -0
  25. package/dest/public/avm/{fixtures → testing}/utils.js +4 -34
  26. package/dest/public/avm_simulator.d.ts +28 -0
  27. package/dest/public/avm_simulator.d.ts.map +1 -0
  28. package/dest/public/avm_simulator.js +4 -0
  29. package/dest/public/avm_simulator_pool.d.ts +45 -0
  30. package/dest/public/avm_simulator_pool.d.ts.map +1 -0
  31. package/dest/public/avm_simulator_pool.js +197 -0
  32. package/dest/public/cdb_ipc_server.d.ts +40 -0
  33. package/dest/public/cdb_ipc_server.d.ts.map +1 -0
  34. package/dest/public/cdb_ipc_server.js +153 -0
  35. package/dest/public/contracts_db_checkpoint.d.ts +2 -2
  36. package/dest/public/contracts_db_checkpoint.d.ts.map +1 -1
  37. package/dest/public/contracts_db_checkpoint.js +1 -1
  38. package/dest/public/fixtures/amm_test.js +4 -4
  39. package/dest/public/fixtures/bulk_test.d.ts +1 -1
  40. package/dest/public/fixtures/bulk_test.d.ts.map +1 -1
  41. package/dest/public/fixtures/bulk_test.js +33 -6
  42. package/dest/public/fixtures/custom_bytecode_tester.d.ts +1 -1
  43. package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -1
  44. package/dest/public/fixtures/custom_bytecode_tester.js +2 -2
  45. package/dest/public/fixtures/index.d.ts +2 -4
  46. package/dest/public/fixtures/index.d.ts.map +1 -1
  47. package/dest/public/fixtures/index.js +1 -3
  48. package/dest/public/fixtures/public_processor_test_env.d.ts +30 -0
  49. package/dest/public/fixtures/public_processor_test_env.d.ts.map +1 -0
  50. package/dest/public/fixtures/public_processor_test_env.js +73 -0
  51. package/dest/public/fixtures/public_tx_simulation_tester.d.ts +12 -7
  52. package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
  53. package/dest/public/fixtures/public_tx_simulation_tester.js +32 -15
  54. package/dest/public/fixtures/simple_contract_data_source.js +1 -1
  55. package/dest/public/fixtures/token_test.js +3 -3
  56. package/dest/public/fixtures/utils.d.ts +2 -2
  57. package/dest/public/fixtures/utils.d.ts.map +1 -1
  58. package/dest/public/fixtures/utils.js +21 -20
  59. package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts +11 -4
  60. package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts.map +1 -1
  61. package/dest/public/fuzzing/avm_fuzzer_simulator.js +24 -10
  62. package/dest/public/fuzzing/avm_simulator_bin.js +4 -4
  63. package/dest/public/index.d.ts +5 -2
  64. package/dest/public/index.d.ts.map +1 -1
  65. package/dest/public/index.js +2 -1
  66. package/dest/public/public_db_sources.d.ts +6 -3
  67. package/dest/public/public_db_sources.d.ts.map +1 -1
  68. package/dest/public/public_db_sources.js +16 -10
  69. package/dest/public/public_processor/guarded_merkle_tree.d.ts +8 -7
  70. package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
  71. package/dest/public/public_processor/guarded_merkle_tree.js +8 -5
  72. package/dest/public/public_processor/public_processor.d.ts +15 -8
  73. package/dest/public/public_processor/public_processor.d.ts.map +1 -1
  74. package/dest/public/public_processor/public_processor.js +117 -78
  75. package/dest/public/public_processor/public_processor_metrics.d.ts +4 -1
  76. package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
  77. package/dest/public/public_processor/public_processor_metrics.js +8 -0
  78. package/dest/public/public_tx_simulator/dumping_public_tx_simulator.d.ts +17 -0
  79. package/dest/public/public_tx_simulator/dumping_public_tx_simulator.d.ts.map +1 -0
  80. package/dest/public/public_tx_simulator/{dumping_cpp_public_tx_simulator.js → dumping_public_tx_simulator.js} +10 -23
  81. package/dest/public/public_tx_simulator/factories.d.ts +8 -8
  82. package/dest/public/public_tx_simulator/factories.d.ts.map +1 -1
  83. package/dest/public/public_tx_simulator/factories.js +9 -9
  84. package/dest/public/public_tx_simulator/index.d.ts +4 -6
  85. package/dest/public/public_tx_simulator/index.d.ts.map +1 -1
  86. package/dest/public/public_tx_simulator/index.js +2 -4
  87. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +42 -71
  88. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
  89. package/dest/public/public_tx_simulator/public_tx_simulator.js +98 -318
  90. package/dest/public/public_tx_simulator/public_tx_simulator_base.d.ts +24 -0
  91. package/dest/public/public_tx_simulator/public_tx_simulator_base.d.ts.map +1 -0
  92. package/dest/public/public_tx_simulator/public_tx_simulator_base.js +31 -0
  93. package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts +5 -5
  94. package/package.json +20 -18
  95. package/src/client.ts +0 -2
  96. package/src/private/acvm_wasm.ts +4 -1
  97. package/src/private/circuit_recording/circuit_recorder.ts +84 -78
  98. package/src/private/circuit_recording/file_circuit_recorder.ts +38 -48
  99. package/src/private/circuit_recording/simulator_recorder_wrapper.ts +9 -15
  100. package/src/public/avm/testing/account_proof.json +553 -0
  101. package/src/public/avm/testing/account_proof_fetcher.ts +166 -0
  102. package/src/public/avm/{fixtures → testing}/base_avm_simulation_tester.ts +23 -3
  103. package/src/public/avm/{fixtures → testing}/utils.ts +4 -40
  104. package/src/public/avm_simulator.ts +29 -0
  105. package/src/public/avm_simulator_pool.ts +226 -0
  106. package/src/public/cdb_ipc_server.ts +198 -0
  107. package/src/public/contracts_db_checkpoint.ts +1 -1
  108. package/src/public/fixtures/amm_test.ts +4 -4
  109. package/src/public/fixtures/bulk_test.ts +31 -6
  110. package/src/public/fixtures/custom_bytecode_tester.ts +2 -2
  111. package/src/public/fixtures/index.ts +1 -3
  112. package/src/public/fixtures/public_processor_test_env.ts +88 -0
  113. package/src/public/fixtures/public_tx_simulation_tester.ts +45 -18
  114. package/src/public/fixtures/simple_contract_data_source.ts +1 -1
  115. package/src/public/fixtures/token_test.ts +3 -3
  116. package/src/public/fixtures/utils.ts +23 -24
  117. package/src/public/fuzzing/avm_fuzzer_simulator.ts +26 -11
  118. package/src/public/fuzzing/avm_simulator_bin.ts +3 -5
  119. package/src/public/index.ts +7 -3
  120. package/src/public/public_db_sources.ts +21 -14
  121. package/src/public/public_processor/guarded_merkle_tree.ts +11 -8
  122. package/src/public/public_processor/public_processor.ts +154 -98
  123. package/src/public/public_processor/public_processor_metrics.ts +12 -0
  124. package/src/public/public_tx_simulator/{dumping_cpp_public_tx_simulator.ts → dumping_public_tx_simulator.ts} +15 -31
  125. package/src/public/public_tx_simulator/factories.ts +29 -11
  126. package/src/public/public_tx_simulator/index.ts +6 -5
  127. package/src/public/public_tx_simulator/public_tx_simulator.ts +139 -476
  128. package/src/public/public_tx_simulator/public_tx_simulator_base.ts +37 -0
  129. package/src/public/public_tx_simulator/public_tx_simulator_interface.ts +5 -5
  130. package/dest/public/avm/avm_context.d.ts +0 -41
  131. package/dest/public/avm/avm_context.d.ts.map +0 -1
  132. package/dest/public/avm/avm_context.js +0 -44
  133. package/dest/public/avm/avm_contract_call_result.d.ts +0 -32
  134. package/dest/public/avm/avm_contract_call_result.d.ts.map +0 -1
  135. package/dest/public/avm/avm_contract_call_result.js +0 -54
  136. package/dest/public/avm/avm_execution_environment.d.ts +0 -24
  137. package/dest/public/avm/avm_execution_environment.d.ts.map +0 -1
  138. package/dest/public/avm/avm_execution_environment.js +0 -33
  139. package/dest/public/avm/avm_gas.d.ts +0 -44
  140. package/dest/public/avm/avm_gas.d.ts.map +0 -1
  141. package/dest/public/avm/avm_gas.js +0 -195
  142. package/dest/public/avm/avm_machine_state.d.ts +0 -98
  143. package/dest/public/avm/avm_machine_state.d.ts.map +0 -1
  144. package/dest/public/avm/avm_machine_state.js +0 -110
  145. package/dest/public/avm/avm_memory_types.d.ts +0 -275
  146. package/dest/public/avm/avm_memory_types.d.ts.map +0 -1
  147. package/dest/public/avm/avm_memory_types.js +0 -354
  148. package/dest/public/avm/avm_simulator.d.ts +0 -41
  149. package/dest/public/avm/avm_simulator.d.ts.map +0 -1
  150. package/dest/public/avm/avm_simulator.js +0 -192
  151. package/dest/public/avm/avm_simulator_interface.d.ts +0 -9
  152. package/dest/public/avm/avm_simulator_interface.d.ts.map +0 -1
  153. package/dest/public/avm/avm_simulator_interface.js +0 -3
  154. package/dest/public/avm/calldata.d.ts +0 -51
  155. package/dest/public/avm/calldata.d.ts.map +0 -1
  156. package/dest/public/avm/calldata.js +0 -63
  157. package/dest/public/avm/errors.d.ts +0 -104
  158. package/dest/public/avm/errors.d.ts.map +0 -1
  159. package/dest/public/avm/errors.js +0 -141
  160. package/dest/public/avm/fixtures/avm_simulation_tester.d.ts +0 -22
  161. package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +0 -1
  162. package/dest/public/avm/fixtures/avm_simulation_tester.js +0 -84
  163. package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +0 -1
  164. package/dest/public/avm/fixtures/initializers.d.ts +0 -42
  165. package/dest/public/avm/fixtures/initializers.d.ts.map +0 -1
  166. package/dest/public/avm/fixtures/initializers.js +0 -45
  167. package/dest/public/avm/fixtures/utils.d.ts +0 -39
  168. package/dest/public/avm/fixtures/utils.d.ts.map +0 -1
  169. package/dest/public/avm/index.d.ts +0 -2
  170. package/dest/public/avm/index.d.ts.map +0 -1
  171. package/dest/public/avm/index.js +0 -1
  172. package/dest/public/avm/opcodes/accrued_substate.d.ts +0 -74
  173. package/dest/public/avm/opcodes/accrued_substate.d.ts.map +0 -1
  174. package/dest/public/avm/opcodes/accrued_substate.js +0 -255
  175. package/dest/public/avm/opcodes/addressing_mode.d.ts +0 -31
  176. package/dest/public/avm/opcodes/addressing_mode.d.ts.map +0 -1
  177. package/dest/public/avm/opcodes/addressing_mode.js +0 -94
  178. package/dest/public/avm/opcodes/arithmetic.d.ts +0 -49
  179. package/dest/public/avm/opcodes/arithmetic.d.ts.map +0 -1
  180. package/dest/public/avm/opcodes/arithmetic.js +0 -97
  181. package/dest/public/avm/opcodes/bitwise.d.ts +0 -42
  182. package/dest/public/avm/opcodes/bitwise.d.ts.map +0 -1
  183. package/dest/public/avm/opcodes/bitwise.js +0 -99
  184. package/dest/public/avm/opcodes/comparators.d.ts +0 -25
  185. package/dest/public/avm/opcodes/comparators.d.ts.map +0 -1
  186. package/dest/public/avm/opcodes/comparators.js +0 -43
  187. package/dest/public/avm/opcodes/contract.d.ts +0 -20
  188. package/dest/public/avm/opcodes/contract.d.ts.map +0 -1
  189. package/dest/public/avm/opcodes/contract.js +0 -65
  190. package/dest/public/avm/opcodes/control_flow.d.ts +0 -41
  191. package/dest/public/avm/opcodes/control_flow.d.ts.map +0 -1
  192. package/dest/public/avm/opcodes/control_flow.js +0 -107
  193. package/dest/public/avm/opcodes/conversion.d.ts +0 -18
  194. package/dest/public/avm/opcodes/conversion.d.ts.map +0 -1
  195. package/dest/public/avm/opcodes/conversion.js +0 -333
  196. package/dest/public/avm/opcodes/ec_add.d.ts +0 -19
  197. package/dest/public/avm/opcodes/ec_add.d.ts.map +0 -1
  198. package/dest/public/avm/opcodes/ec_add.js +0 -93
  199. package/dest/public/avm/opcodes/environment_getters.d.ts +0 -28
  200. package/dest/public/avm/opcodes/environment_getters.d.ts.map +0 -1
  201. package/dest/public/avm/opcodes/environment_getters.js +0 -77
  202. package/dest/public/avm/opcodes/external_calls.d.ts +0 -59
  203. package/dest/public/avm/opcodes/external_calls.d.ts.map +0 -1
  204. package/dest/public/avm/opcodes/external_calls.js +0 -210
  205. package/dest/public/avm/opcodes/hashing.d.ts +0 -36
  206. package/dest/public/avm/opcodes/hashing.d.ts.map +0 -1
  207. package/dest/public/avm/opcodes/hashing.js +0 -119
  208. package/dest/public/avm/opcodes/index.d.ts +0 -16
  209. package/dest/public/avm/opcodes/index.d.ts.map +0 -1
  210. package/dest/public/avm/opcodes/index.js +0 -15
  211. package/dest/public/avm/opcodes/instruction.d.ts +0 -74
  212. package/dest/public/avm/opcodes/instruction.d.ts.map +0 -1
  213. package/dest/public/avm/opcodes/instruction.js +0 -95
  214. package/dest/public/avm/opcodes/instruction_impl.d.ts +0 -19
  215. package/dest/public/avm/opcodes/instruction_impl.d.ts.map +0 -1
  216. package/dest/public/avm/opcodes/instruction_impl.js +0 -30
  217. package/dest/public/avm/opcodes/memory.d.ts +0 -74
  218. package/dest/public/avm/opcodes/memory.d.ts.map +0 -1
  219. package/dest/public/avm/opcodes/memory.js +0 -257
  220. package/dest/public/avm/opcodes/misc.d.ts +0 -18
  221. package/dest/public/avm/opcodes/misc.d.ts.map +0 -1
  222. package/dest/public/avm/opcodes/misc.js +0 -73
  223. package/dest/public/avm/opcodes/storage.d.ts +0 -25
  224. package/dest/public/avm/opcodes/storage.d.ts.map +0 -1
  225. package/dest/public/avm/opcodes/storage.js +0 -78
  226. package/dest/public/avm/revert_reason.d.ts +0 -18
  227. package/dest/public/avm/revert_reason.d.ts.map +0 -1
  228. package/dest/public/avm/revert_reason.js +0 -39
  229. package/dest/public/avm/serialization/buffer_cursor.d.ts +0 -26
  230. package/dest/public/avm/serialization/buffer_cursor.d.ts.map +0 -1
  231. package/dest/public/avm/serialization/buffer_cursor.js +0 -99
  232. package/dest/public/avm/serialization/bytecode_serialization.d.ts +0 -17
  233. package/dest/public/avm/serialization/bytecode_serialization.d.ts.map +0 -1
  234. package/dest/public/avm/serialization/bytecode_serialization.js +0 -336
  235. package/dest/public/avm/serialization/instruction_serialization.d.ts +0 -114
  236. package/dest/public/avm/serialization/instruction_serialization.d.ts.map +0 -1
  237. package/dest/public/avm/serialization/instruction_serialization.js +0 -261
  238. package/dest/public/avm/test_utils.d.ts +0 -15
  239. package/dest/public/avm/test_utils.d.ts.map +0 -1
  240. package/dest/public/avm/test_utils.js +0 -44
  241. package/dest/public/debug_fn_name.d.ts +0 -18
  242. package/dest/public/debug_fn_name.d.ts.map +0 -1
  243. package/dest/public/debug_fn_name.js +0 -37
  244. package/dest/public/fixtures/custom_bytecode_tests.d.ts +0 -12
  245. package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +0 -1
  246. package/dest/public/fixtures/custom_bytecode_tests.js +0 -174
  247. package/dest/public/fixtures/minimal_public_tx.d.ts +0 -4
  248. package/dest/public/fixtures/minimal_public_tx.d.ts.map +0 -1
  249. package/dest/public/fixtures/minimal_public_tx.js +0 -19
  250. package/dest/public/fixtures/opcode_spammer.d.ts +0 -122
  251. package/dest/public/fixtures/opcode_spammer.d.ts.map +0 -1
  252. package/dest/public/fixtures/opcode_spammer.js +0 -1653
  253. package/dest/public/hinting_db_sources.d.ts +0 -80
  254. package/dest/public/hinting_db_sources.d.ts.map +0 -1
  255. package/dest/public/hinting_db_sources.js +0 -355
  256. package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +0 -19
  257. package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +0 -1
  258. package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +0 -98
  259. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +0 -53
  260. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +0 -1
  261. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +0 -132
  262. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts +0 -42
  263. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts.map +0 -1
  264. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.js +0 -86
  265. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts +0 -30
  266. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts.map +0 -1
  267. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.js +0 -171
  268. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts +0 -23
  269. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts.map +0 -1
  270. package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +0 -31
  271. package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts.map +0 -1
  272. package/dest/public/public_tx_simulator/measured_public_tx_simulator.js +0 -51
  273. package/dest/public/public_tx_simulator/public_tx_context.d.ts +0 -131
  274. package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +0 -1
  275. package/dest/public/public_tx_simulator/public_tx_context.js +0 -300
  276. package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts +0 -21
  277. package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts.map +0 -1
  278. package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.js +0 -415
  279. package/dest/public/side_effect_trace.d.ts +0 -87
  280. package/dest/public/side_effect_trace.d.ts.map +0 -1
  281. package/dest/public/side_effect_trace.js +0 -199
  282. package/dest/public/side_effect_trace_interface.d.ts +0 -22
  283. package/dest/public/side_effect_trace_interface.d.ts.map +0 -1
  284. package/dest/public/side_effect_trace_interface.js +0 -1
  285. package/dest/public/state_manager/index.d.ts +0 -2
  286. package/dest/public/state_manager/index.d.ts.map +0 -1
  287. package/dest/public/state_manager/index.js +0 -1
  288. package/dest/public/state_manager/nullifiers.d.ts +0 -61
  289. package/dest/public/state_manager/nullifiers.d.ts.map +0 -1
  290. package/dest/public/state_manager/nullifiers.js +0 -92
  291. package/dest/public/state_manager/public_storage.d.ts +0 -66
  292. package/dest/public/state_manager/public_storage.d.ts.map +0 -1
  293. package/dest/public/state_manager/public_storage.js +0 -145
  294. package/dest/public/state_manager/state_manager.d.ts +0 -170
  295. package/dest/public/state_manager/state_manager.d.ts.map +0 -1
  296. package/dest/public/state_manager/state_manager.js +0 -402
  297. package/src/public/avm/avm_context.ts +0 -61
  298. package/src/public/avm/avm_contract_call_result.ts +0 -69
  299. package/src/public/avm/avm_execution_environment.ts +0 -51
  300. package/src/public/avm/avm_gas.ts +0 -183
  301. package/src/public/avm/avm_machine_state.ts +0 -170
  302. package/src/public/avm/avm_memory_types.ts +0 -440
  303. package/src/public/avm/avm_simulator.ts +0 -279
  304. package/src/public/avm/avm_simulator_interface.ts +0 -8
  305. package/src/public/avm/calldata.ts +0 -100
  306. package/src/public/avm/errors.ts +0 -177
  307. package/src/public/avm/fixtures/avm_simulation_tester.ts +0 -122
  308. package/src/public/avm/fixtures/initializers.ts +0 -103
  309. package/src/public/avm/index.ts +0 -1
  310. package/src/public/avm/opcodes/accrued_substate.ts +0 -286
  311. package/src/public/avm/opcodes/addressing_mode.ts +0 -111
  312. package/src/public/avm/opcodes/arithmetic.ts +0 -129
  313. package/src/public/avm/opcodes/bitwise.ts +0 -113
  314. package/src/public/avm/opcodes/comparators.ts +0 -55
  315. package/src/public/avm/opcodes/contract.ts +0 -72
  316. package/src/public/avm/opcodes/control_flow.ts +0 -123
  317. package/src/public/avm/opcodes/conversion.ts +0 -104
  318. package/src/public/avm/opcodes/ec_add.ts +0 -105
  319. package/src/public/avm/opcodes/environment_getters.ts +0 -87
  320. package/src/public/avm/opcodes/external_calls.ts +0 -262
  321. package/src/public/avm/opcodes/hashing.ts +0 -151
  322. package/src/public/avm/opcodes/index.ts +0 -15
  323. package/src/public/avm/opcodes/instruction.ts +0 -136
  324. package/src/public/avm/opcodes/instruction_impl.ts +0 -36
  325. package/src/public/avm/opcodes/memory.ts +0 -293
  326. package/src/public/avm/opcodes/misc.ts +0 -102
  327. package/src/public/avm/opcodes/storage.ts +0 -95
  328. package/src/public/avm/revert_reason.ts +0 -58
  329. package/src/public/avm/serialization/buffer_cursor.ts +0 -118
  330. package/src/public/avm/serialization/bytecode_serialization.ts +0 -215
  331. package/src/public/avm/serialization/instruction_serialization.ts +0 -249
  332. package/src/public/avm/test_utils.ts +0 -64
  333. package/src/public/debug_fn_name.ts +0 -52
  334. package/src/public/fixtures/custom_bytecode_tests.ts +0 -228
  335. package/src/public/fixtures/minimal_public_tx.ts +0 -26
  336. package/src/public/fixtures/opcode_spammer.ts +0 -1721
  337. package/src/public/hinting_db_sources.ts +0 -607
  338. package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +0 -124
  339. package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +0 -211
  340. package/src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts +0 -134
  341. package/src/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.ts +0 -239
  342. package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +0 -105
  343. package/src/public/public_tx_simulator/public_tx_context.ts +0 -484
  344. package/src/public/public_tx_simulator/telemetry_public_tx_simulator.ts +0 -63
  345. package/src/public/side_effect_trace.ts +0 -293
  346. package/src/public/side_effect_trace_interface.ts +0 -28
  347. package/src/public/state_manager/index.ts +0 -1
  348. package/src/public/state_manager/nullifiers.ts +0 -103
  349. package/src/public/state_manager/public_storage.ts +0 -174
  350. package/src/public/state_manager/state_manager.ts +0 -569
@@ -3,6 +3,8 @@ import { type Logger, type LoggerBindings, resolveLogger } from '@aztec/foundati
3
3
  import { Timer } from '@aztec/foundation/timer';
4
4
  import type { ForeignCallHandler, ForeignCallInput, ForeignCallOutput } from '@aztec/noir-acvm_js';
5
5
 
6
+ import { AsyncLocalStorage } from 'node:async_hooks';
7
+
6
8
  import type { ACIRCallback } from '../acvm/acvm.js';
7
9
  import type { ACVMWitness } from '../acvm/acvm_types.js';
8
10
 
@@ -43,10 +45,23 @@ export class CircuitRecording {
43
45
  }
44
46
  }
45
47
 
48
+ /** Inputs needed to open a recording for a single circuit execution. */
49
+ export type RecordingMetadata = {
50
+ input: ACVMWitness;
51
+ bytecode: Buffer;
52
+ circuitName: string;
53
+ functionName: string;
54
+ };
55
+
46
56
  /**
47
57
  * Class responsible for recording circuit inputs necessary to replay the circuit. These inputs are the initial witness
48
58
  * map and the oracle calls made during the circuit execution/witness generation.
49
59
  *
60
+ * The active recording for an execution lives in `AsyncLocalStorage`, so each (possibly nested) circuit execution owns
61
+ * its own recording and concurrent or re-entrant executions cannot corrupt one another's state. Nested executions
62
+ * (`aztec_prv_callPrivateFunction`, utility calls) re-enter {@link record}, which links the child to the recording
63
+ * active in the enclosing async context and lets ALS restore the parent automatically when the child completes.
64
+ *
50
65
  * Example recording object:
51
66
  * ```json
52
67
  * {
@@ -91,37 +106,44 @@ export class CircuitRecording {
91
106
  export class CircuitRecorder {
92
107
  protected readonly logger: Logger;
93
108
 
94
- protected recording?: CircuitRecording;
95
-
96
- private stackDepth: number = 0;
97
- private newCircuit: boolean = true;
109
+ readonly #recordings = new AsyncLocalStorage<CircuitRecording>();
98
110
 
99
111
  protected constructor(loggerOrBindings?: Logger | LoggerBindings) {
100
112
  this.logger = resolveLogger('simulator:acvm:recording', loggerOrBindings);
101
113
  }
102
114
 
103
115
  /**
104
- * Initializes a new circuit recording session.
105
- * @param recordDir - Directory to store the recording
106
- * @param input - Circuit input witness
107
- * @param circuitBytecode - Compiled circuit bytecode
108
- * @param circuitName - Name of the circuit
109
- * @param functionName - Name of the circuit function (defaults to 'main'). This is meaningful only for
110
- * contracts as protocol circuits artifacts always contain a single entrypoint function called 'main'.
116
+ * Records a single circuit execution. Opens a recording for the circuit (linked as a child of the recording active
117
+ * in the current async context, if any), runs `fn` within that recording's context, and finalizes it. The recording
118
+ * is returned alongside the result so callers can derive per-circuit stats (e.g. oracle timings).
119
+ *
120
+ * Recorder bookkeeping never alters execution: if `fn` throws, the error is attached to the recording and re-thrown
121
+ * unchanged.
122
+ * @param metadata - Identifies the circuit and its initial witness.
123
+ * @param fn - Runs the circuit execution; its oracle calls are recorded into this recording.
111
124
  */
112
- start(input: ACVMWitness, circuitBytecode: Buffer, circuitName: string, functionName: string): Promise<void> {
113
- if (this.newCircuit) {
114
- const parentRef = this.recording;
115
- this.recording = new CircuitRecording(
116
- circuitName,
117
- functionName,
118
- sha512(circuitBytecode).toString('hex'),
119
- Object.fromEntries(input),
120
- );
121
- this.recording.setParent(parentRef);
122
- }
125
+ record<T>(metadata: RecordingMetadata, fn: () => Promise<T>): Promise<{ result: T; recording: CircuitRecording }> {
126
+ const parent = this.#recordings.getStore();
127
+ const recording = new CircuitRecording(
128
+ metadata.circuitName,
129
+ metadata.functionName,
130
+ sha512(metadata.bytecode).toString('hex'),
131
+ Object.fromEntries(metadata.input),
132
+ );
133
+ recording.setParent(parent);
123
134
 
124
- return Promise.resolve();
135
+ return this.#recordings.run(recording, async () => {
136
+ await this.onStart(recording);
137
+ try {
138
+ const result = await fn();
139
+ await this.onFinish(recording);
140
+ return { result, recording };
141
+ } catch (error) {
142
+ recording.error = JSON.stringify(error);
143
+ await this.onError(recording, error);
144
+ throw error;
145
+ }
146
+ });
125
147
  }
126
148
 
127
149
  /**
@@ -147,7 +169,9 @@ export class CircuitRecorder {
147
169
  }
148
170
 
149
171
  /**
150
- * Wraps a user circuit callback to record all oracle calls.
172
+ * Wraps a user circuit callback to record all oracle calls. A nested circuit entered via an oracle (e.g.
173
+ * `aztec_prv_callPrivateFunction`) re-enters {@link record}, so its own oracle calls land on the child recording and
174
+ * this circuit's calls (including the entering oracle call itself) land on this recording once the child completes.
151
175
  * @param callback - The original circuit callback.
152
176
  * @returns A wrapped callback that records all oracle interactions which is to be provided to the ACVM.
153
177
  */
@@ -161,38 +185,16 @@ export class CircuitRecorder {
161
185
  throw new Error(`Oracle method ${name} not found when setting up recording callback`);
162
186
  }
163
187
 
164
- const isExternalCall = (name as keyof ACIRCallback) === 'privateCallPrivateFunction';
165
-
166
188
  recordingCallback[name as keyof ACIRCallback] = (...args: ForeignCallInput[]): ReturnType<typeof fn> => {
167
189
  const timer = new Timer();
168
- // If we're entering another circuit via `privateCallPrivateFunction`, we increase the stack depth and set the
169
- // newCircuit variable to ensure we are creating a new recording object.
170
- if (isExternalCall) {
171
- this.stackDepth++;
172
- this.newCircuit = true;
173
- }
174
190
  const result = fn.call(callback, ...args);
175
191
  if (result instanceof Promise) {
176
192
  return result.then(async r => {
177
- // Once we leave the nested circuit, we decrease the stack depth and set newCircuit to false
178
- // so that the parent circuit continues with its existing recording
179
- // Note: recording restoration is handled by finish()
180
- if (isExternalCall) {
181
- this.stackDepth--;
182
- this.newCircuit = false;
183
- }
184
- await this.recordCall(name, args, r, timer.ms(), this.stackDepth);
193
+ await this.recordCall(name, args, r, timer.ms());
185
194
  return r;
186
195
  }) as ReturnType<typeof fn>;
187
196
  }
188
- // Once we leave the nested circuit, we decrease the stack depth and set newCircuit to false
189
- // so that the parent circuit continues with its existing recording
190
- // Note: recording restoration is handled by finish()
191
- if (isExternalCall) {
192
- this.stackDepth--;
193
- this.newCircuit = false;
194
- }
195
- void this.recordCall(name, args, result, timer.ms(), this.stackDepth);
197
+ void this.recordCall(name, args, result, timer.ms());
196
198
  return result;
197
199
  };
198
200
  }
@@ -209,55 +211,59 @@ export class CircuitRecorder {
209
211
  return async (name: string, inputs: ForeignCallInput[]): Promise<ForeignCallOutput[]> => {
210
212
  const timer = new Timer();
211
213
  const result = await callback(name, inputs);
212
- await this.recordCall(name, inputs, result, timer.ms(), 0);
214
+ await this.recordCall(name, inputs, result, timer.ms());
213
215
  return result;
214
216
  };
215
217
  }
216
218
 
217
219
  /**
218
- * Records a single oracle/foreign call with its inputs and outputs.
220
+ * Records a single oracle/foreign call with its inputs and outputs against the recording active in the current
221
+ * async context.
219
222
  * @param name - Name of the call
220
223
  * @param inputs - Input arguments
221
224
  * @param outputs - Output results
222
225
  */
223
- recordCall(name: string, inputs: unknown[], outputs: unknown, time: number, stackDepth: number): Promise<OracleCall> {
226
+ recordCall(name: string, inputs: unknown[], outputs: unknown, time: number): Promise<OracleCall> {
227
+ const recording = this.#recordings.getStore();
224
228
  const entry = {
225
229
  name,
226
230
  inputs,
227
231
  outputs,
228
232
  time,
229
- stackDepth,
233
+ stackDepth: depthOf(recording),
230
234
  };
231
- this.recording!.oracleCalls.push(entry);
235
+ // Outside any active recording context (e.g. a stray call after the scope closed, or a direct unit-test call)
236
+ // there is nowhere to record; return the entry without throwing into the execution path.
237
+ recording?.oracleCalls.push(entry);
232
238
  return Promise.resolve(entry);
233
239
  }
234
240
 
235
- /**
236
- * Finalizes the recording by resetting the state and returning the recording object.
237
- */
238
- finish(): Promise<CircuitRecording> {
239
- const result = this.recording;
240
- // If this is the top-level circuit recording, we reset the state for the next simulator call
241
- if (!result!.parent) {
242
- this.newCircuit = true;
243
- this.recording = undefined;
244
- } else {
245
- // For nested circuits (utility calls, nested contract calls), restore to parent recording
246
- // Note: we don't set newCircuit=false here because:
247
- // - For privateCallPrivateFunction, the callback wrapper will set it to false
248
- // - For utility calls, we want newCircuit to remain true so the next circuit creates its own recording
249
- this.recording = result!.parent;
250
- }
251
- return Promise.resolve(result!);
241
+ /** The recording active in the current async context, if any. */
242
+ protected currentRecording(): CircuitRecording | undefined {
243
+ return this.#recordings.getStore();
252
244
  }
253
245
 
254
- /**
255
- * Finalizes the recording by resetting the state and returning the recording object with an attached error.
256
- * @param error - The error that occurred during circuit execution
257
- */
258
- async finishWithError(error: unknown): Promise<CircuitRecording> {
259
- const result = await this.finish();
260
- result.error = JSON.stringify(error);
261
- return result;
246
+ /** Hook invoked when a recording opens, within the recording's context. Overridden to persist recordings. */
247
+ protected onStart(_recording: CircuitRecording): Promise<void> {
248
+ return Promise.resolve();
249
+ }
250
+
251
+ /** Hook invoked when a recording completes successfully, within the recording's context. */
252
+ protected onFinish(_recording: CircuitRecording): Promise<void> {
253
+ return Promise.resolve();
254
+ }
255
+
256
+ /** Hook invoked when a recording's execution throws, within the recording's context. */
257
+ protected onError(_recording: CircuitRecording, _error: unknown): Promise<void> {
258
+ return Promise.resolve();
259
+ }
260
+ }
261
+
262
+ /** Depth of a recording in the call tree: 0 for a top-level circuit, incremented per nested circuit. */
263
+ function depthOf(recording: CircuitRecording | undefined): number {
264
+ let depth = 0;
265
+ for (let ancestor = recording?.parent; ancestor; ancestor = ancestor.parent) {
266
+ depth++;
262
267
  }
268
+ return depth;
263
269
  }
@@ -3,11 +3,13 @@ import type { Logger } from '@aztec/foundation/log';
3
3
  import fs from 'fs/promises';
4
4
  import path from 'path';
5
5
 
6
- import type { ACVMWitness } from '../acvm/acvm_types.js';
7
6
  import { CircuitRecorder, type CircuitRecording } from './circuit_recorder.js';
8
7
 
8
+ /** Per-recording file state, keyed by recording so concurrent/nested executions don't share it. */
9
+ type RecordingFileState = { filePath: string; isFirstCall: boolean };
10
+
9
11
  export class FileCircuitRecorder extends CircuitRecorder {
10
- declare recording?: CircuitRecording & { filePath: string; isFirstCall: boolean };
12
+ readonly #fileState = new WeakMap<CircuitRecording, RecordingFileState>();
11
13
 
12
14
  constructor(
13
15
  private readonly recordDir: string,
@@ -16,16 +18,9 @@ export class FileCircuitRecorder extends CircuitRecorder {
16
18
  super(logger);
17
19
  }
18
20
 
19
- override async start(
20
- input: ACVMWitness,
21
- circuitBytecode: Buffer,
22
- circuitName: string,
23
- functionName: string = 'main',
24
- ) {
25
- await super.start(input, circuitBytecode, circuitName, functionName);
26
-
21
+ protected override async onStart(recording: CircuitRecording): Promise<void> {
27
22
  const recordingStringWithoutClosingBracket = JSON.stringify(
28
- { ...this.recording, isFirstCall: undefined, parent: undefined, oracleCalls: undefined, filePath: undefined },
23
+ { ...recording, parent: undefined, oracleCalls: undefined },
29
24
  null,
30
25
  2,
31
26
  ).slice(0, -2);
@@ -45,13 +40,13 @@ export class FileCircuitRecorder extends CircuitRecorder {
45
40
  }
46
41
  }
47
42
 
48
- this.recording!.isFirstCall = true;
49
- this.recording!.filePath = await FileCircuitRecorder.#computeFilePathAndStoreInitialRecording(
43
+ const filePath = await FileCircuitRecorder.#computeFilePathAndStoreInitialRecording(
50
44
  this.recordDir,
51
- this.recording!.circuitName,
52
- this.recording!.functionName,
45
+ recording.circuitName,
46
+ recording.functionName,
53
47
  recordingStringWithoutClosingBracket,
54
48
  );
49
+ this.#fileState.set(recording, { filePath, isFirstCall: true });
55
50
  }
56
51
 
57
52
  /**
@@ -95,53 +90,48 @@ export class FileCircuitRecorder extends CircuitRecorder {
95
90
  * @param inputs - Input arguments
96
91
  * @param outputs - Output results
97
92
  */
98
- override async recordCall(name: string, inputs: unknown[], outputs: unknown, time: number, stackDepth: number) {
99
- const entry = await super.recordCall(name, inputs, outputs, time, stackDepth);
100
- try {
101
- const prefix = this.recording!.isFirstCall ? ' ' : ' ,';
102
- this.recording!.isFirstCall = false;
103
- await fs.appendFile(this.recording!.filePath, prefix + JSON.stringify(entry) + '\n');
104
- } catch (err) {
105
- this.logger.error('Failed to log circuit call', { error: err });
93
+ override async recordCall(name: string, inputs: unknown[], outputs: unknown, time: number) {
94
+ const entry = await super.recordCall(name, inputs, outputs, time);
95
+ const recording = this.currentRecording();
96
+ const state = recording && this.#fileState.get(recording);
97
+ if (state) {
98
+ try {
99
+ const prefix = state.isFirstCall ? ' ' : ' ,';
100
+ state.isFirstCall = false;
101
+ await fs.appendFile(state.filePath, prefix + JSON.stringify(entry) + '\n');
102
+ } catch (err) {
103
+ this.logger.error('Failed to log circuit call', { error: err });
104
+ }
106
105
  }
107
106
  return entry;
108
107
  }
109
108
 
110
- /**
111
- * Finalizes the recording file by adding closing brackets. Without calling this method, the recording file is
112
- * incomplete and it fails to parse.
113
- */
114
- override async finish(): Promise<CircuitRecording> {
115
- // Finish sets the recording to undefined if we are at the topmost circuit,
116
- // so we save the current file path before that
117
- const filePath = this.recording!.filePath;
118
- const result = await super.finish();
109
+ /** Closes the recording file with the trailing brackets so the JSON parses. */
110
+ protected override async onFinish(recording: CircuitRecording): Promise<void> {
111
+ const state = this.#fileState.get(recording);
112
+ if (!state) {
113
+ return;
114
+ }
119
115
  try {
120
- await fs.appendFile(filePath, ' ]\n}\n');
116
+ await fs.appendFile(state.filePath, ' ]\n}\n');
121
117
  } catch (err) {
122
118
  this.logger.error('Failed to finalize recording file', { error: err });
123
119
  }
124
- return result!;
125
120
  }
126
121
 
127
- /**
128
- * Finalizes the recording file by adding the error and closing brackets. Without calling this method or `finish`,
129
- * the recording file is incomplete and it fails to parse.
130
- * @param error - The error that occurred during circuit execution
131
- */
132
- override async finishWithError(error: unknown): Promise<CircuitRecording> {
133
- // Finish sets the recording to undefined if we are at the topmost circuit,
134
- // so we save the current file path before that
135
- const filePath = this.recording!.filePath;
136
- const result = await super.finishWithError(error);
122
+ /** Closes the recording file with the execution error and trailing brackets so the JSON parses. */
123
+ protected override async onError(recording: CircuitRecording, error: unknown): Promise<void> {
124
+ const state = this.#fileState.get(recording);
125
+ if (!state) {
126
+ return;
127
+ }
137
128
  try {
138
- await fs.appendFile(filePath, ' ],\n');
139
- await fs.appendFile(filePath, ` "error": ${JSON.stringify(error)}\n`);
140
- await fs.appendFile(filePath, '}\n');
129
+ await fs.appendFile(state.filePath, ' ],\n');
130
+ await fs.appendFile(state.filePath, ` "error": ${JSON.stringify(error)}\n`);
131
+ await fs.appendFile(state.filePath, '}\n');
141
132
  } catch (err) {
142
133
  this.logger.error('Failed to finalize recording file with error', { error: err });
143
134
  }
144
- return result!;
145
135
  }
146
136
  }
147
137
 
@@ -58,24 +58,18 @@ export class SimulatorRecorderWrapper implements CircuitSimulator {
58
58
  functionName: string,
59
59
  callback: C,
60
60
  ): Promise<T> {
61
- // Start recording circuit execution
62
- await this.recorder.start(input, bytecode, contractName, functionName);
63
-
64
- // If callback was provided, we wrap it in a circuit recorder callback wrapper
61
+ // If a callback was provided, we wrap it so that its oracle calls are recorded. The wrapped callback reads the
62
+ // active recording lazily, so it picks up the recording opened by record() below.
65
63
  const wrappedCallback = this.recorder.wrapCallback(callback);
66
- let result: T;
67
- try {
68
- result = await simulateFn(wrappedCallback as C);
69
- } catch (error) {
70
- // If an error occurs, we finalize the recording file with the error
71
- await this.recorder.finishWithError(error);
72
- throw error;
73
- }
74
64
 
75
- // Witness generation is complete so we finish the circuit recorder
76
- const recording = await this.recorder.finish();
65
+ // record() opens a recording for this circuit, runs the simulation within it, and finalizes it. A simulation
66
+ // failure is re-thrown unchanged, so recorder bookkeeping never masks the underlying error.
67
+ const { result, recording } = await this.recorder.record(
68
+ { input, bytecode, circuitName: contractName, functionName },
69
+ () => simulateFn(wrappedCallback as C),
70
+ );
77
71
 
78
- (result as ACIRExecutionResult).oracles = recording.oracleCalls?.reduce(
72
+ (result as ACIRExecutionResult).oracles = recording.oracleCalls.reduce(
79
73
  (acc, { time, name }) => {
80
74
  if (!acc[name]) {
81
75
  acc[name] = { times: [] };