@aztec/simulator 0.0.1-commit.b655e406 → 0.0.1-commit.b8a057fa

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 (405) hide show
  1. package/README.md +6 -4
  2. package/dest/client.d.ts +1 -3
  3. package/dest/client.d.ts.map +1 -1
  4. package/dest/client.js +0 -2
  5. package/dest/common/errors.d.ts +2 -2
  6. package/dest/common/errors.d.ts.map +1 -1
  7. package/dest/common/index.d.ts +1 -1
  8. package/dest/common/stats/index.d.ts +1 -1
  9. package/dest/common/stats/stats.d.ts +1 -1
  10. package/dest/private/acvm/acvm.d.ts +4 -2
  11. package/dest/private/acvm/acvm.d.ts.map +1 -1
  12. package/dest/private/acvm/acvm.js +4 -3
  13. package/dest/private/acvm/acvm_types.d.ts +1 -1
  14. package/dest/private/acvm/deserialize.d.ts +2 -2
  15. package/dest/private/acvm/deserialize.d.ts.map +1 -1
  16. package/dest/private/acvm/deserialize.js +1 -1
  17. package/dest/private/acvm/index.d.ts +1 -1
  18. package/dest/private/acvm/serialize.d.ts +2 -2
  19. package/dest/private/acvm/serialize.d.ts.map +1 -1
  20. package/dest/private/acvm/serialize.js +1 -1
  21. package/dest/private/acvm_native.d.ts +5 -3
  22. package/dest/private/acvm_native.d.ts.map +1 -1
  23. package/dest/private/acvm_native.js +8 -6
  24. package/dest/private/acvm_wasm.d.ts +4 -3
  25. package/dest/private/acvm_wasm.d.ts.map +1 -1
  26. package/dest/private/acvm_wasm.js +7 -5
  27. package/dest/private/acvm_wasm_with_blobs.d.ts +1 -1
  28. package/dest/private/acvm_wasm_with_blobs.d.ts.map +1 -1
  29. package/dest/private/circuit_recording/circuit_recorder.d.ts +39 -25
  30. package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -1
  31. package/dest/private/circuit_recording/circuit_recorder.js +71 -72
  32. package/dest/private/circuit_recording/file_circuit_recorder.d.ts +9 -20
  33. package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
  34. package/dest/private/circuit_recording/file_circuit_recorder.js +39 -43
  35. package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +7 -2
  36. package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -1
  37. package/dest/private/circuit_recording/memory_circuit_recorder.js +4 -4
  38. package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts +1 -1
  39. package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts.map +1 -1
  40. package/dest/private/circuit_recording/simulator_recorder_wrapper.js +11 -14
  41. package/dest/private/circuit_simulator.d.ts +1 -1
  42. package/dest/private/factory.d.ts +3 -3
  43. package/dest/private/factory.d.ts.map +1 -1
  44. package/dest/private/factory.js +7 -4
  45. package/dest/public/avm/testing/account_proof_fetcher.d.ts +2 -0
  46. package/dest/public/avm/testing/account_proof_fetcher.d.ts.map +1 -0
  47. package/dest/public/avm/testing/account_proof_fetcher.js +152 -0
  48. package/dest/public/avm/{fixtures → testing}/base_avm_simulation_tester.d.ts +3 -2
  49. package/dest/public/avm/testing/base_avm_simulation_tester.d.ts.map +1 -0
  50. package/dest/public/avm/{fixtures → testing}/base_avm_simulation_tester.js +19 -4
  51. package/dest/public/avm/{fixtures → testing}/utils.d.ts +4 -10
  52. package/dest/public/avm/testing/utils.d.ts.map +1 -0
  53. package/dest/public/avm/{fixtures → testing}/utils.js +7 -36
  54. package/dest/public/avm_simulator.d.ts +28 -0
  55. package/dest/public/avm_simulator.d.ts.map +1 -0
  56. package/dest/public/avm_simulator.js +4 -0
  57. package/dest/public/avm_simulator_pool.d.ts +45 -0
  58. package/dest/public/avm_simulator_pool.d.ts.map +1 -0
  59. package/dest/public/avm_simulator_pool.js +197 -0
  60. package/dest/public/cdb/generated/api_types.d.ts +171 -0
  61. package/dest/public/cdb/generated/api_types.d.ts.map +1 -0
  62. package/dest/public/cdb/generated/api_types.js +314 -0
  63. package/dest/public/cdb/generated/server.d.ts +26 -0
  64. package/dest/public/cdb/generated/server.d.ts.map +1 -0
  65. package/dest/public/cdb/generated/server.js +135 -0
  66. package/dest/public/cdb_ipc_server.d.ts +33 -0
  67. package/dest/public/cdb_ipc_server.d.ts.map +1 -0
  68. package/dest/public/cdb_ipc_server.js +153 -0
  69. package/dest/public/contracts_db_checkpoint.d.ts +16 -0
  70. package/dest/public/contracts_db_checkpoint.d.ts.map +1 -0
  71. package/dest/public/contracts_db_checkpoint.js +30 -0
  72. package/dest/public/db_interfaces.d.ts +14 -2
  73. package/dest/public/db_interfaces.d.ts.map +1 -1
  74. package/dest/public/executor_metrics.d.ts +3 -2
  75. package/dest/public/executor_metrics.d.ts.map +1 -1
  76. package/dest/public/executor_metrics.js +13 -34
  77. package/dest/public/executor_metrics_interface.d.ts +3 -2
  78. package/dest/public/executor_metrics_interface.d.ts.map +1 -1
  79. package/dest/public/fixtures/amm_test.d.ts +1 -1
  80. package/dest/public/fixtures/amm_test.js +6 -6
  81. package/dest/public/fixtures/bulk_test.d.ts +3 -3
  82. package/dest/public/fixtures/bulk_test.d.ts.map +1 -1
  83. package/dest/public/fixtures/bulk_test.js +38 -75
  84. package/dest/public/fixtures/custom_bytecode_tester.d.ts +29 -7
  85. package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -1
  86. package/dest/public/fixtures/custom_bytecode_tester.js +36 -12
  87. package/dest/public/fixtures/index.d.ts +3 -3
  88. package/dest/public/fixtures/index.d.ts.map +1 -1
  89. package/dest/public/fixtures/index.js +2 -2
  90. package/dest/public/fixtures/public_processor_test_env.d.ts +30 -0
  91. package/dest/public/fixtures/public_processor_test_env.d.ts.map +1 -0
  92. package/dest/public/fixtures/public_processor_test_env.js +73 -0
  93. package/dest/public/fixtures/public_tx_simulation_tester.d.ts +32 -9
  94. package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
  95. package/dest/public/fixtures/public_tx_simulation_tester.js +84 -26
  96. package/dest/public/fixtures/simple_contract_data_source.d.ts +5 -4
  97. package/dest/public/fixtures/simple_contract_data_source.d.ts.map +1 -1
  98. package/dest/public/fixtures/simple_contract_data_source.js +5 -5
  99. package/dest/public/fixtures/token_test.d.ts +6 -2
  100. package/dest/public/fixtures/token_test.d.ts.map +1 -1
  101. package/dest/public/fixtures/token_test.js +16 -15
  102. package/dest/public/fixtures/utils.d.ts +3 -3
  103. package/dest/public/fixtures/utils.d.ts.map +1 -1
  104. package/dest/public/fixtures/utils.js +25 -23
  105. package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts +67 -0
  106. package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts.map +1 -0
  107. package/dest/public/fuzzing/avm_fuzzer_simulator.js +185 -0
  108. package/dest/public/fuzzing/avm_simulator_bin.d.ts +2 -0
  109. package/dest/public/fuzzing/avm_simulator_bin.d.ts.map +1 -0
  110. package/dest/public/fuzzing/avm_simulator_bin.js +118 -0
  111. package/dest/public/index.d.ts +6 -2
  112. package/dest/public/index.d.ts.map +1 -1
  113. package/dest/public/index.js +2 -1
  114. package/dest/public/public_db_sources.d.ts +29 -66
  115. package/dest/public/public_db_sources.d.ts.map +1 -1
  116. package/dest/public/public_db_sources.js +83 -134
  117. package/dest/public/public_errors.d.ts +1 -1
  118. package/dest/public/public_errors.d.ts.map +1 -1
  119. package/dest/public/public_processor/guarded_merkle_tree.d.ts +8 -5
  120. package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
  121. package/dest/public/public_processor/guarded_merkle_tree.js +12 -4
  122. package/dest/public/public_processor/public_processor.d.ts +24 -22
  123. package/dest/public/public_processor/public_processor.d.ts.map +1 -1
  124. package/dest/public/public_processor/public_processor.js +559 -125
  125. package/dest/public/public_processor/public_processor_metrics.d.ts +5 -2
  126. package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
  127. package/dest/public/public_processor/public_processor_metrics.js +36 -45
  128. package/dest/public/public_tx_simulator/dumping_public_tx_simulator.d.ts +17 -0
  129. package/dest/public/public_tx_simulator/dumping_public_tx_simulator.d.ts.map +1 -0
  130. package/dest/public/public_tx_simulator/dumping_public_tx_simulator.js +39 -0
  131. package/dest/public/public_tx_simulator/factories.d.ts +14 -0
  132. package/dest/public/public_tx_simulator/factories.d.ts.map +1 -0
  133. package/dest/public/public_tx_simulator/factories.js +28 -0
  134. package/dest/public/public_tx_simulator/index.d.ts +6 -4
  135. package/dest/public/public_tx_simulator/index.d.ts.map +1 -1
  136. package/dest/public/public_tx_simulator/index.js +3 -2
  137. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +43 -90
  138. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
  139. package/dest/public/public_tx_simulator/public_tx_simulator.js +99 -331
  140. package/dest/public/public_tx_simulator/public_tx_simulator_base.d.ts +24 -0
  141. package/dest/public/public_tx_simulator/public_tx_simulator_base.d.ts.map +1 -0
  142. package/dest/public/public_tx_simulator/public_tx_simulator_base.js +31 -0
  143. package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts +25 -2
  144. package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts.map +1 -1
  145. package/dest/public/side_effect_errors.d.ts +1 -1
  146. package/dest/public/side_effect_errors.d.ts.map +1 -1
  147. package/dest/public/test_executor_metrics.d.ts +6 -4
  148. package/dest/public/test_executor_metrics.d.ts.map +1 -1
  149. package/dest/public/test_executor_metrics.js +7 -6
  150. package/dest/public/unique_class_ids.d.ts +1 -1
  151. package/dest/public/unique_class_ids.d.ts.map +1 -1
  152. package/dest/public/utils.d.ts +1 -1
  153. package/dest/server.d.ts +1 -1
  154. package/dest/testing.d.ts +1 -1
  155. package/package.json +26 -22
  156. package/src/client.ts +0 -2
  157. package/src/common/errors.ts +1 -1
  158. package/src/private/acvm/acvm.ts +4 -3
  159. package/src/private/acvm/deserialize.ts +1 -1
  160. package/src/private/acvm/serialize.ts +1 -1
  161. package/src/private/acvm_native.ts +11 -5
  162. package/src/private/acvm_wasm.ts +11 -4
  163. package/src/private/circuit_recording/circuit_recorder.ts +90 -81
  164. package/src/private/circuit_recording/file_circuit_recorder.ts +45 -50
  165. package/src/private/circuit_recording/memory_circuit_recorder.ts +6 -4
  166. package/src/private/circuit_recording/simulator_recorder_wrapper.ts +9 -15
  167. package/src/private/factory.ts +7 -4
  168. package/src/public/avm/testing/account_proof.json +553 -0
  169. package/src/public/avm/testing/account_proof_fetcher.ts +166 -0
  170. package/src/public/avm/{fixtures → testing}/base_avm_simulation_tester.ts +24 -4
  171. package/src/public/avm/{fixtures → testing}/utils.ts +7 -42
  172. package/src/public/avm_simulator.ts +29 -0
  173. package/src/public/avm_simulator_pool.ts +226 -0
  174. package/src/public/cdb/generated/api_types.ts +457 -0
  175. package/src/public/cdb/generated/server.ts +109 -0
  176. package/src/public/cdb_ipc_server.ts +197 -0
  177. package/src/public/contracts_db_checkpoint.ts +41 -0
  178. package/src/public/db_interfaces.ts +16 -1
  179. package/src/public/executor_metrics.ts +11 -34
  180. package/src/public/executor_metrics_interface.ts +2 -1
  181. package/src/public/fixtures/amm_test.ts +6 -6
  182. package/src/public/fixtures/bulk_test.ts +40 -15
  183. package/src/public/fixtures/custom_bytecode_tester.ts +54 -20
  184. package/src/public/fixtures/index.ts +6 -2
  185. package/src/public/fixtures/public_processor_test_env.ts +88 -0
  186. package/src/public/fixtures/public_tx_simulation_tester.ts +117 -26
  187. package/src/public/fixtures/simple_contract_data_source.ts +9 -10
  188. package/src/public/fixtures/token_test.ts +21 -13
  189. package/src/public/fixtures/utils.ts +25 -27
  190. package/src/public/fuzzing/avm_fuzzer_simulator.ts +303 -0
  191. package/src/public/fuzzing/avm_simulator_bin.ts +173 -0
  192. package/src/public/index.ts +8 -2
  193. package/src/public/public_db_sources.ts +112 -174
  194. package/src/public/public_processor/guarded_merkle_tree.ts +14 -6
  195. package/src/public/public_processor/public_processor.ts +234 -138
  196. package/src/public/public_processor/public_processor_metrics.ts +28 -44
  197. package/src/public/public_tx_simulator/dumping_public_tx_simulator.ts +67 -0
  198. package/src/public/public_tx_simulator/factories.ts +61 -0
  199. package/src/public/public_tx_simulator/index.ts +8 -3
  200. package/src/public/public_tx_simulator/public_tx_simulator.ts +142 -500
  201. package/src/public/public_tx_simulator/public_tx_simulator_base.ts +37 -0
  202. package/src/public/public_tx_simulator/public_tx_simulator_interface.ts +24 -2
  203. package/src/public/test_executor_metrics.ts +10 -8
  204. package/dest/public/avm/avm_context.d.ts +0 -41
  205. package/dest/public/avm/avm_context.d.ts.map +0 -1
  206. package/dest/public/avm/avm_context.js +0 -44
  207. package/dest/public/avm/avm_contract_call_result.d.ts +0 -32
  208. package/dest/public/avm/avm_contract_call_result.d.ts.map +0 -1
  209. package/dest/public/avm/avm_contract_call_result.js +0 -54
  210. package/dest/public/avm/avm_execution_environment.d.ts +0 -23
  211. package/dest/public/avm/avm_execution_environment.d.ts.map +0 -1
  212. package/dest/public/avm/avm_execution_environment.js +0 -36
  213. package/dest/public/avm/avm_gas.d.ts +0 -44
  214. package/dest/public/avm/avm_gas.d.ts.map +0 -1
  215. package/dest/public/avm/avm_gas.js +0 -195
  216. package/dest/public/avm/avm_machine_state.d.ts +0 -97
  217. package/dest/public/avm/avm_machine_state.d.ts.map +0 -1
  218. package/dest/public/avm/avm_machine_state.js +0 -109
  219. package/dest/public/avm/avm_memory_types.d.ts +0 -275
  220. package/dest/public/avm/avm_memory_types.d.ts.map +0 -1
  221. package/dest/public/avm/avm_memory_types.js +0 -351
  222. package/dest/public/avm/avm_simulator.d.ts +0 -39
  223. package/dest/public/avm/avm_simulator.d.ts.map +0 -1
  224. package/dest/public/avm/avm_simulator.js +0 -190
  225. package/dest/public/avm/avm_simulator_interface.d.ts +0 -9
  226. package/dest/public/avm/avm_simulator_interface.d.ts.map +0 -1
  227. package/dest/public/avm/avm_simulator_interface.js +0 -3
  228. package/dest/public/avm/errors.d.ts +0 -98
  229. package/dest/public/avm/errors.d.ts.map +0 -1
  230. package/dest/public/avm/errors.js +0 -129
  231. package/dest/public/avm/fixtures/avm_simulation_tester.d.ts +0 -22
  232. package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +0 -1
  233. package/dest/public/avm/fixtures/avm_simulation_tester.js +0 -74
  234. package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +0 -1
  235. package/dest/public/avm/fixtures/initializers.d.ts +0 -43
  236. package/dest/public/avm/fixtures/initializers.d.ts.map +0 -1
  237. package/dest/public/avm/fixtures/initializers.js +0 -42
  238. package/dest/public/avm/fixtures/utils.d.ts.map +0 -1
  239. package/dest/public/avm/index.d.ts +0 -2
  240. package/dest/public/avm/index.d.ts.map +0 -1
  241. package/dest/public/avm/index.js +0 -1
  242. package/dest/public/avm/opcodes/accrued_substate.d.ts +0 -75
  243. package/dest/public/avm/opcodes/accrued_substate.d.ts.map +0 -1
  244. package/dest/public/avm/opcodes/accrued_substate.js +0 -255
  245. package/dest/public/avm/opcodes/addressing_mode.d.ts +0 -31
  246. package/dest/public/avm/opcodes/addressing_mode.d.ts.map +0 -1
  247. package/dest/public/avm/opcodes/addressing_mode.js +0 -94
  248. package/dest/public/avm/opcodes/arithmetic.d.ts +0 -47
  249. package/dest/public/avm/opcodes/arithmetic.d.ts.map +0 -1
  250. package/dest/public/avm/opcodes/arithmetic.js +0 -87
  251. package/dest/public/avm/opcodes/bitwise.d.ts +0 -42
  252. package/dest/public/avm/opcodes/bitwise.d.ts.map +0 -1
  253. package/dest/public/avm/opcodes/bitwise.js +0 -99
  254. package/dest/public/avm/opcodes/comparators.d.ts +0 -25
  255. package/dest/public/avm/opcodes/comparators.d.ts.map +0 -1
  256. package/dest/public/avm/opcodes/comparators.js +0 -43
  257. package/dest/public/avm/opcodes/contract.d.ts +0 -20
  258. package/dest/public/avm/opcodes/contract.d.ts.map +0 -1
  259. package/dest/public/avm/opcodes/contract.js +0 -65
  260. package/dest/public/avm/opcodes/control_flow.d.ts +0 -41
  261. package/dest/public/avm/opcodes/control_flow.d.ts.map +0 -1
  262. package/dest/public/avm/opcodes/control_flow.js +0 -107
  263. package/dest/public/avm/opcodes/conversion.d.ts +0 -18
  264. package/dest/public/avm/opcodes/conversion.d.ts.map +0 -1
  265. package/dest/public/avm/opcodes/conversion.js +0 -333
  266. package/dest/public/avm/opcodes/ec_add.d.ts +0 -19
  267. package/dest/public/avm/opcodes/ec_add.d.ts.map +0 -1
  268. package/dest/public/avm/opcodes/ec_add.js +0 -84
  269. package/dest/public/avm/opcodes/environment_getters.d.ts +0 -28
  270. package/dest/public/avm/opcodes/environment_getters.d.ts.map +0 -1
  271. package/dest/public/avm/opcodes/environment_getters.js +0 -77
  272. package/dest/public/avm/opcodes/external_calls.d.ts +0 -59
  273. package/dest/public/avm/opcodes/external_calls.d.ts.map +0 -1
  274. package/dest/public/avm/opcodes/external_calls.js +0 -209
  275. package/dest/public/avm/opcodes/hashing.d.ts +0 -36
  276. package/dest/public/avm/opcodes/hashing.d.ts.map +0 -1
  277. package/dest/public/avm/opcodes/hashing.js +0 -114
  278. package/dest/public/avm/opcodes/index.d.ts +0 -16
  279. package/dest/public/avm/opcodes/index.d.ts.map +0 -1
  280. package/dest/public/avm/opcodes/index.js +0 -15
  281. package/dest/public/avm/opcodes/instruction.d.ts +0 -74
  282. package/dest/public/avm/opcodes/instruction.d.ts.map +0 -1
  283. package/dest/public/avm/opcodes/instruction.js +0 -95
  284. package/dest/public/avm/opcodes/instruction_impl.d.ts +0 -19
  285. package/dest/public/avm/opcodes/instruction_impl.d.ts.map +0 -1
  286. package/dest/public/avm/opcodes/instruction_impl.js +0 -30
  287. package/dest/public/avm/opcodes/memory.d.ts +0 -74
  288. package/dest/public/avm/opcodes/memory.d.ts.map +0 -1
  289. package/dest/public/avm/opcodes/memory.js +0 -257
  290. package/dest/public/avm/opcodes/misc.d.ts +0 -18
  291. package/dest/public/avm/opcodes/misc.d.ts.map +0 -1
  292. package/dest/public/avm/opcodes/misc.js +0 -73
  293. package/dest/public/avm/opcodes/storage.d.ts +0 -24
  294. package/dest/public/avm/opcodes/storage.d.ts.map +0 -1
  295. package/dest/public/avm/opcodes/storage.js +0 -68
  296. package/dest/public/avm/revert_reason.d.ts +0 -18
  297. package/dest/public/avm/revert_reason.d.ts.map +0 -1
  298. package/dest/public/avm/revert_reason.js +0 -38
  299. package/dest/public/avm/serialization/buffer_cursor.d.ts +0 -26
  300. package/dest/public/avm/serialization/buffer_cursor.d.ts.map +0 -1
  301. package/dest/public/avm/serialization/buffer_cursor.js +0 -99
  302. package/dest/public/avm/serialization/bytecode_serialization.d.ts +0 -17
  303. package/dest/public/avm/serialization/bytecode_serialization.d.ts.map +0 -1
  304. package/dest/public/avm/serialization/bytecode_serialization.js +0 -333
  305. package/dest/public/avm/serialization/instruction_serialization.d.ts +0 -114
  306. package/dest/public/avm/serialization/instruction_serialization.d.ts.map +0 -1
  307. package/dest/public/avm/serialization/instruction_serialization.js +0 -261
  308. package/dest/public/avm/test_utils.d.ts +0 -15
  309. package/dest/public/avm/test_utils.d.ts.map +0 -1
  310. package/dest/public/avm/test_utils.js +0 -44
  311. package/dest/public/debug_fn_name.d.ts +0 -5
  312. package/dest/public/debug_fn_name.d.ts.map +0 -1
  313. package/dest/public/debug_fn_name.js +0 -9
  314. package/dest/public/fixtures/custom_bytecode_tests.d.ts +0 -9
  315. package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +0 -1
  316. package/dest/public/fixtures/custom_bytecode_tests.js +0 -109
  317. package/dest/public/fixtures/minimal_public_tx.d.ts +0 -10
  318. package/dest/public/fixtures/minimal_public_tx.d.ts.map +0 -1
  319. package/dest/public/fixtures/minimal_public_tx.js +0 -29
  320. package/dest/public/hinting_db_sources.d.ts +0 -70
  321. package/dest/public/hinting_db_sources.d.ts.map +0 -1
  322. package/dest/public/hinting_db_sources.js +0 -297
  323. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +0 -41
  324. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +0 -1
  325. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +0 -89
  326. package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +0 -24
  327. package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts.map +0 -1
  328. package/dest/public/public_tx_simulator/measured_public_tx_simulator.js +0 -51
  329. package/dest/public/public_tx_simulator/public_tx_context.d.ts +0 -127
  330. package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +0 -1
  331. package/dest/public/public_tx_simulator/public_tx_context.js +0 -292
  332. package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts +0 -21
  333. package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts.map +0 -1
  334. package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.js +0 -39
  335. package/dest/public/side_effect_trace.d.ts +0 -87
  336. package/dest/public/side_effect_trace.d.ts.map +0 -1
  337. package/dest/public/side_effect_trace.js +0 -199
  338. package/dest/public/side_effect_trace_interface.d.ts +0 -23
  339. package/dest/public/side_effect_trace_interface.d.ts.map +0 -1
  340. package/dest/public/side_effect_trace_interface.js +0 -1
  341. package/dest/public/state_manager/index.d.ts +0 -2
  342. package/dest/public/state_manager/index.d.ts.map +0 -1
  343. package/dest/public/state_manager/index.js +0 -1
  344. package/dest/public/state_manager/nullifiers.d.ts +0 -61
  345. package/dest/public/state_manager/nullifiers.d.ts.map +0 -1
  346. package/dest/public/state_manager/nullifiers.js +0 -92
  347. package/dest/public/state_manager/public_storage.d.ts +0 -66
  348. package/dest/public/state_manager/public_storage.d.ts.map +0 -1
  349. package/dest/public/state_manager/public_storage.js +0 -145
  350. package/dest/public/state_manager/state_manager.d.ts +0 -166
  351. package/dest/public/state_manager/state_manager.d.ts.map +0 -1
  352. package/dest/public/state_manager/state_manager.js +0 -391
  353. package/dest/public/tx_contract_cache.d.ts +0 -41
  354. package/dest/public/tx_contract_cache.d.ts.map +0 -1
  355. package/dest/public/tx_contract_cache.js +0 -49
  356. package/src/public/avm/avm_context.ts +0 -61
  357. package/src/public/avm/avm_contract_call_result.ts +0 -67
  358. package/src/public/avm/avm_execution_environment.ts +0 -48
  359. package/src/public/avm/avm_gas.ts +0 -183
  360. package/src/public/avm/avm_machine_state.ts +0 -169
  361. package/src/public/avm/avm_memory_types.ts +0 -436
  362. package/src/public/avm/avm_simulator.ts +0 -274
  363. package/src/public/avm/avm_simulator_interface.ts +0 -8
  364. package/src/public/avm/errors.ts +0 -163
  365. package/src/public/avm/fixtures/avm_simulation_tester.ts +0 -108
  366. package/src/public/avm/fixtures/initializers.ts +0 -104
  367. package/src/public/avm/index.ts +0 -1
  368. package/src/public/avm/opcodes/accrued_substate.ts +0 -288
  369. package/src/public/avm/opcodes/addressing_mode.ts +0 -111
  370. package/src/public/avm/opcodes/arithmetic.ts +0 -117
  371. package/src/public/avm/opcodes/bitwise.ts +0 -113
  372. package/src/public/avm/opcodes/comparators.ts +0 -55
  373. package/src/public/avm/opcodes/contract.ts +0 -75
  374. package/src/public/avm/opcodes/control_flow.ts +0 -123
  375. package/src/public/avm/opcodes/conversion.ts +0 -104
  376. package/src/public/avm/opcodes/ec_add.ts +0 -96
  377. package/src/public/avm/opcodes/environment_getters.ts +0 -87
  378. package/src/public/avm/opcodes/external_calls.ts +0 -260
  379. package/src/public/avm/opcodes/hashing.ts +0 -145
  380. package/src/public/avm/opcodes/index.ts +0 -15
  381. package/src/public/avm/opcodes/instruction.ts +0 -136
  382. package/src/public/avm/opcodes/instruction_impl.ts +0 -36
  383. package/src/public/avm/opcodes/memory.ts +0 -293
  384. package/src/public/avm/opcodes/misc.ts +0 -102
  385. package/src/public/avm/opcodes/storage.ts +0 -87
  386. package/src/public/avm/revert_reason.ts +0 -55
  387. package/src/public/avm/serialization/buffer_cursor.ts +0 -118
  388. package/src/public/avm/serialization/bytecode_serialization.ts +0 -204
  389. package/src/public/avm/serialization/instruction_serialization.ts +0 -249
  390. package/src/public/avm/test_utils.ts +0 -64
  391. package/src/public/debug_fn_name.ts +0 -18
  392. package/src/public/fixtures/custom_bytecode_tests.ts +0 -135
  393. package/src/public/fixtures/minimal_public_tx.ts +0 -36
  394. package/src/public/hinting_db_sources.ts +0 -505
  395. package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +0 -128
  396. package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +0 -109
  397. package/src/public/public_tx_simulator/public_tx_context.ts +0 -471
  398. package/src/public/public_tx_simulator/telemetry_public_tx_simulator.ts +0 -63
  399. package/src/public/side_effect_trace.ts +0 -290
  400. package/src/public/side_effect_trace_interface.ts +0 -28
  401. package/src/public/state_manager/index.ts +0 -1
  402. package/src/public/state_manager/nullifiers.ts +0 -103
  403. package/src/public/state_manager/public_storage.ts +0 -174
  404. package/src/public/state_manager/state_manager.ts +0 -560
  405. package/src/public/tx_contract_cache.ts +0 -69
@@ -1,166 +0,0 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- import { type LogLevel } from '@aztec/foundation/log';
3
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
- import { SerializableContractInstance } from '@aztec/stdlib/contract';
5
- import type { DebugLog } from '@aztec/stdlib/logs';
6
- import { ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
7
- import { MerkleTreeId } from '@aztec/stdlib/trees';
8
- import type { TreeSnapshots } from '@aztec/stdlib/tx';
9
- import type { UInt64 } from '@aztec/stdlib/types';
10
- import type { AvmExecutionEnvironment } from '../avm/avm_execution_environment.js';
11
- import type { PublicContractsDBInterface } from '../db_interfaces.js';
12
- import type { PublicTreesDB } from '../public_db_sources.js';
13
- import type { PublicSideEffectTraceInterface } from '../side_effect_trace_interface.js';
14
- import { NullifierManager } from './nullifiers.js';
15
- import { PublicStorage } from './public_storage.js';
16
- /**
17
- * A class to manage persistable AVM state for contract calls.
18
- * Maintains a cache of the current world state,
19
- * a trace of all side effects.
20
- *
21
- * The simulator should make any world state / tree queries through this object.
22
- *
23
- * Manages merging of successful/reverted child state into current state.
24
- */
25
- export declare class PublicPersistableStateManager {
26
- private readonly treesDB;
27
- private readonly contractsDB;
28
- private readonly trace;
29
- private readonly firstNullifier;
30
- private readonly timestamp;
31
- private readonly doMerkleOperations;
32
- private readonly publicStorage;
33
- private readonly nullifiers;
34
- private readonly log;
35
- /** Make sure a forked state is never merged twice. */
36
- private alreadyMergedIntoParent;
37
- constructor(treesDB: PublicTreesDB, contractsDB: PublicContractsDBInterface, trace: PublicSideEffectTraceInterface, firstNullifier: Fr, // Needed for note hashes.
38
- timestamp: UInt64, // Needed for contract updates.
39
- doMerkleOperations?: boolean, publicStorage?: PublicStorage, nullifiers?: NullifierManager);
40
- /**
41
- * Create a new state manager
42
- */
43
- static create(treesDB: PublicTreesDB, contractsDB: PublicContractsDBInterface, trace: PublicSideEffectTraceInterface, doMerkleOperations: boolean | undefined, firstNullifier: Fr, timestamp: UInt64): PublicPersistableStateManager;
44
- /**
45
- * Create a new state manager forked from this one
46
- */
47
- fork(): Promise<PublicPersistableStateManager>;
48
- /**
49
- * Accept forked world state modifications & traced side effects / hints
50
- */
51
- merge(forkedState: PublicPersistableStateManager): Promise<void>;
52
- /**
53
- * Reject forked world state modifications & traced side effects, keep traced hints
54
- */
55
- reject(forkedState: PublicPersistableStateManager): Promise<void>;
56
- private _merge;
57
- /**
58
- * Write to public storage, journal/trace the write.
59
- *
60
- * @param contractAddress - the address of the contract whose storage is being written to
61
- * @param slot - the slot in the contract's storage being written to
62
- * @param value - the value being written to the slot
63
- */
64
- writeStorage(contractAddress: AztecAddress, slot: Fr, value: Fr, protocolWrite?: boolean): Promise<void>;
65
- isStorageCold(contractAddress: AztecAddress, slot: Fr): boolean;
66
- /**
67
- * Read from public storage.
68
- *
69
- * @param contractAddress - the address of the contract whose storage is being read from
70
- * @param slot - the slot in the contract's storage being read from
71
- * @returns the latest value written to slot, or 0 if never written to before
72
- */
73
- readStorage(contractAddress: AztecAddress, slot: Fr): Promise<Fr>;
74
- /**
75
- * Check if a note hash exists at the given leaf index, trace the check.
76
- *
77
- * @param contractAddress - the address of the contract whose storage is being read from
78
- * @param noteHash - the unsiloed note hash being checked
79
- * @param leafIndex - the leaf index being checked
80
- * @returns true if the note hash exists at the given leaf index, false otherwise
81
- */
82
- checkNoteHashExists(contractAddress: AztecAddress, noteHash: Fr, leafIndex: bigint): Promise<boolean>;
83
- /**
84
- * Write a raw note hash, silo it and make it unique, then trace the write.
85
- * @param noteHash - the unsiloed note hash to write
86
- */
87
- writeNoteHash(contractAddress: AztecAddress, noteHash: Fr): Promise<void>;
88
- /**
89
- * Write a note hash, make it unique, trace the write.
90
- * @param siloedNoteHash - the non unique note hash to write
91
- */
92
- writeSiloedNoteHash(siloedNoteHash: Fr): Promise<void>;
93
- /**
94
- * Write a note hash, trace the write.
95
- * @param uniqueNoteHash - the siloed unique hash to write
96
- */
97
- writeUniqueNoteHash(uniqueNoteHash: Fr): Promise<void>;
98
- /**
99
- * Check if a nullifier exists, trace the check.
100
- * @param contractAddress - address of the contract that the nullifier is associated with
101
- * @param nullifier - the unsiloed nullifier to check
102
- * @returns exists - whether the nullifier exists in the nullifier set
103
- */
104
- checkNullifierExists(contractAddress: AztecAddress, nullifier: Fr): Promise<boolean>;
105
- /**
106
- * Write a nullifier to the nullifier set, trace the write.
107
- * @param contractAddress - address of the contract that the nullifier is associated with
108
- * @param nullifier - the unsiloed nullifier to write
109
- */
110
- writeNullifier(contractAddress: AztecAddress, nullifier: Fr): Promise<void>;
111
- /**
112
- * Write a nullifier to the nullifier set, trace the write.
113
- * @param siloedNullifier - the siloed nullifier to write
114
- */
115
- writeSiloedNullifier(siloedNullifier: Fr): Promise<void>;
116
- /**
117
- * Check if an L1 to L2 message exists, trace the check.
118
- * @param msgHash - the message hash to check existence of
119
- * @param msgLeafIndex - the message leaf index to use in the check
120
- * @returns exists - whether the message exists in the L1 to L2 Messages tree
121
- */
122
- checkL1ToL2MessageExists(msgHash: Fr, msgLeafIndex: Fr): Promise<boolean>;
123
- /**
124
- * Write an L2 to L1 message.
125
- * @param contractAddress - L2 contract address that created this message
126
- * @param recipient - L1 contract address to send the message to.
127
- * @param content - Message content.
128
- */
129
- writeL2ToL1Message(contractAddress: AztecAddress, recipient: Fr, content: Fr): void;
130
- /**
131
- * Write a scoped L2 to L1 message.
132
- * @param l2ToL1Message - The L2 to L1 message to write.
133
- */
134
- writeScopedL2ToL1Message(l2ToL1Message: ScopedL2ToL1Message): void;
135
- writeDebugLog(contractAddress: AztecAddress, level: LogLevel, message: string, fields: Fr[]): void;
136
- writeDebugLogMemoryReads(memoryReads: number): void;
137
- getDebugLogMemoryReads(): number;
138
- getLogs(): DebugLog[];
139
- /**
140
- * Write a public log
141
- * @param contractAddress - address of the contract that emitted the log
142
- * @param log - log contents
143
- */
144
- writePublicLog(contractAddress: AztecAddress, log: Fr[]): void;
145
- /**
146
- * Get a contract instance.
147
- * @param contractAddress - address of the contract instance to retrieve.
148
- * @returns the contract instance or undefined if it does not exist.
149
- */
150
- getContractInstance(contractAddress: AztecAddress): Promise<SerializableContractInstance | undefined>;
151
- private checkContractUpdateInformation;
152
- /**
153
- * Get a contract class.
154
- * @param classId - class id to retrieve.
155
- * @returns the contract class or undefined if it does not exist.
156
- */
157
- private getContractClass;
158
- /**
159
- * Get a contract's bytecode from the contracts DB, also trace the contract class and instance indirectly.
160
- */
161
- getBytecode(contractAddress: AztecAddress): Promise<Buffer | undefined>;
162
- getPublicFunctionDebugName(avmEnvironment: AvmExecutionEnvironment): Promise<string>;
163
- padTree(treeId: MerkleTreeId, leavesToInsert: number): Promise<void>;
164
- getTreeSnapshots(): Promise<TreeSnapshots>;
165
- }
166
- //# sourceMappingURL=state_manager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"state_manager.d.ts","sourceRoot":"","sources":["../../../src/public/state_manager/state_manager.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,KAAK,QAAQ,EAAgB,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAGtE,OAAO,KAAK,EAAE,QAAQ,EAA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TRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS, FEE_JUICE_ADDRESS, MULTI_CALL_ENTRYPOINT_ADDRESS, ROUTER_ADDRESS } from '@aztec/constants';
2
- import { poseidon2Hash } from '@aztec/foundation/crypto';
3
- import { jsonStringify } from '@aztec/foundation/json-rpc';
4
- import { createLogger } from '@aztec/foundation/log';
5
- import { ProtocolContractAddress } from '@aztec/protocol-contracts';
6
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
7
- import { SerializableContractInstance } from '@aztec/stdlib/contract';
8
- import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
9
- import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
10
- import { strict as assert } from 'assert';
11
- import { getPublicFunctionDebugName } from '../debug_fn_name.js';
12
- import { L1ToL2MessageIndexOutOfRangeError, MaxCallsToUniqueContractClassIdsError, NoteHashIndexOutOfRangeError, NullifierCollisionError } from '../side_effect_errors.js';
13
- import { NullifierManager } from './nullifiers.js';
14
- import { PublicStorage } from './public_storage.js';
15
- /**
16
- * A class to manage persistable AVM state for contract calls.
17
- * Maintains a cache of the current world state,
18
- * a trace of all side effects.
19
- *
20
- * The simulator should make any world state / tree queries through this object.
21
- *
22
- * Manages merging of successful/reverted child state into current state.
23
- */ export class PublicPersistableStateManager {
24
- treesDB;
25
- contractsDB;
26
- trace;
27
- firstNullifier;
28
- timestamp;
29
- doMerkleOperations;
30
- publicStorage;
31
- nullifiers;
32
- log;
33
- /** Make sure a forked state is never merged twice. */ alreadyMergedIntoParent;
34
- constructor(treesDB, contractsDB, trace, firstNullifier, timestamp, doMerkleOperations = false, publicStorage = new PublicStorage(treesDB), nullifiers = new NullifierManager(treesDB)){
35
- this.treesDB = treesDB;
36
- this.contractsDB = contractsDB;
37
- this.trace = trace;
38
- this.firstNullifier = firstNullifier;
39
- this.timestamp = timestamp;
40
- this.doMerkleOperations = doMerkleOperations;
41
- this.publicStorage = publicStorage;
42
- this.nullifiers = nullifiers;
43
- this.log = createLogger('simulator:state_manager');
44
- this.alreadyMergedIntoParent = false;
45
- }
46
- /**
47
- * Create a new state manager
48
- */ static create(treesDB, contractsDB, trace, doMerkleOperations = false, firstNullifier, timestamp) {
49
- return new PublicPersistableStateManager(treesDB, contractsDB, trace, firstNullifier, timestamp, doMerkleOperations);
50
- }
51
- /**
52
- * Create a new state manager forked from this one
53
- */ async fork() {
54
- await this.treesDB.createCheckpoint();
55
- return new PublicPersistableStateManager(this.treesDB, this.contractsDB, this.trace.fork(), this.firstNullifier, this.timestamp, this.doMerkleOperations, this.publicStorage.fork(), this.nullifiers.fork());
56
- }
57
- /**
58
- * Accept forked world state modifications & traced side effects / hints
59
- */ async merge(forkedState) {
60
- await this._merge(forkedState, /*reverted=*/ false);
61
- }
62
- /**
63
- * Reject forked world state modifications & traced side effects, keep traced hints
64
- */ async reject(forkedState) {
65
- await this._merge(forkedState, /*reverted=*/ true);
66
- }
67
- async _merge(forkedState, reverted) {
68
- // sanity check to avoid merging the same forked trace twice
69
- assert(!forkedState.alreadyMergedIntoParent, 'Cannot merge forked state that has already been merged into its parent!');
70
- forkedState.alreadyMergedIntoParent = true;
71
- this.publicStorage.acceptAndMerge(forkedState.publicStorage);
72
- this.nullifiers.acceptAndMerge(forkedState.nullifiers);
73
- this.trace.merge(forkedState.trace, reverted);
74
- if (reverted) {
75
- this.log.trace('Reverting forked state...');
76
- await this.treesDB.revertCheckpoint();
77
- } else {
78
- this.log.trace('Merging forked state into parent...');
79
- await this.treesDB.commitCheckpoint();
80
- }
81
- }
82
- /**
83
- * Write to public storage, journal/trace the write.
84
- *
85
- * @param contractAddress - the address of the contract whose storage is being written to
86
- * @param slot - the slot in the contract's storage being written to
87
- * @param value - the value being written to the slot
88
- */ async writeStorage(contractAddress, slot, value, protocolWrite = false) {
89
- this.log.trace(`Storage write (address=${contractAddress}, slot=${slot}): value=${value}`);
90
- await this.trace.tracePublicStorageWrite(contractAddress, slot, value, protocolWrite);
91
- if (this.doMerkleOperations) {
92
- // write to native merkle trees
93
- await this.treesDB.storageWrite(contractAddress, slot, value);
94
- } else {
95
- // Cache storage writes for later reference/reads
96
- this.publicStorage.write(contractAddress, slot, value);
97
- }
98
- }
99
- isStorageCold(contractAddress, slot) {
100
- return this.trace.isStorageCold(contractAddress, slot);
101
- }
102
- /**
103
- * Read from public storage.
104
- *
105
- * @param contractAddress - the address of the contract whose storage is being read from
106
- * @param slot - the slot in the contract's storage being read from
107
- * @returns the latest value written to slot, or 0 if never written to before
108
- */ async readStorage(contractAddress, slot) {
109
- if (this.doMerkleOperations) {
110
- return await this.treesDB.storageRead(contractAddress, slot);
111
- } else {
112
- // TODO(fcarreiro): I don't get this. PublicStorage CAN end up reading the tree. Why is it in the "dont do merkle operations" branch?
113
- const read = await this.publicStorage.read(contractAddress, slot);
114
- this.log.trace(`Storage read results (address=${contractAddress}, slot=${slot}): value=${read.value}, cached=${read.cached}`);
115
- return read.value;
116
- }
117
- }
118
- // TODO(4886): We currently don't silo note hashes.
119
- /**
120
- * Check if a note hash exists at the given leaf index, trace the check.
121
- *
122
- * @param contractAddress - the address of the contract whose storage is being read from
123
- * @param noteHash - the unsiloed note hash being checked
124
- * @param leafIndex - the leaf index being checked
125
- * @returns true if the note hash exists at the given leaf index, false otherwise
126
- */ async checkNoteHashExists(contractAddress, noteHash, leafIndex) {
127
- try {
128
- const gotLeafValue = await this.treesDB.getNoteHash(leafIndex);
129
- const exists = gotLeafValue.equals(noteHash);
130
- this.log.trace(`noteHashes(${contractAddress})@${noteHash} ?? leafIndex: ${leafIndex} | gotLeafValue: ${gotLeafValue}, exists: ${exists}.`);
131
- return Promise.resolve(exists);
132
- } catch (error) {
133
- // If the index is out of range, note_hash_leaf_in_range = 0 and the circuit returns false:
134
- if (error instanceof NoteHashIndexOutOfRangeError) {
135
- return Promise.resolve(false);
136
- }
137
- // Otherwise, unknown error. This is a bug.
138
- throw error;
139
- }
140
- }
141
- /**
142
- * Write a raw note hash, silo it and make it unique, then trace the write.
143
- * @param noteHash - the unsiloed note hash to write
144
- */ async writeNoteHash(contractAddress, noteHash) {
145
- this.log.trace(`noteHashes(${contractAddress}) += ${noteHash}.`);
146
- const siloedNoteHash = await siloNoteHash(contractAddress, noteHash);
147
- await this.writeSiloedNoteHash(siloedNoteHash);
148
- }
149
- /**
150
- * Write a note hash, make it unique, trace the write.
151
- * @param siloedNoteHash - the non unique note hash to write
152
- */ async writeSiloedNoteHash(siloedNoteHash) {
153
- const noteNonce = await computeNoteHashNonce(this.firstNullifier, this.trace.getNoteHashCount());
154
- const uniqueNoteHash = await computeUniqueNoteHash(noteNonce, siloedNoteHash);
155
- await this.writeUniqueNoteHash(uniqueNoteHash);
156
- }
157
- /**
158
- * Write a note hash, trace the write.
159
- * @param uniqueNoteHash - the siloed unique hash to write
160
- */ async writeUniqueNoteHash(uniqueNoteHash) {
161
- this.log.trace(`noteHashes += @${uniqueNoteHash}.`);
162
- this.trace.traceNewNoteHash(uniqueNoteHash);
163
- if (this.doMerkleOperations) {
164
- await this.treesDB.writeNoteHash(uniqueNoteHash);
165
- }
166
- }
167
- /**
168
- * Check if a nullifier exists, trace the check.
169
- * @param contractAddress - address of the contract that the nullifier is associated with
170
- * @param nullifier - the unsiloed nullifier to check
171
- * @returns exists - whether the nullifier exists in the nullifier set
172
- */ async checkNullifierExists(contractAddress, nullifier) {
173
- this.log.trace(`Checking existence of nullifier (address=${contractAddress}, nullifier=${nullifier})`);
174
- const siloedNullifier = await siloNullifier(contractAddress, nullifier);
175
- if (this.doMerkleOperations) {
176
- const exists = await this.treesDB.checkNullifierExists(siloedNullifier);
177
- this.log.trace(`Checked siloed nullifier ${siloedNullifier} (exists=${exists})`);
178
- return Promise.resolve(exists);
179
- } else {
180
- const { exists, cacheHit } = await this.nullifiers.checkExists(siloedNullifier);
181
- this.log.trace(`Checked siloed nullifier ${siloedNullifier} (exists=${exists}), cacheHit=${cacheHit}`);
182
- return Promise.resolve(exists);
183
- }
184
- }
185
- /**
186
- * Write a nullifier to the nullifier set, trace the write.
187
- * @param contractAddress - address of the contract that the nullifier is associated with
188
- * @param nullifier - the unsiloed nullifier to write
189
- */ async writeNullifier(contractAddress, nullifier) {
190
- this.log.trace(`Inserting new nullifier (address=${nullifier}, nullifier=${contractAddress})`);
191
- const siloedNullifier = await siloNullifier(contractAddress, nullifier);
192
- await this.writeSiloedNullifier(siloedNullifier);
193
- }
194
- /**
195
- * Write a nullifier to the nullifier set, trace the write.
196
- * @param siloedNullifier - the siloed nullifier to write
197
- */ async writeSiloedNullifier(siloedNullifier) {
198
- this.log.trace(`Inserting siloed nullifier=${siloedNullifier}`);
199
- this.trace.traceNewNullifier(siloedNullifier);
200
- if (this.doMerkleOperations) {
201
- const exists = await this.treesDB.checkNullifierExists(siloedNullifier);
202
- if (exists) {
203
- this.log.verbose(`Siloed nullifier ${siloedNullifier} already present in tree!`);
204
- throw new NullifierCollisionError(`Siloed nullifier ${siloedNullifier} already exists in parent cache or host.`);
205
- } else {
206
- await this.treesDB.writeNullifier(siloedNullifier);
207
- }
208
- } else {
209
- // Cache pending nullifiers for later access
210
- await this.nullifiers.append(siloedNullifier);
211
- }
212
- }
213
- /**
214
- * Check if an L1 to L2 message exists, trace the check.
215
- * @param msgHash - the message hash to check existence of
216
- * @param msgLeafIndex - the message leaf index to use in the check
217
- * @returns exists - whether the message exists in the L1 to L2 Messages tree
218
- */ async checkL1ToL2MessageExists(msgHash, msgLeafIndex) {
219
- try {
220
- const valueAtIndex = await this.treesDB.getL1ToL2LeafValue(msgLeafIndex.toBigInt());
221
- const exists = valueAtIndex.equals(msgHash);
222
- this.log.trace(`l1ToL2Messages(@${msgLeafIndex}) ?? exists: ${exists}, expected: ${msgHash}, found: ${valueAtIndex}.`);
223
- return Promise.resolve(exists);
224
- } catch (error) {
225
- // If the index is out of range, l1_to_l2_msg_leaf_in_range = 0 and the circuit returns false:
226
- if (error instanceof L1ToL2MessageIndexOutOfRangeError) {
227
- return Promise.resolve(false);
228
- }
229
- // Otherwise, unknown error. This is a bug.
230
- throw error;
231
- }
232
- }
233
- /**
234
- * Write an L2 to L1 message.
235
- * @param contractAddress - L2 contract address that created this message
236
- * @param recipient - L1 contract address to send the message to.
237
- * @param content - Message content.
238
- */ writeL2ToL1Message(contractAddress, recipient, content) {
239
- this.log.trace(`L2ToL1Messages(${contractAddress}) += (recipient: ${recipient}, content: ${content}).`);
240
- this.trace.traceNewL2ToL1Message(contractAddress, recipient, content);
241
- }
242
- /**
243
- * Write a scoped L2 to L1 message.
244
- * @param l2ToL1Message - The L2 to L1 message to write.
245
- */ writeScopedL2ToL1Message(l2ToL1Message) {
246
- this.writeL2ToL1Message(l2ToL1Message.contractAddress, l2ToL1Message.message.recipient.toField(), l2ToL1Message.message.content);
247
- }
248
- writeDebugLog(contractAddress, level, message, fields) {
249
- this.trace.traceDebugLog(contractAddress, level, message, fields);
250
- }
251
- writeDebugLogMemoryReads(memoryReads) {
252
- this.trace.traceDebugLogMemoryReads(memoryReads);
253
- }
254
- getDebugLogMemoryReads() {
255
- return this.trace.getDebugLogMemoryReads();
256
- }
257
- getLogs() {
258
- return this.trace.getDebugLogs();
259
- }
260
- /**
261
- * Write a public log
262
- * @param contractAddress - address of the contract that emitted the log
263
- * @param log - log contents
264
- */ writePublicLog(contractAddress, log) {
265
- this.log.trace(`PublicLog(${contractAddress}) += event with ${log.length} fields.`);
266
- this.trace.tracePublicLog(contractAddress, log);
267
- }
268
- /**
269
- * Get a contract instance.
270
- * @param contractAddress - address of the contract instance to retrieve.
271
- * @returns the contract instance or undefined if it does not exist.
272
- */ async getContractInstance(contractAddress) {
273
- this.log.trace(`Getting contract instance for address ${contractAddress}`);
274
- const instanceWithAddress = await this.contractsDB.getContractInstance(contractAddress, this.timestamp);
275
- const exists = instanceWithAddress !== undefined;
276
- const instance = exists ? new SerializableContractInstance(instanceWithAddress) : undefined;
277
- if (contractAddressIsCanonical(contractAddress)) {
278
- this.log.trace(`Got canonical contract instance (address=${contractAddress}): instance=${jsonStringify(instance)}`);
279
- return instance;
280
- }
281
- // Nullifier check! We do this regardless of whether or not the instance exists,
282
- // as even for non-existence, we need to generate nullifier check hints.
283
- // This will internally decide whether to check the nullifier tree or not depending on doMerkleOperations.
284
- const nullifierExistsInTree = await this.checkNullifierExists(AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), contractAddress.toField());
285
- assert(exists == nullifierExistsInTree, `Contract instance for address ${contractAddress} in DB: ${exists} != nullifier tree: ${nullifierExistsInTree}. This is a bug!`);
286
- if (!exists) {
287
- this.log.debug(`Contract instance NOT FOUND (address=${contractAddress})`);
288
- return undefined;
289
- }
290
- this.log.trace(`Got contract instance (address=${contractAddress}): instance=${jsonStringify(instance)}`);
291
- // All that is left is to check that the contract updatability information is correct.
292
- // That is, that the current and original contract class ids are correct.
293
- await this.checkContractUpdateInformation(instanceWithAddress);
294
- return instance;
295
- }
296
- async checkContractUpdateInformation(instance) {
297
- // If "merkle operations" are not requested, we trust the DB.
298
- // Otherwise we check that the contract updatability information is correct.
299
- // That is, that the current and original contract class ids are correct.
300
- // All failures are fatal and the simulation is not expected to be provable.
301
- if (this.doMerkleOperations) {
302
- // Conceptually, we want to do the following:
303
- // * Read a DelayedPublicMutable at the contract update slot.
304
- // * Obtain the expected current class id from the DelayedPublicMutable, at the current block.
305
- // * if expectedId == 0 then currentClassId should be original contract class id
306
- // * if expectedId != 0 then currentClassId should be expectedId
307
- //
308
- // However, we will also be checking the hash of the delayed public mutable values.
309
- // This is a bit of a leak of information, since the circuit will use it to prove
310
- // one public read instead of N of the delayed public mutable values.
311
- const { delayedPublicMutableSlot, delayedPublicMutableHashSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(instance.address);
312
- const readDeployerStorage = async (storageSlot)=>await this.readStorage(ProtocolContractAddress.ContractInstanceRegistry, storageSlot);
313
- const hash = await readDeployerStorage(delayedPublicMutableHashSlot);
314
- const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, readDeployerStorage);
315
- const preImage = delayedPublicMutableValues.toFields();
316
- // 1) update never scheduled: hash == 0 and preimage should be empty (but poseidon2hash(preimage) will not be 0s)
317
- if (hash.isZero()) {
318
- assert(preImage.every((f)=>f.isZero()), `Found updatability hash 0 but preimage is not empty for contract instance ${instance.address}.`);
319
- assert(instance.currentContractClassId.equals(instance.originalContractClassId), `Found updatability hash 0 for contract instance ${instance.address} but original class id ${instance.originalContractClassId} != current class id ${instance.currentContractClassId}.`);
320
- return;
321
- }
322
- // 2) At this point we know that the hash is not zero and this means that an update has at some point been scheduled.
323
- const computedHash = await poseidon2Hash(preImage);
324
- assert(hash.equals(computedHash), `Delayed public mutable values hash mismatch for contract instance ${instance.address}. Expected: ${hash}, computed: ${computedHash}`);
325
- // We now check that, depending on the current block, the current class id is correct.
326
- const expectedClassIdRaw = delayedPublicMutableValues.svc.getCurrentAt(this.timestamp).at(0);
327
- const expectedClassId = expectedClassIdRaw.isZero() ? instance.originalContractClassId : expectedClassIdRaw;
328
- assert(instance.currentContractClassId.equals(expectedClassId), `Current class id mismatch
329
- for contract instance ${instance.address}. Expected: ${expectedClassId}, current: ${instance.currentContractClassId}`);
330
- }
331
- }
332
- /**
333
- * Get a contract class.
334
- * @param classId - class id to retrieve.
335
- * @returns the contract class or undefined if it does not exist.
336
- */ async getContractClass(classId) {
337
- this.log.trace(`Getting contract class for id ${classId}`);
338
- const contractClass = await this.contractsDB.getContractClass(classId);
339
- const exists = contractClass !== undefined;
340
- let extendedClass = undefined;
341
- // Note: We currently do not generate info to check the nullifier tree, because
342
- // this is not needed for our use cases.
343
- if (exists) {
344
- this.log.trace(`Got contract class (id=${classId})`);
345
- // Extend class information with public bytecode commitment.
346
- const bytecodeCommitment = await this.contractsDB.getBytecodeCommitment(classId);
347
- assert(bytecodeCommitment, `Bytecode commitment was not found in DB for contract class (${classId}). This should not happen!`);
348
- extendedClass = {
349
- ...contractClass,
350
- publicBytecodeCommitment: bytecodeCommitment
351
- };
352
- } else {
353
- this.log.debug(`Contract class NOT FOUND (id=${classId})`);
354
- }
355
- // TODO(dbanks12): does this need to be moved to before the DB accesses as was done with writeNullifier?
356
- this.trace.traceGetContractClass(classId, exists);
357
- return extendedClass;
358
- }
359
- /**
360
- * Get a contract's bytecode from the contracts DB, also trace the contract class and instance indirectly.
361
- */ async getBytecode(contractAddress) {
362
- this.log.debug(`Getting bytecode for contract address ${contractAddress}`);
363
- const contractInstance = await this.getContractInstance(contractAddress);
364
- if (!contractInstance) {
365
- return undefined;
366
- }
367
- try {
368
- const contractClass = await this.getContractClass(contractInstance.currentContractClassId);
369
- assert(contractClass, `Contract class not found in DB, but a contract instance was found with this class ID (${contractInstance.currentContractClassId}). This should not happen!`);
370
- return contractClass.packedBytecode;
371
- } catch (error) {
372
- if (error instanceof MaxCallsToUniqueContractClassIdsError) {
373
- return undefined;
374
- }
375
- // Otherwise, unknown error. This is a bug.
376
- throw error;
377
- }
378
- }
379
- async getPublicFunctionDebugName(avmEnvironment) {
380
- return await getPublicFunctionDebugName(this.contractsDB, avmEnvironment.address, avmEnvironment.calldata);
381
- }
382
- async padTree(treeId, leavesToInsert) {
383
- await this.treesDB.padTree(treeId, leavesToInsert);
384
- }
385
- async getTreeSnapshots() {
386
- return await this.treesDB.getTreeSnapshots();
387
- }
388
- }
389
- function contractAddressIsCanonical(contractAddress) {
390
- return contractAddress.equals(AztecAddress.fromNumber(CANONICAL_AUTH_REGISTRY_ADDRESS)) || contractAddress.equals(AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS)) || contractAddress.equals(AztecAddress.fromNumber(CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS)) || contractAddress.equals(AztecAddress.fromNumber(MULTI_CALL_ENTRYPOINT_ADDRESS)) || contractAddress.equals(AztecAddress.fromNumber(FEE_JUICE_ADDRESS)) || contractAddress.equals(AztecAddress.fromNumber(ROUTER_ADDRESS));
391
- }
@@ -1,41 +0,0 @@
1
- import type { Fr } from '@aztec/foundation/fields';
2
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
- import type { ContractClassPublic, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
4
- /**
5
- * A cache for contract classes and instances for a single transaction.
6
- * Useful for tracking/retrieving contracts for a tx while leaving
7
- * the option to clear them if the tx is reverted.
8
- */
9
- export declare class TxContractCache {
10
- private instanceCache;
11
- private classCache;
12
- /**
13
- * Add a contract instance to the cache
14
- */
15
- addInstance(address: AztecAddress, instance: ContractInstanceWithAddress): void;
16
- /**
17
- * Add a contract class to the cache
18
- */
19
- addClass(classId: Fr, contractClass: ContractClassPublic): void;
20
- /**
21
- * Get a contract instance from the cache
22
- */
23
- getInstance(address: AztecAddress): ContractInstanceWithAddress | undefined;
24
- /**
25
- * Get a contract class from the cache
26
- */
27
- getClass(classId: Fr): ContractClassPublic | undefined;
28
- /**
29
- * Check if the cache has a contract class
30
- */
31
- hasClass(classId: Fr): boolean;
32
- /**
33
- * Clear all entries from the cache
34
- */
35
- clear(): void;
36
- /**
37
- * Merge another cache into this one
38
- */
39
- mergeFrom(other: TxContractCache): void;
40
- }
41
- //# sourceMappingURL=tx_contract_cache.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tx_contract_cache.d.ts","sourceRoot":"","sources":["../../src/public/tx_contract_cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE/F;;;;GAIG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,aAAa,CAAkD;IACvE,OAAO,CAAC,UAAU,CAA0C;IAE5D;;OAEG;IACI,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,2BAA2B,GAAG,IAAI;IAItF;;OAEG;IACI,QAAQ,CAAC,OAAO,EAAE,EAAE,EAAE,aAAa,EAAE,mBAAmB,GAAG,IAAI;IAItE;;OAEG;IACI,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,2BAA2B,GAAG,SAAS;IAIlF;;OAEG;IACI,QAAQ,CAAC,OAAO,EAAE,EAAE,GAAG,mBAAmB,GAAG,SAAS;IAI7D;;OAEG;IACI,QAAQ,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO;IAIrC;;OAEG;IACI,KAAK,IAAI,IAAI;IAKpB;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI;CAS/C"}
@@ -1,49 +0,0 @@
1
- /**
2
- * A cache for contract classes and instances for a single transaction.
3
- * Useful for tracking/retrieving contracts for a tx while leaving
4
- * the option to clear them if the tx is reverted.
5
- */ export class TxContractCache {
6
- instanceCache = new Map();
7
- classCache = new Map();
8
- /**
9
- * Add a contract instance to the cache
10
- */ addInstance(address, instance) {
11
- this.instanceCache.set(address.toString(), instance);
12
- }
13
- /**
14
- * Add a contract class to the cache
15
- */ addClass(classId, contractClass) {
16
- this.classCache.set(classId.toString(), contractClass);
17
- }
18
- /**
19
- * Get a contract instance from the cache
20
- */ getInstance(address) {
21
- return this.instanceCache.get(address.toString());
22
- }
23
- /**
24
- * Get a contract class from the cache
25
- */ getClass(classId) {
26
- return this.classCache.get(classId.toString());
27
- }
28
- /**
29
- * Check if the cache has a contract class
30
- */ hasClass(classId) {
31
- return this.classCache.has(classId.toString());
32
- }
33
- /**
34
- * Clear all entries from the cache
35
- */ clear() {
36
- this.instanceCache.clear();
37
- this.classCache.clear();
38
- }
39
- /**
40
- * Merge another cache into this one
41
- */ mergeFrom(other) {
42
- other.instanceCache.forEach((value, key)=>{
43
- this.instanceCache.set(key, value);
44
- });
45
- other.classCache.forEach((value, key)=>{
46
- this.classCache.set(key, value);
47
- });
48
- }
49
- }