@aztec/simulator 0.0.1-commit.5daedc8 → 0.0.1-commit.6201a7b05
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 +13 -8
- package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -1
- package/dest/public/fixtures/custom_bytecode_tests.js +143 -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 +507 -88
- package/dest/public/public_processor/public_processor_metrics.d.ts +5 -2
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor_metrics.js +36 -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 +249 -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 +153 -91
- package/src/public/public_processor/public_processor_metrics.ts +28 -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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, NULLIFIER_SUBTREE_HEIGHT } from '@aztec/constants';
|
|
2
2
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
|
-
import { Fr } from '@aztec/foundation/
|
|
4
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import { sleep } from '@aztec/foundation/sleep';
|
|
6
6
|
import { DateProvider, Timer, elapsed, executeTimeout } from '@aztec/foundation/timer';
|
|
7
7
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
@@ -25,6 +25,7 @@ import type {
|
|
|
25
25
|
PublicProcessorValidator,
|
|
26
26
|
SequencerConfig,
|
|
27
27
|
} from '@aztec/stdlib/interfaces/server';
|
|
28
|
+
import { type DebugLog, type DebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
28
29
|
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
29
30
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
30
31
|
import {
|
|
@@ -51,9 +52,9 @@ import { AssertionError } from 'assert';
|
|
|
51
52
|
|
|
52
53
|
import { PublicContractsDB, PublicTreesDB } from '../public_db_sources.js';
|
|
53
54
|
import {
|
|
54
|
-
type PublicTxSimulator,
|
|
55
55
|
type PublicTxSimulatorConfig,
|
|
56
|
-
|
|
56
|
+
type PublicTxSimulatorInterface,
|
|
57
|
+
TelemetryCppPublicTxSimulator,
|
|
57
58
|
} from '../public_tx_simulator/index.js';
|
|
58
59
|
import { GuardedMerkleTreeOperations } from './guarded_merkle_tree.js';
|
|
59
60
|
import { PublicProcessorMetrics } from './public_processor_metrics.js';
|
|
@@ -62,11 +63,15 @@ import { PublicProcessorMetrics } from './public_processor_metrics.js';
|
|
|
62
63
|
* Creates new instances of PublicProcessor given the provided merkle tree db and contract data source.
|
|
63
64
|
*/
|
|
64
65
|
export class PublicProcessorFactory {
|
|
66
|
+
private log: Logger;
|
|
65
67
|
constructor(
|
|
66
68
|
private contractDataSource: ContractDataSource,
|
|
67
69
|
private dateProvider: DateProvider = new DateProvider(),
|
|
68
70
|
protected telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
69
|
-
|
|
71
|
+
bindings?: LoggerBindings,
|
|
72
|
+
) {
|
|
73
|
+
this.log = createLogger('simulator:public-processor-factory', bindings);
|
|
74
|
+
}
|
|
70
75
|
|
|
71
76
|
/**
|
|
72
77
|
* Creates a new instance of a PublicProcessor.
|
|
@@ -79,7 +84,8 @@ export class PublicProcessorFactory {
|
|
|
79
84
|
globalVariables: GlobalVariables,
|
|
80
85
|
config: PublicSimulatorConfig,
|
|
81
86
|
): PublicProcessor {
|
|
82
|
-
const
|
|
87
|
+
const bindings = this.log.getBindings();
|
|
88
|
+
const contractsDB = new PublicContractsDB(this.contractDataSource, bindings);
|
|
83
89
|
|
|
84
90
|
const guardedFork = new GuardedMerkleTreeOperations(merkleTree);
|
|
85
91
|
const publicTxSimulator = this.createPublicTxSimulator(guardedFork, contractsDB, globalVariables, config);
|
|
@@ -91,6 +97,7 @@ export class PublicProcessorFactory {
|
|
|
91
97
|
publicTxSimulator,
|
|
92
98
|
this.dateProvider,
|
|
93
99
|
this.telemetryClient,
|
|
100
|
+
createLogger('simulator:public-processor', bindings),
|
|
94
101
|
);
|
|
95
102
|
}
|
|
96
103
|
|
|
@@ -99,8 +106,15 @@ export class PublicProcessorFactory {
|
|
|
99
106
|
contractsDB: PublicContractsDB,
|
|
100
107
|
globalVariables: GlobalVariables,
|
|
101
108
|
config?: Partial<PublicTxSimulatorConfig>,
|
|
102
|
-
):
|
|
103
|
-
return new
|
|
109
|
+
): PublicTxSimulatorInterface {
|
|
110
|
+
return new TelemetryCppPublicTxSimulator(
|
|
111
|
+
merkleTree,
|
|
112
|
+
contractsDB,
|
|
113
|
+
globalVariables,
|
|
114
|
+
this.telemetryClient,
|
|
115
|
+
config,
|
|
116
|
+
this.log.getBindings(),
|
|
117
|
+
);
|
|
104
118
|
}
|
|
105
119
|
}
|
|
106
120
|
|
|
@@ -117,16 +131,16 @@ class PublicProcessorTimeoutError extends Error {
|
|
|
117
131
|
*/
|
|
118
132
|
export class PublicProcessor implements Traceable {
|
|
119
133
|
private metrics: PublicProcessorMetrics;
|
|
120
|
-
|
|
121
134
|
constructor(
|
|
122
135
|
protected globalVariables: GlobalVariables,
|
|
123
136
|
private guardedMerkleTree: GuardedMerkleTreeOperations,
|
|
124
137
|
protected contractsDB: PublicContractsDB,
|
|
125
|
-
protected publicTxSimulator:
|
|
138
|
+
protected publicTxSimulator: PublicTxSimulatorInterface,
|
|
126
139
|
private dateProvider: DateProvider,
|
|
127
140
|
telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
128
|
-
private log
|
|
129
|
-
private opts: Pick<SequencerConfig, 'fakeProcessingDelayPerTxMs'> = {},
|
|
141
|
+
private log: Logger,
|
|
142
|
+
private opts: Pick<SequencerConfig, 'fakeProcessingDelayPerTxMs' | 'fakeThrowAfterProcessingTxCount'> = {},
|
|
143
|
+
private debugLogStore: DebugLogStore = new NullDebugLogStore(),
|
|
130
144
|
) {
|
|
131
145
|
this.metrics = new PublicProcessorMetrics(telemetryClient, 'PublicProcessor');
|
|
132
146
|
}
|
|
@@ -146,12 +160,13 @@ export class PublicProcessor implements Traceable {
|
|
|
146
160
|
txs: Iterable<Tx> | AsyncIterable<Tx>,
|
|
147
161
|
limits: PublicProcessorLimits = {},
|
|
148
162
|
validator: PublicProcessorValidator = {},
|
|
149
|
-
): Promise<[ProcessedTx[], FailedTx[], Tx[], NestedProcessReturnValues[]]> {
|
|
150
|
-
const { maxTransactions,
|
|
163
|
+
): Promise<[ProcessedTx[], FailedTx[], Tx[], NestedProcessReturnValues[], DebugLog[]]> {
|
|
164
|
+
const { maxTransactions, deadline, maxBlockGas, maxBlobFields, isBuildingProposal } = limits;
|
|
151
165
|
const { preprocessValidator, nullifierCache } = validator;
|
|
152
166
|
const result: ProcessedTx[] = [];
|
|
153
167
|
const usedTxs: Tx[] = [];
|
|
154
168
|
const failed: FailedTx[] = [];
|
|
169
|
+
const debugLogs: DebugLog[] = [];
|
|
155
170
|
const timer = new Timer();
|
|
156
171
|
|
|
157
172
|
let totalSizeInBytes = 0;
|
|
@@ -159,8 +174,10 @@ export class PublicProcessor implements Traceable {
|
|
|
159
174
|
let totalPublicGas = new Gas(0, 0);
|
|
160
175
|
let totalBlockGas = new Gas(0, 0);
|
|
161
176
|
let totalBlobFields = 0;
|
|
177
|
+
let silentlySkippedCount = 0;
|
|
178
|
+
let totalSilentlySkippedDurationMs = 0;
|
|
162
179
|
|
|
163
|
-
for await (const
|
|
180
|
+
for await (const tx of txs) {
|
|
164
181
|
// Only process up to the max tx limit
|
|
165
182
|
if (maxTransactions !== undefined && result.length >= maxTransactions) {
|
|
166
183
|
this.log.debug(`Stopping tx processing due to reaching the max tx limit.`);
|
|
@@ -173,22 +190,23 @@ export class PublicProcessor implements Traceable {
|
|
|
173
190
|
break;
|
|
174
191
|
}
|
|
175
192
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
193
|
+
const txHash = tx.getTxHash().toString();
|
|
194
|
+
|
|
195
|
+
// Skip this tx if its estimated blob fields would exceed the limit.
|
|
196
|
+
// Only done during proposal building: during re-execution we must process the exact txs from the proposal.
|
|
197
|
+
const txBlobFields = tx.getPrivateTxEffectsSizeInFields();
|
|
198
|
+
if (isBuildingProposal && maxBlobFields !== undefined && totalBlobFields + txBlobFields > maxBlobFields) {
|
|
199
|
+
this.log.warn(
|
|
200
|
+
`Skipping tx ${txHash} with ${txBlobFields} fields from private side effects due to blob fields limit`,
|
|
201
|
+
{ txHash, txBlobFields, totalBlobFields, maxBlobFields },
|
|
202
|
+
);
|
|
186
203
|
continue;
|
|
187
204
|
}
|
|
188
205
|
|
|
189
|
-
// Skip this tx if its gas limit would exceed the block gas limit
|
|
190
|
-
|
|
191
|
-
|
|
206
|
+
// Skip this tx if its gas limit would exceed the block gas limit (either da or l2).
|
|
207
|
+
// Only done during proposal building: during re-execution we must process the exact txs from the proposal.
|
|
208
|
+
const txGasLimit = tx.data.constants.txContext.gasSettings.gasLimits;
|
|
209
|
+
if (isBuildingProposal && maxBlockGas !== undefined && totalBlockGas.add(txGasLimit).gtAny(maxBlockGas)) {
|
|
192
210
|
this.log.warn(`Skipping processing of tx ${txHash} due to block gas limit`, {
|
|
193
211
|
txHash,
|
|
194
212
|
txGasLimit,
|
|
@@ -198,9 +216,6 @@ export class PublicProcessor implements Traceable {
|
|
|
198
216
|
continue;
|
|
199
217
|
}
|
|
200
218
|
|
|
201
|
-
// The processor modifies the tx objects in place, so we need to clone them.
|
|
202
|
-
const tx = Tx.clone(origTx);
|
|
203
|
-
|
|
204
219
|
// We validate the tx before processing it, to avoid unnecessary work.
|
|
205
220
|
if (preprocessValidator) {
|
|
206
221
|
const result = await preprocessValidator.validateTx(tx);
|
|
@@ -231,26 +246,21 @@ export class PublicProcessor implements Traceable {
|
|
|
231
246
|
this.contractsDB.createCheckpoint();
|
|
232
247
|
|
|
233
248
|
try {
|
|
234
|
-
const [processedTx, returnValues] = await
|
|
249
|
+
const [txProcessingTimeMs, [processedTx, returnValues, txDebugLogs]] = await elapsed(() =>
|
|
250
|
+
this.processTx(tx, deadline),
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
// Inject a fake processing failure after N txs if requested
|
|
254
|
+
const fakeThrowAfter = this.opts.fakeThrowAfterProcessingTxCount;
|
|
255
|
+
if (fakeThrowAfter !== undefined && result.length + failed.length + 1 >= fakeThrowAfter) {
|
|
256
|
+
throw new Error(`Fake error after processing ${fakeThrowAfter} txs`);
|
|
257
|
+
}
|
|
235
258
|
|
|
236
259
|
const txBlobFields = processedTx.txEffect.getNumBlobFields();
|
|
237
|
-
|
|
238
|
-
// If the actual size of this tx would exceed block size, skip it
|
|
239
260
|
const txSize = txBlobFields * Fr.SIZE_IN_BYTES;
|
|
240
|
-
if (maxBlockSize !== undefined && totalSizeInBytes + txSize > maxBlockSize) {
|
|
241
|
-
this.log.debug(`Skipping processed tx ${txHash} sized ${txSize} due to max block size.`, {
|
|
242
|
-
txHash,
|
|
243
|
-
sizeInBytes: txSize,
|
|
244
|
-
totalSizeInBytes,
|
|
245
|
-
maxBlockSize,
|
|
246
|
-
});
|
|
247
|
-
// Need to revert the checkpoint here and don't go any further
|
|
248
|
-
await checkpoint.revert();
|
|
249
|
-
this.contractsDB.revertCheckpoint();
|
|
250
|
-
continue;
|
|
251
|
-
}
|
|
252
261
|
|
|
253
|
-
// If the actual blob fields of this tx would exceed the limit, skip it
|
|
262
|
+
// If the actual blob fields of this tx would exceed the limit, skip it.
|
|
263
|
+
// Note: maxBlobFields already accounts for block end blob fields and previous blocks in checkpoint.
|
|
254
264
|
if (maxBlobFields !== undefined && totalBlobFields + txBlobFields > maxBlobFields) {
|
|
255
265
|
this.log.debug(
|
|
256
266
|
`Skipping processed tx ${txHash} with ${txBlobFields} blob fields due to max blob fields limit.`,
|
|
@@ -259,44 +269,77 @@ export class PublicProcessor implements Traceable {
|
|
|
259
269
|
txBlobFields,
|
|
260
270
|
totalBlobFields,
|
|
261
271
|
maxBlobFields,
|
|
272
|
+
txProcessingTimeMs,
|
|
262
273
|
},
|
|
263
274
|
);
|
|
275
|
+
silentlySkippedCount += 1;
|
|
276
|
+
totalSilentlySkippedDurationMs += txProcessingTimeMs;
|
|
277
|
+
this.metrics.recordSilentlySkipped(txProcessingTimeMs);
|
|
264
278
|
// Need to revert the checkpoint here and don't go any further
|
|
265
279
|
await checkpoint.revert();
|
|
266
280
|
this.contractsDB.revertCheckpoint();
|
|
267
281
|
continue;
|
|
268
282
|
}
|
|
269
283
|
|
|
284
|
+
// During re-execution, check if the actual gas used by this tx would push the block over the gas limit.
|
|
285
|
+
// Unlike the proposal-building check (which uses declared gas limits pessimistically before processing),
|
|
286
|
+
// this uses actual gas and stops processing when the limit is exceeded.
|
|
287
|
+
if (
|
|
288
|
+
!isBuildingProposal &&
|
|
289
|
+
maxBlockGas !== undefined &&
|
|
290
|
+
totalBlockGas.add(processedTx.gasUsed.totalGas).gtAny(maxBlockGas)
|
|
291
|
+
) {
|
|
292
|
+
this.log.warn(`Stopping re-execution since tx ${txHash} would push block gas over limit`, {
|
|
293
|
+
txHash,
|
|
294
|
+
txGas: processedTx.gasUsed.totalGas,
|
|
295
|
+
totalBlockGas,
|
|
296
|
+
maxBlockGas,
|
|
297
|
+
});
|
|
298
|
+
await checkpoint.revert();
|
|
299
|
+
this.contractsDB.revertCheckpoint();
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
|
|
270
303
|
// FIXME(fcarreiro): it's ugly to have to notify the validator of nullifiers.
|
|
271
304
|
// I'd rather pass the validators the processedTx as well and let them deal with it.
|
|
272
305
|
nullifierCache?.addNullifiers(processedTx.txEffect.nullifiers.map(n => n.toBuffer()));
|
|
273
306
|
result.push(processedTx);
|
|
274
307
|
usedTxs.push(tx);
|
|
275
308
|
returns = returns.concat(returnValues);
|
|
309
|
+
debugLogs.push(...txDebugLogs);
|
|
310
|
+
|
|
311
|
+
this.debugLogStore.storeLogs(processedTx.hash.toString(), txDebugLogs);
|
|
276
312
|
|
|
277
313
|
totalPublicGas = totalPublicGas.add(processedTx.gasUsed.publicGas);
|
|
278
314
|
totalBlockGas = totalBlockGas.add(processedTx.gasUsed.totalGas);
|
|
279
315
|
totalSizeInBytes += txSize;
|
|
280
316
|
totalBlobFields += txBlobFields;
|
|
317
|
+
|
|
318
|
+
// Commit the tx-level contracts checkpoint on success
|
|
319
|
+
this.contractsDB.commitCheckpoint();
|
|
281
320
|
} catch (err: any) {
|
|
282
321
|
if (err?.name === 'PublicProcessorTimeoutError') {
|
|
283
322
|
this.log.warn(`Stopping tx processing due to timeout.`);
|
|
284
323
|
// We hit the transaction execution deadline.
|
|
285
|
-
// There may still be a transaction executing
|
|
324
|
+
// There may still be a transaction executing on a worker thread (C++ via NAPI).
|
|
325
|
+
// Signal cancellation AND WAIT for the simulation to actually stop.
|
|
326
|
+
// This is critical because C++ might be in the middle of a slow operation (e.g., pad_trees)
|
|
327
|
+
// and won't check the cancellation flag until that operation completes.
|
|
328
|
+
// Without waiting, we'd proceed to revert checkpoints while C++ is still writing to state.
|
|
329
|
+
// Wait for C++ to stop gracefully.
|
|
330
|
+
await this.publicTxSimulator.cancel?.();
|
|
331
|
+
|
|
332
|
+
// Now stop the guarded fork to prevent any further TS-side access to the world state.
|
|
286
333
|
await this.guardedMerkleTree.stop();
|
|
287
334
|
|
|
288
335
|
// We now know there can't be any further access to world state. The fork is in a state where there is:
|
|
289
336
|
// 1. At least one outstanding checkpoint that has not been committed (the one created before we processed the tx).
|
|
290
337
|
// 2. Possible state updates on that checkpoint or any others created during execution.
|
|
291
338
|
|
|
292
|
-
//
|
|
293
|
-
//
|
|
294
|
-
//
|
|
295
|
-
await checkpoint.
|
|
296
|
-
|
|
297
|
-
// Now we want to revert any/all remaining checkpoints, destroying any outstanding state updates.
|
|
298
|
-
// This needs to be done directly on the underlying fork as the guarded fork has been stopped.
|
|
299
|
-
await this.guardedMerkleTree.getUnderlyingFork().revertAllCheckpoints();
|
|
339
|
+
// Revert all checkpoints at or above this checkpoint's depth (inclusive), destroying any outstanding state
|
|
340
|
+
// updates from this tx and any nested checkpoints created during execution. This preserves any checkpoints
|
|
341
|
+
// created by callers below our depth.
|
|
342
|
+
await checkpoint.revertToCheckpoint();
|
|
300
343
|
|
|
301
344
|
// Revert any contracts added to the DB for the tx.
|
|
302
345
|
this.contractsDB.revertCheckpoint();
|
|
@@ -308,9 +351,9 @@ export class PublicProcessor implements Traceable {
|
|
|
308
351
|
break;
|
|
309
352
|
}
|
|
310
353
|
|
|
311
|
-
// Roll back state to start of TX before proceeding to next TX
|
|
312
|
-
|
|
313
|
-
await
|
|
354
|
+
// Roll back state to start of TX before proceeding to next TX.
|
|
355
|
+
// Reverts all checkpoints at or above this checkpoint's depth, preserving any caller checkpoints below.
|
|
356
|
+
await checkpoint.revertToCheckpoint();
|
|
314
357
|
this.contractsDB.revertCheckpoint();
|
|
315
358
|
const errorMessage = err instanceof Error || err instanceof AssertionError ? err.message : 'Unknown error';
|
|
316
359
|
this.log.warn(`Failed to process tx ${txHash.toString()}: ${errorMessage} ${err?.stack}`);
|
|
@@ -322,7 +365,6 @@ export class PublicProcessor implements Traceable {
|
|
|
322
365
|
} finally {
|
|
323
366
|
// Base case is we always commit the checkpoint. Using the ForkCheckpoint means this has no effect if the tx was previously reverted
|
|
324
367
|
await checkpoint.commit();
|
|
325
|
-
this.contractsDB.commitCheckpointOkIfNone();
|
|
326
368
|
}
|
|
327
369
|
}
|
|
328
370
|
|
|
@@ -330,15 +372,26 @@ export class PublicProcessor implements Traceable {
|
|
|
330
372
|
const rate = duration > 0 ? totalPublicGas.l2Gas / duration : 0;
|
|
331
373
|
this.metrics.recordAllTxs(totalPublicGas, rate);
|
|
332
374
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
375
|
+
const silentlySkippedDurationMs = Math.round(totalSilentlySkippedDurationMs);
|
|
376
|
+
this.log.info(
|
|
377
|
+
`Processed ${result.length} successful txs and ${failed.length} failed txs ` +
|
|
378
|
+
`(${silentlySkippedCount} silently skipped, ${silentlySkippedDurationMs}ms wasted) ` +
|
|
379
|
+
`in ${duration}s`,
|
|
380
|
+
{
|
|
381
|
+
blockNumber: this.globalVariables.blockNumber,
|
|
382
|
+
successfulCount: result.length,
|
|
383
|
+
failedCount: failed.length,
|
|
384
|
+
duration,
|
|
385
|
+
rate,
|
|
386
|
+
totalPublicGas,
|
|
387
|
+
totalBlockGas,
|
|
388
|
+
totalSizeInBytes,
|
|
389
|
+
silentlySkippedCount,
|
|
390
|
+
silentlySkippedDurationMs,
|
|
391
|
+
},
|
|
392
|
+
);
|
|
340
393
|
|
|
341
|
-
return [result, failed, usedTxs, returns];
|
|
394
|
+
return [result, failed, usedTxs, returns, debugLogs];
|
|
342
395
|
}
|
|
343
396
|
|
|
344
397
|
private async checkWorldStateUnchanged(
|
|
@@ -358,8 +411,13 @@ export class PublicProcessor implements Traceable {
|
|
|
358
411
|
}
|
|
359
412
|
|
|
360
413
|
@trackSpan('PublicProcessor.processTx', tx => ({ [Attributes.TX_HASH]: tx.getTxHash().toString() }))
|
|
361
|
-
private async processTx(
|
|
362
|
-
|
|
414
|
+
private async processTx(
|
|
415
|
+
tx: Tx,
|
|
416
|
+
deadline: Date | undefined,
|
|
417
|
+
): Promise<[ProcessedTx, NestedProcessReturnValues[], DebugLog[]]> {
|
|
418
|
+
const [time, [processedTx, returnValues, debugLogs]] = await elapsed(() =>
|
|
419
|
+
this.processTxWithinDeadline(tx, deadline),
|
|
420
|
+
);
|
|
363
421
|
|
|
364
422
|
this.log.verbose(
|
|
365
423
|
!tx.hasPublicCalls()
|
|
@@ -382,7 +440,7 @@ export class PublicProcessor implements Traceable {
|
|
|
382
440
|
},
|
|
383
441
|
);
|
|
384
442
|
|
|
385
|
-
return [processedTx, returnValues ?? []];
|
|
443
|
+
return [processedTx, returnValues ?? [], debugLogs];
|
|
386
444
|
}
|
|
387
445
|
|
|
388
446
|
private async doTreeInsertionsForPrivateOnlyTx(processedTx: ProcessedTx): Promise<void> {
|
|
@@ -416,10 +474,9 @@ export class PublicProcessor implements Traceable {
|
|
|
416
474
|
private async processTxWithinDeadline(
|
|
417
475
|
tx: Tx,
|
|
418
476
|
deadline: Date | undefined,
|
|
419
|
-
): Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined]> {
|
|
420
|
-
const innerProcessFn: () => Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined]> =
|
|
421
|
-
? () => this.processTxWithPublicCalls(tx)
|
|
422
|
-
: () => this.processPrivateOnlyTx(tx);
|
|
477
|
+
): Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined, DebugLog[]]> {
|
|
478
|
+
const innerProcessFn: () => Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined, DebugLog[]]> =
|
|
479
|
+
tx.hasPublicCalls() ? () => this.processTxWithPublicCalls(tx) : () => this.processPrivateOnlyTx(tx);
|
|
423
480
|
|
|
424
481
|
// Fake a delay per tx if instructed (used for tests)
|
|
425
482
|
const fakeDelayPerTxMs = this.opts.fakeProcessingDelayPerTxMs;
|
|
@@ -487,7 +544,7 @@ export class PublicProcessor implements Traceable {
|
|
|
487
544
|
@trackSpan('PublicProcessor.processPrivateOnlyTx', (tx: Tx) => ({
|
|
488
545
|
[Attributes.TX_HASH]: tx.getTxHash().toString(),
|
|
489
546
|
}))
|
|
490
|
-
private async processPrivateOnlyTx(tx: Tx): Promise<[ProcessedTx, undefined]> {
|
|
547
|
+
private async processPrivateOnlyTx(tx: Tx): Promise<[ProcessedTx, undefined, DebugLog[]]> {
|
|
491
548
|
const gasFees = this.globalVariables.gasFees;
|
|
492
549
|
const transactionFee = computeTransactionFee(gasFees, tx.data.constants.txContext.gasSettings, tx.data.gasUsed);
|
|
493
550
|
|
|
@@ -510,24 +567,20 @@ export class PublicProcessor implements Traceable {
|
|
|
510
567
|
// Fee payment insertion has already been done. Do the rest.
|
|
511
568
|
await this.doTreeInsertionsForPrivateOnlyTx(processedTx);
|
|
512
569
|
|
|
513
|
-
|
|
570
|
+
this.contractsDB.addNewContracts(tx);
|
|
514
571
|
|
|
515
|
-
return [processedTx, undefined];
|
|
572
|
+
return [processedTx, undefined, []];
|
|
516
573
|
}
|
|
517
574
|
|
|
518
575
|
@trackSpan('PublicProcessor.processTxWithPublicCalls', tx => ({
|
|
519
576
|
[Attributes.TX_HASH]: tx.getTxHash().toString(),
|
|
520
577
|
}))
|
|
521
|
-
private async processTxWithPublicCalls(tx: Tx): Promise<[ProcessedTx, NestedProcessReturnValues[]]> {
|
|
578
|
+
private async processTxWithPublicCalls(tx: Tx): Promise<[ProcessedTx, NestedProcessReturnValues[], DebugLog[]]> {
|
|
522
579
|
const timer = new Timer();
|
|
523
580
|
|
|
524
|
-
const
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
if (!hints) {
|
|
528
|
-
this.metrics.recordFailedTx();
|
|
529
|
-
throw new Error('Avm proving result was not generated.');
|
|
530
|
-
}
|
|
581
|
+
const result = await this.publicTxSimulator.simulate(tx);
|
|
582
|
+
// TODO: use the callStackMetadata here to extract more data about public execution
|
|
583
|
+
const { hints, publicInputs, publicTxEffect, gasUsed, revertCode /*callStackMetadata*/ } = result;
|
|
531
584
|
|
|
532
585
|
const contractClassLogs = revertCode.isOK()
|
|
533
586
|
? tx.getContractClassLogs()
|
|
@@ -539,19 +592,28 @@ export class PublicProcessor implements Traceable {
|
|
|
539
592
|
);
|
|
540
593
|
|
|
541
594
|
// TODO(fcarreiro): remove phase count metric.
|
|
542
|
-
const phaseCount = 1;
|
|
543
595
|
const durationMs = timer.ms();
|
|
544
|
-
this.metrics.recordTx(phaseCount, durationMs, gasUsed.publicGas);
|
|
596
|
+
this.metrics.recordTx(/*phaseCount=*/ 1, durationMs, gasUsed.publicGas);
|
|
597
|
+
|
|
598
|
+
// Extract the return values from the call stack metadata.
|
|
599
|
+
const appLogicReturnValues: NestedProcessReturnValues[] = result.getAppLogicReturnValues();
|
|
600
|
+
// Extract the revert reason from the call stack metadata.
|
|
601
|
+
const revertReason = result.findRevertReason();
|
|
602
|
+
// Create proving request if we have hints and public inputs.
|
|
603
|
+
const avmProvingRequest =
|
|
604
|
+
hints && publicInputs ? PublicProcessor.generateProvingRequest(publicInputs, hints) : undefined;
|
|
545
605
|
|
|
546
606
|
const processedTx = makeProcessedTxFromTxWithPublicCalls(
|
|
547
607
|
tx,
|
|
548
|
-
|
|
608
|
+
this.globalVariables,
|
|
609
|
+
avmProvingRequest,
|
|
610
|
+
publicTxEffect,
|
|
549
611
|
gasUsed,
|
|
550
612
|
revertCode,
|
|
551
613
|
revertReason,
|
|
552
614
|
);
|
|
553
615
|
|
|
554
|
-
return [processedTx, appLogicReturnValues ?? []];
|
|
616
|
+
return [processedTx, appLogicReturnValues, result.logs ?? []];
|
|
555
617
|
}
|
|
556
618
|
|
|
557
619
|
/**
|
|
@@ -559,7 +621,7 @@ export class PublicProcessor implements Traceable {
|
|
|
559
621
|
*/
|
|
560
622
|
private static generateProvingRequest(
|
|
561
623
|
publicInputs: AvmCircuitPublicInputs,
|
|
562
|
-
hints: AvmExecutionHints,
|
|
624
|
+
hints: AvmExecutionHints = AvmExecutionHints.empty(),
|
|
563
625
|
): AvmProvingRequest {
|
|
564
626
|
return {
|
|
565
627
|
type: ProvingRequestType.PUBLIC_VM,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ContractClassPublishedEvent } from '@aztec/protocol-contracts/class-registry';
|
|
2
2
|
import type { Gas } from '@aztec/stdlib/gas';
|
|
3
|
-
import
|
|
3
|
+
import { TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
4
4
|
import {
|
|
5
5
|
Attributes,
|
|
6
6
|
type Gauge,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
type TelemetryClient,
|
|
10
10
|
type Tracer,
|
|
11
11
|
type UpDownCounter,
|
|
12
|
-
|
|
12
|
+
createUpDownCounterWithDefault,
|
|
13
13
|
} from '@aztec/telemetry-client';
|
|
14
14
|
|
|
15
15
|
export class PublicProcessorMetrics {
|
|
@@ -30,64 +30,43 @@ export class PublicProcessorMetrics {
|
|
|
30
30
|
|
|
31
31
|
private treeInsertionDuration: Histogram;
|
|
32
32
|
|
|
33
|
+
private silentlySkippedCount: UpDownCounter;
|
|
34
|
+
private silentlySkippedDuration: Histogram;
|
|
35
|
+
|
|
33
36
|
constructor(client: TelemetryClient, name = 'PublicProcessor') {
|
|
34
37
|
this.tracer = client.getTracer(name);
|
|
35
38
|
const meter = client.getMeter(name);
|
|
36
39
|
|
|
37
|
-
this.txDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_TX_DURATION
|
|
38
|
-
description: 'How long it takes to process a transaction',
|
|
39
|
-
unit: 'ms',
|
|
40
|
-
valueType: ValueType.INT,
|
|
41
|
-
});
|
|
40
|
+
this.txDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_TX_DURATION);
|
|
42
41
|
|
|
43
|
-
this.txCount = meter
|
|
44
|
-
|
|
42
|
+
this.txCount = createUpDownCounterWithDefault(meter, Metrics.PUBLIC_PROCESSOR_TX_COUNT, {
|
|
43
|
+
[Attributes.OK]: [true, false],
|
|
45
44
|
});
|
|
46
45
|
|
|
47
|
-
this.txPhaseCount = meter
|
|
48
|
-
description: 'Number of phases processed',
|
|
49
|
-
});
|
|
46
|
+
this.txPhaseCount = createUpDownCounterWithDefault(meter, Metrics.PUBLIC_PROCESSOR_TX_PHASE_COUNT);
|
|
50
47
|
|
|
51
|
-
this.phaseDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_PHASE_DURATION
|
|
52
|
-
description: 'How long it takes to process a phase',
|
|
53
|
-
unit: 'ms',
|
|
54
|
-
valueType: ValueType.INT,
|
|
55
|
-
});
|
|
48
|
+
this.phaseDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_PHASE_DURATION);
|
|
56
49
|
|
|
57
|
-
this.phaseCount = meter
|
|
58
|
-
|
|
50
|
+
this.phaseCount = createUpDownCounterWithDefault(meter, Metrics.PUBLIC_PROCESSOR_PHASE_COUNT, {
|
|
51
|
+
[Attributes.TX_PHASE_NAME]: [TxExecutionPhase.SETUP, TxExecutionPhase.APP_LOGIC, TxExecutionPhase.TEARDOWN],
|
|
52
|
+
[Attributes.OK]: [true, false],
|
|
59
53
|
});
|
|
60
54
|
|
|
61
|
-
this.bytecodeDeployed = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_DEPLOY_BYTECODE_SIZE
|
|
62
|
-
description: 'Size of deployed bytecode',
|
|
63
|
-
unit: 'By',
|
|
64
|
-
});
|
|
55
|
+
this.bytecodeDeployed = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_DEPLOY_BYTECODE_SIZE);
|
|
65
56
|
|
|
66
|
-
this.totalGas = meter.createGauge(Metrics.PUBLIC_PROCESSOR_TOTAL_GAS
|
|
67
|
-
description: 'Total gas used in block',
|
|
68
|
-
unit: 'gas',
|
|
69
|
-
});
|
|
57
|
+
this.totalGas = meter.createGauge(Metrics.PUBLIC_PROCESSOR_TOTAL_GAS);
|
|
70
58
|
|
|
71
|
-
this.totalGasHistogram = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_TOTAL_GAS_HISTOGRAM
|
|
72
|
-
description: 'Total gas used in block as histogram',
|
|
73
|
-
unit: 'gas/block',
|
|
74
|
-
});
|
|
59
|
+
this.totalGasHistogram = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_TOTAL_GAS_HISTOGRAM);
|
|
75
60
|
|
|
76
|
-
this.txGas = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_TX_GAS
|
|
77
|
-
description: 'Gas used in transaction',
|
|
78
|
-
unit: 'gas/tx',
|
|
79
|
-
});
|
|
61
|
+
this.txGas = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_TX_GAS);
|
|
80
62
|
|
|
81
|
-
this.gasRate = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_GAS_RATE
|
|
82
|
-
description: 'L2 gas per second for complete block',
|
|
83
|
-
unit: 'gas/s',
|
|
84
|
-
});
|
|
63
|
+
this.gasRate = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_GAS_RATE);
|
|
85
64
|
|
|
86
|
-
this.treeInsertionDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_TREE_INSERTION
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
65
|
+
this.treeInsertionDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_TREE_INSERTION);
|
|
66
|
+
|
|
67
|
+
this.silentlySkippedCount = createUpDownCounterWithDefault(meter, Metrics.PUBLIC_PROCESSOR_SILENTLY_SKIPPED_COUNT);
|
|
68
|
+
|
|
69
|
+
this.silentlySkippedDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_SILENTLY_SKIPPED_DURATION);
|
|
91
70
|
}
|
|
92
71
|
|
|
93
72
|
recordPhaseDuration(phaseName: TxExecutionPhase, durationMs: number) {
|
|
@@ -151,4 +130,9 @@ export class PublicProcessorMetrics {
|
|
|
151
130
|
recordTreeInsertions(durationUs: number) {
|
|
152
131
|
this.treeInsertionDuration.record(Math.ceil(durationUs));
|
|
153
132
|
}
|
|
133
|
+
|
|
134
|
+
recordSilentlySkipped(durationMs: number) {
|
|
135
|
+
this.silentlySkippedCount.add(1);
|
|
136
|
+
this.silentlySkippedDuration.record(Math.ceil(durationMs));
|
|
137
|
+
}
|
|
154
138
|
}
|