@aztec/simulator 0.0.0-test.1 → 0.0.1-fake-ceab37513c
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.
- package/README.md +6 -0
- package/dest/client.d.ts +5 -3
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +4 -2
- package/dest/common/errors.d.ts +4 -7
- package/dest/common/errors.d.ts.map +1 -1
- package/dest/common/errors.js +51 -32
- package/dest/common/index.d.ts +0 -1
- package/dest/common/index.d.ts.map +1 -1
- package/dest/common/index.js +0 -1
- package/dest/private/acvm/acvm.d.ts +11 -5
- package/dest/private/acvm/acvm.d.ts.map +1 -1
- package/dest/private/acvm/acvm.js +10 -16
- package/dest/private/acvm/acvm_types.d.ts +1 -1
- package/dest/private/acvm/acvm_types.d.ts.map +1 -1
- package/dest/private/acvm/deserialize.d.ts +17 -18
- package/dest/private/acvm/deserialize.d.ts.map +1 -1
- package/dest/private/acvm/deserialize.js +31 -23
- package/dest/private/acvm/index.d.ts +0 -1
- package/dest/private/acvm/index.d.ts.map +1 -1
- package/dest/private/acvm/index.js +0 -1
- package/dest/private/acvm/serialize.d.ts +19 -2
- package/dest/private/acvm/serialize.d.ts.map +1 -1
- package/dest/private/acvm/serialize.js +53 -0
- package/dest/private/{providers/acvm_native.d.ts → acvm_native.d.ts} +10 -10
- package/dest/private/acvm_native.d.ts.map +1 -0
- package/dest/private/{providers/acvm_native.js → acvm_native.js} +11 -7
- package/dest/private/acvm_wasm.d.ts +15 -0
- package/dest/private/acvm_wasm.d.ts.map +1 -0
- package/dest/private/{providers/acvm_wasm.js → acvm_wasm.js} +22 -19
- package/dest/private/acvm_wasm_with_blobs.d.ts +20 -0
- package/dest/private/acvm_wasm_with_blobs.d.ts.map +1 -0
- package/dest/private/acvm_wasm_with_blobs.js +35 -0
- package/dest/private/circuit_recording/circuit_recorder.d.ts +108 -0
- package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -0
- package/dest/private/circuit_recording/circuit_recorder.js +209 -0
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts +31 -0
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -0
- package/dest/private/circuit_recording/file_circuit_recorder.js +135 -0
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +5 -0
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -0
- package/dest/private/circuit_recording/memory_circuit_recorder.js +9 -0
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts +21 -0
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts.map +1 -0
- package/dest/private/circuit_recording/simulator_recorder_wrapper.js +44 -0
- package/dest/private/circuit_simulator.d.ts +35 -0
- package/dest/private/circuit_simulator.d.ts.map +1 -0
- package/dest/private/circuit_simulator.js +43 -0
- package/dest/private/factory.d.ts +12 -0
- package/dest/private/factory.d.ts.map +1 -0
- package/dest/private/{providers/factory.js → factory.js} +2 -2
- package/dest/public/avm/avm_context.d.ts +5 -5
- package/dest/public/avm/avm_context.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.d.ts +4 -2
- package/dest/public/avm/avm_contract_call_result.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.js +11 -7
- package/dest/public/avm/avm_execution_environment.d.ts +2 -1
- package/dest/public/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/public/avm/avm_execution_environment.js +4 -2
- package/dest/public/avm/avm_gas.d.ts +4 -20
- package/dest/public/avm/avm_gas.d.ts.map +1 -1
- package/dest/public/avm/avm_gas.js +27 -35
- package/dest/public/avm/avm_machine_state.d.ts +2 -0
- package/dest/public/avm/avm_machine_state.d.ts.map +1 -1
- package/dest/public/avm/avm_machine_state.js +2 -0
- package/dest/public/avm/avm_memory_types.d.ts +98 -87
- package/dest/public/avm/avm_memory_types.d.ts.map +1 -1
- package/dest/public/avm/avm_memory_types.js +17 -6
- package/dest/public/avm/avm_simulator.d.ts +4 -5
- package/dest/public/avm/avm_simulator.d.ts.map +1 -1
- package/dest/public/avm/avm_simulator.js +13 -18
- package/dest/public/avm/avm_simulator_interface.d.ts +9 -0
- package/dest/public/avm/avm_simulator_interface.d.ts.map +1 -0
- package/dest/public/avm/avm_simulator_interface.js +3 -0
- package/dest/public/avm/errors.d.ts +1 -16
- package/dest/public/avm/errors.d.ts.map +1 -1
- package/dest/public/avm/errors.js +0 -37
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts +3 -3
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.js +10 -11
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +4 -4
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/base_avm_simulation_tester.js +16 -15
- package/dest/public/avm/fixtures/initializers.d.ts +43 -0
- package/dest/public/avm/fixtures/initializers.d.ts.map +1 -0
- package/dest/public/avm/fixtures/initializers.js +42 -0
- package/dest/public/avm/fixtures/utils.d.ts +38 -0
- package/dest/public/avm/fixtures/utils.d.ts.map +1 -0
- package/dest/public/avm/fixtures/utils.js +95 -0
- package/dest/public/avm/index.d.ts +0 -2
- package/dest/public/avm/index.d.ts.map +1 -1
- package/dest/public/avm/index.js +0 -2
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/public/avm/opcodes/accrued_substate.js +22 -19
- package/dest/public/avm/opcodes/addressing_mode.d.ts +11 -7
- package/dest/public/avm/opcodes/addressing_mode.d.ts.map +1 -1
- package/dest/public/avm/opcodes/addressing_mode.js +48 -27
- package/dest/public/avm/opcodes/arithmetic.d.ts +11 -1
- package/dest/public/avm/opcodes/arithmetic.d.ts.map +1 -1
- package/dest/public/avm/opcodes/arithmetic.js +16 -2
- package/dest/public/avm/opcodes/bitwise.d.ts +5 -13
- package/dest/public/avm/opcodes/bitwise.d.ts.map +1 -1
- package/dest/public/avm/opcodes/bitwise.js +19 -26
- package/dest/public/avm/opcodes/comparators.d.ts.map +1 -1
- package/dest/public/avm/opcodes/comparators.js +3 -3
- package/dest/public/avm/opcodes/contract.d.ts +1 -2
- package/dest/public/avm/opcodes/contract.d.ts.map +1 -1
- package/dest/public/avm/opcodes/contract.js +9 -10
- package/dest/public/avm/opcodes/control_flow.d.ts.map +1 -1
- package/dest/public/avm/opcodes/control_flow.js +10 -8
- package/dest/public/avm/opcodes/conversion.d.ts +1 -0
- package/dest/public/avm/opcodes/conversion.d.ts.map +1 -1
- package/dest/public/avm/opcodes/conversion.js +264 -3
- package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -1
- package/dest/public/avm/opcodes/ec_add.js +2 -2
- package/dest/public/avm/opcodes/environment_getters.d.ts +2 -2
- package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/public/avm/opcodes/environment_getters.js +12 -12
- package/dest/public/avm/opcodes/external_calls.d.ts +8 -7
- package/dest/public/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/public/avm/opcodes/external_calls.js +39 -33
- package/dest/public/avm/opcodes/hashing.d.ts.map +1 -1
- package/dest/public/avm/opcodes/hashing.js +6 -6
- package/dest/public/avm/opcodes/instruction.d.ts +14 -10
- package/dest/public/avm/opcodes/instruction.d.ts.map +1 -1
- package/dest/public/avm/opcodes/instruction.js +18 -13
- package/dest/public/avm/opcodes/memory.d.ts +4 -4
- package/dest/public/avm/opcodes/memory.d.ts.map +1 -1
- package/dest/public/avm/opcodes/memory.js +37 -33
- package/dest/public/avm/opcodes/misc.d.ts.map +1 -1
- package/dest/public/avm/opcodes/misc.js +17 -12
- package/dest/public/avm/opcodes/storage.d.ts.map +1 -1
- package/dest/public/avm/opcodes/storage.js +7 -5
- package/dest/public/avm/revert_reason.d.ts +18 -0
- package/dest/public/avm/revert_reason.d.ts.map +1 -0
- package/dest/public/avm/revert_reason.js +38 -0
- package/dest/public/avm/serialization/buffer_cursor.d.ts +0 -2
- package/dest/public/avm/serialization/buffer_cursor.d.ts.map +1 -1
- package/dest/public/avm/serialization/bytecode_serialization.d.ts +2 -6
- package/dest/public/avm/serialization/bytecode_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/bytecode_serialization.js +70 -69
- package/dest/public/avm/serialization/instruction_serialization.d.ts +5 -4
- package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/instruction_serialization.js +60 -35
- package/dest/public/avm/test_utils.d.ts +10 -13
- package/dest/public/avm/test_utils.d.ts.map +1 -1
- package/dest/public/avm/test_utils.js +12 -17
- package/dest/public/db_interfaces.d.ts +56 -0
- package/dest/public/db_interfaces.d.ts.map +1 -0
- package/dest/public/db_interfaces.js +3 -0
- package/dest/public/debug_fn_name.d.ts +5 -0
- package/dest/public/debug_fn_name.d.ts.map +1 -0
- package/dest/public/debug_fn_name.js +9 -0
- package/dest/public/executor_metrics.d.ts +10 -3
- package/dest/public/executor_metrics.d.ts.map +1 -1
- package/dest/public/executor_metrics.js +37 -6
- package/dest/public/executor_metrics_interface.d.ts +9 -0
- package/dest/public/executor_metrics_interface.d.ts.map +1 -0
- package/dest/public/executor_metrics_interface.js +1 -0
- package/dest/public/fixtures/amm_test.d.ts +10 -0
- package/dest/public/fixtures/amm_test.d.ts.map +1 -0
- package/dest/public/fixtures/amm_test.js +213 -0
- package/dest/public/fixtures/bulk_test.d.ts +6 -0
- package/dest/public/fixtures/bulk_test.d.ts.map +1 -0
- package/dest/public/fixtures/bulk_test.js +393 -0
- package/dest/public/fixtures/index.d.ts +6 -0
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +6 -0
- package/dest/public/fixtures/minimal_public_tx.d.ts +9 -0
- package/dest/public/fixtures/minimal_public_tx.d.ts.map +1 -0
- package/dest/public/fixtures/minimal_public_tx.js +43 -0
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +33 -13
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +90 -70
- package/dest/public/{avm/fixtures → fixtures}/simple_contract_data_source.d.ts +6 -6
- package/dest/public/fixtures/simple_contract_data_source.d.ts.map +1 -0
- package/dest/public/{avm/fixtures → fixtures}/simple_contract_data_source.js +31 -10
- package/dest/public/fixtures/token_test.d.ts +8 -0
- package/dest/public/fixtures/token_test.d.ts.map +1 -0
- package/dest/public/fixtures/token_test.js +95 -0
- package/dest/public/fixtures/utils.d.ts +16 -3
- package/dest/public/fixtures/utils.d.ts.map +1 -1
- package/dest/public/fixtures/utils.js +100 -58
- package/dest/public/hinting_db_sources.d.ts +68 -0
- package/dest/public/hinting_db_sources.d.ts.map +1 -0
- package/dest/public/hinting_db_sources.js +294 -0
- package/dest/public/index.d.ts +4 -8
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +4 -7
- package/dest/public/public_db_sources.d.ts +30 -39
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +141 -67
- package/dest/public/public_processor/guarded_merkle_tree.d.ts +47 -0
- package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -0
- package/dest/public/public_processor/guarded_merkle_tree.js +105 -0
- package/dest/public/public_processor/public_processor.d.ts +19 -29
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +133 -94
- package/dest/public/public_processor/public_processor_metrics.d.ts +2 -2
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor_metrics.js +1 -1
- package/dest/public/public_tx_simulator/index.d.ts +3 -0
- package/dest/public/public_tx_simulator/index.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/index.js +2 -0
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +23 -0
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.js +52 -0
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +17 -29
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +59 -91
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +27 -42
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +128 -171
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts +20 -0
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.js +39 -0
- package/dest/public/side_effect_trace.d.ts +10 -62
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +43 -108
- package/dest/public/side_effect_trace_interface.d.ts +5 -22
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
- package/dest/public/state_manager/index.d.ts +2 -0
- package/dest/public/state_manager/index.d.ts.map +1 -0
- package/dest/public/state_manager/index.js +1 -0
- package/dest/public/{avm/journal → state_manager}/nullifiers.d.ts +2 -2
- package/dest/public/state_manager/nullifiers.d.ts.map +1 -0
- package/dest/public/{avm/journal → state_manager}/nullifiers.js +2 -2
- package/dest/public/{avm/journal → state_manager}/public_storage.d.ts +2 -2
- package/dest/public/state_manager/public_storage.d.ts.map +1 -0
- package/dest/public/{avm/journal/journal.d.ts → state_manager/state_manager.d.ts} +37 -85
- package/dest/public/state_manager/state_manager.d.ts.map +1 -0
- package/dest/public/state_manager/state_manager.js +352 -0
- package/dest/public/test_executor_metrics.d.ts +54 -0
- package/dest/public/test_executor_metrics.d.ts.map +1 -0
- package/dest/public/test_executor_metrics.js +306 -0
- package/dest/public/unique_class_ids.d.ts.map +1 -1
- package/dest/public/utils.d.ts +2 -4
- package/dest/public/utils.d.ts.map +1 -1
- package/dest/public/utils.js +4 -21
- package/dest/server.d.ts +6 -3
- package/dest/server.d.ts.map +1 -1
- package/dest/server.js +5 -2
- package/dest/testing.d.ts +2 -0
- package/dest/testing.d.ts.map +1 -0
- package/dest/testing.js +1 -0
- package/package.json +31 -30
- package/src/client.ts +5 -3
- package/src/common/errors.ts +79 -44
- package/src/common/index.ts +0 -1
- package/src/private/acvm/acvm.ts +17 -32
- package/src/private/acvm/acvm_types.ts +1 -1
- package/src/private/acvm/deserialize.ts +35 -29
- package/src/private/acvm/index.ts +0 -1
- package/src/private/acvm/serialize.ts +63 -0
- package/src/private/{providers/acvm_native.ts → acvm_native.ts} +31 -15
- package/src/private/acvm_wasm.ts +72 -0
- package/src/private/acvm_wasm_with_blobs.ts +54 -0
- package/src/private/circuit_recording/circuit_recorder.ts +260 -0
- package/src/private/circuit_recording/file_circuit_recorder.ts +158 -0
- package/src/private/circuit_recording/memory_circuit_recorder.ts +11 -0
- package/src/private/circuit_recording/simulator_recorder_wrapper.ts +91 -0
- package/src/private/circuit_simulator.ts +90 -0
- package/src/private/{providers/factory.ts → factory.ts} +6 -6
- package/src/public/avm/avm_context.ts +4 -4
- package/src/public/avm/avm_contract_call_result.ts +17 -5
- package/src/public/avm/avm_execution_environment.ts +7 -1
- package/src/public/avm/avm_gas.ts +23 -35
- package/src/public/avm/avm_machine_state.ts +5 -0
- package/src/public/avm/avm_memory_types.ts +19 -6
- package/src/public/avm/avm_simulator.ts +30 -29
- package/src/public/avm/avm_simulator_interface.ts +8 -0
- package/src/public/avm/errors.ts +1 -53
- package/src/public/avm/fixtures/avm_simulation_tester.ts +19 -18
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +15 -14
- package/src/public/avm/fixtures/initializers.ts +103 -0
- package/src/public/avm/fixtures/utils.ts +150 -0
- package/src/public/avm/index.ts +0 -2
- package/src/public/avm/opcodes/accrued_substate.ts +62 -27
- package/src/public/avm/opcodes/addressing_mode.ts +57 -33
- package/src/public/avm/opcodes/arithmetic.ts +24 -2
- package/src/public/avm/opcodes/bitwise.ts +33 -29
- package/src/public/avm/opcodes/comparators.ts +6 -3
- package/src/public/avm/opcodes/contract.ts +10 -7
- package/src/public/avm/opcodes/control_flow.ts +19 -10
- package/src/public/avm/opcodes/conversion.ts +23 -3
- package/src/public/avm/opcodes/ec_add.ts +5 -2
- package/src/public/avm/opcodes/environment_getters.ts +22 -15
- package/src/public/avm/opcodes/external_calls.ts +61 -28
- package/src/public/avm/opcodes/hashing.ts +28 -8
- package/src/public/avm/opcodes/instruction.ts +23 -15
- package/src/public/avm/opcodes/memory.ts +71 -32
- package/src/public/avm/opcodes/misc.ts +24 -16
- package/src/public/avm/opcodes/storage.ts +22 -6
- package/src/public/avm/revert_reason.ts +55 -0
- package/src/public/avm/serialization/buffer_cursor.ts +4 -1
- package/src/public/avm/serialization/bytecode_serialization.ts +72 -74
- package/src/public/avm/serialization/instruction_serialization.ts +63 -34
- package/src/public/avm/test_utils.ts +23 -32
- package/src/public/db_interfaces.ts +61 -0
- package/src/{common → public}/debug_fn_name.ts +7 -7
- package/src/public/executor_metrics.ts +55 -6
- package/src/public/executor_metrics_interface.ts +14 -0
- package/src/public/fixtures/amm_test.ts +331 -0
- package/src/public/fixtures/bulk_test.ts +151 -0
- package/src/public/fixtures/index.ts +6 -0
- package/src/public/fixtures/minimal_public_tx.ts +59 -0
- package/src/public/fixtures/public_tx_simulation_tester.ts +154 -113
- package/src/public/{avm/fixtures → fixtures}/simple_contract_data_source.ts +36 -18
- package/src/public/fixtures/token_test.ts +140 -0
- package/src/public/fixtures/utils.ts +141 -68
- package/src/public/hinting_db_sources.ts +500 -0
- package/src/public/index.ts +4 -8
- package/src/public/public_db_sources.ts +179 -96
- package/src/public/public_processor/guarded_merkle_tree.ts +149 -0
- package/src/public/public_processor/public_processor.ts +179 -139
- package/src/public/public_processor/public_processor_metrics.ts +2 -2
- package/src/public/public_tx_simulator/index.ts +2 -0
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +106 -0
- package/src/public/public_tx_simulator/public_tx_context.ts +153 -193
- package/src/public/public_tx_simulator/public_tx_simulator.ts +167 -211
- package/src/public/public_tx_simulator/telemetry_public_tx_simulator.ts +72 -0
- package/src/public/side_effect_trace.ts +52 -303
- package/src/public/side_effect_trace_interface.ts +4 -58
- package/src/public/state_manager/index.ts +1 -0
- package/src/public/{avm/journal → state_manager}/nullifiers.ts +4 -4
- package/src/public/{avm/journal → state_manager}/public_storage.ts +2 -2
- package/src/public/state_manager/state_manager.ts +512 -0
- package/src/public/test_executor_metrics.ts +395 -0
- package/src/public/utils.ts +5 -21
- package/src/server.ts +6 -3
- package/src/testing.ts +1 -0
- package/dest/common/db_interfaces.d.ts +0 -80
- package/dest/common/db_interfaces.d.ts.map +0 -1
- package/dest/common/db_interfaces.js +0 -1
- package/dest/common/debug_fn_name.d.ts +0 -5
- package/dest/common/debug_fn_name.d.ts.map +0 -1
- package/dest/common/debug_fn_name.js +0 -6
- package/dest/common/message_load_oracle_inputs.d.ts +0 -15
- package/dest/common/message_load_oracle_inputs.d.ts.map +0 -1
- package/dest/common/message_load_oracle_inputs.js +0 -15
- package/dest/private/acvm/oracle/index.d.ts +0 -14
- package/dest/private/acvm/oracle/index.d.ts.map +0 -1
- package/dest/private/acvm/oracle/index.js +0 -2
- package/dest/private/acvm/oracle/oracle.d.ts +0 -49
- package/dest/private/acvm/oracle/oracle.d.ts.map +0 -1
- package/dest/private/acvm/oracle/oracle.js +0 -263
- package/dest/private/acvm/oracle/typed_oracle.d.ts +0 -83
- package/dest/private/acvm/oracle/typed_oracle.d.ts.map +0 -1
- package/dest/private/acvm/oracle/typed_oracle.js +0 -132
- package/dest/private/execution_data_provider.d.ts +0 -261
- package/dest/private/execution_data_provider.d.ts.map +0 -1
- package/dest/private/execution_data_provider.js +0 -14
- package/dest/private/execution_note_cache.d.ts +0 -93
- package/dest/private/execution_note_cache.d.ts.map +0 -1
- package/dest/private/execution_note_cache.js +0 -180
- package/dest/private/hashed_values_cache.d.ts +0 -28
- package/dest/private/hashed_values_cache.d.ts.map +0 -1
- package/dest/private/hashed_values_cache.js +0 -46
- package/dest/private/index.d.ts +0 -13
- package/dest/private/index.d.ts.map +0 -1
- package/dest/private/index.js +0 -12
- package/dest/private/pick_notes.d.ts +0 -85
- package/dest/private/pick_notes.d.ts.map +0 -1
- package/dest/private/pick_notes.js +0 -51
- package/dest/private/private_execution.d.ts +0 -25
- package/dest/private/private_execution.d.ts.map +0 -1
- package/dest/private/private_execution.js +0 -92
- package/dest/private/private_execution_oracle.d.ts +0 -215
- package/dest/private/private_execution_oracle.d.ts.map +0 -1
- package/dest/private/private_execution_oracle.js +0 -382
- package/dest/private/providers/acvm_native.d.ts.map +0 -1
- package/dest/private/providers/acvm_wasm.d.ts +0 -15
- package/dest/private/providers/acvm_wasm.d.ts.map +0 -1
- package/dest/private/providers/acvm_wasm_with_blobs.d.ts +0 -19
- package/dest/private/providers/acvm_wasm_with_blobs.d.ts.map +0 -1
- package/dest/private/providers/acvm_wasm_with_blobs.js +0 -32
- package/dest/private/providers/factory.d.ts +0 -12
- package/dest/private/providers/factory.d.ts.map +0 -1
- package/dest/private/providers/simulation_provider.d.ts +0 -19
- package/dest/private/providers/simulation_provider.d.ts.map +0 -1
- package/dest/private/providers/simulation_provider.js +0 -24
- package/dest/private/simulator.d.ts +0 -34
- package/dest/private/simulator.d.ts.map +0 -1
- package/dest/private/simulator.js +0 -76
- package/dest/private/unconstrained_execution.d.ts +0 -10
- package/dest/private/unconstrained_execution.d.ts.map +0 -1
- package/dest/private/unconstrained_execution.js +0 -27
- package/dest/private/unconstrained_execution_oracle.d.ts +0 -161
- package/dest/private/unconstrained_execution_oracle.d.ts.map +0 -1
- package/dest/private/unconstrained_execution_oracle.js +0 -258
- package/dest/public/avm/bytecode_utils.d.ts +0 -5
- package/dest/public/avm/bytecode_utils.d.ts.map +0 -1
- package/dest/public/avm/bytecode_utils.js +0 -17
- package/dest/public/avm/fixtures/index.d.ts +0 -84
- package/dest/public/avm/fixtures/index.d.ts.map +0 -1
- package/dest/public/avm/fixtures/index.js +0 -175
- package/dest/public/avm/fixtures/simple_contract_data_source.d.ts.map +0 -1
- package/dest/public/avm/journal/index.d.ts +0 -2
- package/dest/public/avm/journal/index.d.ts.map +0 -1
- package/dest/public/avm/journal/index.js +0 -1
- package/dest/public/avm/journal/journal.d.ts.map +0 -1
- package/dest/public/avm/journal/journal.js +0 -486
- package/dest/public/avm/journal/nullifiers.d.ts.map +0 -1
- package/dest/public/avm/journal/public_storage.d.ts.map +0 -1
- package/dest/public/execution.d.ts +0 -108
- package/dest/public/execution.d.ts.map +0 -1
- package/dest/public/execution.js +0 -9
- package/dest/test/utils.d.ts +0 -13
- package/dest/test/utils.d.ts.map +0 -1
- package/dest/test/utils.js +0 -22
- package/src/common/db_interfaces.ts +0 -94
- package/src/common/message_load_oracle_inputs.ts +0 -15
- package/src/private/acvm/oracle/index.ts +0 -16
- package/src/private/acvm/oracle/oracle.ts +0 -455
- package/src/private/acvm/oracle/typed_oracle.ts +0 -259
- package/src/private/execution_data_provider.ts +0 -323
- package/src/private/execution_note_cache.ts +0 -217
- package/src/private/hashed_values_cache.ts +0 -55
- package/src/private/index.ts +0 -16
- package/src/private/pick_notes.ts +0 -141
- package/src/private/private_execution.ts +0 -151
- package/src/private/private_execution_oracle.ts +0 -614
- package/src/private/providers/acvm_wasm.ts +0 -63
- package/src/private/providers/acvm_wasm_with_blobs.ts +0 -50
- package/src/private/providers/simulation_provider.ts +0 -45
- package/src/private/simulator.ts +0 -147
- package/src/private/unconstrained_execution.ts +0 -50
- package/src/private/unconstrained_execution_oracle.ts +0 -373
- package/src/public/avm/bytecode_utils.ts +0 -17
- package/src/public/avm/fixtures/index.ts +0 -296
- package/src/public/avm/journal/index.ts +0 -1
- package/src/public/avm/journal/journal.ts +0 -742
- package/src/public/avm/opcodes/.eslintrc.cjs +0 -8
- package/src/public/execution.ts +0 -140
- package/src/test/utils.ts +0 -36
- /package/dest/public/{avm/journal → state_manager}/public_storage.js +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { MAX_L2_GAS_PER_TX_PUBLIC_PORTION } from '@aztec/constants';
|
|
2
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
4
4
|
import { strict as assert } from 'assert';
|
|
5
5
|
import { SideEffectLimitReachedError } from '../side_effect_errors.js';
|
|
6
6
|
import { AvmContext } from './avm_context.js';
|
|
7
7
|
import { AvmContractCallResult } from './avm_contract_call_result.js';
|
|
8
8
|
import { AvmExecutionEnvironment } from './avm_execution_environment.js';
|
|
9
9
|
import { AvmMachineState } from './avm_machine_state.js';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { AvmExecutionError, AvmRevertReason, InvalidProgramCounterError } from './errors.js';
|
|
11
|
+
import { revertReasonFromExceptionalHalt, revertReasonFromExplicitRevert } from './revert_reason.js';
|
|
12
12
|
import { INSTRUCTION_SET, decodeInstructionFromBytecode } from './serialization/bytecode_serialization.js';
|
|
13
13
|
export class AvmSimulator {
|
|
14
14
|
context;
|
|
@@ -32,7 +32,6 @@ export class AvmSimulator {
|
|
|
32
32
|
// This will be used by the CALL opcode to create a new simulator. It is required to
|
|
33
33
|
// avoid a dependency cycle.
|
|
34
34
|
context.provideSimulator = AvmSimulator.build;
|
|
35
|
-
assert(context.machineState.gasLeft.l2Gas <= MAX_L2_GAS_PER_TX_PUBLIC_PORTION, `Cannot allocate more than ${MAX_L2_GAS_PER_TX_PUBLIC_PORTION} to the AVM for execution.`);
|
|
36
35
|
this.log = createLogger(`simulator:avm(calldata[0]: ${context.environment.calldata[0]})`);
|
|
37
36
|
// Turn on tallying if explicitly enabled or if trace logging
|
|
38
37
|
if (enableTallying || this.log.isLevelEnabled('trace')) {
|
|
@@ -48,8 +47,8 @@ export class AvmSimulator {
|
|
|
48
47
|
simulator.log = createLogger(`simulator:avm(f:${fnName})`);
|
|
49
48
|
return simulator;
|
|
50
49
|
}
|
|
51
|
-
static async create(stateManager, address, sender, transactionFee, globals, isStaticCall, calldata, allocatedGas) {
|
|
52
|
-
const avmExecutionEnv = new AvmExecutionEnvironment(address, sender, /*contractCallDepth=*/ Fr.zero(), transactionFee, globals, isStaticCall, calldata);
|
|
50
|
+
static async create(stateManager, address, sender, transactionFee, globals, isStaticCall, calldata, allocatedGas, clientInitiatedSimulation = false) {
|
|
51
|
+
const avmExecutionEnv = new AvmExecutionEnvironment(address, sender, /*contractCallDepth=*/ Fr.zero(), transactionFee, globals, isStaticCall, calldata, clientInitiatedSimulation);
|
|
53
52
|
const avmMachineState = new AvmMachineState(allocatedGas);
|
|
54
53
|
const avmContext = new AvmContext(stateManager, avmExecutionEnv, avmMachineState);
|
|
55
54
|
return await AvmSimulator.build(avmContext);
|
|
@@ -65,7 +64,7 @@ export class AvmSimulator {
|
|
|
65
64
|
this.log.error(`Unknown error thrown by AVM during bytecode retrieval: ${err}`);
|
|
66
65
|
throw err;
|
|
67
66
|
}
|
|
68
|
-
return await this.handleFailureToRetrieveBytecode(`Bytecode retrieval for contract '${this.context.environment.address}' failed with ${err}. Reverting...`);
|
|
67
|
+
return await this.handleFailureToRetrieveBytecode(`Bytecode retrieval for contract '${this.context.environment.address}' failed with ${err.message}. Reverting...`);
|
|
69
68
|
}
|
|
70
69
|
if (!bytecode) {
|
|
71
70
|
return await this.handleFailureToRetrieveBytecode(`No bytecode found at: ${this.context.environment.address}. Reverting...`);
|
|
@@ -81,8 +80,7 @@ export class AvmSimulator {
|
|
|
81
80
|
* Executes the provided bytecode in the current context.
|
|
82
81
|
* This method is useful for testing and debugging.
|
|
83
82
|
*/ async executeBytecode(bytecode) {
|
|
84
|
-
const
|
|
85
|
-
assert(isAvmBytecode(bytecode), "AVM simulator can't execute non-AVM bytecode");
|
|
83
|
+
const timer = new Timer();
|
|
86
84
|
assert(bytecode.length > 0, "AVM simulator can't execute empty bytecode");
|
|
87
85
|
this.bytecode = bytecode;
|
|
88
86
|
const { machineState } = this.context;
|
|
@@ -90,7 +88,6 @@ export class AvmSimulator {
|
|
|
90
88
|
try {
|
|
91
89
|
// Execute instruction pointed to by the current program counter
|
|
92
90
|
// continuing until the machine state signifies a halt
|
|
93
|
-
let instrCounter = 0;
|
|
94
91
|
while(!machineState.getHalted()){
|
|
95
92
|
// Get the instruction from cache, or deserialize for the first time
|
|
96
93
|
let cachedInstruction = this.deserializedInstructionsCache.get(machineState.pc);
|
|
@@ -102,9 +99,8 @@ export class AvmSimulator {
|
|
|
102
99
|
const instrStartGas = machineState.gasLeft; // Save gas before executing instruction (for profiling)
|
|
103
100
|
if (this.log.isLevelEnabled('trace')) {
|
|
104
101
|
// Skip this entirely to avoid toStringing etc if trace is not enabled
|
|
105
|
-
this.log.trace(`[PC:${machineState.pc}] [IC:${instrCounter}] ${instruction.toString()} (gasLeft l2=${machineState.l2GasLeft} da=${machineState.daGasLeft})`);
|
|
102
|
+
this.log.trace(`[PC:${machineState.pc}] [IC:${machineState.instrCounter}] ${instruction.toString()} (gasLeft l2=${machineState.l2GasLeft} da=${machineState.daGasLeft})`);
|
|
106
103
|
}
|
|
107
|
-
instrCounter++;
|
|
108
104
|
machineState.nextPc = machineState.pc + bytesRead;
|
|
109
105
|
// Execute the instruction.
|
|
110
106
|
// Normal returns and reverts will return normally here.
|
|
@@ -114,6 +110,7 @@ export class AvmSimulator {
|
|
|
114
110
|
// Increment PC if the instruction doesn't handle it itself
|
|
115
111
|
machineState.pc += bytesRead;
|
|
116
112
|
}
|
|
113
|
+
machineState.instrCounter++;
|
|
117
114
|
// gas used by this instruction - used for profiling/tallying
|
|
118
115
|
const gasUsed = {
|
|
119
116
|
l2Gas: instrStartGas.l2Gas - machineState.l2GasLeft,
|
|
@@ -128,17 +125,15 @@ export class AvmSimulator {
|
|
|
128
125
|
const output = machineState.getOutput();
|
|
129
126
|
const reverted = machineState.getReverted();
|
|
130
127
|
const revertReason = reverted ? await revertReasonFromExplicitRevert(output, this.context) : undefined;
|
|
131
|
-
const results = new AvmContractCallResult(reverted, output, machineState.gasLeft, revertReason);
|
|
128
|
+
const results = new AvmContractCallResult(reverted, output, machineState.gasLeft, revertReason, machineState.instrCounter);
|
|
132
129
|
this.log.debug(`Context execution results: ${results.toString()}`);
|
|
133
130
|
const totalGasUsed = {
|
|
134
131
|
l2Gas: callStartGas.l2Gas - machineState.l2GasLeft,
|
|
135
132
|
daGas: callStartGas.daGas - machineState.daGasLeft
|
|
136
133
|
};
|
|
137
|
-
this.log.debug(`Executed ${instrCounter} instructions and consumed ${totalGasUsed.l2Gas} L2 Gas`);
|
|
134
|
+
this.log.debug(`Executed ${machineState.instrCounter} instructions and consumed ${totalGasUsed.l2Gas} L2 Gas`);
|
|
138
135
|
this.tallyPrintFunction();
|
|
139
|
-
|
|
140
|
-
const totalTime = endTotalTime - startTotalTime;
|
|
141
|
-
this.log.debug(`Core AVM simulation took ${totalTime}ms`);
|
|
136
|
+
this.log.debug(`Core AVM simulation took ${timer.ms()}ms`);
|
|
142
137
|
// Return results for processing by calling context
|
|
143
138
|
return results;
|
|
144
139
|
} catch (err) {
|
|
@@ -157,7 +152,7 @@ export class AvmSimulator {
|
|
|
157
152
|
daGas: 0
|
|
158
153
|
};
|
|
159
154
|
// Note: "exceptional halts" cannot return data, hence [].
|
|
160
|
-
const results = new AvmContractCallResult(/*reverted=*/ true, /*output=*/ [], noGasLeft, revertReason);
|
|
155
|
+
const results = new AvmContractCallResult(/*reverted=*/ true, /*output=*/ [], noGasLeft, revertReason, machineState.instrCounter);
|
|
161
156
|
this.log.debug(`Context execution results: ${results.toString()}`);
|
|
162
157
|
this.tallyPrintFunction();
|
|
163
158
|
// Return results for processing by calling context
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for AvmSimulator to break the circular dependency between avm_context.ts and avm_simulator.ts
|
|
3
|
+
*/
|
|
4
|
+
export interface AvmSimulatorInterface {
|
|
5
|
+
execute(): Promise<any>;
|
|
6
|
+
executeBytecode(bytecode: Buffer): Promise<any>;
|
|
7
|
+
getBytecode(): Buffer | undefined;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=avm_simulator_interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avm_simulator_interface.d.ts","sourceRoot":"","sources":["../../../src/public/avm/avm_simulator_interface.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;IACxB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAChD,WAAW,IAAI,MAAM,GAAG,SAAS,CAAC;CACnC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Point } from '@aztec/foundation/fields';
|
|
2
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
import type { FailingFunction, NoirCallStack } from '@aztec/stdlib/errors';
|
|
4
4
|
import { ExecutionError } from '../../common/errors.js';
|
|
5
|
-
import type { AvmContext } from './avm_context.js';
|
|
6
5
|
/**
|
|
7
6
|
* Avm-specific errors should derive from this
|
|
8
7
|
*/
|
|
@@ -105,18 +104,4 @@ export declare class StaticCallAlterationError extends InstructionExecutionError
|
|
|
105
104
|
export declare class AvmRevertReason extends ExecutionError {
|
|
106
105
|
constructor(message: string, failingFunction: FailingFunction, noirCallStack: NoirCallStack, options?: ErrorOptions);
|
|
107
106
|
}
|
|
108
|
-
/**
|
|
109
|
-
* Create a "revert reason" error for an exceptional halt.
|
|
110
|
-
*
|
|
111
|
-
* @param haltingError - the lower-level error causing the exceptional halt
|
|
112
|
-
* @param context - the context of the AVM execution used to extract the failingFunction and noirCallStack
|
|
113
|
-
*/
|
|
114
|
-
export declare function revertReasonFromExceptionalHalt(haltingError: AvmExecutionError, context: AvmContext): Promise<AvmRevertReason>;
|
|
115
|
-
/**
|
|
116
|
-
* Create a "revert reason" error for an explicit revert (a root cause).
|
|
117
|
-
*
|
|
118
|
-
* @param revertData - output data of the explicit REVERT instruction
|
|
119
|
-
* @param context - the context of the AVM execution used to extract the failingFunction and noirCallStack
|
|
120
|
-
*/
|
|
121
|
-
export declare function revertReasonFromExplicitRevert(revertData: Fr[], context: AvmContext): Promise<AvmRevertReason>;
|
|
122
107
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/public/avm/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/public/avm/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD;;GAEG;AACH,8BAAsB,iBAAkB,SAAQ,KAAK;gBACvC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,0BAA2B,SAAQ,iBAAiB;gBACnD,eAAe,EAAE,YAAY;CAI1C;AAED,qBAAa,eAAgB,SAAQ,iBAAiB;gBACxC,OAAO,EAAE,MAAM;CAI5B;AAED;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,iBAAiB;gBACnD,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;CAIpC;AAED;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,iBAAiB;gBAC3C,GAAG,EAAE,MAAM;CAIxB;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,iBAAiB;gBACxC,GAAG,EAAE,MAAM;CAIxB;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,iBAAiB;gBAC7C,QAAQ,EAAE,MAAM;CAI7B;AAED;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,iBAAiB;gBAClD,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,iBAAiB;WACpC,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa;WAI7E,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa;gBAI5D,OAAO,EAAE,MAAM;CAI5B;AAED;;;GAGG;AACH,qBAAa,8BAA+B,SAAQ,iBAAiB;gBACvD,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAIhD;AAED;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,iBAAiB;gBACnD,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAI3C;AAED,oCAAoC;AACpC,qBAAa,aAAc,SAAQ,iBAAiB;gBACtC,UAAU,EAAE,MAAM,EAAE;CAIjC;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,iBAAiB;gBAC7C,gBAAgB,EAAE,MAAM;CAIrC;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,iBAAiB;gBAChD,KAAK,EAAE,KAAK;CAIzB;AAED;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,iBAAiB;gBAClD,WAAW,EAAE,MAAM;CAIhC;AAED;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,yBAAyB;;CAKvE;AAED;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,cAAc;gBACrC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,YAAY;CAGpH"}
|
|
@@ -140,40 +140,3 @@ export class ArithmeticError extends AvmExecutionError {
|
|
|
140
140
|
super(message, failingFunction, noirCallStack, options);
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
async function createRevertReason(message, revertData, context) {
|
|
144
|
-
// We drop the returnPc information.
|
|
145
|
-
const internalCallStack = context.machineState.internalCallStack.map((entry)=>entry.callPc);
|
|
146
|
-
// If we are reverting due to the same error that we have been tracking, we use the nested error as the cause.
|
|
147
|
-
let nestedError = undefined;
|
|
148
|
-
const revertDataEquals = (a, b)=>a.length === b.length && a.every((v, i)=>v.equals(b[i]));
|
|
149
|
-
if (context.machineState.collectedRevertInfo && revertDataEquals(context.machineState.collectedRevertInfo.revertDataRepresentative, revertData)) {
|
|
150
|
-
nestedError = context.machineState.collectedRevertInfo.recursiveRevertReason;
|
|
151
|
-
message = context.machineState.collectedRevertInfo.recursiveRevertReason.message;
|
|
152
|
-
}
|
|
153
|
-
const fnName = await context.persistableState.getPublicFunctionDebugName(context.environment);
|
|
154
|
-
return new AvmRevertReason(message, /*failingFunction=*/ {
|
|
155
|
-
contractAddress: context.environment.address,
|
|
156
|
-
functionName: fnName
|
|
157
|
-
}, /*noirCallStack=*/ [
|
|
158
|
-
...internalCallStack,
|
|
159
|
-
context.machineState.pc
|
|
160
|
-
].map((pc)=>`0.${pc}`), /*options=*/ {
|
|
161
|
-
cause: nestedError
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Create a "revert reason" error for an exceptional halt.
|
|
166
|
-
*
|
|
167
|
-
* @param haltingError - the lower-level error causing the exceptional halt
|
|
168
|
-
* @param context - the context of the AVM execution used to extract the failingFunction and noirCallStack
|
|
169
|
-
*/ export async function revertReasonFromExceptionalHalt(haltingError, context) {
|
|
170
|
-
return await createRevertReason(haltingError.message, [], context);
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Create a "revert reason" error for an explicit revert (a root cause).
|
|
174
|
-
*
|
|
175
|
-
* @param revertData - output data of the explicit REVERT instruction
|
|
176
|
-
* @param context - the context of the AVM execution used to extract the failingFunction and noirCallStack
|
|
177
|
-
*/ export async function revertReasonFromExplicitRevert(revertData, context) {
|
|
178
|
-
return await createRevertReason('Assertion failed: ', revertData, context);
|
|
179
|
-
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
2
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
3
3
|
import type { AvmContractCallResult } from '../../avm/avm_contract_call_result.js';
|
|
4
|
-
import {
|
|
4
|
+
import { SimpleContractDataSource } from '../../fixtures/simple_contract_data_source.js';
|
|
5
|
+
import { PublicPersistableStateManager } from '../../state_manager/state_manager.js';
|
|
5
6
|
import { BaseAvmSimulationTester } from './base_avm_simulation_tester.js';
|
|
6
|
-
import { SimpleContractDataSource } from './simple_contract_data_source.js';
|
|
7
7
|
/**
|
|
8
8
|
* A test class that extends the BaseAvmSimulationTester to enable real-app testing of the core AvmSimulator.
|
|
9
9
|
* It provides an interface for simulating one top-level call at a time and maintains state between
|
|
@@ -11,7 +11,7 @@ import { SimpleContractDataSource } from './simple_contract_data_source.js';
|
|
|
11
11
|
*/
|
|
12
12
|
export declare class AvmSimulationTester extends BaseAvmSimulationTester {
|
|
13
13
|
private stateManager;
|
|
14
|
-
constructor(contractDataSource: SimpleContractDataSource, merkleTrees: MerkleTreeWriteOperations, stateManager:
|
|
14
|
+
constructor(contractDataSource: SimpleContractDataSource, merkleTrees: MerkleTreeWriteOperations, stateManager: PublicPersistableStateManager);
|
|
15
15
|
static create(): Promise<AvmSimulationTester>;
|
|
16
16
|
/**
|
|
17
17
|
* Simulate a top-level contract call.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avm_simulation_tester.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/fixtures/avm_simulation_tester.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAKjF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"avm_simulation_tester.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/fixtures/avm_simulation_tester.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAKjF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AACnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAEzF,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AAErF,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAW1E;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,uBAAuB;IAI5D,OAAO,CAAC,YAAY;gBAFpB,kBAAkB,EAAE,wBAAwB,EAC5C,WAAW,EAAE,yBAAyB,EAC9B,YAAY,EAAE,6BAA6B;WAKxC,MAAM,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAmBnD;;OAEG;IACG,YAAY,CAChB,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,GAAG,EAAE,EACX,YAAY,UAAQ,GACnB,OAAO,CAAC,qBAAqB,CAAC;CAsClC"}
|
|
@@ -4,13 +4,13 @@ import { GasFees } from '@aztec/stdlib/gas';
|
|
|
4
4
|
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
5
5
|
import { NativeWorldStateService } from '@aztec/world-state';
|
|
6
6
|
import { SideEffectTrace } from '../../../public/side_effect_trace.js';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { SimpleContractDataSource } from '../../fixtures/simple_contract_data_source.js';
|
|
8
|
+
import { PublicContractsDB, PublicTreesDB } from '../../public_db_sources.js';
|
|
9
|
+
import { PublicPersistableStateManager } from '../../state_manager/state_manager.js';
|
|
10
10
|
import { AvmSimulator } from '../avm_simulator.js';
|
|
11
11
|
import { BaseAvmSimulationTester } from './base_avm_simulation_tester.js';
|
|
12
|
-
import {
|
|
13
|
-
|
|
12
|
+
import { initContext, initExecutionEnvironment } from './initializers.js';
|
|
13
|
+
import { DEFAULT_TIMESTAMP, getContractFunctionAbi, getFunctionSelector, resolveContractAssertionMessage } from './utils.js';
|
|
14
14
|
const DEFAULT_GAS_FEES = new GasFees(2, 3);
|
|
15
15
|
/**
|
|
16
16
|
* A test class that extends the BaseAvmSimulationTester to enable real-app testing of the core AvmSimulator.
|
|
@@ -24,12 +24,11 @@ const DEFAULT_GAS_FEES = new GasFees(2, 3);
|
|
|
24
24
|
static async create() {
|
|
25
25
|
const contractDataSource = new SimpleContractDataSource();
|
|
26
26
|
const merkleTrees = await (await NativeWorldStateService.tmp()).fork();
|
|
27
|
-
const
|
|
27
|
+
const treesDB = new PublicTreesDB(merkleTrees);
|
|
28
|
+
const contractsDB = new PublicContractsDB(contractDataSource);
|
|
28
29
|
const trace = new SideEffectTrace();
|
|
29
30
|
const firstNullifier = new Fr(420000);
|
|
30
|
-
|
|
31
|
-
// failures on 2nd call to simulateCall with merkle ops on
|
|
32
|
-
const stateManager = AvmPersistableStateManager.create(worldStateDB, trace, /*doMerkleOperations=*/ false, firstNullifier);
|
|
31
|
+
const stateManager = PublicPersistableStateManager.create(treesDB, contractsDB, trace, /*doMerkleOperations=*/ false, firstNullifier, DEFAULT_TIMESTAMP);
|
|
33
32
|
return new AvmSimulationTester(contractDataSource, merkleTrees, stateManager);
|
|
34
33
|
}
|
|
35
34
|
/**
|
|
@@ -40,14 +39,14 @@ const DEFAULT_GAS_FEES = new GasFees(2, 3);
|
|
|
40
39
|
throw new Error(`Contract not found at address: ${address}`);
|
|
41
40
|
}
|
|
42
41
|
const fnSelector = await getFunctionSelector(fnName, contractArtifact);
|
|
43
|
-
const fnAbi =
|
|
42
|
+
const fnAbi = getContractFunctionAbi(fnName, contractArtifact);
|
|
44
43
|
const encodedArgs = encodeArguments(fnAbi, args);
|
|
45
44
|
const calldata = [
|
|
46
45
|
fnSelector.toField(),
|
|
47
46
|
...encodedArgs
|
|
48
47
|
];
|
|
49
48
|
const globals = GlobalVariables.empty();
|
|
50
|
-
globals.timestamp =
|
|
49
|
+
globals.timestamp = DEFAULT_TIMESTAMP;
|
|
51
50
|
globals.gasFees = DEFAULT_GAS_FEES;
|
|
52
51
|
const environment = initExecutionEnvironment({
|
|
53
52
|
calldata,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
5
5
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
6
|
-
import type { SimpleContractDataSource } from '
|
|
6
|
+
import type { SimpleContractDataSource } from '../../fixtures/simple_contract_data_source.js';
|
|
7
7
|
/**
|
|
8
8
|
* An abstract test class that enables tests of real apps in the AVM without requiring e2e tests.
|
|
9
9
|
* It enables this by letting us (1) perform pseudo-contract-deployments (and registrations)
|
|
@@ -27,10 +27,10 @@ export declare abstract class BaseAvmSimulationTester {
|
|
|
27
27
|
* Derive the contract class and instance with some seed.
|
|
28
28
|
* Add both to the contract data source along with the contract artifact.
|
|
29
29
|
*/
|
|
30
|
-
registerAndDeployContract(constructorArgs: any[], deployer: AztecAddress, contractArtifact: ContractArtifact, skipNullifierInsertion?: boolean, seed?: number, originalContractClassId?: Fr): Promise<ContractInstanceWithAddress>;
|
|
30
|
+
registerAndDeployContract(constructorArgs: any[], deployer: AztecAddress, contractArtifact: ContractArtifact, skipNullifierInsertion?: boolean, seed?: number, contractClassSeed?: number, originalContractClassId?: Fr): Promise<ContractInstanceWithAddress>;
|
|
31
31
|
registerFeeJuiceContract(): Promise<ContractInstanceWithAddress>;
|
|
32
|
-
addContractClass(contractClass: ContractClassPublic, contractArtifact: ContractArtifact): Promise<void>;
|
|
33
32
|
addContractInstance(contractInstance: ContractInstanceWithAddress, skipNullifierInsertion?: boolean): Promise<void>;
|
|
34
33
|
private insertContractAddressNullifier;
|
|
34
|
+
insertNullifier(contractThatEmitted: AztecAddress, nullifier: Fr): Promise<void>;
|
|
35
35
|
}
|
|
36
36
|
//# sourceMappingURL=base_avm_simulation_tester.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base_avm_simulation_tester.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/fixtures/base_avm_simulation_tester.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAI9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"base_avm_simulation_tester.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/fixtures/base_avm_simulation_tester.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAI9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAGjF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAG9F;;;;;;;;;;GAUG;AACH,8BAAsB,uBAAuB;IAIlC,kBAAkB,EAAE,wBAAwB;IAC5C,WAAW,EAAE,yBAAyB;IAC7C,OAAO,CAAC,sBAAsB;IALzB,MAAM,yCAAyC;gBAG7C,kBAAkB,EAAE,wBAAwB,EAC5C,WAAW,EAAE,yBAAyB,EACrC,sBAAsB,KAAmB;IAG7C,kBAAkB,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,KAA8B;IAMhF,gBAAgB,CAAC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE;IAOjE;;;OAGG;IACG,yBAAyB,CAC7B,eAAe,EAAE,GAAG,EAAE,EACtB,QAAQ,EAAE,YAAY,EACtB,gBAAgB,EAAE,gBAAgB,EAClC,sBAAsB,UAAQ,EAC9B,IAAI,SAAI,EACR,iBAAiB,SAAO,EACxB,uBAAuB,CAAC,EAAE,EAAE,GAC3B,OAAO,CAAC,2BAA2B,CAAC;IAkBjC,wBAAwB,IAAI,OAAO,CAAC,2BAA2B,CAAC;IAWhE,mBAAmB,CAAC,gBAAgB,EAAE,2BAA2B,EAAE,sBAAsB,UAAQ;YAOzF,8BAA8B;IAQtC,eAAe,CAAC,mBAAmB,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE;CAIvE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS } from '@aztec/constants';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
@@ -7,7 +7,7 @@ import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
|
7
7
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
8
|
import { computePublicDataTreeLeafSlot, siloNullifier } from '@aztec/stdlib/hash';
|
|
9
9
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
10
|
-
import { createContractClassAndInstance } from './
|
|
10
|
+
import { createContractClassAndInstance } from './utils.js';
|
|
11
11
|
/**
|
|
12
12
|
* An abstract test class that enables tests of real apps in the AVM without requiring e2e tests.
|
|
13
13
|
* It enables this by letting us (1) perform pseudo-contract-deployments (and registrations)
|
|
@@ -38,15 +38,15 @@ import { createContractClassAndInstance } from './index.js';
|
|
|
38
38
|
const leafSlot = await computePublicDataTreeLeafSlot(address, slot);
|
|
39
39
|
// get existing preimage
|
|
40
40
|
const publicDataWrite = new PublicDataWrite(leafSlot, value);
|
|
41
|
-
await this.merkleTrees.
|
|
41
|
+
await this.merkleTrees.sequentialInsert(MerkleTreeId.PUBLIC_DATA_TREE, [
|
|
42
42
|
publicDataWrite.toBuffer()
|
|
43
|
-
]
|
|
43
|
+
]);
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Derive the contract class and instance with some seed.
|
|
47
47
|
* Add both to the contract data source along with the contract artifact.
|
|
48
|
-
*/ async registerAndDeployContract(constructorArgs, deployer, contractArtifact, skipNullifierInsertion = false, seed = 0, originalContractClassId) {
|
|
49
|
-
const { contractClass, contractInstance } = await createContractClassAndInstance(constructorArgs, deployer, contractArtifact, seed, originalContractClassId);
|
|
48
|
+
*/ async registerAndDeployContract(constructorArgs, deployer, contractArtifact, skipNullifierInsertion = false, seed = 0, contractClassSeed = seed, originalContractClassId) {
|
|
49
|
+
const { contractClass, contractInstance } = await createContractClassAndInstance(constructorArgs, deployer, contractArtifact, seed, contractClassSeed, originalContractClassId);
|
|
50
50
|
await this.contractDataSource.addNewContract(contractArtifact, contractClass, contractInstance);
|
|
51
51
|
if (!skipNullifierInsertion) {
|
|
52
52
|
await this.insertContractAddressNullifier(contractInstance.address);
|
|
@@ -58,16 +58,11 @@ import { createContractClassAndInstance } from './index.js';
|
|
|
58
58
|
const feeJuiceContractClassPublic = {
|
|
59
59
|
...feeJuice.contractClass,
|
|
60
60
|
privateFunctions: [],
|
|
61
|
-
|
|
61
|
+
utilityFunctions: []
|
|
62
62
|
};
|
|
63
63
|
await this.contractDataSource.addNewContract(feeJuice.artifact, feeJuiceContractClassPublic, feeJuice.instance);
|
|
64
64
|
return feeJuice.instance;
|
|
65
65
|
}
|
|
66
|
-
addContractClass(contractClass, contractArtifact) {
|
|
67
|
-
this.logger.debug(`Adding contract class with Id ${contractClass.id}`);
|
|
68
|
-
this.contractDataSource.addContractArtifact(contractClass.id, contractArtifact);
|
|
69
|
-
return this.contractDataSource.addContractClass(contractClass);
|
|
70
|
-
}
|
|
71
66
|
async addContractInstance(contractInstance, skipNullifierInsertion = false) {
|
|
72
67
|
if (!skipNullifierInsertion) {
|
|
73
68
|
await this.insertContractAddressNullifier(contractInstance.address);
|
|
@@ -75,9 +70,15 @@ import { createContractClassAndInstance } from './index.js';
|
|
|
75
70
|
await this.contractDataSource.addContractInstance(contractInstance);
|
|
76
71
|
}
|
|
77
72
|
async insertContractAddressNullifier(contractAddress) {
|
|
78
|
-
const contractAddressNullifier = await siloNullifier(AztecAddress.fromNumber(
|
|
79
|
-
await this.merkleTrees.
|
|
73
|
+
const contractAddressNullifier = await siloNullifier(AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), contractAddress.toField());
|
|
74
|
+
await this.merkleTrees.sequentialInsert(MerkleTreeId.NULLIFIER_TREE, [
|
|
80
75
|
contractAddressNullifier.toBuffer()
|
|
81
|
-
]
|
|
76
|
+
]);
|
|
77
|
+
}
|
|
78
|
+
async insertNullifier(contractThatEmitted, nullifier) {
|
|
79
|
+
const siloedNullifier = await siloNullifier(contractThatEmitted, nullifier);
|
|
80
|
+
await this.merkleTrees.sequentialInsert(MerkleTreeId.NULLIFIER_TREE, [
|
|
81
|
+
siloedNullifier.toBuffer()
|
|
82
|
+
]);
|
|
82
83
|
}
|
|
83
84
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
3
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
4
|
+
import type { PublicContractsDB, PublicTreesDB } from '../../public_db_sources.js';
|
|
5
|
+
import type { PublicSideEffectTraceInterface } from '../../side_effect_trace_interface.js';
|
|
6
|
+
import { NullifierManager } from '../../state_manager/nullifiers.js';
|
|
7
|
+
import { PublicStorage } from '../../state_manager/public_storage.js';
|
|
8
|
+
import { PublicPersistableStateManager } from '../../state_manager/state_manager.js';
|
|
9
|
+
import { AvmContext } from '../avm_context.js';
|
|
10
|
+
import { AvmExecutionEnvironment } from '../avm_execution_environment.js';
|
|
11
|
+
import { AvmMachineState } from '../avm_machine_state.js';
|
|
12
|
+
/**
|
|
13
|
+
* Create a new AVM context with default values.
|
|
14
|
+
*/
|
|
15
|
+
export declare function initContext(overrides?: {
|
|
16
|
+
persistableState?: PublicPersistableStateManager;
|
|
17
|
+
env?: AvmExecutionEnvironment;
|
|
18
|
+
machineState?: AvmMachineState;
|
|
19
|
+
}): AvmContext;
|
|
20
|
+
/** Creates an empty state manager with mocked host storage. */
|
|
21
|
+
export declare function initPersistableStateManager(overrides?: {
|
|
22
|
+
treesDB?: PublicTreesDB;
|
|
23
|
+
contractsDB?: PublicContractsDB;
|
|
24
|
+
trace?: PublicSideEffectTraceInterface;
|
|
25
|
+
publicStorage?: PublicStorage;
|
|
26
|
+
nullifiers?: NullifierManager;
|
|
27
|
+
doMerkleOperations?: boolean;
|
|
28
|
+
firstNullifier?: Fr;
|
|
29
|
+
timestamp?: UInt64;
|
|
30
|
+
}): PublicPersistableStateManager;
|
|
31
|
+
/**
|
|
32
|
+
* Create an empty instance of the Execution Environment where all values are zero, unless overridden in the overrides object
|
|
33
|
+
*/
|
|
34
|
+
export declare function initExecutionEnvironment(overrides?: Partial<AvmExecutionEnvironment>): AvmExecutionEnvironment;
|
|
35
|
+
/**
|
|
36
|
+
* Create an empty instance of the Execution Environment where all values are zero, unless overridden in the overrides object
|
|
37
|
+
*/
|
|
38
|
+
export declare function initGlobalVariables(overrides?: Partial<GlobalVariables>): GlobalVariables;
|
|
39
|
+
/**
|
|
40
|
+
* Create an empty instance of the Machine State where all values are set to a large enough amount, unless overridden in the overrides object
|
|
41
|
+
*/
|
|
42
|
+
export declare function initMachineState(overrides?: Partial<AvmMachineState>): AvmMachineState;
|
|
43
|
+
//# sourceMappingURL=initializers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initializers.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/fixtures/initializers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAIlD,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACnF,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAI1D;;GAEG;AACH,wBAAgB,WAAW,CAAC,SAAS,CAAC,EAAE;IACtC,gBAAgB,CAAC,EAAE,6BAA6B,CAAC;IACjD,GAAG,CAAC,EAAE,uBAAuB,CAAC;IAC9B,YAAY,CAAC,EAAE,eAAe,CAAC;CAChC,GAAG,UAAU,CAQb;AAED,+DAA+D;AAC/D,wBAAgB,2BAA2B,CAAC,SAAS,CAAC,EAAE;IACtD,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,KAAK,CAAC,EAAE,8BAA8B,CAAC;IACvC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,cAAc,CAAC,EAAE,EAAE,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,6BAA6B,CAYhC;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,GAAG,uBAAuB,CAW9G;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAWzF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAKtF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { AVM_MAX_PROCESSABLE_L2_GAS } from '@aztec/constants';
|
|
2
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import { GasFees } from '@aztec/stdlib/gas';
|
|
6
|
+
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
7
|
+
import { mock } from 'jest-mock-extended';
|
|
8
|
+
import { PublicPersistableStateManager } from '../../state_manager/state_manager.js';
|
|
9
|
+
import { AvmContext } from '../avm_context.js';
|
|
10
|
+
import { AvmExecutionEnvironment } from '../avm_execution_environment.js';
|
|
11
|
+
import { AvmMachineState } from '../avm_machine_state.js';
|
|
12
|
+
import { AvmSimulator } from '../avm_simulator.js';
|
|
13
|
+
import { DEFAULT_TIMESTAMP } from './utils.js';
|
|
14
|
+
/**
|
|
15
|
+
* Create a new AVM context with default values.
|
|
16
|
+
*/ export function initContext(overrides) {
|
|
17
|
+
const ctx = new AvmContext(overrides?.persistableState || initPersistableStateManager(), overrides?.env || initExecutionEnvironment(), overrides?.machineState || initMachineState());
|
|
18
|
+
ctx.provideSimulator = AvmSimulator.build;
|
|
19
|
+
return ctx;
|
|
20
|
+
}
|
|
21
|
+
/** Creates an empty state manager with mocked host storage. */ export function initPersistableStateManager(overrides) {
|
|
22
|
+
const treesDB = overrides?.treesDB || mock();
|
|
23
|
+
return new PublicPersistableStateManager(treesDB, overrides?.contractsDB || mock(), overrides?.trace || mock(), overrides?.firstNullifier || new Fr(27), overrides?.timestamp || DEFAULT_TIMESTAMP, overrides?.doMerkleOperations || false, overrides?.publicStorage, overrides?.nullifiers);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create an empty instance of the Execution Environment where all values are zero, unless overridden in the overrides object
|
|
27
|
+
*/ export function initExecutionEnvironment(overrides) {
|
|
28
|
+
return new AvmExecutionEnvironment(overrides?.address ?? AztecAddress.zero(), overrides?.sender ?? AztecAddress.zero(), overrides?.contractCallDepth ?? Fr.zero(), overrides?.transactionFee ?? Fr.zero(), overrides?.globals ?? GlobalVariables.empty(), overrides?.isStaticCall ?? false, overrides?.calldata ?? [], overrides?.clientInitiatedSimulation ?? true);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create an empty instance of the Execution Environment where all values are zero, unless overridden in the overrides object
|
|
32
|
+
*/ export function initGlobalVariables(overrides) {
|
|
33
|
+
return new GlobalVariables(overrides?.chainId ?? Fr.zero(), overrides?.version ?? Fr.zero(), overrides?.blockNumber ?? 0, overrides?.slotNumber ?? Fr.zero(), overrides?.timestamp ?? 0n, overrides?.coinbase ?? EthAddress.ZERO, overrides?.feeRecipient ?? AztecAddress.zero(), overrides?.gasFees ?? GasFees.empty());
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Create an empty instance of the Machine State where all values are set to a large enough amount, unless overridden in the overrides object
|
|
37
|
+
*/ export function initMachineState(overrides) {
|
|
38
|
+
return AvmMachineState.fromState({
|
|
39
|
+
l2GasLeft: overrides?.l2GasLeft ?? AVM_MAX_PROCESSABLE_L2_GAS,
|
|
40
|
+
daGasLeft: overrides?.daGasLeft ?? 1e8
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { type ContractArtifact, type FunctionAbi, type FunctionArtifact, FunctionSelector } from '@aztec/stdlib/abi';
|
|
3
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import { type ContractClassPublic, type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
5
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
6
|
+
import { Field, Uint8, Uint32, Uint64 } from '../avm_memory_types.js';
|
|
7
|
+
import type { AvmRevertReason } from '../errors.js';
|
|
8
|
+
export declare const PUBLIC_DISPATCH_FN_NAME = "public_dispatch";
|
|
9
|
+
export declare const DEFAULT_TIMESTAMP: UInt64;
|
|
10
|
+
export declare const DEFAULT_BLOCK_NUMBER = 42;
|
|
11
|
+
/**
|
|
12
|
+
* Create a new object with all the same properties as the original, except for the ones in the overrides object.
|
|
13
|
+
*/
|
|
14
|
+
export declare function allSameExcept(original: any, overrides: any): any;
|
|
15
|
+
export declare function randomMemoryBytes(length: number): Uint8[];
|
|
16
|
+
export declare function randomMemoryUint32s(length: number): Uint32[];
|
|
17
|
+
export declare function randomMemoryUint64s(length: number): Uint64[];
|
|
18
|
+
export declare function randomMemoryFields(length: number): Field[];
|
|
19
|
+
export declare function getFunctionSelector(functionName: string, contractArtifact: ContractArtifact): Promise<FunctionSelector>;
|
|
20
|
+
export declare function getContractFunctionArtifact(functionName: string, contractArtifact: ContractArtifact): FunctionArtifact | undefined;
|
|
21
|
+
export declare function getContractFunctionAbi(functionName: string, contractArtifact: ContractArtifact): FunctionAbi | undefined;
|
|
22
|
+
export declare function resolveContractAssertionMessage(functionName: string, revertReason: AvmRevertReason, output: Fr[], contractArtifact: ContractArtifact): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Create a contract class and instance given constructor args, artifact, etc.
|
|
25
|
+
* NOTE: This is useful for testing real-ish contract class registration and instance deployment TXs (via logs)
|
|
26
|
+
* @param constructorArgs - The constructor arguments for the contract.
|
|
27
|
+
* @param deployer - The deployer of the contract.
|
|
28
|
+
* @param contractArtifact - The contract artifact for the contract.
|
|
29
|
+
* @param seed - The seed for the contract.
|
|
30
|
+
* @param originalContractClassId - The original contract class ID (if upgraded)
|
|
31
|
+
* @returns The contract class, instance, and contract address nullifier.
|
|
32
|
+
*/
|
|
33
|
+
export declare function createContractClassAndInstance(constructorArgs: any[], deployer: AztecAddress, contractArtifact: ContractArtifact, seed?: number, contractClassSeed?: number, originalContractClassId?: Fr): Promise<{
|
|
34
|
+
contractClass: ContractClassPublic;
|
|
35
|
+
contractInstance: ContractInstanceWithAddress;
|
|
36
|
+
contractAddressNullifier: Fr;
|
|
37
|
+
}>;
|
|
38
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/fixtures/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,gBAAgB,EAEjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAEjC,MAAM,wBAAwB,CAAC;AAKhC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAMlD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,eAAO,MAAM,uBAAuB,oBAAoB,CAAC;AACzD,eAAO,MAAM,iBAAiB,EAAE,MAAe,CAAC;AAChD,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,GAAG,GAAG,CAEhE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,CAEzD;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAE5D;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAE5D;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,CAE1D;AAED,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,gBAAgB,GACjC,OAAO,CAAC,gBAAgB,CAAC,CAK3B;AAED,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,gBAAgB,GACjC,gBAAgB,GAAG,SAAS,CAE9B;AAED,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,gBAAgB,GACjC,WAAW,GAAG,SAAS,CAKzB;AAED,wBAAgB,+BAA+B,CAC7C,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,eAAe,EAC7B,MAAM,EAAE,EAAE,EAAE,EACZ,gBAAgB,EAAE,gBAAgB,GACjC,MAAM,GAAG,SAAS,CAWpB;AAED;;;;;;;;;GASG;AACH,wBAAsB,8BAA8B,CAClD,eAAe,EAAE,GAAG,EAAE,EACtB,QAAQ,EAAE,YAAY,EACtB,gBAAgB,EAAE,gBAAgB,EAClC,IAAI,SAAI,EACR,iBAAiB,SAAO,EACxB,uBAAuB,CAAC,EAAE,EAAE,GAC3B,OAAO,CAAC;IACT,aAAa,EAAE,mBAAmB,CAAC;IACnC,gBAAgB,EAAE,2BAA2B,CAAC;IAC9C,wBAAwB,EAAE,EAAE,CAAC;CAC9B,CAAC,CA4BD"}
|