@aztec/simulator 0.0.0-test.1 → 0.0.1-commit.24de95ac
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 +5 -3
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +4 -2
- package/dest/common/errors.d.ts +4 -7
- package/dest/common/errors.d.ts.map +1 -1
- package/dest/common/errors.js +51 -32
- package/dest/common/index.d.ts +0 -1
- package/dest/common/index.d.ts.map +1 -1
- package/dest/common/index.js +0 -1
- package/dest/private/acvm/acvm.d.ts +11 -5
- 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 +1 -1
- package/dest/private/acvm/acvm_types.d.ts.map +1 -1
- package/dest/private/acvm/deserialize.d.ts +17 -18
- 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 +0 -1
- 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 +19 -2
- package/dest/private/acvm/serialize.d.ts.map +1 -1
- package/dest/private/acvm/serialize.js +53 -0
- package/dest/private/{providers/acvm_native.d.ts → acvm_native.d.ts} +9 -10
- 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 +5 -5
- package/dest/public/avm/avm_context.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.d.ts +4 -2
- 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 +3 -1
- package/dest/public/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/public/avm/avm_execution_environment.js +7 -2
- package/dest/public/avm/avm_gas.d.ts +4 -20
- 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 +2 -0
- 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 +98 -87
- 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 +4 -5
- 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 +6 -30
- 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 +5 -4
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.js +12 -14
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +6 -4
- 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 +43 -0
- package/dest/public/avm/fixtures/initializers.d.ts.map +1 -0
- package/dest/public/avm/fixtures/initializers.js +42 -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 +0 -2
- 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 +2 -2
- 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 +11 -7
- 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 +11 -1
- 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 +5 -13
- 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.map +1 -1
- package/dest/public/avm/opcodes/comparators.js +3 -3
- package/dest/public/avm/opcodes/contract.d.ts +1 -2
- 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.map +1 -1
- package/dest/public/avm/opcodes/control_flow.js +10 -8
- package/dest/public/avm/opcodes/conversion.d.ts +1 -0
- 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.map +1 -1
- package/dest/public/avm/opcodes/ec_add.js +6 -6
- package/dest/public/avm/opcodes/environment_getters.d.ts +2 -2
- 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 +8 -7
- 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.map +1 -1
- package/dest/public/avm/opcodes/hashing.js +6 -6
- package/dest/public/avm/opcodes/instruction.d.ts +14 -10
- 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/memory.d.ts +4 -4
- 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 +2 -1
- 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.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 +0 -2
- package/dest/public/avm/serialization/buffer_cursor.d.ts.map +1 -1
- package/dest/public/avm/serialization/bytecode_serialization.d.ts +2 -6
- 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 +13 -4
- 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 +10 -13
- package/dest/public/avm/test_utils.d.ts.map +1 -1
- package/dest/public/avm/test_utils.js +16 -24
- package/dest/public/db_interfaces.d.ts +56 -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 +10 -3
- 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 +9 -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 +7 -0
- 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 +10 -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 -13
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +96 -71
- package/dest/public/{avm/fixtures → fixtures}/simple_contract_data_source.d.ts +6 -6
- 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 +95 -0
- package/dest/public/fixtures/utils.d.ts +16 -3
- 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 +70 -0
- package/dest/public/hinting_db_sources.d.ts.map +1 -0
- package/dest/public/hinting_db_sources.js +297 -0
- package/dest/public/index.d.ts +4 -8
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +4 -7
- package/dest/public/public_db_sources.d.ts +30 -39
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +151 -67
- 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 -30
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +141 -96
- package/dest/public/public_processor/public_processor_metrics.d.ts +2 -2
- 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/cpp_public_tx_simulator.d.ts +41 -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 +89 -0
- package/dest/public/public_tx_simulator/index.d.ts +4 -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 +24 -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 +19 -29
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +63 -91
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +45 -47
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +209 -184
- 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 +41 -1
- 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 +20 -65
- 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 +11 -22
- 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 +2 -5
- 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 +2 -2
- package/dest/public/state_manager/public_storage.d.ts.map +1 -0
- package/dest/public/{avm/journal/journal.d.ts → state_manager/state_manager.d.ts} +42 -85
- package/dest/public/state_manager/state_manager.d.ts.map +1 -0
- package/dest/public/state_manager/state_manager.js +391 -0
- package/dest/public/test_executor_metrics.d.ts +54 -0
- package/dest/public/test_executor_metrics.d.ts.map +1 -0
- package/dest/public/test_executor_metrics.js +306 -0
- package/dest/public/unique_class_ids.d.ts.map +1 -1
- package/dest/public/utils.d.ts +2 -4
- package/dest/public/utils.d.ts.map +1 -1
- package/dest/public/utils.js +4 -21
- package/dest/server.d.ts +6 -3
- 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 +36 -31
- 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 +10 -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 +44 -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 +23 -20
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +45 -12
- package/src/public/avm/fixtures/initializers.ts +104 -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/db_interfaces.ts +61 -0
- package/src/{common → public}/debug_fn_name.ts +7 -7
- package/src/public/executor_metrics.ts +55 -6
- package/src/public/executor_metrics_interface.ts +14 -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 +36 -0
- package/src/public/fixtures/public_tx_simulation_tester.ts +158 -113
- package/src/public/{avm/fixtures → fixtures}/simple_contract_data_source.ts +36 -18
- package/src/public/fixtures/token_test.ts +140 -0
- package/src/public/fixtures/utils.ts +141 -68
- package/src/public/hinting_db_sources.ts +505 -0
- package/src/public/index.ts +9 -8
- package/src/public/public_db_sources.ts +196 -97
- 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 +191 -153
- package/src/public/public_processor/public_processor_metrics.ts +2 -2
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +128 -0
- package/src/public/public_tx_simulator/index.ts +3 -0
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +109 -0
- package/src/public/public_tx_simulator/public_tx_context.ts +160 -193
- package/src/public/public_tx_simulator/public_tx_simulator.ts +294 -220
- package/src/public/public_tx_simulator/public_tx_simulator_interface.ts +11 -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 +560 -0
- package/src/public/test_executor_metrics.ts +395 -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.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.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.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/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/test/utils.ts +0 -36
- /package/dest/public/{avm/journal → state_manager}/public_storage.js +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { serializeToBuffer } from '@aztec/foundation/serialize';
|
|
1
2
|
import { AvmExecutionError, AvmParsingError, InvalidOpcodeError, InvalidProgramCounterError } from '../errors.js';
|
|
2
3
|
import { Add, And, Call, CalldataCopy, Cast, DebugLog, Div, EcAdd, EmitNoteHash, EmitNullifier, EmitUnencryptedLog, Eq, FieldDiv, GetContractInstance, GetEnvVar, Instruction, InternalCall, InternalReturn, Jump, JumpI, KeccakF1600, L1ToL2MessageExists, Lt, Lte, Mov, Mul, Not, NoteHashExists, NullifierExists, Or, Poseidon2, Return, ReturndataCopy, ReturndataSize, Revert, SLoad, SStore, SendL2ToL1Message, Set, Sha256Compression, Shl, Shr, StaticCall, Sub, SuccessCopy, ToRadixBE, Xor } from '../opcodes/index.js';
|
|
3
4
|
import { BufferCursor } from './buffer_cursor.js';
|
|
@@ -5,289 +6,289 @@ import { MAX_OPCODE_VALUE, Opcode } from './instruction_serialization.js';
|
|
|
5
6
|
export const INSTRUCTION_SET = new Map([
|
|
6
7
|
[
|
|
7
8
|
Opcode.ADD_8,
|
|
8
|
-
Add.as(Add.wireFormat8).
|
|
9
|
+
Add.as(Add.wireFormat8).fromBuffer
|
|
9
10
|
],
|
|
10
11
|
[
|
|
11
12
|
Opcode.ADD_16,
|
|
12
|
-
Add.as(Add.wireFormat16).
|
|
13
|
+
Add.as(Add.wireFormat16).fromBuffer
|
|
13
14
|
],
|
|
14
15
|
[
|
|
15
16
|
Opcode.SUB_8,
|
|
16
|
-
Sub.as(Sub.wireFormat8).
|
|
17
|
+
Sub.as(Sub.wireFormat8).fromBuffer
|
|
17
18
|
],
|
|
18
19
|
[
|
|
19
20
|
Opcode.SUB_16,
|
|
20
|
-
Sub.as(Sub.wireFormat16).
|
|
21
|
+
Sub.as(Sub.wireFormat16).fromBuffer
|
|
21
22
|
],
|
|
22
23
|
[
|
|
23
24
|
Opcode.MUL_8,
|
|
24
|
-
Mul.as(Mul.wireFormat8).
|
|
25
|
+
Mul.as(Mul.wireFormat8).fromBuffer
|
|
25
26
|
],
|
|
26
27
|
[
|
|
27
28
|
Opcode.MUL_16,
|
|
28
|
-
Mul.as(Mul.wireFormat16).
|
|
29
|
+
Mul.as(Mul.wireFormat16).fromBuffer
|
|
29
30
|
],
|
|
30
31
|
[
|
|
31
32
|
Opcode.DIV_8,
|
|
32
|
-
Div.as(Div.wireFormat8).
|
|
33
|
+
Div.as(Div.wireFormat8).fromBuffer
|
|
33
34
|
],
|
|
34
35
|
[
|
|
35
36
|
Opcode.DIV_16,
|
|
36
|
-
Div.as(Div.wireFormat16).
|
|
37
|
+
Div.as(Div.wireFormat16).fromBuffer
|
|
37
38
|
],
|
|
38
39
|
[
|
|
39
40
|
Opcode.FDIV_8,
|
|
40
|
-
FieldDiv.as(FieldDiv.wireFormat8).
|
|
41
|
+
FieldDiv.as(FieldDiv.wireFormat8).fromBuffer
|
|
41
42
|
],
|
|
42
43
|
[
|
|
43
44
|
Opcode.FDIV_16,
|
|
44
|
-
FieldDiv.as(FieldDiv.wireFormat16).
|
|
45
|
+
FieldDiv.as(FieldDiv.wireFormat16).fromBuffer
|
|
45
46
|
],
|
|
46
47
|
[
|
|
47
48
|
Opcode.EQ_8,
|
|
48
|
-
Eq.as(Eq.wireFormat8).
|
|
49
|
+
Eq.as(Eq.wireFormat8).fromBuffer
|
|
49
50
|
],
|
|
50
51
|
[
|
|
51
52
|
Opcode.EQ_16,
|
|
52
|
-
Eq.as(Eq.wireFormat16).
|
|
53
|
+
Eq.as(Eq.wireFormat16).fromBuffer
|
|
53
54
|
],
|
|
54
55
|
[
|
|
55
56
|
Opcode.LT_8,
|
|
56
|
-
Lt.as(Lt.wireFormat8).
|
|
57
|
+
Lt.as(Lt.wireFormat8).fromBuffer
|
|
57
58
|
],
|
|
58
59
|
[
|
|
59
60
|
Opcode.LT_16,
|
|
60
|
-
Lt.as(Lt.wireFormat16).
|
|
61
|
+
Lt.as(Lt.wireFormat16).fromBuffer
|
|
61
62
|
],
|
|
62
63
|
[
|
|
63
64
|
Opcode.LTE_8,
|
|
64
|
-
Lte.as(Lte.wireFormat8).
|
|
65
|
+
Lte.as(Lte.wireFormat8).fromBuffer
|
|
65
66
|
],
|
|
66
67
|
[
|
|
67
68
|
Opcode.LTE_16,
|
|
68
|
-
Lte.as(Lte.wireFormat16).
|
|
69
|
+
Lte.as(Lte.wireFormat16).fromBuffer
|
|
69
70
|
],
|
|
70
71
|
[
|
|
71
72
|
Opcode.AND_8,
|
|
72
|
-
And.as(And.wireFormat8).
|
|
73
|
+
And.as(And.wireFormat8).fromBuffer
|
|
73
74
|
],
|
|
74
75
|
[
|
|
75
76
|
Opcode.AND_16,
|
|
76
|
-
And.as(And.wireFormat16).
|
|
77
|
+
And.as(And.wireFormat16).fromBuffer
|
|
77
78
|
],
|
|
78
79
|
[
|
|
79
80
|
Opcode.OR_8,
|
|
80
|
-
Or.as(Or.wireFormat8).
|
|
81
|
+
Or.as(Or.wireFormat8).fromBuffer
|
|
81
82
|
],
|
|
82
83
|
[
|
|
83
84
|
Opcode.OR_16,
|
|
84
|
-
Or.as(Or.wireFormat16).
|
|
85
|
+
Or.as(Or.wireFormat16).fromBuffer
|
|
85
86
|
],
|
|
86
87
|
[
|
|
87
88
|
Opcode.XOR_8,
|
|
88
|
-
Xor.as(Xor.wireFormat8).
|
|
89
|
+
Xor.as(Xor.wireFormat8).fromBuffer
|
|
89
90
|
],
|
|
90
91
|
[
|
|
91
92
|
Opcode.XOR_16,
|
|
92
|
-
Xor.as(Xor.wireFormat16).
|
|
93
|
+
Xor.as(Xor.wireFormat16).fromBuffer
|
|
93
94
|
],
|
|
94
95
|
[
|
|
95
96
|
Opcode.NOT_8,
|
|
96
|
-
Not.as(Not.wireFormat8).
|
|
97
|
+
Not.as(Not.wireFormat8).fromBuffer
|
|
97
98
|
],
|
|
98
99
|
[
|
|
99
100
|
Opcode.NOT_16,
|
|
100
|
-
Not.as(Not.wireFormat16).
|
|
101
|
+
Not.as(Not.wireFormat16).fromBuffer
|
|
101
102
|
],
|
|
102
103
|
[
|
|
103
104
|
Opcode.SHL_8,
|
|
104
|
-
Shl.as(Shl.wireFormat8).
|
|
105
|
+
Shl.as(Shl.wireFormat8).fromBuffer
|
|
105
106
|
],
|
|
106
107
|
[
|
|
107
108
|
Opcode.SHL_16,
|
|
108
|
-
Shl.as(Shl.wireFormat16).
|
|
109
|
+
Shl.as(Shl.wireFormat16).fromBuffer
|
|
109
110
|
],
|
|
110
111
|
[
|
|
111
112
|
Opcode.SHR_8,
|
|
112
|
-
Shr.as(Shr.wireFormat8).
|
|
113
|
+
Shr.as(Shr.wireFormat8).fromBuffer
|
|
113
114
|
],
|
|
114
115
|
[
|
|
115
116
|
Opcode.SHR_16,
|
|
116
|
-
Shr.as(Shr.wireFormat16).
|
|
117
|
+
Shr.as(Shr.wireFormat16).fromBuffer
|
|
117
118
|
],
|
|
118
119
|
[
|
|
119
120
|
Opcode.CAST_8,
|
|
120
|
-
Cast.as(Cast.wireFormat8).
|
|
121
|
+
Cast.as(Cast.wireFormat8).fromBuffer
|
|
121
122
|
],
|
|
122
123
|
[
|
|
123
124
|
Opcode.CAST_16,
|
|
124
|
-
Cast.as(Cast.wireFormat16).
|
|
125
|
+
Cast.as(Cast.wireFormat16).fromBuffer
|
|
125
126
|
],
|
|
126
127
|
// Execution Environment
|
|
127
128
|
[
|
|
128
129
|
Opcode.GETENVVAR_16,
|
|
129
|
-
GetEnvVar.as(GetEnvVar.wireFormat16).
|
|
130
|
+
GetEnvVar.as(GetEnvVar.wireFormat16).fromBuffer
|
|
130
131
|
],
|
|
131
132
|
[
|
|
132
133
|
CalldataCopy.opcode,
|
|
133
|
-
Instruction.
|
|
134
|
+
Instruction.fromBuffer.bind(CalldataCopy)
|
|
134
135
|
],
|
|
135
136
|
[
|
|
136
137
|
SuccessCopy.opcode,
|
|
137
|
-
Instruction.
|
|
138
|
+
Instruction.fromBuffer.bind(SuccessCopy)
|
|
138
139
|
],
|
|
139
140
|
[
|
|
140
141
|
Opcode.RETURNDATASIZE,
|
|
141
|
-
Instruction.
|
|
142
|
+
Instruction.fromBuffer.bind(ReturndataSize)
|
|
142
143
|
],
|
|
143
144
|
[
|
|
144
145
|
Opcode.RETURNDATACOPY,
|
|
145
|
-
Instruction.
|
|
146
|
+
Instruction.fromBuffer.bind(ReturndataCopy)
|
|
146
147
|
],
|
|
147
148
|
// Machine State - Internal Control Flow
|
|
148
149
|
[
|
|
149
150
|
Jump.opcode,
|
|
150
|
-
Instruction.
|
|
151
|
+
Instruction.fromBuffer.bind(Jump)
|
|
151
152
|
],
|
|
152
153
|
[
|
|
153
154
|
JumpI.opcode,
|
|
154
|
-
Instruction.
|
|
155
|
+
Instruction.fromBuffer.bind(JumpI)
|
|
155
156
|
],
|
|
156
157
|
[
|
|
157
158
|
InternalCall.opcode,
|
|
158
|
-
Instruction.
|
|
159
|
+
Instruction.fromBuffer.bind(InternalCall)
|
|
159
160
|
],
|
|
160
161
|
[
|
|
161
162
|
InternalReturn.opcode,
|
|
162
|
-
Instruction.
|
|
163
|
+
Instruction.fromBuffer.bind(InternalReturn)
|
|
163
164
|
],
|
|
164
165
|
[
|
|
165
166
|
Opcode.SET_8,
|
|
166
|
-
Set.as(Set.wireFormat8).
|
|
167
|
+
Set.as(Set.wireFormat8).fromBuffer
|
|
167
168
|
],
|
|
168
169
|
[
|
|
169
170
|
Opcode.SET_16,
|
|
170
|
-
Set.as(Set.wireFormat16).
|
|
171
|
+
Set.as(Set.wireFormat16).fromBuffer
|
|
171
172
|
],
|
|
172
173
|
[
|
|
173
174
|
Opcode.SET_32,
|
|
174
|
-
Set.as(Set.wireFormat32).
|
|
175
|
+
Set.as(Set.wireFormat32).fromBuffer
|
|
175
176
|
],
|
|
176
177
|
[
|
|
177
178
|
Opcode.SET_64,
|
|
178
|
-
Set.as(Set.wireFormat64).
|
|
179
|
+
Set.as(Set.wireFormat64).fromBuffer
|
|
179
180
|
],
|
|
180
181
|
[
|
|
181
182
|
Opcode.SET_128,
|
|
182
|
-
Set.as(Set.wireFormat128).
|
|
183
|
+
Set.as(Set.wireFormat128).fromBuffer
|
|
183
184
|
],
|
|
184
185
|
[
|
|
185
186
|
Opcode.SET_FF,
|
|
186
|
-
Set.as(Set.wireFormatFF).
|
|
187
|
+
Set.as(Set.wireFormatFF).fromBuffer
|
|
187
188
|
],
|
|
188
189
|
[
|
|
189
190
|
Opcode.MOV_8,
|
|
190
|
-
Mov.as(Mov.wireFormat8).
|
|
191
|
+
Mov.as(Mov.wireFormat8).fromBuffer
|
|
191
192
|
],
|
|
192
193
|
[
|
|
193
194
|
Opcode.MOV_16,
|
|
194
|
-
Mov.as(Mov.wireFormat16).
|
|
195
|
+
Mov.as(Mov.wireFormat16).fromBuffer
|
|
195
196
|
],
|
|
196
197
|
// World State
|
|
197
198
|
[
|
|
198
199
|
SLoad.opcode,
|
|
199
|
-
Instruction.
|
|
200
|
+
Instruction.fromBuffer.bind(SLoad)
|
|
200
201
|
],
|
|
201
202
|
[
|
|
202
203
|
SStore.opcode,
|
|
203
|
-
Instruction.
|
|
204
|
+
Instruction.fromBuffer.bind(SStore)
|
|
204
205
|
],
|
|
205
206
|
[
|
|
206
207
|
NoteHashExists.opcode,
|
|
207
|
-
Instruction.
|
|
208
|
+
Instruction.fromBuffer.bind(NoteHashExists)
|
|
208
209
|
],
|
|
209
210
|
[
|
|
210
211
|
EmitNoteHash.opcode,
|
|
211
|
-
Instruction.
|
|
212
|
+
Instruction.fromBuffer.bind(EmitNoteHash)
|
|
212
213
|
],
|
|
213
214
|
[
|
|
214
215
|
NullifierExists.opcode,
|
|
215
|
-
Instruction.
|
|
216
|
+
Instruction.fromBuffer.bind(NullifierExists)
|
|
216
217
|
],
|
|
217
218
|
[
|
|
218
219
|
EmitNullifier.opcode,
|
|
219
|
-
Instruction.
|
|
220
|
+
Instruction.fromBuffer.bind(EmitNullifier)
|
|
220
221
|
],
|
|
221
222
|
[
|
|
222
223
|
L1ToL2MessageExists.opcode,
|
|
223
|
-
Instruction.
|
|
224
|
+
Instruction.fromBuffer.bind(L1ToL2MessageExists)
|
|
224
225
|
],
|
|
225
226
|
// Accrued Substate
|
|
226
227
|
[
|
|
227
228
|
EmitUnencryptedLog.opcode,
|
|
228
|
-
Instruction.
|
|
229
|
+
Instruction.fromBuffer.bind(EmitUnencryptedLog)
|
|
229
230
|
],
|
|
230
231
|
[
|
|
231
232
|
SendL2ToL1Message.opcode,
|
|
232
|
-
Instruction.
|
|
233
|
+
Instruction.fromBuffer.bind(SendL2ToL1Message)
|
|
233
234
|
],
|
|
234
235
|
[
|
|
235
236
|
GetContractInstance.opcode,
|
|
236
|
-
Instruction.
|
|
237
|
+
Instruction.fromBuffer.bind(GetContractInstance)
|
|
237
238
|
],
|
|
238
239
|
// Control Flow - Contract Calls
|
|
239
240
|
[
|
|
240
241
|
Call.opcode,
|
|
241
|
-
Instruction.
|
|
242
|
+
Instruction.fromBuffer.bind(Call)
|
|
242
243
|
],
|
|
243
244
|
[
|
|
244
245
|
StaticCall.opcode,
|
|
245
|
-
Instruction.
|
|
246
|
+
Instruction.fromBuffer.bind(StaticCall)
|
|
246
247
|
],
|
|
247
248
|
[
|
|
248
249
|
Return.opcode,
|
|
249
|
-
Instruction.
|
|
250
|
+
Instruction.fromBuffer.bind(Return)
|
|
250
251
|
],
|
|
251
252
|
[
|
|
252
253
|
Opcode.REVERT_8,
|
|
253
|
-
Revert.as(Revert.wireFormat8).
|
|
254
|
+
Revert.as(Revert.wireFormat8).fromBuffer
|
|
254
255
|
],
|
|
255
256
|
[
|
|
256
257
|
Opcode.REVERT_16,
|
|
257
|
-
Revert.as(Revert.wireFormat16).
|
|
258
|
+
Revert.as(Revert.wireFormat16).fromBuffer
|
|
258
259
|
],
|
|
259
260
|
// Misc
|
|
260
261
|
[
|
|
261
262
|
DebugLog.opcode,
|
|
262
|
-
Instruction.
|
|
263
|
+
Instruction.fromBuffer.bind(DebugLog)
|
|
263
264
|
],
|
|
264
265
|
// Gadgets
|
|
265
266
|
[
|
|
266
267
|
EcAdd.opcode,
|
|
267
|
-
Instruction.
|
|
268
|
+
Instruction.fromBuffer.bind(EcAdd)
|
|
268
269
|
],
|
|
269
270
|
[
|
|
270
271
|
Poseidon2.opcode,
|
|
271
|
-
Instruction.
|
|
272
|
+
Instruction.fromBuffer.bind(Poseidon2)
|
|
272
273
|
],
|
|
273
274
|
[
|
|
274
275
|
Sha256Compression.opcode,
|
|
275
|
-
Instruction.
|
|
276
|
+
Instruction.fromBuffer.bind(Sha256Compression)
|
|
276
277
|
],
|
|
277
278
|
[
|
|
278
279
|
KeccakF1600.opcode,
|
|
279
|
-
Instruction.
|
|
280
|
+
Instruction.fromBuffer.bind(KeccakF1600)
|
|
280
281
|
],
|
|
281
282
|
// Conversions
|
|
282
283
|
[
|
|
283
284
|
ToRadixBE.opcode,
|
|
284
|
-
Instruction.
|
|
285
|
+
Instruction.fromBuffer.bind(ToRadixBE)
|
|
285
286
|
]
|
|
286
287
|
]);
|
|
287
288
|
/**
|
|
288
289
|
* Serializes an array of instructions to bytecode.
|
|
289
290
|
*/ export function encodeToBytecode(instructions) {
|
|
290
|
-
return
|
|
291
|
+
return serializeToBuffer(instructions);
|
|
291
292
|
}
|
|
292
293
|
// For testing only
|
|
293
294
|
export function decodeFromBytecode(bytecode, instructionSet = INSTRUCTION_SET) {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
1
|
import { BufferCursor } from './buffer_cursor.js';
|
|
4
2
|
/**
|
|
5
3
|
* All AVM opcodes. (Keep in sync with cpp counterpart code avm_opcode.hpp and rs in opcodes.rs).
|
|
@@ -82,15 +80,25 @@ export declare enum OperandType {
|
|
|
82
80
|
UINT32 = 2,
|
|
83
81
|
UINT64 = 3,
|
|
84
82
|
UINT128 = 4,
|
|
85
|
-
FF = 5
|
|
83
|
+
FF = 5,
|
|
84
|
+
TAG = 6
|
|
86
85
|
}
|
|
86
|
+
type DeserializedValue = number | bigint;
|
|
87
|
+
/**
|
|
88
|
+
* Returns the size of an operand in bytes.
|
|
89
|
+
* Should not be called with unknown operand types.
|
|
90
|
+
* @param operandType
|
|
91
|
+
* @returns number size in bytes
|
|
92
|
+
* @throws AssertionError if the operand type is unknown
|
|
93
|
+
*/
|
|
94
|
+
export declare function getOperandSize(operandType: OperandType): number;
|
|
87
95
|
/**
|
|
88
96
|
* Reads an array of operands from a buffer.
|
|
89
97
|
* @param cursor Buffer to read from. Might be longer than needed.
|
|
90
98
|
* @param operands Specification of the operand types.
|
|
91
99
|
* @returns An array as big as {@code operands}, with the converted TS values.
|
|
92
100
|
*/
|
|
93
|
-
export declare function deserialize(cursor: BufferCursor | Buffer, operands: OperandType[]):
|
|
101
|
+
export declare function deserialize(cursor: BufferCursor | Buffer, operands: OperandType[]): DeserializedValue[];
|
|
94
102
|
/**
|
|
95
103
|
* Serializes a class using the specified operand types.
|
|
96
104
|
* More specifically, this serializes {@code [cls.constructor.opcode, ...Object.values(cls)]}.
|
|
@@ -102,4 +110,5 @@ export declare function deserialize(cursor: BufferCursor | Buffer, operands: Ope
|
|
|
102
110
|
* @returns
|
|
103
111
|
*/
|
|
104
112
|
export declare function serializeAs(operands: OperandType[], opcode: Opcode, cls: any): Buffer;
|
|
113
|
+
export {};
|
|
105
114
|
//# sourceMappingURL=instruction_serialization.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instruction_serialization.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/serialization/instruction_serialization.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"instruction_serialization.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/serialization/instruction_serialization.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;GAGG;AACH,oBAAY,MAAM;IAEhB,KAAK,IAAA;IACL,MAAM,IAAA;IACN,KAAK,IAAA;IACL,MAAM,IAAA;IACN,KAAK,IAAA;IACL,MAAM,IAAA;IACN,KAAK,IAAA;IACL,MAAM,IAAA;IACN,MAAM,IAAA;IACN,OAAO,IAAA;IACP,IAAI,KAAA;IACJ,KAAK,KAAA;IACL,IAAI,KAAA;IACJ,KAAK,KAAA;IACL,KAAK,KAAA;IACL,MAAM,KAAA;IACN,KAAK,KAAA;IACL,MAAM,KAAA;IACN,IAAI,KAAA;IACJ,KAAK,KAAA;IACL,KAAK,KAAA;IACL,MAAM,KAAA;IACN,KAAK,KAAA;IACL,MAAM,KAAA;IACN,KAAK,KAAA;IACL,MAAM,KAAA;IACN,KAAK,KAAA;IACL,MAAM,KAAA;IACN,MAAM,KAAA;IACN,OAAO,KAAA;IAEP,YAAY,KAAA;IACZ,YAAY,KAAA;IACZ,WAAW,KAAA;IACX,cAAc,KAAA;IACd,cAAc,KAAA;IAEd,OAAO,KAAA;IACP,QAAQ,KAAA;IACR,YAAY,KAAA;IACZ,cAAc,KAAA;IAEd,KAAK,KAAA;IACL,MAAM,KAAA;IACN,MAAM,KAAA;IACN,MAAM,KAAA;IACN,OAAO,KAAA;IACP,MAAM,KAAA;IACN,KAAK,KAAA;IACL,MAAM,KAAA;IAEN,KAAK,KAAA;IACL,MAAM,KAAA;IACN,cAAc,KAAA;IACd,YAAY,KAAA;IACZ,eAAe,KAAA;IACf,aAAa,KAAA;IACb,eAAe,KAAA;IACf,mBAAmB,KAAA;IACnB,kBAAkB,KAAA;IAClB,aAAa,KAAA;IAEb,IAAI,KAAA;IACJ,UAAU,KAAA;IACV,MAAM,KAAA;IACN,QAAQ,KAAA;IACR,SAAS,KAAA;IAET,QAAQ,KAAA;IAER,SAAS,KAAA;IACT,iBAAiB,KAAA;IACjB,WAAW,KAAA;IACX,KAAK,KAAA;IAEL,SAAS,KAAA;CACV;AAED,eAAO,MAAM,gBAAgB,QAI5B,CAAC;AAIF,oBAAY,WAAW;IACrB,KAAK,IAAA;IACL,MAAM,IAAA;IACN,MAAM,IAAA;IACN,MAAM,IAAA;IACN,OAAO,IAAA;IACP,EAAE,IAAA;IACF,GAAG,IAAA;CACJ;AAGD,KAAK,iBAAiB,GAAG,MAAM,GAAG,MAAM,CAAC;AAgBzC;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAG/D;AAkDD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,iBAAiB,EAAE,CAyBvG;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,MAAM,CAmBrF"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
1
2
|
import { strict as assert } from 'assert';
|
|
3
|
+
import { TaggedMemory } from '../avm_memory_types.js';
|
|
2
4
|
import { BufferCursor } from './buffer_cursor.js';
|
|
3
5
|
/**
|
|
4
6
|
* All AVM opcodes. (Keep in sync with cpp counterpart code avm_opcode.hpp and rs in opcodes.rs).
|
|
@@ -84,10 +86,8 @@ import { BufferCursor } from './buffer_cursor.js';
|
|
|
84
86
|
return Opcode;
|
|
85
87
|
}({});
|
|
86
88
|
export const MAX_OPCODE_VALUE = Math.max(...Object.values(Opcode).map((k)=>+k).filter((k)=>!isNaN(k)));
|
|
87
|
-
// Possible types for an instruction's operand in its wire format.
|
|
88
|
-
//
|
|
89
|
-
// Note that cpp code introduced an additional enum value TAG to express the instruction tag. In TS,
|
|
90
|
-
// this one is parsed as UINT8.
|
|
89
|
+
// Possible types for an instruction's operand in its wire format.
|
|
90
|
+
// The counterpart cpp file is: vm2/simulation/lib/serialization.hpp.
|
|
91
91
|
export var OperandType = /*#__PURE__*/ function(OperandType) {
|
|
92
92
|
OperandType[OperandType["UINT8"] = 0] = "UINT8";
|
|
93
93
|
OperandType[OperandType["UINT16"] = 1] = "UINT16";
|
|
@@ -95,6 +95,7 @@ export var OperandType = /*#__PURE__*/ function(OperandType) {
|
|
|
95
95
|
OperandType[OperandType["UINT64"] = 3] = "UINT64";
|
|
96
96
|
OperandType[OperandType["UINT128"] = 4] = "UINT128";
|
|
97
97
|
OperandType[OperandType["FF"] = 5] = "FF";
|
|
98
|
+
OperandType[OperandType["TAG"] = 6] = "TAG";
|
|
98
99
|
return OperandType;
|
|
99
100
|
}({});
|
|
100
101
|
// Specifies how to read and write each operand type.
|
|
@@ -127,58 +128,82 @@ const OPERAND_SPEC = new Map([
|
|
|
127
128
|
3,
|
|
128
129
|
[
|
|
129
130
|
8,
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
readUint64BE,
|
|
132
|
+
writeUint64BE
|
|
132
133
|
]
|
|
133
134
|
],
|
|
134
135
|
[
|
|
135
136
|
4,
|
|
136
137
|
[
|
|
137
138
|
16,
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
readUint128BE,
|
|
140
|
+
writeUint128BE
|
|
140
141
|
]
|
|
141
142
|
],
|
|
142
143
|
[
|
|
143
144
|
5,
|
|
144
145
|
[
|
|
145
146
|
32,
|
|
146
|
-
|
|
147
|
-
|
|
147
|
+
readUint254BE,
|
|
148
|
+
writeUint254BE
|
|
149
|
+
]
|
|
150
|
+
],
|
|
151
|
+
[
|
|
152
|
+
6,
|
|
153
|
+
[
|
|
154
|
+
1,
|
|
155
|
+
Buffer.prototype.readUint8,
|
|
156
|
+
Buffer.prototype.writeUint8
|
|
148
157
|
]
|
|
149
158
|
]
|
|
150
159
|
]);
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
160
|
+
/**
|
|
161
|
+
* Returns the size of an operand in bytes.
|
|
162
|
+
* Should not be called with unknown operand types.
|
|
163
|
+
* @param operandType
|
|
164
|
+
* @returns number size in bytes
|
|
165
|
+
* @throws AssertionError if the operand type is unknown
|
|
166
|
+
*/ export function getOperandSize(operandType) {
|
|
167
|
+
assert(OPERAND_SPEC.has(operandType), `Unknown operand type: ${operandType}`);
|
|
168
|
+
return OPERAND_SPEC.get(operandType)[0];
|
|
169
|
+
}
|
|
170
|
+
function readUintBE(buf, offset, totalBytes) {
|
|
171
|
+
let value = 0n;
|
|
154
172
|
for(let i = 0; i < totalBytes; ++i){
|
|
155
|
-
|
|
156
|
-
|
|
173
|
+
value <<= 8n;
|
|
174
|
+
value |= BigInt(buf.readUint8(i + offset));
|
|
157
175
|
}
|
|
158
|
-
return
|
|
176
|
+
return value;
|
|
159
177
|
}
|
|
160
|
-
function
|
|
161
|
-
const totalBytes = 32;
|
|
178
|
+
function writeUintBE(buf, value, totalBytes) {
|
|
162
179
|
for(let offset = totalBytes - 1; offset >= 0; --offset){
|
|
163
|
-
|
|
180
|
+
buf.writeUint8(Number(value & 0xffn), offset);
|
|
164
181
|
value >>= 8n;
|
|
165
182
|
}
|
|
166
183
|
}
|
|
167
|
-
function
|
|
168
|
-
|
|
169
|
-
let ret = 0n;
|
|
170
|
-
for(let i = 0; i < totalBytes; ++i){
|
|
171
|
-
ret <<= 8n;
|
|
172
|
-
ret |= BigInt(this.readUint8(i + offset));
|
|
173
|
-
}
|
|
174
|
-
return ret;
|
|
184
|
+
function readUint64BE(offset) {
|
|
185
|
+
return readUintBE(this, offset, 8);
|
|
175
186
|
}
|
|
176
|
-
function
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
187
|
+
function writeUint64BE(value) {
|
|
188
|
+
writeUintBE(this, value, 8);
|
|
189
|
+
}
|
|
190
|
+
function readUint254BE(offset) {
|
|
191
|
+
let value = readUintBE(this, offset, 32);
|
|
192
|
+
// In circuit, we only support values up to Fr.MODULUS and any deserialized value
|
|
193
|
+
// would naturally undergo a modulus reduction.
|
|
194
|
+
if (value >= Fr.MODULUS) {
|
|
195
|
+
value = value % Fr.MODULUS;
|
|
181
196
|
}
|
|
197
|
+
return value;
|
|
198
|
+
}
|
|
199
|
+
function writeUint254BE(value) {
|
|
200
|
+
writeUintBE(this, value, 32);
|
|
201
|
+
}
|
|
202
|
+
function readUint128BE(offset) {
|
|
203
|
+
return readUintBE(this, offset, 16);
|
|
204
|
+
}
|
|
205
|
+
function writeUint128BE(value) {
|
|
206
|
+
writeUintBE(this, value, 16);
|
|
182
207
|
}
|
|
183
208
|
/**
|
|
184
209
|
* Reads an array of operands from a buffer.
|
|
@@ -190,12 +215,22 @@ function writeBigInt128BE(value) {
|
|
|
190
215
|
if (Buffer.isBuffer(cursor)) {
|
|
191
216
|
cursor = new BufferCursor(cursor);
|
|
192
217
|
}
|
|
193
|
-
for (const
|
|
194
|
-
const opType = op;
|
|
218
|
+
for (const opType of operands){
|
|
195
219
|
const [sizeBytes, reader, _writer] = OPERAND_SPEC.get(opType);
|
|
196
|
-
|
|
220
|
+
const value = reader.call(cursor.buffer(), cursor.position());
|
|
221
|
+
argValues.push(value);
|
|
197
222
|
cursor.advance(sizeBytes);
|
|
198
223
|
}
|
|
224
|
+
// We first want to detect other parsing errors (e.g., instruction size
|
|
225
|
+
// is longer than remaining bytes) first and therefore tag validation is done after completion
|
|
226
|
+
// of parsing above. Order of errors need to match with circuit.
|
|
227
|
+
for(let i = 0; i < operands.length; i++){
|
|
228
|
+
if (operands[i] === 6) {
|
|
229
|
+
// We parsed a single byte (readUInt8()) and therefore value is of number type (not bigint)
|
|
230
|
+
// We need to cast to number because checkIsValidTag expects a number.
|
|
231
|
+
TaggedMemory.checkIsValidTag(Number(argValues[i] ?? 0));
|
|
232
|
+
}
|
|
233
|
+
}
|
|
199
234
|
return argValues;
|
|
200
235
|
}
|
|
201
236
|
/**
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
-
import {
|
|
5
|
-
import type {
|
|
2
|
+
import type { ContractClassPublic, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
3
|
+
import type { PublicContractsDB, PublicTreesDB } from '../public_db_sources.js';
|
|
6
4
|
import type { PublicSideEffectTraceInterface } from '../side_effect_trace_interface.js';
|
|
7
|
-
export declare function mockGetBytecode(worldStateDB: WorldStateDB, bytecode: Buffer): Promise<void>;
|
|
8
5
|
export declare function mockTraceFork(trace: PublicSideEffectTraceInterface, nestedTrace?: PublicSideEffectTraceInterface): void;
|
|
9
|
-
export declare function mockStorageRead(worldStateDB:
|
|
6
|
+
export declare function mockStorageRead(worldStateDB: PublicTreesDB, value: Fr): void;
|
|
10
7
|
export declare function mockNoteHashCount(mockedTrace: PublicSideEffectTraceInterface, count: number): void;
|
|
11
|
-
export declare function mockStorageReadWithMap(worldStateDB:
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
15
|
-
export declare function
|
|
16
|
-
export declare function
|
|
17
|
-
export declare function
|
|
8
|
+
export declare function mockStorageReadWithMap(worldStateDB: PublicTreesDB, mockedStorage: Map<bigint, Fr>): void;
|
|
9
|
+
export declare function mockGetNoteHash(worldStateDB: PublicTreesDB, _leafIndex: bigint, value?: Fr): void;
|
|
10
|
+
export declare function mockCheckNullifierExists(worldStateDB: PublicTreesDB, exists: boolean, _ignoredValue?: Fr): void;
|
|
11
|
+
export declare function mockGetL1ToL2LeafValue(worldStateDB: PublicTreesDB, leafIndex: bigint, value?: Fr): void;
|
|
12
|
+
export declare function mockGetContractInstance(contractsDB: PublicContractsDB, contractInstance: ContractInstanceWithAddress): void;
|
|
13
|
+
export declare function mockGetContractClass(contractsDB: PublicContractsDB, contractClass: ContractClassPublic): void;
|
|
14
|
+
export declare function mockGetBytecodeCommitment(contractsDB: PublicContractsDB, commitment: Fr): void;
|
|
18
15
|
//# sourceMappingURL=test_utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_utils.d.ts","sourceRoot":"","sources":["../../../src/public/avm/test_utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test_utils.d.ts","sourceRoot":"","sources":["../../../src/public/avm/test_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAK/F,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AAExF,wBAAgB,aAAa,CAAC,KAAK,EAAE,8BAA8B,EAAE,WAAW,CAAC,EAAE,8BAA8B,QAIhH;AAED,wBAAgB,eAAe,CAAC,YAAY,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE,QAErE;AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,8BAA8B,EAAE,KAAK,EAAE,MAAM,QAE3F;AAED,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,QAIjG;AAED,wBAAgB,eAAe,CAAC,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,QAQ1F;AAED,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,EAAE,QAExG;AAED,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,QAQhG;AAED,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,2BAA2B,QAEpH;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,iBAAiB,EAAE,aAAa,EAAE,mBAAmB,QAEtG;AAED,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,iBAAiB,EAAE,UAAU,EAAE,EAAE,QAEvF"}
|