@aztec/simulator 0.0.1-commit.9b94fc1 → 0.0.1-commit.9badcec54
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/common/errors.d.ts +8 -2
- package/dest/common/errors.d.ts.map +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/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/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 +5 -3
- package/dest/private/acvm_native.d.ts.map +1 -1
- package/dest/private/acvm_native.js +8 -6
- 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/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 +23 -20
- 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/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 +7 -6
- package/dest/public/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/public/avm/avm_execution_environment.js +1 -1
- package/dest/public/avm/avm_gas.d.ts +1 -1
- 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 +2 -2
- 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 +4 -3
- package/dest/public/avm/avm_simulator.d.ts.map +1 -1
- package/dest/public/avm/avm_simulator.js +12 -10
- 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 +64 -0
- package/dest/public/avm/errors.d.ts +8 -2
- package/dest/public/avm/errors.d.ts.map +1 -1
- package/dest/public/avm/errors.js +14 -2
- package/dest/public/avm/fixtures/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 +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.js +4 -3
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +2 -2
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/base_avm_simulation_tester.js +1 -1
- package/dest/public/avm/fixtures/initializers.d.ts +2 -2
- package/dest/public/avm/fixtures/initializers.d.ts.map +1 -1
- package/dest/public/avm/fixtures/initializers.js +5 -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/opcodes/accrued_substate.d.ts +17 -18
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/public/avm/opcodes/accrued_substate.js +42 -43
- package/dest/public/avm/opcodes/addressing_mode.js +2 -2
- 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 +12 -2
- package/dest/public/avm/opcodes/bitwise.d.ts +7 -7
- 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 +4 -4
- package/dest/public/avm/opcodes/comparators.d.ts.map +1 -1
- package/dest/public/avm/opcodes/comparators.js +1 -1
- package/dest/public/avm/opcodes/contract.d.ts +3 -3
- package/dest/public/avm/opcodes/contract.d.ts.map +1 -1
- package/dest/public/avm/opcodes/contract.js +8 -8
- package/dest/public/avm/opcodes/control_flow.d.ts +3 -3
- package/dest/public/avm/opcodes/control_flow.d.ts.map +1 -1
- package/dest/public/avm/opcodes/control_flow.js +4 -4
- package/dest/public/avm/opcodes/conversion.d.ts +3 -3
- package/dest/public/avm/opcodes/conversion.d.ts.map +1 -1
- package/dest/public/avm/opcodes/conversion.js +4 -4
- package/dest/public/avm/opcodes/ec_add.d.ts +4 -4
- package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -1
- package/dest/public/avm/opcodes/ec_add.js +17 -8
- package/dest/public/avm/opcodes/environment_getters.d.ts +5 -5
- package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/public/avm/opcodes/environment_getters.js +6 -6
- package/dest/public/avm/opcodes/external_calls.d.ts +9 -9
- package/dest/public/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/public/avm/opcodes/external_calls.js +23 -22
- package/dest/public/avm/opcodes/hashing.d.ts +8 -8
- 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/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 +14 -14
- package/dest/public/avm/opcodes/memory.d.ts.map +1 -1
- package/dest/public/avm/opcodes/memory.js +26 -26
- package/dest/public/avm/opcodes/misc.d.ts +3 -3
- package/dest/public/avm/opcodes/misc.d.ts.map +1 -1
- package/dest/public/avm/opcodes/misc.js +6 -6
- package/dest/public/avm/opcodes/storage.d.ts +16 -15
- 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/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 +2 -2
- package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/instruction_serialization.js +2 -2
- package/dest/public/avm/test_utils.d.ts +2 -2
- package/dest/public/avm/test_utils.d.ts.map +1 -1
- package/dest/public/avm/test_utils.js +1 -1
- package/dest/public/contracts_db_checkpoint.d.ts +3 -3
- package/dest/public/contracts_db_checkpoint.d.ts.map +1 -1
- package/dest/public/contracts_db_checkpoint.js +1 -1
- package/dest/public/db_interfaces.d.ts +2 -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 +1 -1
- package/dest/public/executor_metrics.d.ts.map +1 -1
- package/dest/public/executor_metrics.js +12 -33
- 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 +9 -73
- package/dest/public/fixtures/custom_bytecode_tester.d.ts +28 -6
- package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -1
- package/dest/public/fixtures/custom_bytecode_tester.js +36 -12
- package/dest/public/fixtures/custom_bytecode_tests.d.ts +11 -8
- package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -1
- package/dest/public/fixtures/custom_bytecode_tests.js +83 -18
- package/dest/public/fixtures/index.d.ts +4 -2
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +3 -1
- package/dest/public/fixtures/minimal_public_tx.d.ts +2 -7
- package/dest/public/fixtures/minimal_public_tx.d.ts.map +1 -1
- package/dest/public/fixtures/minimal_public_tx.js +4 -14
- 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 +27 -7
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +87 -23
- 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 -11
- package/dest/public/fixtures/utils.d.ts +3 -3
- package/dest/public/fixtures/utils.d.ts.map +1 -1
- package/dest/public/fixtures/utils.js +14 -13
- 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 +8 -6
- package/dest/public/hinting_db_sources.d.ts.map +1 -1
- package/dest/public/hinting_db_sources.js +13 -7
- package/dest/public/index.d.ts +2 -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 +7 -6
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +15 -15
- package/dest/public/public_processor/guarded_merkle_tree.d.ts +7 -5
- package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
- package/dest/public/public_processor/guarded_merkle_tree.js +9 -4
- package/dest/public/public_processor/public_processor.d.ts +11 -7
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +493 -86
- 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 +3 -14
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +22 -56
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +24 -37
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +65 -144
- 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 +4 -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 +3 -3
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +11 -6
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +17 -19
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +13 -7
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +37 -21
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts +24 -1
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts +2 -2
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.js +395 -19
- package/dest/public/side_effect_trace.d.ts +6 -5
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +4 -4
- package/dest/public/side_effect_trace_interface.d.ts +2 -2
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
- package/dest/public/state_manager/nullifiers.d.ts +2 -2
- package/dest/public/state_manager/nullifiers.d.ts.map +1 -1
- package/dest/public/state_manager/public_storage.d.ts +2 -2
- package/dest/public/state_manager/public_storage.d.ts.map +1 -1
- package/dest/public/state_manager/public_storage.js +1 -1
- package/dest/public/state_manager/state_manager.d.ts +16 -5
- package/dest/public/state_manager/state_manager.d.ts.map +1 -1
- package/dest/public/state_manager/state_manager.js +19 -9
- package/dest/public/test_executor_metrics.d.ts +8 -2
- package/dest/public/test_executor_metrics.d.ts.map +1 -1
- package/dest/public/test_executor_metrics.js +24 -2
- package/package.json +19 -20
- 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 +11 -5
- package/src/private/acvm_wasm.ts +7 -3
- package/src/private/circuit_recording/circuit_recorder.ts +24 -21
- 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/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 +10 -5
- 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 +17 -11
- package/src/public/avm/calldata.ts +101 -0
- package/src/public/avm/errors.ts +17 -3
- 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 +9 -3
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +1 -1
- package/src/public/avm/fixtures/initializers.ts +5 -4
- package/src/public/avm/fixtures/utils.ts +3 -2
- package/src/public/avm/opcodes/accrued_substate.ts +31 -34
- package/src/public/avm/opcodes/addressing_mode.ts +2 -2
- package/src/public/avm/opcodes/arithmetic.ts +14 -2
- package/src/public/avm/opcodes/bitwise.ts +3 -3
- package/src/public/avm/opcodes/comparators.ts +1 -1
- package/src/public/avm/opcodes/contract.ts +4 -7
- package/src/public/avm/opcodes/control_flow.ts +2 -2
- package/src/public/avm/opcodes/conversion.ts +3 -3
- package/src/public/avm/opcodes/ec_add.ts +15 -6
- package/src/public/avm/opcodes/environment_getters.ts +7 -7
- package/src/public/avm/opcodes/external_calls.ts +18 -16
- package/src/public/avm/opcodes/hashing.ts +16 -10
- package/src/public/avm/opcodes/instruction_impl.ts +2 -2
- package/src/public/avm/opcodes/memory.ts +20 -20
- package/src/public/avm/opcodes/misc.ts +4 -4
- 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 +2 -2
- package/src/public/avm/test_utils.ts +1 -1
- package/src/public/contracts_db_checkpoint.ts +2 -2
- package/src/public/db_interfaces.ts +1 -1
- package/src/public/debug_fn_name.ts +39 -5
- package/src/public/executor_metrics.ts +9 -33
- package/src/public/fixtures/amm_test.ts +4 -4
- package/src/public/fixtures/bulk_test.ts +11 -13
- package/src/public/fixtures/custom_bytecode_tester.ts +53 -19
- package/src/public/fixtures/custom_bytecode_tests.ts +111 -18
- package/src/public/fixtures/index.ts +7 -1
- package/src/public/fixtures/minimal_public_tx.ts +6 -15
- package/src/public/fixtures/opcode_spammer.ts +1717 -0
- package/src/public/fixtures/public_tx_simulation_tester.ts +116 -19
- package/src/public/fixtures/simple_contract_data_source.ts +8 -9
- package/src/public/fixtures/token_test.ts +18 -9
- package/src/public/fixtures/utils.ts +19 -15
- 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 +16 -9
- package/src/public/index.ts +7 -1
- package/src/public/public_db_sources.ts +28 -20
- package/src/public/public_processor/guarded_merkle_tree.ts +11 -6
- package/src/public/public_processor/public_processor.ts +127 -84
- package/src/public/public_processor/public_processor_metrics.ts +16 -44
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +27 -64
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +82 -178
- 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 +44 -0
- package/src/public/public_tx_simulator/index.ts +3 -0
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +1 -1
- package/src/public/public_tx_simulator/public_tx_context.ts +22 -17
- package/src/public/public_tx_simulator/public_tx_simulator.ts +56 -26
- package/src/public/public_tx_simulator/public_tx_simulator_interface.ts +23 -0
- package/src/public/public_tx_simulator/telemetry_public_tx_simulator.ts +1 -1
- package/src/public/side_effect_trace.ts +6 -3
- package/src/public/side_effect_trace_interface.ts +1 -1
- package/src/public/state_manager/nullifiers.ts +1 -1
- package/src/public/state_manager/public_storage.ts +1 -1
- package/src/public/state_manager/state_manager.ts +39 -23
- package/src/public/test_executor_metrics.ts +27 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dumping_cpp_public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/dumping_cpp_public_tx_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAIL,KAAK,qBAAqB,EAC1B,cAAc,EAEf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,EAAE,EAAU,MAAM,kBAAkB,CAAC;AAMpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE;;;GAGG;AACH,qBAAa,2BAA4B,SAAQ,oBAAoB;IACnE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAEnC,YACE,UAAU,EAAE,yBAAyB,EACrC,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,OAAO,CAAC,qBAAqB,CAAC,EACtC,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,cAAc,EAM1B;IAEqB,QAAQ,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAQ9D;IAED;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;CA0B7B"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { AvmCircuitInputs, AvmCircuitPublicInputs, AvmExecutionHints, serializeWithMessagePack } from '@aztec/stdlib/avm';
|
|
2
|
+
import { strict as assert } from 'assert';
|
|
3
|
+
import { mkdirSync, writeFileSync } from 'fs';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
import { CppPublicTxSimulator } from './cpp_public_tx_simulator.js';
|
|
6
|
+
/**
|
|
7
|
+
* A C++ public tx simulator that dumps AVM circuit inputs to disk after simulation.
|
|
8
|
+
* Used during nightly CI runs to collect circuit inputs for benchmarking.
|
|
9
|
+
*/ export class DumpingCppPublicTxSimulator extends CppPublicTxSimulator {
|
|
10
|
+
outputDir;
|
|
11
|
+
constructor(merkleTree, contractsDB, globalVariables, config, outputDir, bindings){
|
|
12
|
+
super(merkleTree, contractsDB, globalVariables, config, bindings);
|
|
13
|
+
assert(config.collectHints === true, 'collectHints must be enabled to dump AVM circuit inputs');
|
|
14
|
+
assert(config.collectPublicInputs === true, 'collectPublicInputs must be enabled to dump AVM circuit inputs');
|
|
15
|
+
this.outputDir = outputDir;
|
|
16
|
+
}
|
|
17
|
+
async simulate(tx) {
|
|
18
|
+
const result = await super.simulate(tx);
|
|
19
|
+
// Dump the circuit inputs after successful simulation
|
|
20
|
+
const txHash = this.computeTxHash(tx);
|
|
21
|
+
this.dumpAvmCircuitInputs(result, txHash);
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Dumps AVM circuit inputs to disk.
|
|
26
|
+
*
|
|
27
|
+
* @param result - The simulation result containing hints and public inputs
|
|
28
|
+
* @param txHash - The transaction hash to use in the filename
|
|
29
|
+
*/ dumpAvmCircuitInputs(result, txHash) {
|
|
30
|
+
try {
|
|
31
|
+
// Ensure the output directory exists
|
|
32
|
+
mkdirSync(this.outputDir, {
|
|
33
|
+
recursive: true
|
|
34
|
+
});
|
|
35
|
+
// Generate filename using transaction hash
|
|
36
|
+
const filename = `avm-circuit-inputs-tx-${txHash.toString()}.bin`;
|
|
37
|
+
const filepath = join(this.outputDir, filename);
|
|
38
|
+
// Create circuit inputs from the result
|
|
39
|
+
const hints = result.hints ?? AvmExecutionHints.empty();
|
|
40
|
+
const publicInputs = result.publicInputs ?? AvmCircuitPublicInputs.empty();
|
|
41
|
+
const avmCircuitInputs = new AvmCircuitInputs(hints, publicInputs);
|
|
42
|
+
// Serialize the circuit inputs using MessagePack
|
|
43
|
+
const serialized = serializeWithMessagePack(avmCircuitInputs);
|
|
44
|
+
// Write to disk
|
|
45
|
+
writeFileSync(filepath, serialized);
|
|
46
|
+
this.log.debug(`Dumped AVM circuit inputs to ${filepath}`);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
// Non-blocking error handling - log but don't interrupt processing
|
|
49
|
+
this.log.warn(`Failed to dump AVM circuit inputs for tx ${txHash.toString()}: ${error}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { LoggerBindings } from '@aztec/foundation/log';
|
|
2
|
+
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
3
|
+
import type { GlobalVariables } from '@aztec/stdlib/tx';
|
|
4
|
+
import type { TelemetryClient } from '@aztec/telemetry-client';
|
|
5
|
+
import type { PublicContractsDB } from '../public_db_sources.js';
|
|
6
|
+
import { TelemetryCppPublicTxSimulator } from './cpp_public_tx_simulator.js';
|
|
7
|
+
import { DumpingCppPublicTxSimulator } from './dumping_cpp_public_tx_simulator.js';
|
|
8
|
+
/**
|
|
9
|
+
* Creates a public tx simulator for block building.
|
|
10
|
+
* Uses DumpingCppPublicTxSimulator if DUMP_AVM_INPUTS_TO_DIR env var is set (for CI/testing avm circuit),
|
|
11
|
+
* otherwise uses TelemetryCppPublicTxSimulator (for production).
|
|
12
|
+
*/
|
|
13
|
+
export declare function createPublicTxSimulatorForBlockBuilding(merkleTree: MerkleTreeWriteOperations, contractsDB: PublicContractsDB, globalVariables: GlobalVariables, telemetryClient: TelemetryClient, bindings?: LoggerBindings, collectDebugLogs?: boolean): DumpingCppPublicTxSimulator | TelemetryCppPublicTxSimulator;
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yaWVzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvcHVibGljL3B1YmxpY190eF9zaW11bGF0b3IvZmFjdG9yaWVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGNBQWMsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBRTVELE9BQU8sS0FBSyxFQUFFLHlCQUF5QixFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDckUsT0FBTyxLQUFLLEVBQUUsZUFBZSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDeEQsT0FBTyxLQUFLLE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cAAc,EACzB,gBAAgB,UAAQ,+DAsBzB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
2
|
+
import { TelemetryCppPublicTxSimulator } from './cpp_public_tx_simulator.js';
|
|
3
|
+
import { DumpingCppPublicTxSimulator } from './dumping_cpp_public_tx_simulator.js';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a public tx simulator for block building.
|
|
6
|
+
* Uses DumpingCppPublicTxSimulator if DUMP_AVM_INPUTS_TO_DIR env var is set (for CI/testing avm circuit),
|
|
7
|
+
* otherwise uses TelemetryCppPublicTxSimulator (for production).
|
|
8
|
+
*/ export function createPublicTxSimulatorForBlockBuilding(merkleTree, contractsDB, globalVariables, telemetryClient, bindings, collectDebugLogs = false) {
|
|
9
|
+
const config = PublicSimulatorConfig.from({
|
|
10
|
+
skipFeeEnforcement: false,
|
|
11
|
+
collectDebugLogs,
|
|
12
|
+
collectHints: false,
|
|
13
|
+
collectPublicInputs: false,
|
|
14
|
+
collectStatistics: false,
|
|
15
|
+
collectCallMetadata: false
|
|
16
|
+
});
|
|
17
|
+
const dumpDir = process.env.DUMP_AVM_INPUTS_TO_DIR;
|
|
18
|
+
if (dumpDir) {
|
|
19
|
+
// must collect hints and PIs for dumping
|
|
20
|
+
const dumpingConfig = {
|
|
21
|
+
...config,
|
|
22
|
+
collectHints: true,
|
|
23
|
+
collectPublicInputs: true
|
|
24
|
+
};
|
|
25
|
+
return new DumpingCppPublicTxSimulator(merkleTree, contractsDB, globalVariables, dumpingConfig, dumpDir, bindings);
|
|
26
|
+
}
|
|
27
|
+
return new TelemetryCppPublicTxSimulator(merkleTree, contractsDB, globalVariables, telemetryClient, config, bindings);
|
|
28
|
+
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export * from './public_tx_simulator.js';
|
|
2
|
+
export { CppPublicTxSimulator, TelemetryCppPublicTxSimulator } from './cpp_public_tx_simulator.js';
|
|
3
|
+
export { DumpingCppPublicTxSimulator } from './dumping_cpp_public_tx_simulator.js';
|
|
4
|
+
export { createPublicTxSimulatorForBlockBuilding } from './factories.js';
|
|
2
5
|
export type { PublicTxSimulatorInterface } from './public_tx_simulator_interface.js';
|
|
3
6
|
export { TelemetryPublicTxSimulator } from './telemetry_public_tx_simulator.js';
|
|
4
7
|
export type { PublicTxResult, PublicSimulatorConfig as PublicTxSimulatorConfig } from '@aztec/stdlib/avm';
|
|
5
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wdWJsaWMvcHVibGljX3R4X3NpbXVsYXRvci9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLDBCQUEwQixDQUFDO0FBQ3pDLE9BQU8sRUFBRSxvQkFBb0IsRUFBRSw2QkFBNkIsRUFBRSxNQUFNLDhCQUE4QixDQUFDO0FBQ25HLE9BQU8sRUFBRSwyQkFBMkIsRUFBRSxNQUFNLHNDQUFzQyxDQUFDO0FBQ25GLE9BQU8sRUFBRSx1Q0FBdUMsRUFBRSxNQUFNLGdCQUFnQixDQUFDO0FBQ3pFLFlBQVksRUFBRSwwQkFBMEIsRUFBRSxNQUFNLG9DQUFvQyxDQUFDO0FBQ3JGLE9BQU8sRUFBRSwwQkFBMEIsRUFBRSxNQUFNLG9DQUFvQyxDQUFDO0FBQ2hGLFlBQVksRUFBRSxjQUFjLEVBQUUscUJBQXFCLElBQUksdUJBQXVCLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,YAAY,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AACrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,YAAY,EAAE,cAAc,EAAE,qBAAqB,IAAI,uBAAuB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AACnG,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,uCAAuC,EAAE,MAAM,gBAAgB,CAAC;AACzE,YAAY,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AACrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,YAAY,EAAE,cAAc,EAAE,qBAAqB,IAAI,uBAAuB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export * from './public_tx_simulator.js';
|
|
2
|
+
export { CppPublicTxSimulator, TelemetryCppPublicTxSimulator } from './cpp_public_tx_simulator.js';
|
|
3
|
+
export { DumpingCppPublicTxSimulator } from './dumping_cpp_public_tx_simulator.js';
|
|
4
|
+
export { createPublicTxSimulatorForBlockBuilding } from './factories.js';
|
|
2
5
|
export { TelemetryPublicTxSimulator } from './telemetry_public_tx_simulator.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import type { PublicSimulatorConfig, PublicTxResult } from '@aztec/stdlib/avm';
|
|
3
3
|
import type { Gas } from '@aztec/stdlib/gas';
|
|
4
4
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
@@ -24,8 +24,8 @@ export declare class MeasuredPublicTxSimulator extends PublicTxSimulator impleme
|
|
|
24
24
|
durationMs?: number | undefined;
|
|
25
25
|
returnValues: import("@aztec/stdlib/tx").NestedProcessReturnValues[];
|
|
26
26
|
reverted: boolean;
|
|
27
|
-
revertReason?: import("
|
|
27
|
+
revertReason?: import("@aztec/stdlib/errors").SimulationError | undefined;
|
|
28
28
|
}>;
|
|
29
29
|
protected simulateEnqueuedCallInternal(stateManager: PublicPersistableStateManager, callRequest: PublicCallRequestWithCalldata, allocatedGas: Gas, transactionFee: Fr, fnName: string): Promise<AvmFinalizedCallResult>;
|
|
30
30
|
}
|
|
31
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
31
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVhc3VyZWRfcHVibGljX3R4X3NpbXVsYXRvci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3B1YmxpYy9wdWJsaWNfdHhfc2ltdWxhdG9yL21lYXN1cmVkX3B1YmxpY190eF9zaW11bGF0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFFekQsT0FBTyxLQUFLLEVBQUUscUJBQXFCLEVBQUUsY0FBYyxFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDL0UsT0FBTyxLQUFLLEVBQUUsR0FBRyxFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFFN0MsT0FBTyxLQUFLLEVBQUUseUJBQXlCLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNyRSxPQUFPLEVBQUUsS0FBSyxlQUFlLEVBQUUsNkJBQTZCLEVBQUUsRUFBRSxFQUFFLGdCQUFnQixFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFN0csT0FBTyxLQUFLLEVBQUUsc0JBQXNCLEVBQUUsTUFBTSxv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0lBRUQsVUFBeUIsNEJBQTRCLENBQ25ELFlBQVksRUFBRSw2QkFBNkIsRUFDM0MsV0FBVyxFQUFFLDZCQUE2QixFQUMxQyxZQUFZLEVBQUUsR0FBRyxFQUNqQixjQUFjLEVBQUUsRUFBRSxFQUNsQixNQUFNLEVBQUUsTUFBTSxHQUNiLE9BQU8sQ0FBQyxzQkFBc0IsQ0FBQyxDQXFDakM7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measured_public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/measured_public_tx_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"measured_public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/measured_public_tx_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,KAAK,eAAe,EAAE,6BAA6B,EAAE,EAAE,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE7G,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,oCAAoC,CAAC;AAE7F;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,iBAAkB,YAAW,kCAAkC;IAK1G,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,wBAAwB;IAJtD,YACE,UAAU,EAAE,yBAAyB,EACrC,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EACb,OAAO,EAAE,wBAAwB,EACpD,MAAM,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,EAGxC;IAEqB,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,GAAE,MAAsB,GAAG,OAAO,CAAC,cAAc,CAAC,CAS/F;IAED,UAAyB,+BAA+B,CAAC,OAAO,EAAE,eAAe,iBAIhF;IAED,UAAyB,4BAA4B,CAAC,OAAO,EAAE,eAAe,iBAI7E;IAED,UAAyB,aAAa,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,eAAe;;;;;;OAKvF;IAED,UAAyB,4BAA4B,CACnD,YAAY,EAAE,6BAA6B,EAC3C,WAAW,EAAE,6BAA6B,EAC1C,YAAY,EAAE,GAAG,EACjB,cAAc,EAAE,EAAE,EAClB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,sBAAsB,CAAC,CAqCjC;CACF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { type LoggerBindings } from '@aztec/foundation/log';
|
|
2
3
|
import { AvmCircuitPublicInputs, RevertCode } from '@aztec/stdlib/avm';
|
|
3
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
5
|
import { type ContractDeploymentData } from '@aztec/stdlib/contract';
|
|
@@ -39,7 +40,7 @@ export declare class PublicTxContext {
|
|
|
39
40
|
private revertCode;
|
|
40
41
|
revertReason: SimulationError | undefined;
|
|
41
42
|
private constructor();
|
|
42
|
-
static create(treesDB: PublicTreesDB, contractsDB: PublicContractsDBInterface, tx: Tx, globalVariables: GlobalVariables, protocolContracts: ProtocolContracts, proverId: Fr): Promise<PublicTxContext>;
|
|
43
|
+
static create(treesDB: PublicTreesDB, contractsDB: PublicContractsDBInterface, tx: Tx, globalVariables: GlobalVariables, protocolContracts: ProtocolContracts, proverId: Fr, bindings?: LoggerBindings): Promise<PublicTxContext>;
|
|
43
44
|
/**
|
|
44
45
|
* Signal that the entire transaction execution is done.
|
|
45
46
|
* All phases have been processed.
|
|
@@ -74,8 +75,12 @@ export declare class PublicTxContext {
|
|
|
74
75
|
*/
|
|
75
76
|
consumeGas(phase: TxExecutionPhase, gas: Gas): void;
|
|
76
77
|
/**
|
|
77
|
-
* The gasUsed by public and private,
|
|
78
|
-
*
|
|
78
|
+
* The gasUsed by public and private, as if the entire teardown gas limit was consumed.
|
|
79
|
+
*
|
|
80
|
+
* This is intentional: teardown is used for gas accounting and refunds, so the transaction
|
|
81
|
+
* fee must be deterministic _before_ teardown executes. If fees depended on teardown's actual
|
|
82
|
+
* consumption there would be a circular dependency. Billing the full teardown gas limit
|
|
83
|
+
* (set by the user) makes the fee known in advance and available to the teardown function.
|
|
79
84
|
*/
|
|
80
85
|
getTotalGasUsed(): Gas;
|
|
81
86
|
/**
|
|
@@ -119,7 +124,7 @@ declare class PhaseStateManager {
|
|
|
119
124
|
private readonly txStateManager;
|
|
120
125
|
private log;
|
|
121
126
|
private currentlyActiveStateManager;
|
|
122
|
-
constructor(txStateManager: PublicPersistableStateManager);
|
|
127
|
+
constructor(txStateManager: PublicPersistableStateManager, bindings?: LoggerBindings);
|
|
123
128
|
fork(): Promise<void>;
|
|
124
129
|
getActiveStateManager(): PublicPersistableStateManager;
|
|
125
130
|
isForked(): boolean;
|
|
@@ -127,4 +132,4 @@ declare class PhaseStateManager {
|
|
|
127
132
|
discardForkedState(): Promise<void>;
|
|
128
133
|
}
|
|
129
134
|
export {};
|
|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ksR0FBRyxDQUc1QjtJQUVEOzs7T0FHRztJQUNILGlCQUFpQixDQUFDLEtBQUssRUFBRSxnQkFBZ0IsR0FBRyxFQUFFLENBTTdDO0lBRUQ7OztPQUdHO0lBQ0gsT0FBTyxDQUFDLHVCQUF1QjtJQWEvQjs7T0FFRztJQUNVLDhCQUE4QixJQUFJLE9BQU8sQ0FBQyxzQkFBc0IsQ0FBQyxDQXVIN0U7Q0FDRjtBQUVEOzs7Ozs7Ozs7R0FTRztBQUNILGNBQU0saUJBQWlCO0lBTW5CLE9BQU8sQ0FBQyxRQUFRLENBQUMsY0FBYztJQUxqQyxPQUFPLENBQUMsR0FBRyxDQUFTO0lBRXBCLE9BQU8sQ0FBQywyQkFBMkIsQ0FBNEM7SUFFL0UsWUFDbUIsY0FBYyxFQUFFLDZCQUE2QixFQUM5RCxRQUFRLENBQUMsRUFBRSxjQUFjLEVBRzFCO0lBRUssSUFBSSxrQkFJVDtJQUVELHFCQUFxQixrQ0FFcEI7SUFFRCxRQUFRLFlBRVA7SUFFSyxnQkFBZ0Isa0JBTXJCO0lBRUssa0JBQWtCLGtCQU12QjtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_tx_context.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_context.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,EAAE,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"public_tx_context.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_context.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAe,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAGL,sBAAsB,EAEtB,UAAU,EACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAA6B,KAAK,sBAAsB,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M,iBAAiB;IAMnB,OAAO,CAAC,QAAQ,CAAC,cAAc;IALjC,OAAO,CAAC,GAAG,CAAS;IAEpB,OAAO,CAAC,2BAA2B,CAA4C;IAE/E,YACmB,cAAc,EAAE,6BAA6B,EAC9D,QAAQ,CAAC,EAAE,cAAc,EAG1B;IAEK,IAAI,kBAIT;IAED,qBAAqB,kCAEpB;IAED,QAAQ,YAEP;IAEK,gBAAgB,kBAMrB;IAEK,kBAAkB,kBAMvB;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MAX_ENQUEUED_CALLS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX } from '@aztec/constants';
|
|
2
2
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
|
-
import { Fr } from '@aztec/foundation/
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import { AvmAccumulatedData, AvmAccumulatedDataArrayLengths, AvmCircuitPublicInputs, PublicDataWrite, RevertCode } from '@aztec/stdlib/avm';
|
|
6
6
|
import { AllContractDeploymentData } from '@aztec/stdlib/contract';
|
|
@@ -44,7 +44,7 @@ import { getCallRequestsWithCalldataByPhase } from '../utils.js';
|
|
|
44
44
|
/* Entire transaction execution is done. */ halted;
|
|
45
45
|
/* Where did reverts happen (if at all)? */ revertCode;
|
|
46
46
|
/* What caused a revert (if one occurred)? */ revertReason;
|
|
47
|
-
constructor(txHash, state, startTreeSnapshots, globalVariables, protocolContracts, proverId, gasSettings, gasUsedByPrivate, gasAllocatedToPublic, gasAllocatedToPublicTeardown, setupCallRequests, appLogicCallRequests, teardownCallRequests, nonRevertibleContractDeploymentData, revertibleContractDeploymentData, nonRevertibleAccumulatedDataFromPrivate, revertibleAccumulatedDataFromPrivate, feePayer, trace){
|
|
47
|
+
constructor(txHash, state, startTreeSnapshots, globalVariables, protocolContracts, proverId, gasSettings, gasUsedByPrivate, gasAllocatedToPublic, gasAllocatedToPublicTeardown, setupCallRequests, appLogicCallRequests, teardownCallRequests, nonRevertibleContractDeploymentData, revertibleContractDeploymentData, nonRevertibleAccumulatedDataFromPrivate, revertibleAccumulatedDataFromPrivate, feePayer, trace, bindings){
|
|
48
48
|
this.txHash = txHash;
|
|
49
49
|
this.state = state;
|
|
50
50
|
this.startTreeSnapshots = startTreeSnapshots;
|
|
@@ -68,22 +68,22 @@ import { getCallRequestsWithCalldataByPhase } from '../utils.js';
|
|
|
68
68
|
this.teardownGasUsed = Gas.empty();
|
|
69
69
|
this.halted = false;
|
|
70
70
|
this.revertCode = RevertCode.OK;
|
|
71
|
-
this.log = createLogger(`simulator:public_tx_context
|
|
71
|
+
this.log = createLogger(`simulator:public_tx_context`, bindings);
|
|
72
72
|
}
|
|
73
|
-
static async create(treesDB, contractsDB, tx, globalVariables, protocolContracts, proverId) {
|
|
73
|
+
static async create(treesDB, contractsDB, tx, globalVariables, protocolContracts, proverId, bindings) {
|
|
74
74
|
const contractDeploymentData = AllContractDeploymentData.fromTx(tx);
|
|
75
75
|
const nonRevertibleContractDeploymentData = contractDeploymentData.getNonRevertibleContractDeploymentData();
|
|
76
76
|
const revertibleContractDeploymentData = contractDeploymentData.getRevertibleContractDeploymentData();
|
|
77
77
|
const nonRevertibleAccumulatedDataFromPrivate = tx.data.forPublic.nonRevertibleAccumulatedData;
|
|
78
|
-
const trace = new SideEffectTrace();
|
|
78
|
+
const trace = new SideEffectTrace(0, bindings);
|
|
79
79
|
const firstNullifier = nonRevertibleAccumulatedDataFromPrivate.nullifiers[0];
|
|
80
80
|
// Transaction level state manager that will be forked for revertible phases.
|
|
81
|
-
const txStateManager = PublicPersistableStateManager.create(treesDB, contractsDB, trace, firstNullifier, globalVariables.timestamp);
|
|
81
|
+
const txStateManager = PublicPersistableStateManager.create(treesDB, contractsDB, trace, firstNullifier, globalVariables.timestamp, bindings);
|
|
82
82
|
const gasSettings = tx.data.constants.txContext.gasSettings;
|
|
83
83
|
const gasUsedByPrivate = tx.data.gasUsed;
|
|
84
84
|
const gasAllocatedToPublic = gasSettings.gasLimits.sub(gasUsedByPrivate);
|
|
85
85
|
const gasAllocatedToPublicTeardown = gasSettings.teardownGasLimits;
|
|
86
|
-
return new PublicTxContext(tx.getTxHash(), new PhaseStateManager(txStateManager), await txStateManager.getTreeSnapshots(), globalVariables, protocolContracts, proverId, gasSettings, gasUsedByPrivate, gasAllocatedToPublic, gasAllocatedToPublicTeardown, getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.SETUP), getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.APP_LOGIC), getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.TEARDOWN), nonRevertibleContractDeploymentData, revertibleContractDeploymentData, tx.data.forPublic.nonRevertibleAccumulatedData, tx.data.forPublic.revertibleAccumulatedData, tx.data.feePayer, trace);
|
|
86
|
+
return new PublicTxContext(tx.getTxHash(), new PhaseStateManager(txStateManager, bindings), await txStateManager.getTreeSnapshots(), globalVariables, protocolContracts, proverId, gasSettings, gasUsedByPrivate, gasAllocatedToPublic, gasAllocatedToPublicTeardown, getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.SETUP), getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.APP_LOGIC), getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.TEARDOWN), nonRevertibleContractDeploymentData, revertibleContractDeploymentData, tx.data.forPublic.nonRevertibleAccumulatedData, tx.data.forPublic.revertibleAccumulatedData, tx.data.feePayer, trace, bindings);
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
89
|
* Signal that the entire transaction execution is done.
|
|
@@ -106,14 +106,8 @@ import { getCallRequestsWithCalldataByPhase } from '../utils.js';
|
|
|
106
106
|
}
|
|
107
107
|
if (phase === TxExecutionPhase.SETUP) {
|
|
108
108
|
this.log.warn(`Setup phase reverted! The transaction will be thrown out.`);
|
|
109
|
-
} else if (phase === TxExecutionPhase.APP_LOGIC) {
|
|
110
|
-
this.revertCode = RevertCode.
|
|
111
|
-
} else if (phase === TxExecutionPhase.TEARDOWN) {
|
|
112
|
-
if (this.revertCode.equals(RevertCode.APP_LOGIC_REVERTED)) {
|
|
113
|
-
this.revertCode = RevertCode.BOTH_REVERTED;
|
|
114
|
-
} else {
|
|
115
|
-
this.revertCode = RevertCode.TEARDOWN_REVERTED;
|
|
116
|
-
}
|
|
109
|
+
} else if (phase === TxExecutionPhase.APP_LOGIC || phase === TxExecutionPhase.TEARDOWN) {
|
|
110
|
+
this.revertCode = RevertCode.REVERTED;
|
|
117
111
|
}
|
|
118
112
|
}
|
|
119
113
|
/**
|
|
@@ -168,8 +162,12 @@ import { getCallRequestsWithCalldataByPhase } from '../utils.js';
|
|
|
168
162
|
}
|
|
169
163
|
}
|
|
170
164
|
/**
|
|
171
|
-
* The gasUsed by public and private,
|
|
172
|
-
*
|
|
165
|
+
* The gasUsed by public and private, as if the entire teardown gas limit was consumed.
|
|
166
|
+
*
|
|
167
|
+
* This is intentional: teardown is used for gas accounting and refunds, so the transaction
|
|
168
|
+
* fee must be deterministic _before_ teardown executes. If fees depended on teardown's actual
|
|
169
|
+
* consumption there would be a circular dependency. Billing the full teardown gas limit
|
|
170
|
+
* (set by the user) makes the fee known in advance and available to the teardown function.
|
|
173
171
|
*/ getTotalGasUsed() {
|
|
174
172
|
return this.gasUsedByPrivate.add(this.gasUsedByPublic);
|
|
175
173
|
}
|
|
@@ -268,9 +266,9 @@ import { getCallRequestsWithCalldataByPhase } from '../utils.js';
|
|
|
268
266
|
txStateManager;
|
|
269
267
|
log;
|
|
270
268
|
currentlyActiveStateManager;
|
|
271
|
-
constructor(txStateManager){
|
|
269
|
+
constructor(txStateManager, bindings){
|
|
272
270
|
this.txStateManager = txStateManager;
|
|
273
|
-
this.log = createLogger(`simulator:public_phase_state_manager
|
|
271
|
+
this.log = createLogger(`simulator:public_phase_state_manager`, bindings);
|
|
274
272
|
}
|
|
275
273
|
async fork() {
|
|
276
274
|
assert(!this.currentlyActiveStateManager, 'Cannot fork when already forked');
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
2
|
-
import { type Logger } from '@aztec/foundation/log';
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { type Logger, type LoggerBindings } from '@aztec/foundation/log';
|
|
3
3
|
import { PublicSimulatorConfig, PublicTxResult } from '@aztec/stdlib/avm';
|
|
4
4
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
5
|
-
import
|
|
5
|
+
import { Gas } from '@aztec/stdlib/gas';
|
|
6
6
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
7
|
-
import { type GlobalVariables, NestedProcessReturnValues, PublicCallRequestWithCalldata, Tx, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
7
|
+
import { type GlobalVariables, NestedProcessReturnValues, ProtocolContracts, PublicCallRequestWithCalldata, Tx, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
8
8
|
import type { AvmFinalizedCallResult } from '../avm/avm_contract_call_result.js';
|
|
9
9
|
import { type PublicContractsDB } from '../public_db_sources.js';
|
|
10
10
|
import type { PublicPersistableStateManager } from '../state_manager/state_manager.js';
|
|
@@ -22,9 +22,11 @@ export declare class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
|
22
22
|
protected merkleTree: MerkleTreeWriteOperations;
|
|
23
23
|
protected contractsDB: PublicContractsDB;
|
|
24
24
|
protected globalVariables: GlobalVariables;
|
|
25
|
+
protected protocolContracts: ProtocolContracts;
|
|
25
26
|
protected log: Logger;
|
|
26
27
|
protected readonly config: PublicSimulatorConfig;
|
|
27
|
-
|
|
28
|
+
protected readonly bindings?: LoggerBindings;
|
|
29
|
+
constructor(merkleTree: MerkleTreeWriteOperations, contractsDB: PublicContractsDB, globalVariables: GlobalVariables, config?: Partial<PublicSimulatorConfig>, protocolContracts?: ProtocolContracts, bindings?: LoggerBindings);
|
|
28
30
|
/**
|
|
29
31
|
* Simulate a transaction's public portion including all of its phases.
|
|
30
32
|
* @param tx - The transaction to simulate.
|
|
@@ -69,12 +71,16 @@ export declare class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
|
69
71
|
* Throws TxSimRevertibleInsertionsRevert if there is some checked error during revertible insertions.
|
|
70
72
|
* This function checks for the following errors:
|
|
71
73
|
* - NullifierLimitReachedError
|
|
72
|
-
* - NullifierCollisionError
|
|
73
74
|
* - NoteHashLimitReachedError
|
|
74
75
|
* - L2ToL1MessageLimitReachedError
|
|
76
|
+
*
|
|
77
|
+
* Note: NullifierCollisionError is intentionally NOT caught here. A nullifier collision
|
|
78
|
+
* during revertible insertions is unprovable (the nullifier originated from private, so
|
|
79
|
+
* a collision indicates the tx should never have been proposed). It propagates as-is to
|
|
80
|
+
* make the transaction unrecoverable, matching the AVM circuit behavior.
|
|
75
81
|
*/
|
|
76
82
|
protected insertRevertiblesFromPrivate(context: PublicTxContext): Promise<void>;
|
|
77
83
|
private payFee;
|
|
78
84
|
}
|
|
79
85
|
export {};
|
|
80
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
86
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX3R4X3NpbXVsYXRvci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3B1YmxpYy9wdWJsaWNfdHhfc2ltdWxhdG9yL3B1YmxpY190eF9zaW11bGF0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sRUFBRSxLQUFLLE1BQU0sRUFBRSxLQUFLLGNBQWMsRUFBZ0IsTUFBTSx1QkFBdUIsQ0FBQztBQUd2RixPQUFPLEV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ixDQUFDLENBK0JqQztJQUVEOzs7Ozs7Ozs7Ozs7T0FZRztJQUNILFVBQWdCLDRCQUE0QixDQUMxQyxZQUFZLEVBQUUsNkJBQTZCLEVBQzNDLEVBQUUsT0FBTyxFQUFFLFFBQVEsRUFBRSxFQUFFLDZCQUE2QixFQUNwRCxZQUFZLEVBQUUsR0FBRyxFQUNqQixjQUFjLEVBQUUsRUFBRSxFQUNsQixNQUFNLEVBQUUsTUFBTSxHQUNiLE9BQU8sQ0FBQyxzQkFBc0IsQ0FBQyxDQXFCakM7SUFFRDs7T0FFRztJQUNILFVBQWdCLCtCQUErQixDQUFDLE9BQU8sRUFBRSxlQUFlLGlCQXlCdkU7SUFFRDs7Ozs7Ozs7Ozs7O09BWUc7SUFDSCxVQUFnQiw0QkFBNEIsQ0FBQyxPQUFPLEVBQUUsZUFBZSxpQkEwRXBFO1lBRWEsTUFBTTtDQW1DckIifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_simulator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_simulator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAGvF,OAAO,EAAgC,qBAAqB,EAAkB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EACL,KAAK,eAAe,EACpB,yBAAyB,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cAAc,CAAC,CA4IrD;IAED,SAAS,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,qCAE7B;IAED;;;;OAIG;IACH,UAAgB,aAAa,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAmCxG;IAED;;;;;;OAMG;IACH,UAAgB,oBAAoB,CAClC,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,6BAA6B,GACzC,OAAO,CAAC,sBAAsB,CAAC,CA+BjC;IAED;;;;;;;;;;;;OAYG;IACH,UAAgB,4BAA4B,CAC1C,YAAY,EAAE,6BAA6B,EAC3C,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,6BAA6B,EACpD,YAAY,EAAE,GAAG,EACjB,cAAc,EAAE,EAAE,EAClB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,sBAAsB,CAAC,CAqBjC;IAED;;OAEG;IACH,UAAgB,+BAA+B,CAAC,OAAO,EAAE,eAAe,iBAyBvE;IAED;;;;;;;;;;;;OAYG;IACH,UAAgB,4BAA4B,CAAC,OAAO,EAAE,eAAe,iBA0EpE;YAEa,MAAM;CAmCrB"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MAX_PROCESSABLE_L2_GAS } from '@aztec/constants';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { ProtocolContractAddress, ProtocolContractsList } from '@aztec/protocol-contracts';
|
|
4
4
|
import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
5
|
-
import { AvmExecutionHints, AvmTxHint, PublicSimulatorConfig, PublicTxResult } from '@aztec/stdlib/avm';
|
|
5
|
+
import { AvmExecutionHints, AvmTxHint, PublicSimulatorConfig, PublicTxEffect, PublicTxResult } from '@aztec/stdlib/avm';
|
|
6
6
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
7
7
|
import { NestedProcessReturnValues, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
8
8
|
import { strict as assert } from 'assert';
|
|
9
|
+
import { CallDataArray } from '../avm/calldata.js';
|
|
9
10
|
import { AvmSimulator } from '../avm/index.js';
|
|
10
11
|
import { getPublicFunctionDebugName } from '../debug_fn_name.js';
|
|
11
12
|
import { HintingMerkleWriteOperations, HintingPublicContractsDB } from '../hinting_db_sources.js';
|
|
12
13
|
import { PublicTreesDB } from '../public_db_sources.js';
|
|
13
|
-
import { L2ToL1MessageLimitReachedError, NoteHashLimitReachedError,
|
|
14
|
+
import { L2ToL1MessageLimitReachedError, NoteHashLimitReachedError, NullifierLimitReachedError } from '../side_effect_errors.js';
|
|
14
15
|
import { PublicTxContext } from './public_tx_context.js';
|
|
15
16
|
// The errors below are only thrown here in the public tx simulator,
|
|
16
17
|
// and only during revertible phases (revertible insertions, app logic and teardown).
|
|
@@ -44,14 +45,18 @@ export class PublicTxSimulator {
|
|
|
44
45
|
merkleTree;
|
|
45
46
|
contractsDB;
|
|
46
47
|
globalVariables;
|
|
48
|
+
protocolContracts;
|
|
47
49
|
log;
|
|
48
50
|
config;
|
|
49
|
-
|
|
51
|
+
bindings;
|
|
52
|
+
constructor(merkleTree, contractsDB, globalVariables, config, protocolContracts = ProtocolContractsList, bindings){
|
|
50
53
|
this.merkleTree = merkleTree;
|
|
51
54
|
this.contractsDB = contractsDB;
|
|
52
55
|
this.globalVariables = globalVariables;
|
|
56
|
+
this.protocolContracts = protocolContracts;
|
|
53
57
|
this.config = PublicSimulatorConfig.from(config ?? {});
|
|
54
|
-
this.
|
|
58
|
+
this.bindings = bindings;
|
|
59
|
+
this.log = createLogger(`simulator:public_tx_simulator`, bindings);
|
|
55
60
|
}
|
|
56
61
|
/**
|
|
57
62
|
* Simulate a transaction's public portion including all of its phases.
|
|
@@ -63,11 +68,11 @@ export class PublicTxSimulator {
|
|
|
63
68
|
txHash
|
|
64
69
|
});
|
|
65
70
|
// Create hinting DBs.
|
|
66
|
-
const hints = new AvmExecutionHints(this.globalVariables, AvmTxHint.fromTx(tx, this.globalVariables.gasFees),
|
|
71
|
+
const hints = new AvmExecutionHints(this.globalVariables, AvmTxHint.fromTx(tx, this.globalVariables.gasFees), this.protocolContracts);
|
|
67
72
|
const hintingMerkleTree = await HintingMerkleWriteOperations.create(this.merkleTree, hints);
|
|
68
73
|
const hintingTreesDB = new PublicTreesDB(hintingMerkleTree);
|
|
69
74
|
const hintingContractsDB = new HintingPublicContractsDB(this.contractsDB, hints);
|
|
70
|
-
const context = await PublicTxContext.create(hintingTreesDB, hintingContractsDB, tx, this.globalVariables,
|
|
75
|
+
const context = await PublicTxContext.create(hintingTreesDB, hintingContractsDB, tx, this.globalVariables, this.protocolContracts, this.config.proverId, this.bindings);
|
|
71
76
|
// This will throw if there is a nullifier collision.
|
|
72
77
|
// In that case the transaction will be thrown out.
|
|
73
78
|
await this.insertNonRevertiblesFromPrivate(context);
|
|
@@ -77,7 +82,7 @@ export class PublicTxSimulator {
|
|
|
77
82
|
// In that case the transaction will be thrown out.
|
|
78
83
|
const setupResult = await this.simulatePhase(TxExecutionPhase.SETUP, context);
|
|
79
84
|
if (setupResult.reverted) {
|
|
80
|
-
throw new Error(`
|
|
85
|
+
throw new Error(`[SETUP] UNRECOVERABLE ERROR! The transaction will be thrown out. ${setupResult.revertReason?.message}`);
|
|
81
86
|
}
|
|
82
87
|
processedPhases.push(setupResult);
|
|
83
88
|
}
|
|
@@ -85,7 +90,8 @@ export class PublicTxSimulator {
|
|
|
85
90
|
await context.state.fork();
|
|
86
91
|
hintingContractsDB.createCheckpoint();
|
|
87
92
|
try {
|
|
88
|
-
// This
|
|
93
|
+
// This may throw: a side-effect limit error triggers a soft revert (caught below), while a
|
|
94
|
+
// nullifier collision is unrecoverable and propagates out of simulate() to throw out the tx.
|
|
89
95
|
await this.insertRevertiblesFromPrivate(context);
|
|
90
96
|
// Only proceed with app logic if there was no revert during revertible insertion.
|
|
91
97
|
if (context.hasPhase(TxExecutionPhase.APP_LOGIC)) {
|
|
@@ -132,18 +138,24 @@ export class PublicTxSimulator {
|
|
|
132
138
|
}
|
|
133
139
|
context.halt();
|
|
134
140
|
// Such transactions should be filtered by GasTxValidator.
|
|
135
|
-
assert(context.getActualGasUsed().l2Gas <=
|
|
141
|
+
assert(context.getActualGasUsed().l2Gas <= MAX_PROCESSABLE_L2_GAS, `Transaction consumes ${context.getActualGasUsed().l2Gas} L2 gas, which exceeds the maximum processable gas of ${MAX_PROCESSABLE_L2_GAS}`);
|
|
136
142
|
await this.payFee(context);
|
|
137
143
|
const publicInputs = await context.generateAvmCircuitPublicInputs();
|
|
138
144
|
const revertCode = context.getFinalRevertCode();
|
|
139
|
-
// We only return the app logic phase information.
|
|
145
|
+
// We only return the app logic phase information, and only 1 per phase.
|
|
140
146
|
const appLogicReturnValues = processedPhases.find(({ phase })=>phase === TxExecutionPhase.APP_LOGIC)?.returnValues ?? [];
|
|
147
|
+
// TODO(fcarreiro): This is a temporary backwards compatibility layer until we migrate to the C++ simulator.
|
|
148
|
+
if (context.revertReason !== undefined) {
|
|
149
|
+
appLogicReturnValues.revertReason = context.revertReason;
|
|
150
|
+
}
|
|
151
|
+
// Create PublicTxEffect from PublicInputs.
|
|
152
|
+
const publicTxEffect = new PublicTxEffect(publicInputs.transactionFee, publicInputs.accumulatedData.noteHashes.filter((h)=>!h.isEmpty()), publicInputs.accumulatedData.nullifiers.filter((n)=>!n.isEmpty()), publicInputs.accumulatedData.l2ToL1Msgs.filter((m)=>!m.isEmpty()), publicInputs.accumulatedData.publicLogs.toLogs(), publicInputs.accumulatedData.publicDataWrites.filter((w)=>!w.isEmpty()));
|
|
141
153
|
return new PublicTxResult(/*gasUsed=*/ {
|
|
142
154
|
totalGas: context.getActualGasUsed(),
|
|
143
155
|
teardownGas: context.teardownGasUsed,
|
|
144
156
|
publicGas: context.getActualPublicGasUsed(),
|
|
145
157
|
billedGas: context.getTotalGasUsed()
|
|
146
|
-
}, /*revertCode=*/ revertCode, /*
|
|
158
|
+
}, /*revertCode=*/ revertCode, /*publicTxEffect=*/ publicTxEffect, /*callStackMetadata=*/ appLogicReturnValues, /*logs=*/ context.state.getActiveStateManager().getLogs(), /*hints=*/ hints, /*publicInputs=*/ publicInputs);
|
|
147
159
|
}
|
|
148
160
|
computeTxHash(tx) {
|
|
149
161
|
return tx.getTxHash();
|
|
@@ -168,7 +180,7 @@ export class PublicTxSimulator {
|
|
|
168
180
|
}
|
|
169
181
|
const callRequest = callRequests[i];
|
|
170
182
|
const enqueuedCallResult = await this.simulateEnqueuedCall(phase, context, callRequest);
|
|
171
|
-
returnValues.push(new NestedProcessReturnValues(enqueuedCallResult.output));
|
|
183
|
+
returnValues.push(new NestedProcessReturnValues(enqueuedCallResult.output.bestEffortReadAll()));
|
|
172
184
|
if (enqueuedCallResult.reverted) {
|
|
173
185
|
reverted = true;
|
|
174
186
|
revertReason = enqueuedCallResult.revertReason;
|
|
@@ -190,14 +202,14 @@ export class PublicTxSimulator {
|
|
|
190
202
|
*/ async simulateEnqueuedCall(phase, context, callRequest) {
|
|
191
203
|
const stateManager = context.state.getActiveStateManager();
|
|
192
204
|
const contractAddress = callRequest.request.contractAddress;
|
|
193
|
-
const fnName = await getPublicFunctionDebugName(this.contractsDB, contractAddress, callRequest.calldata);
|
|
205
|
+
const fnName = await getPublicFunctionDebugName(this.contractsDB, contractAddress, new CallDataArray(callRequest.calldata));
|
|
194
206
|
const allocatedGas = context.getGasLeftAtPhase(phase);
|
|
195
207
|
const result = await this.simulateEnqueuedCallInternal(stateManager, callRequest, allocatedGas, /*transactionFee=*/ context.getTransactionFee(phase), fnName);
|
|
196
208
|
const gasUsed = allocatedGas.sub(result.gasLeft); // by enqueued call
|
|
197
209
|
context.consumeGas(phase, gasUsed);
|
|
198
210
|
this.log.debug(`Simulated enqueued public call (${fnName}) consumed ${gasUsed.l2Gas} L2 gas ending with ${result.gasLeft.l2Gas} L2 gas left.`);
|
|
199
211
|
if (result.reverted) {
|
|
200
|
-
const culprit = `${contractAddress}:${
|
|
212
|
+
const culprit = `${contractAddress}:${fnName}`;
|
|
201
213
|
context.revert(phase, result.revertReason, culprit);
|
|
202
214
|
}
|
|
203
215
|
return result;
|
|
@@ -218,7 +230,7 @@ export class PublicTxSimulator {
|
|
|
218
230
|
const address = request.contractAddress;
|
|
219
231
|
const sender = request.msgSender;
|
|
220
232
|
this.log.debug(`Executing enqueued public call to external function ${fnName}@${address} with ${allocatedGas.l2Gas} allocated L2 gas.`);
|
|
221
|
-
const simulator = await AvmSimulator.create(stateManager, address, sender, transactionFee, this.globalVariables, request.isStaticCall, calldata, allocatedGas, this.config);
|
|
233
|
+
const simulator = await AvmSimulator.create(stateManager, address, sender, transactionFee, this.globalVariables, request.isStaticCall, new CallDataArray(calldata), allocatedGas, this.config);
|
|
222
234
|
const avmCallResult = await simulator.execute();
|
|
223
235
|
return avmCallResult.finalize();
|
|
224
236
|
}
|
|
@@ -244,16 +256,20 @@ export class PublicTxSimulator {
|
|
|
244
256
|
// However, things work as expected because later calls to getters on the hintingContractsDB
|
|
245
257
|
// will pick up the new contracts and will generate the necessary hints.
|
|
246
258
|
// So, a consumer of the hints will always see the new contracts.
|
|
247
|
-
|
|
259
|
+
this.contractsDB.addContracts(context.nonRevertibleContractDeploymentData);
|
|
248
260
|
}
|
|
249
261
|
/**
|
|
250
262
|
* Insert the revertible accumulated data from private into the public state.
|
|
251
263
|
* Throws TxSimRevertibleInsertionsRevert if there is some checked error during revertible insertions.
|
|
252
264
|
* This function checks for the following errors:
|
|
253
265
|
* - NullifierLimitReachedError
|
|
254
|
-
* - NullifierCollisionError
|
|
255
266
|
* - NoteHashLimitReachedError
|
|
256
267
|
* - L2ToL1MessageLimitReachedError
|
|
268
|
+
*
|
|
269
|
+
* Note: NullifierCollisionError is intentionally NOT caught here. A nullifier collision
|
|
270
|
+
* during revertible insertions is unprovable (the nullifier originated from private, so
|
|
271
|
+
* a collision indicates the tx should never have been proposed). It propagates as-is to
|
|
272
|
+
* make the transaction unrecoverable, matching the AVM circuit behavior.
|
|
257
273
|
*/ async insertRevertiblesFromPrivate(context) {
|
|
258
274
|
const stateManager = context.state.getActiveStateManager();
|
|
259
275
|
try {
|
|
@@ -261,11 +277,11 @@ export class PublicTxSimulator {
|
|
|
261
277
|
await stateManager.writeSiloedNullifier(siloedNullifier);
|
|
262
278
|
}
|
|
263
279
|
} catch (e) {
|
|
264
|
-
if (e instanceof NullifierLimitReachedError
|
|
280
|
+
if (e instanceof NullifierLimitReachedError) {
|
|
265
281
|
context.revert(TxExecutionPhase.APP_LOGIC, new SimulationError(`Error encountered when inserting revertible nullifiers from private.\nDetails: ${e.message}`, []));
|
|
266
282
|
throw new TxSimRevertibleInsertionsRevert();
|
|
267
283
|
} else {
|
|
268
|
-
// Unchecked/unknown error - re-throw as-is
|
|
284
|
+
// Unchecked/unknown error or NullifierCollisionError (unrecoverable) - re-throw as-is
|
|
269
285
|
throw e;
|
|
270
286
|
}
|
|
271
287
|
}
|
|
@@ -305,7 +321,7 @@ export class PublicTxSimulator {
|
|
|
305
321
|
// However, things work as expected because later calls to getters on the hintingContractsDB
|
|
306
322
|
// will pick up the new contracts and will generate the necessary hints.
|
|
307
323
|
// So, a consumer of the hints will always see the new contracts.
|
|
308
|
-
|
|
324
|
+
this.contractsDB.addContracts(context.revertibleContractDeploymentData);
|
|
309
325
|
}
|
|
310
326
|
async payFee(context) {
|
|
311
327
|
const txFee = context.getTransactionFee(TxExecutionPhase.TEARDOWN);
|