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