@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,614 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MAX_FR_ARGS_TO_ALL_ENQUEUED_CALLS,
|
|
3
|
-
PRIVATE_CONTEXT_INPUTS_LENGTH,
|
|
4
|
-
PUBLIC_DISPATCH_SELECTOR,
|
|
5
|
-
} from '@aztec/constants';
|
|
6
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
7
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
8
|
-
import {
|
|
9
|
-
type FunctionAbi,
|
|
10
|
-
type FunctionArtifact,
|
|
11
|
-
FunctionSelector,
|
|
12
|
-
type NoteSelector,
|
|
13
|
-
countArgumentsSize,
|
|
14
|
-
} from '@aztec/stdlib/abi';
|
|
15
|
-
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
16
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
17
|
-
import { computeUniqueNoteHash, siloNoteHash } from '@aztec/stdlib/hash';
|
|
18
|
-
import { PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
19
|
-
import type { ContractClassLog } from '@aztec/stdlib/logs';
|
|
20
|
-
import { Note, type NoteStatus } from '@aztec/stdlib/note';
|
|
21
|
-
import {
|
|
22
|
-
type BlockHeader,
|
|
23
|
-
CallContext,
|
|
24
|
-
Capsule,
|
|
25
|
-
CountedContractClassLog,
|
|
26
|
-
CountedPublicExecutionRequest,
|
|
27
|
-
NoteAndSlot,
|
|
28
|
-
PrivateCallExecutionResult,
|
|
29
|
-
PublicExecutionRequest,
|
|
30
|
-
type TxContext,
|
|
31
|
-
} from '@aztec/stdlib/tx';
|
|
32
|
-
|
|
33
|
-
import { type NoteData, toACVMWitness } from './acvm/index.js';
|
|
34
|
-
import type { ExecutionDataProvider } from './execution_data_provider.js';
|
|
35
|
-
import type { ExecutionNoteCache } from './execution_note_cache.js';
|
|
36
|
-
import type { HashedValuesCache } from './hashed_values_cache.js';
|
|
37
|
-
import { pickNotes } from './pick_notes.js';
|
|
38
|
-
import { executePrivateFunction, verifyCurrentClassId } from './private_execution.js';
|
|
39
|
-
import type { SimulationProvider } from './providers/simulation_provider.js';
|
|
40
|
-
import { UnconstrainedExecutionOracle } from './unconstrained_execution_oracle.js';
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* The execution oracle for the private part of a transaction.
|
|
44
|
-
*/
|
|
45
|
-
export class PrivateExecutionOracle extends UnconstrainedExecutionOracle {
|
|
46
|
-
/**
|
|
47
|
-
* New notes created during this execution.
|
|
48
|
-
* 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.
|
|
49
|
-
* But we still include those notes in the execution result because their commitments are still in the public inputs of this execution.
|
|
50
|
-
* This information is only for references (currently used for tests), and is not used for any sort of constrains.
|
|
51
|
-
* Users can also use this to get a clearer idea of what's happened during a simulation.
|
|
52
|
-
*/
|
|
53
|
-
private newNotes: NoteAndSlot[] = [];
|
|
54
|
-
/**
|
|
55
|
-
* Notes from previous transactions that are returned to the oracle call `getNotes` during this execution.
|
|
56
|
-
* The mapping maps from the unique siloed note hash to the index for notes created in private executions.
|
|
57
|
-
* It maps from siloed note hash to the index for notes created by public functions.
|
|
58
|
-
*
|
|
59
|
-
* They are not part of the ExecutionNoteCache and being forwarded to nested contexts via `extend()`
|
|
60
|
-
* because these notes are meant to be maintained on a per-call basis
|
|
61
|
-
* They should act as references for the read requests output by an app circuit via public inputs.
|
|
62
|
-
*/
|
|
63
|
-
private noteHashLeafIndexMap: Map<bigint, bigint> = new Map();
|
|
64
|
-
private noteHashNullifierCounterMap: Map<number, number> = new Map();
|
|
65
|
-
private contractClassLogs: CountedContractClassLog[] = [];
|
|
66
|
-
private nestedExecutions: PrivateCallExecutionResult[] = [];
|
|
67
|
-
private enqueuedPublicFunctionCalls: CountedPublicExecutionRequest[] = [];
|
|
68
|
-
private publicTeardownFunctionCall: PublicExecutionRequest = PublicExecutionRequest.empty();
|
|
69
|
-
|
|
70
|
-
constructor(
|
|
71
|
-
private readonly argsHash: Fr,
|
|
72
|
-
private readonly txContext: TxContext,
|
|
73
|
-
private readonly callContext: CallContext,
|
|
74
|
-
/** Header of a block whose state is used during private execution (not the block the transaction is included in). */
|
|
75
|
-
protected readonly historicalHeader: BlockHeader,
|
|
76
|
-
/** List of transient auth witnesses to be used during this simulation */
|
|
77
|
-
authWitnesses: AuthWitness[],
|
|
78
|
-
capsules: Capsule[],
|
|
79
|
-
private readonly executionCache: HashedValuesCache,
|
|
80
|
-
private readonly noteCache: ExecutionNoteCache,
|
|
81
|
-
executionDataProvider: ExecutionDataProvider,
|
|
82
|
-
private provider: SimulationProvider,
|
|
83
|
-
private totalPublicArgsCount: number,
|
|
84
|
-
protected sideEffectCounter: number = 0,
|
|
85
|
-
log = createLogger('simulator:client_execution_context'),
|
|
86
|
-
scopes?: AztecAddress[],
|
|
87
|
-
) {
|
|
88
|
-
super(callContext.contractAddress, authWitnesses, capsules, executionDataProvider, log, scopes);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// We still need this function until we can get user-defined ordering of structs for fn arguments
|
|
92
|
-
// TODO When that is sorted out on noir side, we can use instead the utilities in serialize.ts
|
|
93
|
-
/**
|
|
94
|
-
* Writes the function inputs to the initial witness.
|
|
95
|
-
* @param abi - The function ABI.
|
|
96
|
-
* @returns The initial witness.
|
|
97
|
-
*/
|
|
98
|
-
public getInitialWitness(abi: FunctionAbi) {
|
|
99
|
-
const argumentsSize = countArgumentsSize(abi);
|
|
100
|
-
|
|
101
|
-
const args = this.executionCache.getPreimage(this.argsHash);
|
|
102
|
-
|
|
103
|
-
if (args.length !== argumentsSize) {
|
|
104
|
-
throw new Error(`Invalid arguments size: expected ${argumentsSize}, got ${args.length}`);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const privateContextInputs = new PrivateContextInputs(
|
|
108
|
-
this.callContext,
|
|
109
|
-
this.historicalHeader,
|
|
110
|
-
this.txContext,
|
|
111
|
-
this.sideEffectCounter,
|
|
112
|
-
);
|
|
113
|
-
const privateContextInputsAsFields = privateContextInputs.toFields();
|
|
114
|
-
if (privateContextInputsAsFields.length !== PRIVATE_CONTEXT_INPUTS_LENGTH) {
|
|
115
|
-
throw new Error('Invalid private context inputs size');
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const fields = [...privateContextInputsAsFields, ...args];
|
|
119
|
-
return toACVMWitness(0, fields);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* The KernelProver will use this to fully populate witnesses and provide hints to the kernel circuit
|
|
124
|
-
* regarding which note hash each settled read request corresponds to.
|
|
125
|
-
*/
|
|
126
|
-
public getNoteHashLeafIndexMap() {
|
|
127
|
-
return this.noteHashLeafIndexMap;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Get the data for the newly created notes.
|
|
132
|
-
*/
|
|
133
|
-
public getNewNotes(): NoteAndSlot[] {
|
|
134
|
-
return this.newNotes;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
public getNoteHashNullifierCounterMap() {
|
|
138
|
-
return this.noteHashNullifierCounterMap;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Return the contract class logs emitted during this execution.
|
|
143
|
-
*/
|
|
144
|
-
public getContractClassLogs() {
|
|
145
|
-
return this.contractClassLogs;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Return the nested execution results during this execution.
|
|
150
|
-
*/
|
|
151
|
-
public getNestedExecutions() {
|
|
152
|
-
return this.nestedExecutions;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Return the enqueued public function calls during this execution.
|
|
157
|
-
*/
|
|
158
|
-
public getEnqueuedPublicFunctionCalls() {
|
|
159
|
-
return this.enqueuedPublicFunctionCalls;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Return the public teardown function call set during this execution.
|
|
164
|
-
*/
|
|
165
|
-
public getPublicTeardownFunctionCall() {
|
|
166
|
-
return this.publicTeardownFunctionCall;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Store values in the execution cache.
|
|
171
|
-
* @param values - Values to store.
|
|
172
|
-
* @returns The hash of the values.
|
|
173
|
-
*/
|
|
174
|
-
public override storeInExecutionCache(values: Fr[]): Promise<Fr> {
|
|
175
|
-
return this.executionCache.store(values);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Gets values from the execution cache.
|
|
180
|
-
* @param hash - Hash of the values.
|
|
181
|
-
* @returns The values.
|
|
182
|
-
*/
|
|
183
|
-
public override loadFromExecutionCache(hash: Fr): Promise<Fr[]> {
|
|
184
|
-
return Promise.resolve(this.executionCache.getPreimage(hash));
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Gets some notes for a storage slot.
|
|
189
|
-
*
|
|
190
|
-
* @remarks
|
|
191
|
-
* Check for pending notes with matching slot.
|
|
192
|
-
* Real notes coming from DB will have a leafIndex which
|
|
193
|
-
* represents their index in the note hash tree.
|
|
194
|
-
*
|
|
195
|
-
* @param storageSlot - The storage slot.
|
|
196
|
-
* @param numSelects - The number of valid selects in selectBy and selectValues.
|
|
197
|
-
* @param selectBy - An array of indices of the fields to selects.
|
|
198
|
-
* @param selectValues - The values to match.
|
|
199
|
-
* @param selectComparators - The comparators to match by.
|
|
200
|
-
* @param sortBy - An array of indices of the fields to sort.
|
|
201
|
-
* @param sortOrder - The order of the corresponding index in sortBy. (1: DESC, 2: ASC, 0: Do nothing)
|
|
202
|
-
* @param limit - The number of notes to retrieve per query.
|
|
203
|
-
* @param offset - The starting index for pagination.
|
|
204
|
-
* @param status - The status of notes to fetch.
|
|
205
|
-
* @returns Array of note data.
|
|
206
|
-
*/
|
|
207
|
-
public override async getNotes(
|
|
208
|
-
storageSlot: Fr,
|
|
209
|
-
numSelects: number,
|
|
210
|
-
selectByIndexes: number[],
|
|
211
|
-
selectByOffsets: number[],
|
|
212
|
-
selectByLengths: number[],
|
|
213
|
-
selectValues: Fr[],
|
|
214
|
-
selectComparators: number[],
|
|
215
|
-
sortByIndexes: number[],
|
|
216
|
-
sortByOffsets: number[],
|
|
217
|
-
sortByLengths: number[],
|
|
218
|
-
sortOrder: number[],
|
|
219
|
-
limit: number,
|
|
220
|
-
offset: number,
|
|
221
|
-
status: NoteStatus,
|
|
222
|
-
): Promise<NoteData[]> {
|
|
223
|
-
// Nullified pending notes are already removed from the list.
|
|
224
|
-
const pendingNotes = this.noteCache.getNotes(this.callContext.contractAddress, storageSlot);
|
|
225
|
-
|
|
226
|
-
const pendingNullifiers = this.noteCache.getNullifiers(this.callContext.contractAddress);
|
|
227
|
-
const dbNotes = await this.executionDataProvider.getNotes(
|
|
228
|
-
this.callContext.contractAddress,
|
|
229
|
-
storageSlot,
|
|
230
|
-
status,
|
|
231
|
-
this.scopes,
|
|
232
|
-
);
|
|
233
|
-
const dbNotesFiltered = dbNotes.filter(n => !pendingNullifiers.has((n.siloedNullifier as Fr).value));
|
|
234
|
-
|
|
235
|
-
const notes = pickNotes<NoteData>([...dbNotesFiltered, ...pendingNotes], {
|
|
236
|
-
selects: selectByIndexes.slice(0, numSelects).map((index, i) => ({
|
|
237
|
-
selector: { index, offset: selectByOffsets[i], length: selectByLengths[i] },
|
|
238
|
-
value: selectValues[i],
|
|
239
|
-
comparator: selectComparators[i],
|
|
240
|
-
})),
|
|
241
|
-
sorts: sortByIndexes.map((index, i) => ({
|
|
242
|
-
selector: { index, offset: sortByOffsets[i], length: sortByLengths[i] },
|
|
243
|
-
order: sortOrder[i],
|
|
244
|
-
})),
|
|
245
|
-
limit,
|
|
246
|
-
offset,
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
this.log.debug(
|
|
250
|
-
`Returning ${notes.length} notes for ${this.callContext.contractAddress} at ${storageSlot}: ${notes
|
|
251
|
-
.map(n => `${n.nonce.toString()}:[${n.note.items.map(i => i.toString()).join(',')}]`)
|
|
252
|
-
.join(', ')}`,
|
|
253
|
-
);
|
|
254
|
-
|
|
255
|
-
const noteHashesAndIndexes = await Promise.all(
|
|
256
|
-
notes.map(async n => {
|
|
257
|
-
if (n.index !== undefined) {
|
|
258
|
-
const siloedNoteHash = await siloNoteHash(n.contractAddress, n.noteHash);
|
|
259
|
-
const uniqueNoteHash = await computeUniqueNoteHash(n.nonce, siloedNoteHash);
|
|
260
|
-
|
|
261
|
-
return { hash: uniqueNoteHash, index: n.index };
|
|
262
|
-
}
|
|
263
|
-
}),
|
|
264
|
-
);
|
|
265
|
-
|
|
266
|
-
noteHashesAndIndexes
|
|
267
|
-
.filter(n => n !== undefined)
|
|
268
|
-
.forEach(n => {
|
|
269
|
-
this.noteHashLeafIndexMap.set(n!.hash.toBigInt(), n!.index);
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
return notes;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Keep track of the new note created during execution.
|
|
277
|
-
* It can be used in subsequent calls (or transactions when chaining txs is possible).
|
|
278
|
-
* @param contractAddress - The contract address.
|
|
279
|
-
* @param storageSlot - The storage slot.
|
|
280
|
-
* @param noteTypeId - The type ID of the note.
|
|
281
|
-
* @param noteItems - The items to be included in a Note.
|
|
282
|
-
* @param noteHash - A hash of the new note.
|
|
283
|
-
* @returns
|
|
284
|
-
*/
|
|
285
|
-
public override notifyCreatedNote(
|
|
286
|
-
storageSlot: Fr,
|
|
287
|
-
noteTypeId: NoteSelector,
|
|
288
|
-
noteItems: Fr[],
|
|
289
|
-
noteHash: Fr,
|
|
290
|
-
counter: number,
|
|
291
|
-
) {
|
|
292
|
-
this.log.debug(`Notified of new note with inner hash ${noteHash}`, {
|
|
293
|
-
contractAddress: this.callContext.contractAddress,
|
|
294
|
-
storageSlot,
|
|
295
|
-
noteTypeId,
|
|
296
|
-
counter,
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
const note = new Note(noteItems);
|
|
300
|
-
this.noteCache.addNewNote(
|
|
301
|
-
{
|
|
302
|
-
contractAddress: this.callContext.contractAddress,
|
|
303
|
-
storageSlot,
|
|
304
|
-
nonce: Fr.ZERO, // Nonce cannot be known during private execution.
|
|
305
|
-
note,
|
|
306
|
-
siloedNullifier: undefined, // Siloed nullifier cannot be known for newly created note.
|
|
307
|
-
noteHash,
|
|
308
|
-
},
|
|
309
|
-
counter,
|
|
310
|
-
);
|
|
311
|
-
this.newNotes.push(new NoteAndSlot(note, storageSlot, noteTypeId));
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* Adding a siloed nullifier into the current set of all pending nullifiers created
|
|
316
|
-
* within the current transaction/execution.
|
|
317
|
-
* @param innerNullifier - The pending nullifier to add in the list (not yet siloed by contract address).
|
|
318
|
-
* @param noteHash - A hash of the new note.
|
|
319
|
-
*/
|
|
320
|
-
public override async notifyNullifiedNote(innerNullifier: Fr, noteHash: Fr, counter: number) {
|
|
321
|
-
const nullifiedNoteHashCounter = await this.noteCache.nullifyNote(
|
|
322
|
-
this.callContext.contractAddress,
|
|
323
|
-
innerNullifier,
|
|
324
|
-
noteHash,
|
|
325
|
-
);
|
|
326
|
-
if (nullifiedNoteHashCounter !== undefined) {
|
|
327
|
-
this.noteHashNullifierCounterMap.set(nullifiedNoteHashCounter, counter);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Adding a siloed nullifier into the current set of all pending nullifiers created
|
|
333
|
-
* within the current transaction/execution.
|
|
334
|
-
* @param innerNullifier - The pending nullifier to add in the list (not yet siloed by contract address).
|
|
335
|
-
* @param noteHash - A hash of the new note.
|
|
336
|
-
*/
|
|
337
|
-
public override notifyCreatedNullifier(innerNullifier: Fr) {
|
|
338
|
-
return this.noteCache.nullifierCreated(this.callContext.contractAddress, innerNullifier);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
/**
|
|
342
|
-
* Emit a contract class log.
|
|
343
|
-
* This fn exists because we only carry a poseidon hash through the kernels, and need to
|
|
344
|
-
* keep the preimage in ts for later.
|
|
345
|
-
* @param log - The contract class log to be emitted.
|
|
346
|
-
* @param counter - The contract class log's counter.
|
|
347
|
-
*/
|
|
348
|
-
public override notifyCreatedContractClassLog(log: ContractClassLog, counter: number) {
|
|
349
|
-
this.contractClassLogs.push(new CountedContractClassLog(log, counter));
|
|
350
|
-
const text = log.toBuffer().toString('hex');
|
|
351
|
-
this.log.verbose(
|
|
352
|
-
`Emitted log from ContractClassRegisterer: "${text.length > 100 ? text.slice(0, 100) + '...' : text}"`,
|
|
353
|
-
);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
#checkValidStaticCall(childExecutionResult: PrivateCallExecutionResult) {
|
|
357
|
-
if (
|
|
358
|
-
childExecutionResult.publicInputs.noteHashes.some(item => !item.isEmpty()) ||
|
|
359
|
-
childExecutionResult.publicInputs.nullifiers.some(item => !item.isEmpty()) ||
|
|
360
|
-
childExecutionResult.publicInputs.l2ToL1Msgs.some(item => !item.isEmpty()) ||
|
|
361
|
-
childExecutionResult.publicInputs.privateLogs.some(item => !item.isEmpty()) ||
|
|
362
|
-
childExecutionResult.publicInputs.contractClassLogsHashes.some(item => !item.isEmpty())
|
|
363
|
-
) {
|
|
364
|
-
throw new Error(`Static call cannot update the state, emit L2->L1 messages or generate logs`);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* Calls a private function as a nested execution.
|
|
370
|
-
* @param targetContractAddress - The address of the contract to call.
|
|
371
|
-
* @param functionSelector - The function selector of the function to call.
|
|
372
|
-
* @param argsHash - The arguments hash to pass to the function.
|
|
373
|
-
* @param sideEffectCounter - The side effect counter at the start of the call.
|
|
374
|
-
* @param isStaticCall - Whether the call is a static call.
|
|
375
|
-
* @returns The execution result.
|
|
376
|
-
*/
|
|
377
|
-
override async callPrivateFunction(
|
|
378
|
-
targetContractAddress: AztecAddress,
|
|
379
|
-
functionSelector: FunctionSelector,
|
|
380
|
-
argsHash: Fr,
|
|
381
|
-
sideEffectCounter: number,
|
|
382
|
-
isStaticCall: boolean,
|
|
383
|
-
) {
|
|
384
|
-
this.log.debug(
|
|
385
|
-
`Calling private function ${targetContractAddress}:${functionSelector} from ${this.callContext.contractAddress}`,
|
|
386
|
-
);
|
|
387
|
-
|
|
388
|
-
isStaticCall = isStaticCall || this.callContext.isStaticCall;
|
|
389
|
-
|
|
390
|
-
await verifyCurrentClassId(
|
|
391
|
-
targetContractAddress,
|
|
392
|
-
this.executionDataProvider,
|
|
393
|
-
this.historicalHeader.globalVariables.blockNumber.toNumber(),
|
|
394
|
-
);
|
|
395
|
-
|
|
396
|
-
const targetArtifact = await this.executionDataProvider.getFunctionArtifact(
|
|
397
|
-
targetContractAddress,
|
|
398
|
-
functionSelector,
|
|
399
|
-
);
|
|
400
|
-
|
|
401
|
-
const derivedTxContext = this.txContext.clone();
|
|
402
|
-
|
|
403
|
-
const derivedCallContext = await this.deriveCallContext(targetContractAddress, targetArtifact, isStaticCall);
|
|
404
|
-
|
|
405
|
-
const context = new PrivateExecutionOracle(
|
|
406
|
-
argsHash,
|
|
407
|
-
derivedTxContext,
|
|
408
|
-
derivedCallContext,
|
|
409
|
-
this.historicalHeader,
|
|
410
|
-
this.authWitnesses,
|
|
411
|
-
this.capsules,
|
|
412
|
-
this.executionCache,
|
|
413
|
-
this.noteCache,
|
|
414
|
-
this.executionDataProvider,
|
|
415
|
-
this.provider,
|
|
416
|
-
this.totalPublicArgsCount,
|
|
417
|
-
sideEffectCounter,
|
|
418
|
-
this.log,
|
|
419
|
-
this.scopes,
|
|
420
|
-
);
|
|
421
|
-
|
|
422
|
-
const childExecutionResult = await executePrivateFunction(
|
|
423
|
-
this.provider,
|
|
424
|
-
context,
|
|
425
|
-
targetArtifact,
|
|
426
|
-
targetContractAddress,
|
|
427
|
-
functionSelector,
|
|
428
|
-
);
|
|
429
|
-
|
|
430
|
-
if (isStaticCall) {
|
|
431
|
-
this.#checkValidStaticCall(childExecutionResult);
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
this.nestedExecutions.push(childExecutionResult);
|
|
435
|
-
|
|
436
|
-
const publicInputs = childExecutionResult.publicInputs;
|
|
437
|
-
return {
|
|
438
|
-
endSideEffectCounter: publicInputs.endSideEffectCounter,
|
|
439
|
-
returnsHash: publicInputs.returnsHash,
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* Creates a PublicExecutionRequest object representing the request to call a public function.
|
|
445
|
-
* @param targetContractAddress - The address of the contract to call.
|
|
446
|
-
* @param functionSelector - The function selector of the function to call.
|
|
447
|
-
* @param argsHash - The arguments hash to pass to the function.
|
|
448
|
-
* @param sideEffectCounter - The side effect counter at the start of the call.
|
|
449
|
-
* @param isStaticCall - Whether the call is a static call.
|
|
450
|
-
* @returns The public call stack item with the request information.
|
|
451
|
-
*/
|
|
452
|
-
protected async createPublicExecutionRequest(
|
|
453
|
-
callType: 'enqueued' | 'teardown',
|
|
454
|
-
targetContractAddress: AztecAddress,
|
|
455
|
-
functionSelector: FunctionSelector,
|
|
456
|
-
argsHash: Fr,
|
|
457
|
-
sideEffectCounter: number,
|
|
458
|
-
isStaticCall: boolean,
|
|
459
|
-
) {
|
|
460
|
-
const targetArtifact = await this.executionDataProvider.getFunctionArtifact(
|
|
461
|
-
targetContractAddress,
|
|
462
|
-
functionSelector,
|
|
463
|
-
);
|
|
464
|
-
const derivedCallContext = await this.deriveCallContext(targetContractAddress, targetArtifact, isStaticCall);
|
|
465
|
-
const args = this.executionCache.getPreimage(argsHash);
|
|
466
|
-
|
|
467
|
-
this.log.verbose(
|
|
468
|
-
`Created ${callType} public execution request to ${targetArtifact.name}@${targetContractAddress}`,
|
|
469
|
-
{
|
|
470
|
-
sideEffectCounter,
|
|
471
|
-
isStaticCall,
|
|
472
|
-
functionSelector,
|
|
473
|
-
targetContractAddress,
|
|
474
|
-
callType,
|
|
475
|
-
},
|
|
476
|
-
);
|
|
477
|
-
|
|
478
|
-
const request = PublicExecutionRequest.from({
|
|
479
|
-
args,
|
|
480
|
-
callContext: derivedCallContext,
|
|
481
|
-
});
|
|
482
|
-
|
|
483
|
-
if (callType === 'enqueued') {
|
|
484
|
-
this.enqueuedPublicFunctionCalls.push(new CountedPublicExecutionRequest(request, sideEffectCounter));
|
|
485
|
-
} else {
|
|
486
|
-
this.publicTeardownFunctionCall = request;
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
/**
|
|
491
|
-
* Creates and enqueues a PublicExecutionRequest object representing the request to call a public function. No function
|
|
492
|
-
* is actually called, since that must happen on the sequencer side. All the fields related to the result
|
|
493
|
-
* of the execution are empty.
|
|
494
|
-
* @param targetContractAddress - The address of the contract to call.
|
|
495
|
-
* @param functionSelector - The function selector of the function to call.
|
|
496
|
-
* @param argsHash - The arguments hash to pass to the function.
|
|
497
|
-
* @param sideEffectCounter - The side effect counter at the start of the call.
|
|
498
|
-
* @param isStaticCall - Whether the call is a static call.
|
|
499
|
-
* @returns The public call stack item with the request information.
|
|
500
|
-
*/
|
|
501
|
-
public override async enqueuePublicFunctionCall(
|
|
502
|
-
targetContractAddress: AztecAddress,
|
|
503
|
-
functionSelector: FunctionSelector,
|
|
504
|
-
argsHash: Fr,
|
|
505
|
-
sideEffectCounter: number,
|
|
506
|
-
isStaticCall: boolean,
|
|
507
|
-
): Promise<Fr> {
|
|
508
|
-
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/8985): Fix this.
|
|
509
|
-
// WARNING: This is insecure and should be temporary!
|
|
510
|
-
// The oracle re-hashes the arguments and returns a new args_hash.
|
|
511
|
-
// new_args = [selector, ...old_args], so as to make it suitable to call the public dispatch function.
|
|
512
|
-
// We don't validate or compute it in the circuit because a) it's harder to do with slices, and
|
|
513
|
-
// b) this is only temporary.
|
|
514
|
-
const newArgs = [functionSelector.toField(), ...this.executionCache.getPreimage(argsHash)];
|
|
515
|
-
const newArgsHash = await this.executionCache.store(newArgs);
|
|
516
|
-
await this.createPublicExecutionRequest(
|
|
517
|
-
'enqueued',
|
|
518
|
-
targetContractAddress,
|
|
519
|
-
FunctionSelector.fromField(new Fr(PUBLIC_DISPATCH_SELECTOR)),
|
|
520
|
-
newArgsHash,
|
|
521
|
-
sideEffectCounter,
|
|
522
|
-
isStaticCall,
|
|
523
|
-
);
|
|
524
|
-
this.totalPublicArgsCount += newArgs.length;
|
|
525
|
-
if (this.totalPublicArgsCount > MAX_FR_ARGS_TO_ALL_ENQUEUED_CALLS) {
|
|
526
|
-
throw new Error(`Too many total args to all enqueued public calls! (> ${MAX_FR_ARGS_TO_ALL_ENQUEUED_CALLS})`);
|
|
527
|
-
}
|
|
528
|
-
return newArgsHash;
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
/**
|
|
532
|
-
* Creates a PublicExecutionRequest and sets it as the public teardown function. No function
|
|
533
|
-
* is actually called, since that must happen on the sequencer side. All the fields related to the result
|
|
534
|
-
* of the execution are empty.
|
|
535
|
-
* @param targetContractAddress - The address of the contract to call.
|
|
536
|
-
* @param functionSelector - The function selector of the function to call.
|
|
537
|
-
* @param argsHash - The arguments hash to pass to the function.
|
|
538
|
-
* @param sideEffectCounter - The side effect counter at the start of the call.
|
|
539
|
-
* @param isStaticCall - Whether the call is a static call.
|
|
540
|
-
* @returns The public call stack item with the request information.
|
|
541
|
-
*/
|
|
542
|
-
public override async setPublicTeardownFunctionCall(
|
|
543
|
-
targetContractAddress: AztecAddress,
|
|
544
|
-
functionSelector: FunctionSelector,
|
|
545
|
-
argsHash: Fr,
|
|
546
|
-
sideEffectCounter: number,
|
|
547
|
-
isStaticCall: boolean,
|
|
548
|
-
): Promise<Fr> {
|
|
549
|
-
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/8985): Fix this.
|
|
550
|
-
// WARNING: This is insecure and should be temporary!
|
|
551
|
-
// The oracle rehashes the arguments and returns a new args_hash.
|
|
552
|
-
// new_args = [selector, ...old_args], so as to make it suitable to call the public dispatch function.
|
|
553
|
-
// We don't validate or compute it in the circuit because a) it's harder to do with slices, and
|
|
554
|
-
// b) this is only temporary.
|
|
555
|
-
const newArgsHash = await this.executionCache.store([
|
|
556
|
-
functionSelector.toField(),
|
|
557
|
-
...this.executionCache.getPreimage(argsHash),
|
|
558
|
-
]);
|
|
559
|
-
await this.createPublicExecutionRequest(
|
|
560
|
-
'teardown',
|
|
561
|
-
targetContractAddress,
|
|
562
|
-
FunctionSelector.fromField(new Fr(PUBLIC_DISPATCH_SELECTOR)),
|
|
563
|
-
newArgsHash,
|
|
564
|
-
sideEffectCounter,
|
|
565
|
-
isStaticCall,
|
|
566
|
-
);
|
|
567
|
-
return newArgsHash;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
public override notifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: number): Promise<void> {
|
|
571
|
-
return this.noteCache.setMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter);
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
/**
|
|
575
|
-
* Derives the call context for a nested execution.
|
|
576
|
-
* @param targetContractAddress - The address of the contract being called.
|
|
577
|
-
* @param targetArtifact - The artifact of the function being called.
|
|
578
|
-
* @param isStaticCall - Whether the call is a static call.
|
|
579
|
-
* @returns The derived call context.
|
|
580
|
-
*/
|
|
581
|
-
private async deriveCallContext(
|
|
582
|
-
targetContractAddress: AztecAddress,
|
|
583
|
-
targetArtifact: FunctionArtifact,
|
|
584
|
-
isStaticCall = false,
|
|
585
|
-
) {
|
|
586
|
-
return new CallContext(
|
|
587
|
-
this.contractAddress,
|
|
588
|
-
targetContractAddress,
|
|
589
|
-
await FunctionSelector.fromNameAndParameters(targetArtifact.name, targetArtifact.parameters),
|
|
590
|
-
isStaticCall,
|
|
591
|
-
);
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
public getDebugFunctionName() {
|
|
595
|
-
return this.executionDataProvider.getDebugFunctionName(this.contractAddress, this.callContext.functionSelector);
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
public override async incrementAppTaggingSecretIndexAsSender(sender: AztecAddress, recipient: AztecAddress) {
|
|
599
|
-
await this.executionDataProvider.incrementAppTaggingSecretIndexAsSender(this.contractAddress, sender, recipient);
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
public override async syncNotes() {
|
|
603
|
-
const taggedLogsByRecipient = await this.executionDataProvider.syncTaggedLogs(
|
|
604
|
-
this.contractAddress,
|
|
605
|
-
this.historicalHeader.globalVariables.blockNumber.toNumber(),
|
|
606
|
-
this.scopes,
|
|
607
|
-
);
|
|
608
|
-
for (const [recipient, taggedLogs] of taggedLogsByRecipient.entries()) {
|
|
609
|
-
await this.executionDataProvider.processTaggedLogs(taggedLogs, AztecAddress.fromString(recipient));
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
await this.executionDataProvider.removeNullifiedNotes(this.contractAddress);
|
|
613
|
-
}
|
|
614
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { foreignCallHandler } from '@aztec/noir-protocol-circuits-types/client';
|
|
3
|
-
import type { NoirCompiledCircuit } from '@aztec/stdlib/noir';
|
|
4
|
-
|
|
5
|
-
import initACVM, { type ExecutionError, executeCircuit } from '@noir-lang/acvm_js';
|
|
6
|
-
import initAbi from '@noir-lang/noirc_abi';
|
|
7
|
-
import type { WitnessMap } from '@noir-lang/types';
|
|
8
|
-
|
|
9
|
-
import { type ACIRCallback, acvm } from '../acvm/acvm.js';
|
|
10
|
-
import type { ACVMWitness } from '../acvm/acvm_types.js';
|
|
11
|
-
import { type SimulationProvider, parseErrorPayload } from './simulation_provider.js';
|
|
12
|
-
|
|
13
|
-
export class WASMSimulator implements SimulationProvider {
|
|
14
|
-
constructor(protected log = createLogger('wasm-simulator')) {}
|
|
15
|
-
|
|
16
|
-
async init(): Promise<void> {
|
|
17
|
-
// If these are available, then we are in the
|
|
18
|
-
// web environment. For the node environment, this
|
|
19
|
-
// is a no-op.
|
|
20
|
-
if (typeof initAbi === 'function') {
|
|
21
|
-
/** @ts-expect-error The node bundle doesn't include these default imports, so TS complains */
|
|
22
|
-
await Promise.all([initAbi(), initACVM()]);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async executeProtocolCircuit(input: WitnessMap, compiledCircuit: NoirCompiledCircuit): Promise<WitnessMap> {
|
|
27
|
-
this.log.debug('init', { hash: compiledCircuit.hash });
|
|
28
|
-
await this.init();
|
|
29
|
-
// Execute the circuit on those initial witness values
|
|
30
|
-
//
|
|
31
|
-
// Decode the bytecode from base64 since the acvm does not know about base64 encoding
|
|
32
|
-
const decodedBytecode = Buffer.from(compiledCircuit.bytecode, 'base64');
|
|
33
|
-
//
|
|
34
|
-
// Execute the circuit
|
|
35
|
-
try {
|
|
36
|
-
const _witnessMap = await executeCircuit(
|
|
37
|
-
decodedBytecode,
|
|
38
|
-
input,
|
|
39
|
-
foreignCallHandler, // handle calls to debug_log
|
|
40
|
-
);
|
|
41
|
-
this.log.debug('execution successful', { hash: compiledCircuit.hash });
|
|
42
|
-
return _witnessMap;
|
|
43
|
-
} catch (err) {
|
|
44
|
-
// Typescript types catched errors as unknown or any, so we need to narrow its type to check if it has raw assertion payload.
|
|
45
|
-
if (typeof err === 'object' && err !== null && 'rawAssertionPayload' in err) {
|
|
46
|
-
const parsed = parseErrorPayload(compiledCircuit.abi, err as ExecutionError);
|
|
47
|
-
this.log.debug('execution failed', {
|
|
48
|
-
hash: compiledCircuit.hash,
|
|
49
|
-
error: parsed,
|
|
50
|
-
message: parsed.message,
|
|
51
|
-
});
|
|
52
|
-
throw parsed;
|
|
53
|
-
}
|
|
54
|
-
this.log.debug('execution failed', { hash: compiledCircuit.hash, error: err });
|
|
55
|
-
throw new Error(`Circuit execution failed: ${err}`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async executeUserCircuit(acir: Buffer, initialWitness: ACVMWitness, callback: ACIRCallback) {
|
|
60
|
-
await this.init();
|
|
61
|
-
return acvm(acir, initialWitness, callback);
|
|
62
|
-
}
|
|
63
|
-
}
|