@aztec/simulator 0.0.1-commit.d431d1c → 0.0.1-commit.d58ff9d0
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/client.d.ts +1 -3
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +0 -2
- 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 +39 -25
- package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/circuit_recorder.js +70 -72
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts +9 -20
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/file_circuit_recorder.js +39 -43
- 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_recording/simulator_recorder_wrapper.js +11 -14
- 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 +18 -3
- 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 +4 -34
- package/dest/public/avm_simulator.d.ts +28 -0
- package/dest/public/avm_simulator.d.ts.map +1 -0
- package/dest/public/avm_simulator.js +4 -0
- package/dest/public/avm_simulator_pool.d.ts +45 -0
- package/dest/public/avm_simulator_pool.d.ts.map +1 -0
- package/dest/public/avm_simulator_pool.js +197 -0
- package/dest/public/cdb/generated/api_types.d.ts +171 -0
- package/dest/public/cdb/generated/api_types.d.ts.map +1 -0
- package/dest/public/cdb/generated/api_types.js +314 -0
- package/dest/public/cdb/generated/server.d.ts +26 -0
- package/dest/public/cdb/generated/server.d.ts.map +1 -0
- package/dest/public/cdb/generated/server.js +135 -0
- package/dest/public/cdb_ipc_server.d.ts +33 -0
- package/dest/public/cdb_ipc_server.d.ts.map +1 -0
- package/dest/public/cdb_ipc_server.js +153 -0
- 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 +4 -4
- 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 +33 -6
- package/dest/public/fixtures/custom_bytecode_tester.d.ts +1 -1
- package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -1
- package/dest/public/fixtures/custom_bytecode_tester.js +2 -2
- package/dest/public/fixtures/index.d.ts +2 -4
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +1 -3
- package/dest/public/fixtures/public_processor_test_env.d.ts +30 -0
- package/dest/public/fixtures/public_processor_test_env.d.ts.map +1 -0
- package/dest/public/fixtures/public_processor_test_env.js +73 -0
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +12 -7
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +32 -15
- package/dest/public/fixtures/simple_contract_data_source.js +1 -1
- package/dest/public/fixtures/token_test.js +3 -3
- 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 +21 -20
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts +11 -4
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts.map +1 -1
- package/dest/public/fuzzing/avm_fuzzer_simulator.js +24 -10
- package/dest/public/fuzzing/avm_simulator_bin.js +11 -8
- package/dest/public/index.d.ts +5 -2
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +2 -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 +17 -8
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +119 -77
- 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/dumping_public_tx_simulator.d.ts +17 -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} +10 -23
- package/dest/public/public_tx_simulator/factories.d.ts +9 -8
- package/dest/public/public_tx_simulator/factories.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/factories.js +9 -9
- package/dest/public/public_tx_simulator/index.d.ts +4 -6
- 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 +43 -71
- 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 -316
- package/dest/public/public_tx_simulator/public_tx_simulator_base.d.ts +24 -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 +31 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts +5 -5
- 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 +22 -19
- package/src/client.ts +0 -2
- 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 +89 -81
- package/src/private/circuit_recording/file_circuit_recorder.ts +45 -50
- package/src/private/circuit_recording/memory_circuit_recorder.ts +6 -4
- package/src/private/circuit_recording/simulator_recorder_wrapper.ts +9 -15
- 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 +4 -40
- package/src/public/avm_simulator.ts +29 -0
- package/src/public/avm_simulator_pool.ts +226 -0
- package/src/public/cdb/generated/api_types.ts +457 -0
- package/src/public/cdb/generated/server.ts +109 -0
- package/src/public/cdb_ipc_server.ts +197 -0
- package/src/public/contracts_db_checkpoint.ts +1 -1
- package/src/public/executor_metrics.ts +4 -1
- package/src/public/fixtures/amm_test.ts +4 -4
- package/src/public/fixtures/bulk_test.ts +31 -6
- package/src/public/fixtures/custom_bytecode_tester.ts +2 -2
- package/src/public/fixtures/index.ts +1 -3
- package/src/public/fixtures/public_processor_test_env.ts +88 -0
- package/src/public/fixtures/public_tx_simulation_tester.ts +45 -18
- package/src/public/fixtures/simple_contract_data_source.ts +1 -1
- package/src/public/fixtures/token_test.ts +3 -3
- package/src/public/fixtures/utils.ts +23 -24
- package/src/public/fuzzing/avm_fuzzer_simulator.ts +26 -11
- package/src/public/fuzzing/avm_simulator_bin.ts +14 -6
- package/src/public/index.ts +7 -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 +166 -97
- package/src/public/public_processor/public_processor_metrics.ts +22 -4
- package/src/public/public_tx_simulator/{dumping_cpp_public_tx_simulator.ts → dumping_public_tx_simulator.ts} +17 -31
- package/src/public/public_tx_simulator/factories.ts +31 -11
- package/src/public/public_tx_simulator/index.ts +6 -5
- package/src/public/public_tx_simulator/public_tx_simulator.ts +142 -470
- package/src/public/public_tx_simulator/public_tx_simulator_base.ts +37 -0
- package/src/public/public_tx_simulator/public_tx_simulator_interface.ts +5 -5
- 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 -23
- 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 -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 -40
- package/dest/public/avm/avm_simulator.d.ts.map +0 -1
- package/dest/public/avm/avm_simulator.js +0 -191
- 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 -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 -83
- 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 -44
- 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 -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 -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 -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 -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 -35
- 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 -1681
- 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/contract_provider_for_cpp.d.ts +0 -18
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +0 -1
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +0 -98
- 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 -67
- package/src/public/avm/avm_execution_environment.ts +0 -46
- 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 -276
- package/src/public/avm/avm_simulator_interface.ts +0 -8
- package/src/public/avm/errors.ts +0 -177
- package/src/public/avm/fixtures/avm_simulation_tester.ts +0 -116
- package/src/public/avm/fixtures/initializers.ts +0 -102
- 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 -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 -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 -105
- package/src/public/avm/opcodes/environment_getters.ts +0 -87
- package/src/public/avm/opcodes/external_calls.ts +0 -261
- 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 -87
- 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 -50
- 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 -1725
- package/src/public/hinting_db_sources.ts +0 -607
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +0 -121
- 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
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ It's able to simulate three different types of functions:
|
|
|
12
12
|
|
|
13
13
|
Private functions are simulated and proved client-side, and verified client-side in the private kernel circuit.
|
|
14
14
|
|
|
15
|
-
The public inputs of private functions
|
|
15
|
+
The public inputs of private functions are defined [here](../stdlib/src/structs/private_circuit_public_inputs.ts).
|
|
16
16
|
|
|
17
17
|
They are run with the assistance of a DB oracle that provides any private data requested by the function.
|
|
18
18
|
|
|
@@ -22,17 +22,17 @@ Private functions can call another private function, and can request to call a p
|
|
|
22
22
|
|
|
23
23
|
Public functions are simulated and proved on the sequencer side, and verified by the public kernel circuit.
|
|
24
24
|
|
|
25
|
-
The public inputs of public functions
|
|
25
|
+
The public inputs of public functions are defined [here](../stdlib/src/structs/avm/avm_circuit_public_inputs.ts).
|
|
26
26
|
|
|
27
27
|
They are run with the assistance of an oracle that provides any value read from the public state tree.
|
|
28
28
|
|
|
29
|
-
Public functions can call other public
|
|
29
|
+
Public functions can call other public functions, but cannot call private functions.
|
|
30
30
|
|
|
31
31
|
See the specifications of the [Aztec Virtual Machine (AVM) for public execution](./docs/avm/index.md).
|
|
32
32
|
|
|
33
33
|
### Unconstrained Functions
|
|
34
34
|
|
|
35
|
-
Unconstrained functions are useful to extract
|
|
35
|
+
Unconstrained functions are useful to extract data for users that could produce very large execution traces - such as the summed balance of all of a user's notes.
|
|
36
36
|
They are not proved, and are simulated client-side.
|
|
37
37
|
|
|
38
38
|
They are run with the assistance of a DB oracle that provides any private data requested by the function.
|
package/dest/client.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export * from './private/acvm/index.js';
|
|
2
2
|
export { WASMSimulator } from './private/acvm_wasm.js';
|
|
3
|
-
export { SimulatorRecorderWrapper } from './private/circuit_recording/simulator_recorder_wrapper.js';
|
|
4
|
-
export { MemoryCircuitRecorder } from './private/circuit_recording/memory_circuit_recorder.js';
|
|
5
3
|
export { type CircuitSimulator, type DecodedError } from './private/circuit_simulator.js';
|
|
6
4
|
export * from './common/index.js';
|
|
7
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xpZW50LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY2xpZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMseUJBQXlCLENBQUM7QUFDeEMsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQ3ZELE9BQU8sRUFBRSxLQUFLLGdCQUFnQixFQUFFLEtBQUssWUFBWSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDMUYsY0FBYyxtQkFBbUIsQ0FBQyJ9
|
package/dest/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC1F,cAAc,mBAAmB,CAAC"}
|
package/dest/client.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
export * from './private/acvm/index.js';
|
|
2
2
|
export { WASMSimulator } from './private/acvm_wasm.js';
|
|
3
|
-
export { SimulatorRecorderWrapper } from './private/circuit_recording/simulator_recorder_wrapper.js';
|
|
4
|
-
export { MemoryCircuitRecorder } from './private/circuit_recording/memory_circuit_recorder.js';
|
|
5
3
|
export * from './common/index.js';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Logger, type LoggerBindings } from '@aztec/foundation/log';
|
|
1
2
|
import { type ExecutionError, type ForeignCallInput, type ForeignCallOutput } from '@aztec/noir-acvm_js';
|
|
2
3
|
import type { FunctionDebugMetadata } from '@aztec/stdlib/abi';
|
|
3
4
|
import type { NoirCallStack } from '@aztec/stdlib/errors';
|
|
@@ -27,10 +28,11 @@ export interface ACIRExecutionResult {
|
|
|
27
28
|
* @param acir - The ACIR circuit bytecode to execute.
|
|
28
29
|
* @param initialWitness - The initial witness map defining all of the inputs to `circuit`.
|
|
29
30
|
* @param callback - A callback to process any foreign calls from the circuit.
|
|
31
|
+
* @param logger - Optional logger for ACVM execution logs.
|
|
30
32
|
* @returns The solved witness calculated by executing the circuit on the provided inputs, as well as the return
|
|
31
33
|
* witness indices as specified by the circuit.
|
|
32
34
|
*/
|
|
33
|
-
export declare function acvm(acir: Buffer, initialWitness: ACVMWitness, callback: ACIRCallback): Promise<ACIRExecutionResult>;
|
|
35
|
+
export declare function acvm(acir: Buffer, initialWitness: ACVMWitness, callback: ACIRCallback, loggerOrBindings?: Logger | LoggerBindings): Promise<ACIRExecutionResult>;
|
|
34
36
|
/**
|
|
35
37
|
* Extracts the call stack from an thrown by the acvm.
|
|
36
38
|
* @param error - The error to extract from.
|
|
@@ -38,4 +40,4 @@ export declare function acvm(acir: Buffer, initialWitness: ACVMWitness, callback
|
|
|
38
40
|
* @returns The call stack, if available.
|
|
39
41
|
*/
|
|
40
42
|
export declare function extractCallStack(error: Error | ExecutionError, debug?: FunctionDebugMetadata): NoirCallStack | undefined;
|
|
41
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
43
|
+
//# sourceMappingURL=data:application/json;base64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UQ7Ozs7Ozs7O0dBUUc7QUFDSCx3QkFBc0IsSUFBSSxDQUN4QixJQUFJLEVBQUUsTUFBTSxFQUNaLGNBQWMsRUFBRSxXQUFXLEVBQzNCLFFBQVEsRUFBRSxZQUFZLEVBQ3RCLGdCQUFnQixDQUFDLEVBQUUsTUFBTSxHQUFHLGNBQWMsR0FDekMsT0FBTyxDQUFDLG1CQUFtQixDQUFDLENBdUM5QjtBQUVEOzs7OztHQUtHO0FBQ0gsd0JBQWdCLGdCQUFnQixDQUM5QixLQUFLLEVBQUUsS0FBSyxHQUFHLGNBQWMsRUFDN0IsS0FBSyxDQUFDLEVBQUUscUJBQXFCLEdBQzVCLGFBQWEsR0FBRyxTQUFTLENBYzNCIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acvm.d.ts","sourceRoot":"","sources":["../../../src/private/acvm/acvm.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"acvm.d.ts","sourceRoot":"","sources":["../../../src/private/acvm/acvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,cAAc,EAAiB,MAAM,uBAAuB,CAAC;AACxF,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAEvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,gBAAgB,EAAE,KAAK,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC;AAEzG,MAAM,MAAM,iBAAiB,GAAG;IAAE,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,cAAc,EAAE,WAAW,CAAC;IAC5B,aAAa,EAAE,WAAW,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CAC7C;AAED;;;;;;;;GAQG;AACH,wBAAsB,IAAI,CACxB,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,WAAW,EAC3B,QAAQ,EAAE,YAAY,EACtB,gBAAgB,CAAC,EAAE,MAAM,GAAG,cAAc,GACzC,OAAO,CAAC,mBAAmB,CAAC,CAuC9B;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,KAAK,GAAG,cAAc,EAC7B,KAAK,CAAC,EAAE,qBAAqB,GAC5B,aAAa,GAAG,SAAS,CAc3B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { executeCircuitWithReturnWitness } from '@aztec/noir-acvm_js';
|
|
3
3
|
import { resolveOpcodeLocations, traverseCauseChain } from '../../common/errors.js';
|
|
4
4
|
/**
|
|
@@ -6,10 +6,11 @@ import { resolveOpcodeLocations, traverseCauseChain } from '../../common/errors.
|
|
|
6
6
|
* @param acir - The ACIR circuit bytecode to execute.
|
|
7
7
|
* @param initialWitness - The initial witness map defining all of the inputs to `circuit`.
|
|
8
8
|
* @param callback - A callback to process any foreign calls from the circuit.
|
|
9
|
+
* @param logger - Optional logger for ACVM execution logs.
|
|
9
10
|
* @returns The solved witness calculated by executing the circuit on the provided inputs, as well as the return
|
|
10
11
|
* witness indices as specified by the circuit.
|
|
11
|
-
*/ export async function acvm(acir, initialWitness, callback) {
|
|
12
|
-
const logger =
|
|
12
|
+
*/ export async function acvm(acir, initialWitness, callback, loggerOrBindings) {
|
|
13
|
+
const logger = resolveLogger('simulator:acvm', loggerOrBindings);
|
|
13
14
|
const solvedAndReturnWitness = await executeCircuitWithReturnWitness(acir, initialWitness, (name, args)=>{
|
|
14
15
|
try {
|
|
15
16
|
logger.debug(`Oracle callback ${name}`);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Logger, type LoggerBindings } from '@aztec/foundation/log';
|
|
1
2
|
import type { ForeignCallHandler, WitnessMap } from '@aztec/noir-acvm_js';
|
|
2
3
|
import type { FunctionArtifactWithContractName } from '@aztec/stdlib/abi';
|
|
3
4
|
import type { NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
|
|
@@ -27,13 +28,14 @@ export type ACVMResult = ACVMSuccess | ACVMFailure;
|
|
|
27
28
|
* @param outputFilename - If specified, the output will be stored as a file, encoded using Bincode
|
|
28
29
|
* @returns The completed partial witness outputted from the circuit
|
|
29
30
|
*/
|
|
30
|
-
export declare function executeNativeCircuit(inputWitness: WitnessMap, bytecode: Buffer, workingDirectory: string, pathToAcvm: string, outputFilename?: string): Promise<ACVMResult>;
|
|
31
|
+
export declare function executeNativeCircuit(inputWitness: WitnessMap, bytecode: Buffer, workingDirectory: string, pathToAcvm: string, outputFilename?: string, loggerOrBindings?: Logger | LoggerBindings): Promise<ACVMResult>;
|
|
31
32
|
export declare class NativeACVMSimulator implements CircuitSimulator {
|
|
32
33
|
private workingDirectory;
|
|
33
34
|
private pathToAcvm;
|
|
34
35
|
private witnessFilename?;
|
|
35
|
-
|
|
36
|
+
private logger;
|
|
37
|
+
constructor(workingDirectory: string, pathToAcvm: string, witnessFilename?: string | undefined, loggerOrBindings?: Logger | LoggerBindings);
|
|
36
38
|
executeProtocolCircuit(input: ACVMWitness, artifact: NoirCompiledCircuitWithName, callback: ForeignCallHandler | undefined): Promise<ACVMSuccess>;
|
|
37
39
|
executeUserCircuit(_input: ACVMWitness, _artifact: FunctionArtifactWithContractName, _callback: ACIRCallback): Promise<ACIRExecutionResult>;
|
|
38
40
|
}
|
|
39
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
41
|
+
//# s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G1CQUFtQixDQUFDLENBRTlCO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acvm_native.d.ts","sourceRoot":"","sources":["../../src/private/acvm_native.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"acvm_native.d.ts","sourceRoot":"","sources":["../../src/private/acvm_native.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,cAAc,EAAiB,MAAM,uBAAuB,CAAC;AAExF,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAKtE,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,oBAAY,WAAW;IACrB,OAAO,IAAA;IACP,OAAO,IAAA;CACR;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,WAAW,CAAC;AAmBnD;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,UAAU,EACxB,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,EACxB,UAAU,EAAE,MAAM,EAClB,cAAc,CAAC,EAAE,MAAM,EACvB,gBAAgB,CAAC,EAAE,MAAM,GAAG,cAAc,GACzC,OAAO,CAAC,UAAU,CAAC,CA+ErB;AAED,qBAAa,mBAAoB,YAAW,gBAAgB;IAIxD,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,eAAe,CAAC;IAL1B,OAAO,CAAC,MAAM,CAAS;IAEvB,YACU,gBAAgB,EAAE,MAAM,EACxB,UAAU,EAAE,MAAM,EAClB,eAAe,CAAC,oBAAQ,EAChC,gBAAgB,CAAC,EAAE,MAAM,GAAG,cAAc,EAG3C;IAEK,sBAAsB,CAC1B,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,2BAA2B,EACrC,QAAQ,EAAE,kBAAkB,GAAG,SAAS,GACvC,OAAO,CAAC,WAAW,CAAC,CA4BtB;IAED,kBAAkB,CAChB,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,gCAAgC,EAC3C,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,mBAAmB,CAAC,CAE9B;CACF"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { runInDirectory } from '@aztec/foundation/fs';
|
|
2
|
-
import {
|
|
2
|
+
import { resolveLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
4
4
|
import * as proc from 'child_process';
|
|
5
5
|
import { promises as fs } from 'fs';
|
|
6
|
-
const logger = createLogger('simulator:acvm-native');
|
|
7
6
|
export var ACVM_RESULT = /*#__PURE__*/ function(ACVM_RESULT) {
|
|
8
7
|
ACVM_RESULT[ACVM_RESULT["SUCCESS"] = 0] = "SUCCESS";
|
|
9
8
|
ACVM_RESULT[ACVM_RESULT["FAILURE"] = 1] = "FAILURE";
|
|
@@ -31,7 +30,8 @@ export var ACVM_RESULT = /*#__PURE__*/ function(ACVM_RESULT) {
|
|
|
31
30
|
* @param pathToAcvm - The path to the ACVM binary
|
|
32
31
|
* @param outputFilename - If specified, the output will be stored as a file, encoded using Bincode
|
|
33
32
|
* @returns The completed partial witness outputted from the circuit
|
|
34
|
-
*/ export async function executeNativeCircuit(inputWitness, bytecode, workingDirectory, pathToAcvm, outputFilename) {
|
|
33
|
+
*/ export async function executeNativeCircuit(inputWitness, bytecode, workingDirectory, pathToAcvm, outputFilename, loggerOrBindings) {
|
|
34
|
+
const logger = resolveLogger('simulator:acvm-native', loggerOrBindings);
|
|
35
35
|
const bytecodeFilename = 'bytecode';
|
|
36
36
|
const witnessFilename = 'input_witness.toml';
|
|
37
37
|
// convert the witness map to TOML format
|
|
@@ -117,10 +117,12 @@ export class NativeACVMSimulator {
|
|
|
117
117
|
workingDirectory;
|
|
118
118
|
pathToAcvm;
|
|
119
119
|
witnessFilename;
|
|
120
|
-
|
|
120
|
+
logger;
|
|
121
|
+
constructor(workingDirectory, pathToAcvm, witnessFilename, loggerOrBindings){
|
|
121
122
|
this.workingDirectory = workingDirectory;
|
|
122
123
|
this.pathToAcvm = pathToAcvm;
|
|
123
124
|
this.witnessFilename = witnessFilename;
|
|
125
|
+
this.logger = resolveLogger('simulator:acvm-native', loggerOrBindings);
|
|
124
126
|
}
|
|
125
127
|
async executeProtocolCircuit(input, artifact, callback) {
|
|
126
128
|
// Execute the circuit on those initial witness values
|
|
@@ -131,13 +133,13 @@ export class NativeACVMSimulator {
|
|
|
131
133
|
// Decode the bytecode from base64 since the acvm does not know about base64 encoding
|
|
132
134
|
const decodedBytecode = Buffer.from(artifact.bytecode, 'base64');
|
|
133
135
|
// Execute the circuit
|
|
134
|
-
const result = await executeNativeCircuit(input, decodedBytecode, directory, this.pathToAcvm, this.witnessFilename);
|
|
136
|
+
const result = await executeNativeCircuit(input, decodedBytecode, directory, this.pathToAcvm, this.witnessFilename, this.logger);
|
|
135
137
|
if (result.status == 1) {
|
|
136
138
|
throw new Error(`Failed to generate witness: ${result.reason}`);
|
|
137
139
|
}
|
|
138
140
|
return result;
|
|
139
141
|
};
|
|
140
|
-
return await runInDirectory(this.workingDirectory, operation, false, logger);
|
|
142
|
+
return await runInDirectory(this.workingDirectory, operation, false, this.logger);
|
|
141
143
|
}
|
|
142
144
|
executeUserCircuit(_input, _artifact, _callback) {
|
|
143
145
|
throw new Error('Not implemented');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Logger, type LoggerBindings } from '@aztec/foundation/log';
|
|
1
2
|
import { type ForeignCallHandler } from '@aztec/noir-acvm_js';
|
|
2
3
|
import type { FunctionArtifactWithContractName } from '@aztec/stdlib/abi';
|
|
3
4
|
import type { NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
|
|
@@ -6,10 +7,10 @@ import type { ACVMWitness } from './acvm/acvm_types.js';
|
|
|
6
7
|
import type { ACVMSuccess } from './acvm_native.js';
|
|
7
8
|
import { type CircuitSimulator } from './circuit_simulator.js';
|
|
8
9
|
export declare class WASMSimulator implements CircuitSimulator {
|
|
9
|
-
protected log:
|
|
10
|
-
constructor(
|
|
10
|
+
protected log: Logger;
|
|
11
|
+
constructor(loggerOrBindings?: Logger | LoggerBindings);
|
|
11
12
|
init(): Promise<void>;
|
|
12
13
|
executeProtocolCircuit(input: ACVMWitness, artifact: NoirCompiledCircuitWithName, callback: ForeignCallHandler): Promise<ACVMSuccess>;
|
|
13
14
|
executeUserCircuit(input: ACVMWitness, artifact: FunctionArtifactWithContractName, callback: ACIRCallback): Promise<ACIRExecutionResult>;
|
|
14
15
|
}
|
|
15
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
16
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWN2bV93YXNtLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcHJpdmF0ZS9hY3ZtX3dhc20udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEtBQUssTUFBTSxFQUFFLEtBQUssY0FBYyxFQUF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
|
|
1
|
-
{"version":3,"file":"acvm_wasm.d.ts","sourceRoot":"","sources":["../../src/private/acvm_wasm.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"acvm_wasm.d.ts","sourceRoot":"","sources":["../../src/private/acvm_wasm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,cAAc,EAAiB,MAAM,uBAAuB,CAAC;AAExF,OAAiB,EAAuB,KAAK,kBAAkB,EAAkB,MAAM,qBAAqB,CAAC;AAE7G,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAQ,MAAM,gBAAgB,CAAC;AACnF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,KAAK,gBAAgB,EAAmB,MAAM,wBAAwB,CAAC;AAIhF,qBAAa,aAAc,YAAW,gBAAgB;IACpD,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC;IAEtB,YAAY,gBAAgB,CAAC,EAAE,MAAM,GAAG,cAAc,EAErD;IAEK,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAS1B;IAEK,sBAAsB,CAC1B,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,2BAA2B,EACrC,QAAQ,EAAE,kBAAkB,GAC3B,OAAO,CAAC,WAAW,CAAC,CAgCtB;IAEK,kBAAkB,CACtB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,gCAAgC,EAC1C,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,mBAAmB,CAAC,CAG9B;CACF"}
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { Timer } from '@aztec/foundation/timer';
|
|
3
3
|
import initACVM, { executeCircuit } from '@aztec/noir-acvm_js';
|
|
4
4
|
import initAbi from '@aztec/noir-noirc_abi';
|
|
5
5
|
import { acvm } from './acvm/acvm.js';
|
|
6
6
|
import { enrichNoirError } from './circuit_simulator.js';
|
|
7
|
+
let wasmInitPromise;
|
|
7
8
|
export class WASMSimulator {
|
|
8
9
|
log;
|
|
9
|
-
constructor(
|
|
10
|
-
this.log =
|
|
10
|
+
constructor(loggerOrBindings){
|
|
11
|
+
this.log = resolveLogger('wasm-simulator', loggerOrBindings);
|
|
11
12
|
}
|
|
12
13
|
async init() {
|
|
13
14
|
// If these are available, then we are in the
|
|
14
15
|
// web environment. For the node environment, this
|
|
15
16
|
// is a no-op.
|
|
16
17
|
if (typeof initAbi === 'function') {
|
|
17
|
-
/** @ts-expect-error The node bundle doesn't include these default imports, so TS complains */
|
|
18
|
+
/** @ts-expect-error The node bundle doesn't include these default imports, so TS complains */ wasmInitPromise ??= Promise.all([
|
|
18
19
|
initAbi(),
|
|
19
20
|
initACVM()
|
|
20
21
|
]);
|
|
22
|
+
await wasmInitPromise;
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
async executeProtocolCircuit(input, artifact, callback) {
|
|
@@ -60,6 +62,6 @@ export class WASMSimulator {
|
|
|
60
62
|
}
|
|
61
63
|
async executeUserCircuit(input, artifact, callback) {
|
|
62
64
|
await this.init();
|
|
63
|
-
return acvm(artifact.bytecode, input, callback);
|
|
65
|
+
return acvm(artifact.bytecode, input, callback, this.log.createChild('acvm'));
|
|
64
66
|
}
|
|
65
67
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Logger, type LoggerBindings } from '@aztec/foundation/log';
|
|
1
2
|
import type { ForeignCallHandler } from '@aztec/noir-acvm_js';
|
|
2
3
|
import type { ACIRCallback } from '../acvm/acvm.js';
|
|
3
4
|
import type { ACVMWitness } from '../acvm/acvm_types.js';
|
|
@@ -20,10 +21,22 @@ export declare class CircuitRecording {
|
|
|
20
21
|
constructor(circuitName: string, functionName: string, bytecodeSHA512Hash: string, inputs: Record<string, string>);
|
|
21
22
|
setParent(recording?: CircuitRecording): void;
|
|
22
23
|
}
|
|
24
|
+
/** Inputs needed to open a recording for a single circuit execution. */
|
|
25
|
+
export type RecordingMetadata = {
|
|
26
|
+
input: ACVMWitness;
|
|
27
|
+
bytecode: Buffer;
|
|
28
|
+
circuitName: string;
|
|
29
|
+
functionName: string;
|
|
30
|
+
};
|
|
23
31
|
/**
|
|
24
32
|
* Class responsible for recording circuit inputs necessary to replay the circuit. These inputs are the initial witness
|
|
25
33
|
* map and the oracle calls made during the circuit execution/witness generation.
|
|
26
34
|
*
|
|
35
|
+
* The active recording for an execution lives in `AsyncLocalStorage`, so each (possibly nested) circuit execution owns
|
|
36
|
+
* its own recording and concurrent or re-entrant executions cannot corrupt one another's state. Nested executions
|
|
37
|
+
* (`aztec_prv_callPrivateFunction`, utility calls) re-enter {@link record}, which links the child to the recording
|
|
38
|
+
* active in the enclosing async context and lets ALS restore the parent automatically when the child completes.
|
|
39
|
+
*
|
|
27
40
|
* Example recording object:
|
|
28
41
|
* ```json
|
|
29
42
|
* {
|
|
@@ -67,21 +80,22 @@ export declare class CircuitRecording {
|
|
|
67
80
|
*/
|
|
68
81
|
export declare class CircuitRecorder {
|
|
69
82
|
#private;
|
|
70
|
-
protected readonly logger:
|
|
71
|
-
protected
|
|
72
|
-
private stackDepth;
|
|
73
|
-
private newCircuit;
|
|
74
|
-
protected constructor();
|
|
83
|
+
protected readonly logger: Logger;
|
|
84
|
+
protected constructor(loggerOrBindings?: Logger | LoggerBindings);
|
|
75
85
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
86
|
+
* Records a single circuit execution. Opens a recording for the circuit (linked as a child of the recording active
|
|
87
|
+
* in the current async context, if any), runs `fn` within that recording's context, and finalizes it. The recording
|
|
88
|
+
* is returned alongside the result so callers can derive per-circuit stats (e.g. oracle timings).
|
|
89
|
+
*
|
|
90
|
+
* Recorder bookkeeping never alters execution: if `fn` throws, the error is attached to the recording and re-thrown
|
|
91
|
+
* unchanged.
|
|
92
|
+
* @param metadata - Identifies the circuit and its initial witness.
|
|
93
|
+
* @param fn - Runs the circuit execution; its oracle calls are recorded into this recording.
|
|
83
94
|
*/
|
|
84
|
-
|
|
95
|
+
record<T>(metadata: RecordingMetadata, fn: () => Promise<T>): Promise<{
|
|
96
|
+
result: T;
|
|
97
|
+
recording: CircuitRecording;
|
|
98
|
+
}>;
|
|
85
99
|
/**
|
|
86
100
|
* Wraps a callback to record all oracle/foreign calls.
|
|
87
101
|
* @param callback - The original callback to wrap, either a user circuit callback or protocol circuit callback.
|
|
@@ -89,20 +103,20 @@ export declare class CircuitRecorder {
|
|
|
89
103
|
*/
|
|
90
104
|
wrapCallback(callback: ACIRCallback | ForeignCallHandler | undefined): ACIRCallback | ForeignCallHandler | undefined;
|
|
91
105
|
/**
|
|
92
|
-
* Records a single oracle/foreign call with its inputs and outputs
|
|
106
|
+
* Records a single oracle/foreign call with its inputs and outputs against the recording active in the current
|
|
107
|
+
* async context.
|
|
93
108
|
* @param name - Name of the call
|
|
94
109
|
* @param inputs - Input arguments
|
|
95
110
|
* @param outputs - Output results
|
|
96
111
|
*/
|
|
97
|
-
recordCall(name: string, inputs: unknown[], outputs: unknown, time: number
|
|
98
|
-
/**
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
finishWithError(error: unknown): Promise<CircuitRecording>;
|
|
112
|
+
recordCall(name: string, inputs: unknown[], outputs: unknown, time: number): Promise<OracleCall>;
|
|
113
|
+
/** The recording active in the current async context, if any. */
|
|
114
|
+
protected currentRecording(): CircuitRecording | undefined;
|
|
115
|
+
/** Hook invoked when a recording opens, within the recording's context. Overridden to persist recordings. */
|
|
116
|
+
protected onStart(_recording: CircuitRecording): Promise<void>;
|
|
117
|
+
/** Hook invoked when a recording completes successfully, within the recording's context. */
|
|
118
|
+
protected onFinish(_recording: CircuitRecording): Promise<void>;
|
|
119
|
+
/** Hook invoked when a recording's execution throws, within the recording's context. */
|
|
120
|
+
protected onError(_recording: CircuitRecording, _error: unknown): Promise<void>;
|
|
107
121
|
}
|
|
108
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
122
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2lyY3VpdF9yZWNvcmRlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3ByaXZhdGUvY2lyY3VpdF9yZWNvcmRpbmcvY2lyY3VpdF9yZWNvcmRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQUUsS0FBSyxjQUFjLEVBQWlCLE1BQU0sdUJBQXVCLENBQUM7QUFFeEYsT0FBTyxLQUFLLEVBQUUsa0JBQWtCLEVBQXVDLE1BQU0scUJBQXFCLENBQUM7QUFJbkcsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFFekQsTUFBTSxNQUFNLFVBQVUsR0FBRztJQUN2QixJQUFJLEVBQUUsTUFBTSxDQUFDO0lBQ2IsTUFBTSxFQUFFLE9BQU8sRUFBRSxDQUFDO0lBQ2xCLE9BQU8sRUFBRSxPQUFPLENBQUM7SUFDakIsSUFBSSxFQUFFLE1BQU0sQ0FBQztJQU1iLFVBQVUsRUFBRSxNQUFNLENBQUM7Q0FDcEIsQ0FBQztBQUVGLHFCQUFhLGdCQUFnQjtJQUMzQixXQUFXLEVBQ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|
-
{"version":3,"file":"circuit_recorder.d.ts","sourceRoot":"","sources":["../../../src/private/circuit_recording/circuit_recorder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"circuit_recorder.d.ts","sourceRoot":"","sources":["../../../src/private/circuit_recording/circuit_recorder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,cAAc,EAAiB,MAAM,uBAAuB,CAAC;AAExF,OAAO,KAAK,EAAE,kBAAkB,EAAuC,MAAM,qBAAqB,CAAC;AAInG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IAMb,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,qBAAa,gBAAgB;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAE1B,YAAY,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAOhH;IAED,SAAS,CAAC,SAAS,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAE5C;CACF;AAED,wEAAwE;AACxE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAA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CAAC,CAE9E;CACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { sha512 } from '@aztec/foundation/crypto/sha512';
|
|
2
|
-
import {
|
|
2
|
+
import { resolveLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
4
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
4
5
|
export class CircuitRecording {
|
|
5
6
|
circuitName;
|
|
6
7
|
functionName;
|
|
@@ -26,6 +27,11 @@ export class CircuitRecording {
|
|
|
26
27
|
* Class responsible for recording circuit inputs necessary to replay the circuit. These inputs are the initial witness
|
|
27
28
|
* map and the oracle calls made during the circuit execution/witness generation.
|
|
28
29
|
*
|
|
30
|
+
* The active recording for an execution lives in `AsyncLocalStorage`, so each (possibly nested) circuit execution owns
|
|
31
|
+
* its own recording and concurrent or re-entrant executions cannot corrupt one another's state. Nested executions
|
|
32
|
+
* (`aztec_prv_callPrivateFunction`, utility calls) re-enter {@link record}, which links the child to the recording
|
|
33
|
+
* active in the enclosing async context and lets ALS restore the parent automatically when the child completes.
|
|
34
|
+
*
|
|
29
35
|
* Example recording object:
|
|
30
36
|
* ```json
|
|
31
37
|
* {
|
|
@@ -67,26 +73,39 @@ export class CircuitRecording {
|
|
|
67
73
|
* }
|
|
68
74
|
* ```
|
|
69
75
|
*/ export class CircuitRecorder {
|
|
70
|
-
logger
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
logger;
|
|
77
|
+
#recordings = new AsyncLocalStorage();
|
|
78
|
+
constructor(loggerOrBindings){
|
|
79
|
+
this.logger = resolveLogger('simulator:acvm:recording', loggerOrBindings);
|
|
80
|
+
}
|
|
75
81
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
* Records a single circuit execution. Opens a recording for the circuit (linked as a child of the recording active
|
|
83
|
+
* in the current async context, if any), runs `fn` within that recording's context, and finalizes it. The recording
|
|
84
|
+
* is returned alongside the result so callers can derive per-circuit stats (e.g. oracle timings).
|
|
85
|
+
*
|
|
86
|
+
* Recorder bookkeeping never alters execution: if `fn` throws, the error is attached to the recording and re-thrown
|
|
87
|
+
* unchanged.
|
|
88
|
+
* @param metadata - Identifies the circuit and its initial witness.
|
|
89
|
+
* @param fn - Runs the circuit execution; its oracle calls are recorded into this recording.
|
|
90
|
+
*/ record(metadata, fn) {
|
|
91
|
+
const parent = this.#recordings.getStore();
|
|
92
|
+
const recording = new CircuitRecording(metadata.circuitName, metadata.functionName, sha512(metadata.bytecode).toString('hex'), Object.fromEntries(metadata.input));
|
|
93
|
+
recording.setParent(parent);
|
|
94
|
+
return this.#recordings.run(recording, async ()=>{
|
|
95
|
+
await this.onStart(recording);
|
|
96
|
+
try {
|
|
97
|
+
const result = await fn();
|
|
98
|
+
await this.onFinish(recording);
|
|
99
|
+
return {
|
|
100
|
+
result,
|
|
101
|
+
recording
|
|
102
|
+
};
|
|
103
|
+
} catch (error) {
|
|
104
|
+
recording.error = JSON.stringify(error);
|
|
105
|
+
await this.onError(recording, error);
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
90
109
|
}
|
|
91
110
|
/**
|
|
92
111
|
* Wraps a callback to record all oracle/foreign calls.
|
|
@@ -107,7 +126,9 @@ export class CircuitRecording {
|
|
|
107
126
|
return typeof callback === 'object' && callback !== null && !('call' in callback);
|
|
108
127
|
}
|
|
109
128
|
/**
|
|
110
|
-
* Wraps a user circuit callback to record all oracle calls.
|
|
129
|
+
* Wraps a user circuit callback to record all oracle calls. A nested circuit entered via an oracle (e.g.
|
|
130
|
+
* `aztec_prv_callPrivateFunction`) re-enters {@link record}, so its own oracle calls land on the child recording and
|
|
131
|
+
* this circuit's calls (including the entering oracle call itself) land on this recording once the child completes.
|
|
111
132
|
* @param callback - The original circuit callback.
|
|
112
133
|
* @returns A wrapped callback that records all oracle interactions which is to be provided to the ACVM.
|
|
113
134
|
*/ #wrapUserCircuitCallback(callback) {
|
|
@@ -118,37 +139,16 @@ export class CircuitRecording {
|
|
|
118
139
|
if (!fn || typeof fn !== 'function') {
|
|
119
140
|
throw new Error(`Oracle method ${name} not found when setting up recording callback`);
|
|
120
141
|
}
|
|
121
|
-
const isExternalCall = name === 'privateCallPrivateFunction';
|
|
122
142
|
recordingCallback[name] = (...args)=>{
|
|
123
143
|
const timer = new Timer();
|
|
124
|
-
// If we're entering another circuit via `privateCallPrivateFunction`, we increase the stack depth and set the
|
|
125
|
-
// newCircuit variable to ensure we are creating a new recording object.
|
|
126
|
-
if (isExternalCall) {
|
|
127
|
-
this.stackDepth++;
|
|
128
|
-
this.newCircuit = true;
|
|
129
|
-
}
|
|
130
144
|
const result = fn.call(callback, ...args);
|
|
131
145
|
if (result instanceof Promise) {
|
|
132
146
|
return result.then(async (r)=>{
|
|
133
|
-
|
|
134
|
-
// so that the parent circuit continues with its existing recording
|
|
135
|
-
// Note: recording restoration is handled by finish()
|
|
136
|
-
if (isExternalCall) {
|
|
137
|
-
this.stackDepth--;
|
|
138
|
-
this.newCircuit = false;
|
|
139
|
-
}
|
|
140
|
-
await this.recordCall(name, args, r, timer.ms(), this.stackDepth);
|
|
147
|
+
await this.recordCall(name, args, r, timer.ms());
|
|
141
148
|
return r;
|
|
142
149
|
});
|
|
143
150
|
}
|
|
144
|
-
|
|
145
|
-
// so that the parent circuit continues with its existing recording
|
|
146
|
-
// Note: recording restoration is handled by finish()
|
|
147
|
-
if (isExternalCall) {
|
|
148
|
-
this.stackDepth--;
|
|
149
|
-
this.newCircuit = false;
|
|
150
|
-
}
|
|
151
|
-
void this.recordCall(name, args, result, timer.ms(), this.stackDepth);
|
|
151
|
+
void this.recordCall(name, args, result, timer.ms());
|
|
152
152
|
return result;
|
|
153
153
|
};
|
|
154
154
|
}
|
|
@@ -162,49 +162,47 @@ export class CircuitRecording {
|
|
|
162
162
|
return async (name, inputs)=>{
|
|
163
163
|
const timer = new Timer();
|
|
164
164
|
const result = await callback(name, inputs);
|
|
165
|
-
await this.recordCall(name, inputs, result, timer.ms()
|
|
165
|
+
await this.recordCall(name, inputs, result, timer.ms());
|
|
166
166
|
return result;
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
169
|
/**
|
|
170
|
-
* Records a single oracle/foreign call with its inputs and outputs
|
|
170
|
+
* Records a single oracle/foreign call with its inputs and outputs against the recording active in the current
|
|
171
|
+
* async context.
|
|
171
172
|
* @param name - Name of the call
|
|
172
173
|
* @param inputs - Input arguments
|
|
173
174
|
* @param outputs - Output results
|
|
174
|
-
*/ recordCall(name, inputs, outputs, time
|
|
175
|
+
*/ recordCall(name, inputs, outputs, time) {
|
|
176
|
+
const recording = this.#recordings.getStore();
|
|
175
177
|
const entry = {
|
|
176
178
|
name,
|
|
177
179
|
inputs,
|
|
178
180
|
outputs,
|
|
179
181
|
time,
|
|
180
|
-
stackDepth
|
|
182
|
+
stackDepth: depthOf(recording)
|
|
181
183
|
};
|
|
182
|
-
|
|
184
|
+
// Outside any active recording context (e.g. a stray call after the scope closed, or a direct unit-test call)
|
|
185
|
+
// there is nowhere to record; return the entry without throwing into the execution path.
|
|
186
|
+
recording?.oracleCalls.push(entry);
|
|
183
187
|
return Promise.resolve(entry);
|
|
184
188
|
}
|
|
185
|
-
/**
|
|
186
|
-
|
|
187
|
-
*/ finish() {
|
|
188
|
-
const result = this.recording;
|
|
189
|
-
// If this is the top-level circuit recording, we reset the state for the next simulator call
|
|
190
|
-
if (!result.parent) {
|
|
191
|
-
this.newCircuit = true;
|
|
192
|
-
this.recording = undefined;
|
|
193
|
-
} else {
|
|
194
|
-
// For nested circuits (utility calls, nested contract calls), restore to parent recording
|
|
195
|
-
// Note: we don't set newCircuit=false here because:
|
|
196
|
-
// - For privateCallPrivateFunction, the callback wrapper will set it to false
|
|
197
|
-
// - For utility calls, we want newCircuit to remain true so the next circuit creates its own recording
|
|
198
|
-
this.recording = result.parent;
|
|
199
|
-
}
|
|
200
|
-
return Promise.resolve(result);
|
|
189
|
+
/** The recording active in the current async context, if any. */ currentRecording() {
|
|
190
|
+
return this.#recordings.getStore();
|
|
201
191
|
}
|
|
202
|
-
/**
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
192
|
+
/** Hook invoked when a recording opens, within the recording's context. Overridden to persist recordings. */ onStart(_recording) {
|
|
193
|
+
return Promise.resolve();
|
|
194
|
+
}
|
|
195
|
+
/** Hook invoked when a recording completes successfully, within the recording's context. */ onFinish(_recording) {
|
|
196
|
+
return Promise.resolve();
|
|
197
|
+
}
|
|
198
|
+
/** Hook invoked when a recording's execution throws, within the recording's context. */ onError(_recording, _error) {
|
|
199
|
+
return Promise.resolve();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/** Depth of a recording in the call tree: 0 for a top-level circuit, incremented per nested circuit. */ function depthOf(recording) {
|
|
203
|
+
let depth = 0;
|
|
204
|
+
for(let ancestor = recording?.parent; ancestor; ancestor = ancestor.parent){
|
|
205
|
+
depth++;
|
|
209
206
|
}
|
|
207
|
+
return depth;
|
|
210
208
|
}
|