@aztec/simulator 0.0.1-commit.24de95ac → 0.0.1-commit.29c6b1a3
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 +2 -0
- package/dest/client.d.ts +1 -1
- package/dest/common/errors.d.ts +2 -2
- package/dest/common/errors.d.ts.map +1 -1
- package/dest/common/index.d.ts +1 -1
- package/dest/common/stats/index.d.ts +1 -1
- package/dest/common/stats/stats.d.ts +1 -1
- package/dest/private/acvm/acvm.d.ts +1 -1
- package/dest/private/acvm/acvm_types.d.ts +1 -1
- package/dest/private/acvm/deserialize.d.ts +2 -2
- package/dest/private/acvm/deserialize.d.ts.map +1 -1
- package/dest/private/acvm/deserialize.js +1 -1
- package/dest/private/acvm/index.d.ts +1 -1
- package/dest/private/acvm/serialize.d.ts +2 -2
- package/dest/private/acvm/serialize.d.ts.map +1 -1
- package/dest/private/acvm/serialize.js +1 -1
- package/dest/private/acvm_native.d.ts +1 -1
- package/dest/private/acvm_native.d.ts.map +1 -1
- package/dest/private/acvm_wasm.d.ts +1 -1
- package/dest/private/acvm_wasm.d.ts.map +1 -1
- package/dest/private/acvm_wasm_with_blobs.d.ts +1 -1
- package/dest/private/acvm_wasm_with_blobs.d.ts.map +1 -1
- package/dest/private/circuit_recording/circuit_recorder.d.ts +1 -1
- package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/circuit_recorder.js +16 -15
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts +1 -1
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +1 -1
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts +1 -1
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts.map +1 -1
- package/dest/private/circuit_simulator.d.ts +1 -1
- package/dest/private/factory.d.ts +1 -1
- package/dest/public/avm/avm_context.d.ts +3 -3
- package/dest/public/avm/avm_context.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.d.ts +6 -6
- package/dest/public/avm/avm_contract_call_result.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.js +3 -3
- package/dest/public/avm/avm_execution_environment.d.ts +9 -8
- package/dest/public/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/public/avm/avm_execution_environment.js +5 -8
- package/dest/public/avm/avm_gas.d.ts +2 -2
- package/dest/public/avm/avm_gas.d.ts.map +1 -1
- package/dest/public/avm/avm_machine_state.d.ts +7 -6
- package/dest/public/avm/avm_machine_state.d.ts.map +1 -1
- package/dest/public/avm/avm_machine_state.js +3 -2
- package/dest/public/avm/avm_memory_types.d.ts +14 -14
- package/dest/public/avm/avm_memory_types.d.ts.map +1 -1
- package/dest/public/avm/avm_memory_types.js +4 -1
- package/dest/public/avm/avm_simulator.d.ts +5 -3
- package/dest/public/avm/avm_simulator.d.ts.map +1 -1
- package/dest/public/avm/avm_simulator.js +13 -11
- package/dest/public/avm/avm_simulator_interface.d.ts +1 -1
- package/dest/public/avm/calldata.d.ts +51 -0
- package/dest/public/avm/calldata.d.ts.map +1 -0
- package/dest/public/avm/calldata.js +63 -0
- package/dest/public/avm/errors.d.ts +8 -2
- package/dest/public/avm/errors.d.ts.map +1 -1
- package/dest/public/avm/errors.js +14 -2
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.js +15 -5
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +2 -2
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/base_avm_simulation_tester.js +1 -1
- package/dest/public/avm/fixtures/initializers.d.ts +2 -3
- package/dest/public/avm/fixtures/initializers.d.ts.map +1 -1
- package/dest/public/avm/fixtures/initializers.js +8 -5
- package/dest/public/avm/fixtures/utils.d.ts +4 -3
- package/dest/public/avm/fixtures/utils.d.ts.map +1 -1
- package/dest/public/avm/fixtures/utils.js +3 -2
- package/dest/public/avm/index.d.ts +1 -1
- package/dest/public/avm/opcodes/accrued_substate.d.ts +16 -17
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/public/avm/opcodes/accrued_substate.js +39 -39
- package/dest/public/avm/opcodes/addressing_mode.d.ts +1 -1
- package/dest/public/avm/opcodes/addressing_mode.d.ts.map +1 -1
- package/dest/public/avm/opcodes/addressing_mode.js +2 -2
- package/dest/public/avm/opcodes/arithmetic.d.ts +3 -1
- package/dest/public/avm/opcodes/arithmetic.d.ts.map +1 -1
- package/dest/public/avm/opcodes/arithmetic.js +12 -2
- package/dest/public/avm/opcodes/bitwise.d.ts +3 -3
- package/dest/public/avm/opcodes/bitwise.d.ts.map +1 -1
- package/dest/public/avm/opcodes/bitwise.js +5 -5
- package/dest/public/avm/opcodes/comparators.d.ts +1 -1
- package/dest/public/avm/opcodes/comparators.d.ts.map +1 -1
- package/dest/public/avm/opcodes/comparators.js +1 -1
- package/dest/public/avm/opcodes/contract.d.ts +3 -3
- package/dest/public/avm/opcodes/contract.d.ts.map +1 -1
- package/dest/public/avm/opcodes/contract.js +8 -8
- package/dest/public/avm/opcodes/control_flow.d.ts +3 -3
- package/dest/public/avm/opcodes/control_flow.d.ts.map +1 -1
- package/dest/public/avm/opcodes/control_flow.js +4 -4
- package/dest/public/avm/opcodes/conversion.d.ts +3 -3
- package/dest/public/avm/opcodes/conversion.d.ts.map +1 -1
- package/dest/public/avm/opcodes/conversion.js +4 -4
- package/dest/public/avm/opcodes/ec_add.d.ts +3 -3
- package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -1
- package/dest/public/avm/opcodes/ec_add.js +17 -8
- package/dest/public/avm/opcodes/environment_getters.d.ts +5 -5
- package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/public/avm/opcodes/environment_getters.js +6 -6
- package/dest/public/avm/opcodes/external_calls.d.ts +9 -9
- package/dest/public/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/public/avm/opcodes/external_calls.js +23 -22
- package/dest/public/avm/opcodes/hashing.d.ts +7 -7
- package/dest/public/avm/opcodes/hashing.d.ts.map +1 -1
- package/dest/public/avm/opcodes/hashing.js +21 -16
- package/dest/public/avm/opcodes/index.d.ts +1 -1
- package/dest/public/avm/opcodes/instruction.d.ts +2 -2
- package/dest/public/avm/opcodes/instruction.d.ts.map +1 -1
- package/dest/public/avm/opcodes/instruction_impl.d.ts +4 -4
- package/dest/public/avm/opcodes/instruction_impl.d.ts.map +1 -1
- package/dest/public/avm/opcodes/instruction_impl.js +4 -4
- package/dest/public/avm/opcodes/memory.d.ts +13 -13
- package/dest/public/avm/opcodes/memory.d.ts.map +1 -1
- package/dest/public/avm/opcodes/memory.js +26 -26
- package/dest/public/avm/opcodes/misc.d.ts +3 -3
- package/dest/public/avm/opcodes/misc.d.ts.map +1 -1
- package/dest/public/avm/opcodes/misc.js +8 -8
- package/dest/public/avm/opcodes/storage.d.ts +14 -13
- package/dest/public/avm/opcodes/storage.d.ts.map +1 -1
- package/dest/public/avm/opcodes/storage.js +34 -24
- package/dest/public/avm/revert_reason.d.ts +2 -2
- package/dest/public/avm/revert_reason.d.ts.map +1 -1
- package/dest/public/avm/revert_reason.js +3 -2
- package/dest/public/avm/serialization/buffer_cursor.d.ts +1 -1
- package/dest/public/avm/serialization/buffer_cursor.d.ts.map +1 -1
- package/dest/public/avm/serialization/bytecode_serialization.d.ts +1 -1
- package/dest/public/avm/serialization/bytecode_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/bytecode_serialization.js +9 -6
- package/dest/public/avm/serialization/instruction_serialization.d.ts +1 -1
- package/dest/public/avm/serialization/instruction_serialization.js +1 -1
- package/dest/public/avm/test_utils.d.ts +2 -2
- package/dest/public/avm/test_utils.d.ts.map +1 -1
- package/dest/public/avm/test_utils.js +1 -1
- package/dest/public/contracts_db_checkpoint.d.ts +16 -0
- package/dest/public/contracts_db_checkpoint.d.ts.map +1 -0
- package/dest/public/contracts_db_checkpoint.js +30 -0
- package/dest/public/db_interfaces.d.ts +14 -2
- package/dest/public/db_interfaces.d.ts.map +1 -1
- package/dest/public/debug_fn_name.d.ts +16 -3
- package/dest/public/debug_fn_name.d.ts.map +1 -1
- package/dest/public/debug_fn_name.js +31 -3
- package/dest/public/executor_metrics.d.ts +3 -2
- package/dest/public/executor_metrics.d.ts.map +1 -1
- package/dest/public/executor_metrics.js +9 -35
- package/dest/public/executor_metrics_interface.d.ts +3 -2
- package/dest/public/executor_metrics_interface.d.ts.map +1 -1
- package/dest/public/fixtures/amm_test.d.ts +1 -1
- package/dest/public/fixtures/amm_test.js +2 -2
- package/dest/public/fixtures/bulk_test.d.ts +3 -3
- package/dest/public/fixtures/bulk_test.d.ts.map +1 -1
- package/dest/public/fixtures/bulk_test.js +5 -69
- package/dest/public/fixtures/custom_bytecode_tester.d.ts +29 -7
- package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -1
- package/dest/public/fixtures/custom_bytecode_tester.js +36 -12
- package/dest/public/fixtures/custom_bytecode_tests.d.ts +11 -8
- package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -1
- package/dest/public/fixtures/custom_bytecode_tests.js +83 -18
- package/dest/public/fixtures/index.d.ts +4 -2
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +3 -1
- package/dest/public/fixtures/minimal_public_tx.d.ts +2 -8
- package/dest/public/fixtures/minimal_public_tx.d.ts.map +1 -1
- package/dest/public/fixtures/minimal_public_tx.js +6 -16
- package/dest/public/fixtures/opcode_spammer.d.ts +122 -0
- package/dest/public/fixtures/opcode_spammer.d.ts.map +1 -0
- package/dest/public/fixtures/opcode_spammer.js +1653 -0
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +24 -6
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +62 -21
- package/dest/public/fixtures/simple_contract_data_source.d.ts +5 -4
- package/dest/public/fixtures/simple_contract_data_source.d.ts.map +1 -1
- package/dest/public/fixtures/simple_contract_data_source.js +4 -4
- package/dest/public/fixtures/token_test.d.ts +6 -2
- package/dest/public/fixtures/token_test.d.ts.map +1 -1
- package/dest/public/fixtures/token_test.js +13 -12
- package/dest/public/fixtures/utils.d.ts +2 -2
- package/dest/public/fixtures/utils.d.ts.map +1 -1
- package/dest/public/fixtures/utils.js +4 -3
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts +60 -0
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts.map +1 -0
- package/dest/public/fuzzing/avm_fuzzer_simulator.js +171 -0
- package/dest/public/fuzzing/avm_simulator_bin.d.ts +2 -0
- package/dest/public/fuzzing/avm_simulator_bin.d.ts.map +1 -0
- package/dest/public/fuzzing/avm_simulator_bin.js +118 -0
- package/dest/public/hinting_db_sources.d.ts +14 -4
- package/dest/public/hinting_db_sources.d.ts.map +1 -1
- package/dest/public/hinting_db_sources.js +71 -13
- package/dest/public/index.d.ts +3 -2
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +1 -1
- package/dest/public/public_db_sources.d.ts +22 -63
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +74 -131
- package/dest/public/public_errors.d.ts +1 -1
- package/dest/public/public_errors.d.ts.map +1 -1
- package/dest/public/public_processor/guarded_merkle_tree.d.ts +6 -4
- package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
- package/dest/public/public_processor/guarded_merkle_tree.js +5 -0
- package/dest/public/public_processor/public_processor.d.ts +12 -19
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +456 -64
- package/dest/public/public_processor/public_processor_metrics.d.ts +1 -1
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor_metrics.js +12 -45
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +18 -0
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +98 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +34 -22
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +93 -50
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts +42 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.js +86 -0
- package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts +30 -0
- package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.js +171 -0
- package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts +22 -0
- package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.js +52 -0
- package/dest/public/public_tx_simulator/factories.d.ts +13 -0
- package/dest/public/public_tx_simulator/factories.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/factories.js +28 -0
- package/dest/public/public_tx_simulator/index.d.ts +5 -1
- package/dest/public/public_tx_simulator/index.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/index.js +3 -0
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +14 -7
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.js +5 -5
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +6 -3
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +13 -5
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +13 -32
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +115 -129
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts +25 -2
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts +4 -4
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.js +395 -19
- package/dest/public/side_effect_errors.d.ts +1 -1
- package/dest/public/side_effect_errors.d.ts.map +1 -1
- package/dest/public/side_effect_trace.d.ts +2 -2
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +1 -1
- package/dest/public/side_effect_trace_interface.d.ts +3 -4
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
- package/dest/public/state_manager/index.d.ts +1 -1
- package/dest/public/state_manager/nullifiers.d.ts +2 -2
- package/dest/public/state_manager/nullifiers.d.ts.map +1 -1
- package/dest/public/state_manager/public_storage.d.ts +2 -2
- package/dest/public/state_manager/public_storage.d.ts.map +1 -1
- package/dest/public/state_manager/public_storage.js +1 -1
- package/dest/public/state_manager/state_manager.d.ts +15 -11
- package/dest/public/state_manager/state_manager.d.ts.map +1 -1
- package/dest/public/state_manager/state_manager.js +19 -8
- package/dest/public/test_executor_metrics.d.ts +4 -3
- package/dest/public/test_executor_metrics.d.ts.map +1 -1
- package/dest/public/test_executor_metrics.js +5 -4
- package/dest/public/unique_class_ids.d.ts +1 -1
- package/dest/public/unique_class_ids.d.ts.map +1 -1
- package/dest/public/utils.d.ts +1 -1
- package/dest/server.d.ts +1 -1
- package/dest/testing.d.ts +1 -1
- package/package.json +21 -20
- package/src/common/errors.ts +1 -1
- package/src/private/acvm/deserialize.ts +1 -1
- package/src/private/acvm/serialize.ts +1 -1
- package/src/private/circuit_recording/circuit_recorder.ts +17 -16
- package/src/public/avm/avm_context.ts +2 -2
- package/src/public/avm/avm_contract_call_result.ts +8 -6
- package/src/public/avm/avm_execution_environment.ts +13 -10
- package/src/public/avm/avm_gas.ts +3 -3
- package/src/public/avm/avm_machine_state.ts +7 -6
- package/src/public/avm/avm_memory_types.ts +5 -1
- package/src/public/avm/avm_simulator.ts +19 -14
- package/src/public/avm/calldata.ts +100 -0
- package/src/public/avm/errors.ts +17 -3
- package/src/public/avm/fixtures/avm_simulation_tester.ts +18 -4
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +1 -1
- package/src/public/avm/fixtures/initializers.ts +10 -11
- package/src/public/avm/fixtures/utils.ts +3 -2
- package/src/public/avm/opcodes/accrued_substate.ts +28 -30
- package/src/public/avm/opcodes/addressing_mode.ts +2 -2
- package/src/public/avm/opcodes/arithmetic.ts +14 -2
- package/src/public/avm/opcodes/bitwise.ts +3 -3
- package/src/public/avm/opcodes/comparators.ts +1 -1
- package/src/public/avm/opcodes/contract.ts +4 -7
- package/src/public/avm/opcodes/control_flow.ts +2 -2
- package/src/public/avm/opcodes/conversion.ts +3 -3
- package/src/public/avm/opcodes/ec_add.ts +15 -6
- package/src/public/avm/opcodes/environment_getters.ts +7 -7
- package/src/public/avm/opcodes/external_calls.ts +17 -15
- package/src/public/avm/opcodes/hashing.ts +16 -10
- package/src/public/avm/opcodes/instruction_impl.ts +2 -2
- package/src/public/avm/opcodes/memory.ts +20 -20
- package/src/public/avm/opcodes/misc.ts +6 -6
- package/src/public/avm/opcodes/storage.ts +30 -22
- package/src/public/avm/revert_reason.ts +6 -3
- package/src/public/avm/serialization/bytecode_serialization.ts +17 -6
- package/src/public/avm/serialization/instruction_serialization.ts +1 -1
- package/src/public/avm/test_utils.ts +1 -1
- package/src/public/contracts_db_checkpoint.ts +41 -0
- package/src/public/db_interfaces.ts +16 -1
- package/src/public/debug_fn_name.ts +39 -5
- package/src/public/executor_metrics.ts +9 -35
- package/src/public/executor_metrics_interface.ts +2 -1
- package/src/public/fixtures/amm_test.ts +2 -2
- package/src/public/fixtures/bulk_test.ts +9 -9
- package/src/public/fixtures/custom_bytecode_tester.ts +54 -20
- package/src/public/fixtures/custom_bytecode_tests.ts +111 -18
- package/src/public/fixtures/index.ts +7 -1
- package/src/public/fixtures/minimal_public_tx.ts +7 -17
- package/src/public/fixtures/opcode_spammer.ts +1721 -0
- package/src/public/fixtures/public_tx_simulation_tester.ts +85 -21
- package/src/public/fixtures/simple_contract_data_source.ts +8 -9
- package/src/public/fixtures/token_test.ts +18 -10
- package/src/public/fixtures/utils.ts +2 -3
- package/src/public/fuzzing/avm_fuzzer_simulator.ts +288 -0
- package/src/public/fuzzing/avm_simulator_bin.ts +175 -0
- package/src/public/hinting_db_sources.ts +112 -10
- package/src/public/index.ts +6 -4
- package/src/public/public_db_sources.ts +93 -172
- package/src/public/public_processor/guarded_merkle_tree.ts +8 -3
- package/src/public/public_processor/public_processor.ts +86 -59
- package/src/public/public_processor/public_processor_metrics.ts +11 -45
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +121 -0
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +137 -57
- package/src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts +132 -0
- package/src/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.ts +237 -0
- package/src/public/public_tx_simulator/dumping_cpp_public_tx_simulator.ts +81 -0
- package/src/public/public_tx_simulator/factories.ts +41 -0
- package/src/public/public_tx_simulator/index.ts +4 -0
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +10 -14
- package/src/public/public_tx_simulator/public_tx_context.ts +9 -3
- package/src/public/public_tx_simulator/public_tx_simulator.ts +171 -196
- package/src/public/public_tx_simulator/public_tx_simulator_interface.ts +24 -2
- package/src/public/public_tx_simulator/telemetry_public_tx_simulator.ts +3 -3
- package/src/public/side_effect_trace.ts +1 -1
- package/src/public/side_effect_trace_interface.ts +1 -1
- package/src/public/state_manager/nullifiers.ts +1 -1
- package/src/public/state_manager/public_storage.ts +1 -1
- package/src/public/state_manager/state_manager.ts +24 -30
- package/src/public/test_executor_metrics.ts +7 -5
- package/dest/public/tx_contract_cache.d.ts +0 -41
- package/dest/public/tx_contract_cache.d.ts.map +0 -1
- package/dest/public/tx_contract_cache.js +0 -49
- package/src/public/tx_contract_cache.ts +0 -69
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
|
|
3
3
|
import type { Gas } from './avm_gas.js';
|
|
4
4
|
import { TaggedMemory } from './avm_memory_types.js';
|
|
5
|
+
import { type ReturnData, ReturnDataArray } from './calldata.js';
|
|
5
6
|
import { type AvmRevertReason, OutOfGasError } from './errors.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -39,7 +40,7 @@ export class AvmMachineState {
|
|
|
39
40
|
/** program counter of the next instruction, byte based */
|
|
40
41
|
public nextPc: number = 0;
|
|
41
42
|
/** return/revertdata of the last nested call. */
|
|
42
|
-
public nestedReturndata:
|
|
43
|
+
public nestedReturndata: ReturnData = new ReturnDataArray([]);
|
|
43
44
|
/** Tracks whether the last external call was successful */
|
|
44
45
|
public nestedCallSuccess: boolean = false;
|
|
45
46
|
/**
|
|
@@ -66,7 +67,7 @@ export class AvmMachineState {
|
|
|
66
67
|
/** Signals that execution has reverted normally (this does not cover exceptional halts) */
|
|
67
68
|
private reverted: boolean = false;
|
|
68
69
|
/** Output data must NOT be modified once it is set */
|
|
69
|
-
private output:
|
|
70
|
+
private output: ReturnData = new ReturnDataArray([]);
|
|
70
71
|
|
|
71
72
|
// Metrics only - not needed for execution
|
|
72
73
|
/** instruction counter, including nested calls */
|
|
@@ -129,7 +130,7 @@ export class AvmMachineState {
|
|
|
129
130
|
* Output data must NOT be modified once it is set
|
|
130
131
|
* @param output
|
|
131
132
|
*/
|
|
132
|
-
public return(output:
|
|
133
|
+
public return(output: ReturnData) {
|
|
133
134
|
this.halted = true;
|
|
134
135
|
this.output = output;
|
|
135
136
|
}
|
|
@@ -139,7 +140,7 @@ export class AvmMachineState {
|
|
|
139
140
|
* Output data must NOT be modified once it is set
|
|
140
141
|
* @param output
|
|
141
142
|
*/
|
|
142
|
-
public revert(output:
|
|
143
|
+
public revert(output: ReturnData) {
|
|
143
144
|
this.halted = true;
|
|
144
145
|
this.reverted = true;
|
|
145
146
|
this.output = output;
|
|
@@ -153,7 +154,7 @@ export class AvmMachineState {
|
|
|
153
154
|
return this.reverted;
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
public getOutput():
|
|
157
|
+
public getOutput(): ReturnData {
|
|
157
158
|
return this.output;
|
|
158
159
|
}
|
|
159
160
|
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
MEM_TAG_U128,
|
|
9
9
|
} from '@aztec/constants';
|
|
10
10
|
import { toBufferBE } from '@aztec/foundation/bigint-buffer';
|
|
11
|
-
import { Fr } from '@aztec/foundation/
|
|
11
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
12
12
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
13
13
|
import type { FunctionsOf } from '@aztec/foundation/types';
|
|
14
14
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -369,6 +369,10 @@ export class TaggedMemory implements TaggedMemoryInterface {
|
|
|
369
369
|
* Check tags for all memory in the specified range.
|
|
370
370
|
*/
|
|
371
371
|
public checkTagsRange(tag: TypeTag, startOffset: number, size: number) {
|
|
372
|
+
if (startOffset + size > TaggedMemory.MAX_MEMORY_SIZE) {
|
|
373
|
+
throw new MemorySliceOutOfRangeError(startOffset, size);
|
|
374
|
+
}
|
|
375
|
+
|
|
372
376
|
for (let offset = startOffset; offset < startOffset + size; offset++) {
|
|
373
377
|
this.checkTag(tag, offset);
|
|
374
378
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
4
|
+
import type { PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
4
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
6
|
import type { GlobalVariables } from '@aztec/stdlib/tx';
|
|
6
7
|
|
|
@@ -14,6 +15,7 @@ import { AvmExecutionEnvironment } from './avm_execution_environment.js';
|
|
|
14
15
|
import type { Gas } from './avm_gas.js';
|
|
15
16
|
import { AvmMachineState } from './avm_machine_state.js';
|
|
16
17
|
import type { AvmSimulatorInterface } from './avm_simulator_interface.js';
|
|
18
|
+
import { type CallData, ReturnDataArray } from './calldata.js';
|
|
17
19
|
import { AvmRevertReason, InvalidProgramCounterError } from './errors.js';
|
|
18
20
|
import type { Instruction } from './opcodes/instruction.js';
|
|
19
21
|
import { revertReasonFromExceptionalHalt, revertReasonFromExplicitRevert } from './revert_reason.js';
|
|
@@ -48,7 +50,7 @@ export class AvmSimulator implements AvmSimulatorInterface {
|
|
|
48
50
|
// This will be used by the CALL opcode to create a new simulator. It is required to
|
|
49
51
|
// avoid a dependency cycle.
|
|
50
52
|
context.provideSimulator = AvmSimulator.build;
|
|
51
|
-
this.log = createLogger(`simulator:avm(calldata[0]: ${context.environment.calldata
|
|
53
|
+
this.log = createLogger(`simulator:avm(calldata[0]: ${context.environment.calldata.read(0)})`);
|
|
52
54
|
// Turn on tallying if explicitly enabled or if trace logging
|
|
53
55
|
if (enableTallying || this.log.isLevelEnabled('trace')) {
|
|
54
56
|
this.tallyPrintFunction = this.printOpcodeTallies;
|
|
@@ -73,10 +75,9 @@ export class AvmSimulator implements AvmSimulatorInterface {
|
|
|
73
75
|
transactionFee: Fr,
|
|
74
76
|
globals: GlobalVariables,
|
|
75
77
|
isStaticCall: boolean,
|
|
76
|
-
calldata:
|
|
78
|
+
calldata: CallData,
|
|
77
79
|
allocatedGas: Gas,
|
|
78
|
-
|
|
79
|
-
maxDebugLogMemoryReads?: number,
|
|
80
|
+
config: PublicSimulatorConfig,
|
|
80
81
|
) {
|
|
81
82
|
const avmExecutionEnv = new AvmExecutionEnvironment(
|
|
82
83
|
address,
|
|
@@ -86,8 +87,7 @@ export class AvmSimulator implements AvmSimulatorInterface {
|
|
|
86
87
|
globals,
|
|
87
88
|
isStaticCall,
|
|
88
89
|
calldata,
|
|
89
|
-
|
|
90
|
-
maxDebugLogMemoryReads,
|
|
90
|
+
config,
|
|
91
91
|
);
|
|
92
92
|
|
|
93
93
|
const avmMachineState = new AvmMachineState(allocatedGas);
|
|
@@ -105,7 +105,7 @@ export class AvmSimulator implements AvmSimulatorInterface {
|
|
|
105
105
|
|
|
106
106
|
if (!bytecode) {
|
|
107
107
|
return await this.handleFailureToRetrieveBytecode(
|
|
108
|
-
`No bytecode found, or limit encountered for max calls to unique contract class IDs. Contract address: ${this.context.environment.address}. Reverting...`,
|
|
108
|
+
`No bytecode found. Contract is not deployed, or limit encountered for max calls to unique contract class IDs. Contract address: ${this.context.environment.address}. Reverting...`,
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
111
|
|
|
@@ -178,13 +178,15 @@ export class AvmSimulator implements AvmSimulatorInterface {
|
|
|
178
178
|
|
|
179
179
|
if (machineState.pc >= bytecode.length) {
|
|
180
180
|
this.log.warn('Passed end of program');
|
|
181
|
-
throw new InvalidProgramCounterError(machineState.pc, /*max=*/ bytecode.length);
|
|
181
|
+
throw new InvalidProgramCounterError(machineState.pc, /*max=*/ bytecode.length - 1);
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
const output = machineState.getOutput();
|
|
186
186
|
const reverted = machineState.getReverted();
|
|
187
|
-
const revertReason = reverted
|
|
187
|
+
const revertReason = reverted
|
|
188
|
+
? await revertReasonFromExplicitRevert(output.bestEffortReadAll(), this.context)
|
|
189
|
+
: undefined;
|
|
188
190
|
const results = new AvmContractCallResult(
|
|
189
191
|
reverted,
|
|
190
192
|
output,
|
|
@@ -221,7 +223,7 @@ export class AvmSimulator implements AvmSimulatorInterface {
|
|
|
221
223
|
// Note: "exceptional halts" cannot return data, hence [].
|
|
222
224
|
const results = new AvmContractCallResult(
|
|
223
225
|
/*reverted=*/ true,
|
|
224
|
-
/*output=*/ [],
|
|
226
|
+
/*output=*/ new ReturnDataArray([]),
|
|
225
227
|
noGasLeft,
|
|
226
228
|
revertReason,
|
|
227
229
|
machineState.instrCounter,
|
|
@@ -236,19 +238,22 @@ export class AvmSimulator implements AvmSimulatorInterface {
|
|
|
236
238
|
|
|
237
239
|
private async handleFailureToRetrieveBytecode(message: string): Promise<AvmContractCallResult> {
|
|
238
240
|
// revert, consuming all gas
|
|
239
|
-
const
|
|
241
|
+
const { functionSelector, functionName } = await this.context.persistableState.getPublicFunctionSelectorAndName(
|
|
242
|
+
this.context.environment,
|
|
243
|
+
);
|
|
240
244
|
const revertReason = new AvmRevertReason(
|
|
241
245
|
message,
|
|
242
246
|
/*failingFunction=*/ {
|
|
243
247
|
contractAddress: this.context.environment.address,
|
|
244
|
-
|
|
248
|
+
functionSelector,
|
|
249
|
+
functionName,
|
|
245
250
|
},
|
|
246
251
|
/*noirCallStack=*/ [],
|
|
247
252
|
);
|
|
248
253
|
this.log.warn(message);
|
|
249
254
|
return new AvmContractCallResult(
|
|
250
255
|
/*reverted=*/ true,
|
|
251
|
-
/*output=*/ [],
|
|
256
|
+
/*output=*/ new ReturnDataArray([]),
|
|
252
257
|
/*gasLeft=*/ { l2Gas: 0, daGas: 0 }, // consumes all allocated gas
|
|
253
258
|
revertReason,
|
|
254
259
|
);
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/schemas';
|
|
2
|
+
|
|
3
|
+
import { TaggedMemory } from './avm_memory_types.js';
|
|
4
|
+
|
|
5
|
+
// Allow reading up to 300 kB of return data when unspecified.
|
|
6
|
+
const DEFAULT_BEST_EFFORT_READ_CAP = 10000;
|
|
7
|
+
|
|
8
|
+
export interface LazyReader {
|
|
9
|
+
bestEffortReadAll(readCap?: number): Fr[];
|
|
10
|
+
readAll(): Fr[];
|
|
11
|
+
read(idx: number): Fr | undefined;
|
|
12
|
+
slice(start: number, end: number): Fr[];
|
|
13
|
+
length(): number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class LazyReaderMemory implements LazyReader {
|
|
17
|
+
constructor(
|
|
18
|
+
private memory: TaggedMemory,
|
|
19
|
+
private offset: number,
|
|
20
|
+
private size: number,
|
|
21
|
+
) {}
|
|
22
|
+
|
|
23
|
+
public bestEffortReadAll(readCap = DEFAULT_BEST_EFFORT_READ_CAP): Fr[] {
|
|
24
|
+
const size = Math.min(this.size, readCap, TaggedMemory.MAX_MEMORY_SIZE - this.offset);
|
|
25
|
+
return this.memory.getSlice(this.offset, size).map(word => word.toFr());
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public read(idx: number): Fr | undefined {
|
|
29
|
+
if (idx >= this.size) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
return this.memory.get(this.offset + idx).toFr();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public slice(start: number, end: number): Fr[] {
|
|
36
|
+
const clampedEnd = Math.min(end, this.size);
|
|
37
|
+
const length = Math.max(0, clampedEnd - start);
|
|
38
|
+
return this.memory.getSlice(this.offset + start, length).map(word => word.toFr());
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public readAll(): Fr[] {
|
|
42
|
+
return this.memory.getSlice(this.offset, this.size).map(word => word.toFr());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public length(): number {
|
|
46
|
+
return this.size;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export class LazyReaderArray implements LazyReader {
|
|
51
|
+
constructor(private array: Fr[]) {}
|
|
52
|
+
|
|
53
|
+
public bestEffortReadAll(readCap = DEFAULT_BEST_EFFORT_READ_CAP): Fr[] {
|
|
54
|
+
return this.array.slice(0, readCap);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public read(idx: number): Fr | undefined {
|
|
58
|
+
return this.array[idx];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public slice(start: number, end: number): Fr[] {
|
|
62
|
+
return this.array.slice(start, end);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public readAll(): Fr[] {
|
|
66
|
+
return this.array;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public length(): number {
|
|
70
|
+
return this.array.length;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Compile time branding to avoid swapping CallData and ReturnData by accident.
|
|
75
|
+
declare const CallDataBrand: unique symbol;
|
|
76
|
+
declare const ReturnDataBrand: unique symbol;
|
|
77
|
+
|
|
78
|
+
export type CallData = LazyReader & {
|
|
79
|
+
readonly [CallDataBrand]: true;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export type ReturnData = LazyReader & {
|
|
83
|
+
readonly [ReturnDataBrand]: true;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export class CallDataArray extends LazyReaderArray implements CallData {
|
|
87
|
+
declare readonly [CallDataBrand]: true;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export class CallDataMemory extends LazyReaderMemory implements CallData {
|
|
91
|
+
declare readonly [CallDataBrand]: true;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export class ReturnDataArray extends LazyReaderArray implements ReturnData {
|
|
95
|
+
declare readonly [ReturnDataBrand]: true;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export class ReturnDataMemory extends LazyReaderMemory implements ReturnData {
|
|
99
|
+
declare readonly [ReturnDataBrand]: true;
|
|
100
|
+
}
|
package/src/public/avm/errors.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Point } from '@aztec/foundation/
|
|
1
|
+
import type { Point } from '@aztec/foundation/curves/grumpkin';
|
|
2
2
|
import type { FailingFunction, NoirCallStack } from '@aztec/stdlib/errors';
|
|
3
3
|
|
|
4
4
|
import { ExecutionError } from '../../common/errors.js';
|
|
@@ -58,7 +58,7 @@ export class AvmParsingError extends AvmExecutionError {
|
|
|
58
58
|
*/
|
|
59
59
|
export class InvalidTagValueError extends AvmExecutionError {
|
|
60
60
|
constructor(tagValue: number) {
|
|
61
|
-
super(`Tag value ${tagValue} is invalid.`);
|
|
61
|
+
super(`Tag check failed: Tag value ${tagValue} is invalid.`);
|
|
62
62
|
this.name = 'InvalidTagValueError';
|
|
63
63
|
}
|
|
64
64
|
}
|
|
@@ -77,6 +77,12 @@ export class InstructionExecutionError extends AvmExecutionError {
|
|
|
77
77
|
* Error thrown on failed AVM memory tag check.
|
|
78
78
|
*/
|
|
79
79
|
export class TagCheckError extends AvmExecutionError {
|
|
80
|
+
public static forBaseAddress(gotTag: string): TagCheckError {
|
|
81
|
+
return new TagCheckError(`Base address (mem[0]) is not a valid address (has tag ${gotTag})`);
|
|
82
|
+
}
|
|
83
|
+
public static forIndirectAddress(address: number, gotTag: string): TagCheckError {
|
|
84
|
+
return new TagCheckError(`Address after indirection is not a valid address (address ${address} has tag ${gotTag})`);
|
|
85
|
+
}
|
|
80
86
|
public static forOffset(offset: number, gotTag: string, expectedTag: string): TagCheckError {
|
|
81
87
|
return new TagCheckError(`Tag mismatch at offset ${offset}, got ${gotTag}, expected ${expectedTag}`);
|
|
82
88
|
}
|
|
@@ -97,7 +103,7 @@ export class TagCheckError extends AvmExecutionError {
|
|
|
97
103
|
*/
|
|
98
104
|
export class RelativeAddressOutOfRangeError extends AvmExecutionError {
|
|
99
105
|
constructor(baseAddr: number, relOffset: number) {
|
|
100
|
-
super(`
|
|
106
|
+
super(`Relative address out of range. Base address ${baseAddr}, relative offset ${relOffset}`);
|
|
101
107
|
this.name = 'RelativeAddressOutOfRangeError';
|
|
102
108
|
}
|
|
103
109
|
}
|
|
@@ -161,3 +167,11 @@ export class AvmRevertReason extends ExecutionError {
|
|
|
161
167
|
super(message, failingFunction, noirCallStack, options);
|
|
162
168
|
}
|
|
163
169
|
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Helper to annotate errors occurring during instruction fetching.
|
|
173
|
+
*/
|
|
174
|
+
export function duringInstrFetch(error: Error, pc: number) {
|
|
175
|
+
error.message = `Instruction fetching error at pc ${pc}: ${error.message}`;
|
|
176
|
+
return error;
|
|
177
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { encodeArguments } from '@aztec/stdlib/abi';
|
|
3
|
+
import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
3
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
5
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
5
6
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
@@ -12,6 +13,7 @@ import { SimpleContractDataSource } from '../../fixtures/simple_contract_data_so
|
|
|
12
13
|
import { PublicContractsDB, PublicTreesDB } from '../../public_db_sources.js';
|
|
13
14
|
import { PublicPersistableStateManager } from '../../state_manager/state_manager.js';
|
|
14
15
|
import { AvmSimulator } from '../avm_simulator.js';
|
|
16
|
+
import { CallDataArray } from '../calldata.js';
|
|
15
17
|
import { BaseAvmSimulationTester } from './base_avm_simulation_tester.js';
|
|
16
18
|
import { initContext, initExecutionEnvironment } from './initializers.js';
|
|
17
19
|
import {
|
|
@@ -51,7 +53,6 @@ export class AvmSimulationTester extends BaseAvmSimulationTester {
|
|
|
51
53
|
treesDB,
|
|
52
54
|
contractsDB,
|
|
53
55
|
trace,
|
|
54
|
-
/*doMerkleOperations=*/ false,
|
|
55
56
|
firstNullifier,
|
|
56
57
|
DEFAULT_TIMESTAMP,
|
|
57
58
|
);
|
|
@@ -81,12 +82,20 @@ export class AvmSimulationTester extends BaseAvmSimulationTester {
|
|
|
81
82
|
globals.timestamp = DEFAULT_TIMESTAMP;
|
|
82
83
|
globals.gasFees = DEFAULT_GAS_FEES;
|
|
83
84
|
|
|
85
|
+
const config = PublicSimulatorConfig.from({
|
|
86
|
+
skipFeeEnforcement: false,
|
|
87
|
+
collectDebugLogs: true,
|
|
88
|
+
collectHints: false,
|
|
89
|
+
collectStatistics: false,
|
|
90
|
+
collectCallMetadata: true,
|
|
91
|
+
});
|
|
84
92
|
const environment = initExecutionEnvironment({
|
|
85
|
-
calldata,
|
|
93
|
+
calldata: new CallDataArray(calldata),
|
|
86
94
|
globals,
|
|
87
95
|
address,
|
|
88
96
|
sender,
|
|
89
97
|
isStaticCall,
|
|
98
|
+
config,
|
|
90
99
|
});
|
|
91
100
|
const persistableState = await this.stateManager.fork();
|
|
92
101
|
const context = initContext({ env: environment, persistableState });
|
|
@@ -97,7 +106,12 @@ export class AvmSimulationTester extends BaseAvmSimulationTester {
|
|
|
97
106
|
if (result.reverted) {
|
|
98
107
|
this.logger.error(`Error in ${fnName}:`);
|
|
99
108
|
this.logger.error(
|
|
100
|
-
resolveContractAssertionMessage(
|
|
109
|
+
resolveContractAssertionMessage(
|
|
110
|
+
fnName,
|
|
111
|
+
result.revertReason!,
|
|
112
|
+
result.output.bestEffortReadAll(),
|
|
113
|
+
contractArtifact,
|
|
114
|
+
)!,
|
|
101
115
|
);
|
|
102
116
|
} else {
|
|
103
117
|
this.logger.info(`Simulation of function ${fnName} succeeded!`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS } from '@aztec/constants';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
5
5
|
import { getCanonicalAuthRegistry } from '@aztec/protocol-contracts/auth-registry';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { AVM_MAX_PROCESSABLE_L2_GAS
|
|
1
|
+
import { AVM_MAX_PROCESSABLE_L2_GAS } from '@aztec/constants';
|
|
2
|
+
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
4
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
-
import {
|
|
5
|
+
import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
4
6
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
7
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
6
8
|
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
@@ -17,6 +19,7 @@ import { AvmContext } from '../avm_context.js';
|
|
|
17
19
|
import { AvmExecutionEnvironment } from '../avm_execution_environment.js';
|
|
18
20
|
import { AvmMachineState } from '../avm_machine_state.js';
|
|
19
21
|
import { AvmSimulator } from '../avm_simulator.js';
|
|
22
|
+
import { CallDataArray } from '../calldata.js';
|
|
20
23
|
import { DEFAULT_TIMESTAMP } from './utils.js';
|
|
21
24
|
|
|
22
25
|
/**
|
|
@@ -43,7 +46,6 @@ export function initPersistableStateManager(overrides?: {
|
|
|
43
46
|
trace?: PublicSideEffectTraceInterface;
|
|
44
47
|
publicStorage?: PublicStorage;
|
|
45
48
|
nullifiers?: NullifierManager;
|
|
46
|
-
doMerkleOperations?: boolean;
|
|
47
49
|
firstNullifier?: Fr;
|
|
48
50
|
timestamp?: UInt64;
|
|
49
51
|
}): PublicPersistableStateManager {
|
|
@@ -54,9 +56,7 @@ export function initPersistableStateManager(overrides?: {
|
|
|
54
56
|
overrides?.trace || mock<PublicSideEffectTraceInterface>(),
|
|
55
57
|
overrides?.firstNullifier || new Fr(27),
|
|
56
58
|
overrides?.timestamp || DEFAULT_TIMESTAMP,
|
|
57
|
-
|
|
58
|
-
overrides?.publicStorage,
|
|
59
|
-
overrides?.nullifiers,
|
|
59
|
+
/*doMerkleOperations=*/ false,
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -71,9 +71,8 @@ export function initExecutionEnvironment(overrides?: Partial<AvmExecutionEnviron
|
|
|
71
71
|
overrides?.transactionFee ?? Fr.zero(),
|
|
72
72
|
overrides?.globals ?? GlobalVariables.empty(),
|
|
73
73
|
overrides?.isStaticCall ?? false,
|
|
74
|
-
overrides?.calldata ?? [],
|
|
75
|
-
overrides?.
|
|
76
|
-
overrides?.maxDebugLogMemoryReads ?? DEFAULT_MAX_DEBUG_LOG_MEMORY_READS,
|
|
74
|
+
overrides?.calldata ?? new CallDataArray([]),
|
|
75
|
+
overrides?.config ?? PublicSimulatorConfig.empty(),
|
|
77
76
|
);
|
|
78
77
|
}
|
|
79
78
|
|
|
@@ -84,8 +83,8 @@ export function initGlobalVariables(overrides?: Partial<GlobalVariables>): Globa
|
|
|
84
83
|
return new GlobalVariables(
|
|
85
84
|
overrides?.chainId ?? Fr.zero(),
|
|
86
85
|
overrides?.version ?? Fr.zero(),
|
|
87
|
-
overrides?.blockNumber ??
|
|
88
|
-
overrides?.slotNumber ??
|
|
86
|
+
overrides?.blockNumber ?? BlockNumber.ZERO,
|
|
87
|
+
overrides?.slotNumber ?? SlotNumber.ZERO,
|
|
89
88
|
overrides?.timestamp ?? 0n,
|
|
90
89
|
overrides?.coinbase ?? EthAddress.ZERO,
|
|
91
90
|
overrides?.feeRecipient ?? AztecAddress.zero(),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS } from '@aztec/constants';
|
|
2
|
-
import {
|
|
2
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
4
|
import {
|
|
4
5
|
type ContractArtifact,
|
|
5
6
|
type FunctionAbi,
|
|
@@ -28,7 +29,7 @@ import type { AvmRevertReason } from '../errors.js';
|
|
|
28
29
|
|
|
29
30
|
export const PUBLIC_DISPATCH_FN_NAME = 'public_dispatch';
|
|
30
31
|
export const DEFAULT_TIMESTAMP: UInt64 = 99833n;
|
|
31
|
-
export const DEFAULT_BLOCK_NUMBER = 42;
|
|
32
|
+
export const DEFAULT_BLOCK_NUMBER = BlockNumber(42);
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
35
|
* Create a new object with all the same properties as the original, except for the ones in the overrides object.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { MAX_ETH_ADDRESS_VALUE } from '@aztec/constants';
|
|
2
|
+
|
|
1
3
|
import { NullifierCollisionError } from '../../side_effect_errors.js';
|
|
2
4
|
import type { AvmContext } from '../avm_context.js';
|
|
3
5
|
import { TypeTag, Uint1 } from '../avm_memory_types.js';
|
|
@@ -19,7 +21,7 @@ export class NoteHashExists extends Instruction {
|
|
|
19
21
|
];
|
|
20
22
|
|
|
21
23
|
constructor(
|
|
22
|
-
private
|
|
24
|
+
private addressingMode: number,
|
|
23
25
|
private noteHashOffset: number,
|
|
24
26
|
private leafIndexOffset: number,
|
|
25
27
|
private existsOffset: number,
|
|
@@ -29,7 +31,7 @@ export class NoteHashExists extends Instruction {
|
|
|
29
31
|
|
|
30
32
|
public async execute(context: AvmContext): Promise<void> {
|
|
31
33
|
const memory = context.machineState.memory;
|
|
32
|
-
const addressing = Addressing.fromWire(this.
|
|
34
|
+
const addressing = Addressing.fromWire(this.addressingMode);
|
|
33
35
|
|
|
34
36
|
context.machineState.consumeGas(
|
|
35
37
|
this.baseGasCost(addressing.indirectOperandsCount(), addressing.relativeOperandsCount()),
|
|
@@ -55,7 +57,7 @@ export class EmitNoteHash extends Instruction {
|
|
|
55
57
|
static readonly wireFormat = [OperandType.UINT8, OperandType.UINT8, OperandType.UINT16];
|
|
56
58
|
|
|
57
59
|
constructor(
|
|
58
|
-
private
|
|
60
|
+
private addressingMode: number,
|
|
59
61
|
private noteHashOffset: number,
|
|
60
62
|
) {
|
|
61
63
|
super();
|
|
@@ -63,7 +65,7 @@ export class EmitNoteHash extends Instruction {
|
|
|
63
65
|
|
|
64
66
|
public async execute(context: AvmContext): Promise<void> {
|
|
65
67
|
const memory = context.machineState.memory;
|
|
66
|
-
const addressing = Addressing.fromWire(this.
|
|
68
|
+
const addressing = Addressing.fromWire(this.addressingMode);
|
|
67
69
|
|
|
68
70
|
context.machineState.consumeGas(
|
|
69
71
|
this.baseGasCost(addressing.indirectOperandsCount(), addressing.relativeOperandsCount()),
|
|
@@ -86,18 +88,11 @@ export class NullifierExists extends Instruction {
|
|
|
86
88
|
static type: string = 'NULLIFIEREXISTS';
|
|
87
89
|
static readonly opcode: Opcode = Opcode.NULLIFIEREXISTS;
|
|
88
90
|
// Informs (de)serialization. See Instruction.deserialize.
|
|
89
|
-
static readonly wireFormat = [
|
|
90
|
-
OperandType.UINT8,
|
|
91
|
-
OperandType.UINT8,
|
|
92
|
-
OperandType.UINT16,
|
|
93
|
-
OperandType.UINT16,
|
|
94
|
-
OperandType.UINT16,
|
|
95
|
-
];
|
|
91
|
+
static readonly wireFormat = [OperandType.UINT8, OperandType.UINT8, OperandType.UINT16, OperandType.UINT16];
|
|
96
92
|
|
|
97
93
|
constructor(
|
|
98
|
-
private
|
|
99
|
-
private
|
|
100
|
-
private addressOffset: number,
|
|
94
|
+
private addressingMode: number,
|
|
95
|
+
private siloedNullifierOffset: number,
|
|
101
96
|
private existsOffset: number,
|
|
102
97
|
) {
|
|
103
98
|
super();
|
|
@@ -105,19 +100,18 @@ export class NullifierExists extends Instruction {
|
|
|
105
100
|
|
|
106
101
|
public async execute(context: AvmContext): Promise<void> {
|
|
107
102
|
const memory = context.machineState.memory;
|
|
108
|
-
const addressing = Addressing.fromWire(this.
|
|
103
|
+
const addressing = Addressing.fromWire(this.addressingMode);
|
|
109
104
|
|
|
110
105
|
context.machineState.consumeGas(
|
|
111
106
|
this.baseGasCost(addressing.indirectOperandsCount(), addressing.relativeOperandsCount()),
|
|
112
107
|
);
|
|
113
108
|
|
|
114
|
-
const operands = [this.
|
|
115
|
-
const [
|
|
116
|
-
memory.
|
|
109
|
+
const operands = [this.siloedNullifierOffset, this.existsOffset];
|
|
110
|
+
const [siloedNullifierOffset, existsOffset] = addressing.resolve(operands, memory);
|
|
111
|
+
memory.checkTag(TypeTag.FIELD, siloedNullifierOffset);
|
|
117
112
|
|
|
118
|
-
const
|
|
119
|
-
const
|
|
120
|
-
const exists = await context.persistableState.checkNullifierExists(address, nullifier);
|
|
113
|
+
const siloedNullifier = memory.get(siloedNullifierOffset).toFr();
|
|
114
|
+
const exists = await context.persistableState.checkSiloedNullifierExists(siloedNullifier);
|
|
121
115
|
|
|
122
116
|
memory.set(existsOffset, exists ? new Uint1(1) : new Uint1(0));
|
|
123
117
|
}
|
|
@@ -130,7 +124,7 @@ export class EmitNullifier extends Instruction {
|
|
|
130
124
|
static readonly wireFormat = [OperandType.UINT8, OperandType.UINT8, OperandType.UINT16];
|
|
131
125
|
|
|
132
126
|
constructor(
|
|
133
|
-
private
|
|
127
|
+
private addressingMode: number,
|
|
134
128
|
private nullifierOffset: number,
|
|
135
129
|
) {
|
|
136
130
|
super();
|
|
@@ -142,7 +136,7 @@ export class EmitNullifier extends Instruction {
|
|
|
142
136
|
}
|
|
143
137
|
|
|
144
138
|
const memory = context.machineState.memory;
|
|
145
|
-
const addressing = Addressing.fromWire(this.
|
|
139
|
+
const addressing = Addressing.fromWire(this.addressingMode);
|
|
146
140
|
|
|
147
141
|
context.machineState.consumeGas(
|
|
148
142
|
this.baseGasCost(addressing.indirectOperandsCount(), addressing.relativeOperandsCount()),
|
|
@@ -181,7 +175,7 @@ export class L1ToL2MessageExists extends Instruction {
|
|
|
181
175
|
];
|
|
182
176
|
|
|
183
177
|
constructor(
|
|
184
|
-
private
|
|
178
|
+
private addressingMode: number,
|
|
185
179
|
private msgHashOffset: number,
|
|
186
180
|
private msgLeafIndexOffset: number,
|
|
187
181
|
private existsOffset: number,
|
|
@@ -191,7 +185,7 @@ export class L1ToL2MessageExists extends Instruction {
|
|
|
191
185
|
|
|
192
186
|
public async execute(context: AvmContext): Promise<void> {
|
|
193
187
|
const memory = context.machineState.memory;
|
|
194
|
-
const addressing = Addressing.fromWire(this.
|
|
188
|
+
const addressing = Addressing.fromWire(this.addressingMode);
|
|
195
189
|
|
|
196
190
|
context.machineState.consumeGas(
|
|
197
191
|
this.baseGasCost(addressing.indirectOperandsCount(), addressing.relativeOperandsCount()),
|
|
@@ -218,7 +212,7 @@ export class EmitUnencryptedLog extends Instruction {
|
|
|
218
212
|
static readonly wireFormat = [OperandType.UINT8, OperandType.UINT8, OperandType.UINT16, OperandType.UINT16];
|
|
219
213
|
|
|
220
214
|
constructor(
|
|
221
|
-
private
|
|
215
|
+
private addressingMode: number,
|
|
222
216
|
private logSizeOffset: number,
|
|
223
217
|
private logOffset: number,
|
|
224
218
|
) {
|
|
@@ -231,7 +225,7 @@ export class EmitUnencryptedLog extends Instruction {
|
|
|
231
225
|
}
|
|
232
226
|
|
|
233
227
|
const memory = context.machineState.memory;
|
|
234
|
-
const addressing = Addressing.fromWire(this.
|
|
228
|
+
const addressing = Addressing.fromWire(this.addressingMode);
|
|
235
229
|
|
|
236
230
|
context.machineState.consumeGas(
|
|
237
231
|
this.baseGasCost(addressing.indirectOperandsCount(), addressing.relativeOperandsCount()),
|
|
@@ -241,11 +235,11 @@ export class EmitUnencryptedLog extends Instruction {
|
|
|
241
235
|
const [logSizeOffset, logOffset] = addressing.resolve(operands, memory);
|
|
242
236
|
memory.checkTag(TypeTag.UINT32, logSizeOffset);
|
|
243
237
|
const logSize = memory.get(logSizeOffset).toNumber();
|
|
244
|
-
memory.checkTagsRange(TypeTag.FIELD, logOffset, logSize);
|
|
245
238
|
|
|
246
239
|
const contractAddress = context.environment.address;
|
|
247
240
|
|
|
248
241
|
context.machineState.consumeGas(this.dynamicGasCost(logSize));
|
|
242
|
+
memory.checkTagsRange(TypeTag.FIELD, logOffset, logSize);
|
|
249
243
|
const log = memory.getSlice(logOffset, logSize).map(f => f.toFr());
|
|
250
244
|
context.persistableState.writePublicLog(contractAddress, log);
|
|
251
245
|
}
|
|
@@ -258,7 +252,7 @@ export class SendL2ToL1Message extends Instruction {
|
|
|
258
252
|
static readonly wireFormat = [OperandType.UINT8, OperandType.UINT8, OperandType.UINT16, OperandType.UINT16];
|
|
259
253
|
|
|
260
254
|
constructor(
|
|
261
|
-
private
|
|
255
|
+
private addressingMode: number,
|
|
262
256
|
private recipientOffset: number,
|
|
263
257
|
private contentOffset: number,
|
|
264
258
|
) {
|
|
@@ -271,7 +265,7 @@ export class SendL2ToL1Message extends Instruction {
|
|
|
271
265
|
}
|
|
272
266
|
|
|
273
267
|
const memory = context.machineState.memory;
|
|
274
|
-
const addressing = Addressing.fromWire(this.
|
|
268
|
+
const addressing = Addressing.fromWire(this.addressingMode);
|
|
275
269
|
|
|
276
270
|
context.machineState.consumeGas(
|
|
277
271
|
this.baseGasCost(addressing.indirectOperandsCount(), addressing.relativeOperandsCount()),
|
|
@@ -282,6 +276,10 @@ export class SendL2ToL1Message extends Instruction {
|
|
|
282
276
|
memory.checkTags(TypeTag.FIELD, recipientOffset, contentOffset);
|
|
283
277
|
|
|
284
278
|
const recipient = memory.get(recipientOffset).toFr();
|
|
279
|
+
|
|
280
|
+
if (recipient.toBigInt() > MAX_ETH_ADDRESS_VALUE) {
|
|
281
|
+
throw new InstructionExecutionError(`SENDL2TOL1MSG: Recipient address is too large`);
|
|
282
|
+
}
|
|
285
283
|
const content = memory.get(contentOffset).toFr();
|
|
286
284
|
context.persistableState.writeL2ToL1Message(context.environment.address, recipient, content);
|
|
287
285
|
}
|
|
@@ -83,7 +83,7 @@ export class Addressing {
|
|
|
83
83
|
baseAddr = mem.get(0);
|
|
84
84
|
const baseAddrTag = baseAddr.getTag();
|
|
85
85
|
if (!TaggedMemory.isValidMemoryAddressTag(baseAddrTag!)) {
|
|
86
|
-
throw TagCheckError.
|
|
86
|
+
throw TagCheckError.forBaseAddress(TypeTag[baseAddrTag!]);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
// Here we know that resolved[i] is at most 32 bits and baseAddr is at most 32 bits.
|
|
@@ -100,7 +100,7 @@ export class Addressing {
|
|
|
100
100
|
|
|
101
101
|
// Final check.
|
|
102
102
|
if (!TaggedMemory.isValidMemoryAddressTag(resolvedTag)) {
|
|
103
|
-
throw TagCheckError.
|
|
103
|
+
throw TagCheckError.forIndirectAddress(resolved[i], TypeTag[resolvedTag]);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
resolved[i] = Number(resolvedValue.toBigInt());
|