@aztec/simulator 6.0.0-nightly.20260604 → 6.0.0-nightly.20260721

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 (349) hide show
  1. package/dest/client.d.ts +1 -3
  2. package/dest/client.d.ts.map +1 -1
  3. package/dest/client.js +0 -2
  4. package/dest/private/circuit_recording/circuit_recorder.d.ts +36 -23
  5. package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -1
  6. package/dest/private/circuit_recording/circuit_recorder.js +65 -69
  7. package/dest/private/circuit_recording/file_circuit_recorder.d.ts +7 -19
  8. package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
  9. package/dest/private/circuit_recording/file_circuit_recorder.js +38 -42
  10. package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts +1 -1
  11. package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts.map +1 -1
  12. package/dest/private/circuit_recording/simulator_recorder_wrapper.js +11 -14
  13. package/dest/public/avm/testing/account_proof_fetcher.d.ts +2 -0
  14. package/dest/public/avm/testing/account_proof_fetcher.d.ts.map +1 -0
  15. package/dest/public/avm/{fixtures → testing}/base_avm_simulation_tester.d.ts +1 -1
  16. package/dest/public/avm/testing/base_avm_simulation_tester.d.ts.map +1 -0
  17. package/dest/public/avm/{fixtures → testing}/base_avm_simulation_tester.js +1 -1
  18. package/dest/public/avm/testing/utils.d.ts +32 -0
  19. package/dest/public/avm/testing/utils.d.ts.map +1 -0
  20. package/dest/public/avm/{fixtures → testing}/utils.js +1 -34
  21. package/dest/public/avm_simulator.d.ts +28 -0
  22. package/dest/public/avm_simulator.d.ts.map +1 -0
  23. package/dest/public/avm_simulator.js +4 -0
  24. package/dest/public/avm_simulator_pool.d.ts +45 -0
  25. package/dest/public/avm_simulator_pool.d.ts.map +1 -0
  26. package/dest/public/avm_simulator_pool.js +197 -0
  27. package/dest/public/cdb/generated/api_types.d.ts +171 -0
  28. package/dest/public/cdb/generated/api_types.d.ts.map +1 -0
  29. package/dest/public/cdb/generated/api_types.js +314 -0
  30. package/dest/public/cdb/generated/server.d.ts +26 -0
  31. package/dest/public/cdb/generated/server.d.ts.map +1 -0
  32. package/dest/public/cdb/generated/server.js +135 -0
  33. package/dest/public/cdb_ipc_server.d.ts +33 -0
  34. package/dest/public/cdb_ipc_server.d.ts.map +1 -0
  35. package/dest/public/cdb_ipc_server.js +153 -0
  36. package/dest/public/fixtures/amm_test.js +2 -2
  37. package/dest/public/fixtures/bulk_test.js +2 -2
  38. package/dest/public/fixtures/custom_bytecode_tester.d.ts +1 -1
  39. package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -1
  40. package/dest/public/fixtures/custom_bytecode_tester.js +2 -2
  41. package/dest/public/fixtures/index.d.ts +2 -4
  42. package/dest/public/fixtures/index.d.ts.map +1 -1
  43. package/dest/public/fixtures/index.js +1 -3
  44. package/dest/public/fixtures/public_processor_test_env.d.ts +30 -0
  45. package/dest/public/fixtures/public_processor_test_env.d.ts.map +1 -0
  46. package/dest/public/fixtures/public_processor_test_env.js +73 -0
  47. package/dest/public/fixtures/public_tx_simulation_tester.d.ts +11 -7
  48. package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
  49. package/dest/public/fixtures/public_tx_simulation_tester.js +33 -43
  50. package/dest/public/fixtures/simple_contract_data_source.js +1 -1
  51. package/dest/public/fixtures/token_test.js +3 -3
  52. package/dest/public/fixtures/utils.d.ts +1 -1
  53. package/dest/public/fixtures/utils.d.ts.map +1 -1
  54. package/dest/public/fixtures/utils.js +5 -3
  55. package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts +11 -4
  56. package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts.map +1 -1
  57. package/dest/public/fuzzing/avm_fuzzer_simulator.js +24 -10
  58. package/dest/public/fuzzing/avm_simulator_bin.js +4 -4
  59. package/dest/public/index.d.ts +5 -2
  60. package/dest/public/index.d.ts.map +1 -1
  61. package/dest/public/index.js +2 -1
  62. package/dest/public/public_db_sources.d.ts +2 -2
  63. package/dest/public/public_db_sources.d.ts.map +1 -1
  64. package/dest/public/public_db_sources.js +1 -1
  65. package/dest/public/public_processor/guarded_merkle_tree.d.ts +4 -3
  66. package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
  67. package/dest/public/public_processor/guarded_merkle_tree.js +3 -0
  68. package/dest/public/public_processor/public_processor.d.ts +8 -4
  69. package/dest/public/public_processor/public_processor.d.ts.map +1 -1
  70. package/dest/public/public_processor/public_processor.js +18 -14
  71. package/dest/public/public_tx_simulator/dumping_public_tx_simulator.d.ts +17 -0
  72. package/dest/public/public_tx_simulator/dumping_public_tx_simulator.d.ts.map +1 -0
  73. package/dest/public/public_tx_simulator/{dumping_cpp_public_tx_simulator.js → dumping_public_tx_simulator.js} +10 -23
  74. package/dest/public/public_tx_simulator/factories.d.ts +8 -8
  75. package/dest/public/public_tx_simulator/factories.d.ts.map +1 -1
  76. package/dest/public/public_tx_simulator/factories.js +8 -8
  77. package/dest/public/public_tx_simulator/index.d.ts +4 -6
  78. package/dest/public/public_tx_simulator/index.d.ts.map +1 -1
  79. package/dest/public/public_tx_simulator/index.js +2 -4
  80. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +42 -75
  81. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
  82. package/dest/public/public_tx_simulator/public_tx_simulator.js +98 -323
  83. package/dest/public/public_tx_simulator/public_tx_simulator_base.d.ts +24 -0
  84. package/dest/public/public_tx_simulator/public_tx_simulator_base.d.ts.map +1 -0
  85. package/dest/public/public_tx_simulator/public_tx_simulator_base.js +31 -0
  86. package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts +5 -5
  87. package/dest/public/test_executor_metrics.d.ts +1 -6
  88. package/dest/public/test_executor_metrics.d.ts.map +1 -1
  89. package/dest/public/test_executor_metrics.js +0 -22
  90. package/package.json +22 -19
  91. package/src/client.ts +0 -2
  92. package/src/private/circuit_recording/circuit_recorder.ts +84 -78
  93. package/src/private/circuit_recording/file_circuit_recorder.ts +38 -48
  94. package/src/private/circuit_recording/simulator_recorder_wrapper.ts +9 -15
  95. package/src/public/avm/{fixtures → testing}/base_avm_simulation_tester.ts +1 -1
  96. package/src/public/avm/{fixtures → testing}/utils.ts +1 -40
  97. package/src/public/avm_simulator.ts +29 -0
  98. package/src/public/avm_simulator_pool.ts +226 -0
  99. package/src/public/cdb/generated/api_types.ts +457 -0
  100. package/src/public/cdb/generated/server.ts +109 -0
  101. package/src/public/cdb_ipc_server.ts +197 -0
  102. package/src/public/fixtures/amm_test.ts +2 -2
  103. package/src/public/fixtures/bulk_test.ts +2 -2
  104. package/src/public/fixtures/custom_bytecode_tester.ts +2 -2
  105. package/src/public/fixtures/index.ts +1 -3
  106. package/src/public/fixtures/public_processor_test_env.ts +88 -0
  107. package/src/public/fixtures/public_tx_simulation_tester.ts +41 -55
  108. package/src/public/fixtures/simple_contract_data_source.ts +1 -1
  109. package/src/public/fixtures/token_test.ts +3 -3
  110. package/src/public/fixtures/utils.ts +6 -11
  111. package/src/public/fuzzing/avm_fuzzer_simulator.ts +25 -10
  112. package/src/public/fuzzing/avm_simulator_bin.ts +3 -5
  113. package/src/public/index.ts +7 -3
  114. package/src/public/public_db_sources.ts +1 -1
  115. package/src/public/public_processor/guarded_merkle_tree.ts +5 -2
  116. package/src/public/public_processor/public_processor.ts +24 -17
  117. package/src/public/public_tx_simulator/{dumping_cpp_public_tx_simulator.ts → dumping_public_tx_simulator.ts} +15 -31
  118. package/src/public/public_tx_simulator/factories.ts +27 -10
  119. package/src/public/public_tx_simulator/index.ts +6 -5
  120. package/src/public/public_tx_simulator/public_tx_simulator.ts +139 -480
  121. package/src/public/public_tx_simulator/public_tx_simulator_base.ts +37 -0
  122. package/src/public/public_tx_simulator/public_tx_simulator_interface.ts +5 -5
  123. package/src/public/test_executor_metrics.ts +0 -24
  124. package/dest/public/avm/avm_context.d.ts +0 -41
  125. package/dest/public/avm/avm_context.d.ts.map +0 -1
  126. package/dest/public/avm/avm_context.js +0 -44
  127. package/dest/public/avm/avm_contract_call_result.d.ts +0 -32
  128. package/dest/public/avm/avm_contract_call_result.d.ts.map +0 -1
  129. package/dest/public/avm/avm_contract_call_result.js +0 -54
  130. package/dest/public/avm/avm_execution_environment.d.ts +0 -24
  131. package/dest/public/avm/avm_execution_environment.d.ts.map +0 -1
  132. package/dest/public/avm/avm_execution_environment.js +0 -33
  133. package/dest/public/avm/avm_gas.d.ts +0 -44
  134. package/dest/public/avm/avm_gas.d.ts.map +0 -1
  135. package/dest/public/avm/avm_gas.js +0 -195
  136. package/dest/public/avm/avm_machine_state.d.ts +0 -98
  137. package/dest/public/avm/avm_machine_state.d.ts.map +0 -1
  138. package/dest/public/avm/avm_machine_state.js +0 -110
  139. package/dest/public/avm/avm_memory_types.d.ts +0 -275
  140. package/dest/public/avm/avm_memory_types.d.ts.map +0 -1
  141. package/dest/public/avm/avm_memory_types.js +0 -354
  142. package/dest/public/avm/avm_simulator.d.ts +0 -41
  143. package/dest/public/avm/avm_simulator.d.ts.map +0 -1
  144. package/dest/public/avm/avm_simulator.js +0 -192
  145. package/dest/public/avm/avm_simulator_interface.d.ts +0 -9
  146. package/dest/public/avm/avm_simulator_interface.d.ts.map +0 -1
  147. package/dest/public/avm/avm_simulator_interface.js +0 -3
  148. package/dest/public/avm/calldata.d.ts +0 -51
  149. package/dest/public/avm/calldata.d.ts.map +0 -1
  150. package/dest/public/avm/calldata.js +0 -64
  151. package/dest/public/avm/errors.d.ts +0 -104
  152. package/dest/public/avm/errors.d.ts.map +0 -1
  153. package/dest/public/avm/errors.js +0 -141
  154. package/dest/public/avm/fixtures/account_proof_fetcher.d.ts +0 -2
  155. package/dest/public/avm/fixtures/account_proof_fetcher.d.ts.map +0 -1
  156. package/dest/public/avm/fixtures/avm_simulation_tester.d.ts +0 -22
  157. package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +0 -1
  158. package/dest/public/avm/fixtures/avm_simulation_tester.js +0 -84
  159. package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +0 -1
  160. package/dest/public/avm/fixtures/initializers.d.ts +0 -42
  161. package/dest/public/avm/fixtures/initializers.d.ts.map +0 -1
  162. package/dest/public/avm/fixtures/initializers.js +0 -45
  163. package/dest/public/avm/fixtures/utils.d.ts +0 -39
  164. package/dest/public/avm/fixtures/utils.d.ts.map +0 -1
  165. package/dest/public/avm/index.d.ts +0 -2
  166. package/dest/public/avm/index.d.ts.map +0 -1
  167. package/dest/public/avm/index.js +0 -1
  168. package/dest/public/avm/opcodes/accrued_substate.d.ts +0 -74
  169. package/dest/public/avm/opcodes/accrued_substate.d.ts.map +0 -1
  170. package/dest/public/avm/opcodes/accrued_substate.js +0 -254
  171. package/dest/public/avm/opcodes/addressing_mode.d.ts +0 -31
  172. package/dest/public/avm/opcodes/addressing_mode.d.ts.map +0 -1
  173. package/dest/public/avm/opcodes/addressing_mode.js +0 -94
  174. package/dest/public/avm/opcodes/arithmetic.d.ts +0 -49
  175. package/dest/public/avm/opcodes/arithmetic.d.ts.map +0 -1
  176. package/dest/public/avm/opcodes/arithmetic.js +0 -97
  177. package/dest/public/avm/opcodes/bitwise.d.ts +0 -42
  178. package/dest/public/avm/opcodes/bitwise.d.ts.map +0 -1
  179. package/dest/public/avm/opcodes/bitwise.js +0 -99
  180. package/dest/public/avm/opcodes/comparators.d.ts +0 -25
  181. package/dest/public/avm/opcodes/comparators.d.ts.map +0 -1
  182. package/dest/public/avm/opcodes/comparators.js +0 -43
  183. package/dest/public/avm/opcodes/contract.d.ts +0 -21
  184. package/dest/public/avm/opcodes/contract.d.ts.map +0 -1
  185. package/dest/public/avm/opcodes/contract.js +0 -69
  186. package/dest/public/avm/opcodes/control_flow.d.ts +0 -41
  187. package/dest/public/avm/opcodes/control_flow.d.ts.map +0 -1
  188. package/dest/public/avm/opcodes/control_flow.js +0 -107
  189. package/dest/public/avm/opcodes/conversion.d.ts +0 -18
  190. package/dest/public/avm/opcodes/conversion.d.ts.map +0 -1
  191. package/dest/public/avm/opcodes/conversion.js +0 -333
  192. package/dest/public/avm/opcodes/ec_add.d.ts +0 -17
  193. package/dest/public/avm/opcodes/ec_add.d.ts.map +0 -1
  194. package/dest/public/avm/opcodes/ec_add.js +0 -79
  195. package/dest/public/avm/opcodes/environment_getters.d.ts +0 -28
  196. package/dest/public/avm/opcodes/environment_getters.d.ts.map +0 -1
  197. package/dest/public/avm/opcodes/environment_getters.js +0 -77
  198. package/dest/public/avm/opcodes/external_calls.d.ts +0 -59
  199. package/dest/public/avm/opcodes/external_calls.d.ts.map +0 -1
  200. package/dest/public/avm/opcodes/external_calls.js +0 -210
  201. package/dest/public/avm/opcodes/hashing.d.ts +0 -36
  202. package/dest/public/avm/opcodes/hashing.d.ts.map +0 -1
  203. package/dest/public/avm/opcodes/hashing.js +0 -119
  204. package/dest/public/avm/opcodes/index.d.ts +0 -16
  205. package/dest/public/avm/opcodes/index.d.ts.map +0 -1
  206. package/dest/public/avm/opcodes/index.js +0 -15
  207. package/dest/public/avm/opcodes/instruction.d.ts +0 -74
  208. package/dest/public/avm/opcodes/instruction.d.ts.map +0 -1
  209. package/dest/public/avm/opcodes/instruction.js +0 -95
  210. package/dest/public/avm/opcodes/instruction_impl.d.ts +0 -19
  211. package/dest/public/avm/opcodes/instruction_impl.d.ts.map +0 -1
  212. package/dest/public/avm/opcodes/instruction_impl.js +0 -30
  213. package/dest/public/avm/opcodes/memory.d.ts +0 -74
  214. package/dest/public/avm/opcodes/memory.d.ts.map +0 -1
  215. package/dest/public/avm/opcodes/memory.js +0 -257
  216. package/dest/public/avm/opcodes/misc.d.ts +0 -18
  217. package/dest/public/avm/opcodes/misc.d.ts.map +0 -1
  218. package/dest/public/avm/opcodes/misc.js +0 -73
  219. package/dest/public/avm/opcodes/storage.d.ts +0 -25
  220. package/dest/public/avm/opcodes/storage.d.ts.map +0 -1
  221. package/dest/public/avm/opcodes/storage.js +0 -78
  222. package/dest/public/avm/revert_reason.d.ts +0 -18
  223. package/dest/public/avm/revert_reason.d.ts.map +0 -1
  224. package/dest/public/avm/revert_reason.js +0 -39
  225. package/dest/public/avm/serialization/buffer_cursor.d.ts +0 -26
  226. package/dest/public/avm/serialization/buffer_cursor.d.ts.map +0 -1
  227. package/dest/public/avm/serialization/buffer_cursor.js +0 -99
  228. package/dest/public/avm/serialization/bytecode_serialization.d.ts +0 -17
  229. package/dest/public/avm/serialization/bytecode_serialization.d.ts.map +0 -1
  230. package/dest/public/avm/serialization/bytecode_serialization.js +0 -336
  231. package/dest/public/avm/serialization/instruction_serialization.d.ts +0 -114
  232. package/dest/public/avm/serialization/instruction_serialization.d.ts.map +0 -1
  233. package/dest/public/avm/serialization/instruction_serialization.js +0 -261
  234. package/dest/public/avm/test_utils.d.ts +0 -15
  235. package/dest/public/avm/test_utils.d.ts.map +0 -1
  236. package/dest/public/avm/test_utils.js +0 -44
  237. package/dest/public/debug_fn_name.d.ts +0 -18
  238. package/dest/public/debug_fn_name.d.ts.map +0 -1
  239. package/dest/public/debug_fn_name.js +0 -37
  240. package/dest/public/fixtures/custom_bytecode_tests.d.ts +0 -14
  241. package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +0 -1
  242. package/dest/public/fixtures/custom_bytecode_tests.js +0 -234
  243. package/dest/public/fixtures/minimal_public_tx.d.ts +0 -4
  244. package/dest/public/fixtures/minimal_public_tx.d.ts.map +0 -1
  245. package/dest/public/fixtures/minimal_public_tx.js +0 -19
  246. package/dest/public/fixtures/opcode_spammer.d.ts +0 -122
  247. package/dest/public/fixtures/opcode_spammer.d.ts.map +0 -1
  248. package/dest/public/fixtures/opcode_spammer.js +0 -1645
  249. package/dest/public/hinting_db_sources.d.ts +0 -80
  250. package/dest/public/hinting_db_sources.d.ts.map +0 -1
  251. package/dest/public/hinting_db_sources.js +0 -356
  252. package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +0 -19
  253. package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +0 -1
  254. package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +0 -99
  255. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +0 -53
  256. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +0 -1
  257. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +0 -131
  258. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts +0 -42
  259. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts.map +0 -1
  260. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.js +0 -86
  261. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts +0 -30
  262. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts.map +0 -1
  263. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.js +0 -171
  264. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts +0 -23
  265. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts.map +0 -1
  266. package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +0 -31
  267. package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts.map +0 -1
  268. package/dest/public/public_tx_simulator/measured_public_tx_simulator.js +0 -51
  269. package/dest/public/public_tx_simulator/public_tx_context.d.ts +0 -135
  270. package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +0 -1
  271. package/dest/public/public_tx_simulator/public_tx_context.js +0 -298
  272. package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts +0 -21
  273. package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts.map +0 -1
  274. package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.js +0 -415
  275. package/dest/public/side_effect_trace.d.ts +0 -87
  276. package/dest/public/side_effect_trace.d.ts.map +0 -1
  277. package/dest/public/side_effect_trace.js +0 -199
  278. package/dest/public/side_effect_trace_interface.d.ts +0 -22
  279. package/dest/public/side_effect_trace_interface.d.ts.map +0 -1
  280. package/dest/public/side_effect_trace_interface.js +0 -1
  281. package/dest/public/state_manager/index.d.ts +0 -2
  282. package/dest/public/state_manager/index.d.ts.map +0 -1
  283. package/dest/public/state_manager/index.js +0 -1
  284. package/dest/public/state_manager/nullifiers.d.ts +0 -61
  285. package/dest/public/state_manager/nullifiers.d.ts.map +0 -1
  286. package/dest/public/state_manager/nullifiers.js +0 -92
  287. package/dest/public/state_manager/public_storage.d.ts +0 -66
  288. package/dest/public/state_manager/public_storage.d.ts.map +0 -1
  289. package/dest/public/state_manager/public_storage.js +0 -145
  290. package/dest/public/state_manager/state_manager.d.ts +0 -170
  291. package/dest/public/state_manager/state_manager.d.ts.map +0 -1
  292. package/dest/public/state_manager/state_manager.js +0 -402
  293. package/src/public/avm/avm_context.ts +0 -61
  294. package/src/public/avm/avm_contract_call_result.ts +0 -69
  295. package/src/public/avm/avm_execution_environment.ts +0 -51
  296. package/src/public/avm/avm_gas.ts +0 -183
  297. package/src/public/avm/avm_machine_state.ts +0 -170
  298. package/src/public/avm/avm_memory_types.ts +0 -440
  299. package/src/public/avm/avm_simulator.ts +0 -279
  300. package/src/public/avm/avm_simulator_interface.ts +0 -8
  301. package/src/public/avm/calldata.ts +0 -101
  302. package/src/public/avm/errors.ts +0 -177
  303. package/src/public/avm/fixtures/avm_simulation_tester.ts +0 -122
  304. package/src/public/avm/fixtures/initializers.ts +0 -103
  305. package/src/public/avm/index.ts +0 -1
  306. package/src/public/avm/opcodes/accrued_substate.ts +0 -285
  307. package/src/public/avm/opcodes/addressing_mode.ts +0 -111
  308. package/src/public/avm/opcodes/arithmetic.ts +0 -129
  309. package/src/public/avm/opcodes/bitwise.ts +0 -113
  310. package/src/public/avm/opcodes/comparators.ts +0 -55
  311. package/src/public/avm/opcodes/contract.ts +0 -76
  312. package/src/public/avm/opcodes/control_flow.ts +0 -123
  313. package/src/public/avm/opcodes/conversion.ts +0 -104
  314. package/src/public/avm/opcodes/ec_add.ts +0 -86
  315. package/src/public/avm/opcodes/environment_getters.ts +0 -87
  316. package/src/public/avm/opcodes/external_calls.ts +0 -262
  317. package/src/public/avm/opcodes/hashing.ts +0 -151
  318. package/src/public/avm/opcodes/index.ts +0 -15
  319. package/src/public/avm/opcodes/instruction.ts +0 -136
  320. package/src/public/avm/opcodes/instruction_impl.ts +0 -36
  321. package/src/public/avm/opcodes/memory.ts +0 -293
  322. package/src/public/avm/opcodes/misc.ts +0 -102
  323. package/src/public/avm/opcodes/storage.ts +0 -95
  324. package/src/public/avm/revert_reason.ts +0 -58
  325. package/src/public/avm/serialization/buffer_cursor.ts +0 -118
  326. package/src/public/avm/serialization/bytecode_serialization.ts +0 -215
  327. package/src/public/avm/serialization/instruction_serialization.ts +0 -249
  328. package/src/public/avm/test_utils.ts +0 -64
  329. package/src/public/debug_fn_name.ts +0 -52
  330. package/src/public/fixtures/custom_bytecode_tests.ts +0 -366
  331. package/src/public/fixtures/minimal_public_tx.ts +0 -26
  332. package/src/public/fixtures/opcode_spammer.ts +0 -1713
  333. package/src/public/hinting_db_sources.ts +0 -610
  334. package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +0 -125
  335. package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +0 -210
  336. package/src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts +0 -134
  337. package/src/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.ts +0 -239
  338. package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +0 -105
  339. package/src/public/public_tx_simulator/public_tx_context.ts +0 -482
  340. package/src/public/public_tx_simulator/telemetry_public_tx_simulator.ts +0 -63
  341. package/src/public/side_effect_trace.ts +0 -293
  342. package/src/public/side_effect_trace_interface.ts +0 -28
  343. package/src/public/state_manager/index.ts +0 -1
  344. package/src/public/state_manager/nullifiers.ts +0 -103
  345. package/src/public/state_manager/public_storage.ts +0 -174
  346. package/src/public/state_manager/state_manager.ts +0 -569
  347. /package/dest/public/avm/{fixtures → testing}/account_proof_fetcher.js +0 -0
  348. /package/src/public/avm/{fixtures → testing}/account_proof.json +0 -0
  349. /package/src/public/avm/{fixtures → testing}/account_proof_fetcher.ts +0 -0
@@ -1,261 +0,0 @@
1
- import { Fr } from '@aztec/foundation/curves/bn254';
2
- import { strict as assert } from 'assert';
3
- import { TaggedMemory } from '../avm_memory_types.js';
4
- import { BufferCursor } from './buffer_cursor.js';
5
- /**
6
- * All AVM opcodes. (Keep in sync with cpp counterpart code avm_opcode.hpp and rs in opcodes.rs).
7
- * Source: https://yp-aztec.netlify.app/docs/public-vm/instruction-set
8
- */ export var Opcode = /*#__PURE__*/ function(Opcode) {
9
- // Compute
10
- Opcode[Opcode["ADD_8"] = 0] = "ADD_8";
11
- Opcode[Opcode["ADD_16"] = 1] = "ADD_16";
12
- Opcode[Opcode["SUB_8"] = 2] = "SUB_8";
13
- Opcode[Opcode["SUB_16"] = 3] = "SUB_16";
14
- Opcode[Opcode["MUL_8"] = 4] = "MUL_8";
15
- Opcode[Opcode["MUL_16"] = 5] = "MUL_16";
16
- Opcode[Opcode["DIV_8"] = 6] = "DIV_8";
17
- Opcode[Opcode["DIV_16"] = 7] = "DIV_16";
18
- Opcode[Opcode["FDIV_8"] = 8] = "FDIV_8";
19
- Opcode[Opcode["FDIV_16"] = 9] = "FDIV_16";
20
- Opcode[Opcode["EQ_8"] = 10] = "EQ_8";
21
- Opcode[Opcode["EQ_16"] = 11] = "EQ_16";
22
- Opcode[Opcode["LT_8"] = 12] = "LT_8";
23
- Opcode[Opcode["LT_16"] = 13] = "LT_16";
24
- Opcode[Opcode["LTE_8"] = 14] = "LTE_8";
25
- Opcode[Opcode["LTE_16"] = 15] = "LTE_16";
26
- Opcode[Opcode["AND_8"] = 16] = "AND_8";
27
- Opcode[Opcode["AND_16"] = 17] = "AND_16";
28
- Opcode[Opcode["OR_8"] = 18] = "OR_8";
29
- Opcode[Opcode["OR_16"] = 19] = "OR_16";
30
- Opcode[Opcode["XOR_8"] = 20] = "XOR_8";
31
- Opcode[Opcode["XOR_16"] = 21] = "XOR_16";
32
- Opcode[Opcode["NOT_8"] = 22] = "NOT_8";
33
- Opcode[Opcode["NOT_16"] = 23] = "NOT_16";
34
- Opcode[Opcode["SHL_8"] = 24] = "SHL_8";
35
- Opcode[Opcode["SHL_16"] = 25] = "SHL_16";
36
- Opcode[Opcode["SHR_8"] = 26] = "SHR_8";
37
- Opcode[Opcode["SHR_16"] = 27] = "SHR_16";
38
- Opcode[Opcode["CAST_8"] = 28] = "CAST_8";
39
- Opcode[Opcode["CAST_16"] = 29] = "CAST_16";
40
- // Execution environment
41
- Opcode[Opcode["GETENVVAR_16"] = 30] = "GETENVVAR_16";
42
- Opcode[Opcode["CALLDATACOPY"] = 31] = "CALLDATACOPY";
43
- Opcode[Opcode["SUCCESSCOPY"] = 32] = "SUCCESSCOPY";
44
- Opcode[Opcode["RETURNDATASIZE"] = 33] = "RETURNDATASIZE";
45
- Opcode[Opcode["RETURNDATACOPY"] = 34] = "RETURNDATACOPY";
46
- // Control flow
47
- Opcode[Opcode["JUMP_32"] = 35] = "JUMP_32";
48
- Opcode[Opcode["JUMPI_32"] = 36] = "JUMPI_32";
49
- Opcode[Opcode["INTERNALCALL"] = 37] = "INTERNALCALL";
50
- Opcode[Opcode["INTERNALRETURN"] = 38] = "INTERNALRETURN";
51
- // Memory
52
- Opcode[Opcode["SET_8"] = 39] = "SET_8";
53
- Opcode[Opcode["SET_16"] = 40] = "SET_16";
54
- Opcode[Opcode["SET_32"] = 41] = "SET_32";
55
- Opcode[Opcode["SET_64"] = 42] = "SET_64";
56
- Opcode[Opcode["SET_128"] = 43] = "SET_128";
57
- Opcode[Opcode["SET_FF"] = 44] = "SET_FF";
58
- Opcode[Opcode["MOV_8"] = 45] = "MOV_8";
59
- Opcode[Opcode["MOV_16"] = 46] = "MOV_16";
60
- // World state
61
- Opcode[Opcode["SLOAD"] = 47] = "SLOAD";
62
- Opcode[Opcode["SSTORE"] = 48] = "SSTORE";
63
- Opcode[Opcode["NOTEHASHEXISTS"] = 49] = "NOTEHASHEXISTS";
64
- Opcode[Opcode["EMITNOTEHASH"] = 50] = "EMITNOTEHASH";
65
- Opcode[Opcode["NULLIFIEREXISTS"] = 51] = "NULLIFIEREXISTS";
66
- Opcode[Opcode["EMITNULLIFIER"] = 52] = "EMITNULLIFIER";
67
- Opcode[Opcode["L1TOL2MSGEXISTS"] = 53] = "L1TOL2MSGEXISTS";
68
- Opcode[Opcode["GETCONTRACTINSTANCE"] = 54] = "GETCONTRACTINSTANCE";
69
- Opcode[Opcode["EMITPUBLICLOG"] = 55] = "EMITPUBLICLOG";
70
- Opcode[Opcode["SENDL2TOL1MSG"] = 56] = "SENDL2TOL1MSG";
71
- // External calls
72
- Opcode[Opcode["CALL"] = 57] = "CALL";
73
- Opcode[Opcode["STATICCALL"] = 58] = "STATICCALL";
74
- Opcode[Opcode["RETURN"] = 59] = "RETURN";
75
- Opcode[Opcode["REVERT_8"] = 60] = "REVERT_8";
76
- Opcode[Opcode["REVERT_16"] = 61] = "REVERT_16";
77
- // Misc
78
- Opcode[Opcode["DEBUGLOG"] = 62] = "DEBUGLOG";
79
- // Gadgets
80
- Opcode[Opcode["POSEIDON2"] = 63] = "POSEIDON2";
81
- Opcode[Opcode["SHA256COMPRESSION"] = 64] = "SHA256COMPRESSION";
82
- Opcode[Opcode["KECCAKF1600"] = 65] = "KECCAKF1600";
83
- Opcode[Opcode["ECADD"] = 66] = "ECADD";
84
- // Conversion
85
- Opcode[Opcode["TORADIXBE"] = 67] = "TORADIXBE";
86
- return Opcode;
87
- }({});
88
- export const MAX_OPCODE_VALUE = Math.max(...Object.values(Opcode).map((k)=>+k).filter((k)=>!isNaN(k)));
89
- // Possible types for an instruction's operand in its wire format.
90
- // The counterpart cpp file is: vm2/simulation/lib/serialization.hpp.
91
- export var OperandType = /*#__PURE__*/ function(OperandType) {
92
- OperandType[OperandType["UINT8"] = 0] = "UINT8";
93
- OperandType[OperandType["UINT16"] = 1] = "UINT16";
94
- OperandType[OperandType["UINT32"] = 2] = "UINT32";
95
- OperandType[OperandType["UINT64"] = 3] = "UINT64";
96
- OperandType[OperandType["UINT128"] = 4] = "UINT128";
97
- OperandType[OperandType["FF"] = 5] = "FF";
98
- OperandType[OperandType["TAG"] = 6] = "TAG";
99
- return OperandType;
100
- }({});
101
- // Specifies how to read and write each operand type.
102
- const OPERAND_SPEC = new Map([
103
- [
104
- 0,
105
- [
106
- 1,
107
- Buffer.prototype.readUint8,
108
- Buffer.prototype.writeUint8
109
- ]
110
- ],
111
- [
112
- 1,
113
- [
114
- 2,
115
- Buffer.prototype.readUint16BE,
116
- Buffer.prototype.writeUint16BE
117
- ]
118
- ],
119
- [
120
- 2,
121
- [
122
- 4,
123
- Buffer.prototype.readUint32BE,
124
- Buffer.prototype.writeUint32BE
125
- ]
126
- ],
127
- [
128
- 3,
129
- [
130
- 8,
131
- readUint64BE,
132
- writeUint64BE
133
- ]
134
- ],
135
- [
136
- 4,
137
- [
138
- 16,
139
- readUint128BE,
140
- writeUint128BE
141
- ]
142
- ],
143
- [
144
- 5,
145
- [
146
- 32,
147
- readUint254BE,
148
- writeUint254BE
149
- ]
150
- ],
151
- [
152
- 6,
153
- [
154
- 1,
155
- Buffer.prototype.readUint8,
156
- Buffer.prototype.writeUint8
157
- ]
158
- ]
159
- ]);
160
- /**
161
- * Returns the size of an operand in bytes.
162
- * Should not be called with unknown operand types.
163
- * @param operandType
164
- * @returns number size in bytes
165
- * @throws AssertionError if the operand type is unknown
166
- */ export function getOperandSize(operandType) {
167
- assert(OPERAND_SPEC.has(operandType), `Unknown operand type: ${operandType}`);
168
- return OPERAND_SPEC.get(operandType)[0];
169
- }
170
- function readUintBE(buf, offset, totalBytes) {
171
- let value = 0n;
172
- for(let i = 0; i < totalBytes; ++i){
173
- value <<= 8n;
174
- value |= BigInt(buf.readUint8(i + offset));
175
- }
176
- return value;
177
- }
178
- function writeUintBE(buf, value, totalBytes) {
179
- for(let offset = totalBytes - 1; offset >= 0; --offset){
180
- buf.writeUint8(Number(value & 0xffn), offset);
181
- value >>= 8n;
182
- }
183
- }
184
- function readUint64BE(offset) {
185
- return readUintBE(this, offset, 8);
186
- }
187
- function writeUint64BE(value) {
188
- writeUintBE(this, value, 8);
189
- }
190
- function readUint254BE(offset) {
191
- let value = readUintBE(this, offset, 32);
192
- // In circuit, we only support values up to Fr.MODULUS and any deserialized value
193
- // would naturally undergo a modulus reduction.
194
- if (value >= Fr.MODULUS) {
195
- value = value % Fr.MODULUS;
196
- }
197
- return value;
198
- }
199
- function writeUint254BE(value) {
200
- writeUintBE(this, value, 32);
201
- }
202
- function readUint128BE(offset) {
203
- return readUintBE(this, offset, 16);
204
- }
205
- function writeUint128BE(value) {
206
- writeUintBE(this, value, 16);
207
- }
208
- /**
209
- * Reads an array of operands from a buffer.
210
- * @param cursor Buffer to read from. Might be longer than needed.
211
- * @param operands Specification of the operand types.
212
- * @returns An array as big as {@code operands}, with the converted TS values.
213
- */ export function deserialize(cursor, operands) {
214
- const argValues = [];
215
- if (Buffer.isBuffer(cursor)) {
216
- cursor = new BufferCursor(cursor);
217
- }
218
- for (const opType of operands){
219
- const [sizeBytes, reader, _writer] = OPERAND_SPEC.get(opType);
220
- const value = reader.call(cursor.buffer(), cursor.position());
221
- argValues.push(value);
222
- cursor.advance(sizeBytes);
223
- }
224
- // We first want to detect other parsing errors (e.g., instruction size
225
- // is longer than remaining bytes) first and therefore tag validation is done after completion
226
- // of parsing above. Order of errors need to match with circuit.
227
- for(let i = 0; i < operands.length; i++){
228
- if (operands[i] === 6) {
229
- // We parsed a single byte (readUInt8()) and therefore value is of number type (not bigint)
230
- // We need to cast to number because checkIsValidTag expects a number.
231
- TaggedMemory.checkIsValidTag(Number(argValues[i] ?? 0));
232
- }
233
- }
234
- return argValues;
235
- }
236
- /**
237
- * Serializes a class using the specified operand types.
238
- * More specifically, this serializes {@code [cls.constructor.opcode, ...Object.values(cls)]}.
239
- * Observe in particular that:
240
- * (1) the first operand type specified must correspond to the opcode;
241
- * (2) the rest of the operand types must be specified in the order returned by {@code Object.values()}.
242
- * @param operands Type specification for the values to be serialized.
243
- * @param cls The class to be serialized.
244
- * @returns
245
- */ export function serializeAs(operands, opcode, cls) {
246
- const chunks = [];
247
- const rawClassValues = [
248
- opcode,
249
- ...Object.values(cls)
250
- ];
251
- assert(rawClassValues.length === operands.length, `Got ${rawClassValues.length} values but only ${operands.length} serialization operands are specified!`);
252
- const classValues = rawClassValues;
253
- for(let i = 0; i < operands.length; i++){
254
- const opType = operands[i];
255
- const [sizeBytes, _reader, writer] = OPERAND_SPEC.get(opType);
256
- const buf = Buffer.alloc(sizeBytes);
257
- writer.call(buf, classValues[i]);
258
- chunks.push(buf);
259
- }
260
- return Buffer.concat(chunks);
261
- }
@@ -1,15 +0,0 @@
1
- import { Fr } from '@aztec/foundation/curves/bn254';
2
- import type { ContractClassPublic, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
3
- import type { PublicContractsDB, PublicTreesDB } from '../public_db_sources.js';
4
- import type { PublicSideEffectTraceInterface } from '../side_effect_trace_interface.js';
5
- export declare function mockTraceFork(trace: PublicSideEffectTraceInterface, nestedTrace?: PublicSideEffectTraceInterface): void;
6
- export declare function mockStorageRead(worldStateDB: PublicTreesDB, value: Fr): void;
7
- export declare function mockNoteHashCount(mockedTrace: PublicSideEffectTraceInterface, count: number): void;
8
- export declare function mockStorageReadWithMap(worldStateDB: PublicTreesDB, mockedStorage: Map<bigint, Fr>): void;
9
- export declare function mockGetNoteHash(worldStateDB: PublicTreesDB, _leafIndex: bigint, value?: Fr): void;
10
- export declare function mockCheckNullifierExists(worldStateDB: PublicTreesDB, exists: boolean, _ignoredValue?: Fr): void;
11
- export declare function mockGetL1ToL2LeafValue(worldStateDB: PublicTreesDB, leafIndex: bigint, value?: Fr): void;
12
- export declare function mockGetContractInstance(contractsDB: PublicContractsDB, contractInstance: ContractInstanceWithAddress): void;
13
- export declare function mockGetContractClass(contractsDB: PublicContractsDB, contractClass: ContractClassPublic): void;
14
- export declare function mockGetBytecodeCommitment(contractsDB: PublicContractsDB, commitment: Fr): void;
15
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdF91dGlscy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3B1YmxpYy9hdm0vdGVzdF91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUsvRixPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBRSxhQUFhLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUNoRixPQUFPLEtBQUssRUFBRSw4QkFBOEIsRUFBRSxNQUFNLG1DQUFtQyxDQUFDO0FBRXhGLHdCQUFnQixhQUFhLENBQUMsS0FBSyxFQUFFLDhCQUE4QixFQUFFLFdBQVcsQ0FBQyxFQUFFLDhCQUE4QixRQUloSDtBQUVELHdCQUFnQixlQUFlLENBQUMsWUFBWSxFQUFFLGFBQWEsRUFBRSxLQUFLLEVBQUUsRUFBRSxRQUVyRTtBQUVELHdCQUFnQixpQkFBaUIsQ0FBQyxXQUFXLEVBQUUsOEJBQThCLEVBQUUsS0FBSyxFQUFFLE1BQU0sUUFFM0Y7QUFFRCx3QkFBZ0Isc0JBQXNCLENBQUMsWUFBWSxFQUFFLGFBQWEsRUFBRSxhQUFhLEVBQUUsR0FBRyxDQUFDLE1BQU0sRUFBRSxFQUFFLENBQUMsUUFJakc7QUFFRCx3QkFBZ0IsZUFBZSxDQUFDLFlBQVksRUFBRSxhQUFhLEVBQUUsVUFBVSxFQUFFLE1BQU0sRUFBRSxLQUFLLENBQUMsRUFBRSxFQUFFLFFBUTFGO0FBRUQsd0JBQWdCLHdCQUF3QixDQUFDLFlBQVksRUFBRSxhQUFhLEVBQUUsTUFBTSxFQUFFLE9BQU8sRUFBRSxhQUFhLENBQUMsRUFBRSxFQUFFLFFBRXhHO0FBRUQsd0JBQWdCLHNCQUFzQixDQUFDLFlBQVksRUFBRSxhQUFhLEVBQUUsU0FBUyxFQUFFLE1BQU0sRUFBRSxLQUFLLENBQUMsRUFBRSxFQUFFLFFBUWhHO0FBRUQsd0JBQWdCLHVCQUF1QixDQUFDLFdBQVcsRUFBRSxpQkFBaUIsRUFBRSxnQkFBZ0IsRUFBRSwyQkFBMkIsUUFFcEg7QUFFRCx3QkFBZ0Isb0JBQW9CLENBQUMsV0FBVyxFQUFFLGlCQUFpQixFQUFFLGFBQWEsRUFBRSxtQkFBbUIsUUFFdEc7QUFFRCx3QkFBZ0IseUJBQXlCLENBQUMsV0FBVyxFQUFFLGlCQUFpQixFQUFFLFVBQVUsRUFBRSxFQUFFLFFBRXZGIn0=
@@ -1 +0,0 @@
1
- {"version":3,"file":"test_utils.d.ts","sourceRoot":"","sources":["../../../src/public/avm/test_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAK/F,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AAExF,wBAAgB,aAAa,CAAC,KAAK,EAAE,8BAA8B,EAAE,WAAW,CAAC,EAAE,8BAA8B,QAIhH;AAED,wBAAgB,eAAe,CAAC,YAAY,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE,QAErE;AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,8BAA8B,EAAE,KAAK,EAAE,MAAM,QAE3F;AAED,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,QAIjG;AAED,wBAAgB,eAAe,CAAC,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,QAQ1F;AAED,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,EAAE,QAExG;AAED,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,QAQhG;AAED,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,2BAA2B,QAEpH;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,iBAAiB,EAAE,aAAa,EAAE,mBAAmB,QAEtG;AAED,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,iBAAiB,EAAE,UAAU,EAAE,EAAE,QAEvF"}
@@ -1,44 +0,0 @@
1
- import { Fr } from '@aztec/foundation/curves/bn254';
2
- import { mock } from 'jest-mock-extended';
3
- export function mockTraceFork(trace, nestedTrace) {
4
- trace.fork.mockReturnValue(nestedTrace ?? mock());
5
- }
6
- export function mockStorageRead(worldStateDB, value) {
7
- worldStateDB.storageRead.mockResolvedValue(value);
8
- }
9
- export function mockNoteHashCount(mockedTrace, count) {
10
- mockedTrace.getNoteHashCount.mockReturnValue(count);
11
- }
12
- export function mockStorageReadWithMap(worldStateDB, mockedStorage) {
13
- worldStateDB.storageRead.mockImplementation((_address, slot)=>Promise.resolve(mockedStorage.get(slot.toBigInt()) ?? Fr.ZERO));
14
- }
15
- export function mockGetNoteHash(worldStateDB, _leafIndex, value) {
16
- worldStateDB.getNoteHash.mockImplementation((index)=>{
17
- if (index == _leafIndex && value) {
18
- return Promise.resolve(value);
19
- } else {
20
- return Promise.resolve(Fr.ZERO);
21
- }
22
- });
23
- }
24
- export function mockCheckNullifierExists(worldStateDB, exists, _ignoredValue) {
25
- worldStateDB.checkNullifierExists.mockResolvedValue(exists);
26
- }
27
- export function mockGetL1ToL2LeafValue(worldStateDB, leafIndex, value) {
28
- worldStateDB.getL1ToL2LeafValue.mockImplementation((index)=>{
29
- if (index == leafIndex && value) {
30
- return Promise.resolve(value);
31
- } else {
32
- return Promise.resolve(Fr.ZERO);
33
- }
34
- });
35
- }
36
- export function mockGetContractInstance(contractsDB, contractInstance) {
37
- contractsDB.getContractInstance.mockResolvedValue(contractInstance);
38
- }
39
- export function mockGetContractClass(contractsDB, contractClass) {
40
- contractsDB.getContractClass.mockResolvedValue(contractClass);
41
- }
42
- export function mockGetBytecodeCommitment(contractsDB, commitment) {
43
- contractsDB.getBytecodeCommitment.mockResolvedValue(commitment);
44
- }
@@ -1,18 +0,0 @@
1
- import { FunctionSelector } from '@aztec/stdlib/abi';
2
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
- import type { CallData } from './avm/calldata.js';
4
- import type { PublicContractsDBInterface } from './db_interfaces.js';
5
- export declare function getPublicFunctionDebugName(db: PublicContractsDBInterface, contractAddress: AztecAddress, calldata: CallData): Promise<string>;
6
- /**
7
- * Get the function selector and optional debug name for a public function.
8
- * Returns the selector and name separately, with name only populated if a debug name is available.
9
- * @param db - The contracts database
10
- * @param contractAddress - The contract address
11
- * @param calldata - The calldata (selector is in calldata[0])
12
- * @returns An object with functionSelector (always if calldata[0] exists) and functionName (only if debug name found)
13
- */
14
- export declare function getPublicFunctionSelectorAndName(db: PublicContractsDBInterface, contractAddress: AztecAddress, calldata: CallData): Promise<{
15
- functionSelector?: FunctionSelector;
16
- functionName?: string;
17
- }>;
18
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVidWdfZm5fbmFtZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3B1YmxpYy9kZWJ1Z19mbl9uYW1lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ3JELE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBRWhFLE9BQU8sS0FBSyxFQUFFLFFBQVEsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ2xELE9BQU8sS0FBSyxFQUFFLDBCQUEwQixFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFckUsd0JBQXNCLDBCQUEwQixDQUM5QyxFQUFFLEVBQUUsMEJBQTBCLEVBQzlCLGVBQWUsRUFBRSxZQUFZLEVBQzdCLFFBQVEsRUFBRSxRQUFRLEdBQ2pCLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FZakI7QUFFRDs7Ozs7OztHQU9HO0FBQ0gsd0JBQXNCLGdDQUFnQyxDQUNwRCxFQUFFLEVBQUUsMEJBQTBCLEVBQzlCLGVBQWUsRUFBRSxZQUFZLEVBQzdCLFFBQVEsRUFBRSxRQUFRLEdBQ2pCLE9BQU8sQ0FBQztJQUFFLGdCQUFnQixDQUFDLEVBQUUsZ0JBQWdCLENBQUM7SUFBQyxZQUFZLENBQUMsRUFBRSxNQUFNLENBQUE7Q0FBRSxDQUFDLENBZXpFIn0=
@@ -1 +0,0 @@
1
- {"version":3,"file":"debug_fn_name.d.ts","sourceRoot":"","sources":["../../src/public/debug_fn_name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAErE,wBAAsB,0BAA0B,CAC9C,EAAE,EAAE,0BAA0B,EAC9B,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,MAAM,CAAC,CAYjB;AAED;;;;;;;GAOG;AACH,wBAAsB,gCAAgC,CACpD,EAAE,EAAE,0BAA0B,EAC9B,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC;IAAE,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAezE"}
@@ -1,37 +0,0 @@
1
- import { FunctionSelector } from '@aztec/stdlib/abi';
2
- export async function getPublicFunctionDebugName(db, contractAddress, calldata) {
3
- // Public function is dispatched and therefore the target function is passed in the first argument.
4
- const selectorField = calldata.read(0);
5
- if (!selectorField) {
6
- return `<calldata[0] undefined> (Contract Address: ${contractAddress})`;
7
- }
8
- const fallbackName = `<calldata[0]:${selectorField.toString()}> (Contract Address: ${contractAddress})`;
9
- const selector = FunctionSelector.fromFieldOrUndefined(selectorField);
10
- if (!selector) {
11
- return fallbackName;
12
- }
13
- return await db.getDebugFunctionName(contractAddress, selector) ?? fallbackName;
14
- }
15
- /**
16
- * Get the function selector and optional debug name for a public function.
17
- * Returns the selector and name separately, with name only populated if a debug name is available.
18
- * @param db - The contracts database
19
- * @param contractAddress - The contract address
20
- * @param calldata - The calldata (selector is in calldata[0])
21
- * @returns An object with functionSelector (always if calldata[0] exists) and functionName (only if debug name found)
22
- */ export async function getPublicFunctionSelectorAndName(db, contractAddress, calldata) {
23
- // Public function is dispatched and therefore the target function is passed in the first argument.
24
- const selectorField = calldata.read(0);
25
- if (!selectorField) {
26
- return {};
27
- }
28
- const selector = FunctionSelector.fromFieldOrUndefined(selectorField);
29
- if (!selector) {
30
- return {};
31
- }
32
- const debugName = await db.getDebugFunctionName(contractAddress, selector);
33
- return {
34
- functionSelector: selector,
35
- functionName: debugName ?? undefined
36
- };
37
- }
@@ -1,14 +0,0 @@
1
- import { PublicTxSimulationTester } from './public_tx_simulation_tester.js';
2
- export declare function addressingWithBaseTagIssueTest(isIndirect: boolean, tester: PublicTxSimulationTester): Promise<import("@aztec/stdlib/avm").PublicTxResult>;
3
- export declare function addressingWithIndirectTagIssueTest(tester: PublicTxSimulationTester): Promise<import("@aztec/stdlib/avm").PublicTxResult>;
4
- export declare function addressingWithIndirectThenRelativeTagIssueTest(tester: PublicTxSimulationTester): Promise<import("@aztec/stdlib/avm").PublicTxResult>;
5
- export declare function addressingWithRelativeOverflowAndIndirectTagIssueTest(tester: PublicTxSimulationTester): Promise<import("@aztec/stdlib/avm").PublicTxResult>;
6
- export declare function pcOutOfRangeTest(tester: PublicTxSimulationTester): Promise<import("@aztec/stdlib/avm").PublicTxResult>;
7
- export declare function invalidOpcodeTest(tester: PublicTxSimulationTester): Promise<import("@aztec/stdlib/avm").PublicTxResult>;
8
- export declare function invalidByteTest(tester: PublicTxSimulationTester): Promise<import("@aztec/stdlib/avm").PublicTxResult>;
9
- export declare function instructionTruncatedTest(tester: PublicTxSimulationTester): Promise<import("@aztec/stdlib/avm").PublicTxResult>;
10
- export declare function invalidTagValueTest(tester: PublicTxSimulationTester): Promise<import("@aztec/stdlib/avm").PublicTxResult>;
11
- export declare function invalidTagValueAndInstructionTruncatedTest(tester: PublicTxSimulationTester): Promise<import("@aztec/stdlib/avm").PublicTxResult>;
12
- export declare function setTruncationTest(tester: PublicTxSimulationTester): Promise<import("@aztec/stdlib/avm").PublicTxResult>;
13
- export declare function castTruncationTest(tester: PublicTxSimulationTester): Promise<import("@aztec/stdlib/avm").PublicTxResult>;
14
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3VzdG9tX2J5dGVjb2RlX3Rlc3RzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvcHVibGljL2ZpeHR1cmVzL2N1c3RvbV9ieXRlY29kZV90ZXN0cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFhQSxPQUFPLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSxrQ0FBa0MsQ0FBQztBQUk1RSx3QkFBc0IsOEJBQThCLENBQUMsVUFBVSxFQUFFLE9BQU8sRUFBRSxNQUFNLEVBQUUsd0JBQXdCLHVEQWN6RztBQUtELHdCQUFzQixrQ0FBa0MsQ0FBQyxNQUFNLEVBQUUsd0JBQXdCLHVEQXNCeEY7QUFPRCx3QkFBc0IsOENBQThDLENBQUMsTUFBTSxFQUFFLHdCQUF3Qix1REF3QnBHO0FBT0Qsd0JBQXNCLHFEQUFxRCxDQUFDLE1BQU0sRUFBRSx3QkFBd0IsdURBeUIzRztBQUVELHdCQUFzQixnQkFBZ0IsQ0FBQyxNQUFNLEVBQUUsd0JBQXdCLHVEQVF0RTtBQUVELHdCQUFzQixpQkFBaUIsQ0FBQyxNQUFNLEVBQUUsd0JBQXdCLHVEQWlCdkU7QUFHRCx3QkFBc0IsZUFBZSxDQUFDLE1BQU0sRUFBRSx3QkFBd0IsdURBT3JFO0FBR0Qsd0JBQXNCLHdCQUF3QixDQUFDLE1BQU0sRUFBRSx3QkFBd0IsdURBVTlFO0FBR0Qsd0JBQXNCLG1CQUFtQixDQUFDLE1BQU0sRUFBRSx3QkFBd0IsdURBWXpFO0FBR0Qsd0JBQXNCLDBDQUEwQyxDQUFDLE1BQU0sRUFBRSx3QkFBd0IsdURBaUJoRztBQU1ELHdCQUFzQixpQkFBaUIsQ0FBQyxNQUFNLEVBQUUsd0JBQXdCLHVEQTJEdkU7QUFNRCx3QkFBc0Isa0JBQWtCLENBQUMsTUFBTSxFQUFFLHdCQUF3Qix1REFtRXhFIn0=
@@ -1 +0,0 @@
1
- {"version":3,"file":"custom_bytecode_tests.d.ts","sourceRoot":"","sources":["../../../src/public/fixtures/custom_bytecode_tests.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAI5E,wBAAsB,8BAA8B,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,wBAAwB,uDAczG;AAKD,wBAAsB,kCAAkC,CAAC,MAAM,EAAE,wBAAwB,uDAsBxF;AAOD,wBAAsB,8CAA8C,CAAC,MAAM,EAAE,wBAAwB,uDAwBpG;AAOD,wBAAsB,qDAAqD,CAAC,MAAM,EAAE,wBAAwB,uDAyB3G;AAED,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,wBAAwB,uDAQtE;AAED,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,wBAAwB,uDAiBvE;AAGD,wBAAsB,eAAe,CAAC,MAAM,EAAE,wBAAwB,uDAOrE;AAGD,wBAAsB,wBAAwB,CAAC,MAAM,EAAE,wBAAwB,uDAU9E;AAGD,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,wBAAwB,uDAYzE;AAGD,wBAAsB,0CAA0C,CAAC,MAAM,EAAE,wBAAwB,uDAiBhG;AAMD,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,wBAAwB,uDA2DvE;AAMD,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,uDAmExE"}
@@ -1,234 +0,0 @@
1
- import { strict as assert } from 'assert';
2
- import { TypeTag } from '../avm/avm_memory_types.js';
3
- import { Addressing, AddressingMode } from '../avm/opcodes/addressing_mode.js';
4
- import { Add, CalldataCopy, Cast, Jump, Return, Set } from '../avm/opcodes/index.js';
5
- import { encodeToBytecode } from '../avm/serialization/bytecode_serialization.js';
6
- import { MAX_OPCODE_VALUE, Opcode, OperandType, getOperandSize } from '../avm/serialization/instruction_serialization.js';
7
- import { deployAndExecuteCustomBytecode } from './custom_bytecode_tester.js';
8
- // First instruction resolved a base address (offset 0) which is uninitialized and therefore
9
- // of invalid tag (FF). This will trigger an exceptional halt.
10
- export async function addressingWithBaseTagIssueTest(isIndirect, tester) {
11
- const addressingMode = Addressing.fromModes([
12
- isIndirect ? AddressingMode.INDIRECT_RELATIVE : AddressingMode.RELATIVE,
13
- AddressingMode.DIRECT,
14
- AddressingMode.DIRECT
15
- ]);
16
- const bytecode = encodeToBytecode([
17
- new CalldataCopy(/*addressing_mode=*/ addressingMode.toWire(), /*copySize=*/ 1, /*cdOffset=*/ 0, /*dstOffset=*/ 0),
18
- new Return(/*addressing_mode=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0)
19
- ]);
20
- const txLabel = isIndirect ? 'AddressingWithBaseTagInvalidIndirect' : 'AddressingWithBaseTagInvalidDirect';
21
- return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
22
- }
23
- // First instruction sets a value with tag U64 at offset 0. Then a CalldataCopy instruction
24
- // uses INDIRECT addressing to read from offset 0, which should fail because the value at
25
- // offset 0 has tag U64 (not U32), making it an invalid address tag.
26
- export async function addressingWithIndirectTagIssueTest(tester) {
27
- // Set a U64 value at offset 0 - this will be used as an indirect address
28
- const addressingMode = Addressing.fromModes([
29
- AddressingMode.INDIRECT,
30
- AddressingMode.DIRECT,
31
- AddressingMode.DIRECT
32
- ]);
33
- const bytecode = encodeToBytecode([
34
- // Set a U64 value at offset 0 - this has the wrong tag for an address (should be U32)
35
- new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 0, TypeTag.UINT64, /*value=*/ 100n).as(Opcode.SET_64, Set.wireFormat64),
36
- // Try to use indirect addressing: read from offset 0, which contains a U64 value
37
- // This should fail because U64 is not a valid address tag (must be U32)
38
- new CalldataCopy(/*addressing_mode=*/ addressingMode.toWire(), /*copySize=*/ 1, /*cdOffset=*/ 0, /*dstOffset=*/ 1),
39
- new Return(/*addressing_mode=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0)
40
- ]);
41
- const txLabel = 'AddressingWithIndirectTagInvalid';
42
- return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
43
- }
44
- // First instruction sets a value 10 with tag U32 at offset 1 (direct, no relative).
45
- // Then an ADD_16 instruction uses INDIRECT addressing for the first operand (offset 1)
46
- // and RELATIVE addressing for the second operand (offset 2). The indirect addressing
47
- // succeeds (reads U32 value 10 from offset 1, uses it as address), but the relative
48
- // addressing fails because the base address at offset 0 has the wrong tag (uninitialized/invalid).
49
- export async function addressingWithIndirectThenRelativeTagIssueTest(tester) {
50
- const addressingMode = Addressing.fromModes([
51
- AddressingMode.INDIRECT,
52
- AddressingMode.RELATIVE,
53
- AddressingMode.DIRECT
54
- ]);
55
- const bytecode = encodeToBytecode([
56
- // Set a U32 value 10 at offset 1 - this will be used as an indirect address
57
- new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 1, TypeTag.UINT32, /*value=*/ 10).as(Opcode.SET_32, Set.wireFormat32),
58
- // ADD_16: first operand uses indirect addressing (reads from offset 1, gets value 10, uses as address - succeeds)
59
- // second operand uses relative addressing (tries to read base from offset 0, but offset 0 has wrong tag - fails)
60
- new Add(/*addressing_mode=*/ addressingMode.toWire(), /*aOffset=*/ 1, /*bOffset=*/ 2, /*dstOffset=*/ 3).as(Opcode.ADD_16, Add.wireFormat16),
61
- new Return(/*addressing_mode=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0)
62
- ]);
63
- const txLabel = 'AddressingWithIndirectThenRelativeTagInvalid';
64
- return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
65
- }
66
- // First instruction sets UINT32_MAX at offset 0 (base address) with tag U32.
67
- // Then an ADD_8 instruction uses INDIRECT_RELATIVE addressing for the first operand (offset 1)
68
- // and INDIRECT addressing for the second operand (offset 2). The relative addressing
69
- // for the first operand will overflow (UINT32_MAX + 1 >= MAX_MEMORY_SIZE), causing the instruction to fail.
70
- // The second operand will also fail (indirect addressing from offset 2 which is uninitialized with tag FF).
71
- export async function addressingWithRelativeOverflowAndIndirectTagIssueTest(tester) {
72
- const addressingMode = Addressing.fromModes([
73
- AddressingMode.INDIRECT_RELATIVE,
74
- AddressingMode.INDIRECT,
75
- AddressingMode.DIRECT
76
- ]);
77
- // UINT32_MAX = 2^32 - 1 = 4294967295
78
- const UINT32_MAX = 0xffffffff;
79
- const bytecode = encodeToBytecode([
80
- // Set UINT32_MAX at offset 0 as base address - this will cause overflow when adding relative offset 1
81
- new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 0, TypeTag.UINT32, /*value=*/ UINT32_MAX).as(Opcode.SET_32, Set.wireFormat32),
82
- new Add(/*addressing_mode=*/ addressingMode.toWire(), /*aOffset=*/ 1, /*bOffset=*/ 2, /*dstOffset=*/ 3).as(Opcode.ADD_8, Add.wireFormat8),
83
- new Return(/*addressing_mode=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0)
84
- ]);
85
- const txLabel = 'AddressingWithRelativeOverflowAndIndirectTagInvalid';
86
- return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
87
- }
88
- export async function pcOutOfRangeTest(tester) {
89
- const bytecode = encodeToBytecode([
90
- new Jump(/*jumpOffset=*/ 123),
91
- new Return(/*addressing_mode=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0)
92
- ]);
93
- const txLabel = 'PcOutOfRange';
94
- return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
95
- }
96
- export async function invalidOpcodeTest(tester) {
97
- let bytecode = encodeToBytecode([
98
- new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 0, TypeTag.UINT32, /*value=*/ 0).as(Opcode.SET_8, Set.wireFormat8)
99
- ]);
100
- const offsetReturnOpcodeByte = bytecode.length;
101
- bytecode = Buffer.concat([
102
- bytecode,
103
- encodeToBytecode([
104
- new Return(/*addressing_mode=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0)
105
- ])
106
- ]);
107
- // Manipulate the Return opcode to make the opcode invalid (out of range).
108
- bytecode[offsetReturnOpcodeByte] = MAX_OPCODE_VALUE + 1; // opcode is invalid.
109
- const txLabel = 'InvalidOpcode';
110
- return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
111
- }
112
- // Single invalid byte in the bytecode.
113
- export async function invalidByteTest(tester) {
114
- const invalidOpcode = MAX_OPCODE_VALUE + 7;
115
- assert(invalidOpcode < 256, 'Invalid opcode must fit in a single byte');
116
- const bytecode = Buffer.from([
117
- invalidOpcode
118
- ]);
119
- const txLabel = 'InvalidByte';
120
- return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
121
- }
122
- // Truncate the last instruction in the bytecode.
123
- export async function instructionTruncatedTest(tester) {
124
- let bytecode = encodeToBytecode([
125
- new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 0, TypeTag.UINT32, /*value=*/ 0).as(Opcode.SET_8, Set.wireFormat8)
126
- ]);
127
- // Truncate the bytecode.
128
- bytecode = bytecode.subarray(0, -1);
129
- const txLabel = 'InstructionTruncated';
130
- return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
131
- }
132
- // Invalid tag value byte in an instruction.
133
- export async function invalidTagValueTest(tester) {
134
- const bytecode = encodeToBytecode([
135
- new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 0, TypeTag.UINT32, /*value=*/ 0).as(Opcode.SET_8, Set.wireFormat8),
136
- new Return(/*addressing_mode=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0)
137
- ]);
138
- const tagOffset = getTagOffsetInInstruction(Set.wireFormat8);
139
- assert(bytecode[tagOffset].valueOf() == TypeTag.UINT32.valueOf(), 'Set instruction tag should be UINT32 in test');
140
- bytecode[tagOffset] = TypeTag.INVALID;
141
- const txLabel = 'InvalidTagValue';
142
- return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
143
- }
144
- // Combine an invalid tag in the last instruction that is truncated.
145
- export async function invalidTagValueAndInstructionTruncatedTest(tester) {
146
- let bytecode = encodeToBytecode([
147
- // Important: value argument must be a bigint otherwise a type error will be thrown.
148
- new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 0, TypeTag.UINT128, /*value=*/ 0n).as(Opcode.SET_128, Set.wireFormat128)
149
- ]);
150
- // Truncate the bytecode.
151
- bytecode = bytecode.subarray(0, -5);
152
- const tagOffset = getTagOffsetInInstruction(Set.wireFormat128);
153
- assert(bytecode[tagOffset].valueOf() == TypeTag.UINT128.valueOf(), 'Set instruction tag should be UINT128 in test');
154
- bytecode[tagOffset] = 0x6f; // Invalid tag value.
155
- const txLabel = 'InvalidTagValueAndInstructionTruncated';
156
- return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
157
- }
158
- // Exercise SET truncation: set values whose widths exceed the target tag and
159
- // rely on `buildFromTagTruncating` to truncate to the low bits of the tag.
160
- // Covers sources larger than 128 bits (via SET_FF) and sources in (32, 128]
161
- // bits (via SET_64) against destination tags U1/U8/U16/U32/U64/U128.
162
- export async function setTruncationTest(tester) {
163
- // 200-bit value: forces truncation for every target tag up to U128.
164
- const LARGE_FIELD_VALUE = (1n << 200n) + 0x1234567890abcdef1234567890abcdefn;
165
- // 40-bit value: forces truncation for target tags up to U32.
166
- const LARGE_U64_VALUE = (1n << 40n) + 0xdeadbeefn;
167
- const bytecode = encodeToBytecode([
168
- // Zero U32 at offset 0 — used as the Return copy-size slot.
169
- new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 0, TypeTag.UINT32, /*value=*/ 0).as(Opcode.SET_8, Set.wireFormat8),
170
- // Source >128 bits (via SET_FF) truncated to smaller target tags.
171
- new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 1, TypeTag.UINT128, LARGE_FIELD_VALUE).as(Opcode.SET_FF, Set.wireFormatFF),
172
- new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 2, TypeTag.UINT64, LARGE_FIELD_VALUE).as(Opcode.SET_FF, Set.wireFormatFF),
173
- new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 3, TypeTag.UINT32, LARGE_FIELD_VALUE).as(Opcode.SET_FF, Set.wireFormatFF),
174
- new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 4, TypeTag.UINT16, LARGE_FIELD_VALUE).as(Opcode.SET_FF, Set.wireFormatFF),
175
- new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 5, TypeTag.UINT8, LARGE_FIELD_VALUE).as(Opcode.SET_FF, Set.wireFormatFF),
176
- new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 6, TypeTag.UINT1, LARGE_FIELD_VALUE).as(Opcode.SET_FF, Set.wireFormatFF),
177
- // Source in (32, 128] bits (via SET_64) truncated to smaller target tags.
178
- new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 7, TypeTag.UINT32, LARGE_U64_VALUE).as(Opcode.SET_64, Set.wireFormat64),
179
- new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 8, TypeTag.UINT16, LARGE_U64_VALUE).as(Opcode.SET_64, Set.wireFormat64),
180
- new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 9, TypeTag.UINT8, LARGE_U64_VALUE).as(Opcode.SET_64, Set.wireFormat64),
181
- new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 10, TypeTag.UINT1, LARGE_U64_VALUE).as(Opcode.SET_64, Set.wireFormat64),
182
- new Return(/*addressing_mode=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0)
183
- ]);
184
- const txLabel = 'SetTruncation';
185
- return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
186
- }
187
- // Exercise CAST truncation: store a wide source value in memory then CAST it
188
- // to smaller destination tags. Covers sources larger than 128 bits (FIELD
189
- // source) and sources in (32, 128] bits (UINT64 source) against destination
190
- // tags U1/U8/U16/U32/U64/U128.
191
- export async function castTruncationTest(tester) {
192
- // 200-bit source: stored as FIELD so that CASTs to any integer tag truncate.
193
- const LARGE_FIELD_VALUE = (1n << 200n) + 0x1234567890abcdef1234567890abcdefn;
194
- // 40-bit source: stored as UINT64 so CASTs to U1/U8/U16/U32 truncate.
195
- const LARGE_U64_VALUE = (1n << 40n) + 0xdeadbeefn;
196
- const bytecode = encodeToBytecode([
197
- // Zero U32 at offset 0 — used as the Return copy-size slot.
198
- new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 0, TypeTag.UINT32, /*value=*/ 0).as(Opcode.SET_8, Set.wireFormat8),
199
- // Store wide FIELD source at offset 10, then CAST to smaller tags.
200
- new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 10, TypeTag.FIELD, LARGE_FIELD_VALUE).as(Opcode.SET_FF, Set.wireFormatFF),
201
- new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 10, /*dstOffset=*/ 11, TypeTag.UINT128).as(Opcode.CAST_8, Cast.wireFormat8),
202
- new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 10, /*dstOffset=*/ 12, TypeTag.UINT64).as(Opcode.CAST_8, Cast.wireFormat8),
203
- new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 10, /*dstOffset=*/ 13, TypeTag.UINT32).as(Opcode.CAST_8, Cast.wireFormat8),
204
- new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 10, /*dstOffset=*/ 14, TypeTag.UINT16).as(Opcode.CAST_8, Cast.wireFormat8),
205
- new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 10, /*dstOffset=*/ 15, TypeTag.UINT8).as(Opcode.CAST_8, Cast.wireFormat8),
206
- new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 10, /*dstOffset=*/ 16, TypeTag.UINT1).as(Opcode.CAST_8, Cast.wireFormat8),
207
- // Store UINT64 source at offset 20, then CAST to smaller integer tags.
208
- new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 20, TypeTag.UINT64, LARGE_U64_VALUE).as(Opcode.SET_64, Set.wireFormat64),
209
- new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 20, /*dstOffset=*/ 21, TypeTag.UINT32).as(Opcode.CAST_8, Cast.wireFormat8),
210
- new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 20, /*dstOffset=*/ 22, TypeTag.UINT16).as(Opcode.CAST_8, Cast.wireFormat8),
211
- new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 20, /*dstOffset=*/ 23, TypeTag.UINT8).as(Opcode.CAST_8, Cast.wireFormat8),
212
- new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 20, /*dstOffset=*/ 24, TypeTag.UINT1).as(Opcode.CAST_8, Cast.wireFormat8),
213
- new Return(/*addressing_mode=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0)
214
- ]);
215
- const txLabel = 'CastTruncation';
216
- return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
217
- }
218
- /**
219
- * Returns the offset of the tag in an instruction.
220
- * @details Loops over the wire format operand type entries until it finds the tag.
221
- * Returns the byte offset of the tag based on each operand size that is passed.
222
- *
223
- * @param wireFormat array of operand types
224
- * @returns byte offset of the tag
225
- */ function getTagOffsetInInstruction(wireFormat) {
226
- let offset = 0;
227
- for (const operand of wireFormat){
228
- if (operand === OperandType.TAG) {
229
- break;
230
- }
231
- offset += getOperandSize(operand);
232
- }
233
- return offset;
234
- }