@aztec/simulator 0.0.1-commit.b655e406 → 0.0.1-commit.b9865e97
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 +7 -5
- 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/testing/account_proof_fetcher.d.ts +2 -0
- package/dest/public/avm/testing/account_proof_fetcher.d.ts.map +1 -0
- package/dest/public/avm/testing/account_proof_fetcher.js +152 -0
- package/dest/public/avm/{fixtures → testing}/base_avm_simulation_tester.d.ts +3 -2
- package/dest/public/avm/testing/base_avm_simulation_tester.d.ts.map +1 -0
- package/dest/public/avm/{fixtures → testing}/base_avm_simulation_tester.js +18 -3
- package/dest/public/avm/{fixtures → testing}/utils.d.ts +4 -10
- package/dest/public/avm/testing/utils.d.ts.map +1 -0
- package/dest/public/avm/{fixtures → testing}/utils.js +6 -35
- 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/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 +36 -73
- 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/index.d.ts +2 -3
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +1 -2
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +30 -11
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +98 -31
- 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 +5 -5
- 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 +23 -23
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts +62 -0
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts.map +1 -0
- package/dest/public/fuzzing/avm_fuzzer_simulator.js +176 -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/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 +29 -66
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +83 -134
- 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 +8 -5
- package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
- package/dest/public/public_processor/guarded_merkle_tree.js +12 -4
- package/dest/public/public_processor/public_processor.d.ts +19 -21
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +553 -123
- package/dest/public/public_processor/public_processor_metrics.d.ts +5 -2
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor_metrics.js +36 -45
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +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 +99 -0
- package/dest/public/public_tx_simulator/dumping_public_tx_simulator.d.ts +23 -0
- package/dest/public/public_tx_simulator/dumping_public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/dumping_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 -3
- package/dest/public/public_tx_simulator/index.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/index.js +3 -2
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +42 -89
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +101 -334
- package/dest/public/public_tx_simulator/public_tx_simulator_base.d.ts +22 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_base.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_base.js +28 -0
- 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/side_effect_errors.d.ts +1 -1
- package/dest/public/side_effect_errors.d.ts.map +1 -1
- 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 +22 -22
- 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 +11 -4
- 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/testing/account_proof.json +553 -0
- package/src/public/avm/testing/account_proof_fetcher.ts +166 -0
- package/src/public/avm/{fixtures → testing}/base_avm_simulation_tester.ts +23 -3
- package/src/public/avm/{fixtures → testing}/utils.ts +6 -41
- package/src/public/contracts_db_checkpoint.ts +41 -0
- package/src/public/db_interfaces.ts +16 -1
- 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 +38 -13
- package/src/public/fixtures/custom_bytecode_tester.ts +54 -20
- package/src/public/fixtures/index.ts +5 -2
- package/src/public/fixtures/public_tx_simulation_tester.ts +129 -27
- package/src/public/fixtures/simple_contract_data_source.ts +9 -10
- package/src/public/fixtures/token_test.ts +18 -10
- package/src/public/fixtures/utils.ts +28 -25
- package/src/public/fuzzing/avm_fuzzer_simulator.ts +285 -0
- package/src/public/fuzzing/avm_simulator_bin.ts +173 -0
- package/src/public/index.ts +4 -2
- package/src/public/public_db_sources.ts +112 -174
- package/src/public/public_processor/guarded_merkle_tree.ts +14 -6
- package/src/public/public_processor/public_processor.ts +225 -136
- package/src/public/public_processor/public_processor_metrics.ts +28 -44
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +125 -0
- package/src/public/public_tx_simulator/dumping_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 -2
- package/src/public/public_tx_simulator/public_tx_simulator.ts +153 -500
- package/src/public/public_tx_simulator/public_tx_simulator_base.ts +35 -0
- package/src/public/public_tx_simulator/public_tx_simulator_interface.ts +24 -2
- package/src/public/test_executor_metrics.ts +34 -8
- package/dest/public/avm/avm_context.d.ts +0 -41
- package/dest/public/avm/avm_context.d.ts.map +0 -1
- package/dest/public/avm/avm_context.js +0 -44
- package/dest/public/avm/avm_contract_call_result.d.ts +0 -32
- package/dest/public/avm/avm_contract_call_result.d.ts.map +0 -1
- package/dest/public/avm/avm_contract_call_result.js +0 -54
- package/dest/public/avm/avm_execution_environment.d.ts +0 -23
- package/dest/public/avm/avm_execution_environment.d.ts.map +0 -1
- package/dest/public/avm/avm_execution_environment.js +0 -36
- package/dest/public/avm/avm_gas.d.ts +0 -44
- package/dest/public/avm/avm_gas.d.ts.map +0 -1
- package/dest/public/avm/avm_gas.js +0 -195
- package/dest/public/avm/avm_machine_state.d.ts +0 -97
- package/dest/public/avm/avm_machine_state.d.ts.map +0 -1
- package/dest/public/avm/avm_machine_state.js +0 -109
- package/dest/public/avm/avm_memory_types.d.ts +0 -275
- package/dest/public/avm/avm_memory_types.d.ts.map +0 -1
- package/dest/public/avm/avm_memory_types.js +0 -351
- package/dest/public/avm/avm_simulator.d.ts +0 -39
- package/dest/public/avm/avm_simulator.d.ts.map +0 -1
- package/dest/public/avm/avm_simulator.js +0 -190
- package/dest/public/avm/avm_simulator_interface.d.ts +0 -9
- package/dest/public/avm/avm_simulator_interface.d.ts.map +0 -1
- package/dest/public/avm/avm_simulator_interface.js +0 -3
- package/dest/public/avm/errors.d.ts +0 -98
- package/dest/public/avm/errors.d.ts.map +0 -1
- package/dest/public/avm/errors.js +0 -129
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts +0 -22
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +0 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.js +0 -74
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +0 -1
- package/dest/public/avm/fixtures/initializers.d.ts +0 -43
- package/dest/public/avm/fixtures/initializers.d.ts.map +0 -1
- package/dest/public/avm/fixtures/initializers.js +0 -42
- package/dest/public/avm/fixtures/utils.d.ts.map +0 -1
- package/dest/public/avm/index.d.ts +0 -2
- package/dest/public/avm/index.d.ts.map +0 -1
- package/dest/public/avm/index.js +0 -1
- package/dest/public/avm/opcodes/accrued_substate.d.ts +0 -75
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +0 -1
- package/dest/public/avm/opcodes/accrued_substate.js +0 -255
- package/dest/public/avm/opcodes/addressing_mode.d.ts +0 -31
- package/dest/public/avm/opcodes/addressing_mode.d.ts.map +0 -1
- package/dest/public/avm/opcodes/addressing_mode.js +0 -94
- package/dest/public/avm/opcodes/arithmetic.d.ts +0 -47
- package/dest/public/avm/opcodes/arithmetic.d.ts.map +0 -1
- package/dest/public/avm/opcodes/arithmetic.js +0 -87
- package/dest/public/avm/opcodes/bitwise.d.ts +0 -42
- package/dest/public/avm/opcodes/bitwise.d.ts.map +0 -1
- package/dest/public/avm/opcodes/bitwise.js +0 -99
- package/dest/public/avm/opcodes/comparators.d.ts +0 -25
- package/dest/public/avm/opcodes/comparators.d.ts.map +0 -1
- package/dest/public/avm/opcodes/comparators.js +0 -43
- package/dest/public/avm/opcodes/contract.d.ts +0 -20
- package/dest/public/avm/opcodes/contract.d.ts.map +0 -1
- package/dest/public/avm/opcodes/contract.js +0 -65
- package/dest/public/avm/opcodes/control_flow.d.ts +0 -41
- package/dest/public/avm/opcodes/control_flow.d.ts.map +0 -1
- package/dest/public/avm/opcodes/control_flow.js +0 -107
- package/dest/public/avm/opcodes/conversion.d.ts +0 -18
- package/dest/public/avm/opcodes/conversion.d.ts.map +0 -1
- package/dest/public/avm/opcodes/conversion.js +0 -333
- package/dest/public/avm/opcodes/ec_add.d.ts +0 -19
- package/dest/public/avm/opcodes/ec_add.d.ts.map +0 -1
- package/dest/public/avm/opcodes/ec_add.js +0 -84
- package/dest/public/avm/opcodes/environment_getters.d.ts +0 -28
- package/dest/public/avm/opcodes/environment_getters.d.ts.map +0 -1
- package/dest/public/avm/opcodes/environment_getters.js +0 -77
- package/dest/public/avm/opcodes/external_calls.d.ts +0 -59
- package/dest/public/avm/opcodes/external_calls.d.ts.map +0 -1
- package/dest/public/avm/opcodes/external_calls.js +0 -209
- package/dest/public/avm/opcodes/hashing.d.ts +0 -36
- package/dest/public/avm/opcodes/hashing.d.ts.map +0 -1
- package/dest/public/avm/opcodes/hashing.js +0 -114
- package/dest/public/avm/opcodes/index.d.ts +0 -16
- package/dest/public/avm/opcodes/index.d.ts.map +0 -1
- package/dest/public/avm/opcodes/index.js +0 -15
- package/dest/public/avm/opcodes/instruction.d.ts +0 -74
- package/dest/public/avm/opcodes/instruction.d.ts.map +0 -1
- package/dest/public/avm/opcodes/instruction.js +0 -95
- package/dest/public/avm/opcodes/instruction_impl.d.ts +0 -19
- package/dest/public/avm/opcodes/instruction_impl.d.ts.map +0 -1
- package/dest/public/avm/opcodes/instruction_impl.js +0 -30
- package/dest/public/avm/opcodes/memory.d.ts +0 -74
- package/dest/public/avm/opcodes/memory.d.ts.map +0 -1
- package/dest/public/avm/opcodes/memory.js +0 -257
- package/dest/public/avm/opcodes/misc.d.ts +0 -18
- package/dest/public/avm/opcodes/misc.d.ts.map +0 -1
- package/dest/public/avm/opcodes/misc.js +0 -73
- package/dest/public/avm/opcodes/storage.d.ts +0 -24
- package/dest/public/avm/opcodes/storage.d.ts.map +0 -1
- package/dest/public/avm/opcodes/storage.js +0 -68
- package/dest/public/avm/revert_reason.d.ts +0 -18
- package/dest/public/avm/revert_reason.d.ts.map +0 -1
- package/dest/public/avm/revert_reason.js +0 -38
- package/dest/public/avm/serialization/buffer_cursor.d.ts +0 -26
- package/dest/public/avm/serialization/buffer_cursor.d.ts.map +0 -1
- package/dest/public/avm/serialization/buffer_cursor.js +0 -99
- package/dest/public/avm/serialization/bytecode_serialization.d.ts +0 -17
- package/dest/public/avm/serialization/bytecode_serialization.d.ts.map +0 -1
- package/dest/public/avm/serialization/bytecode_serialization.js +0 -333
- package/dest/public/avm/serialization/instruction_serialization.d.ts +0 -114
- package/dest/public/avm/serialization/instruction_serialization.d.ts.map +0 -1
- package/dest/public/avm/serialization/instruction_serialization.js +0 -261
- package/dest/public/avm/test_utils.d.ts +0 -15
- package/dest/public/avm/test_utils.d.ts.map +0 -1
- package/dest/public/avm/test_utils.js +0 -44
- package/dest/public/debug_fn_name.d.ts +0 -5
- package/dest/public/debug_fn_name.d.ts.map +0 -1
- package/dest/public/debug_fn_name.js +0 -9
- package/dest/public/fixtures/custom_bytecode_tests.d.ts +0 -9
- package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +0 -1
- package/dest/public/fixtures/custom_bytecode_tests.js +0 -109
- package/dest/public/fixtures/minimal_public_tx.d.ts +0 -10
- package/dest/public/fixtures/minimal_public_tx.d.ts.map +0 -1
- package/dest/public/fixtures/minimal_public_tx.js +0 -29
- package/dest/public/hinting_db_sources.d.ts +0 -70
- package/dest/public/hinting_db_sources.d.ts.map +0 -1
- package/dest/public/hinting_db_sources.js +0 -297
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +0 -41
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +0 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +0 -89
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +0 -24
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts.map +0 -1
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.js +0 -51
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +0 -127
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +0 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +0 -292
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts +0 -21
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts.map +0 -1
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.js +0 -39
- package/dest/public/side_effect_trace.d.ts +0 -87
- package/dest/public/side_effect_trace.d.ts.map +0 -1
- package/dest/public/side_effect_trace.js +0 -199
- package/dest/public/side_effect_trace_interface.d.ts +0 -23
- package/dest/public/side_effect_trace_interface.d.ts.map +0 -1
- package/dest/public/side_effect_trace_interface.js +0 -1
- package/dest/public/state_manager/index.d.ts +0 -2
- package/dest/public/state_manager/index.d.ts.map +0 -1
- package/dest/public/state_manager/index.js +0 -1
- package/dest/public/state_manager/nullifiers.d.ts +0 -61
- package/dest/public/state_manager/nullifiers.d.ts.map +0 -1
- package/dest/public/state_manager/nullifiers.js +0 -92
- package/dest/public/state_manager/public_storage.d.ts +0 -66
- package/dest/public/state_manager/public_storage.d.ts.map +0 -1
- package/dest/public/state_manager/public_storage.js +0 -145
- package/dest/public/state_manager/state_manager.d.ts +0 -166
- package/dest/public/state_manager/state_manager.d.ts.map +0 -1
- package/dest/public/state_manager/state_manager.js +0 -391
- 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/avm/avm_context.ts +0 -61
- package/src/public/avm/avm_contract_call_result.ts +0 -67
- package/src/public/avm/avm_execution_environment.ts +0 -48
- package/src/public/avm/avm_gas.ts +0 -183
- package/src/public/avm/avm_machine_state.ts +0 -169
- package/src/public/avm/avm_memory_types.ts +0 -436
- package/src/public/avm/avm_simulator.ts +0 -274
- package/src/public/avm/avm_simulator_interface.ts +0 -8
- package/src/public/avm/errors.ts +0 -163
- package/src/public/avm/fixtures/avm_simulation_tester.ts +0 -108
- package/src/public/avm/fixtures/initializers.ts +0 -104
- package/src/public/avm/index.ts +0 -1
- package/src/public/avm/opcodes/accrued_substate.ts +0 -288
- package/src/public/avm/opcodes/addressing_mode.ts +0 -111
- package/src/public/avm/opcodes/arithmetic.ts +0 -117
- package/src/public/avm/opcodes/bitwise.ts +0 -113
- package/src/public/avm/opcodes/comparators.ts +0 -55
- package/src/public/avm/opcodes/contract.ts +0 -75
- package/src/public/avm/opcodes/control_flow.ts +0 -123
- package/src/public/avm/opcodes/conversion.ts +0 -104
- package/src/public/avm/opcodes/ec_add.ts +0 -96
- package/src/public/avm/opcodes/environment_getters.ts +0 -87
- package/src/public/avm/opcodes/external_calls.ts +0 -260
- package/src/public/avm/opcodes/hashing.ts +0 -145
- package/src/public/avm/opcodes/index.ts +0 -15
- package/src/public/avm/opcodes/instruction.ts +0 -136
- package/src/public/avm/opcodes/instruction_impl.ts +0 -36
- package/src/public/avm/opcodes/memory.ts +0 -293
- package/src/public/avm/opcodes/misc.ts +0 -102
- package/src/public/avm/opcodes/storage.ts +0 -87
- package/src/public/avm/revert_reason.ts +0 -55
- package/src/public/avm/serialization/buffer_cursor.ts +0 -118
- package/src/public/avm/serialization/bytecode_serialization.ts +0 -204
- package/src/public/avm/serialization/instruction_serialization.ts +0 -249
- package/src/public/avm/test_utils.ts +0 -64
- package/src/public/debug_fn_name.ts +0 -18
- package/src/public/fixtures/custom_bytecode_tests.ts +0 -135
- package/src/public/fixtures/minimal_public_tx.ts +0 -36
- package/src/public/hinting_db_sources.ts +0 -505
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +0 -128
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +0 -109
- package/src/public/public_tx_simulator/public_tx_context.ts +0 -471
- package/src/public/public_tx_simulator/telemetry_public_tx_simulator.ts +0 -63
- package/src/public/side_effect_trace.ts +0 -290
- package/src/public/side_effect_trace_interface.ts +0 -28
- package/src/public/state_manager/index.ts +0 -1
- package/src/public/state_manager/nullifiers.ts +0 -103
- package/src/public/state_manager/public_storage.ts +0 -174
- package/src/public/state_manager/state_manager.ts +0 -560
- package/src/public/tx_contract_cache.ts +0 -69
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import type { IndexedTreeLeafPreimage, SiblingPath } from '@aztec/foundation/trees';
|
|
3
|
-
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
4
|
-
import { type AvmExecutionHints } from '@aztec/stdlib/avm';
|
|
5
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import type { ContractClassPublic, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
7
|
-
import { type BatchInsertionResult, type IndexedTreeId, MerkleTreeId, type MerkleTreeLeafType, type MerkleTreeWriteOperations, type SequentialInsertionResult, type TreeHeights } from '@aztec/stdlib/trees';
|
|
8
|
-
import type { UInt64 } from '@aztec/stdlib/types';
|
|
9
|
-
import type { WorldStateRevision } from '@aztec/stdlib/world-state';
|
|
10
|
-
import type { PublicContractsDBInterface } from './db_interfaces.js';
|
|
11
|
-
/**
|
|
12
|
-
* A public contracts database that forwards requests and collects AVM hints.
|
|
13
|
-
*/
|
|
14
|
-
export declare class HintingPublicContractsDB implements PublicContractsDBInterface {
|
|
15
|
-
private readonly db;
|
|
16
|
-
private hints;
|
|
17
|
-
private contractClassIds;
|
|
18
|
-
constructor(db: PublicContractsDBInterface, hints: AvmExecutionHints);
|
|
19
|
-
getContractInstance(address: AztecAddress, timestamp: UInt64): Promise<ContractInstanceWithAddress | undefined>;
|
|
20
|
-
getContractClass(contractClassId: Fr): Promise<ContractClassPublic | undefined>;
|
|
21
|
-
getBytecodeCommitment(contractClassId: Fr): Promise<Fr | undefined>;
|
|
22
|
-
getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* A low-level merkle DB that collects hints.
|
|
26
|
-
*/
|
|
27
|
-
export declare class HintingMerkleWriteOperations implements MerkleTreeWriteOperations {
|
|
28
|
-
private db;
|
|
29
|
-
private hints;
|
|
30
|
-
private static readonly log;
|
|
31
|
-
private checkpointStack;
|
|
32
|
-
private nextCheckpointId;
|
|
33
|
-
private checkpointActionCounter;
|
|
34
|
-
static create(db: MerkleTreeWriteOperations, hints: AvmExecutionHints): Promise<HintingMerkleWriteOperations>;
|
|
35
|
-
private constructor();
|
|
36
|
-
getSiblingPath<ID extends MerkleTreeId>(treeId: ID, index: bigint): Promise<SiblingPath<TreeHeights[ID]>>;
|
|
37
|
-
getPreviousValueIndex<ID extends IndexedTreeId>(treeId: ID, value: bigint): Promise<{
|
|
38
|
-
index: bigint;
|
|
39
|
-
alreadyPresent: boolean;
|
|
40
|
-
} | undefined>;
|
|
41
|
-
getLeafPreimage<ID extends IndexedTreeId>(treeId: ID, index: bigint): Promise<IndexedTreeLeafPreimage | undefined>;
|
|
42
|
-
getLeafValue<ID extends MerkleTreeId>(treeId: ID, index: bigint): Promise<MerkleTreeLeafType<typeof treeId> | undefined>;
|
|
43
|
-
sequentialInsert<TreeHeight extends number, ID extends IndexedTreeId>(treeId: ID, leaves: Buffer[]): Promise<SequentialInsertionResult<TreeHeight>>;
|
|
44
|
-
appendLeaves<ID extends MerkleTreeId>(treeId: ID, leaves: MerkleTreeLeafType<ID>[]): Promise<void>;
|
|
45
|
-
createCheckpoint(): Promise<void>;
|
|
46
|
-
commitAllCheckpoints(): Promise<void>;
|
|
47
|
-
revertAllCheckpoints(): Promise<void>;
|
|
48
|
-
commitCheckpoint(): Promise<void>;
|
|
49
|
-
revertCheckpoint(): Promise<void>;
|
|
50
|
-
private getHintKey;
|
|
51
|
-
private getCurrentCheckpointId;
|
|
52
|
-
private getTreesStateHash;
|
|
53
|
-
private static logTreeChange;
|
|
54
|
-
private appendLeafInternal;
|
|
55
|
-
getTreeInfo(treeId: MerkleTreeId): Promise<import("@aztec/stdlib/trees").TreeInfo>;
|
|
56
|
-
getStateReference(): Promise<import("@aztec/stdlib/tx").StateReference>;
|
|
57
|
-
getInitialHeader(): import("@aztec/stdlib/tx").BlockHeader;
|
|
58
|
-
getRevision(): WorldStateRevision;
|
|
59
|
-
updateArchive(header: any): Promise<void>;
|
|
60
|
-
batchInsert<TreeHeight extends number, SubtreeSiblingPathHeight extends number, ID extends IndexedTreeId>(treeId: ID, leaves: Buffer[], subtreeHeight: number): Promise<BatchInsertionResult<TreeHeight, SubtreeSiblingPathHeight>>;
|
|
61
|
-
close(): Promise<void>;
|
|
62
|
-
findLeafIndices<ID extends MerkleTreeId>(treeId: ID, values: MerkleTreeLeafType<ID>[]): Promise<(bigint | undefined)[]>;
|
|
63
|
-
findSiblingPaths<ID extends MerkleTreeId>(treeId: ID, values: MerkleTreeLeafType<ID>[]): Promise<({
|
|
64
|
-
path: SiblingPath<TreeHeights[ID]>;
|
|
65
|
-
index: bigint;
|
|
66
|
-
} | undefined)[]>;
|
|
67
|
-
findLeafIndicesAfter<ID extends MerkleTreeId>(treeId: ID, values: MerkleTreeLeafType<ID>[], startIndex: bigint): Promise<(bigint | undefined)[]>;
|
|
68
|
-
getBlockNumbersForLeafIndices<ID extends MerkleTreeId>(treeId: ID, leafIndices: bigint[]): Promise<(bigint | undefined)[]>;
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=hinting_db_sources.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hinting_db_sources.d.ts","sourceRoot":"","sources":["../../src/public/hinting_db_sources.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
import { sha256Trunc } from '@aztec/foundation/crypto';
|
|
2
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { AvmAppendLeavesHint, AvmBytecodeCommitmentHint, AvmCommitCheckpointHint, AvmContractClassHint, AvmContractInstanceHint, AvmCreateCheckpointHint, AvmGetLeafPreimageHintNullifierTree, AvmGetLeafPreimageHintPublicDataTree, AvmGetLeafValueHint, AvmGetPreviousValueIndexHint, AvmGetSiblingPathHint, AvmRevertCheckpointHint, AvmSequentialInsertHintNullifierTree, AvmSequentialInsertHintPublicDataTree } from '@aztec/stdlib/avm';
|
|
5
|
-
import { AppendOnlyTreeSnapshot, MerkleTreeId, NullifierLeaf, PublicDataTreeLeaf, getTreeName, merkleTreeIds } from '@aztec/stdlib/trees';
|
|
6
|
-
import { TreeSnapshots } from '@aztec/stdlib/tx';
|
|
7
|
-
import { strict as assert } from 'assert';
|
|
8
|
-
/**
|
|
9
|
-
* A public contracts database that forwards requests and collects AVM hints.
|
|
10
|
-
*/ export class HintingPublicContractsDB {
|
|
11
|
-
db;
|
|
12
|
-
hints;
|
|
13
|
-
// We deduplicate contract classes because they include the whole bytecode.
|
|
14
|
-
contractClassIds;
|
|
15
|
-
constructor(db, hints){
|
|
16
|
-
this.db = db;
|
|
17
|
-
this.hints = hints;
|
|
18
|
-
this.contractClassIds = new Set();
|
|
19
|
-
}
|
|
20
|
-
async getContractInstance(address, timestamp) {
|
|
21
|
-
const instance = await this.db.getContractInstance(address, timestamp);
|
|
22
|
-
if (instance) {
|
|
23
|
-
// We don't need to hint the block number because it doesn't change.
|
|
24
|
-
this.hints.contractInstances.push(new AvmContractInstanceHint(instance.address, instance.salt, instance.deployer, instance.currentContractClassId, instance.originalContractClassId, instance.initializationHash, instance.publicKeys));
|
|
25
|
-
}
|
|
26
|
-
return instance;
|
|
27
|
-
}
|
|
28
|
-
async getContractClass(contractClassId) {
|
|
29
|
-
const contractClass = await this.db.getContractClass(contractClassId);
|
|
30
|
-
if (contractClass && !this.contractClassIds.has(contractClassId.toBigInt())) {
|
|
31
|
-
this.contractClassIds.add(contractClassId.toBigInt());
|
|
32
|
-
this.hints.contractClasses.push(new AvmContractClassHint(contractClass.id, contractClass.artifactHash, contractClass.privateFunctionsRoot, contractClass.packedBytecode));
|
|
33
|
-
}
|
|
34
|
-
return contractClass;
|
|
35
|
-
}
|
|
36
|
-
async getBytecodeCommitment(contractClassId) {
|
|
37
|
-
const commitment = await this.db.getBytecodeCommitment(contractClassId);
|
|
38
|
-
if (commitment) {
|
|
39
|
-
this.hints.bytecodeCommitments.push(new AvmBytecodeCommitmentHint(contractClassId, commitment));
|
|
40
|
-
}
|
|
41
|
-
return commitment;
|
|
42
|
-
}
|
|
43
|
-
async getDebugFunctionName(contractAddress, selector) {
|
|
44
|
-
return await this.db.getDebugFunctionName(contractAddress, selector);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* A low-level merkle DB that collects hints.
|
|
49
|
-
*/ export class HintingMerkleWriteOperations {
|
|
50
|
-
db;
|
|
51
|
-
hints;
|
|
52
|
-
static log = createLogger('simulator:hinting-merkle-db');
|
|
53
|
-
// This stack is only for debugging purposes.
|
|
54
|
-
// The top of the stack is the current checkpoint id.
|
|
55
|
-
// We need the stack to be non-empty and use 0 as an arbitrary initial checkpoint id.
|
|
56
|
-
// This is not necessarily a checkpoint that happened, but whatever tree state we start with.
|
|
57
|
-
checkpointStack;
|
|
58
|
-
nextCheckpointId;
|
|
59
|
-
checkpointActionCounter;
|
|
60
|
-
static async create(db, hints) {
|
|
61
|
-
const hintingTreesDB = new HintingMerkleWriteOperations(db, hints);
|
|
62
|
-
const startStateReference = await db.getStateReference();
|
|
63
|
-
hints.startingTreeRoots = new TreeSnapshots(startStateReference.l1ToL2MessageTree, startStateReference.partial.noteHashTree, startStateReference.partial.nullifierTree, startStateReference.partial.publicDataTree);
|
|
64
|
-
return hintingTreesDB;
|
|
65
|
-
}
|
|
66
|
-
// Use create() to instantiate.
|
|
67
|
-
constructor(db, hints){
|
|
68
|
-
this.db = db;
|
|
69
|
-
this.hints = hints;
|
|
70
|
-
this.checkpointStack = [
|
|
71
|
-
0
|
|
72
|
-
];
|
|
73
|
-
this.nextCheckpointId = 1;
|
|
74
|
-
this.checkpointActionCounter = 0;
|
|
75
|
-
}
|
|
76
|
-
// Getters.
|
|
77
|
-
async getSiblingPath(treeId, index) {
|
|
78
|
-
const path = await this.db.getSiblingPath(treeId, index);
|
|
79
|
-
const key = await this.getHintKey(treeId);
|
|
80
|
-
this.hints.getSiblingPathHints.push(new AvmGetSiblingPathHint(key, treeId, index, path.toFields()));
|
|
81
|
-
return Promise.resolve(path);
|
|
82
|
-
}
|
|
83
|
-
async getPreviousValueIndex(treeId, value) {
|
|
84
|
-
const result = await this.db.getPreviousValueIndex(treeId, value);
|
|
85
|
-
if (result === undefined) {
|
|
86
|
-
throw new Error(`getPreviousValueIndex(${getTreeName(treeId)}, ${value}}) returned undefined. Possible wrong tree setup or corrupted state.`);
|
|
87
|
-
}
|
|
88
|
-
const key = await this.getHintKey(treeId);
|
|
89
|
-
this.hints.getPreviousValueIndexHints.push(new AvmGetPreviousValueIndexHint(key, treeId, new Fr(value), result.index, result.alreadyPresent));
|
|
90
|
-
return result;
|
|
91
|
-
}
|
|
92
|
-
async getLeafPreimage(treeId, index) {
|
|
93
|
-
const preimage = await this.db.getLeafPreimage(treeId, index);
|
|
94
|
-
if (preimage) {
|
|
95
|
-
const key = await this.getHintKey(treeId);
|
|
96
|
-
switch(treeId){
|
|
97
|
-
case MerkleTreeId.PUBLIC_DATA_TREE:
|
|
98
|
-
this.hints.getLeafPreimageHintsPublicDataTree.push(new AvmGetLeafPreimageHintPublicDataTree(key, index, preimage));
|
|
99
|
-
break;
|
|
100
|
-
case MerkleTreeId.NULLIFIER_TREE:
|
|
101
|
-
this.hints.getLeafPreimageHintsNullifierTree.push(new AvmGetLeafPreimageHintNullifierTree(key, index, preimage));
|
|
102
|
-
break;
|
|
103
|
-
default:
|
|
104
|
-
// Use getLeafValue for the other trees.
|
|
105
|
-
throw new Error('getLeafPreimage only supported for PublicDataTree and NullifierTree!');
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return preimage;
|
|
110
|
-
}
|
|
111
|
-
async getLeafValue(treeId, index) {
|
|
112
|
-
// Use getLeafPreimage for PublicDataTree and NullifierTree.
|
|
113
|
-
assert(treeId == MerkleTreeId.NOTE_HASH_TREE || treeId == MerkleTreeId.L1_TO_L2_MESSAGE_TREE);
|
|
114
|
-
const value = await this.db.getLeafValue(treeId, index);
|
|
115
|
-
if (value) {
|
|
116
|
-
const key = await this.getHintKey(treeId);
|
|
117
|
-
// We can cast to Fr because we know the type of the tree.
|
|
118
|
-
this.hints.getLeafValueHints.push(new AvmGetLeafValueHint(key, treeId, index, value));
|
|
119
|
-
}
|
|
120
|
-
return value;
|
|
121
|
-
}
|
|
122
|
-
// State modification.
|
|
123
|
-
// FIXME(fcarreiro): This is a horrible interface (in the merkle ops). It's receiving the leaves as buffers,
|
|
124
|
-
// from a leaf class that is NOT the one that will be used to write. Make this type safe.
|
|
125
|
-
async sequentialInsert(treeId, leaves) {
|
|
126
|
-
// Use appendLeaf for NoteHashTree and L1ToL2MessageTree.
|
|
127
|
-
assert(treeId == MerkleTreeId.PUBLIC_DATA_TREE || treeId == MerkleTreeId.NULLIFIER_TREE);
|
|
128
|
-
// We only support 1 leaf at a time for now. Can easily be extended.
|
|
129
|
-
assert(leaves.length === 1, 'sequentialInsert supports only one leaf at a time!');
|
|
130
|
-
const beforeState = await this.getHintKey(treeId);
|
|
131
|
-
const result = await this.db.sequentialInsert(treeId, leaves);
|
|
132
|
-
const afterState = await this.getHintKey(treeId);
|
|
133
|
-
HintingMerkleWriteOperations.logTreeChange('sequentialInsert', beforeState, afterState, treeId);
|
|
134
|
-
switch(treeId){
|
|
135
|
-
case MerkleTreeId.PUBLIC_DATA_TREE:
|
|
136
|
-
this.hints.sequentialInsertHintsPublicDataTree.push(new AvmSequentialInsertHintPublicDataTree(beforeState, afterState, treeId, PublicDataTreeLeaf.fromBuffer(leaves[0]), {
|
|
137
|
-
leaf: result.lowLeavesWitnessData[0].leafPreimage,
|
|
138
|
-
index: result.lowLeavesWitnessData[0].index,
|
|
139
|
-
path: result.lowLeavesWitnessData[0].siblingPath.toFields()
|
|
140
|
-
}, {
|
|
141
|
-
leaf: result.insertionWitnessData[0].leafPreimage,
|
|
142
|
-
index: result.insertionWitnessData[0].index,
|
|
143
|
-
path: result.insertionWitnessData[0].siblingPath.toFields()
|
|
144
|
-
}));
|
|
145
|
-
break;
|
|
146
|
-
case MerkleTreeId.NULLIFIER_TREE:
|
|
147
|
-
this.hints.sequentialInsertHintsNullifierTree.push(new AvmSequentialInsertHintNullifierTree(beforeState, afterState, treeId, NullifierLeaf.fromBuffer(leaves[0]), {
|
|
148
|
-
leaf: result.lowLeavesWitnessData[0].leafPreimage,
|
|
149
|
-
index: result.lowLeavesWitnessData[0].index,
|
|
150
|
-
path: result.lowLeavesWitnessData[0].siblingPath.toFields()
|
|
151
|
-
}, {
|
|
152
|
-
leaf: result.insertionWitnessData[0].leafPreimage,
|
|
153
|
-
index: result.insertionWitnessData[0].index,
|
|
154
|
-
path: result.insertionWitnessData[0].siblingPath.toFields()
|
|
155
|
-
}));
|
|
156
|
-
break;
|
|
157
|
-
default:
|
|
158
|
-
throw new Error('sequentialInsert only supported for PublicDataTree and NullifierTree!');
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
return result;
|
|
162
|
-
}
|
|
163
|
-
async appendLeaves(treeId, leaves) {
|
|
164
|
-
// Use sequentialInsert for PublicDataTree and NullifierTree.
|
|
165
|
-
assert(treeId == MerkleTreeId.NOTE_HASH_TREE || treeId == MerkleTreeId.L1_TO_L2_MESSAGE_TREE);
|
|
166
|
-
// We need to process each leaf individually because we need the sibling path after insertion, to be able to constraint the insertion.
|
|
167
|
-
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/13380): This can be changed if the world state appendLeaves returns the sibling paths.
|
|
168
|
-
if (leaves.length === 1) {
|
|
169
|
-
await this.appendLeafInternal(treeId, leaves[0]);
|
|
170
|
-
return;
|
|
171
|
-
} else {
|
|
172
|
-
// TODO(dbanks12): NON-HINTING! We skip hinting here for now because:
|
|
173
|
-
// 1. We only ever append multiple leaves (for now) when padding (all empty leaves).
|
|
174
|
-
// 2. We don't need hints per-item when padding.
|
|
175
|
-
// 3. In order to get per-item hints today, you need to append one-at-a-time (mentioned above), which is VERY slow.
|
|
176
|
-
await this.db.appendLeaves(treeId, leaves);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
async createCheckpoint() {
|
|
180
|
-
const actionCounter = this.checkpointActionCounter++;
|
|
181
|
-
const oldCheckpointId = this.getCurrentCheckpointId();
|
|
182
|
-
const treesStateHash = await this.getTreesStateHash();
|
|
183
|
-
await this.db.createCheckpoint();
|
|
184
|
-
this.checkpointStack.push(this.nextCheckpointId++);
|
|
185
|
-
const newCheckpointId = this.getCurrentCheckpointId();
|
|
186
|
-
this.hints.createCheckpointHints.push(new AvmCreateCheckpointHint(actionCounter, oldCheckpointId, newCheckpointId));
|
|
187
|
-
HintingMerkleWriteOperations.log.trace(`[createCheckpoint:${actionCounter}] Checkpoint evolved ${oldCheckpointId} -> ${newCheckpointId} at trees state ${treesStateHash}.`);
|
|
188
|
-
}
|
|
189
|
-
commitAllCheckpoints() {
|
|
190
|
-
throw new Error('commitAllCheckpoints is not supported in HintingMerkleWriteOperations.');
|
|
191
|
-
}
|
|
192
|
-
revertAllCheckpoints() {
|
|
193
|
-
throw new Error('revertAllCheckpoints is not supported in HintingMerkleWriteOperations.');
|
|
194
|
-
}
|
|
195
|
-
async commitCheckpoint() {
|
|
196
|
-
const actionCounter = this.checkpointActionCounter++;
|
|
197
|
-
const oldCheckpointId = this.getCurrentCheckpointId();
|
|
198
|
-
const treesStateHash = await this.getTreesStateHash();
|
|
199
|
-
await this.db.commitCheckpoint();
|
|
200
|
-
this.checkpointStack.pop();
|
|
201
|
-
const newCheckpointId = this.getCurrentCheckpointId();
|
|
202
|
-
this.hints.commitCheckpointHints.push(new AvmCommitCheckpointHint(actionCounter, oldCheckpointId, newCheckpointId));
|
|
203
|
-
HintingMerkleWriteOperations.log.trace(`[commitCheckpoint:${actionCounter}] Checkpoint evolved ${oldCheckpointId} -> ${newCheckpointId} at trees state ${treesStateHash}.`);
|
|
204
|
-
}
|
|
205
|
-
async revertCheckpoint() {
|
|
206
|
-
const actionCounter = this.checkpointActionCounter++;
|
|
207
|
-
const oldCheckpointId = this.getCurrentCheckpointId();
|
|
208
|
-
const treesStateHash = await this.getTreesStateHash();
|
|
209
|
-
const beforeState = {
|
|
210
|
-
[MerkleTreeId.PUBLIC_DATA_TREE]: await this.getHintKey(MerkleTreeId.PUBLIC_DATA_TREE),
|
|
211
|
-
[MerkleTreeId.NULLIFIER_TREE]: await this.getHintKey(MerkleTreeId.NULLIFIER_TREE),
|
|
212
|
-
[MerkleTreeId.NOTE_HASH_TREE]: await this.getHintKey(MerkleTreeId.NOTE_HASH_TREE),
|
|
213
|
-
[MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: await this.getHintKey(MerkleTreeId.L1_TO_L2_MESSAGE_TREE),
|
|
214
|
-
[MerkleTreeId.ARCHIVE]: await this.getHintKey(MerkleTreeId.ARCHIVE)
|
|
215
|
-
};
|
|
216
|
-
await this.db.revertCheckpoint();
|
|
217
|
-
this.checkpointStack.pop();
|
|
218
|
-
const newCheckpointId = this.getCurrentCheckpointId();
|
|
219
|
-
const afterState = {
|
|
220
|
-
[MerkleTreeId.PUBLIC_DATA_TREE]: await this.getHintKey(MerkleTreeId.PUBLIC_DATA_TREE),
|
|
221
|
-
[MerkleTreeId.NULLIFIER_TREE]: await this.getHintKey(MerkleTreeId.NULLIFIER_TREE),
|
|
222
|
-
[MerkleTreeId.NOTE_HASH_TREE]: await this.getHintKey(MerkleTreeId.NOTE_HASH_TREE),
|
|
223
|
-
[MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: await this.getHintKey(MerkleTreeId.L1_TO_L2_MESSAGE_TREE),
|
|
224
|
-
[MerkleTreeId.ARCHIVE]: await this.getHintKey(MerkleTreeId.ARCHIVE)
|
|
225
|
-
};
|
|
226
|
-
this.hints.revertCheckpointHints.push(AvmRevertCheckpointHint.create(actionCounter, oldCheckpointId, newCheckpointId, beforeState, afterState));
|
|
227
|
-
HintingMerkleWriteOperations.log.trace(`[revertCheckpoint:${actionCounter}] Checkpoint evolved ${oldCheckpointId} -> ${newCheckpointId} at trees state ${treesStateHash}.`);
|
|
228
|
-
for (const treeId of merkleTreeIds()){
|
|
229
|
-
HintingMerkleWriteOperations.logTreeChange('revertCheckpoint', beforeState[treeId], afterState[treeId], treeId);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
// Private methods.
|
|
233
|
-
async getHintKey(treeId) {
|
|
234
|
-
const treeInfo = await this.db.getTreeInfo(treeId);
|
|
235
|
-
return new AppendOnlyTreeSnapshot(Fr.fromBuffer(treeInfo.root), Number(treeInfo.size));
|
|
236
|
-
}
|
|
237
|
-
getCurrentCheckpointId() {
|
|
238
|
-
return this.checkpointStack[this.checkpointStack.length - 1];
|
|
239
|
-
}
|
|
240
|
-
// For logging/debugging purposes.
|
|
241
|
-
async getTreesStateHash() {
|
|
242
|
-
const stateReferenceFields = (await this.db.getStateReference()).toFields();
|
|
243
|
-
return Fr.fromBuffer(sha256Trunc(Buffer.concat(stateReferenceFields.map((field)=>field.toBuffer()))));
|
|
244
|
-
}
|
|
245
|
-
static logTreeChange(action, beforeState, afterState, treeId) {
|
|
246
|
-
const treeName = getTreeName(treeId);
|
|
247
|
-
HintingMerkleWriteOperations.log.trace(`[${action}] ${treeName} tree state: ${beforeState.root}, ${beforeState.nextAvailableLeafIndex} -> ${afterState.root}, ${afterState.nextAvailableLeafIndex}.`);
|
|
248
|
-
}
|
|
249
|
-
async appendLeafInternal(treeId, leaf) {
|
|
250
|
-
// Use sequentialInsert for PublicDataTree and NullifierTree.
|
|
251
|
-
assert(treeId == MerkleTreeId.NOTE_HASH_TREE || treeId == MerkleTreeId.L1_TO_L2_MESSAGE_TREE);
|
|
252
|
-
const beforeState = await this.getHintKey(treeId);
|
|
253
|
-
await this.db.appendLeaves(treeId, [
|
|
254
|
-
leaf
|
|
255
|
-
]);
|
|
256
|
-
const afterState = await this.getHintKey(treeId);
|
|
257
|
-
HintingMerkleWriteOperations.logTreeChange('appendLeaves', beforeState, afterState, treeId);
|
|
258
|
-
this.hints.appendLeavesHints.push(new AvmAppendLeavesHint(beforeState, afterState, treeId, [
|
|
259
|
-
leaf
|
|
260
|
-
]));
|
|
261
|
-
return await this.getSiblingPath(treeId, BigInt(beforeState.nextAvailableLeafIndex));
|
|
262
|
-
}
|
|
263
|
-
// Non-hinted required methods from MerkleTreeWriteOperations interface
|
|
264
|
-
async getTreeInfo(treeId) {
|
|
265
|
-
return await this.db.getTreeInfo(treeId);
|
|
266
|
-
}
|
|
267
|
-
async getStateReference() {
|
|
268
|
-
return await this.db.getStateReference();
|
|
269
|
-
}
|
|
270
|
-
getInitialHeader() {
|
|
271
|
-
return this.db.getInitialHeader();
|
|
272
|
-
}
|
|
273
|
-
getRevision() {
|
|
274
|
-
return this.db.getRevision();
|
|
275
|
-
}
|
|
276
|
-
async updateArchive(header) {
|
|
277
|
-
return await this.db.updateArchive(header);
|
|
278
|
-
}
|
|
279
|
-
async batchInsert(treeId, leaves, subtreeHeight) {
|
|
280
|
-
return await this.db.batchInsert(treeId, leaves, subtreeHeight);
|
|
281
|
-
}
|
|
282
|
-
async close() {
|
|
283
|
-
return await this.db.close();
|
|
284
|
-
}
|
|
285
|
-
async findLeafIndices(treeId, values) {
|
|
286
|
-
return await this.db.findLeafIndices(treeId, values);
|
|
287
|
-
}
|
|
288
|
-
findSiblingPaths(treeId, values) {
|
|
289
|
-
return this.db.findSiblingPaths(treeId, values);
|
|
290
|
-
}
|
|
291
|
-
async findLeafIndicesAfter(treeId, values, startIndex) {
|
|
292
|
-
return await this.db.findLeafIndicesAfter(treeId, values, startIndex);
|
|
293
|
-
}
|
|
294
|
-
async getBlockNumbersForLeafIndices(treeId, leafIndices) {
|
|
295
|
-
return await this.db.getBlockNumbersForLeafIndices(treeId, leafIndices);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { type Logger } from '@aztec/foundation/log';
|
|
2
|
-
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
3
|
-
import type { GlobalVariables, Tx } from '@aztec/stdlib/tx';
|
|
4
|
-
import type { ExecutorMetricsInterface } from '../executor_metrics_interface.js';
|
|
5
|
-
import type { PublicContractsDB } from '../public_db_sources.js';
|
|
6
|
-
import { type PublicTxResult, PublicTxSimulator, type PublicTxSimulatorConfig } from './public_tx_simulator.js';
|
|
7
|
-
import type { MeasuredPublicTxSimulatorInterface, PublicTxSimulatorInterface } from './public_tx_simulator_interface.js';
|
|
8
|
-
/**
|
|
9
|
-
* C++ implementation of PublicTxSimulator using pre-collected hints.
|
|
10
|
-
* This implementation runs TS simulation first to collect all hints,
|
|
11
|
-
* then passes the complete AvmCircuitInputs (hints + public inputs)
|
|
12
|
-
* to C++ to run hinted simulation.
|
|
13
|
-
*/
|
|
14
|
-
export declare class CppPublicTxSimulatorHintedDbs extends PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
15
|
-
protected log: Logger;
|
|
16
|
-
constructor(merkleTree: MerkleTreeWriteOperations, contractsDB: PublicContractsDB, globalVariables: GlobalVariables, config?: Partial<PublicTxSimulatorConfig>);
|
|
17
|
-
/**
|
|
18
|
-
* Simulate a transaction's public portion using the C++ vm2 simulator with hinted DBs.
|
|
19
|
-
*
|
|
20
|
-
* This implementation:
|
|
21
|
-
* 1. Runs the full TypeScript simulation to generate AvmCircuitInputs (hints + public inputs)
|
|
22
|
-
* 2. Passes the complete AvmCircuitInputs to C++ to run hinted simulation
|
|
23
|
-
*
|
|
24
|
-
* @param tx - The transaction to simulate.
|
|
25
|
-
* @returns The result of the transaction's public execution.
|
|
26
|
-
*/
|
|
27
|
-
simulate(tx: Tx): Promise<PublicTxResult>;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Class to record metrics for simulation.
|
|
31
|
-
*
|
|
32
|
-
* Note(dbanks12): We might not be able to collect all the same metrics in C++ as we do in TS!
|
|
33
|
-
* Unless we move some of the metrics collection to C++, we don't have inner functions exposed
|
|
34
|
-
* to TS for tracking.
|
|
35
|
-
*/
|
|
36
|
-
export declare class MeasuredCppPublicTxSimulatorHintedDbs extends CppPublicTxSimulatorHintedDbs implements MeasuredPublicTxSimulatorInterface {
|
|
37
|
-
protected readonly metrics: ExecutorMetricsInterface;
|
|
38
|
-
constructor(merkleTree: MerkleTreeWriteOperations, contractsDB: PublicContractsDB, globalVariables: GlobalVariables, metrics: ExecutorMetricsInterface, config?: Partial<PublicTxSimulatorConfig>);
|
|
39
|
-
simulate(tx: Tx, txLabel?: string): Promise<PublicTxResult>;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=cpp_public_tx_simulator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cpp_public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/cpp_public_tx_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAIlE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,KAAK,cAAc,EAAE,iBAAiB,EAAE,KAAK,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAChH,OAAO,KAAK,EACV,kCAAkC,EAClC,0BAA0B,EAC3B,MAAM,oCAAoC,CAAC;AAE5C;;;;;GAKG;AACH,qBAAa,6BAA8B,SAAQ,iBAAkB,YAAW,0BAA0B;IACxG,UAAmB,GAAG,EAAE,MAAM,CAAC;gBAG7B,UAAU,EAAE,yBAAyB,EACrC,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EAChC,MAAM,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC;IAM3C;;;;;;;;;OASG;IACmB,QAAQ,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;CAkDhE;AAED;;;;;;GAMG;AACH,qBAAa,qCACX,SAAQ,6BACR,YAAW,kCAAkC;IAM3C,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,wBAAwB;gBAHpD,UAAU,EAAE,yBAAyB,EACrC,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EACb,OAAO,EAAE,wBAAwB,EACpD,MAAM,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC;IAKrB,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,GAAE,MAAsB,GAAG,OAAO,CAAC,cAAc,CAAC;CAUjG"}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { avmSimulateWithHintedDbs } from '@aztec/native';
|
|
3
|
-
import { deserializeFromMessagePack } from '@aztec/stdlib/avm';
|
|
4
|
-
import { SimulationError } from '@aztec/stdlib/errors';
|
|
5
|
-
import { PublicTxSimulator } from './public_tx_simulator.js';
|
|
6
|
-
/**
|
|
7
|
-
* C++ implementation of PublicTxSimulator using pre-collected hints.
|
|
8
|
-
* This implementation runs TS simulation first to collect all hints,
|
|
9
|
-
* then passes the complete AvmCircuitInputs (hints + public inputs)
|
|
10
|
-
* to C++ to run hinted simulation.
|
|
11
|
-
*/ export class CppPublicTxSimulatorHintedDbs extends PublicTxSimulator {
|
|
12
|
-
log;
|
|
13
|
-
constructor(merkleTree, contractsDB, globalVariables, config){
|
|
14
|
-
super(merkleTree, contractsDB, globalVariables, config);
|
|
15
|
-
this.log = createLogger(`simulator:cpp_public_tx_simulator_hinted_dbs`);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Simulate a transaction's public portion using the C++ vm2 simulator with hinted DBs.
|
|
19
|
-
*
|
|
20
|
-
* This implementation:
|
|
21
|
-
* 1. Runs the full TypeScript simulation to generate AvmCircuitInputs (hints + public inputs)
|
|
22
|
-
* 2. Passes the complete AvmCircuitInputs to C++ to run hinted simulation
|
|
23
|
-
*
|
|
24
|
-
* @param tx - The transaction to simulate.
|
|
25
|
-
* @returns The result of the transaction's public execution.
|
|
26
|
-
*/ async simulate(tx) {
|
|
27
|
-
const txHash = this.computeTxHash(tx);
|
|
28
|
-
this.log.debug(`C++ hinted DB simulation of ${tx.publicFunctionCalldata.length} public calls for tx ${txHash}`, {
|
|
29
|
-
txHash
|
|
30
|
-
});
|
|
31
|
-
// First, run TS simulation to generate hints and public inputs
|
|
32
|
-
this.log.debug(`Running TS simulation for tx ${txHash}`);
|
|
33
|
-
let tsResult;
|
|
34
|
-
try {
|
|
35
|
-
// Run the full TypeScript simulation using the parent class
|
|
36
|
-
// This will modify the merkle tree with the transaction's state changes
|
|
37
|
-
tsResult = await super.simulate(tx);
|
|
38
|
-
this.log.debug(`TS simulation succeeded for tx ${txHash}`);
|
|
39
|
-
} catch (error) {
|
|
40
|
-
// If TS simulation fails, clear any partial contract additions and re-throw the error
|
|
41
|
-
this.contractsDB.clearContractsForTx();
|
|
42
|
-
throw error;
|
|
43
|
-
}
|
|
44
|
-
// Extract the full AvmCircuitInputs from the TS result
|
|
45
|
-
const avmCircuitInputs = tsResult.avmProvingRequest.inputs;
|
|
46
|
-
// Second, run C++ simulation with hinted DBs
|
|
47
|
-
this.log.debug(`Running C++ simulation with hinted DBs for tx ${txHash}`);
|
|
48
|
-
// Serialize to msgpack and call the C++ simulator
|
|
49
|
-
const inputBuffer = avmCircuitInputs.serializeWithMessagePack();
|
|
50
|
-
let resultBuffer;
|
|
51
|
-
try {
|
|
52
|
-
resultBuffer = await avmSimulateWithHintedDbs(inputBuffer);
|
|
53
|
-
} catch (error) {
|
|
54
|
-
throw new SimulationError(`C++ hinted simulation failed: ${error.message}`, []);
|
|
55
|
-
}
|
|
56
|
-
// Deserialize the msgpack result
|
|
57
|
-
const _success = deserializeFromMessagePack(resultBuffer);
|
|
58
|
-
this.log.debug(`C++ hinted simulation completed for tx ${txHash}`, {
|
|
59
|
-
txHash,
|
|
60
|
-
reverted: !tsResult.revertCode.isOK(),
|
|
61
|
-
tsGasUsed: tsResult.gasUsed.totalGas.l2Gas,
|
|
62
|
-
cppGasUsed: tsResult.gasUsed.totalGas.l2Gas
|
|
63
|
-
});
|
|
64
|
-
// TODO(dbanks12): C++ should return PublicTxResult (or something similar)
|
|
65
|
-
return tsResult;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Class to record metrics for simulation.
|
|
70
|
-
*
|
|
71
|
-
* Note(dbanks12): We might not be able to collect all the same metrics in C++ as we do in TS!
|
|
72
|
-
* Unless we move some of the metrics collection to C++, we don't have inner functions exposed
|
|
73
|
-
* to TS for tracking.
|
|
74
|
-
*/ export class MeasuredCppPublicTxSimulatorHintedDbs extends CppPublicTxSimulatorHintedDbs {
|
|
75
|
-
metrics;
|
|
76
|
-
constructor(merkleTree, contractsDB, globalVariables, metrics, config){
|
|
77
|
-
super(merkleTree, contractsDB, globalVariables, config), this.metrics = metrics;
|
|
78
|
-
}
|
|
79
|
-
async simulate(tx, txLabel = 'unlabeledTx') {
|
|
80
|
-
this.metrics.startRecordingTxSimulation(txLabel);
|
|
81
|
-
let result;
|
|
82
|
-
try {
|
|
83
|
-
result = await super.simulate(tx);
|
|
84
|
-
} finally{
|
|
85
|
-
this.metrics.stopRecordingTxSimulation(txLabel, result?.revertCode);
|
|
86
|
-
}
|
|
87
|
-
return result;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import type { Gas } from '@aztec/stdlib/gas';
|
|
3
|
-
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
4
|
-
import { type GlobalVariables, PublicCallRequestWithCalldata, Tx, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
5
|
-
import type { AvmFinalizedCallResult } from '../avm/avm_contract_call_result.js';
|
|
6
|
-
import type { ExecutorMetricsInterface } from '../executor_metrics_interface.js';
|
|
7
|
-
import type { PublicContractsDB } from '../public_db_sources.js';
|
|
8
|
-
import type { PublicPersistableStateManager } from '../state_manager/state_manager.js';
|
|
9
|
-
import { PublicTxContext } from './public_tx_context.js';
|
|
10
|
-
import { type ProcessedPhase, type PublicTxResult, PublicTxSimulator, type PublicTxSimulatorConfig } from './public_tx_simulator.js';
|
|
11
|
-
import type { MeasuredPublicTxSimulatorInterface } from './public_tx_simulator_interface.js';
|
|
12
|
-
/**
|
|
13
|
-
* A public tx simulator that tracks miscellaneous simulation metrics without telemetry.
|
|
14
|
-
*/
|
|
15
|
-
export declare class MeasuredPublicTxSimulator extends PublicTxSimulator implements MeasuredPublicTxSimulatorInterface {
|
|
16
|
-
protected readonly metrics: ExecutorMetricsInterface;
|
|
17
|
-
constructor(merkleTree: MerkleTreeWriteOperations, contractsDB: PublicContractsDB, globalVariables: GlobalVariables, metrics: ExecutorMetricsInterface, config?: Partial<PublicTxSimulatorConfig>);
|
|
18
|
-
simulate(tx: Tx, txLabel?: string): Promise<PublicTxResult>;
|
|
19
|
-
protected insertNonRevertiblesFromPrivate(context: PublicTxContext, tx: Tx): Promise<void>;
|
|
20
|
-
protected insertRevertiblesFromPrivate(context: PublicTxContext, tx: Tx): Promise<void>;
|
|
21
|
-
protected simulatePhase(phase: TxExecutionPhase, context: PublicTxContext): Promise<ProcessedPhase>;
|
|
22
|
-
protected simulateEnqueuedCallInternal(stateManager: PublicPersistableStateManager, callRequest: PublicCallRequestWithCalldata, allocatedGas: Gas, transactionFee: Fr, fnName: string): Promise<AvmFinalizedCallResult>;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=measured_public_tx_simulator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"measured_public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/measured_public_tx_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,KAAK,eAAe,EAAE,6BAA6B,EAAE,EAAE,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE7G,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,iBAAiB,EACjB,KAAK,uBAAuB,EAC7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,oCAAoC,CAAC;AAE7F;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,iBAAkB,YAAW,kCAAkC;IAK1G,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,wBAAwB;gBAHpD,UAAU,EAAE,yBAAyB,EACrC,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EACb,OAAO,EAAE,wBAAwB,EACpD,MAAM,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC;IAKrB,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,GAAE,MAAsB,GAAG,OAAO,CAAC,cAAc,CAAC;cAWvE,+BAA+B,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,EAAE;cAMhE,4BAA4B,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,EAAE;cAM7D,aAAa,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC;cAOzF,4BAA4B,CACnD,YAAY,EAAE,6BAA6B,EAC3C,WAAW,EAAE,6BAA6B,EAC1C,YAAY,EAAE,GAAG,EACjB,cAAc,EAAE,EAAE,EAClB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,sBAAsB,CAAC;CAsCnC"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Timer } from '@aztec/foundation/timer';
|
|
2
|
-
import { PublicTxSimulator } from './public_tx_simulator.js';
|
|
3
|
-
/**
|
|
4
|
-
* A public tx simulator that tracks miscellaneous simulation metrics without telemetry.
|
|
5
|
-
*/ export class MeasuredPublicTxSimulator extends PublicTxSimulator {
|
|
6
|
-
metrics;
|
|
7
|
-
constructor(merkleTree, contractsDB, globalVariables, metrics, config){
|
|
8
|
-
super(merkleTree, contractsDB, globalVariables, config), this.metrics = metrics;
|
|
9
|
-
}
|
|
10
|
-
async simulate(tx, txLabel = 'unlabeledTx') {
|
|
11
|
-
this.metrics.startRecordingTxSimulation(txLabel);
|
|
12
|
-
let avmResult;
|
|
13
|
-
try {
|
|
14
|
-
avmResult = await super.simulate(tx);
|
|
15
|
-
} finally{
|
|
16
|
-
this.metrics.stopRecordingTxSimulation(txLabel, avmResult?.revertCode);
|
|
17
|
-
}
|
|
18
|
-
return avmResult;
|
|
19
|
-
}
|
|
20
|
-
async insertNonRevertiblesFromPrivate(context, tx) {
|
|
21
|
-
const timer = new Timer();
|
|
22
|
-
await super.insertNonRevertiblesFromPrivate(context, tx);
|
|
23
|
-
this.metrics.recordPrivateEffectsInsertion(timer.us(), 'non-revertible');
|
|
24
|
-
}
|
|
25
|
-
async insertRevertiblesFromPrivate(context, tx) {
|
|
26
|
-
const timer = new Timer();
|
|
27
|
-
await super.insertRevertiblesFromPrivate(context, tx);
|
|
28
|
-
this.metrics.recordPrivateEffectsInsertion(timer.us(), 'revertible');
|
|
29
|
-
}
|
|
30
|
-
async simulatePhase(phase, context) {
|
|
31
|
-
const timer = new Timer();
|
|
32
|
-
const result = await super.simulatePhase(phase, context);
|
|
33
|
-
result.durationMs = timer.ms();
|
|
34
|
-
return result;
|
|
35
|
-
}
|
|
36
|
-
async simulateEnqueuedCallInternal(stateManager, callRequest, allocatedGas, transactionFee, fnName) {
|
|
37
|
-
const timer = new Timer();
|
|
38
|
-
const result = await super.simulateEnqueuedCallInternal(stateManager, callRequest, allocatedGas, transactionFee, fnName);
|
|
39
|
-
this.log.verbose(result.reverted ? `Simulation of enqueued public call ${fnName} reverted with reason ${result.revertReason?.message}.` : `Simulation of enqueued public call ${fnName} completed successfully.`, {
|
|
40
|
-
eventName: 'avm-simulation',
|
|
41
|
-
appCircuitName: fnName,
|
|
42
|
-
duration: timer.ms()
|
|
43
|
-
});
|
|
44
|
-
if (result.reverted) {
|
|
45
|
-
this.metrics.recordEnqueuedCallSimulationFailure(fnName, timer.ms(), allocatedGas.sub(result.gasLeft).l2Gas, result.totalInstructions);
|
|
46
|
-
} else {
|
|
47
|
-
this.metrics.recordEnqueuedCallSimulation(fnName, timer.ms(), allocatedGas.sub(result.gasLeft).l2Gas, result.totalInstructions);
|
|
48
|
-
}
|
|
49
|
-
return result;
|
|
50
|
-
}
|
|
51
|
-
}
|