@aztec/simulator 0.0.0-test.0
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 +49 -0
- package/dest/client.d.ts +5 -0
- package/dest/client.d.ts.map +1 -0
- package/dest/client.js +3 -0
- package/dest/common/db_interfaces.d.ts +80 -0
- package/dest/common/db_interfaces.d.ts.map +1 -0
- package/dest/common/db_interfaces.js +1 -0
- package/dest/common/debug_fn_name.d.ts +5 -0
- package/dest/common/debug_fn_name.d.ts.map +1 -0
- package/dest/common/debug_fn_name.js +6 -0
- package/dest/common/errors.d.ts +54 -0
- package/dest/common/errors.d.ts.map +1 -0
- package/dest/common/errors.js +135 -0
- package/dest/common/index.d.ts +4 -0
- package/dest/common/index.d.ts.map +1 -0
- package/dest/common/index.js +3 -0
- package/dest/common/message_load_oracle_inputs.d.ts +15 -0
- package/dest/common/message_load_oracle_inputs.d.ts.map +1 -0
- package/dest/common/message_load_oracle_inputs.js +15 -0
- package/dest/common/stats/index.d.ts +2 -0
- package/dest/common/stats/index.d.ts.map +1 -0
- package/dest/common/stats/index.js +1 -0
- package/dest/common/stats/stats.d.ts +4 -0
- package/dest/common/stats/stats.d.ts.map +1 -0
- package/dest/common/stats/stats.js +10 -0
- package/dest/private/acvm/acvm.d.ts +35 -0
- package/dest/private/acvm/acvm.d.ts.map +1 -0
- package/dest/private/acvm/acvm.js +70 -0
- package/dest/private/acvm/acvm_types.d.ts +10 -0
- package/dest/private/acvm/acvm_types.d.ts.map +1 -0
- package/dest/private/acvm/acvm_types.js +3 -0
- package/dest/private/acvm/deserialize.d.ts +36 -0
- package/dest/private/acvm/deserialize.d.ts.map +1 -0
- package/dest/private/acvm/deserialize.js +42 -0
- package/dest/private/acvm/index.d.ts +6 -0
- package/dest/private/acvm/index.d.ts.map +1 -0
- package/dest/private/acvm/index.js +5 -0
- package/dest/private/acvm/oracle/index.d.ts +14 -0
- package/dest/private/acvm/oracle/index.d.ts.map +1 -0
- package/dest/private/acvm/oracle/index.js +2 -0
- package/dest/private/acvm/oracle/oracle.d.ts +49 -0
- package/dest/private/acvm/oracle/oracle.d.ts.map +1 -0
- package/dest/private/acvm/oracle/oracle.js +263 -0
- package/dest/private/acvm/oracle/typed_oracle.d.ts +83 -0
- package/dest/private/acvm/oracle/typed_oracle.d.ts.map +1 -0
- package/dest/private/acvm/oracle/typed_oracle.js +132 -0
- package/dest/private/acvm/serialize.d.ts +24 -0
- package/dest/private/acvm/serialize.d.ts.map +1 -0
- package/dest/private/acvm/serialize.js +46 -0
- package/dest/private/execution_data_provider.d.ts +261 -0
- package/dest/private/execution_data_provider.d.ts.map +1 -0
- package/dest/private/execution_data_provider.js +14 -0
- package/dest/private/execution_note_cache.d.ts +93 -0
- package/dest/private/execution_note_cache.d.ts.map +1 -0
- package/dest/private/execution_note_cache.js +180 -0
- package/dest/private/hashed_values_cache.d.ts +28 -0
- package/dest/private/hashed_values_cache.d.ts.map +1 -0
- package/dest/private/hashed_values_cache.js +46 -0
- package/dest/private/index.d.ts +13 -0
- package/dest/private/index.d.ts.map +1 -0
- package/dest/private/index.js +12 -0
- package/dest/private/pick_notes.d.ts +85 -0
- package/dest/private/pick_notes.d.ts.map +1 -0
- package/dest/private/pick_notes.js +51 -0
- package/dest/private/private_execution.d.ts +25 -0
- package/dest/private/private_execution.d.ts.map +1 -0
- package/dest/private/private_execution.js +92 -0
- package/dest/private/private_execution_oracle.d.ts +215 -0
- package/dest/private/private_execution_oracle.d.ts.map +1 -0
- package/dest/private/private_execution_oracle.js +382 -0
- package/dest/private/providers/acvm_native.d.ts +40 -0
- package/dest/private/providers/acvm_native.d.ts.map +1 -0
- package/dest/private/providers/acvm_native.js +139 -0
- package/dest/private/providers/acvm_wasm.d.ts +15 -0
- package/dest/private/providers/acvm_wasm.d.ts.map +1 -0
- package/dest/private/providers/acvm_wasm.js +62 -0
- package/dest/private/providers/acvm_wasm_with_blobs.d.ts +19 -0
- package/dest/private/providers/acvm_wasm_with_blobs.d.ts.map +1 -0
- package/dest/private/providers/acvm_wasm_with_blobs.js +32 -0
- package/dest/private/providers/factory.d.ts +12 -0
- package/dest/private/providers/factory.d.ts.map +1 -0
- package/dest/private/providers/factory.js +27 -0
- package/dest/private/providers/simulation_provider.d.ts +19 -0
- package/dest/private/providers/simulation_provider.d.ts.map +1 -0
- package/dest/private/providers/simulation_provider.js +24 -0
- package/dest/private/simulator.d.ts +34 -0
- package/dest/private/simulator.d.ts.map +1 -0
- package/dest/private/simulator.js +76 -0
- package/dest/private/unconstrained_execution.d.ts +10 -0
- package/dest/private/unconstrained_execution.d.ts.map +1 -0
- package/dest/private/unconstrained_execution.js +27 -0
- package/dest/private/unconstrained_execution_oracle.d.ts +161 -0
- package/dest/private/unconstrained_execution_oracle.d.ts.map +1 -0
- package/dest/private/unconstrained_execution_oracle.js +258 -0
- package/dest/public/avm/avm_context.d.ts +41 -0
- package/dest/public/avm/avm_context.d.ts.map +1 -0
- package/dest/public/avm/avm_context.js +44 -0
- package/dest/public/avm/avm_contract_call_result.d.ts +30 -0
- package/dest/public/avm/avm_contract_call_result.d.ts.map +1 -0
- package/dest/public/avm/avm_contract_call_result.js +50 -0
- package/dest/public/avm/avm_execution_environment.d.ts +21 -0
- package/dest/public/avm/avm_execution_environment.d.ts.map +1 -0
- package/dest/public/avm/avm_execution_environment.js +31 -0
- package/dest/public/avm/avm_gas.d.ts +60 -0
- package/dest/public/avm/avm_gas.d.ts.map +1 -0
- package/dest/public/avm/avm_gas.js +203 -0
- package/dest/public/avm/avm_machine_state.d.ts +95 -0
- package/dest/public/avm/avm_machine_state.d.ts.map +1 -0
- package/dest/public/avm/avm_machine_state.js +107 -0
- package/dest/public/avm/avm_memory_types.d.ts +264 -0
- package/dest/public/avm/avm_memory_types.d.ts.map +1 -0
- package/dest/public/avm/avm_memory_types.js +340 -0
- package/dest/public/avm/avm_simulator.d.ts +40 -0
- package/dest/public/avm/avm_simulator.d.ts.map +1 -0
- package/dest/public/avm/avm_simulator.js +202 -0
- package/dest/public/avm/bytecode_utils.d.ts +5 -0
- package/dest/public/avm/bytecode_utils.d.ts.map +1 -0
- package/dest/public/avm/bytecode_utils.js +17 -0
- package/dest/public/avm/errors.d.ts +122 -0
- package/dest/public/avm/errors.d.ts.map +1 -0
- package/dest/public/avm/errors.js +179 -0
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts +21 -0
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -0
- package/dest/public/avm/fixtures/avm_simulation_tester.js +76 -0
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +36 -0
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -0
- package/dest/public/avm/fixtures/base_avm_simulation_tester.js +83 -0
- package/dest/public/avm/fixtures/index.d.ts +84 -0
- package/dest/public/avm/fixtures/index.d.ts.map +1 -0
- package/dest/public/avm/fixtures/index.js +175 -0
- package/dest/public/avm/fixtures/simple_contract_data_source.d.ts +35 -0
- package/dest/public/avm/fixtures/simple_contract_data_source.d.ts.map +1 -0
- package/dest/public/avm/fixtures/simple_contract_data_source.js +74 -0
- package/dest/public/avm/index.d.ts +4 -0
- package/dest/public/avm/index.d.ts.map +1 -0
- package/dest/public/avm/index.js +3 -0
- package/dest/public/avm/journal/index.d.ts +2 -0
- package/dest/public/avm/journal/index.d.ts.map +1 -0
- package/dest/public/avm/journal/index.js +1 -0
- package/dest/public/avm/journal/journal.d.ts +209 -0
- package/dest/public/avm/journal/journal.d.ts.map +1 -0
- package/dest/public/avm/journal/journal.js +486 -0
- package/dest/public/avm/journal/nullifiers.d.ts +64 -0
- package/dest/public/avm/journal/nullifiers.d.ts.map +1 -0
- package/dest/public/avm/journal/nullifiers.js +97 -0
- package/dest/public/avm/journal/public_storage.d.ts +66 -0
- package/dest/public/avm/journal/public_storage.d.ts.map +1 -0
- package/dest/public/avm/journal/public_storage.js +145 -0
- package/dest/public/avm/opcodes/accrued_substate.d.ts +75 -0
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -0
- package/dest/public/avm/opcodes/accrued_substate.js +252 -0
- package/dest/public/avm/opcodes/addressing_mode.d.ts +27 -0
- package/dest/public/avm/opcodes/addressing_mode.d.ts.map +1 -0
- package/dest/public/avm/opcodes/addressing_mode.js +74 -0
- package/dest/public/avm/opcodes/arithmetic.d.ts +37 -0
- package/dest/public/avm/opcodes/arithmetic.d.ts.map +1 -0
- package/dest/public/avm/opcodes/arithmetic.js +73 -0
- package/dest/public/avm/opcodes/bitwise.d.ts +50 -0
- package/dest/public/avm/opcodes/bitwise.d.ts.map +1 -0
- package/dest/public/avm/opcodes/bitwise.js +106 -0
- package/dest/public/avm/opcodes/comparators.d.ts +25 -0
- package/dest/public/avm/opcodes/comparators.d.ts.map +1 -0
- package/dest/public/avm/opcodes/comparators.js +43 -0
- package/dest/public/avm/opcodes/contract.d.ts +21 -0
- package/dest/public/avm/opcodes/contract.d.ts.map +1 -0
- package/dest/public/avm/opcodes/contract.js +66 -0
- package/dest/public/avm/opcodes/control_flow.d.ts +41 -0
- package/dest/public/avm/opcodes/control_flow.d.ts.map +1 -0
- package/dest/public/avm/opcodes/control_flow.js +105 -0
- package/dest/public/avm/opcodes/conversion.d.ts +17 -0
- package/dest/public/avm/opcodes/conversion.d.ts.map +1 -0
- package/dest/public/avm/opcodes/conversion.js +69 -0
- package/dest/public/avm/opcodes/ec_add.d.ts +19 -0
- package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -0
- package/dest/public/avm/opcodes/ec_add.js +84 -0
- package/dest/public/avm/opcodes/environment_getters.d.ts +28 -0
- package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -0
- package/dest/public/avm/opcodes/environment_getters.js +79 -0
- package/dest/public/avm/opcodes/external_calls.d.ts +58 -0
- package/dest/public/avm/opcodes/external_calls.d.ts.map +1 -0
- package/dest/public/avm/opcodes/external_calls.js +204 -0
- package/dest/public/avm/opcodes/hashing.d.ts +36 -0
- package/dest/public/avm/opcodes/hashing.d.ts.map +1 -0
- package/dest/public/avm/opcodes/hashing.js +114 -0
- package/dest/public/avm/opcodes/index.d.ts +16 -0
- package/dest/public/avm/opcodes/index.d.ts.map +1 -0
- package/dest/public/avm/opcodes/index.js +15 -0
- package/dest/public/avm/opcodes/instruction.d.ts +70 -0
- package/dest/public/avm/opcodes/instruction.d.ts.map +1 -0
- package/dest/public/avm/opcodes/instruction.js +91 -0
- package/dest/public/avm/opcodes/instruction_impl.d.ts +19 -0
- package/dest/public/avm/opcodes/instruction_impl.d.ts.map +1 -0
- package/dest/public/avm/opcodes/instruction_impl.js +30 -0
- package/dest/public/avm/opcodes/memory.d.ts +74 -0
- package/dest/public/avm/opcodes/memory.d.ts.map +1 -0
- package/dest/public/avm/opcodes/memory.js +253 -0
- package/dest/public/avm/opcodes/misc.d.ts +17 -0
- package/dest/public/avm/opcodes/misc.d.ts.map +1 -0
- package/dest/public/avm/opcodes/misc.js +48 -0
- package/dest/public/avm/opcodes/storage.d.ts +24 -0
- package/dest/public/avm/opcodes/storage.d.ts.map +1 -0
- package/dest/public/avm/opcodes/storage.js +66 -0
- package/dest/public/avm/serialization/buffer_cursor.d.ts +28 -0
- package/dest/public/avm/serialization/buffer_cursor.d.ts.map +1 -0
- package/dest/public/avm/serialization/buffer_cursor.js +99 -0
- package/dest/public/avm/serialization/bytecode_serialization.d.ts +21 -0
- package/dest/public/avm/serialization/bytecode_serialization.d.ts.map +1 -0
- package/dest/public/avm/serialization/bytecode_serialization.js +332 -0
- package/dest/public/avm/serialization/instruction_serialization.d.ts +105 -0
- package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -0
- package/dest/public/avm/serialization/instruction_serialization.js +226 -0
- package/dest/public/avm/test_utils.d.ts +18 -0
- package/dest/public/avm/test_utils.d.ts.map +1 -0
- package/dest/public/avm/test_utils.js +52 -0
- package/dest/public/bytecode_errors.d.ts +4 -0
- package/dest/public/bytecode_errors.d.ts.map +1 -0
- package/dest/public/bytecode_errors.js +6 -0
- package/dest/public/execution.d.ts +108 -0
- package/dest/public/execution.d.ts.map +1 -0
- package/dest/public/execution.js +9 -0
- package/dest/public/executor_metrics.d.ts +13 -0
- package/dest/public/executor_metrics.d.ts.map +1 -0
- package/dest/public/executor_metrics.js +54 -0
- package/dest/public/fixtures/index.d.ts +3 -0
- package/dest/public/fixtures/index.d.ts.map +1 -0
- package/dest/public/fixtures/index.js +2 -0
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +32 -0
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -0
- package/dest/public/fixtures/public_tx_simulation_tester.js +93 -0
- package/dest/public/fixtures/utils.d.ts +13 -0
- package/dest/public/fixtures/utils.d.ts.map +1 -0
- package/dest/public/fixtures/utils.js +126 -0
- package/dest/public/index.d.ts +10 -0
- package/dest/public/index.d.ts.map +1 -0
- package/dest/public/index.js +8 -0
- package/dest/public/public_db_sources.d.ts +129 -0
- package/dest/public/public_db_sources.d.ts.map +1 -0
- package/dest/public/public_db_sources.js +264 -0
- package/dest/public/public_processor/public_processor.d.ts +74 -0
- package/dest/public/public_processor/public_processor.d.ts.map +1 -0
- package/dest/public/public_processor/public_processor.js +379 -0
- package/dest/public/public_processor/public_processor_metrics.d.ts +27 -0
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -0
- package/dest/public/public_processor/public_processor_metrics.js +125 -0
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +137 -0
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/public_tx_context.js +320 -0
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +102 -0
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/public_tx_simulator.js +334 -0
- package/dest/public/side_effect_errors.d.ts +4 -0
- package/dest/public/side_effect_errors.d.ts.map +1 -0
- package/dest/public/side_effect_errors.js +6 -0
- package/dest/public/side_effect_trace.d.ts +132 -0
- package/dest/public/side_effect_trace.d.ts.map +1 -0
- package/dest/public/side_effect_trace.js +249 -0
- package/dest/public/side_effect_trace_interface.d.ts +34 -0
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -0
- package/dest/public/side_effect_trace_interface.js +1 -0
- package/dest/public/tx_contract_cache.d.ts +41 -0
- package/dest/public/tx_contract_cache.d.ts.map +1 -0
- package/dest/public/tx_contract_cache.js +49 -0
- package/dest/public/unique_class_ids.d.ts +37 -0
- package/dest/public/unique_class_ids.d.ts.map +1 -0
- package/dest/public/unique_class_ids.js +61 -0
- package/dest/public/utils.d.ts +5 -0
- package/dest/public/utils.d.ts.map +1 -0
- package/dest/public/utils.js +35 -0
- package/dest/server.d.ts +6 -0
- package/dest/server.d.ts.map +1 -0
- package/dest/server.js +4 -0
- package/dest/test/utils.d.ts +13 -0
- package/dest/test/utils.d.ts.map +1 -0
- package/dest/test/utils.js +22 -0
- package/package.json +104 -0
- package/src/client.ts +4 -0
- package/src/common/db_interfaces.ts +94 -0
- package/src/common/debug_fn_name.ts +18 -0
- package/src/common/errors.ts +183 -0
- package/src/common/index.ts +3 -0
- package/src/common/message_load_oracle_inputs.ts +15 -0
- package/src/common/stats/index.ts +1 -0
- package/src/common/stats/stats.ts +20 -0
- package/src/private/acvm/acvm.ts +127 -0
- package/src/private/acvm/acvm_types.ts +11 -0
- package/src/private/acvm/deserialize.ts +52 -0
- package/src/private/acvm/index.ts +5 -0
- package/src/private/acvm/oracle/index.ts +16 -0
- package/src/private/acvm/oracle/oracle.ts +455 -0
- package/src/private/acvm/oracle/typed_oracle.ts +259 -0
- package/src/private/acvm/serialize.ts +60 -0
- package/src/private/execution_data_provider.ts +323 -0
- package/src/private/execution_note_cache.ts +217 -0
- package/src/private/hashed_values_cache.ts +55 -0
- package/src/private/index.ts +16 -0
- package/src/private/pick_notes.ts +141 -0
- package/src/private/private_execution.ts +151 -0
- package/src/private/private_execution_oracle.ts +614 -0
- package/src/private/providers/acvm_native.ts +171 -0
- package/src/private/providers/acvm_wasm.ts +63 -0
- package/src/private/providers/acvm_wasm_with_blobs.ts +50 -0
- package/src/private/providers/factory.ts +38 -0
- package/src/private/providers/simulation_provider.ts +45 -0
- package/src/private/simulator.ts +147 -0
- package/src/private/unconstrained_execution.ts +50 -0
- package/src/private/unconstrained_execution_oracle.ts +373 -0
- package/src/public/avm/avm_context.ts +61 -0
- package/src/public/avm/avm_contract_call_result.ts +55 -0
- package/src/public/avm/avm_execution_environment.ts +39 -0
- package/src/public/avm/avm_gas.ts +195 -0
- package/src/public/avm/avm_machine_state.ts +164 -0
- package/src/public/avm/avm_memory_types.ts +423 -0
- package/src/public/avm/avm_simulator.ts +284 -0
- package/src/public/avm/bytecode_utils.ts +17 -0
- package/src/public/avm/errors.ts +232 -0
- package/src/public/avm/fixtures/avm_simulation_tester.ts +105 -0
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +109 -0
- package/src/public/avm/fixtures/index.ts +296 -0
- package/src/public/avm/fixtures/simple_contract_data_source.ts +105 -0
- package/src/public/avm/index.ts +3 -0
- package/src/public/avm/journal/index.ts +1 -0
- package/src/public/avm/journal/journal.ts +742 -0
- package/src/public/avm/journal/nullifiers.ts +109 -0
- package/src/public/avm/journal/public_storage.ts +174 -0
- package/src/public/avm/opcodes/.eslintrc.cjs +8 -0
- package/src/public/avm/opcodes/accrued_substate.ts +253 -0
- package/src/public/avm/opcodes/addressing_mode.ts +87 -0
- package/src/public/avm/opcodes/arithmetic.ts +95 -0
- package/src/public/avm/opcodes/bitwise.ts +109 -0
- package/src/public/avm/opcodes/comparators.ts +52 -0
- package/src/public/avm/opcodes/contract.ts +72 -0
- package/src/public/avm/opcodes/control_flow.ts +114 -0
- package/src/public/avm/opcodes/conversion.ts +80 -0
- package/src/public/avm/opcodes/ec_add.ts +93 -0
- package/src/public/avm/opcodes/environment_getters.ts +82 -0
- package/src/public/avm/opcodes/external_calls.ts +228 -0
- package/src/public/avm/opcodes/hashing.ts +125 -0
- package/src/public/avm/opcodes/index.ts +15 -0
- package/src/public/avm/opcodes/instruction.ts +126 -0
- package/src/public/avm/opcodes/instruction_impl.ts +36 -0
- package/src/public/avm/opcodes/memory.ts +254 -0
- package/src/public/avm/opcodes/misc.ts +60 -0
- package/src/public/avm/opcodes/storage.ts +71 -0
- package/src/public/avm/serialization/buffer_cursor.ts +115 -0
- package/src/public/avm/serialization/bytecode_serialization.ts +206 -0
- package/src/public/avm/serialization/instruction_serialization.ts +208 -0
- package/src/public/avm/test_utils.ts +81 -0
- package/src/public/bytecode_errors.ts +6 -0
- package/src/public/execution.ts +140 -0
- package/src/public/executor_metrics.ts +71 -0
- package/src/public/fixtures/index.ts +2 -0
- package/src/public/fixtures/public_tx_simulation_tester.ts +179 -0
- package/src/public/fixtures/utils.ts +199 -0
- package/src/public/index.ts +9 -0
- package/src/public/public_db_sources.ts +369 -0
- package/src/public/public_processor/public_processor.ts +521 -0
- package/src/public/public_processor/public_processor_metrics.ts +154 -0
- package/src/public/public_tx_simulator/public_tx_context.ts +504 -0
- package/src/public/public_tx_simulator/public_tx_simulator.ts +474 -0
- package/src/public/side_effect_errors.ts +6 -0
- package/src/public/side_effect_trace.ts +516 -0
- package/src/public/side_effect_trace_interface.ts +76 -0
- package/src/public/tx_contract_cache.ts +69 -0
- package/src/public/unique_class_ids.ts +80 -0
- package/src/public/utils.ts +32 -0
- package/src/server.ts +5 -0
- package/src/test/utils.ts +36 -0
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Simulator
|
|
2
|
+
|
|
3
|
+
## Responsibilities
|
|
4
|
+
|
|
5
|
+
This library package is responsible for simulating function circuits compiled to ACIR / AVM.
|
|
6
|
+
|
|
7
|
+
Simulating a function implies generating the partial witness and the public inputs of the function, as well as collecting all the data (such as created notes or nullifiers, or state changes) that are necessary for components upstream.
|
|
8
|
+
|
|
9
|
+
It's able to simulate three different types of functions:
|
|
10
|
+
|
|
11
|
+
### Private Functions
|
|
12
|
+
|
|
13
|
+
Private functions are simulated and proved client-side, and verified client-side in the private kernel circuit.
|
|
14
|
+
|
|
15
|
+
The public inputs of private functions is defined [here](../stdlib/src/structs/private_circuit_public_inputs.ts).
|
|
16
|
+
|
|
17
|
+
They are run with the assistance of a DB oracle that provides any private data requested by the function.
|
|
18
|
+
|
|
19
|
+
Private functions can call another private function, and can request to call a public function, but the public function execution will be performed by the sequencer asynchronously, thus having no access to the return values.
|
|
20
|
+
|
|
21
|
+
### Public Functions
|
|
22
|
+
|
|
23
|
+
Public functions are simulated and proved on the sequencer side, and verified by the public kernel circuit.
|
|
24
|
+
|
|
25
|
+
The public inputs of public functions is defined [here](../stdlib/src/structs/avm/avm_circuit_public_inputs.ts).
|
|
26
|
+
|
|
27
|
+
They are run with the assistance of an oracle that provides any value read from the public state tree.
|
|
28
|
+
|
|
29
|
+
Public functions can call other public function, but no private functions.
|
|
30
|
+
|
|
31
|
+
### Unconstrained Functions
|
|
32
|
+
|
|
33
|
+
Unconstrained functions are useful to extract useful data for users that could produce very large execution traces - such as the summed balance of all a users notes
|
|
34
|
+
They are not proved, and are simulated client-side.
|
|
35
|
+
|
|
36
|
+
They are run with the assistance of a DB oracle that provides any private data requested by the function.
|
|
37
|
+
|
|
38
|
+
At the moment, unconstrained functions cannot call any other function.
|
|
39
|
+
It would be possible to allow them to call other unconstrained functions.
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
### Development
|
|
44
|
+
|
|
45
|
+
Same steps as any other library. They are detailed [here](../README.md#development)
|
|
46
|
+
|
|
47
|
+
### Testing
|
|
48
|
+
|
|
49
|
+
Same steps as any other library. They are detailed [here](../README.md#tests)
|
package/dest/client.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AACrF,cAAc,mBAAmB,CAAC"}
|
package/dest/client.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
4
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
6
|
+
import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
|
|
7
|
+
import type { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
8
|
+
/**
|
|
9
|
+
* Database interface for providing access to public state.
|
|
10
|
+
*/
|
|
11
|
+
export interface PublicStateDB {
|
|
12
|
+
/**
|
|
13
|
+
* Reads a value from public storage, returning zero if none.
|
|
14
|
+
* @param contract - Owner of the storage.
|
|
15
|
+
* @param slot - Slot to read in the contract storage.
|
|
16
|
+
* @returns The current value in the storage slot.
|
|
17
|
+
*/
|
|
18
|
+
storageRead(contract: AztecAddress, slot: Fr): Promise<Fr>;
|
|
19
|
+
/**
|
|
20
|
+
* Records a write to public storage.
|
|
21
|
+
* @param contract - Owner of the storage.
|
|
22
|
+
* @param slot - Slot to read in the contract storage.
|
|
23
|
+
* @param newValue - The new value to store.
|
|
24
|
+
*/
|
|
25
|
+
storageWrite(contract: AztecAddress, slot: Fr, newValue: Fr): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Database interface for providing access to public contract data.
|
|
29
|
+
*/
|
|
30
|
+
export interface PublicContractsDB {
|
|
31
|
+
/**
|
|
32
|
+
* Returns a publicly deployed contract instance.
|
|
33
|
+
* @param address - Address of the contract.
|
|
34
|
+
* @returns The contract instance or undefined if not found.
|
|
35
|
+
*/
|
|
36
|
+
getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined>;
|
|
37
|
+
getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
|
|
38
|
+
}
|
|
39
|
+
/** Database interface for providing access to commitment tree, l1 to l2 message tree, and nullifier tree. */
|
|
40
|
+
export interface CommitmentsDB {
|
|
41
|
+
/**
|
|
42
|
+
* Fetches a message from the db, given its key.
|
|
43
|
+
* @param contractAddress - Address of a contract by which the message was emitted.
|
|
44
|
+
* @param messageHash - Hash of the message.
|
|
45
|
+
* @param secret - Secret used to compute a nullifier.
|
|
46
|
+
* @dev Contract address and secret are only used to compute the nullifier to get non-nullified messages
|
|
47
|
+
* @returns The l1 to l2 membership witness (index of message in the tree and sibling path).
|
|
48
|
+
*/
|
|
49
|
+
getL1ToL2MembershipWitness(contractAddress: AztecAddress, messageHash: Fr, secret: Fr): Promise<MessageLoadOracleInputs<typeof L1_TO_L2_MSG_TREE_HEIGHT>>;
|
|
50
|
+
/**
|
|
51
|
+
* @param leafIndex the leaf to look up
|
|
52
|
+
* @returns The l1 to l2 leaf value or undefined if not found.
|
|
53
|
+
*/
|
|
54
|
+
getL1ToL2LeafValue(leafIndex: bigint): Promise<Fr | undefined>;
|
|
55
|
+
/**
|
|
56
|
+
* Gets the index of a commitment in the note hash tree.
|
|
57
|
+
* @param commitment - The commitment.
|
|
58
|
+
* @returns - The index of the commitment. Undefined if it does not exist in the tree.
|
|
59
|
+
*/
|
|
60
|
+
getCommitmentIndex(commitment: Fr): Promise<bigint | undefined>;
|
|
61
|
+
/**
|
|
62
|
+
* Gets commitment in the note hash tree given a leaf index.
|
|
63
|
+
* @param leafIndex - the leaf to look up.
|
|
64
|
+
* @returns - The commitment at that index. Undefined if leaf index is not found.
|
|
65
|
+
*/
|
|
66
|
+
getCommitmentValue(leafIndex: bigint): Promise<Fr | undefined>;
|
|
67
|
+
/**
|
|
68
|
+
* Gets the index of a nullifier in the nullifier tree.
|
|
69
|
+
* @param nullifier - The nullifier.
|
|
70
|
+
* @returns - The index of the nullifier. Undefined if it does not exist in the tree.
|
|
71
|
+
*/
|
|
72
|
+
getNullifierIndex(nullifier: Fr): Promise<bigint | undefined>;
|
|
73
|
+
/**
|
|
74
|
+
* Returns a nullifier membership witness for the given nullifier or undefined if not found.
|
|
75
|
+
* REFACTOR: Same as getL1ToL2MembershipWitness, can be combined with aztec-node method that does almost the same thing.
|
|
76
|
+
* @param nullifier - Nullifier we're looking for.
|
|
77
|
+
*/
|
|
78
|
+
getNullifierMembershipWitnessAtLatestBlock(nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=db_interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db_interfaces.d.ts","sourceRoot":"","sources":["../../src/common/db_interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAEtE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE/E;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC;IAE3D;;;;;OAKG;IACH,YAAY,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7E;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAAC,CAAC;IAE7F,oBAAoB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CAC9G;AAED,6GAA6G;AAC7G,MAAM,WAAW,aAAa;IAC5B;;;;;;;OAOG;IACH,0BAA0B,CACxB,eAAe,EAAE,YAAY,EAC7B,WAAW,EAAE,EAAE,EACf,MAAM,EAAE,EAAE,GACT,OAAO,CAAC,uBAAuB,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC;IAErE;;;OAGG;IACH,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC;IAE/D;;;;OAIG;IACH,kBAAkB,CAAC,UAAU,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAEhE;;;;OAIG;IACH,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC;IAE/D;;;;OAIG;IACH,iBAAiB,CAAC,SAAS,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAE9D;;;;OAIG;IACH,0CAA0C,CAAC,SAAS,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,GAAG,SAAS,CAAC,CAAC;CAC5G"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/** Database interface for providing access to commitment tree, l1 to l2 message tree, and nullifier tree. */ export { };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { WorldStateDB } from '../public/public_db_sources.js';
|
|
4
|
+
export declare function getPublicFunctionDebugName(db: WorldStateDB, contractAddress: AztecAddress, calldata: Fr[]): Promise<string>;
|
|
5
|
+
//# sourceMappingURL=debug_fn_name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug_fn_name.d.ts","sourceRoot":"","sources":["../../src/common/debug_fn_name.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnE,wBAAsB,0BAA0B,CAC9C,EAAE,EAAE,YAAY,EAChB,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,EAAE,EAAE,GACb,OAAO,CAAC,MAAM,CAAC,CAOjB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
2
|
+
export async function getPublicFunctionDebugName(db, contractAddress, calldata) {
|
|
3
|
+
// Public function is dispatched and therefore the target function is passed in the first argument.
|
|
4
|
+
const targetFunction = calldata[0] !== undefined ? await db.getDebugFunctionName(contractAddress, FunctionSelector.fromField(calldata[0])) : `<calldata[0] undefined> (Contract Address: ${contractAddress})`;
|
|
5
|
+
return `${targetFunction}`;
|
|
6
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import type { BrilligFunctionId, FunctionAbi, FunctionDebugMetadata, OpcodeLocation } from '@aztec/stdlib/abi';
|
|
3
|
+
import { type FailingFunction, type NoirCallStack, SimulationError, type SourceCodeLocation } from '@aztec/stdlib/errors';
|
|
4
|
+
import type { RawAssertionPayload } from '@noir-lang/acvm_js';
|
|
5
|
+
/**
|
|
6
|
+
* An error that occurred during the execution of a function.
|
|
7
|
+
* @param message - the error message
|
|
8
|
+
* @param failingFunction - the Aztec function that failed
|
|
9
|
+
* @param noirCallStack - the internal call stack of the function that failed (within the failing Aztec function)
|
|
10
|
+
* @param options - additional error options (an optional "cause" entry allows for a recursive error stack where
|
|
11
|
+
* an error's cause may be an ExecutionError itself)
|
|
12
|
+
*/
|
|
13
|
+
export declare class ExecutionError extends Error {
|
|
14
|
+
/**
|
|
15
|
+
* The function that failed.
|
|
16
|
+
*/
|
|
17
|
+
failingFunction: FailingFunction;
|
|
18
|
+
/**
|
|
19
|
+
* The noir call stack of the function that failed.
|
|
20
|
+
*/
|
|
21
|
+
noirCallStack?: NoirCallStack | undefined;
|
|
22
|
+
constructor(message: string,
|
|
23
|
+
/**
|
|
24
|
+
* The function that failed.
|
|
25
|
+
*/
|
|
26
|
+
failingFunction: FailingFunction,
|
|
27
|
+
/**
|
|
28
|
+
* The noir call stack of the function that failed.
|
|
29
|
+
*/
|
|
30
|
+
noirCallStack?: NoirCallStack | undefined, options?: ErrorOptions);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Traverses the cause chain of an error.
|
|
34
|
+
* @param error - The error to start from.
|
|
35
|
+
* @param callback - A callback on every error, including the first one.
|
|
36
|
+
*/
|
|
37
|
+
export declare function traverseCauseChain(error: Error, callback: (error: Error) => void): void;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a simulation error from an error chain generated during the execution of a function.
|
|
40
|
+
* @param error - The error thrown during execution.
|
|
41
|
+
* @returns - A simulation error.
|
|
42
|
+
*/
|
|
43
|
+
export declare function createSimulationError(error: Error, revertData?: Fr[]): SimulationError;
|
|
44
|
+
/**
|
|
45
|
+
* Extracts the source code locations for an array of opcode locations
|
|
46
|
+
* @param opcodeLocations - The opcode locations that caused the error.
|
|
47
|
+
* @param debug - The debug metadata of the function.
|
|
48
|
+
* @returns The source code locations.
|
|
49
|
+
*/
|
|
50
|
+
export declare function resolveOpcodeLocations(opcodeLocations: OpcodeLocation[], debug: FunctionDebugMetadata, brilligFunctionId?: BrilligFunctionId): SourceCodeLocation[];
|
|
51
|
+
export declare function resolveAssertionMessage(errorPayload: RawAssertionPayload, abi: FunctionAbi): string | undefined;
|
|
52
|
+
export declare function resolveAssertionMessageFromRevertData(revertData: Fr[], abi: FunctionAbi): string | undefined;
|
|
53
|
+
export declare function resolveAssertionMessageFromError(err: Error, abi: FunctionAbi): string;
|
|
54
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/common/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/G,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,eAAe,EACf,KAAK,kBAAkB,EACxB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAG9D;;;;;;;GAOG;AACH,qBAAa,cAAe,SAAQ,KAAK;IAGrC;;OAEG;IACI,eAAe,EAAE,eAAe;IACvC;;OAEG;IACI,aAAa,CAAC;gBARrB,OAAO,EAAE,MAAM;IACf;;OAEG;IACI,eAAe,EAAE,eAAe;IACvC;;OAEG;IACI,aAAa,CAAC,2BAAe,EACpC,OAAO,CAAC,EAAE,YAAY;CAIzB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,QAUhF;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,eAAe,CAgBtF;AAuDD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,cAAc,EAAE,EACjC,KAAK,EAAE,qBAAqB,EAC5B,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,kBAAkB,EAAE,CAItB;AAED,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,mBAAmB,EAAE,GAAG,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAW/G;AAED,wBAAgB,qCAAqC,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAc5G;AAED,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,WAAW,GAAG,MAAM,CAMrF"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
2
|
+
import { SimulationError } from '@aztec/stdlib/errors';
|
|
3
|
+
import { abiDecodeError } from '@noir-lang/noirc_abi';
|
|
4
|
+
/**
|
|
5
|
+
* An error that occurred during the execution of a function.
|
|
6
|
+
* @param message - the error message
|
|
7
|
+
* @param failingFunction - the Aztec function that failed
|
|
8
|
+
* @param noirCallStack - the internal call stack of the function that failed (within the failing Aztec function)
|
|
9
|
+
* @param options - additional error options (an optional "cause" entry allows for a recursive error stack where
|
|
10
|
+
* an error's cause may be an ExecutionError itself)
|
|
11
|
+
*/ export class ExecutionError extends Error {
|
|
12
|
+
failingFunction;
|
|
13
|
+
noirCallStack;
|
|
14
|
+
constructor(message, /**
|
|
15
|
+
* The function that failed.
|
|
16
|
+
*/ failingFunction, /**
|
|
17
|
+
* The noir call stack of the function that failed.
|
|
18
|
+
*/ noirCallStack, options){
|
|
19
|
+
super(message, options), this.failingFunction = failingFunction, this.noirCallStack = noirCallStack;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Traverses the cause chain of an error.
|
|
24
|
+
* @param error - The error to start from.
|
|
25
|
+
* @param callback - A callback on every error, including the first one.
|
|
26
|
+
*/ export function traverseCauseChain(error, callback) {
|
|
27
|
+
let currentError = error;
|
|
28
|
+
while(currentError){
|
|
29
|
+
callback(currentError);
|
|
30
|
+
if (currentError.cause && currentError.cause instanceof Error) {
|
|
31
|
+
currentError = currentError.cause;
|
|
32
|
+
} else {
|
|
33
|
+
currentError = undefined;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Creates a simulation error from an error chain generated during the execution of a function.
|
|
39
|
+
* @param error - The error thrown during execution.
|
|
40
|
+
* @returns - A simulation error.
|
|
41
|
+
*/ export function createSimulationError(error, revertData) {
|
|
42
|
+
let rootCause = error;
|
|
43
|
+
let noirCallStack = undefined;
|
|
44
|
+
const aztecCallStack = [];
|
|
45
|
+
traverseCauseChain(error, (cause)=>{
|
|
46
|
+
rootCause = cause;
|
|
47
|
+
if (cause instanceof ExecutionError) {
|
|
48
|
+
aztecCallStack.push(cause.failingFunction);
|
|
49
|
+
if (cause.noirCallStack) {
|
|
50
|
+
noirCallStack = cause.noirCallStack;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return new SimulationError(rootCause.message, aztecCallStack, revertData, noirCallStack, {
|
|
55
|
+
cause: rootCause
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Extracts a brillig location from an opcode location.
|
|
60
|
+
* @param opcodeLocation - The opcode location to extract from. It should be in the format `acirLocation.brilligLocation` or `acirLocation`.
|
|
61
|
+
* @returns The brillig location if the opcode location contains one.
|
|
62
|
+
*/ function extractBrilligLocation(opcodeLocation) {
|
|
63
|
+
const splitted = opcodeLocation.split('.');
|
|
64
|
+
if (splitted.length === 2) {
|
|
65
|
+
return splitted[1];
|
|
66
|
+
}
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Extracts the call stack from the location of a failing opcode and the debug metadata.
|
|
71
|
+
* One opcode can point to multiple calls due to inlining.
|
|
72
|
+
*/ function getSourceCodeLocationsFromOpcodeLocation(opcodeLocation, debug, brilligFunctionId) {
|
|
73
|
+
const { debugSymbols, files } = debug;
|
|
74
|
+
let callStack = debugSymbols.locations[opcodeLocation] || [];
|
|
75
|
+
if (callStack.length === 0) {
|
|
76
|
+
const brilligLocation = extractBrilligLocation(opcodeLocation);
|
|
77
|
+
if (brilligFunctionId !== undefined && brilligLocation !== undefined) {
|
|
78
|
+
callStack = debugSymbols.brillig_locations[brilligFunctionId][brilligLocation] || [];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return callStack.map((call)=>{
|
|
82
|
+
const { file: fileId, span } = call;
|
|
83
|
+
const { path, source } = files[fileId];
|
|
84
|
+
const locationText = source.substring(span.start, span.end);
|
|
85
|
+
const precedingText = source.substring(0, span.start);
|
|
86
|
+
const previousLines = precedingText.split('\n');
|
|
87
|
+
// Lines and columns in stacks are one indexed.
|
|
88
|
+
const line = previousLines.length;
|
|
89
|
+
const column = previousLines[previousLines.length - 1].length + 1;
|
|
90
|
+
return {
|
|
91
|
+
filePath: path,
|
|
92
|
+
line,
|
|
93
|
+
column,
|
|
94
|
+
fileSource: source,
|
|
95
|
+
locationText
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Extracts the source code locations for an array of opcode locations
|
|
101
|
+
* @param opcodeLocations - The opcode locations that caused the error.
|
|
102
|
+
* @param debug - The debug metadata of the function.
|
|
103
|
+
* @returns The source code locations.
|
|
104
|
+
*/ export function resolveOpcodeLocations(opcodeLocations, debug, brilligFunctionId) {
|
|
105
|
+
return opcodeLocations.flatMap((opcodeLocation)=>getSourceCodeLocationsFromOpcodeLocation(opcodeLocation, debug, brilligFunctionId));
|
|
106
|
+
}
|
|
107
|
+
export function resolveAssertionMessage(errorPayload, abi) {
|
|
108
|
+
const decoded = abiDecodeError({
|
|
109
|
+
parameters: [],
|
|
110
|
+
error_types: abi.errorTypes,
|
|
111
|
+
return_type: null
|
|
112
|
+
}, errorPayload);
|
|
113
|
+
if (typeof decoded === 'string') {
|
|
114
|
+
return decoded;
|
|
115
|
+
} else {
|
|
116
|
+
return jsonStringify(decoded);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
export function resolveAssertionMessageFromRevertData(revertData, abi) {
|
|
120
|
+
if (revertData.length == 0) {
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
const [errorSelector, ...errorData] = revertData;
|
|
124
|
+
return resolveAssertionMessage({
|
|
125
|
+
selector: errorSelector.toBigInt().toString(),
|
|
126
|
+
data: errorData.map((f)=>f.toString())
|
|
127
|
+
}, abi);
|
|
128
|
+
}
|
|
129
|
+
export function resolveAssertionMessageFromError(err, abi) {
|
|
130
|
+
if (typeof err === 'object' && err !== null && 'rawAssertionPayload' in err && err.rawAssertionPayload) {
|
|
131
|
+
return `Assertion failed: ${resolveAssertionMessage(err.rawAssertionPayload, abi)}`;
|
|
132
|
+
} else {
|
|
133
|
+
return err.message;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import type { SiblingPath } from '@aztec/foundation/trees';
|
|
3
|
+
export declare class MessageLoadOracleInputs<N extends number> {
|
|
4
|
+
/** The index of the message commitment in the merkle tree. */
|
|
5
|
+
index: bigint;
|
|
6
|
+
/** The path in the merkle tree to the message. */
|
|
7
|
+
siblingPath: SiblingPath<N>;
|
|
8
|
+
constructor(
|
|
9
|
+
/** The index of the message commitment in the merkle tree. */
|
|
10
|
+
index: bigint,
|
|
11
|
+
/** The path in the merkle tree to the message. */
|
|
12
|
+
siblingPath: SiblingPath<N>);
|
|
13
|
+
toFields(): Fr[];
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=message_load_oracle_inputs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message_load_oracle_inputs.d.ts","sourceRoot":"","sources":["../../src/common/message_load_oracle_inputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,qBAAa,uBAAuB,CAAC,CAAC,SAAS,MAAM;IAEjD,8DAA8D;IACvD,KAAK,EAAE,MAAM;IACpB,kDAAkD;IAC3C,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;;IAHlC,8DAA8D;IACvD,KAAK,EAAE,MAAM;IACpB,kDAAkD;IAC3C,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;IAGpC,QAAQ,IAAI,EAAE,EAAE;CAGjB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
export class MessageLoadOracleInputs {
|
|
3
|
+
index;
|
|
4
|
+
siblingPath;
|
|
5
|
+
constructor(/** The index of the message commitment in the merkle tree. */ index, /** The path in the merkle tree to the message. */ siblingPath){
|
|
6
|
+
this.index = index;
|
|
7
|
+
this.siblingPath = siblingPath;
|
|
8
|
+
}
|
|
9
|
+
toFields() {
|
|
10
|
+
return [
|
|
11
|
+
new Fr(this.index),
|
|
12
|
+
...this.siblingPath.toFields()
|
|
13
|
+
];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/stats/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './stats.js';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
2
|
+
import type { CircuitName } from '@aztec/stdlib/stats';
|
|
3
|
+
export declare function emitCircuitSimulationStats(circuitName: CircuitName, duration: number, inputSize: number, outputSize: number, logger: Logger): void;
|
|
4
|
+
//# sourceMappingURL=stats.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../../src/common/stats/stats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAA0B,MAAM,qBAAqB,CAAC;AAE/E,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,QAWf"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function emitCircuitSimulationStats(circuitName, duration, inputSize, outputSize, logger) {
|
|
2
|
+
const stats = {
|
|
3
|
+
eventName: 'circuit-simulation',
|
|
4
|
+
circuitName,
|
|
5
|
+
inputSize,
|
|
6
|
+
outputSize,
|
|
7
|
+
duration
|
|
8
|
+
};
|
|
9
|
+
logger.debug('Circuit simulation stats', stats);
|
|
10
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import type { FunctionDebugMetadata } from '@aztec/stdlib/abi';
|
|
4
|
+
import type { NoirCallStack } from '@aztec/stdlib/errors';
|
|
5
|
+
import { type ExecutionError, type ForeignCallInput, type ForeignCallOutput } from '@noir-lang/acvm_js';
|
|
6
|
+
import type { ACVMWitness } from './acvm_types.js';
|
|
7
|
+
import type { ORACLE_NAMES } from './oracle/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* The callback interface for the ACIR.
|
|
10
|
+
*/
|
|
11
|
+
export type ACIRCallback = Record<ORACLE_NAMES, (...args: ForeignCallInput[]) => void | Promise<void> | ForeignCallOutput | ForeignCallOutput[] | Promise<ForeignCallOutput> | Promise<ForeignCallOutput[]>>;
|
|
12
|
+
/**
|
|
13
|
+
* The result of executing an ACIR.
|
|
14
|
+
*/
|
|
15
|
+
export interface ACIRExecutionResult {
|
|
16
|
+
/**
|
|
17
|
+
* An execution result contains two witnesses.
|
|
18
|
+
* 1. The partial witness of the execution.
|
|
19
|
+
* 2. The return witness which contains the given public return values within the full witness.
|
|
20
|
+
*/
|
|
21
|
+
partialWitness: ACVMWitness;
|
|
22
|
+
returnWitness: ACVMWitness;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The function call that executes an ACIR.
|
|
26
|
+
*/
|
|
27
|
+
export declare function acvm(acir: Buffer, initialWitness: ACVMWitness, callback: ACIRCallback): Promise<ACIRExecutionResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Extracts the call stack from an thrown by the acvm.
|
|
30
|
+
* @param error - The error to extract from.
|
|
31
|
+
* @param debug - The debug metadata of the function called.
|
|
32
|
+
* @returns The call stack, if available.
|
|
33
|
+
*/
|
|
34
|
+
export declare function extractCallStack(error: Error | ExecutionError, debug?: FunctionDebugMetadata): NoirCallStack | undefined;
|
|
35
|
+
//# sourceMappingURL=acvm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acvm.d.ts","sourceRoot":"","sources":["../../../src/private/acvm/acvm.ts"],"names":[],"mappings":";;AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAEvB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAC/B,YAAY,EACZ,CACE,GAAG,IAAI,EAAE,gBAAgB,EAAE,KAEzB,IAAI,GACJ,OAAO,CAAC,IAAI,CAAC,GACb,iBAAiB,GACjB,iBAAiB,EAAE,GACnB,OAAO,CAAC,iBAAiB,CAAC,GAC1B,OAAO,CAAC,iBAAiB,EAAE,CAAC,CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,cAAc,EAAE,WAAW,CAAC;IAC5B,aAAa,EAAE,WAAW,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAsB,IAAI,CACxB,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,WAAW,EAC3B,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,mBAAmB,CAAC,CAkD9B;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,KAAK,GAAG,cAAc,EAC7B,KAAK,CAAC,EAAE,qBAAqB,GAC5B,aAAa,GAAG,SAAS,CAc3B"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { executeCircuitWithReturnWitness } from '@noir-lang/acvm_js';
|
|
3
|
+
import { resolveOpcodeLocations, traverseCauseChain } from '../../common/errors.js';
|
|
4
|
+
/**
|
|
5
|
+
* The function call that executes an ACIR.
|
|
6
|
+
*/ export async function acvm(acir, initialWitness, callback) {
|
|
7
|
+
const logger = createLogger('simulator:acvm');
|
|
8
|
+
const solvedAndReturnWitness = await executeCircuitWithReturnWitness(acir, initialWitness, async (name, args)=>{
|
|
9
|
+
try {
|
|
10
|
+
logger.debug(`Oracle callback ${name}`);
|
|
11
|
+
const oracleFunction = callback[name];
|
|
12
|
+
if (!oracleFunction) {
|
|
13
|
+
throw new Error(`Oracle callback ${name} not found`);
|
|
14
|
+
}
|
|
15
|
+
const result = await oracleFunction.call(callback, ...args);
|
|
16
|
+
if (typeof result === 'undefined') {
|
|
17
|
+
return [];
|
|
18
|
+
} else if (result instanceof Array && !result.every((item)=>typeof item === 'string')) {
|
|
19
|
+
// We are dealing with a nested array which means that we do not need it wrap it in another array as to have
|
|
20
|
+
// the nested array structure it is already "wrapped".
|
|
21
|
+
return result;
|
|
22
|
+
} else {
|
|
23
|
+
return [
|
|
24
|
+
result
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
} catch (err) {
|
|
28
|
+
let typedError;
|
|
29
|
+
if (err instanceof Error) {
|
|
30
|
+
typedError = err;
|
|
31
|
+
} else {
|
|
32
|
+
typedError = new Error(`Error in oracle callback ${err}`);
|
|
33
|
+
}
|
|
34
|
+
logger.error(`Error in oracle callback ${name}: ${typedError.message}`);
|
|
35
|
+
throw typedError;
|
|
36
|
+
}
|
|
37
|
+
}).catch((err)=>{
|
|
38
|
+
// Wasm callbacks act as a boundary for stack traces, so we capture it here and complete the error if it happens.
|
|
39
|
+
const stack = new Error().stack;
|
|
40
|
+
traverseCauseChain(err, (cause)=>{
|
|
41
|
+
if (cause.stack) {
|
|
42
|
+
cause.stack += stack;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
throw err;
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
partialWitness: solvedAndReturnWitness.solvedWitness,
|
|
49
|
+
returnWitness: solvedAndReturnWitness.returnWitness
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Extracts the call stack from an thrown by the acvm.
|
|
54
|
+
* @param error - The error to extract from.
|
|
55
|
+
* @param debug - The debug metadata of the function called.
|
|
56
|
+
* @returns The call stack, if available.
|
|
57
|
+
*/ export function extractCallStack(error, debug) {
|
|
58
|
+
if (!('callStack' in error) || !error.callStack) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
const { callStack, brilligFunctionId } = error;
|
|
62
|
+
if (!debug) {
|
|
63
|
+
return callStack;
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
return resolveOpcodeLocations(callStack, debug, brilligFunctionId);
|
|
67
|
+
} catch (err) {
|
|
68
|
+
return callStack;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acvm_types.d.ts","sourceRoot":"","sources":["../../../src/private/acvm/acvm_types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import type { ACVMField, ACVMWitness } from './acvm_types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Converts an ACVM field to a Fr.
|
|
5
|
+
* @param field - The ACVM field to convert.
|
|
6
|
+
* @returns The Fr.
|
|
7
|
+
*/
|
|
8
|
+
export declare function fromACVMField(field: ACVMField): Fr;
|
|
9
|
+
/**
|
|
10
|
+
* Converts a field to a number.
|
|
11
|
+
* @param fr - The field to convert.
|
|
12
|
+
* @returns The number.
|
|
13
|
+
* TODO(#4102): Nuke this once block number is big int.
|
|
14
|
+
*/
|
|
15
|
+
export declare function frToNumber(fr: Fr): number;
|
|
16
|
+
/**
|
|
17
|
+
* Converts a field to a boolean.
|
|
18
|
+
* @param fr - The field to convert.
|
|
19
|
+
*/
|
|
20
|
+
export declare function frToBoolean(fr: Fr): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Converts a Noir BoundedVec of Fields into an Fr array. Note that BoundedVecs are structs, and therefore translated as
|
|
23
|
+
* two separate ACVMField values (an array and a single field).
|
|
24
|
+
*
|
|
25
|
+
* @param storage The array with the BoundedVec's storage (i.e. BoundedVec::storage())
|
|
26
|
+
* @param length The length of the BoundedVec (i.e. BoundedVec::len())
|
|
27
|
+
* @returns An array with the same content as the Noir version. Elements past the length are discarded.
|
|
28
|
+
*/
|
|
29
|
+
export declare function fromBoundedVec(storage: ACVMField[], length: ACVMField): Fr[];
|
|
30
|
+
/**
|
|
31
|
+
* Transforms a witness map to its field elements.
|
|
32
|
+
* @param witness - The witness to extract from.
|
|
33
|
+
* @returns The return values.
|
|
34
|
+
*/
|
|
35
|
+
export declare function witnessMapToFields(witness: ACVMWitness): Fr[];
|
|
36
|
+
//# sourceMappingURL=deserialize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deserialize.d.ts","sourceRoot":"","sources":["../../../src/private/acvm/deserialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9D;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,EAAE,CAElD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,MAAM,CAEzC;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAE3C;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,SAAS,GAAG,EAAE,EAAE,CAE5E;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,EAAE,EAAE,CAG7D"}
|