@aztec/simulator 0.0.0-test.1 → 0.0.1-commit.5daedc8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dest/client.d.ts +6 -4
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +4 -2
- package/dest/common/errors.d.ts +5 -14
- package/dest/common/errors.d.ts.map +1 -1
- package/dest/common/errors.js +51 -32
- package/dest/common/index.d.ts +1 -2
- package/dest/common/index.d.ts.map +1 -1
- package/dest/common/index.js +0 -1
- package/dest/common/stats/index.d.ts +1 -1
- package/dest/common/stats/stats.d.ts +1 -1
- package/dest/private/acvm/acvm.d.ts +12 -6
- package/dest/private/acvm/acvm.d.ts.map +1 -1
- package/dest/private/acvm/acvm.js +10 -16
- package/dest/private/acvm/acvm_types.d.ts +2 -2
- package/dest/private/acvm/acvm_types.d.ts.map +1 -1
- package/dest/private/acvm/deserialize.d.ts +18 -19
- package/dest/private/acvm/deserialize.d.ts.map +1 -1
- package/dest/private/acvm/deserialize.js +31 -23
- package/dest/private/acvm/index.d.ts +1 -2
- package/dest/private/acvm/index.d.ts.map +1 -1
- package/dest/private/acvm/index.js +0 -1
- package/dest/private/acvm/serialize.d.ts +20 -3
- package/dest/private/acvm/serialize.d.ts.map +1 -1
- package/dest/private/acvm/serialize.js +53 -0
- package/dest/private/acvm_native.d.ts +39 -0
- package/dest/private/acvm_native.d.ts.map +1 -0
- package/dest/private/{providers/acvm_native.js → acvm_native.js} +26 -20
- package/dest/private/acvm_wasm.d.ts +15 -0
- package/dest/private/acvm_wasm.d.ts.map +1 -0
- package/dest/private/{providers/acvm_wasm.js → acvm_wasm.js} +22 -19
- package/dest/private/acvm_wasm_with_blobs.d.ts +20 -0
- package/dest/private/acvm_wasm_with_blobs.d.ts.map +1 -0
- package/dest/private/acvm_wasm_with_blobs.js +35 -0
- package/dest/private/circuit_recording/circuit_recorder.d.ts +108 -0
- package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -0
- package/dest/private/circuit_recording/circuit_recorder.js +209 -0
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts +31 -0
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -0
- package/dest/private/circuit_recording/file_circuit_recorder.js +135 -0
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +5 -0
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -0
- package/dest/private/circuit_recording/memory_circuit_recorder.js +9 -0
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts +21 -0
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts.map +1 -0
- package/dest/private/circuit_recording/simulator_recorder_wrapper.js +44 -0
- package/dest/private/circuit_simulator.d.ts +35 -0
- package/dest/private/circuit_simulator.d.ts.map +1 -0
- package/dest/private/circuit_simulator.js +43 -0
- package/dest/private/factory.d.ts +12 -0
- package/dest/private/factory.d.ts.map +1 -0
- package/dest/private/{providers/factory.js → factory.js} +2 -2
- package/dest/public/avm/avm_context.d.ts +6 -6
- package/dest/public/avm/avm_context.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.d.ts +5 -3
- package/dest/public/avm/avm_contract_call_result.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.js +11 -7
- package/dest/public/avm/avm_execution_environment.d.ts +4 -2
- package/dest/public/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/public/avm/avm_execution_environment.js +4 -2
- package/dest/public/avm/avm_gas.d.ts +5 -21
- package/dest/public/avm/avm_gas.d.ts.map +1 -1
- package/dest/public/avm/avm_gas.js +27 -35
- package/dest/public/avm/avm_machine_state.d.ts +3 -1
- package/dest/public/avm/avm_machine_state.d.ts.map +1 -1
- package/dest/public/avm/avm_machine_state.js +2 -0
- package/dest/public/avm/avm_memory_types.d.ts +99 -88
- package/dest/public/avm/avm_memory_types.d.ts.map +1 -1
- package/dest/public/avm/avm_memory_types.js +17 -6
- package/dest/public/avm/avm_simulator.d.ts +6 -6
- package/dest/public/avm/avm_simulator.d.ts.map +1 -1
- package/dest/public/avm/avm_simulator.js +23 -35
- package/dest/public/avm/avm_simulator_interface.d.ts +9 -0
- package/dest/public/avm/avm_simulator_interface.d.ts.map +1 -0
- package/dest/public/avm/avm_simulator_interface.js +3 -0
- package/dest/public/avm/errors.d.ts +7 -31
- package/dest/public/avm/errors.d.ts.map +1 -1
- package/dest/public/avm/errors.js +7 -57
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts +6 -5
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.js +22 -15
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +7 -5
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/base_avm_simulation_tester.js +37 -14
- package/dest/public/avm/fixtures/initializers.d.ts +42 -0
- package/dest/public/avm/fixtures/initializers.d.ts.map +1 -0
- package/dest/public/avm/fixtures/initializers.js +44 -0
- package/dest/public/avm/fixtures/utils.d.ts +38 -0
- package/dest/public/avm/fixtures/utils.d.ts.map +1 -0
- package/dest/public/avm/fixtures/utils.js +95 -0
- package/dest/public/avm/index.d.ts +1 -3
- package/dest/public/avm/index.d.ts.map +1 -1
- package/dest/public/avm/index.js +0 -2
- package/dest/public/avm/opcodes/accrued_substate.d.ts +3 -3
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/public/avm/opcodes/accrued_substate.js +28 -25
- package/dest/public/avm/opcodes/addressing_mode.d.ts +12 -8
- package/dest/public/avm/opcodes/addressing_mode.d.ts.map +1 -1
- package/dest/public/avm/opcodes/addressing_mode.js +46 -26
- package/dest/public/avm/opcodes/arithmetic.d.ts +17 -7
- package/dest/public/avm/opcodes/arithmetic.d.ts.map +1 -1
- package/dest/public/avm/opcodes/arithmetic.js +16 -2
- package/dest/public/avm/opcodes/bitwise.d.ts +10 -18
- package/dest/public/avm/opcodes/bitwise.d.ts.map +1 -1
- package/dest/public/avm/opcodes/bitwise.js +19 -26
- package/dest/public/avm/opcodes/comparators.d.ts +4 -4
- package/dest/public/avm/opcodes/comparators.d.ts.map +1 -1
- package/dest/public/avm/opcodes/comparators.js +3 -3
- package/dest/public/avm/opcodes/contract.d.ts +2 -3
- package/dest/public/avm/opcodes/contract.d.ts.map +1 -1
- package/dest/public/avm/opcodes/contract.js +9 -10
- package/dest/public/avm/opcodes/control_flow.d.ts +1 -1
- package/dest/public/avm/opcodes/control_flow.d.ts.map +1 -1
- package/dest/public/avm/opcodes/control_flow.js +10 -8
- package/dest/public/avm/opcodes/conversion.d.ts +2 -1
- package/dest/public/avm/opcodes/conversion.d.ts.map +1 -1
- package/dest/public/avm/opcodes/conversion.js +267 -3
- package/dest/public/avm/opcodes/ec_add.d.ts +2 -2
- package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -1
- package/dest/public/avm/opcodes/ec_add.js +6 -6
- package/dest/public/avm/opcodes/environment_getters.d.ts +3 -3
- package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/public/avm/opcodes/environment_getters.js +17 -19
- package/dest/public/avm/opcodes/external_calls.d.ts +9 -8
- package/dest/public/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/public/avm/opcodes/external_calls.js +39 -34
- package/dest/public/avm/opcodes/hashing.d.ts +2 -2
- package/dest/public/avm/opcodes/hashing.d.ts.map +1 -1
- package/dest/public/avm/opcodes/hashing.js +6 -6
- package/dest/public/avm/opcodes/index.d.ts +1 -1
- package/dest/public/avm/opcodes/instruction.d.ts +15 -11
- package/dest/public/avm/opcodes/instruction.d.ts.map +1 -1
- package/dest/public/avm/opcodes/instruction.js +23 -19
- package/dest/public/avm/opcodes/instruction_impl.d.ts +1 -1
- package/dest/public/avm/opcodes/instruction_impl.d.ts.map +1 -1
- package/dest/public/avm/opcodes/memory.d.ts +6 -6
- package/dest/public/avm/opcodes/memory.d.ts.map +1 -1
- package/dest/public/avm/opcodes/memory.js +37 -33
- package/dest/public/avm/opcodes/misc.d.ts +3 -2
- package/dest/public/avm/opcodes/misc.d.ts.map +1 -1
- package/dest/public/avm/opcodes/misc.js +41 -16
- package/dest/public/avm/opcodes/storage.d.ts +3 -3
- package/dest/public/avm/opcodes/storage.d.ts.map +1 -1
- package/dest/public/avm/opcodes/storage.js +7 -5
- package/dest/public/avm/revert_reason.d.ts +18 -0
- package/dest/public/avm/revert_reason.d.ts.map +1 -0
- package/dest/public/avm/revert_reason.js +38 -0
- package/dest/public/avm/serialization/buffer_cursor.d.ts +1 -3
- package/dest/public/avm/serialization/buffer_cursor.d.ts.map +1 -1
- package/dest/public/avm/serialization/bytecode_serialization.d.ts +3 -7
- package/dest/public/avm/serialization/bytecode_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/bytecode_serialization.js +70 -69
- package/dest/public/avm/serialization/instruction_serialization.d.ts +14 -5
- package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/instruction_serialization.js +70 -35
- package/dest/public/avm/test_utils.d.ts +11 -14
- package/dest/public/avm/test_utils.d.ts.map +1 -1
- package/dest/public/avm/test_utils.js +16 -24
- package/dest/public/contracts_db_checkpoint.d.ts +16 -0
- package/dest/public/contracts_db_checkpoint.d.ts.map +1 -0
- package/dest/public/contracts_db_checkpoint.js +30 -0
- package/dest/public/db_interfaces.d.ts +68 -0
- package/dest/public/db_interfaces.d.ts.map +1 -0
- package/dest/public/db_interfaces.js +3 -0
- package/dest/public/debug_fn_name.d.ts +5 -0
- package/dest/public/debug_fn_name.d.ts.map +1 -0
- package/dest/public/debug_fn_name.js +9 -0
- package/dest/public/executor_metrics.d.ts +12 -4
- package/dest/public/executor_metrics.d.ts.map +1 -1
- package/dest/public/executor_metrics.js +37 -6
- package/dest/public/executor_metrics_interface.d.ts +10 -0
- package/dest/public/executor_metrics_interface.d.ts.map +1 -0
- package/dest/public/executor_metrics_interface.js +1 -0
- package/dest/public/fixtures/amm_test.d.ts +10 -0
- package/dest/public/fixtures/amm_test.d.ts.map +1 -0
- package/dest/public/fixtures/amm_test.js +213 -0
- package/dest/public/fixtures/bulk_test.d.ts +6 -0
- package/dest/public/fixtures/bulk_test.d.ts.map +1 -0
- package/dest/public/fixtures/bulk_test.js +326 -0
- package/dest/public/fixtures/custom_bytecode_tester.d.ts +12 -0
- package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -0
- package/dest/public/fixtures/custom_bytecode_tester.js +29 -0
- package/dest/public/fixtures/custom_bytecode_tests.d.ts +9 -0
- package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -0
- package/dest/public/fixtures/custom_bytecode_tests.js +109 -0
- package/dest/public/fixtures/index.d.ts +8 -1
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +7 -0
- package/dest/public/fixtures/minimal_public_tx.d.ts +9 -0
- package/dest/public/fixtures/minimal_public_tx.d.ts.map +1 -0
- package/dest/public/fixtures/minimal_public_tx.js +29 -0
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +35 -14
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +100 -71
- package/dest/public/fixtures/simple_contract_data_source.d.ts +35 -0
- package/dest/public/fixtures/simple_contract_data_source.d.ts.map +1 -0
- package/dest/public/{avm/fixtures → fixtures}/simple_contract_data_source.js +31 -10
- package/dest/public/fixtures/token_test.d.ts +8 -0
- package/dest/public/fixtures/token_test.d.ts.map +1 -0
- package/dest/public/fixtures/token_test.js +94 -0
- package/dest/public/fixtures/utils.d.ts +17 -4
- package/dest/public/fixtures/utils.d.ts.map +1 -1
- package/dest/public/fixtures/utils.js +100 -58
- package/dest/public/hinting_db_sources.d.ts +78 -0
- package/dest/public/hinting_db_sources.d.ts.map +1 -0
- package/dest/public/hinting_db_sources.js +350 -0
- package/dest/public/index.d.ts +6 -9
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +4 -7
- package/dest/public/public_db_sources.d.ts +51 -101
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +219 -192
- package/dest/public/public_errors.d.ts +12 -0
- package/dest/public/public_errors.d.ts.map +1 -0
- package/dest/public/public_errors.js +13 -0
- package/dest/public/public_processor/guarded_merkle_tree.d.ts +49 -0
- package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -0
- package/dest/public/public_processor/guarded_merkle_tree.js +108 -0
- package/dest/public/public_processor/public_processor.d.ts +25 -37
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +154 -111
- package/dest/public/public_processor/public_processor_metrics.d.ts +3 -3
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor_metrics.js +1 -1
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +30 -0
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +133 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +66 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +210 -0
- package/dest/public/public_tx_simulator/index.d.ts +5 -0
- package/dest/public/public_tx_simulator/index.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/index.js +2 -0
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +31 -0
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.js +51 -0
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +23 -30
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +71 -91
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +36 -58
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +208 -206
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts +9 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.js +1 -0
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts +21 -0
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.js +39 -0
- package/dest/public/side_effect_errors.d.ts +42 -2
- package/dest/public/side_effect_errors.d.ts.map +1 -1
- package/dest/public/side_effect_errors.js +70 -1
- package/dest/public/side_effect_trace.d.ts +21 -67
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +71 -121
- package/dest/public/side_effect_trace_interface.d.ts +12 -24
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
- package/dest/public/state_manager/index.d.ts +2 -0
- package/dest/public/state_manager/index.d.ts.map +1 -0
- package/dest/public/state_manager/index.js +1 -0
- package/dest/public/{avm/journal → state_manager}/nullifiers.d.ts +3 -6
- package/dest/public/state_manager/nullifiers.d.ts.map +1 -0
- package/dest/public/{avm/journal → state_manager}/nullifiers.js +3 -8
- package/dest/public/{avm/journal → state_manager}/public_storage.d.ts +3 -3
- package/dest/public/state_manager/public_storage.d.ts.map +1 -0
- package/dest/public/state_manager/state_manager.d.ts +159 -0
- package/dest/public/state_manager/state_manager.d.ts.map +1 -0
- package/dest/public/state_manager/state_manager.js +392 -0
- package/dest/public/test_executor_metrics.d.ts +55 -0
- package/dest/public/test_executor_metrics.d.ts.map +1 -0
- package/dest/public/test_executor_metrics.js +307 -0
- package/dest/public/unique_class_ids.d.ts +1 -1
- package/dest/public/unique_class_ids.d.ts.map +1 -1
- package/dest/public/utils.d.ts +3 -5
- package/dest/public/utils.d.ts.map +1 -1
- package/dest/public/utils.js +4 -21
- package/dest/server.d.ts +7 -4
- package/dest/server.d.ts.map +1 -1
- package/dest/server.js +5 -2
- package/dest/testing.d.ts +2 -0
- package/dest/testing.d.ts.map +1 -0
- package/dest/testing.js +1 -0
- package/package.json +39 -33
- package/src/client.ts +5 -3
- package/src/common/errors.ts +79 -44
- package/src/common/index.ts +0 -1
- package/src/private/acvm/acvm.ts +17 -32
- package/src/private/acvm/acvm_types.ts +1 -1
- package/src/private/acvm/deserialize.ts +35 -29
- package/src/private/acvm/index.ts +0 -1
- package/src/private/acvm/serialize.ts +63 -0
- package/src/private/{providers/acvm_native.ts → acvm_native.ts} +47 -24
- package/src/private/acvm_wasm.ts +72 -0
- package/src/private/acvm_wasm_with_blobs.ts +54 -0
- package/src/private/circuit_recording/circuit_recorder.ts +260 -0
- package/src/private/circuit_recording/file_circuit_recorder.ts +158 -0
- package/src/private/circuit_recording/memory_circuit_recorder.ts +11 -0
- package/src/private/circuit_recording/simulator_recorder_wrapper.ts +91 -0
- package/src/private/circuit_simulator.ts +90 -0
- package/src/private/{providers/factory.ts → factory.ts} +6 -6
- package/src/public/avm/avm_context.ts +4 -4
- package/src/public/avm/avm_contract_call_result.ts +17 -5
- package/src/public/avm/avm_execution_environment.ts +8 -1
- package/src/public/avm/avm_gas.ts +23 -35
- package/src/public/avm/avm_machine_state.ts +5 -0
- package/src/public/avm/avm_memory_types.ts +19 -6
- package/src/public/avm/avm_simulator.ts +43 -54
- package/src/public/avm/avm_simulator_interface.ts +8 -0
- package/src/public/avm/errors.ts +8 -77
- package/src/public/avm/fixtures/avm_simulation_tester.ts +32 -21
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +45 -12
- package/src/public/avm/fixtures/initializers.ts +102 -0
- package/src/public/avm/fixtures/utils.ts +150 -0
- package/src/public/avm/index.ts +0 -2
- package/src/public/avm/opcodes/accrued_substate.ts +64 -29
- package/src/public/avm/opcodes/addressing_mode.ts +56 -32
- package/src/public/avm/opcodes/arithmetic.ts +24 -2
- package/src/public/avm/opcodes/bitwise.ts +33 -29
- package/src/public/avm/opcodes/comparators.ts +6 -3
- package/src/public/avm/opcodes/contract.ts +10 -7
- package/src/public/avm/opcodes/control_flow.ts +19 -10
- package/src/public/avm/opcodes/conversion.ts +27 -3
- package/src/public/avm/opcodes/ec_add.ts +9 -6
- package/src/public/avm/opcodes/environment_getters.ts +27 -22
- package/src/public/avm/opcodes/external_calls.ts +61 -29
- package/src/public/avm/opcodes/hashing.ts +28 -8
- package/src/public/avm/opcodes/instruction.ts +31 -21
- package/src/public/avm/opcodes/memory.ts +71 -32
- package/src/public/avm/opcodes/misc.ts +60 -18
- package/src/public/avm/opcodes/storage.ts +22 -6
- package/src/public/avm/revert_reason.ts +55 -0
- package/src/public/avm/serialization/buffer_cursor.ts +4 -1
- package/src/public/avm/serialization/bytecode_serialization.ts +72 -74
- package/src/public/avm/serialization/instruction_serialization.ts +75 -34
- package/src/public/avm/test_utils.ts +24 -41
- package/src/public/contracts_db_checkpoint.ts +41 -0
- package/src/public/db_interfaces.ts +76 -0
- package/src/{common → public}/debug_fn_name.ts +7 -7
- package/src/public/executor_metrics.ts +56 -6
- package/src/public/executor_metrics_interface.ts +15 -0
- package/src/public/fixtures/amm_test.ts +331 -0
- package/src/public/fixtures/bulk_test.ts +169 -0
- package/src/public/fixtures/custom_bytecode_tester.ts +49 -0
- package/src/public/fixtures/custom_bytecode_tests.ts +135 -0
- package/src/public/fixtures/index.ts +7 -0
- package/src/public/fixtures/minimal_public_tx.ts +35 -0
- package/src/public/fixtures/public_tx_simulation_tester.ts +166 -113
- package/src/public/{avm/fixtures → fixtures}/simple_contract_data_source.ts +36 -18
- package/src/public/fixtures/token_test.ts +139 -0
- package/src/public/fixtures/utils.ts +141 -68
- package/src/public/hinting_db_sources.ts +602 -0
- package/src/public/index.ts +5 -8
- package/src/public/public_db_sources.ts +278 -258
- package/src/public/public_errors.ts +14 -0
- package/src/public/public_processor/guarded_merkle_tree.ts +153 -0
- package/src/public/public_processor/public_processor.ts +212 -164
- package/src/public/public_processor/public_processor_metrics.ts +2 -2
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +162 -0
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +306 -0
- package/src/public/public_tx_simulator/index.ts +4 -0
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +105 -0
- package/src/public/public_tx_simulator/public_tx_context.ts +167 -194
- package/src/public/public_tx_simulator/public_tx_simulator.ts +292 -265
- package/src/public/public_tx_simulator/public_tx_simulator_interface.ts +10 -0
- package/src/public/public_tx_simulator/telemetry_public_tx_simulator.ts +63 -0
- package/src/public/side_effect_errors.ts +91 -1
- package/src/public/side_effect_trace.ts +94 -320
- package/src/public/side_effect_trace_interface.ts +10 -58
- package/src/public/state_manager/index.ts +1 -0
- package/src/public/{avm/journal → state_manager}/nullifiers.ts +5 -11
- package/src/public/{avm/journal → state_manager}/public_storage.ts +2 -2
- package/src/public/state_manager/state_manager.ts +553 -0
- package/src/public/test_executor_metrics.ts +397 -0
- package/src/public/utils.ts +5 -21
- package/src/server.ts +6 -3
- package/src/testing.ts +1 -0
- package/dest/common/db_interfaces.d.ts +0 -80
- package/dest/common/db_interfaces.d.ts.map +0 -1
- package/dest/common/db_interfaces.js +0 -1
- package/dest/common/debug_fn_name.d.ts +0 -5
- package/dest/common/debug_fn_name.d.ts.map +0 -1
- package/dest/common/debug_fn_name.js +0 -6
- package/dest/common/message_load_oracle_inputs.d.ts +0 -15
- package/dest/common/message_load_oracle_inputs.d.ts.map +0 -1
- package/dest/common/message_load_oracle_inputs.js +0 -15
- package/dest/private/acvm/oracle/index.d.ts +0 -14
- package/dest/private/acvm/oracle/index.d.ts.map +0 -1
- package/dest/private/acvm/oracle/index.js +0 -2
- package/dest/private/acvm/oracle/oracle.d.ts +0 -49
- package/dest/private/acvm/oracle/oracle.d.ts.map +0 -1
- package/dest/private/acvm/oracle/oracle.js +0 -263
- package/dest/private/acvm/oracle/typed_oracle.d.ts +0 -83
- package/dest/private/acvm/oracle/typed_oracle.d.ts.map +0 -1
- package/dest/private/acvm/oracle/typed_oracle.js +0 -132
- package/dest/private/execution_data_provider.d.ts +0 -261
- package/dest/private/execution_data_provider.d.ts.map +0 -1
- package/dest/private/execution_data_provider.js +0 -14
- package/dest/private/execution_note_cache.d.ts +0 -93
- package/dest/private/execution_note_cache.d.ts.map +0 -1
- package/dest/private/execution_note_cache.js +0 -180
- package/dest/private/hashed_values_cache.d.ts +0 -28
- package/dest/private/hashed_values_cache.d.ts.map +0 -1
- package/dest/private/hashed_values_cache.js +0 -46
- package/dest/private/index.d.ts +0 -13
- package/dest/private/index.d.ts.map +0 -1
- package/dest/private/index.js +0 -12
- package/dest/private/pick_notes.d.ts +0 -85
- package/dest/private/pick_notes.d.ts.map +0 -1
- package/dest/private/pick_notes.js +0 -51
- package/dest/private/private_execution.d.ts +0 -25
- package/dest/private/private_execution.d.ts.map +0 -1
- package/dest/private/private_execution.js +0 -92
- package/dest/private/private_execution_oracle.d.ts +0 -215
- package/dest/private/private_execution_oracle.d.ts.map +0 -1
- package/dest/private/private_execution_oracle.js +0 -382
- package/dest/private/providers/acvm_native.d.ts +0 -40
- package/dest/private/providers/acvm_native.d.ts.map +0 -1
- package/dest/private/providers/acvm_wasm.d.ts +0 -15
- package/dest/private/providers/acvm_wasm.d.ts.map +0 -1
- package/dest/private/providers/acvm_wasm_with_blobs.d.ts +0 -19
- package/dest/private/providers/acvm_wasm_with_blobs.d.ts.map +0 -1
- package/dest/private/providers/acvm_wasm_with_blobs.js +0 -32
- package/dest/private/providers/factory.d.ts +0 -12
- package/dest/private/providers/factory.d.ts.map +0 -1
- package/dest/private/providers/simulation_provider.d.ts +0 -19
- package/dest/private/providers/simulation_provider.d.ts.map +0 -1
- package/dest/private/providers/simulation_provider.js +0 -24
- package/dest/private/simulator.d.ts +0 -34
- package/dest/private/simulator.d.ts.map +0 -1
- package/dest/private/simulator.js +0 -76
- package/dest/private/unconstrained_execution.d.ts +0 -10
- package/dest/private/unconstrained_execution.d.ts.map +0 -1
- package/dest/private/unconstrained_execution.js +0 -27
- package/dest/private/unconstrained_execution_oracle.d.ts +0 -161
- package/dest/private/unconstrained_execution_oracle.d.ts.map +0 -1
- package/dest/private/unconstrained_execution_oracle.js +0 -258
- package/dest/public/avm/bytecode_utils.d.ts +0 -5
- package/dest/public/avm/bytecode_utils.d.ts.map +0 -1
- package/dest/public/avm/bytecode_utils.js +0 -17
- package/dest/public/avm/fixtures/index.d.ts +0 -84
- package/dest/public/avm/fixtures/index.d.ts.map +0 -1
- package/dest/public/avm/fixtures/index.js +0 -175
- package/dest/public/avm/fixtures/simple_contract_data_source.d.ts +0 -35
- package/dest/public/avm/fixtures/simple_contract_data_source.d.ts.map +0 -1
- package/dest/public/avm/journal/index.d.ts +0 -2
- package/dest/public/avm/journal/index.d.ts.map +0 -1
- package/dest/public/avm/journal/index.js +0 -1
- package/dest/public/avm/journal/journal.d.ts +0 -209
- package/dest/public/avm/journal/journal.d.ts.map +0 -1
- package/dest/public/avm/journal/journal.js +0 -486
- package/dest/public/avm/journal/nullifiers.d.ts.map +0 -1
- package/dest/public/avm/journal/public_storage.d.ts.map +0 -1
- package/dest/public/bytecode_errors.d.ts +0 -4
- package/dest/public/bytecode_errors.d.ts.map +0 -1
- package/dest/public/bytecode_errors.js +0 -6
- package/dest/public/execution.d.ts +0 -108
- package/dest/public/execution.d.ts.map +0 -1
- package/dest/public/execution.js +0 -9
- package/dest/public/tx_contract_cache.d.ts +0 -41
- package/dest/public/tx_contract_cache.d.ts.map +0 -1
- package/dest/public/tx_contract_cache.js +0 -49
- package/dest/test/utils.d.ts +0 -13
- package/dest/test/utils.d.ts.map +0 -1
- package/dest/test/utils.js +0 -22
- package/src/common/db_interfaces.ts +0 -94
- package/src/common/message_load_oracle_inputs.ts +0 -15
- package/src/private/acvm/oracle/index.ts +0 -16
- package/src/private/acvm/oracle/oracle.ts +0 -455
- package/src/private/acvm/oracle/typed_oracle.ts +0 -259
- package/src/private/execution_data_provider.ts +0 -323
- package/src/private/execution_note_cache.ts +0 -217
- package/src/private/hashed_values_cache.ts +0 -55
- package/src/private/index.ts +0 -16
- package/src/private/pick_notes.ts +0 -141
- package/src/private/private_execution.ts +0 -151
- package/src/private/private_execution_oracle.ts +0 -614
- package/src/private/providers/acvm_wasm.ts +0 -63
- package/src/private/providers/acvm_wasm_with_blobs.ts +0 -50
- package/src/private/providers/simulation_provider.ts +0 -45
- package/src/private/simulator.ts +0 -147
- package/src/private/unconstrained_execution.ts +0 -50
- package/src/private/unconstrained_execution_oracle.ts +0 -373
- package/src/public/avm/bytecode_utils.ts +0 -17
- package/src/public/avm/fixtures/index.ts +0 -296
- package/src/public/avm/journal/index.ts +0 -1
- package/src/public/avm/journal/journal.ts +0 -742
- package/src/public/avm/opcodes/.eslintrc.cjs +0 -8
- package/src/public/bytecode_errors.ts +0 -6
- package/src/public/execution.ts +0 -140
- package/src/public/tx_contract_cache.ts +0 -69
- package/src/test/utils.ts +0 -36
- /package/dest/public/{avm/journal → state_manager}/public_storage.js +0 -0
|
@@ -1,382 +0,0 @@
|
|
|
1
|
-
import { MAX_FR_ARGS_TO_ALL_ENQUEUED_CALLS, PRIVATE_CONTEXT_INPUTS_LENGTH, PUBLIC_DISPATCH_SELECTOR } from '@aztec/constants';
|
|
2
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { FunctionSelector, countArgumentsSize } from '@aztec/stdlib/abi';
|
|
5
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import { computeUniqueNoteHash, siloNoteHash } from '@aztec/stdlib/hash';
|
|
7
|
-
import { PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
8
|
-
import { Note } from '@aztec/stdlib/note';
|
|
9
|
-
import { CallContext, CountedContractClassLog, CountedPublicExecutionRequest, NoteAndSlot, PublicExecutionRequest } from '@aztec/stdlib/tx';
|
|
10
|
-
import { toACVMWitness } from './acvm/index.js';
|
|
11
|
-
import { pickNotes } from './pick_notes.js';
|
|
12
|
-
import { executePrivateFunction, verifyCurrentClassId } from './private_execution.js';
|
|
13
|
-
import { UnconstrainedExecutionOracle } from './unconstrained_execution_oracle.js';
|
|
14
|
-
/**
|
|
15
|
-
* The execution oracle for the private part of a transaction.
|
|
16
|
-
*/ export class PrivateExecutionOracle extends UnconstrainedExecutionOracle {
|
|
17
|
-
argsHash;
|
|
18
|
-
txContext;
|
|
19
|
-
callContext;
|
|
20
|
-
historicalHeader;
|
|
21
|
-
executionCache;
|
|
22
|
-
noteCache;
|
|
23
|
-
provider;
|
|
24
|
-
totalPublicArgsCount;
|
|
25
|
-
sideEffectCounter;
|
|
26
|
-
/**
|
|
27
|
-
* New notes created during this execution.
|
|
28
|
-
* It's possible that a note in this list has been nullified (in the same or other executions) and doesn't exist in the ExecutionNoteCache and the final proof data.
|
|
29
|
-
* But we still include those notes in the execution result because their commitments are still in the public inputs of this execution.
|
|
30
|
-
* This information is only for references (currently used for tests), and is not used for any sort of constrains.
|
|
31
|
-
* Users can also use this to get a clearer idea of what's happened during a simulation.
|
|
32
|
-
*/ newNotes;
|
|
33
|
-
/**
|
|
34
|
-
* Notes from previous transactions that are returned to the oracle call `getNotes` during this execution.
|
|
35
|
-
* The mapping maps from the unique siloed note hash to the index for notes created in private executions.
|
|
36
|
-
* It maps from siloed note hash to the index for notes created by public functions.
|
|
37
|
-
*
|
|
38
|
-
* They are not part of the ExecutionNoteCache and being forwarded to nested contexts via `extend()`
|
|
39
|
-
* because these notes are meant to be maintained on a per-call basis
|
|
40
|
-
* They should act as references for the read requests output by an app circuit via public inputs.
|
|
41
|
-
*/ noteHashLeafIndexMap;
|
|
42
|
-
noteHashNullifierCounterMap;
|
|
43
|
-
contractClassLogs;
|
|
44
|
-
nestedExecutions;
|
|
45
|
-
enqueuedPublicFunctionCalls;
|
|
46
|
-
publicTeardownFunctionCall;
|
|
47
|
-
constructor(argsHash, txContext, callContext, /** Header of a block whose state is used during private execution (not the block the transaction is included in). */ historicalHeader, /** List of transient auth witnesses to be used during this simulation */ authWitnesses, capsules, executionCache, noteCache, executionDataProvider, provider, totalPublicArgsCount, sideEffectCounter = 0, log = createLogger('simulator:client_execution_context'), scopes){
|
|
48
|
-
super(callContext.contractAddress, authWitnesses, capsules, executionDataProvider, log, scopes), this.argsHash = argsHash, this.txContext = txContext, this.callContext = callContext, this.historicalHeader = historicalHeader, this.executionCache = executionCache, this.noteCache = noteCache, this.provider = provider, this.totalPublicArgsCount = totalPublicArgsCount, this.sideEffectCounter = sideEffectCounter, this.newNotes = [], this.noteHashLeafIndexMap = new Map(), this.noteHashNullifierCounterMap = new Map(), this.contractClassLogs = [], this.nestedExecutions = [], this.enqueuedPublicFunctionCalls = [], this.publicTeardownFunctionCall = PublicExecutionRequest.empty();
|
|
49
|
-
}
|
|
50
|
-
// We still need this function until we can get user-defined ordering of structs for fn arguments
|
|
51
|
-
// TODO When that is sorted out on noir side, we can use instead the utilities in serialize.ts
|
|
52
|
-
/**
|
|
53
|
-
* Writes the function inputs to the initial witness.
|
|
54
|
-
* @param abi - The function ABI.
|
|
55
|
-
* @returns The initial witness.
|
|
56
|
-
*/ getInitialWitness(abi) {
|
|
57
|
-
const argumentsSize = countArgumentsSize(abi);
|
|
58
|
-
const args = this.executionCache.getPreimage(this.argsHash);
|
|
59
|
-
if (args.length !== argumentsSize) {
|
|
60
|
-
throw new Error(`Invalid arguments size: expected ${argumentsSize}, got ${args.length}`);
|
|
61
|
-
}
|
|
62
|
-
const privateContextInputs = new PrivateContextInputs(this.callContext, this.historicalHeader, this.txContext, this.sideEffectCounter);
|
|
63
|
-
const privateContextInputsAsFields = privateContextInputs.toFields();
|
|
64
|
-
if (privateContextInputsAsFields.length !== PRIVATE_CONTEXT_INPUTS_LENGTH) {
|
|
65
|
-
throw new Error('Invalid private context inputs size');
|
|
66
|
-
}
|
|
67
|
-
const fields = [
|
|
68
|
-
...privateContextInputsAsFields,
|
|
69
|
-
...args
|
|
70
|
-
];
|
|
71
|
-
return toACVMWitness(0, fields);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* The KernelProver will use this to fully populate witnesses and provide hints to the kernel circuit
|
|
75
|
-
* regarding which note hash each settled read request corresponds to.
|
|
76
|
-
*/ getNoteHashLeafIndexMap() {
|
|
77
|
-
return this.noteHashLeafIndexMap;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Get the data for the newly created notes.
|
|
81
|
-
*/ getNewNotes() {
|
|
82
|
-
return this.newNotes;
|
|
83
|
-
}
|
|
84
|
-
getNoteHashNullifierCounterMap() {
|
|
85
|
-
return this.noteHashNullifierCounterMap;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Return the contract class logs emitted during this execution.
|
|
89
|
-
*/ getContractClassLogs() {
|
|
90
|
-
return this.contractClassLogs;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Return the nested execution results during this execution.
|
|
94
|
-
*/ getNestedExecutions() {
|
|
95
|
-
return this.nestedExecutions;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Return the enqueued public function calls during this execution.
|
|
99
|
-
*/ getEnqueuedPublicFunctionCalls() {
|
|
100
|
-
return this.enqueuedPublicFunctionCalls;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Return the public teardown function call set during this execution.
|
|
104
|
-
*/ getPublicTeardownFunctionCall() {
|
|
105
|
-
return this.publicTeardownFunctionCall;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Store values in the execution cache.
|
|
109
|
-
* @param values - Values to store.
|
|
110
|
-
* @returns The hash of the values.
|
|
111
|
-
*/ storeInExecutionCache(values) {
|
|
112
|
-
return this.executionCache.store(values);
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Gets values from the execution cache.
|
|
116
|
-
* @param hash - Hash of the values.
|
|
117
|
-
* @returns The values.
|
|
118
|
-
*/ loadFromExecutionCache(hash) {
|
|
119
|
-
return Promise.resolve(this.executionCache.getPreimage(hash));
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Gets some notes for a storage slot.
|
|
123
|
-
*
|
|
124
|
-
* @remarks
|
|
125
|
-
* Check for pending notes with matching slot.
|
|
126
|
-
* Real notes coming from DB will have a leafIndex which
|
|
127
|
-
* represents their index in the note hash tree.
|
|
128
|
-
*
|
|
129
|
-
* @param storageSlot - The storage slot.
|
|
130
|
-
* @param numSelects - The number of valid selects in selectBy and selectValues.
|
|
131
|
-
* @param selectBy - An array of indices of the fields to selects.
|
|
132
|
-
* @param selectValues - The values to match.
|
|
133
|
-
* @param selectComparators - The comparators to match by.
|
|
134
|
-
* @param sortBy - An array of indices of the fields to sort.
|
|
135
|
-
* @param sortOrder - The order of the corresponding index in sortBy. (1: DESC, 2: ASC, 0: Do nothing)
|
|
136
|
-
* @param limit - The number of notes to retrieve per query.
|
|
137
|
-
* @param offset - The starting index for pagination.
|
|
138
|
-
* @param status - The status of notes to fetch.
|
|
139
|
-
* @returns Array of note data.
|
|
140
|
-
*/ async getNotes(storageSlot, numSelects, selectByIndexes, selectByOffsets, selectByLengths, selectValues, selectComparators, sortByIndexes, sortByOffsets, sortByLengths, sortOrder, limit, offset, status) {
|
|
141
|
-
// Nullified pending notes are already removed from the list.
|
|
142
|
-
const pendingNotes = this.noteCache.getNotes(this.callContext.contractAddress, storageSlot);
|
|
143
|
-
const pendingNullifiers = this.noteCache.getNullifiers(this.callContext.contractAddress);
|
|
144
|
-
const dbNotes = await this.executionDataProvider.getNotes(this.callContext.contractAddress, storageSlot, status, this.scopes);
|
|
145
|
-
const dbNotesFiltered = dbNotes.filter((n)=>!pendingNullifiers.has(n.siloedNullifier.value));
|
|
146
|
-
const notes = pickNotes([
|
|
147
|
-
...dbNotesFiltered,
|
|
148
|
-
...pendingNotes
|
|
149
|
-
], {
|
|
150
|
-
selects: selectByIndexes.slice(0, numSelects).map((index, i)=>({
|
|
151
|
-
selector: {
|
|
152
|
-
index,
|
|
153
|
-
offset: selectByOffsets[i],
|
|
154
|
-
length: selectByLengths[i]
|
|
155
|
-
},
|
|
156
|
-
value: selectValues[i],
|
|
157
|
-
comparator: selectComparators[i]
|
|
158
|
-
})),
|
|
159
|
-
sorts: sortByIndexes.map((index, i)=>({
|
|
160
|
-
selector: {
|
|
161
|
-
index,
|
|
162
|
-
offset: sortByOffsets[i],
|
|
163
|
-
length: sortByLengths[i]
|
|
164
|
-
},
|
|
165
|
-
order: sortOrder[i]
|
|
166
|
-
})),
|
|
167
|
-
limit,
|
|
168
|
-
offset
|
|
169
|
-
});
|
|
170
|
-
this.log.debug(`Returning ${notes.length} notes for ${this.callContext.contractAddress} at ${storageSlot}: ${notes.map((n)=>`${n.nonce.toString()}:[${n.note.items.map((i)=>i.toString()).join(',')}]`).join(', ')}`);
|
|
171
|
-
const noteHashesAndIndexes = await Promise.all(notes.map(async (n)=>{
|
|
172
|
-
if (n.index !== undefined) {
|
|
173
|
-
const siloedNoteHash = await siloNoteHash(n.contractAddress, n.noteHash);
|
|
174
|
-
const uniqueNoteHash = await computeUniqueNoteHash(n.nonce, siloedNoteHash);
|
|
175
|
-
return {
|
|
176
|
-
hash: uniqueNoteHash,
|
|
177
|
-
index: n.index
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
}));
|
|
181
|
-
noteHashesAndIndexes.filter((n)=>n !== undefined).forEach((n)=>{
|
|
182
|
-
this.noteHashLeafIndexMap.set(n.hash.toBigInt(), n.index);
|
|
183
|
-
});
|
|
184
|
-
return notes;
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Keep track of the new note created during execution.
|
|
188
|
-
* It can be used in subsequent calls (or transactions when chaining txs is possible).
|
|
189
|
-
* @param contractAddress - The contract address.
|
|
190
|
-
* @param storageSlot - The storage slot.
|
|
191
|
-
* @param noteTypeId - The type ID of the note.
|
|
192
|
-
* @param noteItems - The items to be included in a Note.
|
|
193
|
-
* @param noteHash - A hash of the new note.
|
|
194
|
-
* @returns
|
|
195
|
-
*/ notifyCreatedNote(storageSlot, noteTypeId, noteItems, noteHash, counter) {
|
|
196
|
-
this.log.debug(`Notified of new note with inner hash ${noteHash}`, {
|
|
197
|
-
contractAddress: this.callContext.contractAddress,
|
|
198
|
-
storageSlot,
|
|
199
|
-
noteTypeId,
|
|
200
|
-
counter
|
|
201
|
-
});
|
|
202
|
-
const note = new Note(noteItems);
|
|
203
|
-
this.noteCache.addNewNote({
|
|
204
|
-
contractAddress: this.callContext.contractAddress,
|
|
205
|
-
storageSlot,
|
|
206
|
-
nonce: Fr.ZERO,
|
|
207
|
-
note,
|
|
208
|
-
siloedNullifier: undefined,
|
|
209
|
-
noteHash
|
|
210
|
-
}, counter);
|
|
211
|
-
this.newNotes.push(new NoteAndSlot(note, storageSlot, noteTypeId));
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Adding a siloed nullifier into the current set of all pending nullifiers created
|
|
215
|
-
* within the current transaction/execution.
|
|
216
|
-
* @param innerNullifier - The pending nullifier to add in the list (not yet siloed by contract address).
|
|
217
|
-
* @param noteHash - A hash of the new note.
|
|
218
|
-
*/ async notifyNullifiedNote(innerNullifier, noteHash, counter) {
|
|
219
|
-
const nullifiedNoteHashCounter = await this.noteCache.nullifyNote(this.callContext.contractAddress, innerNullifier, noteHash);
|
|
220
|
-
if (nullifiedNoteHashCounter !== undefined) {
|
|
221
|
-
this.noteHashNullifierCounterMap.set(nullifiedNoteHashCounter, counter);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Adding a siloed nullifier into the current set of all pending nullifiers created
|
|
226
|
-
* within the current transaction/execution.
|
|
227
|
-
* @param innerNullifier - The pending nullifier to add in the list (not yet siloed by contract address).
|
|
228
|
-
* @param noteHash - A hash of the new note.
|
|
229
|
-
*/ notifyCreatedNullifier(innerNullifier) {
|
|
230
|
-
return this.noteCache.nullifierCreated(this.callContext.contractAddress, innerNullifier);
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Emit a contract class log.
|
|
234
|
-
* This fn exists because we only carry a poseidon hash through the kernels, and need to
|
|
235
|
-
* keep the preimage in ts for later.
|
|
236
|
-
* @param log - The contract class log to be emitted.
|
|
237
|
-
* @param counter - The contract class log's counter.
|
|
238
|
-
*/ notifyCreatedContractClassLog(log, counter) {
|
|
239
|
-
this.contractClassLogs.push(new CountedContractClassLog(log, counter));
|
|
240
|
-
const text = log.toBuffer().toString('hex');
|
|
241
|
-
this.log.verbose(`Emitted log from ContractClassRegisterer: "${text.length > 100 ? text.slice(0, 100) + '...' : text}"`);
|
|
242
|
-
}
|
|
243
|
-
#checkValidStaticCall(childExecutionResult) {
|
|
244
|
-
if (childExecutionResult.publicInputs.noteHashes.some((item)=>!item.isEmpty()) || childExecutionResult.publicInputs.nullifiers.some((item)=>!item.isEmpty()) || childExecutionResult.publicInputs.l2ToL1Msgs.some((item)=>!item.isEmpty()) || childExecutionResult.publicInputs.privateLogs.some((item)=>!item.isEmpty()) || childExecutionResult.publicInputs.contractClassLogsHashes.some((item)=>!item.isEmpty())) {
|
|
245
|
-
throw new Error(`Static call cannot update the state, emit L2->L1 messages or generate logs`);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Calls a private function as a nested execution.
|
|
250
|
-
* @param targetContractAddress - The address of the contract to call.
|
|
251
|
-
* @param functionSelector - The function selector of the function to call.
|
|
252
|
-
* @param argsHash - The arguments hash to pass to the function.
|
|
253
|
-
* @param sideEffectCounter - The side effect counter at the start of the call.
|
|
254
|
-
* @param isStaticCall - Whether the call is a static call.
|
|
255
|
-
* @returns The execution result.
|
|
256
|
-
*/ async callPrivateFunction(targetContractAddress, functionSelector, argsHash, sideEffectCounter, isStaticCall) {
|
|
257
|
-
this.log.debug(`Calling private function ${targetContractAddress}:${functionSelector} from ${this.callContext.contractAddress}`);
|
|
258
|
-
isStaticCall = isStaticCall || this.callContext.isStaticCall;
|
|
259
|
-
await verifyCurrentClassId(targetContractAddress, this.executionDataProvider, this.historicalHeader.globalVariables.blockNumber.toNumber());
|
|
260
|
-
const targetArtifact = await this.executionDataProvider.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
261
|
-
const derivedTxContext = this.txContext.clone();
|
|
262
|
-
const derivedCallContext = await this.deriveCallContext(targetContractAddress, targetArtifact, isStaticCall);
|
|
263
|
-
const context = new PrivateExecutionOracle(argsHash, derivedTxContext, derivedCallContext, this.historicalHeader, this.authWitnesses, this.capsules, this.executionCache, this.noteCache, this.executionDataProvider, this.provider, this.totalPublicArgsCount, sideEffectCounter, this.log, this.scopes);
|
|
264
|
-
const childExecutionResult = await executePrivateFunction(this.provider, context, targetArtifact, targetContractAddress, functionSelector);
|
|
265
|
-
if (isStaticCall) {
|
|
266
|
-
this.#checkValidStaticCall(childExecutionResult);
|
|
267
|
-
}
|
|
268
|
-
this.nestedExecutions.push(childExecutionResult);
|
|
269
|
-
const publicInputs = childExecutionResult.publicInputs;
|
|
270
|
-
return {
|
|
271
|
-
endSideEffectCounter: publicInputs.endSideEffectCounter,
|
|
272
|
-
returnsHash: publicInputs.returnsHash
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Creates a PublicExecutionRequest object representing the request to call a public function.
|
|
277
|
-
* @param targetContractAddress - The address of the contract to call.
|
|
278
|
-
* @param functionSelector - The function selector of the function to call.
|
|
279
|
-
* @param argsHash - The arguments hash to pass to the function.
|
|
280
|
-
* @param sideEffectCounter - The side effect counter at the start of the call.
|
|
281
|
-
* @param isStaticCall - Whether the call is a static call.
|
|
282
|
-
* @returns The public call stack item with the request information.
|
|
283
|
-
*/ async createPublicExecutionRequest(callType, targetContractAddress, functionSelector, argsHash, sideEffectCounter, isStaticCall) {
|
|
284
|
-
const targetArtifact = await this.executionDataProvider.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
285
|
-
const derivedCallContext = await this.deriveCallContext(targetContractAddress, targetArtifact, isStaticCall);
|
|
286
|
-
const args = this.executionCache.getPreimage(argsHash);
|
|
287
|
-
this.log.verbose(`Created ${callType} public execution request to ${targetArtifact.name}@${targetContractAddress}`, {
|
|
288
|
-
sideEffectCounter,
|
|
289
|
-
isStaticCall,
|
|
290
|
-
functionSelector,
|
|
291
|
-
targetContractAddress,
|
|
292
|
-
callType
|
|
293
|
-
});
|
|
294
|
-
const request = PublicExecutionRequest.from({
|
|
295
|
-
args,
|
|
296
|
-
callContext: derivedCallContext
|
|
297
|
-
});
|
|
298
|
-
if (callType === 'enqueued') {
|
|
299
|
-
this.enqueuedPublicFunctionCalls.push(new CountedPublicExecutionRequest(request, sideEffectCounter));
|
|
300
|
-
} else {
|
|
301
|
-
this.publicTeardownFunctionCall = request;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Creates and enqueues a PublicExecutionRequest object representing the request to call a public function. No function
|
|
306
|
-
* is actually called, since that must happen on the sequencer side. All the fields related to the result
|
|
307
|
-
* of the execution are empty.
|
|
308
|
-
* @param targetContractAddress - The address of the contract to call.
|
|
309
|
-
* @param functionSelector - The function selector of the function to call.
|
|
310
|
-
* @param argsHash - The arguments hash to pass to the function.
|
|
311
|
-
* @param sideEffectCounter - The side effect counter at the start of the call.
|
|
312
|
-
* @param isStaticCall - Whether the call is a static call.
|
|
313
|
-
* @returns The public call stack item with the request information.
|
|
314
|
-
*/ async enqueuePublicFunctionCall(targetContractAddress, functionSelector, argsHash, sideEffectCounter, isStaticCall) {
|
|
315
|
-
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/8985): Fix this.
|
|
316
|
-
// WARNING: This is insecure and should be temporary!
|
|
317
|
-
// The oracle re-hashes the arguments and returns a new args_hash.
|
|
318
|
-
// new_args = [selector, ...old_args], so as to make it suitable to call the public dispatch function.
|
|
319
|
-
// We don't validate or compute it in the circuit because a) it's harder to do with slices, and
|
|
320
|
-
// b) this is only temporary.
|
|
321
|
-
const newArgs = [
|
|
322
|
-
functionSelector.toField(),
|
|
323
|
-
...this.executionCache.getPreimage(argsHash)
|
|
324
|
-
];
|
|
325
|
-
const newArgsHash = await this.executionCache.store(newArgs);
|
|
326
|
-
await this.createPublicExecutionRequest('enqueued', targetContractAddress, FunctionSelector.fromField(new Fr(PUBLIC_DISPATCH_SELECTOR)), newArgsHash, sideEffectCounter, isStaticCall);
|
|
327
|
-
this.totalPublicArgsCount += newArgs.length;
|
|
328
|
-
if (this.totalPublicArgsCount > MAX_FR_ARGS_TO_ALL_ENQUEUED_CALLS) {
|
|
329
|
-
throw new Error(`Too many total args to all enqueued public calls! (> ${MAX_FR_ARGS_TO_ALL_ENQUEUED_CALLS})`);
|
|
330
|
-
}
|
|
331
|
-
return newArgsHash;
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Creates a PublicExecutionRequest and sets it as the public teardown function. No function
|
|
335
|
-
* is actually called, since that must happen on the sequencer side. All the fields related to the result
|
|
336
|
-
* of the execution are empty.
|
|
337
|
-
* @param targetContractAddress - The address of the contract to call.
|
|
338
|
-
* @param functionSelector - The function selector of the function to call.
|
|
339
|
-
* @param argsHash - The arguments hash to pass to the function.
|
|
340
|
-
* @param sideEffectCounter - The side effect counter at the start of the call.
|
|
341
|
-
* @param isStaticCall - Whether the call is a static call.
|
|
342
|
-
* @returns The public call stack item with the request information.
|
|
343
|
-
*/ async setPublicTeardownFunctionCall(targetContractAddress, functionSelector, argsHash, sideEffectCounter, isStaticCall) {
|
|
344
|
-
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/8985): Fix this.
|
|
345
|
-
// WARNING: This is insecure and should be temporary!
|
|
346
|
-
// The oracle rehashes the arguments and returns a new args_hash.
|
|
347
|
-
// new_args = [selector, ...old_args], so as to make it suitable to call the public dispatch function.
|
|
348
|
-
// We don't validate or compute it in the circuit because a) it's harder to do with slices, and
|
|
349
|
-
// b) this is only temporary.
|
|
350
|
-
const newArgsHash = await this.executionCache.store([
|
|
351
|
-
functionSelector.toField(),
|
|
352
|
-
...this.executionCache.getPreimage(argsHash)
|
|
353
|
-
]);
|
|
354
|
-
await this.createPublicExecutionRequest('teardown', targetContractAddress, FunctionSelector.fromField(new Fr(PUBLIC_DISPATCH_SELECTOR)), newArgsHash, sideEffectCounter, isStaticCall);
|
|
355
|
-
return newArgsHash;
|
|
356
|
-
}
|
|
357
|
-
notifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter) {
|
|
358
|
-
return this.noteCache.setMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter);
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Derives the call context for a nested execution.
|
|
362
|
-
* @param targetContractAddress - The address of the contract being called.
|
|
363
|
-
* @param targetArtifact - The artifact of the function being called.
|
|
364
|
-
* @param isStaticCall - Whether the call is a static call.
|
|
365
|
-
* @returns The derived call context.
|
|
366
|
-
*/ async deriveCallContext(targetContractAddress, targetArtifact, isStaticCall = false) {
|
|
367
|
-
return new CallContext(this.contractAddress, targetContractAddress, await FunctionSelector.fromNameAndParameters(targetArtifact.name, targetArtifact.parameters), isStaticCall);
|
|
368
|
-
}
|
|
369
|
-
getDebugFunctionName() {
|
|
370
|
-
return this.executionDataProvider.getDebugFunctionName(this.contractAddress, this.callContext.functionSelector);
|
|
371
|
-
}
|
|
372
|
-
async incrementAppTaggingSecretIndexAsSender(sender, recipient) {
|
|
373
|
-
await this.executionDataProvider.incrementAppTaggingSecretIndexAsSender(this.contractAddress, sender, recipient);
|
|
374
|
-
}
|
|
375
|
-
async syncNotes() {
|
|
376
|
-
const taggedLogsByRecipient = await this.executionDataProvider.syncTaggedLogs(this.contractAddress, this.historicalHeader.globalVariables.blockNumber.toNumber(), this.scopes);
|
|
377
|
-
for (const [recipient, taggedLogs] of taggedLogsByRecipient.entries()){
|
|
378
|
-
await this.executionDataProvider.processTaggedLogs(taggedLogs, AztecAddress.fromString(recipient));
|
|
379
|
-
}
|
|
380
|
-
await this.executionDataProvider.removeNullifiedNotes(this.contractAddress);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
-
import type { NoirCompiledCircuit } from '@aztec/stdlib/noir';
|
|
4
|
-
import type { WitnessMap } from '@noir-lang/types';
|
|
5
|
-
import type { ACIRCallback, ACIRExecutionResult } from '../acvm/acvm.js';
|
|
6
|
-
import type { ACVMWitness } from '../acvm/acvm_types.js';
|
|
7
|
-
import type { SimulationProvider } from './simulation_provider.js';
|
|
8
|
-
export declare enum ACVM_RESULT {
|
|
9
|
-
SUCCESS = 0,
|
|
10
|
-
FAILURE = 1
|
|
11
|
-
}
|
|
12
|
-
export type ACVMSuccess = {
|
|
13
|
-
status: ACVM_RESULT.SUCCESS;
|
|
14
|
-
duration: number;
|
|
15
|
-
witness: Map<number, string>;
|
|
16
|
-
};
|
|
17
|
-
export type ACVMFailure = {
|
|
18
|
-
status: ACVM_RESULT.FAILURE;
|
|
19
|
-
reason: string;
|
|
20
|
-
};
|
|
21
|
-
export type ACVMResult = ACVMSuccess | ACVMFailure;
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @param inputWitness - The circuit's input witness
|
|
25
|
-
* @param bytecode - The circuit bytecode
|
|
26
|
-
* @param workingDirectory - A directory to use for temporary files by the ACVM
|
|
27
|
-
* @param pathToAcvm - The path to the ACVM binary
|
|
28
|
-
* @param outputFilename - If specified, the output will be stored as a file, encoded using Bincode
|
|
29
|
-
* @returns The completed partial witness outputted from the circuit
|
|
30
|
-
*/
|
|
31
|
-
export declare function executeNativeCircuit(inputWitness: WitnessMap, bytecode: Buffer, workingDirectory: string, pathToAcvm: string, outputFilename?: string): Promise<ACVMResult>;
|
|
32
|
-
export declare class NativeACVMSimulator implements SimulationProvider {
|
|
33
|
-
private workingDirectory;
|
|
34
|
-
private pathToAcvm;
|
|
35
|
-
private witnessFilename?;
|
|
36
|
-
constructor(workingDirectory: string, pathToAcvm: string, witnessFilename?: string | undefined);
|
|
37
|
-
executeProtocolCircuit(input: WitnessMap, compiledCircuit: NoirCompiledCircuit): Promise<WitnessMap>;
|
|
38
|
-
executeUserCircuit(_acir: Buffer, _initialWitness: ACVMWitness, _callback: ACIRCallback): Promise<ACIRExecutionResult>;
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=acvm_native.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"acvm_native.d.ts","sourceRoot":"","sources":["../../../src/private/providers/acvm_native.ts"],"names":[],"mappings":";;AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAInD,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAInE,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,GACtB,OAAO,CAAC,UAAU,CAAC,CAqErB;AAED,qBAAa,mBAAoB,YAAW,kBAAkB;IAChD,OAAO,CAAC,gBAAgB;IAAU,OAAO,CAAC,UAAU;IAAU,OAAO,CAAC,eAAe,CAAC;gBAA9E,gBAAgB,EAAE,MAAM,EAAU,UAAU,EAAE,MAAM,EAAU,eAAe,CAAC,oBAAQ;IACpG,sBAAsB,CAAC,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IAyB1G,kBAAkB,CAChB,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,WAAW,EAC5B,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,mBAAmB,CAAC;CAGhC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
-
import type { NoirCompiledCircuit } from '@aztec/stdlib/noir';
|
|
4
|
-
import type { WitnessMap } from '@noir-lang/types';
|
|
5
|
-
import { type ACIRCallback } from '../acvm/acvm.js';
|
|
6
|
-
import type { ACVMWitness } from '../acvm/acvm_types.js';
|
|
7
|
-
import { type SimulationProvider } from './simulation_provider.js';
|
|
8
|
-
export declare class WASMSimulator implements SimulationProvider {
|
|
9
|
-
protected log: import("@aztec/foundation/log").Logger;
|
|
10
|
-
constructor(log?: import("@aztec/foundation/log").Logger);
|
|
11
|
-
init(): Promise<void>;
|
|
12
|
-
executeProtocolCircuit(input: WitnessMap, compiledCircuit: NoirCompiledCircuit): Promise<WitnessMap>;
|
|
13
|
-
executeUserCircuit(acir: Buffer, initialWitness: ACVMWitness, callback: ACIRCallback): Promise<import("../acvm/acvm.js").ACIRExecutionResult>;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=acvm_wasm.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"acvm_wasm.d.ts","sourceRoot":"","sources":["../../../src/private/providers/acvm_wasm.ts"],"names":[],"mappings":";;AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAI9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,KAAK,YAAY,EAAQ,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,KAAK,kBAAkB,EAAqB,MAAM,0BAA0B,CAAC;AAEtF,qBAAa,aAAc,YAAW,kBAAkB;IAC1C,SAAS,CAAC,GAAG;gBAAH,GAAG,yCAAiC;IAEpD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAUrB,sBAAsB,CAAC,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IAiCpG,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY;CAI3F"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
-
import type { NoirCompiledCircuit } from '@aztec/stdlib/noir';
|
|
4
|
-
import type { WitnessMap } from '@noir-lang/types';
|
|
5
|
-
import type { ACIRCallback, ACIRExecutionResult } from '../acvm/acvm.js';
|
|
6
|
-
import type { ACVMWitness } from '../acvm/acvm_types.js';
|
|
7
|
-
import { type SimulationProvider } from './simulation_provider.js';
|
|
8
|
-
/**
|
|
9
|
-
* A simulation provider that uses the WASM simulator with the ability to handle blobs via the foreign call handler.
|
|
10
|
-
* This class is temporary while brillig cannot handle the blob math, and it is kept separate
|
|
11
|
-
* because the zkg commitment library used in the blob code is not browser compatible.
|
|
12
|
-
*
|
|
13
|
-
* It is only used in the context of server-side code executing simulated protocol circuits.
|
|
14
|
-
*/
|
|
15
|
-
export declare class WASMSimulatorWithBlobs implements SimulationProvider {
|
|
16
|
-
executeProtocolCircuit(input: WitnessMap, compiledCircuit: NoirCompiledCircuit): Promise<WitnessMap>;
|
|
17
|
-
executeUserCircuit(_acir: Buffer, _initialWitness: ACVMWitness, _callback: ACIRCallback): Promise<ACIRExecutionResult>;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=acvm_wasm_with_blobs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"acvm_wasm_with_blobs.d.ts","sourceRoot":"","sources":["../../../src/private/providers/acvm_wasm_with_blobs.ts"],"names":[],"mappings":";;AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAG9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,KAAK,kBAAkB,EAAqB,MAAM,0BAA0B,CAAC;AAEtF;;;;;;GAMG;AACH,qBAAa,sBAAuB,YAAW,kBAAkB;IACzD,sBAAsB,CAAC,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IAwB1G,kBAAkB,CAChB,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,WAAW,EAC5B,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,mBAAmB,CAAC;CAGhC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { foreignCallHandler } from '@aztec/noir-protocol-circuits-types/server';
|
|
2
|
-
import { executeCircuit } from '@noir-lang/acvm_js';
|
|
3
|
-
import { parseErrorPayload } from './simulation_provider.js';
|
|
4
|
-
/**
|
|
5
|
-
* A simulation provider that uses the WASM simulator with the ability to handle blobs via the foreign call handler.
|
|
6
|
-
* This class is temporary while brillig cannot handle the blob math, and it is kept separate
|
|
7
|
-
* because the zkg commitment library used in the blob code is not browser compatible.
|
|
8
|
-
*
|
|
9
|
-
* It is only used in the context of server-side code executing simulated protocol circuits.
|
|
10
|
-
*/ export class WASMSimulatorWithBlobs {
|
|
11
|
-
async executeProtocolCircuit(input, compiledCircuit) {
|
|
12
|
-
// Execute the circuit on those initial witness values
|
|
13
|
-
//
|
|
14
|
-
// Decode the bytecode from base64 since the acvm does not know about base64 encoding
|
|
15
|
-
const decodedBytecode = Buffer.from(compiledCircuit.bytecode, 'base64');
|
|
16
|
-
//
|
|
17
|
-
// Execute the circuit
|
|
18
|
-
try {
|
|
19
|
-
const _witnessMap = await executeCircuit(decodedBytecode, input, foreignCallHandler);
|
|
20
|
-
return _witnessMap;
|
|
21
|
-
} catch (err) {
|
|
22
|
-
// Typescript types catched errors as unknown or any, so we need to narrow its type to check if it has raw assertion payload.
|
|
23
|
-
if (typeof err === 'object' && err !== null && 'rawAssertionPayload' in err) {
|
|
24
|
-
throw parseErrorPayload(compiledCircuit.abi, err);
|
|
25
|
-
}
|
|
26
|
-
throw new Error(`Circuit execution failed: ${err}`);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
executeUserCircuit(_acir, _initialWitness, _callback) {
|
|
30
|
-
throw new Error('Not implemented');
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type Logger } from '@aztec/foundation/log';
|
|
2
|
-
import type { SimulationProvider } from './simulation_provider.js';
|
|
3
|
-
export type SimulationProviderConfig = {
|
|
4
|
-
acvmBinaryPath?: string;
|
|
5
|
-
acvmWorkingDirectory?: string;
|
|
6
|
-
};
|
|
7
|
-
export declare function getSimulationProviderConfigFromEnv(): {
|
|
8
|
-
acvmWorkingDirectory: string | undefined;
|
|
9
|
-
acvmBinaryPath: string | undefined;
|
|
10
|
-
};
|
|
11
|
-
export declare function createSimulationProvider(config: SimulationProviderConfig, logger?: Logger): Promise<SimulationProvider>;
|
|
12
|
-
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/private/providers/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAMlE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,MAAM,MAAM,wBAAwB,GAAG;IACrC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF,wBAAgB,kCAAkC;;;EAMjD;AAED,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,wBAAwB,EAChC,MAAM,GAAE,MAAkC,GACzC,OAAO,CAAC,kBAAkB,CAAC,CAa7B"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
-
import type { NoirCompiledCircuit } from '@aztec/stdlib/noir';
|
|
4
|
-
import type { ExecutionError } from '@noir-lang/acvm_js';
|
|
5
|
-
import type { Abi, WitnessMap } from '@noir-lang/types';
|
|
6
|
-
import type { ACIRCallback, ACIRExecutionResult } from '../acvm/acvm.js';
|
|
7
|
-
import type { ACVMWitness } from '../acvm/acvm_types.js';
|
|
8
|
-
/**
|
|
9
|
-
* Low level simulation interface
|
|
10
|
-
*/
|
|
11
|
-
export interface SimulationProvider {
|
|
12
|
-
executeProtocolCircuit(input: WitnessMap, compiledCircuit: NoirCompiledCircuit): Promise<WitnessMap>;
|
|
13
|
-
executeUserCircuit(acir: Buffer, initialWitness: ACVMWitness, callback: ACIRCallback): Promise<ACIRExecutionResult>;
|
|
14
|
-
}
|
|
15
|
-
export type ErrorWithPayload = ExecutionError & {
|
|
16
|
-
decodedAssertionPayload?: any;
|
|
17
|
-
};
|
|
18
|
-
export declare function parseErrorPayload(abi: Abi, originalError: ExecutionError): Error;
|
|
19
|
-
//# sourceMappingURL=simulation_provider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simulation_provider.d.ts","sourceRoot":"","sources":["../../../src/private/providers/simulation_provider.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,sBAAsB,CAAC,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACrG,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACrH;AAED,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG;IAAE,uBAAuB,CAAC,EAAE,GAAG,CAAA;CAAE,CAAC;AAIlF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,aAAa,EAAE,cAAc,GAAG,KAAK,CAuBhF"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { abiDecodeError } from '@noir-lang/noirc_abi';
|
|
2
|
-
// Error handling taken from noir/noir-repo/tooling/noir_js/src/witness_generation.ts.
|
|
3
|
-
// TODO: import this in isolation without having to import noir_js in its entirety.
|
|
4
|
-
export function parseErrorPayload(abi, originalError) {
|
|
5
|
-
const payload = originalError.rawAssertionPayload;
|
|
6
|
-
if (!payload) {
|
|
7
|
-
return originalError;
|
|
8
|
-
}
|
|
9
|
-
const enrichedError = originalError;
|
|
10
|
-
try {
|
|
11
|
-
// Decode the payload
|
|
12
|
-
const decodedPayload = abiDecodeError(abi, payload);
|
|
13
|
-
if (typeof decodedPayload === 'string') {
|
|
14
|
-
// If it's a string, just add it to the error message
|
|
15
|
-
enrichedError.message = `Circuit execution failed: ${decodedPayload}`;
|
|
16
|
-
} else {
|
|
17
|
-
// If not, attach the payload to the original error
|
|
18
|
-
enrichedError.decodedAssertionPayload = decodedPayload;
|
|
19
|
-
}
|
|
20
|
-
} catch (_errorDecoding) {
|
|
21
|
-
// Ignore errors decoding the payload
|
|
22
|
-
}
|
|
23
|
-
return enrichedError;
|
|
24
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { FunctionCall } from '@aztec/stdlib/abi';
|
|
2
|
-
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
3
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import { PrivateExecutionResult, TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
5
|
-
import type { ExecutionDataProvider } from './execution_data_provider.js';
|
|
6
|
-
import type { SimulationProvider } from './providers/simulation_provider.js';
|
|
7
|
-
/**
|
|
8
|
-
* The ACIR simulator.
|
|
9
|
-
*/
|
|
10
|
-
export declare class AcirSimulator {
|
|
11
|
-
private executionDataProvider;
|
|
12
|
-
private simulationProvider;
|
|
13
|
-
private log;
|
|
14
|
-
constructor(executionDataProvider: ExecutionDataProvider, simulationProvider: SimulationProvider);
|
|
15
|
-
/**
|
|
16
|
-
* Runs a private function.
|
|
17
|
-
* @param request - The transaction request.
|
|
18
|
-
* @param entryPointArtifact - The artifact of the entry point function.
|
|
19
|
-
* @param contractAddress - The address of the contract (should match request.origin)
|
|
20
|
-
* @param msgSender - The address calling the function. This can be replaced to simulate a call from another contract or a specific account.
|
|
21
|
-
* @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
22
|
-
* @returns The result of the execution.
|
|
23
|
-
*/
|
|
24
|
-
run(request: TxExecutionRequest, contractAddress: AztecAddress, selector: FunctionSelector, msgSender?: AztecAddress, scopes?: AztecAddress[]): Promise<PrivateExecutionResult>;
|
|
25
|
-
/**
|
|
26
|
-
* Runs an unconstrained function.
|
|
27
|
-
* @param request - The transaction request.
|
|
28
|
-
* @param entryPointArtifact - The artifact of the entry point function.
|
|
29
|
-
* @param contractAddress - The address of the contract.
|
|
30
|
-
* @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
31
|
-
*/
|
|
32
|
-
runUnconstrained(request: FunctionCall, contractAddress: AztecAddress, selector: FunctionSelector, scopes?: AztecAddress[]): Promise<import("@aztec/stdlib/abi").AbiDecoded>;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=simulator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simulator.d.ts","sourceRoot":"","sources":["../../src/private/simulator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAgB,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAe,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAG3F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAK1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAI7E;;GAEG;AACH,qBAAa,aAAa;IAGZ,OAAO,CAAC,qBAAqB;IAAyB,OAAO,CAAC,kBAAkB;IAF5F,OAAO,CAAC,GAAG,CAAS;gBAEA,qBAAqB,EAAE,qBAAqB,EAAU,kBAAkB,EAAE,kBAAkB;IAIhH;;;;;;;;OAQG;IACU,GAAG,CACd,OAAO,EAAE,kBAAkB,EAC3B,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,eAA6C,EACtD,MAAM,CAAC,EAAE,YAAY,EAAE,GACtB,OAAO,CAAC,sBAAsB,CAAC;IA8DlC;;;;;;OAMG;IACU,gBAAgB,CAC3B,OAAO,EAAE,YAAY,EACrB,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,CAAC,EAAE,YAAY,EAAE;CA+B1B"}
|