@aztec/simulator 0.0.0-test.1 → 0.0.1-fake-c83136db25
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} +9 -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 +3 -1
- package/dest/public/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/public/avm/avm_execution_environment.js +7 -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 +23 -35
- 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 +6 -30
- package/dest/public/avm/errors.d.ts.map +1 -1
- package/dest/public/avm/errors.js +7 -57
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts +5 -4
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.js +12 -14
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +6 -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 +37 -14
- 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 +2 -2
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/public/avm/opcodes/accrued_substate.js +28 -25
- 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 +46 -26
- 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 +267 -3
- package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -1
- package/dest/public/avm/opcodes/ec_add.js +6 -6
- 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 +17 -19
- 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 -34
- 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 +23 -19
- 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 +2 -1
- package/dest/public/avm/opcodes/misc.d.ts.map +1 -1
- package/dest/public/avm/opcodes/misc.js +41 -16
- 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 +13 -4
- package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/instruction_serialization.js +70 -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 +16 -24
- 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 +326 -0
- package/dest/public/fixtures/custom_bytecode_tester.d.ts +12 -0
- package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -0
- package/dest/public/fixtures/custom_bytecode_tester.js +29 -0
- package/dest/public/fixtures/custom_bytecode_tests.d.ts +9 -0
- package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -0
- package/dest/public/fixtures/custom_bytecode_tests.js +109 -0
- package/dest/public/fixtures/index.d.ts +7 -0
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +7 -0
- package/dest/public/fixtures/minimal_public_tx.d.ts +10 -0
- package/dest/public/fixtures/minimal_public_tx.d.ts.map +1 -0
- package/dest/public/fixtures/minimal_public_tx.js +29 -0
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +35 -13
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +96 -71
- 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 +70 -0
- package/dest/public/hinting_db_sources.d.ts.map +1 -0
- package/dest/public/hinting_db_sources.js +297 -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 +151 -67
- package/dest/public/public_errors.d.ts +12 -0
- package/dest/public/public_errors.d.ts.map +1 -0
- package/dest/public/public_errors.js +13 -0
- package/dest/public/public_processor/guarded_merkle_tree.d.ts +49 -0
- package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -0
- package/dest/public/public_processor/guarded_merkle_tree.js +108 -0
- package/dest/public/public_processor/public_processor.d.ts +25 -30
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +141 -96
- 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/cpp_public_tx_simulator.d.ts +41 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +89 -0
- package/dest/public/public_tx_simulator/index.d.ts +4 -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 +24 -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 +51 -0
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +19 -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 +63 -91
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +45 -47
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +209 -184
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts +9 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.js +1 -0
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts +21 -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_errors.d.ts +41 -1
- package/dest/public/side_effect_errors.d.ts.map +1 -1
- package/dest/public/side_effect_errors.js +70 -1
- package/dest/public/side_effect_trace.d.ts +20 -65
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +71 -121
- package/dest/public/side_effect_trace_interface.d.ts +11 -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 -5
- package/dest/public/state_manager/nullifiers.d.ts.map +1 -0
- package/dest/public/{avm/journal → state_manager}/nullifiers.js +3 -8
- 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} +42 -85
- package/dest/public/state_manager/state_manager.d.ts.map +1 -0
- package/dest/public/state_manager/state_manager.js +391 -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 +36 -31
- 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} +30 -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 +10 -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 +44 -54
- package/src/public/avm/avm_simulator_interface.ts +8 -0
- package/src/public/avm/errors.ts +8 -77
- package/src/public/avm/fixtures/avm_simulation_tester.ts +23 -20
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +45 -12
- package/src/public/avm/fixtures/initializers.ts +104 -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 +64 -29
- package/src/public/avm/opcodes/addressing_mode.ts +56 -32
- 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 +27 -3
- package/src/public/avm/opcodes/ec_add.ts +9 -6
- package/src/public/avm/opcodes/environment_getters.ts +27 -22
- package/src/public/avm/opcodes/external_calls.ts +61 -29
- package/src/public/avm/opcodes/hashing.ts +28 -8
- package/src/public/avm/opcodes/instruction.ts +31 -21
- package/src/public/avm/opcodes/memory.ts +71 -32
- package/src/public/avm/opcodes/misc.ts +60 -18
- 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 +75 -34
- package/src/public/avm/test_utils.ts +24 -41
- 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 +169 -0
- package/src/public/fixtures/custom_bytecode_tester.ts +49 -0
- package/src/public/fixtures/custom_bytecode_tests.ts +135 -0
- package/src/public/fixtures/index.ts +7 -0
- package/src/public/fixtures/minimal_public_tx.ts +36 -0
- package/src/public/fixtures/public_tx_simulation_tester.ts +158 -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 +505 -0
- package/src/public/index.ts +9 -8
- package/src/public/public_db_sources.ts +196 -97
- package/src/public/public_errors.ts +14 -0
- package/src/public/public_processor/guarded_merkle_tree.ts +153 -0
- package/src/public/public_processor/public_processor.ts +191 -153
- package/src/public/public_processor/public_processor_metrics.ts +2 -2
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +128 -0
- package/src/public/public_tx_simulator/index.ts +3 -0
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +109 -0
- package/src/public/public_tx_simulator/public_tx_context.ts +160 -193
- package/src/public/public_tx_simulator/public_tx_simulator.ts +294 -220
- package/src/public/public_tx_simulator/public_tx_simulator_interface.ts +11 -0
- package/src/public/public_tx_simulator/telemetry_public_tx_simulator.ts +63 -0
- package/src/public/side_effect_errors.ts +91 -1
- package/src/public/side_effect_trace.ts +94 -320
- package/src/public/side_effect_trace_interface.ts +10 -58
- package/src/public/state_manager/index.ts +1 -0
- package/src/public/{avm/journal → state_manager}/nullifiers.ts +5 -11
- package/src/public/{avm/journal → state_manager}/public_storage.ts +2 -2
- package/src/public/state_manager/state_manager.ts +560 -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/bytecode_errors.d.ts +0 -4
- package/dest/public/bytecode_errors.d.ts.map +0 -1
- package/dest/public/bytecode_errors.js +0 -6
- 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/bytecode_errors.ts +0 -6
- 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
|
@@ -8,20 +8,19 @@ import { NativeWorldStateService } from '@aztec/world-state';
|
|
|
8
8
|
|
|
9
9
|
import { SideEffectTrace } from '../../../public/side_effect_trace.js';
|
|
10
10
|
import type { AvmContractCallResult } from '../../avm/avm_contract_call_result.js';
|
|
11
|
+
import { SimpleContractDataSource } from '../../fixtures/simple_contract_data_source.js';
|
|
12
|
+
import { PublicContractsDB, PublicTreesDB } from '../../public_db_sources.js';
|
|
13
|
+
import { PublicPersistableStateManager } from '../../state_manager/state_manager.js';
|
|
14
|
+
import { AvmSimulator } from '../avm_simulator.js';
|
|
15
|
+
import { BaseAvmSimulationTester } from './base_avm_simulation_tester.js';
|
|
16
|
+
import { initContext, initExecutionEnvironment } from './initializers.js';
|
|
11
17
|
import {
|
|
12
|
-
|
|
18
|
+
DEFAULT_TIMESTAMP,
|
|
19
|
+
getContractFunctionAbi,
|
|
13
20
|
getFunctionSelector,
|
|
14
|
-
initContext,
|
|
15
|
-
initExecutionEnvironment,
|
|
16
21
|
resolveContractAssertionMessage,
|
|
17
|
-
} from '
|
|
18
|
-
import { AvmPersistableStateManager } from '../../avm/journal/journal.js';
|
|
19
|
-
import { WorldStateDB } from '../../public_db_sources.js';
|
|
20
|
-
import { AvmSimulator } from '../avm_simulator.js';
|
|
21
|
-
import { BaseAvmSimulationTester } from './base_avm_simulation_tester.js';
|
|
22
|
-
import { SimpleContractDataSource } from './simple_contract_data_source.js';
|
|
22
|
+
} from './utils.js';
|
|
23
23
|
|
|
24
|
-
const TIMESTAMP = new Fr(99833);
|
|
25
24
|
const DEFAULT_GAS_FEES = new GasFees(2, 3);
|
|
26
25
|
|
|
27
26
|
/**
|
|
@@ -33,24 +32,28 @@ export class AvmSimulationTester extends BaseAvmSimulationTester {
|
|
|
33
32
|
constructor(
|
|
34
33
|
contractDataSource: SimpleContractDataSource,
|
|
35
34
|
merkleTrees: MerkleTreeWriteOperations,
|
|
36
|
-
private stateManager:
|
|
35
|
+
private stateManager: PublicPersistableStateManager,
|
|
37
36
|
) {
|
|
38
37
|
super(contractDataSource, merkleTrees);
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
static async create(
|
|
40
|
+
static async create(
|
|
41
|
+
worldStateService: NativeWorldStateService, // make sure to close this later
|
|
42
|
+
): Promise<AvmSimulationTester> {
|
|
42
43
|
const contractDataSource = new SimpleContractDataSource();
|
|
43
|
-
const merkleTrees = await
|
|
44
|
-
const
|
|
44
|
+
const merkleTrees = await worldStateService.fork();
|
|
45
|
+
const treesDB = new PublicTreesDB(merkleTrees);
|
|
46
|
+
const contractsDB = new PublicContractsDB(contractDataSource);
|
|
45
47
|
const trace = new SideEffectTrace();
|
|
46
48
|
const firstNullifier = new Fr(420000);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
|
|
50
|
+
const stateManager = PublicPersistableStateManager.create(
|
|
51
|
+
treesDB,
|
|
52
|
+
contractsDB,
|
|
51
53
|
trace,
|
|
52
54
|
/*doMerkleOperations=*/ false,
|
|
53
55
|
firstNullifier,
|
|
56
|
+
DEFAULT_TIMESTAMP,
|
|
54
57
|
);
|
|
55
58
|
return new AvmSimulationTester(contractDataSource, merkleTrees, stateManager);
|
|
56
59
|
}
|
|
@@ -70,12 +73,12 @@ export class AvmSimulationTester extends BaseAvmSimulationTester {
|
|
|
70
73
|
throw new Error(`Contract not found at address: ${address}`);
|
|
71
74
|
}
|
|
72
75
|
const fnSelector = await getFunctionSelector(fnName, contractArtifact);
|
|
73
|
-
const fnAbi =
|
|
76
|
+
const fnAbi = getContractFunctionAbi(fnName, contractArtifact);
|
|
74
77
|
const encodedArgs = encodeArguments(fnAbi!, args);
|
|
75
78
|
const calldata = [fnSelector.toField(), ...encodedArgs];
|
|
76
79
|
|
|
77
80
|
const globals = GlobalVariables.empty();
|
|
78
|
-
globals.timestamp =
|
|
81
|
+
globals.timestamp = DEFAULT_TIMESTAMP;
|
|
79
82
|
globals.gasFees = DEFAULT_GAS_FEES;
|
|
80
83
|
|
|
81
84
|
const environment = initExecutionEnvironment({
|
|
@@ -1,18 +1,20 @@
|
|
|
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';
|
|
5
|
+
import { getCanonicalAuthRegistry } from '@aztec/protocol-contracts/auth-registry';
|
|
5
6
|
import { computeFeePayerBalanceStorageSlot, getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
|
|
7
|
+
import { getCanonicalInstanceRegistry } from '@aztec/protocol-contracts/instance-registry';
|
|
6
8
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
7
9
|
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
8
10
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
|
-
import type {
|
|
11
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
10
12
|
import { computePublicDataTreeLeafSlot, siloNullifier } from '@aztec/stdlib/hash';
|
|
11
13
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
12
14
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
13
15
|
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
+
import type { SimpleContractDataSource } from '../../fixtures/simple_contract_data_source.js';
|
|
17
|
+
import { createContractClassAndInstance } from './utils.js';
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* An abstract test class that enables tests of real apps in the AVM without requiring e2e tests.
|
|
@@ -44,7 +46,7 @@ export abstract class BaseAvmSimulationTester {
|
|
|
44
46
|
const leafSlot = await computePublicDataTreeLeafSlot(address, slot);
|
|
45
47
|
// get existing preimage
|
|
46
48
|
const publicDataWrite = new PublicDataWrite(leafSlot, value);
|
|
47
|
-
await this.merkleTrees.
|
|
49
|
+
await this.merkleTrees.sequentialInsert(MerkleTreeId.PUBLIC_DATA_TREE, [publicDataWrite.toBuffer()]);
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
/**
|
|
@@ -57,6 +59,7 @@ export abstract class BaseAvmSimulationTester {
|
|
|
57
59
|
contractArtifact: ContractArtifact,
|
|
58
60
|
skipNullifierInsertion = false,
|
|
59
61
|
seed = 0,
|
|
62
|
+
contractClassSeed = seed,
|
|
60
63
|
originalContractClassId?: Fr, // if previously upgraded
|
|
61
64
|
): Promise<ContractInstanceWithAddress> {
|
|
62
65
|
const { contractClass, contractInstance } = await createContractClassAndInstance(
|
|
@@ -64,6 +67,7 @@ export abstract class BaseAvmSimulationTester {
|
|
|
64
67
|
deployer,
|
|
65
68
|
contractArtifact,
|
|
66
69
|
seed,
|
|
70
|
+
contractClassSeed,
|
|
67
71
|
originalContractClassId,
|
|
68
72
|
);
|
|
69
73
|
|
|
@@ -80,16 +84,40 @@ export abstract class BaseAvmSimulationTester {
|
|
|
80
84
|
const feeJuiceContractClassPublic = {
|
|
81
85
|
...feeJuice.contractClass,
|
|
82
86
|
privateFunctions: [],
|
|
83
|
-
|
|
87
|
+
utilityFunctions: [],
|
|
84
88
|
};
|
|
85
89
|
await this.contractDataSource.addNewContract(feeJuice.artifact, feeJuiceContractClassPublic, feeJuice.instance);
|
|
86
90
|
return feeJuice.instance;
|
|
87
91
|
}
|
|
88
92
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
async registerAuthContract(): Promise<ContractInstanceWithAddress> {
|
|
94
|
+
const authRegistry = await getCanonicalAuthRegistry();
|
|
95
|
+
const authRegistryContractClassPublic = {
|
|
96
|
+
...authRegistry.contractClass,
|
|
97
|
+
privateFunctions: [],
|
|
98
|
+
utilityFunctions: [],
|
|
99
|
+
};
|
|
100
|
+
await this.contractDataSource.addNewContract(
|
|
101
|
+
authRegistry.artifact,
|
|
102
|
+
authRegistryContractClassPublic,
|
|
103
|
+
authRegistry.instance,
|
|
104
|
+
);
|
|
105
|
+
return authRegistry.instance;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async registerInstanceRegistryContract(): Promise<ContractInstanceWithAddress> {
|
|
109
|
+
const instanceRegistry = await getCanonicalInstanceRegistry();
|
|
110
|
+
const instanceRegistryContractClassPublic = {
|
|
111
|
+
...instanceRegistry.contractClass,
|
|
112
|
+
privateFunctions: [],
|
|
113
|
+
utilityFunctions: [],
|
|
114
|
+
};
|
|
115
|
+
await this.contractDataSource.addNewContract(
|
|
116
|
+
instanceRegistry.artifact,
|
|
117
|
+
instanceRegistryContractClassPublic,
|
|
118
|
+
instanceRegistry.instance,
|
|
119
|
+
);
|
|
120
|
+
return instanceRegistry.instance;
|
|
93
121
|
}
|
|
94
122
|
|
|
95
123
|
async addContractInstance(contractInstance: ContractInstanceWithAddress, skipNullifierInsertion = false) {
|
|
@@ -101,9 +129,14 @@ export abstract class BaseAvmSimulationTester {
|
|
|
101
129
|
|
|
102
130
|
private async insertContractAddressNullifier(contractAddress: AztecAddress) {
|
|
103
131
|
const contractAddressNullifier = await siloNullifier(
|
|
104
|
-
AztecAddress.fromNumber(
|
|
132
|
+
AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS),
|
|
105
133
|
contractAddress.toField(),
|
|
106
134
|
);
|
|
107
|
-
await this.merkleTrees.
|
|
135
|
+
await this.merkleTrees.sequentialInsert(MerkleTreeId.NULLIFIER_TREE, [contractAddressNullifier.toBuffer()]);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async insertNullifier(contractThatEmitted: AztecAddress, nullifier: Fr) {
|
|
139
|
+
const siloedNullifier = await siloNullifier(contractThatEmitted, nullifier);
|
|
140
|
+
await this.merkleTrees.sequentialInsert(MerkleTreeId.NULLIFIER_TREE, [siloedNullifier.toBuffer()]);
|
|
108
141
|
}
|
|
109
142
|
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { AVM_MAX_PROCESSABLE_L2_GAS, DEFAULT_MAX_DEBUG_LOG_MEMORY_READS } 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 type { UInt64 } from '@aztec/stdlib/types';
|
|
8
|
+
|
|
9
|
+
import { mock } from 'jest-mock-extended';
|
|
10
|
+
|
|
11
|
+
import type { PublicContractsDB, PublicTreesDB } from '../../public_db_sources.js';
|
|
12
|
+
import type { PublicSideEffectTraceInterface } from '../../side_effect_trace_interface.js';
|
|
13
|
+
import { NullifierManager } from '../../state_manager/nullifiers.js';
|
|
14
|
+
import { PublicStorage } from '../../state_manager/public_storage.js';
|
|
15
|
+
import { PublicPersistableStateManager } from '../../state_manager/state_manager.js';
|
|
16
|
+
import { AvmContext } from '../avm_context.js';
|
|
17
|
+
import { AvmExecutionEnvironment } from '../avm_execution_environment.js';
|
|
18
|
+
import { AvmMachineState } from '../avm_machine_state.js';
|
|
19
|
+
import { AvmSimulator } from '../avm_simulator.js';
|
|
20
|
+
import { DEFAULT_TIMESTAMP } from './utils.js';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Create a new AVM context with default values.
|
|
24
|
+
*/
|
|
25
|
+
export function initContext(overrides?: {
|
|
26
|
+
persistableState?: PublicPersistableStateManager;
|
|
27
|
+
env?: AvmExecutionEnvironment;
|
|
28
|
+
machineState?: AvmMachineState;
|
|
29
|
+
}): AvmContext {
|
|
30
|
+
const ctx = new AvmContext(
|
|
31
|
+
overrides?.persistableState || initPersistableStateManager(),
|
|
32
|
+
overrides?.env || initExecutionEnvironment(),
|
|
33
|
+
overrides?.machineState || initMachineState(),
|
|
34
|
+
);
|
|
35
|
+
ctx.provideSimulator = AvmSimulator.build;
|
|
36
|
+
return ctx;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Creates an empty state manager with mocked host storage. */
|
|
40
|
+
export function initPersistableStateManager(overrides?: {
|
|
41
|
+
treesDB?: PublicTreesDB;
|
|
42
|
+
contractsDB?: PublicContractsDB;
|
|
43
|
+
trace?: PublicSideEffectTraceInterface;
|
|
44
|
+
publicStorage?: PublicStorage;
|
|
45
|
+
nullifiers?: NullifierManager;
|
|
46
|
+
doMerkleOperations?: boolean;
|
|
47
|
+
firstNullifier?: Fr;
|
|
48
|
+
timestamp?: UInt64;
|
|
49
|
+
}): PublicPersistableStateManager {
|
|
50
|
+
const treesDB = overrides?.treesDB || mock<PublicTreesDB>();
|
|
51
|
+
return new PublicPersistableStateManager(
|
|
52
|
+
treesDB,
|
|
53
|
+
overrides?.contractsDB || mock<PublicContractsDB>(),
|
|
54
|
+
overrides?.trace || mock<PublicSideEffectTraceInterface>(),
|
|
55
|
+
overrides?.firstNullifier || new Fr(27),
|
|
56
|
+
overrides?.timestamp || DEFAULT_TIMESTAMP,
|
|
57
|
+
overrides?.doMerkleOperations || false,
|
|
58
|
+
overrides?.publicStorage,
|
|
59
|
+
overrides?.nullifiers,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Create an empty instance of the Execution Environment where all values are zero, unless overridden in the overrides object
|
|
65
|
+
*/
|
|
66
|
+
export function initExecutionEnvironment(overrides?: Partial<AvmExecutionEnvironment>): AvmExecutionEnvironment {
|
|
67
|
+
return new AvmExecutionEnvironment(
|
|
68
|
+
overrides?.address ?? AztecAddress.zero(),
|
|
69
|
+
overrides?.sender ?? AztecAddress.zero(),
|
|
70
|
+
overrides?.contractCallDepth ?? Fr.zero(),
|
|
71
|
+
overrides?.transactionFee ?? Fr.zero(),
|
|
72
|
+
overrides?.globals ?? GlobalVariables.empty(),
|
|
73
|
+
overrides?.isStaticCall ?? false,
|
|
74
|
+
overrides?.calldata ?? [],
|
|
75
|
+
overrides?.clientInitiatedSimulation ?? true, // default to true for testing even though internal default is false
|
|
76
|
+
overrides?.maxDebugLogMemoryReads ?? DEFAULT_MAX_DEBUG_LOG_MEMORY_READS,
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Create an empty instance of the Execution Environment where all values are zero, unless overridden in the overrides object
|
|
82
|
+
*/
|
|
83
|
+
export function initGlobalVariables(overrides?: Partial<GlobalVariables>): GlobalVariables {
|
|
84
|
+
return new GlobalVariables(
|
|
85
|
+
overrides?.chainId ?? Fr.zero(),
|
|
86
|
+
overrides?.version ?? Fr.zero(),
|
|
87
|
+
overrides?.blockNumber ?? 0,
|
|
88
|
+
overrides?.slotNumber ?? Fr.zero(),
|
|
89
|
+
overrides?.timestamp ?? 0n,
|
|
90
|
+
overrides?.coinbase ?? EthAddress.ZERO,
|
|
91
|
+
overrides?.feeRecipient ?? AztecAddress.zero(),
|
|
92
|
+
overrides?.gasFees ?? GasFees.empty(),
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Create an empty instance of the Machine State where all values are set to a large enough amount, unless overridden in the overrides object
|
|
98
|
+
*/
|
|
99
|
+
export function initMachineState(overrides?: Partial<AvmMachineState>): AvmMachineState {
|
|
100
|
+
return AvmMachineState.fromState({
|
|
101
|
+
l2GasLeft: overrides?.l2GasLeft ?? AVM_MAX_PROCESSABLE_L2_GAS,
|
|
102
|
+
daGasLeft: overrides?.daGasLeft ?? 1e8,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS } from '@aztec/constants';
|
|
2
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import {
|
|
4
|
+
type ContractArtifact,
|
|
5
|
+
type FunctionAbi,
|
|
6
|
+
type FunctionArtifact,
|
|
7
|
+
FunctionSelector,
|
|
8
|
+
getAllFunctionAbis,
|
|
9
|
+
} from '@aztec/stdlib/abi';
|
|
10
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
|
+
import {
|
|
12
|
+
type ContractClassPublic,
|
|
13
|
+
type ContractInstanceWithAddress,
|
|
14
|
+
computeInitializationHash,
|
|
15
|
+
} from '@aztec/stdlib/contract';
|
|
16
|
+
import { isNoirCallStackUnresolved } from '@aztec/stdlib/errors';
|
|
17
|
+
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
18
|
+
import { deriveKeys } from '@aztec/stdlib/keys';
|
|
19
|
+
import { makeContractClassPublic, makeContractInstanceFromClassId } from '@aztec/stdlib/testing';
|
|
20
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
21
|
+
|
|
22
|
+
import { strict as assert } from 'assert';
|
|
23
|
+
import merge from 'lodash.merge';
|
|
24
|
+
|
|
25
|
+
import { resolveAssertionMessageFromRevertData, traverseCauseChain } from '../../../common/index.js';
|
|
26
|
+
import { Field, Uint8, Uint32, Uint64 } from '../avm_memory_types.js';
|
|
27
|
+
import type { AvmRevertReason } from '../errors.js';
|
|
28
|
+
|
|
29
|
+
export const PUBLIC_DISPATCH_FN_NAME = 'public_dispatch';
|
|
30
|
+
export const DEFAULT_TIMESTAMP: UInt64 = 99833n;
|
|
31
|
+
export const DEFAULT_BLOCK_NUMBER = 42;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Create a new object with all the same properties as the original, except for the ones in the overrides object.
|
|
35
|
+
*/
|
|
36
|
+
export function allSameExcept(original: any, overrides: any): any {
|
|
37
|
+
return merge({}, original, overrides);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function randomMemoryBytes(length: number): Uint8[] {
|
|
41
|
+
return [...Array(length)].map(_ => new Uint8(Math.floor(Math.random() * 255)));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function randomMemoryUint32s(length: number): Uint32[] {
|
|
45
|
+
return [...Array(length)].map(_ => new Uint32(Math.floor(Math.random() * 255)));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function randomMemoryUint64s(length: number): Uint64[] {
|
|
49
|
+
return [...Array(length)].map(_ => new Uint64(Math.floor(Math.random() * 255)));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function randomMemoryFields(length: number): Field[] {
|
|
53
|
+
return [...Array(length)].map(_ => new Field(Fr.random()));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function getFunctionSelector(
|
|
57
|
+
functionName: string,
|
|
58
|
+
contractArtifact: ContractArtifact,
|
|
59
|
+
): Promise<FunctionSelector> {
|
|
60
|
+
const fnArtifact = getAllFunctionAbis(contractArtifact).find(f => f.name === functionName)!;
|
|
61
|
+
assert(!!fnArtifact, `Function ${functionName} not found in ${contractArtifact.name}`);
|
|
62
|
+
const params = fnArtifact.parameters;
|
|
63
|
+
return FunctionSelector.fromNameAndParameters(fnArtifact.name, params);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function getContractFunctionArtifact(
|
|
67
|
+
functionName: string,
|
|
68
|
+
contractArtifact: ContractArtifact,
|
|
69
|
+
): FunctionArtifact | undefined {
|
|
70
|
+
return contractArtifact.functions.find(f => f.name === functionName);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function getContractFunctionAbi(
|
|
74
|
+
functionName: string,
|
|
75
|
+
contractArtifact: ContractArtifact,
|
|
76
|
+
): FunctionAbi | undefined {
|
|
77
|
+
return (
|
|
78
|
+
contractArtifact.functions.find(f => f.name === functionName) ??
|
|
79
|
+
contractArtifact.nonDispatchPublicFunctions.find(f => f.name === functionName)
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function resolveContractAssertionMessage(
|
|
84
|
+
functionName: string,
|
|
85
|
+
revertReason: AvmRevertReason,
|
|
86
|
+
output: Fr[],
|
|
87
|
+
contractArtifact: ContractArtifact,
|
|
88
|
+
): string | undefined {
|
|
89
|
+
traverseCauseChain(revertReason, cause => {
|
|
90
|
+
revertReason = cause as AvmRevertReason;
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const functionArtifact = getAllFunctionAbis(contractArtifact).find(f => f.name === functionName);
|
|
94
|
+
if (!functionArtifact || !revertReason.noirCallStack || !isNoirCallStackUnresolved(revertReason.noirCallStack)) {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return resolveAssertionMessageFromRevertData(output, functionArtifact);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Create a contract class and instance given constructor args, artifact, etc.
|
|
103
|
+
* NOTE: This is useful for testing real-ish contract class registration and instance deployment TXs (via logs)
|
|
104
|
+
* @param constructorArgs - The constructor arguments for the contract.
|
|
105
|
+
* @param deployer - The deployer of the contract.
|
|
106
|
+
* @param contractArtifact - The contract artifact for the contract.
|
|
107
|
+
* @param seed - The seed for the contract.
|
|
108
|
+
* @param originalContractClassId - The original contract class ID (if upgraded)
|
|
109
|
+
* @returns The contract class, instance, and contract address nullifier.
|
|
110
|
+
*/
|
|
111
|
+
export async function createContractClassAndInstance(
|
|
112
|
+
constructorArgs: any[],
|
|
113
|
+
deployer: AztecAddress,
|
|
114
|
+
contractArtifact: ContractArtifact,
|
|
115
|
+
seed = 0,
|
|
116
|
+
contractClassSeed = seed,
|
|
117
|
+
originalContractClassId?: Fr, // if previously upgraded
|
|
118
|
+
): Promise<{
|
|
119
|
+
contractClass: ContractClassPublic;
|
|
120
|
+
contractInstance: ContractInstanceWithAddress;
|
|
121
|
+
contractAddressNullifier: Fr;
|
|
122
|
+
}> {
|
|
123
|
+
const bytecode = (getContractFunctionArtifact(PUBLIC_DISPATCH_FN_NAME, contractArtifact) as FunctionArtifact)!
|
|
124
|
+
.bytecode;
|
|
125
|
+
const contractClass = await makeContractClassPublic(contractClassSeed, bytecode);
|
|
126
|
+
|
|
127
|
+
const constructorAbi = getContractFunctionAbi('constructor', contractArtifact);
|
|
128
|
+
const { publicKeys } = await deriveKeys(new Fr(seed));
|
|
129
|
+
const initializationHash = await computeInitializationHash(constructorAbi, constructorArgs);
|
|
130
|
+
const contractInstance =
|
|
131
|
+
originalContractClassId === undefined
|
|
132
|
+
? await makeContractInstanceFromClassId(contractClass.id, seed, {
|
|
133
|
+
deployer,
|
|
134
|
+
initializationHash,
|
|
135
|
+
publicKeys,
|
|
136
|
+
})
|
|
137
|
+
: await makeContractInstanceFromClassId(originalContractClassId, seed, {
|
|
138
|
+
deployer,
|
|
139
|
+
initializationHash,
|
|
140
|
+
currentClassId: contractClass.id,
|
|
141
|
+
publicKeys,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const contractAddressNullifier = await siloNullifier(
|
|
145
|
+
AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS),
|
|
146
|
+
contractInstance.address.toField(),
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
return { contractClass, contractInstance, contractAddressNullifier };
|
|
150
|
+
}
|
package/src/public/avm/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { NullifierCollisionError } from '../../side_effect_errors.js';
|
|
1
2
|
import type { AvmContext } from '../avm_context.js';
|
|
2
3
|
import { TypeTag, Uint1 } from '../avm_memory_types.js';
|
|
3
4
|
import { InstructionExecutionError, StaticCallAlterationError } from '../errors.js';
|
|
4
|
-
import { NullifierCollisionError } from '../journal/nullifiers.js';
|
|
5
5
|
import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
|
|
6
6
|
import { Addressing } from './addressing_mode.js';
|
|
7
7
|
import { Instruction } from './instruction.js';
|
|
@@ -29,15 +29,19 @@ export class NoteHashExists extends Instruction {
|
|
|
29
29
|
|
|
30
30
|
public async execute(context: AvmContext): Promise<void> {
|
|
31
31
|
const memory = context.machineState.memory;
|
|
32
|
-
|
|
32
|
+
const addressing = Addressing.fromWire(this.indirect);
|
|
33
|
+
|
|
34
|
+
context.machineState.consumeGas(
|
|
35
|
+
this.baseGasCost(addressing.indirectOperandsCount(), addressing.relativeOperandsCount()),
|
|
36
|
+
);
|
|
33
37
|
const operands = [this.noteHashOffset, this.leafIndexOffset, this.existsOffset];
|
|
34
|
-
const addressing = Addressing.fromWire(this.indirect, operands.length);
|
|
35
38
|
const [noteHashOffset, leafIndexOffset, existsOffset] = addressing.resolve(operands, memory);
|
|
36
|
-
memory.
|
|
39
|
+
memory.checkTag(TypeTag.FIELD, noteHashOffset);
|
|
40
|
+
memory.checkTag(TypeTag.UINT64, leafIndexOffset);
|
|
37
41
|
|
|
38
42
|
// Note that this instruction accepts any type in memory, and converts to Field.
|
|
39
43
|
const noteHash = memory.get(noteHashOffset).toFr();
|
|
40
|
-
const leafIndex = memory.get(leafIndexOffset).
|
|
44
|
+
const leafIndex = memory.get(leafIndexOffset).toBigInt();
|
|
41
45
|
|
|
42
46
|
const exists = await context.persistableState.checkNoteHashExists(context.environment.address, noteHash, leafIndex);
|
|
43
47
|
memory.set(existsOffset, exists ? new Uint1(1) : new Uint1(0));
|
|
@@ -50,16 +54,22 @@ export class EmitNoteHash extends Instruction {
|
|
|
50
54
|
// Informs (de)serialization. See Instruction.deserialize.
|
|
51
55
|
static readonly wireFormat = [OperandType.UINT8, OperandType.UINT8, OperandType.UINT16];
|
|
52
56
|
|
|
53
|
-
constructor(
|
|
57
|
+
constructor(
|
|
58
|
+
private indirect: number,
|
|
59
|
+
private noteHashOffset: number,
|
|
60
|
+
) {
|
|
54
61
|
super();
|
|
55
62
|
}
|
|
56
63
|
|
|
57
64
|
public async execute(context: AvmContext): Promise<void> {
|
|
58
65
|
const memory = context.machineState.memory;
|
|
59
|
-
|
|
66
|
+
const addressing = Addressing.fromWire(this.indirect);
|
|
67
|
+
|
|
68
|
+
context.machineState.consumeGas(
|
|
69
|
+
this.baseGasCost(addressing.indirectOperandsCount(), addressing.relativeOperandsCount()),
|
|
70
|
+
);
|
|
60
71
|
|
|
61
72
|
const operands = [this.noteHashOffset];
|
|
62
|
-
const addressing = Addressing.fromWire(this.indirect, operands.length);
|
|
63
73
|
const [noteHashOffset] = addressing.resolve(operands, memory);
|
|
64
74
|
memory.checkTag(TypeTag.FIELD, noteHashOffset);
|
|
65
75
|
|
|
@@ -95,10 +105,13 @@ export class NullifierExists extends Instruction {
|
|
|
95
105
|
|
|
96
106
|
public async execute(context: AvmContext): Promise<void> {
|
|
97
107
|
const memory = context.machineState.memory;
|
|
98
|
-
|
|
108
|
+
const addressing = Addressing.fromWire(this.indirect);
|
|
109
|
+
|
|
110
|
+
context.machineState.consumeGas(
|
|
111
|
+
this.baseGasCost(addressing.indirectOperandsCount(), addressing.relativeOperandsCount()),
|
|
112
|
+
);
|
|
99
113
|
|
|
100
114
|
const operands = [this.nullifierOffset, this.addressOffset, this.existsOffset];
|
|
101
|
-
const addressing = Addressing.fromWire(this.indirect, operands.length);
|
|
102
115
|
const [nullifierOffset, addressOffset, existsOffset] = addressing.resolve(operands, memory);
|
|
103
116
|
memory.checkTags(TypeTag.FIELD, nullifierOffset, addressOffset);
|
|
104
117
|
|
|
@@ -116,7 +129,10 @@ export class EmitNullifier extends Instruction {
|
|
|
116
129
|
// Informs (de)serialization. See Instruction.deserialize.
|
|
117
130
|
static readonly wireFormat = [OperandType.UINT8, OperandType.UINT8, OperandType.UINT16];
|
|
118
131
|
|
|
119
|
-
constructor(
|
|
132
|
+
constructor(
|
|
133
|
+
private indirect: number,
|
|
134
|
+
private nullifierOffset: number,
|
|
135
|
+
) {
|
|
120
136
|
super();
|
|
121
137
|
}
|
|
122
138
|
|
|
@@ -126,10 +142,13 @@ export class EmitNullifier extends Instruction {
|
|
|
126
142
|
}
|
|
127
143
|
|
|
128
144
|
const memory = context.machineState.memory;
|
|
129
|
-
|
|
145
|
+
const addressing = Addressing.fromWire(this.indirect);
|
|
146
|
+
|
|
147
|
+
context.machineState.consumeGas(
|
|
148
|
+
this.baseGasCost(addressing.indirectOperandsCount(), addressing.relativeOperandsCount()),
|
|
149
|
+
);
|
|
130
150
|
|
|
131
151
|
const operands = [this.nullifierOffset];
|
|
132
|
-
const addressing = Addressing.fromWire(this.indirect, operands.length);
|
|
133
152
|
const [nullifierOffset] = addressing.resolve(operands, memory);
|
|
134
153
|
memory.checkTag(TypeTag.FIELD, nullifierOffset);
|
|
135
154
|
|
|
@@ -172,20 +191,21 @@ export class L1ToL2MessageExists extends Instruction {
|
|
|
172
191
|
|
|
173
192
|
public async execute(context: AvmContext): Promise<void> {
|
|
174
193
|
const memory = context.machineState.memory;
|
|
175
|
-
|
|
194
|
+
const addressing = Addressing.fromWire(this.indirect);
|
|
195
|
+
|
|
196
|
+
context.machineState.consumeGas(
|
|
197
|
+
this.baseGasCost(addressing.indirectOperandsCount(), addressing.relativeOperandsCount()),
|
|
198
|
+
);
|
|
176
199
|
|
|
177
200
|
const operands = [this.msgHashOffset, this.msgLeafIndexOffset, this.existsOffset];
|
|
178
|
-
const addressing = Addressing.fromWire(this.indirect, operands.length);
|
|
179
201
|
const [msgHashOffset, msgLeafIndexOffset, existsOffset] = addressing.resolve(operands, memory);
|
|
180
|
-
|
|
202
|
+
|
|
203
|
+
memory.checkTag(TypeTag.FIELD, msgHashOffset);
|
|
204
|
+
memory.checkTag(TypeTag.UINT64, msgLeafIndexOffset);
|
|
181
205
|
|
|
182
206
|
const msgHash = memory.get(msgHashOffset).toFr();
|
|
183
207
|
const msgLeafIndex = memory.get(msgLeafIndexOffset).toFr();
|
|
184
|
-
const exists = await context.persistableState.checkL1ToL2MessageExists(
|
|
185
|
-
context.environment.address,
|
|
186
|
-
msgHash,
|
|
187
|
-
msgLeafIndex,
|
|
188
|
-
);
|
|
208
|
+
const exists = await context.persistableState.checkL1ToL2MessageExists(msgHash, msgLeafIndex);
|
|
189
209
|
memory.set(existsOffset, exists ? new Uint1(1) : new Uint1(0));
|
|
190
210
|
}
|
|
191
211
|
}
|
|
@@ -197,7 +217,11 @@ export class EmitUnencryptedLog extends Instruction {
|
|
|
197
217
|
// Informs (de)serialization. See Instruction.deserialize.
|
|
198
218
|
static readonly wireFormat = [OperandType.UINT8, OperandType.UINT8, OperandType.UINT16, OperandType.UINT16];
|
|
199
219
|
|
|
200
|
-
constructor(
|
|
220
|
+
constructor(
|
|
221
|
+
private indirect: number,
|
|
222
|
+
private logSizeOffset: number,
|
|
223
|
+
private logOffset: number,
|
|
224
|
+
) {
|
|
201
225
|
super();
|
|
202
226
|
}
|
|
203
227
|
|
|
@@ -207,17 +231,21 @@ export class EmitUnencryptedLog extends Instruction {
|
|
|
207
231
|
}
|
|
208
232
|
|
|
209
233
|
const memory = context.machineState.memory;
|
|
234
|
+
const addressing = Addressing.fromWire(this.indirect);
|
|
210
235
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
236
|
+
context.machineState.consumeGas(
|
|
237
|
+
this.baseGasCost(addressing.indirectOperandsCount(), addressing.relativeOperandsCount()),
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
const operands = [this.logSizeOffset, this.logOffset];
|
|
241
|
+
const [logSizeOffset, logOffset] = addressing.resolve(operands, memory);
|
|
214
242
|
memory.checkTag(TypeTag.UINT32, logSizeOffset);
|
|
215
243
|
const logSize = memory.get(logSizeOffset).toNumber();
|
|
216
244
|
memory.checkTagsRange(TypeTag.FIELD, logOffset, logSize);
|
|
217
245
|
|
|
218
246
|
const contractAddress = context.environment.address;
|
|
219
247
|
|
|
220
|
-
context.machineState.consumeGas(this.
|
|
248
|
+
context.machineState.consumeGas(this.dynamicGasCost(logSize));
|
|
221
249
|
const log = memory.getSlice(logOffset, logSize).map(f => f.toFr());
|
|
222
250
|
context.persistableState.writePublicLog(contractAddress, log);
|
|
223
251
|
}
|
|
@@ -229,7 +257,11 @@ export class SendL2ToL1Message extends Instruction {
|
|
|
229
257
|
// Informs (de)serialization. See Instruction.deserialize.
|
|
230
258
|
static readonly wireFormat = [OperandType.UINT8, OperandType.UINT8, OperandType.UINT16, OperandType.UINT16];
|
|
231
259
|
|
|
232
|
-
constructor(
|
|
260
|
+
constructor(
|
|
261
|
+
private indirect: number,
|
|
262
|
+
private recipientOffset: number,
|
|
263
|
+
private contentOffset: number,
|
|
264
|
+
) {
|
|
233
265
|
super();
|
|
234
266
|
}
|
|
235
267
|
|
|
@@ -239,10 +271,13 @@ export class SendL2ToL1Message extends Instruction {
|
|
|
239
271
|
}
|
|
240
272
|
|
|
241
273
|
const memory = context.machineState.memory;
|
|
242
|
-
|
|
274
|
+
const addressing = Addressing.fromWire(this.indirect);
|
|
275
|
+
|
|
276
|
+
context.machineState.consumeGas(
|
|
277
|
+
this.baseGasCost(addressing.indirectOperandsCount(), addressing.relativeOperandsCount()),
|
|
278
|
+
);
|
|
243
279
|
|
|
244
280
|
const operands = [this.recipientOffset, this.contentOffset];
|
|
245
|
-
const addressing = Addressing.fromWire(this.indirect, operands.length);
|
|
246
281
|
const [recipientOffset, contentOffset] = addressing.resolve(operands, memory);
|
|
247
282
|
memory.checkTags(TypeTag.FIELD, recipientOffset, contentOffset);
|
|
248
283
|
|