1#include <gmock/gmock.h>
2#include <gtest/gtest.h>
36using tracegen::BytecodeTraceBuilder;
37using tracegen::PrecomputedTraceBuilder;
38using tracegen::RangeCheckTraceBuilder;
39using tracegen::TestTraceContainer;
44using instr_fetching = instr_fetching<FF>;
46using simulation::BytecodeDecompositionEvent;
48using simulation::Instruction;
49using simulation::InstructionFetchingEvent;
51using simulation::RangeCheckEvent;
53TEST(InstrFetchingConstrainingTest, EmptyRow)
59TEST(InstrFetchingConstrainingTest, Add8WithTraceGen)
61 TestTraceContainer
trace;
68 .operands = { Operand::from<uint8_t>(0x34), Operand::from<uint8_t>(0x35), Operand::from<uint8_t>(0x36) },
71 std::vector<uint8_t>
bytecode = add_8_instruction.serialize();
73 builder.process_instruction_fetching({ { .bytecode_id = 1,
75 .instruction = add_8_instruction,
81 check_relation<instr_fetching>(trace);
86TEST(InstrFetchingConstrainingTest, EcaddWithTraceGen)
88 TestTraceContainer
trace;
94 .addressing_mode = 0x1f1f,
95 .operands = { Operand::from<uint16_t>(0x1279),
96 Operand::from<uint16_t>(0x127a),
97 Operand::from<uint16_t>(0x127b),
98 Operand::from<uint16_t>(0x127c),
99 Operand::from<uint16_t>(0x127d), },
102 std::vector<uint8_t>
bytecode = ecadd_instruction.serialize();
103 builder.process_instruction_fetching({ { .bytecode_id = 1,
105 .instruction = ecadd_instruction,
111 check_relation<instr_fetching>(trace);
121 instructions.reserve(num_opcodes);
124 for (
size_t i = 0; i < num_opcodes; i++) {
125 pc_positions.at(i) =
static_cast<uint32_t
>(
bytecode.size());
127 instructions.emplace_back(instr);
128 const auto instruction_bytes = instr.serialize();
138 instr_events.reserve(num_opcodes);
139 for (
size_t i = 0; i < num_opcodes; i++) {
140 instr_events.emplace_back(InstructionFetchingEvent{
141 .bytecode_id = 1, .pc = pc_positions.at(i), .instruction = instructions.at(i), .bytecode = bytecode_ptr });
148TEST(InstrFetchingConstrainingTest, EachOpcodeWithTraceGen)
150 TestTraceContainer
trace;
154 builder.process_instruction_fetching(gen_instr_events_each_opcode(), trace);
159 check_relation<instr_fetching>(trace);
165TEST(InstrFetchingConstrainingTest, NegativeWrongOperand)
171 std::vector<size_t> sub_relations = {
183 C::instr_fetching_addressing_mode,
184 C::instr_fetching_op1,
185 C::instr_fetching_op2,
186 C::instr_fetching_op3,
187 C::instr_fetching_op4,
188 C::instr_fetching_op5,
189 C::instr_fetching_op6,
190 C::instr_fetching_op7,
193 for (
const auto& opcode : opcodes) {
194 TestTraceContainer
trace;
196 builder.process_instruction_fetching(
197 { { .bytecode_id = 1,
199 .instruction = instr,
204 check_relation<instr_fetching>(trace);
208 for (
size_t i = 0; i < operand_cols.size(); i++) {
209 auto mutated_trace =
trace;
210 const FF mutated_operand =
trace.
get(operand_cols.at(i), 0) + 1;
211 mutated_trace.set(operand_cols.at(i), 0, mutated_operand);
221TEST(InstrFetchingConstrainingTest, WireInstructionSpecInteractions)
223 TestTraceContainer
trace;
224 BytecodeTraceBuilder bytecode_builder;
229 bytecode_builder.process_instruction_fetching(gen_instr_events_each_opcode(), trace);
234 check_interaction<BytecodeTraceBuilder, lookup_instr_fetching_wire_instruction_info_settings>(trace);
235 check_relation<instr_fetching>(trace);
241 range_check_events.reserve(instr_events.size());
243 for (
const auto& instr_event : instr_events) {
244 range_check_events.emplace_back(RangeCheckEvent{
246 (instr_event.error.has_value() && instr_event.error == InstrDeserializationEventError::PC_OUT_OF_RANGE)
247 ? instr_event.pc - instr_event.bytecode->size()
248 : instr_event.bytecode->size() - instr_event.pc - 1,
252 return range_check_events;
257TEST(InstrFetchingConstrainingTest, BcDecompositionInteractions)
259 TestTraceContainer
trace;
260 BytecodeTraceBuilder bytecode_builder;
263 const auto instr_fetch_events = gen_instr_events_each_opcode();
264 bytecode_builder.process_instruction_fetching(instr_fetch_events, trace);
265 bytecode_builder.process_decomposition({ {
266 .bytecode_id = instr_fetch_events.at(0).bytecode_id,
267 .
bytecode = instr_fetch_events.at(0).bytecode,
279 check_relation<instr_fetching>(trace);
286 TestTraceContainer
trace;
287 BytecodeTraceBuilder bytecode_builder;
295 bytecode_builder.process_instruction_fetching(instr_events, trace);
310 check_relation<instr_fetching>(trace);
316 TestTraceContainer
trace;
317 BytecodeTraceBuilder bytecode_builder;
323 bytecode_builder.process_instruction_fetching(instr_events, trace);
336 check_relation<instr_fetching>(trace);
342TEST(InstrFetchingConstrainingTest, MultipleBytecodes)
344 const auto instr_fetch_events = gen_instr_events_each_opcode();
345 constexpr size_t num_of_bytecodes = 5;
349 for (
size_t i = 0; i < num_of_bytecodes; i++) {
351 const auto num_of_instr = i * 6;
353 for (
size_t j = 0; j < num_of_instr; j++) {
354 const auto& instr = instr_fetch_events.at(j).instruction;
355 const auto instruction_bytes = instr.serialize();
363 for (
size_t j = 0; j < num_of_instr; j++) {
364 auto instr_event = instr_fetch_events.at(j);
365 instr_event.bytecode_id =
static_cast<BytecodeId>(i);
366 instr_event.bytecode = bytecode_ptr;
367 instr_events.emplace_back(instr_event);
382TEST(InstrFetchingConstrainingTest, SingleInstructionOutOfRange)
386 .addressing_mode = 3,
387 .operands = { Operand::from<uint8_t>(0x34), Operand::from<uint8_t>(0x35), Operand::from<uint8_t>(0x36) },
390 std::vector<uint8_t>
bytecode = add_8_instruction.serialize();
398 .bytecode = bytecode_ptr,
399 .error = InstrDeserializationEventError::INSTRUCTION_OUT_OF_RANGE,
406 .bytecode = bytecode_ptr,
417TEST(InstrFetchingConstrainingTest, SingleInstructionOutOfRangeSplitOperand)
421 .addressing_mode = 0x01,
422 .operands = { Operand::from<uint16_t>(0x1279),
427 std::vector<uint8_t>
bytecode = set_ff_instruction.serialize();
435 .bytecode = bytecode_ptr,
436 .error = InstrDeserializationEventError::INSTRUCTION_OUT_OF_RANGE,
443 .bytecode = bytecode_ptr,
451TEST(InstrFetchingConstrainingTest, SingleInstructionPcOutOfRange)
455 .addressing_mode = 3,
456 .operands = { Operand::from<uint8_t>(0x34), Operand::from<uint8_t>(0x35), Operand::from<uint8_t>(0x36) },
459 std::vector<uint8_t>
bytecode = add_8_instruction.serialize();
467 .instruction = add_8_instruction,
468 .bytecode = bytecode_ptr,
472 .pc =
static_cast<uint32_t
>(bytecode_ptr->size() + 1),
474 .error = InstrDeserializationEventError::PC_OUT_OF_RANGE,
481 .bytecode = bytecode_ptr,
491TEST(InstrFetchingConstrainingTest, SingleInstructionOpcodeOutOfRange)
495 .addressing_mode = 0,
496 .operands = { Operand::from<uint16_t>(0x1234),
498 Operand::from<uint128_t>(
static_cast<uint128_t>(0xFF) << 120) },
501 std::vector<uint8_t>
bytecode = set_128_instruction.serialize();
508 .instruction = set_128_instruction,
509 .bytecode = bytecode_ptr,
514 .bytecode = bytecode_ptr,
515 .error = InstrDeserializationEventError::OPCODE_OUT_OF_RANGE,
522 .bytecode = bytecode_ptr,
532TEST(InstrFetchingConstrainingTest, SingleInstructionTagOutOfRange)
536 .addressing_mode = 0,
537 .operands = { Operand::from<uint16_t>(0x1234), Operand::from<uint8_t>(12), Operand::from<uint16_t>(0x5678) },
540 std::vector<uint8_t>
bytecode = set_16_instruction.serialize();
547 .instruction = set_16_instruction,
548 .bytecode = bytecode_ptr,
549 .error = InstrDeserializationEventError::TAG_OUT_OF_RANGE,
556 .bytecode = bytecode_ptr,
564TEST(InstrFetchingConstrainingTest, NegativeWrongWireInstructionSpecInteractions)
566 BytecodeTraceBuilder bytecode_builder;
573 for (
const auto& opcode : opcodes) {
574 TestTraceContainer
trace;
576 bytecode_builder.process_instruction_fetching(
577 { { .bytecode_id = 1,
579 .instruction = instr,
586 check_interaction<BytecodeTraceBuilder, lookup_instr_fetching_wire_instruction_info_settings>(trace);
588 ASSERT_EQ(
trace.
get(C::lookup_instr_fetching_wire_instruction_info_counts,
static_cast<uint32_t
>(opcode)), 1);
591 C::instr_fetching_exec_opcode, C::instr_fetching_instr_size, C::instr_fetching_sel_has_tag,
592 C::instr_fetching_sel_tag_is_op2, C::instr_fetching_sel_op_dc_0, C::instr_fetching_sel_op_dc_1,
593 C::instr_fetching_sel_op_dc_2, C::instr_fetching_sel_op_dc_3, C::instr_fetching_sel_op_dc_4,
594 C::instr_fetching_sel_op_dc_5, C::instr_fetching_sel_op_dc_6, C::instr_fetching_sel_op_dc_7,
595 C::instr_fetching_sel_op_dc_8, C::instr_fetching_sel_op_dc_9, C::instr_fetching_sel_op_dc_10,
596 C::instr_fetching_sel_op_dc_11, C::instr_fetching_sel_op_dc_12, C::instr_fetching_sel_op_dc_13,
597 C::instr_fetching_sel_op_dc_14, C::instr_fetching_sel_op_dc_15, C::instr_fetching_sel_op_dc_16,
601 for (
const auto& col : mutated_cols) {
602 auto mutated_trace =
trace;
603 const FF mutated_value =
trace.
get(col, 0) + 1;
604 mutated_trace.set(col, 0, mutated_value);
607 (check_interaction<BytecodeTraceBuilder, lookup_instr_fetching_wire_instruction_info_settings>(
609 "Failed.*LOOKUP_INSTR_FETCHING_WIRE_INSTRUCTION_INFO.*Could not find tuple in destination.");
615TEST(InstrFetchingConstrainingTest, NegativeWrongBcDecompositionInteractions)
617 TestTraceContainer
trace;
618 BytecodeTraceBuilder bytecode_builder;
624 for (
const auto& opcode : opcodes) {
625 TestTraceContainer
trace;
628 bytecode_builder.process_instruction_fetching({ {
631 .instruction = instr,
632 .bytecode = bytecode_ptr,
635 bytecode_builder.process_decomposition({ {
637 .bytecode = bytecode_ptr,
641 auto valid_trace =
trace;
642 check_interaction<BytecodeTraceBuilder, lookup_instr_fetching_bytes_from_bc_dec_settings>(valid_trace);
645 C::instr_fetching_pc, C::instr_fetching_bytecode_id, C::instr_fetching_bd0, C::instr_fetching_bd1,
646 C::instr_fetching_bd2, C::instr_fetching_bd3, C::instr_fetching_bd4, C::instr_fetching_bd5,
647 C::instr_fetching_bd6, C::instr_fetching_bd7, C::instr_fetching_bd8, C::instr_fetching_bd9,
648 C::instr_fetching_bd10, C::instr_fetching_bd11, C::instr_fetching_bd12, C::instr_fetching_bd13,
649 C::instr_fetching_bd14, C::instr_fetching_bd15, C::instr_fetching_bd16, C::instr_fetching_bd17,
650 C::instr_fetching_bd18, C::instr_fetching_bd19, C::instr_fetching_bd20, C::instr_fetching_bd21,
651 C::instr_fetching_bd22, C::instr_fetching_bd23, C::instr_fetching_bd24, C::instr_fetching_bd25,
652 C::instr_fetching_bd26, C::instr_fetching_bd27, C::instr_fetching_bd28, C::instr_fetching_bd29,
653 C::instr_fetching_bd30, C::instr_fetching_bd31, C::instr_fetching_bd32, C::instr_fetching_bd33,
654 C::instr_fetching_bd34, C::instr_fetching_bd35, C::instr_fetching_bd36,
658 for (
const auto& col : mutated_cols) {
659 auto mutated_trace =
trace;
660 const FF mutated_value =
trace.
get(col, 0) + 1;
661 mutated_trace.set(col, 0, mutated_value);
664 (check_interaction<BytecodeTraceBuilder, lookup_instr_fetching_bytes_from_bc_dec_settings>(
666 "Failed.*BYTES_FROM_BC_DEC. Could not find tuple in destination.");
673TEST(InstrFetchingConstrainingTest, NegativeWrongBytecodeSizeBcDecompositionInteractions)
675 TestTraceContainer
trace;
676 BytecodeTraceBuilder bytecode_builder;
679 const uint32_t pc = 15;
680 std::vector<uint8_t>
bytecode(pc, 0x23);
686 for (
const auto& opcode : opcodes) {
687 TestTraceContainer
trace;
690 const auto instr_bytecode = instr.serialize();
696 bytecode_builder.process_instruction_fetching({ {
699 .instruction = instr,
700 .bytecode = bytecode_ptr,
703 bytecode_builder.process_decomposition({ {
705 .bytecode = bytecode_ptr,
710 auto valid_trace =
trace;
711 check_interaction<BytecodeTraceBuilder, lookup_instr_fetching_bytecode_size_from_bc_dec_settings>(valid_trace);
713 auto mutated_trace =
trace;
714 const FF mutated_value =
trace.
get(C::instr_fetching_bytecode_size, 0) + 1;
715 mutated_trace.set(C::instr_fetching_bytecode_size, 0, mutated_value);
718 (check_interaction<BytecodeTraceBuilder, lookup_instr_fetching_bytecode_size_from_bc_dec_settings>(
720 "Failed.*BYTECODE_SIZE_FROM_BC_DEC. Could not find tuple in destination.");
724using ::bb::avm2::testing::InstructionBuilder;
725using simulation::EventEmitter;
726using simulation::MockExecutionIdManager;
727using simulation::MockGreaterThan;
728using simulation::Poseidon2;
729using simulation::Poseidon2HashEvent;
730using simulation::Poseidon2PermutationEvent;
731using simulation::Poseidon2PermutationMemoryEvent;
732using ::testing::StrictMock;
733using tracegen::Poseidon2TraceBuilder;
735TEST(InstrFetchingConstrainingTest, NegativeTruncatedBytecodeRepro)
737 TestTraceContainer
trace;
738 BytecodeTraceBuilder bytecode_builder;
744 StrictMock<MockGreaterThan>
mock_gt;
753 const uint32_t pc = 15;
754 std::vector<uint8_t>
bytecode(pc, 0x23);
755 const auto add_instr =
756 InstructionBuilder(
WireOpCode::SUB_8).operand<uint8_t>(5).operand<uint8_t>(5).operand<uint8_t>(0).build();
757 const auto instr_bytecode = add_instr.serialize();
763 prepended_fields.insert(prepended_fields.end(), fields.begin(), fields.end());
767 std::vector<uint8_t> trunc_bytecode(pc, 0x23);
768 trunc_bytecode.insert(trunc_bytecode.end(),
771 trunc_bytecode.resize(trunc_bytecode.size() - 1);
774 trunc_prepended_fields.insert(trunc_prepended_fields.end(), trunc_fields.begin(), trunc_fields.end());
781 ASSERT_NE(hash, trunc_hash);
786 InstructionFetchingEvent instr_event = {
789 .instruction = add_instr,
790 .bytecode = bytecode_ptr,
792 bytecode_builder.process_instruction_fetching({ instr_event },
trace);
793 bytecode_builder.process_hashing({ {
795 .bytecode_length_in_bytes =
static_cast<uint32_t
>(trunc_bytecode.size()),
796 .bytecode_fields = trunc_fields,
800 bytecode_builder.process_decomposition({ {
802 .bytecode = trunc_bytecode_ptr,
816 perm_builder(C::bc_decomposition_sel_packed);
817 perm_builder.process(trace);
819 check_relation<bb::avm2::bc_hashing<FF>>(
trace);
821 (check_interaction<BytecodeTraceBuilder, lookup_bc_hashing_poseidon2_hash_settings>(trace)),
822 "Failed.*LOOKUP_BC_HASHING_POSEIDON2_HASH. Could not find tuple in destination.");
825TEST(InstrFetchingConstrainingTest, NegativeWrongTagValidationInteractions)
827 TestTraceContainer
trace;
828 BytecodeTraceBuilder bytecode_builder;
835 for (
const auto& opcode : opcodes) {
836 TestTraceContainer
trace;
838 bytecode_builder.process_instruction_fetching(
839 { { .bytecode_id = 1,
841 .instruction = instr,
848 check_interaction<BytecodeTraceBuilder, lookup_instr_fetching_tag_value_validation_settings>(trace);
850 auto valid_trace =
trace;
853 auto mutated_trace =
trace;
854 ASSERT_EQ(
trace.
get(C::instr_fetching_tag_out_of_range, 0), 0);
855 mutated_trace.set(C::instr_fetching_tag_out_of_range, 0, 1);
858 (check_interaction<BytecodeTraceBuilder, lookup_instr_fetching_tag_value_validation_settings>(
860 "Failed.*LOOKUP_INSTR_FETCHING_TAG_VALUE_VALIDATION.*Could not find tuple in destination.");
865TEST(InstrFetchingConstrainingTest, NegativeNotTogglingInstrOutOfRange)
867 TestTraceContainer
trace({
869 { C::instr_fetching_bytes_to_read, 11 },
870 { C::instr_fetching_instr_abs_diff, 0 },
871 { C::instr_fetching_instr_out_of_range, 1 },
872 { C::instr_fetching_instr_size, 12 },
873 { C::instr_fetching_sel, 1 },
879 trace.
set(C::instr_fetching_instr_out_of_range, 0, 0);
882 "INSTR_OUT_OF_RANGE_TOGGLE");
886TEST(InstrFetchingConstrainingTest, NegativeTogglingInstrInRange)
888 TestTraceContainer
trace({
890 { C::instr_fetching_bytes_to_read, 12 },
891 { C::instr_fetching_instr_abs_diff, 0 },
892 { C::instr_fetching_instr_out_of_range, 0 },
893 { C::instr_fetching_instr_size, 12 },
894 { C::instr_fetching_sel, 1 },
900 trace.
set(C::instr_fetching_instr_out_of_range, 0, 1);
903 "INSTR_OUT_OF_RANGE_TOGGLE");
907TEST(InstrFetchingConstrainingTest, NegativeNotTogglingPcOutOfRange)
909 TestTraceContainer
trace({
911 { C::instr_fetching_bytecode_size, 12 },
912 { C::instr_fetching_pc, 12 },
913 { C::instr_fetching_pc_abs_diff, 0 },
914 { C::instr_fetching_pc_out_of_range, 1 },
915 { C::instr_fetching_sel, 1 },
921 trace.
set(C::instr_fetching_pc_out_of_range, 0, 0);
924 "PC_OUT_OF_RANGE_TOGGLE");
928TEST(InstrFetchingConstrainingTest, NegativeTogglingPcInRange)
930 TestTraceContainer
trace({
932 { C::instr_fetching_bytecode_size, 12 },
933 { C::instr_fetching_pc, 11 },
934 { C::instr_fetching_pc_abs_diff, 0 },
935 { C::instr_fetching_pc_out_of_range, 0 },
936 { C::instr_fetching_sel, 1 },
942 trace.
set(C::instr_fetching_pc_out_of_range, 0, 1);
945 "PC_OUT_OF_RANGE_TOGGLE");
948TEST(InstrFetchingConstrainingTest, ErrorFlagSetButSelParsingErrIsZero)
953 TestTraceContainer
trace({
955 { C::instr_fetching_sel, 1 },
957 { C::instr_fetching_pc_out_of_range, 1 },
958 { C::instr_fetching_opcode_out_of_range, 0 },
959 { C::instr_fetching_instr_out_of_range, 0 },
960 { C::instr_fetching_tag_out_of_range, 0 },
962 { C::instr_fetching_sel_parsing_err, 0 },
966 { C::instr_fetching_bytecode_size, 10 },
967 { C::instr_fetching_pc, 15 },
968 { C::instr_fetching_pc_abs_diff, 5 },
969 { C::instr_fetching_pc_size_in_bits, 32 },
974 { C::instr_fetching_bytes_to_read, 10 },
975 { C::instr_fetching_instr_size, 5 },
976 { C::instr_fetching_instr_abs_diff, 5 },
981 "Relation instr_fetching, subrelation .* failed at row 0");
988TEST(InstrFetchingConstrainingTest, CorrectBehaviorSelParsingErrMatchesErrors)
990 TestTraceContainer
trace({
992 { C::instr_fetching_sel, 1 },
993 { C::instr_fetching_pc_out_of_range, 1 },
994 { C::instr_fetching_opcode_out_of_range, 0 },
995 { C::instr_fetching_instr_out_of_range, 0 },
996 { C::instr_fetching_tag_out_of_range, 0 },
997 { C::instr_fetching_sel_parsing_err, 1 },
999 { C::instr_fetching_bytecode_size, 10 },
1000 { C::instr_fetching_pc, 15 },
1001 { C::instr_fetching_pc_abs_diff, 5 },
1002 { C::instr_fetching_pc_size_in_bits, 32 },
1003 { C::instr_fetching_bytes_to_read, 10 },
1004 { C::instr_fetching_instr_size, 5 },
1005 { C::instr_fetching_instr_abs_diff, 5 },
1010 check_relation<instr_fetching>(trace);
1016TEST(InstrFetchingConstrainingTest, CorrectBehaviorNoErrorsMeansSelParsingErrIsZero)
1018 TestTraceContainer
trace({
1020 { C::instr_fetching_sel, 1 },
1021 { C::instr_fetching_pc_out_of_range, 0 },
1022 { C::instr_fetching_opcode_out_of_range, 0 },
1023 { C::instr_fetching_instr_out_of_range, 0 },
1024 { C::instr_fetching_tag_out_of_range, 0 },
1025 { C::instr_fetching_sel_parsing_err, 0 },
1026 { C::instr_fetching_sel_pc_in_range, 1 },
1030 { C::instr_fetching_bytecode_size, 20 },
1031 { C::instr_fetching_pc, 5 },
1032 { C::instr_fetching_pc_abs_diff, 14 },
1033 { C::instr_fetching_pc_size_in_bits, 32 },
1035 { C::instr_fetching_bytes_to_read, 15 },
1036 { C::instr_fetching_instr_size, 10 },
1037 { C::instr_fetching_instr_abs_diff, 5 },
1042 check_relation<instr_fetching>(trace);
#define EXPECT_THROW_WITH_MESSAGE(code, expectedMessageRegex)
std::shared_ptr< Napi::ThreadSafeFunction > bytecode
#define DOM_SEP__PUBLIC_BYTECODE
#define AVM_PC_SIZE_IN_BITS
StrictMock< MockGreaterThan > mock_gt
EventEmitter< Poseidon2PermutationMemoryEvent > perm_mem_event_emitter
EventEmitter< Poseidon2PermutationEvent > perm_event_emitter
EventEmitter< Poseidon2HashEvent > hash_event_emitter
Poseidon2TraceBuilder poseidon2_builder
StrictMock< MockExecutionIdManager > mock_execution_id_manager
EventEmitter< BytecodeDecompositionEvent > decomposition_events
static constexpr size_t SR_OP1_BYTES_DECOMPOSITION
static constexpr size_t SR_OP3_BYTES_DECOMPOSITION
static constexpr size_t SR_OP6_BYTES_DECOMPOSITION
static constexpr size_t SR_OP4_BYTES_DECOMPOSITION
static constexpr size_t SR_ADDRESSING_MODE_BYTES_DECOMPOSITION
static constexpr size_t SR_INSTR_OUT_OF_RANGE_TOGGLE
static std::string get_subrelation_label(size_t index)
static constexpr size_t SR_OP7_BYTES_DECOMPOSITION
static constexpr size_t SR_OP5_BYTES_DECOMPOSITION
static constexpr size_t SR_PC_OUT_OF_RANGE_TOGGLE
static constexpr size_t SR_OP2_BYTES_DECOMPOSITION
void process_hash(const simulation::EventEmitterInterface< simulation::Poseidon2HashEvent >::Container &hash_events, TraceContainer &trace)
Processes the hash events for the Poseidon2 hash function. It populates the columns for the poseidon2...
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_wire_instruction_spec(TraceContainer &trace)
Populate the wire-level instruction specification table.
void process_memory_tag_range(TraceContainer &trace)
Populate the memory tag out-of-range selector.
void process_sel_range_16(TraceContainer &trace)
Generate a selector column that activates the first 2^16 (65536) rows.
void process_sel_range_8(TraceContainer &trace)
Generate a selector column that activates the first 2^8 (256) rows.
void process(const simulation::EventEmitterInterface< simulation::RangeCheckEvent >::Container &events, TraceContainer &trace)
Processes range check events and populates the trace with decomposed value columns.
const FF & get(Column col, uint32_t row) const
uint32_t get_num_rows() const
void set(Column col, uint32_t row, const FF &value)
Native Poseidon2 hash function implementation.
static FF hash(const std::vector< FF > &input)
Hashes a vector of field elements.
RangeCheckTraceBuilder range_check_builder
PrecomputedTraceBuilder precomputed_builder
void check_interaction(tracegen::TestTraceContainer &trace)
TEST(AvmFixedVKTests, FixedVKCommitments)
Test that the fixed VK commitments agree with the ones computed from precomputed columns.
InstrDeserializationEventError
std::vector< FF > encode_bytecode(std::span< const uint8_t > bytecode)
Encodes the bytecode into a vector of field elements. Each field element represents 31 bytes of the b...
FF compute_public_bytecode_first_field(size_t bytecode_size)
Instruction random_instruction(WireOpCode w_opcode)
TestTraceContainer empty_trace()
lookup_settings< lookup_instr_fetching_wire_instruction_info_settings_ > lookup_instr_fetching_wire_instruction_info_settings
lookup_settings< lookup_instr_fetching_bytecode_size_from_bc_dec_settings_ > lookup_instr_fetching_bytecode_size_from_bc_dec_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_instr_abs_diff_positive_settings_ > lookup_instr_fetching_instr_abs_diff_positive_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
Instruction
Enumeration of VM instructions that can be executed.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
unsigned __int128 uint128_t
static constexpr uint256_t modulus_minus_two