@aztec/simulator 0.0.1-commit.d3ec352c → 0.0.1-commit.e3c1de76

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 (312) hide show
  1. package/README.md +2 -0
  2. package/dest/common/errors.d.ts +8 -2
  3. package/dest/common/errors.d.ts.map +1 -1
  4. package/dest/private/acvm/acvm.d.ts +4 -2
  5. package/dest/private/acvm/acvm.d.ts.map +1 -1
  6. package/dest/private/acvm/acvm.js +4 -3
  7. package/dest/private/acvm/deserialize.d.ts +2 -2
  8. package/dest/private/acvm/deserialize.d.ts.map +1 -1
  9. package/dest/private/acvm/deserialize.js +1 -1
  10. package/dest/private/acvm/serialize.d.ts +2 -2
  11. package/dest/private/acvm/serialize.d.ts.map +1 -1
  12. package/dest/private/acvm/serialize.js +1 -1
  13. package/dest/private/acvm_native.d.ts +5 -3
  14. package/dest/private/acvm_native.d.ts.map +1 -1
  15. package/dest/private/acvm_native.js +8 -6
  16. package/dest/private/acvm_wasm.d.ts +4 -3
  17. package/dest/private/acvm_wasm.d.ts.map +1 -1
  18. package/dest/private/acvm_wasm.js +4 -4
  19. package/dest/private/circuit_recording/circuit_recorder.d.ts +4 -3
  20. package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -1
  21. package/dest/private/circuit_recording/circuit_recorder.js +21 -18
  22. package/dest/private/circuit_recording/file_circuit_recorder.d.ts +3 -2
  23. package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
  24. package/dest/private/circuit_recording/file_circuit_recorder.js +2 -2
  25. package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +7 -2
  26. package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -1
  27. package/dest/private/circuit_recording/memory_circuit_recorder.js +4 -4
  28. package/dest/private/factory.d.ts +3 -3
  29. package/dest/private/factory.d.ts.map +1 -1
  30. package/dest/private/factory.js +7 -4
  31. package/dest/public/avm/avm_context.d.ts +3 -3
  32. package/dest/public/avm/avm_context.d.ts.map +1 -1
  33. package/dest/public/avm/avm_contract_call_result.d.ts +6 -6
  34. package/dest/public/avm/avm_contract_call_result.d.ts.map +1 -1
  35. package/dest/public/avm/avm_contract_call_result.js +3 -3
  36. package/dest/public/avm/avm_execution_environment.d.ts +7 -6
  37. package/dest/public/avm/avm_execution_environment.d.ts.map +1 -1
  38. package/dest/public/avm/avm_execution_environment.js +1 -1
  39. package/dest/public/avm/avm_gas.d.ts +1 -1
  40. package/dest/public/avm/avm_gas.d.ts.map +1 -1
  41. package/dest/public/avm/avm_machine_state.d.ts +7 -6
  42. package/dest/public/avm/avm_machine_state.d.ts.map +1 -1
  43. package/dest/public/avm/avm_machine_state.js +3 -2
  44. package/dest/public/avm/avm_memory_types.d.ts +2 -2
  45. package/dest/public/avm/avm_memory_types.d.ts.map +1 -1
  46. package/dest/public/avm/avm_memory_types.js +4 -1
  47. package/dest/public/avm/avm_simulator.d.ts +4 -3
  48. package/dest/public/avm/avm_simulator.d.ts.map +1 -1
  49. package/dest/public/avm/avm_simulator.js +6 -5
  50. package/dest/public/avm/calldata.d.ts +51 -0
  51. package/dest/public/avm/calldata.d.ts.map +1 -0
  52. package/dest/public/avm/calldata.js +63 -0
  53. package/dest/public/avm/errors.d.ts +2 -2
  54. package/dest/public/avm/errors.d.ts.map +1 -1
  55. package/dest/public/avm/fixtures/avm_simulation_tester.d.ts +1 -1
  56. package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -1
  57. package/dest/public/avm/fixtures/avm_simulation_tester.js +4 -3
  58. package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +2 -2
  59. package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -1
  60. package/dest/public/avm/fixtures/base_avm_simulation_tester.js +1 -1
  61. package/dest/public/avm/fixtures/initializers.d.ts +2 -2
  62. package/dest/public/avm/fixtures/initializers.d.ts.map +1 -1
  63. package/dest/public/avm/fixtures/initializers.js +3 -2
  64. package/dest/public/avm/fixtures/utils.d.ts +2 -2
  65. package/dest/public/avm/fixtures/utils.d.ts.map +1 -1
  66. package/dest/public/avm/fixtures/utils.js +1 -1
  67. package/dest/public/avm/opcodes/accrued_substate.d.ts +16 -17
  68. package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
  69. package/dest/public/avm/opcodes/accrued_substate.js +39 -39
  70. package/dest/public/avm/opcodes/arithmetic.d.ts +10 -8
  71. package/dest/public/avm/opcodes/arithmetic.d.ts.map +1 -1
  72. package/dest/public/avm/opcodes/arithmetic.js +12 -2
  73. package/dest/public/avm/opcodes/bitwise.d.ts +7 -7
  74. package/dest/public/avm/opcodes/bitwise.d.ts.map +1 -1
  75. package/dest/public/avm/opcodes/bitwise.js +5 -5
  76. package/dest/public/avm/opcodes/comparators.d.ts +4 -4
  77. package/dest/public/avm/opcodes/comparators.d.ts.map +1 -1
  78. package/dest/public/avm/opcodes/comparators.js +1 -1
  79. package/dest/public/avm/opcodes/contract.d.ts +3 -3
  80. package/dest/public/avm/opcodes/contract.d.ts.map +1 -1
  81. package/dest/public/avm/opcodes/contract.js +8 -8
  82. package/dest/public/avm/opcodes/control_flow.d.ts +3 -3
  83. package/dest/public/avm/opcodes/control_flow.d.ts.map +1 -1
  84. package/dest/public/avm/opcodes/control_flow.js +4 -4
  85. package/dest/public/avm/opcodes/conversion.d.ts +3 -3
  86. package/dest/public/avm/opcodes/conversion.d.ts.map +1 -1
  87. package/dest/public/avm/opcodes/conversion.js +4 -4
  88. package/dest/public/avm/opcodes/ec_add.d.ts +4 -4
  89. package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -1
  90. package/dest/public/avm/opcodes/ec_add.js +17 -8
  91. package/dest/public/avm/opcodes/environment_getters.d.ts +5 -5
  92. package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -1
  93. package/dest/public/avm/opcodes/environment_getters.js +6 -6
  94. package/dest/public/avm/opcodes/external_calls.d.ts +9 -9
  95. package/dest/public/avm/opcodes/external_calls.d.ts.map +1 -1
  96. package/dest/public/avm/opcodes/external_calls.js +23 -22
  97. package/dest/public/avm/opcodes/hashing.d.ts +8 -8
  98. package/dest/public/avm/opcodes/hashing.d.ts.map +1 -1
  99. package/dest/public/avm/opcodes/hashing.js +21 -16
  100. package/dest/public/avm/opcodes/instruction_impl.d.ts +4 -4
  101. package/dest/public/avm/opcodes/instruction_impl.d.ts.map +1 -1
  102. package/dest/public/avm/opcodes/instruction_impl.js +4 -4
  103. package/dest/public/avm/opcodes/memory.d.ts +14 -14
  104. package/dest/public/avm/opcodes/memory.d.ts.map +1 -1
  105. package/dest/public/avm/opcodes/memory.js +26 -26
  106. package/dest/public/avm/opcodes/misc.d.ts +3 -3
  107. package/dest/public/avm/opcodes/misc.d.ts.map +1 -1
  108. package/dest/public/avm/opcodes/misc.js +4 -4
  109. package/dest/public/avm/opcodes/storage.d.ts +16 -15
  110. package/dest/public/avm/opcodes/storage.d.ts.map +1 -1
  111. package/dest/public/avm/opcodes/storage.js +34 -24
  112. package/dest/public/avm/revert_reason.d.ts +2 -2
  113. package/dest/public/avm/revert_reason.d.ts.map +1 -1
  114. package/dest/public/avm/serialization/instruction_serialization.js +1 -1
  115. package/dest/public/avm/test_utils.d.ts +2 -2
  116. package/dest/public/avm/test_utils.d.ts.map +1 -1
  117. package/dest/public/avm/test_utils.js +1 -1
  118. package/dest/public/contracts_db_checkpoint.d.ts +2 -2
  119. package/dest/public/contracts_db_checkpoint.d.ts.map +1 -1
  120. package/dest/public/db_interfaces.d.ts +2 -2
  121. package/dest/public/db_interfaces.d.ts.map +1 -1
  122. package/dest/public/debug_fn_name.d.ts +4 -4
  123. package/dest/public/debug_fn_name.d.ts.map +1 -1
  124. package/dest/public/debug_fn_name.js +14 -5
  125. package/dest/public/executor_metrics.d.ts +1 -1
  126. package/dest/public/executor_metrics.d.ts.map +1 -1
  127. package/dest/public/executor_metrics.js +12 -33
  128. package/dest/public/fixtures/amm_test.js +2 -2
  129. package/dest/public/fixtures/bulk_test.d.ts +3 -3
  130. package/dest/public/fixtures/bulk_test.d.ts.map +1 -1
  131. package/dest/public/fixtures/bulk_test.js +5 -69
  132. package/dest/public/fixtures/custom_bytecode_tester.d.ts +28 -6
  133. package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -1
  134. package/dest/public/fixtures/custom_bytecode_tester.js +36 -12
  135. package/dest/public/fixtures/custom_bytecode_tests.d.ts +11 -8
  136. package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -1
  137. package/dest/public/fixtures/custom_bytecode_tests.js +83 -18
  138. package/dest/public/fixtures/index.d.ts +4 -2
  139. package/dest/public/fixtures/index.d.ts.map +1 -1
  140. package/dest/public/fixtures/index.js +3 -1
  141. package/dest/public/fixtures/minimal_public_tx.d.ts +2 -7
  142. package/dest/public/fixtures/minimal_public_tx.d.ts.map +1 -1
  143. package/dest/public/fixtures/minimal_public_tx.js +4 -14
  144. package/dest/public/fixtures/opcode_spammer.d.ts +122 -0
  145. package/dest/public/fixtures/opcode_spammer.d.ts.map +1 -0
  146. package/dest/public/fixtures/opcode_spammer.js +1653 -0
  147. package/dest/public/fixtures/public_tx_simulation_tester.d.ts +15 -2
  148. package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
  149. package/dest/public/fixtures/public_tx_simulation_tester.js +36 -8
  150. package/dest/public/fixtures/simple_contract_data_source.d.ts +2 -2
  151. package/dest/public/fixtures/simple_contract_data_source.d.ts.map +1 -1
  152. package/dest/public/fixtures/token_test.js +1 -1
  153. package/dest/public/fixtures/utils.d.ts +2 -2
  154. package/dest/public/fixtures/utils.d.ts.map +1 -1
  155. package/dest/public/fixtures/utils.js +4 -3
  156. package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts +60 -0
  157. package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts.map +1 -0
  158. package/dest/public/fuzzing/avm_fuzzer_simulator.js +171 -0
  159. package/dest/public/fuzzing/avm_simulator_bin.d.ts +2 -0
  160. package/dest/public/fuzzing/avm_simulator_bin.d.ts.map +1 -0
  161. package/dest/public/fuzzing/avm_simulator_bin.js +118 -0
  162. package/dest/public/hinting_db_sources.d.ts +3 -2
  163. package/dest/public/hinting_db_sources.d.ts.map +1 -1
  164. package/dest/public/hinting_db_sources.js +7 -2
  165. package/dest/public/index.d.ts +2 -2
  166. package/dest/public/index.d.ts.map +1 -1
  167. package/dest/public/index.js +1 -1
  168. package/dest/public/public_db_sources.d.ts +5 -4
  169. package/dest/public/public_db_sources.d.ts.map +1 -1
  170. package/dest/public/public_db_sources.js +5 -5
  171. package/dest/public/public_processor/guarded_merkle_tree.d.ts +2 -1
  172. package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
  173. package/dest/public/public_processor/guarded_merkle_tree.js +5 -0
  174. package/dest/public/public_processor/public_processor.d.ts +6 -4
  175. package/dest/public/public_processor/public_processor.d.ts.map +1 -1
  176. package/dest/public/public_processor/public_processor.js +433 -37
  177. package/dest/public/public_processor/public_processor_metrics.d.ts +2 -2
  178. package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
  179. package/dest/public/public_processor/public_processor_metrics.js +28 -45
  180. package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +3 -14
  181. package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +1 -1
  182. package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +20 -55
  183. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +20 -5
  184. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +1 -1
  185. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +50 -11
  186. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts +4 -4
  187. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts.map +1 -1
  188. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.js +5 -5
  189. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts +4 -4
  190. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts.map +1 -1
  191. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.js +12 -11
  192. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts +23 -0
  193. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts.map +1 -0
  194. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.js +52 -0
  195. package/dest/public/public_tx_simulator/factories.d.ts +14 -0
  196. package/dest/public/public_tx_simulator/factories.d.ts.map +1 -0
  197. package/dest/public/public_tx_simulator/factories.js +28 -0
  198. package/dest/public/public_tx_simulator/index.d.ts +3 -1
  199. package/dest/public/public_tx_simulator/index.d.ts.map +1 -1
  200. package/dest/public/public_tx_simulator/index.js +2 -0
  201. package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +3 -3
  202. package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts.map +1 -1
  203. package/dest/public/public_tx_simulator/public_tx_context.d.ts +5 -4
  204. package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
  205. package/dest/public/public_tx_simulator/public_tx_context.js +9 -9
  206. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +7 -5
  207. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
  208. package/dest/public/public_tx_simulator/public_tx_simulator.js +17 -10
  209. package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts +24 -1
  210. package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts.map +1 -1
  211. package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts +2 -2
  212. package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts.map +1 -1
  213. package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.js +395 -19
  214. package/dest/public/side_effect_trace.d.ts +6 -5
  215. package/dest/public/side_effect_trace.d.ts.map +1 -1
  216. package/dest/public/side_effect_trace.js +4 -4
  217. package/dest/public/side_effect_trace_interface.d.ts +2 -2
  218. package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
  219. package/dest/public/state_manager/nullifiers.d.ts +2 -2
  220. package/dest/public/state_manager/nullifiers.d.ts.map +1 -1
  221. package/dest/public/state_manager/public_storage.d.ts +2 -2
  222. package/dest/public/state_manager/public_storage.d.ts.map +1 -1
  223. package/dest/public/state_manager/public_storage.js +1 -1
  224. package/dest/public/state_manager/state_manager.d.ts +11 -5
  225. package/dest/public/state_manager/state_manager.d.ts.map +1 -1
  226. package/dest/public/state_manager/state_manager.js +15 -8
  227. package/dest/public/test_executor_metrics.d.ts +3 -2
  228. package/dest/public/test_executor_metrics.d.ts.map +1 -1
  229. package/dest/public/test_executor_metrics.js +2 -2
  230. package/package.json +18 -18
  231. package/src/common/errors.ts +1 -1
  232. package/src/private/acvm/acvm.ts +4 -3
  233. package/src/private/acvm/deserialize.ts +1 -1
  234. package/src/private/acvm/serialize.ts +1 -1
  235. package/src/private/acvm_native.ts +11 -5
  236. package/src/private/acvm_wasm.ts +7 -3
  237. package/src/private/circuit_recording/circuit_recorder.ts +22 -19
  238. package/src/private/circuit_recording/file_circuit_recorder.ts +7 -2
  239. package/src/private/circuit_recording/memory_circuit_recorder.ts +6 -4
  240. package/src/private/factory.ts +7 -4
  241. package/src/public/avm/avm_context.ts +2 -2
  242. package/src/public/avm/avm_contract_call_result.ts +8 -6
  243. package/src/public/avm/avm_execution_environment.ts +10 -5
  244. package/src/public/avm/avm_gas.ts +3 -3
  245. package/src/public/avm/avm_machine_state.ts +7 -6
  246. package/src/public/avm/avm_memory_types.ts +5 -1
  247. package/src/public/avm/avm_simulator.ts +9 -6
  248. package/src/public/avm/calldata.ts +100 -0
  249. package/src/public/avm/errors.ts +1 -1
  250. package/src/public/avm/fixtures/avm_simulation_tester.ts +9 -3
  251. package/src/public/avm/fixtures/base_avm_simulation_tester.ts +1 -1
  252. package/src/public/avm/fixtures/initializers.ts +3 -2
  253. package/src/public/avm/fixtures/utils.ts +1 -1
  254. package/src/public/avm/opcodes/accrued_substate.ts +28 -30
  255. package/src/public/avm/opcodes/arithmetic.ts +14 -2
  256. package/src/public/avm/opcodes/bitwise.ts +3 -3
  257. package/src/public/avm/opcodes/comparators.ts +1 -1
  258. package/src/public/avm/opcodes/contract.ts +4 -7
  259. package/src/public/avm/opcodes/control_flow.ts +2 -2
  260. package/src/public/avm/opcodes/conversion.ts +3 -3
  261. package/src/public/avm/opcodes/ec_add.ts +15 -6
  262. package/src/public/avm/opcodes/environment_getters.ts +7 -7
  263. package/src/public/avm/opcodes/external_calls.ts +17 -15
  264. package/src/public/avm/opcodes/hashing.ts +16 -10
  265. package/src/public/avm/opcodes/instruction_impl.ts +2 -2
  266. package/src/public/avm/opcodes/memory.ts +20 -20
  267. package/src/public/avm/opcodes/misc.ts +2 -2
  268. package/src/public/avm/opcodes/storage.ts +30 -22
  269. package/src/public/avm/revert_reason.ts +1 -1
  270. package/src/public/avm/serialization/instruction_serialization.ts +1 -1
  271. package/src/public/avm/test_utils.ts +1 -1
  272. package/src/public/contracts_db_checkpoint.ts +1 -1
  273. package/src/public/db_interfaces.ts +1 -1
  274. package/src/public/debug_fn_name.ts +17 -8
  275. package/src/public/executor_metrics.ts +9 -33
  276. package/src/public/fixtures/amm_test.ts +2 -2
  277. package/src/public/fixtures/bulk_test.ts +9 -9
  278. package/src/public/fixtures/custom_bytecode_tester.ts +53 -19
  279. package/src/public/fixtures/custom_bytecode_tests.ts +111 -18
  280. package/src/public/fixtures/index.ts +7 -1
  281. package/src/public/fixtures/minimal_public_tx.ts +6 -15
  282. package/src/public/fixtures/opcode_spammer.ts +1721 -0
  283. package/src/public/fixtures/public_tx_simulation_tester.ts +40 -6
  284. package/src/public/fixtures/simple_contract_data_source.ts +1 -1
  285. package/src/public/fixtures/token_test.ts +1 -1
  286. package/src/public/fixtures/utils.ts +2 -3
  287. package/src/public/fuzzing/avm_fuzzer_simulator.ts +288 -0
  288. package/src/public/fuzzing/avm_simulator_bin.ts +175 -0
  289. package/src/public/hinting_db_sources.ts +6 -2
  290. package/src/public/index.ts +2 -0
  291. package/src/public/public_db_sources.ts +16 -6
  292. package/src/public/public_processor/guarded_merkle_tree.ts +4 -0
  293. package/src/public/public_processor/public_processor.ts +49 -19
  294. package/src/public/public_processor/public_processor_metrics.ts +16 -44
  295. package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +25 -63
  296. package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +65 -9
  297. package/src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts +7 -5
  298. package/src/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.ts +13 -14
  299. package/src/public/public_tx_simulator/dumping_cpp_public_tx_simulator.ts +83 -0
  300. package/src/public/public_tx_simulator/factories.ts +43 -0
  301. package/src/public/public_tx_simulator/index.ts +2 -0
  302. package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +1 -1
  303. package/src/public/public_tx_simulator/public_tx_context.ts +14 -7
  304. package/src/public/public_tx_simulator/public_tx_simulator.ts +32 -10
  305. package/src/public/public_tx_simulator/public_tx_simulator_interface.ts +23 -0
  306. package/src/public/public_tx_simulator/telemetry_public_tx_simulator.ts +1 -1
  307. package/src/public/side_effect_trace.ts +6 -3
  308. package/src/public/side_effect_trace_interface.ts +1 -1
  309. package/src/public/state_manager/nullifiers.ts +1 -1
  310. package/src/public/state_manager/public_storage.ts +1 -1
  311. package/src/public/state_manager/state_manager.ts +31 -22
  312. package/src/public/test_executor_metrics.ts +3 -3
@@ -1,5 +1,4 @@
1
- import { type Logger, createLogger, logLevel } from '@aztec/foundation/log';
2
- import { writeTestData } from '@aztec/foundation/testing/files';
1
+ import { type Logger, type LoggerBindings, createLogger, logLevel } from '@aztec/foundation/log';
3
2
  import { avmSimulate } from '@aztec/native';
4
3
  import { ProtocolContractsList } from '@aztec/protocol-contracts';
5
4
  import {
@@ -38,9 +37,10 @@ export class CppVsTsPublicTxSimulator extends PublicTxSimulator implements Publi
38
37
  contractsDB: PublicContractsDB,
39
38
  globalVariables: GlobalVariables,
40
39
  config?: Partial<PublicSimulatorConfig>,
40
+ bindings?: LoggerBindings,
41
41
  ) {
42
- super(merkleTree, contractsDB, globalVariables, config);
43
- this.log = createLogger(`simulator:cpp_public_tx_simulator`);
42
+ super(merkleTree, contractsDB, globalVariables, config, undefined, bindings);
43
+ this.log = createLogger(`simulator:cpp_vs_public_tx_simulator`, bindings);
44
44
  }
45
45
 
46
46
  /**
@@ -104,7 +104,7 @@ export class CppVsTsPublicTxSimulator extends PublicTxSimulator implements Publi
104
104
  );
105
105
 
106
106
  // Create contract provider for callbacks to TypeScript PublicContractsDB from C++
107
- const contractProvider = new ContractProviderForCpp(this.contractsDB, this.globalVariables);
107
+ const contractProvider = new ContractProviderForCpp(this.contractsDB, this.globalVariables, this.bindings);
108
108
 
109
109
  // Serialize to msgpack and call the C++ simulator
110
110
  this.log.debug(`Serializing fast simulation inputs to msgpack...`);
@@ -126,12 +126,6 @@ export class CppVsTsPublicTxSimulator extends PublicTxSimulator implements Publi
126
126
  // Deserialize the msgpack result
127
127
  this.log.debug(`Deserializing C++ from buffer (size: ${resultBuffer.length})...`);
128
128
  const cppResultJSON: object = deserializeFromMessagePack(resultBuffer);
129
- // Write testdata if AZTEC_WRITE_TESTDATA=1.
130
- writeTestData(
131
- `barretenberg/cpp/src/barretenberg/vm2/testing/tx_result_${txHash}.testdata.bin`,
132
- resultBuffer,
133
- /*raw=*/ true,
134
- );
135
129
  this.log.debug(`Deserializing C++ result to PublicTxResult...`);
136
130
  const cppResult = PublicTxResult.fromPlainObject(cppResultJSON);
137
131
  this.log.debug(`Done.`);
@@ -140,7 +134,10 @@ export class CppVsTsPublicTxSimulator extends PublicTxSimulator implements Publi
140
134
  assert(cppResult.gasUsed.publicGas.equals(tsResult.gasUsed.publicGas));
141
135
  assert(cppResult.gasUsed.teardownGas.equals(tsResult.gasUsed.teardownGas));
142
136
  assert(cppResult.gasUsed.billedGas.equals(tsResult.gasUsed.billedGas));
143
- assert(cppResult.publicInputs.toBuffer().equals(tsResult.publicInputs.toBuffer()));
137
+ assert(cppResult.publicTxEffect.equals(tsResult.publicTxEffect));
138
+ if (cppResult.publicInputs !== undefined) {
139
+ assert(cppResult.publicInputs!.toBuffer().equals(tsResult.publicInputs!.toBuffer()));
140
+ }
144
141
 
145
142
  // TODO(fcarreiro): complete this.
146
143
  // Check that C++ hints are a strict subset of TS hints.
@@ -209,7 +206,8 @@ export class CppVsTsPublicTxSimulator extends PublicTxSimulator implements Publi
209
206
  cppGasUsed: cppResult.gasUsed.totalGas.l2Gas,
210
207
  });
211
208
 
212
- return tsResult;
209
+ // Return cpp result as it has more detailed metadata / revert reasons
210
+ return cppResult;
213
211
  }
214
212
  }
215
213
 
@@ -223,8 +221,9 @@ export class MeasuredCppVsTsPublicTxSimulator
223
221
  globalVariables: GlobalVariables,
224
222
  protected readonly metrics: ExecutorMetricsInterface,
225
223
  config?: Partial<PublicSimulatorConfig>,
224
+ bindings?: LoggerBindings,
226
225
  ) {
227
- super(merkleTree, contractsDB, globalVariables, config);
226
+ super(merkleTree, contractsDB, globalVariables, config, bindings);
228
227
  }
229
228
 
230
229
  public override async simulate(tx: Tx, txLabel: string = 'unlabeledTx'): Promise<PublicTxResult> {
@@ -0,0 +1,83 @@
1
+ import type { LoggerBindings } from '@aztec/foundation/log';
2
+ import {
3
+ AvmCircuitInputs,
4
+ AvmCircuitPublicInputs,
5
+ AvmExecutionHints,
6
+ type PublicSimulatorConfig,
7
+ PublicTxResult,
8
+ serializeWithMessagePack,
9
+ } from '@aztec/stdlib/avm';
10
+ import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
11
+ import type { GlobalVariables, Tx, TxHash } from '@aztec/stdlib/tx';
12
+
13
+ import { strict as assert } from 'assert';
14
+ import { mkdirSync, writeFileSync } from 'fs';
15
+ import { join } from 'path';
16
+
17
+ import type { PublicContractsDB } from '../public_db_sources.js';
18
+ import { CppPublicTxSimulator } from './cpp_public_tx_simulator.js';
19
+
20
+ /**
21
+ * A C++ public tx simulator that dumps AVM circuit inputs to disk after simulation.
22
+ * Used during nightly CI runs to collect circuit inputs for benchmarking.
23
+ */
24
+ export class DumpingCppPublicTxSimulator extends CppPublicTxSimulator {
25
+ private readonly outputDir: string;
26
+
27
+ constructor(
28
+ merkleTree: MerkleTreeWriteOperations,
29
+ contractsDB: PublicContractsDB,
30
+ globalVariables: GlobalVariables,
31
+ config: Partial<PublicSimulatorConfig>,
32
+ outputDir: string,
33
+ bindings?: LoggerBindings,
34
+ ) {
35
+ super(merkleTree, contractsDB, globalVariables, config, bindings);
36
+ assert(config.collectHints === true, 'collectHints must be enabled to dump AVM circuit inputs');
37
+ assert(config.collectPublicInputs === true, 'collectPublicInputs must be enabled to dump AVM circuit inputs');
38
+ this.outputDir = outputDir;
39
+ }
40
+
41
+ public override async simulate(tx: Tx): Promise<PublicTxResult> {
42
+ const result = await super.simulate(tx);
43
+
44
+ // Dump the circuit inputs after successful simulation
45
+ const txHash = this.computeTxHash(tx);
46
+ this.dumpAvmCircuitInputs(result, txHash);
47
+
48
+ return result;
49
+ }
50
+
51
+ /**
52
+ * Dumps AVM circuit inputs to disk.
53
+ *
54
+ * @param result - The simulation result containing hints and public inputs
55
+ * @param txHash - The transaction hash to use in the filename
56
+ */
57
+ private dumpAvmCircuitInputs(result: PublicTxResult, txHash: TxHash): void {
58
+ try {
59
+ // Ensure the output directory exists
60
+ mkdirSync(this.outputDir, { recursive: true });
61
+
62
+ // Generate filename using transaction hash
63
+ const filename = `avm-circuit-inputs-tx-${txHash.toString()}.bin`;
64
+ const filepath = join(this.outputDir, filename);
65
+
66
+ // Create circuit inputs from the result
67
+ const hints = result.hints ?? AvmExecutionHints.empty();
68
+ const publicInputs = result.publicInputs ?? AvmCircuitPublicInputs.empty();
69
+ const avmCircuitInputs = new AvmCircuitInputs(hints, publicInputs);
70
+
71
+ // Serialize the circuit inputs using MessagePack
72
+ const serialized = serializeWithMessagePack(avmCircuitInputs);
73
+
74
+ // Write to disk
75
+ writeFileSync(filepath, serialized);
76
+
77
+ this.log.debug(`Dumped AVM circuit inputs to ${filepath}`);
78
+ } catch (error) {
79
+ // Non-blocking error handling - log but don't interrupt processing
80
+ this.log.warn(`Failed to dump AVM circuit inputs for tx ${txHash.toString()}: ${error}`);
81
+ }
82
+ }
83
+ }
@@ -0,0 +1,43 @@
1
+ import type { LoggerBindings } from '@aztec/foundation/log';
2
+ import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
3
+ import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
4
+ import type { GlobalVariables } from '@aztec/stdlib/tx';
5
+ import type { TelemetryClient } from '@aztec/telemetry-client';
6
+
7
+ import type { PublicContractsDB } from '../public_db_sources.js';
8
+ import { TelemetryCppPublicTxSimulator } from './cpp_public_tx_simulator.js';
9
+ import { DumpingCppPublicTxSimulator } from './dumping_cpp_public_tx_simulator.js';
10
+
11
+ /**
12
+ * Creates a public tx simulator for block building.
13
+ * Uses DumpingCppPublicTxSimulator if DUMP_AVM_INPUTS_TO_DIR env var is set (for CI/testing avm circuit),
14
+ * otherwise uses TelemetryCppPublicTxSimulator (for production).
15
+ */
16
+ export function createPublicTxSimulatorForBlockBuilding(
17
+ merkleTree: MerkleTreeWriteOperations,
18
+ contractsDB: PublicContractsDB,
19
+ globalVariables: GlobalVariables,
20
+ telemetryClient: TelemetryClient,
21
+ bindings?: LoggerBindings,
22
+ ) {
23
+ const config = PublicSimulatorConfig.from({
24
+ skipFeeEnforcement: false,
25
+ collectDebugLogs: false,
26
+ collectHints: false,
27
+ collectPublicInputs: false,
28
+ collectStatistics: false,
29
+ collectCallMetadata: false,
30
+ });
31
+
32
+ const dumpDir = process.env.DUMP_AVM_INPUTS_TO_DIR;
33
+ if (dumpDir) {
34
+ // must collect hints and PIs for dumping
35
+ const dumpingConfig = {
36
+ ...config,
37
+ collectHints: true,
38
+ collectPublicInputs: true,
39
+ };
40
+ return new DumpingCppPublicTxSimulator(merkleTree, contractsDB, globalVariables, dumpingConfig, dumpDir, bindings);
41
+ }
42
+ return new TelemetryCppPublicTxSimulator(merkleTree, contractsDB, globalVariables, telemetryClient, config, bindings);
43
+ }
@@ -1,5 +1,7 @@
1
1
  export * from './public_tx_simulator.js';
2
2
  export { CppPublicTxSimulator, TelemetryCppPublicTxSimulator } from './cpp_public_tx_simulator.js';
3
+ export { DumpingCppPublicTxSimulator } from './dumping_cpp_public_tx_simulator.js';
4
+ export { createPublicTxSimulatorForBlockBuilding } from './factories.js';
3
5
  export type { PublicTxSimulatorInterface } from './public_tx_simulator_interface.js';
4
6
  export { TelemetryPublicTxSimulator } from './telemetry_public_tx_simulator.js';
5
7
  export type { PublicTxResult, PublicSimulatorConfig as PublicTxSimulatorConfig } from '@aztec/stdlib/avm';
@@ -1,4 +1,4 @@
1
- import type { Fr } from '@aztec/foundation/fields';
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { Timer } from '@aztec/foundation/timer';
3
3
  import type { PublicSimulatorConfig, PublicTxResult } from '@aztec/stdlib/avm';
4
4
  import type { Gas } from '@aztec/stdlib/gas';
@@ -6,8 +6,8 @@ import {
6
6
  MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
7
7
  } from '@aztec/constants';
8
8
  import { padArrayEnd } from '@aztec/foundation/collection';
9
- import { Fr } from '@aztec/foundation/fields';
10
- import { type Logger, createLogger } from '@aztec/foundation/log';
9
+ import { Fr } from '@aztec/foundation/curves/bn254';
10
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
11
11
  import {
12
12
  AvmAccumulatedData,
13
13
  AvmAccumulatedDataArrayLengths,
@@ -87,8 +87,9 @@ export class PublicTxContext {
87
87
  public readonly revertibleAccumulatedDataFromPrivate: PrivateToPublicAccumulatedData,
88
88
  public readonly feePayer: AztecAddress,
89
89
  private readonly trace: SideEffectTrace,
90
+ bindings?: LoggerBindings,
90
91
  ) {
91
- this.log = createLogger(`simulator:public_tx_context`);
92
+ this.log = createLogger(`simulator:public_tx_context`, bindings);
92
93
  }
93
94
 
94
95
  public static async create(
@@ -98,13 +99,14 @@ export class PublicTxContext {
98
99
  globalVariables: GlobalVariables,
99
100
  protocolContracts: ProtocolContracts,
100
101
  proverId: Fr,
102
+ bindings?: LoggerBindings,
101
103
  ) {
102
104
  const contractDeploymentData = AllContractDeploymentData.fromTx(tx);
103
105
  const nonRevertibleContractDeploymentData = contractDeploymentData.getNonRevertibleContractDeploymentData();
104
106
  const revertibleContractDeploymentData = contractDeploymentData.getRevertibleContractDeploymentData();
105
107
  const nonRevertibleAccumulatedDataFromPrivate = tx.data.forPublic!.nonRevertibleAccumulatedData;
106
108
 
107
- const trace = new SideEffectTrace();
109
+ const trace = new SideEffectTrace(0, bindings);
108
110
 
109
111
  const firstNullifier = nonRevertibleAccumulatedDataFromPrivate.nullifiers[0];
110
112
 
@@ -115,6 +117,7 @@ export class PublicTxContext {
115
117
  trace,
116
118
  firstNullifier,
117
119
  globalVariables.timestamp,
120
+ bindings,
118
121
  );
119
122
 
120
123
  const gasSettings = tx.data.constants.txContext.gasSettings;
@@ -124,7 +127,7 @@ export class PublicTxContext {
124
127
 
125
128
  return new PublicTxContext(
126
129
  tx.getTxHash(),
127
- new PhaseStateManager(txStateManager),
130
+ new PhaseStateManager(txStateManager, bindings),
128
131
  await txStateManager.getTreeSnapshots(),
129
132
  globalVariables,
130
133
  protocolContracts,
@@ -142,6 +145,7 @@ export class PublicTxContext {
142
145
  tx.data.forPublic!.revertibleAccumulatedData,
143
146
  tx.data.feePayer,
144
147
  trace,
148
+ bindings,
145
149
  );
146
150
  }
147
151
 
@@ -441,8 +445,11 @@ class PhaseStateManager {
441
445
 
442
446
  private currentlyActiveStateManager: PublicPersistableStateManager | undefined;
443
447
 
444
- constructor(private readonly txStateManager: PublicPersistableStateManager) {
445
- this.log = createLogger(`simulator:public_phase_state_manager`);
448
+ constructor(
449
+ private readonly txStateManager: PublicPersistableStateManager,
450
+ bindings?: LoggerBindings,
451
+ ) {
452
+ this.log = createLogger(`simulator:public_phase_state_manager`, bindings);
446
453
  }
447
454
 
448
455
  async fork() {
@@ -1,15 +1,16 @@
1
1
  import { AVM_MAX_PROCESSABLE_L2_GAS } from '@aztec/constants';
2
- import { Fr } from '@aztec/foundation/fields';
3
- import { type Logger, createLogger } from '@aztec/foundation/log';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
4
4
  import { ProtocolContractAddress, ProtocolContractsList } from '@aztec/protocol-contracts';
5
5
  import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
6
- import { AvmExecutionHints, AvmTxHint, PublicSimulatorConfig, PublicTxResult } from '@aztec/stdlib/avm';
6
+ import { AvmExecutionHints, AvmTxHint, PublicSimulatorConfig, PublicTxEffect, PublicTxResult } from '@aztec/stdlib/avm';
7
7
  import { SimulationError } from '@aztec/stdlib/errors';
8
8
  import { Gas } from '@aztec/stdlib/gas';
9
9
  import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
10
10
  import {
11
11
  type GlobalVariables,
12
12
  NestedProcessReturnValues,
13
+ ProtocolContracts,
13
14
  PublicCallRequestWithCalldata,
14
15
  Tx,
15
16
  TxExecutionPhase,
@@ -18,6 +19,7 @@ import {
18
19
  import { strict as assert } from 'assert';
19
20
 
20
21
  import type { AvmFinalizedCallResult } from '../avm/avm_contract_call_result.js';
22
+ import { CallDataArray } from '../avm/calldata.js';
21
23
  import { AvmSimulator } from '../avm/index.js';
22
24
  import { getPublicFunctionDebugName } from '../debug_fn_name.js';
23
25
  import { HintingMerkleWriteOperations, HintingPublicContractsDB } from '../hinting_db_sources.js';
@@ -79,15 +81,19 @@ type ProcessedPhase = {
79
81
  export class PublicTxSimulator implements PublicTxSimulatorInterface {
80
82
  protected log: Logger;
81
83
  protected readonly config: PublicSimulatorConfig;
84
+ protected readonly bindings?: LoggerBindings;
82
85
 
83
86
  constructor(
84
87
  protected merkleTree: MerkleTreeWriteOperations,
85
88
  protected contractsDB: PublicContractsDB,
86
89
  protected globalVariables: GlobalVariables,
87
90
  config?: Partial<PublicSimulatorConfig>,
91
+ protected protocolContracts: ProtocolContracts = ProtocolContractsList,
92
+ bindings?: LoggerBindings,
88
93
  ) {
89
94
  this.config = PublicSimulatorConfig.from(config ?? {});
90
- this.log = createLogger(`simulator:public_tx_simulator`);
95
+ this.bindings = bindings;
96
+ this.log = createLogger(`simulator:public_tx_simulator`, bindings);
91
97
  }
92
98
 
93
99
  /**
@@ -103,7 +109,7 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
103
109
  const hints = new AvmExecutionHints(
104
110
  this.globalVariables,
105
111
  AvmTxHint.fromTx(tx, this.globalVariables.gasFees),
106
- ProtocolContractsList, // imported from file
112
+ this.protocolContracts,
107
113
  );
108
114
  const hintingMerkleTree = await HintingMerkleWriteOperations.create(this.merkleTree, hints);
109
115
  const hintingTreesDB = new PublicTreesDB(hintingMerkleTree);
@@ -114,8 +120,9 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
114
120
  hintingContractsDB,
115
121
  tx,
116
122
  this.globalVariables,
117
- ProtocolContractsList, // imported from file
123
+ this.protocolContracts,
118
124
  this.config.proverId,
125
+ this.bindings,
119
126
  );
120
127
 
121
128
  // This will throw if there is a nullifier collision.
@@ -209,6 +216,16 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
209
216
  (appLogicReturnValues as any).revertReason = context.revertReason;
210
217
  }
211
218
 
219
+ // Create PublicTxEffect from PublicInputs.
220
+ const publicTxEffect = new PublicTxEffect(
221
+ publicInputs.transactionFee,
222
+ publicInputs.accumulatedData.noteHashes.filter(h => !h.isEmpty()),
223
+ publicInputs.accumulatedData.nullifiers.filter(n => !n.isEmpty()),
224
+ publicInputs.accumulatedData.l2ToL1Msgs.filter(m => !m.isEmpty()),
225
+ publicInputs.accumulatedData.publicLogs.toLogs(),
226
+ publicInputs.accumulatedData.publicDataWrites.filter(w => !w.isEmpty()),
227
+ );
228
+
212
229
  return new PublicTxResult(
213
230
  /*gasUsed=*/ {
214
231
  totalGas: context.getActualGasUsed(),
@@ -217,6 +234,7 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
217
234
  billedGas: context.getTotalGasUsed(),
218
235
  },
219
236
  /*revertCode=*/ revertCode,
237
+ /*publicTxEffect=*/ publicTxEffect,
220
238
  /*callStackMetadata=*/ appLogicReturnValues,
221
239
  /*logs=*/ context.state.getActiveStateManager().getLogs(),
222
240
  /*hints=*/ hints,
@@ -254,7 +272,7 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
254
272
 
255
273
  const enqueuedCallResult = await this.simulateEnqueuedCall(phase, context, callRequest);
256
274
 
257
- returnValues.push(new NestedProcessReturnValues(enqueuedCallResult.output));
275
+ returnValues.push(new NestedProcessReturnValues(enqueuedCallResult.output.bestEffortReadAll()));
258
276
 
259
277
  if (enqueuedCallResult.reverted) {
260
278
  reverted = true;
@@ -284,7 +302,11 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
284
302
  ): Promise<AvmFinalizedCallResult> {
285
303
  const stateManager = context.state.getActiveStateManager();
286
304
  const contractAddress = callRequest.request.contractAddress;
287
- const fnName = await getPublicFunctionDebugName(this.contractsDB, contractAddress, callRequest.calldata);
305
+ const fnName = await getPublicFunctionDebugName(
306
+ this.contractsDB,
307
+ contractAddress,
308
+ new CallDataArray(callRequest.calldata),
309
+ );
288
310
 
289
311
  const allocatedGas = context.getGasLeftAtPhase(phase);
290
312
 
@@ -303,7 +325,7 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
303
325
  );
304
326
 
305
327
  if (result.reverted) {
306
- const culprit = `${contractAddress}:${callRequest.functionSelector}`;
328
+ const culprit = `${contractAddress}:${fnName}`;
307
329
  context.revert(phase, result.revertReason, culprit);
308
330
  }
309
331
 
@@ -344,7 +366,7 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
344
366
  transactionFee,
345
367
  this.globalVariables,
346
368
  request.isStaticCall,
347
- calldata,
369
+ new CallDataArray(calldata),
348
370
  allocatedGas,
349
371
  this.config,
350
372
  );
@@ -3,8 +3,31 @@ import type { Tx } from '@aztec/stdlib/tx';
3
3
 
4
4
  export interface PublicTxSimulatorInterface {
5
5
  simulate(tx: Tx): Promise<PublicTxResult>;
6
+ /**
7
+ * Cancel the current simulation if one is in progress.
8
+ * This signals the underlying simulator (e.g., C++) to stop at the next safe point.
9
+ * Safe to call even if no simulation is in progress.
10
+ * Optional - not all implementations support cancellation.
11
+ *
12
+ * @param waitTimeoutMs - If provided, wait up to this many ms for the simulation to actually stop.
13
+ * This is important because signaling cancellation doesn't immediately stop C++ -
14
+ * it only sets a flag that C++ checks at certain points. If C++ is in the middle
15
+ * of a slow operation (e.g., pad_trees), it won't stop until that completes.
16
+ * @returns Promise that resolves when cancellation is signaled (and optionally when simulation stops)
17
+ */
18
+ cancel?(waitTimeoutMs?: number): Promise<void>;
6
19
  }
7
20
 
8
21
  export interface MeasuredPublicTxSimulatorInterface {
9
22
  simulate(tx: Tx, txLabel: string): Promise<PublicTxResult>;
23
+ /**
24
+ * Cancel the current simulation if one is in progress.
25
+ * This signals the underlying simulator (e.g., C++) to stop at the next safe point.
26
+ * Safe to call even if no simulation is in progress.
27
+ * Optional - not all implementations support cancellation.
28
+ *
29
+ * @param waitTimeoutMs - If provided, wait up to this many ms for the simulation to actually stop.
30
+ * @returns Promise that resolves when cancellation is signaled (and optionally when simulation stops)
31
+ */
32
+ cancel?(waitTimeoutMs?: number): Promise<void>;
10
33
  }
@@ -1,4 +1,4 @@
1
- import type { Fr } from '@aztec/foundation/fields';
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import type { PublicSimulatorConfig } from '@aztec/stdlib/avm';
3
3
  import type { Gas } from '@aztec/stdlib/gas';
4
4
  import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
@@ -7,9 +7,9 @@ import {
7
7
  MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
8
8
  PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
9
9
  } from '@aztec/constants';
10
+ import { Fr } from '@aztec/foundation/curves/bn254';
10
11
  import { EthAddress } from '@aztec/foundation/eth-address';
11
- import { Fr } from '@aztec/foundation/fields';
12
- import { type LogLevel, createLogger } from '@aztec/foundation/log';
12
+ import { type LogLevel, type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
13
13
  import { PublicDataUpdateRequest } from '@aztec/stdlib/avm';
14
14
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
15
15
  import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
@@ -61,7 +61,7 @@ export class SideEffectArrayLengths {
61
61
  * Trace side effects for an enqueued public call's execution.
62
62
  */
63
63
  export class SideEffectTrace implements PublicSideEffectTraceInterface {
64
- public log = createLogger('simulator:side_effect_trace');
64
+ public log: Logger;
65
65
 
66
66
  /** The side effect counter increments with every call to the trace. */
67
67
  private sideEffectCounter: number;
@@ -79,6 +79,7 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
79
79
  constructor(
80
80
  /** The counter of this trace's first side effect. */
81
81
  public readonly startSideEffectCounter: number = 0,
82
+ bindings?: LoggerBindings,
82
83
  /** Track parent's (or previous kernel's) lengths so the AVM can properly enforce TX-wide limits,
83
84
  * otherwise the public kernel can fail to prove because TX limits are breached.
84
85
  */
@@ -90,11 +91,13 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
90
91
  private debugLogMemoryReads: number = 0,
91
92
  ) {
92
93
  this.sideEffectCounter = startSideEffectCounter;
94
+ this.log = createLogger('simulator:side_effect_trace', bindings);
93
95
  }
94
96
 
95
97
  public fork() {
96
98
  return new SideEffectTrace(
97
99
  this.sideEffectCounter,
100
+ this.log.getBindings(),
98
101
  new SideEffectArrayLengths(
99
102
  this.previousSideEffectArrayLengths.publicDataWrites + this.userPublicDataWritesLength,
100
103
  this.previousSideEffectArrayLengths.protocolPublicDataWrites + this.protocolPublicDataWritesLength,
@@ -1,4 +1,4 @@
1
- import type { Fr } from '@aztec/foundation/fields';
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import type { LogLevel } from '@aztec/foundation/log';
3
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import type { DebugLog } from '@aztec/stdlib/logs';
@@ -1,4 +1,4 @@
1
- import type { Fr } from '@aztec/foundation/fields';
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
2
 
3
3
  import type { PublicTreesDB } from '../public_db_sources.js';
4
4
  import { NullifierCollisionError } from '../side_effect_errors.js';
@@ -1,4 +1,4 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
3
 
4
4
  import type { PublicStateDBInterface } from '../db_interfaces.js';
@@ -1,15 +1,8 @@
1
- import {
2
- CANONICAL_AUTH_REGISTRY_ADDRESS,
3
- CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS,
4
- CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS,
5
- FEE_JUICE_ADDRESS,
6
- MULTI_CALL_ENTRYPOINT_ADDRESS,
7
- ROUTER_ADDRESS,
8
- } from '@aztec/constants';
9
- import { poseidon2Hash } from '@aztec/foundation/crypto';
10
- import { Fr } from '@aztec/foundation/fields';
1
+ import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS, MAX_PROTOCOL_CONTRACTS } from '@aztec/constants';
2
+ import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
3
+ import { Fr } from '@aztec/foundation/curves/bn254';
11
4
  import { jsonStringify } from '@aztec/foundation/json-rpc';
12
- import { type LogLevel, createLogger } from '@aztec/foundation/log';
5
+ import { type LogLevel, type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
13
6
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
14
7
  import { FunctionSelector } from '@aztec/stdlib/abi';
15
8
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
@@ -49,7 +42,7 @@ import { PublicStorage } from './public_storage.js';
49
42
  * Manages merging of successful/reverted child state into current state.
50
43
  */
51
44
  export class PublicPersistableStateManager {
52
- private readonly log = createLogger('simulator:state_manager');
45
+ private readonly log: Logger;
53
46
 
54
47
  /** Make sure a forked state is never merged twice. */
55
48
  private alreadyMergedIntoParent = false;
@@ -63,7 +56,10 @@ export class PublicPersistableStateManager {
63
56
  private readonly doMerkleOperations: boolean = true,
64
57
  private readonly publicStorage: PublicStorage = new PublicStorage(treesDB),
65
58
  private readonly nullifiers: NullifierManager = new NullifierManager(treesDB),
66
- ) {}
59
+ bindings?: LoggerBindings,
60
+ ) {
61
+ this.log = createLogger('simulator:state_manager', bindings);
62
+ }
67
63
 
68
64
  /**
69
65
  * Create a new state manager
@@ -74,8 +70,19 @@ export class PublicPersistableStateManager {
74
70
  trace: PublicSideEffectTraceInterface,
75
71
  firstNullifier: Fr,
76
72
  timestamp: UInt64,
73
+ bindings?: LoggerBindings,
77
74
  ): PublicPersistableStateManager {
78
- return new PublicPersistableStateManager(treesDB, contractsDB, trace, firstNullifier, timestamp);
75
+ return new PublicPersistableStateManager(
76
+ treesDB,
77
+ contractsDB,
78
+ trace,
79
+ firstNullifier,
80
+ timestamp,
81
+ undefined,
82
+ undefined,
83
+ undefined,
84
+ bindings,
85
+ );
79
86
  }
80
87
 
81
88
  /**
@@ -92,6 +99,7 @@ export class PublicPersistableStateManager {
92
99
  this.doMerkleOperations,
93
100
  this.publicStorage.fork(),
94
101
  this.nullifiers.fork(),
102
+ this.log.getBindings(),
95
103
  );
96
104
  }
97
105
 
@@ -240,7 +248,15 @@ export class PublicPersistableStateManager {
240
248
  public async checkNullifierExists(contractAddress: AztecAddress, nullifier: Fr): Promise<boolean> {
241
249
  this.log.trace(`Checking existence of nullifier (address=${contractAddress}, nullifier=${nullifier})`);
242
250
  const siloedNullifier = await siloNullifier(contractAddress, nullifier);
251
+ return this.checkSiloedNullifierExists(siloedNullifier);
252
+ }
243
253
 
254
+ /**
255
+ * Check if a siloed nullifier exists.
256
+ * @param siloedNullifier - the siloed nullifier to check
257
+ * @returns exists - whether the nullifier exists in the nullifier set
258
+ */
259
+ public async checkSiloedNullifierExists(siloedNullifier: Fr): Promise<boolean> {
244
260
  if (this.doMerkleOperations) {
245
261
  const exists = await this.treesDB.checkNullifierExists(siloedNullifier);
246
262
  this.log.trace(`Checked siloed nullifier ${siloedNullifier} (exists=${exists})`);
@@ -549,12 +565,5 @@ export class PublicPersistableStateManager {
549
565
  }
550
566
 
551
567
  function contractAddressIsCanonical(contractAddress: AztecAddress): boolean {
552
- return (
553
- contractAddress.equals(AztecAddress.fromNumber(CANONICAL_AUTH_REGISTRY_ADDRESS)) ||
554
- contractAddress.equals(AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS)) ||
555
- contractAddress.equals(AztecAddress.fromNumber(CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS)) ||
556
- contractAddress.equals(AztecAddress.fromNumber(MULTI_CALL_ENTRYPOINT_ADDRESS)) ||
557
- contractAddress.equals(AztecAddress.fromNumber(FEE_JUICE_ADDRESS)) ||
558
- contractAddress.equals(AztecAddress.fromNumber(ROUTER_ADDRESS))
559
- );
568
+ return contractAddress.toBigInt() >= 1 && contractAddress.toBigInt() <= MAX_PROTOCOL_CONTRACTS;
560
569
  }
@@ -1,5 +1,5 @@
1
1
  import { sum } from '@aztec/foundation/collection';
2
- import { type Logger, createLogger } from '@aztec/foundation/log';
2
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
3
3
  import { Timer } from '@aztec/foundation/timer';
4
4
  import type { RevertCode } from '@aztec/stdlib/avm';
5
5
  import type { GasUsed } from '@aztec/stdlib/gas';
@@ -88,8 +88,8 @@ export class TestExecutorMetrics implements ExecutorMetricsInterface {
88
88
  private currentTxLabel: string | undefined;
89
89
  private txTimer: Timer | undefined;
90
90
 
91
- constructor() {
92
- this.logger = createLogger(`simulator:test_executor_metrics`);
91
+ constructor(bindings?: LoggerBindings) {
92
+ this.logger = createLogger(`simulator:test_executor_metrics`, bindings);
93
93
  }
94
94
 
95
95
  startRecordingTxSimulation(txLabel: string) {