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

#include <precomputed_trace.hpp>

Public Member Functions

void process_misc (TraceContainer &trace, const uint32_t num_rows=PRECOMPUTED_TRACE_SIZE)
 Populate miscellaneous precomputed columns: first_row selector and idx (row index).
 
void process_bitwise (TraceContainer &trace)
 Populate the 8-bit bitwise lookup table (AND, OR, XOR).
 
void process_sel_range_8 (TraceContainer &trace)
 Generate a selector column that activates the first 2^8 (256) rows.
 
void process_sel_range_16 (TraceContainer &trace)
 Generate a selector column that activates the first 2^16 (65536) rows.
 
void process_power_of_2 (TraceContainer &trace)
 Generate a column where row i holds 2^i, for i in [0, 255], for the values of 254 and 255 the values are modulo reduced by the field modulus (i.e. 2^254 and 2^255 mod p) since the trace operates over a finite field.
 
void process_sha256_round_constants (TraceContainer &trace)
 Populate the 64 SHA-256 round constants (K_0 .. K_63) and their selector. The sel_sha256_compression selector is set high on these rows.
 
void process_tag_parameters (TraceContainer &trace)
 Populate the memory tag parameters table (byte length, max bits, max value per tag).
 
void process_wire_instruction_spec (TraceContainer &trace)
 Populate the wire-level instruction specification table.
 
void process_exec_instruction_spec (TraceContainer &trace)
 Populate the execution-level instruction specification table.
 
void process_to_radix_safe_limbs (TraceContainer &trace)
 Populate the TORADIXBE safe-limbs table (one row per radix 0..255).
 
void process_to_radix_p_decompositions (TraceContainer &trace)
 Populate the TORADIXBE p-decomposition table.
 
void process_memory_tag_range (TraceContainer &trace)
 Populate the memory tag out-of-range selector.
 
void process_addressing_gas (TraceContainer &trace)
 Populate the addressing-mode gas lookup table (65536 rows).
 
void process_phase_table (TraceContainer &trace)
 Populate the transaction phase specification table.
 
void process_keccak_round_constants (TraceContainer &trace)
 Populate the 24 Keccak-f[1600] round constants and their selector. Row 0 is intentionally left empty (round constants are 1-indexed in the Keccak subtrace).
 
void process_get_env_var_table (TraceContainer &trace)
 Populate the GETENVVAR lookup table.
 
void process_get_contract_instance_table (TraceContainer &trace)
 Populate the GETCONTRACTINSTANCE lookup table.
 

Detailed Description

Definition at line 13 of file precomputed_trace.hpp.

Member Function Documentation

◆ process_addressing_gas()

void bb::avm2::tracegen::PrecomputedTraceBuilder::process_addressing_gas ( TraceContainer trace)

Populate the addressing-mode gas lookup table (65536 rows).

For every possible 16-bit addressing mode bitfield, precomputes the L2 gas cost of address resolution (indirect dereferences + relative offsets).

Definition at line 368 of file precomputed_trace.cpp.

◆ process_bitwise()

void bb::avm2::tracegen::PrecomputedTraceBuilder::process_bitwise ( TraceContainer trace)

Populate the 8-bit bitwise lookup table (AND, OR, XOR).

Generates 256×256 = 65536 rows covering all pairs of 8-bit inputs (a, b). Row index is derived as (a << 8) | b.

Definition at line 50 of file precomputed_trace.cpp.

◆ process_exec_instruction_spec()

void bb::avm2::tracegen::PrecomputedTraceBuilder::process_exec_instruction_spec ( TraceContainer trace)

Populate the execution-level instruction specification table.

One row per ExecutionOpCode (0..45). Each row holds gas costs (opcode L2, base DA, dynamic L2, dynamic DA), register info (mem_op, rw, tag_check, expected_tag for each of 6 registers), operand-is-address flags, and subtrace dispatch info (subtrace_id, subtrace_operation_id, dyn_gas_id). Used by the execution and gas subtraces.

Definition at line 232 of file precomputed_trace.cpp.

◆ process_get_contract_instance_table()

void bb::avm2::tracegen::PrecomputedTraceBuilder::process_get_contract_instance_table ( TraceContainer trace)

Populate the GETCONTRACTINSTANCE lookup table.

One row per ContractInstanceMember enum value (DEPLOYER=0, CLASS_ID=1, INIT_HASH=2). Each row holds a validity flag and one-hot member selectors. See opcodes/get_contract_instance.pil for an ascii version of this table.

Definition at line 473 of file precomputed_trace.cpp.

◆ process_get_env_var_table()

void bb::avm2::tracegen::PrecomputedTraceBuilder::process_get_env_var_table ( TraceContainer trace)

Populate the GETENVVAR lookup table.

One row per EnvironmentVariable enum value (0..11). Each row maps the variable to its public-input column/row indices, type selectors (is_address, is_sender, etc.), and output tag. Rows beyond the valid enum range are flagged with invalid_envvar_enum = 1. See opcodes/get_env_var.pil for an ascii version of this table.

Definition at line 437 of file precomputed_trace.cpp.

◆ process_keccak_round_constants()

void bb::avm2::tracegen::PrecomputedTraceBuilder::process_keccak_round_constants ( TraceContainer trace)

Populate the 24 Keccak-f[1600] round constants and their selector. Row 0 is intentionally left empty (round constants are 1-indexed in the Keccak subtrace).

Definition at line 417 of file precomputed_trace.cpp.

◆ process_memory_tag_range()

void bb::avm2::tracegen::PrecomputedTraceBuilder::process_memory_tag_range ( TraceContainer trace)

Populate the memory tag out-of-range selector.

Flags rows where idx > MemoryTag::MAX (i.e., idx ∈ [7, 255]) with sel_mem_tag_out_of_range = 1. Used to detect invalid memory tags via lookup.

Definition at line 354 of file precomputed_trace.cpp.

◆ process_misc()

void bb::avm2::tracegen::PrecomputedTraceBuilder::process_misc ( TraceContainer trace,
const uint32_t  num_rows = PRECOMPUTED_TRACE_SIZE 
)

Populate miscellaneous precomputed columns: first_row selector and idx (row index).

precomputed_first_row is 1 only at row 0. precomputed_idx holds the row index (0..num_rows-1) and is used as the key for most precomputed lookups. precomputed_zero is intentionally left unset (the trace container defaults to 0).

Definition at line 30 of file precomputed_trace.cpp.

◆ process_phase_table()

void bb::avm2::tracegen::PrecomputedTraceBuilder::process_phase_table ( TraceContainer trace)

Populate the transaction phase specification table.

One row per TransactionPhase (0..11). Each row holds boolean flags (is_public_call_request, is_teardown, is_revertible, etc.), public-input read offsets, side-effect append selectors, and the next_phase_on_revert value. Used by the tx subtrace via the #[READ_PHASE_SPEC] lookup.

Definition at line 387 of file precomputed_trace.cpp.

◆ process_power_of_2()

void bb::avm2::tracegen::PrecomputedTraceBuilder::process_power_of_2 ( TraceContainer trace)

Generate a column where row i holds 2^i, for i in [0, 255], for the values of 254 and 255 the values are modulo reduced by the field modulus (i.e. 2^254 and 2^255 mod p) since the trace operates over a finite field.

Definition at line 114 of file precomputed_trace.cpp.

◆ process_sel_range_16()

void bb::avm2::tracegen::PrecomputedTraceBuilder::process_sel_range_16 ( TraceContainer trace)

Generate a selector column that activates the first 2^16 (65536) rows.

Enables 16-bit range checks: a value X is in [0, 65535] iff sel_range_16 is 1 at the row where idx == X.

Definition at line 99 of file precomputed_trace.cpp.

◆ process_sel_range_8()

void bb::avm2::tracegen::PrecomputedTraceBuilder::process_sel_range_8 ( TraceContainer trace)

Generate a selector column that activates the first 2^8 (256) rows.

Enables 8-bit range checks: a value X is in [0, 255] iff sel_range_8 is 1 at the row where idx == X.

Definition at line 83 of file precomputed_trace.cpp.

◆ process_sha256_round_constants()

void bb::avm2::tracegen::PrecomputedTraceBuilder::process_sha256_round_constants ( TraceContainer trace)

Populate the 64 SHA-256 round constants (K_0 .. K_63) and their selector. The sel_sha256_compression selector is set high on these rows.

Definition at line 128 of file precomputed_trace.cpp.

◆ process_tag_parameters()

void bb::avm2::tracegen::PrecomputedTraceBuilder::process_tag_parameters ( TraceContainer trace)

Populate the memory tag parameters table (byte length, max bits, max value per tag).

One row per MemoryTag variant (FF=0, U1=1, U8=2, ..., U128=6).

Definition at line 154 of file precomputed_trace.cpp.

◆ process_to_radix_p_decompositions()

void bb::avm2::tracegen::PrecomputedTraceBuilder::process_to_radix_p_decompositions ( TraceContainer trace)

Populate the TORADIXBE p-decomposition table.

Stores the limb-by-limb decomposition of the BN254 field modulus p in every radix r ∈ [2, 255]. Rows are laid out sequentially: all limbs for radix 2, then radix 3, etc. Each row records (radix, limb_index, limb_value). Used to verify that TORADIXBE output does not exceed p.

Definition at line 332 of file precomputed_trace.cpp.

◆ process_to_radix_safe_limbs()

void bb::avm2::tracegen::PrecomputedTraceBuilder::process_to_radix_safe_limbs ( TraceContainer trace)

Populate the TORADIXBE safe-limbs table (one row per radix 0..255).

For each radix r, stores the number of limbs needed to represent the BN254 scalar field modulus p in base r, and the "safe limbs" count (num_limbs - 1). Radices 0 and 1 have no valid decomposition and default to 0.

Definition at line 307 of file precomputed_trace.cpp.

◆ process_wire_instruction_spec()

void bb::avm2::tracegen::PrecomputedTraceBuilder::process_wire_instruction_spec ( TraceContainer trace)

Populate the wire-level instruction specification table.

One row per WireOpCode (0..67). Each row holds the operand decomposition selectors (sel_op_dc_0..16), the corresponding ExecutionOpCode, instruction size in bytes, and tag operand metadata. Rows beyond the last valid opcode are flagged with opcode_out_of_range. Used by the instruction-fetch subtrace to decode bytecode.

Definition at line 178 of file precomputed_trace.cpp.


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