|
Barretenberg
The ZK-SNARK library at the core of Aztec
|
#include <execution.hpp>
Classes | |
| struct | ExecutionResult |
Public Member Functions | |
| Execution (AluInterface &alu, BitwiseInterface &bitwise, DataCopyInterface &data_copy, Poseidon2Interface &poseidon2, EccInterface &ecc, ToRadixInterface &to_radix, Sha256Interface &sha256, ExecutionComponentsProviderInterface &execution_components, ContextProviderInterface &context_provider, const InstructionInfoDBInterface &instruction_info_db, ExecutionIdManagerInterface &execution_id_manager, EventEmitterInterface< ExecutionEvent > &event_emitter, EventEmitterInterface< ContextStackEvent > &ctx_stack_emitter, KeccakF1600Interface &keccakf1600, GreaterThanInterface &greater_than, GetContractInstanceInterface &get_contract_instance_component, EmitUnencryptedLogInterface &emit_unencrypted_log_component, DebugLoggerInterface &debug_log_component, HighLevelMerkleDBInterface &merkle_db, CallStackMetadataCollectorInterface &call_stack_metadata_collector) | |
| EnqueuedCallResult | execute (std::unique_ptr< ContextInterface > enqueued_call_context) override |
| Execute a top-level enqueued call. | |
| void | add (ContextInterface &context, MemoryAddress a_addr, MemoryAddress b_addr, MemoryAddress dst_addr) |
| ADD execution opcode handler: Add two values. | |
| void | sub (ContextInterface &context, MemoryAddress a_addr, MemoryAddress b_addr, MemoryAddress dst_addr) |
| SUB execution opcode handler: Subtract two values. | |
| void | mul (ContextInterface &context, MemoryAddress a_addr, MemoryAddress b_addr, MemoryAddress dst_addr) |
| MUL execution opcode handler: Multiply two values. | |
| void | div (ContextInterface &context, MemoryAddress a_addr, MemoryAddress b_addr, MemoryAddress dst_addr) |
| DIV execution opcode handler: Divide two values. | |
| void | fdiv (ContextInterface &context, MemoryAddress a_addr, MemoryAddress b_addr, MemoryAddress dst_addr) |
| FDIV execution opcode handler: Divide two field values. | |
| void | eq (ContextInterface &context, MemoryAddress a_addr, MemoryAddress b_addr, MemoryAddress dst_addr) |
| EQ execution opcode handler: Check if two values are equal. | |
| void | lt (ContextInterface &context, MemoryAddress a_addr, MemoryAddress b_addr, MemoryAddress dst_addr) |
| LT execution opcode handler: Check if the first value is less than the second. | |
| void | lte (ContextInterface &context, MemoryAddress a_addr, MemoryAddress b_addr, MemoryAddress dst_addr) |
| LTE execution opcode handler: Check if the first value is less than or equal to the second. | |
| void | op_not (ContextInterface &context, MemoryAddress src_addr, MemoryAddress dst_addr) |
| NOT execution opcode handler: Perform bitwise NOT operation on a value. | |
| void | cast (ContextInterface &context, MemoryAddress src_addr, MemoryAddress dst_addr, uint8_t dst_tag) |
| CAST execution opcode handler: Cast a value to a different tag. | |
| void | get_env_var (ContextInterface &context, MemoryAddress dst_addr, uint8_t var_enum) |
| GETENVVAR execution opcode handler: Get the value of an environment variable. | |
| void | set (ContextInterface &context, MemoryAddress dst_addr, uint8_t tag, const FF &value) |
| SET execution opcode handler: Set the value at a memory location. If the value does not fit in the target tag, it is truncated (like CAST operation). | |
| void | mov (ContextInterface &context, MemoryAddress src_addr, MemoryAddress dst_addr) |
| MOV execution opcode handler: Move a memory value from one memory location to another. | |
| void | jump (ContextInterface &context, uint32_t loc) |
| JUMP execution opcode handler: Jump to a new program counter. Next instruction will be executed at the new program counter. | |
| void | jumpi (ContextInterface &context, MemoryAddress cond_addr, uint32_t loc) |
| JUMPI execution opcode handler: Jump to a new program counter conditionally. Next instruction will be executed at the new program counter if the condition is true. | |
| void | call (ContextInterface &context, MemoryAddress l2_gas_offset, MemoryAddress da_gas_offset, MemoryAddress addr, MemoryAddress cd_size_offset, MemoryAddress cd_offset) |
| CALL execution opcode handler: Call a contract. Creates a new (nested) execution context and triggers execution within that context. Execution proceeds in the nested context until it reaches a halt at which point execution resumes in the current/calling context. A non-existent contract or one with no code will return success. | |
| void | static_call (ContextInterface &context, MemoryAddress l2_gas_offset, MemoryAddress da_gas_offset, MemoryAddress addr, MemoryAddress cd_size_offset, MemoryAddress cd_offset) |
| STATICCALL execution opcode handler: Call a contract in a static context. Creates a new (nested) execution context and triggers execution within that context. Execution proceeds in the nested context until it reaches a halt at which point execution resumes in the current/calling context. The created nested context is forced to be static (contrary to CALL where it is inherited). | |
| void | ret (ContextInterface &context, MemoryAddress ret_size_offset, MemoryAddress ret_offset) |
| RETURN execution opcode handler: Return from a contract. Sets the execution result to the return data size and offset, and halts the execution. The execution result is marked as successful. | |
| void | revert (ContextInterface &context, MemoryAddress rev_size_offset, MemoryAddress rev_offset) |
| REVERT execution opcode handler: Revert from a contract. Sets the execution result to the revert data size and offset, and halts the execution. The execution result is marked as unsuccessful. | |
| void | cd_copy (ContextInterface &context, MemoryAddress cd_size_offset, MemoryAddress cd_offset, MemoryAddress dst_addr) |
| CALLDATACOPY execution opcode handler: Copy calldata from the parent context to the current context. The calldata is copied to the current context's memory at the specified offset. | |
| void | rd_copy (ContextInterface &context, MemoryAddress rd_size_offset, MemoryAddress rd_offset, MemoryAddress dst_addr) |
| RETURNDATACOPY execution opcode handler: Copy return data from the current context to the parent context. | |
| void | rd_size (ContextInterface &context, MemoryAddress dst_addr) |
| RETURNDATASIZE execution opcode handler: Get the size of the return data. | |
| void | internal_call (ContextInterface &context, uint32_t loc) |
| INTERNALCALL execution opcode handler: Call a function in the current context. Pushes the current program counter onto the internal call stack and jumps to the target location to call the function at. | |
| void | internal_return (ContextInterface &context) |
| INTERNALRETURN execution opcode handler: Return from a function in the current context. Pops the current program counter from the internal call stack and jumps to the popped location. | |
| void | keccak_permutation (ContextInterface &context, MemoryAddress dst_addr, MemoryAddress src_addr) |
| KECCAKF1600 execution opcode handler: Perform a Keccak permutation on the data. | |
| void | success_copy (ContextInterface &context, MemoryAddress dst_addr) |
| SUCCESSCOPY execution opcode handler: Copy the success flag to the destination memory location. | |
| void | debug_log (ContextInterface &context, MemoryAddress level_offset, MemoryAddress message_offset, MemoryAddress fields_offset, MemoryAddress fields_size_offset, uint16_t message_size) |
| DEBUGLOG execution opcode handler: Log a debug message. Logs a debug message to the debug logger if the level is enabled. Otherwise, it is a no-op. | |
| void | and_op (ContextInterface &context, MemoryAddress a_addr, MemoryAddress b_addr, MemoryAddress dst_addr) |
| AND execution opcode handler: Perform a bitwise AND operation on the two input values. | |
| void | or_op (ContextInterface &context, MemoryAddress a_addr, MemoryAddress b_addr, MemoryAddress dst_addr) |
| OR execution opcode handler: Perform a bitwise OR operation on the two input values. | |
| void | xor_op (ContextInterface &context, MemoryAddress a_addr, MemoryAddress b_addr, MemoryAddress dst_addr) |
| XOR execution opcode handler: Perform a bitwise XOR operation on the two input values. | |
| void | sload (ContextInterface &context, MemoryAddress slot_addr, MemoryAddress dst_addr) |
| SLOAD execution opcode handler: Load a value from the public data tree. Loads a value from the public data tree at the specified slot. The value is read from the public data tree and written to the destination memory address. | |
| void | sstore (ContextInterface &context, MemoryAddress src_addr, MemoryAddress slot_addr) |
| SSTORE execution opcode handler: Store a value in the public data tree. | |
| void | note_hash_exists (ContextInterface &context, MemoryAddress unique_note_hash_addr, MemoryAddress leaf_index_addr, MemoryAddress dst_addr) |
| NOTEHASHEXISTS execution opcode handler: Check if a note hash exists in the note hash tree at the specified leaf index. The result (boolean value) is written to the destination memory address. | |
| void | nullifier_exists (ContextInterface &context, MemoryAddress nullifier_offset, MemoryAddress address_offset, MemoryAddress exists_offset) |
| NULLIFIEREXISTS execution opcode handler: Check if a nullifier exists in the nullifier tree. | |
| void | emit_nullifier (ContextInterface &context, MemoryAddress nullifier_addr) |
| EMITNULLIFIER execution opcode handler: Emit a nullifier to the nullifier tree. | |
| void | get_contract_instance (ContextInterface &context, MemoryAddress address_offset, MemoryAddress dst_offset, uint8_t member_enum) |
| GETCONTRACTINSTANCE execution opcode handler: Get a contract instance. Gets a contract instance from the contract instance manager. The result is written to the destination memory address. | |
| void | emit_note_hash (ContextInterface &context, MemoryAddress note_hash_addr) |
| EMITNOTEHASH execution opcode handler: Emit a note hash to the note hash tree. | |
| void | l1_to_l2_message_exists (ContextInterface &context, MemoryAddress msg_hash_addr, MemoryAddress leaf_index_addr, MemoryAddress dst_addr) |
| L1TOL2MSGEXISTS execution opcode handler: Check if a L2 to L1 message exists in the L1 to L2 message tree at the specified leaf index. The result (boolean value) is written to the destination memory address. | |
| void | poseidon2_permutation (ContextInterface &context, MemoryAddress src_addr, MemoryAddress dst_addr) |
| POSEIDON2PERMUTATION execution opcode handler: Perform a Poseidon2 permutation on the input value. The result is written to the destination memory address. | |
| void | ecc_add (ContextInterface &context, MemoryAddress p_x_addr, MemoryAddress p_y_addr, MemoryAddress p_inf_addr, MemoryAddress q_x_addr, MemoryAddress q_y_addr, MemoryAddress q_inf_addr, MemoryAddress dst_addr) |
| ECADD execution opcode handler: Perform an elliptic curve addition and write the result to the destination memory address. | |
| void | to_radix_be (ContextInterface &context, MemoryAddress value_addr, MemoryAddress radix_addr, MemoryAddress num_limbs_addr, MemoryAddress is_output_bits_addr, MemoryAddress dst_addr) |
| TORADIXBE execution opcode handler: Convert a value to a radix-based representation. The result is written to the destination memory address. | |
| void | emit_unencrypted_log (ContextInterface &context, MemoryAddress log_size_offset, MemoryAddress log_offset) |
| EMITUNENCRYPTEDLOG execution opcode handler: Emit an unencrypted log. | |
| void | send_l2_to_l1_msg (ContextInterface &context, MemoryAddress recipient_addr, MemoryAddress content_addr) |
| SENDL2TOL1MSG execution opcode handler: Send a L2 to L1 message. | |
| void | sha256_compression (ContextInterface &context, MemoryAddress output_addr, MemoryAddress state_addr, MemoryAddress input_addr) |
| SHA256COMPRESSION execution opcode handler: Perform a SHA256 compression on the input and state values. The result is written to the output memory address. | |
| void | shr (ContextInterface &context, MemoryAddress a_addr, MemoryAddress b_addr, MemoryAddress dst_addr) |
| SHR execution opcode handler: Perform right shift operation on a value. | |
| void | shl (ContextInterface &context, MemoryAddress a_addr, MemoryAddress b_addr, MemoryAddress dst_addr) |
| SHL execution opcode handler: Perform left shift operation on a value. | |
Public Member Functions inherited from bb::avm2::simulation::ExecutionInterface | |
| virtual | ~ExecutionInterface ()=default |
Protected Member Functions | |
| virtual GasTrackerInterface & | get_gas_tracker () |
| void | set_execution_result (const ExecutionResult &exec_result) |
| const ExecutionResult & | get_execution_result () const |
| void | dispatch_opcode (ExecutionOpCode opcode, ContextInterface &context, const std::vector< Operand > &resolved_operands) |
| Dispatch an opcode. This is the main function that dispatches the opcode to the appropriate handler. | |
| template<typename... Ts> | |
| void | call_with_operands (void(Execution::*f)(ContextInterface &, Ts...), ContextInterface &context, const std::vector< Operand > &resolved_operands) |
| Call with operands. This is a template magic function to dispatch the opcode by deducing the number of arguments and types, and making the appropriate checks and casts. | |
| std::vector< Operand > | resolve_operands (const Instruction &instruction, const ExecInstructionSpec &spec) |
| void | handle_enter_call (ContextInterface &parent_context, std::unique_ptr< ContextInterface > child_context) |
| Handle the entering of a call. This is called when a call is made from a context. This is a helper function for the CALL and STATICCALL opcodes. | |
| void | handle_exit_call () |
| Handle the exiting of a call. This is called when a call returns or reverts. | |
| void | handle_exceptional_halt (ContextInterface &context, const std::string &halting_message) |
| Handle the exceptional halt of a context. This is called when an exception is thrown during the execution of a context. | |
| void | set_and_validate_inputs (ExecutionOpCode opcode, const std::vector< MemoryValue > &inputs) |
| Set the register inputs and validate the tags. The tag information is taken from the instruction info database. | |
| void | set_output (ExecutionOpCode opcode, const MemoryValue &output) |
| Set the output register. | |
| const std::vector< MemoryValue > & | get_inputs () const |
| const MemoryValue & | get_output () const |
Definition at line 61 of file execution.hpp.
|
inline |
Definition at line 63 of file execution.hpp.
| void bb::avm2::simulation::Execution::add | ( | ContextInterface & | context, |
| MemoryAddress | a_addr, | ||
| MemoryAddress | b_addr, | ||
| MemoryAddress | dst_addr | ||
| ) |
ADD execution opcode handler: Add two values.
IMPORTANT NOTE FOR OPCODE EXECUTION METHODS:
For every opcode execution method (e.g. Execution::add(), Execution::sub(), etc), it is crucial to preserve the following order of operations (temporality groups 3,4,5,6):
This order is crucial for the completeness of the circuit. In tracegen, we rely on this order to correctly populate the execution trace. In particular, we stop processing if any of the above exceptions are thrown.
| context | The context. |
| a_addr | The resolved address of the first input value. |
| b_addr | The resolved address of the second input value. |
| dst_addr | The resolved address of the output value. |
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the tags of both inputs do not match. |
Definition at line 69 of file execution.cpp.
| void bb::avm2::simulation::Execution::and_op | ( | ContextInterface & | context, |
| MemoryAddress | a_addr, | ||
| MemoryAddress | b_addr, | ||
| MemoryAddress | dst_addr | ||
| ) |
AND execution opcode handler: Perform a bitwise AND operation on the two input values.
| context | The context. |
| a_addr | The resolved address of the first input value. |
| b_addr | The resolved address of the second input value. |
| dst_addr | The resolved address of the output memory value. |
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the bitwise AND operation fails:
|
Definition at line 1005 of file execution.cpp.
| void bb::avm2::simulation::Execution::call | ( | ContextInterface & | context, |
| MemoryAddress | l2_gas_offset, | ||
| MemoryAddress | da_gas_offset, | ||
| MemoryAddress | addr, | ||
| MemoryAddress | cd_size_offset, | ||
| MemoryAddress | cd_offset | ||
| ) |
CALL execution opcode handler: Call a contract. Creates a new (nested) execution context and triggers execution within that context. Execution proceeds in the nested context until it reaches a halt at which point execution resumes in the current/calling context. A non-existent contract or one with no code will return success.
| context | The context. |
| l2_gas_offset | The resolved address of the allocated L2 gas value. |
| da_gas_offset | The resolved address of the allocated DA gas value. |
| addr | The resolved address of the contract address. |
| cd_size_offset | The resolved address of the calldata size value. |
| cd_offset | The resolved address of the calldata offset value. |
| RegisterValidationException | if the tags of the input values do not match the expected tags:
|
| OutOfGasException | if the gas limit is exceeded. |
Definition at line 564 of file execution.cpp.
|
inlineprotected |
Call with operands. This is a template magic function to dispatch the opcode by deducing the number of arguments and types, and making the appropriate checks and casts.
| f | The function to call. |
| context | The context. |
| resolved_operands | The resolved operands. |
Definition at line 2130 of file execution.cpp.
| void bb::avm2::simulation::Execution::cast | ( | ContextInterface & | context, |
| MemoryAddress | src_addr, | ||
| MemoryAddress | dst_addr, | ||
| uint8_t | dst_tag | ||
| ) |
CAST execution opcode handler: Cast a value to a different tag.
| context | The context. |
| src_addr | The resolved address of the input value. |
| dst_addr | The resolved address of the output value. |
| dst_tag | The target memory tag to cast to. |
| OutOfGasException | if the gas limit is exceeded. |
Definition at line 417 of file execution.cpp.
| void bb::avm2::simulation::Execution::cd_copy | ( | ContextInterface & | context, |
| MemoryAddress | cd_size_offset, | ||
| MemoryAddress | cd_offset, | ||
| MemoryAddress | dst_addr | ||
| ) |
CALLDATACOPY execution opcode handler: Copy calldata from the parent context to the current context. The calldata is copied to the current context's memory at the specified offset.
| context | The context. |
| cd_size_offset | The resolved address of the calldata size value. |
| cd_offset | The resolved address of the calldata offset value. |
| dst_addr | The resolved address of the destination memory location. |
| RegisterValidationException | if the tags of the input values do not match the expected tags:
|
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the data copy operation fails:
|
Definition at line 679 of file execution.cpp.
| void bb::avm2::simulation::Execution::debug_log | ( | ContextInterface & | context, |
| MemoryAddress | level_offset, | ||
| MemoryAddress | message_offset, | ||
| MemoryAddress | fields_offset, | ||
| MemoryAddress | fields_size_offset, | ||
| uint16_t | message_size | ||
| ) |
DEBUGLOG execution opcode handler: Log a debug message. Logs a debug message to the debug logger if the level is enabled. Otherwise, it is a no-op.
| context | The context. |
| level_offset | The resolved address of the log level value. |
| message_offset | The resolved address of the log message value. |
| fields_offset | The resolved address of the log fields value. |
| fields_size_offset | The resolved address of the log fields size value. |
| message_size | The size of the log message. |
| OutOfGasException | if the gas limit is exceeded. |
Definition at line 952 of file execution.cpp.
|
protected |
Dispatch an opcode. This is the main function that dispatches the opcode to the appropriate handler.
| opcode | The opcode to dispatch. |
| context | The context. |
| resolved_operands | The resolved operands. |
Definition at line 1967 of file execution.cpp.
| void bb::avm2::simulation::Execution::div | ( | ContextInterface & | context, |
| MemoryAddress | a_addr, | ||
| MemoryAddress | b_addr, | ||
| MemoryAddress | dst_addr | ||
| ) |
DIV execution opcode handler: Divide two values.
| context | The context. |
| a_addr | The resolved address of the first input value. |
| b_addr | The resolved address of the second input value (divisor). |
| dst_addr | The resolved address of the output value. |
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the division operation fails:
|
Definition at line 165 of file execution.cpp.
| void bb::avm2::simulation::Execution::ecc_add | ( | ContextInterface & | context, |
| MemoryAddress | p_x_addr, | ||
| MemoryAddress | p_y_addr, | ||
| MemoryAddress | p_inf_addr, | ||
| MemoryAddress | q_x_addr, | ||
| MemoryAddress | q_y_addr, | ||
| MemoryAddress | q_inf_addr, | ||
| MemoryAddress | dst_addr | ||
| ) |
ECADD execution opcode handler: Perform an elliptic curve addition and write the result to the destination memory address.
| context | The context. |
| p_x_addr | The resolved address of the x coordinate of the first point. |
| p_y_addr | The resolved address of the y coordinate of the first point. |
| p_inf_addr | The resolved address of the infinity flag of the first point. |
| q_x_addr | The resolved address of the x coordinate of the second point. |
| q_y_addr | The resolved address of the y coordinate of the second point. |
| q_inf_addr | The resolved address of the infinity flag of the second point. |
| dst_addr | The resolved address of the destination memory address. |
| RegisterValidationException | if the tags of the input values do not match the expected tags:
|
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the elliptic curve addition operation fails:
|
Definition at line 1475 of file execution.cpp.
| void bb::avm2::simulation::Execution::emit_note_hash | ( | ContextInterface & | context, |
| MemoryAddress | note_hash_addr | ||
| ) |
EMITNOTEHASH execution opcode handler: Emit a note hash to the note hash tree.
| context | The context. |
| note_hash_addr | The resolved address of the note hash value. |
| RegisterValidationException | if the tags of the input values do not match the expected tags:
|
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the note hash write operation fails:
|
Definition at line 1357 of file execution.cpp.
| void bb::avm2::simulation::Execution::emit_nullifier | ( | ContextInterface & | context, |
| MemoryAddress | nullifier_addr | ||
| ) |
EMITNULLIFIER execution opcode handler: Emit a nullifier to the nullifier tree.
| context | The context. |
| nullifier_addr | The resolved address of the nullifier value. |
| RegisterValidationException | if the tags of the input values do not match the expected tags:
|
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the nullifier write operation fails:
|
Definition at line 1272 of file execution.cpp.
| void bb::avm2::simulation::Execution::emit_unencrypted_log | ( | ContextInterface & | context, |
| MemoryAddress | log_size_offset, | ||
| MemoryAddress | log_offset | ||
| ) |
EMITUNENCRYPTEDLOG execution opcode handler: Emit an unencrypted log.
| context | The context. |
| log_size_offset | The resolved address of the log size value. |
| log_offset | The resolved address of the log field values. |
| RegisterValidationException | if the tags of the input values do not match the expected tags:
|
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the unencrypted log emission operation fails:
|
Definition at line 1611 of file execution.cpp.
| void bb::avm2::simulation::Execution::eq | ( | ContextInterface & | context, |
| MemoryAddress | a_addr, | ||
| MemoryAddress | b_addr, | ||
| MemoryAddress | dst_addr | ||
| ) |
EQ execution opcode handler: Check if two values are equal.
| context | The context. |
| a_addr | The resolved address of the first input value. |
| b_addr | The resolved address of the second input value. |
| dst_addr | The resolved address of the output value. |
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the tags of both inputs do not match |
Definition at line 230 of file execution.cpp.
|
overridevirtual |
Execute a top-level enqueued call.
| enqueued_call_context | The unique pointer to a top-level enqueued call context. This context interface is a top-level enqueued call context. |
NOTE: For the moment this trace is not returning the context back.
Implements bb::avm2::simulation::ExecutionInterface.
Reimplemented in bb::avm2::simulation::HybridExecution.
Definition at line 1713 of file execution.cpp.
| void bb::avm2::simulation::Execution::fdiv | ( | ContextInterface & | context, |
| MemoryAddress | a_addr, | ||
| MemoryAddress | b_addr, | ||
| MemoryAddress | dst_addr | ||
| ) |
FDIV execution opcode handler: Divide two field values.
| context | The context. |
| a_addr | The resolved address of the first input value. |
| b_addr | The resolved address of the second input value (divisor). |
| dst_addr | The resolved address of the output value. |
| RegisterValidationException | if one of the input tag is not a field element |
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the field division operation fails:
|
Definition at line 199 of file execution.cpp.
| void bb::avm2::simulation::Execution::get_contract_instance | ( | ContextInterface & | context, |
| MemoryAddress | address_offset, | ||
| MemoryAddress | dst_offset, | ||
| uint8_t | member_enum | ||
| ) |
GETCONTRACTINSTANCE execution opcode handler: Get a contract instance. Gets a contract instance from the contract instance manager. The result is written to the destination memory address.
| context | The context. |
| address_offset | The resolved address of the contract address value. |
| dst_offset | The resolved address of the output (2 memory values: exists flag U1 and member value FF). |
| member_enum | The enum value of the member to get. |
| RegisterValidationException | if the tags of the input values do not match the expected tags:
|
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the contract instance retrieval operation fails:
|
Definition at line 1317 of file execution.cpp.
| void bb::avm2::simulation::Execution::get_env_var | ( | ContextInterface & | context, |
| MemoryAddress | dst_addr, | ||
| uint8_t | var_enum | ||
| ) |
GETENVVAR execution opcode handler: Get the value of an environment variable.
| context | The context. |
| dst_addr | The resolved address of the output value. |
| var_enum | The enum value of the environment variable to get. |
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the enum value is invalid. |
Definition at line 441 of file execution.cpp.
|
inlineprotected |
Definition at line 218 of file execution.hpp.
|
inlineprotectedvirtual |
Definition at line 215 of file execution.hpp.
|
inlineprotected |
Definition at line 236 of file execution.hpp.
|
inlineprotected |
Definition at line 237 of file execution.hpp.
|
protected |
Handle the entering of a call. This is called when a call is made from a context. This is a helper function for the CALL and STATICCALL opcodes.
| parent_context | The parent context. |
| child_context | The child context. |
Definition at line 1848 of file execution.cpp.
|
protected |
Handle the exceptional halt of a context. This is called when an exception is thrown during the execution of a context.
| context | The context. |
| halting_message | The halting message. |
Definition at line 1945 of file execution.cpp.
|
protected |
Handle the exiting of a call. This is called when a call returns or reverts.
Definition at line 1887 of file execution.cpp.
| void bb::avm2::simulation::Execution::internal_call | ( | ContextInterface & | context, |
| uint32_t | loc | ||
| ) |
INTERNALCALL execution opcode handler: Call a function in the current context. Pushes the current program counter onto the internal call stack and jumps to the target location to call the function at.
| context | The context. |
| loc | The target location to call the function at. |
| OutOfGasException | if the gas limit is exceeded. |
Definition at line 879 of file execution.cpp.
| void bb::avm2::simulation::Execution::internal_return | ( | ContextInterface & | context | ) |
INTERNALRETURN execution opcode handler: Return from a function in the current context. Pops the current program counter from the internal call stack and jumps to the popped location.
| context | The context. |
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the internal call stack is empty. |
Definition at line 899 of file execution.cpp.
| void bb::avm2::simulation::Execution::jump | ( | ContextInterface & | context, |
| uint32_t | loc | ||
| ) |
JUMP execution opcode handler: Jump to a new program counter. Next instruction will be executed at the new program counter.
| context | The context. |
| loc | The new program counter. |
| OutOfGasException | if the gas limit is exceeded. |
Definition at line 833 of file execution.cpp.
| void bb::avm2::simulation::Execution::jumpi | ( | ContextInterface & | context, |
| MemoryAddress | cond_addr, | ||
| uint32_t | loc | ||
| ) |
JUMPI execution opcode handler: Jump to a new program counter conditionally. Next instruction will be executed at the new program counter if the condition is true.
| context | The context. |
| cond_addr | The resolved address of the condition value. |
| loc | The new program counter. |
| RegisterValidationException | if the tags of the input values do not match the expected tags:
|
| OutOfGasException | if the gas limit is exceeded. |
Definition at line 853 of file execution.cpp.
| void bb::avm2::simulation::Execution::keccak_permutation | ( | ContextInterface & | context, |
| MemoryAddress | dst_addr, | ||
| MemoryAddress | src_addr | ||
| ) |
KECCAKF1600 execution opcode handler: Perform a Keccak permutation on the data.
| context | The context. |
| dst_addr | The resolved address of the destination memory location. |
| src_addr | The resolved address of the source memory location. |
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the Keccak permutation fails:
|
Definition at line 926 of file execution.cpp.
| void bb::avm2::simulation::Execution::l1_to_l2_message_exists | ( | ContextInterface & | context, |
| MemoryAddress | msg_hash_addr, | ||
| MemoryAddress | leaf_index_addr, | ||
| MemoryAddress | dst_addr | ||
| ) |
L1TOL2MSGEXISTS execution opcode handler: Check if a L2 to L1 message exists in the L1 to L2 message tree at the specified leaf index. The result (boolean value) is written to the destination memory address.
| context | The context. |
| msg_hash_addr | The resolved address of the message hash value. |
| leaf_index_addr | The resolved address of the leaf index value. |
| dst_addr | The resolved address of the output memory value (boolean value U1). |
| RegisterValidationException | if the tags of the input values do not match the expected tags:
|
| OutOfGasException | if the gas limit is exceeded. |
Definition at line 1395 of file execution.cpp.
| void bb::avm2::simulation::Execution::lt | ( | ContextInterface & | context, |
| MemoryAddress | a_addr, | ||
| MemoryAddress | b_addr, | ||
| MemoryAddress | dst_addr | ||
| ) |
LT execution opcode handler: Check if the first value is less than the second.
| context | The context. |
| a_addr | The resolved address of the first input value. (left operand) |
| b_addr | The resolved address of the second input value (right operand). |
| dst_addr | The resolved address of the output value. |
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the tags of both inputs do not match |
Definition at line 261 of file execution.cpp.
| void bb::avm2::simulation::Execution::lte | ( | ContextInterface & | context, |
| MemoryAddress | a_addr, | ||
| MemoryAddress | b_addr, | ||
| MemoryAddress | dst_addr | ||
| ) |
LTE execution opcode handler: Check if the first value is less than or equal to the second.
| context | The context. |
| a_addr | The resolved address of the first input value. (left operand) |
| b_addr | The resolved address of the second input value (right operand). |
| dst_addr | The resolved address of the output value. |
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the tags of both inputs do not match |
Definition at line 292 of file execution.cpp.
| void bb::avm2::simulation::Execution::mov | ( | ContextInterface & | context, |
| MemoryAddress | src_addr, | ||
| MemoryAddress | dst_addr | ||
| ) |
MOV execution opcode handler: Move a memory value from one memory location to another.
| context | The context. |
| src_addr | The resolved address of the source memory value. |
| dst_addr | The resolved address of the output memory value. |
| OutOfGasException | if the gas limit is exceeded. |
Definition at line 529 of file execution.cpp.
| void bb::avm2::simulation::Execution::mul | ( | ContextInterface & | context, |
| MemoryAddress | a_addr, | ||
| MemoryAddress | b_addr, | ||
| MemoryAddress | dst_addr | ||
| ) |
MUL execution opcode handler: Multiply two values.
| context | The context. |
| a_addr | The resolved address of the first input value. |
| b_addr | The resolved address of the second input value. |
| dst_addr | The resolved address of the output value. |
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the tags of both inputs do not match. |
Definition at line 131 of file execution.cpp.
| void bb::avm2::simulation::Execution::note_hash_exists | ( | ContextInterface & | context, |
| MemoryAddress | unique_note_hash_addr, | ||
| MemoryAddress | leaf_index_addr, | ||
| MemoryAddress | dst_addr | ||
| ) |
NOTEHASHEXISTS execution opcode handler: Check if a note hash exists in the note hash tree at the specified leaf index. The result (boolean value) is written to the destination memory address.
| context | The context. |
| unique_note_hash_addr | The resolved address of the unique note hash value. |
| leaf_index_addr | The resolved address of the leaf index value. |
| dst_addr | The resolved address of the output memory value. |
| RegisterValidationException | if the tags of the input values do not match the expected tags:
|
| OutOfGasException | if the gas limit is exceeded. |
Definition at line 1188 of file execution.cpp.
| void bb::avm2::simulation::Execution::nullifier_exists | ( | ContextInterface & | context, |
| MemoryAddress | nullifier_offset, | ||
| MemoryAddress | address_offset, | ||
| MemoryAddress | exists_offset | ||
| ) |
NULLIFIEREXISTS execution opcode handler: Check if a nullifier exists in the nullifier tree.
| context | The context. |
| nullifier_offset | The resolved address of the nullifier value. |
| address_offset | The resolved address of the address value. |
| dst_addr | The resolved address of the output memory value (boolean value U1). |
| RegisterValidationException | if the tags of the input values do not match the expected tags:
|
| OutOfGasException | if the gas limit is exceeded. |
Definition at line 1232 of file execution.cpp.
| void bb::avm2::simulation::Execution::op_not | ( | ContextInterface & | context, |
| MemoryAddress | src_addr, | ||
| MemoryAddress | dst_addr | ||
| ) |
NOT execution opcode handler: Perform bitwise NOT operation on a value.
| context | The context. |
| src_addr | The resolved address of the input value. |
| dst_addr | The resolved address of the output value. (same tag as src_addr) |
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the tag of the input value is FF (field element). |
Definition at line 322 of file execution.cpp.
| void bb::avm2::simulation::Execution::or_op | ( | ContextInterface & | context, |
| MemoryAddress | a_addr, | ||
| MemoryAddress | b_addr, | ||
| MemoryAddress | dst_addr | ||
| ) |
OR execution opcode handler: Perform a bitwise OR operation on the two input values.
| context | The context. |
| a_addr | The resolved address of the first input value. |
| b_addr | The resolved address of the second input value. |
| dst_addr | The resolved address of the output memory value. |
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the bitwise OR operation fails:
|
Definition at line 1042 of file execution.cpp.
| void bb::avm2::simulation::Execution::poseidon2_permutation | ( | ContextInterface & | context, |
| MemoryAddress | src_addr, | ||
| MemoryAddress | dst_addr | ||
| ) |
POSEIDON2PERMUTATION execution opcode handler: Perform a Poseidon2 permutation on the input value. The result is written to the destination memory address.
| context | The context. |
| src_addr | The resolved address of the input value. |
| dst_addr | The resolved address of the output value. |
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the Poseidon2 permutation operation fails:
|
Definition at line 1439 of file execution.cpp.
| void bb::avm2::simulation::Execution::rd_copy | ( | ContextInterface & | context, |
| MemoryAddress | rd_size_offset, | ||
| MemoryAddress | rd_offset, | ||
| MemoryAddress | dst_addr | ||
| ) |
RETURNDATACOPY execution opcode handler: Copy return data from the current context to the parent context.
| context | The context. |
| rd_size_offset | The resolved address of the return data size value. |
| rd_offset | The resolved address of the return data offset value. |
| dst_addr | The resolved address of the destination memory location. |
| RegisterValidationException | if the tags of the input values do not match the expected tags:
|
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the data copy operation fails:
|
Definition at line 715 of file execution.cpp.
| void bb::avm2::simulation::Execution::rd_size | ( | ContextInterface & | context, |
| MemoryAddress | dst_addr | ||
| ) |
RETURNDATASIZE execution opcode handler: Get the size of the return data.
| context | The context. |
| dst_addr | The resolved address of the output memory value (return data size). |
| OutOfGasException | if the gas limit is exceeded. |
Definition at line 744 of file execution.cpp.
|
protected |
| void bb::avm2::simulation::Execution::ret | ( | ContextInterface & | context, |
| MemoryAddress | ret_size_offset, | ||
| MemoryAddress | ret_offset | ||
| ) |
RETURN execution opcode handler: Return from a contract. Sets the execution result to the return data size and offset, and halts the execution. The execution result is marked as successful.
| context | The context. |
| ret_size_offset | The resolved address of the return data size value. |
| ret_offset | The resolved address of the return data offset value. |
| RegisterValidationException | if the tags of the input values do not match the expected tags:
|
| OutOfGasException | if the gas limit is exceeded. |
Definition at line 771 of file execution.cpp.
| void bb::avm2::simulation::Execution::revert | ( | ContextInterface & | context, |
| MemoryAddress | rev_size_offset, | ||
| MemoryAddress | rev_offset | ||
| ) |
REVERT execution opcode handler: Revert from a contract. Sets the execution result to the revert data size and offset, and halts the execution. The execution result is marked as unsuccessful.
| context | The context. |
| rev_size_offset | The resolved address of the revert data size value. |
| rev_offset | The resolved address of the revert data offset value. |
| RegisterValidationException | if the tags of the input values do not match the expected tags:
|
| OutOfGasException | if the gas limit is exceeded. |
Definition at line 804 of file execution.cpp.
| void bb::avm2::simulation::Execution::send_l2_to_l1_msg | ( | ContextInterface & | context, |
| MemoryAddress | recipient_addr, | ||
| MemoryAddress | content_addr | ||
| ) |
SENDL2TOL1MSG execution opcode handler: Send a L2 to L1 message.
| context | The context. |
| recipient_addr | The resolved address of the recipient value. |
| content_addr | The resolved address of the content value. |
| RegisterValidationException | if the tags of the input values do not match the expected tags:
|
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the L2 to L1 message send operation fails:
|
Definition at line 1647 of file execution.cpp.
| void bb::avm2::simulation::Execution::set | ( | ContextInterface & | context, |
| MemoryAddress | dst_addr, | ||
| uint8_t | dst_tag, | ||
| const FF & | value | ||
| ) |
SET execution opcode handler: Set the value at a memory location. If the value does not fit in the target tag, it is truncated (like CAST operation).
| context | The context. |
| dst_addr | The resolved address of the output memory value. |
| dst_tag | The destination tag of the value to set. (as an uint8_t) |
| value | The source value to set. (might get truncated) |
| OutOfGasException | if the gas limit is exceeded. |
Definition at line 509 of file execution.cpp.
|
protected |
Set the register inputs and validate the tags. The tag information is taken from the instruction info database.
| opcode | The opcode. |
| inputs | The inputs. |
Definition at line 2148 of file execution.cpp.
|
inlineprotected |
Definition at line 217 of file execution.hpp.
|
protected |
Set the output register.
| opcode | The opcode. |
| output | The output. |
Definition at line 2171 of file execution.cpp.
| void bb::avm2::simulation::Execution::sha256_compression | ( | ContextInterface & | context, |
| MemoryAddress | output_addr, | ||
| MemoryAddress | state_addr, | ||
| MemoryAddress | input_addr | ||
| ) |
SHA256COMPRESSION execution opcode handler: Perform a SHA256 compression on the input and state values. The result is written to the output memory address.
| context | The context. |
| output_addr | The resolved address of the output memory values. |
| state_addr | The resolved address of the state value. |
| input_addr | The resolved address of the input value. |
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the SHA256 compression operation fails:
|
Definition at line 1688 of file execution.cpp.
| void bb::avm2::simulation::Execution::shl | ( | ContextInterface & | context, |
| MemoryAddress | a_addr, | ||
| MemoryAddress | b_addr, | ||
| MemoryAddress | dst_addr | ||
| ) |
SHL execution opcode handler: Perform left shift operation on a value.
| context | The context. |
| a_addr | The resolved address of the first input value. (left operand) |
| b_addr | The resolved address of the second input value (right operand). |
| dst_addr | The resolved address of the output value. |
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the left shift operation fails:
|
Definition at line 354 of file execution.cpp.
| void bb::avm2::simulation::Execution::shr | ( | ContextInterface & | context, |
| MemoryAddress | a_addr, | ||
| MemoryAddress | b_addr, | ||
| MemoryAddress | dst_addr | ||
| ) |
SHR execution opcode handler: Perform right shift operation on a value.
| context | The context. |
| a_addr | The resolved address of the first input value. (left operand) |
| b_addr | The resolved address of the second input value (right operand). |
| dst_addr | The resolved address of the output value. |
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the right shift operation fails:
|
Definition at line 387 of file execution.cpp.
| void bb::avm2::simulation::Execution::sload | ( | ContextInterface & | context, |
| MemoryAddress | slot_addr, | ||
| MemoryAddress | dst_addr | ||
| ) |
SLOAD execution opcode handler: Load a value from the public data tree. Loads a value from the public data tree at the specified slot. The value is read from the public data tree and written to the destination memory address.
| context | The context. |
| slot_addr | The resolved address of the slot value. |
| dst_addr | The resolved address of the output memory value. |
| RegisterValidationException | if the tags of the input values do not match the expected tags:
|
| OutOfGasException | if the gas limit is exceeded. |
Definition at line 1112 of file execution.cpp.
| void bb::avm2::simulation::Execution::sstore | ( | ContextInterface & | context, |
| MemoryAddress | src_addr, | ||
| MemoryAddress | slot_addr | ||
| ) |
SSTORE execution opcode handler: Store a value in the public data tree.
| context | The context. |
| src_addr | The resolved address of the source memory value. |
| slot_addr | The resolved address of the slot value. |
| RegisterValidationException | if the tags of the input values do not match the expected tags:
|
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the storage write operation fails:
|
Definition at line 1145 of file execution.cpp.
| void bb::avm2::simulation::Execution::static_call | ( | ContextInterface & | context, |
| MemoryAddress | l2_gas_offset, | ||
| MemoryAddress | da_gas_offset, | ||
| MemoryAddress | addr, | ||
| MemoryAddress | cd_size_offset, | ||
| MemoryAddress | cd_offset | ||
| ) |
STATICCALL execution opcode handler: Call a contract in a static context. Creates a new (nested) execution context and triggers execution within that context. Execution proceeds in the nested context until it reaches a halt at which point execution resumes in the current/calling context. The created nested context is forced to be static (contrary to CALL where it is inherited).
| context | The context. |
| l2_gas_offset | The resolved address of the allocated L2 gas value. |
| da_gas_offset | The resolved address of the allocated DA gas value. |
| addr | The resolved address of the contract address. |
| cd_size_offset | The resolved address of the calldata size value. |
| cd_offset | The resolved address of the calldata offset value. |
| RegisterValidationException | if the tags of the input values do not match the expected tags:
|
| OutOfGasException | if the gas limit is exceeded. |
Definition at line 624 of file execution.cpp.
| void bb::avm2::simulation::Execution::sub | ( | ContextInterface & | context, |
| MemoryAddress | a_addr, | ||
| MemoryAddress | b_addr, | ||
| MemoryAddress | dst_addr | ||
| ) |
SUB execution opcode handler: Subtract two values.
| context | The context. |
| a_addr | The resolved address of the first input value. |
| b_addr | The resolved address of the second input value (subtrahend). |
| dst_addr | The resolved address of the output value. |
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the tags of both inputs do not match. |
Definition at line 100 of file execution.cpp.
| void bb::avm2::simulation::Execution::success_copy | ( | ContextInterface & | context, |
| MemoryAddress | dst_addr | ||
| ) |
SUCCESSCOPY execution opcode handler: Copy the success flag to the destination memory location.
| context | The context. |
| dst_addr | The resolved address of the destination memory location. |
| OutOfGasException | if the gas limit is exceeded. |
Definition at line 979 of file execution.cpp.
| void bb::avm2::simulation::Execution::to_radix_be | ( | ContextInterface & | context, |
| MemoryAddress | value_addr, | ||
| MemoryAddress | radix_addr, | ||
| MemoryAddress | num_limbs_addr, | ||
| MemoryAddress | is_output_bits_addr, | ||
| MemoryAddress | dst_addr | ||
| ) |
TORADIXBE execution opcode handler: Convert a value to a radix-based representation. The result is written to the destination memory address.
| context | The context. |
| value_addr | The resolved address of the value value. |
| radix_addr | The resolved address of the radix value. |
| num_limbs_addr | The resolved address of the number of limbs value. |
| is_output_bits_addr | The resolved address of the output bits value. |
| dst_addr | The resolved address of the output memory values. |
| RegisterValidationException | if the tags of the input values do not match the expected tags:
|
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the radix-based conversion operation fails:
|
Definition at line 1536 of file execution.cpp.
| void bb::avm2::simulation::Execution::xor_op | ( | ContextInterface & | context, |
| MemoryAddress | a_addr, | ||
| MemoryAddress | b_addr, | ||
| MemoryAddress | dst_addr | ||
| ) |
XOR execution opcode handler: Perform a bitwise XOR operation on the two input values.
| context | The context. |
| a_addr | The resolved address of the first input value. |
| b_addr | The resolved address of the second input value. |
| dst_addr | The resolved address of the output memory value. |
| OutOfGasException | if the gas limit is exceeded. |
| OpcodeExecutionException | if the bitwise XOR operation fails:
|
Definition at line 1077 of file execution.cpp.
|
protected |
Definition at line 242 of file execution.hpp.
|
protected |
Definition at line 243 of file execution.hpp.
|
protected |
Definition at line 260 of file execution.hpp.
|
protected |
Definition at line 248 of file execution.hpp.
|
protected |
Definition at line 259 of file execution.hpp.
|
protected |
Definition at line 250 of file execution.hpp.
|
protected |
Definition at line 255 of file execution.hpp.
|
protected |
Definition at line 245 of file execution.hpp.
|
protected |
Definition at line 254 of file execution.hpp.
|
protected |
Definition at line 258 of file execution.hpp.
|
protected |
Definition at line 262 of file execution.hpp.
|
protected |
Definition at line 239 of file execution.hpp.
|
protected |
Definition at line 249 of file execution.hpp.
|
protected |
Definition at line 264 of file execution.hpp.
|
protected |
Definition at line 267 of file execution.hpp.
|
protected |
Definition at line 253 of file execution.hpp.
|
protected |
Definition at line 252 of file execution.hpp.
|
protected |
Definition at line 265 of file execution.hpp.
|
protected |
Definition at line 240 of file execution.hpp.
|
protected |
Definition at line 251 of file execution.hpp.
|
protected |
Definition at line 256 of file execution.hpp.
|
protected |
Definition at line 266 of file execution.hpp.
|
protected |
Definition at line 244 of file execution.hpp.
|
protected |
Definition at line 247 of file execution.hpp.
|
protected |
Definition at line 246 of file execution.hpp.