@aztec/simulator 0.76.4 → 0.77.0-testnet-ignition.21

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 (517) hide show
  1. package/README.md +3 -3
  2. package/dest/client.d.ts +5 -0
  3. package/dest/client.d.ts.map +1 -0
  4. package/dest/client.js +3 -0
  5. package/dest/{public → common}/db_interfaces.d.ts +8 -33
  6. package/dest/common/db_interfaces.d.ts.map +1 -0
  7. package/dest/common/db_interfaces.js +1 -0
  8. package/dest/common/debug_fn_name.d.ts +3 -2
  9. package/dest/common/debug_fn_name.d.ts.map +1 -1
  10. package/dest/common/debug_fn_name.js +2 -5
  11. package/dest/common/errors.d.ts +4 -4
  12. package/dest/common/errors.d.ts.map +1 -1
  13. package/dest/common/errors.js +30 -39
  14. package/dest/common/index.d.ts +2 -1
  15. package/dest/common/index.d.ts.map +1 -1
  16. package/dest/common/index.js +2 -2
  17. package/dest/common/message_load_oracle_inputs.d.ts +2 -2
  18. package/dest/common/message_load_oracle_inputs.d.ts.map +1 -1
  19. package/dest/common/message_load_oracle_inputs.js +8 -8
  20. package/dest/common/stats/index.d.ts.map +1 -0
  21. package/dest/{stats → common/stats}/stats.d.ts +2 -2
  22. package/dest/common/stats/stats.d.ts.map +1 -0
  23. package/dest/common/stats/stats.js +10 -0
  24. package/dest/{acvm → private/acvm}/acvm.d.ts +4 -4
  25. package/dest/private/acvm/acvm.d.ts.map +1 -0
  26. package/dest/private/acvm/acvm.js +70 -0
  27. package/dest/{acvm → private/acvm}/acvm_types.d.ts +1 -1
  28. package/dest/private/acvm/acvm_types.d.ts.map +1 -0
  29. package/dest/private/acvm/acvm_types.js +3 -0
  30. package/dest/{acvm → private/acvm}/deserialize.d.ts +2 -2
  31. package/dest/private/acvm/deserialize.d.ts.map +1 -0
  32. package/dest/private/acvm/deserialize.js +42 -0
  33. package/dest/private/acvm/index.d.ts.map +1 -0
  34. package/dest/private/acvm/index.js +5 -0
  35. package/dest/{acvm → private/acvm}/oracle/index.d.ts +1 -1
  36. package/dest/private/acvm/oracle/index.d.ts.map +1 -0
  37. package/dest/private/acvm/oracle/index.js +2 -0
  38. package/dest/{acvm → private/acvm}/oracle/oracle.d.ts +4 -3
  39. package/dest/private/acvm/oracle/oracle.d.ts.map +1 -0
  40. package/dest/private/acvm/oracle/oracle.js +263 -0
  41. package/dest/{acvm → private/acvm}/oracle/typed_oracle.d.ts +12 -6
  42. package/dest/private/acvm/oracle/typed_oracle.d.ts.map +1 -0
  43. package/dest/private/acvm/oracle/typed_oracle.js +132 -0
  44. package/dest/{acvm → private/acvm}/serialize.d.ts +7 -3
  45. package/dest/private/acvm/serialize.d.ts.map +1 -0
  46. package/dest/private/acvm/serialize.js +46 -0
  47. package/dest/{client → private}/client_execution_context.d.ts +20 -17
  48. package/dest/private/client_execution_context.d.ts.map +1 -0
  49. package/dest/private/client_execution_context.js +378 -0
  50. package/dest/{client → private}/db_oracle.d.ts +19 -7
  51. package/dest/private/db_oracle.d.ts.map +1 -0
  52. package/dest/private/db_oracle.js +14 -0
  53. package/dest/{client → private}/execution_note_cache.d.ts +2 -2
  54. package/dest/private/execution_note_cache.d.ts.map +1 -0
  55. package/dest/private/execution_note_cache.js +180 -0
  56. package/dest/{common → private}/hashed_values_cache.d.ts +2 -2
  57. package/dest/private/hashed_values_cache.d.ts.map +1 -0
  58. package/dest/private/hashed_values_cache.js +46 -0
  59. package/dest/private/index.d.ts +13 -0
  60. package/dest/private/index.d.ts.map +1 -0
  61. package/dest/private/index.js +12 -0
  62. package/dest/{client → private}/pick_notes.d.ts +1 -1
  63. package/dest/private/pick_notes.d.ts.map +1 -0
  64. package/dest/private/pick_notes.js +51 -0
  65. package/dest/private/private_execution.d.ts +24 -0
  66. package/dest/private/private_execution.d.ts.map +1 -0
  67. package/dest/private/private_execution.js +90 -0
  68. package/dest/{providers → private/providers}/acvm_native.d.ts +5 -5
  69. package/dest/private/providers/acvm_native.d.ts.map +1 -0
  70. package/dest/private/providers/acvm_native.js +139 -0
  71. package/dest/{providers → private/providers}/acvm_wasm.d.ts +4 -4
  72. package/dest/private/providers/acvm_wasm.d.ts.map +1 -0
  73. package/dest/private/providers/acvm_wasm.js +62 -0
  74. package/dest/{providers → private/providers}/acvm_wasm_with_blobs.d.ts +5 -5
  75. package/dest/private/providers/acvm_wasm_with_blobs.d.ts.map +1 -0
  76. package/dest/{providers → private/providers}/acvm_wasm_with_blobs.js +3 -6
  77. package/dest/{providers → private/providers}/factory.d.ts +1 -1
  78. package/dest/private/providers/factory.d.ts.map +1 -0
  79. package/dest/private/providers/factory.js +27 -0
  80. package/dest/{common → private/providers}/simulation_provider.d.ts +5 -5
  81. package/dest/private/providers/simulation_provider.d.ts.map +1 -0
  82. package/dest/private/providers/simulation_provider.js +24 -0
  83. package/dest/private/simulator.d.ts +36 -0
  84. package/dest/private/simulator.d.ts.map +1 -0
  85. package/dest/private/simulator.js +78 -0
  86. package/dest/{client → private}/unconstrained_execution.d.ts +5 -5
  87. package/dest/private/unconstrained_execution.d.ts.map +1 -0
  88. package/dest/private/unconstrained_execution.js +27 -0
  89. package/dest/{client → private}/view_data_oracle.d.ts +15 -7
  90. package/dest/private/view_data_oracle.d.ts.map +1 -0
  91. package/dest/private/view_data_oracle.js +260 -0
  92. package/dest/{avm → public/avm}/avm_context.d.ts +7 -5
  93. package/dest/public/avm/avm_context.d.ts.map +1 -0
  94. package/dest/public/avm/avm_context.js +44 -0
  95. package/dest/{avm → public/avm}/avm_contract_call_result.d.ts +5 -5
  96. package/dest/public/avm/avm_contract_call_result.d.ts.map +1 -0
  97. package/dest/public/avm/avm_contract_call_result.js +50 -0
  98. package/dest/{avm → public/avm}/avm_execution_environment.d.ts +2 -2
  99. package/dest/public/avm/avm_execution_environment.d.ts.map +1 -0
  100. package/dest/public/avm/avm_execution_environment.js +31 -0
  101. package/dest/public/avm/avm_gas.d.ts.map +1 -0
  102. package/dest/public/avm/avm_gas.js +202 -0
  103. package/dest/{avm → public/avm}/avm_machine_state.d.ts +2 -2
  104. package/dest/public/avm/avm_machine_state.d.ts.map +1 -0
  105. package/dest/public/avm/avm_machine_state.js +106 -0
  106. package/dest/{avm → public/avm}/avm_memory_types.d.ts +2 -2
  107. package/dest/public/avm/avm_memory_types.d.ts.map +1 -0
  108. package/dest/public/avm/avm_memory_types.js +340 -0
  109. package/dest/{avm → public/avm}/avm_simulator.d.ts +5 -3
  110. package/dest/public/avm/avm_simulator.d.ts.map +1 -0
  111. package/dest/public/avm/avm_simulator.js +202 -0
  112. package/dest/public/avm/bytecode_utils.d.ts.map +1 -0
  113. package/dest/public/avm/bytecode_utils.js +17 -0
  114. package/dest/{avm → public/avm}/errors.d.ts +5 -4
  115. package/dest/public/avm/errors.d.ts.map +1 -0
  116. package/dest/public/avm/errors.js +179 -0
  117. package/dest/{avm → public/avm}/fixtures/avm_simulation_tester.d.ts +6 -6
  118. package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -0
  119. package/dest/public/avm/fixtures/avm_simulation_tester.js +76 -0
  120. package/dest/{avm → public/avm}/fixtures/base_avm_simulation_tester.d.ts +13 -12
  121. package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -0
  122. package/dest/public/avm/fixtures/base_avm_simulation_tester.js +83 -0
  123. package/dest/{avm → public/avm}/fixtures/index.d.ts +24 -7
  124. package/dest/public/avm/fixtures/index.d.ts.map +1 -0
  125. package/dest/public/avm/fixtures/index.js +175 -0
  126. package/dest/{avm → public/avm}/fixtures/simple_contract_data_source.d.ts +10 -6
  127. package/dest/public/avm/fixtures/simple_contract_data_source.d.ts.map +1 -0
  128. package/dest/public/avm/fixtures/simple_contract_data_source.js +74 -0
  129. package/dest/public/avm/index.d.ts +4 -0
  130. package/dest/public/avm/index.d.ts.map +1 -0
  131. package/dest/{avm/index.d.ts → public/avm/index.js} +1 -2
  132. package/dest/public/avm/journal/index.d.ts.map +1 -0
  133. package/dest/{avm → public/avm}/journal/journal.d.ts +51 -18
  134. package/dest/public/avm/journal/journal.d.ts.map +1 -0
  135. package/dest/public/avm/journal/journal.js +486 -0
  136. package/dest/{avm → public/avm}/journal/nullifiers.d.ts +8 -6
  137. package/dest/public/avm/journal/nullifiers.d.ts.map +1 -0
  138. package/dest/public/avm/journal/nullifiers.js +97 -0
  139. package/dest/{avm → public/avm}/journal/public_storage.d.ts +2 -2
  140. package/dest/public/avm/journal/public_storage.d.ts.map +1 -0
  141. package/dest/public/avm/journal/public_storage.js +145 -0
  142. package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -0
  143. package/dest/public/avm/opcodes/accrued_substate.js +252 -0
  144. package/dest/public/avm/opcodes/addressing_mode.d.ts.map +1 -0
  145. package/dest/public/avm/opcodes/addressing_mode.js +74 -0
  146. package/dest/public/avm/opcodes/arithmetic.d.ts.map +1 -0
  147. package/dest/public/avm/opcodes/arithmetic.js +73 -0
  148. package/dest/public/avm/opcodes/bitwise.d.ts.map +1 -0
  149. package/dest/public/avm/opcodes/bitwise.js +106 -0
  150. package/dest/public/avm/opcodes/comparators.d.ts.map +1 -0
  151. package/dest/public/avm/opcodes/comparators.js +43 -0
  152. package/dest/public/avm/opcodes/contract.d.ts.map +1 -0
  153. package/dest/public/avm/opcodes/contract.js +66 -0
  154. package/dest/public/avm/opcodes/control_flow.d.ts.map +1 -0
  155. package/dest/public/avm/opcodes/control_flow.js +105 -0
  156. package/dest/{avm → public/avm}/opcodes/conversion.d.ts +1 -1
  157. package/dest/public/avm/opcodes/conversion.d.ts.map +1 -0
  158. package/dest/public/avm/opcodes/conversion.js +69 -0
  159. package/dest/{avm → public/avm}/opcodes/ec_add.d.ts +1 -1
  160. package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -0
  161. package/dest/public/avm/opcodes/ec_add.js +84 -0
  162. package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -0
  163. package/dest/public/avm/opcodes/environment_getters.js +79 -0
  164. package/dest/public/avm/opcodes/external_calls.d.ts.map +1 -0
  165. package/dest/public/avm/opcodes/external_calls.js +180 -0
  166. package/dest/{avm → public/avm}/opcodes/hashing.d.ts +1 -1
  167. package/dest/public/avm/opcodes/hashing.d.ts.map +1 -0
  168. package/dest/public/avm/opcodes/hashing.js +114 -0
  169. package/dest/public/avm/opcodes/index.d.ts.map +1 -0
  170. package/dest/{avm → public/avm}/opcodes/instruction.d.ts +2 -2
  171. package/dest/public/avm/opcodes/instruction.d.ts.map +1 -0
  172. package/dest/public/avm/opcodes/instruction.js +91 -0
  173. package/dest/public/avm/opcodes/instruction_impl.d.ts.map +1 -0
  174. package/dest/public/avm/opcodes/instruction_impl.js +30 -0
  175. package/dest/public/avm/opcodes/memory.d.ts.map +1 -0
  176. package/dest/public/avm/opcodes/memory.js +253 -0
  177. package/dest/{avm → public/avm}/opcodes/misc.d.ts +1 -1
  178. package/dest/public/avm/opcodes/misc.d.ts.map +1 -0
  179. package/dest/public/avm/opcodes/misc.js +48 -0
  180. package/dest/public/avm/opcodes/storage.d.ts.map +1 -0
  181. package/dest/public/avm/opcodes/storage.js +66 -0
  182. package/dest/public/avm/serialization/buffer_cursor.d.ts.map +1 -0
  183. package/dest/public/avm/serialization/buffer_cursor.js +99 -0
  184. package/dest/{avm → public/avm}/serialization/bytecode_serialization.d.ts +1 -1
  185. package/dest/public/avm/serialization/bytecode_serialization.d.ts.map +1 -0
  186. package/dest/public/avm/serialization/bytecode_serialization.js +328 -0
  187. package/dest/{avm → public/avm}/serialization/instruction_serialization.d.ts +1 -2
  188. package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -0
  189. package/dest/public/avm/serialization/instruction_serialization.js +225 -0
  190. package/dest/{avm → public/avm}/test_utils.d.ts +6 -4
  191. package/dest/public/avm/test_utils.d.ts.map +1 -0
  192. package/dest/public/avm/test_utils.js +52 -0
  193. package/dest/public/bytecode_errors.js +1 -2
  194. package/dest/public/execution.d.ts +8 -2
  195. package/dest/public/execution.d.ts.map +1 -1
  196. package/dest/public/execution.js +4 -5
  197. package/dest/public/executor_metrics.js +16 -12
  198. package/dest/public/fixtures/index.js +0 -1
  199. package/dest/public/fixtures/public_tx_simulation_tester.d.ts +15 -9
  200. package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
  201. package/dest/public/fixtures/public_tx_simulation_tester.js +54 -53
  202. package/dest/public/fixtures/utils.d.ts +7 -11
  203. package/dest/public/fixtures/utils.d.ts.map +1 -1
  204. package/dest/public/fixtures/utils.js +92 -32
  205. package/dest/public/index.d.ts +5 -4
  206. package/dest/public/index.d.ts.map +1 -1
  207. package/dest/public/index.js +5 -5
  208. package/dest/public/public_db_sources.d.ts +82 -34
  209. package/dest/public/public_db_sources.d.ts.map +1 -1
  210. package/dest/public/public_db_sources.js +171 -196
  211. package/dest/public/{public_processor.d.ts → public_processor/public_processor.d.ts} +10 -8
  212. package/dest/public/public_processor/public_processor.d.ts.map +1 -0
  213. package/dest/public/public_processor/public_processor.js +379 -0
  214. package/dest/public/{public_processor_metrics.d.ts → public_processor/public_processor_metrics.d.ts} +3 -3
  215. package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -0
  216. package/dest/public/public_processor/public_processor_metrics.js +125 -0
  217. package/dest/public/{public_tx_context.d.ts → public_tx_simulator/public_tx_context.d.ts} +14 -8
  218. package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -0
  219. package/dest/public/public_tx_simulator/public_tx_context.js +320 -0
  220. package/dest/public/{public_tx_simulator.d.ts → public_tx_simulator/public_tx_simulator.d.ts} +10 -7
  221. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -0
  222. package/dest/public/public_tx_simulator/public_tx_simulator.js +325 -0
  223. package/dest/public/side_effect_errors.js +1 -2
  224. package/dest/public/side_effect_trace.d.ts +16 -10
  225. package/dest/public/side_effect_trace.d.ts.map +1 -1
  226. package/dest/public/side_effect_trace.js +82 -149
  227. package/dest/public/side_effect_trace_interface.d.ts +9 -7
  228. package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
  229. package/dest/public/side_effect_trace_interface.js +1 -2
  230. package/dest/public/tx_contract_cache.d.ts +41 -0
  231. package/dest/public/tx_contract_cache.d.ts.map +1 -0
  232. package/dest/public/tx_contract_cache.js +49 -0
  233. package/dest/public/unique_class_ids.js +23 -28
  234. package/dest/public/utils.d.ts +2 -2
  235. package/dest/public/utils.d.ts.map +1 -1
  236. package/dest/public/utils.js +17 -12
  237. package/dest/server.d.ts +4 -4
  238. package/dest/server.d.ts.map +1 -1
  239. package/dest/server.js +3 -5
  240. package/dest/test/utils.d.ts +3 -2
  241. package/dest/test/utils.d.ts.map +1 -1
  242. package/dest/test/utils.js +9 -7
  243. package/package.json +19 -21
  244. package/src/client.ts +4 -0
  245. package/src/{public → common}/db_interfaces.ts +8 -40
  246. package/src/common/debug_fn_name.ts +4 -2
  247. package/src/common/errors.ts +5 -5
  248. package/src/common/index.ts +2 -1
  249. package/src/common/message_load_oracle_inputs.ts +2 -2
  250. package/src/common/stats/index.ts +1 -0
  251. package/src/{stats → common/stats}/stats.ts +2 -2
  252. package/src/{acvm → private/acvm}/acvm.ts +5 -5
  253. package/src/{acvm → private/acvm}/acvm_types.ts +1 -1
  254. package/src/{acvm → private/acvm}/deserialize.ts +2 -2
  255. package/src/{acvm → private/acvm}/oracle/index.ts +1 -1
  256. package/src/{acvm → private/acvm}/oracle/oracle.ts +22 -12
  257. package/src/{acvm → private/acvm}/oracle/typed_oracle.ts +50 -55
  258. package/src/{acvm → private/acvm}/serialize.ts +10 -3
  259. package/src/{client → private}/client_execution_context.ts +54 -37
  260. package/src/{client → private}/db_oracle.ts +20 -20
  261. package/src/{client → private}/execution_note_cache.ts +3 -3
  262. package/src/{common → private}/hashed_values_cache.ts +2 -2
  263. package/src/private/index.ts +12 -0
  264. package/src/{client → private}/pick_notes.ts +1 -1
  265. package/src/{client → private}/private_execution.ts +46 -14
  266. package/src/{providers → private/providers}/acvm_native.ts +6 -6
  267. package/src/{providers → private/providers}/acvm_wasm.ts +4 -4
  268. package/src/{providers → private/providers}/acvm_wasm_with_blobs.ts +5 -5
  269. package/src/{providers → private/providers}/factory.ts +1 -1
  270. package/src/{common → private/providers}/simulation_provider.ts +5 -5
  271. package/src/{client → private}/simulator.ts +31 -123
  272. package/src/{client → private}/unconstrained_execution.ts +7 -7
  273. package/src/{client → private}/view_data_oracle.ts +25 -28
  274. package/src/{avm → public/avm}/avm_context.ts +12 -7
  275. package/src/{avm → public/avm}/avm_contract_call_result.ts +6 -6
  276. package/src/{avm → public/avm}/avm_execution_environment.ts +2 -2
  277. package/src/{avm → public/avm}/avm_gas.ts +1 -3
  278. package/src/{avm → public/avm}/avm_machine_state.ts +2 -2
  279. package/src/{avm → public/avm}/avm_memory_types.ts +4 -4
  280. package/src/{avm → public/avm}/avm_simulator.ts +12 -6
  281. package/src/{avm → public/avm}/errors.ts +5 -4
  282. package/src/{avm → public/avm}/fixtures/avm_simulation_tester.ts +16 -15
  283. package/src/{avm → public/avm}/fixtures/base_avm_simulation_tester.ts +45 -40
  284. package/src/{avm → public/avm}/fixtures/index.ts +77 -12
  285. package/src/{avm → public/avm}/fixtures/simple_contract_data_source.ts +26 -19
  286. package/src/{avm → public/avm}/index.ts +1 -1
  287. package/src/public/avm/journal/index.ts +1 -0
  288. package/src/{avm → public/avm}/journal/journal.ts +330 -305
  289. package/src/{avm → public/avm}/journal/nullifiers.ts +20 -19
  290. package/src/{avm → public/avm}/journal/public_storage.ts +2 -2
  291. package/src/{avm → public/avm}/opcodes/contract.ts +1 -1
  292. package/src/{avm → public/avm}/opcodes/control_flow.ts +1 -1
  293. package/src/{avm → public/avm}/opcodes/conversion.ts +1 -1
  294. package/src/{avm → public/avm}/opcodes/ec_add.ts +2 -2
  295. package/src/{avm → public/avm}/opcodes/external_calls.ts +5 -6
  296. package/src/{avm → public/avm}/opcodes/hashing.ts +1 -1
  297. package/src/public/avm/opcodes/index.ts +15 -0
  298. package/src/{avm → public/avm}/opcodes/instruction.ts +2 -2
  299. package/src/{avm → public/avm}/opcodes/misc.ts +1 -1
  300. package/src/public/avm/serialization/bytecode_serialization.ts +204 -0
  301. package/src/{avm → public/avm}/serialization/instruction_serialization.ts +0 -1
  302. package/src/{avm → public/avm}/test_utils.ts +10 -7
  303. package/src/public/execution.ts +9 -12
  304. package/src/public/fixtures/public_tx_simulation_tester.ts +66 -72
  305. package/src/public/fixtures/utils.ts +122 -33
  306. package/src/public/index.ts +5 -4
  307. package/src/public/public_db_sources.ts +216 -222
  308. package/src/public/{public_processor.ts → public_processor/public_processor.ts} +78 -53
  309. package/src/public/{public_processor_metrics.ts → public_processor/public_processor_metrics.ts} +3 -3
  310. package/src/public/{public_tx_context.ts → public_tx_simulator/public_tx_context.ts} +70 -75
  311. package/src/public/{public_tx_simulator.ts → public_tx_simulator/public_tx_simulator.ts} +104 -91
  312. package/src/public/side_effect_trace.ts +85 -160
  313. package/src/public/side_effect_trace_interface.ts +10 -23
  314. package/src/public/tx_contract_cache.ts +69 -0
  315. package/src/public/unique_class_ids.ts +1 -1
  316. package/src/public/utils.ts +2 -2
  317. package/src/server.ts +4 -4
  318. package/src/test/utils.ts +5 -3
  319. package/dest/acvm/acvm.d.ts.map +0 -1
  320. package/dest/acvm/acvm.js +0 -73
  321. package/dest/acvm/acvm_types.d.ts.map +0 -1
  322. package/dest/acvm/acvm_types.js +0 -2
  323. package/dest/acvm/deserialize.d.ts.map +0 -1
  324. package/dest/acvm/deserialize.js +0 -46
  325. package/dest/acvm/index.d.ts.map +0 -1
  326. package/dest/acvm/index.js +0 -6
  327. package/dest/acvm/oracle/index.d.ts.map +0 -1
  328. package/dest/acvm/oracle/index.js +0 -3
  329. package/dest/acvm/oracle/oracle.d.ts.map +0 -1
  330. package/dest/acvm/oracle/oracle.js +0 -230
  331. package/dest/acvm/oracle/typed_oracle.d.ts.map +0 -1
  332. package/dest/acvm/oracle/typed_oracle.js +0 -131
  333. package/dest/acvm/serialize.d.ts.map +0 -1
  334. package/dest/acvm/serialize.js +0 -48
  335. package/dest/avm/avm_context.d.ts.map +0 -1
  336. package/dest/avm/avm_context.js +0 -44
  337. package/dest/avm/avm_contract_call_result.d.ts.map +0 -1
  338. package/dest/avm/avm_contract_call_result.js +0 -45
  339. package/dest/avm/avm_execution_environment.d.ts.map +0 -1
  340. package/dest/avm/avm_execution_environment.js +0 -28
  341. package/dest/avm/avm_gas.d.ts.map +0 -1
  342. package/dest/avm/avm_gas.js +0 -170
  343. package/dest/avm/avm_machine_state.d.ts.map +0 -1
  344. package/dest/avm/avm_machine_state.js +0 -112
  345. package/dest/avm/avm_memory_types.d.ts.map +0 -1
  346. package/dest/avm/avm_memory_types.js +0 -327
  347. package/dest/avm/avm_simulator.d.ts.map +0 -1
  348. package/dest/avm/avm_simulator.js +0 -193
  349. package/dest/avm/avm_tree.d.ts +0 -282
  350. package/dest/avm/avm_tree.d.ts.map +0 -1
  351. package/dest/avm/avm_tree.js +0 -684
  352. package/dest/avm/bytecode_utils.d.ts.map +0 -1
  353. package/dest/avm/bytecode_utils.js +0 -15
  354. package/dest/avm/errors.d.ts.map +0 -1
  355. package/dest/avm/errors.js +0 -196
  356. package/dest/avm/fixtures/avm_simulation_tester.d.ts.map +0 -1
  357. package/dest/avm/fixtures/avm_simulation_tester.js +0 -73
  358. package/dest/avm/fixtures/base_avm_simulation_tester.d.ts.map +0 -1
  359. package/dest/avm/fixtures/base_avm_simulation_tester.js +0 -76
  360. package/dest/avm/fixtures/index.d.ts.map +0 -1
  361. package/dest/avm/fixtures/index.js +0 -134
  362. package/dest/avm/fixtures/simple_contract_data_source.d.ts.map +0 -1
  363. package/dest/avm/fixtures/simple_contract_data_source.js +0 -75
  364. package/dest/avm/index.d.ts.map +0 -1
  365. package/dest/avm/index.js +0 -4
  366. package/dest/avm/journal/index.d.ts.map +0 -1
  367. package/dest/avm/journal/index.js +0 -2
  368. package/dest/avm/journal/journal.d.ts.map +0 -1
  369. package/dest/avm/journal/journal.js +0 -499
  370. package/dest/avm/journal/nullifiers.d.ts.map +0 -1
  371. package/dest/avm/journal/nullifiers.js +0 -99
  372. package/dest/avm/journal/public_storage.d.ts.map +0 -1
  373. package/dest/avm/journal/public_storage.js +0 -159
  374. package/dest/avm/opcodes/accrued_substate.d.ts.map +0 -1
  375. package/dest/avm/opcodes/accrued_substate.js +0 -215
  376. package/dest/avm/opcodes/addressing_mode.d.ts.map +0 -1
  377. package/dest/avm/opcodes/addressing_mode.js +0 -81
  378. package/dest/avm/opcodes/arithmetic.d.ts.map +0 -1
  379. package/dest/avm/opcodes/arithmetic.js +0 -70
  380. package/dest/avm/opcodes/bitwise.d.ts.map +0 -1
  381. package/dest/avm/opcodes/bitwise.js +0 -90
  382. package/dest/avm/opcodes/comparators.d.ts.map +0 -1
  383. package/dest/avm/opcodes/comparators.js +0 -40
  384. package/dest/avm/opcodes/contract.d.ts.map +0 -1
  385. package/dest/avm/opcodes/contract.js +0 -63
  386. package/dest/avm/opcodes/control_flow.d.ts.map +0 -1
  387. package/dest/avm/opcodes/control_flow.js +0 -97
  388. package/dest/avm/opcodes/conversion.d.ts.map +0 -1
  389. package/dest/avm/opcodes/conversion.js +0 -64
  390. package/dest/avm/opcodes/ec_add.d.ts.map +0 -1
  391. package/dest/avm/opcodes/ec_add.js +0 -82
  392. package/dest/avm/opcodes/environment_getters.d.ts.map +0 -1
  393. package/dest/avm/opcodes/environment_getters.js +0 -78
  394. package/dest/avm/opcodes/external_calls.d.ts.map +0 -1
  395. package/dest/avm/opcodes/external_calls.js +0 -169
  396. package/dest/avm/opcodes/hashing.d.ts.map +0 -1
  397. package/dest/avm/opcodes/hashing.js +0 -103
  398. package/dest/avm/opcodes/index.d.ts.map +0 -1
  399. package/dest/avm/opcodes/index.js +0 -16
  400. package/dest/avm/opcodes/instruction.d.ts.map +0 -1
  401. package/dest/avm/opcodes/instruction.js +0 -100
  402. package/dest/avm/opcodes/instruction_impl.d.ts.map +0 -1
  403. package/dest/avm/opcodes/instruction_impl.js +0 -33
  404. package/dest/avm/opcodes/memory.d.ts.map +0 -1
  405. package/dest/avm/opcodes/memory.js +0 -226
  406. package/dest/avm/opcodes/misc.d.ts.map +0 -1
  407. package/dest/avm/opcodes/misc.js +0 -45
  408. package/dest/avm/opcodes/multi_scalar_mul.d.ts +0 -16
  409. package/dest/avm/opcodes/multi_scalar_mul.d.ts.map +0 -1
  410. package/dest/avm/opcodes/multi_scalar_mul.js +0 -112
  411. package/dest/avm/opcodes/storage.d.ts.map +0 -1
  412. package/dest/avm/opcodes/storage.js +0 -61
  413. package/dest/avm/serialization/buffer_cursor.d.ts.map +0 -1
  414. package/dest/avm/serialization/buffer_cursor.js +0 -99
  415. package/dest/avm/serialization/bytecode_serialization.d.ts.map +0 -1
  416. package/dest/avm/serialization/bytecode_serialization.js +0 -132
  417. package/dest/avm/serialization/instruction_serialization.d.ts.map +0 -1
  418. package/dest/avm/serialization/instruction_serialization.js +0 -187
  419. package/dest/avm/test_utils.d.ts.map +0 -1
  420. package/dest/avm/test_utils.js +0 -52
  421. package/dest/client/client_execution_context.d.ts.map +0 -1
  422. package/dest/client/client_execution_context.js +0 -392
  423. package/dest/client/db_oracle.d.ts.map +0 -1
  424. package/dest/client/db_oracle.js +0 -17
  425. package/dest/client/execution_note_cache.d.ts.map +0 -1
  426. package/dest/client/execution_note_cache.js +0 -181
  427. package/dest/client/index.d.ts +0 -16
  428. package/dest/client/index.d.ts.map +0 -1
  429. package/dest/client/index.js +0 -15
  430. package/dest/client/pick_notes.d.ts.map +0 -1
  431. package/dest/client/pick_notes.js +0 -54
  432. package/dest/client/private_execution.d.ts +0 -19
  433. package/dest/client/private_execution.d.ts.map +0 -1
  434. package/dest/client/private_execution.js +0 -72
  435. package/dest/client/simulator.d.ts +0 -60
  436. package/dest/client/simulator.d.ts.map +0 -1
  437. package/dest/client/simulator.js +0 -136
  438. package/dest/client/unconstrained_execution.d.ts.map +0 -1
  439. package/dest/client/unconstrained_execution.js +0 -30
  440. package/dest/client/view_data_oracle.d.ts.map +0 -1
  441. package/dest/client/view_data_oracle.js +0 -268
  442. package/dest/common/hashed_values_cache.d.ts.map +0 -1
  443. package/dest/common/hashed_values_cache.js +0 -50
  444. package/dest/common/simulation_provider.d.ts.map +0 -1
  445. package/dest/common/simulation_provider.js +0 -27
  446. package/dest/common.d.ts +0 -2
  447. package/dest/common.d.ts.map +0 -1
  448. package/dest/common.js +0 -2
  449. package/dest/providers/acvm_native.d.ts.map +0 -1
  450. package/dest/providers/acvm_native.js +0 -125
  451. package/dest/providers/acvm_wasm.d.ts.map +0 -1
  452. package/dest/providers/acvm_wasm.js +0 -54
  453. package/dest/providers/acvm_wasm_with_blobs.d.ts.map +0 -1
  454. package/dest/providers/factory.d.ts.map +0 -1
  455. package/dest/providers/factory.js +0 -27
  456. package/dest/providers/index.d.ts +0 -5
  457. package/dest/providers/index.d.ts.map +0 -1
  458. package/dest/providers/index.js +0 -5
  459. package/dest/public/db_interfaces.d.ts.map +0 -1
  460. package/dest/public/db_interfaces.js +0 -2
  461. package/dest/public/fee_payment.d.ts +0 -11
  462. package/dest/public/fee_payment.d.ts.map +0 -1
  463. package/dest/public/fee_payment.js +0 -21
  464. package/dest/public/public_processor.d.ts.map +0 -1
  465. package/dest/public/public_processor.js +0 -352
  466. package/dest/public/public_processor_metrics.d.ts.map +0 -1
  467. package/dest/public/public_processor_metrics.js +0 -106
  468. package/dest/public/public_tx_context.d.ts.map +0 -1
  469. package/dest/public/public_tx_context.js +0 -341
  470. package/dest/public/public_tx_simulator.d.ts.map +0 -1
  471. package/dest/public/public_tx_simulator.js +0 -333
  472. package/dest/stats/index.d.ts.map +0 -1
  473. package/dest/stats/index.js +0 -2
  474. package/dest/stats/stats.d.ts.map +0 -1
  475. package/dest/stats/stats.js +0 -11
  476. package/src/avm/avm_tree.ts +0 -887
  477. package/src/avm/opcodes/multi_scalar_mul.ts +0 -121
  478. package/src/avm/serialization/bytecode_serialization.ts +0 -212
  479. package/src/client/index.ts +0 -15
  480. package/src/common.ts +0 -1
  481. package/src/providers/index.ts +0 -4
  482. package/src/public/fee_payment.ts +0 -23
  483. /package/dest/{stats → common/stats}/index.d.ts +0 -0
  484. /package/{src/stats/index.ts → dest/common/stats/index.js} +0 -0
  485. /package/dest/{acvm → private/acvm}/index.d.ts +0 -0
  486. /package/dest/{avm → public/avm}/avm_gas.d.ts +0 -0
  487. /package/dest/{avm → public/avm}/bytecode_utils.d.ts +0 -0
  488. /package/dest/{avm → public/avm}/journal/index.d.ts +0 -0
  489. /package/{src/avm/journal/index.ts → dest/public/avm/journal/index.js} +0 -0
  490. /package/dest/{avm → public/avm}/opcodes/accrued_substate.d.ts +0 -0
  491. /package/dest/{avm → public/avm}/opcodes/addressing_mode.d.ts +0 -0
  492. /package/dest/{avm → public/avm}/opcodes/arithmetic.d.ts +0 -0
  493. /package/dest/{avm → public/avm}/opcodes/bitwise.d.ts +0 -0
  494. /package/dest/{avm → public/avm}/opcodes/comparators.d.ts +0 -0
  495. /package/dest/{avm → public/avm}/opcodes/contract.d.ts +0 -0
  496. /package/dest/{avm → public/avm}/opcodes/control_flow.d.ts +0 -0
  497. /package/dest/{avm → public/avm}/opcodes/environment_getters.d.ts +0 -0
  498. /package/dest/{avm → public/avm}/opcodes/external_calls.d.ts +0 -0
  499. /package/dest/{avm → public/avm}/opcodes/index.d.ts +0 -0
  500. /package/{src/avm/opcodes/index.ts → dest/public/avm/opcodes/index.js} +0 -0
  501. /package/dest/{avm → public/avm}/opcodes/instruction_impl.d.ts +0 -0
  502. /package/dest/{avm → public/avm}/opcodes/memory.d.ts +0 -0
  503. /package/dest/{avm → public/avm}/opcodes/storage.d.ts +0 -0
  504. /package/dest/{avm → public/avm}/serialization/buffer_cursor.d.ts +0 -0
  505. /package/src/{acvm → private/acvm}/index.ts +0 -0
  506. /package/src/{avm → public/avm}/bytecode_utils.ts +0 -0
  507. /package/src/{avm → public/avm}/opcodes/.eslintrc.cjs +0 -0
  508. /package/src/{avm → public/avm}/opcodes/accrued_substate.ts +0 -0
  509. /package/src/{avm → public/avm}/opcodes/addressing_mode.ts +0 -0
  510. /package/src/{avm → public/avm}/opcodes/arithmetic.ts +0 -0
  511. /package/src/{avm → public/avm}/opcodes/bitwise.ts +0 -0
  512. /package/src/{avm → public/avm}/opcodes/comparators.ts +0 -0
  513. /package/src/{avm → public/avm}/opcodes/environment_getters.ts +0 -0
  514. /package/src/{avm → public/avm}/opcodes/instruction_impl.ts +0 -0
  515. /package/src/{avm → public/avm}/opcodes/memory.ts +0 -0
  516. /package/src/{avm → public/avm}/opcodes/storage.ts +0 -0
  517. /package/src/{avm → public/avm}/serialization/buffer_cursor.ts +0 -0
@@ -1,12 +1,12 @@
1
1
  import { foreignCallHandler } from '@aztec/noir-protocol-circuits-types/server';
2
- import { type NoirCompiledCircuit } from '@aztec/types/noir';
2
+ import type { NoirCompiledCircuit } from '@aztec/stdlib/noir';
3
3
 
4
4
  import { type ExecutionError, executeCircuit } from '@noir-lang/acvm_js';
5
- import { type WitnessMap } from '@noir-lang/types';
5
+ import type { WitnessMap } from '@noir-lang/types';
6
6
 
7
- import { type ACIRCallback, type ACIRExecutionResult } from '../acvm/acvm.js';
8
- import { type ACVMWitness } from '../acvm/acvm_types.js';
9
- import { type SimulationProvider, parseErrorPayload } from '../common/simulation_provider.js';
7
+ import type { ACIRCallback, ACIRExecutionResult } from '../acvm/acvm.js';
8
+ import type { ACVMWitness } from '../acvm/acvm_types.js';
9
+ import { type SimulationProvider, parseErrorPayload } from './simulation_provider.js';
10
10
 
11
11
  /**
12
12
  * A simulation provider that uses the WASM simulator with the ability to handle blobs via the foreign call handler.
@@ -2,9 +2,9 @@ import { type Logger, createLogger } from '@aztec/foundation/log';
2
2
 
3
3
  import { promises as fs } from 'fs';
4
4
 
5
- import { type SimulationProvider } from '../common/simulation_provider.js';
6
5
  import { NativeACVMSimulator } from './acvm_native.js';
7
6
  import { WASMSimulator } from './acvm_wasm.js';
7
+ import type { SimulationProvider } from './simulation_provider.js';
8
8
 
9
9
  export type SimulationProviderConfig = {
10
10
  acvmBinaryPath?: string;
@@ -1,11 +1,11 @@
1
- import { type NoirCompiledCircuit } from '@aztec/types/noir';
1
+ import type { NoirCompiledCircuit } from '@aztec/stdlib/noir';
2
2
 
3
- import { type ExecutionError } from '@noir-lang/acvm_js';
3
+ import type { ExecutionError } from '@noir-lang/acvm_js';
4
4
  import { abiDecodeError } from '@noir-lang/noirc_abi';
5
- import { type Abi, type WitnessMap } from '@noir-lang/types';
5
+ import type { Abi, WitnessMap } from '@noir-lang/types';
6
6
 
7
- import { type ACIRCallback, type ACIRExecutionResult } from '../acvm/acvm.js';
8
- import { type ACVMWitness } from '../acvm/acvm_types.js';
7
+ import type { ACIRCallback, ACIRExecutionResult } from '../acvm/acvm.js';
8
+ import type { ACVMWitness } from '../acvm/acvm_types.js';
9
9
 
10
10
  /**
11
11
  * Low level simulation interface
@@ -1,30 +1,18 @@
1
- import {
2
- type AztecNode,
3
- type FunctionCall,
4
- type Note,
5
- PrivateExecutionResult,
6
- type TxExecutionRequest,
7
- } from '@aztec/circuit-types';
8
- import { CallContext } from '@aztec/circuits.js';
9
- import {
10
- type ArrayType,
11
- type FunctionArtifact,
12
- FunctionSelector,
13
- FunctionType,
14
- type NoteSelector,
15
- encodeArguments,
16
- } from '@aztec/foundation/abi';
17
- import { AztecAddress } from '@aztec/foundation/aztec-address';
18
1
  import { Fr } from '@aztec/foundation/fields';
19
2
  import { type Logger, createLogger } from '@aztec/foundation/log';
3
+ import type { FunctionCall } from '@aztec/stdlib/abi';
4
+ import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
5
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
6
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
7
+ import { CallContext, PrivateExecutionResult, TxExecutionRequest } from '@aztec/stdlib/tx';
20
8
 
21
9
  import { createSimulationError } from '../common/errors.js';
22
- import { HashedValuesCache } from '../common/hashed_values_cache.js';
23
- import { type SimulationProvider } from '../common/simulation_provider.js';
24
10
  import { ClientExecutionContext } from './client_execution_context.js';
25
- import { type DBOracle } from './db_oracle.js';
11
+ import type { DBOracle } from './db_oracle.js';
26
12
  import { ExecutionNoteCache } from './execution_note_cache.js';
27
- import { executePrivateFunction } from './private_execution.js';
13
+ import { HashedValuesCache } from './hashed_values_cache.js';
14
+ import { executePrivateFunction, verifyCurrentClassId } from './private_execution.js';
15
+ import type { SimulationProvider } from './providers/simulation_provider.js';
28
16
  import { executeUnconstrainedFunction } from './unconstrained_execution.js';
29
17
  import { ViewDataOracle } from './view_data_oracle.js';
30
18
 
@@ -49,11 +37,21 @@ export class AcirSimulator {
49
37
  */
50
38
  public async run(
51
39
  request: TxExecutionRequest,
52
- entryPointArtifact: FunctionArtifact,
53
40
  contractAddress: AztecAddress,
41
+ selector: FunctionSelector,
54
42
  msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE),
55
43
  scopes?: AztecAddress[],
56
44
  ): Promise<PrivateExecutionResult> {
45
+ const header = await this.db.getBlockHeader();
46
+
47
+ await verifyCurrentClassId(
48
+ contractAddress,
49
+ await this.db.getContractInstance(contractAddress),
50
+ this.node,
51
+ header.globalVariables.blockNumber.toNumber(),
52
+ );
53
+ const entryPointArtifact = await this.db.getFunctionArtifact(contractAddress, selector);
54
+
57
55
  if (entryPointArtifact.functionType !== FunctionType.PRIVATE) {
58
56
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as private`);
59
57
  }
@@ -64,8 +62,6 @@ export class AcirSimulator {
64
62
  );
65
63
  }
66
64
 
67
- const header = await this.db.getBlockHeader();
68
-
69
65
  // reserve the first side effect for the tx hash (inserted by the private kernel)
70
66
  const startSideEffectCounter = 1;
71
67
 
@@ -85,6 +81,7 @@ export class AcirSimulator {
85
81
  callContext,
86
82
  header,
87
83
  request.authWitnesses,
84
+ request.capsules,
88
85
  HashedValuesCache.create(request.argsOfCalls),
89
86
  noteCache,
90
87
  this.db,
@@ -120,15 +117,23 @@ export class AcirSimulator {
120
117
  */
121
118
  public async runUnconstrained(
122
119
  request: FunctionCall,
123
- entryPointArtifact: FunctionArtifact,
124
120
  contractAddress: AztecAddress,
121
+ selector: FunctionSelector,
125
122
  scopes?: AztecAddress[],
126
123
  ) {
124
+ await verifyCurrentClassId(
125
+ contractAddress,
126
+ await this.db.getContractInstance(contractAddress),
127
+ this.node,
128
+ await this.node.getBlockNumber(),
129
+ );
130
+ const entryPointArtifact = await this.db.getFunctionArtifact(contractAddress, selector);
131
+
127
132
  if (entryPointArtifact.functionType !== FunctionType.UNCONSTRAINED) {
128
133
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as unconstrained`);
129
134
  }
130
135
 
131
- const context = new ViewDataOracle(contractAddress, [], this.db, this.node, undefined, scopes);
136
+ const context = new ViewDataOracle(contractAddress, [], [], this.db, this.node, undefined, scopes);
132
137
 
133
138
  try {
134
139
  return await executeUnconstrainedFunction(
@@ -143,101 +148,4 @@ export class AcirSimulator {
143
148
  throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
144
149
  }
145
150
  }
146
-
147
- /**
148
- * Computes the inner nullifier of a note.
149
- * @param contractAddress - The address of the contract.
150
- * @param nonce - The nonce of the note hash.
151
- * @param storageSlot - The storage slot.
152
- * @param noteTypeId - The note type identifier.
153
- * @param computeNullifier - A flag indicating whether to compute the nullifier or just return 0.
154
- * @param note - The note.
155
- * @returns The nullifier.
156
- */
157
- public async computeNoteHashAndOptionallyANullifier(
158
- contractAddress: AztecAddress,
159
- nonce: Fr,
160
- storageSlot: Fr,
161
- noteTypeId: NoteSelector,
162
- computeNullifier: boolean,
163
- note: Note,
164
- ) {
165
- const artifact: FunctionArtifact | undefined = await this.db.getFunctionArtifactByName(
166
- contractAddress,
167
- 'compute_note_hash_and_optionally_a_nullifier',
168
- );
169
- if (!artifact) {
170
- throw new Error(
171
- `Mandatory implementation of "compute_note_hash_and_optionally_a_nullifier" missing in noir contract ${contractAddress.toString()}.`,
172
- );
173
- }
174
-
175
- if (artifact.parameters.length != 6) {
176
- throw new Error(
177
- `Expected 6 parameters in mandatory implementation of "compute_note_hash_and_optionally_a_nullifier", but found ${
178
- artifact.parameters.length
179
- } in noir contract ${contractAddress.toString()}.`,
180
- );
181
- }
182
-
183
- const maxNoteFields = (artifact.parameters[artifact.parameters.length - 1].type as ArrayType).length;
184
- if (maxNoteFields < note.items.length) {
185
- throw new Error(
186
- `The note being processed has ${note.items.length} fields, while "compute_note_hash_and_optionally_a_nullifier" can only handle a maximum of ${maxNoteFields} fields. Please reduce the number of fields in your note.`,
187
- );
188
- }
189
-
190
- const extendedNoteItems = note.items.concat(Array(maxNoteFields - note.items.length).fill(Fr.ZERO));
191
-
192
- const execRequest: FunctionCall = {
193
- name: artifact.name,
194
- to: contractAddress,
195
- selector: await FunctionSelector.fromNameAndParameters(artifact),
196
- type: FunctionType.UNCONSTRAINED,
197
- isStatic: artifact.isStatic,
198
- args: encodeArguments(artifact, [
199
- contractAddress,
200
- nonce,
201
- storageSlot,
202
- noteTypeId,
203
- computeNullifier,
204
- extendedNoteItems,
205
- ]),
206
- returnTypes: artifact.returnTypes,
207
- };
208
-
209
- const [noteHash, uniqueNoteHash, siloedNoteHash, innerNullifier] = (await this.runUnconstrained(
210
- execRequest,
211
- artifact,
212
- contractAddress,
213
- // We can omit scopes here, because "compute_note_hash_and_optionally_a_nullifier" does not need access to any notes.
214
- )) as bigint[];
215
-
216
- return {
217
- noteHash: new Fr(noteHash),
218
- uniqueNoteHash: new Fr(uniqueNoteHash),
219
- siloedNoteHash: new Fr(siloedNoteHash),
220
- innerNullifier: new Fr(innerNullifier),
221
- };
222
- }
223
-
224
- /**
225
- * Computes a hash of the note.
226
- * @param contractAddress - The address of the contract.
227
- * @param storageSlot - The storage slot.
228
- * @param noteTypeId - The note type identifier.
229
- * @param note - The note.
230
- * @returns The note hash.
231
- */
232
- public async computeNoteHash(contractAddress: AztecAddress, storageSlot: Fr, noteTypeId: NoteSelector, note: Note) {
233
- const { noteHash } = await this.computeNoteHashAndOptionallyANullifier(
234
- contractAddress,
235
- Fr.ZERO,
236
- storageSlot,
237
- noteTypeId,
238
- false,
239
- note,
240
- );
241
- return noteHash;
242
- }
243
151
  }
@@ -1,13 +1,13 @@
1
- import { type AbiDecoded, type FunctionArtifact, type FunctionSelector, decodeFromAbi } from '@aztec/foundation/abi';
2
- import { type AztecAddress } from '@aztec/foundation/aztec-address';
3
- import { type Fr } from '@aztec/foundation/fields';
1
+ import type { Fr } from '@aztec/foundation/fields';
4
2
  import { createLogger } from '@aztec/foundation/log';
3
+ import { type AbiDecoded, type FunctionArtifact, type FunctionSelector, decodeFromAbi } from '@aztec/stdlib/abi';
4
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
5
 
6
- import { witnessMapToFields } from '../acvm/deserialize.js';
7
- import { Oracle, extractCallStack, toACVMWitness } from '../acvm/index.js';
8
6
  import { ExecutionError, resolveAssertionMessageFromError } from '../common/errors.js';
9
- import { type SimulationProvider } from '../server.js';
10
- import { type ViewDataOracle } from './view_data_oracle.js';
7
+ import { witnessMapToFields } from './acvm/deserialize.js';
8
+ import { Oracle, extractCallStack, toACVMWitness } from './acvm/index.js';
9
+ import type { SimulationProvider } from './providers/simulation_provider.js';
10
+ import type { ViewDataOracle } from './view_data_oracle.js';
11
11
 
12
12
  // docs:start:execute_unconstrained_function
13
13
  /**
@@ -1,26 +1,19 @@
1
- import {
2
- type AuthWitness,
3
- type AztecNode,
4
- type CompleteAddress,
5
- type MerkleTreeId,
6
- type NoteStatus,
7
- type NullifierMembershipWitness,
8
- type PublicDataWitness,
9
- } from '@aztec/circuit-types';
10
- import {
11
- type BlockHeader,
12
- type ContractInstance,
13
- type IndexedTaggingSecret,
14
- type KeyValidationRequest,
15
- } from '@aztec/circuits.js';
16
- import { Aes128 } from '@aztec/circuits.js/barretenberg';
17
- import { siloNullifier } from '@aztec/circuits.js/hash';
18
- import { AztecAddress } from '@aztec/foundation/aztec-address';
1
+ import { Aes128 } from '@aztec/foundation/crypto';
19
2
  import { Fr } from '@aztec/foundation/fields';
20
3
  import { applyStringFormatting, createLogger } from '@aztec/foundation/log';
21
-
22
- import { type NoteData, TypedOracle } from '../acvm/index.js';
23
- import { type DBOracle } from './db_oracle.js';
4
+ import type { AuthWitness } from '@aztec/stdlib/auth-witness';
5
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
6
+ import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
7
+ import { siloNullifier } from '@aztec/stdlib/hash';
8
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
9
+ import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
10
+ import { IndexedTaggingSecret, LogWithTxData } from '@aztec/stdlib/logs';
11
+ import type { NoteStatus } from '@aztec/stdlib/note';
12
+ import { type MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
13
+ import type { BlockHeader, Capsule } from '@aztec/stdlib/tx';
14
+
15
+ import { type NoteData, TypedOracle } from './acvm/index.js';
16
+ import type { DBOracle } from './db_oracle.js';
24
17
  import { pickNotes } from './pick_notes.js';
25
18
 
26
19
  /**
@@ -32,6 +25,7 @@ export class ViewDataOracle extends TypedOracle {
32
25
  protected readonly contractAddress: AztecAddress,
33
26
  /** List of transient auth witnesses to be used during this simulation */
34
27
  protected readonly authWitnesses: AuthWitness[],
28
+ protected readonly capsules: Capsule[],
35
29
  protected readonly db: DBOracle,
36
30
  protected readonly aztecNode: AztecNode,
37
31
  protected log = createLogger('simulator:client_view_context'),
@@ -320,6 +314,10 @@ export class ViewDataOracle extends TypedOracle {
320
314
  await this.db.deliverNote(contractAddress, storageSlot, nonce, content, noteHash, nullifier, txHash, recipient);
321
315
  }
322
316
 
317
+ public override getLogByTag(tag: Fr): Promise<LogWithTxData | null> {
318
+ return this.db.getLogByTag(tag);
319
+ }
320
+
323
321
  public override storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
324
322
  if (!contractAddress.equals(this.contractAddress)) {
325
323
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
@@ -328,12 +326,15 @@ export class ViewDataOracle extends TypedOracle {
328
326
  return this.db.storeCapsule(this.contractAddress, slot, capsule);
329
327
  }
330
328
 
331
- public override loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
329
+ public override async loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
332
330
  if (!contractAddress.equals(this.contractAddress)) {
333
331
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
334
332
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
335
333
  }
336
- return this.db.loadCapsule(this.contractAddress, slot);
334
+ return (
335
+ this.capsules.find(c => c.contractAddress.equals(contractAddress) && c.storageSlot.equals(slot))?.data ??
336
+ (await this.db.loadCapsule(this.contractAddress, slot))
337
+ );
337
338
  }
338
339
 
339
340
  public override deleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void> {
@@ -359,11 +360,7 @@ export class ViewDataOracle extends TypedOracle {
359
360
 
360
361
  // TODO(#11849): consider replacing this oracle with a pure Noir implementation of aes decryption.
361
362
  public override aes128Decrypt(ciphertext: Buffer, iv: Buffer, symKey: Buffer): Promise<Buffer> {
362
- // Noir can't predict the amount of padding that gets trimmed,
363
- // but it needs to know the length of the returned value.
364
- // So we tell Noir that the length is the (predictable) length
365
- // of the padded plaintext, we return that padded plaintext, and have Noir interpret the padding to do the trimming.
366
363
  const aes128 = new Aes128();
367
- return aes128.decryptBufferCBCKeepPadding(ciphertext, iv, symKey);
364
+ return aes128.decryptBufferCBC(ciphertext, iv, symKey);
368
365
  }
369
366
  }
@@ -1,10 +1,11 @@
1
- import { type AztecAddress } from '@aztec/circuits.js';
2
- import { type Fr } from '@aztec/foundation/fields';
1
+ import type { Fr } from '@aztec/foundation/fields';
2
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
3
 
4
- import { type AvmExecutionEnvironment } from './avm_execution_environment.js';
4
+ import type { AvmExecutionEnvironment } from './avm_execution_environment.js';
5
5
  import { type Gas, gasToGasLeft } from './avm_gas.js';
6
6
  import { AvmMachineState } from './avm_machine_state.js';
7
- import { type AvmPersistableStateManager } from './journal/journal.js';
7
+ import type { AvmSimulator } from './avm_simulator.js';
8
+ import type { AvmPersistableStateManager } from './journal/journal.js';
8
9
 
9
10
  /**
10
11
  * An execution context includes the information necessary to initiate AVM
@@ -24,6 +25,10 @@ export class AvmContext {
24
25
  public machineState: AvmMachineState,
25
26
  ) {}
26
27
 
28
+ // This is needed to break a dependency cycle created by the CALL opcode,
29
+ // which needs to create a new simulator but cannot depend directly on AvmSimulator.
30
+ public provideSimulator?: (ctx: this) => Promise<AvmSimulator>;
31
+
27
32
  /**
28
33
  * Prepare a new AVM context that will be ready for an external/nested call
29
34
  * - Fork the world state journal
@@ -38,18 +43,18 @@ export class AvmContext {
38
43
  * @param callType - Type of call (CALL or STATICCALL)
39
44
  * @returns new AvmContext instance
40
45
  */
41
- public createNestedContractCallContext(
46
+ public async createNestedContractCallContext(
42
47
  address: AztecAddress,
43
48
  calldata: Fr[],
44
49
  allocatedGas: Gas,
45
50
  callType: 'CALL' | 'STATICCALL',
46
- ): AvmContext {
51
+ ): Promise<AvmContext> {
47
52
  const deriveFn =
48
53
  callType === 'CALL'
49
54
  ? this.environment.deriveEnvironmentForNestedCall
50
55
  : this.environment.deriveEnvironmentForNestedStaticCall;
51
56
  const newExecutionEnvironment = deriveFn.call(this.environment, address, calldata);
52
- const forkedWorldState = this.persistableState.fork();
57
+ const forkedWorldState = await this.persistableState.fork();
53
58
  const machineState = AvmMachineState.fromState(gasToGasLeft(allocatedGas));
54
59
  return new AvmContext(forkedWorldState, newExecutionEnvironment, machineState);
55
60
  }
@@ -1,12 +1,12 @@
1
- import { type SimulationError } from '@aztec/circuit-types';
2
- import { Gas } from '@aztec/circuits.js';
3
- import { type Fr } from '@aztec/foundation/fields';
1
+ import type { Fr } from '@aztec/foundation/fields';
2
+ import type { SimulationError } from '@aztec/stdlib/errors';
3
+ import { Gas } from '@aztec/stdlib/gas';
4
4
 
5
5
  import { inspect } from 'util';
6
6
 
7
- import { createSimulationError } from '../common/errors.js';
8
- import { type Gas as AvmGas } from './avm_gas.js';
9
- import { type AvmRevertReason } from './errors.js';
7
+ import { createSimulationError } from '../../common/errors.js';
8
+ import type { Gas as AvmGas } from './avm_gas.js';
9
+ import type { AvmRevertReason } from './errors.js';
10
10
 
11
11
  /**
12
12
  * Results of an contract call's execution in the AVM.
@@ -1,6 +1,6 @@
1
- import { type GlobalVariables } from '@aztec/circuits.js';
2
- import { type AztecAddress } from '@aztec/foundation/aztec-address';
3
1
  import { Fr } from '@aztec/foundation/fields';
2
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import type { GlobalVariables } from '@aztec/stdlib/tx';
4
4
 
5
5
  /**
6
6
  * Contains variables that remain constant during AVM execution
@@ -1,4 +1,4 @@
1
- import * as c from '@aztec/circuits.js/constants';
1
+ import * as c from '@aztec/constants';
2
2
 
3
3
  import { TypeTag } from './avm_memory_types.js';
4
4
  import { InstructionExecutionError } from './errors.js';
@@ -123,7 +123,6 @@ const BASE_GAS_COSTS: Record<Opcode, Gas> = {
123
123
  [Opcode.SHA256COMPRESSION]: makeCost(c.AVM_SHA256COMPRESSION_BASE_L2_GAS, 0),
124
124
  [Opcode.KECCAKF1600]: makeCost(c.AVM_KECCAKF1600_BASE_L2_GAS, 0),
125
125
  [Opcode.ECADD]: makeCost(c.AVM_ECADD_BASE_L2_GAS, 0),
126
- [Opcode.MSM]: makeCost(c.AVM_MSM_BASE_L2_GAS, 0),
127
126
  [Opcode.TORADIXBE]: makeCost(c.AVM_TORADIXBE_BASE_L2_GAS, 0),
128
127
  };
129
128
 
@@ -137,7 +136,6 @@ const DYNAMIC_GAS_COSTS = new Map<Opcode, Gas>([
137
136
  [Opcode.REVERT_8, makeCost(c.AVM_REVERT_DYN_L2_GAS, 0)],
138
137
  [Opcode.REVERT_16, makeCost(c.AVM_REVERT_DYN_L2_GAS, 0)],
139
138
  [Opcode.DEBUGLOG, makeCost(c.AVM_DEBUGLOG_DYN_L2_GAS, 0)],
140
- [Opcode.MSM, makeCost(c.AVM_MSM_DYN_L2_GAS, 0)],
141
139
  [Opcode.TORADIXBE, makeCost(c.AVM_TORADIXBE_DYN_L2_GAS, 0)],
142
140
  ]);
143
141
 
@@ -1,6 +1,6 @@
1
- import { type Fr } from '@aztec/circuits.js';
1
+ import type { Fr } from '@aztec/foundation/fields';
2
2
 
3
- import { type Gas } from './avm_gas.js';
3
+ import type { Gas } from './avm_gas.js';
4
4
  import { TaggedMemory } from './avm_memory_types.js';
5
5
  import { type AvmRevertReason, OutOfGasError } from './errors.js';
6
6
 
@@ -6,12 +6,12 @@ import {
6
6
  MEM_TAG_U32,
7
7
  MEM_TAG_U64,
8
8
  MEM_TAG_U128,
9
- } from '@aztec/circuits.js';
10
- import { AztecAddress } from '@aztec/foundation/aztec-address';
9
+ } from '@aztec/constants';
11
10
  import { toBufferBE } from '@aztec/foundation/bigint-buffer';
12
11
  import { Fr } from '@aztec/foundation/fields';
13
12
  import { type Logger, createLogger } from '@aztec/foundation/log';
14
- import { type FunctionsOf } from '@aztec/foundation/types';
13
+ import type { FunctionsOf } from '@aztec/foundation/types';
14
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
15
15
 
16
16
  import { strict as assert } from 'assert';
17
17
 
@@ -219,7 +219,7 @@ export enum TypeTag {
219
219
  UINT32 = MEM_TAG_U32,
220
220
  UINT64 = MEM_TAG_U64,
221
221
  UINT128 = MEM_TAG_U128,
222
- INVALID,
222
+ INVALID = MEM_TAG_U128 + 1,
223
223
  }
224
224
 
225
225
  // Lazy interface definition for tagged memory
@@ -1,13 +1,16 @@
1
- import { type AztecAddress, Fr, type GlobalVariables, MAX_L2_GAS_PER_TX_PUBLIC_PORTION } from '@aztec/circuits.js';
1
+ import { MAX_L2_GAS_PER_TX_PUBLIC_PORTION } from '@aztec/constants';
2
+ import { Fr } from '@aztec/foundation/fields';
2
3
  import { type Logger, createLogger } from '@aztec/foundation/log';
4
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
+ import type { GlobalVariables } from '@aztec/stdlib/tx';
3
6
 
4
7
  import { strict as assert } from 'assert';
5
8
 
6
- import { SideEffectLimitReachedError } from '../public/side_effect_errors.js';
9
+ import { SideEffectLimitReachedError } from '../side_effect_errors.js';
7
10
  import { AvmContext } from './avm_context.js';
8
11
  import { AvmContractCallResult } from './avm_contract_call_result.js';
9
12
  import { AvmExecutionEnvironment } from './avm_execution_environment.js';
10
- import { type Gas } from './avm_gas.js';
13
+ import type { Gas } from './avm_gas.js';
11
14
  import { AvmMachineState } from './avm_machine_state.js';
12
15
  import { isAvmBytecode } from './bytecode_utils.js';
13
16
  import {
@@ -17,8 +20,8 @@ import {
17
20
  revertReasonFromExceptionalHalt,
18
21
  revertReasonFromExplicitRevert,
19
22
  } from './errors.js';
20
- import { type AvmPersistableStateManager } from './journal/journal.js';
21
- import { type Instruction } from './opcodes/instruction.js';
23
+ import type { AvmPersistableStateManager } from './journal/journal.js';
24
+ import type { Instruction } from './opcodes/instruction.js';
22
25
  import {
23
26
  INSTRUCTION_SET,
24
27
  type InstructionSet,
@@ -44,9 +47,12 @@ export class AvmSimulator {
44
47
  // only. Otherwise, use build() below.
45
48
  constructor(
46
49
  private context: AvmContext,
47
- private instructionSet: InstructionSet = INSTRUCTION_SET(),
50
+ private instructionSet: InstructionSet = INSTRUCTION_SET,
48
51
  enableTallying = false,
49
52
  ) {
53
+ // This will be used by the CALL opcode to create a new simulator. It is required to
54
+ // avoid a dependency cycle.
55
+ context.provideSimulator = AvmSimulator.build;
50
56
  assert(
51
57
  context.machineState.gasLeft.l2Gas <= MAX_L2_GAS_PER_TX_PUBLIC_PORTION,
52
58
  `Cannot allocate more than ${MAX_L2_GAS_PER_TX_PUBLIC_PORTION} to the AVM for execution.`,
@@ -1,8 +1,9 @@
1
- import { type FailingFunction, type NoirCallStack } from '@aztec/circuit-types';
2
- import { type AztecAddress, type Fr, type Point } from '@aztec/circuits.js';
1
+ import type { Fr, Point } from '@aztec/foundation/fields';
2
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import type { FailingFunction, NoirCallStack } from '@aztec/stdlib/errors';
3
4
 
4
- import { ExecutionError } from '../common/errors.js';
5
- import { type AvmContext } from './avm_context.js';
5
+ import { ExecutionError } from '../../common/errors.js';
6
+ import type { AvmContext } from './avm_context.js';
6
7
 
7
8
  /**
8
9
  * Avm-specific errors should derive from this
@@ -1,11 +1,13 @@
1
- import { type MerkleTreeWriteOperations } from '@aztec/circuit-types';
2
- import { GasFees, GlobalVariables } from '@aztec/circuits.js';
3
- import { encodeArguments } from '@aztec/foundation/abi';
4
- import { type AztecAddress } from '@aztec/foundation/aztec-address';
5
1
  import { Fr } from '@aztec/foundation/fields';
2
+ import { encodeArguments } from '@aztec/stdlib/abi';
3
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
+ import { GasFees } from '@aztec/stdlib/gas';
5
+ import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
6
+ import { GlobalVariables } from '@aztec/stdlib/tx';
6
7
  import { NativeWorldStateService } from '@aztec/world-state';
7
8
 
8
- import { type AvmContractCallResult } from '../../avm/avm_contract_call_result.js';
9
+ import { SideEffectTrace } from '../../../public/side_effect_trace.js';
10
+ import type { AvmContractCallResult } from '../../avm/avm_contract_call_result.js';
9
11
  import {
10
12
  getContractFunctionArtifact,
11
13
  getFunctionSelector,
@@ -13,9 +15,9 @@ import {
13
15
  initExecutionEnvironment,
14
16
  resolveContractAssertionMessage,
15
17
  } from '../../avm/fixtures/index.js';
16
- import { WorldStateDB } from '../../public/public_db_sources.js';
17
- import { SideEffectTrace } from '../../public/side_effect_trace.js';
18
- import { AvmPersistableStateManager, AvmSimulator } from '../../server.js';
18
+ import { AvmPersistableStateManager } from '../../avm/journal/journal.js';
19
+ import { WorldStateDB } from '../../public_db_sources.js';
20
+ import { AvmSimulator } from '../avm_simulator.js';
19
21
  import { BaseAvmSimulationTester } from './base_avm_simulation_tester.js';
20
22
  import { SimpleContractDataSource } from './simple_contract_data_source.js';
21
23
 
@@ -31,13 +33,12 @@ export class AvmSimulationTester extends BaseAvmSimulationTester {
31
33
  constructor(
32
34
  contractDataSource: SimpleContractDataSource,
33
35
  merkleTrees: MerkleTreeWriteOperations,
34
- skipContractDeployments = false,
35
36
  private stateManager: AvmPersistableStateManager,
36
37
  ) {
37
- super(contractDataSource, merkleTrees, skipContractDeployments);
38
+ super(contractDataSource, merkleTrees);
38
39
  }
39
40
 
40
- static async create(skipContractDeployments = false): Promise<AvmSimulationTester> {
41
+ static async create(): Promise<AvmSimulationTester> {
41
42
  const contractDataSource = new SimpleContractDataSource();
42
43
  const merkleTrees = await (await NativeWorldStateService.tmp()).fork();
43
44
  const worldStateDB = new WorldStateDB(merkleTrees, contractDataSource);
@@ -45,13 +46,13 @@ export class AvmSimulationTester extends BaseAvmSimulationTester {
45
46
  const firstNullifier = new Fr(420000);
46
47
  // FIXME: merkle ops should work, but I'm seeing frequent (but inconsistent) bytecode retrieval
47
48
  // failures on 2nd call to simulateCall with merkle ops on
48
- const stateManager = await AvmPersistableStateManager.create(
49
+ const stateManager = AvmPersistableStateManager.create(
49
50
  worldStateDB,
50
51
  trace,
51
52
  /*doMerkleOperations=*/ false,
52
53
  firstNullifier,
53
54
  );
54
- return new AvmSimulationTester(contractDataSource, merkleTrees, skipContractDeployments, stateManager);
55
+ return new AvmSimulationTester(contractDataSource, merkleTrees, stateManager);
55
56
  }
56
57
 
57
58
  /**
@@ -84,7 +85,7 @@ export class AvmSimulationTester extends BaseAvmSimulationTester {
84
85
  sender,
85
86
  isStaticCall,
86
87
  });
87
- const persistableState = this.stateManager.fork();
88
+ const persistableState = await this.stateManager.fork();
88
89
  const context = initContext({ env: environment, persistableState });
89
90
 
90
91
  // First we simulate (though it's not needed in this simple case).
@@ -97,7 +98,7 @@ export class AvmSimulationTester extends BaseAvmSimulationTester {
97
98
  );
98
99
  } else {
99
100
  this.logger.info(`Simulation of function ${fnName} succeeded!`);
100
- this.stateManager.merge(persistableState);
101
+ await this.stateManager.merge(persistableState);
101
102
  }
102
103
  return result;
103
104
  }