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),
100 Operand::from<uint16_t>(0x127e),
101 Operand::from<uint16_t>(0x127f) },
104 std::vector<uint8_t>
bytecode = ecadd_instruction.serialize();
105 builder.process_instruction_fetching({ { .bytecode_id = 1,
107 .instruction = ecadd_instruction,
113 check_relation<instr_fetching>(trace);
123 instructions.reserve(num_opcodes);
126 for (
size_t i = 0; i < num_opcodes; i++) {
127 pc_positions.at(i) =
static_cast<uint32_t
>(
bytecode.size());
129 instructions.emplace_back(instr);
130 const auto instruction_bytes = instr.serialize();
140 instr_events.reserve(num_opcodes);
141 for (
size_t i = 0; i < num_opcodes; i++) {
142 instr_events.emplace_back(InstructionFetchingEvent{
143 .bytecode_id = 1, .pc = pc_positions.at(i), .instruction = instructions.at(i), .bytecode = bytecode_ptr });
150TEST(InstrFetchingConstrainingTest, EachOpcodeWithTraceGen)
152 TestTraceContainer
trace;
156 builder.process_instruction_fetching(gen_instr_events_each_opcode(), trace);
161 check_relation<instr_fetching>(trace);
167TEST(InstrFetchingConstrainingTest, NegativeWrongOperand)
173 std::vector<size_t> sub_relations = {
185 C::instr_fetching_addressing_mode,
186 C::instr_fetching_op1,
187 C::instr_fetching_op2,
188 C::instr_fetching_op3,
189 C::instr_fetching_op4,
190 C::instr_fetching_op5,
191 C::instr_fetching_op6,
192 C::instr_fetching_op7,
195 for (
const auto& opcode : opcodes) {
196 TestTraceContainer
trace;
198 builder.process_instruction_fetching(
199 { { .bytecode_id = 1,
201 .instruction = instr,
206 check_relation<instr_fetching>(trace);
210 for (
size_t i = 0; i < operand_cols.size(); i++) {
211 auto mutated_trace =
trace;
212 const FF mutated_operand =
trace.
get(operand_cols.at(i), 0) + 1;
213 mutated_trace.set(operand_cols.at(i), 0, mutated_operand);
223TEST(InstrFetchingConstrainingTest, WireInstructionSpecInteractions)
225 TestTraceContainer
trace;
226 BytecodeTraceBuilder bytecode_builder;
231 bytecode_builder.process_instruction_fetching(gen_instr_events_each_opcode(), trace);
236 check_interaction<BytecodeTraceBuilder, lookup_instr_fetching_wire_instruction_info_settings>(trace);
237 check_relation<instr_fetching>(trace);
243 range_check_events.reserve(instr_events.size());
245 for (
const auto& instr_event : instr_events) {
246 range_check_events.emplace_back(RangeCheckEvent{
248 (instr_event.error.has_value() && instr_event.error == InstrDeserializationEventError::PC_OUT_OF_RANGE)
249 ? instr_event.pc - instr_event.bytecode->size()
250 : instr_event.bytecode->size() - instr_event.pc - 1,
254 return range_check_events;
259TEST(InstrFetchingConstrainingTest, BcDecompositionInteractions)
261 TestTraceContainer
trace;
262 BytecodeTraceBuilder bytecode_builder;
265 const auto instr_fetch_events = gen_instr_events_each_opcode();
266 bytecode_builder.process_instruction_fetching(instr_fetch_events, trace);
267 bytecode_builder.process_decomposition({ {
268 .bytecode_id = instr_fetch_events.at(0).bytecode_id,
269 .
bytecode = instr_fetch_events.at(0).bytecode,
281 check_relation<instr_fetching>(trace);
288 TestTraceContainer
trace;
289 BytecodeTraceBuilder bytecode_builder;
297 bytecode_builder.process_instruction_fetching(instr_events, trace);
312 check_relation<instr_fetching>(trace);
318 TestTraceContainer
trace;
319 BytecodeTraceBuilder bytecode_builder;
325 bytecode_builder.process_instruction_fetching(instr_events, trace);
338 check_relation<instr_fetching>(trace);
344TEST(InstrFetchingConstrainingTest, MultipleBytecodes)
346 const auto instr_fetch_events = gen_instr_events_each_opcode();
347 constexpr size_t num_of_bytecodes = 5;
351 for (
size_t i = 0; i < num_of_bytecodes; i++) {
353 const auto num_of_instr = i * 6;
355 for (
size_t j = 0; j < num_of_instr; j++) {
356 const auto& instr = instr_fetch_events.at(j).instruction;
357 const auto instruction_bytes = instr.serialize();
365 for (
size_t j = 0; j < num_of_instr; j++) {
366 auto instr_event = instr_fetch_events.at(j);
367 instr_event.bytecode_id =
static_cast<BytecodeId>(i);
368 instr_event.bytecode = bytecode_ptr;
369 instr_events.emplace_back(instr_event);
384TEST(InstrFetchingConstrainingTest, SingleInstructionOutOfRange)
388 .addressing_mode = 3,
389 .operands = { Operand::from<uint8_t>(0x34), Operand::from<uint8_t>(0x35), Operand::from<uint8_t>(0x36) },
392 std::vector<uint8_t>
bytecode = add_8_instruction.serialize();
400 .bytecode = bytecode_ptr,
401 .error = InstrDeserializationEventError::INSTRUCTION_OUT_OF_RANGE,
408 .bytecode = bytecode_ptr,
419TEST(InstrFetchingConstrainingTest, SingleInstructionOutOfRangeSplitOperand)
423 .addressing_mode = 0x01,
424 .operands = { Operand::from<uint16_t>(0x1279),
429 std::vector<uint8_t>
bytecode = set_ff_instruction.serialize();
437 .bytecode = bytecode_ptr,
438 .error = InstrDeserializationEventError::INSTRUCTION_OUT_OF_RANGE,
445 .bytecode = bytecode_ptr,
453TEST(InstrFetchingConstrainingTest, SingleInstructionPcOutOfRange)
457 .addressing_mode = 3,
458 .operands = { Operand::from<uint8_t>(0x34), Operand::from<uint8_t>(0x35), Operand::from<uint8_t>(0x36) },
461 std::vector<uint8_t>
bytecode = add_8_instruction.serialize();
469 .instruction = add_8_instruction,
470 .bytecode = bytecode_ptr,
474 .pc =
static_cast<uint32_t
>(bytecode_ptr->size() + 1),
476 .error = InstrDeserializationEventError::PC_OUT_OF_RANGE,
483 .bytecode = bytecode_ptr,
493TEST(InstrFetchingConstrainingTest, SingleInstructionOpcodeOutOfRange)
497 .addressing_mode = 0,
498 .operands = { Operand::from<uint16_t>(0x1234),
500 Operand::from<uint128_t>(
static_cast<uint128_t>(0xFF) << 120) },
503 std::vector<uint8_t>
bytecode = set_128_instruction.serialize();
510 .instruction = set_128_instruction,
511 .bytecode = bytecode_ptr,
516 .bytecode = bytecode_ptr,
517 .error = InstrDeserializationEventError::OPCODE_OUT_OF_RANGE,
524 .bytecode = bytecode_ptr,
534TEST(InstrFetchingConstrainingTest, SingleInstructionTagOutOfRange)
538 .addressing_mode = 0,
539 .operands = { Operand::from<uint16_t>(0x1234), Operand::from<uint8_t>(12), Operand::from<uint16_t>(0x5678) },
542 std::vector<uint8_t>
bytecode = set_16_instruction.serialize();
549 .instruction = set_16_instruction,
550 .bytecode = bytecode_ptr,
551 .error = InstrDeserializationEventError::TAG_OUT_OF_RANGE,
558 .bytecode = bytecode_ptr,
566TEST(InstrFetchingConstrainingTest, NegativeWrongWireInstructionSpecInteractions)
568 BytecodeTraceBuilder bytecode_builder;
575 for (
const auto& opcode : opcodes) {
576 TestTraceContainer
trace;
578 bytecode_builder.process_instruction_fetching(
579 { { .bytecode_id = 1,
581 .instruction = instr,
588 check_interaction<BytecodeTraceBuilder, lookup_instr_fetching_wire_instruction_info_settings>(trace);
590 ASSERT_EQ(
trace.
get(C::lookup_instr_fetching_wire_instruction_info_counts,
static_cast<uint32_t
>(opcode)), 1);
593 C::instr_fetching_exec_opcode, C::instr_fetching_instr_size, C::instr_fetching_sel_has_tag,
594 C::instr_fetching_sel_tag_is_op2, C::instr_fetching_sel_op_dc_0, C::instr_fetching_sel_op_dc_1,
595 C::instr_fetching_sel_op_dc_2, C::instr_fetching_sel_op_dc_3, C::instr_fetching_sel_op_dc_4,
596 C::instr_fetching_sel_op_dc_5, C::instr_fetching_sel_op_dc_6, C::instr_fetching_sel_op_dc_7,
597 C::instr_fetching_sel_op_dc_8, C::instr_fetching_sel_op_dc_9, C::instr_fetching_sel_op_dc_10,
598 C::instr_fetching_sel_op_dc_11, C::instr_fetching_sel_op_dc_12, C::instr_fetching_sel_op_dc_13,
599 C::instr_fetching_sel_op_dc_14, C::instr_fetching_sel_op_dc_15, C::instr_fetching_sel_op_dc_16,
603 for (
const auto& col : mutated_cols) {
604 auto mutated_trace =
trace;
605 const FF mutated_value =
trace.
get(col, 0) + 1;
606 mutated_trace.set(col, 0, mutated_value);
609 (check_interaction<BytecodeTraceBuilder, lookup_instr_fetching_wire_instruction_info_settings>(
611 "Failed.*LOOKUP_INSTR_FETCHING_WIRE_INSTRUCTION_INFO.*Could not find tuple in destination.");
617TEST(InstrFetchingConstrainingTest, NegativeWrongBcDecompositionInteractions)
619 TestTraceContainer
trace;
620 BytecodeTraceBuilder bytecode_builder;
626 for (
const auto& opcode : opcodes) {
627 TestTraceContainer
trace;
630 bytecode_builder.process_instruction_fetching({ {
633 .instruction = instr,
634 .bytecode = bytecode_ptr,
637 bytecode_builder.process_decomposition({ {
639 .bytecode = bytecode_ptr,
643 auto valid_trace =
trace;
644 check_interaction<BytecodeTraceBuilder, lookup_instr_fetching_bytes_from_bc_dec_settings>(valid_trace);
647 C::instr_fetching_pc, C::instr_fetching_bytecode_id, C::instr_fetching_bd0, C::instr_fetching_bd1,
648 C::instr_fetching_bd2, C::instr_fetching_bd3, C::instr_fetching_bd4, C::instr_fetching_bd5,
649 C::instr_fetching_bd6, C::instr_fetching_bd7, C::instr_fetching_bd8, C::instr_fetching_bd9,
650 C::instr_fetching_bd10, C::instr_fetching_bd11, C::instr_fetching_bd12, C::instr_fetching_bd13,
651 C::instr_fetching_bd14, C::instr_fetching_bd15, C::instr_fetching_bd16, C::instr_fetching_bd17,
652 C::instr_fetching_bd18, C::instr_fetching_bd19, C::instr_fetching_bd20, C::instr_fetching_bd21,
653 C::instr_fetching_bd22, C::instr_fetching_bd23, C::instr_fetching_bd24, C::instr_fetching_bd25,
654 C::instr_fetching_bd26, C::instr_fetching_bd27, C::instr_fetching_bd28, C::instr_fetching_bd29,
655 C::instr_fetching_bd30, C::instr_fetching_bd31, C::instr_fetching_bd32, C::instr_fetching_bd33,
656 C::instr_fetching_bd34, C::instr_fetching_bd35, C::instr_fetching_bd36,
660 for (
const auto& col : mutated_cols) {
661 auto mutated_trace =
trace;
662 const FF mutated_value =
trace.
get(col, 0) + 1;
663 mutated_trace.set(col, 0, mutated_value);
666 (check_interaction<BytecodeTraceBuilder, lookup_instr_fetching_bytes_from_bc_dec_settings>(
668 "Failed.*BYTES_FROM_BC_DEC. Could not find tuple in destination.");
675TEST(InstrFetchingConstrainingTest, NegativeWrongBytecodeSizeBcDecompositionInteractions)
677 TestTraceContainer
trace;
678 BytecodeTraceBuilder bytecode_builder;
681 const uint32_t pc = 15;
682 std::vector<uint8_t>
bytecode(pc, 0x23);
688 for (
const auto& opcode : opcodes) {
689 TestTraceContainer
trace;
692 const auto instr_bytecode = instr.serialize();
698 bytecode_builder.process_instruction_fetching({ {
701 .instruction = instr,
702 .bytecode = bytecode_ptr,
705 bytecode_builder.process_decomposition({ {
707 .bytecode = bytecode_ptr,
712 auto valid_trace =
trace;
713 check_interaction<BytecodeTraceBuilder, lookup_instr_fetching_bytecode_size_from_bc_dec_settings>(valid_trace);
715 auto mutated_trace =
trace;
716 const FF mutated_value =
trace.
get(C::instr_fetching_bytecode_size, 0) + 1;
717 mutated_trace.set(C::instr_fetching_bytecode_size, 0, mutated_value);
720 (check_interaction<BytecodeTraceBuilder, lookup_instr_fetching_bytecode_size_from_bc_dec_settings>(
722 "Failed.*BYTECODE_SIZE_FROM_BC_DEC. Could not find tuple in destination.");
726using ::bb::avm2::testing::InstructionBuilder;
727using simulation::EventEmitter;
728using simulation::MockExecutionIdManager;
729using simulation::MockGreaterThan;
730using simulation::Poseidon2;
731using simulation::Poseidon2HashEvent;
732using simulation::Poseidon2PermutationEvent;
733using simulation::Poseidon2PermutationMemoryEvent;
734using ::testing::StrictMock;
735using tracegen::Poseidon2TraceBuilder;
737TEST(InstrFetchingConstrainingTest, NegativeTruncatedBytecodeRepro)
739 TestTraceContainer
trace;
740 BytecodeTraceBuilder bytecode_builder;
746 StrictMock<MockGreaterThan>
mock_gt;
755 const uint32_t pc = 15;
756 std::vector<uint8_t>
bytecode(pc, 0x23);
757 const auto add_instr =
758 InstructionBuilder(
WireOpCode::SUB_8).operand<uint8_t>(5).operand<uint8_t>(5).operand<uint8_t>(0).build();
759 const auto instr_bytecode = add_instr.serialize();
765 prepended_fields.insert(prepended_fields.end(), fields.begin(), fields.end());
769 std::vector<uint8_t> trunc_bytecode(pc, 0x23);
770 trunc_bytecode.insert(trunc_bytecode.end(),
773 trunc_bytecode.resize(trunc_bytecode.size() - 1);
776 trunc_prepended_fields.insert(trunc_prepended_fields.end(), trunc_fields.begin(), trunc_fields.end());
783 ASSERT_NE(hash, trunc_hash);
788 InstructionFetchingEvent instr_event = {
791 .instruction = add_instr,
792 .bytecode = bytecode_ptr,
794 bytecode_builder.process_instruction_fetching({ instr_event },
trace);
795 bytecode_builder.process_hashing({ {
797 .bytecode_length_in_bytes =
static_cast<uint32_t
>(trunc_bytecode.size()),
798 .bytecode_fields = trunc_fields,
802 bytecode_builder.process_decomposition({ {
804 .bytecode = trunc_bytecode_ptr,
818 perm_builder(C::bc_decomposition_sel_packed);
819 perm_builder.process(trace);
821 check_relation<bb::avm2::bc_hashing<FF>>(
trace);
823 (check_interaction<BytecodeTraceBuilder, lookup_bc_hashing_poseidon2_hash_settings>(trace)),
824 "Failed.*LOOKUP_BC_HASHING_POSEIDON2_HASH. Could not find tuple in destination.");
827TEST(InstrFetchingConstrainingTest, NegativeWrongTagValidationInteractions)
829 TestTraceContainer
trace;
830 BytecodeTraceBuilder bytecode_builder;
837 for (
const auto& opcode : opcodes) {
838 TestTraceContainer
trace;
840 bytecode_builder.process_instruction_fetching(
841 { { .bytecode_id = 1,
843 .instruction = instr,
850 check_interaction<BytecodeTraceBuilder, lookup_instr_fetching_tag_value_validation_settings>(trace);
852 auto valid_trace =
trace;
855 auto mutated_trace =
trace;
856 ASSERT_EQ(
trace.
get(C::instr_fetching_tag_out_of_range, 0), 0);
857 mutated_trace.set(C::instr_fetching_tag_out_of_range, 0, 1);
860 (check_interaction<BytecodeTraceBuilder, lookup_instr_fetching_tag_value_validation_settings>(
862 "Failed.*LOOKUP_INSTR_FETCHING_TAG_VALUE_VALIDATION.*Could not find tuple in destination.");
867TEST(InstrFetchingConstrainingTest, NegativeNotTogglingInstrOutOfRange)
869 TestTraceContainer
trace({
871 { C::instr_fetching_bytes_to_read, 11 },
872 { C::instr_fetching_instr_abs_diff, 0 },
873 { C::instr_fetching_instr_out_of_range, 1 },
874 { C::instr_fetching_instr_size, 12 },
875 { C::instr_fetching_sel, 1 },
881 trace.
set(C::instr_fetching_instr_out_of_range, 0, 0);
884 "INSTR_OUT_OF_RANGE_TOGGLE");
888TEST(InstrFetchingConstrainingTest, NegativeTogglingInstrInRange)
890 TestTraceContainer
trace({
892 { C::instr_fetching_bytes_to_read, 12 },
893 { C::instr_fetching_instr_abs_diff, 0 },
894 { C::instr_fetching_instr_out_of_range, 0 },
895 { C::instr_fetching_instr_size, 12 },
896 { C::instr_fetching_sel, 1 },
902 trace.
set(C::instr_fetching_instr_out_of_range, 0, 1);
905 "INSTR_OUT_OF_RANGE_TOGGLE");
909TEST(InstrFetchingConstrainingTest, NegativeNotTogglingPcOutOfRange)
911 TestTraceContainer
trace({
913 { C::instr_fetching_bytecode_size, 12 },
914 { C::instr_fetching_pc, 12 },
915 { C::instr_fetching_pc_abs_diff, 0 },
916 { C::instr_fetching_pc_out_of_range, 1 },
917 { C::instr_fetching_sel, 1 },
923 trace.
set(C::instr_fetching_pc_out_of_range, 0, 0);
926 "PC_OUT_OF_RANGE_TOGGLE");
930TEST(InstrFetchingConstrainingTest, NegativeTogglingPcInRange)
932 TestTraceContainer
trace({
934 { C::instr_fetching_bytecode_size, 12 },
935 { C::instr_fetching_pc, 11 },
936 { C::instr_fetching_pc_abs_diff, 0 },
937 { C::instr_fetching_pc_out_of_range, 0 },
938 { C::instr_fetching_sel, 1 },
944 trace.
set(C::instr_fetching_pc_out_of_range, 0, 1);
947 "PC_OUT_OF_RANGE_TOGGLE");
950TEST(InstrFetchingConstrainingTest, ErrorFlagSetButSelParsingErrIsZero)
955 TestTraceContainer
trace({
957 { C::instr_fetching_sel, 1 },
959 { C::instr_fetching_pc_out_of_range, 1 },
960 { C::instr_fetching_opcode_out_of_range, 0 },
961 { C::instr_fetching_instr_out_of_range, 0 },
962 { C::instr_fetching_tag_out_of_range, 0 },
964 { C::instr_fetching_sel_parsing_err, 0 },
968 { C::instr_fetching_bytecode_size, 10 },
969 { C::instr_fetching_pc, 15 },
970 { C::instr_fetching_pc_abs_diff, 5 },
971 { C::instr_fetching_pc_size_in_bits, 32 },
976 { C::instr_fetching_bytes_to_read, 10 },
977 { C::instr_fetching_instr_size, 5 },
978 { C::instr_fetching_instr_abs_diff, 5 },
983 "Relation instr_fetching, subrelation .* failed at row 0");
990TEST(InstrFetchingConstrainingTest, CorrectBehaviorSelParsingErrMatchesErrors)
992 TestTraceContainer
trace({
994 { C::instr_fetching_sel, 1 },
995 { C::instr_fetching_pc_out_of_range, 1 },
996 { C::instr_fetching_opcode_out_of_range, 0 },
997 { C::instr_fetching_instr_out_of_range, 0 },
998 { C::instr_fetching_tag_out_of_range, 0 },
999 { C::instr_fetching_sel_parsing_err, 1 },
1001 { C::instr_fetching_bytecode_size, 10 },
1002 { C::instr_fetching_pc, 15 },
1003 { C::instr_fetching_pc_abs_diff, 5 },
1004 { C::instr_fetching_pc_size_in_bits, 32 },
1005 { C::instr_fetching_bytes_to_read, 10 },
1006 { C::instr_fetching_instr_size, 5 },
1007 { C::instr_fetching_instr_abs_diff, 5 },
1012 check_relation<instr_fetching>(trace);
1018TEST(InstrFetchingConstrainingTest, CorrectBehaviorNoErrorsMeansSelParsingErrIsZero)
1020 TestTraceContainer
trace({
1022 { C::instr_fetching_sel, 1 },
1023 { C::instr_fetching_pc_out_of_range, 0 },
1024 { C::instr_fetching_opcode_out_of_range, 0 },
1025 { C::instr_fetching_instr_out_of_range, 0 },
1026 { C::instr_fetching_tag_out_of_range, 0 },
1027 { C::instr_fetching_sel_parsing_err, 0 },
1028 { C::instr_fetching_sel_pc_in_range, 1 },
1032 { C::instr_fetching_bytecode_size, 20 },
1033 { C::instr_fetching_pc, 5 },
1034 { C::instr_fetching_pc_abs_diff, 14 },
1035 { C::instr_fetching_pc_size_in_bits, 32 },
1037 { C::instr_fetching_bytes_to_read, 15 },
1038 { C::instr_fetching_instr_size, 10 },
1039 { C::instr_fetching_instr_abs_diff, 5 },
1044 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