@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
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { keccakf1600, poseidon2Permutation, sha256Compression } from '@aztec/foundation/crypto';
|
|
2
|
+
import { Field, TypeTag, Uint32, Uint64 } from '../avm_memory_types.js';
|
|
3
|
+
import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
|
|
4
|
+
import { Addressing } from './addressing_mode.js';
|
|
5
|
+
import { Instruction } from './instruction.js';
|
|
6
|
+
export class Poseidon2 extends Instruction {
|
|
7
|
+
indirect;
|
|
8
|
+
inputStateOffset;
|
|
9
|
+
outputStateOffset;
|
|
10
|
+
static type = 'POSEIDON2';
|
|
11
|
+
static opcode = Opcode.POSEIDON2;
|
|
12
|
+
static stateSize = 4;
|
|
13
|
+
// Informs (de)serialization. See Instruction.deserialize.
|
|
14
|
+
static wireFormat = [
|
|
15
|
+
OperandType.UINT8,
|
|
16
|
+
OperandType.UINT8,
|
|
17
|
+
OperandType.UINT16,
|
|
18
|
+
OperandType.UINT16
|
|
19
|
+
];
|
|
20
|
+
constructor(indirect, inputStateOffset, outputStateOffset){
|
|
21
|
+
super(), this.indirect = indirect, this.inputStateOffset = inputStateOffset, this.outputStateOffset = outputStateOffset;
|
|
22
|
+
}
|
|
23
|
+
async execute(context) {
|
|
24
|
+
const memory = context.machineState.memory;
|
|
25
|
+
context.machineState.consumeGas(this.gasCost());
|
|
26
|
+
const operands = [
|
|
27
|
+
this.inputStateOffset,
|
|
28
|
+
this.outputStateOffset
|
|
29
|
+
];
|
|
30
|
+
const addressing = Addressing.fromWire(this.indirect, operands.length);
|
|
31
|
+
const [inputOffset, outputOffset] = addressing.resolve(operands, memory);
|
|
32
|
+
const inputState = memory.getSlice(inputOffset, Poseidon2.stateSize);
|
|
33
|
+
memory.checkTagsRange(TypeTag.FIELD, inputOffset, Poseidon2.stateSize);
|
|
34
|
+
const outputState = await poseidon2Permutation(inputState);
|
|
35
|
+
memory.setSlice(outputOffset, outputState.map((word)=>new Field(word)));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export class KeccakF1600 extends Instruction {
|
|
39
|
+
indirect;
|
|
40
|
+
dstOffset;
|
|
41
|
+
inputOffset;
|
|
42
|
+
static type = 'KECCAKF1600';
|
|
43
|
+
static opcode = Opcode.KECCAKF1600;
|
|
44
|
+
// Informs (de)serialization. See Instruction.deserialize.
|
|
45
|
+
static wireFormat = [
|
|
46
|
+
OperandType.UINT8,
|
|
47
|
+
OperandType.UINT8,
|
|
48
|
+
OperandType.UINT16,
|
|
49
|
+
OperandType.UINT16
|
|
50
|
+
];
|
|
51
|
+
constructor(indirect, dstOffset, inputOffset){
|
|
52
|
+
super(), this.indirect = indirect, this.dstOffset = dstOffset, this.inputOffset = inputOffset;
|
|
53
|
+
}
|
|
54
|
+
// pub fn keccakf1600(input: [u64; 25]) -> [u64; 25]
|
|
55
|
+
async execute(context) {
|
|
56
|
+
const inputSize = 25;
|
|
57
|
+
const memory = context.machineState.memory;
|
|
58
|
+
const operands = [
|
|
59
|
+
this.dstOffset,
|
|
60
|
+
this.inputOffset
|
|
61
|
+
];
|
|
62
|
+
const addressing = Addressing.fromWire(this.indirect, operands.length);
|
|
63
|
+
const [dstOffset, inputOffset] = addressing.resolve(operands, memory);
|
|
64
|
+
context.machineState.consumeGas(this.gasCost());
|
|
65
|
+
const stateData = memory.getSlice(inputOffset, inputSize).map((word)=>word.toBigInt());
|
|
66
|
+
memory.checkTagsRange(TypeTag.UINT64, inputOffset, inputSize);
|
|
67
|
+
const updatedState = keccakf1600(stateData);
|
|
68
|
+
const res = updatedState.map((word)=>new Uint64(word));
|
|
69
|
+
memory.setSlice(dstOffset, res);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export class Sha256Compression extends Instruction {
|
|
73
|
+
indirect;
|
|
74
|
+
outputOffset;
|
|
75
|
+
stateOffset;
|
|
76
|
+
inputsOffset;
|
|
77
|
+
static type = 'SHA256COMPRESSION';
|
|
78
|
+
static opcode = Opcode.SHA256COMPRESSION;
|
|
79
|
+
// Informs (de)serialization. See Instruction.deserialize.
|
|
80
|
+
static wireFormat = [
|
|
81
|
+
OperandType.UINT8,
|
|
82
|
+
OperandType.UINT8,
|
|
83
|
+
OperandType.UINT16,
|
|
84
|
+
OperandType.UINT16,
|
|
85
|
+
OperandType.UINT16
|
|
86
|
+
];
|
|
87
|
+
constructor(indirect, outputOffset, stateOffset, inputsOffset){
|
|
88
|
+
super(), this.indirect = indirect, this.outputOffset = outputOffset, this.stateOffset = stateOffset, this.inputsOffset = inputsOffset;
|
|
89
|
+
}
|
|
90
|
+
async execute(context) {
|
|
91
|
+
const STATE_SIZE = 8;
|
|
92
|
+
const INPUTS_SIZE = 16;
|
|
93
|
+
const memory = context.machineState.memory;
|
|
94
|
+
const operands = [
|
|
95
|
+
this.outputOffset,
|
|
96
|
+
this.stateOffset,
|
|
97
|
+
this.inputsOffset
|
|
98
|
+
];
|
|
99
|
+
const addressing = Addressing.fromWire(this.indirect, operands.length);
|
|
100
|
+
const [outputOffset, stateOffset, inputsOffset] = addressing.resolve(operands, memory);
|
|
101
|
+
// Note: size of output is same as size of state
|
|
102
|
+
context.machineState.consumeGas(this.gasCost());
|
|
103
|
+
const inputs = Uint32Array.from(memory.getSlice(inputsOffset, INPUTS_SIZE).map((word)=>word.toNumber()));
|
|
104
|
+
const state = Uint32Array.from(memory.getSlice(stateOffset, STATE_SIZE).map((word)=>word.toNumber()));
|
|
105
|
+
memory.checkTagsRange(TypeTag.UINT32, inputsOffset, INPUTS_SIZE);
|
|
106
|
+
memory.checkTagsRange(TypeTag.UINT32, stateOffset, STATE_SIZE);
|
|
107
|
+
const output = sha256Compression(state, inputs);
|
|
108
|
+
// Conversion required from Uint32Array to Uint32[] (can't map directly, need `...`)
|
|
109
|
+
const res = [
|
|
110
|
+
...output
|
|
111
|
+
].map((word)=>new Uint32(word));
|
|
112
|
+
memory.setSlice(outputOffset, res);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './arithmetic.js';
|
|
2
|
+
export * from './bitwise.js';
|
|
3
|
+
export * from './control_flow.js';
|
|
4
|
+
export * from './contract.js';
|
|
5
|
+
export * from './conversion.js';
|
|
6
|
+
export * from './instruction.js';
|
|
7
|
+
export * from './comparators.js';
|
|
8
|
+
export * from './memory.js';
|
|
9
|
+
export * from './misc.js';
|
|
10
|
+
export * from './storage.js';
|
|
11
|
+
export * from './external_calls.js';
|
|
12
|
+
export * from './environment_getters.js';
|
|
13
|
+
export * from './accrued_substate.js';
|
|
14
|
+
export * from './hashing.js';
|
|
15
|
+
export * from './ec_add.js';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/opcodes/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './arithmetic.js';
|
|
2
|
+
export * from './bitwise.js';
|
|
3
|
+
export * from './control_flow.js';
|
|
4
|
+
export * from './contract.js';
|
|
5
|
+
export * from './conversion.js';
|
|
6
|
+
export * from './instruction.js';
|
|
7
|
+
export * from './comparators.js';
|
|
8
|
+
export * from './memory.js';
|
|
9
|
+
export * from './misc.js';
|
|
10
|
+
export * from './storage.js';
|
|
11
|
+
export * from './external_calls.js';
|
|
12
|
+
export * from './environment_getters.js';
|
|
13
|
+
export * from './accrued_substate.js';
|
|
14
|
+
export * from './hashing.js';
|
|
15
|
+
export * from './ec_add.js';
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import type { AvmContext } from '../avm_context.js';
|
|
4
|
+
import { type Gas } from '../avm_gas.js';
|
|
5
|
+
import type { BufferCursor } from '../serialization/buffer_cursor.js';
|
|
6
|
+
import type { Serializable } from '../serialization/bytecode_serialization.js';
|
|
7
|
+
import { Opcode, type OperandType } from '../serialization/instruction_serialization.js';
|
|
8
|
+
type InstructionConstructor = {
|
|
9
|
+
new (...args: any[]): Instruction;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Parent class for all AVM instructions.
|
|
13
|
+
* It's most important aspects are execute and (de)serialize.
|
|
14
|
+
*/
|
|
15
|
+
export declare abstract class Instruction {
|
|
16
|
+
/**
|
|
17
|
+
* Consumes gas and executes the instruction.
|
|
18
|
+
* This is the main entry point for the instruction.
|
|
19
|
+
* @param context - The AvmContext in which the instruction executes.
|
|
20
|
+
*/
|
|
21
|
+
abstract execute(context: AvmContext): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the instruction will modify the PC itself.
|
|
24
|
+
*/
|
|
25
|
+
handlesPC(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Generate a string representation of the instruction including
|
|
28
|
+
* the instruction sub-class name all of its flags and operands.
|
|
29
|
+
* @returns Thee string representation.
|
|
30
|
+
*/
|
|
31
|
+
toString(): string;
|
|
32
|
+
static deserialize(this: InstructionConstructor & {
|
|
33
|
+
wireFormat: OperandType[];
|
|
34
|
+
as: any;
|
|
35
|
+
}, buf: BufferCursor | Buffer): Instruction;
|
|
36
|
+
serialize(): Buffer;
|
|
37
|
+
/**
|
|
38
|
+
* Returns a new instruction instance that can be serialized with the given opcode and wire format.
|
|
39
|
+
* @param opcode The opcode of the instruction.
|
|
40
|
+
* @param wireFormat The wire format of the instruction.
|
|
41
|
+
* @returns The new instruction instance.
|
|
42
|
+
*/
|
|
43
|
+
as(opcode: Opcode, wireFormat: OperandType[]): Instruction & Serializable;
|
|
44
|
+
/**
|
|
45
|
+
* Returns a new instruction class that can be deserialized with the given opcode and wire format.
|
|
46
|
+
* @param opcode The opcode of the instruction.
|
|
47
|
+
* @param wireFormat The wire format of the instruction.
|
|
48
|
+
* @returns The new instruction class.
|
|
49
|
+
*/
|
|
50
|
+
static as(this: InstructionConstructor, wireFormat: OperandType[]): InstructionConstructor & {
|
|
51
|
+
deserialize: (buf: BufferCursor | Buffer) => Instruction;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Computes gas cost for the instruction based on its base cost and memory operations.
|
|
55
|
+
* @returns Gas cost.
|
|
56
|
+
*/
|
|
57
|
+
protected gasCost(dynMultiplier?: number): Gas;
|
|
58
|
+
/**
|
|
59
|
+
* Returns the stringified type of the instruction.
|
|
60
|
+
* Instruction sub-classes should have a static `type` property.
|
|
61
|
+
*/
|
|
62
|
+
get type(): string;
|
|
63
|
+
/**
|
|
64
|
+
* Returns the opcode of the instruction.
|
|
65
|
+
* Instruction sub-classes should have a static `opcode` property.
|
|
66
|
+
*/
|
|
67
|
+
get opcode(): Opcode;
|
|
68
|
+
}
|
|
69
|
+
export {};
|
|
70
|
+
//# sourceMappingURL=instruction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instruction.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/opcodes/instruction.ts"],"names":[],"mappings":";;AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,GAAG,EAAqD,MAAM,eAAe,CAAC;AAC5F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAA4B,MAAM,+CAA+C,CAAC;AAEnH,KAAK,sBAAsB,GAAG;IAC5B,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,WAAW,CAAC;CACnC,CAAC;AAEF;;;GAGG;AACH,8BAAsB,WAAW;IAC/B;;;;OAIG;aACa,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAE3D;;OAEG;IACI,SAAS,IAAI,OAAO;IAI3B;;;;OAIG;IACI,QAAQ,IAAI,MAAM;WAUX,WAAW,CACvB,IAAI,EAAE,sBAAsB,GAAG;QAAE,UAAU,EAAE,WAAW,EAAE,CAAC;QAAC,EAAE,EAAE,GAAG,CAAA;KAAE,EACrE,GAAG,EAAE,YAAY,GAAG,MAAM,GACzB,WAAW;IAKP,SAAS,IAAI,MAAM;IAO1B;;;;;OAKG;IACI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,WAAW,GAAG,YAAY;IAShF;;;;;OAKG;WACW,EAAE,CAAC,IAAI,EAAE,sBAAsB,EAAE,UAAU,EAAE,WAAW,EAAE;2BAEjD,YAAY,GAAG,MAAM,KAAG,WAAW;;IAQ1D;;;OAGG;IACH,SAAS,CAAC,OAAO,CAAC,aAAa,GAAE,MAAU,GAAG,GAAG;IAMjD;;;OAGG;IACH,IAAW,IAAI,IAAI,MAAM,CAMxB;IAED;;;OAGG;IACH,IAAW,MAAM,IAAI,MAAM,CAM1B;CACF"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { strict as assert } from 'assert';
|
|
2
|
+
import { getBaseGasCost, getDynamicGasCost, mulGas, sumGas } from '../avm_gas.js';
|
|
3
|
+
import { Opcode, deserialize, serializeAs } from '../serialization/instruction_serialization.js';
|
|
4
|
+
/**
|
|
5
|
+
* Parent class for all AVM instructions.
|
|
6
|
+
* It's most important aspects are execute and (de)serialize.
|
|
7
|
+
*/ export class Instruction {
|
|
8
|
+
/**
|
|
9
|
+
* Whether the instruction will modify the PC itself.
|
|
10
|
+
*/ handlesPC() {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Generate a string representation of the instruction including
|
|
15
|
+
* the instruction sub-class name all of its flags and operands.
|
|
16
|
+
* @returns Thee string representation.
|
|
17
|
+
*/ toString() {
|
|
18
|
+
let instructionStr = this.constructor.name + ': ';
|
|
19
|
+
// assumes that all properties are flags or operands
|
|
20
|
+
for (const prop of Object.getOwnPropertyNames(this)){
|
|
21
|
+
instructionStr += `${prop}:${this[prop].toString()}, `;
|
|
22
|
+
}
|
|
23
|
+
return instructionStr;
|
|
24
|
+
}
|
|
25
|
+
// Default deserialization which uses Class.opcode and Class.wireFormat.
|
|
26
|
+
static deserialize(buf) {
|
|
27
|
+
return this.as(this.wireFormat).deserialize(buf);
|
|
28
|
+
}
|
|
29
|
+
// Default serialization which uses Class.opcode and Class.wireFormat.
|
|
30
|
+
serialize() {
|
|
31
|
+
const klass = this.constructor;
|
|
32
|
+
assert(klass.opcode !== undefined && klass.opcode !== null);
|
|
33
|
+
assert(klass.wireFormat !== undefined && klass.wireFormat !== null);
|
|
34
|
+
return this.as(klass.opcode, klass.wireFormat).serialize();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns a new instruction instance that can be serialized with the given opcode and wire format.
|
|
38
|
+
* @param opcode The opcode of the instruction.
|
|
39
|
+
* @param wireFormat The wire format of the instruction.
|
|
40
|
+
* @returns The new instruction instance.
|
|
41
|
+
*/ as(opcode, wireFormat) {
|
|
42
|
+
return Object.defineProperty(this, 'serialize', {
|
|
43
|
+
value: ()=>{
|
|
44
|
+
return serializeAs(wireFormat, opcode, this);
|
|
45
|
+
},
|
|
46
|
+
enumerable: false
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Returns a new instruction class that can be deserialized with the given opcode and wire format.
|
|
51
|
+
* @param opcode The opcode of the instruction.
|
|
52
|
+
* @param wireFormat The wire format of the instruction.
|
|
53
|
+
* @returns The new instruction class.
|
|
54
|
+
*/ static as(wireFormat) {
|
|
55
|
+
return Object.assign(this, {
|
|
56
|
+
deserialize: (buf)=>{
|
|
57
|
+
const res = deserialize(buf, wireFormat);
|
|
58
|
+
const args = res.slice(1); // Remove opcode.
|
|
59
|
+
return new this(...args);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Computes gas cost for the instruction based on its base cost and memory operations.
|
|
65
|
+
* @returns Gas cost.
|
|
66
|
+
*/ gasCost(dynMultiplier = 0) {
|
|
67
|
+
const baseGasCost = getBaseGasCost(this.opcode);
|
|
68
|
+
const dynGasCost = mulGas(getDynamicGasCost(this.opcode), dynMultiplier);
|
|
69
|
+
return sumGas(baseGasCost, dynGasCost);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Returns the stringified type of the instruction.
|
|
73
|
+
* Instruction sub-classes should have a static `type` property.
|
|
74
|
+
*/ get type() {
|
|
75
|
+
const type = 'type' in this.constructor && this.constructor.type;
|
|
76
|
+
if (!type) {
|
|
77
|
+
throw new Error(`Instruction class ${this.constructor.name} does not have a static 'type' property defined.`);
|
|
78
|
+
}
|
|
79
|
+
return type;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Returns the opcode of the instruction.
|
|
83
|
+
* Instruction sub-classes should have a static `opcode` property.
|
|
84
|
+
*/ get opcode() {
|
|
85
|
+
const opcode = 'opcode' in this.constructor ? this.constructor.opcode : undefined;
|
|
86
|
+
if (opcode === undefined || Opcode[opcode] === undefined) {
|
|
87
|
+
throw new Error(`Instruction class ${this.constructor.name} does not have a static 'opcode' property defined.`);
|
|
88
|
+
}
|
|
89
|
+
return opcode;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { OperandType } from '../serialization/instruction_serialization.js';
|
|
2
|
+
import { Instruction } from './instruction.js';
|
|
3
|
+
/** Wire format that informs deserialization for instructions with three operands. */
|
|
4
|
+
export declare const ThreeOperandWireFormat8: OperandType[];
|
|
5
|
+
export declare const ThreeOperandWireFormat16: OperandType[];
|
|
6
|
+
/**
|
|
7
|
+
* Covers (de)serialization for an instruction with:
|
|
8
|
+
* indirect, inTag, and three operands.
|
|
9
|
+
*/
|
|
10
|
+
export declare abstract class ThreeOperandInstruction extends Instruction {
|
|
11
|
+
protected indirect: number;
|
|
12
|
+
protected aOffset: number;
|
|
13
|
+
protected bOffset: number;
|
|
14
|
+
protected dstOffset: number;
|
|
15
|
+
static readonly wireFormat8: OperandType[];
|
|
16
|
+
static readonly wireFormat16: OperandType[];
|
|
17
|
+
constructor(indirect: number, aOffset: number, bOffset: number, dstOffset: number);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=instruction_impl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instruction_impl.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/opcodes/instruction_impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,qFAAqF;AACrF,eAAO,MAAM,uBAAuB,eAMnC,CAAC;AACF,eAAO,MAAM,wBAAwB,eAMpC,CAAC;AAEF;;;GAGG;AACH,8BAAsB,uBAAwB,SAAQ,WAAW;IAK7D,SAAS,CAAC,QAAQ,EAAE,MAAM;IAC1B,SAAS,CAAC,OAAO,EAAE,MAAM;IACzB,SAAS,CAAC,OAAO,EAAE,MAAM;IACzB,SAAS,CAAC,SAAS,EAAE,MAAM;IAP7B,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,EAAE,CAA2B;IACrE,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,WAAW,EAAE,CAA4B;gBAG3D,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM;CAI9B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { OperandType } from '../serialization/instruction_serialization.js';
|
|
2
|
+
import { Instruction } from './instruction.js';
|
|
3
|
+
/** Wire format that informs deserialization for instructions with three operands. */ export const ThreeOperandWireFormat8 = [
|
|
4
|
+
OperandType.UINT8,
|
|
5
|
+
OperandType.UINT8,
|
|
6
|
+
OperandType.UINT8,
|
|
7
|
+
OperandType.UINT8,
|
|
8
|
+
OperandType.UINT8
|
|
9
|
+
];
|
|
10
|
+
export const ThreeOperandWireFormat16 = [
|
|
11
|
+
OperandType.UINT8,
|
|
12
|
+
OperandType.UINT8,
|
|
13
|
+
OperandType.UINT16,
|
|
14
|
+
OperandType.UINT16,
|
|
15
|
+
OperandType.UINT16
|
|
16
|
+
];
|
|
17
|
+
/**
|
|
18
|
+
* Covers (de)serialization for an instruction with:
|
|
19
|
+
* indirect, inTag, and three operands.
|
|
20
|
+
*/ export class ThreeOperandInstruction extends Instruction {
|
|
21
|
+
indirect;
|
|
22
|
+
aOffset;
|
|
23
|
+
bOffset;
|
|
24
|
+
dstOffset;
|
|
25
|
+
static wireFormat8 = ThreeOperandWireFormat8;
|
|
26
|
+
static wireFormat16 = ThreeOperandWireFormat16;
|
|
27
|
+
constructor(indirect, aOffset, bOffset, dstOffset){
|
|
28
|
+
super(), this.indirect = indirect, this.aOffset = aOffset, this.bOffset = bOffset, this.dstOffset = dstOffset;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { AvmContext } from '../avm_context.js';
|
|
2
|
+
import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
|
|
3
|
+
import { Instruction } from './instruction.js';
|
|
4
|
+
export declare class Set extends Instruction {
|
|
5
|
+
private indirect;
|
|
6
|
+
private dstOffset;
|
|
7
|
+
private inTag;
|
|
8
|
+
private value;
|
|
9
|
+
static readonly type: string;
|
|
10
|
+
static readonly opcode: Opcode;
|
|
11
|
+
static readonly wireFormat8: OperandType[];
|
|
12
|
+
static readonly wireFormat16: OperandType[];
|
|
13
|
+
static readonly wireFormat32: OperandType[];
|
|
14
|
+
static readonly wireFormat64: OperandType[];
|
|
15
|
+
static readonly wireFormat128: OperandType[];
|
|
16
|
+
static readonly wireFormatFF: OperandType[];
|
|
17
|
+
constructor(indirect: number, dstOffset: number, inTag: number, value: bigint | number);
|
|
18
|
+
execute(context: AvmContext): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export declare class Cast extends Instruction {
|
|
21
|
+
private indirect;
|
|
22
|
+
private srcOffset;
|
|
23
|
+
private dstOffset;
|
|
24
|
+
private dstTag;
|
|
25
|
+
static readonly type: string;
|
|
26
|
+
static readonly opcode = Opcode.CAST_8;
|
|
27
|
+
static readonly wireFormat8: OperandType[];
|
|
28
|
+
static readonly wireFormat16: OperandType[];
|
|
29
|
+
constructor(indirect: number, srcOffset: number, dstOffset: number, dstTag: number);
|
|
30
|
+
execute(context: AvmContext): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export declare class Mov extends Instruction {
|
|
33
|
+
private indirect;
|
|
34
|
+
private srcOffset;
|
|
35
|
+
private dstOffset;
|
|
36
|
+
static readonly type: string;
|
|
37
|
+
static readonly opcode: Opcode;
|
|
38
|
+
static readonly wireFormat8: OperandType[];
|
|
39
|
+
static readonly wireFormat16: OperandType[];
|
|
40
|
+
constructor(indirect: number, srcOffset: number, dstOffset: number);
|
|
41
|
+
execute(context: AvmContext): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
export declare class CalldataCopy extends Instruction {
|
|
44
|
+
private indirect;
|
|
45
|
+
private cdStartOffset;
|
|
46
|
+
private copySizeOffset;
|
|
47
|
+
private dstOffset;
|
|
48
|
+
static readonly type: string;
|
|
49
|
+
static readonly opcode: Opcode;
|
|
50
|
+
static readonly wireFormat: OperandType[];
|
|
51
|
+
constructor(indirect: number, cdStartOffset: number, copySizeOffset: number, dstOffset: number);
|
|
52
|
+
execute(context: AvmContext): Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
export declare class ReturndataSize extends Instruction {
|
|
55
|
+
private indirect;
|
|
56
|
+
private dstOffset;
|
|
57
|
+
static readonly type: string;
|
|
58
|
+
static readonly opcode: Opcode;
|
|
59
|
+
static readonly wireFormat: OperandType[];
|
|
60
|
+
constructor(indirect: number, dstOffset: number);
|
|
61
|
+
execute(context: AvmContext): Promise<void>;
|
|
62
|
+
}
|
|
63
|
+
export declare class ReturndataCopy extends Instruction {
|
|
64
|
+
private indirect;
|
|
65
|
+
private rdStartOffset;
|
|
66
|
+
private copySizeOffset;
|
|
67
|
+
private dstOffset;
|
|
68
|
+
static readonly type: string;
|
|
69
|
+
static readonly opcode: Opcode;
|
|
70
|
+
static readonly wireFormat: OperandType[];
|
|
71
|
+
constructor(indirect: number, rdStartOffset: number, copySizeOffset: number, dstOffset: number);
|
|
72
|
+
execute(context: AvmContext): Promise<void>;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/opcodes/memory.ts"],"names":[],"mappings":"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"}
|