@aztec/simulator 0.0.1-commit.2eb6648a → 0.0.1-commit.2f68f620

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 +4 -4
  2. package/dest/private/acvm_wasm.d.ts +1 -1
  3. package/dest/private/acvm_wasm.d.ts.map +1 -1
  4. package/dest/private/acvm_wasm.js +3 -1
  5. package/dest/private/circuit_recording/circuit_recorder.js +2 -2
  6. package/dest/public/avm/testing/account_proof_fetcher.d.ts +2 -0
  7. package/dest/public/avm/testing/account_proof_fetcher.d.ts.map +1 -0
  8. package/dest/public/avm/testing/account_proof_fetcher.js +152 -0
  9. package/dest/public/avm/{fixtures → testing}/base_avm_simulation_tester.d.ts +2 -1
  10. package/dest/public/avm/testing/base_avm_simulation_tester.d.ts.map +1 -0
  11. package/dest/public/avm/{fixtures → testing}/base_avm_simulation_tester.js +17 -2
  12. package/dest/public/avm/testing/utils.d.ts +32 -0
  13. package/dest/public/avm/testing/utils.d.ts.map +1 -0
  14. package/dest/public/avm/{fixtures → testing}/utils.js +3 -33
  15. package/dest/public/contracts_db_checkpoint.d.ts +2 -2
  16. package/dest/public/contracts_db_checkpoint.d.ts.map +1 -1
  17. package/dest/public/contracts_db_checkpoint.js +1 -1
  18. package/dest/public/fixtures/amm_test.js +2 -2
  19. package/dest/public/fixtures/bulk_test.d.ts +1 -1
  20. package/dest/public/fixtures/bulk_test.d.ts.map +1 -1
  21. package/dest/public/fixtures/bulk_test.js +31 -4
  22. package/dest/public/fixtures/index.d.ts +1 -4
  23. package/dest/public/fixtures/index.d.ts.map +1 -1
  24. package/dest/public/fixtures/index.js +0 -3
  25. package/dest/public/fixtures/public_tx_simulation_tester.d.ts +8 -7
  26. package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
  27. package/dest/public/fixtures/public_tx_simulation_tester.js +16 -17
  28. package/dest/public/fixtures/simple_contract_data_source.js +1 -1
  29. package/dest/public/fixtures/utils.d.ts +2 -2
  30. package/dest/public/fixtures/utils.d.ts.map +1 -1
  31. package/dest/public/fixtures/utils.js +19 -20
  32. package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts +6 -4
  33. package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts.map +1 -1
  34. package/dest/public/fuzzing/avm_fuzzer_simulator.js +12 -7
  35. package/dest/public/fuzzing/avm_simulator_bin.js +4 -4
  36. package/dest/public/index.d.ts +2 -2
  37. package/dest/public/index.d.ts.map +1 -1
  38. package/dest/public/index.js +1 -1
  39. package/dest/public/public_db_sources.d.ts +6 -3
  40. package/dest/public/public_db_sources.d.ts.map +1 -1
  41. package/dest/public/public_db_sources.js +16 -10
  42. package/dest/public/public_processor/guarded_merkle_tree.d.ts +8 -7
  43. package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
  44. package/dest/public/public_processor/guarded_merkle_tree.js +8 -5
  45. package/dest/public/public_processor/public_processor.d.ts +8 -5
  46. package/dest/public/public_processor/public_processor.d.ts.map +1 -1
  47. package/dest/public/public_processor/public_processor.js +109 -74
  48. package/dest/public/public_processor/public_processor_metrics.d.ts +4 -1
  49. package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
  50. package/dest/public/public_processor/public_processor_metrics.js +8 -0
  51. package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +1 -1
  52. package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +1 -1
  53. package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +3 -2
  54. package/dest/public/public_tx_simulator/dumping_public_tx_simulator.d.ts +23 -0
  55. package/dest/public/public_tx_simulator/dumping_public_tx_simulator.d.ts.map +1 -0
  56. package/dest/public/public_tx_simulator/{dumping_cpp_public_tx_simulator.js → dumping_public_tx_simulator.js} +2 -2
  57. package/dest/public/public_tx_simulator/factories.d.ts +6 -6
  58. package/dest/public/public_tx_simulator/factories.d.ts.map +1 -1
  59. package/dest/public/public_tx_simulator/factories.js +8 -8
  60. package/dest/public/public_tx_simulator/index.d.ts +3 -5
  61. package/dest/public/public_tx_simulator/index.d.ts.map +1 -1
  62. package/dest/public/public_tx_simulator/index.js +2 -4
  63. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +41 -70
  64. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
  65. package/dest/public/public_tx_simulator/public_tx_simulator.js +98 -319
  66. package/dest/public/public_tx_simulator/public_tx_simulator_base.d.ts +22 -0
  67. package/dest/public/public_tx_simulator/public_tx_simulator_base.d.ts.map +1 -0
  68. package/dest/public/public_tx_simulator/public_tx_simulator_base.js +28 -0
  69. package/package.json +17 -18
  70. package/src/private/acvm_wasm.ts +4 -1
  71. package/src/private/circuit_recording/circuit_recorder.ts +2 -2
  72. package/src/public/avm/testing/account_proof.json +553 -0
  73. package/src/public/avm/testing/account_proof_fetcher.ts +166 -0
  74. package/src/public/avm/{fixtures → testing}/base_avm_simulation_tester.ts +22 -2
  75. package/src/public/avm/{fixtures → testing}/utils.ts +3 -39
  76. package/src/public/contracts_db_checkpoint.ts +1 -1
  77. package/src/public/fixtures/amm_test.ts +2 -2
  78. package/src/public/fixtures/bulk_test.ts +29 -4
  79. package/src/public/fixtures/index.ts +0 -3
  80. package/src/public/fixtures/public_tx_simulation_tester.ts +30 -15
  81. package/src/public/fixtures/simple_contract_data_source.ts +1 -1
  82. package/src/public/fixtures/utils.ts +26 -22
  83. package/src/public/fuzzing/avm_fuzzer_simulator.ts +16 -19
  84. package/src/public/fuzzing/avm_simulator_bin.ts +3 -5
  85. package/src/public/index.ts +3 -3
  86. package/src/public/public_db_sources.ts +21 -14
  87. package/src/public/public_processor/guarded_merkle_tree.ts +11 -8
  88. package/src/public/public_processor/public_processor.ts +142 -93
  89. package/src/public/public_processor/public_processor_metrics.ts +12 -0
  90. package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +3 -2
  91. package/src/public/public_tx_simulator/{dumping_cpp_public_tx_simulator.ts → dumping_public_tx_simulator.ts} +2 -2
  92. package/src/public/public_tx_simulator/factories.ts +8 -7
  93. package/src/public/public_tx_simulator/index.ts +2 -4
  94. package/src/public/public_tx_simulator/public_tx_simulator.ts +150 -476
  95. package/src/public/public_tx_simulator/public_tx_simulator_base.ts +35 -0
  96. package/dest/public/avm/avm_context.d.ts +0 -41
  97. package/dest/public/avm/avm_context.d.ts.map +0 -1
  98. package/dest/public/avm/avm_context.js +0 -44
  99. package/dest/public/avm/avm_contract_call_result.d.ts +0 -32
  100. package/dest/public/avm/avm_contract_call_result.d.ts.map +0 -1
  101. package/dest/public/avm/avm_contract_call_result.js +0 -54
  102. package/dest/public/avm/avm_execution_environment.d.ts +0 -24
  103. package/dest/public/avm/avm_execution_environment.d.ts.map +0 -1
  104. package/dest/public/avm/avm_execution_environment.js +0 -33
  105. package/dest/public/avm/avm_gas.d.ts +0 -44
  106. package/dest/public/avm/avm_gas.d.ts.map +0 -1
  107. package/dest/public/avm/avm_gas.js +0 -195
  108. package/dest/public/avm/avm_machine_state.d.ts +0 -98
  109. package/dest/public/avm/avm_machine_state.d.ts.map +0 -1
  110. package/dest/public/avm/avm_machine_state.js +0 -110
  111. package/dest/public/avm/avm_memory_types.d.ts +0 -275
  112. package/dest/public/avm/avm_memory_types.d.ts.map +0 -1
  113. package/dest/public/avm/avm_memory_types.js +0 -354
  114. package/dest/public/avm/avm_simulator.d.ts +0 -41
  115. package/dest/public/avm/avm_simulator.d.ts.map +0 -1
  116. package/dest/public/avm/avm_simulator.js +0 -192
  117. package/dest/public/avm/avm_simulator_interface.d.ts +0 -9
  118. package/dest/public/avm/avm_simulator_interface.d.ts.map +0 -1
  119. package/dest/public/avm/avm_simulator_interface.js +0 -3
  120. package/dest/public/avm/calldata.d.ts +0 -51
  121. package/dest/public/avm/calldata.d.ts.map +0 -1
  122. package/dest/public/avm/calldata.js +0 -63
  123. package/dest/public/avm/errors.d.ts +0 -104
  124. package/dest/public/avm/errors.d.ts.map +0 -1
  125. package/dest/public/avm/errors.js +0 -141
  126. package/dest/public/avm/fixtures/avm_simulation_tester.d.ts +0 -22
  127. package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +0 -1
  128. package/dest/public/avm/fixtures/avm_simulation_tester.js +0 -84
  129. package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +0 -1
  130. package/dest/public/avm/fixtures/initializers.d.ts +0 -42
  131. package/dest/public/avm/fixtures/initializers.d.ts.map +0 -1
  132. package/dest/public/avm/fixtures/initializers.js +0 -45
  133. package/dest/public/avm/fixtures/utils.d.ts +0 -39
  134. package/dest/public/avm/fixtures/utils.d.ts.map +0 -1
  135. package/dest/public/avm/index.d.ts +0 -2
  136. package/dest/public/avm/index.d.ts.map +0 -1
  137. package/dest/public/avm/index.js +0 -1
  138. package/dest/public/avm/opcodes/accrued_substate.d.ts +0 -74
  139. package/dest/public/avm/opcodes/accrued_substate.d.ts.map +0 -1
  140. package/dest/public/avm/opcodes/accrued_substate.js +0 -255
  141. package/dest/public/avm/opcodes/addressing_mode.d.ts +0 -31
  142. package/dest/public/avm/opcodes/addressing_mode.d.ts.map +0 -1
  143. package/dest/public/avm/opcodes/addressing_mode.js +0 -94
  144. package/dest/public/avm/opcodes/arithmetic.d.ts +0 -49
  145. package/dest/public/avm/opcodes/arithmetic.d.ts.map +0 -1
  146. package/dest/public/avm/opcodes/arithmetic.js +0 -97
  147. package/dest/public/avm/opcodes/bitwise.d.ts +0 -42
  148. package/dest/public/avm/opcodes/bitwise.d.ts.map +0 -1
  149. package/dest/public/avm/opcodes/bitwise.js +0 -99
  150. package/dest/public/avm/opcodes/comparators.d.ts +0 -25
  151. package/dest/public/avm/opcodes/comparators.d.ts.map +0 -1
  152. package/dest/public/avm/opcodes/comparators.js +0 -43
  153. package/dest/public/avm/opcodes/contract.d.ts +0 -20
  154. package/dest/public/avm/opcodes/contract.d.ts.map +0 -1
  155. package/dest/public/avm/opcodes/contract.js +0 -65
  156. package/dest/public/avm/opcodes/control_flow.d.ts +0 -41
  157. package/dest/public/avm/opcodes/control_flow.d.ts.map +0 -1
  158. package/dest/public/avm/opcodes/control_flow.js +0 -107
  159. package/dest/public/avm/opcodes/conversion.d.ts +0 -18
  160. package/dest/public/avm/opcodes/conversion.d.ts.map +0 -1
  161. package/dest/public/avm/opcodes/conversion.js +0 -333
  162. package/dest/public/avm/opcodes/ec_add.d.ts +0 -19
  163. package/dest/public/avm/opcodes/ec_add.d.ts.map +0 -1
  164. package/dest/public/avm/opcodes/ec_add.js +0 -93
  165. package/dest/public/avm/opcodes/environment_getters.d.ts +0 -28
  166. package/dest/public/avm/opcodes/environment_getters.d.ts.map +0 -1
  167. package/dest/public/avm/opcodes/environment_getters.js +0 -77
  168. package/dest/public/avm/opcodes/external_calls.d.ts +0 -59
  169. package/dest/public/avm/opcodes/external_calls.d.ts.map +0 -1
  170. package/dest/public/avm/opcodes/external_calls.js +0 -210
  171. package/dest/public/avm/opcodes/hashing.d.ts +0 -36
  172. package/dest/public/avm/opcodes/hashing.d.ts.map +0 -1
  173. package/dest/public/avm/opcodes/hashing.js +0 -119
  174. package/dest/public/avm/opcodes/index.d.ts +0 -16
  175. package/dest/public/avm/opcodes/index.d.ts.map +0 -1
  176. package/dest/public/avm/opcodes/index.js +0 -15
  177. package/dest/public/avm/opcodes/instruction.d.ts +0 -74
  178. package/dest/public/avm/opcodes/instruction.d.ts.map +0 -1
  179. package/dest/public/avm/opcodes/instruction.js +0 -95
  180. package/dest/public/avm/opcodes/instruction_impl.d.ts +0 -19
  181. package/dest/public/avm/opcodes/instruction_impl.d.ts.map +0 -1
  182. package/dest/public/avm/opcodes/instruction_impl.js +0 -30
  183. package/dest/public/avm/opcodes/memory.d.ts +0 -74
  184. package/dest/public/avm/opcodes/memory.d.ts.map +0 -1
  185. package/dest/public/avm/opcodes/memory.js +0 -257
  186. package/dest/public/avm/opcodes/misc.d.ts +0 -18
  187. package/dest/public/avm/opcodes/misc.d.ts.map +0 -1
  188. package/dest/public/avm/opcodes/misc.js +0 -73
  189. package/dest/public/avm/opcodes/storage.d.ts +0 -25
  190. package/dest/public/avm/opcodes/storage.d.ts.map +0 -1
  191. package/dest/public/avm/opcodes/storage.js +0 -78
  192. package/dest/public/avm/revert_reason.d.ts +0 -18
  193. package/dest/public/avm/revert_reason.d.ts.map +0 -1
  194. package/dest/public/avm/revert_reason.js +0 -39
  195. package/dest/public/avm/serialization/buffer_cursor.d.ts +0 -26
  196. package/dest/public/avm/serialization/buffer_cursor.d.ts.map +0 -1
  197. package/dest/public/avm/serialization/buffer_cursor.js +0 -99
  198. package/dest/public/avm/serialization/bytecode_serialization.d.ts +0 -17
  199. package/dest/public/avm/serialization/bytecode_serialization.d.ts.map +0 -1
  200. package/dest/public/avm/serialization/bytecode_serialization.js +0 -336
  201. package/dest/public/avm/serialization/instruction_serialization.d.ts +0 -114
  202. package/dest/public/avm/serialization/instruction_serialization.d.ts.map +0 -1
  203. package/dest/public/avm/serialization/instruction_serialization.js +0 -261
  204. package/dest/public/avm/test_utils.d.ts +0 -15
  205. package/dest/public/avm/test_utils.d.ts.map +0 -1
  206. package/dest/public/avm/test_utils.js +0 -44
  207. package/dest/public/debug_fn_name.d.ts +0 -18
  208. package/dest/public/debug_fn_name.d.ts.map +0 -1
  209. package/dest/public/debug_fn_name.js +0 -37
  210. package/dest/public/fixtures/custom_bytecode_tests.d.ts +0 -12
  211. package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +0 -1
  212. package/dest/public/fixtures/custom_bytecode_tests.js +0 -174
  213. package/dest/public/fixtures/minimal_public_tx.d.ts +0 -4
  214. package/dest/public/fixtures/minimal_public_tx.d.ts.map +0 -1
  215. package/dest/public/fixtures/minimal_public_tx.js +0 -19
  216. package/dest/public/fixtures/opcode_spammer.d.ts +0 -122
  217. package/dest/public/fixtures/opcode_spammer.d.ts.map +0 -1
  218. package/dest/public/fixtures/opcode_spammer.js +0 -1653
  219. package/dest/public/hinting_db_sources.d.ts +0 -80
  220. package/dest/public/hinting_db_sources.d.ts.map +0 -1
  221. package/dest/public/hinting_db_sources.js +0 -355
  222. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +0 -53
  223. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +0 -1
  224. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +0 -132
  225. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts +0 -42
  226. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts.map +0 -1
  227. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.js +0 -86
  228. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts +0 -30
  229. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts.map +0 -1
  230. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.js +0 -171
  231. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts +0 -23
  232. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts.map +0 -1
  233. package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +0 -31
  234. package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts.map +0 -1
  235. package/dest/public/public_tx_simulator/measured_public_tx_simulator.js +0 -51
  236. package/dest/public/public_tx_simulator/public_tx_context.d.ts +0 -131
  237. package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +0 -1
  238. package/dest/public/public_tx_simulator/public_tx_context.js +0 -300
  239. package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts +0 -21
  240. package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts.map +0 -1
  241. package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.js +0 -415
  242. package/dest/public/side_effect_trace.d.ts +0 -87
  243. package/dest/public/side_effect_trace.d.ts.map +0 -1
  244. package/dest/public/side_effect_trace.js +0 -199
  245. package/dest/public/side_effect_trace_interface.d.ts +0 -22
  246. package/dest/public/side_effect_trace_interface.d.ts.map +0 -1
  247. package/dest/public/side_effect_trace_interface.js +0 -1
  248. package/dest/public/state_manager/index.d.ts +0 -2
  249. package/dest/public/state_manager/index.d.ts.map +0 -1
  250. package/dest/public/state_manager/index.js +0 -1
  251. package/dest/public/state_manager/nullifiers.d.ts +0 -61
  252. package/dest/public/state_manager/nullifiers.d.ts.map +0 -1
  253. package/dest/public/state_manager/nullifiers.js +0 -92
  254. package/dest/public/state_manager/public_storage.d.ts +0 -66
  255. package/dest/public/state_manager/public_storage.d.ts.map +0 -1
  256. package/dest/public/state_manager/public_storage.js +0 -145
  257. package/dest/public/state_manager/state_manager.d.ts +0 -170
  258. package/dest/public/state_manager/state_manager.d.ts.map +0 -1
  259. package/dest/public/state_manager/state_manager.js +0 -402
  260. package/src/public/avm/avm_context.ts +0 -61
  261. package/src/public/avm/avm_contract_call_result.ts +0 -69
  262. package/src/public/avm/avm_execution_environment.ts +0 -51
  263. package/src/public/avm/avm_gas.ts +0 -183
  264. package/src/public/avm/avm_machine_state.ts +0 -170
  265. package/src/public/avm/avm_memory_types.ts +0 -440
  266. package/src/public/avm/avm_simulator.ts +0 -279
  267. package/src/public/avm/avm_simulator_interface.ts +0 -8
  268. package/src/public/avm/calldata.ts +0 -100
  269. package/src/public/avm/errors.ts +0 -177
  270. package/src/public/avm/fixtures/avm_simulation_tester.ts +0 -122
  271. package/src/public/avm/fixtures/initializers.ts +0 -103
  272. package/src/public/avm/index.ts +0 -1
  273. package/src/public/avm/opcodes/accrued_substate.ts +0 -286
  274. package/src/public/avm/opcodes/addressing_mode.ts +0 -111
  275. package/src/public/avm/opcodes/arithmetic.ts +0 -129
  276. package/src/public/avm/opcodes/bitwise.ts +0 -113
  277. package/src/public/avm/opcodes/comparators.ts +0 -55
  278. package/src/public/avm/opcodes/contract.ts +0 -72
  279. package/src/public/avm/opcodes/control_flow.ts +0 -123
  280. package/src/public/avm/opcodes/conversion.ts +0 -104
  281. package/src/public/avm/opcodes/ec_add.ts +0 -105
  282. package/src/public/avm/opcodes/environment_getters.ts +0 -87
  283. package/src/public/avm/opcodes/external_calls.ts +0 -262
  284. package/src/public/avm/opcodes/hashing.ts +0 -151
  285. package/src/public/avm/opcodes/index.ts +0 -15
  286. package/src/public/avm/opcodes/instruction.ts +0 -136
  287. package/src/public/avm/opcodes/instruction_impl.ts +0 -36
  288. package/src/public/avm/opcodes/memory.ts +0 -293
  289. package/src/public/avm/opcodes/misc.ts +0 -102
  290. package/src/public/avm/opcodes/storage.ts +0 -95
  291. package/src/public/avm/revert_reason.ts +0 -58
  292. package/src/public/avm/serialization/buffer_cursor.ts +0 -118
  293. package/src/public/avm/serialization/bytecode_serialization.ts +0 -215
  294. package/src/public/avm/serialization/instruction_serialization.ts +0 -249
  295. package/src/public/avm/test_utils.ts +0 -64
  296. package/src/public/debug_fn_name.ts +0 -52
  297. package/src/public/fixtures/custom_bytecode_tests.ts +0 -228
  298. package/src/public/fixtures/minimal_public_tx.ts +0 -26
  299. package/src/public/fixtures/opcode_spammer.ts +0 -1721
  300. package/src/public/hinting_db_sources.ts +0 -607
  301. package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +0 -211
  302. package/src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts +0 -134
  303. package/src/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.ts +0 -239
  304. package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +0 -105
  305. package/src/public/public_tx_simulator/public_tx_context.ts +0 -484
  306. package/src/public/public_tx_simulator/telemetry_public_tx_simulator.ts +0 -63
  307. package/src/public/side_effect_trace.ts +0 -293
  308. package/src/public/side_effect_trace_interface.ts +0 -28
  309. package/src/public/state_manager/index.ts +0 -1
  310. package/src/public/state_manager/nullifiers.ts +0 -103
  311. package/src/public/state_manager/public_storage.ts +0 -174
  312. package/src/public/state_manager/state_manager.ts +0 -569
@@ -1,569 +0,0 @@
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';
4
- import { jsonStringify } from '@aztec/foundation/json-rpc';
5
- import { type LogLevel, type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
6
- import { ProtocolContractAddress } from '@aztec/protocol-contracts';
7
- import { FunctionSelector } from '@aztec/stdlib/abi';
8
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
9
- import type { ContractClassPublicWithCommitment, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
10
- import { SerializableContractInstance } from '@aztec/stdlib/contract';
11
- import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
12
- import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
13
- import type { DebugLog } from '@aztec/stdlib/logs';
14
- import { ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
15
- import { MerkleTreeId } from '@aztec/stdlib/trees';
16
- import type { TreeSnapshots } from '@aztec/stdlib/tx';
17
- import type { UInt64 } from '@aztec/stdlib/types';
18
-
19
- import { strict as assert } from 'assert';
20
-
21
- import type { AvmExecutionEnvironment } from '../avm/avm_execution_environment.js';
22
- import type { PublicContractsDBInterface } from '../db_interfaces.js';
23
- import { getPublicFunctionDebugName, getPublicFunctionSelectorAndName } from '../debug_fn_name.js';
24
- import type { PublicTreesDB } from '../public_db_sources.js';
25
- import {
26
- L1ToL2MessageIndexOutOfRangeError,
27
- MaxCallsToUniqueContractClassIdsError,
28
- NoteHashIndexOutOfRangeError,
29
- NullifierCollisionError,
30
- } from '../side_effect_errors.js';
31
- import type { PublicSideEffectTraceInterface } from '../side_effect_trace_interface.js';
32
- import { NullifierManager } from './nullifiers.js';
33
- import { PublicStorage } from './public_storage.js';
34
-
35
- /**
36
- * A class to manage persistable AVM state for contract calls.
37
- * Maintains a cache of the current world state,
38
- * a trace of all side effects.
39
- *
40
- * The simulator should make any world state / tree queries through this object.
41
- *
42
- * Manages merging of successful/reverted child state into current state.
43
- */
44
- export class PublicPersistableStateManager {
45
- private readonly log: Logger;
46
-
47
- /** Make sure a forked state is never merged twice. */
48
- private alreadyMergedIntoParent = false;
49
-
50
- constructor(
51
- private readonly treesDB: PublicTreesDB,
52
- private readonly contractsDB: PublicContractsDBInterface,
53
- private readonly trace: PublicSideEffectTraceInterface,
54
- private readonly firstNullifier: Fr, // Needed for note hashes.
55
- private readonly timestamp: UInt64, // Needed for contract updates.
56
- private readonly doMerkleOperations: boolean = true,
57
- private readonly publicStorage: PublicStorage = new PublicStorage(treesDB),
58
- private readonly nullifiers: NullifierManager = new NullifierManager(treesDB),
59
- bindings?: LoggerBindings,
60
- ) {
61
- this.log = createLogger('simulator:state_manager', bindings);
62
- }
63
-
64
- /**
65
- * Create a new state manager
66
- */
67
- public static create(
68
- treesDB: PublicTreesDB,
69
- contractsDB: PublicContractsDBInterface,
70
- trace: PublicSideEffectTraceInterface,
71
- firstNullifier: Fr,
72
- timestamp: UInt64,
73
- bindings?: LoggerBindings,
74
- ): PublicPersistableStateManager {
75
- return new PublicPersistableStateManager(
76
- treesDB,
77
- contractsDB,
78
- trace,
79
- firstNullifier,
80
- timestamp,
81
- undefined,
82
- undefined,
83
- undefined,
84
- bindings,
85
- );
86
- }
87
-
88
- /**
89
- * Create a new state manager forked from this one
90
- */
91
- public async fork() {
92
- await this.treesDB.createCheckpoint();
93
- return new PublicPersistableStateManager(
94
- this.treesDB,
95
- this.contractsDB,
96
- this.trace.fork(),
97
- this.firstNullifier,
98
- this.timestamp,
99
- this.doMerkleOperations,
100
- this.publicStorage.fork(),
101
- this.nullifiers.fork(),
102
- this.log.getBindings(),
103
- );
104
- }
105
-
106
- /**
107
- * Accept forked world state modifications & traced side effects / hints
108
- */
109
- public async merge(forkedState: PublicPersistableStateManager) {
110
- await this._merge(forkedState, /*reverted=*/ false);
111
- }
112
-
113
- /**
114
- * Reject forked world state modifications & traced side effects, keep traced hints
115
- */
116
- public async reject(forkedState: PublicPersistableStateManager) {
117
- await this._merge(forkedState, /*reverted=*/ true);
118
- }
119
-
120
- private async _merge(forkedState: PublicPersistableStateManager, reverted: boolean) {
121
- // sanity check to avoid merging the same forked trace twice
122
- assert(
123
- !forkedState.alreadyMergedIntoParent,
124
- 'Cannot merge forked state that has already been merged into its parent!',
125
- );
126
- forkedState.alreadyMergedIntoParent = true;
127
- this.publicStorage.acceptAndMerge(forkedState.publicStorage);
128
- this.nullifiers.acceptAndMerge(forkedState.nullifiers);
129
- this.trace.merge(forkedState.trace, reverted);
130
- if (reverted) {
131
- this.log.trace('Reverting forked state...');
132
- await this.treesDB.revertCheckpoint();
133
- } else {
134
- this.log.trace('Merging forked state into parent...');
135
- await this.treesDB.commitCheckpoint();
136
- }
137
- }
138
-
139
- /**
140
- * Write to public storage, journal/trace the write.
141
- *
142
- * @param contractAddress - the address of the contract whose storage is being written to
143
- * @param slot - the slot in the contract's storage being written to
144
- * @param value - the value being written to the slot
145
- */
146
- public async writeStorage(contractAddress: AztecAddress, slot: Fr, value: Fr, protocolWrite = false): Promise<void> {
147
- this.log.trace(`Storage write (address=${contractAddress}, slot=${slot}): value=${value}`);
148
-
149
- await this.trace.tracePublicStorageWrite(contractAddress, slot, value, protocolWrite);
150
-
151
- if (this.doMerkleOperations) {
152
- // write to native merkle trees
153
- await this.treesDB.storageWrite(contractAddress, slot, value);
154
- } else {
155
- // Cache storage writes for later reference/reads
156
- this.publicStorage.write(contractAddress, slot, value);
157
- }
158
- }
159
-
160
- public isStorageCold(contractAddress: AztecAddress, slot: Fr): boolean {
161
- return this.trace.isStorageCold(contractAddress, slot);
162
- }
163
-
164
- /**
165
- * Read from public storage.
166
- *
167
- * @param contractAddress - the address of the contract whose storage is being read from
168
- * @param slot - the slot in the contract's storage being read from
169
- * @returns the latest value written to slot, or 0 if never written to before
170
- */
171
- public async readStorage(contractAddress: AztecAddress, slot: Fr): Promise<Fr> {
172
- if (this.doMerkleOperations) {
173
- return await this.treesDB.storageRead(contractAddress, slot);
174
- } else {
175
- const read = await this.publicStorage.read(contractAddress, slot);
176
- this.log.trace(
177
- `Storage read results (address=${contractAddress}, slot=${slot}): value=${read.value}, cached=${read.cached}`,
178
- );
179
- return read.value;
180
- }
181
- }
182
-
183
- // TODO(4886): We currently don't silo note hashes.
184
- /**
185
- * Check if a note hash exists at the given leaf index, trace the check.
186
- *
187
- * @param contractAddress - the address of the contract whose storage is being read from
188
- * @param noteHash - the unsiloed note hash being checked
189
- * @param leafIndex - the leaf index being checked
190
- * @returns true if the note hash exists at the given leaf index, false otherwise
191
- */
192
- public async checkNoteHashExists(contractAddress: AztecAddress, noteHash: Fr, leafIndex: bigint): Promise<boolean> {
193
- try {
194
- const gotLeafValue = await this.treesDB.getNoteHash(leafIndex);
195
- const exists = gotLeafValue.equals(noteHash);
196
- this.log.trace(
197
- `noteHashes(${contractAddress})@${noteHash} ?? leafIndex: ${leafIndex} | gotLeafValue: ${gotLeafValue}, exists: ${exists}.`,
198
- );
199
- return Promise.resolve(exists);
200
- } catch (error) {
201
- // If the index is out of range, note_hash_leaf_in_range = 0 and the circuit returns false:
202
- if (error instanceof NoteHashIndexOutOfRangeError) {
203
- return Promise.resolve(false);
204
- }
205
- // Otherwise, unknown error. This is a bug.
206
- throw error;
207
- }
208
- }
209
-
210
- /**
211
- * Write a raw note hash, silo it and make it unique, then trace the write.
212
- * @param noteHash - the unsiloed note hash to write
213
- */
214
- public async writeNoteHash(contractAddress: AztecAddress, noteHash: Fr): Promise<void> {
215
- this.log.trace(`noteHashes(${contractAddress}) += ${noteHash}.`);
216
- const siloedNoteHash = await siloNoteHash(contractAddress, noteHash);
217
- await this.writeSiloedNoteHash(siloedNoteHash);
218
- }
219
-
220
- /**
221
- * Write a note hash, make it unique, trace the write.
222
- * @param siloedNoteHash - the non unique note hash to write
223
- */
224
- public async writeSiloedNoteHash(siloedNoteHash: Fr): Promise<void> {
225
- const noteNonce = await computeNoteHashNonce(this.firstNullifier, this.trace.getNoteHashCount());
226
- const uniqueNoteHash = await computeUniqueNoteHash(noteNonce, siloedNoteHash);
227
- await this.writeUniqueNoteHash(uniqueNoteHash);
228
- }
229
-
230
- /**
231
- * Write a note hash, trace the write.
232
- * @param uniqueNoteHash - the siloed unique hash to write
233
- */
234
- public async writeUniqueNoteHash(uniqueNoteHash: Fr): Promise<void> {
235
- this.log.trace(`noteHashes += @${uniqueNoteHash}.`);
236
- this.trace.traceNewNoteHash(uniqueNoteHash);
237
- if (this.doMerkleOperations) {
238
- await this.treesDB.writeNoteHash(uniqueNoteHash);
239
- }
240
- }
241
-
242
- /**
243
- * Check if a nullifier exists, trace the check.
244
- * @param contractAddress - address of the contract that the nullifier is associated with
245
- * @param nullifier - the unsiloed nullifier to check
246
- * @returns exists - whether the nullifier exists in the nullifier set
247
- */
248
- public async checkNullifierExists(contractAddress: AztecAddress, nullifier: Fr): Promise<boolean> {
249
- this.log.trace(`Checking existence of nullifier (address=${contractAddress}, nullifier=${nullifier})`);
250
- const siloedNullifier = await siloNullifier(contractAddress, nullifier);
251
- return this.checkSiloedNullifierExists(siloedNullifier);
252
- }
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> {
260
- if (this.doMerkleOperations) {
261
- const exists = await this.treesDB.checkNullifierExists(siloedNullifier);
262
- this.log.trace(`Checked siloed nullifier ${siloedNullifier} (exists=${exists})`);
263
- return Promise.resolve(exists);
264
- } else {
265
- const { exists, cacheHit } = await this.nullifiers.checkExists(siloedNullifier);
266
- this.log.trace(`Checked siloed nullifier ${siloedNullifier} (exists=${exists}), cacheHit=${cacheHit}`);
267
- return Promise.resolve(exists);
268
- }
269
- }
270
-
271
- /**
272
- * Write a nullifier to the nullifier set, trace the write.
273
- * @param contractAddress - address of the contract that the nullifier is associated with
274
- * @param nullifier - the unsiloed nullifier to write
275
- */
276
- public async writeNullifier(contractAddress: AztecAddress, nullifier: Fr) {
277
- this.log.trace(`Inserting new nullifier (address=${nullifier}, nullifier=${contractAddress})`);
278
- const siloedNullifier = await siloNullifier(contractAddress, nullifier);
279
- await this.writeSiloedNullifier(siloedNullifier);
280
- }
281
-
282
- /**
283
- * Write a nullifier to the nullifier set, trace the write.
284
- * @param siloedNullifier - the siloed nullifier to write
285
- */
286
- public async writeSiloedNullifier(siloedNullifier: Fr) {
287
- this.log.trace(`Inserting siloed nullifier=${siloedNullifier}`);
288
-
289
- this.trace.traceNewNullifier(siloedNullifier);
290
-
291
- if (this.doMerkleOperations) {
292
- const exists = await this.treesDB.checkNullifierExists(siloedNullifier);
293
-
294
- if (exists) {
295
- this.log.verbose(`Siloed nullifier ${siloedNullifier} already present in tree!`);
296
- throw new NullifierCollisionError(
297
- `Siloed nullifier ${siloedNullifier} already exists in parent cache or host.`,
298
- );
299
- } else {
300
- await this.treesDB.writeNullifier(siloedNullifier);
301
- }
302
- } else {
303
- // Cache pending nullifiers for later access
304
- await this.nullifiers.append(siloedNullifier);
305
- }
306
- }
307
-
308
- /**
309
- * Check if an L1 to L2 message exists, trace the check.
310
- * @param msgHash - the message hash to check existence of
311
- * @param msgLeafIndex - the message leaf index to use in the check
312
- * @returns exists - whether the message exists in the L1 to L2 Messages tree
313
- */
314
- public async checkL1ToL2MessageExists(msgHash: Fr, msgLeafIndex: Fr): Promise<boolean> {
315
- try {
316
- const valueAtIndex = await this.treesDB.getL1ToL2LeafValue(msgLeafIndex.toBigInt());
317
- const exists = valueAtIndex.equals(msgHash);
318
- this.log.trace(
319
- `l1ToL2Messages(@${msgLeafIndex}) ?? exists: ${exists}, expected: ${msgHash}, found: ${valueAtIndex}.`,
320
- );
321
- return Promise.resolve(exists);
322
- } catch (error) {
323
- // If the index is out of range, l1_to_l2_msg_leaf_in_range = 0 and the circuit returns false:
324
- if (error instanceof L1ToL2MessageIndexOutOfRangeError) {
325
- return Promise.resolve(false);
326
- }
327
- // Otherwise, unknown error. This is a bug.
328
- throw error;
329
- }
330
- }
331
-
332
- /**
333
- * Write an L2 to L1 message.
334
- * @param contractAddress - L2 contract address that created this message
335
- * @param recipient - L1 contract address to send the message to.
336
- * @param content - Message content.
337
- */
338
- public writeL2ToL1Message(contractAddress: AztecAddress, recipient: Fr, content: Fr) {
339
- this.log.trace(`L2ToL1Messages(${contractAddress}) += (recipient: ${recipient}, content: ${content}).`);
340
- this.trace.traceNewL2ToL1Message(contractAddress, recipient, content);
341
- }
342
-
343
- /**
344
- * Write a scoped L2 to L1 message.
345
- * @param l2ToL1Message - The L2 to L1 message to write.
346
- */
347
- public writeScopedL2ToL1Message(l2ToL1Message: ScopedL2ToL1Message) {
348
- this.writeL2ToL1Message(
349
- l2ToL1Message.contractAddress,
350
- l2ToL1Message.message.recipient.toField(),
351
- l2ToL1Message.message.content,
352
- );
353
- }
354
-
355
- public writeDebugLog(contractAddress: AztecAddress, level: LogLevel, message: string, fields: Fr[]) {
356
- this.trace.traceDebugLog(contractAddress, level, message, fields);
357
- }
358
-
359
- public writeDebugLogMemoryReads(memoryReads: number) {
360
- this.trace.traceDebugLogMemoryReads(memoryReads);
361
- }
362
-
363
- public getDebugLogMemoryReads() {
364
- return this.trace.getDebugLogMemoryReads();
365
- }
366
-
367
- public getLogs(): DebugLog[] {
368
- return this.trace.getDebugLogs();
369
- }
370
-
371
- /**
372
- * Write a public log
373
- * @param contractAddress - address of the contract that emitted the log
374
- * @param log - log contents
375
- */
376
- public writePublicLog(contractAddress: AztecAddress, log: Fr[]) {
377
- this.log.trace(`PublicLog(${contractAddress}) += event with ${log.length} fields.`);
378
- this.trace.tracePublicLog(contractAddress, log);
379
- }
380
-
381
- /**
382
- * Get a contract instance.
383
- * @param contractAddress - address of the contract instance to retrieve.
384
- * @returns the contract instance or undefined if it does not exist.
385
- */
386
- public async getContractInstance(contractAddress: AztecAddress): Promise<SerializableContractInstance | undefined> {
387
- this.log.trace(`Getting contract instance for address ${contractAddress}`);
388
- const instanceWithAddress = await this.contractsDB.getContractInstance(contractAddress, this.timestamp);
389
- const exists = instanceWithAddress !== undefined;
390
-
391
- const instance = exists ? new SerializableContractInstance(instanceWithAddress) : undefined;
392
-
393
- if (contractAddressIsCanonical(contractAddress)) {
394
- this.log.trace(
395
- `Got canonical contract instance (address=${contractAddress}): instance=${jsonStringify(instance!)}`,
396
- );
397
- return instance;
398
- }
399
-
400
- // Nullifier check! We do this regardless of whether or not the instance exists,
401
- // as even for non-existence, we need to generate nullifier check hints.
402
-
403
- // This will internally decide whether to check the nullifier tree or not depending on doMerkleOperations.
404
- const nullifierExistsInTree = await this.checkNullifierExists(
405
- AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS),
406
- contractAddress.toField(),
407
- );
408
- assert(
409
- exists == nullifierExistsInTree,
410
- `Contract instance for address ${contractAddress} in DB: ${exists} != nullifier tree: ${nullifierExistsInTree}. This is a bug!`,
411
- );
412
-
413
- if (!exists) {
414
- this.log.debug(`Contract instance NOT FOUND (address=${contractAddress})`);
415
- return undefined;
416
- }
417
-
418
- this.log.trace(`Got contract instance (address=${contractAddress}): instance=${jsonStringify(instance!)}`);
419
-
420
- // All that is left is to check that the contract updatability information is correct.
421
- // That is, that the current and original contract class ids are correct.
422
- await this.checkContractUpdateInformation(instanceWithAddress);
423
-
424
- return instance;
425
- }
426
-
427
- private async checkContractUpdateInformation(instance: ContractInstanceWithAddress): Promise<void> {
428
- // If "merkle operations" are not requested, we trust the DB.
429
- // Otherwise we check that the contract updatability information is correct.
430
- // That is, that the current and original contract class ids are correct.
431
- // All failures are fatal and the simulation is not expected to be provable.
432
- if (this.doMerkleOperations) {
433
- // Conceptually, we want to do the following:
434
- // * Read a DelayedPublicMutable at the contract update slot.
435
- // * Obtain the expected current class id from the DelayedPublicMutable, at the current block.
436
- // * if expectedId == 0 then currentClassId should be original contract class id
437
- // * if expectedId != 0 then currentClassId should be expectedId
438
- //
439
- // However, we will also be checking the hash of the delayed public mutable values.
440
- // This is a bit of a leak of information, since the circuit will use it to prove
441
- // one public read instead of N of the delayed public mutable values.
442
- const { delayedPublicMutableSlot, delayedPublicMutableHashSlot } =
443
- await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(instance.address);
444
- const readDeployerStorage = async (storageSlot: Fr) =>
445
- await this.readStorage(ProtocolContractAddress.ContractInstanceRegistry, storageSlot);
446
-
447
- const hash = await readDeployerStorage(delayedPublicMutableHashSlot);
448
- // NOTE: The below reads are either not performed (if hash.isZero()) or only performed in unconstrained in c++ simulation.
449
- // See UpdateCheck::check_current_class_id documentation - this means if we generate hints from the merkle db, they are unused:
450
- const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(
451
- delayedPublicMutableSlot,
452
- readDeployerStorage,
453
- );
454
- const preImage = delayedPublicMutableValues.toFields();
455
-
456
- // 1) update never scheduled: hash == 0 and preimage should be empty (but poseidon2hash(preimage) will not be 0s)
457
- if (hash.isZero()) {
458
- assert(
459
- preImage.every(f => f.isZero()),
460
- `Found updatability hash 0 but preimage is not empty for contract instance ${instance.address}.`,
461
- );
462
- assert(
463
- instance.currentContractClassId.equals(instance.originalContractClassId),
464
- `Found updatability hash 0 for contract instance ${instance.address} but original class id ${instance.originalContractClassId} != current class id ${instance.currentContractClassId}.`,
465
- );
466
- return;
467
- }
468
-
469
- // 2) At this point we know that the hash is not zero and this means that an update has at some point been scheduled.
470
- const computedHash = await poseidon2Hash(preImage);
471
- assert(
472
- hash.equals(computedHash),
473
- `Delayed public mutable values hash mismatch for contract instance ${instance.address}. Expected: ${hash}, computed: ${computedHash}`,
474
- );
475
-
476
- // We now check that, depending on the current block, the current class id is correct.
477
- const expectedClassIdRaw = delayedPublicMutableValues.svc.getCurrentAt(this.timestamp).at(0)!;
478
- const expectedClassId = expectedClassIdRaw.isZero() ? instance.originalContractClassId : expectedClassIdRaw;
479
- assert(
480
- instance.currentContractClassId.equals(expectedClassId),
481
- `Current class id mismatch
482
- for contract instance ${instance.address}. Expected: ${expectedClassId}, current: ${instance.currentContractClassId}`,
483
- );
484
- }
485
- }
486
-
487
- /**
488
- * Get a contract class.
489
- * @param classId - class id to retrieve.
490
- * @returns the contract class or undefined if it does not exist.
491
- */
492
- private async getContractClass(classId: Fr): Promise<ContractClassPublicWithCommitment | undefined> {
493
- this.log.trace(`Getting contract class for id ${classId}`);
494
- const contractClass = await this.contractsDB.getContractClass(classId);
495
- const exists = contractClass !== undefined;
496
- let extendedClass: ContractClassPublicWithCommitment | undefined = undefined;
497
-
498
- // Note: We currently do not generate info to check the nullifier tree, because
499
- // this is not needed for our use cases.
500
- if (exists) {
501
- this.log.trace(`Got contract class (id=${classId})`);
502
- // Extend class information with public bytecode commitment.
503
- const bytecodeCommitment = await this.contractsDB.getBytecodeCommitment(classId);
504
- assert(
505
- bytecodeCommitment,
506
- `Bytecode commitment was not found in DB for contract class (${classId}). This should not happen!`,
507
- );
508
- extendedClass = {
509
- ...contractClass,
510
- publicBytecodeCommitment: bytecodeCommitment,
511
- };
512
- } else {
513
- this.log.debug(`Contract class NOT FOUND (id=${classId})`);
514
- }
515
-
516
- // TODO(dbanks12): does this need to be moved to before the DB accesses as was done with writeNullifier?
517
- this.trace.traceGetContractClass(classId, exists);
518
- return extendedClass;
519
- }
520
-
521
- /**
522
- * Get a contract's bytecode from the contracts DB, also trace the contract class and instance indirectly.
523
- */
524
- public async getBytecode(contractAddress: AztecAddress): Promise<Buffer | undefined> {
525
- this.log.debug(`Getting bytecode for contract address ${contractAddress}`);
526
- const contractInstance = await this.getContractInstance(contractAddress);
527
-
528
- if (!contractInstance) {
529
- return undefined;
530
- }
531
-
532
- try {
533
- const contractClass = await this.getContractClass(contractInstance.currentContractClassId);
534
- assert(
535
- contractClass,
536
- `Contract class not found in DB, but a contract instance was found with this class ID (${contractInstance.currentContractClassId}). This should not happen!`,
537
- );
538
- return contractClass.packedBytecode;
539
- } catch (error) {
540
- if (error instanceof MaxCallsToUniqueContractClassIdsError) {
541
- return undefined;
542
- }
543
- // Otherwise, unknown error. This is a bug.
544
- throw error;
545
- }
546
- }
547
-
548
- public async getPublicFunctionDebugName(avmEnvironment: AvmExecutionEnvironment): Promise<string> {
549
- return await getPublicFunctionDebugName(this.contractsDB, avmEnvironment.address, avmEnvironment.calldata);
550
- }
551
-
552
- public async getPublicFunctionSelectorAndName(
553
- avmEnvironment: AvmExecutionEnvironment,
554
- ): Promise<{ functionSelector?: FunctionSelector; functionName?: string }> {
555
- return await getPublicFunctionSelectorAndName(this.contractsDB, avmEnvironment.address, avmEnvironment.calldata);
556
- }
557
-
558
- public async padTree(treeId: MerkleTreeId, leavesToInsert: number): Promise<void> {
559
- await this.treesDB.padTree(treeId, leavesToInsert);
560
- }
561
-
562
- public async getTreeSnapshots(): Promise<TreeSnapshots> {
563
- return await this.treesDB.getTreeSnapshots();
564
- }
565
- }
566
-
567
- function contractAddressIsCanonical(contractAddress: AztecAddress): boolean {
568
- return contractAddress.toBigInt() >= 1 && contractAddress.toBigInt() <= MAX_PROTOCOL_CONTRACTS;
569
- }