@aztec/simulator 4.0.0-nightly.20250907 → 4.0.0-nightly.20260107
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/dest/client.d.ts +1 -1
- package/dest/common/errors.d.ts +2 -8
- 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 +2 -3
- package/dest/private/acvm_native.d.ts.map +1 -1
- package/dest/private/acvm_native.js +15 -13
- 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 +2 -2
- 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 +2 -2
- package/dest/public/avm/avm_context.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.d.ts +2 -2
- package/dest/public/avm/avm_contract_call_result.d.ts.map +1 -1
- package/dest/public/avm/avm_execution_environment.d.ts +5 -4
- package/dest/public/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/public/avm/avm_execution_environment.js +5 -5
- 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_gas.js +2 -2
- package/dest/public/avm/avm_machine_state.d.ts +2 -2
- package/dest/public/avm/avm_machine_state.d.ts.map +1 -1
- package/dest/public/avm/avm_memory_types.d.ts +20 -14
- package/dest/public/avm/avm_memory_types.d.ts.map +1 -1
- package/dest/public/avm/avm_memory_types.js +10 -3
- package/dest/public/avm/avm_simulator.d.ts +4 -3
- package/dest/public/avm/avm_simulator.d.ts.map +1 -1
- package/dest/public/avm/avm_simulator.js +19 -25
- package/dest/public/avm/avm_simulator_interface.d.ts +1 -1
- package/dest/public/avm/errors.d.ts +13 -16
- package/dest/public/avm/errors.d.ts.map +1 -1
- package/dest/public/avm/errors.js +21 -22
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts +3 -2
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.js +14 -6
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +4 -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 +23 -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 +6 -4
- 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 +3 -3
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/public/avm/opcodes/accrued_substate.js +8 -8
- 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 +4 -5
- package/dest/public/avm/opcodes/arithmetic.d.ts +10 -8
- package/dest/public/avm/opcodes/arithmetic.d.ts.map +1 -1
- package/dest/public/avm/opcodes/arithmetic.js +11 -1
- package/dest/public/avm/opcodes/bitwise.d.ts +5 -5
- package/dest/public/avm/opcodes/bitwise.d.ts.map +1 -1
- package/dest/public/avm/opcodes/comparators.d.ts +4 -4
- package/dest/public/avm/opcodes/comparators.d.ts.map +1 -1
- package/dest/public/avm/opcodes/contract.d.ts +1 -1
- package/dest/public/avm/opcodes/contract.d.ts.map +1 -1
- package/dest/public/avm/opcodes/control_flow.d.ts +1 -1
- package/dest/public/avm/opcodes/control_flow.d.ts.map +1 -1
- package/dest/public/avm/opcodes/conversion.d.ts +1 -1
- package/dest/public/avm/opcodes/conversion.d.ts.map +1 -1
- package/dest/public/avm/opcodes/conversion.js +3 -0
- package/dest/public/avm/opcodes/ec_add.d.ts +2 -2
- 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 +1 -1
- package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/public/avm/opcodes/environment_getters.js +5 -7
- package/dest/public/avm/opcodes/external_calls.d.ts +1 -1
- package/dest/public/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/public/avm/opcodes/external_calls.js +1 -1
- package/dest/public/avm/opcodes/hashing.d.ts +2 -2
- package/dest/public/avm/opcodes/hashing.d.ts.map +1 -1
- package/dest/public/avm/opcodes/hashing.js +9 -4
- 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.js +5 -6
- package/dest/public/avm/opcodes/instruction_impl.d.ts +1 -1
- package/dest/public/avm/opcodes/instruction_impl.d.ts.map +1 -1
- package/dest/public/avm/opcodes/memory.d.ts +2 -2
- package/dest/public/avm/opcodes/memory.d.ts.map +1 -1
- package/dest/public/avm/opcodes/memory.js +1 -1
- package/dest/public/avm/opcodes/misc.d.ts +3 -2
- package/dest/public/avm/opcodes/misc.d.ts.map +1 -1
- package/dest/public/avm/opcodes/misc.js +28 -8
- package/dest/public/avm/opcodes/storage.d.ts +3 -3
- package/dest/public/avm/opcodes/storage.d.ts.map +1 -1
- 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 +9 -1
- package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/instruction_serialization.js +11 -1
- package/dest/public/avm/test_utils.d.ts +4 -4
- package/dest/public/avm/test_utils.d.ts.map +1 -1
- package/dest/public/avm/test_utils.js +7 -10
- 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 +15 -2
- package/dest/public/debug_fn_name.d.ts.map +1 -1
- package/dest/public/debug_fn_name.js +28 -2
- 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 +1 -1
- 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 +1 -1
- package/dest/public/fixtures/bulk_test.d.ts.map +1 -1
- package/dest/public/fixtures/bulk_test.js +59 -161
- package/dest/public/fixtures/custom_bytecode_tester.d.ts +34 -0
- package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -0
- package/dest/public/fixtures/custom_bytecode_tester.js +53 -0
- package/dest/public/fixtures/custom_bytecode_tests.d.ts +12 -0
- package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -0
- package/dest/public/fixtures/custom_bytecode_tests.js +174 -0
- package/dest/public/fixtures/index.d.ts +5 -2
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +4 -1
- package/dest/public/fixtures/minimal_public_tx.d.ts +4 -9
- package/dest/public/fixtures/minimal_public_tx.d.ts.map +1 -1
- package/dest/public/fixtures/minimal_public_tx.js +8 -32
- package/dest/public/fixtures/opcode_spammer.d.ts +123 -0
- package/dest/public/fixtures/opcode_spammer.d.ts.map +1 -0
- package/dest/public/fixtures/opcode_spammer.js +1681 -0
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +25 -5
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +63 -17
- 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 +7 -6
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts +46 -0
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts.map +1 -0
- package/dest/public/fuzzing/avm_fuzzer_simulator.js +139 -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 +100 -0
- package/dest/public/hinting_db_sources.d.ts +16 -4
- package/dest/public/hinting_db_sources.d.ts.map +1 -1
- package/dest/public/hinting_db_sources.js +74 -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 +24 -65
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +85 -132
- 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 +6 -2
- package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
- package/dest/public/public_processor/guarded_merkle_tree.js +8 -0
- package/dest/public/public_processor/public_processor.d.ts +11 -13
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +477 -70
- 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_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 +53 -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 +131 -0
- 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 +6 -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 +16 -8
- 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 +7 -8
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +9 -4
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +22 -10
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +22 -29
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +178 -127
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts +32 -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 +4 -3
- 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 +396 -20
- package/dest/public/side_effect_errors.d.ts +42 -2
- 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 +13 -7
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +36 -21
- package/dest/public/side_effect_trace_interface.d.ts +9 -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 -5
- package/dest/public/state_manager/nullifiers.d.ts.map +1 -1
- package/dest/public/state_manager/nullifiers.js +1 -6
- 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 +16 -13
- package/dest/public/state_manager/state_manager.d.ts.map +1 -1
- package/dest/public/state_manager/state_manager.js +64 -21
- 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 +24 -19
- 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/acvm_native.ts +18 -11
- package/src/private/circuit_recording/circuit_recorder.ts +17 -16
- package/src/private/circuit_recording/simulator_recorder_wrapper.ts +1 -1
- package/src/public/avm/avm_context.ts +1 -1
- package/src/public/avm/avm_contract_call_result.ts +1 -1
- package/src/public/avm/avm_execution_environment.ts +4 -3
- package/src/public/avm/avm_gas.ts +5 -5
- package/src/public/avm/avm_machine_state.ts +1 -1
- package/src/public/avm/avm_memory_types.ts +12 -3
- package/src/public/avm/avm_simulator.ts +24 -33
- package/src/public/avm/errors.ts +24 -27
- package/src/public/avm/fixtures/avm_simulation_tester.ts +14 -4
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +33 -1
- package/src/public/avm/fixtures/initializers.ts +7 -8
- package/src/public/avm/fixtures/utils.ts +3 -2
- package/src/public/avm/opcodes/accrued_substate.ts +5 -5
- package/src/public/avm/opcodes/addressing_mode.ts +5 -5
- package/src/public/avm/opcodes/arithmetic.ts +13 -1
- package/src/public/avm/opcodes/conversion.ts +4 -0
- package/src/public/avm/opcodes/ec_add.ts +6 -6
- package/src/public/avm/opcodes/environment_getters.ts +6 -8
- package/src/public/avm/opcodes/external_calls.ts +1 -1
- package/src/public/avm/opcodes/hashing.ts +10 -4
- package/src/public/avm/opcodes/instruction.ts +8 -6
- package/src/public/avm/opcodes/memory.ts +1 -1
- package/src/public/avm/opcodes/misc.ts +41 -7
- 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 +13 -1
- package/src/public/avm/test_utils.ts +7 -15
- package/src/public/contracts_db_checkpoint.ts +41 -0
- package/src/public/db_interfaces.ts +16 -1
- package/src/public/debug_fn_name.ts +35 -3
- package/src/public/executor_metrics.ts +2 -1
- 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 +38 -25
- package/src/public/fixtures/custom_bytecode_tester.ts +83 -0
- package/src/public/fixtures/custom_bytecode_tests.ts +219 -0
- package/src/public/fixtures/index.ts +8 -1
- package/src/public/fixtures/minimal_public_tx.ts +9 -42
- package/src/public/fixtures/opcode_spammer.ts +1638 -0
- package/src/public/fixtures/public_tx_simulation_tester.ts +90 -22
- 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 +5 -6
- package/src/public/fuzzing/avm_fuzzer_simulator.ts +240 -0
- package/src/public/fuzzing/avm_simulator_bin.ts +140 -0
- package/src/public/hinting_db_sources.ts +117 -10
- package/src/public/index.ts +8 -1
- package/src/public/public_db_sources.ts +112 -175
- package/src/public/public_errors.ts +14 -0
- package/src/public/public_processor/guarded_merkle_tree.ts +10 -1
- package/src/public/public_processor/public_processor.ts +112 -79
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +121 -0
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +200 -0
- 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 +5 -0
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +13 -14
- package/src/public/public_tx_simulator/public_tx_context.ts +20 -7
- package/src/public/public_tx_simulator/public_tx_simulator.ts +265 -179
- package/src/public/public_tx_simulator/public_tx_simulator_interface.ts +33 -0
- package/src/public/public_tx_simulator/telemetry_public_tx_simulator.ts +4 -13
- package/src/public/side_effect_errors.ts +91 -1
- package/src/public/side_effect_trace.ts +49 -24
- package/src/public/side_effect_trace_interface.ts +7 -1
- package/src/public/state_manager/nullifiers.ts +2 -8
- package/src/public/state_manager/public_storage.ts +1 -1
- package/src/public/state_manager/state_manager.ts +87 -39
- package/src/public/test_executor_metrics.ts +7 -5
- 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/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/bytecode_errors.ts +0 -6
- package/src/public/tx_contract_cache.ts +0 -69
|
@@ -34,4 +34,4 @@ export declare class UniqueClassIds {
|
|
|
34
34
|
*/
|
|
35
35
|
acceptAndMerge(incoming: UniqueClassIds): void;
|
|
36
36
|
}
|
|
37
|
-
//# sourceMappingURL=
|
|
37
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidW5pcXVlX2NsYXNzX2lkcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3B1YmxpYy91bmlxdWVfY2xhc3NfaWRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUlBOzs7R0FHRztBQUNILHFCQUFhLGNBQWM7SUFHYixPQUFPLENBQUMsUUFBUSxDQUFDLE1BQU0sQ0FBQztJQUZwQyxPQUFPLENBQUMsUUFBUSxDQUFDLFFBQVEsQ0FBMEI7SUFFbkQsWUFBNkIsTUFBTSxDQUFDLDRCQUFnQixFQUFJO0lBRXhEOztPQUVHO0lBQ0ksSUFBSSxtQkFFVjtJQUVEOzs7OztPQUtHO0lBQ0ksR0FBRyxDQUFDLE9BQU8sRUFBRSxNQUFNLEdBQUcsT0FBTyxDQVNuQztJQUVEOztPQUVHO0lBQ0ksSUFBSSxJQUFJLE1BQU0sQ0FFcEI7SUFFRDs7OztPQUlHO0lBQ0ksR0FBRyxDQUFDLE9BQU8sRUFBRSxNQUFNLFFBU3pCO0lBRUQ7Ozs7T0FJRztJQUNJLGNBQWMsQ0FBQyxRQUFRLEVBQUUsY0FBYyxRQWE3QztDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unique_class_ids.d.ts","sourceRoot":"","sources":["../../src/public/unique_class_ids.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,qBAAa,cAAc;IAGb,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IAFpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA0B;
|
|
1
|
+
{"version":3,"file":"unique_class_ids.d.ts","sourceRoot":"","sources":["../../src/public/unique_class_ids.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,qBAAa,cAAc;IAGb,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IAFpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA0B;IAEnD,YAA6B,MAAM,CAAC,4BAAgB,EAAI;IAExD;;OAEG;IACI,IAAI,mBAEV;IAED;;;;;OAKG;IACI,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CASnC;IAED;;OAEG;IACI,IAAI,IAAI,MAAM,CAEpB;IAED;;;;OAIG;IACI,GAAG,CAAC,OAAO,EAAE,MAAM,QASzB;IAED;;;;OAIG;IACI,cAAc,CAAC,QAAQ,EAAE,cAAc,QAa7C;CACF"}
|
package/dest/public/utils.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PublicCallRequestWithCalldata, type Tx, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
2
2
|
export declare function getCallRequestsWithCalldataByPhase(tx: Tx, phase: TxExecutionPhase): PublicCallRequestWithCalldata[];
|
|
3
|
-
//# sourceMappingURL=
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wdWJsaWMvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLDZCQUE2QixFQUFFLEtBQUssRUFBRSxFQUFFLGdCQUFnQixFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFNUYsd0JBQWdCLGtDQUFrQyxDQUFDLEVBQUUsRUFBRSxFQUFFLEVBQUUsS0FBSyxFQUFFLGdCQUFnQixHQUFHLDZCQUE2QixFQUFFLENBYW5IIn0=
|
package/dest/server.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ export { SimulatorRecorderWrapper } from './private/circuit_recording/simulator_
|
|
|
6
6
|
export { MemoryCircuitRecorder } from './private/circuit_recording/memory_circuit_recorder.js';
|
|
7
7
|
export { type CircuitSimulator, type DecodedError } from './private/circuit_simulator.js';
|
|
8
8
|
export * from './common/index.js';
|
|
9
|
-
//# sourceMappingURL=
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VydmVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvc2VydmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsbUJBQW1CLENBQUM7QUFDbEMsY0FBYyx5QkFBeUIsQ0FBQztBQUN4QyxPQUFPLEVBQUUsc0JBQXNCLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQUMzRSxPQUFPLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUMvRCxPQUFPLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSwyREFBMkQsQ0FBQztBQUNyRyxPQUFPLEVBQUUscUJBQXFCLEVBQUUsTUFBTSx3REFBd0QsQ0FBQztBQUMvRixPQUFPLEVBQUUsS0FBSyxnQkFBZ0IsRUFBRSxLQUFLLFlBQVksRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQzFGLGNBQWMsbUJBQW1CLENBQUMifQ==
|
package/dest/testing.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { FileCircuitRecorder } from './private/circuit_recording/file_circuit_recorder.js';
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdGluZy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3Rlc3RpbmcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLG1CQUFtQixFQUFFLE1BQU0sc0RBQXNELENBQUMifQ==
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/simulator",
|
|
3
|
-
"version": "4.0.0-nightly.
|
|
3
|
+
"version": "4.0.0-nightly.20260107",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": "./dest/server.js",
|
|
@@ -17,10 +17,11 @@
|
|
|
17
17
|
"tsconfig": "./tsconfig.json"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
|
-
"build": "yarn clean && tsc
|
|
21
|
-
"build:dev": "tsc
|
|
20
|
+
"build": "yarn clean && ../scripts/tsc.sh",
|
|
21
|
+
"build:dev": "../scripts/tsc.sh --watch",
|
|
22
22
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
23
|
-
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
23
|
+
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
|
|
24
|
+
"build:fuzzer": "yarn clean && ../scripts/tsc.sh"
|
|
24
25
|
},
|
|
25
26
|
"inherits": [
|
|
26
27
|
"../package.common.json"
|
|
@@ -63,35 +64,39 @@
|
|
|
63
64
|
]
|
|
64
65
|
},
|
|
65
66
|
"dependencies": {
|
|
66
|
-
"@aztec/constants": "4.0.0-nightly.
|
|
67
|
-
"@aztec/foundation": "4.0.0-nightly.
|
|
68
|
-
"@aztec/
|
|
69
|
-
"@aztec/noir-
|
|
70
|
-
"@aztec/noir-
|
|
71
|
-
"@aztec/noir-types": "4.0.0-nightly.
|
|
72
|
-
"@aztec/
|
|
73
|
-
"@aztec/
|
|
74
|
-
"@aztec/
|
|
75
|
-
"@aztec/
|
|
67
|
+
"@aztec/constants": "4.0.0-nightly.20260107",
|
|
68
|
+
"@aztec/foundation": "4.0.0-nightly.20260107",
|
|
69
|
+
"@aztec/native": "4.0.0-nightly.20260107",
|
|
70
|
+
"@aztec/noir-acvm_js": "4.0.0-nightly.20260107",
|
|
71
|
+
"@aztec/noir-noirc_abi": "4.0.0-nightly.20260107",
|
|
72
|
+
"@aztec/noir-protocol-circuits-types": "4.0.0-nightly.20260107",
|
|
73
|
+
"@aztec/noir-types": "4.0.0-nightly.20260107",
|
|
74
|
+
"@aztec/protocol-contracts": "4.0.0-nightly.20260107",
|
|
75
|
+
"@aztec/stdlib": "4.0.0-nightly.20260107",
|
|
76
|
+
"@aztec/telemetry-client": "4.0.0-nightly.20260107",
|
|
77
|
+
"@aztec/world-state": "4.0.0-nightly.20260107",
|
|
76
78
|
"lodash.clonedeep": "^4.5.0",
|
|
77
79
|
"lodash.merge": "^4.6.2",
|
|
78
80
|
"tslib": "^2.4.0"
|
|
79
81
|
},
|
|
80
82
|
"devDependencies": {
|
|
81
|
-
"@aztec/kv-store": "4.0.0-nightly.
|
|
82
|
-
"@aztec/merkle-tree": "4.0.0-nightly.
|
|
83
|
-
"@aztec/noir-contracts.js": "4.0.0-nightly.
|
|
84
|
-
"@aztec/noir-test-contracts.js": "4.0.0-nightly.
|
|
83
|
+
"@aztec/kv-store": "4.0.0-nightly.20260107",
|
|
84
|
+
"@aztec/merkle-tree": "4.0.0-nightly.20260107",
|
|
85
|
+
"@aztec/noir-contracts.js": "4.0.0-nightly.20260107",
|
|
86
|
+
"@aztec/noir-test-contracts.js": "4.0.0-nightly.20260107",
|
|
85
87
|
"@jest/globals": "^30.0.0",
|
|
86
88
|
"@types/jest": "^30.0.0",
|
|
87
89
|
"@types/lodash.clonedeep": "^4.5.7",
|
|
88
90
|
"@types/lodash.merge": "^4.6.9",
|
|
89
91
|
"@types/node": "^22.15.17",
|
|
92
|
+
"@typescript/native-preview": "7.0.0-dev.20251126.1",
|
|
93
|
+
"istanbul-lib-hook": "^3.0.0",
|
|
94
|
+
"istanbul-lib-instrument": "^6.0.3",
|
|
90
95
|
"jest": "^30.0.0",
|
|
91
96
|
"jest-mock-extended": "^4.0.0",
|
|
92
97
|
"ts-node": "^10.9.1",
|
|
93
98
|
"typescript": "^5.3.3",
|
|
94
|
-
"viem": "2.
|
|
99
|
+
"viem": "npm:@aztec/viem@2.38.2"
|
|
95
100
|
},
|
|
96
101
|
"files": [
|
|
97
102
|
"dest",
|
package/src/common/errors.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
3
3
|
import type { RawAssertionPayload } from '@aztec/noir-acvm_js';
|
|
4
4
|
import { abiDecodeError } from '@aztec/noir-noirc_abi';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
1
2
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
|
|
5
5
|
import type { ACVMField } from './acvm_types.js';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { runInDirectory } from '@aztec/foundation/fs';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
4
|
-
import type { WitnessMap } from '@aztec/noir-acvm_js';
|
|
5
|
-
import type { ForeignCallHandler } from '@aztec/noir-protocol-circuits-types/types';
|
|
4
|
+
import type { ForeignCallHandler, WitnessMap } from '@aztec/noir-acvm_js';
|
|
6
5
|
import type { FunctionArtifactWithContractName } from '@aztec/stdlib/abi';
|
|
7
6
|
import type { NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
|
|
8
7
|
|
|
@@ -104,21 +103,26 @@ export async function executeNativeCircuit(
|
|
|
104
103
|
logger.debug(`Calling ACVM with ${args.join(' ')}`);
|
|
105
104
|
|
|
106
105
|
const processPromise = new Promise<string>((resolve, reject) => {
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
const outChunks: Buffer[] = [];
|
|
107
|
+
const errChunks: Buffer[] = [];
|
|
108
|
+
let outLen = 0;
|
|
109
|
+
let errLen = 0;
|
|
109
110
|
const acvm = proc.spawn(pathToAcvm, args);
|
|
110
|
-
acvm.stdout.on('data', data => {
|
|
111
|
-
|
|
111
|
+
acvm.stdout.on('data', (data: Buffer) => {
|
|
112
|
+
outChunks.push(data);
|
|
113
|
+
outLen += data.length;
|
|
112
114
|
});
|
|
113
|
-
acvm.stderr.on('data', data => {
|
|
114
|
-
|
|
115
|
+
acvm.stderr.on('data', (data: Buffer) => {
|
|
116
|
+
errChunks.push(data);
|
|
117
|
+
errLen += data.length;
|
|
115
118
|
});
|
|
116
119
|
acvm.on('close', code => {
|
|
117
120
|
if (code === 0) {
|
|
118
|
-
resolve(
|
|
121
|
+
resolve(Buffer.concat(outChunks, outLen).toString('utf-8'));
|
|
119
122
|
} else {
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
const stderr = Buffer.concat(errChunks, errLen);
|
|
124
|
+
logger.error(`From ACVM: ${stderr.toString('utf-8')}`);
|
|
125
|
+
reject(stderr.toString('utf-8'));
|
|
122
126
|
}
|
|
123
127
|
});
|
|
124
128
|
});
|
|
@@ -130,6 +134,9 @@ export async function executeNativeCircuit(
|
|
|
130
134
|
const outputWitnessFileName = `${workingDirectory}/output-witness.gz`;
|
|
131
135
|
await fs.copyFile(outputWitnessFileName, outputFilename);
|
|
132
136
|
}
|
|
137
|
+
// TODO: We shouldn't be parsing the witness from stdout, it's not very performant, and we end up with two ways of fetching the witness.
|
|
138
|
+
// We probably should implement the WitnessStack type, run the ACVM with msgpack serialization mode (env variable), and ungzip and parse the witness from
|
|
139
|
+
// the outputted gz witness file.
|
|
133
140
|
const witness = parseIntoWitnessMap(output);
|
|
134
141
|
return { status: ACVM_RESULT.SUCCESS, witness, duration };
|
|
135
142
|
} catch (error) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sha512 } from '@aztec/foundation/crypto';
|
|
1
|
+
import { sha512 } from '@aztec/foundation/crypto/sha512';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
4
4
|
import type { ForeignCallHandler, ForeignCallInput, ForeignCallOutput } from '@aztec/noir-acvm_js';
|
|
@@ -108,16 +108,16 @@ export class CircuitRecorder {
|
|
|
108
108
|
* contracts as protocol circuits artifacts always contain a single entrypoint function called 'main'.
|
|
109
109
|
*/
|
|
110
110
|
start(input: ACVMWitness, circuitBytecode: Buffer, circuitName: string, functionName: string): Promise<void> {
|
|
111
|
-
const parentRef = this.recording;
|
|
112
111
|
if (this.newCircuit) {
|
|
112
|
+
const parentRef = this.recording;
|
|
113
113
|
this.recording = new CircuitRecording(
|
|
114
114
|
circuitName,
|
|
115
115
|
functionName,
|
|
116
116
|
sha512(circuitBytecode).toString('hex'),
|
|
117
117
|
Object.fromEntries(input),
|
|
118
118
|
);
|
|
119
|
+
this.recording.setParent(parentRef);
|
|
119
120
|
}
|
|
120
|
-
this.recording!.setParent(parentRef);
|
|
121
121
|
|
|
122
122
|
return Promise.resolve();
|
|
123
123
|
}
|
|
@@ -173,22 +173,22 @@ export class CircuitRecorder {
|
|
|
173
173
|
if (result instanceof Promise) {
|
|
174
174
|
return result.then(async r => {
|
|
175
175
|
// Once we leave the nested circuit, we decrease the stack depth and set newCircuit to false
|
|
176
|
-
//
|
|
176
|
+
// so that the parent circuit continues with its existing recording
|
|
177
|
+
// Note: recording restoration is handled by finish()
|
|
177
178
|
if (isExternalCall) {
|
|
178
179
|
this.stackDepth--;
|
|
179
180
|
this.newCircuit = false;
|
|
180
|
-
this.recording = this.recording!.parent;
|
|
181
181
|
}
|
|
182
182
|
await this.recordCall(name, args, r, timer.ms(), this.stackDepth);
|
|
183
183
|
return r;
|
|
184
184
|
}) as ReturnType<typeof fn>;
|
|
185
185
|
}
|
|
186
186
|
// Once we leave the nested circuit, we decrease the stack depth and set newCircuit to false
|
|
187
|
-
//
|
|
187
|
+
// so that the parent circuit continues with its existing recording
|
|
188
|
+
// Note: recording restoration is handled by finish()
|
|
188
189
|
if (isExternalCall) {
|
|
189
190
|
this.stackDepth--;
|
|
190
191
|
this.newCircuit = false;
|
|
191
|
-
this.recording = this.recording!.parent;
|
|
192
192
|
}
|
|
193
193
|
void this.recordCall(name, args, result, timer.ms(), this.stackDepth);
|
|
194
194
|
return result;
|
|
@@ -239,6 +239,12 @@ export class CircuitRecorder {
|
|
|
239
239
|
if (!result!.parent) {
|
|
240
240
|
this.newCircuit = true;
|
|
241
241
|
this.recording = undefined;
|
|
242
|
+
} else {
|
|
243
|
+
// For nested circuits (utility calls, nested contract calls), restore to parent recording
|
|
244
|
+
// Note: we don't set newCircuit=false here because:
|
|
245
|
+
// - For privateCallPrivateFunction, the callback wrapper will set it to false
|
|
246
|
+
// - For utility calls, we want newCircuit to remain true so the next circuit creates its own recording
|
|
247
|
+
this.recording = result!.parent;
|
|
242
248
|
}
|
|
243
249
|
return Promise.resolve(result!);
|
|
244
250
|
}
|
|
@@ -247,14 +253,9 @@ export class CircuitRecorder {
|
|
|
247
253
|
* Finalizes the recording by resetting the state and returning the recording object with an attached error.
|
|
248
254
|
* @param error - The error that occurred during circuit execution
|
|
249
255
|
*/
|
|
250
|
-
finishWithError(error: unknown): Promise<CircuitRecording> {
|
|
251
|
-
const result = this.
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
this.newCircuit = true;
|
|
255
|
-
this.recording = undefined;
|
|
256
|
-
}
|
|
257
|
-
result!.error = JSON.stringify(error);
|
|
258
|
-
return Promise.resolve(result!);
|
|
256
|
+
async finishWithError(error: unknown): Promise<CircuitRecording> {
|
|
257
|
+
const result = await this.finish();
|
|
258
|
+
result.error = JSON.stringify(error);
|
|
259
|
+
return result;
|
|
259
260
|
}
|
|
260
261
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ForeignCallHandler } from '@aztec/noir-
|
|
1
|
+
import type { ForeignCallHandler } from '@aztec/noir-acvm_js';
|
|
2
2
|
import type { FunctionArtifactWithContractName } from '@aztec/stdlib/abi';
|
|
3
3
|
import type { NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
|
|
4
4
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
2
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
4
|
import type { GlobalVariables } from '@aztec/stdlib/tx';
|
|
4
5
|
|
|
@@ -15,7 +16,7 @@ export class AvmExecutionEnvironment {
|
|
|
15
16
|
public readonly globals: GlobalVariables,
|
|
16
17
|
public readonly isStaticCall: boolean,
|
|
17
18
|
public readonly calldata: Fr[],
|
|
18
|
-
public readonly
|
|
19
|
+
public readonly config: PublicSimulatorConfig,
|
|
19
20
|
) {}
|
|
20
21
|
|
|
21
22
|
private deriveEnvironmentForNestedCallInternal(
|
|
@@ -31,7 +32,7 @@ export class AvmExecutionEnvironment {
|
|
|
31
32
|
this.globals,
|
|
32
33
|
isStaticCall,
|
|
33
34
|
calldata,
|
|
34
|
-
|
|
35
|
+
this.config,
|
|
35
36
|
);
|
|
36
37
|
}
|
|
37
38
|
|
|
@@ -26,9 +26,9 @@ export function makeGas(gasCost: Partial<Gas>) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/** Sums together multiple instances of Gas. */
|
|
29
|
-
export function sumGas(...gases: Partial<Gas>[]) {
|
|
30
|
-
return gases.reduce(
|
|
31
|
-
(acc
|
|
29
|
+
export function sumGas(...gases: Partial<Gas>[]): Gas {
|
|
30
|
+
return gases.reduce<Gas>(
|
|
31
|
+
(acc, gas) => ({
|
|
32
32
|
l2Gas: acc.l2Gas + (gas.l2Gas ?? 0),
|
|
33
33
|
daGas: acc.daGas + (gas.daGas ?? 0),
|
|
34
34
|
}),
|
|
@@ -110,7 +110,7 @@ const BASE_GAS_COSTS: Record<Opcode, Gas> = {
|
|
|
110
110
|
[Opcode.NULLIFIEREXISTS]: makeCost(c.AVM_NULLIFIEREXISTS_BASE_L2_GAS, 0),
|
|
111
111
|
[Opcode.EMITNULLIFIER]: makeCost(c.AVM_EMITNULLIFIER_BASE_L2_GAS, c.AVM_EMITNULLIFIER_BASE_DA_GAS),
|
|
112
112
|
[Opcode.L1TOL2MSGEXISTS]: makeCost(c.AVM_L1TOL2MSGEXISTS_BASE_L2_GAS, 0),
|
|
113
|
-
[Opcode.EMITUNENCRYPTEDLOG]: makeCost(c.AVM_EMITUNENCRYPTEDLOG_BASE_L2_GAS,
|
|
113
|
+
[Opcode.EMITUNENCRYPTEDLOG]: makeCost(c.AVM_EMITUNENCRYPTEDLOG_BASE_L2_GAS, c.AVM_EMITUNENCRYPTEDLOG_BASE_DA_GAS),
|
|
114
114
|
[Opcode.SENDL2TOL1MSG]: makeCost(c.AVM_SENDL2TOL1MSG_BASE_L2_GAS, c.AVM_SENDL2TOL1MSG_BASE_DA_GAS),
|
|
115
115
|
[Opcode.GETCONTRACTINSTANCE]: makeCost(c.AVM_GETCONTRACTINSTANCE_BASE_L2_GAS, 0),
|
|
116
116
|
[Opcode.CALL]: makeCost(c.AVM_CALL_BASE_L2_GAS, 0),
|
|
@@ -130,7 +130,7 @@ const DYNAMIC_GAS_COSTS = new Map<Opcode, Gas>([
|
|
|
130
130
|
[Opcode.CALLDATACOPY, makeCost(c.AVM_CALLDATACOPY_DYN_L2_GAS, 0)],
|
|
131
131
|
[Opcode.RETURNDATACOPY, makeCost(c.AVM_RETURNDATACOPY_DYN_L2_GAS, 0)],
|
|
132
132
|
// TODO: Call and static call based on bytecode length
|
|
133
|
-
[Opcode.EMITUNENCRYPTEDLOG, makeCost(
|
|
133
|
+
[Opcode.EMITUNENCRYPTEDLOG, makeCost(c.AVM_EMITUNENCRYPTEDLOG_DYN_L2_GAS, c.AVM_EMITUNENCRYPTEDLOG_DYN_DA_GAS)],
|
|
134
134
|
[Opcode.TORADIXBE, makeCost(c.AVM_TORADIXBE_DYN_L2_GAS, 0)],
|
|
135
135
|
[Opcode.AND_8, makeCost(c.AVM_BITWISE_DYN_L2_GAS, 0)],
|
|
136
136
|
[Opcode.AND_16, makeCost(c.AVM_BITWISE_DYN_L2_GAS, 0)],
|
|
@@ -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';
|
|
@@ -74,6 +74,7 @@ export abstract class IntegralValue extends MemoryValue {
|
|
|
74
74
|
**/
|
|
75
75
|
function UnsignedIntegerClassFactory(bits: number) {
|
|
76
76
|
return class NewUintClass extends IntegralValue {
|
|
77
|
+
static readonly bits: number = bits;
|
|
77
78
|
static readonly mod: bigint = 1n << BigInt(bits);
|
|
78
79
|
static readonly bitmask: bigint = this.mod - 1n;
|
|
79
80
|
public readonly n: bigint; // Cannot be private due to TS limitations.
|
|
@@ -108,12 +109,20 @@ function UnsignedIntegerClassFactory(bits: number) {
|
|
|
108
109
|
|
|
109
110
|
// No sign extension.
|
|
110
111
|
public shr(rhs: NewUintClass): NewUintClass {
|
|
111
|
-
// Note that this.n is
|
|
112
|
+
// Note that this.n is >= 0 by class invariant.
|
|
112
113
|
return this.build(this.n >> rhs.n);
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
public shl(rhs: NewUintClass): NewUintClass {
|
|
116
|
-
|
|
117
|
+
const shiftAmount = rhs.n;
|
|
118
|
+
const bitSize = BigInt(NewUintClass.bits);
|
|
119
|
+
|
|
120
|
+
// Shifting by more than the bit size always results in 0
|
|
121
|
+
if (shiftAmount >= bitSize) {
|
|
122
|
+
return this.build(0n);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return this.build((this.n << shiftAmount) & NewUintClass.bitmask);
|
|
117
126
|
}
|
|
118
127
|
|
|
119
128
|
public and(rhs: NewUintClass): NewUintClass {
|
|
@@ -1,12 +1,13 @@
|
|
|
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
|
|
|
7
8
|
import { strict as assert } from 'assert';
|
|
8
9
|
|
|
9
|
-
import {
|
|
10
|
+
import { CheckedPublicExecutionError } from '../public_errors.js';
|
|
10
11
|
import type { PublicPersistableStateManager } from '../state_manager/state_manager.js';
|
|
11
12
|
import { AvmContext } from './avm_context.js';
|
|
12
13
|
import { AvmContractCallResult } from './avm_contract_call_result.js';
|
|
@@ -14,7 +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';
|
|
17
|
-
import {
|
|
18
|
+
import { AvmRevertReason, InvalidProgramCounterError } from './errors.js';
|
|
18
19
|
import type { Instruction } from './opcodes/instruction.js';
|
|
19
20
|
import { revertReasonFromExceptionalHalt, revertReasonFromExplicitRevert } from './revert_reason.js';
|
|
20
21
|
import {
|
|
@@ -75,7 +76,7 @@ export class AvmSimulator implements AvmSimulatorInterface {
|
|
|
75
76
|
isStaticCall: boolean,
|
|
76
77
|
calldata: Fr[],
|
|
77
78
|
allocatedGas: Gas,
|
|
78
|
-
|
|
79
|
+
config: PublicSimulatorConfig,
|
|
79
80
|
) {
|
|
80
81
|
const avmExecutionEnv = new AvmExecutionEnvironment(
|
|
81
82
|
address,
|
|
@@ -85,7 +86,7 @@ export class AvmSimulator implements AvmSimulatorInterface {
|
|
|
85
86
|
globals,
|
|
86
87
|
isStaticCall,
|
|
87
88
|
calldata,
|
|
88
|
-
|
|
89
|
+
config,
|
|
89
90
|
);
|
|
90
91
|
|
|
91
92
|
const avmMachineState = new AvmMachineState(allocatedGas);
|
|
@@ -97,22 +98,13 @@ export class AvmSimulator implements AvmSimulatorInterface {
|
|
|
97
98
|
* Fetch the bytecode and execute it in the current context.
|
|
98
99
|
*/
|
|
99
100
|
public async execute(): Promise<AvmContractCallResult> {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
} catch (err: any) {
|
|
104
|
-
if (!(err instanceof AvmExecutionError || err instanceof SideEffectLimitReachedError)) {
|
|
105
|
-
this.log.error(`Unknown error thrown by AVM during bytecode retrieval: ${err}`);
|
|
106
|
-
throw err;
|
|
107
|
-
}
|
|
108
|
-
return await this.handleFailureToRetrieveBytecode(
|
|
109
|
-
`Bytecode retrieval for contract '${this.context.environment.address}' failed with ${err.message}. Reverting...`,
|
|
110
|
-
);
|
|
111
|
-
}
|
|
101
|
+
const bytecode = await this.context.persistableState.getBytecode(this.context.environment.address);
|
|
102
|
+
// getBytecode returns undefined if bytecode is not found or if the limit of contract calls to unique class IDs is reached.
|
|
103
|
+
// If it throws an error that reaches this point, it is a bug.
|
|
112
104
|
|
|
113
105
|
if (!bytecode) {
|
|
114
106
|
return await this.handleFailureToRetrieveBytecode(
|
|
115
|
-
`No bytecode found
|
|
107
|
+
`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...`,
|
|
116
108
|
);
|
|
117
109
|
}
|
|
118
110
|
|
|
@@ -135,6 +127,7 @@ export class AvmSimulator implements AvmSimulatorInterface {
|
|
|
135
127
|
assert(bytecode.length > 0, "AVM simulator can't execute empty bytecode");
|
|
136
128
|
|
|
137
129
|
this.bytecode = bytecode;
|
|
130
|
+
let instructionName = 'NONE'; // This is used for logging purposes
|
|
138
131
|
|
|
139
132
|
const { machineState } = this.context;
|
|
140
133
|
const callStartGas = machineState.gasLeft; // Save gas before executing instruction (for profiling)
|
|
@@ -163,6 +156,7 @@ export class AvmSimulator implements AvmSimulatorInterface {
|
|
|
163
156
|
}
|
|
164
157
|
machineState.nextPc = machineState.pc + bytesRead;
|
|
165
158
|
|
|
159
|
+
instructionName = instruction.constructor.name;
|
|
166
160
|
// Execute the instruction.
|
|
167
161
|
// Normal returns and reverts will return normally here.
|
|
168
162
|
// "Exceptional halts" will throw.
|
|
@@ -183,7 +177,7 @@ export class AvmSimulator implements AvmSimulatorInterface {
|
|
|
183
177
|
|
|
184
178
|
if (machineState.pc >= bytecode.length) {
|
|
185
179
|
this.log.warn('Passed end of program');
|
|
186
|
-
throw new InvalidProgramCounterError(machineState.pc, /*max=*/ bytecode.length);
|
|
180
|
+
throw new InvalidProgramCounterError(machineState.pc, /*max=*/ bytecode.length - 1);
|
|
187
181
|
}
|
|
188
182
|
}
|
|
189
183
|
|
|
@@ -211,18 +205,12 @@ export class AvmSimulator implements AvmSimulatorInterface {
|
|
|
211
205
|
// Return results for processing by calling context
|
|
212
206
|
return results;
|
|
213
207
|
} catch (err: any) {
|
|
214
|
-
this.log.
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
if (
|
|
219
|
-
|
|
220
|
-
err.constructor.name == 'OutOfGasError' ||
|
|
221
|
-
err instanceof AvmExecutionError ||
|
|
222
|
-
err instanceof SideEffectLimitReachedError
|
|
223
|
-
)
|
|
224
|
-
) {
|
|
225
|
-
this.log.error(`Unknown error thrown by AVM: ${err}`);
|
|
208
|
+
this.log.info(
|
|
209
|
+
`Exceptional halt (revert by something other than REVERT opcode) for instruction
|
|
210
|
+
${instructionName} at pc ${machineState.pc} and instruction counter ${machineState.instrCounter}`,
|
|
211
|
+
);
|
|
212
|
+
if (!(err instanceof CheckedPublicExecutionError)) {
|
|
213
|
+
this.log.error(`Unchecked/unknown error thrown by AVM. This is a bug. Error: ${err}`);
|
|
226
214
|
throw err;
|
|
227
215
|
}
|
|
228
216
|
|
|
@@ -247,12 +235,15 @@ export class AvmSimulator implements AvmSimulatorInterface {
|
|
|
247
235
|
|
|
248
236
|
private async handleFailureToRetrieveBytecode(message: string): Promise<AvmContractCallResult> {
|
|
249
237
|
// revert, consuming all gas
|
|
250
|
-
const
|
|
238
|
+
const { functionSelector, functionName } = await this.context.persistableState.getPublicFunctionSelectorAndName(
|
|
239
|
+
this.context.environment,
|
|
240
|
+
);
|
|
251
241
|
const revertReason = new AvmRevertReason(
|
|
252
242
|
message,
|
|
253
243
|
/*failingFunction=*/ {
|
|
254
244
|
contractAddress: this.context.environment.address,
|
|
255
|
-
|
|
245
|
+
functionSelector,
|
|
246
|
+
functionName,
|
|
256
247
|
},
|
|
257
248
|
/*noirCallStack=*/ [],
|
|
258
249
|
);
|
package/src/public/avm/errors.ts
CHANGED
|
@@ -1,26 +1,19 @@
|
|
|
1
|
-
import type { Point } from '@aztec/foundation/
|
|
2
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
1
|
+
import type { Point } from '@aztec/foundation/curves/grumpkin';
|
|
3
2
|
import type { FailingFunction, NoirCallStack } from '@aztec/stdlib/errors';
|
|
4
3
|
|
|
5
4
|
import { ExecutionError } from '../../common/errors.js';
|
|
5
|
+
import { CheckedPublicExecutionError } from '../public_errors.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Avm-specific errors should derive from this
|
|
9
9
|
*/
|
|
10
|
-
export abstract class AvmExecutionError extends
|
|
10
|
+
export abstract class AvmExecutionError extends CheckedPublicExecutionError {
|
|
11
11
|
constructor(message: string) {
|
|
12
12
|
super(message);
|
|
13
13
|
this.name = 'AvmExecutionError';
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export class NoBytecodeForContractError extends AvmExecutionError {
|
|
18
|
-
constructor(contractAddress: AztecAddress) {
|
|
19
|
-
super(`No bytecode found at: ${contractAddress}`);
|
|
20
|
-
this.name = 'NoBytecodeFoundInterpreterError';
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
17
|
export class ArithmeticError extends AvmExecutionError {
|
|
25
18
|
constructor(message: string) {
|
|
26
19
|
super(message);
|
|
@@ -65,7 +58,7 @@ export class AvmParsingError extends AvmExecutionError {
|
|
|
65
58
|
*/
|
|
66
59
|
export class InvalidTagValueError extends AvmExecutionError {
|
|
67
60
|
constructor(tagValue: number) {
|
|
68
|
-
super(`Tag value ${tagValue} is invalid.`);
|
|
61
|
+
super(`Tag check failed: Tag value ${tagValue} is invalid.`);
|
|
69
62
|
this.name = 'InvalidTagValueError';
|
|
70
63
|
}
|
|
71
64
|
}
|
|
@@ -84,6 +77,12 @@ export class InstructionExecutionError extends AvmExecutionError {
|
|
|
84
77
|
* Error thrown on failed AVM memory tag check.
|
|
85
78
|
*/
|
|
86
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
|
+
}
|
|
87
86
|
public static forOffset(offset: number, gotTag: string, expectedTag: string): TagCheckError {
|
|
88
87
|
return new TagCheckError(`Tag mismatch at offset ${offset}, got ${gotTag}, expected ${expectedTag}`);
|
|
89
88
|
}
|
|
@@ -104,7 +103,7 @@ export class TagCheckError extends AvmExecutionError {
|
|
|
104
103
|
*/
|
|
105
104
|
export class RelativeAddressOutOfRangeError extends AvmExecutionError {
|
|
106
105
|
constructor(baseAddr: number, relOffset: number) {
|
|
107
|
-
super(`
|
|
106
|
+
super(`Relative address out of range. Base address ${baseAddr}, relative offset ${relOffset}`);
|
|
108
107
|
this.name = 'RelativeAddressOutOfRangeError';
|
|
109
108
|
}
|
|
110
109
|
}
|
|
@@ -129,22 +128,12 @@ export class OutOfGasError extends AvmExecutionError {
|
|
|
129
128
|
}
|
|
130
129
|
|
|
131
130
|
/**
|
|
132
|
-
* Error is thrown when the supplied points
|
|
133
|
-
*/
|
|
134
|
-
export class MSMPointsLengthError extends AvmExecutionError {
|
|
135
|
-
constructor(pointsReadLength: number) {
|
|
136
|
-
super(`Points vector length should be a multiple of 3, was ${pointsReadLength}`);
|
|
137
|
-
this.name = 'MSMPointsLengthError';
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Error is thrown when one of the supplied points does not lie on the Grumpkin curve. Specific for MSM opcode.
|
|
131
|
+
* Error is thrown when one of the supplied points does not lie on the Grumpkin curve. Specific for ECADD opcode.
|
|
143
132
|
*/
|
|
144
|
-
export class
|
|
145
|
-
constructor(point: Point) {
|
|
146
|
-
super(`
|
|
147
|
-
this.name = '
|
|
133
|
+
export class EcAddPointNotOnCurveError extends AvmExecutionError {
|
|
134
|
+
constructor(pointIndex: number, point: Point) {
|
|
135
|
+
super(`EcAdd point${pointIndex} (${point.toString()}) is not on the curve.`);
|
|
136
|
+
this.name = 'EcAddPointNotOnCurveError';
|
|
148
137
|
}
|
|
149
138
|
}
|
|
150
139
|
|
|
@@ -178,3 +167,11 @@ export class AvmRevertReason extends ExecutionError {
|
|
|
178
167
|
super(message, failingFunction, noirCallStack, options);
|
|
179
168
|
}
|
|
180
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
|
+
}
|