Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::avm2::simulation::Execution Class Reference

#include <execution.hpp>

Inheritance diagram for bb::avm2::simulation::Execution:
bb::avm2::simulation::ExecutionInterface bb::avm2::simulation::HybridExecution

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 GasTrackerInterfaceget_gas_tracker ()
 
void set_execution_result (const ExecutionResult &exec_result)
 
const ExecutionResultget_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< Operandresolve_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 MemoryValueget_output () const
 

Protected Attributes

ExecutionComponentsProviderInterfaceexecution_components
 
const InstructionInfoDBInterfaceinstruction_info_db
 
AluInterfacealu
 
BitwiseInterfacebitwise
 
Poseidon2Interfaceposeidon2
 
EccInterfaceembedded_curve
 
ToRadixInterfaceto_radix
 
Sha256Interfacesha256
 
ContextProviderInterfacecontext_provider
 
ExecutionIdManagerInterfaceexecution_id_manager
 
DataCopyInterfacedata_copy
 
KeccakF1600Interfacekeccakf1600
 
GreaterThanInterfacegreater_than
 
GetContractInstanceInterfaceget_contract_instance_component
 
EmitUnencryptedLogInterfaceemit_unencrypted_log_component
 
DebugLoggerInterfacedebug_log_component
 
HighLevelMerkleDBInterfacemerkle_db
 
EventEmitterInterface< ExecutionEvent > & events
 
EventEmitterInterface< ContextStackEvent > & ctx_stack_events
 
CallStackMetadataCollectorInterfacecall_stack_metadata_collector
 
ExecutionResult exec_result
 
std::stack< std::unique_ptr< ContextInterface > > external_call_stack
 
std::vector< MemoryValueinputs
 
MemoryValue output
 
std::unique_ptr< GasTrackerInterfacegas_tracker
 

Detailed Description

Definition at line 61 of file execution.hpp.

Constructor & Destructor Documentation

◆ Execution()

bb::avm2::simulation::Execution::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 
)
inline

Definition at line 63 of file execution.hpp.

Member Function Documentation

◆ add()

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):

  1. Temporality group 3 (Register read): Set the inputs and validate them. (RegisterValidationException might be thrown.)
  2. Temporality group 4 (Gas): Consume gas. (OutOfGasException might be thrown.)
  3. Temporality group 5 (Opcode execution): Execute the opcode. (OpcodeExecutionException might be thrown.)
  4. Temporality group 6 (Register write): Set the output.

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.

Parameters
contextThe context.
a_addrThe resolved address of the first input value.
b_addrThe resolved address of the second input value.
dst_addrThe resolved address of the output value.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the tags of both inputs do not match.

Definition at line 69 of file execution.cpp.

◆ and_op()

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.

Parameters
contextThe context.
a_addrThe resolved address of the first input value.
b_addrThe resolved address of the second input value.
dst_addrThe resolved address of the output memory value.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the bitwise AND operation fails:
  • the tags of both inputs do not match
  • both inputs are field elements

Definition at line 1005 of file execution.cpp.

◆ call()

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.

Parameters
contextThe context.
l2_gas_offsetThe resolved address of the allocated L2 gas value.
da_gas_offsetThe resolved address of the allocated DA gas value.
addrThe resolved address of the contract address.
cd_size_offsetThe resolved address of the calldata size value.
cd_offsetThe resolved address of the calldata offset value.
Exceptions
RegisterValidationExceptionif the tags of the input values do not match the expected tags:
  • l2_gas_offset memory value tag: U32
  • da_gas_offset memory value tag: U32
  • addr memory value tag: FF
  • cd_size_offset memory value tag: U32
OutOfGasExceptionif the gas limit is exceeded.

Definition at line 564 of file execution.cpp.

◆ call_with_operands()

template<typename... Ts>
void bb::avm2::simulation::Execution::call_with_operands ( void(Execution::*)(ContextInterface &, Ts...)  f,
ContextInterface context,
const std::vector< Operand > &  resolved_operands 
)
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.

Parameters
fThe function to call.
contextThe context.
resolved_operandsThe resolved operands.

Definition at line 2130 of file execution.cpp.

◆ cast()

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.

Parameters
contextThe context.
src_addrThe resolved address of the input value.
dst_addrThe resolved address of the output value.
dst_tagThe target memory tag to cast to.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.

Definition at line 417 of file execution.cpp.

◆ cd_copy()

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.

Parameters
contextThe context.
cd_size_offsetThe resolved address of the calldata size value.
cd_offsetThe resolved address of the calldata offset value.
dst_addrThe resolved address of the destination memory location.
Exceptions
RegisterValidationExceptionif the tags of the input values do not match the expected tags:
  • cd_size_offset memory value tag: U32
  • cd_offset memory value tag: U32
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the data copy operation fails:
  • a read or write memory access is out of bounds.

Definition at line 679 of file execution.cpp.

◆ debug_log()

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.

Parameters
contextThe context.
level_offsetThe resolved address of the log level value.
message_offsetThe resolved address of the log message value.
fields_offsetThe resolved address of the log fields value.
fields_size_offsetThe resolved address of the log fields size value.
message_sizeThe size of the log message.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.

Definition at line 952 of file execution.cpp.

◆ dispatch_opcode()

void bb::avm2::simulation::Execution::dispatch_opcode ( ExecutionOpCode  opcode,
ContextInterface context,
const std::vector< Operand > &  resolved_operands 
)
protected

Dispatch an opcode. This is the main function that dispatches the opcode to the appropriate handler.

Parameters
opcodeThe opcode to dispatch.
contextThe context.
resolved_operandsThe resolved operands.

Definition at line 1967 of file execution.cpp.

◆ div()

void bb::avm2::simulation::Execution::div ( ContextInterface context,
MemoryAddress  a_addr,
MemoryAddress  b_addr,
MemoryAddress  dst_addr 
)

DIV execution opcode handler: Divide two values.

Parameters
contextThe context.
a_addrThe resolved address of the first input value.
b_addrThe resolved address of the second input value (divisor).
dst_addrThe resolved address of the output value.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the division operation fails:
  • the tags of both inputs do not match
  • the divisor is zero
  • both inputs are field elements

Definition at line 165 of file execution.cpp.

◆ ecc_add()

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.

Parameters
contextThe context.
p_x_addrThe resolved address of the x coordinate of the first point.
p_y_addrThe resolved address of the y coordinate of the first point.
p_inf_addrThe resolved address of the infinity flag of the first point.
q_x_addrThe resolved address of the x coordinate of the second point.
q_y_addrThe resolved address of the y coordinate of the second point.
q_inf_addrThe resolved address of the infinity flag of the second point.
dst_addrThe resolved address of the destination memory address.
Exceptions
RegisterValidationExceptionif the tags of the input values do not match the expected tags:
  • tag of the memory value at p_x_addr is not FF.
  • tag of the memory value at p_y_addr is not FF.
  • tag of the memory value at p_inf_addr is not U1.
  • tag of the memory value at q_x_addr is not FF.
  • tag of the memory value at q_y_addr is not FF.
  • tag of the memory value at q_inf_addr is not U1.
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the elliptic curve addition operation fails:
  • memory write out of bounds.
  • one of the input points is not on the curve.

Definition at line 1475 of file execution.cpp.

◆ emit_note_hash()

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.

Parameters
contextThe context.
note_hash_addrThe resolved address of the note hash value.
Exceptions
RegisterValidationExceptionif the tags of the input values do not match the expected tags:
  • tag of the memory value at note_hash_addr is not FF.
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the note hash write operation fails:
  • the context is static.
  • the maximum number of note hashes has been reached.

Definition at line 1357 of file execution.cpp.

◆ emit_nullifier()

void bb::avm2::simulation::Execution::emit_nullifier ( ContextInterface context,
MemoryAddress  nullifier_addr 
)

EMITNULLIFIER execution opcode handler: Emit a nullifier to the nullifier tree.

Parameters
contextThe context.
nullifier_addrThe resolved address of the nullifier value.
Exceptions
RegisterValidationExceptionif the tags of the input values do not match the expected tags:
  • tag of the memory value at nullifier_addr is not FF.
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the nullifier write operation fails:
  • the context is static.
  • the maximum number of nullifiers has been reached.
  • the nullifier already exists (collision).

Definition at line 1272 of file execution.cpp.

◆ emit_unencrypted_log()

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.

Parameters
contextThe context.
log_size_offsetThe resolved address of the log size value.
log_offsetThe resolved address of the log field values.
Exceptions
RegisterValidationExceptionif the tags of the input values do not match the expected tags:
  • tag of the memory value at log_size_offset is not U32.
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the unencrypted log emission operation fails:
  • memory read out of bounds.
  • number of log fields exceeds the maximum allowed.
  • tags of the log memory values are not FF.
  • The current context is static.

Definition at line 1611 of file execution.cpp.

◆ eq()

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.

Parameters
contextThe context.
a_addrThe resolved address of the first input value.
b_addrThe resolved address of the second input value.
dst_addrThe resolved address of the output value.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the tags of both inputs do not match

Definition at line 230 of file execution.cpp.

◆ execute()

EnqueuedCallResult bb::avm2::simulation::Execution::execute ( std::unique_ptr< ContextInterface enqueued_call_context)
overridevirtual

Execute a top-level enqueued call.

Parameters
enqueued_call_contextThe unique pointer to a top-level enqueued call context. This context interface is a top-level enqueued call context.
Returns
EnqueuedCallResult: The result of the execution.

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.

◆ fdiv()

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.

Parameters
contextThe context.
a_addrThe resolved address of the first input value.
b_addrThe resolved address of the second input value (divisor).
dst_addrThe resolved address of the output value.
Exceptions
RegisterValidationExceptionif one of the input tag is not a field element
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the field division operation fails:
  • the tags of both inputs do not match
  • the divisor is zero

Definition at line 199 of file execution.cpp.

◆ get_contract_instance()

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.

Parameters
contextThe context.
address_offsetThe resolved address of the contract address value.
dst_offsetThe resolved address of the output (2 memory values: exists flag U1 and member value FF).
member_enumThe enum value of the member to get.
Exceptions
RegisterValidationExceptionif the tags of the input values do not match the expected tags:
  • tag of the memory value at address_offset is not FF.
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the contract instance retrieval operation fails:
  • memory write out of bounds.
  • invalid member enum.

Definition at line 1317 of file execution.cpp.

◆ get_env_var()

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.

Parameters
contextThe context.
dst_addrThe resolved address of the output value.
var_enumThe enum value of the environment variable to get.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the enum value is invalid.

Definition at line 441 of file execution.cpp.

◆ get_execution_result()

const ExecutionResult & bb::avm2::simulation::Execution::get_execution_result ( ) const
inlineprotected

Definition at line 218 of file execution.hpp.

◆ get_gas_tracker()

virtual GasTrackerInterface & bb::avm2::simulation::Execution::get_gas_tracker ( )
inlineprotectedvirtual

Definition at line 215 of file execution.hpp.

◆ get_inputs()

const std::vector< MemoryValue > & bb::avm2::simulation::Execution::get_inputs ( ) const
inlineprotected

Definition at line 236 of file execution.hpp.

◆ get_output()

const MemoryValue & bb::avm2::simulation::Execution::get_output ( ) const
inlineprotected

Definition at line 237 of file execution.hpp.

◆ handle_enter_call()

void bb::avm2::simulation::Execution::handle_enter_call ( ContextInterface parent_context,
std::unique_ptr< ContextInterface child_context 
)
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.

Parameters
parent_contextThe parent context.
child_contextThe child context.

Definition at line 1848 of file execution.cpp.

◆ handle_exceptional_halt()

void bb::avm2::simulation::Execution::handle_exceptional_halt ( ContextInterface context,
const std::string &  halting_message 
)
protected

Handle the exceptional halt of a context. This is called when an exception is thrown during the execution of a context.

Parameters
contextThe context.
halting_messageThe halting message.

Definition at line 1945 of file execution.cpp.

◆ handle_exit_call()

void bb::avm2::simulation::Execution::handle_exit_call ( )
protected

Handle the exiting of a call. This is called when a call returns or reverts.

Definition at line 1887 of file execution.cpp.

◆ internal_call()

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.

Parameters
contextThe context.
locThe target location to call the function at.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.

Definition at line 879 of file execution.cpp.

◆ internal_return()

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.

Parameters
contextThe context.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the internal call stack is empty.

Definition at line 899 of file execution.cpp.

◆ jump()

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.

Parameters
contextThe context.
locThe new program counter.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.

Definition at line 833 of file execution.cpp.

◆ jumpi()

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.

Parameters
contextThe context.
cond_addrThe resolved address of the condition value.
locThe new program counter.
Exceptions
RegisterValidationExceptionif the tags of the input values do not match the expected tags:
  • cond_addr memory value tag: U1
OutOfGasExceptionif the gas limit is exceeded.

Definition at line 853 of file execution.cpp.

◆ keccak_permutation()

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.

Parameters
contextThe context.
dst_addrThe resolved address of the destination memory location.
src_addrThe resolved address of the source memory location.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the Keccak permutation fails:
  • a read or write memory access is out of bounds.
  • a tag error is detected.

Definition at line 926 of file execution.cpp.

◆ l1_to_l2_message_exists()

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.

Parameters
contextThe context.
msg_hash_addrThe resolved address of the message hash value.
leaf_index_addrThe resolved address of the leaf index value.
dst_addrThe resolved address of the output memory value (boolean value U1).
Exceptions
RegisterValidationExceptionif the tags of the input values do not match the expected tags:
  • tag of the memory value at msg_hash_addr is not FF.
  • tag of the memory value at leaf_index_addr is not U64.
OutOfGasExceptionif the gas limit is exceeded.

Definition at line 1395 of file execution.cpp.

◆ lt()

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.

Parameters
contextThe context.
a_addrThe resolved address of the first input value. (left operand)
b_addrThe resolved address of the second input value (right operand).
dst_addrThe resolved address of the output value.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the tags of both inputs do not match

Definition at line 261 of file execution.cpp.

◆ lte()

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.

Parameters
contextThe context.
a_addrThe resolved address of the first input value. (left operand)
b_addrThe resolved address of the second input value (right operand).
dst_addrThe resolved address of the output value.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the tags of both inputs do not match

Definition at line 292 of file execution.cpp.

◆ mov()

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.

Parameters
contextThe context.
src_addrThe resolved address of the source memory value.
dst_addrThe resolved address of the output memory value.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.

Definition at line 529 of file execution.cpp.

◆ mul()

void bb::avm2::simulation::Execution::mul ( ContextInterface context,
MemoryAddress  a_addr,
MemoryAddress  b_addr,
MemoryAddress  dst_addr 
)

MUL execution opcode handler: Multiply two values.

Parameters
contextThe context.
a_addrThe resolved address of the first input value.
b_addrThe resolved address of the second input value.
dst_addrThe resolved address of the output value.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the tags of both inputs do not match.

Definition at line 131 of file execution.cpp.

◆ note_hash_exists()

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.

Parameters
contextThe context.
unique_note_hash_addrThe resolved address of the unique note hash value.
leaf_index_addrThe resolved address of the leaf index value.
dst_addrThe resolved address of the output memory value.
Exceptions
RegisterValidationExceptionif the tags of the input values do not match the expected tags:
  • tag of the memory value at unique_note_hash_addr is not FF.
  • tag of the memory value at leaf_index_addr is not U64.
OutOfGasExceptionif the gas limit is exceeded.

Definition at line 1188 of file execution.cpp.

◆ nullifier_exists()

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.

Parameters
contextThe context.
nullifier_offsetThe resolved address of the nullifier value.
address_offsetThe resolved address of the address value.
dst_addrThe resolved address of the output memory value (boolean value U1).
Exceptions
RegisterValidationExceptionif the tags of the input values do not match the expected tags:
  • tag of the memory value at nullifier_offset is not FF.
  • tag of the memory value at address_offset is not FF.
OutOfGasExceptionif the gas limit is exceeded.

Definition at line 1232 of file execution.cpp.

◆ op_not()

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.

Parameters
contextThe context.
src_addrThe resolved address of the input value.
dst_addrThe resolved address of the output value. (same tag as src_addr)
Exceptions
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the tag of the input value is FF (field element).

Definition at line 322 of file execution.cpp.

◆ or_op()

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.

Parameters
contextThe context.
a_addrThe resolved address of the first input value.
b_addrThe resolved address of the second input value.
dst_addrThe resolved address of the output memory value.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the bitwise OR operation fails:
  • the tags of both inputs do not match
  • both inputs are field elements

Definition at line 1042 of file execution.cpp.

◆ poseidon2_permutation()

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.

Parameters
contextThe context.
src_addrThe resolved address of the input value.
dst_addrThe resolved address of the output value.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the Poseidon2 permutation operation fails:
  • memory write out of bounds.
  • invalid input tags (not FF).

Definition at line 1439 of file execution.cpp.

◆ rd_copy()

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.

Parameters
contextThe context.
rd_size_offsetThe resolved address of the return data size value.
rd_offsetThe resolved address of the return data offset value.
dst_addrThe resolved address of the destination memory location.
Exceptions
RegisterValidationExceptionif the tags of the input values do not match the expected tags:
  • rd_size_offset memory value tag: U32
  • rd_offset memory value tag: U32
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the data copy operation fails:
  • a read or write memory access is out of bounds.

Definition at line 715 of file execution.cpp.

◆ rd_size()

void bb::avm2::simulation::Execution::rd_size ( ContextInterface context,
MemoryAddress  dst_addr 
)

RETURNDATASIZE execution opcode handler: Get the size of the return data.

Parameters
contextThe context.
dst_addrThe resolved address of the output memory value (return data size).
Exceptions
OutOfGasExceptionif the gas limit is exceeded.

Definition at line 744 of file execution.cpp.

◆ resolve_operands()

std::vector< Operand > bb::avm2::simulation::Execution::resolve_operands ( const Instruction instruction,
const ExecInstructionSpec spec 
)
protected

◆ ret()

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.

Parameters
contextThe context.
ret_size_offsetThe resolved address of the return data size value.
ret_offsetThe resolved address of the return data offset value.
Exceptions
RegisterValidationExceptionif the tags of the input values do not match the expected tags:
  • ret_size_offset memory value tag: U32
OutOfGasExceptionif the gas limit is exceeded.

Definition at line 771 of file execution.cpp.

◆ revert()

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.

Parameters
contextThe context.
rev_size_offsetThe resolved address of the revert data size value.
rev_offsetThe resolved address of the revert data offset value.
Exceptions
RegisterValidationExceptionif the tags of the input values do not match the expected tags:
  • rev_size_offset memory value tag: U32
OutOfGasExceptionif the gas limit is exceeded.

Definition at line 804 of file execution.cpp.

◆ send_l2_to_l1_msg()

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.

Parameters
contextThe context.
recipient_addrThe resolved address of the recipient value.
content_addrThe resolved address of the content value.
Exceptions
RegisterValidationExceptionif the tags of the input values do not match the expected tags:
  • tag of the memory value at recipient_addr is not FF.
  • tag of the memory value at content_addr is not FF.
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the L2 to L1 message send operation fails:
  • the maximum number of L2 to L1 messages has been reached.
  • the current context is static.

Definition at line 1647 of file execution.cpp.

◆ set()

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).

Parameters
contextThe context.
dst_addrThe resolved address of the output memory value.
dst_tagThe destination tag of the value to set. (as an uint8_t)
valueThe source value to set. (might get truncated)
Exceptions
OutOfGasExceptionif the gas limit is exceeded.

Definition at line 509 of file execution.cpp.

◆ set_and_validate_inputs()

void bb::avm2::simulation::Execution::set_and_validate_inputs ( ExecutionOpCode  opcode,
const std::vector< MemoryValue > &  inputs 
)
protected

Set the register inputs and validate the tags. The tag information is taken from the instruction info database.

Parameters
opcodeThe opcode.
inputsThe inputs.

Definition at line 2148 of file execution.cpp.

◆ set_execution_result()

void bb::avm2::simulation::Execution::set_execution_result ( const ExecutionResult exec_result)
inlineprotected

Definition at line 217 of file execution.hpp.

◆ set_output()

void bb::avm2::simulation::Execution::set_output ( ExecutionOpCode  opcode,
const MemoryValue output 
)
protected

Set the output register.

Parameters
opcodeThe opcode.
outputThe output.

Definition at line 2171 of file execution.cpp.

◆ sha256_compression()

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.

Parameters
contextThe context.
output_addrThe resolved address of the output memory values.
state_addrThe resolved address of the state value.
input_addrThe resolved address of the input value.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the SHA256 compression operation fails:
  • memory read or write out of bounds (state, input, or output).
  • invalid state or input tags (not U32).

Definition at line 1688 of file execution.cpp.

◆ shl()

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.

Parameters
contextThe context.
a_addrThe resolved address of the first input value. (left operand)
b_addrThe resolved address of the second input value (right operand).
dst_addrThe resolved address of the output value.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the left shift operation fails:
  • the tags of both inputs do not match
  • both inputs are field elements

Definition at line 354 of file execution.cpp.

◆ shr()

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.

Parameters
contextThe context.
a_addrThe resolved address of the first input value. (left operand)
b_addrThe resolved address of the second input value (right operand).
dst_addrThe resolved address of the output value.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the right shift operation fails:
  • the tags of both inputs do not match
  • both inputs are field elements

Definition at line 387 of file execution.cpp.

◆ sload()

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.

Parameters
contextThe context.
slot_addrThe resolved address of the slot value.
dst_addrThe resolved address of the output memory value.
Exceptions
RegisterValidationExceptionif the tags of the input values do not match the expected tags:
  • the slot tag is not FF.
OutOfGasExceptionif the gas limit is exceeded.

Definition at line 1112 of file execution.cpp.

◆ sstore()

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.

Parameters
contextThe context.
src_addrThe resolved address of the source memory value.
slot_addrThe resolved address of the slot value.
Exceptions
RegisterValidationExceptionif the tags of the input values do not match the expected tags:
  • tag of the memory value at src_addr is not FF.
  • tag of the memory value at slot_addr is not FF.
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the storage write operation fails:
  • the context is static.
  • the maximum number of public data writes has been reached.

Definition at line 1145 of file execution.cpp.

◆ static_call()

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).

Parameters
contextThe context.
l2_gas_offsetThe resolved address of the allocated L2 gas value.
da_gas_offsetThe resolved address of the allocated DA gas value.
addrThe resolved address of the contract address.
cd_size_offsetThe resolved address of the calldata size value.
cd_offsetThe resolved address of the calldata offset value.
Exceptions
RegisterValidationExceptionif the tags of the input values do not match the expected tags:
  • l2_gas_offset memory value tag: U32
  • da_gas_offset memory value tag: U32
  • addr memory value tag: FF
  • cd_size_offset memory value tag: U32
OutOfGasExceptionif the gas limit is exceeded.

Definition at line 624 of file execution.cpp.

◆ sub()

void bb::avm2::simulation::Execution::sub ( ContextInterface context,
MemoryAddress  a_addr,
MemoryAddress  b_addr,
MemoryAddress  dst_addr 
)

SUB execution opcode handler: Subtract two values.

Parameters
contextThe context.
a_addrThe resolved address of the first input value.
b_addrThe resolved address of the second input value (subtrahend).
dst_addrThe resolved address of the output value.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the tags of both inputs do not match.

Definition at line 100 of file execution.cpp.

◆ success_copy()

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.

Parameters
contextThe context.
dst_addrThe resolved address of the destination memory location.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.

Definition at line 979 of file execution.cpp.

◆ to_radix_be()

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.

Parameters
contextThe context.
value_addrThe resolved address of the value value.
radix_addrThe resolved address of the radix value.
num_limbs_addrThe resolved address of the number of limbs value.
is_output_bits_addrThe resolved address of the output bits value.
dst_addrThe resolved address of the output memory values.
Exceptions
RegisterValidationExceptionif the tags of the input values do not match the expected tags:
  • tag of the memory value at value_addr is not FF.
  • tag of the memory value at radix_addr is not U32.
  • tag of the memory value at num_limbs_addr is not U32.
  • tag of the memory value at is_output_bits_addr is not U1.
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the radix-based conversion operation fails:
  • memory write out of bounds.
  • invalid radix value (not within the valid range [2, 256]).
  • invalid number of limbs value (if num_limbs is zero, but the value is not zero).
  • invalid output bits value. (if is_output_bits is true, but the radix is not 2).
  • truncation error. (if the value cannot be decomposed into the requested number of limbs).

Definition at line 1536 of file execution.cpp.

◆ xor_op()

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.

Parameters
contextThe context.
a_addrThe resolved address of the first input value.
b_addrThe resolved address of the second input value.
dst_addrThe resolved address of the output memory value.
Exceptions
OutOfGasExceptionif the gas limit is exceeded.
OpcodeExecutionExceptionif the bitwise XOR operation fails:
  • the tags of both inputs do not match
  • both inputs are field elements

Definition at line 1077 of file execution.cpp.

Member Data Documentation

◆ alu

AluInterface& bb::avm2::simulation::Execution::alu
protected

Definition at line 242 of file execution.hpp.

◆ bitwise

BitwiseInterface& bb::avm2::simulation::Execution::bitwise
protected

Definition at line 243 of file execution.hpp.

◆ call_stack_metadata_collector

CallStackMetadataCollectorInterface& bb::avm2::simulation::Execution::call_stack_metadata_collector
protected

Definition at line 260 of file execution.hpp.

◆ context_provider

ContextProviderInterface& bb::avm2::simulation::Execution::context_provider
protected

Definition at line 248 of file execution.hpp.

◆ ctx_stack_events

EventEmitterInterface<ContextStackEvent>& bb::avm2::simulation::Execution::ctx_stack_events
protected

Definition at line 259 of file execution.hpp.

◆ data_copy

DataCopyInterface& bb::avm2::simulation::Execution::data_copy
protected

Definition at line 250 of file execution.hpp.

◆ debug_log_component

DebugLoggerInterface& bb::avm2::simulation::Execution::debug_log_component
protected

Definition at line 255 of file execution.hpp.

◆ embedded_curve

EccInterface& bb::avm2::simulation::Execution::embedded_curve
protected

Definition at line 245 of file execution.hpp.

◆ emit_unencrypted_log_component

EmitUnencryptedLogInterface& bb::avm2::simulation::Execution::emit_unencrypted_log_component
protected

Definition at line 254 of file execution.hpp.

◆ events

EventEmitterInterface<ExecutionEvent>& bb::avm2::simulation::Execution::events
protected

Definition at line 258 of file execution.hpp.

◆ exec_result

ExecutionResult bb::avm2::simulation::Execution::exec_result
protected

Definition at line 262 of file execution.hpp.

◆ execution_components

ExecutionComponentsProviderInterface& bb::avm2::simulation::Execution::execution_components
protected

Definition at line 239 of file execution.hpp.

◆ execution_id_manager

ExecutionIdManagerInterface& bb::avm2::simulation::Execution::execution_id_manager
protected

Definition at line 249 of file execution.hpp.

◆ external_call_stack

std::stack<std::unique_ptr<ContextInterface> > bb::avm2::simulation::Execution::external_call_stack
protected

Definition at line 264 of file execution.hpp.

◆ gas_tracker

std::unique_ptr<GasTrackerInterface> bb::avm2::simulation::Execution::gas_tracker
protected

Definition at line 267 of file execution.hpp.

◆ get_contract_instance_component

GetContractInstanceInterface& bb::avm2::simulation::Execution::get_contract_instance_component
protected

Definition at line 253 of file execution.hpp.

◆ greater_than

GreaterThanInterface& bb::avm2::simulation::Execution::greater_than
protected

Definition at line 252 of file execution.hpp.

◆ inputs

std::vector<MemoryValue> bb::avm2::simulation::Execution::inputs
protected

Definition at line 265 of file execution.hpp.

◆ instruction_info_db

const InstructionInfoDBInterface& bb::avm2::simulation::Execution::instruction_info_db
protected

Definition at line 240 of file execution.hpp.

◆ keccakf1600

KeccakF1600Interface& bb::avm2::simulation::Execution::keccakf1600
protected

Definition at line 251 of file execution.hpp.

◆ merkle_db

HighLevelMerkleDBInterface& bb::avm2::simulation::Execution::merkle_db
protected

Definition at line 256 of file execution.hpp.

◆ output

MemoryValue bb::avm2::simulation::Execution::output
protected

Definition at line 266 of file execution.hpp.

◆ poseidon2

Poseidon2Interface& bb::avm2::simulation::Execution::poseidon2
protected

Definition at line 244 of file execution.hpp.

◆ sha256

Sha256Interface& bb::avm2::simulation::Execution::sha256
protected

Definition at line 247 of file execution.hpp.

◆ to_radix

ToRadixInterface& bb::avm2::simulation::Execution::to_radix
protected

Definition at line 246 of file execution.hpp.


The documentation for this class was generated from the following files: