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

#include <get_contract_instance.hpp>

Inheritance diagram for bb::avm2::simulation::GetContractInstance:
bb::avm2::simulation::GetContractInstanceInterface

Public Member Functions

 GetContractInstance (ExecutionIdManagerInterface &execution_id_manager, HighLevelMerkleDBInterface &merkle_db, EventEmitterInterface< GetContractInstanceEvent > &event_emitter, ContractInstanceManagerInterface &instance_manager)
 Construct a GetContractInstance gadget with its dependencies.
 
void get_contract_instance (MemoryInterface &memory, const AztecAddress &contract_address, MemoryAddress dst_offset, uint8_t member_enum) override
 Retrieve a contract instance member and write the result to memory.
 
- Public Member Functions inherited from bb::avm2::simulation::GetContractInstanceInterface
virtual ~GetContractInstanceInterface ()=default
 

Static Private Member Functions

static void write_results (MemoryInterface &memory, MemoryAddress dst_offset, bool exists, const FF &member_value)
 Write the contract instance existence flag and member value to memory.
 
static FF select_instance_member (const ContractInstance &instance, uint8_t member_enum)
 Select a contract instance member by enum value.
 

Private Attributes

ExecutionIdManagerInterfaceexecution_id_manager
 
HighLevelMerkleDBInterfacemerkle_db
 
EventEmitterInterface< GetContractInstanceEvent > & event_emitter
 
ContractInstanceManagerInterfaceinstance_manager
 

Detailed Description

Definition at line 17 of file get_contract_instance.hpp.

Constructor & Destructor Documentation

◆ GetContractInstance()

bb::avm2::simulation::GetContractInstance::GetContractInstance ( ExecutionIdManagerInterface execution_id_manager,
HighLevelMerkleDBInterface merkle_db,
EventEmitterInterface< GetContractInstanceEvent > &  event_emitter,
ContractInstanceManagerInterface instance_manager 
)

Construct a GetContractInstance gadget with its dependencies.

Parameters
execution_id_managerProvides monotonic execution clock values for event ordering.
merkle_dbHigh-level Merkle database for reading tree state (roots).
event_emitterEmitter for GetContractInstanceEvent used by tracegen.
instance_managerManager that retrieves (and caches) contract instances from the world state.

Definition at line 22 of file get_contract_instance.cpp.

Member Function Documentation

◆ get_contract_instance()

void bb::avm2::simulation::GetContractInstance::get_contract_instance ( MemoryInterface memory,
const AztecAddress contract_address,
MemoryAddress  dst_offset,
uint8_t  member_enum 
)
overridevirtual

Retrieve a contract instance member and write the result to memory.

Validates that dst_offset+1 is in bounds and that member_enum is valid, then retrieves the contract instance via the ContractInstanceManager. Writes the existence flag (U1) to dst_offset and the selected member value (FF) to dst_offset+1.

Parameters
memoryThe memory interface for the current context.
contract_addressThe address of the contract to look up.
dst_offsetThe memory offset at which to write the exists flag.
member_enumThe enum selecting which instance member to retrieve (deployer/class_id/init_hash).
Exceptions
GetContractInstanceExceptionIf dst_offset+1 is out of bounds (checked first).
GetContractInstanceExceptionIf member_enum is invalid (checked after bounds check).

Implements bb::avm2::simulation::GetContractInstanceInterface.

Definition at line 46 of file get_contract_instance.cpp.

◆ select_instance_member()

FF bb::avm2::simulation::GetContractInstance::select_instance_member ( const ContractInstance instance,
uint8_t  member_enum 
)
staticprivate

Select a contract instance member by enum value.

Parameters
instanceThe contract instance to select from.
member_enumThe enum value identifying which member to return.
Returns
The field value of the selected member.
Exceptions
std::runtime_errorIf member_enum is not a valid ContractInstanceMember (should be unreachable).

Definition at line 133 of file get_contract_instance.cpp.

◆ write_results()

void bb::avm2::simulation::GetContractInstance::write_results ( MemoryInterface memory,
MemoryAddress  dst_offset,
bool  exists,
const FF member_value 
)
staticprivate

Write the contract instance existence flag and member value to memory.

Parameters
memoryThe memory interface for the current context.
dst_offsetThe memory offset at which to write the exists flag (U1).
existsWhether the contract instance was found.
member_valueThe selected member value to write at dst_offset+1 (FF).

Definition at line 114 of file get_contract_instance.cpp.

Member Data Documentation

◆ event_emitter

EventEmitterInterface<GetContractInstanceEvent>& bb::avm2::simulation::GetContractInstance::event_emitter
private

Definition at line 32 of file get_contract_instance.hpp.

◆ execution_id_manager

ExecutionIdManagerInterface& bb::avm2::simulation::GetContractInstance::execution_id_manager
private

Definition at line 30 of file get_contract_instance.hpp.

◆ instance_manager

ContractInstanceManagerInterface& bb::avm2::simulation::GetContractInstance::instance_manager
private

Definition at line 33 of file get_contract_instance.hpp.

◆ merkle_db

HighLevelMerkleDBInterface& bb::avm2::simulation::GetContractInstance::merkle_db
private

Definition at line 31 of file get_contract_instance.hpp.


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