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

#include <data_copy.hpp>

Inheritance diagram for bb::avm2::simulation::DataCopy:
bb::avm2::simulation::DataCopyInterface

Public Member Functions

 DataCopy (ExecutionIdGetterInterface &execution_id_manager, GreaterThanInterface &gt, EventEmitterInterface< DataCopyEvent > &event_emitter)
 
void cd_copy (ContextInterface &context, const uint32_t cd_copy_size, const uint32_t cd_offset, const MemoryAddress dst_addr) override
 Writes calldata into dst_addr. There is slight difference in how enqueued and nested contexts, this is mostly encapsulated in context.get_calldata()
 
void rd_copy (ContextInterface &context, const uint32_t rd_copy_size, const uint32_t rd_offset, const MemoryAddress dst_addr) override
 Copies returndata from the last executed context to the dst_addr.
 
- Public Member Functions inherited from bb::avm2::simulation::DataCopyInterface
virtual ~DataCopyInterface ()=default
 

Private Member Functions

uint64_t min (uint64_t a, uint64_t b)
 

Private Attributes

ExecutionIdGetterInterfaceexecution_id_manager
 
GreaterThanInterfacegt
 
EventEmitterInterface< DataCopyEvent > & events
 

Detailed Description

Definition at line 25 of file data_copy.hpp.

Constructor & Destructor Documentation

◆ DataCopy()

bb::avm2::simulation::DataCopy::DataCopy ( ExecutionIdGetterInterface execution_id_manager,
GreaterThanInterface gt,
EventEmitterInterface< DataCopyEvent > &  event_emitter 
)
inline

Definition at line 27 of file data_copy.hpp.

Member Function Documentation

◆ cd_copy()

void bb::avm2::simulation::DataCopy::cd_copy ( ContextInterface context,
const uint32_t  copy_size,
const uint32_t  offset,
const MemoryAddress  dst_addr 
)
overridevirtual

Writes calldata into dst_addr. There is slight difference in how enqueued and nested contexts, this is mostly encapsulated in context.get_calldata()

Notes on DataCopy: The simulation for DataCopy has a lot of subtle complexity due to the requirements of the circuit constraints. The main complexity comes from the need to have the following 32-bit range checks (1) Computing the max_read_index via min, which is used to determine the final index in the cd/rd to read up to. (2) In error handling to check that reads and writes are within bounds of the memory. (3) In computing the actual number of elements from calldata/returndata to read (i.e. from [offset, max_read_index])

Parameters
cd_copy_sizeThe size of calldata to copy, must be a u32.
cd_offsetThe offset in calldata to start copying from, must be a u32.
dst_addrThe address in memory to write the calldata to.
Exceptions
DataCopyExceptionif the calldata size or offset are not u32, or if the memory access is out of bounds.

Implements bb::avm2::simulation::DataCopyInterface.

Definition at line 87 of file data_copy.cpp.

◆ min()

uint64_t bb::avm2::simulation::DataCopy::min ( uint64_t  a,
uint64_t  b 
)
private

Definition at line 60 of file data_copy.cpp.

◆ rd_copy()

void bb::avm2::simulation::DataCopy::rd_copy ( ContextInterface context,
const uint32_t  copy_size,
const uint32_t  offset,
const MemoryAddress  dst_addr 
)
overridevirtual

Copies returndata from the last executed context to the dst_addr.

Parameters
rd_copy_sizeThe size of returndata to copy, must be a u32.
rd_offsetThe offset in returndata to start copying from, must be a u32.
dst_addrThe address in memory to write the returndata to.
Exceptions
DataCopyExceptionif the returndata size or offset are not u32, or if the memory access is out of bounds.

Implements bb::avm2::simulation::DataCopyInterface.

Definition at line 145 of file data_copy.cpp.

Member Data Documentation

◆ events

EventEmitterInterface<DataCopyEvent>& bb::avm2::simulation::DataCopy::events
private

Definition at line 49 of file data_copy.hpp.

◆ execution_id_manager

ExecutionIdGetterInterface& bb::avm2::simulation::DataCopy::execution_id_manager
private

Definition at line 47 of file data_copy.hpp.

◆ gt

GreaterThanInterface& bb::avm2::simulation::DataCopy::gt
private

Definition at line 48 of file data_copy.hpp.


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