@aztec/simulator 0.0.1-commit.2ed92850 → 0.0.1-commit.2f68f620
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 +4 -4
- 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_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/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 +7 -5
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts +3 -2
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/file_circuit_recorder.js +2 -2
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +7 -2
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/memory_circuit_recorder.js +4 -4
- package/dest/private/factory.d.ts +3 -3
- package/dest/private/factory.d.ts.map +1 -1
- package/dest/private/factory.js +7 -4
- package/dest/public/avm/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 +2 -1
- 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 +17 -2
- package/dest/public/avm/testing/utils.d.ts +32 -0
- package/dest/public/avm/testing/utils.d.ts.map +1 -0
- package/dest/public/avm/{fixtures → testing}/utils.js +3 -33
- package/dest/public/contracts_db_checkpoint.d.ts +2 -2
- package/dest/public/contracts_db_checkpoint.d.ts.map +1 -1
- package/dest/public/contracts_db_checkpoint.js +1 -1
- package/dest/public/executor_metrics.d.ts +1 -1
- package/dest/public/executor_metrics.d.ts.map +1 -1
- package/dest/public/executor_metrics.js +7 -2
- package/dest/public/fixtures/amm_test.js +2 -2
- package/dest/public/fixtures/bulk_test.d.ts +1 -1
- package/dest/public/fixtures/bulk_test.d.ts.map +1 -1
- package/dest/public/fixtures/bulk_test.js +31 -4
- package/dest/public/fixtures/index.d.ts +1 -4
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +0 -3
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +8 -7
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +16 -17
- package/dest/public/fixtures/simple_contract_data_source.js +1 -1
- 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 +19 -20
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts +6 -4
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts.map +1 -1
- package/dest/public/fuzzing/avm_fuzzer_simulator.js +12 -7
- package/dest/public/fuzzing/avm_simulator_bin.js +4 -4
- package/dest/public/index.d.ts +2 -2
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +1 -1
- package/dest/public/public_db_sources.d.ts +9 -5
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +20 -14
- package/dest/public/public_processor/guarded_merkle_tree.d.ts +8 -7
- package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
- package/dest/public/public_processor/guarded_merkle_tree.js +8 -5
- package/dest/public/public_processor/public_processor.d.ts +11 -6
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +112 -74
- 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 +28 -4
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +3 -2
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +5 -4
- 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_cpp_public_tx_simulator.js → dumping_public_tx_simulator.js} +4 -4
- package/dest/public/public_tx_simulator/factories.d.ts +7 -6
- package/dest/public/public_tx_simulator/factories.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/factories.js +8 -8
- package/dest/public/public_tx_simulator/index.d.ts +3 -5
- package/dest/public/public_tx_simulator/index.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/index.js +2 -4
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +42 -70
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +99 -318
- 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/test_executor_metrics.d.ts +3 -2
- package/dest/public/test_executor_metrics.d.ts.map +1 -1
- package/dest/public/test_executor_metrics.js +2 -2
- package/package.json +17 -18
- package/src/private/acvm/acvm.ts +4 -3
- package/src/private/acvm_native.ts +11 -5
- package/src/private/acvm_wasm.ts +11 -4
- package/src/private/circuit_recording/circuit_recorder.ts +7 -5
- 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 +22 -2
- package/src/public/avm/{fixtures → testing}/utils.ts +3 -39
- package/src/public/contracts_db_checkpoint.ts +1 -1
- package/src/public/executor_metrics.ts +4 -1
- package/src/public/fixtures/amm_test.ts +2 -2
- package/src/public/fixtures/bulk_test.ts +29 -4
- package/src/public/fixtures/index.ts +0 -3
- package/src/public/fixtures/public_tx_simulation_tester.ts +30 -15
- package/src/public/fixtures/simple_contract_data_source.ts +1 -1
- package/src/public/fixtures/utils.ts +26 -22
- package/src/public/fuzzing/avm_fuzzer_simulator.ts +16 -19
- package/src/public/fuzzing/avm_simulator_bin.ts +3 -5
- package/src/public/index.ts +3 -3
- package/src/public/public_db_sources.ts +36 -19
- package/src/public/public_processor/guarded_merkle_tree.ts +11 -8
- package/src/public/public_processor/public_processor.ts +156 -94
- package/src/public/public_processor/public_processor_metrics.ts +22 -4
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +9 -5
- package/src/public/public_tx_simulator/{dumping_cpp_public_tx_simulator.ts → dumping_public_tx_simulator.ts} +5 -3
- package/src/public/public_tx_simulator/factories.ts +10 -7
- package/src/public/public_tx_simulator/index.ts +2 -4
- package/src/public/public_tx_simulator/public_tx_simulator.ts +153 -475
- package/src/public/public_tx_simulator/public_tx_simulator_base.ts +35 -0
- package/src/public/test_executor_metrics.ts +3 -3
- 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 -24
- package/dest/public/avm/avm_execution_environment.d.ts.map +0 -1
- package/dest/public/avm/avm_execution_environment.js +0 -33
- 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 -98
- package/dest/public/avm/avm_machine_state.d.ts.map +0 -1
- package/dest/public/avm/avm_machine_state.js +0 -110
- 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 -354
- package/dest/public/avm/avm_simulator.d.ts +0 -41
- package/dest/public/avm/avm_simulator.d.ts.map +0 -1
- package/dest/public/avm/avm_simulator.js +0 -192
- 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/calldata.d.ts +0 -51
- package/dest/public/avm/calldata.d.ts.map +0 -1
- package/dest/public/avm/calldata.js +0 -63
- package/dest/public/avm/errors.d.ts +0 -104
- package/dest/public/avm/errors.d.ts.map +0 -1
- package/dest/public/avm/errors.js +0 -141
- 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 -84
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +0 -1
- package/dest/public/avm/fixtures/initializers.d.ts +0 -42
- package/dest/public/avm/fixtures/initializers.d.ts.map +0 -1
- package/dest/public/avm/fixtures/initializers.js +0 -45
- package/dest/public/avm/fixtures/utils.d.ts +0 -39
- 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 -259
- 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 -49
- package/dest/public/avm/opcodes/arithmetic.d.ts.map +0 -1
- package/dest/public/avm/opcodes/arithmetic.js +0 -97
- 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 -93
- 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 -210
- 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 -119
- 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 -25
- package/dest/public/avm/opcodes/storage.d.ts.map +0 -1
- package/dest/public/avm/opcodes/storage.js +0 -78
- 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 -39
- 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 -336
- 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 -18
- package/dest/public/debug_fn_name.d.ts.map +0 -1
- package/dest/public/debug_fn_name.js +0 -37
- package/dest/public/fixtures/custom_bytecode_tests.d.ts +0 -12
- package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +0 -1
- package/dest/public/fixtures/custom_bytecode_tests.js +0 -174
- package/dest/public/fixtures/minimal_public_tx.d.ts +0 -4
- package/dest/public/fixtures/minimal_public_tx.d.ts.map +0 -1
- package/dest/public/fixtures/minimal_public_tx.js +0 -19
- package/dest/public/fixtures/opcode_spammer.d.ts +0 -123
- package/dest/public/fixtures/opcode_spammer.d.ts.map +0 -1
- package/dest/public/fixtures/opcode_spammer.js +0 -1693
- package/dest/public/hinting_db_sources.d.ts +0 -80
- package/dest/public/hinting_db_sources.d.ts.map +0 -1
- package/dest/public/hinting_db_sources.js +0 -355
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +0 -53
- 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 -132
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts +0 -42
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts.map +0 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.js +0 -86
- package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts +0 -30
- package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts.map +0 -1
- package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.js +0 -171
- package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts +0 -22
- package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts.map +0 -1
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +0 -31
- 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 -130
- 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 -300
- 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 -415
- 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 -22
- 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 -164
- package/dest/public/state_manager/state_manager.d.ts.map +0 -1
- package/dest/public/state_manager/state_manager.js +0 -395
- package/src/public/avm/avm_context.ts +0 -61
- package/src/public/avm/avm_contract_call_result.ts +0 -69
- package/src/public/avm/avm_execution_environment.ts +0 -51
- package/src/public/avm/avm_gas.ts +0 -183
- package/src/public/avm/avm_machine_state.ts +0 -170
- package/src/public/avm/avm_memory_types.ts +0 -440
- package/src/public/avm/avm_simulator.ts +0 -279
- package/src/public/avm/avm_simulator_interface.ts +0 -8
- package/src/public/avm/calldata.ts +0 -100
- package/src/public/avm/errors.ts +0 -177
- package/src/public/avm/fixtures/avm_simulation_tester.ts +0 -122
- package/src/public/avm/fixtures/initializers.ts +0 -103
- package/src/public/avm/index.ts +0 -1
- package/src/public/avm/opcodes/accrued_substate.ts +0 -294
- package/src/public/avm/opcodes/addressing_mode.ts +0 -111
- package/src/public/avm/opcodes/arithmetic.ts +0 -129
- 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 -72
- 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 -105
- package/src/public/avm/opcodes/environment_getters.ts +0 -87
- package/src/public/avm/opcodes/external_calls.ts +0 -262
- package/src/public/avm/opcodes/hashing.ts +0 -151
- 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 -95
- package/src/public/avm/revert_reason.ts +0 -58
- package/src/public/avm/serialization/buffer_cursor.ts +0 -118
- package/src/public/avm/serialization/bytecode_serialization.ts +0 -215
- 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 -52
- package/src/public/fixtures/custom_bytecode_tests.ts +0 -228
- package/src/public/fixtures/minimal_public_tx.ts +0 -26
- package/src/public/fixtures/opcode_spammer.ts +0 -1754
- package/src/public/hinting_db_sources.ts +0 -607
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +0 -208
- package/src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts +0 -132
- package/src/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.ts +0 -237
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +0 -105
- package/src/public/public_tx_simulator/public_tx_context.ts +0 -477
- 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 -546
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import type { IndexedTreeLeafPreimage, SiblingPath } from '@aztec/foundation/trees';
|
|
4
|
-
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
5
|
-
import { type AvmExecutionHints } from '@aztec/stdlib/avm';
|
|
6
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
|
-
import type { ContractClassPublic, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
8
|
-
import { type BatchInsertionResult, type IndexedTreeId, MerkleTreeId, type MerkleTreeLeafType, type MerkleTreeWriteOperations, type SequentialInsertionResult, type TreeHeights } from '@aztec/stdlib/trees';
|
|
9
|
-
import type { UInt64 } from '@aztec/stdlib/types';
|
|
10
|
-
import type { WorldStateRevision } from '@aztec/stdlib/world-state';
|
|
11
|
-
import type { PublicContractsDBInterface } from './db_interfaces.js';
|
|
12
|
-
/**
|
|
13
|
-
* A public contracts database that forwards requests and collects AVM hints.
|
|
14
|
-
*/
|
|
15
|
-
export declare class HintingPublicContractsDB implements PublicContractsDBInterface {
|
|
16
|
-
private readonly db;
|
|
17
|
-
private hints;
|
|
18
|
-
private static readonly log;
|
|
19
|
-
private checkpointActionCounter;
|
|
20
|
-
private nextCheckpointId;
|
|
21
|
-
private checkpointStack;
|
|
22
|
-
constructor(db: PublicContractsDBInterface, hints: AvmExecutionHints);
|
|
23
|
-
getContractInstance(address: AztecAddress, timestamp: UInt64): Promise<ContractInstanceWithAddress | undefined>;
|
|
24
|
-
getContractClass(contractClassId: Fr): Promise<ContractClassPublic | undefined>;
|
|
25
|
-
getBytecodeCommitment(contractClassId: Fr): Promise<Fr | undefined>;
|
|
26
|
-
getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
|
|
27
|
-
createCheckpoint(): void;
|
|
28
|
-
commitCheckpoint(): void;
|
|
29
|
-
revertCheckpoint(): void;
|
|
30
|
-
private getHintKey;
|
|
31
|
-
private getCurrentCheckpointId;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* A low-level merkle DB that collects hints.
|
|
35
|
-
*/
|
|
36
|
-
export declare class HintingMerkleWriteOperations implements MerkleTreeWriteOperations {
|
|
37
|
-
private db;
|
|
38
|
-
private hints;
|
|
39
|
-
private static readonly log;
|
|
40
|
-
private checkpointStack;
|
|
41
|
-
private nextCheckpointId;
|
|
42
|
-
private checkpointActionCounter;
|
|
43
|
-
static create(db: MerkleTreeWriteOperations, hints: AvmExecutionHints): Promise<HintingMerkleWriteOperations>;
|
|
44
|
-
private constructor();
|
|
45
|
-
getSiblingPath<ID extends MerkleTreeId>(treeId: ID, index: bigint): Promise<SiblingPath<TreeHeights[ID]>>;
|
|
46
|
-
getPreviousValueIndex<ID extends IndexedTreeId>(treeId: ID, value: bigint): Promise<{
|
|
47
|
-
index: bigint;
|
|
48
|
-
alreadyPresent: boolean;
|
|
49
|
-
} | undefined>;
|
|
50
|
-
getLeafPreimage<ID extends IndexedTreeId>(treeId: ID, index: bigint): Promise<IndexedTreeLeafPreimage | undefined>;
|
|
51
|
-
getLeafValue<ID extends MerkleTreeId>(treeId: ID, index: bigint): Promise<MerkleTreeLeafType<typeof treeId> | undefined>;
|
|
52
|
-
sequentialInsert<TreeHeight extends number, ID extends IndexedTreeId>(treeId: ID, leaves: Buffer[]): Promise<SequentialInsertionResult<TreeHeight>>;
|
|
53
|
-
appendLeaves<ID extends MerkleTreeId>(treeId: ID, leaves: MerkleTreeLeafType<ID>[]): Promise<void>;
|
|
54
|
-
createCheckpoint(): Promise<void>;
|
|
55
|
-
commitAllCheckpoints(): Promise<void>;
|
|
56
|
-
revertAllCheckpoints(): Promise<void>;
|
|
57
|
-
commitCheckpoint(): Promise<void>;
|
|
58
|
-
revertCheckpoint(): Promise<void>;
|
|
59
|
-
private getHintKey;
|
|
60
|
-
private getCurrentCheckpointId;
|
|
61
|
-
private getTreesStateHash;
|
|
62
|
-
private static logTreeChange;
|
|
63
|
-
private appendLeafInternal;
|
|
64
|
-
getTreeInfo(treeId: MerkleTreeId): Promise<import("@aztec/stdlib/trees").TreeInfo>;
|
|
65
|
-
getStateReference(): Promise<import("@aztec/stdlib/tx").StateReference>;
|
|
66
|
-
getInitialHeader(): import("@aztec/stdlib/tx").BlockHeader;
|
|
67
|
-
getRevision(): WorldStateRevision;
|
|
68
|
-
updateArchive(header: any): Promise<void>;
|
|
69
|
-
batchInsert<TreeHeight extends number, SubtreeSiblingPathHeight extends number, ID extends IndexedTreeId>(treeId: ID, leaves: Buffer[], subtreeHeight: number): Promise<BatchInsertionResult<TreeHeight, SubtreeSiblingPathHeight>>;
|
|
70
|
-
close(): Promise<void>;
|
|
71
|
-
[Symbol.dispose](): Promise<void>;
|
|
72
|
-
findLeafIndices<ID extends MerkleTreeId>(treeId: ID, values: MerkleTreeLeafType<ID>[]): Promise<(bigint | undefined)[]>;
|
|
73
|
-
findSiblingPaths<ID extends MerkleTreeId>(treeId: ID, values: MerkleTreeLeafType<ID>[]): Promise<({
|
|
74
|
-
path: SiblingPath<TreeHeights[ID]>;
|
|
75
|
-
index: bigint;
|
|
76
|
-
} | undefined)[]>;
|
|
77
|
-
findLeafIndicesAfter<ID extends MerkleTreeId>(treeId: ID, values: MerkleTreeLeafType<ID>[], startIndex: bigint): Promise<(bigint | undefined)[]>;
|
|
78
|
-
getBlockNumbersForLeafIndices<ID extends MerkleTreeId>(treeId: ID, leafIndices: bigint[]): Promise<(BlockNumber | undefined)[]>;
|
|
79
|
-
}
|
|
80
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGludGluZ19kYl9zb3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EAAE,EAChC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC,CAEjC;IAEY,6BAA6B,CAAC,EAAE,SAAS,YAAY,EAChE,MAAM,EAAE,EAAE,EACV,WAAW,EAAE,MAAM,EAAE,GACpB,OAAO,CAAC,CAAC,WAAW,GAAG,SAAS,CAAC,EAAE,CAAC,CAEtC;CACF"}
|
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
var _computedKey;
|
|
2
|
-
import { sha256Trunc } from '@aztec/foundation/crypto/sha256';
|
|
3
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
-
import { AvmAppendLeavesHint, AvmBytecodeCommitmentHint, AvmCommitCheckpointHint, AvmContractClassHint, AvmContractDbCommitCheckpointHint, AvmContractDbCreateCheckpointHint, AvmContractDbRevertCheckpointHint, AvmContractInstanceHint, AvmCreateCheckpointHint, AvmDebugFunctionNameHint, AvmGetLeafPreimageHintNullifierTree, AvmGetLeafPreimageHintPublicDataTree, AvmGetLeafValueHint, AvmGetPreviousValueIndexHint, AvmGetSiblingPathHint, AvmRevertCheckpointHint, AvmSequentialInsertHintNullifierTree, AvmSequentialInsertHintPublicDataTree } from '@aztec/stdlib/avm';
|
|
6
|
-
import { AppendOnlyTreeSnapshot, MerkleTreeId, NullifierLeaf, PublicDataTreeLeaf, getTreeName, merkleTreeIds } from '@aztec/stdlib/trees';
|
|
7
|
-
import { TreeSnapshots } from '@aztec/stdlib/tx';
|
|
8
|
-
import { strict as assert } from 'assert';
|
|
9
|
-
/**
|
|
10
|
-
* A public contracts database that forwards requests and collects AVM hints.
|
|
11
|
-
*/ export class HintingPublicContractsDB {
|
|
12
|
-
db;
|
|
13
|
-
hints;
|
|
14
|
-
static log = createLogger('simulator:hinting-public-contracts-db');
|
|
15
|
-
checkpointActionCounter;
|
|
16
|
-
nextCheckpointId;
|
|
17
|
-
checkpointStack;
|
|
18
|
-
constructor(db, hints){
|
|
19
|
-
this.db = db;
|
|
20
|
-
this.hints = hints;
|
|
21
|
-
this.checkpointActionCounter = 0;
|
|
22
|
-
this.nextCheckpointId = 1;
|
|
23
|
-
this.checkpointStack = [
|
|
24
|
-
0
|
|
25
|
-
];
|
|
26
|
-
}
|
|
27
|
-
async getContractInstance(address, timestamp) {
|
|
28
|
-
const instance = await this.db.getContractInstance(address, timestamp);
|
|
29
|
-
if (instance) {
|
|
30
|
-
const hintKey = this.getHintKey();
|
|
31
|
-
this.hints.contractInstances.push(new AvmContractInstanceHint(hintKey, instance.address, instance.salt, instance.deployer, instance.currentContractClassId, instance.originalContractClassId, instance.initializationHash, instance.publicKeys));
|
|
32
|
-
HintingPublicContractsDB.log.trace(`[getContractInstance:${hintKey}] Added contract instance ${instance.address.toString()} to hints.`);
|
|
33
|
-
}
|
|
34
|
-
return instance;
|
|
35
|
-
}
|
|
36
|
-
async getContractClass(contractClassId) {
|
|
37
|
-
const contractClass = await this.db.getContractClass(contractClassId);
|
|
38
|
-
if (contractClass) {
|
|
39
|
-
const hintKey = this.getHintKey();
|
|
40
|
-
this.hints.contractClasses.push(new AvmContractClassHint(hintKey, contractClass.id, contractClass.artifactHash, contractClass.privateFunctionsRoot, contractClass.packedBytecode));
|
|
41
|
-
HintingPublicContractsDB.log.trace(`[getContractClass:${hintKey}] Added contract class ${contractClassId.toString()} to hints.`);
|
|
42
|
-
}
|
|
43
|
-
return contractClass;
|
|
44
|
-
}
|
|
45
|
-
async getBytecodeCommitment(contractClassId) {
|
|
46
|
-
const commitment = await this.db.getBytecodeCommitment(contractClassId);
|
|
47
|
-
if (commitment) {
|
|
48
|
-
const hintKey = this.getHintKey();
|
|
49
|
-
this.hints.bytecodeCommitments.push(new AvmBytecodeCommitmentHint(hintKey, contractClassId, commitment));
|
|
50
|
-
HintingPublicContractsDB.log.trace(`[getBytecodeCommitment:${hintKey}] Added bytecode commitment ${commitment.toString()} to hints for contract class ${contractClassId.toString()}.`);
|
|
51
|
-
}
|
|
52
|
-
return commitment;
|
|
53
|
-
}
|
|
54
|
-
async getDebugFunctionName(contractAddress, selector) {
|
|
55
|
-
const name = await this.db.getDebugFunctionName(contractAddress, selector);
|
|
56
|
-
if (name) {
|
|
57
|
-
HintingPublicContractsDB.log.debug(`[getDebugFunctionName] Adding debug function name ${name} to hints for contract ${contractAddress.toString()} and selector ${selector.toString()}.`);
|
|
58
|
-
// We hint selector as a field to make things way simpler in C++.
|
|
59
|
-
this.hints.debugFunctionNames.push(new AvmDebugFunctionNameHint(contractAddress, selector.toField(), name));
|
|
60
|
-
}
|
|
61
|
-
return name;
|
|
62
|
-
}
|
|
63
|
-
createCheckpoint() {
|
|
64
|
-
const hintKey = this.getHintKey();
|
|
65
|
-
this.checkpointActionCounter++;
|
|
66
|
-
const oldCheckpointId = this.getCurrentCheckpointId();
|
|
67
|
-
this.db.createCheckpoint();
|
|
68
|
-
const newCheckpointId = this.nextCheckpointId++;
|
|
69
|
-
this.checkpointStack.push(newCheckpointId);
|
|
70
|
-
this.hints.contractDbCreateCheckpointHints.push(new AvmContractDbCreateCheckpointHint(hintKey, oldCheckpointId, newCheckpointId));
|
|
71
|
-
HintingPublicContractsDB.log.trace(`[createCheckpoint:${hintKey}] Checkpoint evolved ${oldCheckpointId} -> ${newCheckpointId}.`);
|
|
72
|
-
}
|
|
73
|
-
commitCheckpoint() {
|
|
74
|
-
const hintKey = this.getHintKey();
|
|
75
|
-
this.checkpointActionCounter++;
|
|
76
|
-
const oldCheckpointId = this.getCurrentCheckpointId();
|
|
77
|
-
this.db.commitCheckpoint();
|
|
78
|
-
this.checkpointStack.pop();
|
|
79
|
-
const newCheckpointId = this.getCurrentCheckpointId();
|
|
80
|
-
this.hints.contractDbCommitCheckpointHints.push(new AvmContractDbCommitCheckpointHint(hintKey, oldCheckpointId, newCheckpointId));
|
|
81
|
-
HintingPublicContractsDB.log.trace(`[commitCheckpoint:${hintKey}] Checkpoint evolved ${oldCheckpointId} -> ${newCheckpointId}.`);
|
|
82
|
-
}
|
|
83
|
-
revertCheckpoint() {
|
|
84
|
-
const hintKey = this.getHintKey();
|
|
85
|
-
this.checkpointActionCounter++;
|
|
86
|
-
const oldCheckpointId = this.getCurrentCheckpointId();
|
|
87
|
-
this.db.revertCheckpoint();
|
|
88
|
-
this.checkpointStack.pop();
|
|
89
|
-
const newCheckpointId = this.getCurrentCheckpointId();
|
|
90
|
-
this.hints.contractDbRevertCheckpointHints.push(new AvmContractDbRevertCheckpointHint(hintKey, oldCheckpointId, newCheckpointId));
|
|
91
|
-
HintingPublicContractsDB.log.trace(`[revertCheckpoint:${hintKey}] Checkpoint evolved ${oldCheckpointId} -> ${newCheckpointId}.`);
|
|
92
|
-
}
|
|
93
|
-
// Private methods.
|
|
94
|
-
getHintKey() {
|
|
95
|
-
return this.checkpointActionCounter;
|
|
96
|
-
}
|
|
97
|
-
getCurrentCheckpointId() {
|
|
98
|
-
return this.checkpointStack[this.checkpointStack.length - 1];
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
_computedKey = Symbol.dispose;
|
|
102
|
-
/**
|
|
103
|
-
* A low-level merkle DB that collects hints.
|
|
104
|
-
*/ export class HintingMerkleWriteOperations {
|
|
105
|
-
db;
|
|
106
|
-
hints;
|
|
107
|
-
static log = createLogger('simulator:hinting-merkle-db');
|
|
108
|
-
// This stack is only for debugging purposes.
|
|
109
|
-
// The top of the stack is the current checkpoint id.
|
|
110
|
-
// We need the stack to be non-empty and use 0 as an arbitrary initial checkpoint id.
|
|
111
|
-
// This is not necessarily a checkpoint that happened, but whatever tree state we start with.
|
|
112
|
-
checkpointStack;
|
|
113
|
-
nextCheckpointId;
|
|
114
|
-
checkpointActionCounter;
|
|
115
|
-
static async create(db, hints) {
|
|
116
|
-
const hintingTreesDB = new HintingMerkleWriteOperations(db, hints);
|
|
117
|
-
const startStateReference = await db.getStateReference();
|
|
118
|
-
hints.startingTreeRoots = new TreeSnapshots(startStateReference.l1ToL2MessageTree, startStateReference.partial.noteHashTree, startStateReference.partial.nullifierTree, startStateReference.partial.publicDataTree);
|
|
119
|
-
return hintingTreesDB;
|
|
120
|
-
}
|
|
121
|
-
// Use create() to instantiate.
|
|
122
|
-
constructor(db, hints){
|
|
123
|
-
this.db = db;
|
|
124
|
-
this.hints = hints;
|
|
125
|
-
this.checkpointStack = [
|
|
126
|
-
0
|
|
127
|
-
];
|
|
128
|
-
this.nextCheckpointId = 1;
|
|
129
|
-
this.checkpointActionCounter = 0;
|
|
130
|
-
}
|
|
131
|
-
// Getters.
|
|
132
|
-
async getSiblingPath(treeId, index) {
|
|
133
|
-
const path = await this.db.getSiblingPath(treeId, index);
|
|
134
|
-
const key = await this.getHintKey(treeId);
|
|
135
|
-
this.hints.getSiblingPathHints.push(new AvmGetSiblingPathHint(key, treeId, index, path.toFields()));
|
|
136
|
-
return Promise.resolve(path);
|
|
137
|
-
}
|
|
138
|
-
async getPreviousValueIndex(treeId, value) {
|
|
139
|
-
const result = await this.db.getPreviousValueIndex(treeId, value);
|
|
140
|
-
if (result === undefined) {
|
|
141
|
-
throw new Error(`getPreviousValueIndex(${getTreeName(treeId)}, ${value}}) returned undefined. Possible wrong tree setup or corrupted state.`);
|
|
142
|
-
}
|
|
143
|
-
const key = await this.getHintKey(treeId);
|
|
144
|
-
this.hints.getPreviousValueIndexHints.push(new AvmGetPreviousValueIndexHint(key, treeId, new Fr(value), result.index, result.alreadyPresent));
|
|
145
|
-
return result;
|
|
146
|
-
}
|
|
147
|
-
async getLeafPreimage(treeId, index) {
|
|
148
|
-
const preimage = await this.db.getLeafPreimage(treeId, index);
|
|
149
|
-
if (preimage) {
|
|
150
|
-
const key = await this.getHintKey(treeId);
|
|
151
|
-
switch(treeId){
|
|
152
|
-
case MerkleTreeId.PUBLIC_DATA_TREE:
|
|
153
|
-
this.hints.getLeafPreimageHintsPublicDataTree.push(new AvmGetLeafPreimageHintPublicDataTree(key, index, preimage));
|
|
154
|
-
break;
|
|
155
|
-
case MerkleTreeId.NULLIFIER_TREE:
|
|
156
|
-
this.hints.getLeafPreimageHintsNullifierTree.push(new AvmGetLeafPreimageHintNullifierTree(key, index, preimage));
|
|
157
|
-
break;
|
|
158
|
-
default:
|
|
159
|
-
// Use getLeafValue for the other trees.
|
|
160
|
-
throw new Error('getLeafPreimage only supported for PublicDataTree and NullifierTree!');
|
|
161
|
-
break;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return preimage;
|
|
165
|
-
}
|
|
166
|
-
async getLeafValue(treeId, index) {
|
|
167
|
-
// Use getLeafPreimage for PublicDataTree and NullifierTree.
|
|
168
|
-
assert(treeId == MerkleTreeId.NOTE_HASH_TREE || treeId == MerkleTreeId.L1_TO_L2_MESSAGE_TREE);
|
|
169
|
-
const value = await this.db.getLeafValue(treeId, index);
|
|
170
|
-
if (value) {
|
|
171
|
-
const key = await this.getHintKey(treeId);
|
|
172
|
-
// We can cast to Fr because we know the type of the tree.
|
|
173
|
-
this.hints.getLeafValueHints.push(new AvmGetLeafValueHint(key, treeId, index, value));
|
|
174
|
-
}
|
|
175
|
-
return value;
|
|
176
|
-
}
|
|
177
|
-
// State modification.
|
|
178
|
-
// FIXME(fcarreiro): This is a horrible interface (in the merkle ops). It's receiving the leaves as buffers,
|
|
179
|
-
// from a leaf class that is NOT the one that will be used to write. Make this type safe.
|
|
180
|
-
async sequentialInsert(treeId, leaves) {
|
|
181
|
-
// Use appendLeaf for NoteHashTree and L1ToL2MessageTree.
|
|
182
|
-
assert(treeId == MerkleTreeId.PUBLIC_DATA_TREE || treeId == MerkleTreeId.NULLIFIER_TREE);
|
|
183
|
-
// We only support 1 leaf at a time for now. Can easily be extended.
|
|
184
|
-
assert(leaves.length === 1, 'sequentialInsert supports only one leaf at a time!');
|
|
185
|
-
const beforeState = await this.getHintKey(treeId);
|
|
186
|
-
const result = await this.db.sequentialInsert(treeId, leaves);
|
|
187
|
-
const afterState = await this.getHintKey(treeId);
|
|
188
|
-
HintingMerkleWriteOperations.logTreeChange('sequentialInsert', beforeState, afterState, treeId);
|
|
189
|
-
switch(treeId){
|
|
190
|
-
case MerkleTreeId.PUBLIC_DATA_TREE:
|
|
191
|
-
this.hints.sequentialInsertHintsPublicDataTree.push(new AvmSequentialInsertHintPublicDataTree(beforeState, afterState, treeId, PublicDataTreeLeaf.fromBuffer(leaves[0]), {
|
|
192
|
-
leaf: result.lowLeavesWitnessData[0].leafPreimage,
|
|
193
|
-
index: result.lowLeavesWitnessData[0].index,
|
|
194
|
-
path: result.lowLeavesWitnessData[0].siblingPath.toFields()
|
|
195
|
-
}, {
|
|
196
|
-
leaf: result.insertionWitnessData[0].leafPreimage,
|
|
197
|
-
index: result.insertionWitnessData[0].index,
|
|
198
|
-
path: result.insertionWitnessData[0].siblingPath.toFields()
|
|
199
|
-
}));
|
|
200
|
-
break;
|
|
201
|
-
case MerkleTreeId.NULLIFIER_TREE:
|
|
202
|
-
this.hints.sequentialInsertHintsNullifierTree.push(new AvmSequentialInsertHintNullifierTree(beforeState, afterState, treeId, NullifierLeaf.fromBuffer(leaves[0]), {
|
|
203
|
-
leaf: result.lowLeavesWitnessData[0].leafPreimage,
|
|
204
|
-
index: result.lowLeavesWitnessData[0].index,
|
|
205
|
-
path: result.lowLeavesWitnessData[0].siblingPath.toFields()
|
|
206
|
-
}, {
|
|
207
|
-
leaf: result.insertionWitnessData[0].leafPreimage,
|
|
208
|
-
index: result.insertionWitnessData[0].index,
|
|
209
|
-
path: result.insertionWitnessData[0].siblingPath.toFields()
|
|
210
|
-
}));
|
|
211
|
-
break;
|
|
212
|
-
default:
|
|
213
|
-
throw new Error('sequentialInsert only supported for PublicDataTree and NullifierTree!');
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
return result;
|
|
217
|
-
}
|
|
218
|
-
async appendLeaves(treeId, leaves) {
|
|
219
|
-
// Use sequentialInsert for PublicDataTree and NullifierTree.
|
|
220
|
-
assert(treeId == MerkleTreeId.NOTE_HASH_TREE || treeId == MerkleTreeId.L1_TO_L2_MESSAGE_TREE);
|
|
221
|
-
// We need to process each leaf individually because we need the sibling path after insertion, to be able to constraint the insertion.
|
|
222
|
-
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/13380): This can be changed if the world state appendLeaves returns the sibling paths.
|
|
223
|
-
if (leaves.length === 1) {
|
|
224
|
-
await this.appendLeafInternal(treeId, leaves[0]);
|
|
225
|
-
return;
|
|
226
|
-
} else {
|
|
227
|
-
// TODO(dbanks12): NON-HINTING! We skip hinting here for now because:
|
|
228
|
-
// 1. We only ever append multiple leaves (for now) when padding (all empty leaves).
|
|
229
|
-
// 2. We don't need hints per-item when padding.
|
|
230
|
-
// 3. In order to get per-item hints today, you need to append one-at-a-time (mentioned above), which is VERY slow.
|
|
231
|
-
await this.db.appendLeaves(treeId, leaves);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
async createCheckpoint() {
|
|
235
|
-
const actionCounter = this.checkpointActionCounter++;
|
|
236
|
-
const oldCheckpointId = this.getCurrentCheckpointId();
|
|
237
|
-
const treesStateHash = await this.getTreesStateHash();
|
|
238
|
-
await this.db.createCheckpoint();
|
|
239
|
-
this.checkpointStack.push(this.nextCheckpointId++);
|
|
240
|
-
const newCheckpointId = this.getCurrentCheckpointId();
|
|
241
|
-
this.hints.createCheckpointHints.push(new AvmCreateCheckpointHint(actionCounter, oldCheckpointId, newCheckpointId));
|
|
242
|
-
HintingMerkleWriteOperations.log.trace(`[createCheckpoint:${actionCounter}] Checkpoint evolved ${oldCheckpointId} -> ${newCheckpointId} at trees state ${treesStateHash}.`);
|
|
243
|
-
}
|
|
244
|
-
commitAllCheckpoints() {
|
|
245
|
-
throw new Error('commitAllCheckpoints is not supported in HintingMerkleWriteOperations.');
|
|
246
|
-
}
|
|
247
|
-
revertAllCheckpoints() {
|
|
248
|
-
throw new Error('revertAllCheckpoints is not supported in HintingMerkleWriteOperations.');
|
|
249
|
-
}
|
|
250
|
-
async commitCheckpoint() {
|
|
251
|
-
const actionCounter = this.checkpointActionCounter++;
|
|
252
|
-
const oldCheckpointId = this.getCurrentCheckpointId();
|
|
253
|
-
const treesStateHash = await this.getTreesStateHash();
|
|
254
|
-
await this.db.commitCheckpoint();
|
|
255
|
-
this.checkpointStack.pop();
|
|
256
|
-
const newCheckpointId = this.getCurrentCheckpointId();
|
|
257
|
-
this.hints.commitCheckpointHints.push(new AvmCommitCheckpointHint(actionCounter, oldCheckpointId, newCheckpointId));
|
|
258
|
-
HintingMerkleWriteOperations.log.trace(`[commitCheckpoint:${actionCounter}] Checkpoint evolved ${oldCheckpointId} -> ${newCheckpointId} at trees state ${treesStateHash}.`);
|
|
259
|
-
}
|
|
260
|
-
async revertCheckpoint() {
|
|
261
|
-
const actionCounter = this.checkpointActionCounter++;
|
|
262
|
-
const oldCheckpointId = this.getCurrentCheckpointId();
|
|
263
|
-
const treesStateHash = await this.getTreesStateHash();
|
|
264
|
-
const beforeState = {
|
|
265
|
-
[MerkleTreeId.PUBLIC_DATA_TREE]: await this.getHintKey(MerkleTreeId.PUBLIC_DATA_TREE),
|
|
266
|
-
[MerkleTreeId.NULLIFIER_TREE]: await this.getHintKey(MerkleTreeId.NULLIFIER_TREE),
|
|
267
|
-
[MerkleTreeId.NOTE_HASH_TREE]: await this.getHintKey(MerkleTreeId.NOTE_HASH_TREE),
|
|
268
|
-
[MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: await this.getHintKey(MerkleTreeId.L1_TO_L2_MESSAGE_TREE),
|
|
269
|
-
[MerkleTreeId.ARCHIVE]: await this.getHintKey(MerkleTreeId.ARCHIVE)
|
|
270
|
-
};
|
|
271
|
-
await this.db.revertCheckpoint();
|
|
272
|
-
this.checkpointStack.pop();
|
|
273
|
-
const newCheckpointId = this.getCurrentCheckpointId();
|
|
274
|
-
const afterState = {
|
|
275
|
-
[MerkleTreeId.PUBLIC_DATA_TREE]: await this.getHintKey(MerkleTreeId.PUBLIC_DATA_TREE),
|
|
276
|
-
[MerkleTreeId.NULLIFIER_TREE]: await this.getHintKey(MerkleTreeId.NULLIFIER_TREE),
|
|
277
|
-
[MerkleTreeId.NOTE_HASH_TREE]: await this.getHintKey(MerkleTreeId.NOTE_HASH_TREE),
|
|
278
|
-
[MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: await this.getHintKey(MerkleTreeId.L1_TO_L2_MESSAGE_TREE),
|
|
279
|
-
[MerkleTreeId.ARCHIVE]: await this.getHintKey(MerkleTreeId.ARCHIVE)
|
|
280
|
-
};
|
|
281
|
-
this.hints.revertCheckpointHints.push(AvmRevertCheckpointHint.create(actionCounter, oldCheckpointId, newCheckpointId, beforeState, afterState));
|
|
282
|
-
HintingMerkleWriteOperations.log.trace(`[revertCheckpoint:${actionCounter}] Checkpoint evolved ${oldCheckpointId} -> ${newCheckpointId} at trees state ${treesStateHash}.`);
|
|
283
|
-
for (const treeId of merkleTreeIds()){
|
|
284
|
-
HintingMerkleWriteOperations.logTreeChange('revertCheckpoint', beforeState[treeId], afterState[treeId], treeId);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
// Private methods.
|
|
288
|
-
async getHintKey(treeId) {
|
|
289
|
-
const treeInfo = await this.db.getTreeInfo(treeId);
|
|
290
|
-
return new AppendOnlyTreeSnapshot(Fr.fromBuffer(treeInfo.root), Number(treeInfo.size));
|
|
291
|
-
}
|
|
292
|
-
getCurrentCheckpointId() {
|
|
293
|
-
return this.checkpointStack[this.checkpointStack.length - 1];
|
|
294
|
-
}
|
|
295
|
-
// For logging/debugging purposes.
|
|
296
|
-
async getTreesStateHash() {
|
|
297
|
-
const stateReferenceFields = (await this.db.getStateReference()).toFields();
|
|
298
|
-
return Fr.fromBuffer(sha256Trunc(Buffer.concat(stateReferenceFields.map((field)=>field.toBuffer()))));
|
|
299
|
-
}
|
|
300
|
-
static logTreeChange(action, beforeState, afterState, treeId) {
|
|
301
|
-
const treeName = getTreeName(treeId);
|
|
302
|
-
HintingMerkleWriteOperations.log.trace(`[${action}] ${treeName} tree state: ${beforeState.root}, ${beforeState.nextAvailableLeafIndex} -> ${afterState.root}, ${afterState.nextAvailableLeafIndex}.`);
|
|
303
|
-
}
|
|
304
|
-
async appendLeafInternal(treeId, leaf) {
|
|
305
|
-
// Use sequentialInsert for PublicDataTree and NullifierTree.
|
|
306
|
-
assert(treeId == MerkleTreeId.NOTE_HASH_TREE || treeId == MerkleTreeId.L1_TO_L2_MESSAGE_TREE);
|
|
307
|
-
const beforeState = await this.getHintKey(treeId);
|
|
308
|
-
await this.db.appendLeaves(treeId, [
|
|
309
|
-
leaf
|
|
310
|
-
]);
|
|
311
|
-
const afterState = await this.getHintKey(treeId);
|
|
312
|
-
HintingMerkleWriteOperations.logTreeChange('appendLeaves', beforeState, afterState, treeId);
|
|
313
|
-
this.hints.appendLeavesHints.push(new AvmAppendLeavesHint(beforeState, afterState, treeId, [
|
|
314
|
-
leaf
|
|
315
|
-
]));
|
|
316
|
-
return await this.getSiblingPath(treeId, BigInt(beforeState.nextAvailableLeafIndex));
|
|
317
|
-
}
|
|
318
|
-
// Non-hinted required methods from MerkleTreeWriteOperations interface
|
|
319
|
-
async getTreeInfo(treeId) {
|
|
320
|
-
return await this.db.getTreeInfo(treeId);
|
|
321
|
-
}
|
|
322
|
-
async getStateReference() {
|
|
323
|
-
return await this.db.getStateReference();
|
|
324
|
-
}
|
|
325
|
-
getInitialHeader() {
|
|
326
|
-
return this.db.getInitialHeader();
|
|
327
|
-
}
|
|
328
|
-
getRevision() {
|
|
329
|
-
return this.db.getRevision();
|
|
330
|
-
}
|
|
331
|
-
async updateArchive(header) {
|
|
332
|
-
return await this.db.updateArchive(header);
|
|
333
|
-
}
|
|
334
|
-
async batchInsert(treeId, leaves, subtreeHeight) {
|
|
335
|
-
return await this.db.batchInsert(treeId, leaves, subtreeHeight);
|
|
336
|
-
}
|
|
337
|
-
async close() {
|
|
338
|
-
return await this.db.close();
|
|
339
|
-
}
|
|
340
|
-
async [_computedKey]() {
|
|
341
|
-
await this.close();
|
|
342
|
-
}
|
|
343
|
-
async findLeafIndices(treeId, values) {
|
|
344
|
-
return await this.db.findLeafIndices(treeId, values);
|
|
345
|
-
}
|
|
346
|
-
findSiblingPaths(treeId, values) {
|
|
347
|
-
return this.db.findSiblingPaths(treeId, values);
|
|
348
|
-
}
|
|
349
|
-
async findLeafIndicesAfter(treeId, values, startIndex) {
|
|
350
|
-
return await this.db.findLeafIndicesAfter(treeId, values, startIndex);
|
|
351
|
-
}
|
|
352
|
-
async getBlockNumbersForLeafIndices(treeId, leafIndices) {
|
|
353
|
-
return await this.db.getBlockNumbersForLeafIndices(treeId, leafIndices);
|
|
354
|
-
}
|
|
355
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { type Logger } from '@aztec/foundation/log';
|
|
2
|
-
import { type PublicSimulatorConfig, PublicTxResult } from '@aztec/stdlib/avm';
|
|
3
|
-
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
4
|
-
import type { GlobalVariables, Tx } from '@aztec/stdlib/tx';
|
|
5
|
-
import { type TelemetryClient, type Tracer } from '@aztec/telemetry-client';
|
|
6
|
-
import type { ExecutorMetricsInterface } from '../executor_metrics_interface.js';
|
|
7
|
-
import type { PublicContractsDB } from '../public_db_sources.js';
|
|
8
|
-
import { PublicTxSimulator } from './public_tx_simulator.js';
|
|
9
|
-
import type { MeasuredPublicTxSimulatorInterface, PublicTxSimulatorInterface } from './public_tx_simulator_interface.js';
|
|
10
|
-
/**
|
|
11
|
-
* C++ implementation of PublicTxSimulator using the C++ simulator.
|
|
12
|
-
* The C++ simulator accesses the world state directly/natively within C++.
|
|
13
|
-
* For contract DB accesses, it makes callbacks through NAPI back to the TS PublicContractsDB cache.
|
|
14
|
-
*/
|
|
15
|
-
export declare class CppPublicTxSimulator extends PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
16
|
-
protected log: Logger;
|
|
17
|
-
/** Current cancellation token for in-flight simulation. */
|
|
18
|
-
private cancellationToken?;
|
|
19
|
-
/** Current simulation promise, used to wait for completion after cancellation. */
|
|
20
|
-
private simulationPromise?;
|
|
21
|
-
constructor(merkleTree: MerkleTreeWriteOperations, contractsDB: PublicContractsDB, globalVariables: GlobalVariables, config?: Partial<PublicSimulatorConfig>);
|
|
22
|
-
/**
|
|
23
|
-
* Simulate a transaction's public portion using the C++ avvm simulator.
|
|
24
|
-
*
|
|
25
|
-
* @param tx - The transaction to simulate.
|
|
26
|
-
* @returns The result of the transaction's public execution.
|
|
27
|
-
*/
|
|
28
|
-
simulate(tx: Tx): Promise<PublicTxResult>;
|
|
29
|
-
/**
|
|
30
|
-
* Cancel the current simulation if one is in progress.
|
|
31
|
-
* This signals the C++ simulator to stop at the next opcode or before the next WorldState write.
|
|
32
|
-
* Safe to call even if no simulation is in progress.
|
|
33
|
-
*
|
|
34
|
-
* @param waitTimeoutMs - If provided, wait up to this many ms for the simulation to actually stop.
|
|
35
|
-
* This is important because C++ might be in the middle of a slow operation
|
|
36
|
-
* (e.g., pad_trees) and won't check the cancellation flag until it completes.
|
|
37
|
-
* Default timeout of 100ms after cancellation.
|
|
38
|
-
*/
|
|
39
|
-
cancel(waitTimeoutMs?: number): Promise<void>;
|
|
40
|
-
}
|
|
41
|
-
export declare class MeasuredCppPublicTxSimulator extends CppPublicTxSimulator implements MeasuredPublicTxSimulatorInterface {
|
|
42
|
-
protected readonly metrics: ExecutorMetricsInterface;
|
|
43
|
-
constructor(merkleTree: MerkleTreeWriteOperations, contractsDB: PublicContractsDB, globalVariables: GlobalVariables, metrics: ExecutorMetricsInterface, config?: Partial<PublicSimulatorConfig>);
|
|
44
|
-
simulate(tx: Tx, txLabel?: string): Promise<PublicTxResult>;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* A C++ public tx simulator that tracks runtime/production metrics with telemetry.
|
|
48
|
-
*/
|
|
49
|
-
export declare class TelemetryCppPublicTxSimulator extends MeasuredCppPublicTxSimulator {
|
|
50
|
-
readonly tracer: Tracer;
|
|
51
|
-
constructor(merkleTree: MerkleTreeWriteOperations, contractsDB: PublicContractsDB, globalVariables: GlobalVariables, telemetryClient?: TelemetryClient, config?: Partial<PublicSimulatorConfig>);
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3BwX3B1YmxpY190eF9zaW11bGF0b3IuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wdWJsaWMvcHVibGljX3R4X3NpbXVsYXRvci9jcHBfcHVibGljX3R4X3NpbXVsYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQTBCLE1BQU0sdUJBQXVCLENBQUM7QUFJNUUsT0FBTyxFQUdMLEtBQUsscUJBQXFCLEVBQzFCLGNBQWMsRUFFZixNQUFNLG1CQUFtQixDQUFDO0FBRTNCLE9BQU8sS0FBSyxFQUFFLHlCQUF5QixFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDckUsT0FBTyxLQUFLLEVBQUUsZUFBZSxFQUFFLEVBQUUsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRTVELE9BQU8sRUFBRSxLQUFLLGVBQWUsRUFBRSxLQUFLLE1BQU0sRUFBc0IsTUFBTSx5QkFBeUIsQ0FBQztBQUtoRyxPQUFPLEtBQUssRUFBRSx3QkFBd0IsRUFBRSxNQUFNLGtDQUFrQyxDQUFDO0FBQ2pGLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFakUsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFDN0QsT0FBTyxLQUFLLEVBQ1Ysa0NBQWtDLEVBQ2xDLDBCQUEwQixFQUMzQixNQUFNLG9DQUFvQyxDQUFDO0FBRTVDOzs7O0dBSUc7QUFDSCxxQkFBYSxvQkFBcUIsU0FBUSxpQkFBa0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,CAAkB;IAE5C,YACE,UAAU,EAAE,yBAAyB,EACrC,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EAChC,MAAM,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,EAIxC;IAED;;;;;OAKG;IACmB,QAAQ,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CA+E9D;IAED;;;;;;;;;OASG;IACU,MAAM,CAAC,aAAa,GAAE,MAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAe9D;CACF;AAED,qBAAa,4BAA6B,SAAQ,oBAAqB,YAAW,kCAAkC;IAKhH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,wBAAwB;IAJtD,YACE,UAAU,EAAE,yBAAyB,EACrC,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EACb,OAAO,EAAE,wBAAwB,EACpD,MAAM,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,EAGxC;IAEqB,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,GAAE,MAAsB,GAAG,OAAO,CAAC,cAAc,CAAC,CAS/F;CACF;AAED;;GAEG;AACH,qBAAa,6BAA8B,SAAQ,4BAA4B;IAE7E,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,YACE,UAAU,EAAE,yBAAyB,EACrC,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EAChC,eAAe,GAAE,eAAsC,EACvD,MAAM,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,EAKxC;CACF"}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { createLogger, logLevel } from '@aztec/foundation/log';
|
|
2
|
-
import { sleep } from '@aztec/foundation/sleep';
|
|
3
|
-
import { avmSimulate, cancelSimulation, createCancellationToken } from '@aztec/native';
|
|
4
|
-
import { ProtocolContractsList } from '@aztec/protocol-contracts';
|
|
5
|
-
import { AvmFastSimulationInputs, AvmTxHint, PublicTxResult, deserializeFromMessagePack } from '@aztec/stdlib/avm';
|
|
6
|
-
import { SimulationError } from '@aztec/stdlib/errors';
|
|
7
|
-
import { WorldStateRevisionWithHandle } from '@aztec/stdlib/world-state';
|
|
8
|
-
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
9
|
-
import { strict as assert } from 'assert';
|
|
10
|
-
import { ExecutorMetrics } from '../executor_metrics.js';
|
|
11
|
-
import { ContractProviderForCpp } from './contract_provider_for_cpp.js';
|
|
12
|
-
import { PublicTxSimulator } from './public_tx_simulator.js';
|
|
13
|
-
/**
|
|
14
|
-
* C++ implementation of PublicTxSimulator using the C++ simulator.
|
|
15
|
-
* The C++ simulator accesses the world state directly/natively within C++.
|
|
16
|
-
* For contract DB accesses, it makes callbacks through NAPI back to the TS PublicContractsDB cache.
|
|
17
|
-
*/ export class CppPublicTxSimulator extends PublicTxSimulator {
|
|
18
|
-
log;
|
|
19
|
-
/** Current cancellation token for in-flight simulation. */ cancellationToken;
|
|
20
|
-
/** Current simulation promise, used to wait for completion after cancellation. */ simulationPromise;
|
|
21
|
-
constructor(merkleTree, contractsDB, globalVariables, config){
|
|
22
|
-
super(merkleTree, contractsDB, globalVariables, config);
|
|
23
|
-
this.log = createLogger(`simulator:cpp_public_tx_simulator`);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Simulate a transaction's public portion using the C++ avvm simulator.
|
|
27
|
-
*
|
|
28
|
-
* @param tx - The transaction to simulate.
|
|
29
|
-
* @returns The result of the transaction's public execution.
|
|
30
|
-
*/ async simulate(tx) {
|
|
31
|
-
const txHash = this.computeTxHash(tx);
|
|
32
|
-
this.log.debug(`C++ simulation of ${tx.publicFunctionCalldata.length} public calls for tx ${txHash}`, {
|
|
33
|
-
txHash
|
|
34
|
-
});
|
|
35
|
-
// Using the "as WorldStateRevisionWithHandle" is a bit of a "trust me bro", hence the assert.
|
|
36
|
-
let wsRevision = this.merkleTree.getRevision();
|
|
37
|
-
assert(wsRevision instanceof WorldStateRevisionWithHandle, 'CppPublicTxSimulator a real NativeWorldStateInstance with a handle to the C++ WorldState object');
|
|
38
|
-
const wsCppHandle = wsRevision.handle;
|
|
39
|
-
wsRevision = wsRevision.toWorldStateRevision(); // for msgpack serialization, we don't include the handle in the type
|
|
40
|
-
this.log.trace(`Running C++ simulation with world state revision ${JSON.stringify(wsRevision)}`);
|
|
41
|
-
// Create the fast simulation inputs
|
|
42
|
-
const txHint = AvmTxHint.fromTx(tx, this.globalVariables.gasFees);
|
|
43
|
-
const protocolContracts = ProtocolContractsList;
|
|
44
|
-
const fastSimInputs = new AvmFastSimulationInputs(wsRevision, this.config, txHint, this.globalVariables, protocolContracts);
|
|
45
|
-
// Create contract provider for callbacks to TypeScript PublicContractsDB from C++
|
|
46
|
-
const contractProvider = new ContractProviderForCpp(this.contractsDB, this.globalVariables);
|
|
47
|
-
// Serialize to msgpack and call the C++ simulator
|
|
48
|
-
this.log.trace(`Serializing fast simulation inputs to msgpack...`);
|
|
49
|
-
const inputBuffer = fastSimInputs.serializeWithMessagePack();
|
|
50
|
-
// Create cancellation token for this simulation
|
|
51
|
-
this.cancellationToken = createCancellationToken();
|
|
52
|
-
// Store the promise so cancel() can wait for it
|
|
53
|
-
this.log.debug(`Calling C++ simulator for tx ${txHash}`);
|
|
54
|
-
this.simulationPromise = avmSimulate(inputBuffer, contractProvider, wsCppHandle, logLevel, // TODO: re-enable logging
|
|
55
|
-
undefined, this.cancellationToken);
|
|
56
|
-
let resultBuffer;
|
|
57
|
-
try {
|
|
58
|
-
resultBuffer = await this.simulationPromise;
|
|
59
|
-
} catch (error) {
|
|
60
|
-
// Check if this was a cancellation
|
|
61
|
-
if (error.message?.includes('Simulation cancelled')) {
|
|
62
|
-
throw new SimulationError(`C++ simulation cancelled`, []);
|
|
63
|
-
}
|
|
64
|
-
throw new SimulationError(`C++ simulation failed: ${error.message}`, []);
|
|
65
|
-
} finally{
|
|
66
|
-
this.cancellationToken = undefined;
|
|
67
|
-
this.simulationPromise = undefined;
|
|
68
|
-
}
|
|
69
|
-
// If we've reached this point, C++ succeeded during simulation,
|
|
70
|
-
// Deserialize the msgpack result
|
|
71
|
-
this.log.trace(`Deserializing C++ from buffer (size: ${resultBuffer.length})...`);
|
|
72
|
-
const cppResultJSON = deserializeFromMessagePack(resultBuffer);
|
|
73
|
-
this.log.trace(`Deserializing C++ result to PublicTxResult...`);
|
|
74
|
-
const cppResult = PublicTxResult.fromPlainObject(cppResultJSON);
|
|
75
|
-
this.log.trace(`C++ simulation completed for tx ${txHash}`, {
|
|
76
|
-
txHash,
|
|
77
|
-
reverted: !cppResult.revertCode.isOK(),
|
|
78
|
-
cppGasUsed: cppResult.gasUsed.totalGas.l2Gas
|
|
79
|
-
});
|
|
80
|
-
return cppResult;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Cancel the current simulation if one is in progress.
|
|
84
|
-
* This signals the C++ simulator to stop at the next opcode or before the next WorldState write.
|
|
85
|
-
* Safe to call even if no simulation is in progress.
|
|
86
|
-
*
|
|
87
|
-
* @param waitTimeoutMs - If provided, wait up to this many ms for the simulation to actually stop.
|
|
88
|
-
* This is important because C++ might be in the middle of a slow operation
|
|
89
|
-
* (e.g., pad_trees) and won't check the cancellation flag until it completes.
|
|
90
|
-
* Default timeout of 100ms after cancellation.
|
|
91
|
-
*/ async cancel(waitTimeoutMs = 100) {
|
|
92
|
-
if (this.cancellationToken) {
|
|
93
|
-
this.log.debug('Cancelling C++ simulation');
|
|
94
|
-
cancelSimulation(this.cancellationToken);
|
|
95
|
-
}
|
|
96
|
-
// Wait for the simulation to actually complete if not already done
|
|
97
|
-
if (this.simulationPromise) {
|
|
98
|
-
this.log.debug(`Waiting up to ${waitTimeoutMs}ms for C++ simulation to stop`);
|
|
99
|
-
await Promise.race([
|
|
100
|
-
this.simulationPromise.catch(()=>{}),
|
|
101
|
-
sleep(waitTimeoutMs)
|
|
102
|
-
]);
|
|
103
|
-
this.log.debug('C++ simulation stopped or wait timed out');
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
export class MeasuredCppPublicTxSimulator extends CppPublicTxSimulator {
|
|
108
|
-
metrics;
|
|
109
|
-
constructor(merkleTree, contractsDB, globalVariables, metrics, config){
|
|
110
|
-
super(merkleTree, contractsDB, globalVariables, config), this.metrics = metrics;
|
|
111
|
-
}
|
|
112
|
-
async simulate(tx, txLabel = 'unlabeledTx') {
|
|
113
|
-
this.metrics.startRecordingTxSimulation(txLabel);
|
|
114
|
-
let result;
|
|
115
|
-
try {
|
|
116
|
-
result = await super.simulate(tx);
|
|
117
|
-
} finally{
|
|
118
|
-
this.metrics.stopRecordingTxSimulation(txLabel, result?.gasUsed, result?.revertCode);
|
|
119
|
-
}
|
|
120
|
-
return result;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* A C++ public tx simulator that tracks runtime/production metrics with telemetry.
|
|
125
|
-
*/ export class TelemetryCppPublicTxSimulator extends MeasuredCppPublicTxSimulator {
|
|
126
|
-
/* tracer needed by trackSpans */ tracer;
|
|
127
|
-
constructor(merkleTree, contractsDB, globalVariables, telemetryClient = getTelemetryClient(), config){
|
|
128
|
-
const metrics = new ExecutorMetrics(telemetryClient, 'CppPublicTxSimulator');
|
|
129
|
-
super(merkleTree, contractsDB, globalVariables, metrics, config);
|
|
130
|
-
this.tracer = metrics.tracer;
|
|
131
|
-
}
|
|
132
|
-
}
|