@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
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
import { AVM_MAX_PROCESSABLE_L2_GAS } from '@aztec/constants';
|
|
2
|
-
import
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
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,
|
|
@@ -23,15 +15,60 @@ import {
|
|
|
23
15
|
TxExecutionPhase,
|
|
24
16
|
} from '@aztec/stdlib/tx';
|
|
25
17
|
|
|
18
|
+
import { strict as assert } from 'assert';
|
|
19
|
+
|
|
26
20
|
import type { AvmFinalizedCallResult } from '../avm/avm_contract_call_result.js';
|
|
27
21
|
import { AvmSimulator } from '../avm/index.js';
|
|
28
22
|
import { getPublicFunctionDebugName } from '../debug_fn_name.js';
|
|
29
23
|
import { HintingMerkleWriteOperations, HintingPublicContractsDB } from '../hinting_db_sources.js';
|
|
30
24
|
import { type PublicContractsDB, PublicTreesDB } from '../public_db_sources.js';
|
|
25
|
+
import {
|
|
26
|
+
L2ToL1MessageLimitReachedError,
|
|
27
|
+
NoteHashLimitReachedError,
|
|
28
|
+
NullifierCollisionError,
|
|
29
|
+
NullifierLimitReachedError,
|
|
30
|
+
} from '../side_effect_errors.js';
|
|
31
31
|
import type { PublicPersistableStateManager } from '../state_manager/state_manager.js';
|
|
32
32
|
import { PublicTxContext } from './public_tx_context.js';
|
|
33
|
+
import type { PublicTxSimulatorInterface } from './public_tx_simulator_interface.js';
|
|
34
|
+
|
|
35
|
+
// The errors below are only thrown here in the public tx simulator,
|
|
36
|
+
// and only during revertible phases (revertible insertions, app logic and teardown).
|
|
37
|
+
// These are strictly "checked" errors (not exported and never propagated).
|
|
38
|
+
// They are used internally for control flow to trigger rollbacks to the post-setup state.
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Error thrown when public tx simulation reverts in a known/checked way during revertible insertions.
|
|
42
|
+
*/
|
|
43
|
+
class TxSimRevertibleInsertionsRevert extends Error {
|
|
44
|
+
constructor() {
|
|
45
|
+
super('Public Tx Simulation reverted during Revertible Insertions');
|
|
46
|
+
this.name = 'TxSimRevertibleInsertionsRevert';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Error thrown when public tx simulation reverts during app logic.
|
|
52
|
+
*/
|
|
53
|
+
class TxSimAppLogicRevert extends Error {
|
|
54
|
+
constructor() {
|
|
55
|
+
super('Public Tx Simulation reverted during App Logic');
|
|
56
|
+
this.name = 'TxSimAppLogicRevert';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Error thrown when public tx simulation reverts during teardown.
|
|
62
|
+
*/
|
|
63
|
+
class TxSimTeardownRevert extends Error {
|
|
64
|
+
constructor() {
|
|
65
|
+
super('Public Tx Simulation reverted during Teardown');
|
|
66
|
+
this.name = 'TxSimTeardownRevert';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
33
69
|
|
|
34
|
-
|
|
70
|
+
/** Only used internally. */
|
|
71
|
+
type ProcessedPhase = {
|
|
35
72
|
phase: TxExecutionPhase;
|
|
36
73
|
durationMs?: number;
|
|
37
74
|
returnValues: NestedProcessReturnValues[];
|
|
@@ -39,27 +76,17 @@ export type ProcessedPhase = {
|
|
|
39
76
|
revertReason?: SimulationError;
|
|
40
77
|
};
|
|
41
78
|
|
|
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 {
|
|
79
|
+
export class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
53
80
|
protected log: Logger;
|
|
81
|
+
protected readonly config: PublicSimulatorConfig;
|
|
54
82
|
|
|
55
83
|
constructor(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
private skipFeeEnforcement: boolean = false,
|
|
61
|
-
private clientInitiatedSimulation: boolean = false,
|
|
84
|
+
protected merkleTree: MerkleTreeWriteOperations,
|
|
85
|
+
protected contractsDB: PublicContractsDB,
|
|
86
|
+
protected globalVariables: GlobalVariables,
|
|
87
|
+
config?: Partial<PublicSimulatorConfig>,
|
|
62
88
|
) {
|
|
89
|
+
this.config = PublicSimulatorConfig.from(config ?? {});
|
|
63
90
|
this.log = createLogger(`simulator:public_tx_simulator`);
|
|
64
91
|
}
|
|
65
92
|
|
|
@@ -69,121 +96,143 @@ export class PublicTxSimulator {
|
|
|
69
96
|
* @returns The result of the transaction's public execution.
|
|
70
97
|
*/
|
|
71
98
|
public async simulate(tx: Tx): Promise<PublicTxResult> {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
99
|
+
const txHash = this.computeTxHash(tx);
|
|
100
|
+
this.log.debug(`Simulating ${tx.publicFunctionCalldata.length} public calls for tx ${txHash}`, { txHash });
|
|
101
|
+
|
|
102
|
+
// Create hinting DBs.
|
|
103
|
+
const hints = new AvmExecutionHints(
|
|
104
|
+
this.globalVariables,
|
|
105
|
+
AvmTxHint.fromTx(tx, this.globalVariables.gasFees),
|
|
106
|
+
ProtocolContractsList, // imported from file
|
|
107
|
+
);
|
|
108
|
+
const hintingMerkleTree = await HintingMerkleWriteOperations.create(this.merkleTree, hints);
|
|
109
|
+
const hintingTreesDB = new PublicTreesDB(hintingMerkleTree);
|
|
110
|
+
const hintingContractsDB = new HintingPublicContractsDB(this.contractsDB, hints);
|
|
111
|
+
|
|
112
|
+
const context = await PublicTxContext.create(
|
|
113
|
+
hintingTreesDB,
|
|
114
|
+
hintingContractsDB,
|
|
115
|
+
tx,
|
|
116
|
+
this.globalVariables,
|
|
117
|
+
ProtocolContractsList, // imported from file
|
|
118
|
+
this.config.proverId,
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
// This will throw if there is a nullifier collision.
|
|
122
|
+
// In that case the transaction will be thrown out.
|
|
123
|
+
await this.insertNonRevertiblesFromPrivate(context);
|
|
89
124
|
|
|
90
|
-
|
|
125
|
+
const processedPhases: ProcessedPhase[] = [];
|
|
126
|
+
if (context.hasPhase(TxExecutionPhase.SETUP)) {
|
|
127
|
+
// This will throw if the setup phase reverts.
|
|
91
128
|
// 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);
|
|
129
|
+
const setupResult = await this.simulatePhase(TxExecutionPhase.SETUP, context);
|
|
130
|
+
if (setupResult.reverted) {
|
|
131
|
+
throw new Error(
|
|
132
|
+
`[SETUP] UNRECOVERABLE ERROR! The transaction will be thrown out. ${setupResult.revertReason?.message}`,
|
|
133
|
+
);
|
|
105
134
|
}
|
|
135
|
+
processedPhases.push(setupResult);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// The checkpoint we should go back to if anything from now on reverts.
|
|
139
|
+
await context.state.fork();
|
|
140
|
+
hintingContractsDB.createCheckpoint();
|
|
106
141
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (appLogicResult.reverted) {
|
|
118
|
-
throw new Error(`App logic phase reverted! ${appLogicResult.revertReason?.message}`);
|
|
119
|
-
}
|
|
142
|
+
try {
|
|
143
|
+
// This will throw if there is a nullifier collision or other insertion error (limit reached).
|
|
144
|
+
await this.insertRevertiblesFromPrivate(context);
|
|
145
|
+
|
|
146
|
+
// Only proceed with app logic if there was no revert during revertible insertion.
|
|
147
|
+
if (context.hasPhase(TxExecutionPhase.APP_LOGIC)) {
|
|
148
|
+
const appLogicResult = await this.simulatePhase(TxExecutionPhase.APP_LOGIC, context);
|
|
149
|
+
processedPhases.push(appLogicResult);
|
|
150
|
+
if (appLogicResult.reverted) {
|
|
151
|
+
throw new TxSimAppLogicRevert();
|
|
120
152
|
}
|
|
121
|
-
}
|
|
122
|
-
|
|
153
|
+
}
|
|
154
|
+
} catch (e: any) {
|
|
155
|
+
if (e instanceof TxSimRevertibleInsertionsRevert || e instanceof TxSimAppLogicRevert) {
|
|
123
156
|
// We revert to the post-setup state.
|
|
124
157
|
await context.state.discardForkedState();
|
|
158
|
+
hintingContractsDB.revertCheckpoint();
|
|
125
159
|
// But we also create a new fork so that the teardown phase can transparently
|
|
126
160
|
// commit or rollback at the end of teardown.
|
|
127
161
|
await context.state.fork();
|
|
162
|
+
hintingContractsDB.createCheckpoint();
|
|
163
|
+
} else {
|
|
164
|
+
// Unchecked/unknown error - re-throw as-is
|
|
165
|
+
throw e;
|
|
128
166
|
}
|
|
167
|
+
}
|
|
129
168
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
169
|
+
try {
|
|
170
|
+
if (context.hasPhase(TxExecutionPhase.TEARDOWN)) {
|
|
171
|
+
const teardownResult = await this.simulatePhase(TxExecutionPhase.TEARDOWN, context);
|
|
172
|
+
processedPhases.push(teardownResult);
|
|
173
|
+
if (teardownResult.reverted) {
|
|
174
|
+
throw new TxSimTeardownRevert();
|
|
137
175
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
176
|
+
}
|
|
177
|
+
// We commit the forked state and we are done.
|
|
178
|
+
await context.state.mergeForkedState();
|
|
179
|
+
hintingContractsDB.commitCheckpoint();
|
|
180
|
+
} catch (e: any) {
|
|
181
|
+
if (e instanceof TxSimTeardownRevert) {
|
|
182
|
+
// We revert to the post-setup state and we are done.
|
|
144
183
|
await context.state.discardForkedState();
|
|
184
|
+
hintingContractsDB.revertCheckpoint();
|
|
185
|
+
} else {
|
|
186
|
+
// Unchecked/unknown error - re-throw as-is
|
|
187
|
+
throw e;
|
|
145
188
|
}
|
|
189
|
+
}
|
|
146
190
|
|
|
147
|
-
|
|
191
|
+
context.halt();
|
|
148
192
|
|
|
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();
|
|
193
|
+
// Such transactions should be filtered by GasTxValidator.
|
|
194
|
+
assert(
|
|
195
|
+
context.getActualGasUsed().l2Gas <= AVM_MAX_PROCESSABLE_L2_GAS,
|
|
196
|
+
`Transaction consumes ${context.getActualGasUsed().l2Gas} L2 gas, which exceeds the AVM maximum processable gas of ${AVM_MAX_PROCESSABLE_L2_GAS}`,
|
|
197
|
+
);
|
|
198
|
+
await this.payFee(context);
|
|
199
|
+
|
|
200
|
+
const publicInputs = await context.generateAvmCircuitPublicInputs();
|
|
201
|
+
const revertCode = context.getFinalRevertCode();
|
|
202
|
+
|
|
203
|
+
// We only return the app logic phase information, and only 1 per phase.
|
|
204
|
+
const appLogicReturnValues: NestedProcessReturnValues[] =
|
|
205
|
+
processedPhases.find(({ phase }) => phase === TxExecutionPhase.APP_LOGIC)?.returnValues ?? [];
|
|
206
|
+
|
|
207
|
+
// TODO(fcarreiro): This is a temporary backwards compatibility layer until we migrate to the C++ simulator.
|
|
208
|
+
if (context.revertReason !== undefined) {
|
|
209
|
+
(appLogicReturnValues as any).revertReason = context.revertReason;
|
|
186
210
|
}
|
|
211
|
+
|
|
212
|
+
// Create PublicTxEffect from PublicInputs.
|
|
213
|
+
const publicTxEffect = new PublicTxEffect(
|
|
214
|
+
publicInputs.transactionFee,
|
|
215
|
+
publicInputs.accumulatedData.noteHashes.filter(h => !h.isEmpty()),
|
|
216
|
+
publicInputs.accumulatedData.nullifiers.filter(n => !n.isEmpty()),
|
|
217
|
+
publicInputs.accumulatedData.l2ToL1Msgs.filter(m => !m.isEmpty()),
|
|
218
|
+
publicInputs.accumulatedData.publicLogs.toLogs(),
|
|
219
|
+
publicInputs.accumulatedData.publicDataWrites.filter(w => !w.isEmpty()),
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
return new PublicTxResult(
|
|
223
|
+
/*gasUsed=*/ {
|
|
224
|
+
totalGas: context.getActualGasUsed(),
|
|
225
|
+
teardownGas: context.teardownGasUsed,
|
|
226
|
+
publicGas: context.getActualPublicGasUsed(),
|
|
227
|
+
billedGas: context.getTotalGasUsed(),
|
|
228
|
+
},
|
|
229
|
+
/*revertCode=*/ revertCode,
|
|
230
|
+
/*publicTxEffect=*/ publicTxEffect,
|
|
231
|
+
/*callStackMetadata=*/ appLogicReturnValues,
|
|
232
|
+
/*logs=*/ context.state.getActiveStateManager().getLogs(),
|
|
233
|
+
/*hints=*/ hints,
|
|
234
|
+
/*publicInputs=*/ publicInputs,
|
|
235
|
+
);
|
|
187
236
|
}
|
|
188
237
|
|
|
189
238
|
protected computeTxHash(tx: Tx) {
|
|
@@ -265,7 +314,7 @@ export class PublicTxSimulator {
|
|
|
265
314
|
);
|
|
266
315
|
|
|
267
316
|
if (result.reverted) {
|
|
268
|
-
const culprit = `${contractAddress}:${
|
|
317
|
+
const culprit = `${contractAddress}:${fnName}`;
|
|
269
318
|
context.revert(phase, result.revertReason, culprit);
|
|
270
319
|
}
|
|
271
320
|
|
|
@@ -308,7 +357,7 @@ export class PublicTxSimulator {
|
|
|
308
357
|
request.isStaticCall,
|
|
309
358
|
calldata,
|
|
310
359
|
allocatedGas,
|
|
311
|
-
this.
|
|
360
|
+
this.config,
|
|
312
361
|
);
|
|
313
362
|
const avmCallResult = await simulator.execute();
|
|
314
363
|
return avmCallResult.finalize();
|
|
@@ -317,7 +366,7 @@ export class PublicTxSimulator {
|
|
|
317
366
|
/**
|
|
318
367
|
* Insert the non-revertible accumulated data from private into the public state.
|
|
319
368
|
*/
|
|
320
|
-
protected async insertNonRevertiblesFromPrivate(context: PublicTxContext
|
|
369
|
+
protected async insertNonRevertiblesFromPrivate(context: PublicTxContext) {
|
|
321
370
|
const stateManager = context.state.getActiveStateManager();
|
|
322
371
|
|
|
323
372
|
for (const siloedNullifier of context.nonRevertibleAccumulatedDataFromPrivate.nullifiers.filter(
|
|
@@ -336,58 +385,107 @@ export class PublicTxSimulator {
|
|
|
336
385
|
}
|
|
337
386
|
}
|
|
338
387
|
|
|
339
|
-
// add new contracts to the contracts db so that their
|
|
340
|
-
//
|
|
341
|
-
//
|
|
342
|
-
//
|
|
343
|
-
|
|
388
|
+
// add new contracts to the contracts db so that their code may be found and called
|
|
389
|
+
// FIXME(fcarreiro): this should conceptually use the hinting contracts db.
|
|
390
|
+
// However, things work as expected because later calls to getters on the hintingContractsDB
|
|
391
|
+
// will pick up the new contracts and will generate the necessary hints.
|
|
392
|
+
// So, a consumer of the hints will always see the new contracts.
|
|
393
|
+
await this.contractsDB.addContracts(context.nonRevertibleContractDeploymentData);
|
|
344
394
|
}
|
|
345
395
|
|
|
346
396
|
/**
|
|
347
397
|
* Insert the revertible accumulated data from private into the public state.
|
|
348
|
-
*
|
|
398
|
+
* Throws TxSimRevertibleInsertionsRevert if there is some checked error during revertible insertions.
|
|
399
|
+
* This function checks for the following errors:
|
|
400
|
+
* - NullifierLimitReachedError
|
|
401
|
+
* - NullifierCollisionError
|
|
402
|
+
* - NoteHashLimitReachedError
|
|
403
|
+
* - L2ToL1MessageLimitReachedError
|
|
349
404
|
*/
|
|
350
|
-
protected async insertRevertiblesFromPrivate(context: PublicTxContext
|
|
405
|
+
protected async insertRevertiblesFromPrivate(context: PublicTxContext) {
|
|
351
406
|
const stateManager = context.state.getActiveStateManager();
|
|
352
407
|
|
|
353
408
|
try {
|
|
354
409
|
for (const siloedNullifier of context.revertibleAccumulatedDataFromPrivate.nullifiers.filter(n => !n.isEmpty())) {
|
|
355
410
|
await stateManager.writeSiloedNullifier(siloedNullifier);
|
|
356
411
|
}
|
|
357
|
-
} catch (e) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
412
|
+
} catch (e: any) {
|
|
413
|
+
if (e instanceof NullifierLimitReachedError || e instanceof NullifierCollisionError) {
|
|
414
|
+
context.revert(
|
|
415
|
+
TxExecutionPhase.APP_LOGIC,
|
|
416
|
+
new SimulationError(
|
|
417
|
+
`Error encountered when inserting revertible nullifiers from private.\nDetails: ${e.message}`,
|
|
418
|
+
[],
|
|
419
|
+
),
|
|
420
|
+
);
|
|
421
|
+
throw new TxSimRevertibleInsertionsRevert();
|
|
422
|
+
} else {
|
|
423
|
+
// Unchecked/unknown error - re-throw as-is
|
|
424
|
+
throw e;
|
|
425
|
+
}
|
|
366
426
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
427
|
+
|
|
428
|
+
try {
|
|
429
|
+
for (const noteHash of context.revertibleAccumulatedDataFromPrivate.noteHashes) {
|
|
430
|
+
if (!noteHash.isEmpty()) {
|
|
431
|
+
// Revertible note hashes from private are not hashed with nonce, since private can't know their final position, only we can.
|
|
432
|
+
await stateManager.writeSiloedNoteHash(noteHash);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
} catch (e: any) {
|
|
436
|
+
if (e instanceof NoteHashLimitReachedError) {
|
|
437
|
+
context.revert(
|
|
438
|
+
TxExecutionPhase.APP_LOGIC,
|
|
439
|
+
new SimulationError(
|
|
440
|
+
`Error encountered when inserting revertible note hashes from private.\nDetails: ${e.message}`,
|
|
441
|
+
[],
|
|
442
|
+
),
|
|
443
|
+
);
|
|
444
|
+
throw new TxSimRevertibleInsertionsRevert();
|
|
445
|
+
} else {
|
|
446
|
+
// Unchecked/unknown error - re-throw as-is
|
|
447
|
+
throw e;
|
|
371
448
|
}
|
|
372
449
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
450
|
+
|
|
451
|
+
try {
|
|
452
|
+
for (const l2ToL1Message of context.revertibleAccumulatedDataFromPrivate.l2ToL1Msgs) {
|
|
453
|
+
if (!l2ToL1Message.isEmpty()) {
|
|
454
|
+
stateManager.writeScopedL2ToL1Message(l2ToL1Message);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
} catch (e: any) {
|
|
458
|
+
if (e instanceof L2ToL1MessageLimitReachedError) {
|
|
459
|
+
context.revert(
|
|
460
|
+
TxExecutionPhase.APP_LOGIC,
|
|
461
|
+
new SimulationError(
|
|
462
|
+
`Error encountered when inserting revertible L2-to-L1 messages from private.\nDetails: ${e.message}`,
|
|
463
|
+
[],
|
|
464
|
+
),
|
|
465
|
+
);
|
|
466
|
+
throw new TxSimRevertibleInsertionsRevert();
|
|
467
|
+
} else {
|
|
468
|
+
// Unchecked/unknown error - re-throw as-is
|
|
469
|
+
throw e;
|
|
376
470
|
}
|
|
377
471
|
}
|
|
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
472
|
|
|
383
|
-
|
|
473
|
+
// add new contracts to the contracts db so that their functions may be found and called
|
|
474
|
+
// FIXME(fcarreiro): this should conceptually use the hinting contracts db.
|
|
475
|
+
// However, things work as expected because later calls to getters on the hintingContractsDB
|
|
476
|
+
// will pick up the new contracts and will generate the necessary hints.
|
|
477
|
+
// So, a consumer of the hints will always see the new contracts.
|
|
478
|
+
await this.contractsDB.addContracts(context.revertibleContractDeploymentData);
|
|
384
479
|
}
|
|
385
480
|
|
|
386
481
|
private async payFee(context: PublicTxContext) {
|
|
387
482
|
const txFee = context.getTransactionFee(TxExecutionPhase.TEARDOWN);
|
|
388
483
|
|
|
389
484
|
if (context.feePayer.isZero()) {
|
|
390
|
-
|
|
485
|
+
// Real transactions are enforced by private kernel to have nonzero fee payer.
|
|
486
|
+
// Real transactions cannot skip fee enforcement (skipping fee enforcement makes them unprovable).
|
|
487
|
+
assert(this.config.skipFeeEnforcement, 'Fee payer cannot be 0 unless skipping fee enforcement for simulation');
|
|
488
|
+
this.log.debug(`Fee payer is 0. Skipping fee enforcement. No one is paying the fee of ${txFee.toBigInt()}`);
|
|
391
489
|
return;
|
|
392
490
|
}
|
|
393
491
|
|
|
@@ -402,29 +500,17 @@ export class PublicTxSimulator {
|
|
|
402
500
|
// When mocking the balance of the fee payer, the circuit should not be able to prove the simulation
|
|
403
501
|
|
|
404
502
|
if (currentBalance.lt(txFee)) {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
)
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
503
|
+
// Without "skipFeeEnforcement", such transactions should be filtered by GasTxValidator.
|
|
504
|
+
assert(
|
|
505
|
+
this.config.skipFeeEnforcement,
|
|
506
|
+
`Not enough balance for fee payer to pay for transaction (got ${currentBalance.toBigInt()} needs ${txFee.toBigInt()})`,
|
|
507
|
+
);
|
|
508
|
+
this.log.debug(`Fee payer balance insufficient, but we're skipping fee enforcement`);
|
|
509
|
+
// We still proceed and perform the storage write to minimize deviation from normal execution.
|
|
510
|
+
currentBalance = txFee;
|
|
412
511
|
}
|
|
413
512
|
|
|
414
513
|
const updatedBalance = currentBalance.sub(txFee);
|
|
415
514
|
await stateManager.writeStorage(feeJuiceAddress, balanceSlot, updatedBalance, true);
|
|
416
515
|
}
|
|
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
516
|
}
|
|
@@ -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
|
|