@aztec/simulator 0.0.1-commit.24de95ac → 0.0.1-commit.27d773e65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dest/client.d.ts +1 -1
- package/dest/common/errors.d.ts +2 -2
- package/dest/common/errors.d.ts.map +1 -1
- package/dest/common/index.d.ts +1 -1
- package/dest/common/stats/index.d.ts +1 -1
- package/dest/common/stats/stats.d.ts +1 -1
- package/dest/private/acvm/acvm.d.ts +4 -2
- package/dest/private/acvm/acvm.d.ts.map +1 -1
- package/dest/private/acvm/acvm.js +4 -3
- package/dest/private/acvm/acvm_types.d.ts +1 -1
- package/dest/private/acvm/deserialize.d.ts +2 -2
- package/dest/private/acvm/deserialize.d.ts.map +1 -1
- package/dest/private/acvm/deserialize.js +1 -1
- package/dest/private/acvm/index.d.ts +1 -1
- package/dest/private/acvm/serialize.d.ts +2 -2
- package/dest/private/acvm/serialize.d.ts.map +1 -1
- package/dest/private/acvm/serialize.js +1 -1
- package/dest/private/acvm_native.d.ts +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/acvm_wasm_with_blobs.d.ts +1 -1
- package/dest/private/acvm_wasm_with_blobs.d.ts.map +1 -1
- package/dest/private/circuit_recording/circuit_recorder.d.ts +4 -3
- package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/circuit_recorder.js +21 -18
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts +3 -2
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/file_circuit_recorder.js +2 -2
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +7 -2
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/memory_circuit_recorder.js +4 -4
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts +1 -1
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts.map +1 -1
- package/dest/private/circuit_simulator.d.ts +1 -1
- package/dest/private/factory.d.ts +3 -3
- package/dest/private/factory.d.ts.map +1 -1
- package/dest/private/factory.js +7 -4
- package/dest/public/avm/avm_context.d.ts +3 -3
- package/dest/public/avm/avm_context.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.d.ts +6 -6
- package/dest/public/avm/avm_contract_call_result.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.js +3 -3
- package/dest/public/avm/avm_execution_environment.d.ts +9 -8
- package/dest/public/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/public/avm/avm_execution_environment.js +5 -8
- package/dest/public/avm/avm_gas.d.ts +2 -2
- package/dest/public/avm/avm_gas.d.ts.map +1 -1
- package/dest/public/avm/avm_gas.js +3 -3
- package/dest/public/avm/avm_machine_state.d.ts +7 -6
- package/dest/public/avm/avm_machine_state.d.ts.map +1 -1
- package/dest/public/avm/avm_machine_state.js +3 -2
- package/dest/public/avm/avm_memory_types.d.ts +14 -14
- package/dest/public/avm/avm_memory_types.d.ts.map +1 -1
- package/dest/public/avm/avm_memory_types.js +4 -1
- package/dest/public/avm/avm_simulator.d.ts +5 -3
- package/dest/public/avm/avm_simulator.d.ts.map +1 -1
- package/dest/public/avm/avm_simulator.js +13 -11
- package/dest/public/avm/avm_simulator_interface.d.ts +1 -1
- package/dest/public/avm/calldata.d.ts +51 -0
- package/dest/public/avm/calldata.d.ts.map +1 -0
- package/dest/public/avm/calldata.js +63 -0
- package/dest/public/avm/errors.d.ts +8 -2
- package/dest/public/avm/errors.d.ts.map +1 -1
- package/dest/public/avm/errors.js +14 -2
- package/dest/public/avm/fixtures/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 +15 -5
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +2 -2
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/base_avm_simulation_tester.js +1 -1
- package/dest/public/avm/fixtures/initializers.d.ts +2 -3
- package/dest/public/avm/fixtures/initializers.d.ts.map +1 -1
- package/dest/public/avm/fixtures/initializers.js +8 -5
- package/dest/public/avm/fixtures/utils.d.ts +4 -3
- package/dest/public/avm/fixtures/utils.d.ts.map +1 -1
- package/dest/public/avm/fixtures/utils.js +3 -2
- package/dest/public/avm/index.d.ts +1 -1
- package/dest/public/avm/opcodes/accrued_substate.d.ts +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.d.ts +1 -1
- package/dest/public/avm/opcodes/addressing_mode.d.ts.map +1 -1
- package/dest/public/avm/opcodes/addressing_mode.js +2 -2
- package/dest/public/avm/opcodes/arithmetic.d.ts +3 -1
- package/dest/public/avm/opcodes/arithmetic.d.ts.map +1 -1
- package/dest/public/avm/opcodes/arithmetic.js +12 -2
- package/dest/public/avm/opcodes/bitwise.d.ts +3 -3
- package/dest/public/avm/opcodes/bitwise.d.ts.map +1 -1
- package/dest/public/avm/opcodes/bitwise.js +5 -5
- package/dest/public/avm/opcodes/comparators.d.ts +1 -1
- package/dest/public/avm/opcodes/comparators.d.ts.map +1 -1
- package/dest/public/avm/opcodes/comparators.js +1 -1
- package/dest/public/avm/opcodes/contract.d.ts +3 -3
- package/dest/public/avm/opcodes/contract.d.ts.map +1 -1
- package/dest/public/avm/opcodes/contract.js +8 -8
- package/dest/public/avm/opcodes/control_flow.d.ts +3 -3
- package/dest/public/avm/opcodes/control_flow.d.ts.map +1 -1
- package/dest/public/avm/opcodes/control_flow.js +4 -4
- package/dest/public/avm/opcodes/conversion.d.ts +3 -3
- package/dest/public/avm/opcodes/conversion.d.ts.map +1 -1
- package/dest/public/avm/opcodes/conversion.js +4 -4
- package/dest/public/avm/opcodes/ec_add.d.ts +3 -3
- package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -1
- package/dest/public/avm/opcodes/ec_add.js +17 -8
- package/dest/public/avm/opcodes/environment_getters.d.ts +5 -5
- package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/public/avm/opcodes/environment_getters.js +6 -6
- package/dest/public/avm/opcodes/external_calls.d.ts +9 -9
- package/dest/public/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/public/avm/opcodes/external_calls.js +23 -22
- package/dest/public/avm/opcodes/hashing.d.ts +7 -7
- package/dest/public/avm/opcodes/hashing.d.ts.map +1 -1
- package/dest/public/avm/opcodes/hashing.js +21 -16
- package/dest/public/avm/opcodes/index.d.ts +1 -1
- package/dest/public/avm/opcodes/instruction.d.ts +2 -2
- package/dest/public/avm/opcodes/instruction.d.ts.map +1 -1
- package/dest/public/avm/opcodes/instruction_impl.d.ts +4 -4
- package/dest/public/avm/opcodes/instruction_impl.d.ts.map +1 -1
- package/dest/public/avm/opcodes/instruction_impl.js +4 -4
- package/dest/public/avm/opcodes/memory.d.ts +13 -13
- package/dest/public/avm/opcodes/memory.d.ts.map +1 -1
- package/dest/public/avm/opcodes/memory.js +26 -26
- package/dest/public/avm/opcodes/misc.d.ts +3 -3
- package/dest/public/avm/opcodes/misc.d.ts.map +1 -1
- package/dest/public/avm/opcodes/misc.js +8 -8
- package/dest/public/avm/opcodes/storage.d.ts +14 -13
- package/dest/public/avm/opcodes/storage.d.ts.map +1 -1
- package/dest/public/avm/opcodes/storage.js +34 -24
- package/dest/public/avm/revert_reason.d.ts +2 -2
- package/dest/public/avm/revert_reason.d.ts.map +1 -1
- package/dest/public/avm/revert_reason.js +3 -2
- package/dest/public/avm/serialization/buffer_cursor.d.ts +1 -1
- package/dest/public/avm/serialization/buffer_cursor.d.ts.map +1 -1
- package/dest/public/avm/serialization/bytecode_serialization.d.ts +1 -1
- package/dest/public/avm/serialization/bytecode_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/bytecode_serialization.js +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 +16 -0
- package/dest/public/contracts_db_checkpoint.d.ts.map +1 -0
- package/dest/public/contracts_db_checkpoint.js +30 -0
- package/dest/public/db_interfaces.d.ts +14 -2
- package/dest/public/db_interfaces.d.ts.map +1 -1
- package/dest/public/debug_fn_name.d.ts +16 -3
- package/dest/public/debug_fn_name.d.ts.map +1 -1
- package/dest/public/debug_fn_name.js +31 -3
- package/dest/public/executor_metrics.d.ts +3 -2
- package/dest/public/executor_metrics.d.ts.map +1 -1
- package/dest/public/executor_metrics.js +13 -34
- package/dest/public/executor_metrics_interface.d.ts +3 -2
- package/dest/public/executor_metrics_interface.d.ts.map +1 -1
- package/dest/public/fixtures/amm_test.d.ts +1 -1
- package/dest/public/fixtures/amm_test.js +4 -4
- package/dest/public/fixtures/bulk_test.d.ts +3 -3
- package/dest/public/fixtures/bulk_test.d.ts.map +1 -1
- package/dest/public/fixtures/bulk_test.js +5 -69
- package/dest/public/fixtures/custom_bytecode_tester.d.ts +29 -7
- package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -1
- package/dest/public/fixtures/custom_bytecode_tester.js +36 -12
- package/dest/public/fixtures/custom_bytecode_tests.d.ts +11 -8
- package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -1
- package/dest/public/fixtures/custom_bytecode_tests.js +83 -18
- package/dest/public/fixtures/index.d.ts +4 -2
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +3 -1
- package/dest/public/fixtures/minimal_public_tx.d.ts +2 -8
- package/dest/public/fixtures/minimal_public_tx.d.ts.map +1 -1
- package/dest/public/fixtures/minimal_public_tx.js +6 -16
- package/dest/public/fixtures/opcode_spammer.d.ts +122 -0
- package/dest/public/fixtures/opcode_spammer.d.ts.map +1 -0
- package/dest/public/fixtures/opcode_spammer.js +1653 -0
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +24 -6
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +89 -21
- package/dest/public/fixtures/simple_contract_data_source.d.ts +5 -4
- package/dest/public/fixtures/simple_contract_data_source.d.ts.map +1 -1
- package/dest/public/fixtures/simple_contract_data_source.js +4 -4
- package/dest/public/fixtures/token_test.d.ts +6 -2
- package/dest/public/fixtures/token_test.d.ts.map +1 -1
- package/dest/public/fixtures/token_test.js +13 -12
- package/dest/public/fixtures/utils.d.ts +2 -2
- package/dest/public/fixtures/utils.d.ts.map +1 -1
- package/dest/public/fixtures/utils.js +8 -7
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts +60 -0
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts.map +1 -0
- package/dest/public/fuzzing/avm_fuzzer_simulator.js +171 -0
- package/dest/public/fuzzing/avm_simulator_bin.d.ts +2 -0
- package/dest/public/fuzzing/avm_simulator_bin.d.ts.map +1 -0
- package/dest/public/fuzzing/avm_simulator_bin.js +118 -0
- package/dest/public/hinting_db_sources.d.ts +14 -4
- package/dest/public/hinting_db_sources.d.ts.map +1 -1
- package/dest/public/hinting_db_sources.js +71 -13
- package/dest/public/index.d.ts +3 -2
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +1 -1
- package/dest/public/public_db_sources.d.ts +25 -65
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +78 -135
- package/dest/public/public_errors.d.ts +1 -1
- package/dest/public/public_errors.d.ts.map +1 -1
- package/dest/public/public_processor/guarded_merkle_tree.d.ts +6 -4
- package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
- package/dest/public/public_processor/guarded_merkle_tree.js +5 -0
- package/dest/public/public_processor/public_processor.d.ts +17 -20
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +477 -72
- package/dest/public/public_processor/public_processor_metrics.d.ts +2 -2
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor_metrics.js +28 -45
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +19 -0
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +98 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +35 -23
- 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 +95 -53
- 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 +5 -1
- package/dest/public/public_tx_simulator/index.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/index.js +3 -0
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +14 -7
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.js +5 -5
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +8 -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 +17 -9
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +15 -33
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +118 -130
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts +25 -2
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts +4 -4
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.js +395 -19
- package/dest/public/side_effect_errors.d.ts +1 -1
- package/dest/public/side_effect_errors.d.ts.map +1 -1
- package/dest/public/side_effect_trace.d.ts +5 -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 +3 -4
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
- package/dest/public/state_manager/index.d.ts +1 -1
- package/dest/public/state_manager/nullifiers.d.ts +2 -2
- package/dest/public/state_manager/nullifiers.d.ts.map +1 -1
- package/dest/public/state_manager/public_storage.d.ts +2 -2
- package/dest/public/state_manager/public_storage.d.ts.map +1 -1
- package/dest/public/state_manager/public_storage.js +1 -1
- package/dest/public/state_manager/state_manager.d.ts +16 -12
- package/dest/public/state_manager/state_manager.d.ts.map +1 -1
- package/dest/public/state_manager/state_manager.js +21 -10
- package/dest/public/test_executor_metrics.d.ts +11 -4
- package/dest/public/test_executor_metrics.d.ts.map +1 -1
- package/dest/public/test_executor_metrics.js +29 -6
- package/dest/public/unique_class_ids.d.ts +1 -1
- package/dest/public/unique_class_ids.d.ts.map +1 -1
- package/dest/public/utils.d.ts +1 -1
- package/dest/server.d.ts +1 -1
- package/dest/testing.d.ts +1 -1
- package/package.json +21 -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 +22 -19
- package/src/private/circuit_recording/file_circuit_recorder.ts +7 -2
- package/src/private/circuit_recording/memory_circuit_recorder.ts +6 -4
- package/src/private/factory.ts +7 -4
- package/src/public/avm/avm_context.ts +2 -2
- package/src/public/avm/avm_contract_call_result.ts +8 -6
- package/src/public/avm/avm_execution_environment.ts +13 -10
- 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 +19 -14
- package/src/public/avm/calldata.ts +100 -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 +18 -4
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +1 -1
- package/src/public/avm/fixtures/initializers.ts +10 -11
- package/src/public/avm/fixtures/utils.ts +3 -2
- package/src/public/avm/opcodes/accrued_substate.ts +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 +17 -15
- package/src/public/avm/opcodes/hashing.ts +16 -10
- package/src/public/avm/opcodes/instruction_impl.ts +2 -2
- package/src/public/avm/opcodes/memory.ts +20 -20
- package/src/public/avm/opcodes/misc.ts +6 -6
- package/src/public/avm/opcodes/storage.ts +30 -22
- package/src/public/avm/revert_reason.ts +6 -3
- package/src/public/avm/serialization/bytecode_serialization.ts +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 +41 -0
- package/src/public/db_interfaces.ts +16 -1
- package/src/public/debug_fn_name.ts +39 -5
- package/src/public/executor_metrics.ts +11 -34
- package/src/public/executor_metrics_interface.ts +2 -1
- package/src/public/fixtures/amm_test.ts +4 -4
- package/src/public/fixtures/bulk_test.ts +9 -9
- package/src/public/fixtures/custom_bytecode_tester.ts +54 -20
- package/src/public/fixtures/custom_bytecode_tests.ts +111 -18
- package/src/public/fixtures/index.ts +7 -1
- package/src/public/fixtures/minimal_public_tx.ts +7 -17
- package/src/public/fixtures/opcode_spammer.ts +1717 -0
- package/src/public/fixtures/public_tx_simulation_tester.ts +116 -21
- package/src/public/fixtures/simple_contract_data_source.ts +8 -9
- package/src/public/fixtures/token_test.ts +18 -10
- package/src/public/fixtures/utils.ts +6 -7
- package/src/public/fuzzing/avm_fuzzer_simulator.ts +288 -0
- package/src/public/fuzzing/avm_simulator_bin.ts +175 -0
- package/src/public/hinting_db_sources.ts +112 -10
- package/src/public/index.ts +6 -4
- package/src/public/public_db_sources.ts +107 -176
- package/src/public/public_processor/guarded_merkle_tree.ts +8 -3
- package/src/public/public_processor/public_processor.ts +124 -75
- package/src/public/public_processor/public_processor_metrics.ts +16 -44
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +124 -0
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +141 -59
- 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 +4 -0
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +10 -14
- package/src/public/public_tx_simulator/public_tx_context.ts +22 -9
- package/src/public/public_tx_simulator/public_tx_simulator.ts +177 -198
- package/src/public/public_tx_simulator/public_tx_simulator_interface.ts +24 -2
- package/src/public/public_tx_simulator/telemetry_public_tx_simulator.ts +3 -3
- package/src/public/side_effect_trace.ts +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 +35 -26
- package/src/public/test_executor_metrics.ts +34 -8
- package/dest/public/tx_contract_cache.d.ts +0 -41
- package/dest/public/tx_contract_cache.d.ts.map +0 -1
- package/dest/public/tx_contract_cache.js +0 -49
- package/src/public/tx_contract_cache.ts +0 -69
|
@@ -1,8 +1,9 @@
|
|
|
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
|
+
import { AllContractDeploymentData } from '@aztec/stdlib/contract';
|
|
6
7
|
import { computeEffectiveGasFees, computeTransactionFee } from '@aztec/stdlib/fees';
|
|
7
8
|
import { Gas } from '@aztec/stdlib/gas';
|
|
8
9
|
import { PrivateToAvmAccumulatedData, PrivateToAvmAccumulatedDataArrayLengths, PublicCallRequest, PublicCallRequestArrayLengths, countAccumulatedItems } from '@aztec/stdlib/kernel';
|
|
@@ -31,6 +32,8 @@ import { getCallRequestsWithCalldataByPhase } from '../utils.js';
|
|
|
31
32
|
setupCallRequests;
|
|
32
33
|
appLogicCallRequests;
|
|
33
34
|
teardownCallRequests;
|
|
35
|
+
nonRevertibleContractDeploymentData;
|
|
36
|
+
revertibleContractDeploymentData;
|
|
34
37
|
nonRevertibleAccumulatedDataFromPrivate;
|
|
35
38
|
revertibleAccumulatedDataFromPrivate;
|
|
36
39
|
feePayer;
|
|
@@ -41,7 +44,7 @@ import { getCallRequestsWithCalldataByPhase } from '../utils.js';
|
|
|
41
44
|
/* Entire transaction execution is done. */ halted;
|
|
42
45
|
/* Where did reverts happen (if at all)? */ revertCode;
|
|
43
46
|
/* What caused a revert (if one occurred)? */ revertReason;
|
|
44
|
-
constructor(txHash, state, startTreeSnapshots, globalVariables, protocolContracts, proverId, gasSettings, gasUsedByPrivate, gasAllocatedToPublic, gasAllocatedToPublicTeardown, setupCallRequests, appLogicCallRequests, teardownCallRequests, 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){
|
|
45
48
|
this.txHash = txHash;
|
|
46
49
|
this.state = state;
|
|
47
50
|
this.startTreeSnapshots = startTreeSnapshots;
|
|
@@ -55,6 +58,8 @@ import { getCallRequestsWithCalldataByPhase } from '../utils.js';
|
|
|
55
58
|
this.setupCallRequests = setupCallRequests;
|
|
56
59
|
this.appLogicCallRequests = appLogicCallRequests;
|
|
57
60
|
this.teardownCallRequests = teardownCallRequests;
|
|
61
|
+
this.nonRevertibleContractDeploymentData = nonRevertibleContractDeploymentData;
|
|
62
|
+
this.revertibleContractDeploymentData = revertibleContractDeploymentData;
|
|
58
63
|
this.nonRevertibleAccumulatedDataFromPrivate = nonRevertibleAccumulatedDataFromPrivate;
|
|
59
64
|
this.revertibleAccumulatedDataFromPrivate = revertibleAccumulatedDataFromPrivate;
|
|
60
65
|
this.feePayer = feePayer;
|
|
@@ -63,19 +68,22 @@ import { getCallRequestsWithCalldataByPhase } from '../utils.js';
|
|
|
63
68
|
this.teardownGasUsed = Gas.empty();
|
|
64
69
|
this.halted = false;
|
|
65
70
|
this.revertCode = RevertCode.OK;
|
|
66
|
-
this.log = createLogger(`simulator:public_tx_context
|
|
71
|
+
this.log = createLogger(`simulator:public_tx_context`, bindings);
|
|
67
72
|
}
|
|
68
|
-
static async create(treesDB, contractsDB, tx, globalVariables, protocolContracts,
|
|
73
|
+
static async create(treesDB, contractsDB, tx, globalVariables, protocolContracts, proverId, bindings) {
|
|
74
|
+
const contractDeploymentData = AllContractDeploymentData.fromTx(tx);
|
|
75
|
+
const nonRevertibleContractDeploymentData = contractDeploymentData.getNonRevertibleContractDeploymentData();
|
|
76
|
+
const revertibleContractDeploymentData = contractDeploymentData.getRevertibleContractDeploymentData();
|
|
69
77
|
const nonRevertibleAccumulatedDataFromPrivate = tx.data.forPublic.nonRevertibleAccumulatedData;
|
|
70
|
-
const trace = new SideEffectTrace();
|
|
78
|
+
const trace = new SideEffectTrace(0, bindings);
|
|
71
79
|
const firstNullifier = nonRevertibleAccumulatedDataFromPrivate.nullifiers[0];
|
|
72
80
|
// Transaction level state manager that will be forked for revertible phases.
|
|
73
|
-
const txStateManager = PublicPersistableStateManager.create(treesDB, contractsDB, trace,
|
|
81
|
+
const txStateManager = PublicPersistableStateManager.create(treesDB, contractsDB, trace, firstNullifier, globalVariables.timestamp, bindings);
|
|
74
82
|
const gasSettings = tx.data.constants.txContext.gasSettings;
|
|
75
83
|
const gasUsedByPrivate = tx.data.gasUsed;
|
|
76
84
|
const gasAllocatedToPublic = gasSettings.gasLimits.sub(gasUsedByPrivate);
|
|
77
85
|
const gasAllocatedToPublicTeardown = gasSettings.teardownGasLimits;
|
|
78
|
-
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), 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);
|
|
79
87
|
}
|
|
80
88
|
/**
|
|
81
89
|
* Signal that the entire transaction execution is done.
|
|
@@ -260,9 +268,9 @@ import { getCallRequestsWithCalldataByPhase } from '../utils.js';
|
|
|
260
268
|
txStateManager;
|
|
261
269
|
log;
|
|
262
270
|
currentlyActiveStateManager;
|
|
263
|
-
constructor(txStateManager){
|
|
271
|
+
constructor(txStateManager, bindings){
|
|
264
272
|
this.txStateManager = txStateManager;
|
|
265
|
-
this.log = createLogger(`simulator:public_phase_state_manager
|
|
273
|
+
this.log = createLogger(`simulator:public_phase_state_manager`, bindings);
|
|
266
274
|
}
|
|
267
275
|
async fork() {
|
|
268
276
|
assert(!this.currentlyActiveStateManager, 'Cannot fork when already forked');
|
|
@@ -1,47 +1,32 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
2
|
-
import { type Logger } from '@aztec/foundation/log';
|
|
3
|
-
import {
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { type Logger, type LoggerBindings } from '@aztec/foundation/log';
|
|
3
|
+
import { PublicSimulatorConfig, PublicTxResult } from '@aztec/stdlib/avm';
|
|
4
4
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
5
|
-
import
|
|
6
|
-
import type { DebugLog } from '@aztec/stdlib/logs';
|
|
5
|
+
import { Gas } from '@aztec/stdlib/gas';
|
|
7
6
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
8
|
-
import { type GlobalVariables, NestedProcessReturnValues, PublicCallRequestWithCalldata, Tx, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
7
|
+
import { type GlobalVariables, NestedProcessReturnValues, ProtocolContracts, PublicCallRequestWithCalldata, Tx, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
9
8
|
import type { AvmFinalizedCallResult } from '../avm/avm_contract_call_result.js';
|
|
10
9
|
import { type PublicContractsDB } from '../public_db_sources.js';
|
|
11
10
|
import type { PublicPersistableStateManager } from '../state_manager/state_manager.js';
|
|
12
11
|
import { PublicTxContext } from './public_tx_context.js';
|
|
13
12
|
import type { PublicTxSimulatorInterface } from './public_tx_simulator_interface.js';
|
|
14
|
-
|
|
13
|
+
/** Only used internally. */
|
|
14
|
+
type ProcessedPhase = {
|
|
15
15
|
phase: TxExecutionPhase;
|
|
16
16
|
durationMs?: number;
|
|
17
17
|
returnValues: NestedProcessReturnValues[];
|
|
18
18
|
reverted: boolean;
|
|
19
19
|
revertReason?: SimulationError;
|
|
20
20
|
};
|
|
21
|
-
export type PublicTxResult = {
|
|
22
|
-
avmProvingRequest: AvmProvingRequest;
|
|
23
|
-
/** Gas used during the execution of this tx */
|
|
24
|
-
gasUsed: GasUsed;
|
|
25
|
-
revertCode: RevertCode;
|
|
26
|
-
/** Revert reason, if any */
|
|
27
|
-
revertReason?: SimulationError;
|
|
28
|
-
processedPhases: ProcessedPhase[];
|
|
29
|
-
logs: DebugLog[];
|
|
30
|
-
};
|
|
31
|
-
export type PublicTxSimulatorConfig = {
|
|
32
|
-
proverId: Fr;
|
|
33
|
-
doMerkleOperations: boolean;
|
|
34
|
-
skipFeeEnforcement: boolean;
|
|
35
|
-
clientInitiatedSimulation: boolean;
|
|
36
|
-
maxDebugLogMemoryReads: number;
|
|
37
|
-
};
|
|
38
21
|
export declare class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
39
22
|
protected merkleTree: MerkleTreeWriteOperations;
|
|
40
23
|
protected contractsDB: PublicContractsDB;
|
|
41
24
|
protected globalVariables: GlobalVariables;
|
|
25
|
+
protected protocolContracts: ProtocolContracts;
|
|
42
26
|
protected log: Logger;
|
|
43
|
-
|
|
44
|
-
|
|
27
|
+
protected readonly config: PublicSimulatorConfig;
|
|
28
|
+
protected readonly bindings?: LoggerBindings;
|
|
29
|
+
constructor(merkleTree: MerkleTreeWriteOperations, contractsDB: PublicContractsDB, globalVariables: GlobalVariables, config?: Partial<PublicSimulatorConfig>, protocolContracts?: ProtocolContracts, bindings?: LoggerBindings);
|
|
45
30
|
/**
|
|
46
31
|
* Simulate a transaction's public portion including all of its phases.
|
|
47
32
|
* @param tx - The transaction to simulate.
|
|
@@ -80,7 +65,7 @@ export declare class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
|
80
65
|
/**
|
|
81
66
|
* Insert the non-revertible accumulated data from private into the public state.
|
|
82
67
|
*/
|
|
83
|
-
protected insertNonRevertiblesFromPrivate(context: PublicTxContext
|
|
68
|
+
protected insertNonRevertiblesFromPrivate(context: PublicTxContext): Promise<void>;
|
|
84
69
|
/**
|
|
85
70
|
* Insert the revertible accumulated data from private into the public state.
|
|
86
71
|
* Throws TxSimRevertibleInsertionsRevert if there is some checked error during revertible insertions.
|
|
@@ -90,11 +75,8 @@ export declare class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
|
90
75
|
* - NoteHashLimitReachedError
|
|
91
76
|
* - L2ToL1MessageLimitReachedError
|
|
92
77
|
*/
|
|
93
|
-
protected insertRevertiblesFromPrivate(context: PublicTxContext
|
|
78
|
+
protected insertRevertiblesFromPrivate(context: PublicTxContext): Promise<void>;
|
|
94
79
|
private payFee;
|
|
95
|
-
/**
|
|
96
|
-
* Generate the proving request for the AVM circuit.
|
|
97
|
-
*/
|
|
98
|
-
private static generateProvingRequest;
|
|
99
80
|
}
|
|
100
|
-
|
|
81
|
+
export {};
|
|
82
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX3R4X3NpbXVsYXRvci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3B1YmxpYy9wdWJsaWNfdHhfc2ltdWxhdG9yL3B1YmxpY190eF9zaW11bGF0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQU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DQUNsQyxLQUFLLEVBQUUsZ0JBQWdCLEVBQ3ZCLE9BQU8sRUFBRSxlQUFlLEVBQ3hCLFdBQVcsRUFBRSw2QkFBNkIsR0FDekMsT0FBTyxDQUFDLHNCQUFzQixDQUFDLENBK0JqQztJQUVEOzs7Ozs7Ozs7Ozs7T0FZRztJQUNILFVBQWdCLDRCQUE0QixDQUMxQyxZQUFZLEVBQUUsNkJBQTZCLEVBQzNDLEVBQUUsT0FBTyxFQUFFLFFBQVEsRUFBRSxFQUFFLDZCQUE2QixFQUNwRCxZQUFZLEVBQUUsR0FBRyxFQUNqQixjQUFjLEVBQUUsRUFBRSxFQUNsQixNQUFNLEVBQUUsTUFBTSxHQUNiLE9BQU8sQ0FBQyxzQkFBc0IsQ0FBQyxDQXFCakM7SUFFRDs7T0FFRztJQUNILFVBQWdCLCtCQUErQixDQUFDLE9BQU8sRUFBRSxlQUFlLGlCQXlCdkU7SUFFRDs7Ozs7Ozs7T0FRRztJQUNILFVBQWdCLDRCQUE0QixDQUFDLE9BQU8sRUFBRSxlQUFlLGlCQTBFcEU7WUFFYSxNQUFNO0NBbUNyQiJ9
|
|
@@ -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,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C7B,iBAAiB,GAAE,iBAAyC,EACtE,QAAQ,CAAC,EAAE,cAAc,EAK1B;IAED;;;;OAIG;IACU,QAAQ,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CA2IrD;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;;;;;;;;OAQG;IACH,UAAgB,4BAA4B,CAAC,OAAO,EAAE,eAAe,iBA0EpE;YAEa,MAAM;CAmCrB"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
1
|
+
import { MAX_PROCESSABLE_L2_GAS } from '@aztec/constants';
|
|
3
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
3
|
import { ProtocolContractAddress, ProtocolContractsList } from '@aztec/protocol-contracts';
|
|
5
4
|
import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
6
|
-
import {
|
|
5
|
+
import { AvmExecutionHints, AvmTxHint, PublicSimulatorConfig, PublicTxEffect, PublicTxResult } from '@aztec/stdlib/avm';
|
|
7
6
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
8
|
-
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
9
7
|
import { NestedProcessReturnValues, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
10
8
|
import { strict as assert } from 'assert';
|
|
9
|
+
import { CallDataArray } from '../avm/calldata.js';
|
|
11
10
|
import { AvmSimulator } from '../avm/index.js';
|
|
12
11
|
import { getPublicFunctionDebugName } from '../debug_fn_name.js';
|
|
13
12
|
import { HintingMerkleWriteOperations, HintingPublicContractsDB } from '../hinting_db_sources.js';
|
|
@@ -46,127 +45,116 @@ export class PublicTxSimulator {
|
|
|
46
45
|
merkleTree;
|
|
47
46
|
contractsDB;
|
|
48
47
|
globalVariables;
|
|
48
|
+
protocolContracts;
|
|
49
49
|
log;
|
|
50
50
|
config;
|
|
51
|
-
|
|
51
|
+
bindings;
|
|
52
|
+
constructor(merkleTree, contractsDB, globalVariables, config, protocolContracts = ProtocolContractsList, bindings){
|
|
52
53
|
this.merkleTree = merkleTree;
|
|
53
54
|
this.contractsDB = contractsDB;
|
|
54
55
|
this.globalVariables = globalVariables;
|
|
55
|
-
this.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
clientInitiatedSimulation: config?.clientInitiatedSimulation ?? false,
|
|
60
|
-
maxDebugLogMemoryReads: config?.maxDebugLogMemoryReads ?? DEFAULT_MAX_DEBUG_LOG_MEMORY_READS
|
|
61
|
-
};
|
|
62
|
-
this.log = createLogger(`simulator:public_tx_simulator`);
|
|
56
|
+
this.protocolContracts = protocolContracts;
|
|
57
|
+
this.config = PublicSimulatorConfig.from(config ?? {});
|
|
58
|
+
this.bindings = bindings;
|
|
59
|
+
this.log = createLogger(`simulator:public_tx_simulator`, bindings);
|
|
63
60
|
}
|
|
64
61
|
/**
|
|
65
62
|
* Simulate a transaction's public portion including all of its phases.
|
|
66
63
|
* @param tx - The transaction to simulate.
|
|
67
64
|
* @returns The result of the transaction's public execution.
|
|
68
65
|
*/ async simulate(tx) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
66
|
+
const txHash = this.computeTxHash(tx);
|
|
67
|
+
this.log.debug(`Simulating ${tx.publicFunctionCalldata.length} public calls for tx ${txHash}`, {
|
|
68
|
+
txHash
|
|
69
|
+
});
|
|
70
|
+
// Create hinting DBs.
|
|
71
|
+
const hints = new AvmExecutionHints(this.globalVariables, AvmTxHint.fromTx(tx, this.globalVariables.gasFees), this.protocolContracts);
|
|
72
|
+
const hintingMerkleTree = await HintingMerkleWriteOperations.create(this.merkleTree, hints);
|
|
73
|
+
const hintingTreesDB = new PublicTreesDB(hintingMerkleTree);
|
|
74
|
+
const hintingContractsDB = new HintingPublicContractsDB(this.contractsDB, hints);
|
|
75
|
+
const context = await PublicTxContext.create(hintingTreesDB, hintingContractsDB, tx, this.globalVariables, this.protocolContracts, this.config.proverId, this.bindings);
|
|
76
|
+
// This will throw if there is a nullifier collision.
|
|
77
|
+
// In that case the transaction will be thrown out.
|
|
78
|
+
await this.insertNonRevertiblesFromPrivate(context);
|
|
79
|
+
const processedPhases = [];
|
|
80
|
+
if (context.hasPhase(TxExecutionPhase.SETUP)) {
|
|
81
|
+
// This will throw if the setup phase reverts.
|
|
81
82
|
// In that case the transaction will be thrown out.
|
|
82
|
-
await this.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
// This will throw if the setup phase reverts.
|
|
86
|
-
// In that case the transaction will be thrown out.
|
|
87
|
-
const setupResult = await this.simulatePhase(TxExecutionPhase.SETUP, context);
|
|
88
|
-
if (setupResult.reverted) {
|
|
89
|
-
throw new Error(`Setup phase reverted! The transaction will be thrown out. ${setupResult.revertReason?.message}`);
|
|
90
|
-
}
|
|
91
|
-
processedPhases.push(setupResult);
|
|
83
|
+
const setupResult = await this.simulatePhase(TxExecutionPhase.SETUP, context);
|
|
84
|
+
if (setupResult.reverted) {
|
|
85
|
+
throw new Error(`[SETUP] UNRECOVERABLE ERROR! The transaction will be thrown out. ${setupResult.revertReason?.message}`);
|
|
92
86
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if (e instanceof TxSimRevertibleInsertionsRevert || e instanceof TxSimAppLogicRevert) {
|
|
108
|
-
// We revert to the post-setup state.
|
|
109
|
-
await context.state.discardForkedState();
|
|
110
|
-
// But we also create a new fork so that the teardown phase can transparently
|
|
111
|
-
// commit or rollback at the end of teardown.
|
|
112
|
-
await context.state.fork();
|
|
113
|
-
} else {
|
|
114
|
-
// Unchecked/unknown error - re-throw as-is
|
|
115
|
-
throw e;
|
|
87
|
+
processedPhases.push(setupResult);
|
|
88
|
+
}
|
|
89
|
+
// The checkpoint we should go back to if anything from now on reverts.
|
|
90
|
+
await context.state.fork();
|
|
91
|
+
hintingContractsDB.createCheckpoint();
|
|
92
|
+
try {
|
|
93
|
+
// This will throw if there is a nullifier collision or other insertion error (limit reached).
|
|
94
|
+
await this.insertRevertiblesFromPrivate(context);
|
|
95
|
+
// Only proceed with app logic if there was no revert during revertible insertion.
|
|
96
|
+
if (context.hasPhase(TxExecutionPhase.APP_LOGIC)) {
|
|
97
|
+
const appLogicResult = await this.simulatePhase(TxExecutionPhase.APP_LOGIC, context);
|
|
98
|
+
processedPhases.push(appLogicResult);
|
|
99
|
+
if (appLogicResult.reverted) {
|
|
100
|
+
throw new TxSimAppLogicRevert();
|
|
116
101
|
}
|
|
117
102
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
103
|
+
} catch (e) {
|
|
104
|
+
if (e instanceof TxSimRevertibleInsertionsRevert || e instanceof TxSimAppLogicRevert) {
|
|
105
|
+
// We revert to the post-setup state.
|
|
106
|
+
await context.state.discardForkedState();
|
|
107
|
+
hintingContractsDB.revertCheckpoint();
|
|
108
|
+
// But we also create a new fork so that the teardown phase can transparently
|
|
109
|
+
// commit or rollback at the end of teardown.
|
|
110
|
+
await context.state.fork();
|
|
111
|
+
hintingContractsDB.createCheckpoint();
|
|
112
|
+
} else {
|
|
113
|
+
// Unchecked/unknown error - re-throw as-is
|
|
114
|
+
throw e;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
if (context.hasPhase(TxExecutionPhase.TEARDOWN)) {
|
|
119
|
+
const teardownResult = await this.simulatePhase(TxExecutionPhase.TEARDOWN, context);
|
|
120
|
+
processedPhases.push(teardownResult);
|
|
121
|
+
if (teardownResult.reverted) {
|
|
122
|
+
throw new TxSimTeardownRevert();
|
|
135
123
|
}
|
|
136
124
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
this.contractsDB.commitContractsForTx(/*onlyNonRevertibles=*/ !revertCode.isOK());
|
|
150
|
-
return {
|
|
151
|
-
avmProvingRequest,
|
|
152
|
-
gasUsed: {
|
|
153
|
-
totalGas: context.getActualGasUsed(),
|
|
154
|
-
teardownGas: context.teardownGasUsed,
|
|
155
|
-
publicGas: context.getActualPublicGasUsed(),
|
|
156
|
-
billedGas: context.getTotalGasUsed()
|
|
157
|
-
},
|
|
158
|
-
revertCode,
|
|
159
|
-
revertReason: context.revertReason,
|
|
160
|
-
processedPhases: processedPhases,
|
|
161
|
-
logs: context.state.getActiveStateManager().getLogs()
|
|
162
|
-
};
|
|
163
|
-
} finally{
|
|
164
|
-
// Make sure there are no new contracts in the tx-level cache.
|
|
165
|
-
// They should either be committed to block-level cache or cleared.
|
|
166
|
-
// FIXME(fcarreiro): this should conceptually use the hinted contracts db.
|
|
167
|
-
// However things should work as they are now because the hinted db would still pick up the new contracts.
|
|
168
|
-
this.contractsDB.clearContractsForTx();
|
|
125
|
+
// We commit the forked state and we are done.
|
|
126
|
+
await context.state.mergeForkedState();
|
|
127
|
+
hintingContractsDB.commitCheckpoint();
|
|
128
|
+
} catch (e) {
|
|
129
|
+
if (e instanceof TxSimTeardownRevert) {
|
|
130
|
+
// We revert to the post-setup state and we are done.
|
|
131
|
+
await context.state.discardForkedState();
|
|
132
|
+
hintingContractsDB.revertCheckpoint();
|
|
133
|
+
} else {
|
|
134
|
+
// Unchecked/unknown error - re-throw as-is
|
|
135
|
+
throw e;
|
|
136
|
+
}
|
|
169
137
|
}
|
|
138
|
+
context.halt();
|
|
139
|
+
// Such transactions should be filtered by GasTxValidator.
|
|
140
|
+
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}`);
|
|
141
|
+
await this.payFee(context);
|
|
142
|
+
const publicInputs = await context.generateAvmCircuitPublicInputs();
|
|
143
|
+
const revertCode = context.getFinalRevertCode();
|
|
144
|
+
// We only return the app logic phase information, and only 1 per phase.
|
|
145
|
+
const appLogicReturnValues = processedPhases.find(({ phase })=>phase === TxExecutionPhase.APP_LOGIC)?.returnValues ?? [];
|
|
146
|
+
// TODO(fcarreiro): This is a temporary backwards compatibility layer until we migrate to the C++ simulator.
|
|
147
|
+
if (context.revertReason !== undefined) {
|
|
148
|
+
appLogicReturnValues.revertReason = context.revertReason;
|
|
149
|
+
}
|
|
150
|
+
// Create PublicTxEffect from PublicInputs.
|
|
151
|
+
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()));
|
|
152
|
+
return new PublicTxResult(/*gasUsed=*/ {
|
|
153
|
+
totalGas: context.getActualGasUsed(),
|
|
154
|
+
teardownGas: context.teardownGasUsed,
|
|
155
|
+
publicGas: context.getActualPublicGasUsed(),
|
|
156
|
+
billedGas: context.getTotalGasUsed()
|
|
157
|
+
}, /*revertCode=*/ revertCode, /*publicTxEffect=*/ publicTxEffect, /*callStackMetadata=*/ appLogicReturnValues, /*logs=*/ context.state.getActiveStateManager().getLogs(), /*hints=*/ hints, /*publicInputs=*/ publicInputs);
|
|
170
158
|
}
|
|
171
159
|
computeTxHash(tx) {
|
|
172
160
|
return tx.getTxHash();
|
|
@@ -191,7 +179,7 @@ export class PublicTxSimulator {
|
|
|
191
179
|
}
|
|
192
180
|
const callRequest = callRequests[i];
|
|
193
181
|
const enqueuedCallResult = await this.simulateEnqueuedCall(phase, context, callRequest);
|
|
194
|
-
returnValues.push(new NestedProcessReturnValues(enqueuedCallResult.output));
|
|
182
|
+
returnValues.push(new NestedProcessReturnValues(enqueuedCallResult.output.bestEffortReadAll()));
|
|
195
183
|
if (enqueuedCallResult.reverted) {
|
|
196
184
|
reverted = true;
|
|
197
185
|
revertReason = enqueuedCallResult.revertReason;
|
|
@@ -213,14 +201,14 @@ export class PublicTxSimulator {
|
|
|
213
201
|
*/ async simulateEnqueuedCall(phase, context, callRequest) {
|
|
214
202
|
const stateManager = context.state.getActiveStateManager();
|
|
215
203
|
const contractAddress = callRequest.request.contractAddress;
|
|
216
|
-
const fnName = await getPublicFunctionDebugName(this.contractsDB, contractAddress, callRequest.calldata);
|
|
204
|
+
const fnName = await getPublicFunctionDebugName(this.contractsDB, contractAddress, new CallDataArray(callRequest.calldata));
|
|
217
205
|
const allocatedGas = context.getGasLeftAtPhase(phase);
|
|
218
206
|
const result = await this.simulateEnqueuedCallInternal(stateManager, callRequest, allocatedGas, /*transactionFee=*/ context.getTransactionFee(phase), fnName);
|
|
219
207
|
const gasUsed = allocatedGas.sub(result.gasLeft); // by enqueued call
|
|
220
208
|
context.consumeGas(phase, gasUsed);
|
|
221
209
|
this.log.debug(`Simulated enqueued public call (${fnName}) consumed ${gasUsed.l2Gas} L2 gas ending with ${result.gasLeft.l2Gas} L2 gas left.`);
|
|
222
210
|
if (result.reverted) {
|
|
223
|
-
const culprit = `${contractAddress}:${
|
|
211
|
+
const culprit = `${contractAddress}:${fnName}`;
|
|
224
212
|
context.revert(phase, result.revertReason, culprit);
|
|
225
213
|
}
|
|
226
214
|
return result;
|
|
@@ -241,13 +229,13 @@ export class PublicTxSimulator {
|
|
|
241
229
|
const address = request.contractAddress;
|
|
242
230
|
const sender = request.msgSender;
|
|
243
231
|
this.log.debug(`Executing enqueued public call to external function ${fnName}@${address} with ${allocatedGas.l2Gas} allocated L2 gas.`);
|
|
244
|
-
const simulator = await AvmSimulator.create(stateManager, address, sender, transactionFee, this.globalVariables, request.isStaticCall, calldata, allocatedGas, this.config
|
|
232
|
+
const simulator = await AvmSimulator.create(stateManager, address, sender, transactionFee, this.globalVariables, request.isStaticCall, new CallDataArray(calldata), allocatedGas, this.config);
|
|
245
233
|
const avmCallResult = await simulator.execute();
|
|
246
234
|
return avmCallResult.finalize();
|
|
247
235
|
}
|
|
248
236
|
/**
|
|
249
237
|
* Insert the non-revertible accumulated data from private into the public state.
|
|
250
|
-
*/ async insertNonRevertiblesFromPrivate(context
|
|
238
|
+
*/ async insertNonRevertiblesFromPrivate(context) {
|
|
251
239
|
const stateManager = context.state.getActiveStateManager();
|
|
252
240
|
for (const siloedNullifier of context.nonRevertibleAccumulatedDataFromPrivate.nullifiers.filter((n)=>!n.isEmpty())){
|
|
253
241
|
await stateManager.writeSiloedNullifier(siloedNullifier);
|
|
@@ -262,11 +250,12 @@ export class PublicTxSimulator {
|
|
|
262
250
|
stateManager.writeScopedL2ToL1Message(l2ToL1Message);
|
|
263
251
|
}
|
|
264
252
|
}
|
|
265
|
-
// add new contracts to the contracts db so that their
|
|
266
|
-
//
|
|
267
|
-
//
|
|
268
|
-
//
|
|
269
|
-
|
|
253
|
+
// add new contracts to the contracts db so that their code may be found and called
|
|
254
|
+
// FIXME(fcarreiro): this should conceptually use the hinting contracts db.
|
|
255
|
+
// However, things work as expected because later calls to getters on the hintingContractsDB
|
|
256
|
+
// will pick up the new contracts and will generate the necessary hints.
|
|
257
|
+
// So, a consumer of the hints will always see the new contracts.
|
|
258
|
+
await this.contractsDB.addContracts(context.nonRevertibleContractDeploymentData);
|
|
270
259
|
}
|
|
271
260
|
/**
|
|
272
261
|
* Insert the revertible accumulated data from private into the public state.
|
|
@@ -276,7 +265,7 @@ export class PublicTxSimulator {
|
|
|
276
265
|
* - NullifierCollisionError
|
|
277
266
|
* - NoteHashLimitReachedError
|
|
278
267
|
* - L2ToL1MessageLimitReachedError
|
|
279
|
-
*/ async insertRevertiblesFromPrivate(context
|
|
268
|
+
*/ async insertRevertiblesFromPrivate(context) {
|
|
280
269
|
const stateManager = context.state.getActiveStateManager();
|
|
281
270
|
try {
|
|
282
271
|
for (const siloedNullifier of context.revertibleAccumulatedDataFromPrivate.nullifiers.filter((n)=>!n.isEmpty())){
|
|
@@ -323,14 +312,19 @@ export class PublicTxSimulator {
|
|
|
323
312
|
}
|
|
324
313
|
}
|
|
325
314
|
// add new contracts to the contracts db so that their functions may be found and called
|
|
326
|
-
// FIXME(fcarreiro): this should conceptually use the
|
|
327
|
-
// However things
|
|
328
|
-
|
|
315
|
+
// FIXME(fcarreiro): this should conceptually use the hinting contracts db.
|
|
316
|
+
// However, things work as expected because later calls to getters on the hintingContractsDB
|
|
317
|
+
// will pick up the new contracts and will generate the necessary hints.
|
|
318
|
+
// So, a consumer of the hints will always see the new contracts.
|
|
319
|
+
await this.contractsDB.addContracts(context.revertibleContractDeploymentData);
|
|
329
320
|
}
|
|
330
321
|
async payFee(context) {
|
|
331
322
|
const txFee = context.getTransactionFee(TxExecutionPhase.TEARDOWN);
|
|
332
323
|
if (context.feePayer.isZero()) {
|
|
333
|
-
|
|
324
|
+
// Real transactions are enforced by private kernel to have nonzero fee payer.
|
|
325
|
+
// Real transactions cannot skip fee enforcement (skipping fee enforcement makes them unprovable).
|
|
326
|
+
assert(this.config.skipFeeEnforcement, 'Fee payer cannot be 0 unless skipping fee enforcement for simulation');
|
|
327
|
+
this.log.debug(`Fee payer is 0. Skipping fee enforcement. No one is paying the fee of ${txFee.toBigInt()}`);
|
|
334
328
|
return;
|
|
335
329
|
}
|
|
336
330
|
const feeJuiceAddress = ProtocolContractAddress.FeeJuice;
|
|
@@ -343,17 +337,11 @@ export class PublicTxSimulator {
|
|
|
343
337
|
if (currentBalance.lt(txFee)) {
|
|
344
338
|
// Without "skipFeeEnforcement", such transactions should be filtered by GasTxValidator.
|
|
345
339
|
assert(this.config.skipFeeEnforcement, `Not enough balance for fee payer to pay for transaction (got ${currentBalance.toBigInt()} needs ${txFee.toBigInt()})`);
|
|
340
|
+
this.log.debug(`Fee payer balance insufficient, but we're skipping fee enforcement`);
|
|
341
|
+
// We still proceed and perform the storage write to minimize deviation from normal execution.
|
|
346
342
|
currentBalance = txFee;
|
|
347
343
|
}
|
|
348
344
|
const updatedBalance = currentBalance.sub(txFee);
|
|
349
345
|
await stateManager.writeStorage(feeJuiceAddress, balanceSlot, updatedBalance, true);
|
|
350
346
|
}
|
|
351
|
-
/**
|
|
352
|
-
* Generate the proving request for the AVM circuit.
|
|
353
|
-
*/ static generateProvingRequest(publicInputs, hints) {
|
|
354
|
-
return {
|
|
355
|
-
type: ProvingRequestType.PUBLIC_VM,
|
|
356
|
-
inputs: new AvmCircuitInputs(hints, publicInputs)
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
347
|
}
|
|
@@ -1,9 +1,32 @@
|
|
|
1
|
+
import type { PublicTxResult } from '@aztec/stdlib/avm';
|
|
1
2
|
import type { Tx } from '@aztec/stdlib/tx';
|
|
2
|
-
import type { PublicTxResult } from './public_tx_simulator.js';
|
|
3
3
|
export interface PublicTxSimulatorInterface {
|
|
4
4
|
simulate(tx: Tx): Promise<PublicTxResult>;
|
|
5
|
+
/**
|
|
6
|
+
* Cancel the current simulation if one is in progress.
|
|
7
|
+
* This signals the underlying simulator (e.g., C++) to stop at the next safe point.
|
|
8
|
+
* Safe to call even if no simulation is in progress.
|
|
9
|
+
* Optional - not all implementations support cancellation.
|
|
10
|
+
*
|
|
11
|
+
* @param waitTimeoutMs - If provided, wait up to this many ms for the simulation to actually stop.
|
|
12
|
+
* This is important because signaling cancellation doesn't immediately stop C++ -
|
|
13
|
+
* it only sets a flag that C++ checks at certain points. If C++ is in the middle
|
|
14
|
+
* of a slow operation (e.g., pad_trees), it won't stop until that completes.
|
|
15
|
+
* @returns Promise that resolves when cancellation is signaled (and optionally when simulation stops)
|
|
16
|
+
*/
|
|
17
|
+
cancel?(waitTimeoutMs?: number): Promise<void>;
|
|
5
18
|
}
|
|
6
19
|
export interface MeasuredPublicTxSimulatorInterface {
|
|
7
20
|
simulate(tx: Tx, txLabel: string): Promise<PublicTxResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Cancel the current simulation if one is in progress.
|
|
23
|
+
* This signals the underlying simulator (e.g., C++) to stop at the next safe point.
|
|
24
|
+
* Safe to call even if no simulation is in progress.
|
|
25
|
+
* Optional - not all implementations support cancellation.
|
|
26
|
+
*
|
|
27
|
+
* @param waitTimeoutMs - If provided, wait up to this many ms for the simulation to actually stop.
|
|
28
|
+
* @returns Promise that resolves when cancellation is signaled (and optionally when simulation stops)
|
|
29
|
+
*/
|
|
30
|
+
cancel?(waitTimeoutMs?: number): Promise<void>;
|
|
8
31
|
}
|
|
9
|
-
//# sourceMappingURL=
|
|
32
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX3R4X3NpbXVsYXRvcl9pbnRlcmZhY2UuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wdWJsaWMvcHVibGljX3R4X3NpbXVsYXRvci9wdWJsaWNfdHhfc2ltdWxhdG9yX2ludGVyZmFjZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxjQUFjLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUN4RCxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUUzQyxNQUFNLFdBQVcsMEJBQTBCO0lBQ3pDLFFBQVEsQ0FBQyxFQUFFLEVBQUUsRUFBRSxHQUFHLE9BQU8sQ0FBQyxjQUFjLENBQUMsQ0FBQztJQUMxQzs7Ozs7Ozs7Ozs7T0FXRztJQUNILE1BQU0sQ0FBQyxDQUFDLGFBQWEsQ0FBQyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUM7Q0FDaEQ7QUFFRCxNQUFNLFdBQVcsa0NBQWtDO0lBQ2pELFFBQVEsQ0FBQyxFQUFFLEVBQUUsRUFBRSxFQUFFLE9BQU8sRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLGNBQWMsQ0FBQyxDQUFDO0lBQzNEOzs7Ozs7OztPQVFHO0lBQ0gsTUFBTSxDQUFDLENBQUMsYUFBYSxDQUFDLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQztDQUNoRCJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_tx_simulator_interface.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_simulator_interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"public_tx_simulator_interface.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_simulator_interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAC1C;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD;AAED,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAC3D;;;;;;;;OAQG;IACH,MAAM,CAAC,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD"}
|
|
@@ -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';
|
|
@@ -8,14 +9,13 @@ import type { PublicContractsDB } from '../public_db_sources.js';
|
|
|
8
9
|
import type { PublicPersistableStateManager } from '../state_manager/state_manager.js';
|
|
9
10
|
import { MeasuredPublicTxSimulator } from './measured_public_tx_simulator.js';
|
|
10
11
|
import { PublicTxContext } from './public_tx_context.js';
|
|
11
|
-
import type { PublicTxSimulatorConfig } from './public_tx_simulator.js';
|
|
12
12
|
/**
|
|
13
13
|
* A public tx simulator that tracks runtime/production metrics with telemetry.
|
|
14
14
|
*/
|
|
15
15
|
export declare class TelemetryPublicTxSimulator extends MeasuredPublicTxSimulator {
|
|
16
16
|
readonly tracer: Tracer;
|
|
17
|
-
constructor(merkleTree: MerkleTreeWriteOperations, contractsDB: PublicContractsDB, globalVariables: GlobalVariables, telemetryClient?: TelemetryClient, config?: Partial<
|
|
17
|
+
constructor(merkleTree: MerkleTreeWriteOperations, contractsDB: PublicContractsDB, globalVariables: GlobalVariables, telemetryClient?: TelemetryClient, config?: Partial<PublicSimulatorConfig>);
|
|
18
18
|
protected simulateEnqueuedCall(phase: TxExecutionPhase, context: PublicTxContext, callRequest: PublicCallRequestWithCalldata): Promise<AvmFinalizedCallResult>;
|
|
19
19
|
protected simulateEnqueuedCallInternal(stateManager: PublicPersistableStateManager, callRequest: PublicCallRequestWithCalldata, allocatedGas: Gas, transactionFee: Fr, fnName: string): Promise<AvmFinalizedCallResult>;
|
|
20
20
|
}
|
|
21
|
-
//# sourceMappingURL=
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVsZW1ldHJ5X3B1YmxpY190eF9zaW11bGF0b3IuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wdWJsaWMvcHVibGljX3R4X3NpbXVsYXRvci90ZWxlbWV0cnlfcHVibGljX3R4X3NpbXVsYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxxQkFBcUIsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQy9ELE9BQU8sS0FB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QyxDQUVqQztJQUVELFVBTXlCLDRCQUE0QixDQUNuRCxZQUFZLEVBQUUsNkJBQTZCLEVBQzNDLFdBQVcsRUFBRSw2QkFBNkIsRUFDMUMsWUFBWSxFQUFFLEdBQUcsRUFDakIsY0FBYyxFQUFFLEVBQUUsRUFDbEIsTUFBTSxFQUFFLE1BQU0sR0FDYixPQUFPLENBQUMsc0JBQXNCLENBQUMsQ0FFakM7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry_public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/telemetry_public_tx_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"telemetry_public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/telemetry_public_tx_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,KAAK,eAAe,EAAE,6BAA6B,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzG,OAAO,EAAc,KAAK,eAAe,EAAE,KAAK,MAAM,EAAiC,MAAM,yBAAyB,CAAC;AAEvH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAEjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,M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