@aztec/simulator 0.0.1-fake-ceab37513c → 0.0.6-commit.a2d1860fe9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- 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 +4 -2
- package/dest/private/acvm/acvm.d.ts.map +1 -1
- package/dest/private/acvm/acvm.js +4 -3
- 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 +6 -5
- package/dest/private/acvm_native.d.ts.map +1 -1
- package/dest/private/acvm_native.js +23 -19
- package/dest/private/acvm_wasm.d.ts +4 -3
- package/dest/private/acvm_wasm.d.ts.map +1 -1
- package/dest/private/acvm_wasm.js +4 -4
- 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 +4 -3
- package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/circuit_recorder.js +21 -18
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts +3 -2
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/file_circuit_recorder.js +2 -2
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +7 -2
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/memory_circuit_recorder.js +4 -4
- 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 +3 -3
- package/dest/private/factory.d.ts.map +1 -1
- package/dest/private/factory.js +7 -4
- 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 -7
- 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 +3 -3
- 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 +24 -29
- 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 +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/account_proof_fetcher.d.ts +2 -0
- package/dest/public/avm/fixtures/account_proof_fetcher.d.ts.map +1 -0
- package/dest/public/avm/fixtures/account_proof_fetcher.js +152 -0
- 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 +17 -8
- 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 +7 -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 +18 -19
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/public/avm/opcodes/accrued_substate.js +47 -48
- 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 +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 +7 -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 +20 -11
- 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 +11 -13
- 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 -23
- 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.js +5 -6
- 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 +4 -3
- package/dest/public/avm/opcodes/misc.d.ts.map +1 -1
- package/dest/public/avm/opcodes/misc.js +30 -10
- 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 +12 -9
- package/dest/public/avm/serialization/instruction_serialization.d.ts +10 -2
- package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/instruction_serialization.js +12 -2
- 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 +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 +13 -34
- 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 +4 -4
- 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 +63 -194
- 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 +10 -34
- 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 +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 +11 -10
- 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 +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 +27 -67
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +89 -136
- 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 +16 -15
- 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 +2 -2
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor_metrics.js +28 -45
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +19 -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 +132 -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 +23 -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 +14 -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 +11 -5
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +26 -14
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +26 -31
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +186 -130
- 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 +15 -8
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +38 -23
- 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 +22 -13
- package/dest/public/state_manager/state_manager.d.ts.map +1 -1
- package/dest/public/state_manager/state_manager.js +75 -25
- package/dest/public/test_executor_metrics.d.ts +6 -4
- package/dest/public/test_executor_metrics.d.ts.map +1 -1
- package/dest/public/test_executor_metrics.js +7 -6
- 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/acvm.ts +4 -3
- package/src/private/acvm/deserialize.ts +1 -1
- package/src/private/acvm/serialize.ts +1 -1
- package/src/private/acvm_native.ts +29 -16
- package/src/private/acvm_wasm.ts +7 -3
- package/src/private/circuit_recording/circuit_recorder.ts +22 -19
- package/src/private/circuit_recording/file_circuit_recorder.ts +7 -2
- package/src/private/circuit_recording/memory_circuit_recorder.ts +6 -4
- package/src/private/circuit_recording/simulator_recorder_wrapper.ts +1 -1
- package/src/private/factory.ts +7 -4
- 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 -7
- package/src/public/avm/avm_gas.ts +5 -5
- 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 +32 -38
- package/src/public/avm/calldata.ts +100 -0
- package/src/public/avm/errors.ts +24 -27
- package/src/public/avm/fixtures/account_proof.json +553 -0
- package/src/public/avm/fixtures/account_proof_fetcher.ts +166 -0
- package/src/public/avm/fixtures/avm_simulation_tester.ts +22 -6
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +33 -1
- package/src/public/avm/fixtures/initializers.ts +9 -9
- package/src/public/avm/fixtures/utils.ts +3 -2
- package/src/public/avm/opcodes/accrued_substate.ts +35 -38
- package/src/public/avm/opcodes/addressing_mode.ts +5 -5
- 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 +7 -3
- package/src/public/avm/opcodes/ec_add.ts +18 -9
- package/src/public/avm/opcodes/environment_getters.ts +13 -15
- package/src/public/avm/opcodes/external_calls.ts +17 -16
- package/src/public/avm/opcodes/hashing.ts +16 -10
- package/src/public/avm/opcodes/instruction.ts +8 -6
- 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 +43 -9
- 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 +19 -8
- package/src/public/avm/serialization/instruction_serialization.ts +14 -2
- 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 +39 -5
- package/src/public/executor_metrics.ts +11 -34
- package/src/public/executor_metrics_interface.ts +2 -1
- package/src/public/fixtures/amm_test.ts +4 -4
- package/src/public/fixtures/bulk_test.ts +46 -28
- package/src/public/fixtures/custom_bytecode_tester.ts +83 -0
- package/src/public/fixtures/custom_bytecode_tests.ts +228 -0
- package/src/public/fixtures/index.ts +8 -1
- package/src/public/fixtures/minimal_public_tx.ts +11 -44
- package/src/public/fixtures/opcode_spammer.ts +1717 -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 +9 -10
- 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 +117 -10
- package/src/public/index.ts +8 -1
- package/src/public/public_db_sources.ts +126 -179
- 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 +123 -79
- package/src/public/public_processor/public_processor_metrics.ts +16 -44
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +124 -0
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +211 -0
- package/src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts +134 -0
- package/src/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.ts +239 -0
- package/src/public/public_tx_simulator/dumping_cpp_public_tx_simulator.ts +83 -0
- package/src/public/public_tx_simulator/factories.ts +43 -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 +33 -13
- package/src/public/public_tx_simulator/public_tx_simulator.ts +281 -184
- 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 +53 -25
- 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 +107 -50
- package/src/public/test_executor_metrics.ts +10 -8
- 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
|
@@ -1,37 +1,76 @@
|
|
|
1
1
|
import { AVM_MAX_PROCESSABLE_L2_GAS } from '@aztec/constants';
|
|
2
|
-
import
|
|
3
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { ProtocolContractAddress, ProtocolContractsList } from '@aztec/protocol-contracts';
|
|
5
5
|
import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
6
|
-
import {
|
|
7
|
-
AvmCircuitInputs,
|
|
8
|
-
AvmCircuitPublicInputs,
|
|
9
|
-
AvmExecutionHints,
|
|
10
|
-
type AvmProvingRequest,
|
|
11
|
-
AvmTxHint,
|
|
12
|
-
type RevertCode,
|
|
13
|
-
} from '@aztec/stdlib/avm';
|
|
6
|
+
import { AvmExecutionHints, AvmTxHint, PublicSimulatorConfig, PublicTxEffect, PublicTxResult } from '@aztec/stdlib/avm';
|
|
14
7
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
15
|
-
import
|
|
16
|
-
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
8
|
+
import { Gas } from '@aztec/stdlib/gas';
|
|
17
9
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
18
10
|
import {
|
|
19
11
|
type GlobalVariables,
|
|
20
12
|
NestedProcessReturnValues,
|
|
13
|
+
ProtocolContracts,
|
|
21
14
|
PublicCallRequestWithCalldata,
|
|
22
15
|
Tx,
|
|
23
16
|
TxExecutionPhase,
|
|
24
17
|
} from '@aztec/stdlib/tx';
|
|
25
18
|
|
|
19
|
+
import { strict as assert } from 'assert';
|
|
20
|
+
|
|
26
21
|
import type { AvmFinalizedCallResult } from '../avm/avm_contract_call_result.js';
|
|
22
|
+
import { CallDataArray } from '../avm/calldata.js';
|
|
27
23
|
import { AvmSimulator } from '../avm/index.js';
|
|
28
24
|
import { getPublicFunctionDebugName } from '../debug_fn_name.js';
|
|
29
25
|
import { HintingMerkleWriteOperations, HintingPublicContractsDB } from '../hinting_db_sources.js';
|
|
30
26
|
import { type PublicContractsDB, PublicTreesDB } from '../public_db_sources.js';
|
|
27
|
+
import {
|
|
28
|
+
L2ToL1MessageLimitReachedError,
|
|
29
|
+
NoteHashLimitReachedError,
|
|
30
|
+
NullifierCollisionError,
|
|
31
|
+
NullifierLimitReachedError,
|
|
32
|
+
} from '../side_effect_errors.js';
|
|
31
33
|
import type { PublicPersistableStateManager } from '../state_manager/state_manager.js';
|
|
32
34
|
import { PublicTxContext } from './public_tx_context.js';
|
|
35
|
+
import type { PublicTxSimulatorInterface } from './public_tx_simulator_interface.js';
|
|
36
|
+
|
|
37
|
+
// The errors below are only thrown here in the public tx simulator,
|
|
38
|
+
// and only during revertible phases (revertible insertions, app logic and teardown).
|
|
39
|
+
// These are strictly "checked" errors (not exported and never propagated).
|
|
40
|
+
// They are used internally for control flow to trigger rollbacks to the post-setup state.
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Error thrown when public tx simulation reverts in a known/checked way during revertible insertions.
|
|
44
|
+
*/
|
|
45
|
+
class TxSimRevertibleInsertionsRevert extends Error {
|
|
46
|
+
constructor() {
|
|
47
|
+
super('Public Tx Simulation reverted during Revertible Insertions');
|
|
48
|
+
this.name = 'TxSimRevertibleInsertionsRevert';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Error thrown when public tx simulation reverts during app logic.
|
|
54
|
+
*/
|
|
55
|
+
class TxSimAppLogicRevert extends Error {
|
|
56
|
+
constructor() {
|
|
57
|
+
super('Public Tx Simulation reverted during App Logic');
|
|
58
|
+
this.name = 'TxSimAppLogicRevert';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Error thrown when public tx simulation reverts during teardown.
|
|
64
|
+
*/
|
|
65
|
+
class TxSimTeardownRevert extends Error {
|
|
66
|
+
constructor() {
|
|
67
|
+
super('Public Tx Simulation reverted during Teardown');
|
|
68
|
+
this.name = 'TxSimTeardownRevert';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
33
71
|
|
|
34
|
-
|
|
72
|
+
/** Only used internally. */
|
|
73
|
+
type ProcessedPhase = {
|
|
35
74
|
phase: TxExecutionPhase;
|
|
36
75
|
durationMs?: number;
|
|
37
76
|
returnValues: NestedProcessReturnValues[];
|
|
@@ -39,28 +78,22 @@ export type ProcessedPhase = {
|
|
|
39
78
|
revertReason?: SimulationError;
|
|
40
79
|
};
|
|
41
80
|
|
|
42
|
-
export
|
|
43
|
-
avmProvingRequest: AvmProvingRequest;
|
|
44
|
-
/** Gas used during the execution of this tx */
|
|
45
|
-
gasUsed: GasUsed;
|
|
46
|
-
revertCode: RevertCode;
|
|
47
|
-
/** Revert reason, if any */
|
|
48
|
-
revertReason?: SimulationError;
|
|
49
|
-
processedPhases: ProcessedPhase[];
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export class PublicTxSimulator {
|
|
81
|
+
export class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
53
82
|
protected log: Logger;
|
|
83
|
+
protected readonly config: PublicSimulatorConfig;
|
|
84
|
+
protected readonly bindings?: LoggerBindings;
|
|
54
85
|
|
|
55
86
|
constructor(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
87
|
+
protected merkleTree: MerkleTreeWriteOperations,
|
|
88
|
+
protected contractsDB: PublicContractsDB,
|
|
89
|
+
protected globalVariables: GlobalVariables,
|
|
90
|
+
config?: Partial<PublicSimulatorConfig>,
|
|
91
|
+
protected protocolContracts: ProtocolContracts = ProtocolContractsList,
|
|
92
|
+
bindings?: LoggerBindings,
|
|
62
93
|
) {
|
|
63
|
-
this.
|
|
94
|
+
this.config = PublicSimulatorConfig.from(config ?? {});
|
|
95
|
+
this.bindings = bindings;
|
|
96
|
+
this.log = createLogger(`simulator:public_tx_simulator`, bindings);
|
|
64
97
|
}
|
|
65
98
|
|
|
66
99
|
/**
|
|
@@ -69,121 +102,144 @@ export class PublicTxSimulator {
|
|
|
69
102
|
* @returns The result of the transaction's public execution.
|
|
70
103
|
*/
|
|
71
104
|
public async simulate(tx: Tx): Promise<PublicTxResult> {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
105
|
+
const txHash = this.computeTxHash(tx);
|
|
106
|
+
this.log.debug(`Simulating ${tx.publicFunctionCalldata.length} public calls for tx ${txHash}`, { txHash });
|
|
107
|
+
|
|
108
|
+
// Create hinting DBs.
|
|
109
|
+
const hints = new AvmExecutionHints(
|
|
110
|
+
this.globalVariables,
|
|
111
|
+
AvmTxHint.fromTx(tx, this.globalVariables.gasFees),
|
|
112
|
+
this.protocolContracts,
|
|
113
|
+
);
|
|
114
|
+
const hintingMerkleTree = await HintingMerkleWriteOperations.create(this.merkleTree, hints);
|
|
115
|
+
const hintingTreesDB = new PublicTreesDB(hintingMerkleTree);
|
|
116
|
+
const hintingContractsDB = new HintingPublicContractsDB(this.contractsDB, hints);
|
|
117
|
+
|
|
118
|
+
const context = await PublicTxContext.create(
|
|
119
|
+
hintingTreesDB,
|
|
120
|
+
hintingContractsDB,
|
|
121
|
+
tx,
|
|
122
|
+
this.globalVariables,
|
|
123
|
+
this.protocolContracts,
|
|
124
|
+
this.config.proverId,
|
|
125
|
+
this.bindings,
|
|
126
|
+
);
|
|
89
127
|
|
|
90
|
-
|
|
128
|
+
// This will throw if there is a nullifier collision.
|
|
129
|
+
// In that case the transaction will be thrown out.
|
|
130
|
+
await this.insertNonRevertiblesFromPrivate(context);
|
|
131
|
+
|
|
132
|
+
const processedPhases: ProcessedPhase[] = [];
|
|
133
|
+
if (context.hasPhase(TxExecutionPhase.SETUP)) {
|
|
134
|
+
// This will throw if the setup phase reverts.
|
|
91
135
|
// In that case the transaction will be thrown out.
|
|
92
|
-
await this.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
// In that case the transaction will be thrown out.
|
|
98
|
-
const setupResult = await this.simulatePhase(TxExecutionPhase.SETUP, context);
|
|
99
|
-
if (setupResult.reverted) {
|
|
100
|
-
throw new Error(
|
|
101
|
-
`Setup phase reverted! The transaction will be thrown out. ${setupResult.revertReason?.message}`,
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
processedPhases.push(setupResult);
|
|
136
|
+
const setupResult = await this.simulatePhase(TxExecutionPhase.SETUP, context);
|
|
137
|
+
if (setupResult.reverted) {
|
|
138
|
+
throw new Error(
|
|
139
|
+
`[SETUP] UNRECOVERABLE ERROR! The transaction will be thrown out. ${setupResult.revertReason?.message}`,
|
|
140
|
+
);
|
|
105
141
|
}
|
|
142
|
+
processedPhases.push(setupResult);
|
|
143
|
+
}
|
|
106
144
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
145
|
+
// The checkpoint we should go back to if anything from now on reverts.
|
|
146
|
+
await context.state.fork();
|
|
147
|
+
hintingContractsDB.createCheckpoint();
|
|
148
|
+
|
|
149
|
+
try {
|
|
150
|
+
// This will throw if there is a nullifier collision or other insertion error (limit reached).
|
|
151
|
+
await this.insertRevertiblesFromPrivate(context);
|
|
152
|
+
|
|
153
|
+
// Only proceed with app logic if there was no revert during revertible insertion.
|
|
154
|
+
if (context.hasPhase(TxExecutionPhase.APP_LOGIC)) {
|
|
155
|
+
const appLogicResult = await this.simulatePhase(TxExecutionPhase.APP_LOGIC, context);
|
|
156
|
+
processedPhases.push(appLogicResult);
|
|
157
|
+
if (appLogicResult.reverted) {
|
|
158
|
+
throw new TxSimAppLogicRevert();
|
|
120
159
|
}
|
|
121
|
-
}
|
|
122
|
-
|
|
160
|
+
}
|
|
161
|
+
} catch (e: any) {
|
|
162
|
+
if (e instanceof TxSimRevertibleInsertionsRevert || e instanceof TxSimAppLogicRevert) {
|
|
123
163
|
// We revert to the post-setup state.
|
|
124
164
|
await context.state.discardForkedState();
|
|
165
|
+
hintingContractsDB.revertCheckpoint();
|
|
125
166
|
// But we also create a new fork so that the teardown phase can transparently
|
|
126
167
|
// commit or rollback at the end of teardown.
|
|
127
168
|
await context.state.fork();
|
|
169
|
+
hintingContractsDB.createCheckpoint();
|
|
170
|
+
} else {
|
|
171
|
+
// Unchecked/unknown error - re-throw as-is
|
|
172
|
+
throw e;
|
|
128
173
|
}
|
|
174
|
+
}
|
|
129
175
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
176
|
+
try {
|
|
177
|
+
if (context.hasPhase(TxExecutionPhase.TEARDOWN)) {
|
|
178
|
+
const teardownResult = await this.simulatePhase(TxExecutionPhase.TEARDOWN, context);
|
|
179
|
+
processedPhases.push(teardownResult);
|
|
180
|
+
if (teardownResult.reverted) {
|
|
181
|
+
throw new TxSimTeardownRevert();
|
|
137
182
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
183
|
+
}
|
|
184
|
+
// We commit the forked state and we are done.
|
|
185
|
+
await context.state.mergeForkedState();
|
|
186
|
+
hintingContractsDB.commitCheckpoint();
|
|
187
|
+
} catch (e: any) {
|
|
188
|
+
if (e instanceof TxSimTeardownRevert) {
|
|
189
|
+
// We revert to the post-setup state and we are done.
|
|
144
190
|
await context.state.discardForkedState();
|
|
191
|
+
hintingContractsDB.revertCheckpoint();
|
|
192
|
+
} else {
|
|
193
|
+
// Unchecked/unknown error - re-throw as-is
|
|
194
|
+
throw e;
|
|
145
195
|
}
|
|
196
|
+
}
|
|
146
197
|
|
|
147
|
-
|
|
198
|
+
context.halt();
|
|
148
199
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
this.contractsDB.commitContractsForTx(/*onlyNonRevertibles=*/ !revertCode.isOK());
|
|
167
|
-
|
|
168
|
-
return {
|
|
169
|
-
avmProvingRequest,
|
|
170
|
-
gasUsed: {
|
|
171
|
-
totalGas: context.getActualGasUsed(),
|
|
172
|
-
teardownGas: context.teardownGasUsed,
|
|
173
|
-
publicGas: context.getActualPublicGasUsed(),
|
|
174
|
-
billedGas: context.getTotalGasUsed(),
|
|
175
|
-
},
|
|
176
|
-
revertCode,
|
|
177
|
-
revertReason: context.revertReason,
|
|
178
|
-
processedPhases: processedPhases,
|
|
179
|
-
};
|
|
180
|
-
} finally {
|
|
181
|
-
// Make sure there are no new contracts in the tx-level cache.
|
|
182
|
-
// They should either be committed to block-level cache or cleared.
|
|
183
|
-
// FIXME(fcarreiro): this should conceptually use the hinted contracts db.
|
|
184
|
-
// However things should work as they are now because the hinted db would still pick up the new contracts.
|
|
185
|
-
this.contractsDB.clearContractsForTx();
|
|
200
|
+
// Such transactions should be filtered by GasTxValidator.
|
|
201
|
+
assert(
|
|
202
|
+
context.getActualGasUsed().l2Gas <= AVM_MAX_PROCESSABLE_L2_GAS,
|
|
203
|
+
`Transaction consumes ${context.getActualGasUsed().l2Gas} L2 gas, which exceeds the AVM maximum processable gas of ${AVM_MAX_PROCESSABLE_L2_GAS}`,
|
|
204
|
+
);
|
|
205
|
+
await this.payFee(context);
|
|
206
|
+
|
|
207
|
+
const publicInputs = await context.generateAvmCircuitPublicInputs();
|
|
208
|
+
const revertCode = context.getFinalRevertCode();
|
|
209
|
+
|
|
210
|
+
// We only return the app logic phase information, and only 1 per phase.
|
|
211
|
+
const appLogicReturnValues: NestedProcessReturnValues[] =
|
|
212
|
+
processedPhases.find(({ phase }) => phase === TxExecutionPhase.APP_LOGIC)?.returnValues ?? [];
|
|
213
|
+
|
|
214
|
+
// TODO(fcarreiro): This is a temporary backwards compatibility layer until we migrate to the C++ simulator.
|
|
215
|
+
if (context.revertReason !== undefined) {
|
|
216
|
+
(appLogicReturnValues as any).revertReason = context.revertReason;
|
|
186
217
|
}
|
|
218
|
+
|
|
219
|
+
// Create PublicTxEffect from PublicInputs.
|
|
220
|
+
const publicTxEffect = new PublicTxEffect(
|
|
221
|
+
publicInputs.transactionFee,
|
|
222
|
+
publicInputs.accumulatedData.noteHashes.filter(h => !h.isEmpty()),
|
|
223
|
+
publicInputs.accumulatedData.nullifiers.filter(n => !n.isEmpty()),
|
|
224
|
+
publicInputs.accumulatedData.l2ToL1Msgs.filter(m => !m.isEmpty()),
|
|
225
|
+
publicInputs.accumulatedData.publicLogs.toLogs(),
|
|
226
|
+
publicInputs.accumulatedData.publicDataWrites.filter(w => !w.isEmpty()),
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
return new PublicTxResult(
|
|
230
|
+
/*gasUsed=*/ {
|
|
231
|
+
totalGas: context.getActualGasUsed(),
|
|
232
|
+
teardownGas: context.teardownGasUsed,
|
|
233
|
+
publicGas: context.getActualPublicGasUsed(),
|
|
234
|
+
billedGas: context.getTotalGasUsed(),
|
|
235
|
+
},
|
|
236
|
+
/*revertCode=*/ revertCode,
|
|
237
|
+
/*publicTxEffect=*/ publicTxEffect,
|
|
238
|
+
/*callStackMetadata=*/ appLogicReturnValues,
|
|
239
|
+
/*logs=*/ context.state.getActiveStateManager().getLogs(),
|
|
240
|
+
/*hints=*/ hints,
|
|
241
|
+
/*publicInputs=*/ publicInputs,
|
|
242
|
+
);
|
|
187
243
|
}
|
|
188
244
|
|
|
189
245
|
protected computeTxHash(tx: Tx) {
|
|
@@ -216,7 +272,7 @@ export class PublicTxSimulator {
|
|
|
216
272
|
|
|
217
273
|
const enqueuedCallResult = await this.simulateEnqueuedCall(phase, context, callRequest);
|
|
218
274
|
|
|
219
|
-
returnValues.push(new NestedProcessReturnValues(enqueuedCallResult.output));
|
|
275
|
+
returnValues.push(new NestedProcessReturnValues(enqueuedCallResult.output.bestEffortReadAll()));
|
|
220
276
|
|
|
221
277
|
if (enqueuedCallResult.reverted) {
|
|
222
278
|
reverted = true;
|
|
@@ -246,7 +302,11 @@ export class PublicTxSimulator {
|
|
|
246
302
|
): Promise<AvmFinalizedCallResult> {
|
|
247
303
|
const stateManager = context.state.getActiveStateManager();
|
|
248
304
|
const contractAddress = callRequest.request.contractAddress;
|
|
249
|
-
const fnName = await getPublicFunctionDebugName(
|
|
305
|
+
const fnName = await getPublicFunctionDebugName(
|
|
306
|
+
this.contractsDB,
|
|
307
|
+
contractAddress,
|
|
308
|
+
new CallDataArray(callRequest.calldata),
|
|
309
|
+
);
|
|
250
310
|
|
|
251
311
|
const allocatedGas = context.getGasLeftAtPhase(phase);
|
|
252
312
|
|
|
@@ -265,7 +325,7 @@ export class PublicTxSimulator {
|
|
|
265
325
|
);
|
|
266
326
|
|
|
267
327
|
if (result.reverted) {
|
|
268
|
-
const culprit = `${contractAddress}:${
|
|
328
|
+
const culprit = `${contractAddress}:${fnName}`;
|
|
269
329
|
context.revert(phase, result.revertReason, culprit);
|
|
270
330
|
}
|
|
271
331
|
|
|
@@ -306,9 +366,9 @@ export class PublicTxSimulator {
|
|
|
306
366
|
transactionFee,
|
|
307
367
|
this.globalVariables,
|
|
308
368
|
request.isStaticCall,
|
|
309
|
-
calldata,
|
|
369
|
+
new CallDataArray(calldata),
|
|
310
370
|
allocatedGas,
|
|
311
|
-
this.
|
|
371
|
+
this.config,
|
|
312
372
|
);
|
|
313
373
|
const avmCallResult = await simulator.execute();
|
|
314
374
|
return avmCallResult.finalize();
|
|
@@ -317,7 +377,7 @@ export class PublicTxSimulator {
|
|
|
317
377
|
/**
|
|
318
378
|
* Insert the non-revertible accumulated data from private into the public state.
|
|
319
379
|
*/
|
|
320
|
-
protected async insertNonRevertiblesFromPrivate(context: PublicTxContext
|
|
380
|
+
protected async insertNonRevertiblesFromPrivate(context: PublicTxContext) {
|
|
321
381
|
const stateManager = context.state.getActiveStateManager();
|
|
322
382
|
|
|
323
383
|
for (const siloedNullifier of context.nonRevertibleAccumulatedDataFromPrivate.nullifiers.filter(
|
|
@@ -336,58 +396,107 @@ export class PublicTxSimulator {
|
|
|
336
396
|
}
|
|
337
397
|
}
|
|
338
398
|
|
|
339
|
-
// add new contracts to the contracts db so that their
|
|
340
|
-
//
|
|
341
|
-
//
|
|
342
|
-
//
|
|
343
|
-
|
|
399
|
+
// add new contracts to the contracts db so that their code may be found and called
|
|
400
|
+
// FIXME(fcarreiro): this should conceptually use the hinting contracts db.
|
|
401
|
+
// However, things work as expected because later calls to getters on the hintingContractsDB
|
|
402
|
+
// will pick up the new contracts and will generate the necessary hints.
|
|
403
|
+
// So, a consumer of the hints will always see the new contracts.
|
|
404
|
+
await this.contractsDB.addContracts(context.nonRevertibleContractDeploymentData);
|
|
344
405
|
}
|
|
345
406
|
|
|
346
407
|
/**
|
|
347
408
|
* Insert the revertible accumulated data from private into the public state.
|
|
348
|
-
*
|
|
409
|
+
* Throws TxSimRevertibleInsertionsRevert if there is some checked error during revertible insertions.
|
|
410
|
+
* This function checks for the following errors:
|
|
411
|
+
* - NullifierLimitReachedError
|
|
412
|
+
* - NullifierCollisionError
|
|
413
|
+
* - NoteHashLimitReachedError
|
|
414
|
+
* - L2ToL1MessageLimitReachedError
|
|
349
415
|
*/
|
|
350
|
-
protected async insertRevertiblesFromPrivate(context: PublicTxContext
|
|
416
|
+
protected async insertRevertiblesFromPrivate(context: PublicTxContext) {
|
|
351
417
|
const stateManager = context.state.getActiveStateManager();
|
|
352
418
|
|
|
353
419
|
try {
|
|
354
420
|
for (const siloedNullifier of context.revertibleAccumulatedDataFromPrivate.nullifiers.filter(n => !n.isEmpty())) {
|
|
355
421
|
await stateManager.writeSiloedNullifier(siloedNullifier);
|
|
356
422
|
}
|
|
357
|
-
} catch (e) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
423
|
+
} catch (e: any) {
|
|
424
|
+
if (e instanceof NullifierLimitReachedError || e instanceof NullifierCollisionError) {
|
|
425
|
+
context.revert(
|
|
426
|
+
TxExecutionPhase.APP_LOGIC,
|
|
427
|
+
new SimulationError(
|
|
428
|
+
`Error encountered when inserting revertible nullifiers from private.\nDetails: ${e.message}`,
|
|
429
|
+
[],
|
|
430
|
+
),
|
|
431
|
+
);
|
|
432
|
+
throw new TxSimRevertibleInsertionsRevert();
|
|
433
|
+
} else {
|
|
434
|
+
// Unchecked/unknown error - re-throw as-is
|
|
435
|
+
throw e;
|
|
436
|
+
}
|
|
366
437
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
438
|
+
|
|
439
|
+
try {
|
|
440
|
+
for (const noteHash of context.revertibleAccumulatedDataFromPrivate.noteHashes) {
|
|
441
|
+
if (!noteHash.isEmpty()) {
|
|
442
|
+
// Revertible note hashes from private are not hashed with nonce, since private can't know their final position, only we can.
|
|
443
|
+
await stateManager.writeSiloedNoteHash(noteHash);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
} catch (e: any) {
|
|
447
|
+
if (e instanceof NoteHashLimitReachedError) {
|
|
448
|
+
context.revert(
|
|
449
|
+
TxExecutionPhase.APP_LOGIC,
|
|
450
|
+
new SimulationError(
|
|
451
|
+
`Error encountered when inserting revertible note hashes from private.\nDetails: ${e.message}`,
|
|
452
|
+
[],
|
|
453
|
+
),
|
|
454
|
+
);
|
|
455
|
+
throw new TxSimRevertibleInsertionsRevert();
|
|
456
|
+
} else {
|
|
457
|
+
// Unchecked/unknown error - re-throw as-is
|
|
458
|
+
throw e;
|
|
371
459
|
}
|
|
372
460
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
461
|
+
|
|
462
|
+
try {
|
|
463
|
+
for (const l2ToL1Message of context.revertibleAccumulatedDataFromPrivate.l2ToL1Msgs) {
|
|
464
|
+
if (!l2ToL1Message.isEmpty()) {
|
|
465
|
+
stateManager.writeScopedL2ToL1Message(l2ToL1Message);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
} catch (e: any) {
|
|
469
|
+
if (e instanceof L2ToL1MessageLimitReachedError) {
|
|
470
|
+
context.revert(
|
|
471
|
+
TxExecutionPhase.APP_LOGIC,
|
|
472
|
+
new SimulationError(
|
|
473
|
+
`Error encountered when inserting revertible L2-to-L1 messages from private.\nDetails: ${e.message}`,
|
|
474
|
+
[],
|
|
475
|
+
),
|
|
476
|
+
);
|
|
477
|
+
throw new TxSimRevertibleInsertionsRevert();
|
|
478
|
+
} else {
|
|
479
|
+
// Unchecked/unknown error - re-throw as-is
|
|
480
|
+
throw e;
|
|
376
481
|
}
|
|
377
482
|
}
|
|
378
|
-
// add new contracts to the contracts db so that their functions may be found and called
|
|
379
|
-
// FIXME(fcarreiro): this should conceptually use the hinted contracts db.
|
|
380
|
-
// However things should work as they are now because the hinted db would still pick up the new contracts.
|
|
381
|
-
await this.contractsDB.addNewRevertibleContracts(tx);
|
|
382
483
|
|
|
383
|
-
|
|
484
|
+
// add new contracts to the contracts db so that their functions may be found and called
|
|
485
|
+
// FIXME(fcarreiro): this should conceptually use the hinting contracts db.
|
|
486
|
+
// However, things work as expected because later calls to getters on the hintingContractsDB
|
|
487
|
+
// will pick up the new contracts and will generate the necessary hints.
|
|
488
|
+
// So, a consumer of the hints will always see the new contracts.
|
|
489
|
+
await this.contractsDB.addContracts(context.revertibleContractDeploymentData);
|
|
384
490
|
}
|
|
385
491
|
|
|
386
492
|
private async payFee(context: PublicTxContext) {
|
|
387
493
|
const txFee = context.getTransactionFee(TxExecutionPhase.TEARDOWN);
|
|
388
494
|
|
|
389
495
|
if (context.feePayer.isZero()) {
|
|
390
|
-
|
|
496
|
+
// Real transactions are enforced by private kernel to have nonzero fee payer.
|
|
497
|
+
// Real transactions cannot skip fee enforcement (skipping fee enforcement makes them unprovable).
|
|
498
|
+
assert(this.config.skipFeeEnforcement, 'Fee payer cannot be 0 unless skipping fee enforcement for simulation');
|
|
499
|
+
this.log.debug(`Fee payer is 0. Skipping fee enforcement. No one is paying the fee of ${txFee.toBigInt()}`);
|
|
391
500
|
return;
|
|
392
501
|
}
|
|
393
502
|
|
|
@@ -402,29 +511,17 @@ export class PublicTxSimulator {
|
|
|
402
511
|
// When mocking the balance of the fee payer, the circuit should not be able to prove the simulation
|
|
403
512
|
|
|
404
513
|
if (currentBalance.lt(txFee)) {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
)
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
514
|
+
// Without "skipFeeEnforcement", such transactions should be filtered by GasTxValidator.
|
|
515
|
+
assert(
|
|
516
|
+
this.config.skipFeeEnforcement,
|
|
517
|
+
`Not enough balance for fee payer to pay for transaction (got ${currentBalance.toBigInt()} needs ${txFee.toBigInt()})`,
|
|
518
|
+
);
|
|
519
|
+
this.log.debug(`Fee payer balance insufficient, but we're skipping fee enforcement`);
|
|
520
|
+
// We still proceed and perform the storage write to minimize deviation from normal execution.
|
|
521
|
+
currentBalance = txFee;
|
|
412
522
|
}
|
|
413
523
|
|
|
414
524
|
const updatedBalance = currentBalance.sub(txFee);
|
|
415
525
|
await stateManager.writeStorage(feeJuiceAddress, balanceSlot, updatedBalance, true);
|
|
416
526
|
}
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* Generate the proving request for the AVM circuit.
|
|
420
|
-
*/
|
|
421
|
-
private static generateProvingRequest(
|
|
422
|
-
publicInputs: AvmCircuitPublicInputs,
|
|
423
|
-
hints: AvmExecutionHints,
|
|
424
|
-
): AvmProvingRequest {
|
|
425
|
-
return {
|
|
426
|
-
type: ProvingRequestType.PUBLIC_VM,
|
|
427
|
-
inputs: new AvmCircuitInputs(hints, publicInputs),
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
527
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { PublicTxResult } from '@aztec/stdlib/avm';
|
|
2
|
+
import type { Tx } from '@aztec/stdlib/tx';
|
|
3
|
+
|
|
4
|
+
export interface PublicTxSimulatorInterface {
|
|
5
|
+
simulate(tx: Tx): Promise<PublicTxResult>;
|
|
6
|
+
/**
|
|
7
|
+
* Cancel the current simulation if one is in progress.
|
|
8
|
+
* This signals the underlying simulator (e.g., C++) to stop at the next safe point.
|
|
9
|
+
* Safe to call even if no simulation is in progress.
|
|
10
|
+
* Optional - not all implementations support cancellation.
|
|
11
|
+
*
|
|
12
|
+
* @param waitTimeoutMs - If provided, wait up to this many ms for the simulation to actually stop.
|
|
13
|
+
* This is important because signaling cancellation doesn't immediately stop C++ -
|
|
14
|
+
* it only sets a flag that C++ checks at certain points. If C++ is in the middle
|
|
15
|
+
* of a slow operation (e.g., pad_trees), it won't stop until that completes.
|
|
16
|
+
* @returns Promise that resolves when cancellation is signaled (and optionally when simulation stops)
|
|
17
|
+
*/
|
|
18
|
+
cancel?(waitTimeoutMs?: number): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface MeasuredPublicTxSimulatorInterface {
|
|
22
|
+
simulate(tx: Tx, txLabel: string): Promise<PublicTxResult>;
|
|
23
|
+
/**
|
|
24
|
+
* Cancel the current simulation if one is in progress.
|
|
25
|
+
* This signals the underlying simulator (e.g., C++) to stop at the next safe point.
|
|
26
|
+
* Safe to call even if no simulation is in progress.
|
|
27
|
+
* Optional - not all implementations support cancellation.
|
|
28
|
+
*
|
|
29
|
+
* @param waitTimeoutMs - If provided, wait up to this many ms for the simulation to actually stop.
|
|
30
|
+
* @returns Promise that resolves when cancellation is signaled (and optionally when simulation stops)
|
|
31
|
+
*/
|
|
32
|
+
cancel?(waitTimeoutMs?: number): Promise<void>;
|
|
33
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
2
3
|
import type { Gas } from '@aztec/stdlib/gas';
|
|
3
4
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
4
5
|
import { type GlobalVariables, PublicCallRequestWithCalldata, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
@@ -22,21 +23,11 @@ export class TelemetryPublicTxSimulator extends MeasuredPublicTxSimulator {
|
|
|
22
23
|
merkleTree: MerkleTreeWriteOperations,
|
|
23
24
|
contractsDB: PublicContractsDB,
|
|
24
25
|
globalVariables: GlobalVariables,
|
|
25
|
-
doMerkleOperations: boolean = false,
|
|
26
|
-
skipFeeEnforcement: boolean = false,
|
|
27
|
-
clientInitiatedSimulation: boolean = false,
|
|
28
26
|
telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
27
|
+
config?: Partial<PublicSimulatorConfig>,
|
|
29
28
|
) {
|
|
30
29
|
const metrics = new ExecutorMetrics(telemetryClient, 'PublicTxSimulator');
|
|
31
|
-
super(
|
|
32
|
-
merkleTree,
|
|
33
|
-
contractsDB,
|
|
34
|
-
globalVariables,
|
|
35
|
-
doMerkleOperations,
|
|
36
|
-
skipFeeEnforcement,
|
|
37
|
-
clientInitiatedSimulation,
|
|
38
|
-
metrics,
|
|
39
|
-
);
|
|
30
|
+
super(merkleTree, contractsDB, globalVariables, metrics, config);
|
|
40
31
|
this.tracer = metrics.tracer;
|
|
41
32
|
}
|
|
42
33
|
|