Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::avm2::tracegen::BytecodeTraceBuilder Class Referencefinal

#include <bytecode_trace.hpp>

Public Member Functions

void process_hashing (const simulation::EventEmitterInterface< simulation::BytecodeHashingEvent >::Container &events, TraceContainer &trace)
 Process bytecode hashing events and populate the bc_hashing columns in the trace. Corresponds to bc_hashing.pil.
 
void process_retrieval (const simulation::EventEmitterInterface< simulation::BytecodeRetrievalEvent >::Container &events, TraceContainer &trace)
 Process bytecode retrieval events and populate the relevant columns in the trace. Corresponds to bc_retrieval.pil.
 
void process_decomposition (const simulation::EventEmitterInterface< simulation::BytecodeDecompositionEvent >::Container &events, TraceContainer &trace)
 Process bytecode decomposition events and populate the relevant columns in the trace. Corresponds to bc_decomposition.pil.
 
void process_instruction_fetching (const simulation::EventEmitterInterface< simulation::InstructionFetchingEvent >::Container &events, TraceContainer &trace)
 Process instruction fetching events and populate the relevant columns in the trace. Corresponds to instr_fetching.pil.
 

Static Public Attributes

static const InteractionDefinition interactions
 

Detailed Description

Definition at line 10 of file bytecode_trace.hpp.

Member Function Documentation

◆ process_decomposition()

void bb::avm2::tracegen::BytecodeTraceBuilder::process_decomposition ( const simulation::EventEmitterInterface< simulation::BytecodeDecompositionEvent >::Container &  events,
TraceContainer trace 
)

Process bytecode decomposition events and populate the relevant columns in the trace. Corresponds to bc_decomposition.pil.

This trace is non memory-aware and does not handle any errors. It populates the columns with bytecode values in a stream or 'sliding window' of DECOMPOSE_WINDOW_SIZE = MAX_INSTRUCTION_SIZE = 37 individual bytes, range checking each byte. It enforces the size of the bytecode by decrementing the bytes_remaining counter. The trace additionally constrains the bytecode as fields by packing in 31 byte segments. These fields are used by the hashing trace to enforce correctness of the bytecode id (= hashed public bytecode commitment).

Parameters
eventsThe container of bytecode decomposition events to process.
traceThe trace container.

Definition at line 40 of file bytecode_trace.cpp.

◆ process_hashing()

void bb::avm2::tracegen::BytecodeTraceBuilder::process_hashing ( const simulation::EventEmitterInterface< simulation::BytecodeHashingEvent >::Container &  events,
TraceContainer trace 
)

Process bytecode hashing events and populate the bc_hashing columns in the trace. Corresponds to bc_hashing.pil.

For each bytecode, this function prepends a domain-separated length field to the bytecode field elements, then lays out Poseidon2 hashing rounds (3 inputs per round). Padding fields are added when the total field count is not a multiple of 3. The output hash equals the bytecode_id and is propagated to every row of the hashing sub-trace.

Parameters
eventsThe container of bytecode hashing events to process.
traceThe trace container.

Definition at line 186 of file bytecode_trace.cpp.

◆ process_instruction_fetching()

void bb::avm2::tracegen::BytecodeTraceBuilder::process_instruction_fetching ( const simulation::EventEmitterInterface< simulation::InstructionFetchingEvent >::Container &  events,
TraceContainer trace 
)

Process instruction fetching events and populate the relevant columns in the trace. Corresponds to instr_fetching.pil.

Uses a single row per event. Note that events are already deduplicated by simulation (see See InstructionFetchingEvent and DeduplicatingEventEmitter used in simulate_for_witgen), so no further deduplication is performed here.

This function does not perform any error detection itself; all error classification has already been done in simulation so we simply read directly from the event's error field. The four possible errors are:

  • PC_OUT_OF_RANGE
  • OPCODE_OUT_OF_RANGE
  • INSTRUCTION_OUT_OF_RANGE
  • TAG_OUT_OF_RANGE See simulation ([pure_]bytecode_manager.cpp) and instr_fetching.pil for error documentation.
Parameters
eventsThe container of instruction fetching events to process.
traceThe trace container.

Definition at line 336 of file bytecode_trace.cpp.

◆ process_retrieval()

void bb::avm2::tracegen::BytecodeTraceBuilder::process_retrieval ( const simulation::EventEmitterInterface< simulation::BytecodeRetrievalEvent >::Container &  events,
TraceContainer trace 
)

Process bytecode retrieval events and populate the relevant columns in the trace. Corresponds to bc_retrieval.pil.

This trace is non memory-aware and uses a single row per retrieval event to prove success or failure of bytecode retrieval. It largely delegates checks to other traces via lookups (see bc_retrieval.pil). It handles two possible errors:

  • INSTANCE_NOT_FOUND: the contract at the given address is not deployed.
  • TOO_MANY_BYTECODES: we have reached the limit of the number of bytecodes to retrieve for this tx.
Parameters
eventsThe container of bytecode retrieval events to process.
traceThe trace container.

Definition at line 253 of file bytecode_trace.cpp.

Member Data Documentation

◆ interactions

const InteractionDefinition bb::avm2::tracegen::BytecodeTraceBuilder::interactions
static
Initial value:
=
InteractionDefinition()
perm_bc_hashing_get_packed_field_2_settings>(C::bc_decomposition_sel_packed)
.add<InteractionType::LookupSequential, lookup_bc_retrieval_contract_instance_retrieval_settings>()
.add<InteractionType::LookupSequential, lookup_bc_retrieval_is_new_class_check_settings>()
.add<InteractionType::LookupIntoIndexedByRow, lookup_bc_decomposition_bytes_are_bytes_settings>()
.add<InteractionType::LookupIntoIndexedByRow, lookup_instr_fetching_instr_abs_diff_positive_settings>()
.add<InteractionType::LookupGeneric, lookup_instr_fetching_bytecode_size_from_bc_dec_settings>()
.add<InteractionType::LookupIntoIndexedByRow, lookup_instr_fetching_wire_instruction_info_settings>()
permutation_settings< perm_bc_hashing_bytecode_length_bytes_settings_ > perm_bc_hashing_bytecode_length_bytes_settings
lookup_settings< lookup_bc_retrieval_retrieved_bytecodes_insertion_settings_ > lookup_bc_retrieval_retrieved_bytecodes_insertion_settings
lookup_settings< lookup_bc_hashing_poseidon2_hash_settings_ > lookup_bc_hashing_poseidon2_hash_settings
lookup_settings< lookup_instr_fetching_bytes_from_bc_dec_settings_ > lookup_instr_fetching_bytes_from_bc_dec_settings
permutation_settings< perm_bc_hashing_get_packed_field_2_settings_ > perm_bc_hashing_get_packed_field_2_settings
permutation_settings< perm_bc_hashing_get_packed_field_1_settings_ > perm_bc_hashing_get_packed_field_1_settings
permutation_settings< perm_bc_hashing_get_packed_field_0_settings_ > perm_bc_hashing_get_packed_field_0_settings
lookup_settings< lookup_instr_fetching_pc_abs_diff_positive_settings_ > lookup_instr_fetching_pc_abs_diff_positive_settings
lookup_settings< lookup_instr_fetching_tag_value_validation_settings_ > lookup_instr_fetching_tag_value_validation_settings
lookup_settings< lookup_bc_retrieval_class_id_derivation_settings_ > lookup_bc_retrieval_class_id_derivation_settings

Definition at line 27 of file bytecode_trace.hpp.


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