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

#include <hybrid_execution.hpp>

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

Public Member Functions

EnqueuedCallResult execute (std::unique_ptr< ContextInterface > enqueued_call_context) override
 Execute a top-level enqueued call.
 
 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)
 
- Public Member Functions inherited from 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)
 
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
 

Private Member Functions

std::vector< FFextract_return_data (ContextInterface &context)
 

Additional Inherited Members

- Protected Member Functions inherited from bb::avm2::simulation::Execution
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 inherited from bb::avm2::simulation::Execution
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 11 of file hybrid_execution.hpp.

Member Function Documentation

◆ execute()

EnqueuedCallResult bb::avm2::simulation::HybridExecution::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.

Reimplemented from bb::avm2::simulation::Execution.

Definition at line 18 of file hybrid_execution.cpp.

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

◆ extract_return_data()

std::vector< FF > bb::avm2::simulation::HybridExecution::extract_return_data ( ContextInterface context)
private

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