@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,195 @@
|
|
|
1
|
+
import * as c from '@aztec/constants';
|
|
2
|
+
|
|
3
|
+
import { TypeTag } from './avm_memory_types.js';
|
|
4
|
+
import { InstructionExecutionError } from './errors.js';
|
|
5
|
+
import { Addressing, AddressingMode } from './opcodes/addressing_mode.js';
|
|
6
|
+
import { Opcode } from './serialization/instruction_serialization.js';
|
|
7
|
+
|
|
8
|
+
/** Gas counters in L1, L2, and DA. */
|
|
9
|
+
export type Gas = {
|
|
10
|
+
l2Gas: number;
|
|
11
|
+
daGas: number;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** Maps a Gas struct to gasLeft properties. */
|
|
15
|
+
export function gasToGasLeft(gas: Gas) {
|
|
16
|
+
return { l2GasLeft: gas.l2Gas, daGasLeft: gas.daGas };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Maps gasLeft properties to a gas struct. */
|
|
20
|
+
export function gasLeftToGas(gasLeft: { l2GasLeft: number; daGasLeft: number }) {
|
|
21
|
+
return { l2Gas: gasLeft.l2GasLeft, daGas: gasLeft.daGasLeft };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Creates a new instance with all values set to zero except the ones set. */
|
|
25
|
+
export function makeGas(gasCost: Partial<Gas>) {
|
|
26
|
+
return { ...EmptyGas, ...gasCost };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Sums together multiple instances of Gas. */
|
|
30
|
+
export function sumGas(...gases: Partial<Gas>[]) {
|
|
31
|
+
return gases.reduce(
|
|
32
|
+
(acc: Gas, gas) => ({
|
|
33
|
+
l2Gas: acc.l2Gas + (gas.l2Gas ?? 0),
|
|
34
|
+
daGas: acc.daGas + (gas.daGas ?? 0),
|
|
35
|
+
}),
|
|
36
|
+
EmptyGas,
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Multiplies a gas instance by a scalar. */
|
|
41
|
+
export function mulGas(gas: Partial<Gas>, scalar: number) {
|
|
42
|
+
return { l2Gas: (gas.l2Gas ?? 0) * scalar, daGas: (gas.daGas ?? 0) * scalar };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Zero gas across all gas dimensions. */
|
|
46
|
+
export const EmptyGas: Gas = {
|
|
47
|
+
l2Gas: 0,
|
|
48
|
+
daGas: 0,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
function makeCost(l2Gas: number, daGas: number): Gas {
|
|
52
|
+
return { l2Gas, daGas };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Dimensions of gas usage: L1, L2, and DA. */
|
|
56
|
+
export const GAS_DIMENSIONS = ['l2Gas', 'daGas'] as const;
|
|
57
|
+
|
|
58
|
+
/** Base gas costs for each instruction. Additional gas cost may be added on top due to memory or storage accesses, etc. */
|
|
59
|
+
const BASE_GAS_COSTS: Record<Opcode, Gas> = {
|
|
60
|
+
[Opcode.ADD_8]: makeCost(c.AVM_ADD_BASE_L2_GAS, 0),
|
|
61
|
+
[Opcode.ADD_16]: makeCost(c.AVM_ADD_BASE_L2_GAS, 0),
|
|
62
|
+
[Opcode.SUB_8]: makeCost(c.AVM_SUB_BASE_L2_GAS, 0),
|
|
63
|
+
[Opcode.SUB_16]: makeCost(c.AVM_SUB_BASE_L2_GAS, 0),
|
|
64
|
+
[Opcode.MUL_8]: makeCost(c.AVM_MUL_BASE_L2_GAS, 0),
|
|
65
|
+
[Opcode.MUL_16]: makeCost(c.AVM_MUL_BASE_L2_GAS, 0),
|
|
66
|
+
[Opcode.DIV_8]: makeCost(c.AVM_DIV_BASE_L2_GAS, 0),
|
|
67
|
+
[Opcode.DIV_16]: makeCost(c.AVM_DIV_BASE_L2_GAS, 0),
|
|
68
|
+
[Opcode.FDIV_8]: makeCost(c.AVM_FDIV_BASE_L2_GAS, 0),
|
|
69
|
+
[Opcode.FDIV_16]: makeCost(c.AVM_FDIV_BASE_L2_GAS, 0),
|
|
70
|
+
[Opcode.EQ_8]: makeCost(c.AVM_EQ_BASE_L2_GAS, 0),
|
|
71
|
+
[Opcode.EQ_16]: makeCost(c.AVM_EQ_BASE_L2_GAS, 0),
|
|
72
|
+
[Opcode.LT_8]: makeCost(c.AVM_LT_BASE_L2_GAS, 0),
|
|
73
|
+
[Opcode.LT_16]: makeCost(c.AVM_LT_BASE_L2_GAS, 0),
|
|
74
|
+
[Opcode.LTE_8]: makeCost(c.AVM_LTE_BASE_L2_GAS, 0),
|
|
75
|
+
[Opcode.LTE_16]: makeCost(c.AVM_LTE_BASE_L2_GAS, 0),
|
|
76
|
+
[Opcode.AND_8]: makeCost(c.AVM_AND_BASE_L2_GAS, 0),
|
|
77
|
+
[Opcode.AND_16]: makeCost(c.AVM_AND_BASE_L2_GAS, 0),
|
|
78
|
+
[Opcode.OR_8]: makeCost(c.AVM_OR_BASE_L2_GAS, 0),
|
|
79
|
+
[Opcode.OR_16]: makeCost(c.AVM_OR_BASE_L2_GAS, 0),
|
|
80
|
+
[Opcode.XOR_8]: makeCost(c.AVM_XOR_BASE_L2_GAS, 0),
|
|
81
|
+
[Opcode.XOR_16]: makeCost(c.AVM_XOR_BASE_L2_GAS, 0),
|
|
82
|
+
[Opcode.NOT_8]: makeCost(c.AVM_NOT_BASE_L2_GAS, 0),
|
|
83
|
+
[Opcode.NOT_16]: makeCost(c.AVM_NOT_BASE_L2_GAS, 0),
|
|
84
|
+
[Opcode.SHL_8]: makeCost(c.AVM_SHL_BASE_L2_GAS, 0),
|
|
85
|
+
[Opcode.SHL_16]: makeCost(c.AVM_SHL_BASE_L2_GAS, 0),
|
|
86
|
+
[Opcode.SHR_8]: makeCost(c.AVM_SHR_BASE_L2_GAS, 0),
|
|
87
|
+
[Opcode.SHR_16]: makeCost(c.AVM_SHR_BASE_L2_GAS, 0),
|
|
88
|
+
[Opcode.CAST_8]: makeCost(c.AVM_CAST_BASE_L2_GAS, 0),
|
|
89
|
+
[Opcode.CAST_16]: makeCost(c.AVM_CAST_BASE_L2_GAS, 0),
|
|
90
|
+
[Opcode.GETENVVAR_16]: makeCost(c.AVM_GETENVVAR_BASE_L2_GAS, 0),
|
|
91
|
+
[Opcode.CALLDATACOPY]: makeCost(c.AVM_CALLDATACOPY_BASE_L2_GAS, 0),
|
|
92
|
+
[Opcode.SUCCESSCOPY]: makeCost(c.AVM_SUCCESSCOPY_BASE_L2_GAS, 0),
|
|
93
|
+
[Opcode.RETURNDATASIZE]: makeCost(c.AVM_RETURNDATASIZE_BASE_L2_GAS, 0),
|
|
94
|
+
[Opcode.RETURNDATACOPY]: makeCost(c.AVM_RETURNDATACOPY_BASE_L2_GAS, 0),
|
|
95
|
+
[Opcode.JUMP_32]: makeCost(c.AVM_JUMP_BASE_L2_GAS, 0),
|
|
96
|
+
[Opcode.JUMPI_32]: makeCost(c.AVM_JUMPI_BASE_L2_GAS, 0),
|
|
97
|
+
[Opcode.INTERNALCALL]: makeCost(c.AVM_INTERNALCALL_BASE_L2_GAS, 0),
|
|
98
|
+
[Opcode.INTERNALRETURN]: makeCost(c.AVM_INTERNALRETURN_BASE_L2_GAS, 0),
|
|
99
|
+
[Opcode.SET_8]: makeCost(c.AVM_SET_BASE_L2_GAS, 0),
|
|
100
|
+
[Opcode.SET_16]: makeCost(c.AVM_SET_BASE_L2_GAS, 0),
|
|
101
|
+
[Opcode.SET_32]: makeCost(c.AVM_SET_BASE_L2_GAS, 0),
|
|
102
|
+
[Opcode.SET_64]: makeCost(c.AVM_SET_BASE_L2_GAS, 0),
|
|
103
|
+
[Opcode.SET_128]: makeCost(c.AVM_SET_BASE_L2_GAS, 0),
|
|
104
|
+
[Opcode.SET_FF]: makeCost(c.AVM_SET_BASE_L2_GAS, 0),
|
|
105
|
+
[Opcode.MOV_8]: makeCost(c.AVM_MOV_BASE_L2_GAS, 0),
|
|
106
|
+
[Opcode.MOV_16]: makeCost(c.AVM_MOV_BASE_L2_GAS, 0),
|
|
107
|
+
[Opcode.SLOAD]: makeCost(c.AVM_SLOAD_BASE_L2_GAS, 0),
|
|
108
|
+
[Opcode.SSTORE]: makeCost(c.AVM_SSTORE_BASE_L2_GAS, c.AVM_SSTORE_BASE_DA_GAS),
|
|
109
|
+
[Opcode.NOTEHASHEXISTS]: makeCost(c.AVM_NOTEHASHEXISTS_BASE_L2_GAS, 0),
|
|
110
|
+
[Opcode.EMITNOTEHASH]: makeCost(c.AVM_EMITNOTEHASH_BASE_L2_GAS, c.AVM_EMITNOTEHASH_BASE_DA_GAS),
|
|
111
|
+
[Opcode.NULLIFIEREXISTS]: makeCost(c.AVM_NULLIFIEREXISTS_BASE_L2_GAS, 0),
|
|
112
|
+
[Opcode.EMITNULLIFIER]: makeCost(c.AVM_EMITNULLIFIER_BASE_L2_GAS, c.AVM_EMITNULLIFIER_BASE_DA_GAS),
|
|
113
|
+
[Opcode.L1TOL2MSGEXISTS]: makeCost(c.AVM_L1TOL2MSGEXISTS_BASE_L2_GAS, 0),
|
|
114
|
+
[Opcode.EMITUNENCRYPTEDLOG]: makeCost(c.AVM_EMITUNENCRYPTEDLOG_BASE_L2_GAS, 0),
|
|
115
|
+
[Opcode.SENDL2TOL1MSG]: makeCost(c.AVM_SENDL2TOL1MSG_BASE_L2_GAS, c.AVM_SENDL2TOL1MSG_BASE_DA_GAS),
|
|
116
|
+
[Opcode.GETCONTRACTINSTANCE]: makeCost(c.AVM_GETCONTRACTINSTANCE_BASE_L2_GAS, 0),
|
|
117
|
+
[Opcode.CALL]: makeCost(c.AVM_CALL_BASE_L2_GAS, 0),
|
|
118
|
+
[Opcode.STATICCALL]: makeCost(c.AVM_STATICCALL_BASE_L2_GAS, 0),
|
|
119
|
+
[Opcode.RETURN]: makeCost(c.AVM_RETURN_BASE_L2_GAS, 0),
|
|
120
|
+
[Opcode.REVERT_8]: makeCost(c.AVM_REVERT_BASE_L2_GAS, 0),
|
|
121
|
+
[Opcode.REVERT_16]: makeCost(c.AVM_REVERT_BASE_L2_GAS, 0),
|
|
122
|
+
[Opcode.DEBUGLOG]: makeCost(c.AVM_DEBUGLOG_BASE_L2_GAS, 0),
|
|
123
|
+
[Opcode.POSEIDON2]: makeCost(c.AVM_POSEIDON2_BASE_L2_GAS, 0),
|
|
124
|
+
[Opcode.SHA256COMPRESSION]: makeCost(c.AVM_SHA256COMPRESSION_BASE_L2_GAS, 0),
|
|
125
|
+
[Opcode.KECCAKF1600]: makeCost(c.AVM_KECCAKF1600_BASE_L2_GAS, 0),
|
|
126
|
+
[Opcode.ECADD]: makeCost(c.AVM_ECADD_BASE_L2_GAS, 0),
|
|
127
|
+
[Opcode.TORADIXBE]: makeCost(c.AVM_TORADIXBE_BASE_L2_GAS, 0),
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const DYNAMIC_GAS_COSTS = new Map<Opcode, Gas>([
|
|
131
|
+
[Opcode.CALLDATACOPY, makeCost(c.AVM_CALLDATACOPY_DYN_L2_GAS, 0)],
|
|
132
|
+
[Opcode.RETURNDATACOPY, makeCost(c.AVM_RETURNDATACOPY_DYN_L2_GAS, 0)],
|
|
133
|
+
[Opcode.EMITUNENCRYPTEDLOG, makeCost(c.AVM_EMITUNENCRYPTEDLOG_DYN_L2_GAS, c.AVM_EMITUNENCRYPTEDLOG_DYN_DA_GAS)],
|
|
134
|
+
[Opcode.CALL, makeCost(c.AVM_CALL_DYN_L2_GAS, 0)],
|
|
135
|
+
[Opcode.STATICCALL, makeCost(c.AVM_STATICCALL_DYN_L2_GAS, 0)],
|
|
136
|
+
[Opcode.RETURN, makeCost(c.AVM_RETURN_DYN_L2_GAS, 0)],
|
|
137
|
+
[Opcode.REVERT_8, makeCost(c.AVM_REVERT_DYN_L2_GAS, 0)],
|
|
138
|
+
[Opcode.REVERT_16, makeCost(c.AVM_REVERT_DYN_L2_GAS, 0)],
|
|
139
|
+
[Opcode.DEBUGLOG, makeCost(c.AVM_DEBUGLOG_DYN_L2_GAS, 0)],
|
|
140
|
+
[Opcode.TORADIXBE, makeCost(c.AVM_TORADIXBE_DYN_L2_GAS, 0)],
|
|
141
|
+
]);
|
|
142
|
+
|
|
143
|
+
/** Returns the fixed base gas cost for a given opcode. */
|
|
144
|
+
export function getBaseGasCost(opcode: Opcode): Gas {
|
|
145
|
+
return BASE_GAS_COSTS[opcode];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function getDynamicGasCost(opcode: Opcode): Gas {
|
|
149
|
+
return DYNAMIC_GAS_COSTS.has(opcode) ? DYNAMIC_GAS_COSTS.get(opcode)! : makeCost(0, 0);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Returns the gas cost associated with the memory operations performed. */
|
|
153
|
+
export function getMemoryGasCost(args: { reads?: number; writes?: number; indirect?: number }) {
|
|
154
|
+
const { reads, writes, indirect } = args;
|
|
155
|
+
const indirectCount = Addressing.fromWire(indirect ?? 0).count(AddressingMode.INDIRECT);
|
|
156
|
+
const l2MemoryGasCost =
|
|
157
|
+
(reads ?? 0) * GAS_COST_CONSTANTS.MEMORY_READ +
|
|
158
|
+
(writes ?? 0) * GAS_COST_CONSTANTS.MEMORY_WRITE +
|
|
159
|
+
indirectCount * GAS_COST_CONSTANTS.MEMORY_INDIRECT_READ_PENALTY;
|
|
160
|
+
return makeGas({ l2Gas: l2MemoryGasCost });
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Constants used in base cost calculations. */
|
|
164
|
+
export const GAS_COST_CONSTANTS = {
|
|
165
|
+
MEMORY_READ: 10,
|
|
166
|
+
MEMORY_INDIRECT_READ_PENALTY: 10,
|
|
167
|
+
MEMORY_WRITE: 100,
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/** Returns gas cost for an operation on a given type tag based on the base cost per byte. */
|
|
171
|
+
export function getGasCostForTypeTag(tag: TypeTag, baseCost: Gas) {
|
|
172
|
+
return mulGas(baseCost, getGasCostMultiplierFromTypeTag(tag));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Returns a multiplier based on the size of the type represented by the tag. Throws on uninitialized or invalid. */
|
|
176
|
+
function getGasCostMultiplierFromTypeTag(tag: TypeTag) {
|
|
177
|
+
switch (tag) {
|
|
178
|
+
case TypeTag.UINT1: // same as u8
|
|
179
|
+
return 1;
|
|
180
|
+
case TypeTag.UINT8:
|
|
181
|
+
return 1;
|
|
182
|
+
case TypeTag.UINT16:
|
|
183
|
+
return 2;
|
|
184
|
+
case TypeTag.UINT32:
|
|
185
|
+
return 4;
|
|
186
|
+
case TypeTag.UINT64:
|
|
187
|
+
return 8;
|
|
188
|
+
case TypeTag.UINT128:
|
|
189
|
+
return 16;
|
|
190
|
+
case TypeTag.FIELD:
|
|
191
|
+
return 32;
|
|
192
|
+
case TypeTag.INVALID:
|
|
193
|
+
throw new InstructionExecutionError(`Invalid tag type for gas cost multiplier: ${TypeTag[tag]}`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
|
|
3
|
+
import type { Gas } from './avm_gas.js';
|
|
4
|
+
import { TaggedMemory } from './avm_memory_types.js';
|
|
5
|
+
import { type AvmRevertReason, OutOfGasError } from './errors.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A few fields of machine state are initialized from AVM session inputs or call instruction arguments
|
|
9
|
+
*/
|
|
10
|
+
export type InitialAvmMachineState = {
|
|
11
|
+
l2GasLeft: number;
|
|
12
|
+
daGasLeft: number;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Used to track the call stack and revert data of nested calls.
|
|
17
|
+
* This is used to provide a more detailed revert reason when a contract call reverts.
|
|
18
|
+
* It is only a heuristic and may not always provide the correct revert reason.
|
|
19
|
+
*/
|
|
20
|
+
type TrackedRevertInfo = {
|
|
21
|
+
revertDataRepresentative: Fr[];
|
|
22
|
+
recursiveRevertReason: AvmRevertReason;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type CallStackEntry = {
|
|
26
|
+
callPc: number;
|
|
27
|
+
returnPc: number;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Avm state modified on an instruction-per-instruction basis.
|
|
32
|
+
*/
|
|
33
|
+
export class AvmMachineState {
|
|
34
|
+
/** gas remaining of the gas allocated for a contract call */
|
|
35
|
+
public l2GasLeft: number;
|
|
36
|
+
public daGasLeft: number;
|
|
37
|
+
/** program counter, byte based */
|
|
38
|
+
public pc: number = 0;
|
|
39
|
+
/** program counter of the next instruction, byte based */
|
|
40
|
+
public nextPc: number = 0;
|
|
41
|
+
/** return/revertdata of the last nested call. */
|
|
42
|
+
public nestedReturndata: Fr[] = [];
|
|
43
|
+
/** Tracks whether the last external call was successful */
|
|
44
|
+
public nestedCallSuccess: boolean = false;
|
|
45
|
+
/**
|
|
46
|
+
* Used to track the call stack and revert data of nested calls.
|
|
47
|
+
* This is used to provide a more detailed revert reason when a contract call reverts.
|
|
48
|
+
* It is only a heuristic and may not always provide the correct revert reason.
|
|
49
|
+
*/
|
|
50
|
+
public collectedRevertInfo: TrackedRevertInfo | undefined;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* On INTERNALCALL, internal call stack is pushed to with the current pc and the return pc.
|
|
54
|
+
* On INTERNALRETURN, value is popped from the internal call stack and assigned to the return pc.
|
|
55
|
+
*/
|
|
56
|
+
public internalCallStack: CallStackEntry[] = [];
|
|
57
|
+
|
|
58
|
+
/** Memory accessible to user code */
|
|
59
|
+
public readonly memory: TaggedMemory = new TaggedMemory();
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Signals that execution should end.
|
|
63
|
+
* AvmContext execution continues executing instructions until the machine state signals "halted"
|
|
64
|
+
*/
|
|
65
|
+
private halted: boolean = false;
|
|
66
|
+
/** Signals that execution has reverted normally (this does not cover exceptional halts) */
|
|
67
|
+
private reverted: boolean = false;
|
|
68
|
+
/** Output data must NOT be modified once it is set */
|
|
69
|
+
private output: Fr[] = [];
|
|
70
|
+
|
|
71
|
+
constructor(gasLeft: Gas);
|
|
72
|
+
constructor(l2GasLeft: number, daGasLeft: number);
|
|
73
|
+
constructor(gasLeftOrL2GasLeft: Gas | number, daGasLeft?: number) {
|
|
74
|
+
if (typeof gasLeftOrL2GasLeft === 'object') {
|
|
75
|
+
({ l2Gas: this.l2GasLeft, daGas: this.daGasLeft } = gasLeftOrL2GasLeft);
|
|
76
|
+
} else {
|
|
77
|
+
this.l2GasLeft = gasLeftOrL2GasLeft!;
|
|
78
|
+
this.daGasLeft = daGasLeft!;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public get gasLeft(): Gas {
|
|
83
|
+
return { l2Gas: this.l2GasLeft, daGas: this.daGasLeft };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public static fromState(state: InitialAvmMachineState): AvmMachineState {
|
|
87
|
+
return new AvmMachineState(state.l2GasLeft, state.daGasLeft);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Consumes the given gas.
|
|
92
|
+
* Should any of the gas dimensions get depleted, it sets all gas left to zero and triggers
|
|
93
|
+
* an exceptional halt by throwing an OutOfGasError.
|
|
94
|
+
*/
|
|
95
|
+
public consumeGas(gasCost: Partial<Gas>) {
|
|
96
|
+
// Assert there is enough gas on every dimension.
|
|
97
|
+
const outOfL2Gas = this.l2GasLeft - (gasCost.l2Gas ?? 0) < 0;
|
|
98
|
+
const outOfDaGas = this.daGasLeft - (gasCost.daGas ?? 0) < 0;
|
|
99
|
+
// If not, trigger an exceptional halt.
|
|
100
|
+
if (outOfL2Gas || outOfDaGas) {
|
|
101
|
+
this.exceptionalHalt();
|
|
102
|
+
const dimensions = [];
|
|
103
|
+
if (outOfL2Gas) {
|
|
104
|
+
dimensions.push('l2Gas');
|
|
105
|
+
}
|
|
106
|
+
if (outOfDaGas) {
|
|
107
|
+
dimensions.push('daGas');
|
|
108
|
+
}
|
|
109
|
+
throw new OutOfGasError(dimensions);
|
|
110
|
+
}
|
|
111
|
+
// Otherwise, charge the corresponding gas
|
|
112
|
+
this.l2GasLeft -= gasCost.l2Gas ?? 0;
|
|
113
|
+
this.daGasLeft -= gasCost.daGas ?? 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Increases the gas left by the amounts specified. */
|
|
117
|
+
public refundGas(gasRefund: Partial<Gas>) {
|
|
118
|
+
this.l2GasLeft += gasRefund.l2Gas ?? 0;
|
|
119
|
+
this.daGasLeft += gasRefund.daGas ?? 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Halt as successful
|
|
124
|
+
* Output data must NOT be modified once it is set
|
|
125
|
+
* @param output
|
|
126
|
+
*/
|
|
127
|
+
public return(output: Fr[]) {
|
|
128
|
+
this.halted = true;
|
|
129
|
+
this.output = output;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Halt as reverted
|
|
134
|
+
* Output data must NOT be modified once it is set
|
|
135
|
+
* @param output
|
|
136
|
+
*/
|
|
137
|
+
public revert(output: Fr[]) {
|
|
138
|
+
this.halted = true;
|
|
139
|
+
this.reverted = true;
|
|
140
|
+
this.output = output;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public getHalted(): boolean {
|
|
144
|
+
return this.halted;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
public getReverted(): boolean {
|
|
148
|
+
return this.reverted;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
public getOutput(): Fr[] {
|
|
152
|
+
return this.output;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Flag an exceptional halt. Clears gas left and sets the reverted flag. No output data.
|
|
157
|
+
*/
|
|
158
|
+
private exceptionalHalt() {
|
|
159
|
+
this.l2GasLeft = 0;
|
|
160
|
+
this.daGasLeft = 0;
|
|
161
|
+
this.reverted = true;
|
|
162
|
+
this.halted = true;
|
|
163
|
+
}
|
|
164
|
+
}
|