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

#include <execution_trace.hpp>

Public Member Functions

void process (const simulation::EventEmitterInterface< simulation::ExecutionEvent >::Container &ex_events, TraceContainer &trace)
 Process the execution events and populate the relevant columns in the trace. ExecutionError enum is used to track the error type of the event. Each error type is mutually exclusive and pertains to a specific temporality group. Each temporality group is processed sequentially and an error prevents the processing of the subsequent temporality groups.
 
void process_instr_fetching (const simulation::Instruction &instruction, TraceContainer &trace, uint32_t row)
 Process instruction fetching in execution and populate the relevant columns in the trace.
 
void process_execution_spec (const simulation::ExecutionEvent &ex_event, TraceContainer &trace, uint32_t row)
 Process the execution specification lookup columns (gas costs, register info, subtrace dispatch).
 
void process_gas (const simulation::GasEvent &gas_event, ExecutionOpCode exec_opcode, TraceContainer &trace, uint32_t row)
 Process gas consumption and populate gas-related columns (OOG flags, addressing gas, dynamic gas).
 
void process_addressing (const simulation::AddressingEvent &addr_event, const simulation::Instruction &instruction, TraceContainer &trace, uint32_t row)
 Process addressing resolution and populate operand columns (relative, indirect, resolved values, error flags).
 
void invert_columns (TraceContainer &trace)
 Batch-invert all columns that were populated with pre-inversion values during trace generation.
 
void process_registers (ExecutionOpCode exec_opcode, const std::vector< MemoryValue > &inputs, const MemoryValue &output, std::span< MemoryValue > registers, bool register_processing_failed, TraceContainer &trace, uint32_t row)
 Process register reads: populate register value/tag columns and detect tag check failures.
 
void process_registers_write (ExecutionOpCode exec_opcode, TraceContainer &trace, uint32_t row)
 Process register writes: activate the write selector and effective write columns for the opcode.
 
void process_get_env_var_opcode (simulation::Operand envvar_enum, MemoryValue output, TraceContainer &trace, uint32_t row)
 Process the GETENVVAR opcode: populate environment variable lookup and selector columns.
 

Static Public Attributes

static const InteractionDefinition interactions
 

Detailed Description

Definition at line 19 of file execution_trace.hpp.

Member Function Documentation

◆ invert_columns()

void bb::avm2::tracegen::ExecutionTraceBuilder::invert_columns ( TraceContainer trace)

Batch-invert all columns that were populated with pre-inversion values during trace generation.

Parameters
traceThe trace container whose columns are inverted in place.

Definition at line 1088 of file execution_trace.cpp.

◆ process()

void bb::avm2::tracegen::ExecutionTraceBuilder::process ( const simulation::EventEmitterInterface< simulation::ExecutionEvent >::Container &  ex_events,
TraceContainer trace 
)

Process the execution events and populate the relevant columns in the trace. ExecutionError enum is used to track the error type of the event. Each error type is mutually exclusive and pertains to a specific temporality group. Each temporality group is processed sequentially and an error prevents the processing of the subsequent temporality groups.

Events are emitted in the following flavors (keyed by ExecutionError enum value). The error field is populated in all failing variants; the bullets below describe which additional (non-error) fields are populated:

  1. ExecutionError::NONE — normal execution: all fields populated.
  2. ExecutionError::BYTECODE_RETRIEVAL — TG1 failure: only context fields populated.
  3. ExecutionError::INSTRUCTION_FETCHING — TG2 failure: context and bytecode fields populated.
  4. ExecutionError::ADDRESSING — TG2 failure: instruction fetched but operand resolution failed.
  5. ExecutionError::REGISTER_READ — TG3 failure: addressing succeeded but tag validation failed.
  6. ExecutionError::GAS — TG4 failure: registers read but gas check failed.
  7. ExecutionError::OPCODE_EXECUTION — TG5 failure: gas consumed but opcode logic failed, no register write.
Parameters
ex_eventsContainer of ExecutionEvent to process.
traceThe trace container to populate.

Definition at line 317 of file execution_trace.cpp.

◆ process_addressing()

void bb::avm2::tracegen::ExecutionTraceBuilder::process_addressing ( const simulation::AddressingEvent addr_event,
const simulation::Instruction instruction,
TraceContainer trace,
uint32_t  row 
)

Process addressing resolution and populate operand columns (relative, indirect, resolved values, error flags).

Parameters
addr_eventThe addressing event from simulation.
instructionThe fetched instruction (for addressing mode bits).
traceThe trace container to populate.
rowThe current row index.

Definition at line 935 of file execution_trace.cpp.

◆ process_execution_spec()

void bb::avm2::tracegen::ExecutionTraceBuilder::process_execution_spec ( const simulation::ExecutionEvent ex_event,
TraceContainer trace,
uint32_t  row 
)

Process the execution specification lookup columns (gas costs, register info, subtrace dispatch).

Parameters
ex_eventThe execution event.
traceThe trace container to populate.
rowThe current row index.

Definition at line 845 of file execution_trace.cpp.

◆ process_gas()

void bb::avm2::tracegen::ExecutionTraceBuilder::process_gas ( const simulation::GasEvent gas_event,
ExecutionOpCode  exec_opcode,
TraceContainer trace,
uint32_t  row 
)

Process gas consumption and populate gas-related columns (OOG flags, addressing gas, dynamic gas).

Parameters
gas_eventThe gas event from simulation.
exec_opcodeThe execution opcode.
traceThe trace container to populate.
rowThe current row index.

Definition at line 899 of file execution_trace.cpp.

◆ process_get_env_var_opcode()

void bb::avm2::tracegen::ExecutionTraceBuilder::process_get_env_var_opcode ( simulation::Operand  envvar_enum,
MemoryValue  output,
TraceContainer trace,
uint32_t  row 
)

Process the GETENVVAR opcode: populate environment variable lookup and selector columns.

Parameters
envvar_enumThe environment variable enum operand (must have tag U8).
outputThe output memory value produced by simulation.
traceThe trace container to populate.
rowThe current row index.

Definition at line 1216 of file execution_trace.cpp.

◆ process_instr_fetching()

void bb::avm2::tracegen::ExecutionTraceBuilder::process_instr_fetching ( const simulation::Instruction instruction,
TraceContainer trace,
uint32_t  row 
)

Process instruction fetching in execution and populate the relevant columns in the trace.

This function is only called when instruction fetching has succeeded (i.e. !bytecode_retrieval_failed && !error_in_instruction_fetching), so we can set execution_sel_instruction_fetching_success = 1. See fetching simulation ([pure_]bytecode_manager.cpp) and instr_fetching.pil for error documentation.

Parameters
instructionThe instruction to process.
traceThe trace container.
rowThe current row index.

Definition at line 816 of file execution_trace.cpp.

◆ process_registers()

void bb::avm2::tracegen::ExecutionTraceBuilder::process_registers ( ExecutionOpCode  exec_opcode,
const std::vector< MemoryValue > &  inputs,
const MemoryValue output,
std::span< MemoryValue registers,
bool  register_processing_failed,
TraceContainer trace,
uint32_t  row 
)

Process register reads: populate register value/tag columns and detect tag check failures.

Parameters
exec_opcodeThe execution opcode (determines register layout).
inputsThe input memory values from simulation.
outputThe output memory value from simulation.
registersOutput span filled with the register values for downstream use.
register_processing_failedWhether a tag check failed during register reading.
traceThe trace container to populate.
rowThe current row index.

Definition at line 1124 of file execution_trace.cpp.

◆ process_registers_write()

void bb::avm2::tracegen::ExecutionTraceBuilder::process_registers_write ( ExecutionOpCode  exec_opcode,
TraceContainer trace,
uint32_t  row 
)

Process register writes: activate the write selector and effective write columns for the opcode.

Parameters
exec_opcodeThe execution opcode (determines which registers are written).
traceThe trace container to populate.
rowThe current row index.

Definition at line 1194 of file execution_trace.cpp.

Member Data Documentation

◆ interactions

const InteractionDefinition bb::avm2::tracegen::ExecutionTraceBuilder::interactions
static

Definition at line 51 of file execution_trace.hpp.


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