@aztec/simulator 0.0.1-fake-ceab37513c → 0.0.2-commit.217f559981
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 +6 -5
- package/dest/private/acvm_native.d.ts.map +1 -1
- package/dest/private/acvm_native.js +23 -19
- package/dest/private/acvm_wasm.d.ts +4 -3
- package/dest/private/acvm_wasm.d.ts.map +1 -1
- package/dest/private/acvm_wasm.js +4 -4
- package/dest/private/acvm_wasm_with_blobs.d.ts +1 -1
- package/dest/private/acvm_wasm_with_blobs.d.ts.map +1 -1
- package/dest/private/circuit_recording/circuit_recorder.d.ts +4 -3
- package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/circuit_recorder.js +21 -18
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts +3 -2
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/file_circuit_recorder.js +2 -2
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +7 -2
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/memory_circuit_recorder.js +4 -4
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts +2 -2
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts.map +1 -1
- package/dest/private/circuit_simulator.d.ts +1 -1
- package/dest/private/factory.d.ts +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 -7
- package/dest/public/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/public/avm/avm_execution_environment.js +5 -5
- package/dest/public/avm/avm_gas.d.ts +2 -2
- package/dest/public/avm/avm_gas.d.ts.map +1 -1
- package/dest/public/avm/avm_gas.js +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 +24 -29
- 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 +13 -16
- package/dest/public/avm/errors.d.ts.map +1 -1
- package/dest/public/avm/errors.js +21 -22
- package/dest/public/avm/fixtures/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 +3 -2
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.js +17 -8
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +4 -2
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/base_avm_simulation_tester.js +23 -1
- package/dest/public/avm/fixtures/initializers.d.ts +2 -3
- package/dest/public/avm/fixtures/initializers.d.ts.map +1 -1
- package/dest/public/avm/fixtures/initializers.js +7 -4
- package/dest/public/avm/fixtures/utils.d.ts +4 -3
- package/dest/public/avm/fixtures/utils.d.ts.map +1 -1
- package/dest/public/avm/fixtures/utils.js +3 -2
- package/dest/public/avm/index.d.ts +1 -1
- package/dest/public/avm/opcodes/accrued_substate.d.ts +18 -19
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/public/avm/opcodes/accrued_substate.js +47 -48
- package/dest/public/avm/opcodes/addressing_mode.d.ts +1 -1
- package/dest/public/avm/opcodes/addressing_mode.d.ts.map +1 -1
- package/dest/public/avm/opcodes/addressing_mode.js +4 -5
- package/dest/public/avm/opcodes/arithmetic.d.ts +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 +7 -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 +20 -11
- 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 +11 -13
- 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 -23
- 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.js +5 -6
- 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 +4 -3
- package/dest/public/avm/opcodes/misc.d.ts.map +1 -1
- package/dest/public/avm/opcodes/misc.js +30 -10
- 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 +10 -2
- package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/instruction_serialization.js +12 -2
- package/dest/public/avm/test_utils.d.ts +4 -4
- package/dest/public/avm/test_utils.d.ts.map +1 -1
- package/dest/public/avm/test_utils.js +7 -10
- package/dest/public/contracts_db_checkpoint.d.ts +16 -0
- package/dest/public/contracts_db_checkpoint.d.ts.map +1 -0
- package/dest/public/contracts_db_checkpoint.js +30 -0
- package/dest/public/db_interfaces.d.ts +14 -2
- package/dest/public/db_interfaces.d.ts.map +1 -1
- package/dest/public/debug_fn_name.d.ts +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 +63 -194
- package/dest/public/fixtures/custom_bytecode_tester.d.ts +34 -0
- package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -0
- package/dest/public/fixtures/custom_bytecode_tester.js +53 -0
- package/dest/public/fixtures/custom_bytecode_tests.d.ts +12 -0
- package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -0
- package/dest/public/fixtures/custom_bytecode_tests.js +174 -0
- package/dest/public/fixtures/index.d.ts +5 -2
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +4 -1
- package/dest/public/fixtures/minimal_public_tx.d.ts +4 -9
- package/dest/public/fixtures/minimal_public_tx.d.ts.map +1 -1
- package/dest/public/fixtures/minimal_public_tx.js +10 -34
- 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 +25 -5
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +63 -17
- package/dest/public/fixtures/simple_contract_data_source.d.ts +5 -4
- package/dest/public/fixtures/simple_contract_data_source.d.ts.map +1 -1
- package/dest/public/fixtures/simple_contract_data_source.js +4 -4
- package/dest/public/fixtures/token_test.d.ts +6 -2
- package/dest/public/fixtures/token_test.d.ts.map +1 -1
- package/dest/public/fixtures/token_test.js +13 -12
- package/dest/public/fixtures/utils.d.ts +2 -2
- package/dest/public/fixtures/utils.d.ts.map +1 -1
- package/dest/public/fixtures/utils.js +11 -10
- 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 +16 -4
- package/dest/public/hinting_db_sources.d.ts.map +1 -1
- package/dest/public/hinting_db_sources.js +74 -13
- package/dest/public/index.d.ts +3 -2
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +1 -1
- package/dest/public/public_db_sources.d.ts +27 -67
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +89 -136
- package/dest/public/public_errors.d.ts +12 -0
- package/dest/public/public_errors.d.ts.map +1 -0
- package/dest/public/public_errors.js +13 -0
- package/dest/public/public_processor/guarded_merkle_tree.d.ts +6 -2
- package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
- package/dest/public/public_processor/guarded_merkle_tree.js +8 -0
- package/dest/public/public_processor/public_processor.d.ts +16 -15
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +477 -70
- package/dest/public/public_processor/public_processor_metrics.d.ts +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 +53 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +132 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts +42 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.js +86 -0
- package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts +30 -0
- package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.js +171 -0
- package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts +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 +6 -1
- package/dest/public/public_tx_simulator/index.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/index.js +3 -0
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +16 -8
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.js +7 -8
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +11 -5
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +26 -14
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +26 -31
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +186 -130
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts +32 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.js +1 -0
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts +4 -3
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.js +396 -20
- package/dest/public/side_effect_errors.d.ts +42 -2
- package/dest/public/side_effect_errors.d.ts.map +1 -1
- package/dest/public/side_effect_errors.js +70 -1
- package/dest/public/side_effect_trace.d.ts +15 -8
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +38 -23
- package/dest/public/side_effect_trace_interface.d.ts +9 -4
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
- package/dest/public/state_manager/index.d.ts +1 -1
- package/dest/public/state_manager/nullifiers.d.ts +2 -5
- package/dest/public/state_manager/nullifiers.d.ts.map +1 -1
- package/dest/public/state_manager/nullifiers.js +1 -6
- package/dest/public/state_manager/public_storage.d.ts +2 -2
- package/dest/public/state_manager/public_storage.d.ts.map +1 -1
- package/dest/public/state_manager/public_storage.js +1 -1
- package/dest/public/state_manager/state_manager.d.ts +22 -13
- package/dest/public/state_manager/state_manager.d.ts.map +1 -1
- package/dest/public/state_manager/state_manager.js +75 -25
- package/dest/public/test_executor_metrics.d.ts +6 -4
- package/dest/public/test_executor_metrics.d.ts.map +1 -1
- package/dest/public/test_executor_metrics.js +7 -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 +24 -19
- 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 +29 -16
- package/src/private/acvm_wasm.ts +7 -3
- package/src/private/circuit_recording/circuit_recorder.ts +22 -19
- package/src/private/circuit_recording/file_circuit_recorder.ts +7 -2
- package/src/private/circuit_recording/memory_circuit_recorder.ts +6 -4
- package/src/private/circuit_recording/simulator_recorder_wrapper.ts +1 -1
- 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 -7
- 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 +32 -38
- package/src/public/avm/calldata.ts +100 -0
- package/src/public/avm/errors.ts +24 -27
- 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 +22 -6
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +33 -1
- package/src/public/avm/fixtures/initializers.ts +9 -9
- package/src/public/avm/fixtures/utils.ts +3 -2
- package/src/public/avm/opcodes/accrued_substate.ts +35 -38
- package/src/public/avm/opcodes/addressing_mode.ts +5 -5
- 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 +7 -3
- package/src/public/avm/opcodes/ec_add.ts +18 -9
- package/src/public/avm/opcodes/environment_getters.ts +13 -15
- package/src/public/avm/opcodes/external_calls.ts +17 -16
- package/src/public/avm/opcodes/hashing.ts +16 -10
- package/src/public/avm/opcodes/instruction.ts +8 -6
- 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 +43 -9
- 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 +14 -2
- package/src/public/avm/test_utils.ts +7 -15
- package/src/public/contracts_db_checkpoint.ts +41 -0
- package/src/public/db_interfaces.ts +16 -1
- package/src/public/debug_fn_name.ts +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 +46 -28
- package/src/public/fixtures/custom_bytecode_tester.ts +83 -0
- package/src/public/fixtures/custom_bytecode_tests.ts +228 -0
- package/src/public/fixtures/index.ts +8 -1
- package/src/public/fixtures/minimal_public_tx.ts +11 -44
- package/src/public/fixtures/opcode_spammer.ts +1717 -0
- package/src/public/fixtures/public_tx_simulation_tester.ts +90 -22
- package/src/public/fixtures/simple_contract_data_source.ts +8 -9
- package/src/public/fixtures/token_test.ts +18 -10
- package/src/public/fixtures/utils.ts +9 -10
- 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 +117 -10
- package/src/public/index.ts +8 -1
- package/src/public/public_db_sources.ts +126 -179
- package/src/public/public_errors.ts +14 -0
- package/src/public/public_processor/guarded_merkle_tree.ts +10 -1
- package/src/public/public_processor/public_processor.ts +123 -79
- 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 +211 -0
- 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 +43 -0
- package/src/public/public_tx_simulator/index.ts +5 -0
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +13 -14
- package/src/public/public_tx_simulator/public_tx_context.ts +33 -13
- package/src/public/public_tx_simulator/public_tx_simulator.ts +281 -184
- package/src/public/public_tx_simulator/public_tx_simulator_interface.ts +33 -0
- package/src/public/public_tx_simulator/telemetry_public_tx_simulator.ts +4 -13
- package/src/public/side_effect_errors.ts +91 -1
- package/src/public/side_effect_trace.ts +53 -25
- package/src/public/side_effect_trace_interface.ts +7 -1
- package/src/public/state_manager/nullifiers.ts +2 -8
- package/src/public/state_manager/public_storage.ts +1 -1
- package/src/public/state_manager/state_manager.ts +107 -50
- package/src/public/test_executor_metrics.ts +10 -8
- package/dest/public/bytecode_errors.d.ts +0 -4
- package/dest/public/bytecode_errors.d.ts.map +0 -1
- package/dest/public/bytecode_errors.js +0 -6
- package/dest/public/tx_contract_cache.d.ts +0 -41
- package/dest/public/tx_contract_cache.d.ts.map +0 -1
- package/dest/public/tx_contract_cache.js +0 -49
- package/src/public/bytecode_errors.ts +0 -6
- package/src/public/tx_contract_cache.ts +0 -69
|
@@ -1,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 } 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';
|
|
@@ -40,8 +48,14 @@ import {
|
|
|
40
48
|
} from '@aztec/telemetry-client';
|
|
41
49
|
import { ForkCheckpoint } from '@aztec/world-state/native';
|
|
42
50
|
|
|
51
|
+
import { AssertionError } from 'assert';
|
|
52
|
+
|
|
43
53
|
import { PublicContractsDB, PublicTreesDB } from '../public_db_sources.js';
|
|
44
|
-
import {
|
|
54
|
+
import {
|
|
55
|
+
type PublicTxSimulatorConfig,
|
|
56
|
+
type PublicTxSimulatorInterface,
|
|
57
|
+
TelemetryCppPublicTxSimulator,
|
|
58
|
+
} from '../public_tx_simulator/index.js';
|
|
45
59
|
import { GuardedMerkleTreeOperations } from './guarded_merkle_tree.js';
|
|
46
60
|
import { PublicProcessorMetrics } from './public_processor_metrics.js';
|
|
47
61
|
|
|
@@ -49,15 +63,18 @@ import { PublicProcessorMetrics } from './public_processor_metrics.js';
|
|
|
49
63
|
* Creates new instances of PublicProcessor given the provided merkle tree db and contract data source.
|
|
50
64
|
*/
|
|
51
65
|
export class PublicProcessorFactory {
|
|
66
|
+
private log: Logger;
|
|
52
67
|
constructor(
|
|
53
68
|
private contractDataSource: ContractDataSource,
|
|
54
69
|
private dateProvider: DateProvider = new DateProvider(),
|
|
55
70
|
protected telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
56
|
-
|
|
71
|
+
bindings?: LoggerBindings,
|
|
72
|
+
) {
|
|
73
|
+
this.log = createLogger('simulator:public-processor-factory', bindings);
|
|
74
|
+
}
|
|
57
75
|
|
|
58
76
|
/**
|
|
59
77
|
* Creates a new instance of a PublicProcessor.
|
|
60
|
-
* @param historicalHeader - The header of a block previous to the one in which the tx is included.
|
|
61
78
|
* @param globalVariables - The global variables for the block being processed.
|
|
62
79
|
* @param skipFeeEnforcement - Allows disabling balance checks for fee estimations.
|
|
63
80
|
* @returns A new instance of a PublicProcessor.
|
|
@@ -65,20 +82,13 @@ export class PublicProcessorFactory {
|
|
|
65
82
|
public create(
|
|
66
83
|
merkleTree: MerkleTreeWriteOperations,
|
|
67
84
|
globalVariables: GlobalVariables,
|
|
68
|
-
|
|
69
|
-
clientInitiatedSimulation: boolean = false,
|
|
85
|
+
config: PublicSimulatorConfig,
|
|
70
86
|
): PublicProcessor {
|
|
71
|
-
const
|
|
87
|
+
const bindings = this.log.getBindings();
|
|
88
|
+
const contractsDB = new PublicContractsDB(this.contractDataSource, bindings);
|
|
72
89
|
|
|
73
90
|
const guardedFork = new GuardedMerkleTreeOperations(merkleTree);
|
|
74
|
-
const publicTxSimulator = this.createPublicTxSimulator(
|
|
75
|
-
guardedFork,
|
|
76
|
-
contractsDB,
|
|
77
|
-
globalVariables,
|
|
78
|
-
/*doMerkleOperations=*/ true,
|
|
79
|
-
skipFeeEnforcement,
|
|
80
|
-
clientInitiatedSimulation,
|
|
81
|
-
);
|
|
91
|
+
const publicTxSimulator = this.createPublicTxSimulator(guardedFork, contractsDB, globalVariables, config);
|
|
82
92
|
|
|
83
93
|
return new PublicProcessor(
|
|
84
94
|
globalVariables,
|
|
@@ -87,6 +97,7 @@ export class PublicProcessorFactory {
|
|
|
87
97
|
publicTxSimulator,
|
|
88
98
|
this.dateProvider,
|
|
89
99
|
this.telemetryClient,
|
|
100
|
+
createLogger('simulator:public-processor', bindings),
|
|
90
101
|
);
|
|
91
102
|
}
|
|
92
103
|
|
|
@@ -94,18 +105,15 @@ export class PublicProcessorFactory {
|
|
|
94
105
|
merkleTree: MerkleTreeWriteOperations,
|
|
95
106
|
contractsDB: PublicContractsDB,
|
|
96
107
|
globalVariables: GlobalVariables,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
): PublicTxSimulator {
|
|
101
|
-
return new TelemetryPublicTxSimulator(
|
|
108
|
+
config?: Partial<PublicTxSimulatorConfig>,
|
|
109
|
+
): PublicTxSimulatorInterface {
|
|
110
|
+
return new TelemetryCppPublicTxSimulator(
|
|
102
111
|
merkleTree,
|
|
103
112
|
contractsDB,
|
|
104
113
|
globalVariables,
|
|
105
|
-
doMerkleOperations,
|
|
106
|
-
skipFeeEnforcement,
|
|
107
|
-
clientInitiatedSimulation,
|
|
108
114
|
this.telemetryClient,
|
|
115
|
+
config,
|
|
116
|
+
this.log.getBindings(),
|
|
109
117
|
);
|
|
110
118
|
}
|
|
111
119
|
}
|
|
@@ -123,16 +131,15 @@ class PublicProcessorTimeoutError extends Error {
|
|
|
123
131
|
*/
|
|
124
132
|
export class PublicProcessor implements Traceable {
|
|
125
133
|
private metrics: PublicProcessorMetrics;
|
|
126
|
-
|
|
127
134
|
constructor(
|
|
128
135
|
protected globalVariables: GlobalVariables,
|
|
129
136
|
private guardedMerkleTree: GuardedMerkleTreeOperations,
|
|
130
137
|
protected contractsDB: PublicContractsDB,
|
|
131
|
-
protected publicTxSimulator:
|
|
138
|
+
protected publicTxSimulator: PublicTxSimulatorInterface,
|
|
132
139
|
private dateProvider: DateProvider,
|
|
133
140
|
telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
134
|
-
private log
|
|
135
|
-
private opts: Pick<SequencerConfig, 'fakeProcessingDelayPerTxMs'> = {},
|
|
141
|
+
private log: Logger,
|
|
142
|
+
private opts: Pick<SequencerConfig, 'fakeProcessingDelayPerTxMs' | 'fakeThrowAfterProcessingTxCount'> = {},
|
|
136
143
|
) {
|
|
137
144
|
this.metrics = new PublicProcessorMetrics(telemetryClient, 'PublicProcessor');
|
|
138
145
|
}
|
|
@@ -152,12 +159,13 @@ export class PublicProcessor implements Traceable {
|
|
|
152
159
|
txs: Iterable<Tx> | AsyncIterable<Tx>,
|
|
153
160
|
limits: PublicProcessorLimits = {},
|
|
154
161
|
validator: PublicProcessorValidator = {},
|
|
155
|
-
): Promise<[ProcessedTx[], FailedTx[], Tx[], NestedProcessReturnValues[]]> {
|
|
162
|
+
): Promise<[ProcessedTx[], FailedTx[], Tx[], NestedProcessReturnValues[], number, DebugLog[]]> {
|
|
156
163
|
const { maxTransactions, maxBlockSize, deadline, maxBlockGas, maxBlobFields } = limits;
|
|
157
164
|
const { preprocessValidator, nullifierCache } = validator;
|
|
158
165
|
const result: ProcessedTx[] = [];
|
|
159
166
|
const usedTxs: Tx[] = [];
|
|
160
167
|
const failed: FailedTx[] = [];
|
|
168
|
+
const debugLogs: DebugLog[] = [];
|
|
161
169
|
const timer = new Timer();
|
|
162
170
|
|
|
163
171
|
let totalSizeInBytes = 0;
|
|
@@ -166,7 +174,7 @@ export class PublicProcessor implements Traceable {
|
|
|
166
174
|
let totalBlockGas = new Gas(0, 0);
|
|
167
175
|
let totalBlobFields = 0;
|
|
168
176
|
|
|
169
|
-
for await (const
|
|
177
|
+
for await (const tx of txs) {
|
|
170
178
|
// Only process up to the max tx limit
|
|
171
179
|
if (maxTransactions !== undefined && result.length >= maxTransactions) {
|
|
172
180
|
this.log.debug(`Stopping tx processing due to reaching the max tx limit.`);
|
|
@@ -180,8 +188,8 @@ export class PublicProcessor implements Traceable {
|
|
|
180
188
|
}
|
|
181
189
|
|
|
182
190
|
// Skip this tx if it'd exceed max block size
|
|
183
|
-
const txHash =
|
|
184
|
-
const preTxSizeInBytes =
|
|
191
|
+
const txHash = tx.getTxHash().toString();
|
|
192
|
+
const preTxSizeInBytes = tx.getEstimatedPrivateTxEffectsSize();
|
|
185
193
|
if (maxBlockSize !== undefined && totalSizeInBytes + preTxSizeInBytes > maxBlockSize) {
|
|
186
194
|
this.log.warn(`Skipping processing of tx ${txHash} sized ${preTxSizeInBytes} bytes due to block size limit`, {
|
|
187
195
|
txHash,
|
|
@@ -193,7 +201,7 @@ export class PublicProcessor implements Traceable {
|
|
|
193
201
|
}
|
|
194
202
|
|
|
195
203
|
// Skip this tx if its gas limit would exceed the block gas limit
|
|
196
|
-
const txGasLimit =
|
|
204
|
+
const txGasLimit = tx.data.constants.txContext.gasSettings.gasLimits;
|
|
197
205
|
if (maxBlockGas !== undefined && totalBlockGas.add(txGasLimit).gtAny(maxBlockGas)) {
|
|
198
206
|
this.log.warn(`Skipping processing of tx ${txHash} due to block gas limit`, {
|
|
199
207
|
txHash,
|
|
@@ -204,9 +212,6 @@ export class PublicProcessor implements Traceable {
|
|
|
204
212
|
continue;
|
|
205
213
|
}
|
|
206
214
|
|
|
207
|
-
// The processor modifies the tx objects in place, so we need to clone them.
|
|
208
|
-
const tx = Tx.clone(origTx);
|
|
209
|
-
|
|
210
215
|
// We validate the tx before processing it, to avoid unnecessary work.
|
|
211
216
|
if (preprocessValidator) {
|
|
212
217
|
const result = await preprocessValidator.validateTx(tx);
|
|
@@ -234,12 +239,21 @@ export class PublicProcessor implements Traceable {
|
|
|
234
239
|
// Note: We use the underlying fork here not the guarded one, this ensures that it's not impacted by stopping the guarded version
|
|
235
240
|
const checkpoint = await ForkCheckpoint.new(this.guardedMerkleTree.getUnderlyingFork());
|
|
236
241
|
const startStateReference = await this.guardedMerkleTree.getUnderlyingFork().getStateReference();
|
|
242
|
+
this.contractsDB.createCheckpoint();
|
|
237
243
|
|
|
238
244
|
try {
|
|
239
|
-
const [processedTx, returnValues] = await this.processTx(tx, deadline);
|
|
245
|
+
const [processedTx, returnValues, txDebugLogs] = await this.processTx(tx, deadline);
|
|
246
|
+
|
|
247
|
+
// Inject a fake processing failure after N txs if requested
|
|
248
|
+
const fakeThrowAfter = this.opts.fakeThrowAfterProcessingTxCount;
|
|
249
|
+
if (fakeThrowAfter !== undefined && result.length + failed.length + 1 >= fakeThrowAfter) {
|
|
250
|
+
throw new Error(`Fake error after processing ${fakeThrowAfter} txs`);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const txBlobFields = processedTx.txEffect.getNumBlobFields();
|
|
240
254
|
|
|
241
255
|
// If the actual size of this tx would exceed block size, skip it
|
|
242
|
-
const txSize =
|
|
256
|
+
const txSize = txBlobFields * Fr.SIZE_IN_BYTES;
|
|
243
257
|
if (maxBlockSize !== undefined && totalSizeInBytes + txSize > maxBlockSize) {
|
|
244
258
|
this.log.debug(`Skipping processed tx ${txHash} sized ${txSize} due to max block size.`, {
|
|
245
259
|
txHash,
|
|
@@ -249,11 +263,12 @@ export class PublicProcessor implements Traceable {
|
|
|
249
263
|
});
|
|
250
264
|
// Need to revert the checkpoint here and don't go any further
|
|
251
265
|
await checkpoint.revert();
|
|
266
|
+
this.contractsDB.revertCheckpoint();
|
|
252
267
|
continue;
|
|
253
268
|
}
|
|
254
269
|
|
|
255
270
|
// If the actual blob fields of this tx would exceed the limit, skip it
|
|
256
|
-
|
|
271
|
+
// Note: maxBlobFields already accounts for block end blob fields and previous blocks in checkpoint.
|
|
257
272
|
if (maxBlobFields !== undefined && totalBlobFields + txBlobFields > maxBlobFields) {
|
|
258
273
|
this.log.debug(
|
|
259
274
|
`Skipping processed tx ${txHash} with ${txBlobFields} blob fields due to max blob fields limit.`,
|
|
@@ -266,6 +281,7 @@ export class PublicProcessor implements Traceable {
|
|
|
266
281
|
);
|
|
267
282
|
// Need to revert the checkpoint here and don't go any further
|
|
268
283
|
await checkpoint.revert();
|
|
284
|
+
this.contractsDB.revertCheckpoint();
|
|
269
285
|
continue;
|
|
270
286
|
}
|
|
271
287
|
|
|
@@ -275,6 +291,7 @@ export class PublicProcessor implements Traceable {
|
|
|
275
291
|
result.push(processedTx);
|
|
276
292
|
usedTxs.push(tx);
|
|
277
293
|
returns = returns.concat(returnValues);
|
|
294
|
+
debugLogs.push(...txDebugLogs);
|
|
278
295
|
|
|
279
296
|
totalPublicGas = totalPublicGas.add(processedTx.gasUsed.publicGas);
|
|
280
297
|
totalBlockGas = totalBlockGas.add(processedTx.gasUsed.totalGas);
|
|
@@ -284,7 +301,15 @@ export class PublicProcessor implements Traceable {
|
|
|
284
301
|
if (err?.name === 'PublicProcessorTimeoutError') {
|
|
285
302
|
this.log.warn(`Stopping tx processing due to timeout.`);
|
|
286
303
|
// We hit the transaction execution deadline.
|
|
287
|
-
// There may still be a transaction executing
|
|
304
|
+
// There may still be a transaction executing on a worker thread (C++ via NAPI).
|
|
305
|
+
// Signal cancellation AND WAIT for the simulation to actually stop.
|
|
306
|
+
// This is critical because C++ might be in the middle of a slow operation (e.g., pad_trees)
|
|
307
|
+
// and won't check the cancellation flag until that operation completes.
|
|
308
|
+
// Without waiting, we'd proceed to revert checkpoints while C++ is still writing to state.
|
|
309
|
+
// Wait for C++ to stop gracefully.
|
|
310
|
+
await this.publicTxSimulator.cancel?.();
|
|
311
|
+
|
|
312
|
+
// Now stop the guarded fork to prevent any further TS-side access to the world state.
|
|
288
313
|
await this.guardedMerkleTree.stop();
|
|
289
314
|
|
|
290
315
|
// We now know there can't be any further access to world state. The fork is in a state where there is:
|
|
@@ -300,6 +325,9 @@ export class PublicProcessor implements Traceable {
|
|
|
300
325
|
// This needs to be done directly on the underlying fork as the guarded fork has been stopped.
|
|
301
326
|
await this.guardedMerkleTree.getUnderlyingFork().revertAllCheckpoints();
|
|
302
327
|
|
|
328
|
+
// Revert any contracts added to the DB for the tx.
|
|
329
|
+
this.contractsDB.revertCheckpoint();
|
|
330
|
+
|
|
303
331
|
// Ensure we're at the same state as when we started processing this tx.
|
|
304
332
|
await this.checkWorldStateUnchanged(startStateReference, txHash, err);
|
|
305
333
|
|
|
@@ -310,7 +338,8 @@ export class PublicProcessor implements Traceable {
|
|
|
310
338
|
// Roll back state to start of TX before proceeding to next TX
|
|
311
339
|
await checkpoint.revert();
|
|
312
340
|
await this.guardedMerkleTree.getUnderlyingFork().revertAllCheckpoints();
|
|
313
|
-
|
|
341
|
+
this.contractsDB.revertCheckpoint();
|
|
342
|
+
const errorMessage = err instanceof Error || err instanceof AssertionError ? err.message : 'Unknown error';
|
|
314
343
|
this.log.warn(`Failed to process tx ${txHash.toString()}: ${errorMessage} ${err?.stack}`);
|
|
315
344
|
failed.push({ tx, error: err instanceof Error ? err : new Error(errorMessage) });
|
|
316
345
|
returns.push(new NestedProcessReturnValues([]));
|
|
@@ -320,8 +349,7 @@ export class PublicProcessor implements Traceable {
|
|
|
320
349
|
} finally {
|
|
321
350
|
// Base case is we always commit the checkpoint. Using the ForkCheckpoint means this has no effect if the tx was previously reverted
|
|
322
351
|
await checkpoint.commit();
|
|
323
|
-
|
|
324
|
-
this.contractsDB.clearContractsForTx();
|
|
352
|
+
this.contractsDB.commitCheckpointOkIfNone();
|
|
325
353
|
}
|
|
326
354
|
}
|
|
327
355
|
|
|
@@ -337,7 +365,7 @@ export class PublicProcessor implements Traceable {
|
|
|
337
365
|
totalSizeInBytes,
|
|
338
366
|
});
|
|
339
367
|
|
|
340
|
-
return [result, failed, usedTxs, returns];
|
|
368
|
+
return [result, failed, usedTxs, returns, totalBlobFields, debugLogs];
|
|
341
369
|
}
|
|
342
370
|
|
|
343
371
|
private async checkWorldStateUnchanged(
|
|
@@ -357,8 +385,13 @@ export class PublicProcessor implements Traceable {
|
|
|
357
385
|
}
|
|
358
386
|
|
|
359
387
|
@trackSpan('PublicProcessor.processTx', tx => ({ [Attributes.TX_HASH]: tx.getTxHash().toString() }))
|
|
360
|
-
private async processTx(
|
|
361
|
-
|
|
388
|
+
private async processTx(
|
|
389
|
+
tx: Tx,
|
|
390
|
+
deadline: Date | undefined,
|
|
391
|
+
): Promise<[ProcessedTx, NestedProcessReturnValues[], DebugLog[]]> {
|
|
392
|
+
const [time, [processedTx, returnValues, debugLogs]] = await elapsed(() =>
|
|
393
|
+
this.processTxWithinDeadline(tx, deadline),
|
|
394
|
+
);
|
|
362
395
|
|
|
363
396
|
this.log.verbose(
|
|
364
397
|
!tx.hasPublicCalls()
|
|
@@ -381,7 +414,7 @@ export class PublicProcessor implements Traceable {
|
|
|
381
414
|
},
|
|
382
415
|
);
|
|
383
416
|
|
|
384
|
-
return [processedTx, returnValues ?? []];
|
|
417
|
+
return [processedTx, returnValues ?? [], debugLogs];
|
|
385
418
|
}
|
|
386
419
|
|
|
387
420
|
private async doTreeInsertionsForPrivateOnlyTx(processedTx: ProcessedTx): Promise<void> {
|
|
@@ -415,10 +448,9 @@ export class PublicProcessor implements Traceable {
|
|
|
415
448
|
private async processTxWithinDeadline(
|
|
416
449
|
tx: Tx,
|
|
417
450
|
deadline: Date | undefined,
|
|
418
|
-
): Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined]> {
|
|
419
|
-
const innerProcessFn: () => Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined]> =
|
|
420
|
-
? () => this.processTxWithPublicCalls(tx)
|
|
421
|
-
: () => this.processPrivateOnlyTx(tx);
|
|
451
|
+
): Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined, DebugLog[]]> {
|
|
452
|
+
const innerProcessFn: () => Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined, DebugLog[]]> =
|
|
453
|
+
tx.hasPublicCalls() ? () => this.processTxWithPublicCalls(tx) : () => this.processPrivateOnlyTx(tx);
|
|
422
454
|
|
|
423
455
|
// Fake a delay per tx if instructed (used for tests)
|
|
424
456
|
const fakeDelayPerTxMs = this.opts.fakeProcessingDelayPerTxMs;
|
|
@@ -486,7 +518,7 @@ export class PublicProcessor implements Traceable {
|
|
|
486
518
|
@trackSpan('PublicProcessor.processPrivateOnlyTx', (tx: Tx) => ({
|
|
487
519
|
[Attributes.TX_HASH]: tx.getTxHash().toString(),
|
|
488
520
|
}))
|
|
489
|
-
private async processPrivateOnlyTx(tx: Tx): Promise<[ProcessedTx, undefined]> {
|
|
521
|
+
private async processPrivateOnlyTx(tx: Tx): Promise<[ProcessedTx, undefined, DebugLog[]]> {
|
|
490
522
|
const gasFees = this.globalVariables.gasFees;
|
|
491
523
|
const transactionFee = computeTransactionFee(gasFees, tx.data.constants.txContext.gasSettings, tx.data.gasUsed);
|
|
492
524
|
|
|
@@ -509,35 +541,20 @@ export class PublicProcessor implements Traceable {
|
|
|
509
541
|
// Fee payment insertion has already been done. Do the rest.
|
|
510
542
|
await this.doTreeInsertionsForPrivateOnlyTx(processedTx);
|
|
511
543
|
|
|
512
|
-
// Add any contracts registered/deployed in this private-only tx to the block-level cache
|
|
513
|
-
// (add to tx-level cache and then commit to block-level cache)
|
|
514
544
|
await this.contractsDB.addNewContracts(tx);
|
|
515
|
-
this.contractsDB.commitContractsForTx();
|
|
516
545
|
|
|
517
|
-
return [processedTx, undefined];
|
|
546
|
+
return [processedTx, undefined, []];
|
|
518
547
|
}
|
|
519
548
|
|
|
520
549
|
@trackSpan('PublicProcessor.processTxWithPublicCalls', tx => ({
|
|
521
550
|
[Attributes.TX_HASH]: tx.getTxHash().toString(),
|
|
522
551
|
}))
|
|
523
|
-
private async processTxWithPublicCalls(tx: Tx): Promise<[ProcessedTx, NestedProcessReturnValues[]]> {
|
|
552
|
+
private async processTxWithPublicCalls(tx: Tx): Promise<[ProcessedTx, NestedProcessReturnValues[], DebugLog[]]> {
|
|
524
553
|
const timer = new Timer();
|
|
525
554
|
|
|
526
|
-
const
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
if (!avmProvingRequest) {
|
|
530
|
-
this.metrics.recordFailedTx();
|
|
531
|
-
throw new Error('Avm proving result was not generated.');
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
processedPhases.forEach(phase => {
|
|
535
|
-
if (phase.reverted) {
|
|
536
|
-
this.metrics.recordRevertedPhase(phase.phase);
|
|
537
|
-
} else {
|
|
538
|
-
this.metrics.recordPhaseDuration(phase.phase, phase.durationMs ?? 0);
|
|
539
|
-
}
|
|
540
|
-
});
|
|
555
|
+
const result = await this.publicTxSimulator.simulate(tx);
|
|
556
|
+
// TODO: use the callStackMetadata here to extract more data about public execution
|
|
557
|
+
const { hints, publicInputs, publicTxEffect, gasUsed, revertCode /*callStackMetadata*/ } = result;
|
|
541
558
|
|
|
542
559
|
const contractClassLogs = revertCode.isOK()
|
|
543
560
|
? tx.getContractClassLogs()
|
|
@@ -548,14 +565,41 @@ export class PublicProcessor implements Traceable {
|
|
|
548
565
|
.map(log => ContractClassPublishedEvent.fromLog(log)),
|
|
549
566
|
);
|
|
550
567
|
|
|
551
|
-
|
|
568
|
+
// TODO(fcarreiro): remove phase count metric.
|
|
552
569
|
const durationMs = timer.ms();
|
|
553
|
-
this.metrics.recordTx(phaseCount, durationMs, gasUsed.publicGas);
|
|
570
|
+
this.metrics.recordTx(/*phaseCount=*/ 1, durationMs, gasUsed.publicGas);
|
|
554
571
|
|
|
555
|
-
|
|
572
|
+
// Extract the return values from the call stack metadata.
|
|
573
|
+
const appLogicReturnValues: NestedProcessReturnValues[] = result.getAppLogicReturnValues();
|
|
574
|
+
// Extract the revert reason from the call stack metadata.
|
|
575
|
+
const revertReason = result.findRevertReason();
|
|
576
|
+
// Create proving request if we have hints and public inputs.
|
|
577
|
+
const avmProvingRequest =
|
|
578
|
+
hints && publicInputs ? PublicProcessor.generateProvingRequest(publicInputs, hints) : undefined;
|
|
556
579
|
|
|
557
|
-
const
|
|
580
|
+
const processedTx = makeProcessedTxFromTxWithPublicCalls(
|
|
581
|
+
tx,
|
|
582
|
+
this.globalVariables,
|
|
583
|
+
avmProvingRequest,
|
|
584
|
+
publicTxEffect,
|
|
585
|
+
gasUsed,
|
|
586
|
+
revertCode,
|
|
587
|
+
revertReason,
|
|
588
|
+
);
|
|
558
589
|
|
|
559
|
-
return [processedTx,
|
|
590
|
+
return [processedTx, appLogicReturnValues, result.logs ?? []];
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Generate the proving request for the AVM circuit.
|
|
595
|
+
*/
|
|
596
|
+
private static generateProvingRequest(
|
|
597
|
+
publicInputs: AvmCircuitPublicInputs,
|
|
598
|
+
hints: AvmExecutionHints = AvmExecutionHints.empty(),
|
|
599
|
+
): AvmProvingRequest {
|
|
600
|
+
return {
|
|
601
|
+
type: ProvingRequestType.PUBLIC_VM,
|
|
602
|
+
inputs: new AvmCircuitInputs(hints, publicInputs),
|
|
603
|
+
};
|
|
560
604
|
}
|
|
561
605
|
}
|
|
@@ -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) {
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import type { ContractProvider } from '@aztec/native';
|
|
4
|
+
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
5
|
+
import { deserializeFromMessagePack, serializeWithMessagePack } from '@aztec/stdlib/avm';
|
|
6
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
|
+
import { ContractDeploymentData } from '@aztec/stdlib/contract';
|
|
8
|
+
import type { GlobalVariables } from '@aztec/stdlib/tx';
|
|
9
|
+
|
|
10
|
+
import type { PublicContractsDB } from '../public_db_sources.js';
|
|
11
|
+
|
|
12
|
+
export class ContractProviderForCpp implements ContractProvider {
|
|
13
|
+
private log: Logger;
|
|
14
|
+
|
|
15
|
+
constructor(
|
|
16
|
+
private contractsDB: PublicContractsDB,
|
|
17
|
+
private globalVariables: GlobalVariables,
|
|
18
|
+
bindings?: LoggerBindings,
|
|
19
|
+
) {
|
|
20
|
+
this.log = createLogger('simulator:contract_provider_for_cpp', bindings);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public getContractInstance = async (address: string): Promise<Buffer | undefined> => {
|
|
24
|
+
this.log.trace(`Contract provider callback: getContractInstance(${address})`);
|
|
25
|
+
|
|
26
|
+
const aztecAddr = AztecAddress.fromString(address);
|
|
27
|
+
|
|
28
|
+
const instance = await this.contractsDB.getContractInstance(aztecAddr, this.globalVariables.timestamp);
|
|
29
|
+
|
|
30
|
+
if (!instance) {
|
|
31
|
+
this.log.debug(`Contract instance not found: ${address}`);
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return serializeWithMessagePack(instance);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
public getContractClass = async (classId: string): Promise<Buffer | undefined> => {
|
|
39
|
+
this.log.trace(`Contract provider callback: getContractClass(${classId})`);
|
|
40
|
+
|
|
41
|
+
// Parse classId string to Fr
|
|
42
|
+
const classIdFr = Fr.fromString(classId);
|
|
43
|
+
|
|
44
|
+
// Fetch contract class from the contracts DB
|
|
45
|
+
const contractClass = await this.contractsDB.getContractClass(classIdFr);
|
|
46
|
+
|
|
47
|
+
if (!contractClass) {
|
|
48
|
+
this.log.debug(`Contract class not found: ${classId}`);
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return serializeWithMessagePack(contractClass);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
public addContracts = async (contractDeploymentDataBuffer: Buffer): Promise<void> => {
|
|
56
|
+
this.log.trace(`Contract provider callback: addContracts`);
|
|
57
|
+
|
|
58
|
+
const rawData: any = deserializeFromMessagePack(contractDeploymentDataBuffer);
|
|
59
|
+
|
|
60
|
+
// Construct ContractDeploymentData from plain object.
|
|
61
|
+
const contractDeploymentData = ContractDeploymentData.fromPlainObject(rawData);
|
|
62
|
+
|
|
63
|
+
// Add contracts to the contracts DB
|
|
64
|
+
this.log.trace(`Calling contractsDB.addContracts`);
|
|
65
|
+
await this.contractsDB.addContracts(contractDeploymentData);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
public getBytecodeCommitment = async (classId: string): Promise<Buffer | undefined> => {
|
|
69
|
+
this.log.trace(`Contract provider callback: getBytecodeCommitment(${classId})`);
|
|
70
|
+
|
|
71
|
+
// Parse classId string to Fr
|
|
72
|
+
const classIdFr = Fr.fromString(classId);
|
|
73
|
+
|
|
74
|
+
// Fetch bytecode commitment from the contracts DB
|
|
75
|
+
const commitment = await this.contractsDB.getBytecodeCommitment(classIdFr);
|
|
76
|
+
|
|
77
|
+
if (!commitment) {
|
|
78
|
+
this.log.debug(`Bytecode commitment not found: ${classId}`);
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Serialize the Fr to buffer
|
|
83
|
+
return serializeWithMessagePack(commitment);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
public getDebugFunctionName = async (address: string, selector: string): Promise<string | undefined> => {
|
|
87
|
+
this.log.trace(`Contract provider callback: getDebugFunctionName(${address}, ${selector})`);
|
|
88
|
+
|
|
89
|
+
// Parse address and selector strings
|
|
90
|
+
const aztecAddr = AztecAddress.fromString(address);
|
|
91
|
+
const selectorFr = Fr.fromString(selector);
|
|
92
|
+
const functionSelector = FunctionSelector.fromFieldOrUndefined(selectorFr);
|
|
93
|
+
|
|
94
|
+
if (!functionSelector) {
|
|
95
|
+
this.log.trace(`calldata[0] is not a function selector: ${selector}`);
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Fetch debug function name from the contracts DB
|
|
100
|
+
const name = await this.contractsDB.getDebugFunctionName(aztecAddr, functionSelector);
|
|
101
|
+
|
|
102
|
+
if (!name) {
|
|
103
|
+
this.log.trace(`Debug function name not found for ${address}:${selector}`);
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return name;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
public createCheckpoint = (): Promise<void> => {
|
|
111
|
+
this.log.trace(`Contract provider callback: createCheckpoint`);
|
|
112
|
+
return Promise.resolve(this.contractsDB.createCheckpoint());
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
public commitCheckpoint = (): Promise<void> => {
|
|
116
|
+
this.log.trace(`Contract provider callback: commitCheckpoint`);
|
|
117
|
+
return Promise.resolve(this.contractsDB.commitCheckpoint());
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
public revertCheckpoint = (): Promise<void> => {
|
|
121
|
+
this.log.trace(`Contract provider callback: revertCheckpoint`);
|
|
122
|
+
return Promise.resolve(this.contractsDB.revertCheckpoint());
|
|
123
|
+
};
|
|
124
|
+
}
|