From 38cb2e9f3041a21077613209fe2c14d9296d67b4 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Fri, 7 Mar 2025 17:37:27 +0000 Subject: [PATCH 01/25] Instr fetching error handling wip --- barretenberg/cpp/pil/vm2/instr_fetching.pil | 98 ++++++- barretenberg/cpp/pil/vm2/precomputed.pil | 9 +- .../relations/instr_fetching.test.cpp | 47 ++-- .../barretenberg/vm2/generated/columns.hpp | 18 +- .../src/barretenberg/vm2/generated/flavor.hpp | 11 +- .../generated/relations/instr_fetching.hpp | 158 ++++++++--- .../relations/lookups_instr_fetching.hpp | 240 +++++++++++------ .../vm2/simulation/events/bytecode_events.hpp | 8 + .../vm2/tracegen/bytecode_trace.cpp | 246 +++++++++++------- .../vm2/tracegen/bytecode_trace.test.cpp | 12 +- .../vm2/tracegen/precomputed_trace.cpp | 22 +- .../src/barretenberg/vm2/tracegen_helper.cpp | 12 +- 12 files changed, 622 insertions(+), 259 deletions(-) diff --git a/barretenberg/cpp/pil/vm2/instr_fetching.pil b/barretenberg/cpp/pil/vm2/instr_fetching.pil index f7844dc34fde..401402c86580 100644 --- a/barretenberg/cpp/pil/vm2/instr_fetching.pil +++ b/barretenberg/cpp/pil/vm2/instr_fetching.pil @@ -11,8 +11,66 @@ sel * (1 - sel) = 0; pol commit pc; pol commit bytecode_id; -// TODO: How do we handle parsing errors? -// pol commit parsing_err; + +// pc out-of-range error boolean +pol commit pc_out_of_range; +pc_out_of_range * (1 - pc_out_of_range) = 0; + +// Instruction out-of-range error boolean (happens iff instr_size > bytes_to_read) +pol commit instr_out_of_range; +instr_out_of_range * (1 - instr_out_of_range) = 0; + +// opcode is out-of-range error boolean +pol commit opcode_out_of_range; // copied from precomputed.pil + +// If any error occurs, we toggle the following boolean: +pol commit parsing_err; +parsing_err = 1 - (1 - pc_out_of_range) * (1 - instr_out_of_range) * (1 - opcode_out_of_range); +// parsing_err is a boolean by definition (followed from above formula) + +// If the current row is not active, then there are no more active rows after that. +// (not enforced for the first row) +// Gives guarantee that the active trace must start just after the first row (clk == 0) +// and from there it is contiguous. +#[TRACE_CONTINUITY] +(1 - precomputed.first_row) * (1 - sel) * sel' = 0; + +// Last row of a given bytecode portion (i.e., pertaining to a given bytecode_id) +pol commit last_of_bytecode; +last_of_bytecode * (1 - last_of_bytecode) = 0; + +// last_of_bytecode is toggled iff BC_ID_DIFF != 0 +// Standard non-zero inequality involving helper inverse column +pol BC_ID_DIFF = bytecode_id' - bytecode_id; +pol commit bc_id_diff_inv; +sel * (BC_ID_DIFF * ((1 - last_of_bytecode) * (1 - bc_id_diff_inv) + bc_id_diff_inv) - last_of_bytecode) = 0; + +// Note that last_of_bytecode might not be toggled at the last active row. + +// If last_of_bytecode OR precomputed.first_row then next row has pc == 0 +#[PC_IS_ZERO_IN_BYTECODE_FIRST_ROW] +(last_of_bytecode + precomputed.first_row) * pc' = 0; + +// Retrieved from bc_decomposition.pil +pol commit bytes_remaining; +pol commit bytes_to_read; + +pol commit bytecode_size; +(last_of_bytecode + precomputed.first_row) * (bytecode_size' - bytes_remaining') = 0; + +#[SAME_BYTECODE_SIZE] +sel * (1 - last_of_bytecode) * (bytecode_size - bytecode_size') = 0; + +// Absolute difference variant where we compute: +// bytes_to_read - instr_size if instr_size <= bytes_to_read +// instr_size - bytes_to_read - 1 if instr_size > bytes_to_read +pol commit abs_diff; + +// From the following relation, we have: abs_diff >= 0 ==> [instr_size > bytes_to_read <==> instr_out_of_range == 1] +abs_diff = (2 * instr_out_of_range - 1) * (instr_size - bytes_to_read) - instr_out_of_range; + +#[ABS_DIFF_POSITIVE] +sel {abs_diff} in precomputed.sel_range_8 {precomputed.clk}; // bytecode[pc] to bytecode[pc + 36] pol commit bd0, bd1, bd2, bd3, bd4, @@ -24,19 +82,18 @@ pol commit bd0, bd1, bd2, bd3, bd4, bd31, bd32, bd33, bd34, bd35, bd36; -pol commit indirect; -// Operands. -pol commit op1, op2, op3, op4, op5, op6, op7; -// Wire to execution opcodes translation. -pol commit exec_opcode; - -pol commit instr_size_in_bytes; +// selector for lookup to bc_decomposition.pil +pol commit sel_lookup_bc_decomposition; +// Toggled except when pc is out of range. +sel_lookup_bc_decomposition = sel * (1 - pc_out_of_range); // Bring in the bytes from the bytecode columns. #[BYTES_FROM_BC_DEC] -sel { +sel_lookup_bc_decomposition { pc, bytecode_id, + bytes_remaining, + bytes_to_read, bd0, bd1, bd2, bd3, bd4, bd5, bd6, bd7, bd8, bd9, bd10, bd11, bd12, bd13, bd14, @@ -49,6 +106,8 @@ sel { bc_decomposition.sel { bc_decomposition.pc, bc_decomposition.id, + bc_decomposition.bytes_remaining, + bc_decomposition.bytes_to_read, bc_decomposition.bytes, bc_decomposition.bytes_pc_plus_1, bc_decomposition.bytes_pc_plus_2, bc_decomposition.bytes_pc_plus_3, bc_decomposition.bytes_pc_plus_4, bc_decomposition.bytes_pc_plus_5, bc_decomposition.bytes_pc_plus_6, bc_decomposition.bytes_pc_plus_7, bc_decomposition.bytes_pc_plus_8, bc_decomposition.bytes_pc_plus_9, bc_decomposition.bytes_pc_plus_10, bc_decomposition.bytes_pc_plus_11, bc_decomposition.bytes_pc_plus_12, bc_decomposition.bytes_pc_plus_13, bc_decomposition.bytes_pc_plus_14, @@ -59,6 +118,12 @@ bc_decomposition.sel { bc_decomposition.bytes_pc_plus_35, bc_decomposition.bytes_pc_plus_36 }; +// Wire to execution opcodes translation. +pol commit exec_opcode; + +// Instruction size in bytes +pol commit instr_size; + // Selectors for operands decomposition into bytes (copied from precomputed.pil) // This table is populated by a map generated by a cpp test in op_decomposition.test.cpp. pol commit sel_op_dc_0; @@ -83,18 +148,20 @@ pol commit sel_op_dc_17; #[WIRE_INSTRUCTION_INFO] sel { bd0, + opcode_out_of_range, exec_opcode, - instr_size_in_bytes, + instr_size, sel_op_dc_0, sel_op_dc_1, sel_op_dc_2, sel_op_dc_3, sel_op_dc_4, sel_op_dc_5, sel_op_dc_6, sel_op_dc_7, sel_op_dc_8, sel_op_dc_9, sel_op_dc_10, sel_op_dc_11, sel_op_dc_12, sel_op_dc_13, sel_op_dc_14, sel_op_dc_15, sel_op_dc_16, sel_op_dc_17 } in -precomputed.sel_range_wire_opcode { +precomputed.sel_range_8 { precomputed.clk, + precomputed.opcode_out_of_range, precomputed.exec_opcode, - precomputed.instr_size_in_bytes, + precomputed.instr_size, precomputed.sel_op_dc_0, precomputed.sel_op_dc_1, precomputed.sel_op_dc_2, precomputed.sel_op_dc_3, precomputed.sel_op_dc_4, precomputed.sel_op_dc_5, precomputed.sel_op_dc_6, precomputed.sel_op_dc_7, precomputed.sel_op_dc_8, precomputed.sel_op_dc_9, precomputed.sel_op_dc_10, precomputed.sel_op_dc_11, @@ -102,6 +169,11 @@ precomputed.sel_range_wire_opcode { precomputed.sel_op_dc_16, precomputed.sel_op_dc_17 }; +pol commit indirect; + +// Operands. +pol commit op1, op2, op3, op4, op5, op6, op7; + // The following relations decomposing operands (indirect, op1, ...) into bytes were code-generated by // a cpp test in op_decomposition.test.cpp. // Remark: Upper-casing the alias needs to be edited manually (not code-generated)! diff --git a/barretenberg/cpp/pil/vm2/precomputed.pil b/barretenberg/cpp/pil/vm2/precomputed.pil index 1876db3cf825..cb925d2a7818 100644 --- a/barretenberg/cpp/pil/vm2/precomputed.pil +++ b/barretenberg/cpp/pil/vm2/precomputed.pil @@ -75,12 +75,11 @@ pol constant sel_op_dc_16; pol constant sel_op_dc_17; pol constant exec_opcode; -pol constant instr_size_in_bytes; +pol constant instr_size; // Instruction size in bytes -// Toggle the rows which index (clk) is equal to a wire opcode -// Is used to lookup into the wire instruction spec table which contains the operand decomposition -// selectors as well as exec_opcode -pol constant sel_range_wire_opcode; +// Toggled at rows whose clk interpreted as a byte does not correspond to a valid wire opcode +// Toggled only up to clk = 255. (within range specified by sel_range_8) +pol constant opcode_out_of_range; // Used for getting the number of safe limbs for a given radix. // The selector is on for 1 < clk <= 256 diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp index 1a69d21a6068..7275487942ee 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp @@ -42,6 +42,8 @@ TEST(InstrFetchingConstrainingTest, Add8WithTraceGen) { TestTraceContainer trace; BytecodeTraceBuilder builder; + PrecomputedTraceBuilder precomputed_builder; + Instruction add_8_instruction = { .opcode = WireOpCode::ADD_8, .indirect = 3, @@ -55,8 +57,9 @@ TEST(InstrFetchingConstrainingTest, Add8WithTraceGen) .instruction = add_8_instruction, .bytecode = std::make_shared>(bytecode) } }, trace); + precomputed_builder.process_misc(trace, trace.get_num_rows()); // Limit to the number of rows we need. - EXPECT_EQ(trace.get_num_rows(), 1); + EXPECT_EQ(trace.get_num_rows(), 2); check_relation(trace); } @@ -66,6 +69,8 @@ TEST(InstrFetchingConstrainingTest, EcaddWithTraceGen) { TestTraceContainer trace; BytecodeTraceBuilder builder; + PrecomputedTraceBuilder precomputed_builder; + Instruction ecadd_instruction = { .opcode = WireOpCode::ECADD, .indirect = 0x1f1f, @@ -84,8 +89,9 @@ TEST(InstrFetchingConstrainingTest, EcaddWithTraceGen) .instruction = ecadd_instruction, .bytecode = std::make_shared>(bytecode) } }, trace); + precomputed_builder.process_misc(trace, trace.get_num_rows()); // Limit to the number of rows we need. - EXPECT_EQ(trace.get_num_rows(), 1); + EXPECT_EQ(trace.get_num_rows(), 2); check_relation(trace); } @@ -127,11 +133,13 @@ TEST(InstrFetchingConstrainingTest, EachOpcodeWithTraceGen) { TestTraceContainer trace; BytecodeTraceBuilder builder; + PrecomputedTraceBuilder precomputed_builder; builder.process_instruction_fetching(gen_instr_events_each_opcode(), trace); + precomputed_builder.process_misc(trace, trace.get_num_rows()); // Limit to the number of rows we need. constexpr auto num_opcodes = static_cast(WireOpCode::LAST_OPCODE_SENTINEL); - EXPECT_EQ(trace.get_num_rows(), num_opcodes); + EXPECT_EQ(trace.get_num_rows(), num_opcodes + 1); check_relation(trace); } @@ -141,6 +149,7 @@ TEST(InstrFetchingConstrainingTest, EachOpcodeWithTraceGen) TEST(InstrFetchingConstrainingTest, NegativeWrongOperand) { BytecodeTraceBuilder builder; + PrecomputedTraceBuilder precomputed_builder; std::vector opcodes = { WireOpCode::REVERT_16, WireOpCode::CAST_8, WireOpCode::TORADIXBE }; std::vector sub_relations = { @@ -164,9 +173,11 @@ TEST(InstrFetchingConstrainingTest, NegativeWrongOperand) .instruction = instr, .bytecode = std::make_shared>(instr.serialize()) } }, trace); + precomputed_builder.process_misc(trace, trace.get_num_rows()); // Limit to the number of rows we need. + check_relation(trace); - EXPECT_EQ(trace.get_num_rows(), 1); + EXPECT_EQ(trace.get_num_rows(), 2); for (size_t i = 0; i < operand_cols.size(); i++) { auto mutated_trace = trace; @@ -187,9 +198,10 @@ TEST(InstrFetchingConstrainingTest, WireInstructionSpecInteractions) TestTraceContainer trace; BytecodeTraceBuilder bytecode_builder; - PrecomputedTraceBuilder precomputed_builder; + precomputed_builder.process_wire_instruction_spec(trace); + precomputed_builder.process_sel_range_8(trace); bytecode_builder.process_instruction_fetching(gen_instr_events_each_opcode(), trace); precomputed_builder.process_misc(trace, trace.get_num_rows()); // Limit to the number of rows we need. @@ -208,6 +220,7 @@ TEST(InstrFetchingConstrainingTest, BcDecompositionInteractions) TestTraceContainer trace; BytecodeTraceBuilder bytecode_builder; + PrecomputedTraceBuilder precomputed_builder; const auto instr_fetch_events = gen_instr_events_each_opcode(); bytecode_builder.process_instruction_fetching(instr_fetch_events, trace); @@ -216,8 +229,9 @@ TEST(InstrFetchingConstrainingTest, BcDecompositionInteractions) .bytecode = instr_fetch_events.at(0).bytecode, } }, trace); + precomputed_builder.process_misc(trace, trace.get_num_rows()); // Limit to the number of rows we need. - tracegen::LookupIntoDynamicTableSequential().process(trace); + tracegen::LookupIntoDynamicTableGeneric().process(trace); check_relation(trace); check_interaction(trace); @@ -246,6 +260,7 @@ TEST(InstrFetchingConstrainingTest, NegativeWrongWireInstructionSpecInteractions .bytecode = std::make_shared>(instr.serialize()) } }, trace); precomputed_builder.process_wire_instruction_spec(trace); + precomputed_builder.process_sel_range_8(trace); precomputed_builder.process_misc(trace, trace.get_num_rows()); // Limit to the number of rows we need. LookupIntoIndexedByClk().process(trace); @@ -254,20 +269,20 @@ TEST(InstrFetchingConstrainingTest, NegativeWrongWireInstructionSpecInteractions check_interaction(trace); constexpr std::array mutated_cols = { - C::instr_fetching_exec_opcode, C::instr_fetching_instr_size_in_bytes, C::instr_fetching_sel_op_dc_0, - C::instr_fetching_sel_op_dc_1, C::instr_fetching_sel_op_dc_2, C::instr_fetching_sel_op_dc_3, - C::instr_fetching_sel_op_dc_4, C::instr_fetching_sel_op_dc_5, C::instr_fetching_sel_op_dc_6, - C::instr_fetching_sel_op_dc_7, C::instr_fetching_sel_op_dc_8, C::instr_fetching_sel_op_dc_9, - C::instr_fetching_sel_op_dc_10, C::instr_fetching_sel_op_dc_11, C::instr_fetching_sel_op_dc_12, - C::instr_fetching_sel_op_dc_13, C::instr_fetching_sel_op_dc_14, C::instr_fetching_sel_op_dc_15, + C::instr_fetching_exec_opcode, C::instr_fetching_instr_size, C::instr_fetching_sel_op_dc_0, + C::instr_fetching_sel_op_dc_1, C::instr_fetching_sel_op_dc_2, C::instr_fetching_sel_op_dc_3, + C::instr_fetching_sel_op_dc_4, C::instr_fetching_sel_op_dc_5, C::instr_fetching_sel_op_dc_6, + C::instr_fetching_sel_op_dc_7, C::instr_fetching_sel_op_dc_8, C::instr_fetching_sel_op_dc_9, + C::instr_fetching_sel_op_dc_10, C::instr_fetching_sel_op_dc_11, C::instr_fetching_sel_op_dc_12, + C::instr_fetching_sel_op_dc_13, C::instr_fetching_sel_op_dc_14, C::instr_fetching_sel_op_dc_15, C::instr_fetching_sel_op_dc_16, C::instr_fetching_sel_op_dc_17, }; // Mutate execution opcode for (const auto& col : mutated_cols) { auto mutated_trace = trace; - const FF mutated_value = trace.get(col, 0) + 1; // Mutate to value + 1 - mutated_trace.set(col, 0, mutated_value); + const FF mutated_value = trace.get(col, 1) + 1; // Mutate to value + 1 + mutated_trace.set(col, 1, mutated_value); // We do not need to re-run LookupIntoIndexedByClk().process(trace); // because we never mutate the indexing column for this lookup (clk) and for this lookup @@ -329,8 +344,8 @@ TEST(InstrFetchingConstrainingTest, NegativeWrongBcDecompositionInteractions) // Mutate execution opcode for (const auto& col : mutated_cols) { auto mutated_trace = trace; - const FF mutated_value = trace.get(col, 0) + 1; // Mutate to value + 1 - mutated_trace.set(col, 0, mutated_value); + const FF mutated_value = trace.get(col, 1) + 1; // Mutate to value + 1 + mutated_trace.set(col, 1, mutated_value); // This sets the length of the inverse polynomial via SetDummyInverses, so we still need to call this even // though we know it will fail. diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp index 6627a3a833d2..9ae61bc243ce 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp @@ -9,17 +9,17 @@ namespace bb::avm2 { // The entities that will be used in the flavor. // clang-format off -#define AVM2_PRECOMPUTED_ENTITIES precomputed_as_unary, precomputed_bitwise_input_a, precomputed_bitwise_input_b, precomputed_bitwise_op_id, precomputed_bitwise_output, precomputed_clk, precomputed_exec_opcode, precomputed_first_row, precomputed_instr_size_in_bytes, precomputed_integral_tag_length, precomputed_p_decomposition_limb, precomputed_p_decomposition_limb_index, precomputed_p_decomposition_radix, precomputed_power_of_2, precomputed_sel_bitwise, precomputed_sel_integral_tag, precomputed_sel_op_dc_0, precomputed_sel_op_dc_1, precomputed_sel_op_dc_10, precomputed_sel_op_dc_11, precomputed_sel_op_dc_12, precomputed_sel_op_dc_13, precomputed_sel_op_dc_14, precomputed_sel_op_dc_15, precomputed_sel_op_dc_16, precomputed_sel_op_dc_17, precomputed_sel_op_dc_2, precomputed_sel_op_dc_3, precomputed_sel_op_dc_4, precomputed_sel_op_dc_5, precomputed_sel_op_dc_6, precomputed_sel_op_dc_7, precomputed_sel_op_dc_8, precomputed_sel_op_dc_9, precomputed_sel_p_decomposition, precomputed_sel_range_16, precomputed_sel_range_8, precomputed_sel_range_wire_opcode, precomputed_sel_sha256_compression, precomputed_sel_to_radix_safe_limbs, precomputed_sel_unary, precomputed_sha256_compression_round_constant, precomputed_to_radix_safe_limbs, precomputed_zero -#define AVM2_WIRE_ENTITIES execution_input, address_derivation_address, address_derivation_address_y, address_derivation_class_id, address_derivation_deployer_addr, address_derivation_g1_x, address_derivation_g1_y, address_derivation_incoming_viewing_key_x, address_derivation_incoming_viewing_key_y, address_derivation_init_hash, address_derivation_nullifier_key_x, address_derivation_nullifier_key_y, address_derivation_outgoing_viewing_key_x, address_derivation_outgoing_viewing_key_y, address_derivation_partial_address, address_derivation_partial_address_domain_separator, address_derivation_preaddress, address_derivation_preaddress_domain_separator, address_derivation_preaddress_public_key_x, address_derivation_preaddress_public_key_y, address_derivation_public_keys_hash, address_derivation_public_keys_hash_domain_separator, address_derivation_salt, address_derivation_salted_init_hash, address_derivation_sel, address_derivation_tagging_key_x, address_derivation_tagging_key_y, alu_dst_addr, alu_ia, alu_ia_addr, alu_ib, alu_ib_addr, alu_ic, alu_op, alu_sel_op_add, bc_decomposition_abs_diff, bc_decomposition_bytes, bc_decomposition_bytes_pc_plus_1, bc_decomposition_bytes_pc_plus_10, bc_decomposition_bytes_pc_plus_11, bc_decomposition_bytes_pc_plus_12, bc_decomposition_bytes_pc_plus_13, bc_decomposition_bytes_pc_plus_14, bc_decomposition_bytes_pc_plus_15, bc_decomposition_bytes_pc_plus_16, bc_decomposition_bytes_pc_plus_17, bc_decomposition_bytes_pc_plus_18, bc_decomposition_bytes_pc_plus_19, bc_decomposition_bytes_pc_plus_2, bc_decomposition_bytes_pc_plus_20, bc_decomposition_bytes_pc_plus_21, bc_decomposition_bytes_pc_plus_22, bc_decomposition_bytes_pc_plus_23, bc_decomposition_bytes_pc_plus_24, bc_decomposition_bytes_pc_plus_25, bc_decomposition_bytes_pc_plus_26, bc_decomposition_bytes_pc_plus_27, bc_decomposition_bytes_pc_plus_28, bc_decomposition_bytes_pc_plus_29, bc_decomposition_bytes_pc_plus_3, bc_decomposition_bytes_pc_plus_30, bc_decomposition_bytes_pc_plus_31, bc_decomposition_bytes_pc_plus_32, bc_decomposition_bytes_pc_plus_33, bc_decomposition_bytes_pc_plus_34, bc_decomposition_bytes_pc_plus_35, bc_decomposition_bytes_pc_plus_36, bc_decomposition_bytes_pc_plus_4, bc_decomposition_bytes_pc_plus_5, bc_decomposition_bytes_pc_plus_6, bc_decomposition_bytes_pc_plus_7, bc_decomposition_bytes_pc_plus_8, bc_decomposition_bytes_pc_plus_9, bc_decomposition_bytes_rem_inv, bc_decomposition_bytes_rem_min_one_inv, bc_decomposition_bytes_remaining, bc_decomposition_bytes_to_read, bc_decomposition_bytes_to_read_unary, bc_decomposition_id, bc_decomposition_last_of_contract, bc_decomposition_packed_field, bc_decomposition_pc, bc_decomposition_sel, bc_decomposition_sel_overflow_correction_needed, bc_decomposition_sel_packed, bc_decomposition_sel_pc_plus_1, bc_decomposition_sel_pc_plus_10, bc_decomposition_sel_pc_plus_11, bc_decomposition_sel_pc_plus_12, bc_decomposition_sel_pc_plus_13, bc_decomposition_sel_pc_plus_14, bc_decomposition_sel_pc_plus_15, bc_decomposition_sel_pc_plus_16, bc_decomposition_sel_pc_plus_17, bc_decomposition_sel_pc_plus_18, bc_decomposition_sel_pc_plus_19, bc_decomposition_sel_pc_plus_2, bc_decomposition_sel_pc_plus_20, bc_decomposition_sel_pc_plus_21, bc_decomposition_sel_pc_plus_22, bc_decomposition_sel_pc_plus_23, bc_decomposition_sel_pc_plus_24, bc_decomposition_sel_pc_plus_25, bc_decomposition_sel_pc_plus_26, bc_decomposition_sel_pc_plus_27, bc_decomposition_sel_pc_plus_28, bc_decomposition_sel_pc_plus_29, bc_decomposition_sel_pc_plus_3, bc_decomposition_sel_pc_plus_30, bc_decomposition_sel_pc_plus_31, bc_decomposition_sel_pc_plus_32, bc_decomposition_sel_pc_plus_33, bc_decomposition_sel_pc_plus_34, bc_decomposition_sel_pc_plus_35, bc_decomposition_sel_pc_plus_36, bc_decomposition_sel_pc_plus_4, bc_decomposition_sel_pc_plus_5, bc_decomposition_sel_pc_plus_6, bc_decomposition_sel_pc_plus_7, bc_decomposition_sel_pc_plus_8, bc_decomposition_sel_pc_plus_9, bc_hashing_bytecode_id, bc_hashing_incremental_hash, bc_hashing_latch, bc_hashing_output_hash, bc_hashing_packed_field, bc_hashing_pc_index, bc_hashing_sel, bc_hashing_start, bc_retrieval_address, bc_retrieval_artifact_hash, bc_retrieval_bytecode_id, bc_retrieval_class_id, bc_retrieval_deployer_addr, bc_retrieval_err, bc_retrieval_incoming_viewing_key_x, bc_retrieval_incoming_viewing_key_y, bc_retrieval_init_hash, bc_retrieval_nullifier_key_x, bc_retrieval_nullifier_key_y, bc_retrieval_outgoing_viewing_key_x, bc_retrieval_outgoing_viewing_key_y, bc_retrieval_private_function_root, bc_retrieval_public_bytecode_commitment, bc_retrieval_salt, bc_retrieval_sel, bc_retrieval_siloed_address, bc_retrieval_tagging_key_x, bc_retrieval_tagging_key_y, bitwise_acc_ia, bitwise_acc_ib, bitwise_acc_ic, bitwise_ctr, bitwise_ctr_inv, bitwise_ctr_min_one_inv, bitwise_ia_byte, bitwise_ib_byte, bitwise_ic_byte, bitwise_last, bitwise_op_id, bitwise_sel, bitwise_start, bitwise_tag, class_id_derivation_artifact_hash, class_id_derivation_class_id, class_id_derivation_private_function_root, class_id_derivation_public_bytecode_commitment, class_id_derivation_sel, class_id_derivation_temp_constant_for_lookup, ecc_add_op, ecc_double_op, ecc_inv_2_p_y, ecc_inv_x_diff, ecc_inv_y_diff, ecc_lambda, ecc_p_is_inf, ecc_p_x, ecc_p_y, ecc_q_is_inf, ecc_q_x, ecc_q_y, ecc_r_is_inf, ecc_r_x, ecc_r_y, ecc_result_infinity, ecc_sel, ecc_x_match, ecc_y_match, execution_addressing_error_idx, execution_addressing_error_kind, execution_base_address_tag, execution_base_address_val, execution_bytecode_id, execution_clk, execution_ex_opcode, execution_indirect, execution_last, execution_op1, execution_op1_after_relative, execution_op2, execution_op2_after_relative, execution_op3, execution_op3_after_relative, execution_op4, execution_op4_after_relative, execution_pc, execution_rop1, execution_rop2, execution_rop3, execution_rop4, execution_sel, execution_sel_addressing_error, execution_sel_op1_is_address, execution_sel_op2_is_address, execution_sel_op3_is_address, execution_sel_op4_is_address, instr_fetching_bd0, instr_fetching_bd1, instr_fetching_bd10, instr_fetching_bd11, instr_fetching_bd12, instr_fetching_bd13, instr_fetching_bd14, instr_fetching_bd15, instr_fetching_bd16, instr_fetching_bd17, instr_fetching_bd18, instr_fetching_bd19, instr_fetching_bd2, instr_fetching_bd20, instr_fetching_bd21, instr_fetching_bd22, instr_fetching_bd23, instr_fetching_bd24, instr_fetching_bd25, instr_fetching_bd26, instr_fetching_bd27, instr_fetching_bd28, instr_fetching_bd29, instr_fetching_bd3, instr_fetching_bd30, instr_fetching_bd31, instr_fetching_bd32, instr_fetching_bd33, instr_fetching_bd34, instr_fetching_bd35, instr_fetching_bd36, instr_fetching_bd4, instr_fetching_bd5, instr_fetching_bd6, instr_fetching_bd7, instr_fetching_bd8, instr_fetching_bd9, instr_fetching_bytecode_id, instr_fetching_exec_opcode, instr_fetching_indirect, instr_fetching_instr_size_in_bytes, instr_fetching_op1, instr_fetching_op2, instr_fetching_op3, instr_fetching_op4, instr_fetching_op5, instr_fetching_op6, instr_fetching_op7, instr_fetching_pc, instr_fetching_sel, instr_fetching_sel_op_dc_0, instr_fetching_sel_op_dc_1, instr_fetching_sel_op_dc_10, instr_fetching_sel_op_dc_11, instr_fetching_sel_op_dc_12, instr_fetching_sel_op_dc_13, instr_fetching_sel_op_dc_14, instr_fetching_sel_op_dc_15, instr_fetching_sel_op_dc_16, instr_fetching_sel_op_dc_17, instr_fetching_sel_op_dc_2, instr_fetching_sel_op_dc_3, instr_fetching_sel_op_dc_4, instr_fetching_sel_op_dc_5, instr_fetching_sel_op_dc_6, instr_fetching_sel_op_dc_7, instr_fetching_sel_op_dc_8, instr_fetching_sel_op_dc_9, poseidon2_hash_a_0, poseidon2_hash_a_1, poseidon2_hash_a_2, poseidon2_hash_a_3, poseidon2_hash_b_0, poseidon2_hash_b_1, poseidon2_hash_b_2, poseidon2_hash_b_3, poseidon2_hash_end, poseidon2_hash_input_0, poseidon2_hash_input_1, poseidon2_hash_input_2, poseidon2_hash_input_len, poseidon2_hash_num_perm_rounds_rem, poseidon2_hash_num_perm_rounds_rem_inv, poseidon2_hash_output, poseidon2_hash_padding, poseidon2_hash_sel, poseidon2_hash_start, poseidon2_perm_B_10_0, poseidon2_perm_B_10_1, poseidon2_perm_B_10_2, poseidon2_perm_B_10_3, poseidon2_perm_B_11_0, poseidon2_perm_B_11_1, poseidon2_perm_B_11_2, poseidon2_perm_B_11_3, poseidon2_perm_B_12_0, poseidon2_perm_B_12_1, poseidon2_perm_B_12_2, poseidon2_perm_B_12_3, poseidon2_perm_B_13_0, poseidon2_perm_B_13_1, poseidon2_perm_B_13_2, poseidon2_perm_B_13_3, poseidon2_perm_B_14_0, poseidon2_perm_B_14_1, poseidon2_perm_B_14_2, poseidon2_perm_B_14_3, poseidon2_perm_B_15_0, poseidon2_perm_B_15_1, poseidon2_perm_B_15_2, poseidon2_perm_B_15_3, poseidon2_perm_B_16_0, poseidon2_perm_B_16_1, poseidon2_perm_B_16_2, poseidon2_perm_B_16_3, poseidon2_perm_B_17_0, poseidon2_perm_B_17_1, poseidon2_perm_B_17_2, poseidon2_perm_B_17_3, poseidon2_perm_B_18_0, poseidon2_perm_B_18_1, poseidon2_perm_B_18_2, poseidon2_perm_B_18_3, poseidon2_perm_B_19_0, poseidon2_perm_B_19_1, poseidon2_perm_B_19_2, poseidon2_perm_B_19_3, poseidon2_perm_B_20_0, poseidon2_perm_B_20_1, poseidon2_perm_B_20_2, poseidon2_perm_B_20_3, poseidon2_perm_B_21_0, poseidon2_perm_B_21_1, poseidon2_perm_B_21_2, poseidon2_perm_B_21_3, poseidon2_perm_B_22_0, poseidon2_perm_B_22_1, poseidon2_perm_B_22_2, poseidon2_perm_B_22_3, poseidon2_perm_B_23_0, poseidon2_perm_B_23_1, poseidon2_perm_B_23_2, poseidon2_perm_B_23_3, poseidon2_perm_B_24_0, poseidon2_perm_B_24_1, poseidon2_perm_B_24_2, poseidon2_perm_B_24_3, poseidon2_perm_B_25_0, poseidon2_perm_B_25_1, poseidon2_perm_B_25_2, poseidon2_perm_B_25_3, poseidon2_perm_B_26_0, poseidon2_perm_B_26_1, poseidon2_perm_B_26_2, poseidon2_perm_B_26_3, poseidon2_perm_B_27_0, poseidon2_perm_B_27_1, poseidon2_perm_B_27_2, poseidon2_perm_B_27_3, poseidon2_perm_B_28_0, poseidon2_perm_B_28_1, poseidon2_perm_B_28_2, poseidon2_perm_B_28_3, poseidon2_perm_B_29_0, poseidon2_perm_B_29_1, poseidon2_perm_B_29_2, poseidon2_perm_B_29_3, poseidon2_perm_B_30_0, poseidon2_perm_B_30_1, poseidon2_perm_B_30_2, poseidon2_perm_B_30_3, poseidon2_perm_B_31_0, poseidon2_perm_B_31_1, poseidon2_perm_B_31_2, poseidon2_perm_B_31_3, poseidon2_perm_B_32_0, poseidon2_perm_B_32_1, poseidon2_perm_B_32_2, poseidon2_perm_B_32_3, poseidon2_perm_B_33_0, poseidon2_perm_B_33_1, poseidon2_perm_B_33_2, poseidon2_perm_B_33_3, poseidon2_perm_B_34_0, poseidon2_perm_B_34_1, poseidon2_perm_B_34_2, poseidon2_perm_B_34_3, poseidon2_perm_B_35_0, poseidon2_perm_B_35_1, poseidon2_perm_B_35_2, poseidon2_perm_B_35_3, poseidon2_perm_B_36_0, poseidon2_perm_B_36_1, poseidon2_perm_B_36_2, poseidon2_perm_B_36_3, poseidon2_perm_B_37_0, poseidon2_perm_B_37_1, poseidon2_perm_B_37_2, poseidon2_perm_B_37_3, poseidon2_perm_B_38_0, poseidon2_perm_B_38_1, poseidon2_perm_B_38_2, poseidon2_perm_B_38_3, poseidon2_perm_B_39_0, poseidon2_perm_B_39_1, poseidon2_perm_B_39_2, poseidon2_perm_B_39_3, poseidon2_perm_B_40_0, poseidon2_perm_B_40_1, poseidon2_perm_B_40_2, poseidon2_perm_B_40_3, poseidon2_perm_B_41_0, poseidon2_perm_B_41_1, poseidon2_perm_B_41_2, poseidon2_perm_B_41_3, poseidon2_perm_B_42_0, poseidon2_perm_B_42_1, poseidon2_perm_B_42_2, poseidon2_perm_B_42_3, poseidon2_perm_B_43_0, poseidon2_perm_B_43_1, poseidon2_perm_B_43_2, poseidon2_perm_B_43_3, poseidon2_perm_B_44_0, poseidon2_perm_B_44_1, poseidon2_perm_B_44_2, poseidon2_perm_B_44_3, poseidon2_perm_B_45_0, poseidon2_perm_B_45_1, poseidon2_perm_B_45_2, poseidon2_perm_B_45_3, poseidon2_perm_B_46_0, poseidon2_perm_B_46_1, poseidon2_perm_B_46_2, poseidon2_perm_B_46_3, poseidon2_perm_B_47_0, poseidon2_perm_B_47_1, poseidon2_perm_B_47_2, poseidon2_perm_B_47_3, poseidon2_perm_B_48_0, poseidon2_perm_B_48_1, poseidon2_perm_B_48_2, poseidon2_perm_B_48_3, poseidon2_perm_B_49_0, poseidon2_perm_B_49_1, poseidon2_perm_B_49_2, poseidon2_perm_B_49_3, poseidon2_perm_B_4_0, poseidon2_perm_B_4_1, poseidon2_perm_B_4_2, poseidon2_perm_B_4_3, poseidon2_perm_B_50_0, poseidon2_perm_B_50_1, poseidon2_perm_B_50_2, poseidon2_perm_B_50_3, poseidon2_perm_B_51_0, poseidon2_perm_B_51_1, poseidon2_perm_B_51_2, poseidon2_perm_B_51_3, poseidon2_perm_B_52_0, poseidon2_perm_B_52_1, poseidon2_perm_B_52_2, poseidon2_perm_B_52_3, poseidon2_perm_B_53_0, poseidon2_perm_B_53_1, poseidon2_perm_B_53_2, poseidon2_perm_B_53_3, poseidon2_perm_B_54_0, poseidon2_perm_B_54_1, poseidon2_perm_B_54_2, poseidon2_perm_B_54_3, poseidon2_perm_B_55_0, poseidon2_perm_B_55_1, poseidon2_perm_B_55_2, poseidon2_perm_B_55_3, poseidon2_perm_B_56_0, poseidon2_perm_B_56_1, poseidon2_perm_B_56_2, poseidon2_perm_B_56_3, poseidon2_perm_B_57_0, poseidon2_perm_B_57_1, poseidon2_perm_B_57_2, poseidon2_perm_B_57_3, poseidon2_perm_B_58_0, poseidon2_perm_B_58_1, poseidon2_perm_B_58_2, poseidon2_perm_B_58_3, poseidon2_perm_B_59_0, poseidon2_perm_B_59_1, poseidon2_perm_B_59_2, poseidon2_perm_B_59_3, poseidon2_perm_B_5_0, poseidon2_perm_B_5_1, poseidon2_perm_B_5_2, poseidon2_perm_B_5_3, poseidon2_perm_B_6_0, poseidon2_perm_B_6_1, poseidon2_perm_B_6_2, poseidon2_perm_B_6_3, poseidon2_perm_B_7_0, poseidon2_perm_B_7_1, poseidon2_perm_B_7_2, poseidon2_perm_B_7_3, poseidon2_perm_B_8_0, poseidon2_perm_B_8_1, poseidon2_perm_B_8_2, poseidon2_perm_B_8_3, poseidon2_perm_B_9_0, poseidon2_perm_B_9_1, poseidon2_perm_B_9_2, poseidon2_perm_B_9_3, poseidon2_perm_EXT_LAYER_4, poseidon2_perm_EXT_LAYER_5, poseidon2_perm_EXT_LAYER_6, poseidon2_perm_EXT_LAYER_7, poseidon2_perm_T_0_4, poseidon2_perm_T_0_5, poseidon2_perm_T_0_6, poseidon2_perm_T_0_7, poseidon2_perm_T_1_4, poseidon2_perm_T_1_5, poseidon2_perm_T_1_6, poseidon2_perm_T_1_7, poseidon2_perm_T_2_4, poseidon2_perm_T_2_5, poseidon2_perm_T_2_6, poseidon2_perm_T_2_7, poseidon2_perm_T_3_4, poseidon2_perm_T_3_5, poseidon2_perm_T_3_6, poseidon2_perm_T_3_7, poseidon2_perm_T_60_4, poseidon2_perm_T_60_5, poseidon2_perm_T_60_6, poseidon2_perm_T_60_7, poseidon2_perm_T_61_4, poseidon2_perm_T_61_5, poseidon2_perm_T_61_6, poseidon2_perm_T_61_7, poseidon2_perm_T_62_4, poseidon2_perm_T_62_5, poseidon2_perm_T_62_6, poseidon2_perm_T_62_7, poseidon2_perm_T_63_4, poseidon2_perm_T_63_5, poseidon2_perm_T_63_6, poseidon2_perm_T_63_7, poseidon2_perm_a_0, poseidon2_perm_a_1, poseidon2_perm_a_2, poseidon2_perm_a_3, poseidon2_perm_b_0, poseidon2_perm_b_1, poseidon2_perm_b_2, poseidon2_perm_b_3, poseidon2_perm_sel, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_rng_chk_bits, range_check_sel, range_check_sel_r0_16_bit_rng_lookup, range_check_sel_r1_16_bit_rng_lookup, range_check_sel_r2_16_bit_rng_lookup, range_check_sel_r3_16_bit_rng_lookup, range_check_sel_r4_16_bit_rng_lookup, range_check_sel_r5_16_bit_rng_lookup, range_check_sel_r6_16_bit_rng_lookup, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, scalar_mul_bit, scalar_mul_bit_idx, scalar_mul_bit_radix, scalar_mul_end, scalar_mul_not_end, scalar_mul_point_inf, scalar_mul_point_x, scalar_mul_point_y, scalar_mul_res_inf, scalar_mul_res_x, scalar_mul_res_y, scalar_mul_scalar, scalar_mul_sel, scalar_mul_should_add, scalar_mul_start, scalar_mul_temp_inf, scalar_mul_temp_x, scalar_mul_temp_y, sha256_a, sha256_a_and_b, sha256_a_and_b_xor_a_and_c, sha256_a_and_c, sha256_a_rotr_13, sha256_a_rotr_2, sha256_a_rotr_22, sha256_a_rotr_2_xor_a_rotr_13, sha256_and_sel, sha256_b, sha256_b_and_c, sha256_c, sha256_ch, sha256_clk, sha256_computed_w_lhs, sha256_computed_w_rhs, sha256_d, sha256_e, sha256_e_and_f, sha256_e_rotr_11, sha256_e_rotr_25, sha256_e_rotr_6, sha256_e_rotr_6_xor_e_rotr_11, sha256_f, sha256_g, sha256_h, sha256_helper_w0, sha256_helper_w1, sha256_helper_w10, sha256_helper_w11, sha256_helper_w12, sha256_helper_w13, sha256_helper_w14, sha256_helper_w15, sha256_helper_w2, sha256_helper_w3, sha256_helper_w4, sha256_helper_w5, sha256_helper_w6, sha256_helper_w7, sha256_helper_w8, sha256_helper_w9, sha256_init_a, sha256_init_b, sha256_init_c, sha256_init_d, sha256_init_e, sha256_init_f, sha256_init_g, sha256_init_h, sha256_input_offset, sha256_is_input_round, sha256_latch, sha256_lhs_a_13, sha256_lhs_a_2, sha256_lhs_a_22, sha256_lhs_e_11, sha256_lhs_e_25, sha256_lhs_e_6, sha256_lhs_w_10, sha256_lhs_w_17, sha256_lhs_w_18, sha256_lhs_w_19, sha256_lhs_w_3, sha256_lhs_w_7, sha256_maj, sha256_next_a_lhs, sha256_next_a_rhs, sha256_next_e_lhs, sha256_next_e_rhs, sha256_not_e, sha256_not_e_and_g, sha256_output_a_lhs, sha256_output_a_rhs, sha256_output_b_lhs, sha256_output_b_rhs, sha256_output_c_lhs, sha256_output_c_rhs, sha256_output_d_lhs, sha256_output_d_rhs, sha256_output_e_lhs, sha256_output_e_rhs, sha256_output_f_lhs, sha256_output_f_rhs, sha256_output_g_lhs, sha256_output_g_rhs, sha256_output_h_lhs, sha256_output_h_rhs, sha256_output_offset, sha256_perform_round, sha256_rhs_a_13, sha256_rhs_a_2, sha256_rhs_a_22, sha256_rhs_e_11, sha256_rhs_e_25, sha256_rhs_e_6, sha256_rhs_w_10, sha256_rhs_w_17, sha256_rhs_w_18, sha256_rhs_w_19, sha256_rhs_w_3, sha256_rhs_w_7, sha256_round_constant, sha256_round_count, sha256_rounds_remaining, sha256_rounds_remaining_inv, sha256_s_0, sha256_s_1, sha256_sel, sha256_start, sha256_state_offset, sha256_w, sha256_w_15_rotr_18, sha256_w_15_rotr_7, sha256_w_15_rotr_7_xor_w_15_rotr_18, sha256_w_15_rshift_3, sha256_w_2_rotr_17, sha256_w_2_rotr_17_xor_w_2_rotr_19, sha256_w_2_rotr_19, sha256_w_2_rshift_10, sha256_w_s_0, sha256_w_s_1, sha256_xor_sel, to_radix_acc, to_radix_acc_under_p, to_radix_end, to_radix_exponent, to_radix_found, to_radix_is_unsafe_limb, to_radix_limb, to_radix_limb_eq_p, to_radix_limb_index, to_radix_limb_lt_p, to_radix_limb_p_diff, to_radix_limb_radix_diff, to_radix_not_end, to_radix_not_padding_limb, to_radix_p_limb, to_radix_radix, to_radix_rem_inverse, to_radix_safe_limbs, to_radix_safety_diff_inverse, to_radix_sel, to_radix_start, to_radix_value, lookup_poseidon2_hash_poseidon2_perm_counts, lookup_range_check_dyn_rng_chk_pow_2_counts, lookup_range_check_dyn_diff_is_u16_counts, lookup_range_check_r0_is_u16_counts, lookup_range_check_r1_is_u16_counts, lookup_range_check_r2_is_u16_counts, lookup_range_check_r3_is_u16_counts, lookup_range_check_r4_is_u16_counts, lookup_range_check_r5_is_u16_counts, lookup_range_check_r6_is_u16_counts, lookup_range_check_r7_is_u16_counts, lookup_to_radix_limb_range_counts, lookup_to_radix_limb_less_than_radix_range_counts, lookup_to_radix_fetch_safe_limbs_counts, lookup_to_radix_fetch_p_limb_counts, lookup_to_radix_limb_p_diff_range_counts, lookup_scalar_mul_to_radix_counts, lookup_scalar_mul_double_counts, lookup_scalar_mul_add_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_0_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_1_counts, lookup_address_derivation_partial_address_poseidon2_counts, lookup_address_derivation_public_keys_hash_poseidon2_0_counts, lookup_address_derivation_public_keys_hash_poseidon2_1_counts, lookup_address_derivation_public_keys_hash_poseidon2_2_counts, lookup_address_derivation_public_keys_hash_poseidon2_3_counts, lookup_address_derivation_public_keys_hash_poseidon2_4_counts, lookup_address_derivation_preaddress_poseidon2_counts, lookup_address_derivation_preaddress_scalar_mul_counts, lookup_address_derivation_address_ecadd_counts, lookup_bc_decomposition_bytes_are_bytes_counts, lookup_bc_decomposition_abs_diff_is_u16_counts, lookup_bc_decomposition_bytes_to_read_as_unary_counts, lookup_bc_hashing_get_packed_field_counts, lookup_bc_hashing_iv_is_len_counts, lookup_bc_hashing_poseidon2_hash_counts, lookup_bc_retrieval_class_id_derivation_counts, lookup_bc_retrieval_bytecode_hash_is_correct_counts, lookup_instr_fetching_bytes_from_bc_dec_counts, lookup_instr_fetching_wire_instruction_info_counts, lookup_class_id_derivation_class_id_poseidon2_0_counts, lookup_class_id_derivation_class_id_poseidon2_1_counts, lookup_bitwise_integral_tag_length_counts, lookup_bitwise_byte_operations_counts, lookup_sha256_round_constant_counts -#define AVM2_DERIVED_WITNESS_ENTITIES lookup_poseidon2_hash_poseidon2_perm_inv, lookup_range_check_dyn_rng_chk_pow_2_inv, lookup_range_check_dyn_diff_is_u16_inv, lookup_range_check_r0_is_u16_inv, lookup_range_check_r1_is_u16_inv, lookup_range_check_r2_is_u16_inv, lookup_range_check_r3_is_u16_inv, lookup_range_check_r4_is_u16_inv, lookup_range_check_r5_is_u16_inv, lookup_range_check_r6_is_u16_inv, lookup_range_check_r7_is_u16_inv, lookup_to_radix_limb_range_inv, lookup_to_radix_limb_less_than_radix_range_inv, lookup_to_radix_fetch_safe_limbs_inv, lookup_to_radix_fetch_p_limb_inv, lookup_to_radix_limb_p_diff_range_inv, lookup_scalar_mul_to_radix_inv, lookup_scalar_mul_double_inv, lookup_scalar_mul_add_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_0_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_1_inv, lookup_address_derivation_partial_address_poseidon2_inv, lookup_address_derivation_public_keys_hash_poseidon2_0_inv, lookup_address_derivation_public_keys_hash_poseidon2_1_inv, lookup_address_derivation_public_keys_hash_poseidon2_2_inv, lookup_address_derivation_public_keys_hash_poseidon2_3_inv, lookup_address_derivation_public_keys_hash_poseidon2_4_inv, lookup_address_derivation_preaddress_poseidon2_inv, lookup_address_derivation_preaddress_scalar_mul_inv, lookup_address_derivation_address_ecadd_inv, lookup_bc_decomposition_bytes_are_bytes_inv, lookup_bc_decomposition_abs_diff_is_u16_inv, lookup_bc_decomposition_bytes_to_read_as_unary_inv, lookup_bc_hashing_get_packed_field_inv, lookup_bc_hashing_iv_is_len_inv, lookup_bc_hashing_poseidon2_hash_inv, lookup_bc_retrieval_class_id_derivation_inv, lookup_bc_retrieval_bytecode_hash_is_correct_inv, lookup_instr_fetching_bytes_from_bc_dec_inv, lookup_instr_fetching_wire_instruction_info_inv, lookup_class_id_derivation_class_id_poseidon2_0_inv, lookup_class_id_derivation_class_id_poseidon2_1_inv, lookup_bitwise_integral_tag_length_inv, lookup_bitwise_byte_operations_inv, lookup_sha256_round_constant_inv -#define AVM2_SHIFTED_ENTITIES bc_decomposition_bytes_shift, bc_decomposition_bytes_pc_plus_1_shift, bc_decomposition_bytes_pc_plus_10_shift, bc_decomposition_bytes_pc_plus_11_shift, bc_decomposition_bytes_pc_plus_12_shift, bc_decomposition_bytes_pc_plus_13_shift, bc_decomposition_bytes_pc_plus_14_shift, bc_decomposition_bytes_pc_plus_15_shift, bc_decomposition_bytes_pc_plus_16_shift, bc_decomposition_bytes_pc_plus_17_shift, bc_decomposition_bytes_pc_plus_18_shift, bc_decomposition_bytes_pc_plus_19_shift, bc_decomposition_bytes_pc_plus_2_shift, bc_decomposition_bytes_pc_plus_20_shift, bc_decomposition_bytes_pc_plus_21_shift, bc_decomposition_bytes_pc_plus_22_shift, bc_decomposition_bytes_pc_plus_23_shift, bc_decomposition_bytes_pc_plus_24_shift, bc_decomposition_bytes_pc_plus_25_shift, bc_decomposition_bytes_pc_plus_26_shift, bc_decomposition_bytes_pc_plus_27_shift, bc_decomposition_bytes_pc_plus_28_shift, bc_decomposition_bytes_pc_plus_29_shift, bc_decomposition_bytes_pc_plus_3_shift, bc_decomposition_bytes_pc_plus_30_shift, bc_decomposition_bytes_pc_plus_31_shift, bc_decomposition_bytes_pc_plus_32_shift, bc_decomposition_bytes_pc_plus_33_shift, bc_decomposition_bytes_pc_plus_34_shift, bc_decomposition_bytes_pc_plus_35_shift, bc_decomposition_bytes_pc_plus_4_shift, bc_decomposition_bytes_pc_plus_5_shift, bc_decomposition_bytes_pc_plus_6_shift, bc_decomposition_bytes_pc_plus_7_shift, bc_decomposition_bytes_pc_plus_8_shift, bc_decomposition_bytes_pc_plus_9_shift, bc_decomposition_bytes_remaining_shift, bc_decomposition_id_shift, bc_decomposition_pc_shift, bc_decomposition_sel_shift, bc_hashing_bytecode_id_shift, bc_hashing_incremental_hash_shift, bc_hashing_pc_index_shift, bc_hashing_sel_shift, bc_hashing_start_shift, bitwise_acc_ia_shift, bitwise_acc_ib_shift, bitwise_acc_ic_shift, bitwise_ctr_shift, bitwise_op_id_shift, execution_sel_shift, poseidon2_hash_a_0_shift, poseidon2_hash_a_1_shift, poseidon2_hash_a_2_shift, poseidon2_hash_a_3_shift, poseidon2_hash_input_0_shift, poseidon2_hash_input_1_shift, poseidon2_hash_input_2_shift, poseidon2_hash_num_perm_rounds_rem_shift, poseidon2_hash_output_shift, poseidon2_hash_sel_shift, poseidon2_hash_start_shift, scalar_mul_bit_idx_shift, scalar_mul_point_inf_shift, scalar_mul_point_x_shift, scalar_mul_point_y_shift, scalar_mul_res_inf_shift, scalar_mul_res_x_shift, scalar_mul_res_y_shift, scalar_mul_scalar_shift, scalar_mul_sel_shift, scalar_mul_start_shift, scalar_mul_temp_inf_shift, scalar_mul_temp_x_shift, scalar_mul_temp_y_shift, sha256_a_shift, sha256_b_shift, sha256_c_shift, sha256_d_shift, sha256_e_shift, sha256_f_shift, sha256_g_shift, sha256_h_shift, sha256_helper_w0_shift, sha256_helper_w1_shift, sha256_helper_w10_shift, sha256_helper_w11_shift, sha256_helper_w12_shift, sha256_helper_w13_shift, sha256_helper_w14_shift, sha256_helper_w15_shift, sha256_helper_w2_shift, sha256_helper_w3_shift, sha256_helper_w4_shift, sha256_helper_w5_shift, sha256_helper_w6_shift, sha256_helper_w7_shift, sha256_helper_w8_shift, sha256_helper_w9_shift, sha256_rounds_remaining_shift, sha256_sel_shift, sha256_start_shift, to_radix_acc_shift, to_radix_acc_under_p_shift, to_radix_exponent_shift, to_radix_limb_shift, to_radix_limb_eq_p_shift, to_radix_limb_index_shift, to_radix_limb_lt_p_shift, to_radix_not_padding_limb_shift, to_radix_radix_shift, to_radix_safe_limbs_shift, to_radix_sel_shift, to_radix_start_shift, to_radix_value_shift -#define AVM2_TO_BE_SHIFTED(e) e.bc_decomposition_bytes, e.bc_decomposition_bytes_pc_plus_1, e.bc_decomposition_bytes_pc_plus_10, e.bc_decomposition_bytes_pc_plus_11, e.bc_decomposition_bytes_pc_plus_12, e.bc_decomposition_bytes_pc_plus_13, e.bc_decomposition_bytes_pc_plus_14, e.bc_decomposition_bytes_pc_plus_15, e.bc_decomposition_bytes_pc_plus_16, e.bc_decomposition_bytes_pc_plus_17, e.bc_decomposition_bytes_pc_plus_18, e.bc_decomposition_bytes_pc_plus_19, e.bc_decomposition_bytes_pc_plus_2, e.bc_decomposition_bytes_pc_plus_20, e.bc_decomposition_bytes_pc_plus_21, e.bc_decomposition_bytes_pc_plus_22, e.bc_decomposition_bytes_pc_plus_23, e.bc_decomposition_bytes_pc_plus_24, e.bc_decomposition_bytes_pc_plus_25, e.bc_decomposition_bytes_pc_plus_26, e.bc_decomposition_bytes_pc_plus_27, e.bc_decomposition_bytes_pc_plus_28, e.bc_decomposition_bytes_pc_plus_29, e.bc_decomposition_bytes_pc_plus_3, e.bc_decomposition_bytes_pc_plus_30, e.bc_decomposition_bytes_pc_plus_31, e.bc_decomposition_bytes_pc_plus_32, e.bc_decomposition_bytes_pc_plus_33, e.bc_decomposition_bytes_pc_plus_34, e.bc_decomposition_bytes_pc_plus_35, e.bc_decomposition_bytes_pc_plus_4, e.bc_decomposition_bytes_pc_plus_5, e.bc_decomposition_bytes_pc_plus_6, e.bc_decomposition_bytes_pc_plus_7, e.bc_decomposition_bytes_pc_plus_8, e.bc_decomposition_bytes_pc_plus_9, e.bc_decomposition_bytes_remaining, e.bc_decomposition_id, e.bc_decomposition_pc, e.bc_decomposition_sel, e.bc_hashing_bytecode_id, e.bc_hashing_incremental_hash, e.bc_hashing_pc_index, e.bc_hashing_sel, e.bc_hashing_start, e.bitwise_acc_ia, e.bitwise_acc_ib, e.bitwise_acc_ic, e.bitwise_ctr, e.bitwise_op_id, e.execution_sel, e.poseidon2_hash_a_0, e.poseidon2_hash_a_1, e.poseidon2_hash_a_2, e.poseidon2_hash_a_3, e.poseidon2_hash_input_0, e.poseidon2_hash_input_1, e.poseidon2_hash_input_2, e.poseidon2_hash_num_perm_rounds_rem, e.poseidon2_hash_output, e.poseidon2_hash_sel, e.poseidon2_hash_start, e.scalar_mul_bit_idx, e.scalar_mul_point_inf, e.scalar_mul_point_x, e.scalar_mul_point_y, e.scalar_mul_res_inf, e.scalar_mul_res_x, e.scalar_mul_res_y, e.scalar_mul_scalar, e.scalar_mul_sel, e.scalar_mul_start, e.scalar_mul_temp_inf, e.scalar_mul_temp_x, e.scalar_mul_temp_y, e.sha256_a, e.sha256_b, e.sha256_c, e.sha256_d, e.sha256_e, e.sha256_f, e.sha256_g, e.sha256_h, e.sha256_helper_w0, e.sha256_helper_w1, e.sha256_helper_w10, e.sha256_helper_w11, e.sha256_helper_w12, e.sha256_helper_w13, e.sha256_helper_w14, e.sha256_helper_w15, e.sha256_helper_w2, e.sha256_helper_w3, e.sha256_helper_w4, e.sha256_helper_w5, e.sha256_helper_w6, e.sha256_helper_w7, e.sha256_helper_w8, e.sha256_helper_w9, e.sha256_rounds_remaining, e.sha256_sel, e.sha256_start, e.to_radix_acc, e.to_radix_acc_under_p, e.to_radix_exponent, e.to_radix_limb, e.to_radix_limb_eq_p, e.to_radix_limb_index, e.to_radix_limb_lt_p, e.to_radix_not_padding_limb, e.to_radix_radix, e.to_radix_safe_limbs, e.to_radix_sel, e.to_radix_start, e.to_radix_value +#define AVM2_PRECOMPUTED_ENTITIES precomputed_as_unary, precomputed_bitwise_input_a, precomputed_bitwise_input_b, precomputed_bitwise_op_id, precomputed_bitwise_output, precomputed_clk, precomputed_exec_opcode, precomputed_first_row, precomputed_instr_size, precomputed_integral_tag_length, precomputed_opcode_out_of_range, precomputed_p_decomposition_limb, precomputed_p_decomposition_limb_index, precomputed_p_decomposition_radix, precomputed_power_of_2, precomputed_sel_bitwise, precomputed_sel_integral_tag, precomputed_sel_op_dc_0, precomputed_sel_op_dc_1, precomputed_sel_op_dc_10, precomputed_sel_op_dc_11, precomputed_sel_op_dc_12, precomputed_sel_op_dc_13, precomputed_sel_op_dc_14, precomputed_sel_op_dc_15, precomputed_sel_op_dc_16, precomputed_sel_op_dc_17, precomputed_sel_op_dc_2, precomputed_sel_op_dc_3, precomputed_sel_op_dc_4, precomputed_sel_op_dc_5, precomputed_sel_op_dc_6, precomputed_sel_op_dc_7, precomputed_sel_op_dc_8, precomputed_sel_op_dc_9, precomputed_sel_p_decomposition, precomputed_sel_range_16, precomputed_sel_range_8, precomputed_sel_sha256_compression, precomputed_sel_to_radix_safe_limbs, precomputed_sel_unary, precomputed_sha256_compression_round_constant, precomputed_to_radix_safe_limbs, precomputed_zero +#define AVM2_WIRE_ENTITIES execution_input, address_derivation_address, address_derivation_address_y, address_derivation_class_id, address_derivation_deployer_addr, address_derivation_g1_x, address_derivation_g1_y, address_derivation_incoming_viewing_key_x, address_derivation_incoming_viewing_key_y, address_derivation_init_hash, address_derivation_nullifier_key_x, address_derivation_nullifier_key_y, address_derivation_outgoing_viewing_key_x, address_derivation_outgoing_viewing_key_y, address_derivation_partial_address, address_derivation_partial_address_domain_separator, address_derivation_preaddress, address_derivation_preaddress_domain_separator, address_derivation_preaddress_public_key_x, address_derivation_preaddress_public_key_y, address_derivation_public_keys_hash, address_derivation_public_keys_hash_domain_separator, address_derivation_salt, address_derivation_salted_init_hash, address_derivation_sel, address_derivation_tagging_key_x, address_derivation_tagging_key_y, alu_dst_addr, alu_ia, alu_ia_addr, alu_ib, alu_ib_addr, alu_ic, alu_op, alu_sel_op_add, bc_decomposition_abs_diff, bc_decomposition_bytes, bc_decomposition_bytes_pc_plus_1, bc_decomposition_bytes_pc_plus_10, bc_decomposition_bytes_pc_plus_11, bc_decomposition_bytes_pc_plus_12, bc_decomposition_bytes_pc_plus_13, bc_decomposition_bytes_pc_plus_14, bc_decomposition_bytes_pc_plus_15, bc_decomposition_bytes_pc_plus_16, bc_decomposition_bytes_pc_plus_17, bc_decomposition_bytes_pc_plus_18, bc_decomposition_bytes_pc_plus_19, bc_decomposition_bytes_pc_plus_2, bc_decomposition_bytes_pc_plus_20, bc_decomposition_bytes_pc_plus_21, bc_decomposition_bytes_pc_plus_22, bc_decomposition_bytes_pc_plus_23, bc_decomposition_bytes_pc_plus_24, bc_decomposition_bytes_pc_plus_25, bc_decomposition_bytes_pc_plus_26, bc_decomposition_bytes_pc_plus_27, bc_decomposition_bytes_pc_plus_28, bc_decomposition_bytes_pc_plus_29, bc_decomposition_bytes_pc_plus_3, bc_decomposition_bytes_pc_plus_30, bc_decomposition_bytes_pc_plus_31, bc_decomposition_bytes_pc_plus_32, bc_decomposition_bytes_pc_plus_33, bc_decomposition_bytes_pc_plus_34, bc_decomposition_bytes_pc_plus_35, bc_decomposition_bytes_pc_plus_36, bc_decomposition_bytes_pc_plus_4, bc_decomposition_bytes_pc_plus_5, bc_decomposition_bytes_pc_plus_6, bc_decomposition_bytes_pc_plus_7, bc_decomposition_bytes_pc_plus_8, bc_decomposition_bytes_pc_plus_9, bc_decomposition_bytes_rem_inv, bc_decomposition_bytes_rem_min_one_inv, bc_decomposition_bytes_remaining, bc_decomposition_bytes_to_read, bc_decomposition_bytes_to_read_unary, bc_decomposition_id, bc_decomposition_last_of_contract, bc_decomposition_packed_field, bc_decomposition_pc, bc_decomposition_sel, bc_decomposition_sel_overflow_correction_needed, bc_decomposition_sel_packed, bc_decomposition_sel_pc_plus_1, bc_decomposition_sel_pc_plus_10, bc_decomposition_sel_pc_plus_11, bc_decomposition_sel_pc_plus_12, bc_decomposition_sel_pc_plus_13, bc_decomposition_sel_pc_plus_14, bc_decomposition_sel_pc_plus_15, bc_decomposition_sel_pc_plus_16, bc_decomposition_sel_pc_plus_17, bc_decomposition_sel_pc_plus_18, bc_decomposition_sel_pc_plus_19, bc_decomposition_sel_pc_plus_2, bc_decomposition_sel_pc_plus_20, bc_decomposition_sel_pc_plus_21, bc_decomposition_sel_pc_plus_22, bc_decomposition_sel_pc_plus_23, bc_decomposition_sel_pc_plus_24, bc_decomposition_sel_pc_plus_25, bc_decomposition_sel_pc_plus_26, bc_decomposition_sel_pc_plus_27, bc_decomposition_sel_pc_plus_28, bc_decomposition_sel_pc_plus_29, bc_decomposition_sel_pc_plus_3, bc_decomposition_sel_pc_plus_30, bc_decomposition_sel_pc_plus_31, bc_decomposition_sel_pc_plus_32, bc_decomposition_sel_pc_plus_33, bc_decomposition_sel_pc_plus_34, bc_decomposition_sel_pc_plus_35, bc_decomposition_sel_pc_plus_36, bc_decomposition_sel_pc_plus_4, bc_decomposition_sel_pc_plus_5, bc_decomposition_sel_pc_plus_6, bc_decomposition_sel_pc_plus_7, bc_decomposition_sel_pc_plus_8, bc_decomposition_sel_pc_plus_9, bc_hashing_bytecode_id, bc_hashing_incremental_hash, bc_hashing_latch, bc_hashing_output_hash, bc_hashing_packed_field, bc_hashing_pc_index, bc_hashing_sel, bc_hashing_start, bc_retrieval_address, bc_retrieval_artifact_hash, bc_retrieval_bytecode_id, bc_retrieval_class_id, bc_retrieval_deployer_addr, bc_retrieval_err, bc_retrieval_incoming_viewing_key_x, bc_retrieval_incoming_viewing_key_y, bc_retrieval_init_hash, bc_retrieval_nullifier_key_x, bc_retrieval_nullifier_key_y, bc_retrieval_outgoing_viewing_key_x, bc_retrieval_outgoing_viewing_key_y, bc_retrieval_private_function_root, bc_retrieval_public_bytecode_commitment, bc_retrieval_salt, bc_retrieval_sel, bc_retrieval_siloed_address, bc_retrieval_tagging_key_x, bc_retrieval_tagging_key_y, bitwise_acc_ia, bitwise_acc_ib, bitwise_acc_ic, bitwise_ctr, bitwise_ctr_inv, bitwise_ctr_min_one_inv, bitwise_ia_byte, bitwise_ib_byte, bitwise_ic_byte, bitwise_last, bitwise_op_id, bitwise_sel, bitwise_start, bitwise_tag, class_id_derivation_artifact_hash, class_id_derivation_class_id, class_id_derivation_private_function_root, class_id_derivation_public_bytecode_commitment, class_id_derivation_sel, class_id_derivation_temp_constant_for_lookup, ecc_add_op, ecc_double_op, ecc_inv_2_p_y, ecc_inv_x_diff, ecc_inv_y_diff, ecc_lambda, ecc_p_is_inf, ecc_p_x, ecc_p_y, ecc_q_is_inf, ecc_q_x, ecc_q_y, ecc_r_is_inf, ecc_r_x, ecc_r_y, ecc_result_infinity, ecc_sel, ecc_x_match, ecc_y_match, execution_addressing_error_idx, execution_addressing_error_kind, execution_base_address_tag, execution_base_address_val, execution_bytecode_id, execution_clk, execution_ex_opcode, execution_indirect, execution_last, execution_op1, execution_op1_after_relative, execution_op2, execution_op2_after_relative, execution_op3, execution_op3_after_relative, execution_op4, execution_op4_after_relative, execution_pc, execution_rop1, execution_rop2, execution_rop3, execution_rop4, execution_sel, execution_sel_addressing_error, execution_sel_op1_is_address, execution_sel_op2_is_address, execution_sel_op3_is_address, execution_sel_op4_is_address, instr_fetching_abs_diff, instr_fetching_bc_id_diff_inv, instr_fetching_bd0, instr_fetching_bd1, instr_fetching_bd10, instr_fetching_bd11, instr_fetching_bd12, instr_fetching_bd13, instr_fetching_bd14, instr_fetching_bd15, instr_fetching_bd16, instr_fetching_bd17, instr_fetching_bd18, instr_fetching_bd19, instr_fetching_bd2, instr_fetching_bd20, instr_fetching_bd21, instr_fetching_bd22, instr_fetching_bd23, instr_fetching_bd24, instr_fetching_bd25, instr_fetching_bd26, instr_fetching_bd27, instr_fetching_bd28, instr_fetching_bd29, instr_fetching_bd3, instr_fetching_bd30, instr_fetching_bd31, instr_fetching_bd32, instr_fetching_bd33, instr_fetching_bd34, instr_fetching_bd35, instr_fetching_bd36, instr_fetching_bd4, instr_fetching_bd5, instr_fetching_bd6, instr_fetching_bd7, instr_fetching_bd8, instr_fetching_bd9, instr_fetching_bytecode_id, instr_fetching_bytecode_size, instr_fetching_bytes_remaining, instr_fetching_bytes_to_read, instr_fetching_exec_opcode, instr_fetching_indirect, instr_fetching_instr_out_of_range, instr_fetching_instr_size, instr_fetching_last_of_bytecode, instr_fetching_op1, instr_fetching_op2, instr_fetching_op3, instr_fetching_op4, instr_fetching_op5, instr_fetching_op6, instr_fetching_op7, instr_fetching_opcode_out_of_range, instr_fetching_parsing_err, instr_fetching_pc, instr_fetching_pc_out_of_range, instr_fetching_sel, instr_fetching_sel_lookup_bc_decomposition, instr_fetching_sel_op_dc_0, instr_fetching_sel_op_dc_1, instr_fetching_sel_op_dc_10, instr_fetching_sel_op_dc_11, instr_fetching_sel_op_dc_12, instr_fetching_sel_op_dc_13, instr_fetching_sel_op_dc_14, instr_fetching_sel_op_dc_15, instr_fetching_sel_op_dc_16, instr_fetching_sel_op_dc_17, instr_fetching_sel_op_dc_2, instr_fetching_sel_op_dc_3, instr_fetching_sel_op_dc_4, instr_fetching_sel_op_dc_5, instr_fetching_sel_op_dc_6, instr_fetching_sel_op_dc_7, instr_fetching_sel_op_dc_8, instr_fetching_sel_op_dc_9, poseidon2_hash_a_0, poseidon2_hash_a_1, poseidon2_hash_a_2, poseidon2_hash_a_3, poseidon2_hash_b_0, poseidon2_hash_b_1, poseidon2_hash_b_2, poseidon2_hash_b_3, poseidon2_hash_end, poseidon2_hash_input_0, poseidon2_hash_input_1, poseidon2_hash_input_2, poseidon2_hash_input_len, poseidon2_hash_num_perm_rounds_rem, poseidon2_hash_num_perm_rounds_rem_inv, poseidon2_hash_output, poseidon2_hash_padding, poseidon2_hash_sel, poseidon2_hash_start, poseidon2_perm_B_10_0, poseidon2_perm_B_10_1, poseidon2_perm_B_10_2, poseidon2_perm_B_10_3, poseidon2_perm_B_11_0, poseidon2_perm_B_11_1, poseidon2_perm_B_11_2, poseidon2_perm_B_11_3, poseidon2_perm_B_12_0, poseidon2_perm_B_12_1, poseidon2_perm_B_12_2, poseidon2_perm_B_12_3, poseidon2_perm_B_13_0, poseidon2_perm_B_13_1, poseidon2_perm_B_13_2, poseidon2_perm_B_13_3, poseidon2_perm_B_14_0, poseidon2_perm_B_14_1, poseidon2_perm_B_14_2, poseidon2_perm_B_14_3, poseidon2_perm_B_15_0, poseidon2_perm_B_15_1, poseidon2_perm_B_15_2, poseidon2_perm_B_15_3, poseidon2_perm_B_16_0, poseidon2_perm_B_16_1, poseidon2_perm_B_16_2, poseidon2_perm_B_16_3, poseidon2_perm_B_17_0, poseidon2_perm_B_17_1, poseidon2_perm_B_17_2, poseidon2_perm_B_17_3, poseidon2_perm_B_18_0, poseidon2_perm_B_18_1, poseidon2_perm_B_18_2, poseidon2_perm_B_18_3, poseidon2_perm_B_19_0, poseidon2_perm_B_19_1, poseidon2_perm_B_19_2, poseidon2_perm_B_19_3, poseidon2_perm_B_20_0, poseidon2_perm_B_20_1, poseidon2_perm_B_20_2, poseidon2_perm_B_20_3, poseidon2_perm_B_21_0, poseidon2_perm_B_21_1, poseidon2_perm_B_21_2, poseidon2_perm_B_21_3, poseidon2_perm_B_22_0, poseidon2_perm_B_22_1, poseidon2_perm_B_22_2, poseidon2_perm_B_22_3, poseidon2_perm_B_23_0, poseidon2_perm_B_23_1, poseidon2_perm_B_23_2, poseidon2_perm_B_23_3, poseidon2_perm_B_24_0, poseidon2_perm_B_24_1, poseidon2_perm_B_24_2, poseidon2_perm_B_24_3, poseidon2_perm_B_25_0, poseidon2_perm_B_25_1, poseidon2_perm_B_25_2, poseidon2_perm_B_25_3, poseidon2_perm_B_26_0, poseidon2_perm_B_26_1, poseidon2_perm_B_26_2, poseidon2_perm_B_26_3, poseidon2_perm_B_27_0, poseidon2_perm_B_27_1, poseidon2_perm_B_27_2, poseidon2_perm_B_27_3, poseidon2_perm_B_28_0, poseidon2_perm_B_28_1, poseidon2_perm_B_28_2, poseidon2_perm_B_28_3, poseidon2_perm_B_29_0, poseidon2_perm_B_29_1, poseidon2_perm_B_29_2, poseidon2_perm_B_29_3, poseidon2_perm_B_30_0, poseidon2_perm_B_30_1, poseidon2_perm_B_30_2, poseidon2_perm_B_30_3, poseidon2_perm_B_31_0, poseidon2_perm_B_31_1, poseidon2_perm_B_31_2, poseidon2_perm_B_31_3, poseidon2_perm_B_32_0, poseidon2_perm_B_32_1, poseidon2_perm_B_32_2, poseidon2_perm_B_32_3, poseidon2_perm_B_33_0, poseidon2_perm_B_33_1, poseidon2_perm_B_33_2, poseidon2_perm_B_33_3, poseidon2_perm_B_34_0, poseidon2_perm_B_34_1, poseidon2_perm_B_34_2, poseidon2_perm_B_34_3, poseidon2_perm_B_35_0, poseidon2_perm_B_35_1, poseidon2_perm_B_35_2, poseidon2_perm_B_35_3, poseidon2_perm_B_36_0, poseidon2_perm_B_36_1, poseidon2_perm_B_36_2, poseidon2_perm_B_36_3, poseidon2_perm_B_37_0, poseidon2_perm_B_37_1, poseidon2_perm_B_37_2, poseidon2_perm_B_37_3, poseidon2_perm_B_38_0, poseidon2_perm_B_38_1, poseidon2_perm_B_38_2, poseidon2_perm_B_38_3, poseidon2_perm_B_39_0, poseidon2_perm_B_39_1, poseidon2_perm_B_39_2, poseidon2_perm_B_39_3, poseidon2_perm_B_40_0, poseidon2_perm_B_40_1, poseidon2_perm_B_40_2, poseidon2_perm_B_40_3, poseidon2_perm_B_41_0, poseidon2_perm_B_41_1, poseidon2_perm_B_41_2, poseidon2_perm_B_41_3, poseidon2_perm_B_42_0, poseidon2_perm_B_42_1, poseidon2_perm_B_42_2, poseidon2_perm_B_42_3, poseidon2_perm_B_43_0, poseidon2_perm_B_43_1, poseidon2_perm_B_43_2, poseidon2_perm_B_43_3, poseidon2_perm_B_44_0, poseidon2_perm_B_44_1, poseidon2_perm_B_44_2, poseidon2_perm_B_44_3, poseidon2_perm_B_45_0, poseidon2_perm_B_45_1, poseidon2_perm_B_45_2, poseidon2_perm_B_45_3, poseidon2_perm_B_46_0, poseidon2_perm_B_46_1, poseidon2_perm_B_46_2, poseidon2_perm_B_46_3, poseidon2_perm_B_47_0, poseidon2_perm_B_47_1, poseidon2_perm_B_47_2, poseidon2_perm_B_47_3, poseidon2_perm_B_48_0, poseidon2_perm_B_48_1, poseidon2_perm_B_48_2, poseidon2_perm_B_48_3, poseidon2_perm_B_49_0, poseidon2_perm_B_49_1, poseidon2_perm_B_49_2, poseidon2_perm_B_49_3, poseidon2_perm_B_4_0, poseidon2_perm_B_4_1, poseidon2_perm_B_4_2, poseidon2_perm_B_4_3, poseidon2_perm_B_50_0, poseidon2_perm_B_50_1, poseidon2_perm_B_50_2, poseidon2_perm_B_50_3, poseidon2_perm_B_51_0, poseidon2_perm_B_51_1, poseidon2_perm_B_51_2, poseidon2_perm_B_51_3, poseidon2_perm_B_52_0, poseidon2_perm_B_52_1, poseidon2_perm_B_52_2, poseidon2_perm_B_52_3, poseidon2_perm_B_53_0, poseidon2_perm_B_53_1, poseidon2_perm_B_53_2, poseidon2_perm_B_53_3, poseidon2_perm_B_54_0, poseidon2_perm_B_54_1, poseidon2_perm_B_54_2, poseidon2_perm_B_54_3, poseidon2_perm_B_55_0, poseidon2_perm_B_55_1, poseidon2_perm_B_55_2, poseidon2_perm_B_55_3, poseidon2_perm_B_56_0, poseidon2_perm_B_56_1, poseidon2_perm_B_56_2, poseidon2_perm_B_56_3, poseidon2_perm_B_57_0, poseidon2_perm_B_57_1, poseidon2_perm_B_57_2, poseidon2_perm_B_57_3, poseidon2_perm_B_58_0, poseidon2_perm_B_58_1, poseidon2_perm_B_58_2, poseidon2_perm_B_58_3, poseidon2_perm_B_59_0, poseidon2_perm_B_59_1, poseidon2_perm_B_59_2, poseidon2_perm_B_59_3, poseidon2_perm_B_5_0, poseidon2_perm_B_5_1, poseidon2_perm_B_5_2, poseidon2_perm_B_5_3, poseidon2_perm_B_6_0, poseidon2_perm_B_6_1, poseidon2_perm_B_6_2, poseidon2_perm_B_6_3, poseidon2_perm_B_7_0, poseidon2_perm_B_7_1, poseidon2_perm_B_7_2, poseidon2_perm_B_7_3, poseidon2_perm_B_8_0, poseidon2_perm_B_8_1, poseidon2_perm_B_8_2, poseidon2_perm_B_8_3, poseidon2_perm_B_9_0, poseidon2_perm_B_9_1, poseidon2_perm_B_9_2, poseidon2_perm_B_9_3, poseidon2_perm_EXT_LAYER_4, poseidon2_perm_EXT_LAYER_5, poseidon2_perm_EXT_LAYER_6, poseidon2_perm_EXT_LAYER_7, poseidon2_perm_T_0_4, poseidon2_perm_T_0_5, poseidon2_perm_T_0_6, poseidon2_perm_T_0_7, poseidon2_perm_T_1_4, poseidon2_perm_T_1_5, poseidon2_perm_T_1_6, poseidon2_perm_T_1_7, poseidon2_perm_T_2_4, poseidon2_perm_T_2_5, poseidon2_perm_T_2_6, poseidon2_perm_T_2_7, poseidon2_perm_T_3_4, poseidon2_perm_T_3_5, poseidon2_perm_T_3_6, poseidon2_perm_T_3_7, poseidon2_perm_T_60_4, poseidon2_perm_T_60_5, poseidon2_perm_T_60_6, poseidon2_perm_T_60_7, poseidon2_perm_T_61_4, poseidon2_perm_T_61_5, poseidon2_perm_T_61_6, poseidon2_perm_T_61_7, poseidon2_perm_T_62_4, poseidon2_perm_T_62_5, poseidon2_perm_T_62_6, poseidon2_perm_T_62_7, poseidon2_perm_T_63_4, poseidon2_perm_T_63_5, poseidon2_perm_T_63_6, poseidon2_perm_T_63_7, poseidon2_perm_a_0, poseidon2_perm_a_1, poseidon2_perm_a_2, poseidon2_perm_a_3, poseidon2_perm_b_0, poseidon2_perm_b_1, poseidon2_perm_b_2, poseidon2_perm_b_3, poseidon2_perm_sel, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_rng_chk_bits, range_check_sel, range_check_sel_r0_16_bit_rng_lookup, range_check_sel_r1_16_bit_rng_lookup, range_check_sel_r2_16_bit_rng_lookup, range_check_sel_r3_16_bit_rng_lookup, range_check_sel_r4_16_bit_rng_lookup, range_check_sel_r5_16_bit_rng_lookup, range_check_sel_r6_16_bit_rng_lookup, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, scalar_mul_bit, scalar_mul_bit_idx, scalar_mul_bit_radix, scalar_mul_end, scalar_mul_not_end, scalar_mul_point_inf, scalar_mul_point_x, scalar_mul_point_y, scalar_mul_res_inf, scalar_mul_res_x, scalar_mul_res_y, scalar_mul_scalar, scalar_mul_sel, scalar_mul_should_add, scalar_mul_start, scalar_mul_temp_inf, scalar_mul_temp_x, scalar_mul_temp_y, sha256_a, sha256_a_and_b, sha256_a_and_b_xor_a_and_c, sha256_a_and_c, sha256_a_rotr_13, sha256_a_rotr_2, sha256_a_rotr_22, sha256_a_rotr_2_xor_a_rotr_13, sha256_and_sel, sha256_b, sha256_b_and_c, sha256_c, sha256_ch, sha256_clk, sha256_computed_w_lhs, sha256_computed_w_rhs, sha256_d, sha256_e, sha256_e_and_f, sha256_e_rotr_11, sha256_e_rotr_25, sha256_e_rotr_6, sha256_e_rotr_6_xor_e_rotr_11, sha256_f, sha256_g, sha256_h, sha256_helper_w0, sha256_helper_w1, sha256_helper_w10, sha256_helper_w11, sha256_helper_w12, sha256_helper_w13, sha256_helper_w14, sha256_helper_w15, sha256_helper_w2, sha256_helper_w3, sha256_helper_w4, sha256_helper_w5, sha256_helper_w6, sha256_helper_w7, sha256_helper_w8, sha256_helper_w9, sha256_init_a, sha256_init_b, sha256_init_c, sha256_init_d, sha256_init_e, sha256_init_f, sha256_init_g, sha256_init_h, sha256_input_offset, sha256_is_input_round, sha256_latch, sha256_lhs_a_13, sha256_lhs_a_2, sha256_lhs_a_22, sha256_lhs_e_11, sha256_lhs_e_25, sha256_lhs_e_6, sha256_lhs_w_10, sha256_lhs_w_17, sha256_lhs_w_18, sha256_lhs_w_19, sha256_lhs_w_3, sha256_lhs_w_7, sha256_maj, sha256_next_a_lhs, sha256_next_a_rhs, sha256_next_e_lhs, sha256_next_e_rhs, sha256_not_e, sha256_not_e_and_g, sha256_output_a_lhs, sha256_output_a_rhs, sha256_output_b_lhs, sha256_output_b_rhs, sha256_output_c_lhs, sha256_output_c_rhs, sha256_output_d_lhs, sha256_output_d_rhs, sha256_output_e_lhs, sha256_output_e_rhs, sha256_output_f_lhs, sha256_output_f_rhs, sha256_output_g_lhs, sha256_output_g_rhs, sha256_output_h_lhs, sha256_output_h_rhs, sha256_output_offset, sha256_perform_round, sha256_rhs_a_13, sha256_rhs_a_2, sha256_rhs_a_22, sha256_rhs_e_11, sha256_rhs_e_25, sha256_rhs_e_6, sha256_rhs_w_10, sha256_rhs_w_17, sha256_rhs_w_18, sha256_rhs_w_19, sha256_rhs_w_3, sha256_rhs_w_7, sha256_round_constant, sha256_round_count, sha256_rounds_remaining, sha256_rounds_remaining_inv, sha256_s_0, sha256_s_1, sha256_sel, sha256_start, sha256_state_offset, sha256_w, sha256_w_15_rotr_18, sha256_w_15_rotr_7, sha256_w_15_rotr_7_xor_w_15_rotr_18, sha256_w_15_rshift_3, sha256_w_2_rotr_17, sha256_w_2_rotr_17_xor_w_2_rotr_19, sha256_w_2_rotr_19, sha256_w_2_rshift_10, sha256_w_s_0, sha256_w_s_1, sha256_xor_sel, to_radix_acc, to_radix_acc_under_p, to_radix_end, to_radix_exponent, to_radix_found, to_radix_is_unsafe_limb, to_radix_limb, to_radix_limb_eq_p, to_radix_limb_index, to_radix_limb_lt_p, to_radix_limb_p_diff, to_radix_limb_radix_diff, to_radix_not_end, to_radix_not_padding_limb, to_radix_p_limb, to_radix_radix, to_radix_rem_inverse, to_radix_safe_limbs, to_radix_safety_diff_inverse, to_radix_sel, to_radix_start, to_radix_value, lookup_poseidon2_hash_poseidon2_perm_counts, lookup_range_check_dyn_rng_chk_pow_2_counts, lookup_range_check_dyn_diff_is_u16_counts, lookup_range_check_r0_is_u16_counts, lookup_range_check_r1_is_u16_counts, lookup_range_check_r2_is_u16_counts, lookup_range_check_r3_is_u16_counts, lookup_range_check_r4_is_u16_counts, lookup_range_check_r5_is_u16_counts, lookup_range_check_r6_is_u16_counts, lookup_range_check_r7_is_u16_counts, lookup_to_radix_limb_range_counts, lookup_to_radix_limb_less_than_radix_range_counts, lookup_to_radix_fetch_safe_limbs_counts, lookup_to_radix_fetch_p_limb_counts, lookup_to_radix_limb_p_diff_range_counts, lookup_scalar_mul_to_radix_counts, lookup_scalar_mul_double_counts, lookup_scalar_mul_add_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_0_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_1_counts, lookup_address_derivation_partial_address_poseidon2_counts, lookup_address_derivation_public_keys_hash_poseidon2_0_counts, lookup_address_derivation_public_keys_hash_poseidon2_1_counts, lookup_address_derivation_public_keys_hash_poseidon2_2_counts, lookup_address_derivation_public_keys_hash_poseidon2_3_counts, lookup_address_derivation_public_keys_hash_poseidon2_4_counts, lookup_address_derivation_preaddress_poseidon2_counts, lookup_address_derivation_preaddress_scalar_mul_counts, lookup_address_derivation_address_ecadd_counts, lookup_bc_decomposition_bytes_are_bytes_counts, lookup_bc_decomposition_abs_diff_is_u16_counts, lookup_bc_decomposition_bytes_to_read_as_unary_counts, lookup_bc_hashing_get_packed_field_counts, lookup_bc_hashing_iv_is_len_counts, lookup_bc_hashing_poseidon2_hash_counts, lookup_bc_retrieval_class_id_derivation_counts, lookup_bc_retrieval_bytecode_hash_is_correct_counts, lookup_instr_fetching_abs_diff_positive_counts, lookup_instr_fetching_bytes_from_bc_dec_counts, lookup_instr_fetching_wire_instruction_info_counts, lookup_class_id_derivation_class_id_poseidon2_0_counts, lookup_class_id_derivation_class_id_poseidon2_1_counts, lookup_bitwise_integral_tag_length_counts, lookup_bitwise_byte_operations_counts, lookup_sha256_round_constant_counts +#define AVM2_DERIVED_WITNESS_ENTITIES lookup_poseidon2_hash_poseidon2_perm_inv, lookup_range_check_dyn_rng_chk_pow_2_inv, lookup_range_check_dyn_diff_is_u16_inv, lookup_range_check_r0_is_u16_inv, lookup_range_check_r1_is_u16_inv, lookup_range_check_r2_is_u16_inv, lookup_range_check_r3_is_u16_inv, lookup_range_check_r4_is_u16_inv, lookup_range_check_r5_is_u16_inv, lookup_range_check_r6_is_u16_inv, lookup_range_check_r7_is_u16_inv, lookup_to_radix_limb_range_inv, lookup_to_radix_limb_less_than_radix_range_inv, lookup_to_radix_fetch_safe_limbs_inv, lookup_to_radix_fetch_p_limb_inv, lookup_to_radix_limb_p_diff_range_inv, lookup_scalar_mul_to_radix_inv, lookup_scalar_mul_double_inv, lookup_scalar_mul_add_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_0_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_1_inv, lookup_address_derivation_partial_address_poseidon2_inv, lookup_address_derivation_public_keys_hash_poseidon2_0_inv, lookup_address_derivation_public_keys_hash_poseidon2_1_inv, lookup_address_derivation_public_keys_hash_poseidon2_2_inv, lookup_address_derivation_public_keys_hash_poseidon2_3_inv, lookup_address_derivation_public_keys_hash_poseidon2_4_inv, lookup_address_derivation_preaddress_poseidon2_inv, lookup_address_derivation_preaddress_scalar_mul_inv, lookup_address_derivation_address_ecadd_inv, lookup_bc_decomposition_bytes_are_bytes_inv, lookup_bc_decomposition_abs_diff_is_u16_inv, lookup_bc_decomposition_bytes_to_read_as_unary_inv, lookup_bc_hashing_get_packed_field_inv, lookup_bc_hashing_iv_is_len_inv, lookup_bc_hashing_poseidon2_hash_inv, lookup_bc_retrieval_class_id_derivation_inv, lookup_bc_retrieval_bytecode_hash_is_correct_inv, lookup_instr_fetching_abs_diff_positive_inv, lookup_instr_fetching_bytes_from_bc_dec_inv, lookup_instr_fetching_wire_instruction_info_inv, lookup_class_id_derivation_class_id_poseidon2_0_inv, lookup_class_id_derivation_class_id_poseidon2_1_inv, lookup_bitwise_integral_tag_length_inv, lookup_bitwise_byte_operations_inv, lookup_sha256_round_constant_inv +#define AVM2_SHIFTED_ENTITIES bc_decomposition_bytes_shift, bc_decomposition_bytes_pc_plus_1_shift, bc_decomposition_bytes_pc_plus_10_shift, bc_decomposition_bytes_pc_plus_11_shift, bc_decomposition_bytes_pc_plus_12_shift, bc_decomposition_bytes_pc_plus_13_shift, bc_decomposition_bytes_pc_plus_14_shift, bc_decomposition_bytes_pc_plus_15_shift, bc_decomposition_bytes_pc_plus_16_shift, bc_decomposition_bytes_pc_plus_17_shift, bc_decomposition_bytes_pc_plus_18_shift, bc_decomposition_bytes_pc_plus_19_shift, bc_decomposition_bytes_pc_plus_2_shift, bc_decomposition_bytes_pc_plus_20_shift, bc_decomposition_bytes_pc_plus_21_shift, bc_decomposition_bytes_pc_plus_22_shift, bc_decomposition_bytes_pc_plus_23_shift, bc_decomposition_bytes_pc_plus_24_shift, bc_decomposition_bytes_pc_plus_25_shift, bc_decomposition_bytes_pc_plus_26_shift, bc_decomposition_bytes_pc_plus_27_shift, bc_decomposition_bytes_pc_plus_28_shift, bc_decomposition_bytes_pc_plus_29_shift, bc_decomposition_bytes_pc_plus_3_shift, bc_decomposition_bytes_pc_plus_30_shift, bc_decomposition_bytes_pc_plus_31_shift, bc_decomposition_bytes_pc_plus_32_shift, bc_decomposition_bytes_pc_plus_33_shift, bc_decomposition_bytes_pc_plus_34_shift, bc_decomposition_bytes_pc_plus_35_shift, bc_decomposition_bytes_pc_plus_4_shift, bc_decomposition_bytes_pc_plus_5_shift, bc_decomposition_bytes_pc_plus_6_shift, bc_decomposition_bytes_pc_plus_7_shift, bc_decomposition_bytes_pc_plus_8_shift, bc_decomposition_bytes_pc_plus_9_shift, bc_decomposition_bytes_remaining_shift, bc_decomposition_id_shift, bc_decomposition_pc_shift, bc_decomposition_sel_shift, bc_hashing_bytecode_id_shift, bc_hashing_incremental_hash_shift, bc_hashing_pc_index_shift, bc_hashing_sel_shift, bc_hashing_start_shift, bitwise_acc_ia_shift, bitwise_acc_ib_shift, bitwise_acc_ic_shift, bitwise_ctr_shift, bitwise_op_id_shift, execution_sel_shift, instr_fetching_bytecode_id_shift, instr_fetching_bytecode_size_shift, instr_fetching_bytes_remaining_shift, instr_fetching_pc_shift, instr_fetching_sel_shift, poseidon2_hash_a_0_shift, poseidon2_hash_a_1_shift, poseidon2_hash_a_2_shift, poseidon2_hash_a_3_shift, poseidon2_hash_input_0_shift, poseidon2_hash_input_1_shift, poseidon2_hash_input_2_shift, poseidon2_hash_num_perm_rounds_rem_shift, poseidon2_hash_output_shift, poseidon2_hash_sel_shift, poseidon2_hash_start_shift, scalar_mul_bit_idx_shift, scalar_mul_point_inf_shift, scalar_mul_point_x_shift, scalar_mul_point_y_shift, scalar_mul_res_inf_shift, scalar_mul_res_x_shift, scalar_mul_res_y_shift, scalar_mul_scalar_shift, scalar_mul_sel_shift, scalar_mul_start_shift, scalar_mul_temp_inf_shift, scalar_mul_temp_x_shift, scalar_mul_temp_y_shift, sha256_a_shift, sha256_b_shift, sha256_c_shift, sha256_d_shift, sha256_e_shift, sha256_f_shift, sha256_g_shift, sha256_h_shift, sha256_helper_w0_shift, sha256_helper_w1_shift, sha256_helper_w10_shift, sha256_helper_w11_shift, sha256_helper_w12_shift, sha256_helper_w13_shift, sha256_helper_w14_shift, sha256_helper_w15_shift, sha256_helper_w2_shift, sha256_helper_w3_shift, sha256_helper_w4_shift, sha256_helper_w5_shift, sha256_helper_w6_shift, sha256_helper_w7_shift, sha256_helper_w8_shift, sha256_helper_w9_shift, sha256_rounds_remaining_shift, sha256_sel_shift, sha256_start_shift, to_radix_acc_shift, to_radix_acc_under_p_shift, to_radix_exponent_shift, to_radix_limb_shift, to_radix_limb_eq_p_shift, to_radix_limb_index_shift, to_radix_limb_lt_p_shift, to_radix_not_padding_limb_shift, to_radix_radix_shift, to_radix_safe_limbs_shift, to_radix_sel_shift, to_radix_start_shift, to_radix_value_shift +#define AVM2_TO_BE_SHIFTED(e) e.bc_decomposition_bytes, e.bc_decomposition_bytes_pc_plus_1, e.bc_decomposition_bytes_pc_plus_10, e.bc_decomposition_bytes_pc_plus_11, e.bc_decomposition_bytes_pc_plus_12, e.bc_decomposition_bytes_pc_plus_13, e.bc_decomposition_bytes_pc_plus_14, e.bc_decomposition_bytes_pc_plus_15, e.bc_decomposition_bytes_pc_plus_16, e.bc_decomposition_bytes_pc_plus_17, e.bc_decomposition_bytes_pc_plus_18, e.bc_decomposition_bytes_pc_plus_19, e.bc_decomposition_bytes_pc_plus_2, e.bc_decomposition_bytes_pc_plus_20, e.bc_decomposition_bytes_pc_plus_21, e.bc_decomposition_bytes_pc_plus_22, e.bc_decomposition_bytes_pc_plus_23, e.bc_decomposition_bytes_pc_plus_24, e.bc_decomposition_bytes_pc_plus_25, e.bc_decomposition_bytes_pc_plus_26, e.bc_decomposition_bytes_pc_plus_27, e.bc_decomposition_bytes_pc_plus_28, e.bc_decomposition_bytes_pc_plus_29, e.bc_decomposition_bytes_pc_plus_3, e.bc_decomposition_bytes_pc_plus_30, e.bc_decomposition_bytes_pc_plus_31, e.bc_decomposition_bytes_pc_plus_32, e.bc_decomposition_bytes_pc_plus_33, e.bc_decomposition_bytes_pc_plus_34, e.bc_decomposition_bytes_pc_plus_35, e.bc_decomposition_bytes_pc_plus_4, e.bc_decomposition_bytes_pc_plus_5, e.bc_decomposition_bytes_pc_plus_6, e.bc_decomposition_bytes_pc_plus_7, e.bc_decomposition_bytes_pc_plus_8, e.bc_decomposition_bytes_pc_plus_9, e.bc_decomposition_bytes_remaining, e.bc_decomposition_id, e.bc_decomposition_pc, e.bc_decomposition_sel, e.bc_hashing_bytecode_id, e.bc_hashing_incremental_hash, e.bc_hashing_pc_index, e.bc_hashing_sel, e.bc_hashing_start, e.bitwise_acc_ia, e.bitwise_acc_ib, e.bitwise_acc_ic, e.bitwise_ctr, e.bitwise_op_id, e.execution_sel, e.instr_fetching_bytecode_id, e.instr_fetching_bytecode_size, e.instr_fetching_bytes_remaining, e.instr_fetching_pc, e.instr_fetching_sel, e.poseidon2_hash_a_0, e.poseidon2_hash_a_1, e.poseidon2_hash_a_2, e.poseidon2_hash_a_3, e.poseidon2_hash_input_0, e.poseidon2_hash_input_1, e.poseidon2_hash_input_2, e.poseidon2_hash_num_perm_rounds_rem, e.poseidon2_hash_output, e.poseidon2_hash_sel, e.poseidon2_hash_start, e.scalar_mul_bit_idx, e.scalar_mul_point_inf, e.scalar_mul_point_x, e.scalar_mul_point_y, e.scalar_mul_res_inf, e.scalar_mul_res_x, e.scalar_mul_res_y, e.scalar_mul_scalar, e.scalar_mul_sel, e.scalar_mul_start, e.scalar_mul_temp_inf, e.scalar_mul_temp_x, e.scalar_mul_temp_y, e.sha256_a, e.sha256_b, e.sha256_c, e.sha256_d, e.sha256_e, e.sha256_f, e.sha256_g, e.sha256_h, e.sha256_helper_w0, e.sha256_helper_w1, e.sha256_helper_w10, e.sha256_helper_w11, e.sha256_helper_w12, e.sha256_helper_w13, e.sha256_helper_w14, e.sha256_helper_w15, e.sha256_helper_w2, e.sha256_helper_w3, e.sha256_helper_w4, e.sha256_helper_w5, e.sha256_helper_w6, e.sha256_helper_w7, e.sha256_helper_w8, e.sha256_helper_w9, e.sha256_rounds_remaining, e.sha256_sel, e.sha256_start, e.to_radix_acc, e.to_radix_acc_under_p, e.to_radix_exponent, e.to_radix_limb, e.to_radix_limb_eq_p, e.to_radix_limb_index, e.to_radix_limb_lt_p, e.to_radix_not_padding_limb, e.to_radix_radix, e.to_radix_safe_limbs, e.to_radix_sel, e.to_radix_start, e.to_radix_value #define AVM2_ALL_ENTITIES AVM2_PRECOMPUTED_ENTITIES, AVM2_WIRE_ENTITIES, AVM2_DERIVED_WITNESS_ENTITIES, AVM2_SHIFTED_ENTITIES #define AVM2_UNSHIFTED_ENTITIES AVM2_PRECOMPUTED_ENTITIES, AVM2_WIRE_ENTITIES, AVM2_DERIVED_WITNESS_ENTITIES #define AVM2_WITNESS_ENTITIES AVM2_WIRE_ENTITIES, AVM2_DERIVED_WITNESS_ENTITIES -#define AVM2_TO_BE_SHIFTED_COLUMNS Column::bc_decomposition_bytes, Column::bc_decomposition_bytes_pc_plus_1, Column::bc_decomposition_bytes_pc_plus_10, Column::bc_decomposition_bytes_pc_plus_11, Column::bc_decomposition_bytes_pc_plus_12, Column::bc_decomposition_bytes_pc_plus_13, Column::bc_decomposition_bytes_pc_plus_14, Column::bc_decomposition_bytes_pc_plus_15, Column::bc_decomposition_bytes_pc_plus_16, Column::bc_decomposition_bytes_pc_plus_17, Column::bc_decomposition_bytes_pc_plus_18, Column::bc_decomposition_bytes_pc_plus_19, Column::bc_decomposition_bytes_pc_plus_2, Column::bc_decomposition_bytes_pc_plus_20, Column::bc_decomposition_bytes_pc_plus_21, Column::bc_decomposition_bytes_pc_plus_22, Column::bc_decomposition_bytes_pc_plus_23, Column::bc_decomposition_bytes_pc_plus_24, Column::bc_decomposition_bytes_pc_plus_25, Column::bc_decomposition_bytes_pc_plus_26, Column::bc_decomposition_bytes_pc_plus_27, Column::bc_decomposition_bytes_pc_plus_28, Column::bc_decomposition_bytes_pc_plus_29, Column::bc_decomposition_bytes_pc_plus_3, Column::bc_decomposition_bytes_pc_plus_30, Column::bc_decomposition_bytes_pc_plus_31, Column::bc_decomposition_bytes_pc_plus_32, Column::bc_decomposition_bytes_pc_plus_33, Column::bc_decomposition_bytes_pc_plus_34, Column::bc_decomposition_bytes_pc_plus_35, Column::bc_decomposition_bytes_pc_plus_4, Column::bc_decomposition_bytes_pc_plus_5, Column::bc_decomposition_bytes_pc_plus_6, Column::bc_decomposition_bytes_pc_plus_7, Column::bc_decomposition_bytes_pc_plus_8, Column::bc_decomposition_bytes_pc_plus_9, Column::bc_decomposition_bytes_remaining, Column::bc_decomposition_id, Column::bc_decomposition_pc, Column::bc_decomposition_sel, Column::bc_hashing_bytecode_id, Column::bc_hashing_incremental_hash, Column::bc_hashing_pc_index, Column::bc_hashing_sel, Column::bc_hashing_start, Column::bitwise_acc_ia, Column::bitwise_acc_ib, Column::bitwise_acc_ic, Column::bitwise_ctr, Column::bitwise_op_id, Column::execution_sel, Column::poseidon2_hash_a_0, Column::poseidon2_hash_a_1, Column::poseidon2_hash_a_2, Column::poseidon2_hash_a_3, Column::poseidon2_hash_input_0, Column::poseidon2_hash_input_1, Column::poseidon2_hash_input_2, Column::poseidon2_hash_num_perm_rounds_rem, Column::poseidon2_hash_output, Column::poseidon2_hash_sel, Column::poseidon2_hash_start, Column::scalar_mul_bit_idx, Column::scalar_mul_point_inf, Column::scalar_mul_point_x, Column::scalar_mul_point_y, Column::scalar_mul_res_inf, Column::scalar_mul_res_x, Column::scalar_mul_res_y, Column::scalar_mul_scalar, Column::scalar_mul_sel, Column::scalar_mul_start, Column::scalar_mul_temp_inf, Column::scalar_mul_temp_x, Column::scalar_mul_temp_y, Column::sha256_a, Column::sha256_b, Column::sha256_c, Column::sha256_d, Column::sha256_e, Column::sha256_f, Column::sha256_g, Column::sha256_h, Column::sha256_helper_w0, Column::sha256_helper_w1, Column::sha256_helper_w10, Column::sha256_helper_w11, Column::sha256_helper_w12, Column::sha256_helper_w13, Column::sha256_helper_w14, Column::sha256_helper_w15, Column::sha256_helper_w2, Column::sha256_helper_w3, Column::sha256_helper_w4, Column::sha256_helper_w5, Column::sha256_helper_w6, Column::sha256_helper_w7, Column::sha256_helper_w8, Column::sha256_helper_w9, Column::sha256_rounds_remaining, Column::sha256_sel, Column::sha256_start, Column::to_radix_acc, Column::to_radix_acc_under_p, Column::to_radix_exponent, Column::to_radix_limb, Column::to_radix_limb_eq_p, Column::to_radix_limb_index, Column::to_radix_limb_lt_p, Column::to_radix_not_padding_limb, Column::to_radix_radix, Column::to_radix_safe_limbs, Column::to_radix_sel, Column::to_radix_start, Column::to_radix_value -#define AVM2_SHIFTED_COLUMNS ColumnAndShifts::bc_decomposition_bytes_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_1_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_10_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_11_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_12_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_13_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_14_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_15_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_16_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_17_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_18_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_19_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_2_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_20_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_21_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_22_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_23_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_24_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_25_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_26_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_27_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_28_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_29_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_3_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_30_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_31_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_32_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_33_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_34_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_35_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_4_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_5_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_6_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_7_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_8_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_9_shift, ColumnAndShifts::bc_decomposition_bytes_remaining_shift, ColumnAndShifts::bc_decomposition_id_shift, ColumnAndShifts::bc_decomposition_pc_shift, ColumnAndShifts::bc_decomposition_sel_shift, ColumnAndShifts::bc_hashing_bytecode_id_shift, ColumnAndShifts::bc_hashing_incremental_hash_shift, ColumnAndShifts::bc_hashing_pc_index_shift, ColumnAndShifts::bc_hashing_sel_shift, ColumnAndShifts::bc_hashing_start_shift, ColumnAndShifts::bitwise_acc_ia_shift, ColumnAndShifts::bitwise_acc_ib_shift, ColumnAndShifts::bitwise_acc_ic_shift, ColumnAndShifts::bitwise_ctr_shift, ColumnAndShifts::bitwise_op_id_shift, ColumnAndShifts::execution_sel_shift, ColumnAndShifts::poseidon2_hash_a_0_shift, ColumnAndShifts::poseidon2_hash_a_1_shift, ColumnAndShifts::poseidon2_hash_a_2_shift, ColumnAndShifts::poseidon2_hash_a_3_shift, ColumnAndShifts::poseidon2_hash_input_0_shift, ColumnAndShifts::poseidon2_hash_input_1_shift, ColumnAndShifts::poseidon2_hash_input_2_shift, ColumnAndShifts::poseidon2_hash_num_perm_rounds_rem_shift, ColumnAndShifts::poseidon2_hash_output_shift, ColumnAndShifts::poseidon2_hash_sel_shift, ColumnAndShifts::poseidon2_hash_start_shift, ColumnAndShifts::scalar_mul_bit_idx_shift, ColumnAndShifts::scalar_mul_point_inf_shift, ColumnAndShifts::scalar_mul_point_x_shift, ColumnAndShifts::scalar_mul_point_y_shift, ColumnAndShifts::scalar_mul_res_inf_shift, ColumnAndShifts::scalar_mul_res_x_shift, ColumnAndShifts::scalar_mul_res_y_shift, ColumnAndShifts::scalar_mul_scalar_shift, ColumnAndShifts::scalar_mul_sel_shift, ColumnAndShifts::scalar_mul_start_shift, ColumnAndShifts::scalar_mul_temp_inf_shift, ColumnAndShifts::scalar_mul_temp_x_shift, ColumnAndShifts::scalar_mul_temp_y_shift, ColumnAndShifts::sha256_a_shift, ColumnAndShifts::sha256_b_shift, ColumnAndShifts::sha256_c_shift, ColumnAndShifts::sha256_d_shift, ColumnAndShifts::sha256_e_shift, ColumnAndShifts::sha256_f_shift, ColumnAndShifts::sha256_g_shift, ColumnAndShifts::sha256_h_shift, ColumnAndShifts::sha256_helper_w0_shift, ColumnAndShifts::sha256_helper_w1_shift, ColumnAndShifts::sha256_helper_w10_shift, ColumnAndShifts::sha256_helper_w11_shift, ColumnAndShifts::sha256_helper_w12_shift, ColumnAndShifts::sha256_helper_w13_shift, ColumnAndShifts::sha256_helper_w14_shift, ColumnAndShifts::sha256_helper_w15_shift, ColumnAndShifts::sha256_helper_w2_shift, ColumnAndShifts::sha256_helper_w3_shift, ColumnAndShifts::sha256_helper_w4_shift, ColumnAndShifts::sha256_helper_w5_shift, ColumnAndShifts::sha256_helper_w6_shift, ColumnAndShifts::sha256_helper_w7_shift, ColumnAndShifts::sha256_helper_w8_shift, ColumnAndShifts::sha256_helper_w9_shift, ColumnAndShifts::sha256_rounds_remaining_shift, ColumnAndShifts::sha256_sel_shift, ColumnAndShifts::sha256_start_shift, ColumnAndShifts::to_radix_acc_shift, ColumnAndShifts::to_radix_acc_under_p_shift, ColumnAndShifts::to_radix_exponent_shift, ColumnAndShifts::to_radix_limb_shift, ColumnAndShifts::to_radix_limb_eq_p_shift, ColumnAndShifts::to_radix_limb_index_shift, ColumnAndShifts::to_radix_limb_lt_p_shift, ColumnAndShifts::to_radix_not_padding_limb_shift, ColumnAndShifts::to_radix_radix_shift, ColumnAndShifts::to_radix_safe_limbs_shift, ColumnAndShifts::to_radix_sel_shift, ColumnAndShifts::to_radix_start_shift, ColumnAndShifts::to_radix_value_shift +#define AVM2_TO_BE_SHIFTED_COLUMNS Column::bc_decomposition_bytes, Column::bc_decomposition_bytes_pc_plus_1, Column::bc_decomposition_bytes_pc_plus_10, Column::bc_decomposition_bytes_pc_plus_11, Column::bc_decomposition_bytes_pc_plus_12, Column::bc_decomposition_bytes_pc_plus_13, Column::bc_decomposition_bytes_pc_plus_14, Column::bc_decomposition_bytes_pc_plus_15, Column::bc_decomposition_bytes_pc_plus_16, Column::bc_decomposition_bytes_pc_plus_17, Column::bc_decomposition_bytes_pc_plus_18, Column::bc_decomposition_bytes_pc_plus_19, Column::bc_decomposition_bytes_pc_plus_2, Column::bc_decomposition_bytes_pc_plus_20, Column::bc_decomposition_bytes_pc_plus_21, Column::bc_decomposition_bytes_pc_plus_22, Column::bc_decomposition_bytes_pc_plus_23, Column::bc_decomposition_bytes_pc_plus_24, Column::bc_decomposition_bytes_pc_plus_25, Column::bc_decomposition_bytes_pc_plus_26, Column::bc_decomposition_bytes_pc_plus_27, Column::bc_decomposition_bytes_pc_plus_28, Column::bc_decomposition_bytes_pc_plus_29, Column::bc_decomposition_bytes_pc_plus_3, Column::bc_decomposition_bytes_pc_plus_30, Column::bc_decomposition_bytes_pc_plus_31, Column::bc_decomposition_bytes_pc_plus_32, Column::bc_decomposition_bytes_pc_plus_33, Column::bc_decomposition_bytes_pc_plus_34, Column::bc_decomposition_bytes_pc_plus_35, Column::bc_decomposition_bytes_pc_plus_4, Column::bc_decomposition_bytes_pc_plus_5, Column::bc_decomposition_bytes_pc_plus_6, Column::bc_decomposition_bytes_pc_plus_7, Column::bc_decomposition_bytes_pc_plus_8, Column::bc_decomposition_bytes_pc_plus_9, Column::bc_decomposition_bytes_remaining, Column::bc_decomposition_id, Column::bc_decomposition_pc, Column::bc_decomposition_sel, Column::bc_hashing_bytecode_id, Column::bc_hashing_incremental_hash, Column::bc_hashing_pc_index, Column::bc_hashing_sel, Column::bc_hashing_start, Column::bitwise_acc_ia, Column::bitwise_acc_ib, Column::bitwise_acc_ic, Column::bitwise_ctr, Column::bitwise_op_id, Column::execution_sel, Column::instr_fetching_bytecode_id, Column::instr_fetching_bytecode_size, Column::instr_fetching_bytes_remaining, Column::instr_fetching_pc, Column::instr_fetching_sel, Column::poseidon2_hash_a_0, Column::poseidon2_hash_a_1, Column::poseidon2_hash_a_2, Column::poseidon2_hash_a_3, Column::poseidon2_hash_input_0, Column::poseidon2_hash_input_1, Column::poseidon2_hash_input_2, Column::poseidon2_hash_num_perm_rounds_rem, Column::poseidon2_hash_output, Column::poseidon2_hash_sel, Column::poseidon2_hash_start, Column::scalar_mul_bit_idx, Column::scalar_mul_point_inf, Column::scalar_mul_point_x, Column::scalar_mul_point_y, Column::scalar_mul_res_inf, Column::scalar_mul_res_x, Column::scalar_mul_res_y, Column::scalar_mul_scalar, Column::scalar_mul_sel, Column::scalar_mul_start, Column::scalar_mul_temp_inf, Column::scalar_mul_temp_x, Column::scalar_mul_temp_y, Column::sha256_a, Column::sha256_b, Column::sha256_c, Column::sha256_d, Column::sha256_e, Column::sha256_f, Column::sha256_g, Column::sha256_h, Column::sha256_helper_w0, Column::sha256_helper_w1, Column::sha256_helper_w10, Column::sha256_helper_w11, Column::sha256_helper_w12, Column::sha256_helper_w13, Column::sha256_helper_w14, Column::sha256_helper_w15, Column::sha256_helper_w2, Column::sha256_helper_w3, Column::sha256_helper_w4, Column::sha256_helper_w5, Column::sha256_helper_w6, Column::sha256_helper_w7, Column::sha256_helper_w8, Column::sha256_helper_w9, Column::sha256_rounds_remaining, Column::sha256_sel, Column::sha256_start, Column::to_radix_acc, Column::to_radix_acc_under_p, Column::to_radix_exponent, Column::to_radix_limb, Column::to_radix_limb_eq_p, Column::to_radix_limb_index, Column::to_radix_limb_lt_p, Column::to_radix_not_padding_limb, Column::to_radix_radix, Column::to_radix_safe_limbs, Column::to_radix_sel, Column::to_radix_start, Column::to_radix_value +#define AVM2_SHIFTED_COLUMNS ColumnAndShifts::bc_decomposition_bytes_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_1_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_10_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_11_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_12_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_13_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_14_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_15_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_16_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_17_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_18_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_19_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_2_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_20_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_21_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_22_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_23_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_24_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_25_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_26_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_27_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_28_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_29_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_3_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_30_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_31_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_32_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_33_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_34_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_35_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_4_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_5_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_6_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_7_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_8_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_9_shift, ColumnAndShifts::bc_decomposition_bytes_remaining_shift, ColumnAndShifts::bc_decomposition_id_shift, ColumnAndShifts::bc_decomposition_pc_shift, ColumnAndShifts::bc_decomposition_sel_shift, ColumnAndShifts::bc_hashing_bytecode_id_shift, ColumnAndShifts::bc_hashing_incremental_hash_shift, ColumnAndShifts::bc_hashing_pc_index_shift, ColumnAndShifts::bc_hashing_sel_shift, ColumnAndShifts::bc_hashing_start_shift, ColumnAndShifts::bitwise_acc_ia_shift, ColumnAndShifts::bitwise_acc_ib_shift, ColumnAndShifts::bitwise_acc_ic_shift, ColumnAndShifts::bitwise_ctr_shift, ColumnAndShifts::bitwise_op_id_shift, ColumnAndShifts::execution_sel_shift, ColumnAndShifts::instr_fetching_bytecode_id_shift, ColumnAndShifts::instr_fetching_bytecode_size_shift, ColumnAndShifts::instr_fetching_bytes_remaining_shift, ColumnAndShifts::instr_fetching_pc_shift, ColumnAndShifts::instr_fetching_sel_shift, ColumnAndShifts::poseidon2_hash_a_0_shift, ColumnAndShifts::poseidon2_hash_a_1_shift, ColumnAndShifts::poseidon2_hash_a_2_shift, ColumnAndShifts::poseidon2_hash_a_3_shift, ColumnAndShifts::poseidon2_hash_input_0_shift, ColumnAndShifts::poseidon2_hash_input_1_shift, ColumnAndShifts::poseidon2_hash_input_2_shift, ColumnAndShifts::poseidon2_hash_num_perm_rounds_rem_shift, ColumnAndShifts::poseidon2_hash_output_shift, ColumnAndShifts::poseidon2_hash_sel_shift, ColumnAndShifts::poseidon2_hash_start_shift, ColumnAndShifts::scalar_mul_bit_idx_shift, ColumnAndShifts::scalar_mul_point_inf_shift, ColumnAndShifts::scalar_mul_point_x_shift, ColumnAndShifts::scalar_mul_point_y_shift, ColumnAndShifts::scalar_mul_res_inf_shift, ColumnAndShifts::scalar_mul_res_x_shift, ColumnAndShifts::scalar_mul_res_y_shift, ColumnAndShifts::scalar_mul_scalar_shift, ColumnAndShifts::scalar_mul_sel_shift, ColumnAndShifts::scalar_mul_start_shift, ColumnAndShifts::scalar_mul_temp_inf_shift, ColumnAndShifts::scalar_mul_temp_x_shift, ColumnAndShifts::scalar_mul_temp_y_shift, ColumnAndShifts::sha256_a_shift, ColumnAndShifts::sha256_b_shift, ColumnAndShifts::sha256_c_shift, ColumnAndShifts::sha256_d_shift, ColumnAndShifts::sha256_e_shift, ColumnAndShifts::sha256_f_shift, ColumnAndShifts::sha256_g_shift, ColumnAndShifts::sha256_h_shift, ColumnAndShifts::sha256_helper_w0_shift, ColumnAndShifts::sha256_helper_w1_shift, ColumnAndShifts::sha256_helper_w10_shift, ColumnAndShifts::sha256_helper_w11_shift, ColumnAndShifts::sha256_helper_w12_shift, ColumnAndShifts::sha256_helper_w13_shift, ColumnAndShifts::sha256_helper_w14_shift, ColumnAndShifts::sha256_helper_w15_shift, ColumnAndShifts::sha256_helper_w2_shift, ColumnAndShifts::sha256_helper_w3_shift, ColumnAndShifts::sha256_helper_w4_shift, ColumnAndShifts::sha256_helper_w5_shift, ColumnAndShifts::sha256_helper_w6_shift, ColumnAndShifts::sha256_helper_w7_shift, ColumnAndShifts::sha256_helper_w8_shift, ColumnAndShifts::sha256_helper_w9_shift, ColumnAndShifts::sha256_rounds_remaining_shift, ColumnAndShifts::sha256_sel_shift, ColumnAndShifts::sha256_start_shift, ColumnAndShifts::to_radix_acc_shift, ColumnAndShifts::to_radix_acc_under_p_shift, ColumnAndShifts::to_radix_exponent_shift, ColumnAndShifts::to_radix_limb_shift, ColumnAndShifts::to_radix_limb_eq_p_shift, ColumnAndShifts::to_radix_limb_index_shift, ColumnAndShifts::to_radix_limb_lt_p_shift, ColumnAndShifts::to_radix_not_padding_limb_shift, ColumnAndShifts::to_radix_radix_shift, ColumnAndShifts::to_radix_safe_limbs_shift, ColumnAndShifts::to_radix_sel_shift, ColumnAndShifts::to_radix_start_shift, ColumnAndShifts::to_radix_value_shift // clang-format on // All columns minus shifts. @@ -31,8 +31,8 @@ enum class ColumnAndShifts { SENTINEL_DO_NOT_USE, }; -constexpr auto NUM_COLUMNS_WITH_SHIFTS = 1013; -constexpr auto NUM_COLUMNS_WITHOUT_SHIFTS = 898; +constexpr auto NUM_COLUMNS_WITH_SHIFTS = 1031; +constexpr auto NUM_COLUMNS_WITHOUT_SHIFTS = 911; constexpr auto TO_BE_SHIFTED_COLUMNS_ARRAY = []() { return std::array{ AVM2_TO_BE_SHIFTED_COLUMNS }; }(); constexpr auto SHIFTED_COLUMNS_ARRAY = []() { return std::array{ AVM2_SHIFTED_COLUMNS }; }(); static_assert(TO_BE_SHIFTED_COLUMNS_ARRAY.size() == SHIFTED_COLUMNS_ARRAY.size()); diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp index faca728e9857..39410a80e44d 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp @@ -90,12 +90,12 @@ class AvmFlavor { static constexpr bool HasZK = false; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 44; - static constexpr size_t NUM_WITNESS_ENTITIES = 854; - static constexpr size_t NUM_SHIFTED_ENTITIES = 115; + static constexpr size_t NUM_WITNESS_ENTITIES = 867; + static constexpr size_t NUM_SHIFTED_ENTITIES = 120; static constexpr size_t NUM_WIRES = NUM_WITNESS_ENTITIES + NUM_PRECOMPUTED_ENTITIES; // We have two copies of the witness entities, so we subtract the number of fixed ones (they have no shift), one for // the unshifted and one for the shifted - static constexpr size_t NUM_ALL_ENTITIES = 1013; + static constexpr size_t NUM_ALL_ENTITIES = 1031; // In the sumcheck univariate computation, we divide the trace in chunks and each chunk is // evenly processed by all the threads. This constant defines the maximum number of rows @@ -157,6 +157,7 @@ class AvmFlavor { lookup_bitwise_integral_tag_length_relation, lookup_class_id_derivation_class_id_poseidon2_0_relation, lookup_class_id_derivation_class_id_poseidon2_1_relation, + lookup_instr_fetching_abs_diff_positive_relation, lookup_instr_fetching_bytes_from_bc_dec_relation, lookup_instr_fetching_wire_instruction_info_relation, lookup_poseidon2_hash_poseidon2_perm_relation, @@ -435,8 +436,9 @@ class AvmFlavor { this->precomputed_clk = verification_key->precomputed_clk; this->precomputed_exec_opcode = verification_key->precomputed_exec_opcode; this->precomputed_first_row = verification_key->precomputed_first_row; - this->precomputed_instr_size_in_bytes = verification_key->precomputed_instr_size_in_bytes; + this->precomputed_instr_size = verification_key->precomputed_instr_size; this->precomputed_integral_tag_length = verification_key->precomputed_integral_tag_length; + this->precomputed_opcode_out_of_range = verification_key->precomputed_opcode_out_of_range; this->precomputed_p_decomposition_limb = verification_key->precomputed_p_decomposition_limb; this->precomputed_p_decomposition_limb_index = verification_key->precomputed_p_decomposition_limb_index; this->precomputed_p_decomposition_radix = verification_key->precomputed_p_decomposition_radix; @@ -464,7 +466,6 @@ class AvmFlavor { this->precomputed_sel_p_decomposition = verification_key->precomputed_sel_p_decomposition; this->precomputed_sel_range_16 = verification_key->precomputed_sel_range_16; this->precomputed_sel_range_8 = verification_key->precomputed_sel_range_8; - this->precomputed_sel_range_wire_opcode = verification_key->precomputed_sel_range_wire_opcode; this->precomputed_sel_sha256_compression = verification_key->precomputed_sel_sha256_compression; this->precomputed_sel_to_radix_safe_limbs = verification_key->precomputed_sel_to_radix_safe_limbs; this->precomputed_sel_unary = verification_key->precomputed_sel_unary; diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp index c43da9b15267..02b51c6cb756 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp @@ -12,7 +12,8 @@ template class instr_fetchingImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3, 3, 3, 3, 3, 3, 3, 3, 3 }; + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3, 3, 3, 4, 4, 3, 5, 3, 3, 4, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }; template inline static bool skip(const AllEntities& in) { @@ -26,6 +27,8 @@ template class instr_fetchingImpl { [[maybe_unused]] const RelationParameters&, [[maybe_unused]] const FF& scaling_factor) { + const auto instr_fetching_BC_ID_DIFF = + (new_term.instr_fetching_bytecode_id_shift - new_term.instr_fetching_bytecode_id); const auto instr_fetching_SEL_OP_DC_18 = new_term.instr_fetching_sel_op_dc_2 + new_term.instr_fetching_sel_op_dc_6; @@ -37,15 +40,97 @@ template class instr_fetchingImpl { } { using Accumulator = typename std::tuple_element_t<1, ContainerOverSubrelations>; + auto tmp = new_term.instr_fetching_pc_out_of_range * (FF(1) - new_term.instr_fetching_pc_out_of_range); + tmp *= scaling_factor; + std::get<1>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<2, ContainerOverSubrelations>; + auto tmp = + new_term.instr_fetching_instr_out_of_range * (FF(1) - new_term.instr_fetching_instr_out_of_range); + tmp *= scaling_factor; + std::get<2>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<3, ContainerOverSubrelations>; + auto tmp = (new_term.instr_fetching_parsing_err - + (FF(1) - (FF(1) - new_term.instr_fetching_pc_out_of_range) * + (FF(1) - new_term.instr_fetching_instr_out_of_range) * + (FF(1) - new_term.instr_fetching_opcode_out_of_range))); + tmp *= scaling_factor; + std::get<3>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<4, ContainerOverSubrelations>; + auto tmp = (FF(1) - new_term.precomputed_first_row) * (FF(1) - new_term.instr_fetching_sel) * + new_term.instr_fetching_sel_shift; + tmp *= scaling_factor; + std::get<4>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<5, ContainerOverSubrelations>; + auto tmp = new_term.instr_fetching_last_of_bytecode * (FF(1) - new_term.instr_fetching_last_of_bytecode); + tmp *= scaling_factor; + std::get<5>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<6, ContainerOverSubrelations>; + auto tmp = new_term.instr_fetching_sel * + (instr_fetching_BC_ID_DIFF * ((FF(1) - new_term.instr_fetching_last_of_bytecode) * + (FF(1) - new_term.instr_fetching_bc_id_diff_inv) + + new_term.instr_fetching_bc_id_diff_inv) - + new_term.instr_fetching_last_of_bytecode); + tmp *= scaling_factor; + std::get<6>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<7, ContainerOverSubrelations>; + auto tmp = (new_term.instr_fetching_last_of_bytecode + new_term.precomputed_first_row) * + new_term.instr_fetching_pc_shift; + tmp *= scaling_factor; + std::get<7>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<8, ContainerOverSubrelations>; + auto tmp = (new_term.instr_fetching_last_of_bytecode + new_term.precomputed_first_row) * + (new_term.instr_fetching_bytecode_size_shift - new_term.instr_fetching_bytes_remaining_shift); + tmp *= scaling_factor; + std::get<8>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<9, ContainerOverSubrelations>; + auto tmp = new_term.instr_fetching_sel * (FF(1) - new_term.instr_fetching_last_of_bytecode) * + (new_term.instr_fetching_bytecode_size - new_term.instr_fetching_bytecode_size_shift); + tmp *= scaling_factor; + std::get<9>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<10, ContainerOverSubrelations>; + auto tmp = (new_term.instr_fetching_abs_diff - + ((FF(2) * new_term.instr_fetching_instr_out_of_range - FF(1)) * + (new_term.instr_fetching_instr_size - new_term.instr_fetching_bytes_to_read) - + new_term.instr_fetching_instr_out_of_range)); + tmp *= scaling_factor; + std::get<10>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<11, ContainerOverSubrelations>; + auto tmp = (new_term.instr_fetching_sel_lookup_bc_decomposition - + new_term.instr_fetching_sel * (FF(1) - new_term.instr_fetching_pc_out_of_range)); + tmp *= scaling_factor; + std::get<11>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<12, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_indirect - (new_term.instr_fetching_sel_op_dc_0 * (new_term.instr_fetching_bd1 * FF(256) + new_term.instr_fetching_bd2 * FF(1)) + instr_fetching_SEL_OP_DC_18 * new_term.instr_fetching_bd1 * FF(1))); tmp *= scaling_factor; - std::get<1>(evals) += typename Accumulator::View(tmp); + std::get<12>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<2, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<13, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op1 - (new_term.instr_fetching_sel_op_dc_0 * (new_term.instr_fetching_bd3 * FF(256) + new_term.instr_fetching_bd4 * FF(1)) + @@ -56,10 +141,10 @@ template class instr_fetchingImpl { (new_term.instr_fetching_bd1 * FF(16777216) + new_term.instr_fetching_bd2 * FF(65536) + new_term.instr_fetching_bd3 * FF(256) + new_term.instr_fetching_bd4 * FF(1)))); tmp *= scaling_factor; - std::get<2>(evals) += typename Accumulator::View(tmp); + std::get<13>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<3, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<14, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op2 - (new_term.instr_fetching_sel_op_dc_0 * (new_term.instr_fetching_bd5 * FF(256) + new_term.instr_fetching_bd6 * FF(1)) + @@ -71,10 +156,10 @@ template class instr_fetchingImpl { (new_term.instr_fetching_bd4 * FF(16777216) + new_term.instr_fetching_bd5 * FF(65536) + new_term.instr_fetching_bd6 * FF(256) + new_term.instr_fetching_bd7 * FF(1)))); tmp *= scaling_factor; - std::get<3>(evals) += typename Accumulator::View(tmp); + std::get<14>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<4, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<15, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op3 - (new_term.instr_fetching_sel_op_dc_0 * (new_term.instr_fetching_bd7 * FF(256) + new_term.instr_fetching_bd8 * FF(1)) + @@ -141,10 +226,10 @@ template class instr_fetchingImpl { new_term.instr_fetching_sel_op_dc_14 * new_term.instr_fetching_bd4 * FF(1) + new_term.instr_fetching_sel_op_dc_17 * new_term.instr_fetching_bd6 * FF(1))); tmp *= scaling_factor; - std::get<4>(evals) += typename Accumulator::View(tmp); + std::get<15>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<5, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<16, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op4 - (new_term.instr_fetching_sel_op_dc_0 * (new_term.instr_fetching_bd9 * FF(256) + new_term.instr_fetching_bd10 * FF(1)) + @@ -152,31 +237,31 @@ template class instr_fetchingImpl { (new_term.instr_fetching_bd8 * FF(256) + new_term.instr_fetching_bd9 * FF(1)) + new_term.instr_fetching_sel_op_dc_7 * new_term.instr_fetching_bd8 * FF(1))); tmp *= scaling_factor; - std::get<5>(evals) += typename Accumulator::View(tmp); + std::get<16>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<6, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<17, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op5 - new_term.instr_fetching_sel_op_dc_0 * (new_term.instr_fetching_bd11 * FF(256) + new_term.instr_fetching_bd12 * FF(1))); tmp *= scaling_factor; - std::get<6>(evals) += typename Accumulator::View(tmp); + std::get<17>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<7, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<18, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op6 - new_term.instr_fetching_sel_op_dc_1 * (new_term.instr_fetching_bd13 * FF(256) + new_term.instr_fetching_bd14 * FF(1))); tmp *= scaling_factor; - std::get<7>(evals) += typename Accumulator::View(tmp); + std::get<18>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<8, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<19, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op7 - new_term.instr_fetching_sel_op_dc_1 * (new_term.instr_fetching_bd15 * FF(256) + new_term.instr_fetching_bd16 * FF(1))); tmp *= scaling_factor; - std::get<8>(evals) += typename Accumulator::View(tmp); + std::get<19>(evals) += typename Accumulator::View(tmp); } } }; @@ -188,35 +273,44 @@ template class instr_fetching : public Relation SRC_COLUMNS = { + ColumnAndShifts::instr_fetching_abs_diff + }; + static constexpr std::array DST_COLUMNS = { ColumnAndShifts::precomputed_clk }; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in._instr_fetching_sel() == 1 || in._precomputed_sel_range_8() == 1); + } + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in._instr_fetching_sel()); + const auto is_table_entry = View(in._precomputed_sel_range_8()); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + template static inline auto get_const_entities(const AllEntities& in) + { + return get_entities(in); + } + + template static inline auto get_nonconst_entities(AllEntities& in) + { + return get_entities(in); + } + + template static inline auto get_entities(AllEntities&& in) + { + return std::forward_as_tuple(in._lookup_instr_fetching_abs_diff_positive_inv(), + in._lookup_instr_fetching_abs_diff_positive_counts(), + in._instr_fetching_sel(), + in._precomputed_sel_range_8(), + in._instr_fetching_abs_diff(), + in._precomputed_clk()); + } +}; + +template +class lookup_instr_fetching_abs_diff_positive_relation + : public GenericLookupRelation { + public: + using Settings = lookup_instr_fetching_abs_diff_positive_settings; + static constexpr std::string_view NAME = lookup_instr_fetching_abs_diff_positive_settings::NAME; + static constexpr std::string_view RELATION_NAME = lookup_instr_fetching_abs_diff_positive_settings::RELATION_NAME; + + template inline static bool skip(const AllEntities& in) + { + return in.lookup_instr_fetching_abs_diff_positive_inv.is_zero(); + } + + static std::string get_subrelation_label(size_t index) + { + if (index == 0) { + return "INVERSES_ARE_CORRECT"; + } else if (index == 1) { + return "ACCUMULATION_IS_CORRECT"; + } + return std::to_string(index); + } +}; + /////////////////// lookup_instr_fetching_bytes_from_bc_dec /////////////////// class lookup_instr_fetching_bytes_from_bc_dec_settings { @@ -21,41 +106,64 @@ class lookup_instr_fetching_bytes_from_bc_dec_settings { static constexpr size_t WRITE_TERMS = 1; static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - static constexpr size_t LOOKUP_TUPLE_SIZE = 39; + static constexpr size_t LOOKUP_TUPLE_SIZE = 41; static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; static constexpr size_t READ_TERM_DEGREE = 0; static constexpr size_t WRITE_TERM_DEGREE = 0; // Columns using the Column enum. - static constexpr Column SRC_SELECTOR = Column::instr_fetching_sel; + static constexpr Column SRC_SELECTOR = Column::instr_fetching_sel_lookup_bc_decomposition; static constexpr Column DST_SELECTOR = Column::bc_decomposition_sel; static constexpr Column COUNTS = Column::lookup_instr_fetching_bytes_from_bc_dec_counts; static constexpr Column INVERSES = Column::lookup_instr_fetching_bytes_from_bc_dec_inv; static constexpr std::array SRC_COLUMNS = { - ColumnAndShifts::instr_fetching_pc, ColumnAndShifts::instr_fetching_bytecode_id, - ColumnAndShifts::instr_fetching_bd0, ColumnAndShifts::instr_fetching_bd1, - ColumnAndShifts::instr_fetching_bd2, ColumnAndShifts::instr_fetching_bd3, - ColumnAndShifts::instr_fetching_bd4, ColumnAndShifts::instr_fetching_bd5, - ColumnAndShifts::instr_fetching_bd6, ColumnAndShifts::instr_fetching_bd7, - ColumnAndShifts::instr_fetching_bd8, ColumnAndShifts::instr_fetching_bd9, - ColumnAndShifts::instr_fetching_bd10, ColumnAndShifts::instr_fetching_bd11, - ColumnAndShifts::instr_fetching_bd12, ColumnAndShifts::instr_fetching_bd13, - ColumnAndShifts::instr_fetching_bd14, ColumnAndShifts::instr_fetching_bd15, - ColumnAndShifts::instr_fetching_bd16, ColumnAndShifts::instr_fetching_bd17, - ColumnAndShifts::instr_fetching_bd18, ColumnAndShifts::instr_fetching_bd19, - ColumnAndShifts::instr_fetching_bd20, ColumnAndShifts::instr_fetching_bd21, - ColumnAndShifts::instr_fetching_bd22, ColumnAndShifts::instr_fetching_bd23, - ColumnAndShifts::instr_fetching_bd24, ColumnAndShifts::instr_fetching_bd25, - ColumnAndShifts::instr_fetching_bd26, ColumnAndShifts::instr_fetching_bd27, - ColumnAndShifts::instr_fetching_bd28, ColumnAndShifts::instr_fetching_bd29, - ColumnAndShifts::instr_fetching_bd30, ColumnAndShifts::instr_fetching_bd31, - ColumnAndShifts::instr_fetching_bd32, ColumnAndShifts::instr_fetching_bd33, - ColumnAndShifts::instr_fetching_bd34, ColumnAndShifts::instr_fetching_bd35, + ColumnAndShifts::instr_fetching_pc, + ColumnAndShifts::instr_fetching_bytecode_id, + ColumnAndShifts::instr_fetching_bytes_remaining, + ColumnAndShifts::instr_fetching_bytes_to_read, + ColumnAndShifts::instr_fetching_bd0, + ColumnAndShifts::instr_fetching_bd1, + ColumnAndShifts::instr_fetching_bd2, + ColumnAndShifts::instr_fetching_bd3, + ColumnAndShifts::instr_fetching_bd4, + ColumnAndShifts::instr_fetching_bd5, + ColumnAndShifts::instr_fetching_bd6, + ColumnAndShifts::instr_fetching_bd7, + ColumnAndShifts::instr_fetching_bd8, + ColumnAndShifts::instr_fetching_bd9, + ColumnAndShifts::instr_fetching_bd10, + ColumnAndShifts::instr_fetching_bd11, + ColumnAndShifts::instr_fetching_bd12, + ColumnAndShifts::instr_fetching_bd13, + ColumnAndShifts::instr_fetching_bd14, + ColumnAndShifts::instr_fetching_bd15, + ColumnAndShifts::instr_fetching_bd16, + ColumnAndShifts::instr_fetching_bd17, + ColumnAndShifts::instr_fetching_bd18, + ColumnAndShifts::instr_fetching_bd19, + ColumnAndShifts::instr_fetching_bd20, + ColumnAndShifts::instr_fetching_bd21, + ColumnAndShifts::instr_fetching_bd22, + ColumnAndShifts::instr_fetching_bd23, + ColumnAndShifts::instr_fetching_bd24, + ColumnAndShifts::instr_fetching_bd25, + ColumnAndShifts::instr_fetching_bd26, + ColumnAndShifts::instr_fetching_bd27, + ColumnAndShifts::instr_fetching_bd28, + ColumnAndShifts::instr_fetching_bd29, + ColumnAndShifts::instr_fetching_bd30, + ColumnAndShifts::instr_fetching_bd31, + ColumnAndShifts::instr_fetching_bd32, + ColumnAndShifts::instr_fetching_bd33, + ColumnAndShifts::instr_fetching_bd34, + ColumnAndShifts::instr_fetching_bd35, ColumnAndShifts::instr_fetching_bd36 }; static constexpr std::array DST_COLUMNS = { ColumnAndShifts::bc_decomposition_pc, ColumnAndShifts::bc_decomposition_id, + ColumnAndShifts::bc_decomposition_bytes_remaining, + ColumnAndShifts::bc_decomposition_bytes_to_read, ColumnAndShifts::bc_decomposition_bytes, ColumnAndShifts::bc_decomposition_bytes_pc_plus_1, ColumnAndShifts::bc_decomposition_bytes_pc_plus_2, @@ -97,14 +205,14 @@ class lookup_instr_fetching_bytes_from_bc_dec_settings { template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { - return (in._instr_fetching_sel() == 1 || in._bc_decomposition_sel() == 1); + return (in._instr_fetching_sel_lookup_bc_decomposition() == 1 || in._bc_decomposition_sel() == 1); } template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; - const auto is_operation = View(in._instr_fetching_sel()); + const auto is_operation = View(in._instr_fetching_sel_lookup_bc_decomposition()); const auto is_table_entry = View(in._bc_decomposition_sel()); return (is_operation + is_table_entry - is_operation * is_table_entry); } @@ -123,10 +231,12 @@ class lookup_instr_fetching_bytes_from_bc_dec_settings { { return std::forward_as_tuple(in._lookup_instr_fetching_bytes_from_bc_dec_inv(), in._lookup_instr_fetching_bytes_from_bc_dec_counts(), - in._instr_fetching_sel(), + in._instr_fetching_sel_lookup_bc_decomposition(), in._bc_decomposition_sel(), in._instr_fetching_pc(), in._instr_fetching_bytecode_id(), + in._instr_fetching_bytes_remaining(), + in._instr_fetching_bytes_to_read(), in._instr_fetching_bd0(), in._instr_fetching_bd1(), in._instr_fetching_bd2(), @@ -166,6 +276,8 @@ class lookup_instr_fetching_bytes_from_bc_dec_settings { in._instr_fetching_bd36(), in._bc_decomposition_pc(), in._bc_decomposition_id(), + in._bc_decomposition_bytes_remaining(), + in._bc_decomposition_bytes_to_read(), in._bc_decomposition_bytes(), in._bc_decomposition_bytes_pc_plus_1(), in._bc_decomposition_bytes_pc_plus_2(), @@ -241,66 +353,46 @@ class lookup_instr_fetching_wire_instruction_info_settings { static constexpr size_t WRITE_TERMS = 1; static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - static constexpr size_t LOOKUP_TUPLE_SIZE = 21; + static constexpr size_t LOOKUP_TUPLE_SIZE = 22; static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; static constexpr size_t READ_TERM_DEGREE = 0; static constexpr size_t WRITE_TERM_DEGREE = 0; // Columns using the Column enum. static constexpr Column SRC_SELECTOR = Column::instr_fetching_sel; - static constexpr Column DST_SELECTOR = Column::precomputed_sel_range_wire_opcode; + static constexpr Column DST_SELECTOR = Column::precomputed_sel_range_8; static constexpr Column COUNTS = Column::lookup_instr_fetching_wire_instruction_info_counts; static constexpr Column INVERSES = Column::lookup_instr_fetching_wire_instruction_info_inv; static constexpr std::array SRC_COLUMNS = { - ColumnAndShifts::instr_fetching_bd0, - ColumnAndShifts::instr_fetching_exec_opcode, - ColumnAndShifts::instr_fetching_instr_size_in_bytes, - ColumnAndShifts::instr_fetching_sel_op_dc_0, - ColumnAndShifts::instr_fetching_sel_op_dc_1, - ColumnAndShifts::instr_fetching_sel_op_dc_2, - ColumnAndShifts::instr_fetching_sel_op_dc_3, - ColumnAndShifts::instr_fetching_sel_op_dc_4, - ColumnAndShifts::instr_fetching_sel_op_dc_5, - ColumnAndShifts::instr_fetching_sel_op_dc_6, - ColumnAndShifts::instr_fetching_sel_op_dc_7, - ColumnAndShifts::instr_fetching_sel_op_dc_8, - ColumnAndShifts::instr_fetching_sel_op_dc_9, - ColumnAndShifts::instr_fetching_sel_op_dc_10, - ColumnAndShifts::instr_fetching_sel_op_dc_11, - ColumnAndShifts::instr_fetching_sel_op_dc_12, - ColumnAndShifts::instr_fetching_sel_op_dc_13, - ColumnAndShifts::instr_fetching_sel_op_dc_14, - ColumnAndShifts::instr_fetching_sel_op_dc_15, - ColumnAndShifts::instr_fetching_sel_op_dc_16, - ColumnAndShifts::instr_fetching_sel_op_dc_17 + ColumnAndShifts::instr_fetching_bd0, ColumnAndShifts::instr_fetching_opcode_out_of_range, + ColumnAndShifts::instr_fetching_exec_opcode, ColumnAndShifts::instr_fetching_instr_size, + ColumnAndShifts::instr_fetching_sel_op_dc_0, ColumnAndShifts::instr_fetching_sel_op_dc_1, + ColumnAndShifts::instr_fetching_sel_op_dc_2, ColumnAndShifts::instr_fetching_sel_op_dc_3, + ColumnAndShifts::instr_fetching_sel_op_dc_4, ColumnAndShifts::instr_fetching_sel_op_dc_5, + ColumnAndShifts::instr_fetching_sel_op_dc_6, ColumnAndShifts::instr_fetching_sel_op_dc_7, + ColumnAndShifts::instr_fetching_sel_op_dc_8, ColumnAndShifts::instr_fetching_sel_op_dc_9, + ColumnAndShifts::instr_fetching_sel_op_dc_10, ColumnAndShifts::instr_fetching_sel_op_dc_11, + ColumnAndShifts::instr_fetching_sel_op_dc_12, ColumnAndShifts::instr_fetching_sel_op_dc_13, + ColumnAndShifts::instr_fetching_sel_op_dc_14, ColumnAndShifts::instr_fetching_sel_op_dc_15, + ColumnAndShifts::instr_fetching_sel_op_dc_16, ColumnAndShifts::instr_fetching_sel_op_dc_17 }; static constexpr std::array DST_COLUMNS = { - ColumnAndShifts::precomputed_clk, - ColumnAndShifts::precomputed_exec_opcode, - ColumnAndShifts::precomputed_instr_size_in_bytes, - ColumnAndShifts::precomputed_sel_op_dc_0, - ColumnAndShifts::precomputed_sel_op_dc_1, - ColumnAndShifts::precomputed_sel_op_dc_2, - ColumnAndShifts::precomputed_sel_op_dc_3, - ColumnAndShifts::precomputed_sel_op_dc_4, - ColumnAndShifts::precomputed_sel_op_dc_5, - ColumnAndShifts::precomputed_sel_op_dc_6, - ColumnAndShifts::precomputed_sel_op_dc_7, - ColumnAndShifts::precomputed_sel_op_dc_8, - ColumnAndShifts::precomputed_sel_op_dc_9, - ColumnAndShifts::precomputed_sel_op_dc_10, - ColumnAndShifts::precomputed_sel_op_dc_11, - ColumnAndShifts::precomputed_sel_op_dc_12, - ColumnAndShifts::precomputed_sel_op_dc_13, - ColumnAndShifts::precomputed_sel_op_dc_14, - ColumnAndShifts::precomputed_sel_op_dc_15, - ColumnAndShifts::precomputed_sel_op_dc_16, - ColumnAndShifts::precomputed_sel_op_dc_17 + ColumnAndShifts::precomputed_clk, ColumnAndShifts::precomputed_opcode_out_of_range, + ColumnAndShifts::precomputed_exec_opcode, ColumnAndShifts::precomputed_instr_size, + ColumnAndShifts::precomputed_sel_op_dc_0, ColumnAndShifts::precomputed_sel_op_dc_1, + ColumnAndShifts::precomputed_sel_op_dc_2, ColumnAndShifts::precomputed_sel_op_dc_3, + ColumnAndShifts::precomputed_sel_op_dc_4, ColumnAndShifts::precomputed_sel_op_dc_5, + ColumnAndShifts::precomputed_sel_op_dc_6, ColumnAndShifts::precomputed_sel_op_dc_7, + ColumnAndShifts::precomputed_sel_op_dc_8, ColumnAndShifts::precomputed_sel_op_dc_9, + ColumnAndShifts::precomputed_sel_op_dc_10, ColumnAndShifts::precomputed_sel_op_dc_11, + ColumnAndShifts::precomputed_sel_op_dc_12, ColumnAndShifts::precomputed_sel_op_dc_13, + ColumnAndShifts::precomputed_sel_op_dc_14, ColumnAndShifts::precomputed_sel_op_dc_15, + ColumnAndShifts::precomputed_sel_op_dc_16, ColumnAndShifts::precomputed_sel_op_dc_17 }; template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { - return (in._instr_fetching_sel() == 1 || in._precomputed_sel_range_wire_opcode() == 1); + return (in._instr_fetching_sel() == 1 || in._precomputed_sel_range_8() == 1); } template @@ -308,7 +400,7 @@ class lookup_instr_fetching_wire_instruction_info_settings { { using View = typename Accumulator::View; const auto is_operation = View(in._instr_fetching_sel()); - const auto is_table_entry = View(in._precomputed_sel_range_wire_opcode()); + const auto is_table_entry = View(in._precomputed_sel_range_8()); return (is_operation + is_table_entry - is_operation * is_table_entry); } @@ -327,10 +419,11 @@ class lookup_instr_fetching_wire_instruction_info_settings { return std::forward_as_tuple(in._lookup_instr_fetching_wire_instruction_info_inv(), in._lookup_instr_fetching_wire_instruction_info_counts(), in._instr_fetching_sel(), - in._precomputed_sel_range_wire_opcode(), + in._precomputed_sel_range_8(), in._instr_fetching_bd0(), + in._instr_fetching_opcode_out_of_range(), in._instr_fetching_exec_opcode(), - in._instr_fetching_instr_size_in_bytes(), + in._instr_fetching_instr_size(), in._instr_fetching_sel_op_dc_0(), in._instr_fetching_sel_op_dc_1(), in._instr_fetching_sel_op_dc_2(), @@ -350,8 +443,9 @@ class lookup_instr_fetching_wire_instruction_info_settings { in._instr_fetching_sel_op_dc_16(), in._instr_fetching_sel_op_dc_17(), in._precomputed_clk(), + in._precomputed_opcode_out_of_range(), in._precomputed_exec_opcode(), - in._precomputed_instr_size_in_bytes(), + in._precomputed_instr_size(), in._precomputed_sel_op_dc_0(), in._precomputed_sel_op_dc_1(), in._precomputed_sel_op_dc_2(), diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/bytecode_events.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/bytecode_events.hpp index c4a6f8829f35..6b5c80e7ef36 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/bytecode_events.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/bytecode_events.hpp @@ -39,12 +39,20 @@ struct BytecodeRetrievalEvent { bool error = false; }; +enum class InstructionFetchingError : uint8_t { + NO_ERROR, + PC_OUT_OF_RANGE, + OPCODE_OUT_OF_RANGE, + INSTRUCTION_OUT_OF_RANGE, +}; + struct InstructionFetchingEvent { BytecodeId bytecode_id; uint32_t pc; // TODO: Do we want to have a dep on Instruction here or do we redefine what we need? Instruction instruction; std::shared_ptr> bytecode; + InstructionFetchingError error = InstructionFetchingError::NO_ERROR; // To be used with deduplicating event emitters. using Key = std::tuple; diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp index 5e7b445516d0..d5b4fbb850be 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp @@ -246,95 +246,165 @@ void BytecodeTraceBuilder::process_instruction_fetching( TraceContainer& trace) { using C = Column; + using simulation::BytecodeId; + using simulation::InstructionFetchingEvent; + using simulation::InstructionFetchingError::INSTRUCTION_OUT_OF_RANGE; + using simulation::InstructionFetchingError::NO_ERROR; + using simulation::InstructionFetchingError::OPCODE_OUT_OF_RANGE; + using simulation::InstructionFetchingError::PC_OUT_OF_RANGE; - uint32_t row = 0; - for (const auto& event : events) { - auto get_operand = [&](size_t i) -> FF { - return i < event.instruction.operands.size() ? static_cast(event.instruction.operands[i]) : 0; - }; - auto bytecode_at = [&](size_t i) -> uint8_t { return i < event.bytecode->size() ? (*event.bytecode)[i] : 0; }; - - const uint8_t wire_opcode = bytecode_at(event.pc); - const auto w_opcode = static_cast(wire_opcode); - - trace.set(row, - { { - { C::instr_fetching_sel, 1 }, - { C::instr_fetching_bytecode_id, event.bytecode_id }, - { C::instr_fetching_pc, event.pc }, - // indirect + operands. - { C::instr_fetching_indirect, event.instruction.indirect }, - { C::instr_fetching_op1, get_operand(0) }, - { C::instr_fetching_op2, get_operand(1) }, - { C::instr_fetching_op3, get_operand(2) }, - { C::instr_fetching_op4, get_operand(3) }, - { C::instr_fetching_op5, get_operand(4) }, - { C::instr_fetching_op6, get_operand(5) }, - { C::instr_fetching_op7, get_operand(6) }, - // Single bytes. - { C::instr_fetching_bd0, wire_opcode }, - { C::instr_fetching_bd1, bytecode_at(event.pc + 1) }, - { C::instr_fetching_bd2, bytecode_at(event.pc + 2) }, - { C::instr_fetching_bd3, bytecode_at(event.pc + 3) }, - { C::instr_fetching_bd4, bytecode_at(event.pc + 4) }, - { C::instr_fetching_bd5, bytecode_at(event.pc + 5) }, - { C::instr_fetching_bd6, bytecode_at(event.pc + 6) }, - { C::instr_fetching_bd7, bytecode_at(event.pc + 7) }, - { C::instr_fetching_bd8, bytecode_at(event.pc + 8) }, - { C::instr_fetching_bd9, bytecode_at(event.pc + 9) }, - { C::instr_fetching_bd10, bytecode_at(event.pc + 10) }, - { C::instr_fetching_bd11, bytecode_at(event.pc + 11) }, - { C::instr_fetching_bd12, bytecode_at(event.pc + 12) }, - { C::instr_fetching_bd13, bytecode_at(event.pc + 13) }, - { C::instr_fetching_bd14, bytecode_at(event.pc + 14) }, - { C::instr_fetching_bd15, bytecode_at(event.pc + 15) }, - { C::instr_fetching_bd16, bytecode_at(event.pc + 16) }, - { C::instr_fetching_bd17, bytecode_at(event.pc + 17) }, - { C::instr_fetching_bd18, bytecode_at(event.pc + 18) }, - { C::instr_fetching_bd19, bytecode_at(event.pc + 19) }, - { C::instr_fetching_bd20, bytecode_at(event.pc + 20) }, - { C::instr_fetching_bd21, bytecode_at(event.pc + 21) }, - { C::instr_fetching_bd22, bytecode_at(event.pc + 22) }, - { C::instr_fetching_bd23, bytecode_at(event.pc + 23) }, - { C::instr_fetching_bd24, bytecode_at(event.pc + 24) }, - { C::instr_fetching_bd25, bytecode_at(event.pc + 25) }, - { C::instr_fetching_bd26, bytecode_at(event.pc + 26) }, - { C::instr_fetching_bd27, bytecode_at(event.pc + 27) }, - { C::instr_fetching_bd28, bytecode_at(event.pc + 28) }, - { C::instr_fetching_bd29, bytecode_at(event.pc + 29) }, - { C::instr_fetching_bd30, bytecode_at(event.pc + 30) }, - { C::instr_fetching_bd31, bytecode_at(event.pc + 31) }, - { C::instr_fetching_bd32, bytecode_at(event.pc + 32) }, - { C::instr_fetching_bd33, bytecode_at(event.pc + 33) }, - { C::instr_fetching_bd34, bytecode_at(event.pc + 34) }, - { C::instr_fetching_bd35, bytecode_at(event.pc + 35) }, - { C::instr_fetching_bd36, bytecode_at(event.pc + 36) }, - - // From instruction table. - { C::instr_fetching_exec_opcode, - static_cast(WIRE_INSTRUCTION_SPEC.at(w_opcode).exec_opcode) }, - { C::instr_fetching_instr_size_in_bytes, WIRE_INSTRUCTION_SPEC.at(w_opcode).size_in_bytes }, - // Fill operand decomposition selectors - { C::instr_fetching_sel_op_dc_0, WIRE_INSTRUCTION_SPEC.at(w_opcode).op_dc_selectors.at(0) }, - { C::instr_fetching_sel_op_dc_1, WIRE_INSTRUCTION_SPEC.at(w_opcode).op_dc_selectors.at(1) }, - { C::instr_fetching_sel_op_dc_2, WIRE_INSTRUCTION_SPEC.at(w_opcode).op_dc_selectors.at(2) }, - { C::instr_fetching_sel_op_dc_3, WIRE_INSTRUCTION_SPEC.at(w_opcode).op_dc_selectors.at(3) }, - { C::instr_fetching_sel_op_dc_4, WIRE_INSTRUCTION_SPEC.at(w_opcode).op_dc_selectors.at(4) }, - { C::instr_fetching_sel_op_dc_5, WIRE_INSTRUCTION_SPEC.at(w_opcode).op_dc_selectors.at(5) }, - { C::instr_fetching_sel_op_dc_6, WIRE_INSTRUCTION_SPEC.at(w_opcode).op_dc_selectors.at(6) }, - { C::instr_fetching_sel_op_dc_7, WIRE_INSTRUCTION_SPEC.at(w_opcode).op_dc_selectors.at(7) }, - { C::instr_fetching_sel_op_dc_8, WIRE_INSTRUCTION_SPEC.at(w_opcode).op_dc_selectors.at(8) }, - { C::instr_fetching_sel_op_dc_9, WIRE_INSTRUCTION_SPEC.at(w_opcode).op_dc_selectors.at(9) }, - { C::instr_fetching_sel_op_dc_10, WIRE_INSTRUCTION_SPEC.at(w_opcode).op_dc_selectors.at(10) }, - { C::instr_fetching_sel_op_dc_11, WIRE_INSTRUCTION_SPEC.at(w_opcode).op_dc_selectors.at(11) }, - { C::instr_fetching_sel_op_dc_12, WIRE_INSTRUCTION_SPEC.at(w_opcode).op_dc_selectors.at(12) }, - { C::instr_fetching_sel_op_dc_13, WIRE_INSTRUCTION_SPEC.at(w_opcode).op_dc_selectors.at(13) }, - { C::instr_fetching_sel_op_dc_14, WIRE_INSTRUCTION_SPEC.at(w_opcode).op_dc_selectors.at(14) }, - { C::instr_fetching_sel_op_dc_15, WIRE_INSTRUCTION_SPEC.at(w_opcode).op_dc_selectors.at(15) }, - { C::instr_fetching_sel_op_dc_16, WIRE_INSTRUCTION_SPEC.at(w_opcode).op_dc_selectors.at(16) }, - { C::instr_fetching_sel_op_dc_17, WIRE_INSTRUCTION_SPEC.at(w_opcode).op_dc_selectors.at(17) }, - } }); - row++; + // We start from row 1 because we need a row of zeroes for the shifts. + uint32_t row = 1; + + // Group and process events per bytecode_id. + // The trace is expecting all rows pertaining to a given bytecode_id to be contigous. + unordered_flat_map> bytecode_id_to_events; + + for (size_t i = 0; i < events.size(); i++) { + if (bytecode_id_to_events.contains(events.at(i).bytecode_id)) { + bytecode_id_to_events.at(events.at(i).bytecode_id).push_back(i); + } else { + assert(events.at(i).pc == 0); + bytecode_id_to_events[events.at(i).bytecode_id] = { i }; + } + } + + for (auto it = bytecode_id_to_events.begin(); it != bytecode_id_to_events.end(); it++) { + const auto& event_indices = it->second; + const auto& bytecode_id = it->first; + const BytecodeId next_bytecode_id = next(it) != bytecode_id_to_events.end() ? next(it)->first : 0; + + for (const auto& idx : event_indices) { + const auto& event = events.at(idx); + const auto bytecode_size = event.bytecode->size(); + + auto get_operand = [&](size_t i) -> FF { + return i < event.instruction.operands.size() ? static_cast(event.instruction.operands[i]) : 0; + }; + auto bytecode_at = [&](size_t i) -> uint8_t { return i < bytecode_size ? (*event.bytecode)[i] : 0; }; + + const bool is_last_of_bytecode = event_indices.back() == idx && bytecode_id != next_bytecode_id; + + FF bytecode_id_diff_inv = 0; + if (is_last_of_bytecode) { + bytecode_id_diff_inv = (FF(next_bytecode_id) - FF(bytecode_id)).invert(); + } + + const uint8_t wire_opcode = bytecode_at(event.pc); + const bool wire_opcode_in_range = wire_opcode < static_cast(WireOpCode::LAST_OPCODE_SENTINEL); + const auto wire_instr_spec = wire_opcode_in_range + ? WIRE_INSTRUCTION_SPEC.at(static_cast(wire_opcode)) + : WireInstructionSpec{ .exec_opcode = static_cast(0), + .size_in_bytes = 0, + .op_dc_selectors = {} }; + + const uint32_t bytes_remaining = + event.error == PC_OUT_OF_RANGE ? 0 : static_cast(bytecode_size - event.pc); + const uint32_t bytes_to_read = std::min(bytes_remaining, DECOMPOSE_WINDOW_SIZE); + + uint32_t abs_diff = 0; + if (wire_instr_spec.size_in_bytes <= bytes_to_read) { + abs_diff = bytes_to_read - wire_instr_spec.size_in_bytes; + } else { + abs_diff = wire_instr_spec.size_in_bytes - bytes_to_read - 1; + } + + trace.set(row, + { { + { C::instr_fetching_sel, 1 }, + { C::instr_fetching_bytecode_id, bytecode_id }, + { C::instr_fetching_pc, event.pc }, + // indirect + operands. + { C::instr_fetching_indirect, event.instruction.indirect }, + { C::instr_fetching_op1, get_operand(0) }, + { C::instr_fetching_op2, get_operand(1) }, + { C::instr_fetching_op3, get_operand(2) }, + { C::instr_fetching_op4, get_operand(3) }, + { C::instr_fetching_op5, get_operand(4) }, + { C::instr_fetching_op6, get_operand(5) }, + { C::instr_fetching_op7, get_operand(6) }, + // Single bytes. + { C::instr_fetching_bd0, wire_opcode }, + { C::instr_fetching_bd1, bytecode_at(event.pc + 1) }, + { C::instr_fetching_bd2, bytecode_at(event.pc + 2) }, + { C::instr_fetching_bd3, bytecode_at(event.pc + 3) }, + { C::instr_fetching_bd4, bytecode_at(event.pc + 4) }, + { C::instr_fetching_bd5, bytecode_at(event.pc + 5) }, + { C::instr_fetching_bd6, bytecode_at(event.pc + 6) }, + { C::instr_fetching_bd7, bytecode_at(event.pc + 7) }, + { C::instr_fetching_bd8, bytecode_at(event.pc + 8) }, + { C::instr_fetching_bd9, bytecode_at(event.pc + 9) }, + { C::instr_fetching_bd10, bytecode_at(event.pc + 10) }, + { C::instr_fetching_bd11, bytecode_at(event.pc + 11) }, + { C::instr_fetching_bd12, bytecode_at(event.pc + 12) }, + { C::instr_fetching_bd13, bytecode_at(event.pc + 13) }, + { C::instr_fetching_bd14, bytecode_at(event.pc + 14) }, + { C::instr_fetching_bd15, bytecode_at(event.pc + 15) }, + { C::instr_fetching_bd16, bytecode_at(event.pc + 16) }, + { C::instr_fetching_bd17, bytecode_at(event.pc + 17) }, + { C::instr_fetching_bd18, bytecode_at(event.pc + 18) }, + { C::instr_fetching_bd19, bytecode_at(event.pc + 19) }, + { C::instr_fetching_bd20, bytecode_at(event.pc + 20) }, + { C::instr_fetching_bd21, bytecode_at(event.pc + 21) }, + { C::instr_fetching_bd22, bytecode_at(event.pc + 22) }, + { C::instr_fetching_bd23, bytecode_at(event.pc + 23) }, + { C::instr_fetching_bd24, bytecode_at(event.pc + 24) }, + { C::instr_fetching_bd25, bytecode_at(event.pc + 25) }, + { C::instr_fetching_bd26, bytecode_at(event.pc + 26) }, + { C::instr_fetching_bd27, bytecode_at(event.pc + 27) }, + { C::instr_fetching_bd28, bytecode_at(event.pc + 28) }, + { C::instr_fetching_bd29, bytecode_at(event.pc + 29) }, + { C::instr_fetching_bd30, bytecode_at(event.pc + 30) }, + { C::instr_fetching_bd31, bytecode_at(event.pc + 31) }, + { C::instr_fetching_bd32, bytecode_at(event.pc + 32) }, + { C::instr_fetching_bd33, bytecode_at(event.pc + 33) }, + { C::instr_fetching_bd34, bytecode_at(event.pc + 34) }, + { C::instr_fetching_bd35, bytecode_at(event.pc + 35) }, + { C::instr_fetching_bd36, bytecode_at(event.pc + 36) }, + + // From instruction table. + { C::instr_fetching_exec_opcode, static_cast(wire_instr_spec.exec_opcode) }, + { C::instr_fetching_instr_size, wire_instr_spec.size_in_bytes }, + { C::instr_fetching_opcode_out_of_range, wire_opcode_in_range ? 0 : 1 }, + + // Fill operand decomposition selectors + { C::instr_fetching_sel_op_dc_0, wire_instr_spec.op_dc_selectors.at(0) }, + { C::instr_fetching_sel_op_dc_1, wire_instr_spec.op_dc_selectors.at(1) }, + { C::instr_fetching_sel_op_dc_2, wire_instr_spec.op_dc_selectors.at(2) }, + { C::instr_fetching_sel_op_dc_3, wire_instr_spec.op_dc_selectors.at(3) }, + { C::instr_fetching_sel_op_dc_4, wire_instr_spec.op_dc_selectors.at(4) }, + { C::instr_fetching_sel_op_dc_5, wire_instr_spec.op_dc_selectors.at(5) }, + { C::instr_fetching_sel_op_dc_6, wire_instr_spec.op_dc_selectors.at(6) }, + { C::instr_fetching_sel_op_dc_7, wire_instr_spec.op_dc_selectors.at(7) }, + { C::instr_fetching_sel_op_dc_8, wire_instr_spec.op_dc_selectors.at(8) }, + { C::instr_fetching_sel_op_dc_9, wire_instr_spec.op_dc_selectors.at(9) }, + { C::instr_fetching_sel_op_dc_10, wire_instr_spec.op_dc_selectors.at(10) }, + { C::instr_fetching_sel_op_dc_11, wire_instr_spec.op_dc_selectors.at(11) }, + { C::instr_fetching_sel_op_dc_12, wire_instr_spec.op_dc_selectors.at(12) }, + { C::instr_fetching_sel_op_dc_13, wire_instr_spec.op_dc_selectors.at(13) }, + { C::instr_fetching_sel_op_dc_14, wire_instr_spec.op_dc_selectors.at(14) }, + { C::instr_fetching_sel_op_dc_15, wire_instr_spec.op_dc_selectors.at(15) }, + { C::instr_fetching_sel_op_dc_16, wire_instr_spec.op_dc_selectors.at(16) }, + { C::instr_fetching_sel_op_dc_17, wire_instr_spec.op_dc_selectors.at(17) }, + + // Parsing errors + { C::instr_fetching_pc_out_of_range, event.error == PC_OUT_OF_RANGE ? 1 : 0 }, + { C::instr_fetching_opcode_out_of_range, event.error == OPCODE_OUT_OF_RANGE ? 1 : 0 }, + { C::instr_fetching_instr_out_of_range, event.error == INSTRUCTION_OUT_OF_RANGE ? 1 : 0 }, + { C::instr_fetching_parsing_err, event.error != NO_ERROR ? 1 : 0 }, + + // selector for lookups + { C::instr_fetching_sel_lookup_bc_decomposition, event.error != PC_OUT_OF_RANGE ? 1 : 0 }, + + { C::instr_fetching_last_of_bytecode, is_last_of_bytecode ? 1 : 0 }, + { C::instr_fetching_bc_id_diff_inv, bytecode_id_diff_inv }, + { C::instr_fetching_bytecode_size, bytecode_size }, + { C::instr_fetching_bytes_remaining, bytes_remaining }, + { C::instr_fetching_bytes_to_read, bytes_to_read }, + { C::instr_fetching_abs_diff, abs_diff }, + } }); + row++; + } } } diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp index c60eed8bd88c..ba3bc2817814 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp @@ -358,27 +358,27 @@ TEST(BytecodeTraceGenTest, InstrDecompositionInBytesEachOpcode) // Check size_in_bytes column const auto expected_size_in_bytes = WIRE_INSTRUCTION_SPEC.at(w_opcode).size_in_bytes; ASSERT_EQ(instr_encoded.size(), expected_size_in_bytes); - EXPECT_EQ(FF(expected_size_in_bytes), trace.get(C::instr_fetching_instr_size_in_bytes, i)); + EXPECT_EQ(FF(expected_size_in_bytes), trace.get(C::instr_fetching_instr_size, i + 1)); // Inspect each byte for (size_t j = 0; j < static_cast(expected_size_in_bytes); j++) { - EXPECT_EQ(FF(instr_encoded.at(j)), trace.get(bd_columns.at(j), i)); + EXPECT_EQ(FF(instr_encoded.at(j)), trace.get(bd_columns.at(j), i + 1)); } // Check exection opcode EXPECT_EQ(FF(static_cast(WIRE_INSTRUCTION_SPEC.at(w_opcode).exec_opcode)), - trace.get(C::instr_fetching_exec_opcode, i)); + trace.get(C::instr_fetching_exec_opcode, i + 1)); // Check indirect - EXPECT_EQ(FF(instr.indirect), trace.get(C::instr_fetching_indirect, i)); + EXPECT_EQ(FF(instr.indirect), trace.get(C::instr_fetching_indirect, i + 1)); // Check PCs - EXPECT_EQ(FF(pcs.at(i)), trace.get(C::instr_fetching_pc, i)); + EXPECT_EQ(FF(pcs.at(i)), trace.get(C::instr_fetching_pc, i + 1)); // Check operands size_t operand_idx = 0; for (const auto& operand : instr.operands) { - EXPECT_EQ(FF(operand), trace.get(operand_columns.at(operand_idx++), i)); + EXPECT_EQ(FF(operand), trace.get(operand_columns.at(operand_idx++), i + 1)); } } } diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/precomputed_trace.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/precomputed_trace.cpp index fd0f44de96c2..f7eb2fff42ae 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/precomputed_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/precomputed_trace.cpp @@ -194,22 +194,30 @@ void PrecomputedTraceBuilder::process_wire_instruction_spec(TraceContainer& trac }; // First set the selector for this table lookup. - for (uint32_t i = 0; i < static_cast(WireOpCode::LAST_OPCODE_SENTINEL); i++) { - trace.set(C::precomputed_sel_range_wire_opcode, i, 1); + constexpr uint32_t num_rows = 1 << 8; // 256 + constexpr uint32_t num_opcodes = static_cast(WireOpCode::LAST_OPCODE_SENTINEL); + trace.reserve_column(C::precomputed_opcode_out_of_range, num_rows - num_opcodes); + for (uint32_t i = num_opcodes; i < num_rows; i++) { + trace.set(C::precomputed_opcode_out_of_range, i, 1); } + for (size_t i = 0; i < NUM_OP_DC_SELECTORS; i++) { + trace.reserve_column(sel_op_dc_columns.at(i), num_opcodes); + } + trace.reserve_column(C::precomputed_exec_opcode, num_opcodes); + trace.reserve_column(C::precomputed_instr_size, num_opcodes); + // Fill the lookup tables with the operand decomposition selectors. for (const auto& [wire_opcode, wire_instruction_spec] : WIRE_INSTRUCTION_SPEC) { for (size_t i = 0; i < NUM_OP_DC_SELECTORS; i++) { - trace.set( - sel_op_dc_columns[i], static_cast(wire_opcode), wire_instruction_spec.op_dc_selectors[i]); + trace.set(sel_op_dc_columns.at(i), + static_cast(wire_opcode), + wire_instruction_spec.op_dc_selectors.at(i)); } trace.set(C::precomputed_exec_opcode, static_cast(wire_opcode), static_cast(wire_instruction_spec.exec_opcode)); - trace.set(C::precomputed_instr_size_in_bytes, - static_cast(wire_opcode), - wire_instruction_spec.size_in_bytes); + trace.set(C::precomputed_instr_size, static_cast(wire_opcode), wire_instruction_spec.size_in_bytes); } } diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp index 3e13c5a930b3..bcbedce30896 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp @@ -255,7 +255,6 @@ TraceContainer AvmTraceGenHelper::generate_trace(EventsContainer&& events) { auto jobs_interactions = make_jobs>( std::make_unique>(), - std::make_unique>(), std::make_unique>(), std::make_unique>(), std::make_unique>(), @@ -268,10 +267,6 @@ TraceContainer AvmTraceGenHelper::generate_trace(EventsContainer&& events) std::make_unique>(), std::make_unique>(), std::make_unique>(), - std::make_unique>(), - std::make_unique>(), - std::make_unique>(), - std::make_unique>(), std::make_unique>(), // Bytecode Hashing std::make_unique>(), @@ -280,6 +275,13 @@ TraceContainer AvmTraceGenHelper::generate_trace(EventsContainer&& events) // Bytecode Retrieval std::make_unique>(), std::make_unique>(), + // Bytecode Decomposition + std::make_unique>(), + std::make_unique>(), + std::make_unique>(), + // Instruction Fetching + std::make_unique>(), + std::make_unique>(), // Class Id Derivation std::make_unique< LookupIntoDynamicTableSequential>(), From f0830773f7f67eb1d4f6b77f1d7925ad3a039261 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Tue, 11 Mar 2025 15:55:29 +0000 Subject: [PATCH 02/25] Add pil and tracegen error handling for pc out of range --- barretenberg/cpp/pil/vm2/instr_fetching.pil | 21 +++ .../barretenberg/vm2/generated/columns.hpp | 8 +- .../src/barretenberg/vm2/generated/flavor.hpp | 6 +- .../generated/relations/instr_fetching.hpp | 89 +++++---- .../relations/lookups_instr_fetching.hpp | 172 ++++++++++++++++++ .../vm2/tracegen/bytecode_trace.cpp | 9 + 6 files changed, 265 insertions(+), 40 deletions(-) diff --git a/barretenberg/cpp/pil/vm2/instr_fetching.pil b/barretenberg/cpp/pil/vm2/instr_fetching.pil index 401402c86580..9a530272c0f7 100644 --- a/barretenberg/cpp/pil/vm2/instr_fetching.pil +++ b/barretenberg/cpp/pil/vm2/instr_fetching.pil @@ -72,6 +72,27 @@ abs_diff = (2 * instr_out_of_range - 1) * (instr_size - bytes_to_read) - instr_o #[ABS_DIFF_POSITIVE] sel {abs_diff} in precomputed.sel_range_8 {precomputed.clk}; +// We have to enforce that: pc < bytecode_size <==> pc_out_of_range == 0 +// We use same trick as above by using an absolute difference value. + +// pc - bytecode_size if bytecode_size <= pc +// bytecode_size - pc - 1 if bytecode_size > pc +pol commit pc_abs_diff; +pc_abs_diff = sel * ((2 * pc_out_of_range - 1) * (pc - bytecode_size) - 1 + pc_out_of_range); + +// pc_abs_diff might take 32 bits and we decompose into 2 16-bit limbs +pol commit pc_abs_diff_lo; +pol commit pc_abs_diff_hi; + +#[PC_ABS_DIFF_LIMBS] +pc_abs_diff = pc_abs_diff_lo + 2**16 * pc_abs_diff_hi; + +#[ABS_DIFF_POSITIVE_LO] +sel {pc_abs_diff_lo} in precomputed.sel_range_16 {precomputed.clk}; + +#[ABS_DIFF_POSITIVE_HI] +sel {pc_abs_diff_hi} in precomputed.sel_range_16 {precomputed.clk}; + // bytecode[pc] to bytecode[pc + 36] pol commit bd0, bd1, bd2, bd3, bd4, bd5, bd6, bd7, bd8, bd9, bd10, diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp index 9ae61bc243ce..5f783a918337 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp @@ -10,8 +10,8 @@ namespace bb::avm2 { // The entities that will be used in the flavor. // clang-format off #define AVM2_PRECOMPUTED_ENTITIES precomputed_as_unary, precomputed_bitwise_input_a, precomputed_bitwise_input_b, precomputed_bitwise_op_id, precomputed_bitwise_output, precomputed_clk, precomputed_exec_opcode, precomputed_first_row, precomputed_instr_size, precomputed_integral_tag_length, precomputed_opcode_out_of_range, precomputed_p_decomposition_limb, precomputed_p_decomposition_limb_index, precomputed_p_decomposition_radix, precomputed_power_of_2, precomputed_sel_bitwise, precomputed_sel_integral_tag, precomputed_sel_op_dc_0, precomputed_sel_op_dc_1, precomputed_sel_op_dc_10, precomputed_sel_op_dc_11, precomputed_sel_op_dc_12, precomputed_sel_op_dc_13, precomputed_sel_op_dc_14, precomputed_sel_op_dc_15, precomputed_sel_op_dc_16, precomputed_sel_op_dc_17, precomputed_sel_op_dc_2, precomputed_sel_op_dc_3, precomputed_sel_op_dc_4, precomputed_sel_op_dc_5, precomputed_sel_op_dc_6, precomputed_sel_op_dc_7, precomputed_sel_op_dc_8, precomputed_sel_op_dc_9, precomputed_sel_p_decomposition, precomputed_sel_range_16, precomputed_sel_range_8, precomputed_sel_sha256_compression, precomputed_sel_to_radix_safe_limbs, precomputed_sel_unary, precomputed_sha256_compression_round_constant, precomputed_to_radix_safe_limbs, precomputed_zero -#define AVM2_WIRE_ENTITIES execution_input, address_derivation_address, address_derivation_address_y, address_derivation_class_id, address_derivation_deployer_addr, address_derivation_g1_x, address_derivation_g1_y, address_derivation_incoming_viewing_key_x, address_derivation_incoming_viewing_key_y, address_derivation_init_hash, address_derivation_nullifier_key_x, address_derivation_nullifier_key_y, address_derivation_outgoing_viewing_key_x, address_derivation_outgoing_viewing_key_y, address_derivation_partial_address, address_derivation_partial_address_domain_separator, address_derivation_preaddress, address_derivation_preaddress_domain_separator, address_derivation_preaddress_public_key_x, address_derivation_preaddress_public_key_y, address_derivation_public_keys_hash, address_derivation_public_keys_hash_domain_separator, address_derivation_salt, address_derivation_salted_init_hash, address_derivation_sel, address_derivation_tagging_key_x, address_derivation_tagging_key_y, alu_dst_addr, alu_ia, alu_ia_addr, alu_ib, alu_ib_addr, alu_ic, alu_op, alu_sel_op_add, bc_decomposition_abs_diff, bc_decomposition_bytes, bc_decomposition_bytes_pc_plus_1, bc_decomposition_bytes_pc_plus_10, bc_decomposition_bytes_pc_plus_11, bc_decomposition_bytes_pc_plus_12, bc_decomposition_bytes_pc_plus_13, bc_decomposition_bytes_pc_plus_14, bc_decomposition_bytes_pc_plus_15, bc_decomposition_bytes_pc_plus_16, bc_decomposition_bytes_pc_plus_17, bc_decomposition_bytes_pc_plus_18, bc_decomposition_bytes_pc_plus_19, bc_decomposition_bytes_pc_plus_2, bc_decomposition_bytes_pc_plus_20, bc_decomposition_bytes_pc_plus_21, bc_decomposition_bytes_pc_plus_22, bc_decomposition_bytes_pc_plus_23, bc_decomposition_bytes_pc_plus_24, bc_decomposition_bytes_pc_plus_25, bc_decomposition_bytes_pc_plus_26, bc_decomposition_bytes_pc_plus_27, bc_decomposition_bytes_pc_plus_28, bc_decomposition_bytes_pc_plus_29, bc_decomposition_bytes_pc_plus_3, bc_decomposition_bytes_pc_plus_30, bc_decomposition_bytes_pc_plus_31, bc_decomposition_bytes_pc_plus_32, bc_decomposition_bytes_pc_plus_33, bc_decomposition_bytes_pc_plus_34, bc_decomposition_bytes_pc_plus_35, bc_decomposition_bytes_pc_plus_36, bc_decomposition_bytes_pc_plus_4, bc_decomposition_bytes_pc_plus_5, bc_decomposition_bytes_pc_plus_6, bc_decomposition_bytes_pc_plus_7, bc_decomposition_bytes_pc_plus_8, bc_decomposition_bytes_pc_plus_9, bc_decomposition_bytes_rem_inv, bc_decomposition_bytes_rem_min_one_inv, bc_decomposition_bytes_remaining, bc_decomposition_bytes_to_read, bc_decomposition_bytes_to_read_unary, bc_decomposition_id, bc_decomposition_last_of_contract, bc_decomposition_packed_field, bc_decomposition_pc, bc_decomposition_sel, bc_decomposition_sel_overflow_correction_needed, bc_decomposition_sel_packed, bc_decomposition_sel_pc_plus_1, bc_decomposition_sel_pc_plus_10, bc_decomposition_sel_pc_plus_11, bc_decomposition_sel_pc_plus_12, bc_decomposition_sel_pc_plus_13, bc_decomposition_sel_pc_plus_14, bc_decomposition_sel_pc_plus_15, bc_decomposition_sel_pc_plus_16, bc_decomposition_sel_pc_plus_17, bc_decomposition_sel_pc_plus_18, bc_decomposition_sel_pc_plus_19, bc_decomposition_sel_pc_plus_2, bc_decomposition_sel_pc_plus_20, bc_decomposition_sel_pc_plus_21, bc_decomposition_sel_pc_plus_22, bc_decomposition_sel_pc_plus_23, bc_decomposition_sel_pc_plus_24, bc_decomposition_sel_pc_plus_25, bc_decomposition_sel_pc_plus_26, bc_decomposition_sel_pc_plus_27, bc_decomposition_sel_pc_plus_28, bc_decomposition_sel_pc_plus_29, bc_decomposition_sel_pc_plus_3, bc_decomposition_sel_pc_plus_30, bc_decomposition_sel_pc_plus_31, bc_decomposition_sel_pc_plus_32, bc_decomposition_sel_pc_plus_33, bc_decomposition_sel_pc_plus_34, bc_decomposition_sel_pc_plus_35, bc_decomposition_sel_pc_plus_36, bc_decomposition_sel_pc_plus_4, bc_decomposition_sel_pc_plus_5, bc_decomposition_sel_pc_plus_6, bc_decomposition_sel_pc_plus_7, bc_decomposition_sel_pc_plus_8, bc_decomposition_sel_pc_plus_9, bc_hashing_bytecode_id, bc_hashing_incremental_hash, bc_hashing_latch, bc_hashing_output_hash, bc_hashing_packed_field, bc_hashing_pc_index, bc_hashing_sel, bc_hashing_start, bc_retrieval_address, bc_retrieval_artifact_hash, bc_retrieval_bytecode_id, bc_retrieval_class_id, bc_retrieval_deployer_addr, bc_retrieval_err, bc_retrieval_incoming_viewing_key_x, bc_retrieval_incoming_viewing_key_y, bc_retrieval_init_hash, bc_retrieval_nullifier_key_x, bc_retrieval_nullifier_key_y, bc_retrieval_outgoing_viewing_key_x, bc_retrieval_outgoing_viewing_key_y, bc_retrieval_private_function_root, bc_retrieval_public_bytecode_commitment, bc_retrieval_salt, bc_retrieval_sel, bc_retrieval_siloed_address, bc_retrieval_tagging_key_x, bc_retrieval_tagging_key_y, bitwise_acc_ia, bitwise_acc_ib, bitwise_acc_ic, bitwise_ctr, bitwise_ctr_inv, bitwise_ctr_min_one_inv, bitwise_ia_byte, bitwise_ib_byte, bitwise_ic_byte, bitwise_last, bitwise_op_id, bitwise_sel, bitwise_start, bitwise_tag, class_id_derivation_artifact_hash, class_id_derivation_class_id, class_id_derivation_private_function_root, class_id_derivation_public_bytecode_commitment, class_id_derivation_sel, class_id_derivation_temp_constant_for_lookup, ecc_add_op, ecc_double_op, ecc_inv_2_p_y, ecc_inv_x_diff, ecc_inv_y_diff, ecc_lambda, ecc_p_is_inf, ecc_p_x, ecc_p_y, ecc_q_is_inf, ecc_q_x, ecc_q_y, ecc_r_is_inf, ecc_r_x, ecc_r_y, ecc_result_infinity, ecc_sel, ecc_x_match, ecc_y_match, execution_addressing_error_idx, execution_addressing_error_kind, execution_base_address_tag, execution_base_address_val, execution_bytecode_id, execution_clk, execution_ex_opcode, execution_indirect, execution_last, execution_op1, execution_op1_after_relative, execution_op2, execution_op2_after_relative, execution_op3, execution_op3_after_relative, execution_op4, execution_op4_after_relative, execution_pc, execution_rop1, execution_rop2, execution_rop3, execution_rop4, execution_sel, execution_sel_addressing_error, execution_sel_op1_is_address, execution_sel_op2_is_address, execution_sel_op3_is_address, execution_sel_op4_is_address, instr_fetching_abs_diff, instr_fetching_bc_id_diff_inv, instr_fetching_bd0, instr_fetching_bd1, instr_fetching_bd10, instr_fetching_bd11, instr_fetching_bd12, instr_fetching_bd13, instr_fetching_bd14, instr_fetching_bd15, instr_fetching_bd16, instr_fetching_bd17, instr_fetching_bd18, instr_fetching_bd19, instr_fetching_bd2, instr_fetching_bd20, instr_fetching_bd21, instr_fetching_bd22, instr_fetching_bd23, instr_fetching_bd24, instr_fetching_bd25, instr_fetching_bd26, instr_fetching_bd27, instr_fetching_bd28, instr_fetching_bd29, instr_fetching_bd3, instr_fetching_bd30, instr_fetching_bd31, instr_fetching_bd32, instr_fetching_bd33, instr_fetching_bd34, instr_fetching_bd35, instr_fetching_bd36, instr_fetching_bd4, instr_fetching_bd5, instr_fetching_bd6, instr_fetching_bd7, instr_fetching_bd8, instr_fetching_bd9, instr_fetching_bytecode_id, instr_fetching_bytecode_size, instr_fetching_bytes_remaining, instr_fetching_bytes_to_read, instr_fetching_exec_opcode, instr_fetching_indirect, instr_fetching_instr_out_of_range, instr_fetching_instr_size, instr_fetching_last_of_bytecode, instr_fetching_op1, instr_fetching_op2, instr_fetching_op3, instr_fetching_op4, instr_fetching_op5, instr_fetching_op6, instr_fetching_op7, instr_fetching_opcode_out_of_range, instr_fetching_parsing_err, instr_fetching_pc, instr_fetching_pc_out_of_range, instr_fetching_sel, instr_fetching_sel_lookup_bc_decomposition, instr_fetching_sel_op_dc_0, instr_fetching_sel_op_dc_1, instr_fetching_sel_op_dc_10, instr_fetching_sel_op_dc_11, instr_fetching_sel_op_dc_12, instr_fetching_sel_op_dc_13, instr_fetching_sel_op_dc_14, instr_fetching_sel_op_dc_15, instr_fetching_sel_op_dc_16, instr_fetching_sel_op_dc_17, instr_fetching_sel_op_dc_2, instr_fetching_sel_op_dc_3, instr_fetching_sel_op_dc_4, instr_fetching_sel_op_dc_5, instr_fetching_sel_op_dc_6, instr_fetching_sel_op_dc_7, instr_fetching_sel_op_dc_8, instr_fetching_sel_op_dc_9, poseidon2_hash_a_0, poseidon2_hash_a_1, poseidon2_hash_a_2, poseidon2_hash_a_3, poseidon2_hash_b_0, poseidon2_hash_b_1, poseidon2_hash_b_2, poseidon2_hash_b_3, poseidon2_hash_end, poseidon2_hash_input_0, poseidon2_hash_input_1, poseidon2_hash_input_2, poseidon2_hash_input_len, poseidon2_hash_num_perm_rounds_rem, poseidon2_hash_num_perm_rounds_rem_inv, poseidon2_hash_output, poseidon2_hash_padding, poseidon2_hash_sel, poseidon2_hash_start, poseidon2_perm_B_10_0, poseidon2_perm_B_10_1, poseidon2_perm_B_10_2, poseidon2_perm_B_10_3, poseidon2_perm_B_11_0, poseidon2_perm_B_11_1, poseidon2_perm_B_11_2, poseidon2_perm_B_11_3, poseidon2_perm_B_12_0, poseidon2_perm_B_12_1, poseidon2_perm_B_12_2, poseidon2_perm_B_12_3, poseidon2_perm_B_13_0, poseidon2_perm_B_13_1, poseidon2_perm_B_13_2, poseidon2_perm_B_13_3, poseidon2_perm_B_14_0, poseidon2_perm_B_14_1, poseidon2_perm_B_14_2, poseidon2_perm_B_14_3, poseidon2_perm_B_15_0, poseidon2_perm_B_15_1, poseidon2_perm_B_15_2, poseidon2_perm_B_15_3, poseidon2_perm_B_16_0, poseidon2_perm_B_16_1, poseidon2_perm_B_16_2, poseidon2_perm_B_16_3, poseidon2_perm_B_17_0, poseidon2_perm_B_17_1, poseidon2_perm_B_17_2, poseidon2_perm_B_17_3, poseidon2_perm_B_18_0, poseidon2_perm_B_18_1, poseidon2_perm_B_18_2, poseidon2_perm_B_18_3, poseidon2_perm_B_19_0, poseidon2_perm_B_19_1, poseidon2_perm_B_19_2, poseidon2_perm_B_19_3, poseidon2_perm_B_20_0, poseidon2_perm_B_20_1, poseidon2_perm_B_20_2, poseidon2_perm_B_20_3, poseidon2_perm_B_21_0, poseidon2_perm_B_21_1, poseidon2_perm_B_21_2, poseidon2_perm_B_21_3, poseidon2_perm_B_22_0, poseidon2_perm_B_22_1, poseidon2_perm_B_22_2, poseidon2_perm_B_22_3, poseidon2_perm_B_23_0, poseidon2_perm_B_23_1, poseidon2_perm_B_23_2, poseidon2_perm_B_23_3, poseidon2_perm_B_24_0, poseidon2_perm_B_24_1, poseidon2_perm_B_24_2, poseidon2_perm_B_24_3, poseidon2_perm_B_25_0, poseidon2_perm_B_25_1, poseidon2_perm_B_25_2, poseidon2_perm_B_25_3, poseidon2_perm_B_26_0, poseidon2_perm_B_26_1, poseidon2_perm_B_26_2, poseidon2_perm_B_26_3, poseidon2_perm_B_27_0, poseidon2_perm_B_27_1, poseidon2_perm_B_27_2, poseidon2_perm_B_27_3, poseidon2_perm_B_28_0, poseidon2_perm_B_28_1, poseidon2_perm_B_28_2, poseidon2_perm_B_28_3, poseidon2_perm_B_29_0, poseidon2_perm_B_29_1, poseidon2_perm_B_29_2, poseidon2_perm_B_29_3, poseidon2_perm_B_30_0, poseidon2_perm_B_30_1, poseidon2_perm_B_30_2, poseidon2_perm_B_30_3, poseidon2_perm_B_31_0, poseidon2_perm_B_31_1, poseidon2_perm_B_31_2, poseidon2_perm_B_31_3, poseidon2_perm_B_32_0, poseidon2_perm_B_32_1, poseidon2_perm_B_32_2, poseidon2_perm_B_32_3, poseidon2_perm_B_33_0, poseidon2_perm_B_33_1, poseidon2_perm_B_33_2, poseidon2_perm_B_33_3, poseidon2_perm_B_34_0, poseidon2_perm_B_34_1, poseidon2_perm_B_34_2, poseidon2_perm_B_34_3, poseidon2_perm_B_35_0, poseidon2_perm_B_35_1, poseidon2_perm_B_35_2, poseidon2_perm_B_35_3, poseidon2_perm_B_36_0, poseidon2_perm_B_36_1, poseidon2_perm_B_36_2, poseidon2_perm_B_36_3, poseidon2_perm_B_37_0, poseidon2_perm_B_37_1, poseidon2_perm_B_37_2, poseidon2_perm_B_37_3, poseidon2_perm_B_38_0, poseidon2_perm_B_38_1, poseidon2_perm_B_38_2, poseidon2_perm_B_38_3, poseidon2_perm_B_39_0, poseidon2_perm_B_39_1, poseidon2_perm_B_39_2, poseidon2_perm_B_39_3, poseidon2_perm_B_40_0, poseidon2_perm_B_40_1, poseidon2_perm_B_40_2, poseidon2_perm_B_40_3, poseidon2_perm_B_41_0, poseidon2_perm_B_41_1, poseidon2_perm_B_41_2, poseidon2_perm_B_41_3, poseidon2_perm_B_42_0, poseidon2_perm_B_42_1, poseidon2_perm_B_42_2, poseidon2_perm_B_42_3, poseidon2_perm_B_43_0, poseidon2_perm_B_43_1, poseidon2_perm_B_43_2, poseidon2_perm_B_43_3, poseidon2_perm_B_44_0, poseidon2_perm_B_44_1, poseidon2_perm_B_44_2, poseidon2_perm_B_44_3, poseidon2_perm_B_45_0, poseidon2_perm_B_45_1, poseidon2_perm_B_45_2, poseidon2_perm_B_45_3, poseidon2_perm_B_46_0, poseidon2_perm_B_46_1, poseidon2_perm_B_46_2, poseidon2_perm_B_46_3, poseidon2_perm_B_47_0, poseidon2_perm_B_47_1, poseidon2_perm_B_47_2, poseidon2_perm_B_47_3, poseidon2_perm_B_48_0, poseidon2_perm_B_48_1, poseidon2_perm_B_48_2, poseidon2_perm_B_48_3, poseidon2_perm_B_49_0, poseidon2_perm_B_49_1, poseidon2_perm_B_49_2, poseidon2_perm_B_49_3, poseidon2_perm_B_4_0, poseidon2_perm_B_4_1, poseidon2_perm_B_4_2, poseidon2_perm_B_4_3, poseidon2_perm_B_50_0, poseidon2_perm_B_50_1, poseidon2_perm_B_50_2, poseidon2_perm_B_50_3, poseidon2_perm_B_51_0, poseidon2_perm_B_51_1, poseidon2_perm_B_51_2, poseidon2_perm_B_51_3, poseidon2_perm_B_52_0, poseidon2_perm_B_52_1, poseidon2_perm_B_52_2, poseidon2_perm_B_52_3, poseidon2_perm_B_53_0, poseidon2_perm_B_53_1, poseidon2_perm_B_53_2, poseidon2_perm_B_53_3, poseidon2_perm_B_54_0, poseidon2_perm_B_54_1, poseidon2_perm_B_54_2, poseidon2_perm_B_54_3, poseidon2_perm_B_55_0, poseidon2_perm_B_55_1, poseidon2_perm_B_55_2, poseidon2_perm_B_55_3, poseidon2_perm_B_56_0, poseidon2_perm_B_56_1, poseidon2_perm_B_56_2, poseidon2_perm_B_56_3, poseidon2_perm_B_57_0, poseidon2_perm_B_57_1, poseidon2_perm_B_57_2, poseidon2_perm_B_57_3, poseidon2_perm_B_58_0, poseidon2_perm_B_58_1, poseidon2_perm_B_58_2, poseidon2_perm_B_58_3, poseidon2_perm_B_59_0, poseidon2_perm_B_59_1, poseidon2_perm_B_59_2, poseidon2_perm_B_59_3, poseidon2_perm_B_5_0, poseidon2_perm_B_5_1, poseidon2_perm_B_5_2, poseidon2_perm_B_5_3, poseidon2_perm_B_6_0, poseidon2_perm_B_6_1, poseidon2_perm_B_6_2, poseidon2_perm_B_6_3, poseidon2_perm_B_7_0, poseidon2_perm_B_7_1, poseidon2_perm_B_7_2, poseidon2_perm_B_7_3, poseidon2_perm_B_8_0, poseidon2_perm_B_8_1, poseidon2_perm_B_8_2, poseidon2_perm_B_8_3, poseidon2_perm_B_9_0, poseidon2_perm_B_9_1, poseidon2_perm_B_9_2, poseidon2_perm_B_9_3, poseidon2_perm_EXT_LAYER_4, poseidon2_perm_EXT_LAYER_5, poseidon2_perm_EXT_LAYER_6, poseidon2_perm_EXT_LAYER_7, poseidon2_perm_T_0_4, poseidon2_perm_T_0_5, poseidon2_perm_T_0_6, poseidon2_perm_T_0_7, poseidon2_perm_T_1_4, poseidon2_perm_T_1_5, poseidon2_perm_T_1_6, poseidon2_perm_T_1_7, poseidon2_perm_T_2_4, poseidon2_perm_T_2_5, poseidon2_perm_T_2_6, poseidon2_perm_T_2_7, poseidon2_perm_T_3_4, poseidon2_perm_T_3_5, poseidon2_perm_T_3_6, poseidon2_perm_T_3_7, poseidon2_perm_T_60_4, poseidon2_perm_T_60_5, poseidon2_perm_T_60_6, poseidon2_perm_T_60_7, poseidon2_perm_T_61_4, poseidon2_perm_T_61_5, poseidon2_perm_T_61_6, poseidon2_perm_T_61_7, poseidon2_perm_T_62_4, poseidon2_perm_T_62_5, poseidon2_perm_T_62_6, poseidon2_perm_T_62_7, poseidon2_perm_T_63_4, poseidon2_perm_T_63_5, poseidon2_perm_T_63_6, poseidon2_perm_T_63_7, poseidon2_perm_a_0, poseidon2_perm_a_1, poseidon2_perm_a_2, poseidon2_perm_a_3, poseidon2_perm_b_0, poseidon2_perm_b_1, poseidon2_perm_b_2, poseidon2_perm_b_3, poseidon2_perm_sel, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_rng_chk_bits, range_check_sel, range_check_sel_r0_16_bit_rng_lookup, range_check_sel_r1_16_bit_rng_lookup, range_check_sel_r2_16_bit_rng_lookup, range_check_sel_r3_16_bit_rng_lookup, range_check_sel_r4_16_bit_rng_lookup, range_check_sel_r5_16_bit_rng_lookup, range_check_sel_r6_16_bit_rng_lookup, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, scalar_mul_bit, scalar_mul_bit_idx, scalar_mul_bit_radix, scalar_mul_end, scalar_mul_not_end, scalar_mul_point_inf, scalar_mul_point_x, scalar_mul_point_y, scalar_mul_res_inf, scalar_mul_res_x, scalar_mul_res_y, scalar_mul_scalar, scalar_mul_sel, scalar_mul_should_add, scalar_mul_start, scalar_mul_temp_inf, scalar_mul_temp_x, scalar_mul_temp_y, sha256_a, sha256_a_and_b, sha256_a_and_b_xor_a_and_c, sha256_a_and_c, sha256_a_rotr_13, sha256_a_rotr_2, sha256_a_rotr_22, sha256_a_rotr_2_xor_a_rotr_13, sha256_and_sel, sha256_b, sha256_b_and_c, sha256_c, sha256_ch, sha256_clk, sha256_computed_w_lhs, sha256_computed_w_rhs, sha256_d, sha256_e, sha256_e_and_f, sha256_e_rotr_11, sha256_e_rotr_25, sha256_e_rotr_6, sha256_e_rotr_6_xor_e_rotr_11, sha256_f, sha256_g, sha256_h, sha256_helper_w0, sha256_helper_w1, sha256_helper_w10, sha256_helper_w11, sha256_helper_w12, sha256_helper_w13, sha256_helper_w14, sha256_helper_w15, sha256_helper_w2, sha256_helper_w3, sha256_helper_w4, sha256_helper_w5, sha256_helper_w6, sha256_helper_w7, sha256_helper_w8, sha256_helper_w9, sha256_init_a, sha256_init_b, sha256_init_c, sha256_init_d, sha256_init_e, sha256_init_f, sha256_init_g, sha256_init_h, sha256_input_offset, sha256_is_input_round, sha256_latch, sha256_lhs_a_13, sha256_lhs_a_2, sha256_lhs_a_22, sha256_lhs_e_11, sha256_lhs_e_25, sha256_lhs_e_6, sha256_lhs_w_10, sha256_lhs_w_17, sha256_lhs_w_18, sha256_lhs_w_19, sha256_lhs_w_3, sha256_lhs_w_7, sha256_maj, sha256_next_a_lhs, sha256_next_a_rhs, sha256_next_e_lhs, sha256_next_e_rhs, sha256_not_e, sha256_not_e_and_g, sha256_output_a_lhs, sha256_output_a_rhs, sha256_output_b_lhs, sha256_output_b_rhs, sha256_output_c_lhs, sha256_output_c_rhs, sha256_output_d_lhs, sha256_output_d_rhs, sha256_output_e_lhs, sha256_output_e_rhs, sha256_output_f_lhs, sha256_output_f_rhs, sha256_output_g_lhs, sha256_output_g_rhs, sha256_output_h_lhs, sha256_output_h_rhs, sha256_output_offset, sha256_perform_round, sha256_rhs_a_13, sha256_rhs_a_2, sha256_rhs_a_22, sha256_rhs_e_11, sha256_rhs_e_25, sha256_rhs_e_6, sha256_rhs_w_10, sha256_rhs_w_17, sha256_rhs_w_18, sha256_rhs_w_19, sha256_rhs_w_3, sha256_rhs_w_7, sha256_round_constant, sha256_round_count, sha256_rounds_remaining, sha256_rounds_remaining_inv, sha256_s_0, sha256_s_1, sha256_sel, sha256_start, sha256_state_offset, sha256_w, sha256_w_15_rotr_18, sha256_w_15_rotr_7, sha256_w_15_rotr_7_xor_w_15_rotr_18, sha256_w_15_rshift_3, sha256_w_2_rotr_17, sha256_w_2_rotr_17_xor_w_2_rotr_19, sha256_w_2_rotr_19, sha256_w_2_rshift_10, sha256_w_s_0, sha256_w_s_1, sha256_xor_sel, to_radix_acc, to_radix_acc_under_p, to_radix_end, to_radix_exponent, to_radix_found, to_radix_is_unsafe_limb, to_radix_limb, to_radix_limb_eq_p, to_radix_limb_index, to_radix_limb_lt_p, to_radix_limb_p_diff, to_radix_limb_radix_diff, to_radix_not_end, to_radix_not_padding_limb, to_radix_p_limb, to_radix_radix, to_radix_rem_inverse, to_radix_safe_limbs, to_radix_safety_diff_inverse, to_radix_sel, to_radix_start, to_radix_value, lookup_poseidon2_hash_poseidon2_perm_counts, lookup_range_check_dyn_rng_chk_pow_2_counts, lookup_range_check_dyn_diff_is_u16_counts, lookup_range_check_r0_is_u16_counts, lookup_range_check_r1_is_u16_counts, lookup_range_check_r2_is_u16_counts, lookup_range_check_r3_is_u16_counts, lookup_range_check_r4_is_u16_counts, lookup_range_check_r5_is_u16_counts, lookup_range_check_r6_is_u16_counts, lookup_range_check_r7_is_u16_counts, lookup_to_radix_limb_range_counts, lookup_to_radix_limb_less_than_radix_range_counts, lookup_to_radix_fetch_safe_limbs_counts, lookup_to_radix_fetch_p_limb_counts, lookup_to_radix_limb_p_diff_range_counts, lookup_scalar_mul_to_radix_counts, lookup_scalar_mul_double_counts, lookup_scalar_mul_add_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_0_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_1_counts, lookup_address_derivation_partial_address_poseidon2_counts, lookup_address_derivation_public_keys_hash_poseidon2_0_counts, lookup_address_derivation_public_keys_hash_poseidon2_1_counts, lookup_address_derivation_public_keys_hash_poseidon2_2_counts, lookup_address_derivation_public_keys_hash_poseidon2_3_counts, lookup_address_derivation_public_keys_hash_poseidon2_4_counts, lookup_address_derivation_preaddress_poseidon2_counts, lookup_address_derivation_preaddress_scalar_mul_counts, lookup_address_derivation_address_ecadd_counts, lookup_bc_decomposition_bytes_are_bytes_counts, lookup_bc_decomposition_abs_diff_is_u16_counts, lookup_bc_decomposition_bytes_to_read_as_unary_counts, lookup_bc_hashing_get_packed_field_counts, lookup_bc_hashing_iv_is_len_counts, lookup_bc_hashing_poseidon2_hash_counts, lookup_bc_retrieval_class_id_derivation_counts, lookup_bc_retrieval_bytecode_hash_is_correct_counts, lookup_instr_fetching_abs_diff_positive_counts, lookup_instr_fetching_bytes_from_bc_dec_counts, lookup_instr_fetching_wire_instruction_info_counts, lookup_class_id_derivation_class_id_poseidon2_0_counts, lookup_class_id_derivation_class_id_poseidon2_1_counts, lookup_bitwise_integral_tag_length_counts, lookup_bitwise_byte_operations_counts, lookup_sha256_round_constant_counts -#define AVM2_DERIVED_WITNESS_ENTITIES lookup_poseidon2_hash_poseidon2_perm_inv, lookup_range_check_dyn_rng_chk_pow_2_inv, lookup_range_check_dyn_diff_is_u16_inv, lookup_range_check_r0_is_u16_inv, lookup_range_check_r1_is_u16_inv, lookup_range_check_r2_is_u16_inv, lookup_range_check_r3_is_u16_inv, lookup_range_check_r4_is_u16_inv, lookup_range_check_r5_is_u16_inv, lookup_range_check_r6_is_u16_inv, lookup_range_check_r7_is_u16_inv, lookup_to_radix_limb_range_inv, lookup_to_radix_limb_less_than_radix_range_inv, lookup_to_radix_fetch_safe_limbs_inv, lookup_to_radix_fetch_p_limb_inv, lookup_to_radix_limb_p_diff_range_inv, lookup_scalar_mul_to_radix_inv, lookup_scalar_mul_double_inv, lookup_scalar_mul_add_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_0_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_1_inv, lookup_address_derivation_partial_address_poseidon2_inv, lookup_address_derivation_public_keys_hash_poseidon2_0_inv, lookup_address_derivation_public_keys_hash_poseidon2_1_inv, lookup_address_derivation_public_keys_hash_poseidon2_2_inv, lookup_address_derivation_public_keys_hash_poseidon2_3_inv, lookup_address_derivation_public_keys_hash_poseidon2_4_inv, lookup_address_derivation_preaddress_poseidon2_inv, lookup_address_derivation_preaddress_scalar_mul_inv, lookup_address_derivation_address_ecadd_inv, lookup_bc_decomposition_bytes_are_bytes_inv, lookup_bc_decomposition_abs_diff_is_u16_inv, lookup_bc_decomposition_bytes_to_read_as_unary_inv, lookup_bc_hashing_get_packed_field_inv, lookup_bc_hashing_iv_is_len_inv, lookup_bc_hashing_poseidon2_hash_inv, lookup_bc_retrieval_class_id_derivation_inv, lookup_bc_retrieval_bytecode_hash_is_correct_inv, lookup_instr_fetching_abs_diff_positive_inv, lookup_instr_fetching_bytes_from_bc_dec_inv, lookup_instr_fetching_wire_instruction_info_inv, lookup_class_id_derivation_class_id_poseidon2_0_inv, lookup_class_id_derivation_class_id_poseidon2_1_inv, lookup_bitwise_integral_tag_length_inv, lookup_bitwise_byte_operations_inv, lookup_sha256_round_constant_inv +#define AVM2_WIRE_ENTITIES execution_input, address_derivation_address, address_derivation_address_y, address_derivation_class_id, address_derivation_deployer_addr, address_derivation_g1_x, address_derivation_g1_y, address_derivation_incoming_viewing_key_x, address_derivation_incoming_viewing_key_y, address_derivation_init_hash, address_derivation_nullifier_key_x, address_derivation_nullifier_key_y, address_derivation_outgoing_viewing_key_x, address_derivation_outgoing_viewing_key_y, address_derivation_partial_address, address_derivation_partial_address_domain_separator, address_derivation_preaddress, address_derivation_preaddress_domain_separator, address_derivation_preaddress_public_key_x, address_derivation_preaddress_public_key_y, address_derivation_public_keys_hash, address_derivation_public_keys_hash_domain_separator, address_derivation_salt, address_derivation_salted_init_hash, address_derivation_sel, address_derivation_tagging_key_x, address_derivation_tagging_key_y, alu_dst_addr, alu_ia, alu_ia_addr, alu_ib, alu_ib_addr, alu_ic, alu_op, alu_sel_op_add, bc_decomposition_abs_diff, bc_decomposition_bytes, bc_decomposition_bytes_pc_plus_1, bc_decomposition_bytes_pc_plus_10, bc_decomposition_bytes_pc_plus_11, bc_decomposition_bytes_pc_plus_12, bc_decomposition_bytes_pc_plus_13, bc_decomposition_bytes_pc_plus_14, bc_decomposition_bytes_pc_plus_15, bc_decomposition_bytes_pc_plus_16, bc_decomposition_bytes_pc_plus_17, bc_decomposition_bytes_pc_plus_18, bc_decomposition_bytes_pc_plus_19, bc_decomposition_bytes_pc_plus_2, bc_decomposition_bytes_pc_plus_20, bc_decomposition_bytes_pc_plus_21, bc_decomposition_bytes_pc_plus_22, bc_decomposition_bytes_pc_plus_23, bc_decomposition_bytes_pc_plus_24, bc_decomposition_bytes_pc_plus_25, bc_decomposition_bytes_pc_plus_26, bc_decomposition_bytes_pc_plus_27, bc_decomposition_bytes_pc_plus_28, bc_decomposition_bytes_pc_plus_29, bc_decomposition_bytes_pc_plus_3, bc_decomposition_bytes_pc_plus_30, bc_decomposition_bytes_pc_plus_31, bc_decomposition_bytes_pc_plus_32, bc_decomposition_bytes_pc_plus_33, bc_decomposition_bytes_pc_plus_34, bc_decomposition_bytes_pc_plus_35, bc_decomposition_bytes_pc_plus_36, bc_decomposition_bytes_pc_plus_4, bc_decomposition_bytes_pc_plus_5, bc_decomposition_bytes_pc_plus_6, bc_decomposition_bytes_pc_plus_7, bc_decomposition_bytes_pc_plus_8, bc_decomposition_bytes_pc_plus_9, bc_decomposition_bytes_rem_inv, bc_decomposition_bytes_rem_min_one_inv, bc_decomposition_bytes_remaining, bc_decomposition_bytes_to_read, bc_decomposition_bytes_to_read_unary, bc_decomposition_id, bc_decomposition_last_of_contract, bc_decomposition_packed_field, bc_decomposition_pc, bc_decomposition_sel, bc_decomposition_sel_overflow_correction_needed, bc_decomposition_sel_packed, bc_decomposition_sel_pc_plus_1, bc_decomposition_sel_pc_plus_10, bc_decomposition_sel_pc_plus_11, bc_decomposition_sel_pc_plus_12, bc_decomposition_sel_pc_plus_13, bc_decomposition_sel_pc_plus_14, bc_decomposition_sel_pc_plus_15, bc_decomposition_sel_pc_plus_16, bc_decomposition_sel_pc_plus_17, bc_decomposition_sel_pc_plus_18, bc_decomposition_sel_pc_plus_19, bc_decomposition_sel_pc_plus_2, bc_decomposition_sel_pc_plus_20, bc_decomposition_sel_pc_plus_21, bc_decomposition_sel_pc_plus_22, bc_decomposition_sel_pc_plus_23, bc_decomposition_sel_pc_plus_24, bc_decomposition_sel_pc_plus_25, bc_decomposition_sel_pc_plus_26, bc_decomposition_sel_pc_plus_27, bc_decomposition_sel_pc_plus_28, bc_decomposition_sel_pc_plus_29, bc_decomposition_sel_pc_plus_3, bc_decomposition_sel_pc_plus_30, bc_decomposition_sel_pc_plus_31, bc_decomposition_sel_pc_plus_32, bc_decomposition_sel_pc_plus_33, bc_decomposition_sel_pc_plus_34, bc_decomposition_sel_pc_plus_35, bc_decomposition_sel_pc_plus_36, bc_decomposition_sel_pc_plus_4, bc_decomposition_sel_pc_plus_5, bc_decomposition_sel_pc_plus_6, bc_decomposition_sel_pc_plus_7, bc_decomposition_sel_pc_plus_8, bc_decomposition_sel_pc_plus_9, bc_hashing_bytecode_id, bc_hashing_incremental_hash, bc_hashing_latch, bc_hashing_output_hash, bc_hashing_packed_field, bc_hashing_pc_index, bc_hashing_sel, bc_hashing_start, bc_retrieval_address, bc_retrieval_artifact_hash, bc_retrieval_bytecode_id, bc_retrieval_class_id, bc_retrieval_deployer_addr, bc_retrieval_err, bc_retrieval_incoming_viewing_key_x, bc_retrieval_incoming_viewing_key_y, bc_retrieval_init_hash, bc_retrieval_nullifier_key_x, bc_retrieval_nullifier_key_y, bc_retrieval_outgoing_viewing_key_x, bc_retrieval_outgoing_viewing_key_y, bc_retrieval_private_function_root, bc_retrieval_public_bytecode_commitment, bc_retrieval_salt, bc_retrieval_sel, bc_retrieval_siloed_address, bc_retrieval_tagging_key_x, bc_retrieval_tagging_key_y, bitwise_acc_ia, bitwise_acc_ib, bitwise_acc_ic, bitwise_ctr, bitwise_ctr_inv, bitwise_ctr_min_one_inv, bitwise_ia_byte, bitwise_ib_byte, bitwise_ic_byte, bitwise_last, bitwise_op_id, bitwise_sel, bitwise_start, bitwise_tag, class_id_derivation_artifact_hash, class_id_derivation_class_id, class_id_derivation_private_function_root, class_id_derivation_public_bytecode_commitment, class_id_derivation_sel, class_id_derivation_temp_constant_for_lookup, ecc_add_op, ecc_double_op, ecc_inv_2_p_y, ecc_inv_x_diff, ecc_inv_y_diff, ecc_lambda, ecc_p_is_inf, ecc_p_x, ecc_p_y, ecc_q_is_inf, ecc_q_x, ecc_q_y, ecc_r_is_inf, ecc_r_x, ecc_r_y, ecc_result_infinity, ecc_sel, ecc_x_match, ecc_y_match, execution_addressing_error_idx, execution_addressing_error_kind, execution_base_address_tag, execution_base_address_val, execution_bytecode_id, execution_clk, execution_ex_opcode, execution_indirect, execution_last, execution_op1, execution_op1_after_relative, execution_op2, execution_op2_after_relative, execution_op3, execution_op3_after_relative, execution_op4, execution_op4_after_relative, execution_pc, execution_rop1, execution_rop2, execution_rop3, execution_rop4, execution_sel, execution_sel_addressing_error, execution_sel_op1_is_address, execution_sel_op2_is_address, execution_sel_op3_is_address, execution_sel_op4_is_address, instr_fetching_abs_diff, instr_fetching_bc_id_diff_inv, instr_fetching_bd0, instr_fetching_bd1, instr_fetching_bd10, instr_fetching_bd11, instr_fetching_bd12, instr_fetching_bd13, instr_fetching_bd14, instr_fetching_bd15, instr_fetching_bd16, instr_fetching_bd17, instr_fetching_bd18, instr_fetching_bd19, instr_fetching_bd2, instr_fetching_bd20, instr_fetching_bd21, instr_fetching_bd22, instr_fetching_bd23, instr_fetching_bd24, instr_fetching_bd25, instr_fetching_bd26, instr_fetching_bd27, instr_fetching_bd28, instr_fetching_bd29, instr_fetching_bd3, instr_fetching_bd30, instr_fetching_bd31, instr_fetching_bd32, instr_fetching_bd33, instr_fetching_bd34, instr_fetching_bd35, instr_fetching_bd36, instr_fetching_bd4, instr_fetching_bd5, instr_fetching_bd6, instr_fetching_bd7, instr_fetching_bd8, instr_fetching_bd9, instr_fetching_bytecode_id, instr_fetching_bytecode_size, instr_fetching_bytes_remaining, instr_fetching_bytes_to_read, instr_fetching_exec_opcode, instr_fetching_indirect, instr_fetching_instr_out_of_range, instr_fetching_instr_size, instr_fetching_last_of_bytecode, instr_fetching_op1, instr_fetching_op2, instr_fetching_op3, instr_fetching_op4, instr_fetching_op5, instr_fetching_op6, instr_fetching_op7, instr_fetching_opcode_out_of_range, instr_fetching_parsing_err, instr_fetching_pc, instr_fetching_pc_abs_diff, instr_fetching_pc_abs_diff_hi, instr_fetching_pc_abs_diff_lo, instr_fetching_pc_out_of_range, instr_fetching_sel, instr_fetching_sel_lookup_bc_decomposition, instr_fetching_sel_op_dc_0, instr_fetching_sel_op_dc_1, instr_fetching_sel_op_dc_10, instr_fetching_sel_op_dc_11, instr_fetching_sel_op_dc_12, instr_fetching_sel_op_dc_13, instr_fetching_sel_op_dc_14, instr_fetching_sel_op_dc_15, instr_fetching_sel_op_dc_16, instr_fetching_sel_op_dc_17, instr_fetching_sel_op_dc_2, instr_fetching_sel_op_dc_3, instr_fetching_sel_op_dc_4, instr_fetching_sel_op_dc_5, instr_fetching_sel_op_dc_6, instr_fetching_sel_op_dc_7, instr_fetching_sel_op_dc_8, instr_fetching_sel_op_dc_9, poseidon2_hash_a_0, poseidon2_hash_a_1, poseidon2_hash_a_2, poseidon2_hash_a_3, poseidon2_hash_b_0, poseidon2_hash_b_1, poseidon2_hash_b_2, poseidon2_hash_b_3, poseidon2_hash_end, poseidon2_hash_input_0, poseidon2_hash_input_1, poseidon2_hash_input_2, poseidon2_hash_input_len, poseidon2_hash_num_perm_rounds_rem, poseidon2_hash_num_perm_rounds_rem_inv, poseidon2_hash_output, poseidon2_hash_padding, poseidon2_hash_sel, poseidon2_hash_start, poseidon2_perm_B_10_0, poseidon2_perm_B_10_1, poseidon2_perm_B_10_2, poseidon2_perm_B_10_3, poseidon2_perm_B_11_0, poseidon2_perm_B_11_1, poseidon2_perm_B_11_2, poseidon2_perm_B_11_3, poseidon2_perm_B_12_0, poseidon2_perm_B_12_1, poseidon2_perm_B_12_2, poseidon2_perm_B_12_3, poseidon2_perm_B_13_0, poseidon2_perm_B_13_1, poseidon2_perm_B_13_2, poseidon2_perm_B_13_3, poseidon2_perm_B_14_0, poseidon2_perm_B_14_1, poseidon2_perm_B_14_2, poseidon2_perm_B_14_3, poseidon2_perm_B_15_0, poseidon2_perm_B_15_1, poseidon2_perm_B_15_2, poseidon2_perm_B_15_3, poseidon2_perm_B_16_0, poseidon2_perm_B_16_1, poseidon2_perm_B_16_2, poseidon2_perm_B_16_3, poseidon2_perm_B_17_0, poseidon2_perm_B_17_1, poseidon2_perm_B_17_2, poseidon2_perm_B_17_3, poseidon2_perm_B_18_0, poseidon2_perm_B_18_1, poseidon2_perm_B_18_2, poseidon2_perm_B_18_3, poseidon2_perm_B_19_0, poseidon2_perm_B_19_1, poseidon2_perm_B_19_2, poseidon2_perm_B_19_3, poseidon2_perm_B_20_0, poseidon2_perm_B_20_1, poseidon2_perm_B_20_2, poseidon2_perm_B_20_3, poseidon2_perm_B_21_0, poseidon2_perm_B_21_1, poseidon2_perm_B_21_2, poseidon2_perm_B_21_3, poseidon2_perm_B_22_0, poseidon2_perm_B_22_1, poseidon2_perm_B_22_2, poseidon2_perm_B_22_3, poseidon2_perm_B_23_0, poseidon2_perm_B_23_1, poseidon2_perm_B_23_2, poseidon2_perm_B_23_3, poseidon2_perm_B_24_0, poseidon2_perm_B_24_1, poseidon2_perm_B_24_2, poseidon2_perm_B_24_3, poseidon2_perm_B_25_0, poseidon2_perm_B_25_1, poseidon2_perm_B_25_2, poseidon2_perm_B_25_3, poseidon2_perm_B_26_0, poseidon2_perm_B_26_1, poseidon2_perm_B_26_2, poseidon2_perm_B_26_3, poseidon2_perm_B_27_0, poseidon2_perm_B_27_1, poseidon2_perm_B_27_2, poseidon2_perm_B_27_3, poseidon2_perm_B_28_0, poseidon2_perm_B_28_1, poseidon2_perm_B_28_2, poseidon2_perm_B_28_3, poseidon2_perm_B_29_0, poseidon2_perm_B_29_1, poseidon2_perm_B_29_2, poseidon2_perm_B_29_3, poseidon2_perm_B_30_0, poseidon2_perm_B_30_1, poseidon2_perm_B_30_2, poseidon2_perm_B_30_3, poseidon2_perm_B_31_0, poseidon2_perm_B_31_1, poseidon2_perm_B_31_2, poseidon2_perm_B_31_3, poseidon2_perm_B_32_0, poseidon2_perm_B_32_1, poseidon2_perm_B_32_2, poseidon2_perm_B_32_3, poseidon2_perm_B_33_0, poseidon2_perm_B_33_1, poseidon2_perm_B_33_2, poseidon2_perm_B_33_3, poseidon2_perm_B_34_0, poseidon2_perm_B_34_1, poseidon2_perm_B_34_2, poseidon2_perm_B_34_3, poseidon2_perm_B_35_0, poseidon2_perm_B_35_1, poseidon2_perm_B_35_2, poseidon2_perm_B_35_3, poseidon2_perm_B_36_0, poseidon2_perm_B_36_1, poseidon2_perm_B_36_2, poseidon2_perm_B_36_3, poseidon2_perm_B_37_0, poseidon2_perm_B_37_1, poseidon2_perm_B_37_2, poseidon2_perm_B_37_3, poseidon2_perm_B_38_0, poseidon2_perm_B_38_1, poseidon2_perm_B_38_2, poseidon2_perm_B_38_3, poseidon2_perm_B_39_0, poseidon2_perm_B_39_1, poseidon2_perm_B_39_2, poseidon2_perm_B_39_3, poseidon2_perm_B_40_0, poseidon2_perm_B_40_1, poseidon2_perm_B_40_2, poseidon2_perm_B_40_3, poseidon2_perm_B_41_0, poseidon2_perm_B_41_1, poseidon2_perm_B_41_2, poseidon2_perm_B_41_3, poseidon2_perm_B_42_0, poseidon2_perm_B_42_1, poseidon2_perm_B_42_2, poseidon2_perm_B_42_3, poseidon2_perm_B_43_0, poseidon2_perm_B_43_1, poseidon2_perm_B_43_2, poseidon2_perm_B_43_3, poseidon2_perm_B_44_0, poseidon2_perm_B_44_1, poseidon2_perm_B_44_2, poseidon2_perm_B_44_3, poseidon2_perm_B_45_0, poseidon2_perm_B_45_1, poseidon2_perm_B_45_2, poseidon2_perm_B_45_3, poseidon2_perm_B_46_0, poseidon2_perm_B_46_1, poseidon2_perm_B_46_2, poseidon2_perm_B_46_3, poseidon2_perm_B_47_0, poseidon2_perm_B_47_1, poseidon2_perm_B_47_2, poseidon2_perm_B_47_3, poseidon2_perm_B_48_0, poseidon2_perm_B_48_1, poseidon2_perm_B_48_2, poseidon2_perm_B_48_3, poseidon2_perm_B_49_0, poseidon2_perm_B_49_1, poseidon2_perm_B_49_2, poseidon2_perm_B_49_3, poseidon2_perm_B_4_0, poseidon2_perm_B_4_1, poseidon2_perm_B_4_2, poseidon2_perm_B_4_3, poseidon2_perm_B_50_0, poseidon2_perm_B_50_1, poseidon2_perm_B_50_2, poseidon2_perm_B_50_3, poseidon2_perm_B_51_0, poseidon2_perm_B_51_1, poseidon2_perm_B_51_2, poseidon2_perm_B_51_3, poseidon2_perm_B_52_0, poseidon2_perm_B_52_1, poseidon2_perm_B_52_2, poseidon2_perm_B_52_3, poseidon2_perm_B_53_0, poseidon2_perm_B_53_1, poseidon2_perm_B_53_2, poseidon2_perm_B_53_3, poseidon2_perm_B_54_0, poseidon2_perm_B_54_1, poseidon2_perm_B_54_2, poseidon2_perm_B_54_3, poseidon2_perm_B_55_0, poseidon2_perm_B_55_1, poseidon2_perm_B_55_2, poseidon2_perm_B_55_3, poseidon2_perm_B_56_0, poseidon2_perm_B_56_1, poseidon2_perm_B_56_2, poseidon2_perm_B_56_3, poseidon2_perm_B_57_0, poseidon2_perm_B_57_1, poseidon2_perm_B_57_2, poseidon2_perm_B_57_3, poseidon2_perm_B_58_0, poseidon2_perm_B_58_1, poseidon2_perm_B_58_2, poseidon2_perm_B_58_3, poseidon2_perm_B_59_0, poseidon2_perm_B_59_1, poseidon2_perm_B_59_2, poseidon2_perm_B_59_3, poseidon2_perm_B_5_0, poseidon2_perm_B_5_1, poseidon2_perm_B_5_2, poseidon2_perm_B_5_3, poseidon2_perm_B_6_0, poseidon2_perm_B_6_1, poseidon2_perm_B_6_2, poseidon2_perm_B_6_3, poseidon2_perm_B_7_0, poseidon2_perm_B_7_1, poseidon2_perm_B_7_2, poseidon2_perm_B_7_3, poseidon2_perm_B_8_0, poseidon2_perm_B_8_1, poseidon2_perm_B_8_2, poseidon2_perm_B_8_3, poseidon2_perm_B_9_0, poseidon2_perm_B_9_1, poseidon2_perm_B_9_2, poseidon2_perm_B_9_3, poseidon2_perm_EXT_LAYER_4, poseidon2_perm_EXT_LAYER_5, poseidon2_perm_EXT_LAYER_6, poseidon2_perm_EXT_LAYER_7, poseidon2_perm_T_0_4, poseidon2_perm_T_0_5, poseidon2_perm_T_0_6, poseidon2_perm_T_0_7, poseidon2_perm_T_1_4, poseidon2_perm_T_1_5, poseidon2_perm_T_1_6, poseidon2_perm_T_1_7, poseidon2_perm_T_2_4, poseidon2_perm_T_2_5, poseidon2_perm_T_2_6, poseidon2_perm_T_2_7, poseidon2_perm_T_3_4, poseidon2_perm_T_3_5, poseidon2_perm_T_3_6, poseidon2_perm_T_3_7, poseidon2_perm_T_60_4, poseidon2_perm_T_60_5, poseidon2_perm_T_60_6, poseidon2_perm_T_60_7, poseidon2_perm_T_61_4, poseidon2_perm_T_61_5, poseidon2_perm_T_61_6, poseidon2_perm_T_61_7, poseidon2_perm_T_62_4, poseidon2_perm_T_62_5, poseidon2_perm_T_62_6, poseidon2_perm_T_62_7, poseidon2_perm_T_63_4, poseidon2_perm_T_63_5, poseidon2_perm_T_63_6, poseidon2_perm_T_63_7, poseidon2_perm_a_0, poseidon2_perm_a_1, poseidon2_perm_a_2, poseidon2_perm_a_3, poseidon2_perm_b_0, poseidon2_perm_b_1, poseidon2_perm_b_2, poseidon2_perm_b_3, poseidon2_perm_sel, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_rng_chk_bits, range_check_sel, range_check_sel_r0_16_bit_rng_lookup, range_check_sel_r1_16_bit_rng_lookup, range_check_sel_r2_16_bit_rng_lookup, range_check_sel_r3_16_bit_rng_lookup, range_check_sel_r4_16_bit_rng_lookup, range_check_sel_r5_16_bit_rng_lookup, range_check_sel_r6_16_bit_rng_lookup, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, scalar_mul_bit, scalar_mul_bit_idx, scalar_mul_bit_radix, scalar_mul_end, scalar_mul_not_end, scalar_mul_point_inf, scalar_mul_point_x, scalar_mul_point_y, scalar_mul_res_inf, scalar_mul_res_x, scalar_mul_res_y, scalar_mul_scalar, scalar_mul_sel, scalar_mul_should_add, scalar_mul_start, scalar_mul_temp_inf, scalar_mul_temp_x, scalar_mul_temp_y, sha256_a, sha256_a_and_b, sha256_a_and_b_xor_a_and_c, sha256_a_and_c, sha256_a_rotr_13, sha256_a_rotr_2, sha256_a_rotr_22, sha256_a_rotr_2_xor_a_rotr_13, sha256_and_sel, sha256_b, sha256_b_and_c, sha256_c, sha256_ch, sha256_clk, sha256_computed_w_lhs, sha256_computed_w_rhs, sha256_d, sha256_e, sha256_e_and_f, sha256_e_rotr_11, sha256_e_rotr_25, sha256_e_rotr_6, sha256_e_rotr_6_xor_e_rotr_11, sha256_f, sha256_g, sha256_h, sha256_helper_w0, sha256_helper_w1, sha256_helper_w10, sha256_helper_w11, sha256_helper_w12, sha256_helper_w13, sha256_helper_w14, sha256_helper_w15, sha256_helper_w2, sha256_helper_w3, sha256_helper_w4, sha256_helper_w5, sha256_helper_w6, sha256_helper_w7, sha256_helper_w8, sha256_helper_w9, sha256_init_a, sha256_init_b, sha256_init_c, sha256_init_d, sha256_init_e, sha256_init_f, sha256_init_g, sha256_init_h, sha256_input_offset, sha256_is_input_round, sha256_latch, sha256_lhs_a_13, sha256_lhs_a_2, sha256_lhs_a_22, sha256_lhs_e_11, sha256_lhs_e_25, sha256_lhs_e_6, sha256_lhs_w_10, sha256_lhs_w_17, sha256_lhs_w_18, sha256_lhs_w_19, sha256_lhs_w_3, sha256_lhs_w_7, sha256_maj, sha256_next_a_lhs, sha256_next_a_rhs, sha256_next_e_lhs, sha256_next_e_rhs, sha256_not_e, sha256_not_e_and_g, sha256_output_a_lhs, sha256_output_a_rhs, sha256_output_b_lhs, sha256_output_b_rhs, sha256_output_c_lhs, sha256_output_c_rhs, sha256_output_d_lhs, sha256_output_d_rhs, sha256_output_e_lhs, sha256_output_e_rhs, sha256_output_f_lhs, sha256_output_f_rhs, sha256_output_g_lhs, sha256_output_g_rhs, sha256_output_h_lhs, sha256_output_h_rhs, sha256_output_offset, sha256_perform_round, sha256_rhs_a_13, sha256_rhs_a_2, sha256_rhs_a_22, sha256_rhs_e_11, sha256_rhs_e_25, sha256_rhs_e_6, sha256_rhs_w_10, sha256_rhs_w_17, sha256_rhs_w_18, sha256_rhs_w_19, sha256_rhs_w_3, sha256_rhs_w_7, sha256_round_constant, sha256_round_count, sha256_rounds_remaining, sha256_rounds_remaining_inv, sha256_s_0, sha256_s_1, sha256_sel, sha256_start, sha256_state_offset, sha256_w, sha256_w_15_rotr_18, sha256_w_15_rotr_7, sha256_w_15_rotr_7_xor_w_15_rotr_18, sha256_w_15_rshift_3, sha256_w_2_rotr_17, sha256_w_2_rotr_17_xor_w_2_rotr_19, sha256_w_2_rotr_19, sha256_w_2_rshift_10, sha256_w_s_0, sha256_w_s_1, sha256_xor_sel, to_radix_acc, to_radix_acc_under_p, to_radix_end, to_radix_exponent, to_radix_found, to_radix_is_unsafe_limb, to_radix_limb, to_radix_limb_eq_p, to_radix_limb_index, to_radix_limb_lt_p, to_radix_limb_p_diff, to_radix_limb_radix_diff, to_radix_not_end, to_radix_not_padding_limb, to_radix_p_limb, to_radix_radix, to_radix_rem_inverse, to_radix_safe_limbs, to_radix_safety_diff_inverse, to_radix_sel, to_radix_start, to_radix_value, lookup_poseidon2_hash_poseidon2_perm_counts, lookup_range_check_dyn_rng_chk_pow_2_counts, lookup_range_check_dyn_diff_is_u16_counts, lookup_range_check_r0_is_u16_counts, lookup_range_check_r1_is_u16_counts, lookup_range_check_r2_is_u16_counts, lookup_range_check_r3_is_u16_counts, lookup_range_check_r4_is_u16_counts, lookup_range_check_r5_is_u16_counts, lookup_range_check_r6_is_u16_counts, lookup_range_check_r7_is_u16_counts, lookup_to_radix_limb_range_counts, lookup_to_radix_limb_less_than_radix_range_counts, lookup_to_radix_fetch_safe_limbs_counts, lookup_to_radix_fetch_p_limb_counts, lookup_to_radix_limb_p_diff_range_counts, lookup_scalar_mul_to_radix_counts, lookup_scalar_mul_double_counts, lookup_scalar_mul_add_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_0_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_1_counts, lookup_address_derivation_partial_address_poseidon2_counts, lookup_address_derivation_public_keys_hash_poseidon2_0_counts, lookup_address_derivation_public_keys_hash_poseidon2_1_counts, lookup_address_derivation_public_keys_hash_poseidon2_2_counts, lookup_address_derivation_public_keys_hash_poseidon2_3_counts, lookup_address_derivation_public_keys_hash_poseidon2_4_counts, lookup_address_derivation_preaddress_poseidon2_counts, lookup_address_derivation_preaddress_scalar_mul_counts, lookup_address_derivation_address_ecadd_counts, lookup_bc_decomposition_bytes_are_bytes_counts, lookup_bc_decomposition_abs_diff_is_u16_counts, lookup_bc_decomposition_bytes_to_read_as_unary_counts, lookup_bc_hashing_get_packed_field_counts, lookup_bc_hashing_iv_is_len_counts, lookup_bc_hashing_poseidon2_hash_counts, lookup_bc_retrieval_class_id_derivation_counts, lookup_bc_retrieval_bytecode_hash_is_correct_counts, lookup_instr_fetching_abs_diff_positive_counts, lookup_instr_fetching_abs_diff_positive_lo_counts, lookup_instr_fetching_abs_diff_positive_hi_counts, lookup_instr_fetching_bytes_from_bc_dec_counts, lookup_instr_fetching_wire_instruction_info_counts, lookup_class_id_derivation_class_id_poseidon2_0_counts, lookup_class_id_derivation_class_id_poseidon2_1_counts, lookup_bitwise_integral_tag_length_counts, lookup_bitwise_byte_operations_counts, lookup_sha256_round_constant_counts +#define AVM2_DERIVED_WITNESS_ENTITIES lookup_poseidon2_hash_poseidon2_perm_inv, lookup_range_check_dyn_rng_chk_pow_2_inv, lookup_range_check_dyn_diff_is_u16_inv, lookup_range_check_r0_is_u16_inv, lookup_range_check_r1_is_u16_inv, lookup_range_check_r2_is_u16_inv, lookup_range_check_r3_is_u16_inv, lookup_range_check_r4_is_u16_inv, lookup_range_check_r5_is_u16_inv, lookup_range_check_r6_is_u16_inv, lookup_range_check_r7_is_u16_inv, lookup_to_radix_limb_range_inv, lookup_to_radix_limb_less_than_radix_range_inv, lookup_to_radix_fetch_safe_limbs_inv, lookup_to_radix_fetch_p_limb_inv, lookup_to_radix_limb_p_diff_range_inv, lookup_scalar_mul_to_radix_inv, lookup_scalar_mul_double_inv, lookup_scalar_mul_add_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_0_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_1_inv, lookup_address_derivation_partial_address_poseidon2_inv, lookup_address_derivation_public_keys_hash_poseidon2_0_inv, lookup_address_derivation_public_keys_hash_poseidon2_1_inv, lookup_address_derivation_public_keys_hash_poseidon2_2_inv, lookup_address_derivation_public_keys_hash_poseidon2_3_inv, lookup_address_derivation_public_keys_hash_poseidon2_4_inv, lookup_address_derivation_preaddress_poseidon2_inv, lookup_address_derivation_preaddress_scalar_mul_inv, lookup_address_derivation_address_ecadd_inv, lookup_bc_decomposition_bytes_are_bytes_inv, lookup_bc_decomposition_abs_diff_is_u16_inv, lookup_bc_decomposition_bytes_to_read_as_unary_inv, lookup_bc_hashing_get_packed_field_inv, lookup_bc_hashing_iv_is_len_inv, lookup_bc_hashing_poseidon2_hash_inv, lookup_bc_retrieval_class_id_derivation_inv, lookup_bc_retrieval_bytecode_hash_is_correct_inv, lookup_instr_fetching_abs_diff_positive_inv, lookup_instr_fetching_abs_diff_positive_lo_inv, lookup_instr_fetching_abs_diff_positive_hi_inv, lookup_instr_fetching_bytes_from_bc_dec_inv, lookup_instr_fetching_wire_instruction_info_inv, lookup_class_id_derivation_class_id_poseidon2_0_inv, lookup_class_id_derivation_class_id_poseidon2_1_inv, lookup_bitwise_integral_tag_length_inv, lookup_bitwise_byte_operations_inv, lookup_sha256_round_constant_inv #define AVM2_SHIFTED_ENTITIES bc_decomposition_bytes_shift, bc_decomposition_bytes_pc_plus_1_shift, bc_decomposition_bytes_pc_plus_10_shift, bc_decomposition_bytes_pc_plus_11_shift, bc_decomposition_bytes_pc_plus_12_shift, bc_decomposition_bytes_pc_plus_13_shift, bc_decomposition_bytes_pc_plus_14_shift, bc_decomposition_bytes_pc_plus_15_shift, bc_decomposition_bytes_pc_plus_16_shift, bc_decomposition_bytes_pc_plus_17_shift, bc_decomposition_bytes_pc_plus_18_shift, bc_decomposition_bytes_pc_plus_19_shift, bc_decomposition_bytes_pc_plus_2_shift, bc_decomposition_bytes_pc_plus_20_shift, bc_decomposition_bytes_pc_plus_21_shift, bc_decomposition_bytes_pc_plus_22_shift, bc_decomposition_bytes_pc_plus_23_shift, bc_decomposition_bytes_pc_plus_24_shift, bc_decomposition_bytes_pc_plus_25_shift, bc_decomposition_bytes_pc_plus_26_shift, bc_decomposition_bytes_pc_plus_27_shift, bc_decomposition_bytes_pc_plus_28_shift, bc_decomposition_bytes_pc_plus_29_shift, bc_decomposition_bytes_pc_plus_3_shift, bc_decomposition_bytes_pc_plus_30_shift, bc_decomposition_bytes_pc_plus_31_shift, bc_decomposition_bytes_pc_plus_32_shift, bc_decomposition_bytes_pc_plus_33_shift, bc_decomposition_bytes_pc_plus_34_shift, bc_decomposition_bytes_pc_plus_35_shift, bc_decomposition_bytes_pc_plus_4_shift, bc_decomposition_bytes_pc_plus_5_shift, bc_decomposition_bytes_pc_plus_6_shift, bc_decomposition_bytes_pc_plus_7_shift, bc_decomposition_bytes_pc_plus_8_shift, bc_decomposition_bytes_pc_plus_9_shift, bc_decomposition_bytes_remaining_shift, bc_decomposition_id_shift, bc_decomposition_pc_shift, bc_decomposition_sel_shift, bc_hashing_bytecode_id_shift, bc_hashing_incremental_hash_shift, bc_hashing_pc_index_shift, bc_hashing_sel_shift, bc_hashing_start_shift, bitwise_acc_ia_shift, bitwise_acc_ib_shift, bitwise_acc_ic_shift, bitwise_ctr_shift, bitwise_op_id_shift, execution_sel_shift, instr_fetching_bytecode_id_shift, instr_fetching_bytecode_size_shift, instr_fetching_bytes_remaining_shift, instr_fetching_pc_shift, instr_fetching_sel_shift, poseidon2_hash_a_0_shift, poseidon2_hash_a_1_shift, poseidon2_hash_a_2_shift, poseidon2_hash_a_3_shift, poseidon2_hash_input_0_shift, poseidon2_hash_input_1_shift, poseidon2_hash_input_2_shift, poseidon2_hash_num_perm_rounds_rem_shift, poseidon2_hash_output_shift, poseidon2_hash_sel_shift, poseidon2_hash_start_shift, scalar_mul_bit_idx_shift, scalar_mul_point_inf_shift, scalar_mul_point_x_shift, scalar_mul_point_y_shift, scalar_mul_res_inf_shift, scalar_mul_res_x_shift, scalar_mul_res_y_shift, scalar_mul_scalar_shift, scalar_mul_sel_shift, scalar_mul_start_shift, scalar_mul_temp_inf_shift, scalar_mul_temp_x_shift, scalar_mul_temp_y_shift, sha256_a_shift, sha256_b_shift, sha256_c_shift, sha256_d_shift, sha256_e_shift, sha256_f_shift, sha256_g_shift, sha256_h_shift, sha256_helper_w0_shift, sha256_helper_w1_shift, sha256_helper_w10_shift, sha256_helper_w11_shift, sha256_helper_w12_shift, sha256_helper_w13_shift, sha256_helper_w14_shift, sha256_helper_w15_shift, sha256_helper_w2_shift, sha256_helper_w3_shift, sha256_helper_w4_shift, sha256_helper_w5_shift, sha256_helper_w6_shift, sha256_helper_w7_shift, sha256_helper_w8_shift, sha256_helper_w9_shift, sha256_rounds_remaining_shift, sha256_sel_shift, sha256_start_shift, to_radix_acc_shift, to_radix_acc_under_p_shift, to_radix_exponent_shift, to_radix_limb_shift, to_radix_limb_eq_p_shift, to_radix_limb_index_shift, to_radix_limb_lt_p_shift, to_radix_not_padding_limb_shift, to_radix_radix_shift, to_radix_safe_limbs_shift, to_radix_sel_shift, to_radix_start_shift, to_radix_value_shift #define AVM2_TO_BE_SHIFTED(e) e.bc_decomposition_bytes, e.bc_decomposition_bytes_pc_plus_1, e.bc_decomposition_bytes_pc_plus_10, e.bc_decomposition_bytes_pc_plus_11, e.bc_decomposition_bytes_pc_plus_12, e.bc_decomposition_bytes_pc_plus_13, e.bc_decomposition_bytes_pc_plus_14, e.bc_decomposition_bytes_pc_plus_15, e.bc_decomposition_bytes_pc_plus_16, e.bc_decomposition_bytes_pc_plus_17, e.bc_decomposition_bytes_pc_plus_18, e.bc_decomposition_bytes_pc_plus_19, e.bc_decomposition_bytes_pc_plus_2, e.bc_decomposition_bytes_pc_plus_20, e.bc_decomposition_bytes_pc_plus_21, e.bc_decomposition_bytes_pc_plus_22, e.bc_decomposition_bytes_pc_plus_23, e.bc_decomposition_bytes_pc_plus_24, e.bc_decomposition_bytes_pc_plus_25, e.bc_decomposition_bytes_pc_plus_26, e.bc_decomposition_bytes_pc_plus_27, e.bc_decomposition_bytes_pc_plus_28, e.bc_decomposition_bytes_pc_plus_29, e.bc_decomposition_bytes_pc_plus_3, e.bc_decomposition_bytes_pc_plus_30, e.bc_decomposition_bytes_pc_plus_31, e.bc_decomposition_bytes_pc_plus_32, e.bc_decomposition_bytes_pc_plus_33, e.bc_decomposition_bytes_pc_plus_34, e.bc_decomposition_bytes_pc_plus_35, e.bc_decomposition_bytes_pc_plus_4, e.bc_decomposition_bytes_pc_plus_5, e.bc_decomposition_bytes_pc_plus_6, e.bc_decomposition_bytes_pc_plus_7, e.bc_decomposition_bytes_pc_plus_8, e.bc_decomposition_bytes_pc_plus_9, e.bc_decomposition_bytes_remaining, e.bc_decomposition_id, e.bc_decomposition_pc, e.bc_decomposition_sel, e.bc_hashing_bytecode_id, e.bc_hashing_incremental_hash, e.bc_hashing_pc_index, e.bc_hashing_sel, e.bc_hashing_start, e.bitwise_acc_ia, e.bitwise_acc_ib, e.bitwise_acc_ic, e.bitwise_ctr, e.bitwise_op_id, e.execution_sel, e.instr_fetching_bytecode_id, e.instr_fetching_bytecode_size, e.instr_fetching_bytes_remaining, e.instr_fetching_pc, e.instr_fetching_sel, e.poseidon2_hash_a_0, e.poseidon2_hash_a_1, e.poseidon2_hash_a_2, e.poseidon2_hash_a_3, e.poseidon2_hash_input_0, e.poseidon2_hash_input_1, e.poseidon2_hash_input_2, e.poseidon2_hash_num_perm_rounds_rem, e.poseidon2_hash_output, e.poseidon2_hash_sel, e.poseidon2_hash_start, e.scalar_mul_bit_idx, e.scalar_mul_point_inf, e.scalar_mul_point_x, e.scalar_mul_point_y, e.scalar_mul_res_inf, e.scalar_mul_res_x, e.scalar_mul_res_y, e.scalar_mul_scalar, e.scalar_mul_sel, e.scalar_mul_start, e.scalar_mul_temp_inf, e.scalar_mul_temp_x, e.scalar_mul_temp_y, e.sha256_a, e.sha256_b, e.sha256_c, e.sha256_d, e.sha256_e, e.sha256_f, e.sha256_g, e.sha256_h, e.sha256_helper_w0, e.sha256_helper_w1, e.sha256_helper_w10, e.sha256_helper_w11, e.sha256_helper_w12, e.sha256_helper_w13, e.sha256_helper_w14, e.sha256_helper_w15, e.sha256_helper_w2, e.sha256_helper_w3, e.sha256_helper_w4, e.sha256_helper_w5, e.sha256_helper_w6, e.sha256_helper_w7, e.sha256_helper_w8, e.sha256_helper_w9, e.sha256_rounds_remaining, e.sha256_sel, e.sha256_start, e.to_radix_acc, e.to_radix_acc_under_p, e.to_radix_exponent, e.to_radix_limb, e.to_radix_limb_eq_p, e.to_radix_limb_index, e.to_radix_limb_lt_p, e.to_radix_not_padding_limb, e.to_radix_radix, e.to_radix_safe_limbs, e.to_radix_sel, e.to_radix_start, e.to_radix_value #define AVM2_ALL_ENTITIES AVM2_PRECOMPUTED_ENTITIES, AVM2_WIRE_ENTITIES, AVM2_DERIVED_WITNESS_ENTITIES, AVM2_SHIFTED_ENTITIES @@ -31,8 +31,8 @@ enum class ColumnAndShifts { SENTINEL_DO_NOT_USE, }; -constexpr auto NUM_COLUMNS_WITH_SHIFTS = 1031; -constexpr auto NUM_COLUMNS_WITHOUT_SHIFTS = 911; +constexpr auto NUM_COLUMNS_WITH_SHIFTS = 1038; +constexpr auto NUM_COLUMNS_WITHOUT_SHIFTS = 918; constexpr auto TO_BE_SHIFTED_COLUMNS_ARRAY = []() { return std::array{ AVM2_TO_BE_SHIFTED_COLUMNS }; }(); constexpr auto SHIFTED_COLUMNS_ARRAY = []() { return std::array{ AVM2_SHIFTED_COLUMNS }; }(); static_assert(TO_BE_SHIFTED_COLUMNS_ARRAY.size() == SHIFTED_COLUMNS_ARRAY.size()); diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp index 39410a80e44d..950b85b626f2 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp @@ -90,12 +90,12 @@ class AvmFlavor { static constexpr bool HasZK = false; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 44; - static constexpr size_t NUM_WITNESS_ENTITIES = 867; + static constexpr size_t NUM_WITNESS_ENTITIES = 874; static constexpr size_t NUM_SHIFTED_ENTITIES = 120; static constexpr size_t NUM_WIRES = NUM_WITNESS_ENTITIES + NUM_PRECOMPUTED_ENTITIES; // We have two copies of the witness entities, so we subtract the number of fixed ones (they have no shift), one for // the unshifted and one for the shifted - static constexpr size_t NUM_ALL_ENTITIES = 1031; + static constexpr size_t NUM_ALL_ENTITIES = 1038; // In the sumcheck univariate computation, we divide the trace in chunks and each chunk is // evenly processed by all the threads. This constant defines the maximum number of rows @@ -158,6 +158,8 @@ class AvmFlavor { lookup_class_id_derivation_class_id_poseidon2_0_relation, lookup_class_id_derivation_class_id_poseidon2_1_relation, lookup_instr_fetching_abs_diff_positive_relation, + lookup_instr_fetching_abs_diff_positive_hi_relation, + lookup_instr_fetching_abs_diff_positive_lo_relation, lookup_instr_fetching_bytes_from_bc_dec_relation, lookup_instr_fetching_wire_instruction_info_relation, lookup_poseidon2_hash_poseidon2_perm_relation, diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp index 02b51c6cb756..87b29041a0de 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp @@ -12,8 +12,8 @@ template class instr_fetchingImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3, 3, 3, 4, 4, 3, 5, 3, 3, 4, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }; + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3, 3, 3, 4, 4, 3, 5, 3, 3, 4, 3, + 4, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3 }; template inline static bool skip(const AllEntities& in) { @@ -115,22 +115,40 @@ template class instr_fetchingImpl { } { using Accumulator = typename std::tuple_element_t<11, ContainerOverSubrelations>; - auto tmp = (new_term.instr_fetching_sel_lookup_bc_decomposition - - new_term.instr_fetching_sel * (FF(1) - new_term.instr_fetching_pc_out_of_range)); + auto tmp = (new_term.instr_fetching_pc_abs_diff - + new_term.instr_fetching_sel * + (((FF(2) * new_term.instr_fetching_pc_out_of_range - FF(1)) * + (new_term.instr_fetching_pc - new_term.instr_fetching_bytecode_size) - + FF(1)) + + new_term.instr_fetching_pc_out_of_range)); tmp *= scaling_factor; std::get<11>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<12, ContainerOverSubrelations>; + auto tmp = (new_term.instr_fetching_pc_abs_diff - + (new_term.instr_fetching_pc_abs_diff_lo + FF(65536) * new_term.instr_fetching_pc_abs_diff_hi)); + tmp *= scaling_factor; + std::get<12>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<13, ContainerOverSubrelations>; + auto tmp = (new_term.instr_fetching_sel_lookup_bc_decomposition - + new_term.instr_fetching_sel * (FF(1) - new_term.instr_fetching_pc_out_of_range)); + tmp *= scaling_factor; + std::get<13>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<14, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_indirect - (new_term.instr_fetching_sel_op_dc_0 * (new_term.instr_fetching_bd1 * FF(256) + new_term.instr_fetching_bd2 * FF(1)) + instr_fetching_SEL_OP_DC_18 * new_term.instr_fetching_bd1 * FF(1))); tmp *= scaling_factor; - std::get<12>(evals) += typename Accumulator::View(tmp); + std::get<14>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<13, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<15, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op1 - (new_term.instr_fetching_sel_op_dc_0 * (new_term.instr_fetching_bd3 * FF(256) + new_term.instr_fetching_bd4 * FF(1)) + @@ -141,10 +159,10 @@ template class instr_fetchingImpl { (new_term.instr_fetching_bd1 * FF(16777216) + new_term.instr_fetching_bd2 * FF(65536) + new_term.instr_fetching_bd3 * FF(256) + new_term.instr_fetching_bd4 * FF(1)))); tmp *= scaling_factor; - std::get<13>(evals) += typename Accumulator::View(tmp); + std::get<15>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<14, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<16, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op2 - (new_term.instr_fetching_sel_op_dc_0 * (new_term.instr_fetching_bd5 * FF(256) + new_term.instr_fetching_bd6 * FF(1)) + @@ -156,10 +174,10 @@ template class instr_fetchingImpl { (new_term.instr_fetching_bd4 * FF(16777216) + new_term.instr_fetching_bd5 * FF(65536) + new_term.instr_fetching_bd6 * FF(256) + new_term.instr_fetching_bd7 * FF(1)))); tmp *= scaling_factor; - std::get<14>(evals) += typename Accumulator::View(tmp); + std::get<16>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<15, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<17, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op3 - (new_term.instr_fetching_sel_op_dc_0 * (new_term.instr_fetching_bd7 * FF(256) + new_term.instr_fetching_bd8 * FF(1)) + @@ -226,10 +244,10 @@ template class instr_fetchingImpl { new_term.instr_fetching_sel_op_dc_14 * new_term.instr_fetching_bd4 * FF(1) + new_term.instr_fetching_sel_op_dc_17 * new_term.instr_fetching_bd6 * FF(1))); tmp *= scaling_factor; - std::get<15>(evals) += typename Accumulator::View(tmp); + std::get<17>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<16, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<18, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op4 - (new_term.instr_fetching_sel_op_dc_0 * (new_term.instr_fetching_bd9 * FF(256) + new_term.instr_fetching_bd10 * FF(1)) + @@ -237,31 +255,31 @@ template class instr_fetchingImpl { (new_term.instr_fetching_bd8 * FF(256) + new_term.instr_fetching_bd9 * FF(1)) + new_term.instr_fetching_sel_op_dc_7 * new_term.instr_fetching_bd8 * FF(1))); tmp *= scaling_factor; - std::get<16>(evals) += typename Accumulator::View(tmp); + std::get<18>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<17, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<19, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op5 - new_term.instr_fetching_sel_op_dc_0 * (new_term.instr_fetching_bd11 * FF(256) + new_term.instr_fetching_bd12 * FF(1))); tmp *= scaling_factor; - std::get<17>(evals) += typename Accumulator::View(tmp); + std::get<19>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<18, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<20, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op6 - new_term.instr_fetching_sel_op_dc_1 * (new_term.instr_fetching_bd13 * FF(256) + new_term.instr_fetching_bd14 * FF(1))); tmp *= scaling_factor; - std::get<18>(evals) += typename Accumulator::View(tmp); + std::get<20>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<19, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<21, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op7 - new_term.instr_fetching_sel_op_dc_1 * (new_term.instr_fetching_bd15 * FF(256) + new_term.instr_fetching_bd16 * FF(1))); tmp *= scaling_factor; - std::get<19>(evals) += typename Accumulator::View(tmp); + std::get<21>(evals) += typename Accumulator::View(tmp); } } }; @@ -280,20 +298,22 @@ template class instr_fetching : public Relation class instr_fetching : public Relation SRC_COLUMNS = { + ColumnAndShifts::instr_fetching_pc_abs_diff_lo + }; + static constexpr std::array DST_COLUMNS = { ColumnAndShifts::precomputed_clk }; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in._instr_fetching_sel() == 1 || in._precomputed_sel_range_16() == 1); + } + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in._instr_fetching_sel()); + const auto is_table_entry = View(in._precomputed_sel_range_16()); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + template static inline auto get_const_entities(const AllEntities& in) + { + return get_entities(in); + } + + template static inline auto get_nonconst_entities(AllEntities& in) + { + return get_entities(in); + } + + template static inline auto get_entities(AllEntities&& in) + { + return std::forward_as_tuple(in._lookup_instr_fetching_abs_diff_positive_lo_inv(), + in._lookup_instr_fetching_abs_diff_positive_lo_counts(), + in._instr_fetching_sel(), + in._precomputed_sel_range_16(), + in._instr_fetching_pc_abs_diff_lo(), + in._precomputed_clk()); + } +}; + +template +class lookup_instr_fetching_abs_diff_positive_lo_relation + : public GenericLookupRelation { + public: + using Settings = lookup_instr_fetching_abs_diff_positive_lo_settings; + static constexpr std::string_view NAME = lookup_instr_fetching_abs_diff_positive_lo_settings::NAME; + static constexpr std::string_view RELATION_NAME = + lookup_instr_fetching_abs_diff_positive_lo_settings::RELATION_NAME; + + template inline static bool skip(const AllEntities& in) + { + return in.lookup_instr_fetching_abs_diff_positive_lo_inv.is_zero(); + } + + static std::string get_subrelation_label(size_t index) + { + if (index == 0) { + return "INVERSES_ARE_CORRECT"; + } else if (index == 1) { + return "ACCUMULATION_IS_CORRECT"; + } + return std::to_string(index); + } +}; + +/////////////////// lookup_instr_fetching_abs_diff_positive_hi /////////////////// + +class lookup_instr_fetching_abs_diff_positive_hi_settings { + public: + static constexpr std::string_view NAME = "LOOKUP_INSTR_FETCHING_ABS_DIFF_POSITIVE_HI"; + static constexpr std::string_view RELATION_NAME = "instr_fetching"; + + static constexpr size_t READ_TERMS = 1; + static constexpr size_t WRITE_TERMS = 1; + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + static constexpr size_t READ_TERM_DEGREE = 0; + static constexpr size_t WRITE_TERM_DEGREE = 0; + + // Columns using the Column enum. + static constexpr Column SRC_SELECTOR = Column::instr_fetching_sel; + static constexpr Column DST_SELECTOR = Column::precomputed_sel_range_16; + static constexpr Column COUNTS = Column::lookup_instr_fetching_abs_diff_positive_hi_counts; + static constexpr Column INVERSES = Column::lookup_instr_fetching_abs_diff_positive_hi_inv; + static constexpr std::array SRC_COLUMNS = { + ColumnAndShifts::instr_fetching_pc_abs_diff_hi + }; + static constexpr std::array DST_COLUMNS = { ColumnAndShifts::precomputed_clk }; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in._instr_fetching_sel() == 1 || in._precomputed_sel_range_16() == 1); + } + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in._instr_fetching_sel()); + const auto is_table_entry = View(in._precomputed_sel_range_16()); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + template static inline auto get_const_entities(const AllEntities& in) + { + return get_entities(in); + } + + template static inline auto get_nonconst_entities(AllEntities& in) + { + return get_entities(in); + } + + template static inline auto get_entities(AllEntities&& in) + { + return std::forward_as_tuple(in._lookup_instr_fetching_abs_diff_positive_hi_inv(), + in._lookup_instr_fetching_abs_diff_positive_hi_counts(), + in._instr_fetching_sel(), + in._precomputed_sel_range_16(), + in._instr_fetching_pc_abs_diff_hi(), + in._precomputed_clk()); + } +}; + +template +class lookup_instr_fetching_abs_diff_positive_hi_relation + : public GenericLookupRelation { + public: + using Settings = lookup_instr_fetching_abs_diff_positive_hi_settings; + static constexpr std::string_view NAME = lookup_instr_fetching_abs_diff_positive_hi_settings::NAME; + static constexpr std::string_view RELATION_NAME = + lookup_instr_fetching_abs_diff_positive_hi_settings::RELATION_NAME; + + template inline static bool skip(const AllEntities& in) + { + return in.lookup_instr_fetching_abs_diff_positive_hi_inv.is_zero(); + } + + static std::string get_subrelation_label(size_t index) + { + if (index == 0) { + return "INVERSES_ARE_CORRECT"; + } else if (index == 1) { + return "ACCUMULATION_IS_CORRECT"; + } + return std::to_string(index); + } +}; + /////////////////// lookup_instr_fetching_bytes_from_bc_dec /////////////////// class lookup_instr_fetching_bytes_from_bc_dec_settings { diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp index d5b4fbb850be..220542c010d5 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp @@ -309,6 +309,12 @@ void BytecodeTraceBuilder::process_instruction_fetching( abs_diff = wire_instr_spec.size_in_bytes - bytes_to_read - 1; } + uint32_t bytecode_size_u32 = static_cast(bytecode_size); + uint32_t pc_abs_diff = + bytecode_size_u32 > event.pc ? bytecode_size_u32 - event.pc - 1 : event.pc - bytecode_size_u32; + uint32_t pc_abs_diff_lo = pc_abs_diff & 0xFFFF; + uint32_t pc_abs_diff_hi = pc_abs_diff >> 16; + trace.set(row, { { { C::instr_fetching_sel, 1 }, @@ -402,6 +408,9 @@ void BytecodeTraceBuilder::process_instruction_fetching( { C::instr_fetching_bytes_remaining, bytes_remaining }, { C::instr_fetching_bytes_to_read, bytes_to_read }, { C::instr_fetching_abs_diff, abs_diff }, + { C::instr_fetching_pc_abs_diff, pc_abs_diff }, + { C::instr_fetching_pc_abs_diff_lo, pc_abs_diff_lo }, + { C::instr_fetching_pc_abs_diff_hi, pc_abs_diff_hi }, } }); row++; } From 9d0509f5a074707d1a597d4a91c125bfea4a70f6 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Wed, 12 Mar 2025 11:42:58 +0000 Subject: [PATCH 03/25] Add error handling for instruction fetching in simulation --- barretenberg/cpp/pil/vm2/instr_fetching.pil | 9 ++- .../src/barretenberg/vm2/common/stringify.hpp | 24 ++++++ .../barretenberg/vm2/generated/columns.hpp | 4 +- .../src/barretenberg/vm2/generated/flavor.hpp | 4 +- .../generated/relations/instr_fetching.hpp | 5 +- .../relations/lookups_instr_fetching.hpp | 52 ++++++------- .../vm2/simulation/bytecode_manager.cpp | 20 ++++- .../vm2/simulation/lib/serialization.cpp | 74 ++++++++++--------- .../vm2/simulation/lib/serialization.hpp | 4 +- .../vm2/simulation/lib/serialization.test.cpp | 50 +++++++++++++ .../vm2/tracegen/bytecode_trace.cpp | 2 + .../src/barretenberg/vm2/tracegen_helper.cpp | 3 + 12 files changed, 174 insertions(+), 77 deletions(-) create mode 100644 barretenberg/cpp/src/barretenberg/vm2/common/stringify.hpp diff --git a/barretenberg/cpp/pil/vm2/instr_fetching.pil b/barretenberg/cpp/pil/vm2/instr_fetching.pil index 9a530272c0f7..ffdc2ae9140e 100644 --- a/barretenberg/cpp/pil/vm2/instr_fetching.pil +++ b/barretenberg/cpp/pil/vm2/instr_fetching.pil @@ -45,7 +45,6 @@ pol BC_ID_DIFF = bytecode_id' - bytecode_id; pol commit bc_id_diff_inv; sel * (BC_ID_DIFF * ((1 - last_of_bytecode) * (1 - bc_id_diff_inv) + bc_id_diff_inv) - last_of_bytecode) = 0; -// Note that last_of_bytecode might not be toggled at the last active row. // If last_of_bytecode OR precomputed.first_row then next row has pc == 0 #[PC_IS_ZERO_IN_BYTECODE_FIRST_ROW] @@ -59,7 +58,9 @@ pol commit bytecode_size; (last_of_bytecode + precomputed.first_row) * (bytecode_size' - bytes_remaining') = 0; #[SAME_BYTECODE_SIZE] -sel * (1 - last_of_bytecode) * (bytecode_size - bytecode_size') = 0; +sel * sel' * (1 - last_of_bytecode) * (bytecode_size - bytecode_size') = 0; +// Note that last_of_bytecode might not be toggled at the last active row. +// For this reason, we need the factor sel' in the above relation. // Absolute difference variant where we compute: // bytes_to_read - instr_size if instr_size <= bytes_to_read @@ -87,10 +88,10 @@ pol commit pc_abs_diff_hi; #[PC_ABS_DIFF_LIMBS] pc_abs_diff = pc_abs_diff_lo + 2**16 * pc_abs_diff_hi; -#[ABS_DIFF_POSITIVE_LO] +#[PC_ABS_DIFF_POSITIVE_LO] sel {pc_abs_diff_lo} in precomputed.sel_range_16 {precomputed.clk}; -#[ABS_DIFF_POSITIVE_HI] +#[PC_ABS_DIFF_POSITIVE_HI] sel {pc_abs_diff_hi} in precomputed.sel_range_16 {precomputed.clk}; // bytecode[pc] to bytecode[pc + 36] diff --git a/barretenberg/cpp/src/barretenberg/vm2/common/stringify.hpp b/barretenberg/cpp/src/barretenberg/vm2/common/stringify.hpp new file mode 100644 index 000000000000..5b49f013ad35 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/common/stringify.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include +#include +#include +#include + +#include "barretenberg/numeric/uint128/uint128.hpp" + +namespace bb::avm2 { + +template + requires(std::unsigned_integral) +std::string to_hex(T value) +{ + std::ostringstream stream; + auto num_bytes = static_cast(sizeof(T)); + auto mask = static_cast((static_cast(1) << (num_bytes * 8)) - 1); + auto padding = static_cast(num_bytes * 2); + stream << std::setfill('0') << std::setw(padding) << std::hex << (value & mask); + return stream.str(); +} + +} // namespace bb::avm2 \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp index 5f783a918337..54e5b7690bc8 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp @@ -10,8 +10,8 @@ namespace bb::avm2 { // The entities that will be used in the flavor. // clang-format off #define AVM2_PRECOMPUTED_ENTITIES precomputed_as_unary, precomputed_bitwise_input_a, precomputed_bitwise_input_b, precomputed_bitwise_op_id, precomputed_bitwise_output, precomputed_clk, precomputed_exec_opcode, precomputed_first_row, precomputed_instr_size, precomputed_integral_tag_length, precomputed_opcode_out_of_range, precomputed_p_decomposition_limb, precomputed_p_decomposition_limb_index, precomputed_p_decomposition_radix, precomputed_power_of_2, precomputed_sel_bitwise, precomputed_sel_integral_tag, precomputed_sel_op_dc_0, precomputed_sel_op_dc_1, precomputed_sel_op_dc_10, precomputed_sel_op_dc_11, precomputed_sel_op_dc_12, precomputed_sel_op_dc_13, precomputed_sel_op_dc_14, precomputed_sel_op_dc_15, precomputed_sel_op_dc_16, precomputed_sel_op_dc_17, precomputed_sel_op_dc_2, precomputed_sel_op_dc_3, precomputed_sel_op_dc_4, precomputed_sel_op_dc_5, precomputed_sel_op_dc_6, precomputed_sel_op_dc_7, precomputed_sel_op_dc_8, precomputed_sel_op_dc_9, precomputed_sel_p_decomposition, precomputed_sel_range_16, precomputed_sel_range_8, precomputed_sel_sha256_compression, precomputed_sel_to_radix_safe_limbs, precomputed_sel_unary, precomputed_sha256_compression_round_constant, precomputed_to_radix_safe_limbs, precomputed_zero -#define AVM2_WIRE_ENTITIES execution_input, address_derivation_address, address_derivation_address_y, address_derivation_class_id, address_derivation_deployer_addr, address_derivation_g1_x, address_derivation_g1_y, address_derivation_incoming_viewing_key_x, address_derivation_incoming_viewing_key_y, address_derivation_init_hash, address_derivation_nullifier_key_x, address_derivation_nullifier_key_y, address_derivation_outgoing_viewing_key_x, address_derivation_outgoing_viewing_key_y, address_derivation_partial_address, address_derivation_partial_address_domain_separator, address_derivation_preaddress, address_derivation_preaddress_domain_separator, address_derivation_preaddress_public_key_x, address_derivation_preaddress_public_key_y, address_derivation_public_keys_hash, address_derivation_public_keys_hash_domain_separator, address_derivation_salt, address_derivation_salted_init_hash, address_derivation_sel, address_derivation_tagging_key_x, address_derivation_tagging_key_y, alu_dst_addr, alu_ia, alu_ia_addr, alu_ib, alu_ib_addr, alu_ic, alu_op, alu_sel_op_add, bc_decomposition_abs_diff, bc_decomposition_bytes, bc_decomposition_bytes_pc_plus_1, bc_decomposition_bytes_pc_plus_10, bc_decomposition_bytes_pc_plus_11, bc_decomposition_bytes_pc_plus_12, bc_decomposition_bytes_pc_plus_13, bc_decomposition_bytes_pc_plus_14, bc_decomposition_bytes_pc_plus_15, bc_decomposition_bytes_pc_plus_16, bc_decomposition_bytes_pc_plus_17, bc_decomposition_bytes_pc_plus_18, bc_decomposition_bytes_pc_plus_19, bc_decomposition_bytes_pc_plus_2, bc_decomposition_bytes_pc_plus_20, bc_decomposition_bytes_pc_plus_21, bc_decomposition_bytes_pc_plus_22, bc_decomposition_bytes_pc_plus_23, bc_decomposition_bytes_pc_plus_24, bc_decomposition_bytes_pc_plus_25, bc_decomposition_bytes_pc_plus_26, bc_decomposition_bytes_pc_plus_27, bc_decomposition_bytes_pc_plus_28, bc_decomposition_bytes_pc_plus_29, bc_decomposition_bytes_pc_plus_3, bc_decomposition_bytes_pc_plus_30, bc_decomposition_bytes_pc_plus_31, bc_decomposition_bytes_pc_plus_32, bc_decomposition_bytes_pc_plus_33, bc_decomposition_bytes_pc_plus_34, bc_decomposition_bytes_pc_plus_35, bc_decomposition_bytes_pc_plus_36, bc_decomposition_bytes_pc_plus_4, bc_decomposition_bytes_pc_plus_5, bc_decomposition_bytes_pc_plus_6, bc_decomposition_bytes_pc_plus_7, bc_decomposition_bytes_pc_plus_8, bc_decomposition_bytes_pc_plus_9, bc_decomposition_bytes_rem_inv, bc_decomposition_bytes_rem_min_one_inv, bc_decomposition_bytes_remaining, bc_decomposition_bytes_to_read, bc_decomposition_bytes_to_read_unary, bc_decomposition_id, bc_decomposition_last_of_contract, bc_decomposition_packed_field, bc_decomposition_pc, bc_decomposition_sel, bc_decomposition_sel_overflow_correction_needed, bc_decomposition_sel_packed, bc_decomposition_sel_pc_plus_1, bc_decomposition_sel_pc_plus_10, bc_decomposition_sel_pc_plus_11, bc_decomposition_sel_pc_plus_12, bc_decomposition_sel_pc_plus_13, bc_decomposition_sel_pc_plus_14, bc_decomposition_sel_pc_plus_15, bc_decomposition_sel_pc_plus_16, bc_decomposition_sel_pc_plus_17, bc_decomposition_sel_pc_plus_18, bc_decomposition_sel_pc_plus_19, bc_decomposition_sel_pc_plus_2, bc_decomposition_sel_pc_plus_20, bc_decomposition_sel_pc_plus_21, bc_decomposition_sel_pc_plus_22, bc_decomposition_sel_pc_plus_23, bc_decomposition_sel_pc_plus_24, bc_decomposition_sel_pc_plus_25, bc_decomposition_sel_pc_plus_26, bc_decomposition_sel_pc_plus_27, bc_decomposition_sel_pc_plus_28, bc_decomposition_sel_pc_plus_29, bc_decomposition_sel_pc_plus_3, bc_decomposition_sel_pc_plus_30, bc_decomposition_sel_pc_plus_31, bc_decomposition_sel_pc_plus_32, bc_decomposition_sel_pc_plus_33, bc_decomposition_sel_pc_plus_34, bc_decomposition_sel_pc_plus_35, bc_decomposition_sel_pc_plus_36, bc_decomposition_sel_pc_plus_4, bc_decomposition_sel_pc_plus_5, bc_decomposition_sel_pc_plus_6, bc_decomposition_sel_pc_plus_7, bc_decomposition_sel_pc_plus_8, bc_decomposition_sel_pc_plus_9, bc_hashing_bytecode_id, bc_hashing_incremental_hash, bc_hashing_latch, bc_hashing_output_hash, bc_hashing_packed_field, bc_hashing_pc_index, bc_hashing_sel, bc_hashing_start, bc_retrieval_address, bc_retrieval_artifact_hash, bc_retrieval_bytecode_id, bc_retrieval_class_id, bc_retrieval_deployer_addr, bc_retrieval_err, bc_retrieval_incoming_viewing_key_x, bc_retrieval_incoming_viewing_key_y, bc_retrieval_init_hash, bc_retrieval_nullifier_key_x, bc_retrieval_nullifier_key_y, bc_retrieval_outgoing_viewing_key_x, bc_retrieval_outgoing_viewing_key_y, bc_retrieval_private_function_root, bc_retrieval_public_bytecode_commitment, bc_retrieval_salt, bc_retrieval_sel, bc_retrieval_siloed_address, bc_retrieval_tagging_key_x, bc_retrieval_tagging_key_y, bitwise_acc_ia, bitwise_acc_ib, bitwise_acc_ic, bitwise_ctr, bitwise_ctr_inv, bitwise_ctr_min_one_inv, bitwise_ia_byte, bitwise_ib_byte, bitwise_ic_byte, bitwise_last, bitwise_op_id, bitwise_sel, bitwise_start, bitwise_tag, class_id_derivation_artifact_hash, class_id_derivation_class_id, class_id_derivation_private_function_root, class_id_derivation_public_bytecode_commitment, class_id_derivation_sel, class_id_derivation_temp_constant_for_lookup, ecc_add_op, ecc_double_op, ecc_inv_2_p_y, ecc_inv_x_diff, ecc_inv_y_diff, ecc_lambda, ecc_p_is_inf, ecc_p_x, ecc_p_y, ecc_q_is_inf, ecc_q_x, ecc_q_y, ecc_r_is_inf, ecc_r_x, ecc_r_y, ecc_result_infinity, ecc_sel, ecc_x_match, ecc_y_match, execution_addressing_error_idx, execution_addressing_error_kind, execution_base_address_tag, execution_base_address_val, execution_bytecode_id, execution_clk, execution_ex_opcode, execution_indirect, execution_last, execution_op1, execution_op1_after_relative, execution_op2, execution_op2_after_relative, execution_op3, execution_op3_after_relative, execution_op4, execution_op4_after_relative, execution_pc, execution_rop1, execution_rop2, execution_rop3, execution_rop4, execution_sel, execution_sel_addressing_error, execution_sel_op1_is_address, execution_sel_op2_is_address, execution_sel_op3_is_address, execution_sel_op4_is_address, instr_fetching_abs_diff, instr_fetching_bc_id_diff_inv, instr_fetching_bd0, instr_fetching_bd1, instr_fetching_bd10, instr_fetching_bd11, instr_fetching_bd12, instr_fetching_bd13, instr_fetching_bd14, instr_fetching_bd15, instr_fetching_bd16, instr_fetching_bd17, instr_fetching_bd18, instr_fetching_bd19, instr_fetching_bd2, instr_fetching_bd20, instr_fetching_bd21, instr_fetching_bd22, instr_fetching_bd23, instr_fetching_bd24, instr_fetching_bd25, instr_fetching_bd26, instr_fetching_bd27, instr_fetching_bd28, instr_fetching_bd29, instr_fetching_bd3, instr_fetching_bd30, instr_fetching_bd31, instr_fetching_bd32, instr_fetching_bd33, instr_fetching_bd34, instr_fetching_bd35, instr_fetching_bd36, instr_fetching_bd4, instr_fetching_bd5, instr_fetching_bd6, instr_fetching_bd7, instr_fetching_bd8, instr_fetching_bd9, instr_fetching_bytecode_id, instr_fetching_bytecode_size, instr_fetching_bytes_remaining, instr_fetching_bytes_to_read, instr_fetching_exec_opcode, instr_fetching_indirect, instr_fetching_instr_out_of_range, instr_fetching_instr_size, instr_fetching_last_of_bytecode, instr_fetching_op1, instr_fetching_op2, instr_fetching_op3, instr_fetching_op4, instr_fetching_op5, instr_fetching_op6, instr_fetching_op7, instr_fetching_opcode_out_of_range, instr_fetching_parsing_err, instr_fetching_pc, instr_fetching_pc_abs_diff, instr_fetching_pc_abs_diff_hi, instr_fetching_pc_abs_diff_lo, instr_fetching_pc_out_of_range, instr_fetching_sel, instr_fetching_sel_lookup_bc_decomposition, instr_fetching_sel_op_dc_0, instr_fetching_sel_op_dc_1, instr_fetching_sel_op_dc_10, instr_fetching_sel_op_dc_11, instr_fetching_sel_op_dc_12, instr_fetching_sel_op_dc_13, instr_fetching_sel_op_dc_14, instr_fetching_sel_op_dc_15, instr_fetching_sel_op_dc_16, instr_fetching_sel_op_dc_17, instr_fetching_sel_op_dc_2, instr_fetching_sel_op_dc_3, instr_fetching_sel_op_dc_4, instr_fetching_sel_op_dc_5, instr_fetching_sel_op_dc_6, instr_fetching_sel_op_dc_7, instr_fetching_sel_op_dc_8, instr_fetching_sel_op_dc_9, poseidon2_hash_a_0, poseidon2_hash_a_1, poseidon2_hash_a_2, poseidon2_hash_a_3, poseidon2_hash_b_0, poseidon2_hash_b_1, poseidon2_hash_b_2, poseidon2_hash_b_3, poseidon2_hash_end, poseidon2_hash_input_0, poseidon2_hash_input_1, poseidon2_hash_input_2, poseidon2_hash_input_len, poseidon2_hash_num_perm_rounds_rem, poseidon2_hash_num_perm_rounds_rem_inv, poseidon2_hash_output, poseidon2_hash_padding, poseidon2_hash_sel, poseidon2_hash_start, poseidon2_perm_B_10_0, poseidon2_perm_B_10_1, poseidon2_perm_B_10_2, poseidon2_perm_B_10_3, poseidon2_perm_B_11_0, poseidon2_perm_B_11_1, poseidon2_perm_B_11_2, poseidon2_perm_B_11_3, poseidon2_perm_B_12_0, poseidon2_perm_B_12_1, poseidon2_perm_B_12_2, poseidon2_perm_B_12_3, poseidon2_perm_B_13_0, poseidon2_perm_B_13_1, poseidon2_perm_B_13_2, poseidon2_perm_B_13_3, poseidon2_perm_B_14_0, poseidon2_perm_B_14_1, poseidon2_perm_B_14_2, poseidon2_perm_B_14_3, poseidon2_perm_B_15_0, poseidon2_perm_B_15_1, poseidon2_perm_B_15_2, poseidon2_perm_B_15_3, poseidon2_perm_B_16_0, poseidon2_perm_B_16_1, poseidon2_perm_B_16_2, poseidon2_perm_B_16_3, poseidon2_perm_B_17_0, poseidon2_perm_B_17_1, poseidon2_perm_B_17_2, poseidon2_perm_B_17_3, poseidon2_perm_B_18_0, poseidon2_perm_B_18_1, poseidon2_perm_B_18_2, poseidon2_perm_B_18_3, poseidon2_perm_B_19_0, poseidon2_perm_B_19_1, poseidon2_perm_B_19_2, poseidon2_perm_B_19_3, poseidon2_perm_B_20_0, poseidon2_perm_B_20_1, poseidon2_perm_B_20_2, poseidon2_perm_B_20_3, poseidon2_perm_B_21_0, poseidon2_perm_B_21_1, poseidon2_perm_B_21_2, poseidon2_perm_B_21_3, poseidon2_perm_B_22_0, poseidon2_perm_B_22_1, poseidon2_perm_B_22_2, poseidon2_perm_B_22_3, poseidon2_perm_B_23_0, poseidon2_perm_B_23_1, poseidon2_perm_B_23_2, poseidon2_perm_B_23_3, poseidon2_perm_B_24_0, poseidon2_perm_B_24_1, poseidon2_perm_B_24_2, poseidon2_perm_B_24_3, poseidon2_perm_B_25_0, poseidon2_perm_B_25_1, poseidon2_perm_B_25_2, poseidon2_perm_B_25_3, poseidon2_perm_B_26_0, poseidon2_perm_B_26_1, poseidon2_perm_B_26_2, poseidon2_perm_B_26_3, poseidon2_perm_B_27_0, poseidon2_perm_B_27_1, poseidon2_perm_B_27_2, poseidon2_perm_B_27_3, poseidon2_perm_B_28_0, poseidon2_perm_B_28_1, poseidon2_perm_B_28_2, poseidon2_perm_B_28_3, poseidon2_perm_B_29_0, poseidon2_perm_B_29_1, poseidon2_perm_B_29_2, poseidon2_perm_B_29_3, poseidon2_perm_B_30_0, poseidon2_perm_B_30_1, poseidon2_perm_B_30_2, poseidon2_perm_B_30_3, poseidon2_perm_B_31_0, poseidon2_perm_B_31_1, poseidon2_perm_B_31_2, poseidon2_perm_B_31_3, poseidon2_perm_B_32_0, poseidon2_perm_B_32_1, poseidon2_perm_B_32_2, poseidon2_perm_B_32_3, poseidon2_perm_B_33_0, poseidon2_perm_B_33_1, poseidon2_perm_B_33_2, poseidon2_perm_B_33_3, poseidon2_perm_B_34_0, poseidon2_perm_B_34_1, poseidon2_perm_B_34_2, poseidon2_perm_B_34_3, poseidon2_perm_B_35_0, poseidon2_perm_B_35_1, poseidon2_perm_B_35_2, poseidon2_perm_B_35_3, poseidon2_perm_B_36_0, poseidon2_perm_B_36_1, poseidon2_perm_B_36_2, poseidon2_perm_B_36_3, poseidon2_perm_B_37_0, poseidon2_perm_B_37_1, poseidon2_perm_B_37_2, poseidon2_perm_B_37_3, poseidon2_perm_B_38_0, poseidon2_perm_B_38_1, poseidon2_perm_B_38_2, poseidon2_perm_B_38_3, poseidon2_perm_B_39_0, poseidon2_perm_B_39_1, poseidon2_perm_B_39_2, poseidon2_perm_B_39_3, poseidon2_perm_B_40_0, poseidon2_perm_B_40_1, poseidon2_perm_B_40_2, poseidon2_perm_B_40_3, poseidon2_perm_B_41_0, poseidon2_perm_B_41_1, poseidon2_perm_B_41_2, poseidon2_perm_B_41_3, poseidon2_perm_B_42_0, poseidon2_perm_B_42_1, poseidon2_perm_B_42_2, poseidon2_perm_B_42_3, poseidon2_perm_B_43_0, poseidon2_perm_B_43_1, poseidon2_perm_B_43_2, poseidon2_perm_B_43_3, poseidon2_perm_B_44_0, poseidon2_perm_B_44_1, poseidon2_perm_B_44_2, poseidon2_perm_B_44_3, poseidon2_perm_B_45_0, poseidon2_perm_B_45_1, poseidon2_perm_B_45_2, poseidon2_perm_B_45_3, poseidon2_perm_B_46_0, poseidon2_perm_B_46_1, poseidon2_perm_B_46_2, poseidon2_perm_B_46_3, poseidon2_perm_B_47_0, poseidon2_perm_B_47_1, poseidon2_perm_B_47_2, poseidon2_perm_B_47_3, poseidon2_perm_B_48_0, poseidon2_perm_B_48_1, poseidon2_perm_B_48_2, poseidon2_perm_B_48_3, poseidon2_perm_B_49_0, poseidon2_perm_B_49_1, poseidon2_perm_B_49_2, poseidon2_perm_B_49_3, poseidon2_perm_B_4_0, poseidon2_perm_B_4_1, poseidon2_perm_B_4_2, poseidon2_perm_B_4_3, poseidon2_perm_B_50_0, poseidon2_perm_B_50_1, poseidon2_perm_B_50_2, poseidon2_perm_B_50_3, poseidon2_perm_B_51_0, poseidon2_perm_B_51_1, poseidon2_perm_B_51_2, poseidon2_perm_B_51_3, poseidon2_perm_B_52_0, poseidon2_perm_B_52_1, poseidon2_perm_B_52_2, poseidon2_perm_B_52_3, poseidon2_perm_B_53_0, poseidon2_perm_B_53_1, poseidon2_perm_B_53_2, poseidon2_perm_B_53_3, poseidon2_perm_B_54_0, poseidon2_perm_B_54_1, poseidon2_perm_B_54_2, poseidon2_perm_B_54_3, poseidon2_perm_B_55_0, poseidon2_perm_B_55_1, poseidon2_perm_B_55_2, poseidon2_perm_B_55_3, poseidon2_perm_B_56_0, poseidon2_perm_B_56_1, poseidon2_perm_B_56_2, poseidon2_perm_B_56_3, poseidon2_perm_B_57_0, poseidon2_perm_B_57_1, poseidon2_perm_B_57_2, poseidon2_perm_B_57_3, poseidon2_perm_B_58_0, poseidon2_perm_B_58_1, poseidon2_perm_B_58_2, poseidon2_perm_B_58_3, poseidon2_perm_B_59_0, poseidon2_perm_B_59_1, poseidon2_perm_B_59_2, poseidon2_perm_B_59_3, poseidon2_perm_B_5_0, poseidon2_perm_B_5_1, poseidon2_perm_B_5_2, poseidon2_perm_B_5_3, poseidon2_perm_B_6_0, poseidon2_perm_B_6_1, poseidon2_perm_B_6_2, poseidon2_perm_B_6_3, poseidon2_perm_B_7_0, poseidon2_perm_B_7_1, poseidon2_perm_B_7_2, poseidon2_perm_B_7_3, poseidon2_perm_B_8_0, poseidon2_perm_B_8_1, poseidon2_perm_B_8_2, poseidon2_perm_B_8_3, poseidon2_perm_B_9_0, poseidon2_perm_B_9_1, poseidon2_perm_B_9_2, poseidon2_perm_B_9_3, poseidon2_perm_EXT_LAYER_4, poseidon2_perm_EXT_LAYER_5, poseidon2_perm_EXT_LAYER_6, poseidon2_perm_EXT_LAYER_7, poseidon2_perm_T_0_4, poseidon2_perm_T_0_5, poseidon2_perm_T_0_6, poseidon2_perm_T_0_7, poseidon2_perm_T_1_4, poseidon2_perm_T_1_5, poseidon2_perm_T_1_6, poseidon2_perm_T_1_7, poseidon2_perm_T_2_4, poseidon2_perm_T_2_5, poseidon2_perm_T_2_6, poseidon2_perm_T_2_7, poseidon2_perm_T_3_4, poseidon2_perm_T_3_5, poseidon2_perm_T_3_6, poseidon2_perm_T_3_7, poseidon2_perm_T_60_4, poseidon2_perm_T_60_5, poseidon2_perm_T_60_6, poseidon2_perm_T_60_7, poseidon2_perm_T_61_4, poseidon2_perm_T_61_5, poseidon2_perm_T_61_6, poseidon2_perm_T_61_7, poseidon2_perm_T_62_4, poseidon2_perm_T_62_5, poseidon2_perm_T_62_6, poseidon2_perm_T_62_7, poseidon2_perm_T_63_4, poseidon2_perm_T_63_5, poseidon2_perm_T_63_6, poseidon2_perm_T_63_7, poseidon2_perm_a_0, poseidon2_perm_a_1, poseidon2_perm_a_2, poseidon2_perm_a_3, poseidon2_perm_b_0, poseidon2_perm_b_1, poseidon2_perm_b_2, poseidon2_perm_b_3, poseidon2_perm_sel, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_rng_chk_bits, range_check_sel, range_check_sel_r0_16_bit_rng_lookup, range_check_sel_r1_16_bit_rng_lookup, range_check_sel_r2_16_bit_rng_lookup, range_check_sel_r3_16_bit_rng_lookup, range_check_sel_r4_16_bit_rng_lookup, range_check_sel_r5_16_bit_rng_lookup, range_check_sel_r6_16_bit_rng_lookup, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, scalar_mul_bit, scalar_mul_bit_idx, scalar_mul_bit_radix, scalar_mul_end, scalar_mul_not_end, scalar_mul_point_inf, scalar_mul_point_x, scalar_mul_point_y, scalar_mul_res_inf, scalar_mul_res_x, scalar_mul_res_y, scalar_mul_scalar, scalar_mul_sel, scalar_mul_should_add, scalar_mul_start, scalar_mul_temp_inf, scalar_mul_temp_x, scalar_mul_temp_y, sha256_a, sha256_a_and_b, sha256_a_and_b_xor_a_and_c, sha256_a_and_c, sha256_a_rotr_13, sha256_a_rotr_2, sha256_a_rotr_22, sha256_a_rotr_2_xor_a_rotr_13, sha256_and_sel, sha256_b, sha256_b_and_c, sha256_c, sha256_ch, sha256_clk, sha256_computed_w_lhs, sha256_computed_w_rhs, sha256_d, sha256_e, sha256_e_and_f, sha256_e_rotr_11, sha256_e_rotr_25, sha256_e_rotr_6, sha256_e_rotr_6_xor_e_rotr_11, sha256_f, sha256_g, sha256_h, sha256_helper_w0, sha256_helper_w1, sha256_helper_w10, sha256_helper_w11, sha256_helper_w12, sha256_helper_w13, sha256_helper_w14, sha256_helper_w15, sha256_helper_w2, sha256_helper_w3, sha256_helper_w4, sha256_helper_w5, sha256_helper_w6, sha256_helper_w7, sha256_helper_w8, sha256_helper_w9, sha256_init_a, sha256_init_b, sha256_init_c, sha256_init_d, sha256_init_e, sha256_init_f, sha256_init_g, sha256_init_h, sha256_input_offset, sha256_is_input_round, sha256_latch, sha256_lhs_a_13, sha256_lhs_a_2, sha256_lhs_a_22, sha256_lhs_e_11, sha256_lhs_e_25, sha256_lhs_e_6, sha256_lhs_w_10, sha256_lhs_w_17, sha256_lhs_w_18, sha256_lhs_w_19, sha256_lhs_w_3, sha256_lhs_w_7, sha256_maj, sha256_next_a_lhs, sha256_next_a_rhs, sha256_next_e_lhs, sha256_next_e_rhs, sha256_not_e, sha256_not_e_and_g, sha256_output_a_lhs, sha256_output_a_rhs, sha256_output_b_lhs, sha256_output_b_rhs, sha256_output_c_lhs, sha256_output_c_rhs, sha256_output_d_lhs, sha256_output_d_rhs, sha256_output_e_lhs, sha256_output_e_rhs, sha256_output_f_lhs, sha256_output_f_rhs, sha256_output_g_lhs, sha256_output_g_rhs, sha256_output_h_lhs, sha256_output_h_rhs, sha256_output_offset, sha256_perform_round, sha256_rhs_a_13, sha256_rhs_a_2, sha256_rhs_a_22, sha256_rhs_e_11, sha256_rhs_e_25, sha256_rhs_e_6, sha256_rhs_w_10, sha256_rhs_w_17, sha256_rhs_w_18, sha256_rhs_w_19, sha256_rhs_w_3, sha256_rhs_w_7, sha256_round_constant, sha256_round_count, sha256_rounds_remaining, sha256_rounds_remaining_inv, sha256_s_0, sha256_s_1, sha256_sel, sha256_start, sha256_state_offset, sha256_w, sha256_w_15_rotr_18, sha256_w_15_rotr_7, sha256_w_15_rotr_7_xor_w_15_rotr_18, sha256_w_15_rshift_3, sha256_w_2_rotr_17, sha256_w_2_rotr_17_xor_w_2_rotr_19, sha256_w_2_rotr_19, sha256_w_2_rshift_10, sha256_w_s_0, sha256_w_s_1, sha256_xor_sel, to_radix_acc, to_radix_acc_under_p, to_radix_end, to_radix_exponent, to_radix_found, to_radix_is_unsafe_limb, to_radix_limb, to_radix_limb_eq_p, to_radix_limb_index, to_radix_limb_lt_p, to_radix_limb_p_diff, to_radix_limb_radix_diff, to_radix_not_end, to_radix_not_padding_limb, to_radix_p_limb, to_radix_radix, to_radix_rem_inverse, to_radix_safe_limbs, to_radix_safety_diff_inverse, to_radix_sel, to_radix_start, to_radix_value, lookup_poseidon2_hash_poseidon2_perm_counts, lookup_range_check_dyn_rng_chk_pow_2_counts, lookup_range_check_dyn_diff_is_u16_counts, lookup_range_check_r0_is_u16_counts, lookup_range_check_r1_is_u16_counts, lookup_range_check_r2_is_u16_counts, lookup_range_check_r3_is_u16_counts, lookup_range_check_r4_is_u16_counts, lookup_range_check_r5_is_u16_counts, lookup_range_check_r6_is_u16_counts, lookup_range_check_r7_is_u16_counts, lookup_to_radix_limb_range_counts, lookup_to_radix_limb_less_than_radix_range_counts, lookup_to_radix_fetch_safe_limbs_counts, lookup_to_radix_fetch_p_limb_counts, lookup_to_radix_limb_p_diff_range_counts, lookup_scalar_mul_to_radix_counts, lookup_scalar_mul_double_counts, lookup_scalar_mul_add_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_0_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_1_counts, lookup_address_derivation_partial_address_poseidon2_counts, lookup_address_derivation_public_keys_hash_poseidon2_0_counts, lookup_address_derivation_public_keys_hash_poseidon2_1_counts, lookup_address_derivation_public_keys_hash_poseidon2_2_counts, lookup_address_derivation_public_keys_hash_poseidon2_3_counts, lookup_address_derivation_public_keys_hash_poseidon2_4_counts, lookup_address_derivation_preaddress_poseidon2_counts, lookup_address_derivation_preaddress_scalar_mul_counts, lookup_address_derivation_address_ecadd_counts, lookup_bc_decomposition_bytes_are_bytes_counts, lookup_bc_decomposition_abs_diff_is_u16_counts, lookup_bc_decomposition_bytes_to_read_as_unary_counts, lookup_bc_hashing_get_packed_field_counts, lookup_bc_hashing_iv_is_len_counts, lookup_bc_hashing_poseidon2_hash_counts, lookup_bc_retrieval_class_id_derivation_counts, lookup_bc_retrieval_bytecode_hash_is_correct_counts, lookup_instr_fetching_abs_diff_positive_counts, lookup_instr_fetching_abs_diff_positive_lo_counts, lookup_instr_fetching_abs_diff_positive_hi_counts, lookup_instr_fetching_bytes_from_bc_dec_counts, lookup_instr_fetching_wire_instruction_info_counts, lookup_class_id_derivation_class_id_poseidon2_0_counts, lookup_class_id_derivation_class_id_poseidon2_1_counts, lookup_bitwise_integral_tag_length_counts, lookup_bitwise_byte_operations_counts, lookup_sha256_round_constant_counts -#define AVM2_DERIVED_WITNESS_ENTITIES lookup_poseidon2_hash_poseidon2_perm_inv, lookup_range_check_dyn_rng_chk_pow_2_inv, lookup_range_check_dyn_diff_is_u16_inv, lookup_range_check_r0_is_u16_inv, lookup_range_check_r1_is_u16_inv, lookup_range_check_r2_is_u16_inv, lookup_range_check_r3_is_u16_inv, lookup_range_check_r4_is_u16_inv, lookup_range_check_r5_is_u16_inv, lookup_range_check_r6_is_u16_inv, lookup_range_check_r7_is_u16_inv, lookup_to_radix_limb_range_inv, lookup_to_radix_limb_less_than_radix_range_inv, lookup_to_radix_fetch_safe_limbs_inv, lookup_to_radix_fetch_p_limb_inv, lookup_to_radix_limb_p_diff_range_inv, lookup_scalar_mul_to_radix_inv, lookup_scalar_mul_double_inv, lookup_scalar_mul_add_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_0_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_1_inv, lookup_address_derivation_partial_address_poseidon2_inv, lookup_address_derivation_public_keys_hash_poseidon2_0_inv, lookup_address_derivation_public_keys_hash_poseidon2_1_inv, lookup_address_derivation_public_keys_hash_poseidon2_2_inv, lookup_address_derivation_public_keys_hash_poseidon2_3_inv, lookup_address_derivation_public_keys_hash_poseidon2_4_inv, lookup_address_derivation_preaddress_poseidon2_inv, lookup_address_derivation_preaddress_scalar_mul_inv, lookup_address_derivation_address_ecadd_inv, lookup_bc_decomposition_bytes_are_bytes_inv, lookup_bc_decomposition_abs_diff_is_u16_inv, lookup_bc_decomposition_bytes_to_read_as_unary_inv, lookup_bc_hashing_get_packed_field_inv, lookup_bc_hashing_iv_is_len_inv, lookup_bc_hashing_poseidon2_hash_inv, lookup_bc_retrieval_class_id_derivation_inv, lookup_bc_retrieval_bytecode_hash_is_correct_inv, lookup_instr_fetching_abs_diff_positive_inv, lookup_instr_fetching_abs_diff_positive_lo_inv, lookup_instr_fetching_abs_diff_positive_hi_inv, lookup_instr_fetching_bytes_from_bc_dec_inv, lookup_instr_fetching_wire_instruction_info_inv, lookup_class_id_derivation_class_id_poseidon2_0_inv, lookup_class_id_derivation_class_id_poseidon2_1_inv, lookup_bitwise_integral_tag_length_inv, lookup_bitwise_byte_operations_inv, lookup_sha256_round_constant_inv +#define AVM2_WIRE_ENTITIES execution_input, address_derivation_address, address_derivation_address_y, address_derivation_class_id, address_derivation_deployer_addr, address_derivation_g1_x, address_derivation_g1_y, address_derivation_incoming_viewing_key_x, address_derivation_incoming_viewing_key_y, address_derivation_init_hash, address_derivation_nullifier_key_x, address_derivation_nullifier_key_y, address_derivation_outgoing_viewing_key_x, address_derivation_outgoing_viewing_key_y, address_derivation_partial_address, address_derivation_partial_address_domain_separator, address_derivation_preaddress, address_derivation_preaddress_domain_separator, address_derivation_preaddress_public_key_x, address_derivation_preaddress_public_key_y, address_derivation_public_keys_hash, address_derivation_public_keys_hash_domain_separator, address_derivation_salt, address_derivation_salted_init_hash, address_derivation_sel, address_derivation_tagging_key_x, address_derivation_tagging_key_y, alu_dst_addr, alu_ia, alu_ia_addr, alu_ib, alu_ib_addr, alu_ic, alu_op, alu_sel_op_add, bc_decomposition_abs_diff, bc_decomposition_bytes, bc_decomposition_bytes_pc_plus_1, bc_decomposition_bytes_pc_plus_10, bc_decomposition_bytes_pc_plus_11, bc_decomposition_bytes_pc_plus_12, bc_decomposition_bytes_pc_plus_13, bc_decomposition_bytes_pc_plus_14, bc_decomposition_bytes_pc_plus_15, bc_decomposition_bytes_pc_plus_16, bc_decomposition_bytes_pc_plus_17, bc_decomposition_bytes_pc_plus_18, bc_decomposition_bytes_pc_plus_19, bc_decomposition_bytes_pc_plus_2, bc_decomposition_bytes_pc_plus_20, bc_decomposition_bytes_pc_plus_21, bc_decomposition_bytes_pc_plus_22, bc_decomposition_bytes_pc_plus_23, bc_decomposition_bytes_pc_plus_24, bc_decomposition_bytes_pc_plus_25, bc_decomposition_bytes_pc_plus_26, bc_decomposition_bytes_pc_plus_27, bc_decomposition_bytes_pc_plus_28, bc_decomposition_bytes_pc_plus_29, bc_decomposition_bytes_pc_plus_3, bc_decomposition_bytes_pc_plus_30, bc_decomposition_bytes_pc_plus_31, bc_decomposition_bytes_pc_plus_32, bc_decomposition_bytes_pc_plus_33, bc_decomposition_bytes_pc_plus_34, bc_decomposition_bytes_pc_plus_35, bc_decomposition_bytes_pc_plus_36, bc_decomposition_bytes_pc_plus_4, bc_decomposition_bytes_pc_plus_5, bc_decomposition_bytes_pc_plus_6, bc_decomposition_bytes_pc_plus_7, bc_decomposition_bytes_pc_plus_8, bc_decomposition_bytes_pc_plus_9, bc_decomposition_bytes_rem_inv, bc_decomposition_bytes_rem_min_one_inv, bc_decomposition_bytes_remaining, bc_decomposition_bytes_to_read, bc_decomposition_bytes_to_read_unary, bc_decomposition_id, bc_decomposition_last_of_contract, bc_decomposition_packed_field, bc_decomposition_pc, bc_decomposition_sel, bc_decomposition_sel_overflow_correction_needed, bc_decomposition_sel_packed, bc_decomposition_sel_pc_plus_1, bc_decomposition_sel_pc_plus_10, bc_decomposition_sel_pc_plus_11, bc_decomposition_sel_pc_plus_12, bc_decomposition_sel_pc_plus_13, bc_decomposition_sel_pc_plus_14, bc_decomposition_sel_pc_plus_15, bc_decomposition_sel_pc_plus_16, bc_decomposition_sel_pc_plus_17, bc_decomposition_sel_pc_plus_18, bc_decomposition_sel_pc_plus_19, bc_decomposition_sel_pc_plus_2, bc_decomposition_sel_pc_plus_20, bc_decomposition_sel_pc_plus_21, bc_decomposition_sel_pc_plus_22, bc_decomposition_sel_pc_plus_23, bc_decomposition_sel_pc_plus_24, bc_decomposition_sel_pc_plus_25, bc_decomposition_sel_pc_plus_26, bc_decomposition_sel_pc_plus_27, bc_decomposition_sel_pc_plus_28, bc_decomposition_sel_pc_plus_29, bc_decomposition_sel_pc_plus_3, bc_decomposition_sel_pc_plus_30, bc_decomposition_sel_pc_plus_31, bc_decomposition_sel_pc_plus_32, bc_decomposition_sel_pc_plus_33, bc_decomposition_sel_pc_plus_34, bc_decomposition_sel_pc_plus_35, bc_decomposition_sel_pc_plus_36, bc_decomposition_sel_pc_plus_4, bc_decomposition_sel_pc_plus_5, bc_decomposition_sel_pc_plus_6, bc_decomposition_sel_pc_plus_7, bc_decomposition_sel_pc_plus_8, bc_decomposition_sel_pc_plus_9, bc_hashing_bytecode_id, bc_hashing_incremental_hash, bc_hashing_latch, bc_hashing_output_hash, bc_hashing_packed_field, bc_hashing_pc_index, bc_hashing_sel, bc_hashing_start, bc_retrieval_address, bc_retrieval_artifact_hash, bc_retrieval_bytecode_id, bc_retrieval_class_id, bc_retrieval_deployer_addr, bc_retrieval_err, bc_retrieval_incoming_viewing_key_x, bc_retrieval_incoming_viewing_key_y, bc_retrieval_init_hash, bc_retrieval_nullifier_key_x, bc_retrieval_nullifier_key_y, bc_retrieval_outgoing_viewing_key_x, bc_retrieval_outgoing_viewing_key_y, bc_retrieval_private_function_root, bc_retrieval_public_bytecode_commitment, bc_retrieval_salt, bc_retrieval_sel, bc_retrieval_siloed_address, bc_retrieval_tagging_key_x, bc_retrieval_tagging_key_y, bitwise_acc_ia, bitwise_acc_ib, bitwise_acc_ic, bitwise_ctr, bitwise_ctr_inv, bitwise_ctr_min_one_inv, bitwise_ia_byte, bitwise_ib_byte, bitwise_ic_byte, bitwise_last, bitwise_op_id, bitwise_sel, bitwise_start, bitwise_tag, class_id_derivation_artifact_hash, class_id_derivation_class_id, class_id_derivation_private_function_root, class_id_derivation_public_bytecode_commitment, class_id_derivation_sel, class_id_derivation_temp_constant_for_lookup, ecc_add_op, ecc_double_op, ecc_inv_2_p_y, ecc_inv_x_diff, ecc_inv_y_diff, ecc_lambda, ecc_p_is_inf, ecc_p_x, ecc_p_y, ecc_q_is_inf, ecc_q_x, ecc_q_y, ecc_r_is_inf, ecc_r_x, ecc_r_y, ecc_result_infinity, ecc_sel, ecc_x_match, ecc_y_match, execution_addressing_error_idx, execution_addressing_error_kind, execution_base_address_tag, execution_base_address_val, execution_bytecode_id, execution_clk, execution_ex_opcode, execution_indirect, execution_last, execution_op1, execution_op1_after_relative, execution_op2, execution_op2_after_relative, execution_op3, execution_op3_after_relative, execution_op4, execution_op4_after_relative, execution_pc, execution_rop1, execution_rop2, execution_rop3, execution_rop4, execution_sel, execution_sel_addressing_error, execution_sel_op1_is_address, execution_sel_op2_is_address, execution_sel_op3_is_address, execution_sel_op4_is_address, instr_fetching_abs_diff, instr_fetching_bc_id_diff_inv, instr_fetching_bd0, instr_fetching_bd1, instr_fetching_bd10, instr_fetching_bd11, instr_fetching_bd12, instr_fetching_bd13, instr_fetching_bd14, instr_fetching_bd15, instr_fetching_bd16, instr_fetching_bd17, instr_fetching_bd18, instr_fetching_bd19, instr_fetching_bd2, instr_fetching_bd20, instr_fetching_bd21, instr_fetching_bd22, instr_fetching_bd23, instr_fetching_bd24, instr_fetching_bd25, instr_fetching_bd26, instr_fetching_bd27, instr_fetching_bd28, instr_fetching_bd29, instr_fetching_bd3, instr_fetching_bd30, instr_fetching_bd31, instr_fetching_bd32, instr_fetching_bd33, instr_fetching_bd34, instr_fetching_bd35, instr_fetching_bd36, instr_fetching_bd4, instr_fetching_bd5, instr_fetching_bd6, instr_fetching_bd7, instr_fetching_bd8, instr_fetching_bd9, instr_fetching_bytecode_id, instr_fetching_bytecode_size, instr_fetching_bytes_remaining, instr_fetching_bytes_to_read, instr_fetching_exec_opcode, instr_fetching_indirect, instr_fetching_instr_out_of_range, instr_fetching_instr_size, instr_fetching_last_of_bytecode, instr_fetching_op1, instr_fetching_op2, instr_fetching_op3, instr_fetching_op4, instr_fetching_op5, instr_fetching_op6, instr_fetching_op7, instr_fetching_opcode_out_of_range, instr_fetching_parsing_err, instr_fetching_pc, instr_fetching_pc_abs_diff, instr_fetching_pc_abs_diff_hi, instr_fetching_pc_abs_diff_lo, instr_fetching_pc_out_of_range, instr_fetching_sel, instr_fetching_sel_lookup_bc_decomposition, instr_fetching_sel_op_dc_0, instr_fetching_sel_op_dc_1, instr_fetching_sel_op_dc_10, instr_fetching_sel_op_dc_11, instr_fetching_sel_op_dc_12, instr_fetching_sel_op_dc_13, instr_fetching_sel_op_dc_14, instr_fetching_sel_op_dc_15, instr_fetching_sel_op_dc_16, instr_fetching_sel_op_dc_17, instr_fetching_sel_op_dc_2, instr_fetching_sel_op_dc_3, instr_fetching_sel_op_dc_4, instr_fetching_sel_op_dc_5, instr_fetching_sel_op_dc_6, instr_fetching_sel_op_dc_7, instr_fetching_sel_op_dc_8, instr_fetching_sel_op_dc_9, poseidon2_hash_a_0, poseidon2_hash_a_1, poseidon2_hash_a_2, poseidon2_hash_a_3, poseidon2_hash_b_0, poseidon2_hash_b_1, poseidon2_hash_b_2, poseidon2_hash_b_3, poseidon2_hash_end, poseidon2_hash_input_0, poseidon2_hash_input_1, poseidon2_hash_input_2, poseidon2_hash_input_len, poseidon2_hash_num_perm_rounds_rem, poseidon2_hash_num_perm_rounds_rem_inv, poseidon2_hash_output, poseidon2_hash_padding, poseidon2_hash_sel, poseidon2_hash_start, poseidon2_perm_B_10_0, poseidon2_perm_B_10_1, poseidon2_perm_B_10_2, poseidon2_perm_B_10_3, poseidon2_perm_B_11_0, poseidon2_perm_B_11_1, poseidon2_perm_B_11_2, poseidon2_perm_B_11_3, poseidon2_perm_B_12_0, poseidon2_perm_B_12_1, poseidon2_perm_B_12_2, poseidon2_perm_B_12_3, poseidon2_perm_B_13_0, poseidon2_perm_B_13_1, poseidon2_perm_B_13_2, poseidon2_perm_B_13_3, poseidon2_perm_B_14_0, poseidon2_perm_B_14_1, poseidon2_perm_B_14_2, poseidon2_perm_B_14_3, poseidon2_perm_B_15_0, poseidon2_perm_B_15_1, poseidon2_perm_B_15_2, poseidon2_perm_B_15_3, poseidon2_perm_B_16_0, poseidon2_perm_B_16_1, poseidon2_perm_B_16_2, poseidon2_perm_B_16_3, poseidon2_perm_B_17_0, poseidon2_perm_B_17_1, poseidon2_perm_B_17_2, poseidon2_perm_B_17_3, poseidon2_perm_B_18_0, poseidon2_perm_B_18_1, poseidon2_perm_B_18_2, poseidon2_perm_B_18_3, poseidon2_perm_B_19_0, poseidon2_perm_B_19_1, poseidon2_perm_B_19_2, poseidon2_perm_B_19_3, poseidon2_perm_B_20_0, poseidon2_perm_B_20_1, poseidon2_perm_B_20_2, poseidon2_perm_B_20_3, poseidon2_perm_B_21_0, poseidon2_perm_B_21_1, poseidon2_perm_B_21_2, poseidon2_perm_B_21_3, poseidon2_perm_B_22_0, poseidon2_perm_B_22_1, poseidon2_perm_B_22_2, poseidon2_perm_B_22_3, poseidon2_perm_B_23_0, poseidon2_perm_B_23_1, poseidon2_perm_B_23_2, poseidon2_perm_B_23_3, poseidon2_perm_B_24_0, poseidon2_perm_B_24_1, poseidon2_perm_B_24_2, poseidon2_perm_B_24_3, poseidon2_perm_B_25_0, poseidon2_perm_B_25_1, poseidon2_perm_B_25_2, poseidon2_perm_B_25_3, poseidon2_perm_B_26_0, poseidon2_perm_B_26_1, poseidon2_perm_B_26_2, poseidon2_perm_B_26_3, poseidon2_perm_B_27_0, poseidon2_perm_B_27_1, poseidon2_perm_B_27_2, poseidon2_perm_B_27_3, poseidon2_perm_B_28_0, poseidon2_perm_B_28_1, poseidon2_perm_B_28_2, poseidon2_perm_B_28_3, poseidon2_perm_B_29_0, poseidon2_perm_B_29_1, poseidon2_perm_B_29_2, poseidon2_perm_B_29_3, poseidon2_perm_B_30_0, poseidon2_perm_B_30_1, poseidon2_perm_B_30_2, poseidon2_perm_B_30_3, poseidon2_perm_B_31_0, poseidon2_perm_B_31_1, poseidon2_perm_B_31_2, poseidon2_perm_B_31_3, poseidon2_perm_B_32_0, poseidon2_perm_B_32_1, poseidon2_perm_B_32_2, poseidon2_perm_B_32_3, poseidon2_perm_B_33_0, poseidon2_perm_B_33_1, poseidon2_perm_B_33_2, poseidon2_perm_B_33_3, poseidon2_perm_B_34_0, poseidon2_perm_B_34_1, poseidon2_perm_B_34_2, poseidon2_perm_B_34_3, poseidon2_perm_B_35_0, poseidon2_perm_B_35_1, poseidon2_perm_B_35_2, poseidon2_perm_B_35_3, poseidon2_perm_B_36_0, poseidon2_perm_B_36_1, poseidon2_perm_B_36_2, poseidon2_perm_B_36_3, poseidon2_perm_B_37_0, poseidon2_perm_B_37_1, poseidon2_perm_B_37_2, poseidon2_perm_B_37_3, poseidon2_perm_B_38_0, poseidon2_perm_B_38_1, poseidon2_perm_B_38_2, poseidon2_perm_B_38_3, poseidon2_perm_B_39_0, poseidon2_perm_B_39_1, poseidon2_perm_B_39_2, poseidon2_perm_B_39_3, poseidon2_perm_B_40_0, poseidon2_perm_B_40_1, poseidon2_perm_B_40_2, poseidon2_perm_B_40_3, poseidon2_perm_B_41_0, poseidon2_perm_B_41_1, poseidon2_perm_B_41_2, poseidon2_perm_B_41_3, poseidon2_perm_B_42_0, poseidon2_perm_B_42_1, poseidon2_perm_B_42_2, poseidon2_perm_B_42_3, poseidon2_perm_B_43_0, poseidon2_perm_B_43_1, poseidon2_perm_B_43_2, poseidon2_perm_B_43_3, poseidon2_perm_B_44_0, poseidon2_perm_B_44_1, poseidon2_perm_B_44_2, poseidon2_perm_B_44_3, poseidon2_perm_B_45_0, poseidon2_perm_B_45_1, poseidon2_perm_B_45_2, poseidon2_perm_B_45_3, poseidon2_perm_B_46_0, poseidon2_perm_B_46_1, poseidon2_perm_B_46_2, poseidon2_perm_B_46_3, poseidon2_perm_B_47_0, poseidon2_perm_B_47_1, poseidon2_perm_B_47_2, poseidon2_perm_B_47_3, poseidon2_perm_B_48_0, poseidon2_perm_B_48_1, poseidon2_perm_B_48_2, poseidon2_perm_B_48_3, poseidon2_perm_B_49_0, poseidon2_perm_B_49_1, poseidon2_perm_B_49_2, poseidon2_perm_B_49_3, poseidon2_perm_B_4_0, poseidon2_perm_B_4_1, poseidon2_perm_B_4_2, poseidon2_perm_B_4_3, poseidon2_perm_B_50_0, poseidon2_perm_B_50_1, poseidon2_perm_B_50_2, poseidon2_perm_B_50_3, poseidon2_perm_B_51_0, poseidon2_perm_B_51_1, poseidon2_perm_B_51_2, poseidon2_perm_B_51_3, poseidon2_perm_B_52_0, poseidon2_perm_B_52_1, poseidon2_perm_B_52_2, poseidon2_perm_B_52_3, poseidon2_perm_B_53_0, poseidon2_perm_B_53_1, poseidon2_perm_B_53_2, poseidon2_perm_B_53_3, poseidon2_perm_B_54_0, poseidon2_perm_B_54_1, poseidon2_perm_B_54_2, poseidon2_perm_B_54_3, poseidon2_perm_B_55_0, poseidon2_perm_B_55_1, poseidon2_perm_B_55_2, poseidon2_perm_B_55_3, poseidon2_perm_B_56_0, poseidon2_perm_B_56_1, poseidon2_perm_B_56_2, poseidon2_perm_B_56_3, poseidon2_perm_B_57_0, poseidon2_perm_B_57_1, poseidon2_perm_B_57_2, poseidon2_perm_B_57_3, poseidon2_perm_B_58_0, poseidon2_perm_B_58_1, poseidon2_perm_B_58_2, poseidon2_perm_B_58_3, poseidon2_perm_B_59_0, poseidon2_perm_B_59_1, poseidon2_perm_B_59_2, poseidon2_perm_B_59_3, poseidon2_perm_B_5_0, poseidon2_perm_B_5_1, poseidon2_perm_B_5_2, poseidon2_perm_B_5_3, poseidon2_perm_B_6_0, poseidon2_perm_B_6_1, poseidon2_perm_B_6_2, poseidon2_perm_B_6_3, poseidon2_perm_B_7_0, poseidon2_perm_B_7_1, poseidon2_perm_B_7_2, poseidon2_perm_B_7_3, poseidon2_perm_B_8_0, poseidon2_perm_B_8_1, poseidon2_perm_B_8_2, poseidon2_perm_B_8_3, poseidon2_perm_B_9_0, poseidon2_perm_B_9_1, poseidon2_perm_B_9_2, poseidon2_perm_B_9_3, poseidon2_perm_EXT_LAYER_4, poseidon2_perm_EXT_LAYER_5, poseidon2_perm_EXT_LAYER_6, poseidon2_perm_EXT_LAYER_7, poseidon2_perm_T_0_4, poseidon2_perm_T_0_5, poseidon2_perm_T_0_6, poseidon2_perm_T_0_7, poseidon2_perm_T_1_4, poseidon2_perm_T_1_5, poseidon2_perm_T_1_6, poseidon2_perm_T_1_7, poseidon2_perm_T_2_4, poseidon2_perm_T_2_5, poseidon2_perm_T_2_6, poseidon2_perm_T_2_7, poseidon2_perm_T_3_4, poseidon2_perm_T_3_5, poseidon2_perm_T_3_6, poseidon2_perm_T_3_7, poseidon2_perm_T_60_4, poseidon2_perm_T_60_5, poseidon2_perm_T_60_6, poseidon2_perm_T_60_7, poseidon2_perm_T_61_4, poseidon2_perm_T_61_5, poseidon2_perm_T_61_6, poseidon2_perm_T_61_7, poseidon2_perm_T_62_4, poseidon2_perm_T_62_5, poseidon2_perm_T_62_6, poseidon2_perm_T_62_7, poseidon2_perm_T_63_4, poseidon2_perm_T_63_5, poseidon2_perm_T_63_6, poseidon2_perm_T_63_7, poseidon2_perm_a_0, poseidon2_perm_a_1, poseidon2_perm_a_2, poseidon2_perm_a_3, poseidon2_perm_b_0, poseidon2_perm_b_1, poseidon2_perm_b_2, poseidon2_perm_b_3, poseidon2_perm_sel, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_rng_chk_bits, range_check_sel, range_check_sel_r0_16_bit_rng_lookup, range_check_sel_r1_16_bit_rng_lookup, range_check_sel_r2_16_bit_rng_lookup, range_check_sel_r3_16_bit_rng_lookup, range_check_sel_r4_16_bit_rng_lookup, range_check_sel_r5_16_bit_rng_lookup, range_check_sel_r6_16_bit_rng_lookup, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, scalar_mul_bit, scalar_mul_bit_idx, scalar_mul_bit_radix, scalar_mul_end, scalar_mul_not_end, scalar_mul_point_inf, scalar_mul_point_x, scalar_mul_point_y, scalar_mul_res_inf, scalar_mul_res_x, scalar_mul_res_y, scalar_mul_scalar, scalar_mul_sel, scalar_mul_should_add, scalar_mul_start, scalar_mul_temp_inf, scalar_mul_temp_x, scalar_mul_temp_y, sha256_a, sha256_a_and_b, sha256_a_and_b_xor_a_and_c, sha256_a_and_c, sha256_a_rotr_13, sha256_a_rotr_2, sha256_a_rotr_22, sha256_a_rotr_2_xor_a_rotr_13, sha256_and_sel, sha256_b, sha256_b_and_c, sha256_c, sha256_ch, sha256_clk, sha256_computed_w_lhs, sha256_computed_w_rhs, sha256_d, sha256_e, sha256_e_and_f, sha256_e_rotr_11, sha256_e_rotr_25, sha256_e_rotr_6, sha256_e_rotr_6_xor_e_rotr_11, sha256_f, sha256_g, sha256_h, sha256_helper_w0, sha256_helper_w1, sha256_helper_w10, sha256_helper_w11, sha256_helper_w12, sha256_helper_w13, sha256_helper_w14, sha256_helper_w15, sha256_helper_w2, sha256_helper_w3, sha256_helper_w4, sha256_helper_w5, sha256_helper_w6, sha256_helper_w7, sha256_helper_w8, sha256_helper_w9, sha256_init_a, sha256_init_b, sha256_init_c, sha256_init_d, sha256_init_e, sha256_init_f, sha256_init_g, sha256_init_h, sha256_input_offset, sha256_is_input_round, sha256_latch, sha256_lhs_a_13, sha256_lhs_a_2, sha256_lhs_a_22, sha256_lhs_e_11, sha256_lhs_e_25, sha256_lhs_e_6, sha256_lhs_w_10, sha256_lhs_w_17, sha256_lhs_w_18, sha256_lhs_w_19, sha256_lhs_w_3, sha256_lhs_w_7, sha256_maj, sha256_next_a_lhs, sha256_next_a_rhs, sha256_next_e_lhs, sha256_next_e_rhs, sha256_not_e, sha256_not_e_and_g, sha256_output_a_lhs, sha256_output_a_rhs, sha256_output_b_lhs, sha256_output_b_rhs, sha256_output_c_lhs, sha256_output_c_rhs, sha256_output_d_lhs, sha256_output_d_rhs, sha256_output_e_lhs, sha256_output_e_rhs, sha256_output_f_lhs, sha256_output_f_rhs, sha256_output_g_lhs, sha256_output_g_rhs, sha256_output_h_lhs, sha256_output_h_rhs, sha256_output_offset, sha256_perform_round, sha256_rhs_a_13, sha256_rhs_a_2, sha256_rhs_a_22, sha256_rhs_e_11, sha256_rhs_e_25, sha256_rhs_e_6, sha256_rhs_w_10, sha256_rhs_w_17, sha256_rhs_w_18, sha256_rhs_w_19, sha256_rhs_w_3, sha256_rhs_w_7, sha256_round_constant, sha256_round_count, sha256_rounds_remaining, sha256_rounds_remaining_inv, sha256_s_0, sha256_s_1, sha256_sel, sha256_start, sha256_state_offset, sha256_w, sha256_w_15_rotr_18, sha256_w_15_rotr_7, sha256_w_15_rotr_7_xor_w_15_rotr_18, sha256_w_15_rshift_3, sha256_w_2_rotr_17, sha256_w_2_rotr_17_xor_w_2_rotr_19, sha256_w_2_rotr_19, sha256_w_2_rshift_10, sha256_w_s_0, sha256_w_s_1, sha256_xor_sel, to_radix_acc, to_radix_acc_under_p, to_radix_end, to_radix_exponent, to_radix_found, to_radix_is_unsafe_limb, to_radix_limb, to_radix_limb_eq_p, to_radix_limb_index, to_radix_limb_lt_p, to_radix_limb_p_diff, to_radix_limb_radix_diff, to_radix_not_end, to_radix_not_padding_limb, to_radix_p_limb, to_radix_radix, to_radix_rem_inverse, to_radix_safe_limbs, to_radix_safety_diff_inverse, to_radix_sel, to_radix_start, to_radix_value, lookup_poseidon2_hash_poseidon2_perm_counts, lookup_range_check_dyn_rng_chk_pow_2_counts, lookup_range_check_dyn_diff_is_u16_counts, lookup_range_check_r0_is_u16_counts, lookup_range_check_r1_is_u16_counts, lookup_range_check_r2_is_u16_counts, lookup_range_check_r3_is_u16_counts, lookup_range_check_r4_is_u16_counts, lookup_range_check_r5_is_u16_counts, lookup_range_check_r6_is_u16_counts, lookup_range_check_r7_is_u16_counts, lookup_to_radix_limb_range_counts, lookup_to_radix_limb_less_than_radix_range_counts, lookup_to_radix_fetch_safe_limbs_counts, lookup_to_radix_fetch_p_limb_counts, lookup_to_radix_limb_p_diff_range_counts, lookup_scalar_mul_to_radix_counts, lookup_scalar_mul_double_counts, lookup_scalar_mul_add_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_0_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_1_counts, lookup_address_derivation_partial_address_poseidon2_counts, lookup_address_derivation_public_keys_hash_poseidon2_0_counts, lookup_address_derivation_public_keys_hash_poseidon2_1_counts, lookup_address_derivation_public_keys_hash_poseidon2_2_counts, lookup_address_derivation_public_keys_hash_poseidon2_3_counts, lookup_address_derivation_public_keys_hash_poseidon2_4_counts, lookup_address_derivation_preaddress_poseidon2_counts, lookup_address_derivation_preaddress_scalar_mul_counts, lookup_address_derivation_address_ecadd_counts, lookup_bc_decomposition_bytes_are_bytes_counts, lookup_bc_decomposition_abs_diff_is_u16_counts, lookup_bc_decomposition_bytes_to_read_as_unary_counts, lookup_bc_hashing_get_packed_field_counts, lookup_bc_hashing_iv_is_len_counts, lookup_bc_hashing_poseidon2_hash_counts, lookup_bc_retrieval_class_id_derivation_counts, lookup_bc_retrieval_bytecode_hash_is_correct_counts, lookup_instr_fetching_abs_diff_positive_counts, lookup_instr_fetching_pc_abs_diff_positive_lo_counts, lookup_instr_fetching_pc_abs_diff_positive_hi_counts, lookup_instr_fetching_bytes_from_bc_dec_counts, lookup_instr_fetching_wire_instruction_info_counts, lookup_class_id_derivation_class_id_poseidon2_0_counts, lookup_class_id_derivation_class_id_poseidon2_1_counts, lookup_bitwise_integral_tag_length_counts, lookup_bitwise_byte_operations_counts, lookup_sha256_round_constant_counts +#define AVM2_DERIVED_WITNESS_ENTITIES lookup_poseidon2_hash_poseidon2_perm_inv, lookup_range_check_dyn_rng_chk_pow_2_inv, lookup_range_check_dyn_diff_is_u16_inv, lookup_range_check_r0_is_u16_inv, lookup_range_check_r1_is_u16_inv, lookup_range_check_r2_is_u16_inv, lookup_range_check_r3_is_u16_inv, lookup_range_check_r4_is_u16_inv, lookup_range_check_r5_is_u16_inv, lookup_range_check_r6_is_u16_inv, lookup_range_check_r7_is_u16_inv, lookup_to_radix_limb_range_inv, lookup_to_radix_limb_less_than_radix_range_inv, lookup_to_radix_fetch_safe_limbs_inv, lookup_to_radix_fetch_p_limb_inv, lookup_to_radix_limb_p_diff_range_inv, lookup_scalar_mul_to_radix_inv, lookup_scalar_mul_double_inv, lookup_scalar_mul_add_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_0_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_1_inv, lookup_address_derivation_partial_address_poseidon2_inv, lookup_address_derivation_public_keys_hash_poseidon2_0_inv, lookup_address_derivation_public_keys_hash_poseidon2_1_inv, lookup_address_derivation_public_keys_hash_poseidon2_2_inv, lookup_address_derivation_public_keys_hash_poseidon2_3_inv, lookup_address_derivation_public_keys_hash_poseidon2_4_inv, lookup_address_derivation_preaddress_poseidon2_inv, lookup_address_derivation_preaddress_scalar_mul_inv, lookup_address_derivation_address_ecadd_inv, lookup_bc_decomposition_bytes_are_bytes_inv, lookup_bc_decomposition_abs_diff_is_u16_inv, lookup_bc_decomposition_bytes_to_read_as_unary_inv, lookup_bc_hashing_get_packed_field_inv, lookup_bc_hashing_iv_is_len_inv, lookup_bc_hashing_poseidon2_hash_inv, lookup_bc_retrieval_class_id_derivation_inv, lookup_bc_retrieval_bytecode_hash_is_correct_inv, lookup_instr_fetching_abs_diff_positive_inv, lookup_instr_fetching_pc_abs_diff_positive_lo_inv, lookup_instr_fetching_pc_abs_diff_positive_hi_inv, lookup_instr_fetching_bytes_from_bc_dec_inv, lookup_instr_fetching_wire_instruction_info_inv, lookup_class_id_derivation_class_id_poseidon2_0_inv, lookup_class_id_derivation_class_id_poseidon2_1_inv, lookup_bitwise_integral_tag_length_inv, lookup_bitwise_byte_operations_inv, lookup_sha256_round_constant_inv #define AVM2_SHIFTED_ENTITIES bc_decomposition_bytes_shift, bc_decomposition_bytes_pc_plus_1_shift, bc_decomposition_bytes_pc_plus_10_shift, bc_decomposition_bytes_pc_plus_11_shift, bc_decomposition_bytes_pc_plus_12_shift, bc_decomposition_bytes_pc_plus_13_shift, bc_decomposition_bytes_pc_plus_14_shift, bc_decomposition_bytes_pc_plus_15_shift, bc_decomposition_bytes_pc_plus_16_shift, bc_decomposition_bytes_pc_plus_17_shift, bc_decomposition_bytes_pc_plus_18_shift, bc_decomposition_bytes_pc_plus_19_shift, bc_decomposition_bytes_pc_plus_2_shift, bc_decomposition_bytes_pc_plus_20_shift, bc_decomposition_bytes_pc_plus_21_shift, bc_decomposition_bytes_pc_plus_22_shift, bc_decomposition_bytes_pc_plus_23_shift, bc_decomposition_bytes_pc_plus_24_shift, bc_decomposition_bytes_pc_plus_25_shift, bc_decomposition_bytes_pc_plus_26_shift, bc_decomposition_bytes_pc_plus_27_shift, bc_decomposition_bytes_pc_plus_28_shift, bc_decomposition_bytes_pc_plus_29_shift, bc_decomposition_bytes_pc_plus_3_shift, bc_decomposition_bytes_pc_plus_30_shift, bc_decomposition_bytes_pc_plus_31_shift, bc_decomposition_bytes_pc_plus_32_shift, bc_decomposition_bytes_pc_plus_33_shift, bc_decomposition_bytes_pc_plus_34_shift, bc_decomposition_bytes_pc_plus_35_shift, bc_decomposition_bytes_pc_plus_4_shift, bc_decomposition_bytes_pc_plus_5_shift, bc_decomposition_bytes_pc_plus_6_shift, bc_decomposition_bytes_pc_plus_7_shift, bc_decomposition_bytes_pc_plus_8_shift, bc_decomposition_bytes_pc_plus_9_shift, bc_decomposition_bytes_remaining_shift, bc_decomposition_id_shift, bc_decomposition_pc_shift, bc_decomposition_sel_shift, bc_hashing_bytecode_id_shift, bc_hashing_incremental_hash_shift, bc_hashing_pc_index_shift, bc_hashing_sel_shift, bc_hashing_start_shift, bitwise_acc_ia_shift, bitwise_acc_ib_shift, bitwise_acc_ic_shift, bitwise_ctr_shift, bitwise_op_id_shift, execution_sel_shift, instr_fetching_bytecode_id_shift, instr_fetching_bytecode_size_shift, instr_fetching_bytes_remaining_shift, instr_fetching_pc_shift, instr_fetching_sel_shift, poseidon2_hash_a_0_shift, poseidon2_hash_a_1_shift, poseidon2_hash_a_2_shift, poseidon2_hash_a_3_shift, poseidon2_hash_input_0_shift, poseidon2_hash_input_1_shift, poseidon2_hash_input_2_shift, poseidon2_hash_num_perm_rounds_rem_shift, poseidon2_hash_output_shift, poseidon2_hash_sel_shift, poseidon2_hash_start_shift, scalar_mul_bit_idx_shift, scalar_mul_point_inf_shift, scalar_mul_point_x_shift, scalar_mul_point_y_shift, scalar_mul_res_inf_shift, scalar_mul_res_x_shift, scalar_mul_res_y_shift, scalar_mul_scalar_shift, scalar_mul_sel_shift, scalar_mul_start_shift, scalar_mul_temp_inf_shift, scalar_mul_temp_x_shift, scalar_mul_temp_y_shift, sha256_a_shift, sha256_b_shift, sha256_c_shift, sha256_d_shift, sha256_e_shift, sha256_f_shift, sha256_g_shift, sha256_h_shift, sha256_helper_w0_shift, sha256_helper_w1_shift, sha256_helper_w10_shift, sha256_helper_w11_shift, sha256_helper_w12_shift, sha256_helper_w13_shift, sha256_helper_w14_shift, sha256_helper_w15_shift, sha256_helper_w2_shift, sha256_helper_w3_shift, sha256_helper_w4_shift, sha256_helper_w5_shift, sha256_helper_w6_shift, sha256_helper_w7_shift, sha256_helper_w8_shift, sha256_helper_w9_shift, sha256_rounds_remaining_shift, sha256_sel_shift, sha256_start_shift, to_radix_acc_shift, to_radix_acc_under_p_shift, to_radix_exponent_shift, to_radix_limb_shift, to_radix_limb_eq_p_shift, to_radix_limb_index_shift, to_radix_limb_lt_p_shift, to_radix_not_padding_limb_shift, to_radix_radix_shift, to_radix_safe_limbs_shift, to_radix_sel_shift, to_radix_start_shift, to_radix_value_shift #define AVM2_TO_BE_SHIFTED(e) e.bc_decomposition_bytes, e.bc_decomposition_bytes_pc_plus_1, e.bc_decomposition_bytes_pc_plus_10, e.bc_decomposition_bytes_pc_plus_11, e.bc_decomposition_bytes_pc_plus_12, e.bc_decomposition_bytes_pc_plus_13, e.bc_decomposition_bytes_pc_plus_14, e.bc_decomposition_bytes_pc_plus_15, e.bc_decomposition_bytes_pc_plus_16, e.bc_decomposition_bytes_pc_plus_17, e.bc_decomposition_bytes_pc_plus_18, e.bc_decomposition_bytes_pc_plus_19, e.bc_decomposition_bytes_pc_plus_2, e.bc_decomposition_bytes_pc_plus_20, e.bc_decomposition_bytes_pc_plus_21, e.bc_decomposition_bytes_pc_plus_22, e.bc_decomposition_bytes_pc_plus_23, e.bc_decomposition_bytes_pc_plus_24, e.bc_decomposition_bytes_pc_plus_25, e.bc_decomposition_bytes_pc_plus_26, e.bc_decomposition_bytes_pc_plus_27, e.bc_decomposition_bytes_pc_plus_28, e.bc_decomposition_bytes_pc_plus_29, e.bc_decomposition_bytes_pc_plus_3, e.bc_decomposition_bytes_pc_plus_30, e.bc_decomposition_bytes_pc_plus_31, e.bc_decomposition_bytes_pc_plus_32, e.bc_decomposition_bytes_pc_plus_33, e.bc_decomposition_bytes_pc_plus_34, e.bc_decomposition_bytes_pc_plus_35, e.bc_decomposition_bytes_pc_plus_4, e.bc_decomposition_bytes_pc_plus_5, e.bc_decomposition_bytes_pc_plus_6, e.bc_decomposition_bytes_pc_plus_7, e.bc_decomposition_bytes_pc_plus_8, e.bc_decomposition_bytes_pc_plus_9, e.bc_decomposition_bytes_remaining, e.bc_decomposition_id, e.bc_decomposition_pc, e.bc_decomposition_sel, e.bc_hashing_bytecode_id, e.bc_hashing_incremental_hash, e.bc_hashing_pc_index, e.bc_hashing_sel, e.bc_hashing_start, e.bitwise_acc_ia, e.bitwise_acc_ib, e.bitwise_acc_ic, e.bitwise_ctr, e.bitwise_op_id, e.execution_sel, e.instr_fetching_bytecode_id, e.instr_fetching_bytecode_size, e.instr_fetching_bytes_remaining, e.instr_fetching_pc, e.instr_fetching_sel, e.poseidon2_hash_a_0, e.poseidon2_hash_a_1, e.poseidon2_hash_a_2, e.poseidon2_hash_a_3, e.poseidon2_hash_input_0, e.poseidon2_hash_input_1, e.poseidon2_hash_input_2, e.poseidon2_hash_num_perm_rounds_rem, e.poseidon2_hash_output, e.poseidon2_hash_sel, e.poseidon2_hash_start, e.scalar_mul_bit_idx, e.scalar_mul_point_inf, e.scalar_mul_point_x, e.scalar_mul_point_y, e.scalar_mul_res_inf, e.scalar_mul_res_x, e.scalar_mul_res_y, e.scalar_mul_scalar, e.scalar_mul_sel, e.scalar_mul_start, e.scalar_mul_temp_inf, e.scalar_mul_temp_x, e.scalar_mul_temp_y, e.sha256_a, e.sha256_b, e.sha256_c, e.sha256_d, e.sha256_e, e.sha256_f, e.sha256_g, e.sha256_h, e.sha256_helper_w0, e.sha256_helper_w1, e.sha256_helper_w10, e.sha256_helper_w11, e.sha256_helper_w12, e.sha256_helper_w13, e.sha256_helper_w14, e.sha256_helper_w15, e.sha256_helper_w2, e.sha256_helper_w3, e.sha256_helper_w4, e.sha256_helper_w5, e.sha256_helper_w6, e.sha256_helper_w7, e.sha256_helper_w8, e.sha256_helper_w9, e.sha256_rounds_remaining, e.sha256_sel, e.sha256_start, e.to_radix_acc, e.to_radix_acc_under_p, e.to_radix_exponent, e.to_radix_limb, e.to_radix_limb_eq_p, e.to_radix_limb_index, e.to_radix_limb_lt_p, e.to_radix_not_padding_limb, e.to_radix_radix, e.to_radix_safe_limbs, e.to_radix_sel, e.to_radix_start, e.to_radix_value #define AVM2_ALL_ENTITIES AVM2_PRECOMPUTED_ENTITIES, AVM2_WIRE_ENTITIES, AVM2_DERIVED_WITNESS_ENTITIES, AVM2_SHIFTED_ENTITIES diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp index 950b85b626f2..ad5e4c5d8bb8 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp @@ -158,9 +158,9 @@ class AvmFlavor { lookup_class_id_derivation_class_id_poseidon2_0_relation, lookup_class_id_derivation_class_id_poseidon2_1_relation, lookup_instr_fetching_abs_diff_positive_relation, - lookup_instr_fetching_abs_diff_positive_hi_relation, - lookup_instr_fetching_abs_diff_positive_lo_relation, lookup_instr_fetching_bytes_from_bc_dec_relation, + lookup_instr_fetching_pc_abs_diff_positive_hi_relation, + lookup_instr_fetching_pc_abs_diff_positive_lo_relation, lookup_instr_fetching_wire_instruction_info_relation, lookup_poseidon2_hash_poseidon2_perm_relation, lookup_range_check_dyn_diff_is_u16_relation, diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp index 87b29041a0de..3e5837e77894 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp @@ -12,7 +12,7 @@ template class instr_fetchingImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3, 3, 3, 4, 4, 3, 5, 3, 3, 4, 3, + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3, 3, 3, 4, 4, 3, 5, 3, 3, 5, 3, 4, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3 }; template inline static bool skip(const AllEntities& in) @@ -99,7 +99,8 @@ template class instr_fetchingImpl { } { using Accumulator = typename std::tuple_element_t<9, ContainerOverSubrelations>; - auto tmp = new_term.instr_fetching_sel * (FF(1) - new_term.instr_fetching_last_of_bytecode) * + auto tmp = new_term.instr_fetching_sel * new_term.instr_fetching_sel_shift * + (FF(1) - new_term.instr_fetching_last_of_bytecode) * (new_term.instr_fetching_bytecode_size - new_term.instr_fetching_bytecode_size_shift); tmp *= scaling_factor; std::get<9>(evals) += typename Accumulator::View(tmp); diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_instr_fetching.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_instr_fetching.hpp index 44fe9f16c43e..aea56ae90532 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_instr_fetching.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_instr_fetching.hpp @@ -95,11 +95,11 @@ class lookup_instr_fetching_abs_diff_positive_relation } }; -/////////////////// lookup_instr_fetching_abs_diff_positive_lo /////////////////// +/////////////////// lookup_instr_fetching_pc_abs_diff_positive_lo /////////////////// -class lookup_instr_fetching_abs_diff_positive_lo_settings { +class lookup_instr_fetching_pc_abs_diff_positive_lo_settings { public: - static constexpr std::string_view NAME = "LOOKUP_INSTR_FETCHING_ABS_DIFF_POSITIVE_LO"; + static constexpr std::string_view NAME = "LOOKUP_INSTR_FETCHING_PC_ABS_DIFF_POSITIVE_LO"; static constexpr std::string_view RELATION_NAME = "instr_fetching"; static constexpr size_t READ_TERMS = 1; @@ -114,8 +114,8 @@ class lookup_instr_fetching_abs_diff_positive_lo_settings { // Columns using the Column enum. static constexpr Column SRC_SELECTOR = Column::instr_fetching_sel; static constexpr Column DST_SELECTOR = Column::precomputed_sel_range_16; - static constexpr Column COUNTS = Column::lookup_instr_fetching_abs_diff_positive_lo_counts; - static constexpr Column INVERSES = Column::lookup_instr_fetching_abs_diff_positive_lo_inv; + static constexpr Column COUNTS = Column::lookup_instr_fetching_pc_abs_diff_positive_lo_counts; + static constexpr Column INVERSES = Column::lookup_instr_fetching_pc_abs_diff_positive_lo_inv; static constexpr std::array SRC_COLUMNS = { ColumnAndShifts::instr_fetching_pc_abs_diff_lo }; @@ -147,8 +147,8 @@ class lookup_instr_fetching_abs_diff_positive_lo_settings { template static inline auto get_entities(AllEntities&& in) { - return std::forward_as_tuple(in._lookup_instr_fetching_abs_diff_positive_lo_inv(), - in._lookup_instr_fetching_abs_diff_positive_lo_counts(), + return std::forward_as_tuple(in._lookup_instr_fetching_pc_abs_diff_positive_lo_inv(), + in._lookup_instr_fetching_pc_abs_diff_positive_lo_counts(), in._instr_fetching_sel(), in._precomputed_sel_range_16(), in._instr_fetching_pc_abs_diff_lo(), @@ -157,17 +157,17 @@ class lookup_instr_fetching_abs_diff_positive_lo_settings { }; template -class lookup_instr_fetching_abs_diff_positive_lo_relation - : public GenericLookupRelation { +class lookup_instr_fetching_pc_abs_diff_positive_lo_relation + : public GenericLookupRelation { public: - using Settings = lookup_instr_fetching_abs_diff_positive_lo_settings; - static constexpr std::string_view NAME = lookup_instr_fetching_abs_diff_positive_lo_settings::NAME; + using Settings = lookup_instr_fetching_pc_abs_diff_positive_lo_settings; + static constexpr std::string_view NAME = lookup_instr_fetching_pc_abs_diff_positive_lo_settings::NAME; static constexpr std::string_view RELATION_NAME = - lookup_instr_fetching_abs_diff_positive_lo_settings::RELATION_NAME; + lookup_instr_fetching_pc_abs_diff_positive_lo_settings::RELATION_NAME; template inline static bool skip(const AllEntities& in) { - return in.lookup_instr_fetching_abs_diff_positive_lo_inv.is_zero(); + return in.lookup_instr_fetching_pc_abs_diff_positive_lo_inv.is_zero(); } static std::string get_subrelation_label(size_t index) @@ -181,11 +181,11 @@ class lookup_instr_fetching_abs_diff_positive_lo_relation } }; -/////////////////// lookup_instr_fetching_abs_diff_positive_hi /////////////////// +/////////////////// lookup_instr_fetching_pc_abs_diff_positive_hi /////////////////// -class lookup_instr_fetching_abs_diff_positive_hi_settings { +class lookup_instr_fetching_pc_abs_diff_positive_hi_settings { public: - static constexpr std::string_view NAME = "LOOKUP_INSTR_FETCHING_ABS_DIFF_POSITIVE_HI"; + static constexpr std::string_view NAME = "LOOKUP_INSTR_FETCHING_PC_ABS_DIFF_POSITIVE_HI"; static constexpr std::string_view RELATION_NAME = "instr_fetching"; static constexpr size_t READ_TERMS = 1; @@ -200,8 +200,8 @@ class lookup_instr_fetching_abs_diff_positive_hi_settings { // Columns using the Column enum. static constexpr Column SRC_SELECTOR = Column::instr_fetching_sel; static constexpr Column DST_SELECTOR = Column::precomputed_sel_range_16; - static constexpr Column COUNTS = Column::lookup_instr_fetching_abs_diff_positive_hi_counts; - static constexpr Column INVERSES = Column::lookup_instr_fetching_abs_diff_positive_hi_inv; + static constexpr Column COUNTS = Column::lookup_instr_fetching_pc_abs_diff_positive_hi_counts; + static constexpr Column INVERSES = Column::lookup_instr_fetching_pc_abs_diff_positive_hi_inv; static constexpr std::array SRC_COLUMNS = { ColumnAndShifts::instr_fetching_pc_abs_diff_hi }; @@ -233,8 +233,8 @@ class lookup_instr_fetching_abs_diff_positive_hi_settings { template static inline auto get_entities(AllEntities&& in) { - return std::forward_as_tuple(in._lookup_instr_fetching_abs_diff_positive_hi_inv(), - in._lookup_instr_fetching_abs_diff_positive_hi_counts(), + return std::forward_as_tuple(in._lookup_instr_fetching_pc_abs_diff_positive_hi_inv(), + in._lookup_instr_fetching_pc_abs_diff_positive_hi_counts(), in._instr_fetching_sel(), in._precomputed_sel_range_16(), in._instr_fetching_pc_abs_diff_hi(), @@ -243,17 +243,17 @@ class lookup_instr_fetching_abs_diff_positive_hi_settings { }; template -class lookup_instr_fetching_abs_diff_positive_hi_relation - : public GenericLookupRelation { +class lookup_instr_fetching_pc_abs_diff_positive_hi_relation + : public GenericLookupRelation { public: - using Settings = lookup_instr_fetching_abs_diff_positive_hi_settings; - static constexpr std::string_view NAME = lookup_instr_fetching_abs_diff_positive_hi_settings::NAME; + using Settings = lookup_instr_fetching_pc_abs_diff_positive_hi_settings; + static constexpr std::string_view NAME = lookup_instr_fetching_pc_abs_diff_positive_hi_settings::NAME; static constexpr std::string_view RELATION_NAME = - lookup_instr_fetching_abs_diff_positive_hi_settings::RELATION_NAME; + lookup_instr_fetching_pc_abs_diff_positive_hi_settings::RELATION_NAME; template inline static bool skip(const AllEntities& in) { - return in.lookup_instr_fetching_abs_diff_positive_hi_inv.is_zero(); + return in.lookup_instr_fetching_pc_abs_diff_positive_hi_inv.is_zero(); } static std::string get_subrelation_label(size_t index) diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.cpp index bd3f2f3b16b3..9323cb6c95e9 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.cpp @@ -62,12 +62,24 @@ Instruction TxBytecodeManager::read_instruction(BytecodeId bytecode_id, uint32_t auto bytecode_ptr = it->second; const auto& bytecode = *bytecode_ptr; - // TODO: catch errors etc. - Instruction instruction = deserialize_instruction(bytecode, pc); + InstructionFetchingError instr_fetch_err = InstructionFetchingError::NO_ERROR; + Instruction instruction; + + // TODO: Propagate instruction fetching error to the upper layer (execution loop) + try { + instruction = deserialize_instruction(bytecode, pc); + } catch (const InstructionFetchingError& error) { + instr_fetch_err = error; + } // The event will be deduplicated internally. - fetching_events.emit( - { .bytecode_id = bytecode_id, .pc = pc, .instruction = instruction, .bytecode = bytecode_ptr }); + fetching_events.emit({ + .bytecode_id = bytecode_id, + .pc = pc, + .instruction = instruction, + .bytecode = bytecode_ptr, + .error = instr_fetch_err, + }); return instruction; } diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.cpp index 106f0a363cd9..431fb98f53b7 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.cpp @@ -14,8 +14,11 @@ #include "barretenberg/numeric/uint256/uint256.hpp" #include "barretenberg/vm2/common/instruction_spec.hpp" #include "barretenberg/vm2/common/opcodes.hpp" +#include "barretenberg/vm2/common/stringify.hpp" +#include "barretenberg/vm2/simulation/events/bytecode_events.hpp" namespace bb::avm2::simulation { +using avm2::to_hex; const std::unordered_map OPERAND_TYPE_SIZE_BYTES = { { OperandType::INDIRECT8, 1 }, { OperandType::INDIRECT16, 2 }, { OperandType::TAG, 1 }, @@ -199,6 +202,15 @@ const std::unordered_map& get_operand_type_sizes() } // namespace testonly +namespace { + +bool is_wire_opcode_valid(uint8_t w_opcode) +{ + return w_opcode < static_cast(WireOpCode::LAST_OPCODE_SENTINEL); +} + +} // namespace + Operand::Operand(const Operand& other) { // Lazy implementation using the assignment operator. @@ -356,54 +368,46 @@ Instruction deserialize_instruction(std::span bytecode, size_t po { const auto bytecode_length = bytecode.size(); - assert(pos < bytecode_length); - (void)bytecode_length; // Avoid GCC unused parameter warning when asserts are disabled. - // if (pos >= length) { - // info("Position is out of range. Position: " + std::to_string(pos) + - // " Bytecode length: " + std::to_string(length)); - // return InstructionWithError{ - // .instruction = Instruction(WireOpCode::LAST_WireOpCode_SENTINEL, {}), - // .error = AvmError::INVALID_PROGRAM_COUNTER, - // }; - // } + if (pos >= bytecode_length) { + info("PC is out of range. Position: " + std::to_string(pos) + + " Bytecode length: " + std::to_string(bytecode_length)); + throw InstructionFetchingError::PC_OUT_OF_RANGE; + } const uint8_t opcode_byte = bytecode[pos]; - // if (!Bytecode::is_valid(WireOpCode_byte)) { - // info("Invalid WireOpCode byte: " + to_hex(WireOpCode_byte) + " at position: " + std::to_string(pos)); - // return InstructionWithError{ - // .instruction = Instruction(WireOpCode::LAST_WireOpCode_SENTINEL, {}), - // .error = AvmError::INVALID_WireOpCode, - // }; - // } - pos++; + if (!is_wire_opcode_valid(opcode_byte)) { + info("Invalid wire opcode byte: 0x" + to_hex(opcode_byte) + " at position: " + std::to_string(pos)); + throw InstructionFetchingError::OPCODE_OUT_OF_RANGE; + } const auto opcode = static_cast(opcode_byte); const auto iter = WireOpCode_WIRE_FORMAT.find(opcode); assert(iter != WireOpCode_WIRE_FORMAT.end()); - // if (iter == WireOpCode_WIRE_FORMAT.end()) { - // info("WireOpCode not found in WireOpCode_WIRE_FORMAT: " + to_hex(opcode) + " name " + to_string(opcode)); - // return InstructionWithError{ - // .instruction = Instruction(WireOpCode::LAST_WireOpCode_SENTINEL, {}), - // .error = AvmError::INVALID_WireOpCode, - // }; - // } const auto& inst_format = iter->second; + const uint32_t instruction_size = WIRE_INSTRUCTION_SPEC.at(opcode).size_in_bytes; + + if (pos + instruction_size > bytecode_length) { + info("Instruction does not fit in remaining bytecode. Wire opcode: ", + opcode, + " pos: ", + pos, + " instruction size: ", + instruction_size, + " bytecode length: ", + bytecode_length); + throw InstructionFetchingError::INSTRUCTION_OUT_OF_RANGE; + } + + pos++; // move after opcode byte + uint16_t indirect = 0; std::vector operands; for (const OperandType op_type : inst_format) { - // No underflow as above condition guarantees pos <= length (after pos++) const auto operand_size = OPERAND_TYPE_SIZE_BYTES.at(op_type); - assert(pos + operand_size <= bytecode_length); - // if (length - pos < operand_size) { - // info("Operand is missing at position " + std::to_string(pos) + " for WireOpCode " + to_hex(opcode) + - // " not enough bytes for operand type " + std::to_string(static_cast(op_type))); - // return InstructionWithError{ - // .instruction = Instruction(WireOpCode::LAST_WireOpCode_SENTINEL, {}), - // .error = AvmError::PARSING_ERROR, - // }; - // } + assert(pos + operand_size <= bytecode_length); // Guaranteed to hold due to + // pos + instruction_size <= bytecode_length switch (op_type) { case OperandType::TAG: { diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp index 010f3218cbb1..7cb1be68014f 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp @@ -66,8 +66,8 @@ class Operand { }; struct Instruction { - WireOpCode opcode; - uint16_t indirect; + WireOpCode opcode = WireOpCode::LAST_OPCODE_SENTINEL; + uint16_t indirect = 0; std::vector operands; std::string to_string() const; diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.test.cpp index 35ef430de2c4..2ec2acc664b4 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.test.cpp @@ -1,12 +1,14 @@ #include #include +#include "barretenberg/vm2/simulation/events/bytecode_events.hpp" #include "barretenberg/vm2/simulation/lib/serialization.hpp" namespace bb::avm2 { namespace { using simulation::deserialize_instruction; using simulation::Instruction; +using simulation::InstructionFetchingError; using simulation::Operand; // Testing serialization with some u8 variants @@ -81,5 +83,53 @@ TEST(SerializationTest, SetFFRoundTrip) EXPECT_EQ(instr, decoded); } +// Testing deserialization pc out of range error +TEST(SerializationTest, PCOutOfRange) +{ + std::vector bytecode; + bytecode.resize(35, 0); + + try { + deserialize_instruction(bytecode, bytecode.size() + 1); + } catch (const InstructionFetchingError& error) { + EXPECT_EQ(error, InstructionFetchingError::PC_OUT_OF_RANGE); + } +} + +// Testing deserialization wire opcode out of range error +TEST(SerializationTest, OpcodeOutOfRange) +{ + std::vector bytecode; + bytecode.push_back(static_cast(WireOpCode::LAST_OPCODE_SENTINEL) + 1); // Invalid opcode + + try { + deserialize_instruction(bytecode, 0); + } catch (const InstructionFetchingError& error) { + EXPECT_EQ(error, InstructionFetchingError::OPCODE_OUT_OF_RANGE); + } +} + +// Testing deserialization instruction out of range error +TEST(SerializationTest, InstructionOutOfRange) +{ + // Create a valid SET_16 instruction + Instruction instr = { + .opcode = WireOpCode::SET_16, + .indirect = 2, + .operands = { Operand::u16(1002), Operand::u8(static_cast(MemoryTag::U16)), Operand::u16(12345) } + }; + + auto bytecode = instr.serialize(); + + // Truncate the bytecode + bytecode.resize(bytecode.size() - 1); + + try { + deserialize_instruction(bytecode, 0); + } catch (const InstructionFetchingError& error) { + EXPECT_EQ(error, InstructionFetchingError::INSTRUCTION_OUT_OF_RANGE); + } +} + } // namespace } // namespace bb::avm2 diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp index 220542c010d5..5382bde74276 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp @@ -284,6 +284,8 @@ void BytecodeTraceBuilder::process_instruction_fetching( auto bytecode_at = [&](size_t i) -> uint8_t { return i < bytecode_size ? (*event.bytecode)[i] : 0; }; const bool is_last_of_bytecode = event_indices.back() == idx && bytecode_id != next_bytecode_id; + // Note that bytecode_id == next_bytecode_id && event_indices.back() == idx only when bytecode_id == 0 + // and this is the last interation of outer loop (last bytecode_id). FF bytecode_id_diff_inv = 0; if (is_last_of_bytecode) { diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp index bcbedce30896..efc0f856be0f 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp @@ -282,6 +282,9 @@ TraceContainer AvmTraceGenHelper::generate_trace(EventsContainer&& events) // Instruction Fetching std::make_unique>(), std::make_unique>(), + std::make_unique>(), + std::make_unique>(), + std::make_unique>(), // Class Id Derivation std::make_unique< LookupIntoDynamicTableSequential>(), From 1810447d2bbc3eb3f7400c28a165c065eba63506 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Wed, 12 Mar 2025 15:44:23 +0000 Subject: [PATCH 04/25] Add a TODO comment --- barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp index efc0f856be0f..ad2f7f39b30a 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp @@ -280,6 +280,10 @@ TraceContainer AvmTraceGenHelper::generate_trace(EventsContainer&& events) std::make_unique>(), std::make_unique>(), // Instruction Fetching + // TODO: Define another flavor for LookupIntoDynamicTableGeneric which takes only a prefix of the tuple + // as key. This would lower memory and potentially a short speed-up. Here, the two first elements + // (pc, bytecode_id) would define a unique key which is much shorter than this tuple which is about + // 40 elements long. std::make_unique>(), std::make_unique>(), std::make_unique>(), From 39eeb0e6b6d8ca49571f8226dc8853789105c046 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Wed, 12 Mar 2025 17:04:44 +0000 Subject: [PATCH 05/25] Typo --- .../barretenberg/sumcheck/sumcheck_round.hpp | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp index 6c278bd556e3..7cfed11d75dd 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp @@ -159,7 +159,7 @@ template class SumcheckProverRound { template SumcheckRoundUnivariate compute_univariate(ProverPolynomialsOrPartiallyEvaluatedMultivariates& polynomials, const bb::RelationParameters& relation_parameters, - const bb::GateSeparatorPolynomial& gate_sparators, + const bb::GateSeparatorPolynomial& gate_separators, const RelationSeparator alpha) { PROFILE_THIS_NAME("compute_univariate"); @@ -257,7 +257,7 @@ template class SumcheckProverRound { accumulate_relation_univariates(thread_univariate_accumulators[thread_idx], extended_edges, relation_parameters, - gate_sparators[(edge_idx >> 1) * gate_sparators.periodicity]); + gate_separators[(edge_idx >> 1) * gate_separators.periodicity]); } } }); @@ -268,7 +268,7 @@ template class SumcheckProverRound { } // Batch the univariate contributions from each sub-relation to obtain the round univariate - return batch_over_relations(univariate_accumulators, alpha, gate_sparators); + return batch_over_relations(univariate_accumulators, alpha, gate_separators); } /** @@ -280,7 +280,7 @@ template class SumcheckProverRound { SumcheckRoundUnivariate compute_univariate(const size_t round_idx, ProverPolynomialsOrPartiallyEvaluatedMultivariates& polynomials, const bb::RelationParameters& relation_parameters, - const bb::GateSeparatorPolynomial& gate_sparators, + const bb::GateSeparatorPolynomial& gate_separators, const RelationSeparator alpha, const ZKData& zk_sumcheck_data, // only populated when Flavor HasZK RowDisablingPolynomial row_disabling_poly) @@ -316,7 +316,7 @@ template class SumcheckProverRound { accumulate_relation_univariates(thread_univariate_accumulators[thread_idx], extended_edges, relation_parameters, - gate_sparators[(edge_idx >> 1) * gate_sparators.periodicity]); + gate_separators[(edge_idx >> 1) * gate_separators.periodicity]); } }); @@ -327,11 +327,11 @@ template class SumcheckProverRound { // For ZK Flavors: The evaluations of the round univariates are masked by the evaluations of Libra univariates // and corrected by subtracting the contribution from the disabled rows const auto contribution_from_disabled_rows = compute_disabled_contribution( - polynomials, relation_parameters, gate_sparators, alpha, round_idx, row_disabling_poly); + polynomials, relation_parameters, gate_separators, alpha, round_idx, row_disabling_poly); const auto libra_round_univariate = compute_libra_round_univariate(zk_sumcheck_data, round_idx); // Batch the univariate contributions from each sub-relation to obtain the round univariate const auto round_univariate = - batch_over_relations(univariate_accumulators, alpha, gate_sparators); + batch_over_relations(univariate_accumulators, alpha, gate_separators); // Mask the round univariate return round_univariate + libra_round_univariate - contribution_from_disabled_rows; }; @@ -346,7 +346,7 @@ template class SumcheckProverRound { SumcheckRoundUnivariate compute_disabled_contribution( ProverPolynomialsOrPartiallyEvaluatedMultivariates& polynomials, const bb::RelationParameters& relation_parameters, - const bb::GateSeparatorPolynomial& gate_sparators, + const bb::GateSeparatorPolynomial& gate_separators, const RelationSeparator alpha, const size_t round_idx, const RowDisablingPolynomial row_disabling_polynomial) @@ -363,9 +363,9 @@ template class SumcheckProverRound { accumulate_relation_univariates(univariate_accumulator, extended_edges, relation_parameters, - gate_sparators[(edge_idx >> 1) * gate_sparators.periodicity]); + gate_separators[(edge_idx >> 1) * gate_separators.periodicity]); } - result = batch_over_relations(univariate_accumulator, alpha, gate_sparators); + result = batch_over_relations(univariate_accumulator, alpha, gate_separators); bb::Univariate row_disabling_factor = bb::Univariate({ row_disabling_polynomial.eval_at_0, row_disabling_polynomial.eval_at_1 }); SumcheckRoundUnivariate row_disabling_factor_extended = @@ -389,18 +389,18 @@ template class SumcheckProverRound { * \tilde{S}^i(D))\f$. * * @param challenge Challenge \f$\alpha\f$. - * @param gate_sparators Round \f$pow_{\beta}\f$-factor given by \f$ ( (1−u_i) + u_i\cdot \beta_i )\f$. + * @param gate_separators Round \f$pow_{\beta}\f$-factor given by \f$ ( (1−u_i) + u_i\cdot \beta_i )\f$. */ template static ExtendedUnivariate batch_over_relations(ContainerOverSubrelations& univariate_accumulators, const RelationSeparator& challenge, - const bb::GateSeparatorPolynomial& gate_sparators) + const bb::GateSeparatorPolynomial& gate_separators) { auto running_challenge = FF(1); Utils::scale_univariates(univariate_accumulators, challenge, running_challenge); auto result = ExtendedUnivariate(0); - extend_and_batch_univariates(univariate_accumulators, result, gate_sparators); + extend_and_batch_univariates(univariate_accumulators, result, gate_separators); // Reset all univariate accumulators to 0 before beginning accumulation in the next round Utils::zero_univariates(univariate_accumulators); @@ -418,16 +418,16 @@ template class SumcheckProverRound { * @tparam extended_size Size after extension * @param tuple A tuple of tuples of Univariates * @param result Round univariate \f$ \tilde{S}^i\f$ represented by its evaluations over \f$ \{0,\ldots, D\} \f$. - * @param gate_sparators Round \f$pow_{\beta}\f$-factor \f$ ( (1−X_i) + X_i\cdot \beta_i )\f$. + * @param gate_separators Round \f$pow_{\beta}\f$-factor \f$ ( (1−X_i) + X_i\cdot \beta_i )\f$. */ template static void extend_and_batch_univariates(const TupleOfTuplesOfUnivariates& tuple, ExtendedUnivariate& result, - const bb::GateSeparatorPolynomial& gate_sparators) + const bb::GateSeparatorPolynomial& gate_separators) { ExtendedUnivariate extended_random_polynomial; // Pow-Factor \f$ (1-X) + X\beta_i \f$ - auto random_polynomial = bb::Univariate({ 1, gate_sparators.current_element() }); + auto random_polynomial = bb::Univariate({ 1, gate_separators.current_element() }); extended_random_polynomial = random_polynomial.template extend_to(); auto extend_and_sum = [&](Element& element) { @@ -446,7 +446,7 @@ template class SumcheckProverRound { // Multiply by the pow polynomial univariate contribution and the partial // evaluation result c_i (i.e. \f$ pow(u_0,...,u_{l-1})) \f$ where \f$(u_0,...,u_{i-1})\f$ are the // verifier challenges from previous rounds. - result += extended * extended_random_polynomial * gate_sparators.partial_evaluation_result; + result += extended * extended_random_polynomial * gate_separators.partial_evaluation_result; } }; Utils::apply_to_tuple_of_tuples(tuple, extend_and_sum); @@ -673,12 +673,14 @@ template class SumcheckVerifierRound { */ FF compute_full_relation_purported_value(const ClaimedEvaluations& purported_evaluations, const bb::RelationParameters& relation_parameters, - const bb::GateSeparatorPolynomial& gate_sparators, + const bb::GateSeparatorPolynomial& gate_separators, const RelationSeparator alpha) { // The verifier should never skip computation of contributions from any relation - Utils::template accumulate_relation_evaluations_without_skipping<>( - purported_evaluations, relation_evaluations, relation_parameters, gate_sparators.partial_evaluation_result); + Utils::template accumulate_relation_evaluations_without_skipping<>(purported_evaluations, + relation_evaluations, + relation_parameters, + gate_separators.partial_evaluation_result); FF running_challenge{ 1 }; FF output{ 0 }; From d984fe3dc3a535b9392c003e3d161f76dcdb4dff Mon Sep 17 00:00:00 2001 From: jeanmon Date: Thu, 13 Mar 2025 14:51:40 +0000 Subject: [PATCH 06/25] unit tests --- barretenberg/cpp/pil/vm2/instr_fetching.pil | 9 +- .../barretenberg/vm2/generated/columns.hpp | 2 +- .../generated/relations/instr_fetching.hpp | 2 +- .../relations/lookups_instr_fetching.hpp | 4 +- .../vm2/tracegen/bytecode_trace.cpp | 9 +- .../vm2/tracegen/bytecode_trace.test.cpp | 297 ++++++++++++++++-- 6 files changed, 278 insertions(+), 45 deletions(-) diff --git a/barretenberg/cpp/pil/vm2/instr_fetching.pil b/barretenberg/cpp/pil/vm2/instr_fetching.pil index ffdc2ae9140e..97bef073f405 100644 --- a/barretenberg/cpp/pil/vm2/instr_fetching.pil +++ b/barretenberg/cpp/pil/vm2/instr_fetching.pil @@ -45,7 +45,6 @@ pol BC_ID_DIFF = bytecode_id' - bytecode_id; pol commit bc_id_diff_inv; sel * (BC_ID_DIFF * ((1 - last_of_bytecode) * (1 - bc_id_diff_inv) + bc_id_diff_inv) - last_of_bytecode) = 0; - // If last_of_bytecode OR precomputed.first_row then next row has pc == 0 #[PC_IS_ZERO_IN_BYTECODE_FIRST_ROW] (last_of_bytecode + precomputed.first_row) * pc' = 0; @@ -65,13 +64,13 @@ sel * sel' * (1 - last_of_bytecode) * (bytecode_size - bytecode_size') = 0; // Absolute difference variant where we compute: // bytes_to_read - instr_size if instr_size <= bytes_to_read // instr_size - bytes_to_read - 1 if instr_size > bytes_to_read -pol commit abs_diff; +pol commit instr_abs_diff; -// From the following relation, we have: abs_diff >= 0 ==> [instr_size > bytes_to_read <==> instr_out_of_range == 1] -abs_diff = (2 * instr_out_of_range - 1) * (instr_size - bytes_to_read) - instr_out_of_range; +// From the following relation, we have: instr_abs_diff >= 0 ==> [instr_size > bytes_to_read <==> instr_out_of_range == 1] +instr_abs_diff = (2 * instr_out_of_range - 1) * (instr_size - bytes_to_read) - instr_out_of_range; #[ABS_DIFF_POSITIVE] -sel {abs_diff} in precomputed.sel_range_8 {precomputed.clk}; +sel {instr_abs_diff} in precomputed.sel_range_8 {precomputed.clk}; // We have to enforce that: pc < bytecode_size <==> pc_out_of_range == 0 // We use same trick as above by using an absolute difference value. diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp index 54e5b7690bc8..2023a9636602 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp @@ -10,7 +10,7 @@ namespace bb::avm2 { // The entities that will be used in the flavor. // clang-format off #define AVM2_PRECOMPUTED_ENTITIES precomputed_as_unary, precomputed_bitwise_input_a, precomputed_bitwise_input_b, precomputed_bitwise_op_id, precomputed_bitwise_output, precomputed_clk, precomputed_exec_opcode, precomputed_first_row, precomputed_instr_size, precomputed_integral_tag_length, precomputed_opcode_out_of_range, precomputed_p_decomposition_limb, precomputed_p_decomposition_limb_index, precomputed_p_decomposition_radix, precomputed_power_of_2, precomputed_sel_bitwise, precomputed_sel_integral_tag, precomputed_sel_op_dc_0, precomputed_sel_op_dc_1, precomputed_sel_op_dc_10, precomputed_sel_op_dc_11, precomputed_sel_op_dc_12, precomputed_sel_op_dc_13, precomputed_sel_op_dc_14, precomputed_sel_op_dc_15, precomputed_sel_op_dc_16, precomputed_sel_op_dc_17, precomputed_sel_op_dc_2, precomputed_sel_op_dc_3, precomputed_sel_op_dc_4, precomputed_sel_op_dc_5, precomputed_sel_op_dc_6, precomputed_sel_op_dc_7, precomputed_sel_op_dc_8, precomputed_sel_op_dc_9, precomputed_sel_p_decomposition, precomputed_sel_range_16, precomputed_sel_range_8, precomputed_sel_sha256_compression, precomputed_sel_to_radix_safe_limbs, precomputed_sel_unary, precomputed_sha256_compression_round_constant, precomputed_to_radix_safe_limbs, precomputed_zero -#define AVM2_WIRE_ENTITIES execution_input, address_derivation_address, address_derivation_address_y, address_derivation_class_id, address_derivation_deployer_addr, address_derivation_g1_x, address_derivation_g1_y, address_derivation_incoming_viewing_key_x, address_derivation_incoming_viewing_key_y, address_derivation_init_hash, address_derivation_nullifier_key_x, address_derivation_nullifier_key_y, address_derivation_outgoing_viewing_key_x, address_derivation_outgoing_viewing_key_y, address_derivation_partial_address, address_derivation_partial_address_domain_separator, address_derivation_preaddress, address_derivation_preaddress_domain_separator, address_derivation_preaddress_public_key_x, address_derivation_preaddress_public_key_y, address_derivation_public_keys_hash, address_derivation_public_keys_hash_domain_separator, address_derivation_salt, address_derivation_salted_init_hash, address_derivation_sel, address_derivation_tagging_key_x, address_derivation_tagging_key_y, alu_dst_addr, alu_ia, alu_ia_addr, alu_ib, alu_ib_addr, alu_ic, alu_op, alu_sel_op_add, bc_decomposition_abs_diff, bc_decomposition_bytes, bc_decomposition_bytes_pc_plus_1, bc_decomposition_bytes_pc_plus_10, bc_decomposition_bytes_pc_plus_11, bc_decomposition_bytes_pc_plus_12, bc_decomposition_bytes_pc_plus_13, bc_decomposition_bytes_pc_plus_14, bc_decomposition_bytes_pc_plus_15, bc_decomposition_bytes_pc_plus_16, bc_decomposition_bytes_pc_plus_17, bc_decomposition_bytes_pc_plus_18, bc_decomposition_bytes_pc_plus_19, bc_decomposition_bytes_pc_plus_2, bc_decomposition_bytes_pc_plus_20, bc_decomposition_bytes_pc_plus_21, bc_decomposition_bytes_pc_plus_22, bc_decomposition_bytes_pc_plus_23, bc_decomposition_bytes_pc_plus_24, bc_decomposition_bytes_pc_plus_25, bc_decomposition_bytes_pc_plus_26, bc_decomposition_bytes_pc_plus_27, bc_decomposition_bytes_pc_plus_28, bc_decomposition_bytes_pc_plus_29, bc_decomposition_bytes_pc_plus_3, bc_decomposition_bytes_pc_plus_30, bc_decomposition_bytes_pc_plus_31, bc_decomposition_bytes_pc_plus_32, bc_decomposition_bytes_pc_plus_33, bc_decomposition_bytes_pc_plus_34, bc_decomposition_bytes_pc_plus_35, bc_decomposition_bytes_pc_plus_36, bc_decomposition_bytes_pc_plus_4, bc_decomposition_bytes_pc_plus_5, bc_decomposition_bytes_pc_plus_6, bc_decomposition_bytes_pc_plus_7, bc_decomposition_bytes_pc_plus_8, bc_decomposition_bytes_pc_plus_9, bc_decomposition_bytes_rem_inv, bc_decomposition_bytes_rem_min_one_inv, bc_decomposition_bytes_remaining, bc_decomposition_bytes_to_read, bc_decomposition_bytes_to_read_unary, bc_decomposition_id, bc_decomposition_last_of_contract, bc_decomposition_packed_field, bc_decomposition_pc, bc_decomposition_sel, bc_decomposition_sel_overflow_correction_needed, bc_decomposition_sel_packed, bc_decomposition_sel_pc_plus_1, bc_decomposition_sel_pc_plus_10, bc_decomposition_sel_pc_plus_11, bc_decomposition_sel_pc_plus_12, bc_decomposition_sel_pc_plus_13, bc_decomposition_sel_pc_plus_14, bc_decomposition_sel_pc_plus_15, bc_decomposition_sel_pc_plus_16, bc_decomposition_sel_pc_plus_17, bc_decomposition_sel_pc_plus_18, bc_decomposition_sel_pc_plus_19, bc_decomposition_sel_pc_plus_2, bc_decomposition_sel_pc_plus_20, bc_decomposition_sel_pc_plus_21, bc_decomposition_sel_pc_plus_22, bc_decomposition_sel_pc_plus_23, bc_decomposition_sel_pc_plus_24, bc_decomposition_sel_pc_plus_25, bc_decomposition_sel_pc_plus_26, bc_decomposition_sel_pc_plus_27, bc_decomposition_sel_pc_plus_28, bc_decomposition_sel_pc_plus_29, bc_decomposition_sel_pc_plus_3, bc_decomposition_sel_pc_plus_30, bc_decomposition_sel_pc_plus_31, bc_decomposition_sel_pc_plus_32, bc_decomposition_sel_pc_plus_33, bc_decomposition_sel_pc_plus_34, bc_decomposition_sel_pc_plus_35, bc_decomposition_sel_pc_plus_36, bc_decomposition_sel_pc_plus_4, bc_decomposition_sel_pc_plus_5, bc_decomposition_sel_pc_plus_6, bc_decomposition_sel_pc_plus_7, bc_decomposition_sel_pc_plus_8, bc_decomposition_sel_pc_plus_9, bc_hashing_bytecode_id, bc_hashing_incremental_hash, bc_hashing_latch, bc_hashing_output_hash, bc_hashing_packed_field, bc_hashing_pc_index, bc_hashing_sel, bc_hashing_start, bc_retrieval_address, bc_retrieval_artifact_hash, bc_retrieval_bytecode_id, bc_retrieval_class_id, bc_retrieval_deployer_addr, bc_retrieval_err, bc_retrieval_incoming_viewing_key_x, bc_retrieval_incoming_viewing_key_y, bc_retrieval_init_hash, bc_retrieval_nullifier_key_x, bc_retrieval_nullifier_key_y, bc_retrieval_outgoing_viewing_key_x, bc_retrieval_outgoing_viewing_key_y, bc_retrieval_private_function_root, bc_retrieval_public_bytecode_commitment, bc_retrieval_salt, bc_retrieval_sel, bc_retrieval_siloed_address, bc_retrieval_tagging_key_x, bc_retrieval_tagging_key_y, bitwise_acc_ia, bitwise_acc_ib, bitwise_acc_ic, bitwise_ctr, bitwise_ctr_inv, bitwise_ctr_min_one_inv, bitwise_ia_byte, bitwise_ib_byte, bitwise_ic_byte, bitwise_last, bitwise_op_id, bitwise_sel, bitwise_start, bitwise_tag, class_id_derivation_artifact_hash, class_id_derivation_class_id, class_id_derivation_private_function_root, class_id_derivation_public_bytecode_commitment, class_id_derivation_sel, class_id_derivation_temp_constant_for_lookup, ecc_add_op, ecc_double_op, ecc_inv_2_p_y, ecc_inv_x_diff, ecc_inv_y_diff, ecc_lambda, ecc_p_is_inf, ecc_p_x, ecc_p_y, ecc_q_is_inf, ecc_q_x, ecc_q_y, ecc_r_is_inf, ecc_r_x, ecc_r_y, ecc_result_infinity, ecc_sel, ecc_x_match, ecc_y_match, execution_addressing_error_idx, execution_addressing_error_kind, execution_base_address_tag, execution_base_address_val, execution_bytecode_id, execution_clk, execution_ex_opcode, execution_indirect, execution_last, execution_op1, execution_op1_after_relative, execution_op2, execution_op2_after_relative, execution_op3, execution_op3_after_relative, execution_op4, execution_op4_after_relative, execution_pc, execution_rop1, execution_rop2, execution_rop3, execution_rop4, execution_sel, execution_sel_addressing_error, execution_sel_op1_is_address, execution_sel_op2_is_address, execution_sel_op3_is_address, execution_sel_op4_is_address, instr_fetching_abs_diff, instr_fetching_bc_id_diff_inv, instr_fetching_bd0, instr_fetching_bd1, instr_fetching_bd10, instr_fetching_bd11, instr_fetching_bd12, instr_fetching_bd13, instr_fetching_bd14, instr_fetching_bd15, instr_fetching_bd16, instr_fetching_bd17, instr_fetching_bd18, instr_fetching_bd19, instr_fetching_bd2, instr_fetching_bd20, instr_fetching_bd21, instr_fetching_bd22, instr_fetching_bd23, instr_fetching_bd24, instr_fetching_bd25, instr_fetching_bd26, instr_fetching_bd27, instr_fetching_bd28, instr_fetching_bd29, instr_fetching_bd3, instr_fetching_bd30, instr_fetching_bd31, instr_fetching_bd32, instr_fetching_bd33, instr_fetching_bd34, instr_fetching_bd35, instr_fetching_bd36, instr_fetching_bd4, instr_fetching_bd5, instr_fetching_bd6, instr_fetching_bd7, instr_fetching_bd8, instr_fetching_bd9, instr_fetching_bytecode_id, instr_fetching_bytecode_size, instr_fetching_bytes_remaining, instr_fetching_bytes_to_read, instr_fetching_exec_opcode, instr_fetching_indirect, instr_fetching_instr_out_of_range, instr_fetching_instr_size, instr_fetching_last_of_bytecode, instr_fetching_op1, instr_fetching_op2, instr_fetching_op3, instr_fetching_op4, instr_fetching_op5, instr_fetching_op6, instr_fetching_op7, instr_fetching_opcode_out_of_range, instr_fetching_parsing_err, instr_fetching_pc, instr_fetching_pc_abs_diff, instr_fetching_pc_abs_diff_hi, instr_fetching_pc_abs_diff_lo, instr_fetching_pc_out_of_range, instr_fetching_sel, instr_fetching_sel_lookup_bc_decomposition, instr_fetching_sel_op_dc_0, instr_fetching_sel_op_dc_1, instr_fetching_sel_op_dc_10, instr_fetching_sel_op_dc_11, instr_fetching_sel_op_dc_12, instr_fetching_sel_op_dc_13, instr_fetching_sel_op_dc_14, instr_fetching_sel_op_dc_15, instr_fetching_sel_op_dc_16, instr_fetching_sel_op_dc_17, instr_fetching_sel_op_dc_2, instr_fetching_sel_op_dc_3, instr_fetching_sel_op_dc_4, instr_fetching_sel_op_dc_5, instr_fetching_sel_op_dc_6, instr_fetching_sel_op_dc_7, instr_fetching_sel_op_dc_8, instr_fetching_sel_op_dc_9, poseidon2_hash_a_0, poseidon2_hash_a_1, poseidon2_hash_a_2, poseidon2_hash_a_3, poseidon2_hash_b_0, poseidon2_hash_b_1, poseidon2_hash_b_2, poseidon2_hash_b_3, poseidon2_hash_end, poseidon2_hash_input_0, poseidon2_hash_input_1, poseidon2_hash_input_2, poseidon2_hash_input_len, poseidon2_hash_num_perm_rounds_rem, poseidon2_hash_num_perm_rounds_rem_inv, poseidon2_hash_output, poseidon2_hash_padding, poseidon2_hash_sel, poseidon2_hash_start, poseidon2_perm_B_10_0, poseidon2_perm_B_10_1, poseidon2_perm_B_10_2, poseidon2_perm_B_10_3, poseidon2_perm_B_11_0, poseidon2_perm_B_11_1, poseidon2_perm_B_11_2, poseidon2_perm_B_11_3, poseidon2_perm_B_12_0, poseidon2_perm_B_12_1, poseidon2_perm_B_12_2, poseidon2_perm_B_12_3, poseidon2_perm_B_13_0, poseidon2_perm_B_13_1, poseidon2_perm_B_13_2, poseidon2_perm_B_13_3, poseidon2_perm_B_14_0, poseidon2_perm_B_14_1, poseidon2_perm_B_14_2, poseidon2_perm_B_14_3, poseidon2_perm_B_15_0, poseidon2_perm_B_15_1, poseidon2_perm_B_15_2, poseidon2_perm_B_15_3, poseidon2_perm_B_16_0, poseidon2_perm_B_16_1, poseidon2_perm_B_16_2, poseidon2_perm_B_16_3, poseidon2_perm_B_17_0, poseidon2_perm_B_17_1, poseidon2_perm_B_17_2, poseidon2_perm_B_17_3, poseidon2_perm_B_18_0, poseidon2_perm_B_18_1, poseidon2_perm_B_18_2, poseidon2_perm_B_18_3, poseidon2_perm_B_19_0, poseidon2_perm_B_19_1, poseidon2_perm_B_19_2, poseidon2_perm_B_19_3, poseidon2_perm_B_20_0, poseidon2_perm_B_20_1, poseidon2_perm_B_20_2, poseidon2_perm_B_20_3, poseidon2_perm_B_21_0, poseidon2_perm_B_21_1, poseidon2_perm_B_21_2, poseidon2_perm_B_21_3, poseidon2_perm_B_22_0, poseidon2_perm_B_22_1, poseidon2_perm_B_22_2, poseidon2_perm_B_22_3, poseidon2_perm_B_23_0, poseidon2_perm_B_23_1, poseidon2_perm_B_23_2, poseidon2_perm_B_23_3, poseidon2_perm_B_24_0, poseidon2_perm_B_24_1, poseidon2_perm_B_24_2, poseidon2_perm_B_24_3, poseidon2_perm_B_25_0, poseidon2_perm_B_25_1, poseidon2_perm_B_25_2, poseidon2_perm_B_25_3, poseidon2_perm_B_26_0, poseidon2_perm_B_26_1, poseidon2_perm_B_26_2, poseidon2_perm_B_26_3, poseidon2_perm_B_27_0, poseidon2_perm_B_27_1, poseidon2_perm_B_27_2, poseidon2_perm_B_27_3, poseidon2_perm_B_28_0, poseidon2_perm_B_28_1, poseidon2_perm_B_28_2, poseidon2_perm_B_28_3, poseidon2_perm_B_29_0, poseidon2_perm_B_29_1, poseidon2_perm_B_29_2, poseidon2_perm_B_29_3, poseidon2_perm_B_30_0, poseidon2_perm_B_30_1, poseidon2_perm_B_30_2, poseidon2_perm_B_30_3, poseidon2_perm_B_31_0, poseidon2_perm_B_31_1, poseidon2_perm_B_31_2, poseidon2_perm_B_31_3, poseidon2_perm_B_32_0, poseidon2_perm_B_32_1, poseidon2_perm_B_32_2, poseidon2_perm_B_32_3, poseidon2_perm_B_33_0, poseidon2_perm_B_33_1, poseidon2_perm_B_33_2, poseidon2_perm_B_33_3, poseidon2_perm_B_34_0, poseidon2_perm_B_34_1, poseidon2_perm_B_34_2, poseidon2_perm_B_34_3, poseidon2_perm_B_35_0, poseidon2_perm_B_35_1, poseidon2_perm_B_35_2, poseidon2_perm_B_35_3, poseidon2_perm_B_36_0, poseidon2_perm_B_36_1, poseidon2_perm_B_36_2, poseidon2_perm_B_36_3, poseidon2_perm_B_37_0, poseidon2_perm_B_37_1, poseidon2_perm_B_37_2, poseidon2_perm_B_37_3, poseidon2_perm_B_38_0, poseidon2_perm_B_38_1, poseidon2_perm_B_38_2, poseidon2_perm_B_38_3, poseidon2_perm_B_39_0, poseidon2_perm_B_39_1, poseidon2_perm_B_39_2, poseidon2_perm_B_39_3, poseidon2_perm_B_40_0, poseidon2_perm_B_40_1, poseidon2_perm_B_40_2, poseidon2_perm_B_40_3, poseidon2_perm_B_41_0, poseidon2_perm_B_41_1, poseidon2_perm_B_41_2, poseidon2_perm_B_41_3, poseidon2_perm_B_42_0, poseidon2_perm_B_42_1, poseidon2_perm_B_42_2, poseidon2_perm_B_42_3, poseidon2_perm_B_43_0, poseidon2_perm_B_43_1, poseidon2_perm_B_43_2, poseidon2_perm_B_43_3, poseidon2_perm_B_44_0, poseidon2_perm_B_44_1, poseidon2_perm_B_44_2, poseidon2_perm_B_44_3, poseidon2_perm_B_45_0, poseidon2_perm_B_45_1, poseidon2_perm_B_45_2, poseidon2_perm_B_45_3, poseidon2_perm_B_46_0, poseidon2_perm_B_46_1, poseidon2_perm_B_46_2, poseidon2_perm_B_46_3, poseidon2_perm_B_47_0, poseidon2_perm_B_47_1, poseidon2_perm_B_47_2, poseidon2_perm_B_47_3, poseidon2_perm_B_48_0, poseidon2_perm_B_48_1, poseidon2_perm_B_48_2, poseidon2_perm_B_48_3, poseidon2_perm_B_49_0, poseidon2_perm_B_49_1, poseidon2_perm_B_49_2, poseidon2_perm_B_49_3, poseidon2_perm_B_4_0, poseidon2_perm_B_4_1, poseidon2_perm_B_4_2, poseidon2_perm_B_4_3, poseidon2_perm_B_50_0, poseidon2_perm_B_50_1, poseidon2_perm_B_50_2, poseidon2_perm_B_50_3, poseidon2_perm_B_51_0, poseidon2_perm_B_51_1, poseidon2_perm_B_51_2, poseidon2_perm_B_51_3, poseidon2_perm_B_52_0, poseidon2_perm_B_52_1, poseidon2_perm_B_52_2, poseidon2_perm_B_52_3, poseidon2_perm_B_53_0, poseidon2_perm_B_53_1, poseidon2_perm_B_53_2, poseidon2_perm_B_53_3, poseidon2_perm_B_54_0, poseidon2_perm_B_54_1, poseidon2_perm_B_54_2, poseidon2_perm_B_54_3, poseidon2_perm_B_55_0, poseidon2_perm_B_55_1, poseidon2_perm_B_55_2, poseidon2_perm_B_55_3, poseidon2_perm_B_56_0, poseidon2_perm_B_56_1, poseidon2_perm_B_56_2, poseidon2_perm_B_56_3, poseidon2_perm_B_57_0, poseidon2_perm_B_57_1, poseidon2_perm_B_57_2, poseidon2_perm_B_57_3, poseidon2_perm_B_58_0, poseidon2_perm_B_58_1, poseidon2_perm_B_58_2, poseidon2_perm_B_58_3, poseidon2_perm_B_59_0, poseidon2_perm_B_59_1, poseidon2_perm_B_59_2, poseidon2_perm_B_59_3, poseidon2_perm_B_5_0, poseidon2_perm_B_5_1, poseidon2_perm_B_5_2, poseidon2_perm_B_5_3, poseidon2_perm_B_6_0, poseidon2_perm_B_6_1, poseidon2_perm_B_6_2, poseidon2_perm_B_6_3, poseidon2_perm_B_7_0, poseidon2_perm_B_7_1, poseidon2_perm_B_7_2, poseidon2_perm_B_7_3, poseidon2_perm_B_8_0, poseidon2_perm_B_8_1, poseidon2_perm_B_8_2, poseidon2_perm_B_8_3, poseidon2_perm_B_9_0, poseidon2_perm_B_9_1, poseidon2_perm_B_9_2, poseidon2_perm_B_9_3, poseidon2_perm_EXT_LAYER_4, poseidon2_perm_EXT_LAYER_5, poseidon2_perm_EXT_LAYER_6, poseidon2_perm_EXT_LAYER_7, poseidon2_perm_T_0_4, poseidon2_perm_T_0_5, poseidon2_perm_T_0_6, poseidon2_perm_T_0_7, poseidon2_perm_T_1_4, poseidon2_perm_T_1_5, poseidon2_perm_T_1_6, poseidon2_perm_T_1_7, poseidon2_perm_T_2_4, poseidon2_perm_T_2_5, poseidon2_perm_T_2_6, poseidon2_perm_T_2_7, poseidon2_perm_T_3_4, poseidon2_perm_T_3_5, poseidon2_perm_T_3_6, poseidon2_perm_T_3_7, poseidon2_perm_T_60_4, poseidon2_perm_T_60_5, poseidon2_perm_T_60_6, poseidon2_perm_T_60_7, poseidon2_perm_T_61_4, poseidon2_perm_T_61_5, poseidon2_perm_T_61_6, poseidon2_perm_T_61_7, poseidon2_perm_T_62_4, poseidon2_perm_T_62_5, poseidon2_perm_T_62_6, poseidon2_perm_T_62_7, poseidon2_perm_T_63_4, poseidon2_perm_T_63_5, poseidon2_perm_T_63_6, poseidon2_perm_T_63_7, poseidon2_perm_a_0, poseidon2_perm_a_1, poseidon2_perm_a_2, poseidon2_perm_a_3, poseidon2_perm_b_0, poseidon2_perm_b_1, poseidon2_perm_b_2, poseidon2_perm_b_3, poseidon2_perm_sel, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_rng_chk_bits, range_check_sel, range_check_sel_r0_16_bit_rng_lookup, range_check_sel_r1_16_bit_rng_lookup, range_check_sel_r2_16_bit_rng_lookup, range_check_sel_r3_16_bit_rng_lookup, range_check_sel_r4_16_bit_rng_lookup, range_check_sel_r5_16_bit_rng_lookup, range_check_sel_r6_16_bit_rng_lookup, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, scalar_mul_bit, scalar_mul_bit_idx, scalar_mul_bit_radix, scalar_mul_end, scalar_mul_not_end, scalar_mul_point_inf, scalar_mul_point_x, scalar_mul_point_y, scalar_mul_res_inf, scalar_mul_res_x, scalar_mul_res_y, scalar_mul_scalar, scalar_mul_sel, scalar_mul_should_add, scalar_mul_start, scalar_mul_temp_inf, scalar_mul_temp_x, scalar_mul_temp_y, sha256_a, sha256_a_and_b, sha256_a_and_b_xor_a_and_c, sha256_a_and_c, sha256_a_rotr_13, sha256_a_rotr_2, sha256_a_rotr_22, sha256_a_rotr_2_xor_a_rotr_13, sha256_and_sel, sha256_b, sha256_b_and_c, sha256_c, sha256_ch, sha256_clk, sha256_computed_w_lhs, sha256_computed_w_rhs, sha256_d, sha256_e, sha256_e_and_f, sha256_e_rotr_11, sha256_e_rotr_25, sha256_e_rotr_6, sha256_e_rotr_6_xor_e_rotr_11, sha256_f, sha256_g, sha256_h, sha256_helper_w0, sha256_helper_w1, sha256_helper_w10, sha256_helper_w11, sha256_helper_w12, sha256_helper_w13, sha256_helper_w14, sha256_helper_w15, sha256_helper_w2, sha256_helper_w3, sha256_helper_w4, sha256_helper_w5, sha256_helper_w6, sha256_helper_w7, sha256_helper_w8, sha256_helper_w9, sha256_init_a, sha256_init_b, sha256_init_c, sha256_init_d, sha256_init_e, sha256_init_f, sha256_init_g, sha256_init_h, sha256_input_offset, sha256_is_input_round, sha256_latch, sha256_lhs_a_13, sha256_lhs_a_2, sha256_lhs_a_22, sha256_lhs_e_11, sha256_lhs_e_25, sha256_lhs_e_6, sha256_lhs_w_10, sha256_lhs_w_17, sha256_lhs_w_18, sha256_lhs_w_19, sha256_lhs_w_3, sha256_lhs_w_7, sha256_maj, sha256_next_a_lhs, sha256_next_a_rhs, sha256_next_e_lhs, sha256_next_e_rhs, sha256_not_e, sha256_not_e_and_g, sha256_output_a_lhs, sha256_output_a_rhs, sha256_output_b_lhs, sha256_output_b_rhs, sha256_output_c_lhs, sha256_output_c_rhs, sha256_output_d_lhs, sha256_output_d_rhs, sha256_output_e_lhs, sha256_output_e_rhs, sha256_output_f_lhs, sha256_output_f_rhs, sha256_output_g_lhs, sha256_output_g_rhs, sha256_output_h_lhs, sha256_output_h_rhs, sha256_output_offset, sha256_perform_round, sha256_rhs_a_13, sha256_rhs_a_2, sha256_rhs_a_22, sha256_rhs_e_11, sha256_rhs_e_25, sha256_rhs_e_6, sha256_rhs_w_10, sha256_rhs_w_17, sha256_rhs_w_18, sha256_rhs_w_19, sha256_rhs_w_3, sha256_rhs_w_7, sha256_round_constant, sha256_round_count, sha256_rounds_remaining, sha256_rounds_remaining_inv, sha256_s_0, sha256_s_1, sha256_sel, sha256_start, sha256_state_offset, sha256_w, sha256_w_15_rotr_18, sha256_w_15_rotr_7, sha256_w_15_rotr_7_xor_w_15_rotr_18, sha256_w_15_rshift_3, sha256_w_2_rotr_17, sha256_w_2_rotr_17_xor_w_2_rotr_19, sha256_w_2_rotr_19, sha256_w_2_rshift_10, sha256_w_s_0, sha256_w_s_1, sha256_xor_sel, to_radix_acc, to_radix_acc_under_p, to_radix_end, to_radix_exponent, to_radix_found, to_radix_is_unsafe_limb, to_radix_limb, to_radix_limb_eq_p, to_radix_limb_index, to_radix_limb_lt_p, to_radix_limb_p_diff, to_radix_limb_radix_diff, to_radix_not_end, to_radix_not_padding_limb, to_radix_p_limb, to_radix_radix, to_radix_rem_inverse, to_radix_safe_limbs, to_radix_safety_diff_inverse, to_radix_sel, to_radix_start, to_radix_value, lookup_poseidon2_hash_poseidon2_perm_counts, lookup_range_check_dyn_rng_chk_pow_2_counts, lookup_range_check_dyn_diff_is_u16_counts, lookup_range_check_r0_is_u16_counts, lookup_range_check_r1_is_u16_counts, lookup_range_check_r2_is_u16_counts, lookup_range_check_r3_is_u16_counts, lookup_range_check_r4_is_u16_counts, lookup_range_check_r5_is_u16_counts, lookup_range_check_r6_is_u16_counts, lookup_range_check_r7_is_u16_counts, lookup_to_radix_limb_range_counts, lookup_to_radix_limb_less_than_radix_range_counts, lookup_to_radix_fetch_safe_limbs_counts, lookup_to_radix_fetch_p_limb_counts, lookup_to_radix_limb_p_diff_range_counts, lookup_scalar_mul_to_radix_counts, lookup_scalar_mul_double_counts, lookup_scalar_mul_add_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_0_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_1_counts, lookup_address_derivation_partial_address_poseidon2_counts, lookup_address_derivation_public_keys_hash_poseidon2_0_counts, lookup_address_derivation_public_keys_hash_poseidon2_1_counts, lookup_address_derivation_public_keys_hash_poseidon2_2_counts, lookup_address_derivation_public_keys_hash_poseidon2_3_counts, lookup_address_derivation_public_keys_hash_poseidon2_4_counts, lookup_address_derivation_preaddress_poseidon2_counts, lookup_address_derivation_preaddress_scalar_mul_counts, lookup_address_derivation_address_ecadd_counts, lookup_bc_decomposition_bytes_are_bytes_counts, lookup_bc_decomposition_abs_diff_is_u16_counts, lookup_bc_decomposition_bytes_to_read_as_unary_counts, lookup_bc_hashing_get_packed_field_counts, lookup_bc_hashing_iv_is_len_counts, lookup_bc_hashing_poseidon2_hash_counts, lookup_bc_retrieval_class_id_derivation_counts, lookup_bc_retrieval_bytecode_hash_is_correct_counts, lookup_instr_fetching_abs_diff_positive_counts, lookup_instr_fetching_pc_abs_diff_positive_lo_counts, lookup_instr_fetching_pc_abs_diff_positive_hi_counts, lookup_instr_fetching_bytes_from_bc_dec_counts, lookup_instr_fetching_wire_instruction_info_counts, lookup_class_id_derivation_class_id_poseidon2_0_counts, lookup_class_id_derivation_class_id_poseidon2_1_counts, lookup_bitwise_integral_tag_length_counts, lookup_bitwise_byte_operations_counts, lookup_sha256_round_constant_counts +#define AVM2_WIRE_ENTITIES execution_input, address_derivation_address, address_derivation_address_y, address_derivation_class_id, address_derivation_deployer_addr, address_derivation_g1_x, address_derivation_g1_y, address_derivation_incoming_viewing_key_x, address_derivation_incoming_viewing_key_y, address_derivation_init_hash, address_derivation_nullifier_key_x, address_derivation_nullifier_key_y, address_derivation_outgoing_viewing_key_x, address_derivation_outgoing_viewing_key_y, address_derivation_partial_address, address_derivation_partial_address_domain_separator, address_derivation_preaddress, address_derivation_preaddress_domain_separator, address_derivation_preaddress_public_key_x, address_derivation_preaddress_public_key_y, address_derivation_public_keys_hash, address_derivation_public_keys_hash_domain_separator, address_derivation_salt, address_derivation_salted_init_hash, address_derivation_sel, address_derivation_tagging_key_x, address_derivation_tagging_key_y, alu_dst_addr, alu_ia, alu_ia_addr, alu_ib, alu_ib_addr, alu_ic, alu_op, alu_sel_op_add, bc_decomposition_abs_diff, bc_decomposition_bytes, bc_decomposition_bytes_pc_plus_1, bc_decomposition_bytes_pc_plus_10, bc_decomposition_bytes_pc_plus_11, bc_decomposition_bytes_pc_plus_12, bc_decomposition_bytes_pc_plus_13, bc_decomposition_bytes_pc_plus_14, bc_decomposition_bytes_pc_plus_15, bc_decomposition_bytes_pc_plus_16, bc_decomposition_bytes_pc_plus_17, bc_decomposition_bytes_pc_plus_18, bc_decomposition_bytes_pc_plus_19, bc_decomposition_bytes_pc_plus_2, bc_decomposition_bytes_pc_plus_20, bc_decomposition_bytes_pc_plus_21, bc_decomposition_bytes_pc_plus_22, bc_decomposition_bytes_pc_plus_23, bc_decomposition_bytes_pc_plus_24, bc_decomposition_bytes_pc_plus_25, bc_decomposition_bytes_pc_plus_26, bc_decomposition_bytes_pc_plus_27, bc_decomposition_bytes_pc_plus_28, bc_decomposition_bytes_pc_plus_29, bc_decomposition_bytes_pc_plus_3, bc_decomposition_bytes_pc_plus_30, bc_decomposition_bytes_pc_plus_31, bc_decomposition_bytes_pc_plus_32, bc_decomposition_bytes_pc_plus_33, bc_decomposition_bytes_pc_plus_34, bc_decomposition_bytes_pc_plus_35, bc_decomposition_bytes_pc_plus_36, bc_decomposition_bytes_pc_plus_4, bc_decomposition_bytes_pc_plus_5, bc_decomposition_bytes_pc_plus_6, bc_decomposition_bytes_pc_plus_7, bc_decomposition_bytes_pc_plus_8, bc_decomposition_bytes_pc_plus_9, bc_decomposition_bytes_rem_inv, bc_decomposition_bytes_rem_min_one_inv, bc_decomposition_bytes_remaining, bc_decomposition_bytes_to_read, bc_decomposition_bytes_to_read_unary, bc_decomposition_id, bc_decomposition_last_of_contract, bc_decomposition_packed_field, bc_decomposition_pc, bc_decomposition_sel, bc_decomposition_sel_overflow_correction_needed, bc_decomposition_sel_packed, bc_decomposition_sel_pc_plus_1, bc_decomposition_sel_pc_plus_10, bc_decomposition_sel_pc_plus_11, bc_decomposition_sel_pc_plus_12, bc_decomposition_sel_pc_plus_13, bc_decomposition_sel_pc_plus_14, bc_decomposition_sel_pc_plus_15, bc_decomposition_sel_pc_plus_16, bc_decomposition_sel_pc_plus_17, bc_decomposition_sel_pc_plus_18, bc_decomposition_sel_pc_plus_19, bc_decomposition_sel_pc_plus_2, bc_decomposition_sel_pc_plus_20, bc_decomposition_sel_pc_plus_21, bc_decomposition_sel_pc_plus_22, bc_decomposition_sel_pc_plus_23, bc_decomposition_sel_pc_plus_24, bc_decomposition_sel_pc_plus_25, bc_decomposition_sel_pc_plus_26, bc_decomposition_sel_pc_plus_27, bc_decomposition_sel_pc_plus_28, bc_decomposition_sel_pc_plus_29, bc_decomposition_sel_pc_plus_3, bc_decomposition_sel_pc_plus_30, bc_decomposition_sel_pc_plus_31, bc_decomposition_sel_pc_plus_32, bc_decomposition_sel_pc_plus_33, bc_decomposition_sel_pc_plus_34, bc_decomposition_sel_pc_plus_35, bc_decomposition_sel_pc_plus_36, bc_decomposition_sel_pc_plus_4, bc_decomposition_sel_pc_plus_5, bc_decomposition_sel_pc_plus_6, bc_decomposition_sel_pc_plus_7, bc_decomposition_sel_pc_plus_8, bc_decomposition_sel_pc_plus_9, bc_hashing_bytecode_id, bc_hashing_incremental_hash, bc_hashing_latch, bc_hashing_output_hash, bc_hashing_packed_field, bc_hashing_pc_index, bc_hashing_sel, bc_hashing_start, bc_retrieval_address, bc_retrieval_artifact_hash, bc_retrieval_bytecode_id, bc_retrieval_class_id, bc_retrieval_deployer_addr, bc_retrieval_err, bc_retrieval_incoming_viewing_key_x, bc_retrieval_incoming_viewing_key_y, bc_retrieval_init_hash, bc_retrieval_nullifier_key_x, bc_retrieval_nullifier_key_y, bc_retrieval_outgoing_viewing_key_x, bc_retrieval_outgoing_viewing_key_y, bc_retrieval_private_function_root, bc_retrieval_public_bytecode_commitment, bc_retrieval_salt, bc_retrieval_sel, bc_retrieval_siloed_address, bc_retrieval_tagging_key_x, bc_retrieval_tagging_key_y, bitwise_acc_ia, bitwise_acc_ib, bitwise_acc_ic, bitwise_ctr, bitwise_ctr_inv, bitwise_ctr_min_one_inv, bitwise_ia_byte, bitwise_ib_byte, bitwise_ic_byte, bitwise_last, bitwise_op_id, bitwise_sel, bitwise_start, bitwise_tag, class_id_derivation_artifact_hash, class_id_derivation_class_id, class_id_derivation_private_function_root, class_id_derivation_public_bytecode_commitment, class_id_derivation_sel, class_id_derivation_temp_constant_for_lookup, ecc_add_op, ecc_double_op, ecc_inv_2_p_y, ecc_inv_x_diff, ecc_inv_y_diff, ecc_lambda, ecc_p_is_inf, ecc_p_x, ecc_p_y, ecc_q_is_inf, ecc_q_x, ecc_q_y, ecc_r_is_inf, ecc_r_x, ecc_r_y, ecc_result_infinity, ecc_sel, ecc_x_match, ecc_y_match, execution_addressing_error_idx, execution_addressing_error_kind, execution_base_address_tag, execution_base_address_val, execution_bytecode_id, execution_clk, execution_ex_opcode, execution_indirect, execution_last, execution_op1, execution_op1_after_relative, execution_op2, execution_op2_after_relative, execution_op3, execution_op3_after_relative, execution_op4, execution_op4_after_relative, execution_pc, execution_rop1, execution_rop2, execution_rop3, execution_rop4, execution_sel, execution_sel_addressing_error, execution_sel_op1_is_address, execution_sel_op2_is_address, execution_sel_op3_is_address, execution_sel_op4_is_address, instr_fetching_bc_id_diff_inv, instr_fetching_bd0, instr_fetching_bd1, instr_fetching_bd10, instr_fetching_bd11, instr_fetching_bd12, instr_fetching_bd13, instr_fetching_bd14, instr_fetching_bd15, instr_fetching_bd16, instr_fetching_bd17, instr_fetching_bd18, instr_fetching_bd19, instr_fetching_bd2, instr_fetching_bd20, instr_fetching_bd21, instr_fetching_bd22, instr_fetching_bd23, instr_fetching_bd24, instr_fetching_bd25, instr_fetching_bd26, instr_fetching_bd27, instr_fetching_bd28, instr_fetching_bd29, instr_fetching_bd3, instr_fetching_bd30, instr_fetching_bd31, instr_fetching_bd32, instr_fetching_bd33, instr_fetching_bd34, instr_fetching_bd35, instr_fetching_bd36, instr_fetching_bd4, instr_fetching_bd5, instr_fetching_bd6, instr_fetching_bd7, instr_fetching_bd8, instr_fetching_bd9, instr_fetching_bytecode_id, instr_fetching_bytecode_size, instr_fetching_bytes_remaining, instr_fetching_bytes_to_read, instr_fetching_exec_opcode, instr_fetching_indirect, instr_fetching_instr_abs_diff, instr_fetching_instr_out_of_range, instr_fetching_instr_size, instr_fetching_last_of_bytecode, instr_fetching_op1, instr_fetching_op2, instr_fetching_op3, instr_fetching_op4, instr_fetching_op5, instr_fetching_op6, instr_fetching_op7, instr_fetching_opcode_out_of_range, instr_fetching_parsing_err, instr_fetching_pc, instr_fetching_pc_abs_diff, instr_fetching_pc_abs_diff_hi, instr_fetching_pc_abs_diff_lo, instr_fetching_pc_out_of_range, instr_fetching_sel, instr_fetching_sel_lookup_bc_decomposition, instr_fetching_sel_op_dc_0, instr_fetching_sel_op_dc_1, instr_fetching_sel_op_dc_10, instr_fetching_sel_op_dc_11, instr_fetching_sel_op_dc_12, instr_fetching_sel_op_dc_13, instr_fetching_sel_op_dc_14, instr_fetching_sel_op_dc_15, instr_fetching_sel_op_dc_16, instr_fetching_sel_op_dc_17, instr_fetching_sel_op_dc_2, instr_fetching_sel_op_dc_3, instr_fetching_sel_op_dc_4, instr_fetching_sel_op_dc_5, instr_fetching_sel_op_dc_6, instr_fetching_sel_op_dc_7, instr_fetching_sel_op_dc_8, instr_fetching_sel_op_dc_9, poseidon2_hash_a_0, poseidon2_hash_a_1, poseidon2_hash_a_2, poseidon2_hash_a_3, poseidon2_hash_b_0, poseidon2_hash_b_1, poseidon2_hash_b_2, poseidon2_hash_b_3, poseidon2_hash_end, poseidon2_hash_input_0, poseidon2_hash_input_1, poseidon2_hash_input_2, poseidon2_hash_input_len, poseidon2_hash_num_perm_rounds_rem, poseidon2_hash_num_perm_rounds_rem_inv, poseidon2_hash_output, poseidon2_hash_padding, poseidon2_hash_sel, poseidon2_hash_start, poseidon2_perm_B_10_0, poseidon2_perm_B_10_1, poseidon2_perm_B_10_2, poseidon2_perm_B_10_3, poseidon2_perm_B_11_0, poseidon2_perm_B_11_1, poseidon2_perm_B_11_2, poseidon2_perm_B_11_3, poseidon2_perm_B_12_0, poseidon2_perm_B_12_1, poseidon2_perm_B_12_2, poseidon2_perm_B_12_3, poseidon2_perm_B_13_0, poseidon2_perm_B_13_1, poseidon2_perm_B_13_2, poseidon2_perm_B_13_3, poseidon2_perm_B_14_0, poseidon2_perm_B_14_1, poseidon2_perm_B_14_2, poseidon2_perm_B_14_3, poseidon2_perm_B_15_0, poseidon2_perm_B_15_1, poseidon2_perm_B_15_2, poseidon2_perm_B_15_3, poseidon2_perm_B_16_0, poseidon2_perm_B_16_1, poseidon2_perm_B_16_2, poseidon2_perm_B_16_3, poseidon2_perm_B_17_0, poseidon2_perm_B_17_1, poseidon2_perm_B_17_2, poseidon2_perm_B_17_3, poseidon2_perm_B_18_0, poseidon2_perm_B_18_1, poseidon2_perm_B_18_2, poseidon2_perm_B_18_3, poseidon2_perm_B_19_0, poseidon2_perm_B_19_1, poseidon2_perm_B_19_2, poseidon2_perm_B_19_3, poseidon2_perm_B_20_0, poseidon2_perm_B_20_1, poseidon2_perm_B_20_2, poseidon2_perm_B_20_3, poseidon2_perm_B_21_0, poseidon2_perm_B_21_1, poseidon2_perm_B_21_2, poseidon2_perm_B_21_3, poseidon2_perm_B_22_0, poseidon2_perm_B_22_1, poseidon2_perm_B_22_2, poseidon2_perm_B_22_3, poseidon2_perm_B_23_0, poseidon2_perm_B_23_1, poseidon2_perm_B_23_2, poseidon2_perm_B_23_3, poseidon2_perm_B_24_0, poseidon2_perm_B_24_1, poseidon2_perm_B_24_2, poseidon2_perm_B_24_3, poseidon2_perm_B_25_0, poseidon2_perm_B_25_1, poseidon2_perm_B_25_2, poseidon2_perm_B_25_3, poseidon2_perm_B_26_0, poseidon2_perm_B_26_1, poseidon2_perm_B_26_2, poseidon2_perm_B_26_3, poseidon2_perm_B_27_0, poseidon2_perm_B_27_1, poseidon2_perm_B_27_2, poseidon2_perm_B_27_3, poseidon2_perm_B_28_0, poseidon2_perm_B_28_1, poseidon2_perm_B_28_2, poseidon2_perm_B_28_3, poseidon2_perm_B_29_0, poseidon2_perm_B_29_1, poseidon2_perm_B_29_2, poseidon2_perm_B_29_3, poseidon2_perm_B_30_0, poseidon2_perm_B_30_1, poseidon2_perm_B_30_2, poseidon2_perm_B_30_3, poseidon2_perm_B_31_0, poseidon2_perm_B_31_1, poseidon2_perm_B_31_2, poseidon2_perm_B_31_3, poseidon2_perm_B_32_0, poseidon2_perm_B_32_1, poseidon2_perm_B_32_2, poseidon2_perm_B_32_3, poseidon2_perm_B_33_0, poseidon2_perm_B_33_1, poseidon2_perm_B_33_2, poseidon2_perm_B_33_3, poseidon2_perm_B_34_0, poseidon2_perm_B_34_1, poseidon2_perm_B_34_2, poseidon2_perm_B_34_3, poseidon2_perm_B_35_0, poseidon2_perm_B_35_1, poseidon2_perm_B_35_2, poseidon2_perm_B_35_3, poseidon2_perm_B_36_0, poseidon2_perm_B_36_1, poseidon2_perm_B_36_2, poseidon2_perm_B_36_3, poseidon2_perm_B_37_0, poseidon2_perm_B_37_1, poseidon2_perm_B_37_2, poseidon2_perm_B_37_3, poseidon2_perm_B_38_0, poseidon2_perm_B_38_1, poseidon2_perm_B_38_2, poseidon2_perm_B_38_3, poseidon2_perm_B_39_0, poseidon2_perm_B_39_1, poseidon2_perm_B_39_2, poseidon2_perm_B_39_3, poseidon2_perm_B_40_0, poseidon2_perm_B_40_1, poseidon2_perm_B_40_2, poseidon2_perm_B_40_3, poseidon2_perm_B_41_0, poseidon2_perm_B_41_1, poseidon2_perm_B_41_2, poseidon2_perm_B_41_3, poseidon2_perm_B_42_0, poseidon2_perm_B_42_1, poseidon2_perm_B_42_2, poseidon2_perm_B_42_3, poseidon2_perm_B_43_0, poseidon2_perm_B_43_1, poseidon2_perm_B_43_2, poseidon2_perm_B_43_3, poseidon2_perm_B_44_0, poseidon2_perm_B_44_1, poseidon2_perm_B_44_2, poseidon2_perm_B_44_3, poseidon2_perm_B_45_0, poseidon2_perm_B_45_1, poseidon2_perm_B_45_2, poseidon2_perm_B_45_3, poseidon2_perm_B_46_0, poseidon2_perm_B_46_1, poseidon2_perm_B_46_2, poseidon2_perm_B_46_3, poseidon2_perm_B_47_0, poseidon2_perm_B_47_1, poseidon2_perm_B_47_2, poseidon2_perm_B_47_3, poseidon2_perm_B_48_0, poseidon2_perm_B_48_1, poseidon2_perm_B_48_2, poseidon2_perm_B_48_3, poseidon2_perm_B_49_0, poseidon2_perm_B_49_1, poseidon2_perm_B_49_2, poseidon2_perm_B_49_3, poseidon2_perm_B_4_0, poseidon2_perm_B_4_1, poseidon2_perm_B_4_2, poseidon2_perm_B_4_3, poseidon2_perm_B_50_0, poseidon2_perm_B_50_1, poseidon2_perm_B_50_2, poseidon2_perm_B_50_3, poseidon2_perm_B_51_0, poseidon2_perm_B_51_1, poseidon2_perm_B_51_2, poseidon2_perm_B_51_3, poseidon2_perm_B_52_0, poseidon2_perm_B_52_1, poseidon2_perm_B_52_2, poseidon2_perm_B_52_3, poseidon2_perm_B_53_0, poseidon2_perm_B_53_1, poseidon2_perm_B_53_2, poseidon2_perm_B_53_3, poseidon2_perm_B_54_0, poseidon2_perm_B_54_1, poseidon2_perm_B_54_2, poseidon2_perm_B_54_3, poseidon2_perm_B_55_0, poseidon2_perm_B_55_1, poseidon2_perm_B_55_2, poseidon2_perm_B_55_3, poseidon2_perm_B_56_0, poseidon2_perm_B_56_1, poseidon2_perm_B_56_2, poseidon2_perm_B_56_3, poseidon2_perm_B_57_0, poseidon2_perm_B_57_1, poseidon2_perm_B_57_2, poseidon2_perm_B_57_3, poseidon2_perm_B_58_0, poseidon2_perm_B_58_1, poseidon2_perm_B_58_2, poseidon2_perm_B_58_3, poseidon2_perm_B_59_0, poseidon2_perm_B_59_1, poseidon2_perm_B_59_2, poseidon2_perm_B_59_3, poseidon2_perm_B_5_0, poseidon2_perm_B_5_1, poseidon2_perm_B_5_2, poseidon2_perm_B_5_3, poseidon2_perm_B_6_0, poseidon2_perm_B_6_1, poseidon2_perm_B_6_2, poseidon2_perm_B_6_3, poseidon2_perm_B_7_0, poseidon2_perm_B_7_1, poseidon2_perm_B_7_2, poseidon2_perm_B_7_3, poseidon2_perm_B_8_0, poseidon2_perm_B_8_1, poseidon2_perm_B_8_2, poseidon2_perm_B_8_3, poseidon2_perm_B_9_0, poseidon2_perm_B_9_1, poseidon2_perm_B_9_2, poseidon2_perm_B_9_3, poseidon2_perm_EXT_LAYER_4, poseidon2_perm_EXT_LAYER_5, poseidon2_perm_EXT_LAYER_6, poseidon2_perm_EXT_LAYER_7, poseidon2_perm_T_0_4, poseidon2_perm_T_0_5, poseidon2_perm_T_0_6, poseidon2_perm_T_0_7, poseidon2_perm_T_1_4, poseidon2_perm_T_1_5, poseidon2_perm_T_1_6, poseidon2_perm_T_1_7, poseidon2_perm_T_2_4, poseidon2_perm_T_2_5, poseidon2_perm_T_2_6, poseidon2_perm_T_2_7, poseidon2_perm_T_3_4, poseidon2_perm_T_3_5, poseidon2_perm_T_3_6, poseidon2_perm_T_3_7, poseidon2_perm_T_60_4, poseidon2_perm_T_60_5, poseidon2_perm_T_60_6, poseidon2_perm_T_60_7, poseidon2_perm_T_61_4, poseidon2_perm_T_61_5, poseidon2_perm_T_61_6, poseidon2_perm_T_61_7, poseidon2_perm_T_62_4, poseidon2_perm_T_62_5, poseidon2_perm_T_62_6, poseidon2_perm_T_62_7, poseidon2_perm_T_63_4, poseidon2_perm_T_63_5, poseidon2_perm_T_63_6, poseidon2_perm_T_63_7, poseidon2_perm_a_0, poseidon2_perm_a_1, poseidon2_perm_a_2, poseidon2_perm_a_3, poseidon2_perm_b_0, poseidon2_perm_b_1, poseidon2_perm_b_2, poseidon2_perm_b_3, poseidon2_perm_sel, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_rng_chk_bits, range_check_sel, range_check_sel_r0_16_bit_rng_lookup, range_check_sel_r1_16_bit_rng_lookup, range_check_sel_r2_16_bit_rng_lookup, range_check_sel_r3_16_bit_rng_lookup, range_check_sel_r4_16_bit_rng_lookup, range_check_sel_r5_16_bit_rng_lookup, range_check_sel_r6_16_bit_rng_lookup, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, scalar_mul_bit, scalar_mul_bit_idx, scalar_mul_bit_radix, scalar_mul_end, scalar_mul_not_end, scalar_mul_point_inf, scalar_mul_point_x, scalar_mul_point_y, scalar_mul_res_inf, scalar_mul_res_x, scalar_mul_res_y, scalar_mul_scalar, scalar_mul_sel, scalar_mul_should_add, scalar_mul_start, scalar_mul_temp_inf, scalar_mul_temp_x, scalar_mul_temp_y, sha256_a, sha256_a_and_b, sha256_a_and_b_xor_a_and_c, sha256_a_and_c, sha256_a_rotr_13, sha256_a_rotr_2, sha256_a_rotr_22, sha256_a_rotr_2_xor_a_rotr_13, sha256_and_sel, sha256_b, sha256_b_and_c, sha256_c, sha256_ch, sha256_clk, sha256_computed_w_lhs, sha256_computed_w_rhs, sha256_d, sha256_e, sha256_e_and_f, sha256_e_rotr_11, sha256_e_rotr_25, sha256_e_rotr_6, sha256_e_rotr_6_xor_e_rotr_11, sha256_f, sha256_g, sha256_h, sha256_helper_w0, sha256_helper_w1, sha256_helper_w10, sha256_helper_w11, sha256_helper_w12, sha256_helper_w13, sha256_helper_w14, sha256_helper_w15, sha256_helper_w2, sha256_helper_w3, sha256_helper_w4, sha256_helper_w5, sha256_helper_w6, sha256_helper_w7, sha256_helper_w8, sha256_helper_w9, sha256_init_a, sha256_init_b, sha256_init_c, sha256_init_d, sha256_init_e, sha256_init_f, sha256_init_g, sha256_init_h, sha256_input_offset, sha256_is_input_round, sha256_latch, sha256_lhs_a_13, sha256_lhs_a_2, sha256_lhs_a_22, sha256_lhs_e_11, sha256_lhs_e_25, sha256_lhs_e_6, sha256_lhs_w_10, sha256_lhs_w_17, sha256_lhs_w_18, sha256_lhs_w_19, sha256_lhs_w_3, sha256_lhs_w_7, sha256_maj, sha256_next_a_lhs, sha256_next_a_rhs, sha256_next_e_lhs, sha256_next_e_rhs, sha256_not_e, sha256_not_e_and_g, sha256_output_a_lhs, sha256_output_a_rhs, sha256_output_b_lhs, sha256_output_b_rhs, sha256_output_c_lhs, sha256_output_c_rhs, sha256_output_d_lhs, sha256_output_d_rhs, sha256_output_e_lhs, sha256_output_e_rhs, sha256_output_f_lhs, sha256_output_f_rhs, sha256_output_g_lhs, sha256_output_g_rhs, sha256_output_h_lhs, sha256_output_h_rhs, sha256_output_offset, sha256_perform_round, sha256_rhs_a_13, sha256_rhs_a_2, sha256_rhs_a_22, sha256_rhs_e_11, sha256_rhs_e_25, sha256_rhs_e_6, sha256_rhs_w_10, sha256_rhs_w_17, sha256_rhs_w_18, sha256_rhs_w_19, sha256_rhs_w_3, sha256_rhs_w_7, sha256_round_constant, sha256_round_count, sha256_rounds_remaining, sha256_rounds_remaining_inv, sha256_s_0, sha256_s_1, sha256_sel, sha256_start, sha256_state_offset, sha256_w, sha256_w_15_rotr_18, sha256_w_15_rotr_7, sha256_w_15_rotr_7_xor_w_15_rotr_18, sha256_w_15_rshift_3, sha256_w_2_rotr_17, sha256_w_2_rotr_17_xor_w_2_rotr_19, sha256_w_2_rotr_19, sha256_w_2_rshift_10, sha256_w_s_0, sha256_w_s_1, sha256_xor_sel, to_radix_acc, to_radix_acc_under_p, to_radix_end, to_radix_exponent, to_radix_found, to_radix_is_unsafe_limb, to_radix_limb, to_radix_limb_eq_p, to_radix_limb_index, to_radix_limb_lt_p, to_radix_limb_p_diff, to_radix_limb_radix_diff, to_radix_not_end, to_radix_not_padding_limb, to_radix_p_limb, to_radix_radix, to_radix_rem_inverse, to_radix_safe_limbs, to_radix_safety_diff_inverse, to_radix_sel, to_radix_start, to_radix_value, lookup_poseidon2_hash_poseidon2_perm_counts, lookup_range_check_dyn_rng_chk_pow_2_counts, lookup_range_check_dyn_diff_is_u16_counts, lookup_range_check_r0_is_u16_counts, lookup_range_check_r1_is_u16_counts, lookup_range_check_r2_is_u16_counts, lookup_range_check_r3_is_u16_counts, lookup_range_check_r4_is_u16_counts, lookup_range_check_r5_is_u16_counts, lookup_range_check_r6_is_u16_counts, lookup_range_check_r7_is_u16_counts, lookup_to_radix_limb_range_counts, lookup_to_radix_limb_less_than_radix_range_counts, lookup_to_radix_fetch_safe_limbs_counts, lookup_to_radix_fetch_p_limb_counts, lookup_to_radix_limb_p_diff_range_counts, lookup_scalar_mul_to_radix_counts, lookup_scalar_mul_double_counts, lookup_scalar_mul_add_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_0_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_1_counts, lookup_address_derivation_partial_address_poseidon2_counts, lookup_address_derivation_public_keys_hash_poseidon2_0_counts, lookup_address_derivation_public_keys_hash_poseidon2_1_counts, lookup_address_derivation_public_keys_hash_poseidon2_2_counts, lookup_address_derivation_public_keys_hash_poseidon2_3_counts, lookup_address_derivation_public_keys_hash_poseidon2_4_counts, lookup_address_derivation_preaddress_poseidon2_counts, lookup_address_derivation_preaddress_scalar_mul_counts, lookup_address_derivation_address_ecadd_counts, lookup_bc_decomposition_bytes_are_bytes_counts, lookup_bc_decomposition_abs_diff_is_u16_counts, lookup_bc_decomposition_bytes_to_read_as_unary_counts, lookup_bc_hashing_get_packed_field_counts, lookup_bc_hashing_iv_is_len_counts, lookup_bc_hashing_poseidon2_hash_counts, lookup_bc_retrieval_class_id_derivation_counts, lookup_bc_retrieval_bytecode_hash_is_correct_counts, lookup_instr_fetching_abs_diff_positive_counts, lookup_instr_fetching_pc_abs_diff_positive_lo_counts, lookup_instr_fetching_pc_abs_diff_positive_hi_counts, lookup_instr_fetching_bytes_from_bc_dec_counts, lookup_instr_fetching_wire_instruction_info_counts, lookup_class_id_derivation_class_id_poseidon2_0_counts, lookup_class_id_derivation_class_id_poseidon2_1_counts, lookup_bitwise_integral_tag_length_counts, lookup_bitwise_byte_operations_counts, lookup_sha256_round_constant_counts #define AVM2_DERIVED_WITNESS_ENTITIES lookup_poseidon2_hash_poseidon2_perm_inv, lookup_range_check_dyn_rng_chk_pow_2_inv, lookup_range_check_dyn_diff_is_u16_inv, lookup_range_check_r0_is_u16_inv, lookup_range_check_r1_is_u16_inv, lookup_range_check_r2_is_u16_inv, lookup_range_check_r3_is_u16_inv, lookup_range_check_r4_is_u16_inv, lookup_range_check_r5_is_u16_inv, lookup_range_check_r6_is_u16_inv, lookup_range_check_r7_is_u16_inv, lookup_to_radix_limb_range_inv, lookup_to_radix_limb_less_than_radix_range_inv, lookup_to_radix_fetch_safe_limbs_inv, lookup_to_radix_fetch_p_limb_inv, lookup_to_radix_limb_p_diff_range_inv, lookup_scalar_mul_to_radix_inv, lookup_scalar_mul_double_inv, lookup_scalar_mul_add_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_0_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_1_inv, lookup_address_derivation_partial_address_poseidon2_inv, lookup_address_derivation_public_keys_hash_poseidon2_0_inv, lookup_address_derivation_public_keys_hash_poseidon2_1_inv, lookup_address_derivation_public_keys_hash_poseidon2_2_inv, lookup_address_derivation_public_keys_hash_poseidon2_3_inv, lookup_address_derivation_public_keys_hash_poseidon2_4_inv, lookup_address_derivation_preaddress_poseidon2_inv, lookup_address_derivation_preaddress_scalar_mul_inv, lookup_address_derivation_address_ecadd_inv, lookup_bc_decomposition_bytes_are_bytes_inv, lookup_bc_decomposition_abs_diff_is_u16_inv, lookup_bc_decomposition_bytes_to_read_as_unary_inv, lookup_bc_hashing_get_packed_field_inv, lookup_bc_hashing_iv_is_len_inv, lookup_bc_hashing_poseidon2_hash_inv, lookup_bc_retrieval_class_id_derivation_inv, lookup_bc_retrieval_bytecode_hash_is_correct_inv, lookup_instr_fetching_abs_diff_positive_inv, lookup_instr_fetching_pc_abs_diff_positive_lo_inv, lookup_instr_fetching_pc_abs_diff_positive_hi_inv, lookup_instr_fetching_bytes_from_bc_dec_inv, lookup_instr_fetching_wire_instruction_info_inv, lookup_class_id_derivation_class_id_poseidon2_0_inv, lookup_class_id_derivation_class_id_poseidon2_1_inv, lookup_bitwise_integral_tag_length_inv, lookup_bitwise_byte_operations_inv, lookup_sha256_round_constant_inv #define AVM2_SHIFTED_ENTITIES bc_decomposition_bytes_shift, bc_decomposition_bytes_pc_plus_1_shift, bc_decomposition_bytes_pc_plus_10_shift, bc_decomposition_bytes_pc_plus_11_shift, bc_decomposition_bytes_pc_plus_12_shift, bc_decomposition_bytes_pc_plus_13_shift, bc_decomposition_bytes_pc_plus_14_shift, bc_decomposition_bytes_pc_plus_15_shift, bc_decomposition_bytes_pc_plus_16_shift, bc_decomposition_bytes_pc_plus_17_shift, bc_decomposition_bytes_pc_plus_18_shift, bc_decomposition_bytes_pc_plus_19_shift, bc_decomposition_bytes_pc_plus_2_shift, bc_decomposition_bytes_pc_plus_20_shift, bc_decomposition_bytes_pc_plus_21_shift, bc_decomposition_bytes_pc_plus_22_shift, bc_decomposition_bytes_pc_plus_23_shift, bc_decomposition_bytes_pc_plus_24_shift, bc_decomposition_bytes_pc_plus_25_shift, bc_decomposition_bytes_pc_plus_26_shift, bc_decomposition_bytes_pc_plus_27_shift, bc_decomposition_bytes_pc_plus_28_shift, bc_decomposition_bytes_pc_plus_29_shift, bc_decomposition_bytes_pc_plus_3_shift, bc_decomposition_bytes_pc_plus_30_shift, bc_decomposition_bytes_pc_plus_31_shift, bc_decomposition_bytes_pc_plus_32_shift, bc_decomposition_bytes_pc_plus_33_shift, bc_decomposition_bytes_pc_plus_34_shift, bc_decomposition_bytes_pc_plus_35_shift, bc_decomposition_bytes_pc_plus_4_shift, bc_decomposition_bytes_pc_plus_5_shift, bc_decomposition_bytes_pc_plus_6_shift, bc_decomposition_bytes_pc_plus_7_shift, bc_decomposition_bytes_pc_plus_8_shift, bc_decomposition_bytes_pc_plus_9_shift, bc_decomposition_bytes_remaining_shift, bc_decomposition_id_shift, bc_decomposition_pc_shift, bc_decomposition_sel_shift, bc_hashing_bytecode_id_shift, bc_hashing_incremental_hash_shift, bc_hashing_pc_index_shift, bc_hashing_sel_shift, bc_hashing_start_shift, bitwise_acc_ia_shift, bitwise_acc_ib_shift, bitwise_acc_ic_shift, bitwise_ctr_shift, bitwise_op_id_shift, execution_sel_shift, instr_fetching_bytecode_id_shift, instr_fetching_bytecode_size_shift, instr_fetching_bytes_remaining_shift, instr_fetching_pc_shift, instr_fetching_sel_shift, poseidon2_hash_a_0_shift, poseidon2_hash_a_1_shift, poseidon2_hash_a_2_shift, poseidon2_hash_a_3_shift, poseidon2_hash_input_0_shift, poseidon2_hash_input_1_shift, poseidon2_hash_input_2_shift, poseidon2_hash_num_perm_rounds_rem_shift, poseidon2_hash_output_shift, poseidon2_hash_sel_shift, poseidon2_hash_start_shift, scalar_mul_bit_idx_shift, scalar_mul_point_inf_shift, scalar_mul_point_x_shift, scalar_mul_point_y_shift, scalar_mul_res_inf_shift, scalar_mul_res_x_shift, scalar_mul_res_y_shift, scalar_mul_scalar_shift, scalar_mul_sel_shift, scalar_mul_start_shift, scalar_mul_temp_inf_shift, scalar_mul_temp_x_shift, scalar_mul_temp_y_shift, sha256_a_shift, sha256_b_shift, sha256_c_shift, sha256_d_shift, sha256_e_shift, sha256_f_shift, sha256_g_shift, sha256_h_shift, sha256_helper_w0_shift, sha256_helper_w1_shift, sha256_helper_w10_shift, sha256_helper_w11_shift, sha256_helper_w12_shift, sha256_helper_w13_shift, sha256_helper_w14_shift, sha256_helper_w15_shift, sha256_helper_w2_shift, sha256_helper_w3_shift, sha256_helper_w4_shift, sha256_helper_w5_shift, sha256_helper_w6_shift, sha256_helper_w7_shift, sha256_helper_w8_shift, sha256_helper_w9_shift, sha256_rounds_remaining_shift, sha256_sel_shift, sha256_start_shift, to_radix_acc_shift, to_radix_acc_under_p_shift, to_radix_exponent_shift, to_radix_limb_shift, to_radix_limb_eq_p_shift, to_radix_limb_index_shift, to_radix_limb_lt_p_shift, to_radix_not_padding_limb_shift, to_radix_radix_shift, to_radix_safe_limbs_shift, to_radix_sel_shift, to_radix_start_shift, to_radix_value_shift #define AVM2_TO_BE_SHIFTED(e) e.bc_decomposition_bytes, e.bc_decomposition_bytes_pc_plus_1, e.bc_decomposition_bytes_pc_plus_10, e.bc_decomposition_bytes_pc_plus_11, e.bc_decomposition_bytes_pc_plus_12, e.bc_decomposition_bytes_pc_plus_13, e.bc_decomposition_bytes_pc_plus_14, e.bc_decomposition_bytes_pc_plus_15, e.bc_decomposition_bytes_pc_plus_16, e.bc_decomposition_bytes_pc_plus_17, e.bc_decomposition_bytes_pc_plus_18, e.bc_decomposition_bytes_pc_plus_19, e.bc_decomposition_bytes_pc_plus_2, e.bc_decomposition_bytes_pc_plus_20, e.bc_decomposition_bytes_pc_plus_21, e.bc_decomposition_bytes_pc_plus_22, e.bc_decomposition_bytes_pc_plus_23, e.bc_decomposition_bytes_pc_plus_24, e.bc_decomposition_bytes_pc_plus_25, e.bc_decomposition_bytes_pc_plus_26, e.bc_decomposition_bytes_pc_plus_27, e.bc_decomposition_bytes_pc_plus_28, e.bc_decomposition_bytes_pc_plus_29, e.bc_decomposition_bytes_pc_plus_3, e.bc_decomposition_bytes_pc_plus_30, e.bc_decomposition_bytes_pc_plus_31, e.bc_decomposition_bytes_pc_plus_32, e.bc_decomposition_bytes_pc_plus_33, e.bc_decomposition_bytes_pc_plus_34, e.bc_decomposition_bytes_pc_plus_35, e.bc_decomposition_bytes_pc_plus_4, e.bc_decomposition_bytes_pc_plus_5, e.bc_decomposition_bytes_pc_plus_6, e.bc_decomposition_bytes_pc_plus_7, e.bc_decomposition_bytes_pc_plus_8, e.bc_decomposition_bytes_pc_plus_9, e.bc_decomposition_bytes_remaining, e.bc_decomposition_id, e.bc_decomposition_pc, e.bc_decomposition_sel, e.bc_hashing_bytecode_id, e.bc_hashing_incremental_hash, e.bc_hashing_pc_index, e.bc_hashing_sel, e.bc_hashing_start, e.bitwise_acc_ia, e.bitwise_acc_ib, e.bitwise_acc_ic, e.bitwise_ctr, e.bitwise_op_id, e.execution_sel, e.instr_fetching_bytecode_id, e.instr_fetching_bytecode_size, e.instr_fetching_bytes_remaining, e.instr_fetching_pc, e.instr_fetching_sel, e.poseidon2_hash_a_0, e.poseidon2_hash_a_1, e.poseidon2_hash_a_2, e.poseidon2_hash_a_3, e.poseidon2_hash_input_0, e.poseidon2_hash_input_1, e.poseidon2_hash_input_2, e.poseidon2_hash_num_perm_rounds_rem, e.poseidon2_hash_output, e.poseidon2_hash_sel, e.poseidon2_hash_start, e.scalar_mul_bit_idx, e.scalar_mul_point_inf, e.scalar_mul_point_x, e.scalar_mul_point_y, e.scalar_mul_res_inf, e.scalar_mul_res_x, e.scalar_mul_res_y, e.scalar_mul_scalar, e.scalar_mul_sel, e.scalar_mul_start, e.scalar_mul_temp_inf, e.scalar_mul_temp_x, e.scalar_mul_temp_y, e.sha256_a, e.sha256_b, e.sha256_c, e.sha256_d, e.sha256_e, e.sha256_f, e.sha256_g, e.sha256_h, e.sha256_helper_w0, e.sha256_helper_w1, e.sha256_helper_w10, e.sha256_helper_w11, e.sha256_helper_w12, e.sha256_helper_w13, e.sha256_helper_w14, e.sha256_helper_w15, e.sha256_helper_w2, e.sha256_helper_w3, e.sha256_helper_w4, e.sha256_helper_w5, e.sha256_helper_w6, e.sha256_helper_w7, e.sha256_helper_w8, e.sha256_helper_w9, e.sha256_rounds_remaining, e.sha256_sel, e.sha256_start, e.to_radix_acc, e.to_radix_acc_under_p, e.to_radix_exponent, e.to_radix_limb, e.to_radix_limb_eq_p, e.to_radix_limb_index, e.to_radix_limb_lt_p, e.to_radix_not_padding_limb, e.to_radix_radix, e.to_radix_safe_limbs, e.to_radix_sel, e.to_radix_start, e.to_radix_value diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp index 3e5837e77894..3f20ba250258 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp @@ -107,7 +107,7 @@ template class instr_fetchingImpl { } { using Accumulator = typename std::tuple_element_t<10, ContainerOverSubrelations>; - auto tmp = (new_term.instr_fetching_abs_diff - + auto tmp = (new_term.instr_fetching_instr_abs_diff - ((FF(2) * new_term.instr_fetching_instr_out_of_range - FF(1)) * (new_term.instr_fetching_instr_size - new_term.instr_fetching_bytes_to_read) - new_term.instr_fetching_instr_out_of_range)); diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_instr_fetching.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_instr_fetching.hpp index aea56ae90532..404a3f7fa7fa 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_instr_fetching.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_instr_fetching.hpp @@ -32,7 +32,7 @@ class lookup_instr_fetching_abs_diff_positive_settings { static constexpr Column COUNTS = Column::lookup_instr_fetching_abs_diff_positive_counts; static constexpr Column INVERSES = Column::lookup_instr_fetching_abs_diff_positive_inv; static constexpr std::array SRC_COLUMNS = { - ColumnAndShifts::instr_fetching_abs_diff + ColumnAndShifts::instr_fetching_instr_abs_diff }; static constexpr std::array DST_COLUMNS = { ColumnAndShifts::precomputed_clk }; @@ -66,7 +66,7 @@ class lookup_instr_fetching_abs_diff_positive_settings { in._lookup_instr_fetching_abs_diff_positive_counts(), in._instr_fetching_sel(), in._precomputed_sel_range_8(), - in._instr_fetching_abs_diff(), + in._instr_fetching_instr_abs_diff(), in._precomputed_clk()); } }; diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp index 5382bde74276..0c257e9e49fd 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp @@ -304,11 +304,11 @@ void BytecodeTraceBuilder::process_instruction_fetching( event.error == PC_OUT_OF_RANGE ? 0 : static_cast(bytecode_size - event.pc); const uint32_t bytes_to_read = std::min(bytes_remaining, DECOMPOSE_WINDOW_SIZE); - uint32_t abs_diff = 0; + uint32_t instr_abs_diff = 0; if (wire_instr_spec.size_in_bytes <= bytes_to_read) { - abs_diff = bytes_to_read - wire_instr_spec.size_in_bytes; + instr_abs_diff = bytes_to_read - wire_instr_spec.size_in_bytes; } else { - abs_diff = wire_instr_spec.size_in_bytes - bytes_to_read - 1; + instr_abs_diff = wire_instr_spec.size_in_bytes - bytes_to_read - 1; } uint32_t bytecode_size_u32 = static_cast(bytecode_size); @@ -373,7 +373,6 @@ void BytecodeTraceBuilder::process_instruction_fetching( // From instruction table. { C::instr_fetching_exec_opcode, static_cast(wire_instr_spec.exec_opcode) }, { C::instr_fetching_instr_size, wire_instr_spec.size_in_bytes }, - { C::instr_fetching_opcode_out_of_range, wire_opcode_in_range ? 0 : 1 }, // Fill operand decomposition selectors { C::instr_fetching_sel_op_dc_0, wire_instr_spec.op_dc_selectors.at(0) }, @@ -409,7 +408,7 @@ void BytecodeTraceBuilder::process_instruction_fetching( { C::instr_fetching_bytecode_size, bytecode_size }, { C::instr_fetching_bytes_remaining, bytes_remaining }, { C::instr_fetching_bytes_to_read, bytes_to_read }, - { C::instr_fetching_abs_diff, abs_diff }, + { C::instr_fetching_instr_abs_diff, instr_abs_diff }, { C::instr_fetching_pc_abs_diff, pc_abs_diff }, { C::instr_fetching_pc_abs_diff_lo, pc_abs_diff_lo }, { C::instr_fetching_pc_abs_diff_hi, pc_abs_diff_hi }, diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp index ba3bc2817814..157627f93f66 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp @@ -23,6 +23,11 @@ using ::testing::Field; using R = TestTraceContainer::Row; using FF = R::FF; +using C = Column; + +using simulation::BytecodeId; +using simulation::Instruction; +using simulation::InstructionFetchingEvent; TEST(BytecodeTraceGenTest, BasicShortLength) { @@ -285,14 +290,68 @@ TEST(BytecodeTraceGenTest, BasicHashing) ROW_FIELD_EQ(R, bc_hashing_packed_field, 20))); } +namespace { + +std::vector gen_random_instructions(std::span opcodes) +{ + std::vector instructions; + instructions.reserve(opcodes.size()); + for (const auto& opcode : opcodes) { + instructions.emplace_back(testing::random_instruction(opcode)); + } + return instructions; +} + +std::vector create_bytecode(std::span instructions) +{ + std::vector bytecode; + for (const auto& instruction : instructions) { + auto serialized_instruction = instruction.serialize(); + bytecode.insert(bytecode.end(), + std::make_move_iterator(serialized_instruction.begin()), + std::make_move_iterator(serialized_instruction.end())); + } + return bytecode; +} + +std::vector gen_pcs(std::span opcodes) +{ + std::vector pcs; + pcs.reserve(opcodes.size()); + size_t pc = 0; + for (const auto& opcode : opcodes) { + pcs.emplace_back(pc); + pc += WIRE_INSTRUCTION_SPEC.at(opcode).size_in_bytes; + } + return pcs; +} + +std::vector create_instruction_fetching_events( + const std::vector& instructions, + const std::vector& pcs, + const std::shared_ptr>& bytecode_ptr, + const BytecodeId bytecode_id) +{ + std::vector events; + events.reserve(instructions.size()); + + for (size_t i = 0; i < instructions.size(); i++) { + events.emplace_back(InstructionFetchingEvent{ + .bytecode_id = bytecode_id, + .pc = static_cast(pcs.at(i)), + .instruction = instructions.at(i), + .bytecode = bytecode_ptr, + }); + } + return events; +} + +} // end of anonymous namespace + // We build a random InstructionFetchingEvent for each wire opcode. // We then verify that the bytes (bd0, bd1, ...) correspond to the serialized instruction. TEST(BytecodeTraceGenTest, InstrDecompositionInBytesEachOpcode) { - using simulation::Instruction; - using simulation::InstructionFetchingEvent; - using C = Column; - TestTraceContainer trace; BytecodeTraceBuilder builder; @@ -314,39 +373,22 @@ TEST(BytecodeTraceGenTest, InstrDecompositionInBytesEachOpcode) C::instr_fetching_op5, C::instr_fetching_op6, C::instr_fetching_op7, }; + constexpr BytecodeId bytecode_id = 1; constexpr auto num_opcodes = static_cast(WireOpCode::LAST_OPCODE_SENTINEL); - std::vector events; - events.reserve(num_opcodes); - std::vector instructions; - instructions.reserve(num_opcodes); - std::vector pcs; - pcs.reserve(num_opcodes); - std::vector bytecode; - bytecode.reserve(1024); // Rough estimate - - uint32_t pc = 0; + std::vector opcodes; + opcodes.reserve(num_opcodes); for (size_t i = 0; i < num_opcodes; i++) { - const auto w_opcode = static_cast(i); - const auto instr = testing::random_instruction(w_opcode); - const auto instr_encoded = instr.serialize(); - instructions.emplace_back(instr); - pcs.emplace_back(pc); - pc += instr_encoded.size(); - bytecode.insert(bytecode.end(), - std::make_move_iterator(instr_encoded.begin()), - std::make_move_iterator(instr_encoded.end())); + opcodes.emplace_back(static_cast(i)); } + std::vector instructions = gen_random_instructions(opcodes); + std::vector pcs = gen_pcs(opcodes); + std::vector bytecode = create_bytecode(instructions); + auto bytecode_ptr = std::make_shared>(bytecode); - for (size_t i = 0; i < num_opcodes; i++) { - events.emplace_back(InstructionFetchingEvent{ - .bytecode_id = 1, - .pc = pcs.at(i), - .instruction = instructions.at(i), - .bytecode = bytecode_ptr, - }); - } + std::vector events = + create_instruction_fetching_events(instructions, pcs, bytecode_ptr, bytecode_id); builder.process_instruction_fetching(events, trace); @@ -383,5 +425,198 @@ TEST(BytecodeTraceGenTest, InstrDecompositionInBytesEachOpcode) } } +TEST(BytecodeTraceGenTest, InstrFetchingSingleBytecode) +{ + TestTraceContainer trace; + BytecodeTraceBuilder builder; + + constexpr BytecodeId bytecode_id = 1; + constexpr size_t num_of_opcodes = 10; + constexpr std::array opcodes = { + WireOpCode::DIV_16, + WireOpCode::RETURNDATASIZE, + WireOpCode::AND_8, + WireOpCode::EMITUNENCRYPTEDLOG, + WireOpCode::CAST_16, + WireOpCode::CALL, + WireOpCode::SUCCESSCOPY, + WireOpCode::MOV_8, + WireOpCode::SHA256COMPRESSION, + WireOpCode::INTERNALCALL, + }; + + std::vector instructions = gen_random_instructions(opcodes); + std::vector pcs = gen_pcs(opcodes); + std::vector bytecode = create_bytecode(instructions); + + std::vector events = create_instruction_fetching_events( + instructions, pcs, std::make_shared>(bytecode), bytecode_id); + + builder.process_instruction_fetching(events, trace); + + // One extra empty row is prepended. + const auto rows = trace.as_rows(); + const auto bytecode_size = bytecode.size(); + EXPECT_EQ(rows.size(), num_of_opcodes + 1); + + for (size_t i = 0; i < num_of_opcodes; i++) { + const auto pc = pcs.at(i); + const auto instr_size = WIRE_INSTRUCTION_SPEC.at(opcodes.at(i)).size_in_bytes; + const auto bytes_remaining = bytecode_size - pc; + const auto bytes_to_read = std::min(DECOMPOSE_WINDOW_SIZE, bytes_remaining); + + EXPECT_LE(instr_size, bytes_to_read); + const auto instr_abs_diff = bytes_to_read - instr_size; + + EXPECT_LT(pc, bytecode_size); + const auto pc_abs_diff = bytecode_size - pc - 1; + + ASSERT_LE(bytecode_size, UINT16_MAX); + const auto pc_abs_diff_lo = pc_abs_diff; + const auto pc_abs_diff_hi = 0; + + EXPECT_THAT(rows.at(i + 1), + AllOf(ROW_FIELD_EQ(R, instr_fetching_sel, 1), + ROW_FIELD_EQ(R, instr_fetching_last_of_bytecode, i == num_of_opcodes - 1 ? 1 : 0), + ROW_FIELD_EQ(R, instr_fetching_pc, pc), + ROW_FIELD_EQ(R, instr_fetching_bd0, static_cast(opcodes.at(i))), + ROW_FIELD_EQ(R, instr_fetching_bytecode_id, bytecode_id), + ROW_FIELD_EQ(R, instr_fetching_bytes_to_read, bytes_to_read), + ROW_FIELD_EQ(R, instr_fetching_bytecode_size, bytecode_size), + ROW_FIELD_EQ(R, instr_fetching_bytes_remaining, bytes_remaining), + ROW_FIELD_EQ(R, instr_fetching_instr_size, instr_size), + ROW_FIELD_EQ(R, instr_fetching_instr_abs_diff, instr_abs_diff), + ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff, pc_abs_diff), + ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff_lo, pc_abs_diff_lo), + ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff_hi, pc_abs_diff_hi), + ROW_FIELD_EQ(R, instr_fetching_pc_out_of_range, 0), + ROW_FIELD_EQ(R, instr_fetching_opcode_out_of_range, 0), + ROW_FIELD_EQ(R, instr_fetching_instr_out_of_range, 0), + ROW_FIELD_EQ(R, instr_fetching_parsing_err, 0), + ROW_FIELD_EQ(R, + instr_fetching_bc_id_diff_inv, + i == num_of_opcodes - 1 ? FF(FF::modulus - bytecode_id).invert() : 0), + ROW_FIELD_EQ(R, instr_fetching_sel_lookup_bc_decomposition, 1))); + } +} + +// Test involving 3 different bytecode_id's for each 2 opcodes (same bytecode). +TEST(BytecodeTraceGenTest, InstrFetchingMultipleBytecodes) +{ + TestTraceContainer trace; + BytecodeTraceBuilder builder; + + constexpr size_t num_of_opcodes = 2; + constexpr std::array opcodes = { + WireOpCode::DIV_16, + WireOpCode::RETURNDATASIZE, + }; + + std::vector instructions = gen_random_instructions(opcodes); + std::vector pcs = gen_pcs(opcodes); + std::vector bytecode = create_bytecode(instructions); + + std::vector events; + for (size_t i = 0; i < 3; i++) { + auto bytecode_ptr = std::make_shared>(bytecode); + auto new_events = + create_instruction_fetching_events(instructions, pcs, bytecode_ptr, static_cast(i + 1)); + events.insert(events.end(), new_events.begin(), new_events.end()); + } + + builder.process_instruction_fetching(events, trace); + + // One extra empty row is prepended. + const auto rows = trace.as_rows(); + EXPECT_EQ(rows.size(), 6 + 1); + + for (size_t i = 0; i < 3; i++) { + EXPECT_THAT(rows.at(2 * i + 1), + AllOf(ROW_FIELD_EQ(R, instr_fetching_last_of_bytecode, 0), ROW_FIELD_EQ(R, instr_fetching_pc, 0))); + EXPECT_THAT(rows.at(2 * i + 2), AllOf(ROW_FIELD_EQ(R, instr_fetching_last_of_bytecode, 1))); + } +} + +// Test which processes three single instruction events, each of one with a different parsing error. +// The bytecode can be filled with trivial bytes of size 20 with all bytes being increasing from 0 to 19. +// First byte at index 0 is set to LAST_OPCODE_SENTINEL + 1. +// Then consider for the instruction events pc = 0, pc = 19, pc = 38. +// pc == 0 will correspond to the error OPCODE_OUT_OF_RANGE +// pc == 19 will have INSTRUCTION_OUT_OF_RANGE +// pc == 38 will have PC_OUT_OF_RANGE +// Check for each row that column instr_fetching_parsing_err in addition to the column of the respective error. +// It is not an issue that the instruction is generated at random in the event and is not consistent with the +// bytecode for this test case. +TEST(BytecodeTraceGenTest, InstrFetchingParsingErrors) +{ + TestTraceContainer trace; + BytecodeTraceBuilder builder; + + constexpr BytecodeId bytecode_id = 1; + constexpr size_t bytecode_size = 20; + std::vector bytecode(bytecode_size); + for (size_t i = 0; i < bytecode_size; i++) { + bytecode[i] = static_cast(i); + } + bytecode[0] = static_cast(WireOpCode::LAST_OPCODE_SENTINEL) + 1; + + std::vector events; + auto bytecode_ptr = std::make_shared>(bytecode); + events.emplace_back(InstructionFetchingEvent{ + .bytecode_id = bytecode_id, + .pc = 0, + .instruction = testing::random_instruction(WireOpCode::ADD_8), + .bytecode = bytecode_ptr, + .error = simulation::InstructionFetchingError::OPCODE_OUT_OF_RANGE, + }); + events.emplace_back(InstructionFetchingEvent{ + .bytecode_id = bytecode_id, + .pc = 19, + .instruction = testing::random_instruction(WireOpCode::ADD_8), + .bytecode = bytecode_ptr, + .error = simulation::InstructionFetchingError::INSTRUCTION_OUT_OF_RANGE, + }); + events.emplace_back(InstructionFetchingEvent{ + .bytecode_id = bytecode_id, + .pc = 38, + .instruction = testing::random_instruction(WireOpCode::ADD_8), + .bytecode = bytecode_ptr, + .error = simulation::InstructionFetchingError::PC_OUT_OF_RANGE, + }); + + builder.process_instruction_fetching(events, trace); + + // One extra empty row is prepended. + const auto rows = trace.as_rows(); + EXPECT_EQ(rows.size(), 3 + 1); + + EXPECT_THAT(rows.at(1), + AllOf(ROW_FIELD_EQ(R, instr_fetching_sel, 1), + ROW_FIELD_EQ(R, instr_fetching_sel_lookup_bc_decomposition, 1), + ROW_FIELD_EQ(R, instr_fetching_pc, 0), + ROW_FIELD_EQ(R, instr_fetching_parsing_err, 1), + ROW_FIELD_EQ(R, instr_fetching_opcode_out_of_range, 1))); + + EXPECT_THAT(rows.at(2), + AllOf(ROW_FIELD_EQ(R, instr_fetching_sel, 1), + ROW_FIELD_EQ(R, instr_fetching_sel_lookup_bc_decomposition, 1), + ROW_FIELD_EQ(R, instr_fetching_pc, 19), // OR_16 opcode + ROW_FIELD_EQ(R, instr_fetching_bytes_to_read, 1), + ROW_FIELD_EQ(R, instr_fetching_bytes_remaining, 1), + ROW_FIELD_EQ(R, instr_fetching_instr_size, 8), // OR_16 is 8 bytes long + ROW_FIELD_EQ(R, + instr_fetching_instr_abs_diff, + 6), // instr_size < bytes_to_read: bytes_to_read - instr_size - 1 + ROW_FIELD_EQ(R, instr_fetching_parsing_err, 1), + ROW_FIELD_EQ(R, instr_fetching_instr_out_of_range, 1))); + + EXPECT_THAT(rows.at(3), + AllOf(ROW_FIELD_EQ(R, instr_fetching_sel, 1), + ROW_FIELD_EQ(R, instr_fetching_sel_lookup_bc_decomposition, 0), + ROW_FIELD_EQ(R, instr_fetching_pc, 38), + ROW_FIELD_EQ(R, instr_fetching_parsing_err, 1), + ROW_FIELD_EQ(R, instr_fetching_pc_out_of_range, 1))); +} + } // namespace } // namespace bb::avm2::tracegen From ae578290552b0c2890adb0fa7fdc958616e6ac96 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Fri, 14 Mar 2025 16:00:54 +0000 Subject: [PATCH 07/25] Positive constraining unit tests --- .../relations/instr_fetching.test.cpp | 128 ++++++++++++++++-- 1 file changed, 120 insertions(+), 8 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp index 7275487942ee..832dd0d62eb3 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp @@ -22,14 +22,23 @@ namespace bb::avm2::constraining { namespace { using tracegen::BytecodeTraceBuilder; +using tracegen::LookupIntoDynamicTableGeneric; +using tracegen::LookupIntoDynamicTableSequential; +using tracegen::LookupIntoIndexedByClk; using tracegen::PrecomputedTraceBuilder; using tracegen::TestTraceContainer; + using FF = AvmFlavorSettings::FF; using C = Column; -using instr_fetching = bb::avm2::instr_fetching; + +using instr_fetching = instr_fetching; + +using simulation::BytecodeDecompositionEvent; +using simulation::BytecodeId; using simulation::Instruction; using simulation::InstructionFetchingEvent; using simulation::Operand; + using testing::random_bytes; TEST(InstrFetchingConstrainingTest, EmptyRow) @@ -205,15 +214,45 @@ TEST(InstrFetchingConstrainingTest, WireInstructionSpecInteractions) bytecode_builder.process_instruction_fetching(gen_instr_events_each_opcode(), trace); precomputed_builder.process_misc(trace, trace.get_num_rows()); // Limit to the number of rows we need. - tracegen::LookupIntoIndexedByClk().process(trace); + LookupIntoIndexedByClk().process(trace); + + EXPECT_EQ(trace.get_num_rows(), 1 << 8); // 2^8 for selector against wire_instruction_spec check_relation(trace); check_interaction(trace); } +// Positive test for interaction with range checks using same events as for the test +// EachOpcodeWithTraceGen, i.e., one event/row is generated per wire opcode. +TEST(InstrFetchingConstrainingTest, RangeCheckInteractions) +{ + using abs_diff_positive_lookup = lookup_instr_fetching_abs_diff_positive_relation; + using pc_abs_diff_positive_lo_lookup = lookup_instr_fetching_pc_abs_diff_positive_lo_relation; + using pc_abs_diff_positive_hi_lookup = lookup_instr_fetching_pc_abs_diff_positive_hi_relation; + + TestTraceContainer trace; + BytecodeTraceBuilder bytecode_builder; + PrecomputedTraceBuilder precomputed_builder; + + precomputed_builder.process_sel_range_8(trace); + precomputed_builder.process_sel_range_16(trace); + bytecode_builder.process_instruction_fetching(gen_instr_events_each_opcode(), trace); + precomputed_builder.process_misc(trace, trace.get_num_rows()); // Limit to the number of rows we need. + + LookupIntoIndexedByClk().process(trace); + LookupIntoIndexedByClk().process(trace); + LookupIntoIndexedByClk().process(trace); + + EXPECT_EQ(trace.get_num_rows(), 1 << 16); // 2^16 for range checks + + check_relation(trace); + check_interaction(trace); + check_interaction(trace); + check_interaction(trace); +} + // Positive test for the interaction with bytecode decomposition table. // One event/row is generated per wire opcode (same as for test WireInstructionSpecInteractions). -// It works as long as the relations are not constraining the correct range for TAG nor indirect. TEST(InstrFetchingConstrainingTest, BcDecompositionInteractions) { using bc_decomposition_lookup = lookup_instr_fetching_bytes_from_bc_dec_relation; @@ -231,9 +270,82 @@ TEST(InstrFetchingConstrainingTest, BcDecompositionInteractions) trace); precomputed_builder.process_misc(trace, trace.get_num_rows()); // Limit to the number of rows we need. - tracegen::LookupIntoDynamicTableGeneric().process(trace); + LookupIntoDynamicTableGeneric().process(trace); + + // BC Decomposition trace is the longest here. + EXPECT_EQ(trace.get_num_rows(), instr_fetch_events.at(0).bytecode->size() + 1); + + check_relation(trace); + check_interaction(trace); +} + +// Positive test with 5 five bytecodes and bytecode_id = 0,1,2,3,4 +// Bytecode i is generated by truncating instr_fetch_events to i * 6 instructions. +// Check relations and all interactions. +TEST(InstrFetchingConstrainingTest, MultipleBytecodes) +{ + using abs_diff_positive_lookup = lookup_instr_fetching_abs_diff_positive_relation; + using pc_abs_diff_positive_lo_lookup = lookup_instr_fetching_pc_abs_diff_positive_lo_relation; + using pc_abs_diff_positive_hi_lookup = lookup_instr_fetching_pc_abs_diff_positive_hi_relation; + using wire_instr_spec_lookup = lookup_instr_fetching_wire_instruction_info_relation; + using bc_decomposition_lookup = lookup_instr_fetching_bytes_from_bc_dec_relation; + + TestTraceContainer trace; + BytecodeTraceBuilder bytecode_builder; + PrecomputedTraceBuilder precomputed_builder; + + const auto instr_fetch_events = gen_instr_events_each_opcode(); + constexpr size_t num_of_bytecodes = 5; + std::vector decomposition_events; + std::vector instr_events; + + for (size_t i = 0; i < num_of_bytecodes; i++) { + std::vector bytecode; + const auto num_of_instr = i * 6; + + for (size_t j = 0; j < num_of_instr; j++) { + const auto& instr = instr_fetch_events.at(j).instruction; + const auto instruction_bytes = instr.serialize(); + bytecode.insert(bytecode.end(), + std::make_move_iterator(instruction_bytes.begin()), + std::make_move_iterator(instruction_bytes.end())); + } + + const auto bytecode_ptr = std::make_shared>(std::move(bytecode)); + + for (size_t j = 0; j < num_of_instr; j++) { + auto instr_event = instr_fetch_events.at(j); + instr_event.bytecode_id = static_cast(i); + instr_event.bytecode = bytecode_ptr; + instr_events.emplace_back(instr_event); + } + + decomposition_events.emplace_back(BytecodeDecompositionEvent{ + .bytecode_id = static_cast(i), + .bytecode = bytecode_ptr, + }); + } + + precomputed_builder.process_wire_instruction_spec(trace); + precomputed_builder.process_sel_range_8(trace); + precomputed_builder.process_sel_range_16(trace); + bytecode_builder.process_instruction_fetching(instr_events, trace); + bytecode_builder.process_decomposition(decomposition_events, trace); + precomputed_builder.process_misc(trace, trace.get_num_rows()); // Limit to the number of rows we need. + + LookupIntoIndexedByClk().process(trace); + LookupIntoIndexedByClk().process(trace); + LookupIntoIndexedByClk().process(trace); + LookupIntoIndexedByClk().process(trace); + LookupIntoDynamicTableGeneric().process(trace); + + EXPECT_EQ(trace.get_num_rows(), 1 << 16); // 2^16 for range checks check_relation(trace); + check_interaction(trace); + check_interaction(trace); + check_interaction(trace); + check_interaction(trace); check_interaction(trace); } @@ -241,7 +353,6 @@ TEST(InstrFetchingConstrainingTest, BcDecompositionInteractions) TEST(InstrFetchingConstrainingTest, NegativeWrongWireInstructionSpecInteractions) { using wire_instr_spec_lookup = lookup_instr_fetching_wire_instruction_info_relation; - using tracegen::LookupIntoIndexedByClk; BytecodeTraceBuilder bytecode_builder; PrecomputedTraceBuilder precomputed_builder; @@ -298,7 +409,6 @@ TEST(InstrFetchingConstrainingTest, NegativeWrongWireInstructionSpecInteractions TEST(InstrFetchingConstrainingTest, NegativeWrongBcDecompositionInteractions) { using bc_decomposition_lookup = lookup_instr_fetching_bytes_from_bc_dec_relation; - using tracegen::LookupIntoDynamicTableSequential; TestTraceContainer trace; BytecodeTraceBuilder bytecode_builder; @@ -347,8 +457,8 @@ TEST(InstrFetchingConstrainingTest, NegativeWrongBcDecompositionInteractions) const FF mutated_value = trace.get(col, 1) + 1; // Mutate to value + 1 mutated_trace.set(col, 1, mutated_value); - // This sets the length of the inverse polynomial via SetDummyInverses, so we still need to call this even - // though we know it will fail. + // This sets the length of the inverse polynomial via SetDummyInverses, so we still need to call this + // even though we know it will fail. EXPECT_THROW_WITH_MESSAGE( LookupIntoDynamicTableSequential().process(mutated_trace), "Failed.*BYTES_FROM_BC_DEC. Could not find tuple in destination."); @@ -359,5 +469,7 @@ TEST(InstrFetchingConstrainingTest, NegativeWrongBcDecompositionInteractions) } } +// + } // namespace } // namespace bb::avm2::constraining From 87bfa898ab6fd3eca6dcac8d59ea61eb1f18ec76 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Mon, 17 Mar 2025 13:25:57 +0000 Subject: [PATCH 08/25] Unit tests and debugging --- barretenberg/cpp/pil/vm2/instr_fetching.pil | 10 +- .../relations/instr_fetching.test.cpp | 231 +++++++++++++++--- .../barretenberg/vm2/generated/columns.hpp | 4 +- .../src/barretenberg/vm2/generated/flavor.hpp | 2 +- .../generated/relations/instr_fetching.hpp | 2 +- .../relations/lookups_instr_fetching.hpp | 43 ++-- .../vm2/simulation/bytecode_manager.cpp | 14 +- .../vm2/simulation/events/bytecode_events.hpp | 9 +- .../vm2/simulation/lib/serialization.cpp | 54 ++-- .../vm2/simulation/lib/serialization.hpp | 18 +- .../vm2/simulation/lib/serialization.test.cpp | 32 +-- .../vm2/tracegen/bytecode_trace.cpp | 13 +- .../vm2/tracegen/bytecode_trace.test.cpp | 35 ++- .../src/barretenberg/vm2/tracegen_helper.cpp | 2 +- 14 files changed, 325 insertions(+), 144 deletions(-) diff --git a/barretenberg/cpp/pil/vm2/instr_fetching.pil b/barretenberg/cpp/pil/vm2/instr_fetching.pil index 97bef073f405..e1059b1fe484 100644 --- a/barretenberg/cpp/pil/vm2/instr_fetching.pil +++ b/barretenberg/cpp/pil/vm2/instr_fetching.pil @@ -69,7 +69,7 @@ pol commit instr_abs_diff; // From the following relation, we have: instr_abs_diff >= 0 ==> [instr_size > bytes_to_read <==> instr_out_of_range == 1] instr_abs_diff = (2 * instr_out_of_range - 1) * (instr_size - bytes_to_read) - instr_out_of_range; -#[ABS_DIFF_POSITIVE] +#[INSTR_ABS_DIFF_POSITIVE] sel {instr_abs_diff} in precomputed.sel_range_8 {precomputed.clk}; // We have to enforce that: pc < bytecode_size <==> pc_out_of_range == 0 @@ -104,13 +104,13 @@ pol commit bd0, bd1, bd2, bd3, bd4, bd36; // selector for lookup to bc_decomposition.pil -pol commit sel_lookup_bc_decomposition; +pol commit sel_opcode_defined; // Toggled except when pc is out of range. -sel_lookup_bc_decomposition = sel * (1 - pc_out_of_range); +sel_opcode_defined = sel * (1 - pc_out_of_range); // Bring in the bytes from the bytecode columns. #[BYTES_FROM_BC_DEC] -sel_lookup_bc_decomposition { +sel_opcode_defined { pc, bytecode_id, bytes_remaining, @@ -167,7 +167,7 @@ pol commit sel_op_dc_16; pol commit sel_op_dc_17; #[WIRE_INSTRUCTION_INFO] -sel { +sel_opcode_defined { bd0, opcode_out_of_range, exec_opcode, diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp index 832dd0d62eb3..53d0dc5e2ab3 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp @@ -35,10 +35,17 @@ using instr_fetching = instr_fetching; using simulation::BytecodeDecompositionEvent; using simulation::BytecodeId; +using simulation::InstrDeserializationError; using simulation::Instruction; using simulation::InstructionFetchingEvent; using simulation::Operand; +using abs_diff_positive_lookup = lookup_instr_fetching_instr_abs_diff_positive_relation; +using pc_abs_diff_positive_lo_lookup = lookup_instr_fetching_pc_abs_diff_positive_lo_relation; +using pc_abs_diff_positive_hi_lookup = lookup_instr_fetching_pc_abs_diff_positive_hi_relation; +using wire_instr_spec_lookup = lookup_instr_fetching_wire_instruction_info_relation; +using bc_decomposition_lookup = lookup_instr_fetching_bytes_from_bc_dec_relation; + using testing::random_bytes; TEST(InstrFetchingConstrainingTest, EmptyRow) @@ -226,10 +233,6 @@ TEST(InstrFetchingConstrainingTest, WireInstructionSpecInteractions) // EachOpcodeWithTraceGen, i.e., one event/row is generated per wire opcode. TEST(InstrFetchingConstrainingTest, RangeCheckInteractions) { - using abs_diff_positive_lookup = lookup_instr_fetching_abs_diff_positive_relation; - using pc_abs_diff_positive_lo_lookup = lookup_instr_fetching_pc_abs_diff_positive_lo_relation; - using pc_abs_diff_positive_hi_lookup = lookup_instr_fetching_pc_abs_diff_positive_hi_relation; - TestTraceContainer trace; BytecodeTraceBuilder bytecode_builder; PrecomputedTraceBuilder precomputed_builder; @@ -255,8 +258,6 @@ TEST(InstrFetchingConstrainingTest, RangeCheckInteractions) // One event/row is generated per wire opcode (same as for test WireInstructionSpecInteractions). TEST(InstrFetchingConstrainingTest, BcDecompositionInteractions) { - using bc_decomposition_lookup = lookup_instr_fetching_bytes_from_bc_dec_relation; - TestTraceContainer trace; BytecodeTraceBuilder bytecode_builder; PrecomputedTraceBuilder precomputed_builder; @@ -279,21 +280,41 @@ TEST(InstrFetchingConstrainingTest, BcDecompositionInteractions) check_interaction(trace); } -// Positive test with 5 five bytecodes and bytecode_id = 0,1,2,3,4 -// Bytecode i is generated by truncating instr_fetch_events to i * 6 instructions. -// Check relations and all interactions. -TEST(InstrFetchingConstrainingTest, MultipleBytecodes) +void check_all(const std::vector& instr_events, + const std::vector& decomposition_events) { - using abs_diff_positive_lookup = lookup_instr_fetching_abs_diff_positive_relation; - using pc_abs_diff_positive_lo_lookup = lookup_instr_fetching_pc_abs_diff_positive_lo_relation; - using pc_abs_diff_positive_hi_lookup = lookup_instr_fetching_pc_abs_diff_positive_hi_relation; - using wire_instr_spec_lookup = lookup_instr_fetching_wire_instruction_info_relation; - using bc_decomposition_lookup = lookup_instr_fetching_bytes_from_bc_dec_relation; - TestTraceContainer trace; BytecodeTraceBuilder bytecode_builder; PrecomputedTraceBuilder precomputed_builder; + precomputed_builder.process_wire_instruction_spec(trace); + precomputed_builder.process_sel_range_8(trace); + precomputed_builder.process_sel_range_16(trace); + bytecode_builder.process_instruction_fetching(instr_events, trace); + bytecode_builder.process_decomposition(decomposition_events, trace); + precomputed_builder.process_misc(trace, trace.get_num_rows()); // Limit to the number of rows we need. + + LookupIntoIndexedByClk().process(trace); + LookupIntoIndexedByClk().process(trace); + LookupIntoIndexedByClk().process(trace); + LookupIntoIndexedByClk().process(trace); + LookupIntoDynamicTableGeneric().process(trace); + + EXPECT_EQ(trace.get_num_rows(), 1 << 16); // 2^16 for range checks + + check_relation(trace); + check_interaction(trace); + check_interaction(trace); + check_interaction(trace); + check_interaction(trace); + check_interaction(trace); +} + +// Positive test with 5 five bytecodes and bytecode_id = 0,1,2,3,4 +// Bytecode i is generated by truncating instr_fetch_events to i * 6 instructions. +// Check relations and all interactions. +TEST(InstrFetchingConstrainingTest, MultipleBytecodes) +{ const auto instr_fetch_events = gen_instr_events_each_opcode(); constexpr size_t num_of_bytecodes = 5; std::vector decomposition_events; @@ -326,34 +347,170 @@ TEST(InstrFetchingConstrainingTest, MultipleBytecodes) }); } - precomputed_builder.process_wire_instruction_spec(trace); - precomputed_builder.process_sel_range_8(trace); - precomputed_builder.process_sel_range_16(trace); - bytecode_builder.process_instruction_fetching(instr_events, trace); - bytecode_builder.process_decomposition(decomposition_events, trace); - precomputed_builder.process_misc(trace, trace.get_num_rows()); // Limit to the number of rows we need. + check_all(instr_events, decomposition_events); +} - LookupIntoIndexedByClk().process(trace); - LookupIntoIndexedByClk().process(trace); - LookupIntoIndexedByClk().process(trace); - LookupIntoIndexedByClk().process(trace); - LookupIntoDynamicTableGeneric().process(trace); +// Positive test with one single instruction with error INSTRUCTION_OUT_OF_RANGE. +// The bytecode consists into a serialized single instruction with pc = 0 and +// the bytecode had the last byte removed. This byte corresponds to a full operand. +TEST(InstrFetchingConstrainingTest, SingleInstructionOutOfRange) +{ + Instruction add_8_instruction = { + .opcode = WireOpCode::ADD_8, + .indirect = 3, + .operands = { Operand::u8(0x34), Operand::u8(0x35), Operand::u8(0x36) }, + }; - EXPECT_EQ(trace.get_num_rows(), 1 << 16); // 2^16 for range checks + std::vector bytecode = add_8_instruction.serialize(); + bytecode.pop_back(); // Remove last byte + const auto instr_with_err = simulation::deserialize_instruction(bytecode, 0); + const auto bytecode_ptr = std::make_shared>(std::move(bytecode)); - check_relation(trace); - check_interaction(trace); - check_interaction(trace); - check_interaction(trace); - check_interaction(trace); - check_interaction(trace); + ASSERT_EQ(instr_with_err.error, InstrDeserializationError::INSTRUCTION_OUT_OF_RANGE); + + const std::vector instr_events = { + { + .bytecode_id = 1, + .pc = 0, + .instruction = instr_with_err.instruction, + .bytecode = bytecode_ptr, + .error = InstrDeserializationError::INSTRUCTION_OUT_OF_RANGE, + }, + }; + + const std::vector decomposition_events = { + { + .bytecode_id = 1, + .bytecode = bytecode_ptr, + }, + }; + + check_all(instr_events, decomposition_events); +} + +// Positive test with one single instruction (SET_FF) with error INSTRUCTION_OUT_OF_RANGE. +// The bytecode consists into a serialized single instruction with pc = 0 and +// the bytecode had the two last bytes removed. The truncated instruction is cut +// in the middle of an operand. +TEST(InstrFetchingConstrainingTest, SingleInstructionOutOfRangeSplitOperand) +{ + Instruction set_ff_instruction = { + .opcode = WireOpCode::SET_FF, + .indirect = 0x01, + .operands = { Operand::u16(0x1279), + Operand::u8(static_cast(MemoryTag::FF)), + Operand::ff(FF::modulus_minus_two) }, + }; + + std::vector bytecode = set_ff_instruction.serialize(); + bytecode.resize(bytecode.size() - 2); // Remove last two bytes) + const auto instr_with_err = simulation::deserialize_instruction(bytecode, 0); + const auto bytecode_ptr = std::make_shared>(std::move(bytecode)); + + ASSERT_EQ(instr_with_err.error, InstrDeserializationError::INSTRUCTION_OUT_OF_RANGE); + + const std::vector instr_events = { + { + .bytecode_id = 1, + .pc = 0, + .instruction = instr_with_err.instruction, + .bytecode = bytecode_ptr, + .error = InstrDeserializationError::INSTRUCTION_OUT_OF_RANGE, + }, + }; + + const std::vector decomposition_events = { + { + .bytecode_id = 1, + .bytecode = bytecode_ptr, + }, + }; + + check_all(instr_events, decomposition_events); +} + +// Positive test with error case PC_OUT_OF_RANGE. We pass a pc which is out of range. +TEST(InstrFetchingConstrainingTest, SingleInstructionPcOutOfRange) +{ + Instruction add_8_instruction = { + .opcode = WireOpCode::SUB_8, + .indirect = 3, + .operands = { Operand::u8(0x34), Operand::u8(0x35), Operand::u8(0x36) }, + }; + + std::vector bytecode = add_8_instruction.serialize(); + const auto bytecode_ptr = std::make_shared>(std::move(bytecode)); + + const std::vector instr_events = { + // We first need a first instruction at pc == 0 as the trace assumes this. + { + .bytecode_id = 1, + .pc = 0, + .instruction = add_8_instruction, + .bytecode = bytecode_ptr, + }, + { + .bytecode_id = 1, + .pc = static_cast(bytecode_ptr->size() + 1), + .bytecode = bytecode_ptr, + .error = InstrDeserializationError::PC_OUT_OF_RANGE, + }, + }; + + const std::vector decomposition_events = { + { + .bytecode_id = 1, + .bytecode = bytecode_ptr, + }, + }; + + check_all(instr_events, decomposition_events); +} + +// Positive test with error case OPCODE_OUT_OF_RANGE. We generate bytecode of a SET_128 instruction and +// move the PC to a position corresponding to the beginning of the 128-bit immediate value of SET_128. +// The immediate value in SET_128 starts with byte 0xFF (which we know is not a valid opcode). +TEST(InstrFetchingConstrainingTest, SingleInstructionOpcodeOutOfRange) +{ + Instruction set_128_instruction = { + .opcode = WireOpCode::SET_128, + .indirect = 0, + .operands = { Operand::u16(0x1234), + Operand::u8(static_cast(MemoryTag::U128)), + Operand::u128(static_cast(0xFF) << 120) }, + }; + + std::vector bytecode = set_128_instruction.serialize(); + const auto bytecode_ptr = std::make_shared>(std::move(bytecode)); + + const std::vector instr_events = { + { + .bytecode_id = 1, + .pc = 0, + .instruction = set_128_instruction, + .bytecode = bytecode_ptr, + }, + { + .bytecode_id = 1, + .pc = 5, // We move pc to the beginning of the 128-bit immediate value. + .bytecode = bytecode_ptr, + .error = InstrDeserializationError::OPCODE_OUT_OF_RANGE, + }, + }; + + const std::vector decomposition_events = { + { + .bytecode_id = 1, + .bytecode = bytecode_ptr, + }, + }; + + check_all(instr_events, decomposition_events); } // Negative interaction test with some values not matching the instruction spec table. TEST(InstrFetchingConstrainingTest, NegativeWrongWireInstructionSpecInteractions) { - using wire_instr_spec_lookup = lookup_instr_fetching_wire_instruction_info_relation; - BytecodeTraceBuilder bytecode_builder; PrecomputedTraceBuilder precomputed_builder; @@ -408,8 +565,6 @@ TEST(InstrFetchingConstrainingTest, NegativeWrongWireInstructionSpecInteractions // Negative interaction test with some values not matching the bytecode decomposition table. TEST(InstrFetchingConstrainingTest, NegativeWrongBcDecompositionInteractions) { - using bc_decomposition_lookup = lookup_instr_fetching_bytes_from_bc_dec_relation; - TestTraceContainer trace; BytecodeTraceBuilder bytecode_builder; diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp index 2023a9636602..0bdb9de7d972 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp @@ -10,8 +10,8 @@ namespace bb::avm2 { // The entities that will be used in the flavor. // clang-format off #define AVM2_PRECOMPUTED_ENTITIES precomputed_as_unary, precomputed_bitwise_input_a, precomputed_bitwise_input_b, precomputed_bitwise_op_id, precomputed_bitwise_output, precomputed_clk, precomputed_exec_opcode, precomputed_first_row, precomputed_instr_size, precomputed_integral_tag_length, precomputed_opcode_out_of_range, precomputed_p_decomposition_limb, precomputed_p_decomposition_limb_index, precomputed_p_decomposition_radix, precomputed_power_of_2, precomputed_sel_bitwise, precomputed_sel_integral_tag, precomputed_sel_op_dc_0, precomputed_sel_op_dc_1, precomputed_sel_op_dc_10, precomputed_sel_op_dc_11, precomputed_sel_op_dc_12, precomputed_sel_op_dc_13, precomputed_sel_op_dc_14, precomputed_sel_op_dc_15, precomputed_sel_op_dc_16, precomputed_sel_op_dc_17, precomputed_sel_op_dc_2, precomputed_sel_op_dc_3, precomputed_sel_op_dc_4, precomputed_sel_op_dc_5, precomputed_sel_op_dc_6, precomputed_sel_op_dc_7, precomputed_sel_op_dc_8, precomputed_sel_op_dc_9, precomputed_sel_p_decomposition, precomputed_sel_range_16, precomputed_sel_range_8, precomputed_sel_sha256_compression, precomputed_sel_to_radix_safe_limbs, precomputed_sel_unary, precomputed_sha256_compression_round_constant, precomputed_to_radix_safe_limbs, precomputed_zero -#define AVM2_WIRE_ENTITIES execution_input, address_derivation_address, address_derivation_address_y, address_derivation_class_id, address_derivation_deployer_addr, address_derivation_g1_x, address_derivation_g1_y, address_derivation_incoming_viewing_key_x, address_derivation_incoming_viewing_key_y, address_derivation_init_hash, address_derivation_nullifier_key_x, address_derivation_nullifier_key_y, address_derivation_outgoing_viewing_key_x, address_derivation_outgoing_viewing_key_y, address_derivation_partial_address, address_derivation_partial_address_domain_separator, address_derivation_preaddress, address_derivation_preaddress_domain_separator, address_derivation_preaddress_public_key_x, address_derivation_preaddress_public_key_y, address_derivation_public_keys_hash, address_derivation_public_keys_hash_domain_separator, address_derivation_salt, address_derivation_salted_init_hash, address_derivation_sel, address_derivation_tagging_key_x, address_derivation_tagging_key_y, alu_dst_addr, alu_ia, alu_ia_addr, alu_ib, alu_ib_addr, alu_ic, alu_op, alu_sel_op_add, bc_decomposition_abs_diff, bc_decomposition_bytes, bc_decomposition_bytes_pc_plus_1, bc_decomposition_bytes_pc_plus_10, bc_decomposition_bytes_pc_plus_11, bc_decomposition_bytes_pc_plus_12, bc_decomposition_bytes_pc_plus_13, bc_decomposition_bytes_pc_plus_14, bc_decomposition_bytes_pc_plus_15, bc_decomposition_bytes_pc_plus_16, bc_decomposition_bytes_pc_plus_17, bc_decomposition_bytes_pc_plus_18, bc_decomposition_bytes_pc_plus_19, bc_decomposition_bytes_pc_plus_2, bc_decomposition_bytes_pc_plus_20, bc_decomposition_bytes_pc_plus_21, bc_decomposition_bytes_pc_plus_22, bc_decomposition_bytes_pc_plus_23, bc_decomposition_bytes_pc_plus_24, bc_decomposition_bytes_pc_plus_25, bc_decomposition_bytes_pc_plus_26, bc_decomposition_bytes_pc_plus_27, bc_decomposition_bytes_pc_plus_28, bc_decomposition_bytes_pc_plus_29, bc_decomposition_bytes_pc_plus_3, bc_decomposition_bytes_pc_plus_30, bc_decomposition_bytes_pc_plus_31, bc_decomposition_bytes_pc_plus_32, bc_decomposition_bytes_pc_plus_33, bc_decomposition_bytes_pc_plus_34, bc_decomposition_bytes_pc_plus_35, bc_decomposition_bytes_pc_plus_36, bc_decomposition_bytes_pc_plus_4, bc_decomposition_bytes_pc_plus_5, bc_decomposition_bytes_pc_plus_6, bc_decomposition_bytes_pc_plus_7, bc_decomposition_bytes_pc_plus_8, bc_decomposition_bytes_pc_plus_9, bc_decomposition_bytes_rem_inv, bc_decomposition_bytes_rem_min_one_inv, bc_decomposition_bytes_remaining, bc_decomposition_bytes_to_read, bc_decomposition_bytes_to_read_unary, bc_decomposition_id, bc_decomposition_last_of_contract, bc_decomposition_packed_field, bc_decomposition_pc, bc_decomposition_sel, bc_decomposition_sel_overflow_correction_needed, bc_decomposition_sel_packed, bc_decomposition_sel_pc_plus_1, bc_decomposition_sel_pc_plus_10, bc_decomposition_sel_pc_plus_11, bc_decomposition_sel_pc_plus_12, bc_decomposition_sel_pc_plus_13, bc_decomposition_sel_pc_plus_14, bc_decomposition_sel_pc_plus_15, bc_decomposition_sel_pc_plus_16, bc_decomposition_sel_pc_plus_17, bc_decomposition_sel_pc_plus_18, bc_decomposition_sel_pc_plus_19, bc_decomposition_sel_pc_plus_2, bc_decomposition_sel_pc_plus_20, bc_decomposition_sel_pc_plus_21, bc_decomposition_sel_pc_plus_22, bc_decomposition_sel_pc_plus_23, bc_decomposition_sel_pc_plus_24, bc_decomposition_sel_pc_plus_25, bc_decomposition_sel_pc_plus_26, bc_decomposition_sel_pc_plus_27, bc_decomposition_sel_pc_plus_28, bc_decomposition_sel_pc_plus_29, bc_decomposition_sel_pc_plus_3, bc_decomposition_sel_pc_plus_30, bc_decomposition_sel_pc_plus_31, bc_decomposition_sel_pc_plus_32, bc_decomposition_sel_pc_plus_33, bc_decomposition_sel_pc_plus_34, bc_decomposition_sel_pc_plus_35, bc_decomposition_sel_pc_plus_36, bc_decomposition_sel_pc_plus_4, bc_decomposition_sel_pc_plus_5, bc_decomposition_sel_pc_plus_6, bc_decomposition_sel_pc_plus_7, bc_decomposition_sel_pc_plus_8, bc_decomposition_sel_pc_plus_9, bc_hashing_bytecode_id, bc_hashing_incremental_hash, bc_hashing_latch, bc_hashing_output_hash, bc_hashing_packed_field, bc_hashing_pc_index, bc_hashing_sel, bc_hashing_start, bc_retrieval_address, bc_retrieval_artifact_hash, bc_retrieval_bytecode_id, bc_retrieval_class_id, bc_retrieval_deployer_addr, bc_retrieval_err, bc_retrieval_incoming_viewing_key_x, bc_retrieval_incoming_viewing_key_y, bc_retrieval_init_hash, bc_retrieval_nullifier_key_x, bc_retrieval_nullifier_key_y, bc_retrieval_outgoing_viewing_key_x, bc_retrieval_outgoing_viewing_key_y, bc_retrieval_private_function_root, bc_retrieval_public_bytecode_commitment, bc_retrieval_salt, bc_retrieval_sel, bc_retrieval_siloed_address, bc_retrieval_tagging_key_x, bc_retrieval_tagging_key_y, bitwise_acc_ia, bitwise_acc_ib, bitwise_acc_ic, bitwise_ctr, bitwise_ctr_inv, bitwise_ctr_min_one_inv, bitwise_ia_byte, bitwise_ib_byte, bitwise_ic_byte, bitwise_last, bitwise_op_id, bitwise_sel, bitwise_start, bitwise_tag, class_id_derivation_artifact_hash, class_id_derivation_class_id, class_id_derivation_private_function_root, class_id_derivation_public_bytecode_commitment, class_id_derivation_sel, class_id_derivation_temp_constant_for_lookup, ecc_add_op, ecc_double_op, ecc_inv_2_p_y, ecc_inv_x_diff, ecc_inv_y_diff, ecc_lambda, ecc_p_is_inf, ecc_p_x, ecc_p_y, ecc_q_is_inf, ecc_q_x, ecc_q_y, ecc_r_is_inf, ecc_r_x, ecc_r_y, ecc_result_infinity, ecc_sel, ecc_x_match, ecc_y_match, execution_addressing_error_idx, execution_addressing_error_kind, execution_base_address_tag, execution_base_address_val, execution_bytecode_id, execution_clk, execution_ex_opcode, execution_indirect, execution_last, execution_op1, execution_op1_after_relative, execution_op2, execution_op2_after_relative, execution_op3, execution_op3_after_relative, execution_op4, execution_op4_after_relative, execution_pc, execution_rop1, execution_rop2, execution_rop3, execution_rop4, execution_sel, execution_sel_addressing_error, execution_sel_op1_is_address, execution_sel_op2_is_address, execution_sel_op3_is_address, execution_sel_op4_is_address, instr_fetching_bc_id_diff_inv, instr_fetching_bd0, instr_fetching_bd1, instr_fetching_bd10, instr_fetching_bd11, instr_fetching_bd12, instr_fetching_bd13, instr_fetching_bd14, instr_fetching_bd15, instr_fetching_bd16, instr_fetching_bd17, instr_fetching_bd18, instr_fetching_bd19, instr_fetching_bd2, instr_fetching_bd20, instr_fetching_bd21, instr_fetching_bd22, instr_fetching_bd23, instr_fetching_bd24, instr_fetching_bd25, instr_fetching_bd26, instr_fetching_bd27, instr_fetching_bd28, instr_fetching_bd29, instr_fetching_bd3, instr_fetching_bd30, instr_fetching_bd31, instr_fetching_bd32, instr_fetching_bd33, instr_fetching_bd34, instr_fetching_bd35, instr_fetching_bd36, instr_fetching_bd4, instr_fetching_bd5, instr_fetching_bd6, instr_fetching_bd7, instr_fetching_bd8, instr_fetching_bd9, instr_fetching_bytecode_id, instr_fetching_bytecode_size, instr_fetching_bytes_remaining, instr_fetching_bytes_to_read, instr_fetching_exec_opcode, instr_fetching_indirect, instr_fetching_instr_abs_diff, instr_fetching_instr_out_of_range, instr_fetching_instr_size, instr_fetching_last_of_bytecode, instr_fetching_op1, instr_fetching_op2, instr_fetching_op3, instr_fetching_op4, instr_fetching_op5, instr_fetching_op6, instr_fetching_op7, instr_fetching_opcode_out_of_range, instr_fetching_parsing_err, instr_fetching_pc, instr_fetching_pc_abs_diff, instr_fetching_pc_abs_diff_hi, instr_fetching_pc_abs_diff_lo, instr_fetching_pc_out_of_range, instr_fetching_sel, instr_fetching_sel_lookup_bc_decomposition, instr_fetching_sel_op_dc_0, instr_fetching_sel_op_dc_1, instr_fetching_sel_op_dc_10, instr_fetching_sel_op_dc_11, instr_fetching_sel_op_dc_12, instr_fetching_sel_op_dc_13, instr_fetching_sel_op_dc_14, instr_fetching_sel_op_dc_15, instr_fetching_sel_op_dc_16, instr_fetching_sel_op_dc_17, instr_fetching_sel_op_dc_2, instr_fetching_sel_op_dc_3, instr_fetching_sel_op_dc_4, instr_fetching_sel_op_dc_5, instr_fetching_sel_op_dc_6, instr_fetching_sel_op_dc_7, instr_fetching_sel_op_dc_8, instr_fetching_sel_op_dc_9, poseidon2_hash_a_0, poseidon2_hash_a_1, poseidon2_hash_a_2, poseidon2_hash_a_3, poseidon2_hash_b_0, poseidon2_hash_b_1, poseidon2_hash_b_2, poseidon2_hash_b_3, poseidon2_hash_end, poseidon2_hash_input_0, poseidon2_hash_input_1, poseidon2_hash_input_2, poseidon2_hash_input_len, poseidon2_hash_num_perm_rounds_rem, poseidon2_hash_num_perm_rounds_rem_inv, poseidon2_hash_output, poseidon2_hash_padding, poseidon2_hash_sel, poseidon2_hash_start, poseidon2_perm_B_10_0, poseidon2_perm_B_10_1, poseidon2_perm_B_10_2, poseidon2_perm_B_10_3, poseidon2_perm_B_11_0, poseidon2_perm_B_11_1, poseidon2_perm_B_11_2, poseidon2_perm_B_11_3, poseidon2_perm_B_12_0, poseidon2_perm_B_12_1, poseidon2_perm_B_12_2, poseidon2_perm_B_12_3, poseidon2_perm_B_13_0, poseidon2_perm_B_13_1, poseidon2_perm_B_13_2, poseidon2_perm_B_13_3, poseidon2_perm_B_14_0, poseidon2_perm_B_14_1, poseidon2_perm_B_14_2, poseidon2_perm_B_14_3, poseidon2_perm_B_15_0, poseidon2_perm_B_15_1, poseidon2_perm_B_15_2, poseidon2_perm_B_15_3, poseidon2_perm_B_16_0, poseidon2_perm_B_16_1, poseidon2_perm_B_16_2, poseidon2_perm_B_16_3, poseidon2_perm_B_17_0, poseidon2_perm_B_17_1, poseidon2_perm_B_17_2, poseidon2_perm_B_17_3, poseidon2_perm_B_18_0, poseidon2_perm_B_18_1, poseidon2_perm_B_18_2, poseidon2_perm_B_18_3, poseidon2_perm_B_19_0, poseidon2_perm_B_19_1, poseidon2_perm_B_19_2, poseidon2_perm_B_19_3, poseidon2_perm_B_20_0, poseidon2_perm_B_20_1, poseidon2_perm_B_20_2, poseidon2_perm_B_20_3, poseidon2_perm_B_21_0, poseidon2_perm_B_21_1, poseidon2_perm_B_21_2, poseidon2_perm_B_21_3, poseidon2_perm_B_22_0, poseidon2_perm_B_22_1, poseidon2_perm_B_22_2, poseidon2_perm_B_22_3, poseidon2_perm_B_23_0, poseidon2_perm_B_23_1, poseidon2_perm_B_23_2, poseidon2_perm_B_23_3, poseidon2_perm_B_24_0, poseidon2_perm_B_24_1, poseidon2_perm_B_24_2, poseidon2_perm_B_24_3, poseidon2_perm_B_25_0, poseidon2_perm_B_25_1, poseidon2_perm_B_25_2, poseidon2_perm_B_25_3, poseidon2_perm_B_26_0, poseidon2_perm_B_26_1, poseidon2_perm_B_26_2, poseidon2_perm_B_26_3, poseidon2_perm_B_27_0, poseidon2_perm_B_27_1, poseidon2_perm_B_27_2, poseidon2_perm_B_27_3, poseidon2_perm_B_28_0, poseidon2_perm_B_28_1, poseidon2_perm_B_28_2, poseidon2_perm_B_28_3, poseidon2_perm_B_29_0, poseidon2_perm_B_29_1, poseidon2_perm_B_29_2, poseidon2_perm_B_29_3, poseidon2_perm_B_30_0, poseidon2_perm_B_30_1, poseidon2_perm_B_30_2, poseidon2_perm_B_30_3, poseidon2_perm_B_31_0, poseidon2_perm_B_31_1, poseidon2_perm_B_31_2, poseidon2_perm_B_31_3, poseidon2_perm_B_32_0, poseidon2_perm_B_32_1, poseidon2_perm_B_32_2, poseidon2_perm_B_32_3, poseidon2_perm_B_33_0, poseidon2_perm_B_33_1, poseidon2_perm_B_33_2, poseidon2_perm_B_33_3, poseidon2_perm_B_34_0, poseidon2_perm_B_34_1, poseidon2_perm_B_34_2, poseidon2_perm_B_34_3, poseidon2_perm_B_35_0, poseidon2_perm_B_35_1, poseidon2_perm_B_35_2, poseidon2_perm_B_35_3, poseidon2_perm_B_36_0, poseidon2_perm_B_36_1, poseidon2_perm_B_36_2, poseidon2_perm_B_36_3, poseidon2_perm_B_37_0, poseidon2_perm_B_37_1, poseidon2_perm_B_37_2, poseidon2_perm_B_37_3, poseidon2_perm_B_38_0, poseidon2_perm_B_38_1, poseidon2_perm_B_38_2, poseidon2_perm_B_38_3, poseidon2_perm_B_39_0, poseidon2_perm_B_39_1, poseidon2_perm_B_39_2, poseidon2_perm_B_39_3, poseidon2_perm_B_40_0, poseidon2_perm_B_40_1, poseidon2_perm_B_40_2, poseidon2_perm_B_40_3, poseidon2_perm_B_41_0, poseidon2_perm_B_41_1, poseidon2_perm_B_41_2, poseidon2_perm_B_41_3, poseidon2_perm_B_42_0, poseidon2_perm_B_42_1, poseidon2_perm_B_42_2, poseidon2_perm_B_42_3, poseidon2_perm_B_43_0, poseidon2_perm_B_43_1, poseidon2_perm_B_43_2, poseidon2_perm_B_43_3, poseidon2_perm_B_44_0, poseidon2_perm_B_44_1, poseidon2_perm_B_44_2, poseidon2_perm_B_44_3, poseidon2_perm_B_45_0, poseidon2_perm_B_45_1, poseidon2_perm_B_45_2, poseidon2_perm_B_45_3, poseidon2_perm_B_46_0, poseidon2_perm_B_46_1, poseidon2_perm_B_46_2, poseidon2_perm_B_46_3, poseidon2_perm_B_47_0, poseidon2_perm_B_47_1, poseidon2_perm_B_47_2, poseidon2_perm_B_47_3, poseidon2_perm_B_48_0, poseidon2_perm_B_48_1, poseidon2_perm_B_48_2, poseidon2_perm_B_48_3, poseidon2_perm_B_49_0, poseidon2_perm_B_49_1, poseidon2_perm_B_49_2, poseidon2_perm_B_49_3, poseidon2_perm_B_4_0, poseidon2_perm_B_4_1, poseidon2_perm_B_4_2, poseidon2_perm_B_4_3, poseidon2_perm_B_50_0, poseidon2_perm_B_50_1, poseidon2_perm_B_50_2, poseidon2_perm_B_50_3, poseidon2_perm_B_51_0, poseidon2_perm_B_51_1, poseidon2_perm_B_51_2, poseidon2_perm_B_51_3, poseidon2_perm_B_52_0, poseidon2_perm_B_52_1, poseidon2_perm_B_52_2, poseidon2_perm_B_52_3, poseidon2_perm_B_53_0, poseidon2_perm_B_53_1, poseidon2_perm_B_53_2, poseidon2_perm_B_53_3, poseidon2_perm_B_54_0, poseidon2_perm_B_54_1, poseidon2_perm_B_54_2, poseidon2_perm_B_54_3, poseidon2_perm_B_55_0, poseidon2_perm_B_55_1, poseidon2_perm_B_55_2, poseidon2_perm_B_55_3, poseidon2_perm_B_56_0, poseidon2_perm_B_56_1, poseidon2_perm_B_56_2, poseidon2_perm_B_56_3, poseidon2_perm_B_57_0, poseidon2_perm_B_57_1, poseidon2_perm_B_57_2, poseidon2_perm_B_57_3, poseidon2_perm_B_58_0, poseidon2_perm_B_58_1, poseidon2_perm_B_58_2, poseidon2_perm_B_58_3, poseidon2_perm_B_59_0, poseidon2_perm_B_59_1, poseidon2_perm_B_59_2, poseidon2_perm_B_59_3, poseidon2_perm_B_5_0, poseidon2_perm_B_5_1, poseidon2_perm_B_5_2, poseidon2_perm_B_5_3, poseidon2_perm_B_6_0, poseidon2_perm_B_6_1, poseidon2_perm_B_6_2, poseidon2_perm_B_6_3, poseidon2_perm_B_7_0, poseidon2_perm_B_7_1, poseidon2_perm_B_7_2, poseidon2_perm_B_7_3, poseidon2_perm_B_8_0, poseidon2_perm_B_8_1, poseidon2_perm_B_8_2, poseidon2_perm_B_8_3, poseidon2_perm_B_9_0, poseidon2_perm_B_9_1, poseidon2_perm_B_9_2, poseidon2_perm_B_9_3, poseidon2_perm_EXT_LAYER_4, poseidon2_perm_EXT_LAYER_5, poseidon2_perm_EXT_LAYER_6, poseidon2_perm_EXT_LAYER_7, poseidon2_perm_T_0_4, poseidon2_perm_T_0_5, poseidon2_perm_T_0_6, poseidon2_perm_T_0_7, poseidon2_perm_T_1_4, poseidon2_perm_T_1_5, poseidon2_perm_T_1_6, poseidon2_perm_T_1_7, poseidon2_perm_T_2_4, poseidon2_perm_T_2_5, poseidon2_perm_T_2_6, poseidon2_perm_T_2_7, poseidon2_perm_T_3_4, poseidon2_perm_T_3_5, poseidon2_perm_T_3_6, poseidon2_perm_T_3_7, poseidon2_perm_T_60_4, poseidon2_perm_T_60_5, poseidon2_perm_T_60_6, poseidon2_perm_T_60_7, poseidon2_perm_T_61_4, poseidon2_perm_T_61_5, poseidon2_perm_T_61_6, poseidon2_perm_T_61_7, poseidon2_perm_T_62_4, poseidon2_perm_T_62_5, poseidon2_perm_T_62_6, poseidon2_perm_T_62_7, poseidon2_perm_T_63_4, poseidon2_perm_T_63_5, poseidon2_perm_T_63_6, poseidon2_perm_T_63_7, poseidon2_perm_a_0, poseidon2_perm_a_1, poseidon2_perm_a_2, poseidon2_perm_a_3, poseidon2_perm_b_0, poseidon2_perm_b_1, poseidon2_perm_b_2, poseidon2_perm_b_3, poseidon2_perm_sel, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_rng_chk_bits, range_check_sel, range_check_sel_r0_16_bit_rng_lookup, range_check_sel_r1_16_bit_rng_lookup, range_check_sel_r2_16_bit_rng_lookup, range_check_sel_r3_16_bit_rng_lookup, range_check_sel_r4_16_bit_rng_lookup, range_check_sel_r5_16_bit_rng_lookup, range_check_sel_r6_16_bit_rng_lookup, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, scalar_mul_bit, scalar_mul_bit_idx, scalar_mul_bit_radix, scalar_mul_end, scalar_mul_not_end, scalar_mul_point_inf, scalar_mul_point_x, scalar_mul_point_y, scalar_mul_res_inf, scalar_mul_res_x, scalar_mul_res_y, scalar_mul_scalar, scalar_mul_sel, scalar_mul_should_add, scalar_mul_start, scalar_mul_temp_inf, scalar_mul_temp_x, scalar_mul_temp_y, sha256_a, sha256_a_and_b, sha256_a_and_b_xor_a_and_c, sha256_a_and_c, sha256_a_rotr_13, sha256_a_rotr_2, sha256_a_rotr_22, sha256_a_rotr_2_xor_a_rotr_13, sha256_and_sel, sha256_b, sha256_b_and_c, sha256_c, sha256_ch, sha256_clk, sha256_computed_w_lhs, sha256_computed_w_rhs, sha256_d, sha256_e, sha256_e_and_f, sha256_e_rotr_11, sha256_e_rotr_25, sha256_e_rotr_6, sha256_e_rotr_6_xor_e_rotr_11, sha256_f, sha256_g, sha256_h, sha256_helper_w0, sha256_helper_w1, sha256_helper_w10, sha256_helper_w11, sha256_helper_w12, sha256_helper_w13, sha256_helper_w14, sha256_helper_w15, sha256_helper_w2, sha256_helper_w3, sha256_helper_w4, sha256_helper_w5, sha256_helper_w6, sha256_helper_w7, sha256_helper_w8, sha256_helper_w9, sha256_init_a, sha256_init_b, sha256_init_c, sha256_init_d, sha256_init_e, sha256_init_f, sha256_init_g, sha256_init_h, sha256_input_offset, sha256_is_input_round, sha256_latch, sha256_lhs_a_13, sha256_lhs_a_2, sha256_lhs_a_22, sha256_lhs_e_11, sha256_lhs_e_25, sha256_lhs_e_6, sha256_lhs_w_10, sha256_lhs_w_17, sha256_lhs_w_18, sha256_lhs_w_19, sha256_lhs_w_3, sha256_lhs_w_7, sha256_maj, sha256_next_a_lhs, sha256_next_a_rhs, sha256_next_e_lhs, sha256_next_e_rhs, sha256_not_e, sha256_not_e_and_g, sha256_output_a_lhs, sha256_output_a_rhs, sha256_output_b_lhs, sha256_output_b_rhs, sha256_output_c_lhs, sha256_output_c_rhs, sha256_output_d_lhs, sha256_output_d_rhs, sha256_output_e_lhs, sha256_output_e_rhs, sha256_output_f_lhs, sha256_output_f_rhs, sha256_output_g_lhs, sha256_output_g_rhs, sha256_output_h_lhs, sha256_output_h_rhs, sha256_output_offset, sha256_perform_round, sha256_rhs_a_13, sha256_rhs_a_2, sha256_rhs_a_22, sha256_rhs_e_11, sha256_rhs_e_25, sha256_rhs_e_6, sha256_rhs_w_10, sha256_rhs_w_17, sha256_rhs_w_18, sha256_rhs_w_19, sha256_rhs_w_3, sha256_rhs_w_7, sha256_round_constant, sha256_round_count, sha256_rounds_remaining, sha256_rounds_remaining_inv, sha256_s_0, sha256_s_1, sha256_sel, sha256_start, sha256_state_offset, sha256_w, sha256_w_15_rotr_18, sha256_w_15_rotr_7, sha256_w_15_rotr_7_xor_w_15_rotr_18, sha256_w_15_rshift_3, sha256_w_2_rotr_17, sha256_w_2_rotr_17_xor_w_2_rotr_19, sha256_w_2_rotr_19, sha256_w_2_rshift_10, sha256_w_s_0, sha256_w_s_1, sha256_xor_sel, to_radix_acc, to_radix_acc_under_p, to_radix_end, to_radix_exponent, to_radix_found, to_radix_is_unsafe_limb, to_radix_limb, to_radix_limb_eq_p, to_radix_limb_index, to_radix_limb_lt_p, to_radix_limb_p_diff, to_radix_limb_radix_diff, to_radix_not_end, to_radix_not_padding_limb, to_radix_p_limb, to_radix_radix, to_radix_rem_inverse, to_radix_safe_limbs, to_radix_safety_diff_inverse, to_radix_sel, to_radix_start, to_radix_value, lookup_poseidon2_hash_poseidon2_perm_counts, lookup_range_check_dyn_rng_chk_pow_2_counts, lookup_range_check_dyn_diff_is_u16_counts, lookup_range_check_r0_is_u16_counts, lookup_range_check_r1_is_u16_counts, lookup_range_check_r2_is_u16_counts, lookup_range_check_r3_is_u16_counts, lookup_range_check_r4_is_u16_counts, lookup_range_check_r5_is_u16_counts, lookup_range_check_r6_is_u16_counts, lookup_range_check_r7_is_u16_counts, lookup_to_radix_limb_range_counts, lookup_to_radix_limb_less_than_radix_range_counts, lookup_to_radix_fetch_safe_limbs_counts, lookup_to_radix_fetch_p_limb_counts, lookup_to_radix_limb_p_diff_range_counts, lookup_scalar_mul_to_radix_counts, lookup_scalar_mul_double_counts, lookup_scalar_mul_add_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_0_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_1_counts, lookup_address_derivation_partial_address_poseidon2_counts, lookup_address_derivation_public_keys_hash_poseidon2_0_counts, lookup_address_derivation_public_keys_hash_poseidon2_1_counts, lookup_address_derivation_public_keys_hash_poseidon2_2_counts, lookup_address_derivation_public_keys_hash_poseidon2_3_counts, lookup_address_derivation_public_keys_hash_poseidon2_4_counts, lookup_address_derivation_preaddress_poseidon2_counts, lookup_address_derivation_preaddress_scalar_mul_counts, lookup_address_derivation_address_ecadd_counts, lookup_bc_decomposition_bytes_are_bytes_counts, lookup_bc_decomposition_abs_diff_is_u16_counts, lookup_bc_decomposition_bytes_to_read_as_unary_counts, lookup_bc_hashing_get_packed_field_counts, lookup_bc_hashing_iv_is_len_counts, lookup_bc_hashing_poseidon2_hash_counts, lookup_bc_retrieval_class_id_derivation_counts, lookup_bc_retrieval_bytecode_hash_is_correct_counts, lookup_instr_fetching_abs_diff_positive_counts, lookup_instr_fetching_pc_abs_diff_positive_lo_counts, lookup_instr_fetching_pc_abs_diff_positive_hi_counts, lookup_instr_fetching_bytes_from_bc_dec_counts, lookup_instr_fetching_wire_instruction_info_counts, lookup_class_id_derivation_class_id_poseidon2_0_counts, lookup_class_id_derivation_class_id_poseidon2_1_counts, lookup_bitwise_integral_tag_length_counts, lookup_bitwise_byte_operations_counts, lookup_sha256_round_constant_counts -#define AVM2_DERIVED_WITNESS_ENTITIES lookup_poseidon2_hash_poseidon2_perm_inv, lookup_range_check_dyn_rng_chk_pow_2_inv, lookup_range_check_dyn_diff_is_u16_inv, lookup_range_check_r0_is_u16_inv, lookup_range_check_r1_is_u16_inv, lookup_range_check_r2_is_u16_inv, lookup_range_check_r3_is_u16_inv, lookup_range_check_r4_is_u16_inv, lookup_range_check_r5_is_u16_inv, lookup_range_check_r6_is_u16_inv, lookup_range_check_r7_is_u16_inv, lookup_to_radix_limb_range_inv, lookup_to_radix_limb_less_than_radix_range_inv, lookup_to_radix_fetch_safe_limbs_inv, lookup_to_radix_fetch_p_limb_inv, lookup_to_radix_limb_p_diff_range_inv, lookup_scalar_mul_to_radix_inv, lookup_scalar_mul_double_inv, lookup_scalar_mul_add_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_0_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_1_inv, lookup_address_derivation_partial_address_poseidon2_inv, lookup_address_derivation_public_keys_hash_poseidon2_0_inv, lookup_address_derivation_public_keys_hash_poseidon2_1_inv, lookup_address_derivation_public_keys_hash_poseidon2_2_inv, lookup_address_derivation_public_keys_hash_poseidon2_3_inv, lookup_address_derivation_public_keys_hash_poseidon2_4_inv, lookup_address_derivation_preaddress_poseidon2_inv, lookup_address_derivation_preaddress_scalar_mul_inv, lookup_address_derivation_address_ecadd_inv, lookup_bc_decomposition_bytes_are_bytes_inv, lookup_bc_decomposition_abs_diff_is_u16_inv, lookup_bc_decomposition_bytes_to_read_as_unary_inv, lookup_bc_hashing_get_packed_field_inv, lookup_bc_hashing_iv_is_len_inv, lookup_bc_hashing_poseidon2_hash_inv, lookup_bc_retrieval_class_id_derivation_inv, lookup_bc_retrieval_bytecode_hash_is_correct_inv, lookup_instr_fetching_abs_diff_positive_inv, lookup_instr_fetching_pc_abs_diff_positive_lo_inv, lookup_instr_fetching_pc_abs_diff_positive_hi_inv, lookup_instr_fetching_bytes_from_bc_dec_inv, lookup_instr_fetching_wire_instruction_info_inv, lookup_class_id_derivation_class_id_poseidon2_0_inv, lookup_class_id_derivation_class_id_poseidon2_1_inv, lookup_bitwise_integral_tag_length_inv, lookup_bitwise_byte_operations_inv, lookup_sha256_round_constant_inv +#define AVM2_WIRE_ENTITIES execution_input, address_derivation_address, address_derivation_address_y, address_derivation_class_id, address_derivation_deployer_addr, address_derivation_g1_x, address_derivation_g1_y, address_derivation_incoming_viewing_key_x, address_derivation_incoming_viewing_key_y, address_derivation_init_hash, address_derivation_nullifier_key_x, address_derivation_nullifier_key_y, address_derivation_outgoing_viewing_key_x, address_derivation_outgoing_viewing_key_y, address_derivation_partial_address, address_derivation_partial_address_domain_separator, address_derivation_preaddress, address_derivation_preaddress_domain_separator, address_derivation_preaddress_public_key_x, address_derivation_preaddress_public_key_y, address_derivation_public_keys_hash, address_derivation_public_keys_hash_domain_separator, address_derivation_salt, address_derivation_salted_init_hash, address_derivation_sel, address_derivation_tagging_key_x, address_derivation_tagging_key_y, alu_dst_addr, alu_ia, alu_ia_addr, alu_ib, alu_ib_addr, alu_ic, alu_op, alu_sel_op_add, bc_decomposition_abs_diff, bc_decomposition_bytes, bc_decomposition_bytes_pc_plus_1, bc_decomposition_bytes_pc_plus_10, bc_decomposition_bytes_pc_plus_11, bc_decomposition_bytes_pc_plus_12, bc_decomposition_bytes_pc_plus_13, bc_decomposition_bytes_pc_plus_14, bc_decomposition_bytes_pc_plus_15, bc_decomposition_bytes_pc_plus_16, bc_decomposition_bytes_pc_plus_17, bc_decomposition_bytes_pc_plus_18, bc_decomposition_bytes_pc_plus_19, bc_decomposition_bytes_pc_plus_2, bc_decomposition_bytes_pc_plus_20, bc_decomposition_bytes_pc_plus_21, bc_decomposition_bytes_pc_plus_22, bc_decomposition_bytes_pc_plus_23, bc_decomposition_bytes_pc_plus_24, bc_decomposition_bytes_pc_plus_25, bc_decomposition_bytes_pc_plus_26, bc_decomposition_bytes_pc_plus_27, bc_decomposition_bytes_pc_plus_28, bc_decomposition_bytes_pc_plus_29, bc_decomposition_bytes_pc_plus_3, bc_decomposition_bytes_pc_plus_30, bc_decomposition_bytes_pc_plus_31, bc_decomposition_bytes_pc_plus_32, bc_decomposition_bytes_pc_plus_33, bc_decomposition_bytes_pc_plus_34, bc_decomposition_bytes_pc_plus_35, bc_decomposition_bytes_pc_plus_36, bc_decomposition_bytes_pc_plus_4, bc_decomposition_bytes_pc_plus_5, bc_decomposition_bytes_pc_plus_6, bc_decomposition_bytes_pc_plus_7, bc_decomposition_bytes_pc_plus_8, bc_decomposition_bytes_pc_plus_9, bc_decomposition_bytes_rem_inv, bc_decomposition_bytes_rem_min_one_inv, bc_decomposition_bytes_remaining, bc_decomposition_bytes_to_read, bc_decomposition_bytes_to_read_unary, bc_decomposition_id, bc_decomposition_last_of_contract, bc_decomposition_packed_field, bc_decomposition_pc, bc_decomposition_sel, bc_decomposition_sel_overflow_correction_needed, bc_decomposition_sel_packed, bc_decomposition_sel_pc_plus_1, bc_decomposition_sel_pc_plus_10, bc_decomposition_sel_pc_plus_11, bc_decomposition_sel_pc_plus_12, bc_decomposition_sel_pc_plus_13, bc_decomposition_sel_pc_plus_14, bc_decomposition_sel_pc_plus_15, bc_decomposition_sel_pc_plus_16, bc_decomposition_sel_pc_plus_17, bc_decomposition_sel_pc_plus_18, bc_decomposition_sel_pc_plus_19, bc_decomposition_sel_pc_plus_2, bc_decomposition_sel_pc_plus_20, bc_decomposition_sel_pc_plus_21, bc_decomposition_sel_pc_plus_22, bc_decomposition_sel_pc_plus_23, bc_decomposition_sel_pc_plus_24, bc_decomposition_sel_pc_plus_25, bc_decomposition_sel_pc_plus_26, bc_decomposition_sel_pc_plus_27, bc_decomposition_sel_pc_plus_28, bc_decomposition_sel_pc_plus_29, bc_decomposition_sel_pc_plus_3, bc_decomposition_sel_pc_plus_30, bc_decomposition_sel_pc_plus_31, bc_decomposition_sel_pc_plus_32, bc_decomposition_sel_pc_plus_33, bc_decomposition_sel_pc_plus_34, bc_decomposition_sel_pc_plus_35, bc_decomposition_sel_pc_plus_36, bc_decomposition_sel_pc_plus_4, bc_decomposition_sel_pc_plus_5, bc_decomposition_sel_pc_plus_6, bc_decomposition_sel_pc_plus_7, bc_decomposition_sel_pc_plus_8, bc_decomposition_sel_pc_plus_9, bc_hashing_bytecode_id, bc_hashing_incremental_hash, bc_hashing_latch, bc_hashing_output_hash, bc_hashing_packed_field, bc_hashing_pc_index, bc_hashing_sel, bc_hashing_start, bc_retrieval_address, bc_retrieval_artifact_hash, bc_retrieval_bytecode_id, bc_retrieval_class_id, bc_retrieval_deployer_addr, bc_retrieval_err, bc_retrieval_incoming_viewing_key_x, bc_retrieval_incoming_viewing_key_y, bc_retrieval_init_hash, bc_retrieval_nullifier_key_x, bc_retrieval_nullifier_key_y, bc_retrieval_outgoing_viewing_key_x, bc_retrieval_outgoing_viewing_key_y, bc_retrieval_private_function_root, bc_retrieval_public_bytecode_commitment, bc_retrieval_salt, bc_retrieval_sel, bc_retrieval_siloed_address, bc_retrieval_tagging_key_x, bc_retrieval_tagging_key_y, bitwise_acc_ia, bitwise_acc_ib, bitwise_acc_ic, bitwise_ctr, bitwise_ctr_inv, bitwise_ctr_min_one_inv, bitwise_ia_byte, bitwise_ib_byte, bitwise_ic_byte, bitwise_last, bitwise_op_id, bitwise_sel, bitwise_start, bitwise_tag, class_id_derivation_artifact_hash, class_id_derivation_class_id, class_id_derivation_private_function_root, class_id_derivation_public_bytecode_commitment, class_id_derivation_sel, class_id_derivation_temp_constant_for_lookup, ecc_add_op, ecc_double_op, ecc_inv_2_p_y, ecc_inv_x_diff, ecc_inv_y_diff, ecc_lambda, ecc_p_is_inf, ecc_p_x, ecc_p_y, ecc_q_is_inf, ecc_q_x, ecc_q_y, ecc_r_is_inf, ecc_r_x, ecc_r_y, ecc_result_infinity, ecc_sel, ecc_x_match, ecc_y_match, execution_addressing_error_idx, execution_addressing_error_kind, execution_base_address_tag, execution_base_address_val, execution_bytecode_id, execution_clk, execution_ex_opcode, execution_indirect, execution_last, execution_op1, execution_op1_after_relative, execution_op2, execution_op2_after_relative, execution_op3, execution_op3_after_relative, execution_op4, execution_op4_after_relative, execution_pc, execution_rop1, execution_rop2, execution_rop3, execution_rop4, execution_sel, execution_sel_addressing_error, execution_sel_op1_is_address, execution_sel_op2_is_address, execution_sel_op3_is_address, execution_sel_op4_is_address, instr_fetching_bc_id_diff_inv, instr_fetching_bd0, instr_fetching_bd1, instr_fetching_bd10, instr_fetching_bd11, instr_fetching_bd12, instr_fetching_bd13, instr_fetching_bd14, instr_fetching_bd15, instr_fetching_bd16, instr_fetching_bd17, instr_fetching_bd18, instr_fetching_bd19, instr_fetching_bd2, instr_fetching_bd20, instr_fetching_bd21, instr_fetching_bd22, instr_fetching_bd23, instr_fetching_bd24, instr_fetching_bd25, instr_fetching_bd26, instr_fetching_bd27, instr_fetching_bd28, instr_fetching_bd29, instr_fetching_bd3, instr_fetching_bd30, instr_fetching_bd31, instr_fetching_bd32, instr_fetching_bd33, instr_fetching_bd34, instr_fetching_bd35, instr_fetching_bd36, instr_fetching_bd4, instr_fetching_bd5, instr_fetching_bd6, instr_fetching_bd7, instr_fetching_bd8, instr_fetching_bd9, instr_fetching_bytecode_id, instr_fetching_bytecode_size, instr_fetching_bytes_remaining, instr_fetching_bytes_to_read, instr_fetching_exec_opcode, instr_fetching_indirect, instr_fetching_instr_abs_diff, instr_fetching_instr_out_of_range, instr_fetching_instr_size, instr_fetching_last_of_bytecode, instr_fetching_op1, instr_fetching_op2, instr_fetching_op3, instr_fetching_op4, instr_fetching_op5, instr_fetching_op6, instr_fetching_op7, instr_fetching_opcode_out_of_range, instr_fetching_parsing_err, instr_fetching_pc, instr_fetching_pc_abs_diff, instr_fetching_pc_abs_diff_hi, instr_fetching_pc_abs_diff_lo, instr_fetching_pc_out_of_range, instr_fetching_sel, instr_fetching_sel_op_dc_0, instr_fetching_sel_op_dc_1, instr_fetching_sel_op_dc_10, instr_fetching_sel_op_dc_11, instr_fetching_sel_op_dc_12, instr_fetching_sel_op_dc_13, instr_fetching_sel_op_dc_14, instr_fetching_sel_op_dc_15, instr_fetching_sel_op_dc_16, instr_fetching_sel_op_dc_17, instr_fetching_sel_op_dc_2, instr_fetching_sel_op_dc_3, instr_fetching_sel_op_dc_4, instr_fetching_sel_op_dc_5, instr_fetching_sel_op_dc_6, instr_fetching_sel_op_dc_7, instr_fetching_sel_op_dc_8, instr_fetching_sel_op_dc_9, instr_fetching_sel_opcode_defined, poseidon2_hash_a_0, poseidon2_hash_a_1, poseidon2_hash_a_2, poseidon2_hash_a_3, poseidon2_hash_b_0, poseidon2_hash_b_1, poseidon2_hash_b_2, poseidon2_hash_b_3, poseidon2_hash_end, poseidon2_hash_input_0, poseidon2_hash_input_1, poseidon2_hash_input_2, poseidon2_hash_input_len, poseidon2_hash_num_perm_rounds_rem, poseidon2_hash_num_perm_rounds_rem_inv, poseidon2_hash_output, poseidon2_hash_padding, poseidon2_hash_sel, poseidon2_hash_start, poseidon2_perm_B_10_0, poseidon2_perm_B_10_1, poseidon2_perm_B_10_2, poseidon2_perm_B_10_3, poseidon2_perm_B_11_0, poseidon2_perm_B_11_1, poseidon2_perm_B_11_2, poseidon2_perm_B_11_3, poseidon2_perm_B_12_0, poseidon2_perm_B_12_1, poseidon2_perm_B_12_2, poseidon2_perm_B_12_3, poseidon2_perm_B_13_0, poseidon2_perm_B_13_1, poseidon2_perm_B_13_2, poseidon2_perm_B_13_3, poseidon2_perm_B_14_0, poseidon2_perm_B_14_1, poseidon2_perm_B_14_2, poseidon2_perm_B_14_3, poseidon2_perm_B_15_0, poseidon2_perm_B_15_1, poseidon2_perm_B_15_2, poseidon2_perm_B_15_3, poseidon2_perm_B_16_0, poseidon2_perm_B_16_1, poseidon2_perm_B_16_2, poseidon2_perm_B_16_3, poseidon2_perm_B_17_0, poseidon2_perm_B_17_1, poseidon2_perm_B_17_2, poseidon2_perm_B_17_3, poseidon2_perm_B_18_0, poseidon2_perm_B_18_1, poseidon2_perm_B_18_2, poseidon2_perm_B_18_3, poseidon2_perm_B_19_0, poseidon2_perm_B_19_1, poseidon2_perm_B_19_2, poseidon2_perm_B_19_3, poseidon2_perm_B_20_0, poseidon2_perm_B_20_1, poseidon2_perm_B_20_2, poseidon2_perm_B_20_3, poseidon2_perm_B_21_0, poseidon2_perm_B_21_1, poseidon2_perm_B_21_2, poseidon2_perm_B_21_3, poseidon2_perm_B_22_0, poseidon2_perm_B_22_1, poseidon2_perm_B_22_2, poseidon2_perm_B_22_3, poseidon2_perm_B_23_0, poseidon2_perm_B_23_1, poseidon2_perm_B_23_2, poseidon2_perm_B_23_3, poseidon2_perm_B_24_0, poseidon2_perm_B_24_1, poseidon2_perm_B_24_2, poseidon2_perm_B_24_3, poseidon2_perm_B_25_0, poseidon2_perm_B_25_1, poseidon2_perm_B_25_2, poseidon2_perm_B_25_3, poseidon2_perm_B_26_0, poseidon2_perm_B_26_1, poseidon2_perm_B_26_2, poseidon2_perm_B_26_3, poseidon2_perm_B_27_0, poseidon2_perm_B_27_1, poseidon2_perm_B_27_2, poseidon2_perm_B_27_3, poseidon2_perm_B_28_0, poseidon2_perm_B_28_1, poseidon2_perm_B_28_2, poseidon2_perm_B_28_3, poseidon2_perm_B_29_0, poseidon2_perm_B_29_1, poseidon2_perm_B_29_2, poseidon2_perm_B_29_3, poseidon2_perm_B_30_0, poseidon2_perm_B_30_1, poseidon2_perm_B_30_2, poseidon2_perm_B_30_3, poseidon2_perm_B_31_0, poseidon2_perm_B_31_1, poseidon2_perm_B_31_2, poseidon2_perm_B_31_3, poseidon2_perm_B_32_0, poseidon2_perm_B_32_1, poseidon2_perm_B_32_2, poseidon2_perm_B_32_3, poseidon2_perm_B_33_0, poseidon2_perm_B_33_1, poseidon2_perm_B_33_2, poseidon2_perm_B_33_3, poseidon2_perm_B_34_0, poseidon2_perm_B_34_1, poseidon2_perm_B_34_2, poseidon2_perm_B_34_3, poseidon2_perm_B_35_0, poseidon2_perm_B_35_1, poseidon2_perm_B_35_2, poseidon2_perm_B_35_3, poseidon2_perm_B_36_0, poseidon2_perm_B_36_1, poseidon2_perm_B_36_2, poseidon2_perm_B_36_3, poseidon2_perm_B_37_0, poseidon2_perm_B_37_1, poseidon2_perm_B_37_2, poseidon2_perm_B_37_3, poseidon2_perm_B_38_0, poseidon2_perm_B_38_1, poseidon2_perm_B_38_2, poseidon2_perm_B_38_3, poseidon2_perm_B_39_0, poseidon2_perm_B_39_1, poseidon2_perm_B_39_2, poseidon2_perm_B_39_3, poseidon2_perm_B_40_0, poseidon2_perm_B_40_1, poseidon2_perm_B_40_2, poseidon2_perm_B_40_3, poseidon2_perm_B_41_0, poseidon2_perm_B_41_1, poseidon2_perm_B_41_2, poseidon2_perm_B_41_3, poseidon2_perm_B_42_0, poseidon2_perm_B_42_1, poseidon2_perm_B_42_2, poseidon2_perm_B_42_3, poseidon2_perm_B_43_0, poseidon2_perm_B_43_1, poseidon2_perm_B_43_2, poseidon2_perm_B_43_3, poseidon2_perm_B_44_0, poseidon2_perm_B_44_1, poseidon2_perm_B_44_2, poseidon2_perm_B_44_3, poseidon2_perm_B_45_0, poseidon2_perm_B_45_1, poseidon2_perm_B_45_2, poseidon2_perm_B_45_3, poseidon2_perm_B_46_0, poseidon2_perm_B_46_1, poseidon2_perm_B_46_2, poseidon2_perm_B_46_3, poseidon2_perm_B_47_0, poseidon2_perm_B_47_1, poseidon2_perm_B_47_2, poseidon2_perm_B_47_3, poseidon2_perm_B_48_0, poseidon2_perm_B_48_1, poseidon2_perm_B_48_2, poseidon2_perm_B_48_3, poseidon2_perm_B_49_0, poseidon2_perm_B_49_1, poseidon2_perm_B_49_2, poseidon2_perm_B_49_3, poseidon2_perm_B_4_0, poseidon2_perm_B_4_1, poseidon2_perm_B_4_2, poseidon2_perm_B_4_3, poseidon2_perm_B_50_0, poseidon2_perm_B_50_1, poseidon2_perm_B_50_2, poseidon2_perm_B_50_3, poseidon2_perm_B_51_0, poseidon2_perm_B_51_1, poseidon2_perm_B_51_2, poseidon2_perm_B_51_3, poseidon2_perm_B_52_0, poseidon2_perm_B_52_1, poseidon2_perm_B_52_2, poseidon2_perm_B_52_3, poseidon2_perm_B_53_0, poseidon2_perm_B_53_1, poseidon2_perm_B_53_2, poseidon2_perm_B_53_3, poseidon2_perm_B_54_0, poseidon2_perm_B_54_1, poseidon2_perm_B_54_2, poseidon2_perm_B_54_3, poseidon2_perm_B_55_0, poseidon2_perm_B_55_1, poseidon2_perm_B_55_2, poseidon2_perm_B_55_3, poseidon2_perm_B_56_0, poseidon2_perm_B_56_1, poseidon2_perm_B_56_2, poseidon2_perm_B_56_3, poseidon2_perm_B_57_0, poseidon2_perm_B_57_1, poseidon2_perm_B_57_2, poseidon2_perm_B_57_3, poseidon2_perm_B_58_0, poseidon2_perm_B_58_1, poseidon2_perm_B_58_2, poseidon2_perm_B_58_3, poseidon2_perm_B_59_0, poseidon2_perm_B_59_1, poseidon2_perm_B_59_2, poseidon2_perm_B_59_3, poseidon2_perm_B_5_0, poseidon2_perm_B_5_1, poseidon2_perm_B_5_2, poseidon2_perm_B_5_3, poseidon2_perm_B_6_0, poseidon2_perm_B_6_1, poseidon2_perm_B_6_2, poseidon2_perm_B_6_3, poseidon2_perm_B_7_0, poseidon2_perm_B_7_1, poseidon2_perm_B_7_2, poseidon2_perm_B_7_3, poseidon2_perm_B_8_0, poseidon2_perm_B_8_1, poseidon2_perm_B_8_2, poseidon2_perm_B_8_3, poseidon2_perm_B_9_0, poseidon2_perm_B_9_1, poseidon2_perm_B_9_2, poseidon2_perm_B_9_3, poseidon2_perm_EXT_LAYER_4, poseidon2_perm_EXT_LAYER_5, poseidon2_perm_EXT_LAYER_6, poseidon2_perm_EXT_LAYER_7, poseidon2_perm_T_0_4, poseidon2_perm_T_0_5, poseidon2_perm_T_0_6, poseidon2_perm_T_0_7, poseidon2_perm_T_1_4, poseidon2_perm_T_1_5, poseidon2_perm_T_1_6, poseidon2_perm_T_1_7, poseidon2_perm_T_2_4, poseidon2_perm_T_2_5, poseidon2_perm_T_2_6, poseidon2_perm_T_2_7, poseidon2_perm_T_3_4, poseidon2_perm_T_3_5, poseidon2_perm_T_3_6, poseidon2_perm_T_3_7, poseidon2_perm_T_60_4, poseidon2_perm_T_60_5, poseidon2_perm_T_60_6, poseidon2_perm_T_60_7, poseidon2_perm_T_61_4, poseidon2_perm_T_61_5, poseidon2_perm_T_61_6, poseidon2_perm_T_61_7, poseidon2_perm_T_62_4, poseidon2_perm_T_62_5, poseidon2_perm_T_62_6, poseidon2_perm_T_62_7, poseidon2_perm_T_63_4, poseidon2_perm_T_63_5, poseidon2_perm_T_63_6, poseidon2_perm_T_63_7, poseidon2_perm_a_0, poseidon2_perm_a_1, poseidon2_perm_a_2, poseidon2_perm_a_3, poseidon2_perm_b_0, poseidon2_perm_b_1, poseidon2_perm_b_2, poseidon2_perm_b_3, poseidon2_perm_sel, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_rng_chk_bits, range_check_sel, range_check_sel_r0_16_bit_rng_lookup, range_check_sel_r1_16_bit_rng_lookup, range_check_sel_r2_16_bit_rng_lookup, range_check_sel_r3_16_bit_rng_lookup, range_check_sel_r4_16_bit_rng_lookup, range_check_sel_r5_16_bit_rng_lookup, range_check_sel_r6_16_bit_rng_lookup, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, scalar_mul_bit, scalar_mul_bit_idx, scalar_mul_bit_radix, scalar_mul_end, scalar_mul_not_end, scalar_mul_point_inf, scalar_mul_point_x, scalar_mul_point_y, scalar_mul_res_inf, scalar_mul_res_x, scalar_mul_res_y, scalar_mul_scalar, scalar_mul_sel, scalar_mul_should_add, scalar_mul_start, scalar_mul_temp_inf, scalar_mul_temp_x, scalar_mul_temp_y, sha256_a, sha256_a_and_b, sha256_a_and_b_xor_a_and_c, sha256_a_and_c, sha256_a_rotr_13, sha256_a_rotr_2, sha256_a_rotr_22, sha256_a_rotr_2_xor_a_rotr_13, sha256_and_sel, sha256_b, sha256_b_and_c, sha256_c, sha256_ch, sha256_clk, sha256_computed_w_lhs, sha256_computed_w_rhs, sha256_d, sha256_e, sha256_e_and_f, sha256_e_rotr_11, sha256_e_rotr_25, sha256_e_rotr_6, sha256_e_rotr_6_xor_e_rotr_11, sha256_f, sha256_g, sha256_h, sha256_helper_w0, sha256_helper_w1, sha256_helper_w10, sha256_helper_w11, sha256_helper_w12, sha256_helper_w13, sha256_helper_w14, sha256_helper_w15, sha256_helper_w2, sha256_helper_w3, sha256_helper_w4, sha256_helper_w5, sha256_helper_w6, sha256_helper_w7, sha256_helper_w8, sha256_helper_w9, sha256_init_a, sha256_init_b, sha256_init_c, sha256_init_d, sha256_init_e, sha256_init_f, sha256_init_g, sha256_init_h, sha256_input_offset, sha256_is_input_round, sha256_latch, sha256_lhs_a_13, sha256_lhs_a_2, sha256_lhs_a_22, sha256_lhs_e_11, sha256_lhs_e_25, sha256_lhs_e_6, sha256_lhs_w_10, sha256_lhs_w_17, sha256_lhs_w_18, sha256_lhs_w_19, sha256_lhs_w_3, sha256_lhs_w_7, sha256_maj, sha256_next_a_lhs, sha256_next_a_rhs, sha256_next_e_lhs, sha256_next_e_rhs, sha256_not_e, sha256_not_e_and_g, sha256_output_a_lhs, sha256_output_a_rhs, sha256_output_b_lhs, sha256_output_b_rhs, sha256_output_c_lhs, sha256_output_c_rhs, sha256_output_d_lhs, sha256_output_d_rhs, sha256_output_e_lhs, sha256_output_e_rhs, sha256_output_f_lhs, sha256_output_f_rhs, sha256_output_g_lhs, sha256_output_g_rhs, sha256_output_h_lhs, sha256_output_h_rhs, sha256_output_offset, sha256_perform_round, sha256_rhs_a_13, sha256_rhs_a_2, sha256_rhs_a_22, sha256_rhs_e_11, sha256_rhs_e_25, sha256_rhs_e_6, sha256_rhs_w_10, sha256_rhs_w_17, sha256_rhs_w_18, sha256_rhs_w_19, sha256_rhs_w_3, sha256_rhs_w_7, sha256_round_constant, sha256_round_count, sha256_rounds_remaining, sha256_rounds_remaining_inv, sha256_s_0, sha256_s_1, sha256_sel, sha256_start, sha256_state_offset, sha256_w, sha256_w_15_rotr_18, sha256_w_15_rotr_7, sha256_w_15_rotr_7_xor_w_15_rotr_18, sha256_w_15_rshift_3, sha256_w_2_rotr_17, sha256_w_2_rotr_17_xor_w_2_rotr_19, sha256_w_2_rotr_19, sha256_w_2_rshift_10, sha256_w_s_0, sha256_w_s_1, sha256_xor_sel, to_radix_acc, to_radix_acc_under_p, to_radix_end, to_radix_exponent, to_radix_found, to_radix_is_unsafe_limb, to_radix_limb, to_radix_limb_eq_p, to_radix_limb_index, to_radix_limb_lt_p, to_radix_limb_p_diff, to_radix_limb_radix_diff, to_radix_not_end, to_radix_not_padding_limb, to_radix_p_limb, to_radix_radix, to_radix_rem_inverse, to_radix_safe_limbs, to_radix_safety_diff_inverse, to_radix_sel, to_radix_start, to_radix_value, lookup_poseidon2_hash_poseidon2_perm_counts, lookup_range_check_dyn_rng_chk_pow_2_counts, lookup_range_check_dyn_diff_is_u16_counts, lookup_range_check_r0_is_u16_counts, lookup_range_check_r1_is_u16_counts, lookup_range_check_r2_is_u16_counts, lookup_range_check_r3_is_u16_counts, lookup_range_check_r4_is_u16_counts, lookup_range_check_r5_is_u16_counts, lookup_range_check_r6_is_u16_counts, lookup_range_check_r7_is_u16_counts, lookup_to_radix_limb_range_counts, lookup_to_radix_limb_less_than_radix_range_counts, lookup_to_radix_fetch_safe_limbs_counts, lookup_to_radix_fetch_p_limb_counts, lookup_to_radix_limb_p_diff_range_counts, lookup_scalar_mul_to_radix_counts, lookup_scalar_mul_double_counts, lookup_scalar_mul_add_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_0_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_1_counts, lookup_address_derivation_partial_address_poseidon2_counts, lookup_address_derivation_public_keys_hash_poseidon2_0_counts, lookup_address_derivation_public_keys_hash_poseidon2_1_counts, lookup_address_derivation_public_keys_hash_poseidon2_2_counts, lookup_address_derivation_public_keys_hash_poseidon2_3_counts, lookup_address_derivation_public_keys_hash_poseidon2_4_counts, lookup_address_derivation_preaddress_poseidon2_counts, lookup_address_derivation_preaddress_scalar_mul_counts, lookup_address_derivation_address_ecadd_counts, lookup_bc_decomposition_bytes_are_bytes_counts, lookup_bc_decomposition_abs_diff_is_u16_counts, lookup_bc_decomposition_bytes_to_read_as_unary_counts, lookup_bc_hashing_get_packed_field_counts, lookup_bc_hashing_iv_is_len_counts, lookup_bc_hashing_poseidon2_hash_counts, lookup_bc_retrieval_class_id_derivation_counts, lookup_bc_retrieval_bytecode_hash_is_correct_counts, lookup_instr_fetching_instr_abs_diff_positive_counts, lookup_instr_fetching_pc_abs_diff_positive_lo_counts, lookup_instr_fetching_pc_abs_diff_positive_hi_counts, lookup_instr_fetching_bytes_from_bc_dec_counts, lookup_instr_fetching_wire_instruction_info_counts, lookup_class_id_derivation_class_id_poseidon2_0_counts, lookup_class_id_derivation_class_id_poseidon2_1_counts, lookup_bitwise_integral_tag_length_counts, lookup_bitwise_byte_operations_counts, lookup_sha256_round_constant_counts +#define AVM2_DERIVED_WITNESS_ENTITIES lookup_poseidon2_hash_poseidon2_perm_inv, lookup_range_check_dyn_rng_chk_pow_2_inv, lookup_range_check_dyn_diff_is_u16_inv, lookup_range_check_r0_is_u16_inv, lookup_range_check_r1_is_u16_inv, lookup_range_check_r2_is_u16_inv, lookup_range_check_r3_is_u16_inv, lookup_range_check_r4_is_u16_inv, lookup_range_check_r5_is_u16_inv, lookup_range_check_r6_is_u16_inv, lookup_range_check_r7_is_u16_inv, lookup_to_radix_limb_range_inv, lookup_to_radix_limb_less_than_radix_range_inv, lookup_to_radix_fetch_safe_limbs_inv, lookup_to_radix_fetch_p_limb_inv, lookup_to_radix_limb_p_diff_range_inv, lookup_scalar_mul_to_radix_inv, lookup_scalar_mul_double_inv, lookup_scalar_mul_add_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_0_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_1_inv, lookup_address_derivation_partial_address_poseidon2_inv, lookup_address_derivation_public_keys_hash_poseidon2_0_inv, lookup_address_derivation_public_keys_hash_poseidon2_1_inv, lookup_address_derivation_public_keys_hash_poseidon2_2_inv, lookup_address_derivation_public_keys_hash_poseidon2_3_inv, lookup_address_derivation_public_keys_hash_poseidon2_4_inv, lookup_address_derivation_preaddress_poseidon2_inv, lookup_address_derivation_preaddress_scalar_mul_inv, lookup_address_derivation_address_ecadd_inv, lookup_bc_decomposition_bytes_are_bytes_inv, lookup_bc_decomposition_abs_diff_is_u16_inv, lookup_bc_decomposition_bytes_to_read_as_unary_inv, lookup_bc_hashing_get_packed_field_inv, lookup_bc_hashing_iv_is_len_inv, lookup_bc_hashing_poseidon2_hash_inv, lookup_bc_retrieval_class_id_derivation_inv, lookup_bc_retrieval_bytecode_hash_is_correct_inv, lookup_instr_fetching_instr_abs_diff_positive_inv, lookup_instr_fetching_pc_abs_diff_positive_lo_inv, lookup_instr_fetching_pc_abs_diff_positive_hi_inv, lookup_instr_fetching_bytes_from_bc_dec_inv, lookup_instr_fetching_wire_instruction_info_inv, lookup_class_id_derivation_class_id_poseidon2_0_inv, lookup_class_id_derivation_class_id_poseidon2_1_inv, lookup_bitwise_integral_tag_length_inv, lookup_bitwise_byte_operations_inv, lookup_sha256_round_constant_inv #define AVM2_SHIFTED_ENTITIES bc_decomposition_bytes_shift, bc_decomposition_bytes_pc_plus_1_shift, bc_decomposition_bytes_pc_plus_10_shift, bc_decomposition_bytes_pc_plus_11_shift, bc_decomposition_bytes_pc_plus_12_shift, bc_decomposition_bytes_pc_plus_13_shift, bc_decomposition_bytes_pc_plus_14_shift, bc_decomposition_bytes_pc_plus_15_shift, bc_decomposition_bytes_pc_plus_16_shift, bc_decomposition_bytes_pc_plus_17_shift, bc_decomposition_bytes_pc_plus_18_shift, bc_decomposition_bytes_pc_plus_19_shift, bc_decomposition_bytes_pc_plus_2_shift, bc_decomposition_bytes_pc_plus_20_shift, bc_decomposition_bytes_pc_plus_21_shift, bc_decomposition_bytes_pc_plus_22_shift, bc_decomposition_bytes_pc_plus_23_shift, bc_decomposition_bytes_pc_plus_24_shift, bc_decomposition_bytes_pc_plus_25_shift, bc_decomposition_bytes_pc_plus_26_shift, bc_decomposition_bytes_pc_plus_27_shift, bc_decomposition_bytes_pc_plus_28_shift, bc_decomposition_bytes_pc_plus_29_shift, bc_decomposition_bytes_pc_plus_3_shift, bc_decomposition_bytes_pc_plus_30_shift, bc_decomposition_bytes_pc_plus_31_shift, bc_decomposition_bytes_pc_plus_32_shift, bc_decomposition_bytes_pc_plus_33_shift, bc_decomposition_bytes_pc_plus_34_shift, bc_decomposition_bytes_pc_plus_35_shift, bc_decomposition_bytes_pc_plus_4_shift, bc_decomposition_bytes_pc_plus_5_shift, bc_decomposition_bytes_pc_plus_6_shift, bc_decomposition_bytes_pc_plus_7_shift, bc_decomposition_bytes_pc_plus_8_shift, bc_decomposition_bytes_pc_plus_9_shift, bc_decomposition_bytes_remaining_shift, bc_decomposition_id_shift, bc_decomposition_pc_shift, bc_decomposition_sel_shift, bc_hashing_bytecode_id_shift, bc_hashing_incremental_hash_shift, bc_hashing_pc_index_shift, bc_hashing_sel_shift, bc_hashing_start_shift, bitwise_acc_ia_shift, bitwise_acc_ib_shift, bitwise_acc_ic_shift, bitwise_ctr_shift, bitwise_op_id_shift, execution_sel_shift, instr_fetching_bytecode_id_shift, instr_fetching_bytecode_size_shift, instr_fetching_bytes_remaining_shift, instr_fetching_pc_shift, instr_fetching_sel_shift, poseidon2_hash_a_0_shift, poseidon2_hash_a_1_shift, poseidon2_hash_a_2_shift, poseidon2_hash_a_3_shift, poseidon2_hash_input_0_shift, poseidon2_hash_input_1_shift, poseidon2_hash_input_2_shift, poseidon2_hash_num_perm_rounds_rem_shift, poseidon2_hash_output_shift, poseidon2_hash_sel_shift, poseidon2_hash_start_shift, scalar_mul_bit_idx_shift, scalar_mul_point_inf_shift, scalar_mul_point_x_shift, scalar_mul_point_y_shift, scalar_mul_res_inf_shift, scalar_mul_res_x_shift, scalar_mul_res_y_shift, scalar_mul_scalar_shift, scalar_mul_sel_shift, scalar_mul_start_shift, scalar_mul_temp_inf_shift, scalar_mul_temp_x_shift, scalar_mul_temp_y_shift, sha256_a_shift, sha256_b_shift, sha256_c_shift, sha256_d_shift, sha256_e_shift, sha256_f_shift, sha256_g_shift, sha256_h_shift, sha256_helper_w0_shift, sha256_helper_w1_shift, sha256_helper_w10_shift, sha256_helper_w11_shift, sha256_helper_w12_shift, sha256_helper_w13_shift, sha256_helper_w14_shift, sha256_helper_w15_shift, sha256_helper_w2_shift, sha256_helper_w3_shift, sha256_helper_w4_shift, sha256_helper_w5_shift, sha256_helper_w6_shift, sha256_helper_w7_shift, sha256_helper_w8_shift, sha256_helper_w9_shift, sha256_rounds_remaining_shift, sha256_sel_shift, sha256_start_shift, to_radix_acc_shift, to_radix_acc_under_p_shift, to_radix_exponent_shift, to_radix_limb_shift, to_radix_limb_eq_p_shift, to_radix_limb_index_shift, to_radix_limb_lt_p_shift, to_radix_not_padding_limb_shift, to_radix_radix_shift, to_radix_safe_limbs_shift, to_radix_sel_shift, to_radix_start_shift, to_radix_value_shift #define AVM2_TO_BE_SHIFTED(e) e.bc_decomposition_bytes, e.bc_decomposition_bytes_pc_plus_1, e.bc_decomposition_bytes_pc_plus_10, e.bc_decomposition_bytes_pc_plus_11, e.bc_decomposition_bytes_pc_plus_12, e.bc_decomposition_bytes_pc_plus_13, e.bc_decomposition_bytes_pc_plus_14, e.bc_decomposition_bytes_pc_plus_15, e.bc_decomposition_bytes_pc_plus_16, e.bc_decomposition_bytes_pc_plus_17, e.bc_decomposition_bytes_pc_plus_18, e.bc_decomposition_bytes_pc_plus_19, e.bc_decomposition_bytes_pc_plus_2, e.bc_decomposition_bytes_pc_plus_20, e.bc_decomposition_bytes_pc_plus_21, e.bc_decomposition_bytes_pc_plus_22, e.bc_decomposition_bytes_pc_plus_23, e.bc_decomposition_bytes_pc_plus_24, e.bc_decomposition_bytes_pc_plus_25, e.bc_decomposition_bytes_pc_plus_26, e.bc_decomposition_bytes_pc_plus_27, e.bc_decomposition_bytes_pc_plus_28, e.bc_decomposition_bytes_pc_plus_29, e.bc_decomposition_bytes_pc_plus_3, e.bc_decomposition_bytes_pc_plus_30, e.bc_decomposition_bytes_pc_plus_31, e.bc_decomposition_bytes_pc_plus_32, e.bc_decomposition_bytes_pc_plus_33, e.bc_decomposition_bytes_pc_plus_34, e.bc_decomposition_bytes_pc_plus_35, e.bc_decomposition_bytes_pc_plus_4, e.bc_decomposition_bytes_pc_plus_5, e.bc_decomposition_bytes_pc_plus_6, e.bc_decomposition_bytes_pc_plus_7, e.bc_decomposition_bytes_pc_plus_8, e.bc_decomposition_bytes_pc_plus_9, e.bc_decomposition_bytes_remaining, e.bc_decomposition_id, e.bc_decomposition_pc, e.bc_decomposition_sel, e.bc_hashing_bytecode_id, e.bc_hashing_incremental_hash, e.bc_hashing_pc_index, e.bc_hashing_sel, e.bc_hashing_start, e.bitwise_acc_ia, e.bitwise_acc_ib, e.bitwise_acc_ic, e.bitwise_ctr, e.bitwise_op_id, e.execution_sel, e.instr_fetching_bytecode_id, e.instr_fetching_bytecode_size, e.instr_fetching_bytes_remaining, e.instr_fetching_pc, e.instr_fetching_sel, e.poseidon2_hash_a_0, e.poseidon2_hash_a_1, e.poseidon2_hash_a_2, e.poseidon2_hash_a_3, e.poseidon2_hash_input_0, e.poseidon2_hash_input_1, e.poseidon2_hash_input_2, e.poseidon2_hash_num_perm_rounds_rem, e.poseidon2_hash_output, e.poseidon2_hash_sel, e.poseidon2_hash_start, e.scalar_mul_bit_idx, e.scalar_mul_point_inf, e.scalar_mul_point_x, e.scalar_mul_point_y, e.scalar_mul_res_inf, e.scalar_mul_res_x, e.scalar_mul_res_y, e.scalar_mul_scalar, e.scalar_mul_sel, e.scalar_mul_start, e.scalar_mul_temp_inf, e.scalar_mul_temp_x, e.scalar_mul_temp_y, e.sha256_a, e.sha256_b, e.sha256_c, e.sha256_d, e.sha256_e, e.sha256_f, e.sha256_g, e.sha256_h, e.sha256_helper_w0, e.sha256_helper_w1, e.sha256_helper_w10, e.sha256_helper_w11, e.sha256_helper_w12, e.sha256_helper_w13, e.sha256_helper_w14, e.sha256_helper_w15, e.sha256_helper_w2, e.sha256_helper_w3, e.sha256_helper_w4, e.sha256_helper_w5, e.sha256_helper_w6, e.sha256_helper_w7, e.sha256_helper_w8, e.sha256_helper_w9, e.sha256_rounds_remaining, e.sha256_sel, e.sha256_start, e.to_radix_acc, e.to_radix_acc_under_p, e.to_radix_exponent, e.to_radix_limb, e.to_radix_limb_eq_p, e.to_radix_limb_index, e.to_radix_limb_lt_p, e.to_radix_not_padding_limb, e.to_radix_radix, e.to_radix_safe_limbs, e.to_radix_sel, e.to_radix_start, e.to_radix_value #define AVM2_ALL_ENTITIES AVM2_PRECOMPUTED_ENTITIES, AVM2_WIRE_ENTITIES, AVM2_DERIVED_WITNESS_ENTITIES, AVM2_SHIFTED_ENTITIES diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp index ad5e4c5d8bb8..b7d28d0ab916 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp @@ -157,8 +157,8 @@ class AvmFlavor { lookup_bitwise_integral_tag_length_relation, lookup_class_id_derivation_class_id_poseidon2_0_relation, lookup_class_id_derivation_class_id_poseidon2_1_relation, - lookup_instr_fetching_abs_diff_positive_relation, lookup_instr_fetching_bytes_from_bc_dec_relation, + lookup_instr_fetching_instr_abs_diff_positive_relation, lookup_instr_fetching_pc_abs_diff_positive_hi_relation, lookup_instr_fetching_pc_abs_diff_positive_lo_relation, lookup_instr_fetching_wire_instruction_info_relation, diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp index 3f20ba250258..7a309db9f9be 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp @@ -134,7 +134,7 @@ template class instr_fetchingImpl { } { using Accumulator = typename std::tuple_element_t<13, ContainerOverSubrelations>; - auto tmp = (new_term.instr_fetching_sel_lookup_bc_decomposition - + auto tmp = (new_term.instr_fetching_sel_opcode_defined - new_term.instr_fetching_sel * (FF(1) - new_term.instr_fetching_pc_out_of_range)); tmp *= scaling_factor; std::get<13>(evals) += typename Accumulator::View(tmp); diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_instr_fetching.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_instr_fetching.hpp index 404a3f7fa7fa..b44c0443f395 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_instr_fetching.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_instr_fetching.hpp @@ -10,11 +10,11 @@ namespace bb::avm2 { -/////////////////// lookup_instr_fetching_abs_diff_positive /////////////////// +/////////////////// lookup_instr_fetching_instr_abs_diff_positive /////////////////// -class lookup_instr_fetching_abs_diff_positive_settings { +class lookup_instr_fetching_instr_abs_diff_positive_settings { public: - static constexpr std::string_view NAME = "LOOKUP_INSTR_FETCHING_ABS_DIFF_POSITIVE"; + static constexpr std::string_view NAME = "LOOKUP_INSTR_FETCHING_INSTR_ABS_DIFF_POSITIVE"; static constexpr std::string_view RELATION_NAME = "instr_fetching"; static constexpr size_t READ_TERMS = 1; @@ -29,8 +29,8 @@ class lookup_instr_fetching_abs_diff_positive_settings { // Columns using the Column enum. static constexpr Column SRC_SELECTOR = Column::instr_fetching_sel; static constexpr Column DST_SELECTOR = Column::precomputed_sel_range_8; - static constexpr Column COUNTS = Column::lookup_instr_fetching_abs_diff_positive_counts; - static constexpr Column INVERSES = Column::lookup_instr_fetching_abs_diff_positive_inv; + static constexpr Column COUNTS = Column::lookup_instr_fetching_instr_abs_diff_positive_counts; + static constexpr Column INVERSES = Column::lookup_instr_fetching_instr_abs_diff_positive_inv; static constexpr std::array SRC_COLUMNS = { ColumnAndShifts::instr_fetching_instr_abs_diff }; @@ -62,8 +62,8 @@ class lookup_instr_fetching_abs_diff_positive_settings { template static inline auto get_entities(AllEntities&& in) { - return std::forward_as_tuple(in._lookup_instr_fetching_abs_diff_positive_inv(), - in._lookup_instr_fetching_abs_diff_positive_counts(), + return std::forward_as_tuple(in._lookup_instr_fetching_instr_abs_diff_positive_inv(), + in._lookup_instr_fetching_instr_abs_diff_positive_counts(), in._instr_fetching_sel(), in._precomputed_sel_range_8(), in._instr_fetching_instr_abs_diff(), @@ -72,16 +72,17 @@ class lookup_instr_fetching_abs_diff_positive_settings { }; template -class lookup_instr_fetching_abs_diff_positive_relation - : public GenericLookupRelation { +class lookup_instr_fetching_instr_abs_diff_positive_relation + : public GenericLookupRelation { public: - using Settings = lookup_instr_fetching_abs_diff_positive_settings; - static constexpr std::string_view NAME = lookup_instr_fetching_abs_diff_positive_settings::NAME; - static constexpr std::string_view RELATION_NAME = lookup_instr_fetching_abs_diff_positive_settings::RELATION_NAME; + using Settings = lookup_instr_fetching_instr_abs_diff_positive_settings; + static constexpr std::string_view NAME = lookup_instr_fetching_instr_abs_diff_positive_settings::NAME; + static constexpr std::string_view RELATION_NAME = + lookup_instr_fetching_instr_abs_diff_positive_settings::RELATION_NAME; template inline static bool skip(const AllEntities& in) { - return in.lookup_instr_fetching_abs_diff_positive_inv.is_zero(); + return in.lookup_instr_fetching_instr_abs_diff_positive_inv.is_zero(); } static std::string get_subrelation_label(size_t index) @@ -284,7 +285,7 @@ class lookup_instr_fetching_bytes_from_bc_dec_settings { static constexpr size_t WRITE_TERM_DEGREE = 0; // Columns using the Column enum. - static constexpr Column SRC_SELECTOR = Column::instr_fetching_sel_lookup_bc_decomposition; + static constexpr Column SRC_SELECTOR = Column::instr_fetching_sel_opcode_defined; static constexpr Column DST_SELECTOR = Column::bc_decomposition_sel; static constexpr Column COUNTS = Column::lookup_instr_fetching_bytes_from_bc_dec_counts; static constexpr Column INVERSES = Column::lookup_instr_fetching_bytes_from_bc_dec_inv; @@ -377,14 +378,14 @@ class lookup_instr_fetching_bytes_from_bc_dec_settings { template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { - return (in._instr_fetching_sel_lookup_bc_decomposition() == 1 || in._bc_decomposition_sel() == 1); + return (in._instr_fetching_sel_opcode_defined() == 1 || in._bc_decomposition_sel() == 1); } template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; - const auto is_operation = View(in._instr_fetching_sel_lookup_bc_decomposition()); + const auto is_operation = View(in._instr_fetching_sel_opcode_defined()); const auto is_table_entry = View(in._bc_decomposition_sel()); return (is_operation + is_table_entry - is_operation * is_table_entry); } @@ -403,7 +404,7 @@ class lookup_instr_fetching_bytes_from_bc_dec_settings { { return std::forward_as_tuple(in._lookup_instr_fetching_bytes_from_bc_dec_inv(), in._lookup_instr_fetching_bytes_from_bc_dec_counts(), - in._instr_fetching_sel_lookup_bc_decomposition(), + in._instr_fetching_sel_opcode_defined(), in._bc_decomposition_sel(), in._instr_fetching_pc(), in._instr_fetching_bytecode_id(), @@ -531,7 +532,7 @@ class lookup_instr_fetching_wire_instruction_info_settings { static constexpr size_t WRITE_TERM_DEGREE = 0; // Columns using the Column enum. - static constexpr Column SRC_SELECTOR = Column::instr_fetching_sel; + static constexpr Column SRC_SELECTOR = Column::instr_fetching_sel_opcode_defined; static constexpr Column DST_SELECTOR = Column::precomputed_sel_range_8; static constexpr Column COUNTS = Column::lookup_instr_fetching_wire_instruction_info_counts; static constexpr Column INVERSES = Column::lookup_instr_fetching_wire_instruction_info_inv; @@ -564,14 +565,14 @@ class lookup_instr_fetching_wire_instruction_info_settings { template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { - return (in._instr_fetching_sel() == 1 || in._precomputed_sel_range_8() == 1); + return (in._instr_fetching_sel_opcode_defined() == 1 || in._precomputed_sel_range_8() == 1); } template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; - const auto is_operation = View(in._instr_fetching_sel()); + const auto is_operation = View(in._instr_fetching_sel_opcode_defined()); const auto is_table_entry = View(in._precomputed_sel_range_8()); return (is_operation + is_table_entry - is_operation * is_table_entry); } @@ -590,7 +591,7 @@ class lookup_instr_fetching_wire_instruction_info_settings { { return std::forward_as_tuple(in._lookup_instr_fetching_wire_instruction_info_inv(), in._lookup_instr_fetching_wire_instruction_info_counts(), - in._instr_fetching_sel(), + in._instr_fetching_sel_opcode_defined(), in._precomputed_sel_range_8(), in._instr_fetching_bd0(), in._instr_fetching_opcode_out_of_range(), diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.cpp index 9323cb6c95e9..7478b22bac88 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.cpp @@ -62,26 +62,20 @@ Instruction TxBytecodeManager::read_instruction(BytecodeId bytecode_id, uint32_t auto bytecode_ptr = it->second; const auto& bytecode = *bytecode_ptr; - InstructionFetchingError instr_fetch_err = InstructionFetchingError::NO_ERROR; - Instruction instruction; // TODO: Propagate instruction fetching error to the upper layer (execution loop) - try { - instruction = deserialize_instruction(bytecode, pc); - } catch (const InstructionFetchingError& error) { - instr_fetch_err = error; - } + InstructionWithError instruction_with_err = deserialize_instruction(bytecode, pc); // The event will be deduplicated internally. fetching_events.emit({ .bytecode_id = bytecode_id, .pc = pc, - .instruction = instruction, + .instruction = instruction_with_err.instruction, .bytecode = bytecode_ptr, - .error = instr_fetch_err, + .error = instruction_with_err.error, }); - return instruction; + return instruction_with_err.instruction; } } // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/bytecode_events.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/bytecode_events.hpp index 6b5c80e7ef36..aace0ed903c9 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/bytecode_events.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/bytecode_events.hpp @@ -39,20 +39,13 @@ struct BytecodeRetrievalEvent { bool error = false; }; -enum class InstructionFetchingError : uint8_t { - NO_ERROR, - PC_OUT_OF_RANGE, - OPCODE_OUT_OF_RANGE, - INSTRUCTION_OUT_OF_RANGE, -}; - struct InstructionFetchingEvent { BytecodeId bytecode_id; uint32_t pc; // TODO: Do we want to have a dep on Instruction here or do we redefine what we need? Instruction instruction; std::shared_ptr> bytecode; - InstructionFetchingError error = InstructionFetchingError::NO_ERROR; + InstrDeserializationError error = InstrDeserializationError::NO_ERROR; // To be used with deduplicating event emitters. using Key = std::tuple; diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.cpp index 431fb98f53b7..33100f8a3e40 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.cpp @@ -15,7 +15,6 @@ #include "barretenberg/vm2/common/instruction_spec.hpp" #include "barretenberg/vm2/common/opcodes.hpp" #include "barretenberg/vm2/common/stringify.hpp" -#include "barretenberg/vm2/simulation/events/bytecode_events.hpp" namespace bb::avm2::simulation { using avm2::to_hex; @@ -364,21 +363,21 @@ std::string Operand::to_string() const __builtin_unreachable(); } -Instruction deserialize_instruction(std::span bytecode, size_t pos) +InstructionWithError deserialize_instruction(std::span bytecode, size_t pos) { const auto bytecode_length = bytecode.size(); if (pos >= bytecode_length) { info("PC is out of range. Position: " + std::to_string(pos) + " Bytecode length: " + std::to_string(bytecode_length)); - throw InstructionFetchingError::PC_OUT_OF_RANGE; + return { .error = InstrDeserializationError::PC_OUT_OF_RANGE }; } const uint8_t opcode_byte = bytecode[pos]; if (!is_wire_opcode_valid(opcode_byte)) { info("Invalid wire opcode byte: 0x" + to_hex(opcode_byte) + " at position: " + std::to_string(pos)); - throw InstructionFetchingError::OPCODE_OUT_OF_RANGE; + return { .error = InstrDeserializationError::OPCODE_OUT_OF_RANGE }; } const auto opcode = static_cast(opcode_byte); @@ -388,6 +387,8 @@ Instruction deserialize_instruction(std::span bytecode, size_t po const uint32_t instruction_size = WIRE_INSTRUCTION_SPEC.at(opcode).size_in_bytes; + // We know we will throw an error but we delay throwing the error, because + // we need the partial instruction to be parsed for witness generation. if (pos + instruction_size > bytecode_length) { info("Instruction does not fit in remaining bytecode. Wire opcode: ", opcode, @@ -397,7 +398,6 @@ Instruction deserialize_instruction(std::span bytecode, size_t po instruction_size, " bytecode length: ", bytecode_length); - throw InstructionFetchingError::INSTRUCTION_OUT_OF_RANGE; } pos++; // move after opcode byte @@ -406,8 +406,25 @@ Instruction deserialize_instruction(std::span bytecode, size_t po std::vector operands; for (const OperandType op_type : inst_format) { const auto operand_size = OPERAND_TYPE_SIZE_BYTES.at(op_type); - assert(pos + operand_size <= bytecode_length); // Guaranteed to hold due to - // pos + instruction_size <= bytecode_length + + // No remaining byte to process + if (pos == bytecode_length) { + return { .instruction = { .opcode = opcode, .indirect = indirect, .operands = std::move(operands) }, + .error = InstrDeserializationError::INSTRUCTION_OUT_OF_RANGE }; + } + + uint8_t const* pos_ptr = &bytecode[pos]; + std::array operand_padded = { 0 }; // Fill with zeros + bool out_of_range = false; + + // We will throw during processing of this operand + // In this case, we need to pad the operand to get the partial instruction required + // by witness generation. + if (pos + operand_size > bytecode_length) { + std::copy(bytecode.begin() + static_cast(pos), bytecode.end(), operand_padded.begin()); + pos_ptr = operand_padded.data(); + out_of_range = true; + } switch (op_type) { case OperandType::TAG: { @@ -433,54 +450,55 @@ Instruction deserialize_instruction(std::span bytecode, size_t po } case OperandType::INDIRECT16: { uint16_t operand_u16 = 0; - uint8_t const* pos_ptr = &bytecode[pos]; serialize::read(pos_ptr, operand_u16); indirect = operand_u16; break; } case OperandType::UINT16: { uint16_t operand_u16 = 0; - uint8_t const* pos_ptr = &bytecode[pos]; serialize::read(pos_ptr, operand_u16); operands.emplace_back(operand_u16); break; } case OperandType::UINT32: { uint32_t operand_u32 = 0; - uint8_t const* pos_ptr = &bytecode[pos]; serialize::read(pos_ptr, operand_u32); operands.emplace_back(operand_u32); break; } case OperandType::UINT64: { uint64_t operand_u64 = 0; - uint8_t const* pos_ptr = &bytecode[pos]; serialize::read(pos_ptr, operand_u64); operands.emplace_back(operand_u64); break; } case OperandType::UINT128: { uint128_t operand_u128 = 0; - uint8_t const* pos_ptr = &bytecode[pos]; serialize::read(pos_ptr, operand_u128); operands.emplace_back(Operand::u128(operand_u128)); break; } case OperandType::FF: { FF operand_ff; - uint8_t const* pos_ptr = &bytecode[pos]; read(pos_ptr, operand_ff); operands.emplace_back(Operand::ff(operand_ff)); } } + + if (out_of_range) { + return { .instruction = { .opcode = opcode, .indirect = indirect, .operands = std::move(operands) }, + .error = InstrDeserializationError::INSTRUCTION_OUT_OF_RANGE }; + } + pos += operand_size; } - return { - .opcode = opcode, - .indirect = indirect, - .operands = std::move(operands), - }; + return { .instruction = { + .opcode = opcode, + .indirect = indirect, + .operands = std::move(operands), + }, + .error = InstrDeserializationError::NO_ERROR }; }; std::string Instruction::to_string() const diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp index 7cb1be68014f..27095ed6f713 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp @@ -66,7 +66,7 @@ class Operand { }; struct Instruction { - WireOpCode opcode = WireOpCode::LAST_OPCODE_SENTINEL; + WireOpCode opcode = WireOpCode::ADD_8; // Opcode which value 0 uint16_t indirect = 0; std::vector operands; @@ -77,6 +77,18 @@ struct Instruction { bool operator==(const Instruction& other) const = default; }; +enum class InstrDeserializationError : uint8_t { + NO_ERROR, + PC_OUT_OF_RANGE, + OPCODE_OUT_OF_RANGE, + INSTRUCTION_OUT_OF_RANGE, +}; + +struct InstructionWithError { + Instruction instruction; + InstrDeserializationError error = InstrDeserializationError::NO_ERROR; +}; + /** * @brief Parsing of an instruction in the supplied bytecode at byte position pos. This * checks that the WireOpCode value is in the defined range and extracts the operands @@ -85,8 +97,8 @@ struct Instruction { * @param bytecode The bytecode to be parsed as a vector of bytes/uint8_t * @param pos Bytecode position * @throws runtime_error exception when the bytecode is invalid or pos is out-of-range - * @return The instruction + * @return The instruction enahnced with an error */ -Instruction deserialize_instruction(std::span bytecode, size_t pos); +InstructionWithError deserialize_instruction(std::span bytecode, size_t pos); } // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.test.cpp index 2ec2acc664b4..c201e2eb90af 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.test.cpp @@ -7,8 +7,8 @@ namespace bb::avm2 { namespace { using simulation::deserialize_instruction; +using simulation::InstrDeserializationError; using simulation::Instruction; -using simulation::InstructionFetchingError; using simulation::Operand; // Testing serialization with some u8 variants @@ -17,7 +17,7 @@ TEST(SerializationTest, Not8RoundTrip) const Instruction instr = { .opcode = WireOpCode::NOT_8, .indirect = 5, .operands = { Operand::u8(123), Operand::u8(45) } }; - const auto decoded = deserialize_instruction(instr.serialize(), 0); + const auto decoded = deserialize_instruction(instr.serialize(), 0).instruction; EXPECT_EQ(instr, decoded); } @@ -27,7 +27,7 @@ TEST(SerializationTest, Add16RoundTrip) const Instruction instr = { .opcode = WireOpCode::ADD_16, .indirect = 3, .operands = { Operand::u16(1000), Operand::u16(1001), Operand::u16(1002) } }; - const auto decoded = deserialize_instruction(instr.serialize(), 0); + const auto decoded = deserialize_instruction(instr.serialize(), 0).instruction; EXPECT_EQ(instr, decoded); } @@ -37,7 +37,7 @@ TEST(SerializationTest, Jumpi32RoundTrip) const Instruction instr = { .opcode = WireOpCode::JUMPI_32, .indirect = 7, .operands = { Operand::u16(12345), Operand::u32(678901234) } }; - const auto decoded = deserialize_instruction(instr.serialize(), 0); + const auto decoded = deserialize_instruction(instr.serialize(), 0).instruction; EXPECT_EQ(instr, decoded); } @@ -51,7 +51,7 @@ TEST(SerializationTest, Set64RoundTrip) .indirect = 2, .operands = { Operand::u16(1002), Operand::u8(static_cast(MemoryTag::U64)), Operand::u64(value_64) } }; - const auto decoded = deserialize_instruction(instr.serialize(), 0); + const auto decoded = deserialize_instruction(instr.serialize(), 0).instruction; EXPECT_EQ(instr, decoded); } @@ -65,7 +65,7 @@ TEST(SerializationTest, Set128RoundTrip) .indirect = 2, .operands = { Operand::u16(1002), Operand::u8(static_cast(MemoryTag::U128)), Operand::u128(value_128) } }; - const auto decoded = deserialize_instruction(instr.serialize(), 0); + const auto decoded = deserialize_instruction(instr.serialize(), 0).instruction; EXPECT_EQ(instr, decoded); } @@ -79,7 +79,7 @@ TEST(SerializationTest, SetFFRoundTrip) .indirect = 2, .operands = { Operand::u16(1002), Operand::u8(static_cast(MemoryTag::FF)), Operand::ff(large_ff) } }; - const auto decoded = deserialize_instruction(instr.serialize(), 0); + const auto decoded = deserialize_instruction(instr.serialize(), 0).instruction; EXPECT_EQ(instr, decoded); } @@ -89,11 +89,7 @@ TEST(SerializationTest, PCOutOfRange) std::vector bytecode; bytecode.resize(35, 0); - try { - deserialize_instruction(bytecode, bytecode.size() + 1); - } catch (const InstructionFetchingError& error) { - EXPECT_EQ(error, InstructionFetchingError::PC_OUT_OF_RANGE); - } + EXPECT_EQ(deserialize_instruction(bytecode, bytecode.size() + 1).error, InstrDeserializationError::PC_OUT_OF_RANGE); } // Testing deserialization wire opcode out of range error @@ -102,11 +98,7 @@ TEST(SerializationTest, OpcodeOutOfRange) std::vector bytecode; bytecode.push_back(static_cast(WireOpCode::LAST_OPCODE_SENTINEL) + 1); // Invalid opcode - try { - deserialize_instruction(bytecode, 0); - } catch (const InstructionFetchingError& error) { - EXPECT_EQ(error, InstructionFetchingError::OPCODE_OUT_OF_RANGE); - } + EXPECT_EQ(deserialize_instruction(bytecode, 0).error, InstrDeserializationError::OPCODE_OUT_OF_RANGE); } // Testing deserialization instruction out of range error @@ -124,11 +116,7 @@ TEST(SerializationTest, InstructionOutOfRange) // Truncate the bytecode bytecode.resize(bytecode.size() - 1); - try { - deserialize_instruction(bytecode, 0); - } catch (const InstructionFetchingError& error) { - EXPECT_EQ(error, InstructionFetchingError::INSTRUCTION_OUT_OF_RANGE); - } + EXPECT_EQ(deserialize_instruction(bytecode, 0).error, InstrDeserializationError::INSTRUCTION_OUT_OF_RANGE); } } // namespace diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp index 0c257e9e49fd..c161e3166292 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp @@ -248,10 +248,10 @@ void BytecodeTraceBuilder::process_instruction_fetching( using C = Column; using simulation::BytecodeId; using simulation::InstructionFetchingEvent; - using simulation::InstructionFetchingError::INSTRUCTION_OUT_OF_RANGE; - using simulation::InstructionFetchingError::NO_ERROR; - using simulation::InstructionFetchingError::OPCODE_OUT_OF_RANGE; - using simulation::InstructionFetchingError::PC_OUT_OF_RANGE; + using simulation::InstrDeserializationError::INSTRUCTION_OUT_OF_RANGE; + using simulation::InstrDeserializationError::NO_ERROR; + using simulation::InstrDeserializationError::OPCODE_OUT_OF_RANGE; + using simulation::InstrDeserializationError::PC_OUT_OF_RANGE; // We start from row 1 because we need a row of zeroes for the shifts. uint32_t row = 1; @@ -293,7 +293,8 @@ void BytecodeTraceBuilder::process_instruction_fetching( } const uint8_t wire_opcode = bytecode_at(event.pc); - const bool wire_opcode_in_range = wire_opcode < static_cast(WireOpCode::LAST_OPCODE_SENTINEL); + const bool wire_opcode_in_range = + event.error != PC_OUT_OF_RANGE && wire_opcode < static_cast(WireOpCode::LAST_OPCODE_SENTINEL); const auto wire_instr_spec = wire_opcode_in_range ? WIRE_INSTRUCTION_SPEC.at(static_cast(wire_opcode)) : WireInstructionSpec{ .exec_opcode = static_cast(0), @@ -401,7 +402,7 @@ void BytecodeTraceBuilder::process_instruction_fetching( { C::instr_fetching_parsing_err, event.error != NO_ERROR ? 1 : 0 }, // selector for lookups - { C::instr_fetching_sel_lookup_bc_decomposition, event.error != PC_OUT_OF_RANGE ? 1 : 0 }, + { C::instr_fetching_sel_opcode_defined, event.error != PC_OUT_OF_RANGE ? 1 : 0 }, { C::instr_fetching_last_of_bytecode, is_last_of_bytecode ? 1 : 0 }, { C::instr_fetching_bc_id_diff_inv, bytecode_id_diff_inv }, diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp index 157627f93f66..a9192f16880f 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp @@ -496,7 +496,7 @@ TEST(BytecodeTraceGenTest, InstrFetchingSingleBytecode) ROW_FIELD_EQ(R, instr_fetching_bc_id_diff_inv, i == num_of_opcodes - 1 ? FF(FF::modulus - bytecode_id).invert() : 0), - ROW_FIELD_EQ(R, instr_fetching_sel_lookup_bc_decomposition, 1))); + ROW_FIELD_EQ(R, instr_fetching_sel_opcode_defined, 1))); } } @@ -567,21 +567,21 @@ TEST(BytecodeTraceGenTest, InstrFetchingParsingErrors) .pc = 0, .instruction = testing::random_instruction(WireOpCode::ADD_8), .bytecode = bytecode_ptr, - .error = simulation::InstructionFetchingError::OPCODE_OUT_OF_RANGE, + .error = simulation::InstrDeserializationError::OPCODE_OUT_OF_RANGE, }); events.emplace_back(InstructionFetchingEvent{ .bytecode_id = bytecode_id, .pc = 19, .instruction = testing::random_instruction(WireOpCode::ADD_8), .bytecode = bytecode_ptr, - .error = simulation::InstructionFetchingError::INSTRUCTION_OUT_OF_RANGE, + .error = simulation::InstrDeserializationError::INSTRUCTION_OUT_OF_RANGE, }); events.emplace_back(InstructionFetchingEvent{ .bytecode_id = bytecode_id, .pc = 38, .instruction = testing::random_instruction(WireOpCode::ADD_8), .bytecode = bytecode_ptr, - .error = simulation::InstructionFetchingError::PC_OUT_OF_RANGE, + .error = simulation::InstrDeserializationError::PC_OUT_OF_RANGE, }); builder.process_instruction_fetching(events, trace); @@ -592,29 +592,48 @@ TEST(BytecodeTraceGenTest, InstrFetchingParsingErrors) EXPECT_THAT(rows.at(1), AllOf(ROW_FIELD_EQ(R, instr_fetching_sel, 1), - ROW_FIELD_EQ(R, instr_fetching_sel_lookup_bc_decomposition, 1), + ROW_FIELD_EQ(R, instr_fetching_sel_opcode_defined, 1), ROW_FIELD_EQ(R, instr_fetching_pc, 0), + ROW_FIELD_EQ(R, instr_fetching_bytes_to_read, 20), + ROW_FIELD_EQ(R, instr_fetching_bytes_remaining, 20), + ROW_FIELD_EQ(R, instr_fetching_instr_size, 0), + ROW_FIELD_EQ(R, + instr_fetching_instr_abs_diff, + 20), // instr_size <= bytes_to_read: bytes_to_read - instr_size ROW_FIELD_EQ(R, instr_fetching_parsing_err, 1), + ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff, 19), + ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff_lo, 19), + ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff_hi, 0), ROW_FIELD_EQ(R, instr_fetching_opcode_out_of_range, 1))); EXPECT_THAT(rows.at(2), AllOf(ROW_FIELD_EQ(R, instr_fetching_sel, 1), - ROW_FIELD_EQ(R, instr_fetching_sel_lookup_bc_decomposition, 1), + ROW_FIELD_EQ(R, instr_fetching_sel_opcode_defined, 1), ROW_FIELD_EQ(R, instr_fetching_pc, 19), // OR_16 opcode ROW_FIELD_EQ(R, instr_fetching_bytes_to_read, 1), ROW_FIELD_EQ(R, instr_fetching_bytes_remaining, 1), ROW_FIELD_EQ(R, instr_fetching_instr_size, 8), // OR_16 is 8 bytes long ROW_FIELD_EQ(R, instr_fetching_instr_abs_diff, - 6), // instr_size < bytes_to_read: bytes_to_read - instr_size - 1 + 6), // instr_size > bytes_to_read: instr_size - bytes_to_read - 1 ROW_FIELD_EQ(R, instr_fetching_parsing_err, 1), + ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff, 0), + ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff_lo, 0), + ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff_hi, 0), ROW_FIELD_EQ(R, instr_fetching_instr_out_of_range, 1))); EXPECT_THAT(rows.at(3), AllOf(ROW_FIELD_EQ(R, instr_fetching_sel, 1), - ROW_FIELD_EQ(R, instr_fetching_sel_lookup_bc_decomposition, 0), + ROW_FIELD_EQ(R, instr_fetching_sel_opcode_defined, 0), ROW_FIELD_EQ(R, instr_fetching_pc, 38), + ROW_FIELD_EQ(R, instr_fetching_bytes_to_read, 0), + ROW_FIELD_EQ(R, instr_fetching_bytes_remaining, 0), + ROW_FIELD_EQ(R, instr_fetching_instr_size, 0), + ROW_FIELD_EQ(R, instr_fetching_instr_abs_diff, 0), ROW_FIELD_EQ(R, instr_fetching_parsing_err, 1), + ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff, 18), + ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff_lo, 18), + ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff_hi, 0), ROW_FIELD_EQ(R, instr_fetching_pc_out_of_range, 1))); } diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp index ad2f7f39b30a..002271026f03 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp @@ -286,7 +286,7 @@ TraceContainer AvmTraceGenHelper::generate_trace(EventsContainer&& events) // 40 elements long. std::make_unique>(), std::make_unique>(), - std::make_unique>(), + std::make_unique>(), std::make_unique>(), std::make_unique>(), // Class Id Derivation From 92c178c9d57d2dd85f35c96cf40fd4368d607dff Mon Sep 17 00:00:00 2001 From: jeanmon Date: Mon, 17 Mar 2025 15:33:06 +0000 Subject: [PATCH 09/25] wip negative unit tests --- barretenberg/cpp/pil/vm2/instr_fetching.pil | 4 + .../relations/instr_fetching.test.cpp | 95 ++++++++++++++++++- .../generated/relations/instr_fetching.hpp | 12 +++ .../vm2/simulation/lib/serialization.cpp | 1 + 4 files changed, 111 insertions(+), 1 deletion(-) diff --git a/barretenberg/cpp/pil/vm2/instr_fetching.pil b/barretenberg/cpp/pil/vm2/instr_fetching.pil index e1059b1fe484..516b28bb1bcf 100644 --- a/barretenberg/cpp/pil/vm2/instr_fetching.pil +++ b/barretenberg/cpp/pil/vm2/instr_fetching.pil @@ -43,6 +43,7 @@ last_of_bytecode * (1 - last_of_bytecode) = 0; // Standard non-zero inequality involving helper inverse column pol BC_ID_DIFF = bytecode_id' - bytecode_id; pol commit bc_id_diff_inv; +#[LAST_OF_BYTECODE_TOGGLE] sel * (BC_ID_DIFF * ((1 - last_of_bytecode) * (1 - bc_id_diff_inv) + bc_id_diff_inv) - last_of_bytecode) = 0; // If last_of_bytecode OR precomputed.first_row then next row has pc == 0 @@ -54,6 +55,7 @@ pol commit bytes_remaining; pol commit bytes_to_read; pol commit bytecode_size; +#[BYTECODE_SIZE_INIT] (last_of_bytecode + precomputed.first_row) * (bytecode_size' - bytes_remaining') = 0; #[SAME_BYTECODE_SIZE] @@ -67,6 +69,7 @@ sel * sel' * (1 - last_of_bytecode) * (bytecode_size - bytecode_size') = 0; pol commit instr_abs_diff; // From the following relation, we have: instr_abs_diff >= 0 ==> [instr_size > bytes_to_read <==> instr_out_of_range == 1] +#[INSTR_OUT_OF_RANGE_TOGGLE] instr_abs_diff = (2 * instr_out_of_range - 1) * (instr_size - bytes_to_read) - instr_out_of_range; #[INSTR_ABS_DIFF_POSITIVE] @@ -78,6 +81,7 @@ sel {instr_abs_diff} in precomputed.sel_range_8 {precomputed.clk}; // pc - bytecode_size if bytecode_size <= pc // bytecode_size - pc - 1 if bytecode_size > pc pol commit pc_abs_diff; +#[PC_OUT_OF_RANGE_TOGGLE] pc_abs_diff = sel * ((2 * pc_out_of_range - 1) * (pc - bytecode_size) - 1 + pc_out_of_range); // pc_abs_diff might take 32 bits and we decompose into 2 16-bit limbs diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp index 53d0dc5e2ab3..d58e72163fa5 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp @@ -624,7 +624,100 @@ TEST(InstrFetchingConstrainingTest, NegativeWrongBcDecompositionInteractions) } } -// +// Negative test on trace continuity. Gap after first row. +TEST(InstrFetchingConstrainingTest, NegativeGapAfterFirstRow) +{ + TestTraceContainer trace = TestTraceContainer::from_rows({ + { .precomputed_first_row = 1 }, + { + .instr_fetching_sel = 0, + }, + { + .instr_fetching_sel = 1, + }, + }); + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_TRACE_CONTINUITY), + "TRACE_CONTINUITY"); +} + +// Negative test on trace continuity. Gap in the middle. +TEST(InstrFetchingConstrainingTest, NegativeGapInTheMiddle) +{ + TestTraceContainer trace = TestTraceContainer::from_rows({ + { .precomputed_first_row = 1 }, + { + .instr_fetching_sel = 1, + }, + { + .instr_fetching_sel = 0, + }, + { + .instr_fetching_sel = 1, + }, + }); + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_TRACE_CONTINUITY), + "TRACE_CONTINUITY"); +} + +// Negative test on pc == 0 for first entry pertaining to a bytecode_id +// Pick a trace with two bytecode_id = 2 and 3. +// For first entry of bytecode_id == 3, we set pc = 23. +TEST(InstrFetchingConstrainingTest, NegativePcNotZeroFirstEntryBytecode1) +{ + TestTraceContainer trace = TestTraceContainer::from_rows({ + { .precomputed_first_row = 1 }, + { + .instr_fetching_bytecode_id = 2, + .instr_fetching_last_of_bytecode = 1, + .instr_fetching_pc = 0, + .instr_fetching_sel = 1, + }, + { + .instr_fetching_bytecode_id = 3, + .instr_fetching_pc = 23, + .instr_fetching_sel = 1, + }, + { + .instr_fetching_bytecode_id = 3, + .instr_fetching_last_of_bytecode = 1, + .instr_fetching_sel = 1, + }, + }); + + EXPECT_THROW_WITH_MESSAGE( + check_relation(trace, instr_fetching::SR_PC_IS_ZERO_IN_BYTECODE_FIRST_ROW), + "PC_IS_ZERO_IN_BYTECODE_FIRST_ROW"); +} + +// Same as before but pc is wrongly set for the first bytecode +TEST(InstrFetchingConstrainingTest, NegativePcNotZeroFirstEntryBytecode2) +{ + TestTraceContainer trace = TestTraceContainer::from_rows({ + { .precomputed_first_row = 1 }, + { + .instr_fetching_bytecode_id = 2, + .instr_fetching_last_of_bytecode = 1, + .instr_fetching_pc = 12, + .instr_fetching_sel = 1, + }, + { + .instr_fetching_bytecode_id = 3, + .instr_fetching_pc = 0, + .instr_fetching_sel = 1, + }, + { + .instr_fetching_bytecode_id = 3, + .instr_fetching_last_of_bytecode = 1, + .instr_fetching_sel = 1, + }, + }); + + EXPECT_THROW_WITH_MESSAGE( + check_relation(trace, instr_fetching::SR_PC_IS_ZERO_IN_BYTECODE_FIRST_ROW), + "PC_IS_ZERO_IN_BYTECODE_FIRST_ROW"); +} } // namespace } // namespace bb::avm2::constraining diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp index 7a309db9f9be..235969655cfe 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp @@ -294,10 +294,18 @@ template class instr_fetching : public Relation class instr_fetching : public Relation bytecode, switch (op_type) { case OperandType::TAG: { uint8_t tag_u8 = bytecode[pos]; + // TODO: To handle in a subsequent PR (not decided if handled in specific opcode gadgets) // if (tag_u8 > MAX_MEM_TAG) { // info("Instruction tag is invalid at position " + std::to_string(pos) + // " value: " + std::to_string(tag_u8) + " for WireOpCode: " + to_string(WireOpCode)); From 09bab9f216f4a649ec27dd13260308a2a95b5ca1 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Mon, 17 Mar 2025 17:15:53 +0000 Subject: [PATCH 10/25] Negative unit tests on instruction fetching --- .../relations/instr_fetching.test.cpp | 268 +++++++++++++++++- 1 file changed, 264 insertions(+), 4 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp index d58e72163fa5..24484587cb3a 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp @@ -630,13 +630,16 @@ TEST(InstrFetchingConstrainingTest, NegativeGapAfterFirstRow) TestTraceContainer trace = TestTraceContainer::from_rows({ { .precomputed_first_row = 1 }, { - .instr_fetching_sel = 0, + .instr_fetching_sel = 1, // Will be mutated to zero }, { .instr_fetching_sel = 1, }, }); + check_relation(trace, instr_fetching::SR_TRACE_CONTINUITY); + + trace.set(C::instr_fetching_sel, 1, 0); // Mutate to wrong value EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_TRACE_CONTINUITY), "TRACE_CONTINUITY"); } @@ -650,13 +653,16 @@ TEST(InstrFetchingConstrainingTest, NegativeGapInTheMiddle) .instr_fetching_sel = 1, }, { - .instr_fetching_sel = 0, + .instr_fetching_sel = 1, // Will be mutated to 0 }, { .instr_fetching_sel = 1, }, }); + check_relation(trace, instr_fetching::SR_TRACE_CONTINUITY); + + trace.set(C::instr_fetching_sel, 2, 0); // Mutate to wrong value (row 2) EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_TRACE_CONTINUITY), "TRACE_CONTINUITY"); } @@ -676,7 +682,7 @@ TEST(InstrFetchingConstrainingTest, NegativePcNotZeroFirstEntryBytecode1) }, { .instr_fetching_bytecode_id = 3, - .instr_fetching_pc = 23, + .instr_fetching_pc = 0, // Will be mutated to 23 .instr_fetching_sel = 1, }, { @@ -686,6 +692,10 @@ TEST(InstrFetchingConstrainingTest, NegativePcNotZeroFirstEntryBytecode1) }, }); + check_relation(trace, instr_fetching::SR_PC_IS_ZERO_IN_BYTECODE_FIRST_ROW); + + trace.set(C::instr_fetching_pc, 2, 23); // Mutate to wrong value (row 2) + EXPECT_THROW_WITH_MESSAGE( check_relation(trace, instr_fetching::SR_PC_IS_ZERO_IN_BYTECODE_FIRST_ROW), "PC_IS_ZERO_IN_BYTECODE_FIRST_ROW"); @@ -699,7 +709,7 @@ TEST(InstrFetchingConstrainingTest, NegativePcNotZeroFirstEntryBytecode2) { .instr_fetching_bytecode_id = 2, .instr_fetching_last_of_bytecode = 1, - .instr_fetching_pc = 12, + .instr_fetching_pc = 0, // Will be mutated to 12 .instr_fetching_sel = 1, }, { @@ -714,10 +724,260 @@ TEST(InstrFetchingConstrainingTest, NegativePcNotZeroFirstEntryBytecode2) }, }); + check_relation(trace, instr_fetching::SR_PC_IS_ZERO_IN_BYTECODE_FIRST_ROW); + + trace.set(C::instr_fetching_pc, 1, 12); // Mutate to wrong value (row 1) + EXPECT_THROW_WITH_MESSAGE( check_relation(trace, instr_fetching::SR_PC_IS_ZERO_IN_BYTECODE_FIRST_ROW), "PC_IS_ZERO_IN_BYTECODE_FIRST_ROW"); } +// Negative test on not toggling last_of_bytecode when bytecode_id changes +TEST(InstrFetchingConstrainingTest, NegativeNotTogglingLastOfBytecode) +{ + TestTraceContainer trace = TestTraceContainer::from_rows({ + { .precomputed_first_row = 1 }, + { + .instr_fetching_bc_id_diff_inv = 1, + .instr_fetching_bytecode_id = 2, + .instr_fetching_last_of_bytecode = 1, // Will be mutated to 0 + .instr_fetching_sel = 1, + }, + { + .instr_fetching_bc_id_diff_inv = FF(FF::modulus - 3).invert(), + .instr_fetching_bytecode_id = 3, + .instr_fetching_last_of_bytecode = 1, + .instr_fetching_sel = 1, + }, + }); + + check_relation(trace, instr_fetching::SR_LAST_OF_BYTECODE_TOGGLE); + + trace.set(C::instr_fetching_bytecode_id, 1, 0); // Mutate to wrong value (row 1) + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_LAST_OF_BYTECODE_TOGGLE), + "LAST_OF_BYTECODE_TOGGLE"); + + // Second attempt by mutating instr_fetching_bc_id_diff_inv to 0 + trace.set(C::instr_fetching_bc_id_diff_inv, 1, 0); + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_LAST_OF_BYTECODE_TOGGLE), + "LAST_OF_BYTECODE_TOGGLE"); +} + +// Negative test on wrongly toggling last_of_bytecod when bytecode_id remains constant (equal to 11) +TEST(InstrFetchingConstrainingTest, NegativeTogglingLastOfBytecode) +{ + TestTraceContainer trace = TestTraceContainer::from_rows({ + { .precomputed_first_row = 1 }, + { + .instr_fetching_bc_id_diff_inv = 0, + .instr_fetching_bytecode_id = 11, + .instr_fetching_last_of_bytecode = 0, // Will be mutated to 1 + .instr_fetching_sel = 1, + }, + { + .instr_fetching_bc_id_diff_inv = FF(FF::modulus - 11).invert(), + .instr_fetching_bytecode_id = 11, + .instr_fetching_last_of_bytecode = 1, + .instr_fetching_sel = 1, + }, + }); + + check_relation(trace, instr_fetching::SR_LAST_OF_BYTECODE_TOGGLE); + + trace.set(C::instr_fetching_last_of_bytecode, 1, 1); // Mutate to wrong value (row 1) + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_LAST_OF_BYTECODE_TOGGLE), + "LAST_OF_BYTECODE_TOGGLE"); +} + +// Negative test on not keeping same bytecode_size when bytecode_id is the same +TEST(InstrFetchingConstrainingTest, NegativeNotSameBytecodeSize) +{ + TestTraceContainer trace = TestTraceContainer::from_rows({ + { .precomputed_first_row = 1 }, + { + .instr_fetching_bytecode_id = 2, + .instr_fetching_bytecode_size = 12, + .instr_fetching_sel = 1, + }, + { + .instr_fetching_bytecode_id = 2, + .instr_fetching_bytecode_size = 12, // Will be mutated to 13 + .instr_fetching_last_of_bytecode = 1, + .instr_fetching_sel = 1, + }, + }); + + check_relation(trace, instr_fetching::SR_SAME_BYTECODE_SIZE); + + trace.set(C::instr_fetching_bytecode_size, 2, 13); // Mutate to wrong value + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_SAME_BYTECODE_SIZE), + "SAME_BYTECODE_SIZE"); +} + +// Negative test on not initializing bytecode_size in the first row of a given bytecode. +// Case first bytecode +TEST(InstrFetchingConstrainingTest, NegativeNotInitBytecodeSize1) +{ + TestTraceContainer trace = TestTraceContainer::from_rows({ + { .precomputed_first_row = 1 }, + { + .instr_fetching_bytecode_id = 2, + .instr_fetching_bytecode_size = 12, // Will be mutated to 17 + .instr_fetching_bytes_remaining = 12, + .instr_fetching_last_of_bytecode = 1, + .instr_fetching_sel = 1, + }, + }); + + check_relation(trace, instr_fetching::SR_BYTECODE_SIZE_INIT); + + trace.set(C::instr_fetching_bytecode_size, 1, 17); // Mutate to wrong value + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_BYTECODE_SIZE_INIT), + "BYTECODE_SIZE_INIT"); +} + +// Negative test on not initializing bytecode_size in the first row of a given bytecode. +// Case: a bytecode in the middle +TEST(InstrFetchingConstrainingTest, NegativeNotInitBytecodeSize2) +{ + TestTraceContainer trace = TestTraceContainer::from_rows({ + { .precomputed_first_row = 1 }, + { + .instr_fetching_bytecode_id = 2, + .instr_fetching_bytecode_size = 12, + .instr_fetching_bytes_remaining = 12, + .instr_fetching_last_of_bytecode = 1, + .instr_fetching_sel = 1, + }, + { + .instr_fetching_bytecode_id = 3, + .instr_fetching_bytecode_size = 14, // Will be mutated to zero + .instr_fetching_bytes_remaining = 14, + .instr_fetching_sel = 1, + }, + }); + + check_relation(trace, instr_fetching::SR_BYTECODE_SIZE_INIT); + + trace.set(C::instr_fetching_bytecode_size, 2, 0); // Mutate to wrong value + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_BYTECODE_SIZE_INIT), + "BYTECODE_SIZE_INIT"); +} + +// Negative test on not toggling instr_out_of_range when instr_size > bytes_to_read +TEST(InstrFetchingConstrainingTest, NegativeNotTogglingInstrOutOfRange) +{ + TestTraceContainer trace = TestTraceContainer::from_rows({ + { .precomputed_first_row = 1 }, + { + .instr_fetching_bytes_to_read = 11, + .instr_fetching_instr_abs_diff = 0, + .instr_fetching_instr_out_of_range = 1, // Will be mutated to zero + .instr_fetching_instr_size = 12, + .instr_fetching_sel = 1, + }, + }); + + check_relation(trace, instr_fetching::SR_INSTR_OUT_OF_RANGE_TOGGLE); + + trace.set(C::instr_fetching_instr_out_of_range, 1, 0); // Mutate to wrong value + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_INSTR_OUT_OF_RANGE_TOGGLE), + "INSTR_OUT_OF_RANGE_TOGGLE"); +} + +// Negative test on wrongly toggling instr_out_of_range when instr_size <= bytes_to_read +TEST(InstrFetchingConstrainingTest, NegativeTogglingInstrInRange) +{ + TestTraceContainer trace = TestTraceContainer::from_rows({ + { .precomputed_first_row = 1 }, + { + .instr_fetching_bytes_to_read = 12, + .instr_fetching_instr_abs_diff = 0, + .instr_fetching_instr_out_of_range = 0, // Will be mutated to 1 + .instr_fetching_instr_size = 12, + .instr_fetching_sel = 1, + }, + }); + + check_relation(trace, instr_fetching::SR_INSTR_OUT_OF_RANGE_TOGGLE); + + trace.set(C::instr_fetching_instr_out_of_range, 1, 1); // Mutate to wrong value + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_INSTR_OUT_OF_RANGE_TOGGLE), + "INSTR_OUT_OF_RANGE_TOGGLE"); +} + +// Negative test on not toggling pc_out_of_range when pc >= bytecode_size +TEST(InstrFetchingConstrainingTest, NegativeNotTogglingPcOutOfRange) +{ + TestTraceContainer trace = TestTraceContainer::from_rows({ + { .precomputed_first_row = 1 }, + { + .instr_fetching_bytecode_size = 12, + .instr_fetching_pc = 12, + .instr_fetching_pc_abs_diff = 0, + .instr_fetching_pc_out_of_range = 1, // Will be mutated to 0 + .instr_fetching_sel = 1, + }, + }); + + check_relation(trace, instr_fetching::SR_PC_OUT_OF_RANGE_TOGGLE); + + trace.set(C::instr_fetching_pc_out_of_range, 1, 0); // Mutate to wrong value + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_PC_OUT_OF_RANGE_TOGGLE), + "PC_OUT_OF_RANGE_TOGGLE"); +} + +// Negative test on wrongly toggling pc_out_of_range when pc < bytecode_size +TEST(InstrFetchingConstrainingTest, NegativeTogglingPcInRange) +{ + TestTraceContainer trace = TestTraceContainer::from_rows({ + { .precomputed_first_row = 1 }, + { + .instr_fetching_bytecode_size = 12, + .instr_fetching_pc = 11, + .instr_fetching_pc_abs_diff = 0, + .instr_fetching_pc_out_of_range = 0, // Will be mutated to 1 + .instr_fetching_sel = 1, + }, + }); + + check_relation(trace, instr_fetching::SR_PC_OUT_OF_RANGE_TOGGLE); + + trace.set(C::instr_fetching_pc_out_of_range, 1, 1); // Mutate to wrong value + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_PC_OUT_OF_RANGE_TOGGLE), + "PC_OUT_OF_RANGE_TOGGLE"); +} + +// Negative test on wrong decomposing pc_abs_diff into limbs +TEST(InstrFetchingConstrainingTest, NegativePcAbsDiffLimbs) +{ + TestTraceContainer trace = TestTraceContainer::from_rows({ + { .precomputed_first_row = 1 }, + { + .instr_fetching_pc_abs_diff = 7 * (1 << 16) + 347, + .instr_fetching_pc_abs_diff_hi = 7, + .instr_fetching_pc_abs_diff_lo = 347, // Will be mutated to 348 + }, + }); + + check_relation(trace, instr_fetching::SR_PC_ABS_DIFF_LIMBS); + + trace.set(C::instr_fetching_pc_abs_diff_lo, 1, 348); // Mutate to wrong value + + EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_PC_ABS_DIFF_LIMBS), + "PC_ABS_DIFF_LIMBS"); +} + } // namespace } // namespace bb::avm2::constraining From da1cf7e5d5094bdf7d800cf5cb2fe7c5b5ea0dc3 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Mon, 17 Mar 2025 17:22:29 +0000 Subject: [PATCH 11/25] Comments --- .../cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp index 27095ed6f713..54cd9f1a6a7b 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp @@ -84,6 +84,7 @@ enum class InstrDeserializationError : uint8_t { INSTRUCTION_OUT_OF_RANGE, }; +// Structure to group an instruction and an error struct InstructionWithError { Instruction instruction; InstrDeserializationError error = InstrDeserializationError::NO_ERROR; @@ -96,8 +97,7 @@ struct InstructionWithError { * * @param bytecode The bytecode to be parsed as a vector of bytes/uint8_t * @param pos Bytecode position - * @throws runtime_error exception when the bytecode is invalid or pos is out-of-range - * @return The instruction enahnced with an error + * @return The instruction enhanced with an error */ InstructionWithError deserialize_instruction(std::span bytecode, size_t pos); From 7947364d9d82dd63561cd2e75e0146ba9ce25dc3 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Mon, 17 Mar 2025 17:33:25 +0000 Subject: [PATCH 12/25] Comments --- barretenberg/cpp/pil/vm2/instr_fetching.pil | 2 +- .../cpp/src/barretenberg/vm2/simulation/lib/serialization.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/barretenberg/cpp/pil/vm2/instr_fetching.pil b/barretenberg/cpp/pil/vm2/instr_fetching.pil index 516b28bb1bcf..57a8702a8c29 100644 --- a/barretenberg/cpp/pil/vm2/instr_fetching.pil +++ b/barretenberg/cpp/pil/vm2/instr_fetching.pil @@ -107,7 +107,7 @@ pol commit bd0, bd1, bd2, bd3, bd4, bd31, bd32, bd33, bd34, bd35, bd36; -// selector for lookup to bc_decomposition.pil +// Source selector for lookups to bc_decomposition.pil and instruction specifications in precomputed.pil. pol commit sel_opcode_defined; // Toggled except when pc is out of range. sel_opcode_defined = sel * (1 - pc_out_of_range); diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.cpp index fea2a7510057..334246860f8f 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.cpp @@ -387,7 +387,7 @@ InstructionWithError deserialize_instruction(std::span bytecode, const uint32_t instruction_size = WIRE_INSTRUCTION_SPEC.at(opcode).size_in_bytes; - // We know we will throw an error but we delay throwing the error, because + // We know we will encounter a parsing error, but continue processing because // we need the partial instruction to be parsed for witness generation. if (pos + instruction_size > bytecode_length) { info("Instruction does not fit in remaining bytecode. Wire opcode: ", @@ -417,7 +417,7 @@ InstructionWithError deserialize_instruction(std::span bytecode, std::array operand_padded = { 0 }; // Fill with zeros bool out_of_range = false; - // We will throw during processing of this operand + // Check whether we encounter the parsing error while processing this operand. // In this case, we need to pad the operand to get the partial instruction required // by witness generation. if (pos + operand_size > bytecode_length) { From 72075c21769e486fa48ccbc7bd3df647926c248e Mon Sep 17 00:00:00 2001 From: jeanmon Date: Mon, 17 Mar 2025 17:43:58 +0000 Subject: [PATCH 13/25] Comments --- .../src/barretenberg/vm2/simulation/lib/serialization.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp index 54cd9f1a6a7b..8405bde07d6b 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp @@ -71,7 +71,12 @@ struct Instruction { std::vector operands; std::string to_string() const; + // Serialize the instruction according to the specification from OPCODE_WIRE_FORMAT. + // There is no validation that the instructions operands comply to the format. Namely, + // they are casted according to the operand variant specified in format (throw only in + // truncation case). If the number of operands is larger than specified in format, + // no error will be thrown neither. std::vector serialize() const; bool operator==(const Instruction& other) const = default; From 61bdfeb600e20a157564cdbaffbd6be865a865df Mon Sep 17 00:00:00 2001 From: jeanmon Date: Tue, 18 Mar 2025 12:06:00 +0000 Subject: [PATCH 14/25] Review feedback --- barretenberg/cpp/pil/vm2/instr_fetching.pil | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/pil/vm2/instr_fetching.pil b/barretenberg/cpp/pil/vm2/instr_fetching.pil index 57a8702a8c29..60b459956f13 100644 --- a/barretenberg/cpp/pil/vm2/instr_fetching.pil +++ b/barretenberg/cpp/pil/vm2/instr_fetching.pil @@ -60,7 +60,7 @@ pol commit bytecode_size; #[SAME_BYTECODE_SIZE] sel * sel' * (1 - last_of_bytecode) * (bytecode_size - bytecode_size') = 0; -// Note that last_of_bytecode might not be toggled at the last active row. +// Note that last_of_bytecode might not be toggled at the last active row (if bytecode_id == 0). // For this reason, we need the factor sel' in the above relation. // Absolute difference variant where we compute: From 24096d8f2efdcf647ff12747ff43b3382a6823f0 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Tue, 18 Mar 2025 15:16:24 +0000 Subject: [PATCH 15/25] Add extra space in lookup tuples --- .../cpp/pil/vm2/address_derivation.pil | 2 +- barretenberg/cpp/pil/vm2/bc_hashing.pil | 14 ++-- barretenberg/cpp/pil/vm2/bitwise.pil | 8 +-- .../cpp/pil/vm2/class_id_derivation.pil | 2 +- barretenberg/cpp/pil/vm2/instr_fetching.pil | 6 +- barretenberg/cpp/pil/vm2/range_check.pil | 2 +- barretenberg/cpp/pil/vm2/sha256.pil | 68 +++++++++---------- 7 files changed, 51 insertions(+), 51 deletions(-) diff --git a/barretenberg/cpp/pil/vm2/address_derivation.pil b/barretenberg/cpp/pil/vm2/address_derivation.pil index 4f167b589cfd..644b0100706d 100644 --- a/barretenberg/cpp/pil/vm2/address_derivation.pil +++ b/barretenberg/cpp/pil/vm2/address_derivation.pil @@ -44,7 +44,7 @@ namespace address_derivation; in poseidon2_hash.start { poseidon2_hash.input_0, poseidon2_hash.input_1, poseidon2_hash.input_2, poseidon2_hash.output }; #[SALTED_INITIALIZATION_HASH_POSEIDON2_1] - sel { deployer_addr, precomputed.zero, precomputed.zero, salted_init_hash} + sel { deployer_addr, precomputed.zero, precomputed.zero, salted_init_hash } in poseidon2_hash.end { poseidon2_hash.input_0, poseidon2_hash.input_1, poseidon2_hash.input_2, poseidon2_hash.output }; diff --git a/barretenberg/cpp/pil/vm2/bc_hashing.pil b/barretenberg/cpp/pil/vm2/bc_hashing.pil index 4b278ca3e16e..d3e223fc4c32 100644 --- a/barretenberg/cpp/pil/vm2/bc_hashing.pil +++ b/barretenberg/cpp/pil/vm2/bc_hashing.pil @@ -75,9 +75,9 @@ namespace bc_hashing; pol commit packed_field; #[GET_PACKED_FIELD] - sel {pc_index, bytecode_id, packed_field} + sel { pc_index, bytecode_id, packed_field } in - bc_decomposition.sel_packed {bc_decomposition.pc, bc_decomposition.id, bc_decomposition.packed_field}; + bc_decomposition.sel_packed { bc_decomposition.pc, bc_decomposition.id, bc_decomposition.packed_field }; // This tracks the incremental bytecode hash after the i-th input // The first incremental hash of each new bytecode_id is the length of the bytecode @@ -86,16 +86,16 @@ namespace bc_hashing; // At the start of a new bytecode hash, the initial incremental hash has to be the length of the bytecode // Note the looked up PC = 0 (enforced by the PC_INCREMENTS relation), i.e. the initial incremental hash value == bytecode length #[IV_IS_LEN] - start {pc_index, bytecode_id, incremental_hash} + start { pc_index, bytecode_id, incremental_hash } in - bc_decomposition.sel_packed {bc_decomposition.pc, bc_decomposition.id, bc_decomposition.bytes_remaining}; + bc_decomposition.sel_packed { bc_decomposition.pc, bc_decomposition.id, bc_decomposition.bytes_remaining }; // Start Hashing, Poseidon2(packed_field, running_hash) pol commit output_hash; #[POSEIDON2_HASH] - sel {packed_field, incremental_hash, output_hash} - in poseidon2_hash.sel {poseidon2_hash.input_0, poseidon2_hash.input_1, poseidon2_hash.output}; - + sel { packed_field, incremental_hash, output_hash } + in poseidon2_hash.sel { poseidon2_hash.input_0, poseidon2_hash.input_1, poseidon2_hash.output }; + // The output hash has to be incremental_hash of the next row (unless it's latched) #[CHAIN_OUTPUT_TO_INCR] sel' * (1 - LATCH_CONDITION) * (incremental_hash' - output_hash) = 0; diff --git a/barretenberg/cpp/pil/vm2/bitwise.pil b/barretenberg/cpp/pil/vm2/bitwise.pil index 7edffd7b1a3f..f233d3a2043d 100644 --- a/barretenberg/cpp/pil/vm2/bitwise.pil +++ b/barretenberg/cpp/pil/vm2/bitwise.pil @@ -92,14 +92,14 @@ last * (acc_ic - ic_byte) = 0; (acc_ic - ic_byte - 256 * acc_ic') * (1 - last) = 0; #[INTEGRAL_TAG_LENGTH] -start {tag, ctr} +start { tag, ctr } in -precomputed.sel_integral_tag {precomputed.clk, precomputed.integral_tag_length}; +precomputed.sel_integral_tag { precomputed.clk, precomputed.integral_tag_length }; #[BYTE_OPERATIONS] -sel {op_id, ia_byte, ib_byte, ic_byte} +sel { op_id, ia_byte, ib_byte, ic_byte } in -precomputed.sel_bitwise {precomputed.bitwise_op_id, precomputed.bitwise_input_a, precomputed.bitwise_input_b, precomputed.bitwise_output}; +precomputed.sel_bitwise { precomputed.bitwise_op_id, precomputed.bitwise_input_a, precomputed.bitwise_input_b, precomputed.bitwise_output }; // TODOs: See two following paragraphs diff --git a/barretenberg/cpp/pil/vm2/class_id_derivation.pil b/barretenberg/cpp/pil/vm2/class_id_derivation.pil index c5e6d4fd8c06..d5b5df4faca0 100644 --- a/barretenberg/cpp/pil/vm2/class_id_derivation.pil +++ b/barretenberg/cpp/pil/vm2/class_id_derivation.pil @@ -28,7 +28,7 @@ namespace class_id_derivation; in poseidon2_hash.start { poseidon2_hash.input_0, poseidon2_hash.input_1, poseidon2_hash.input_2, poseidon2_hash.output }; #[CLASS_ID_POSEIDON2_1] - sel { public_bytecode_commitment, precomputed.zero, precomputed.zero, class_id} + sel { public_bytecode_commitment, precomputed.zero, precomputed.zero, class_id } in poseidon2_hash.end { poseidon2_hash.input_0, poseidon2_hash.input_1, poseidon2_hash.input_2, poseidon2_hash.output }; diff --git a/barretenberg/cpp/pil/vm2/instr_fetching.pil b/barretenberg/cpp/pil/vm2/instr_fetching.pil index 60b459956f13..02e0fe39868d 100644 --- a/barretenberg/cpp/pil/vm2/instr_fetching.pil +++ b/barretenberg/cpp/pil/vm2/instr_fetching.pil @@ -73,7 +73,7 @@ pol commit instr_abs_diff; instr_abs_diff = (2 * instr_out_of_range - 1) * (instr_size - bytes_to_read) - instr_out_of_range; #[INSTR_ABS_DIFF_POSITIVE] -sel {instr_abs_diff} in precomputed.sel_range_8 {precomputed.clk}; +sel { instr_abs_diff } in precomputed.sel_range_8 { precomputed.clk }; // We have to enforce that: pc < bytecode_size <==> pc_out_of_range == 0 // We use same trick as above by using an absolute difference value. @@ -92,10 +92,10 @@ pol commit pc_abs_diff_hi; pc_abs_diff = pc_abs_diff_lo + 2**16 * pc_abs_diff_hi; #[PC_ABS_DIFF_POSITIVE_LO] -sel {pc_abs_diff_lo} in precomputed.sel_range_16 {precomputed.clk}; +sel { pc_abs_diff_lo } in precomputed.sel_range_16 { precomputed.clk }; #[PC_ABS_DIFF_POSITIVE_HI] -sel {pc_abs_diff_hi} in precomputed.sel_range_16 {precomputed.clk}; +sel { pc_abs_diff_hi } in precomputed.sel_range_16 { precomputed.clk }; // bytecode[pc] to bytecode[pc + 36] pol commit bd0, bd1, bd2, bd3, bd4, diff --git a/barretenberg/cpp/pil/vm2/range_check.pil b/barretenberg/cpp/pil/vm2/range_check.pil index 07d81e6a2ece..cedc806bf550 100644 --- a/barretenberg/cpp/pil/vm2/range_check.pil +++ b/barretenberg/cpp/pil/vm2/range_check.pil @@ -143,7 +143,7 @@ namespace range_check(256); // This lookup does 2 things (1) Indirectly range checks dyn_rng_chk_bits to not have underflowed and (2) Simplified calculation of 2^dyn_rng_chk_bits #[DYN_RNG_CHK_POW_2] - sel {dyn_rng_chk_bits, dyn_rng_chk_pow_2} in precomputed.sel_range_8 {precomputed.clk, precomputed.power_of_2}; + sel { dyn_rng_chk_bits, dyn_rng_chk_pow_2 } in precomputed.sel_range_8 { precomputed.clk, precomputed.power_of_2 }; // NOTE: `sel_range_8` is chosen because it gives us rows [0, 256] which will give us all of the powers we need (plus many we don't need) // Now we need to perform the dynamic range check itself diff --git a/barretenberg/cpp/pil/vm2/sha256.pil b/barretenberg/cpp/pil/vm2/sha256.pil index 995a358e930a..ad0cbf36107b 100644 --- a/barretenberg/cpp/pil/vm2/sha256.pil +++ b/barretenberg/cpp/pil/vm2/sha256.pil @@ -160,15 +160,15 @@ namespace sha256; // s0 := (w[i-15] `rotr` 7) `xor` (w[i-15] `rotr` 18) `xor` (w[i-15] `rightshift` 3) pol commit w_15_rotr_7_xor_w_15_rotr_18; // #[LOOKUP_W_S_0_XOR_0] - // dummy_zero {w_15_rotr_7, w_15_rotr_18, w_15_rotr_7_xor_w_15_rotr_18, xor_sel} + // dummy_zero { w_15_rotr_7, w_15_rotr_18, w_15_rotr_7_xor_w_15_rotr_18, xor_sel } // in - // binary.start {binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id}; + // binary.start { binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id }; pol commit w_s_0; // #[LOOKUP_W_S_0_XOR_1] - // dummy_zero {w_15_rotr_7_xor_w_15_rotr_18, w_15_rshift_3, w_s_0, xor_sel} + // dummy_zero { w_15_rotr_7_xor_w_15_rotr_18, w_15_rshift_3, w_s_0, xor_sel } // in - // binary.start {binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id}; + // binary.start { binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id }; // ========== Compute w_s1 =================== // w[i-2] `rotr` 17 @@ -192,15 +192,15 @@ namespace sha256; // s1 := (w[i-2] `rotr` 17) `xor` (w[i-2] `rotr` 19) `xor` (w[i-2] `rightshift` 10) pol commit w_2_rotr_17_xor_w_2_rotr_19; // #[LOOKUP_W_S_1_XOR_0] - // dummy_zero {w_2_rotr_17, w_2_rotr_19, w_2_rotr_17_xor_w_2_rotr_19, xor_sel} + // dummy_zero { w_2_rotr_17, w_2_rotr_19, w_2_rotr_17_xor_w_2_rotr_19, xor_sel } // in - // binary.start {binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id}; + // binary.start { binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id }; pol commit w_s_1; // #[LOOKUP_W_S_1_XOR_1] - // dummy_zero {w_2_rotr_17_xor_w_2_rotr_19, w_2_rshift_10, w_s_1, xor_sel} + // dummy_zero { w_2_rotr_17_xor_w_2_rotr_19, w_2_rshift_10, w_s_1, xor_sel } // in - // binary.start {binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id}; + // binary.start { binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id }; // ========== START OF COMPRESSION BLOCK ================== @@ -228,47 +228,47 @@ namespace sha256; pol commit e_rotr_6_xor_e_rotr_11; // #[LOOKUP_S_1_XOR_0] - // dummy_zero {e_rotr_6, e_rotr_11, e_rotr_6_xor_e_rotr_11, xor_sel} + // dummy_zero { e_rotr_6, e_rotr_11, e_rotr_6_xor_e_rotr_11, xor_sel } // in - // binary.start {binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id}; + // binary.start { binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id }; pol commit s_1; // #[LOOKUP_S_1_XOR_1] - // dummy_zero {e_rotr_6_xor_e_rotr_11, e_rotr_25, s_1, xor_sel} + // dummy_zero { e_rotr_6_xor_e_rotr_11, e_rotr_25, s_1, xor_sel } // in - // binary.start {binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id}; + // binary.start { binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id }; // ==== COMPUTING CH =========== // pol CH_0 = (E_0 `and` F_0) `xor` ((`not` E_0) `and` G_0); pol commit e_and_f; // #[LOOKUP_CH_AND_0] - // dummy_zero {e, f, e_and_f, and_sel} + // dummy_zero { e, f, e_and_f, and_sel } // in - // binary.start {binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id}; + // binary.start { binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id }; pol commit not_e; perform_round * (e + not_e - (2**32 - 1)) = 0; pol commit not_e_and_g; // #[LOOKUP_CH_AND_1] - // dummy_zero {not_e, g, not_e_and_g, and_sel} + // dummy_zero { not_e, g, not_e_and_g, and_sel } // in - // binary.start {binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id}; + // binary.start { binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id }; pol commit ch; // #[LOOKUP_CH_XOR] - // dummy_zero {e_and_f, not_e_and_g, ch, xor_sel} + // dummy_zero { e_and_f, not_e_and_g, ch, xor_sel } // in - // binary.start {binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id}; + // binary.start { binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id }; // ===== COMPUTING TMP 1 =========== // Lookup round constants pol commit round_constant; #[ROUND_CONSTANT] - perform_round {round_count, round_constant} + perform_round { round_count, round_constant } in - precomputed.sel_sha256_compression {precomputed.clk, precomputed.sha256_compression_round_constant}; + precomputed.sel_sha256_compression { precomputed.clk, precomputed.sha256_compression_round_constant }; pol TMP_1 = h + s_1 + ch + round_constant + w; @@ -295,47 +295,47 @@ namespace sha256; // (A_0 `rotr` 2) `xor` (A_0 `rotr` 13) pol commit a_rotr_2_xor_a_rotr_13; // #[LOOKUP_S_0_XOR_0] - // dummy_zero {a_rotr_2, a_rotr_13, a_rotr_2_xor_a_rotr_13, xor_sel} + // dummy_zero { a_rotr_2, a_rotr_13, a_rotr_2_xor_a_rotr_13, xor_sel } // in - // binary.start {binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id}; + // binary.start { binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id }; pol commit s_0; // #[LOOKUP_S_0_XOR_1] - // dummy_zero {a_rotr_2_xor_a_rotr_13, a_rotr_22, s_0, xor_sel} + // dummy_zero { a_rotr_2_xor_a_rotr_13, a_rotr_22, s_0, xor_sel } // in - // binary.start {binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id}; + // binary.start { binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id }; // ====== Computing Maj ========= // pol MAJ_0 = (A_0 `and` B_0) `xor` (A_0 `and` C_0) `xor` (B_0 `and` C_0); pol commit a_and_b; // #[LOOKUP_MAJ_AND_0] - // dummy_zero {a, b, a_and_b, and_sel} + // dummy_zero { a, b, a_and_b, and_sel } // in - // binary.start {binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id}; + // binary.start { binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id }; pol commit a_and_c; // #[LOOKUP_MAJ_AND_1] - // dummy_zero {a, c, a_and_c, and_sel} + // dummy_zero { a, c, a_and_c, and_sel } // in - // binary.start {binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id}; + // binary.start { binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id }; pol commit b_and_c; // #[LOOKUP_MAJ_AND_2] - // dummy_zero {b, c, b_and_c, and_sel} + // dummy_zero { b, c, b_and_c, and_sel } // in - // binary.start {binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id}; + // binary.start { binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id }; pol commit a_and_b_xor_a_and_c; // #[LOOKUP_MAJ_XOR_0] - // dummy_zero {a_and_b, a_and_c, a_and_b_xor_a_and_c, xor_sel} + // dummy_zero { a_and_b, a_and_c, a_and_b_xor_a_and_c, xor_sel } // in - // binary.start {binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id}; + // binary.start { binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id }; pol commit maj; // #[LOOKUP_MAJ_XOR_1] - // dummy_zero {a_and_b_xor_a_and_c, b_and_c, maj, xor_sel} + // dummy_zero { a_and_b_xor_a_and_c, b_and_c, maj, xor_sel } // in - // binary.start {binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id}; + // binary.start { binary.acc_ia, binary.acc_ib, binary.acc_ic, binary.op_id }; // ==== Compute TMP 2 ==== pol NEXT_A = s_0 + maj + TMP_1; From 4e1bb1ea38236cb898aaba2b7b8fa6d8d27a57bb Mon Sep 17 00:00:00 2001 From: jeanmon Date: Tue, 18 Mar 2025 15:41:42 +0000 Subject: [PATCH 16/25] Gate operand derivation on no parsing error --- barretenberg/cpp/pil/vm2/instr_fetching.pil | 16 ++++++++-------- .../relations/op_decomposition.test.cpp | 2 ++ .../vm2/generated/relations/instr_fetching.hpp | 18 +++++++++--------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/barretenberg/cpp/pil/vm2/instr_fetching.pil b/barretenberg/cpp/pil/vm2/instr_fetching.pil index 02e0fe39868d..a83108890d9b 100644 --- a/barretenberg/cpp/pil/vm2/instr_fetching.pil +++ b/barretenberg/cpp/pil/vm2/instr_fetching.pil @@ -205,18 +205,18 @@ pol commit op1, op2, op3, op4, op5, op6, op7; pol SEL_OP_DC_18 = sel_op_dc_2 + sel_op_dc_6; #[INDIRECT_BYTES_DECOMPOSITION] -indirect = sel_op_dc_0 * (bd1 * 2**8 + bd2 * 2**0) + SEL_OP_DC_18 * (bd1 * 2**0); +indirect = (1 - parsing_err) * sel_op_dc_0 * (bd1 * 2**8 + bd2 * 2**0) + SEL_OP_DC_18 * (bd1 * 2**0); #[OP1_BYTES_DECOMPOSITION] -op1 = sel_op_dc_0 * (bd3 * 2**8 + bd4 * 2**0) + sel_op_dc_2 * (bd2 * 2**8 + bd3 * 2**0) + sel_op_dc_6 * (bd2 * 2**0) + sel_op_dc_15 * (bd1 * 2**24 + bd2 * 2**16 + bd3 * 2**8 + bd4 * 2**0); +op1 = (1 - parsing_err) * sel_op_dc_0 * (bd3 * 2**8 + bd4 * 2**0) + sel_op_dc_2 * (bd2 * 2**8 + bd3 * 2**0) + sel_op_dc_6 * (bd2 * 2**0) + sel_op_dc_15 * (bd1 * 2**24 + bd2 * 2**16 + bd3 * 2**8 + bd4 * 2**0); #[OP2_BYTES_DECOMPOSITION] -op2 = sel_op_dc_0 * (bd5 * 2**8 + bd6 * 2**0) + sel_op_dc_3 * (bd4 * 2**8 + bd5 * 2**0) + sel_op_dc_6 * (bd3 * 2**0) + sel_op_dc_8 * (bd4 * 2**0) + sel_op_dc_16 * (bd4 * 2**24 + bd5 * 2**16 + bd6 * 2**8 + bd7 * 2**0); +op2 = (1 - parsing_err) * sel_op_dc_0 * (bd5 * 2**8 + bd6 * 2**0) + sel_op_dc_3 * (bd4 * 2**8 + bd5 * 2**0) + sel_op_dc_6 * (bd3 * 2**0) + sel_op_dc_8 * (bd4 * 2**0) + sel_op_dc_16 * (bd4 * 2**24 + bd5 * 2**16 + bd6 * 2**8 + bd7 * 2**0); #[OP3_BYTES_DECOMPOSITION] -op3 = sel_op_dc_0 * (bd7 * 2**8 + bd8 * 2**0) + sel_op_dc_4 * (bd6 * 2**8 + bd7 * 2**0) + sel_op_dc_9 * (bd5 * 2**248 + bd6 * 2**240 + bd7 * 2**232 + bd8 * 2**224 + bd9 * 2**216 + bd10 * 2**208 + bd11 * 2**200 + bd12 * 2**192 + bd13 * 2**184 + bd14 * 2**176 + bd15 * 2**168 + bd16 * 2**160 + bd17 * 2**152 + bd18 * 2**144 + bd19 * 2**136 + bd20 * 2**128 + bd21 * 2**120 + bd22 * 2**112 + bd23 * 2**104 + bd24 * 2**96 + bd25 * 2**88 + bd26 * 2**80 + bd27 * 2**72 + bd28 * 2**64 + bd29 * 2**56 + bd30 * 2**48 + bd31 * 2**40 + bd32 * 2**32 + bd33 * 2**24 + bd34 * 2**16 + bd35 * 2**8 + bd36 * 2**0) + sel_op_dc_10 * (bd5 * 2**120 + bd6 * 2**112 + bd7 * 2**104 + bd8 * 2**96 + bd9 * 2**88 + bd10 * 2**80 + bd11 * 2**72 + bd12 * 2**64 + bd13 * 2**56 + bd14 * 2**48 + bd15 * 2**40 + bd16 * 2**32 + bd17 * 2**24 + bd18 * 2**16 + bd19 * 2**8 + bd20 * 2**0) + sel_op_dc_11 * (bd5 * 2**56 + bd6 * 2**48 + bd7 * 2**40 + bd8 * 2**32 + bd9 * 2**24 + bd10 * 2**16 + bd11 * 2**8 + bd12 * 2**0) + sel_op_dc_12 * (bd5 * 2**24 + bd6 * 2**16 + bd7 * 2**8 + bd8 * 2**0) + sel_op_dc_13 * (bd5 * 2**8 + bd6 * 2**0) + sel_op_dc_14 * (bd4 * 2**0) + sel_op_dc_17 * (bd6 * 2**0); +op3 = (1 - parsing_err) * sel_op_dc_0 * (bd7 * 2**8 + bd8 * 2**0) + sel_op_dc_4 * (bd6 * 2**8 + bd7 * 2**0) + sel_op_dc_9 * (bd5 * 2**248 + bd6 * 2**240 + bd7 * 2**232 + bd8 * 2**224 + bd9 * 2**216 + bd10 * 2**208 + bd11 * 2**200 + bd12 * 2**192 + bd13 * 2**184 + bd14 * 2**176 + bd15 * 2**168 + bd16 * 2**160 + bd17 * 2**152 + bd18 * 2**144 + bd19 * 2**136 + bd20 * 2**128 + bd21 * 2**120 + bd22 * 2**112 + bd23 * 2**104 + bd24 * 2**96 + bd25 * 2**88 + bd26 * 2**80 + bd27 * 2**72 + bd28 * 2**64 + bd29 * 2**56 + bd30 * 2**48 + bd31 * 2**40 + bd32 * 2**32 + bd33 * 2**24 + bd34 * 2**16 + bd35 * 2**8 + bd36 * 2**0) + sel_op_dc_10 * (bd5 * 2**120 + bd6 * 2**112 + bd7 * 2**104 + bd8 * 2**96 + bd9 * 2**88 + bd10 * 2**80 + bd11 * 2**72 + bd12 * 2**64 + bd13 * 2**56 + bd14 * 2**48 + bd15 * 2**40 + bd16 * 2**32 + bd17 * 2**24 + bd18 * 2**16 + bd19 * 2**8 + bd20 * 2**0) + sel_op_dc_11 * (bd5 * 2**56 + bd6 * 2**48 + bd7 * 2**40 + bd8 * 2**32 + bd9 * 2**24 + bd10 * 2**16 + bd11 * 2**8 + bd12 * 2**0) + sel_op_dc_12 * (bd5 * 2**24 + bd6 * 2**16 + bd7 * 2**8 + bd8 * 2**0) + sel_op_dc_13 * (bd5 * 2**8 + bd6 * 2**0) + sel_op_dc_14 * (bd4 * 2**0) + sel_op_dc_17 * (bd6 * 2**0); #[OP4_BYTES_DECOMPOSITION] -op4 = sel_op_dc_0 * (bd9 * 2**8 + bd10 * 2**0) + sel_op_dc_5 * (bd8 * 2**8 + bd9 * 2**0) + sel_op_dc_7 * (bd8 * 2**0); +op4 = (1 - parsing_err) * sel_op_dc_0 * (bd9 * 2**8 + bd10 * 2**0) + sel_op_dc_5 * (bd8 * 2**8 + bd9 * 2**0) + sel_op_dc_7 * (bd8 * 2**0); #[OP5_BYTES_DECOMPOSITION] -op5 = sel_op_dc_0 * (bd11 * 2**8 + bd12 * 2**0); +op5 = (1 - parsing_err) * sel_op_dc_0 * (bd11 * 2**8 + bd12 * 2**0); #[OP6_BYTES_DECOMPOSITION] -op6 = sel_op_dc_1 * (bd13 * 2**8 + bd14 * 2**0); +op6 = (1 - parsing_err) * sel_op_dc_1 * (bd13 * 2**8 + bd14 * 2**0); #[OP7_BYTES_DECOMPOSITION] -op7 = sel_op_dc_1 * (bd15 * 2**8 + bd16 * 2**0); +op7 = (1 - parsing_err) * sel_op_dc_1 * (bd15 * 2**8 + bd16 * 2**0); diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/op_decomposition.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/op_decomposition.test.cpp index fe998d6617ba..2fcc0116fd52 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/op_decomposition.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/op_decomposition.test.cpp @@ -177,6 +177,8 @@ std::string render_pil( : format("#[OP", static_cast(i), "_BYTES_DECOMPOSITION]\n"); pil_equations += (i == 0) ? "indirect = " : format(OPERAND_PREFIX, static_cast(i), " = "); + pil_equations += "(1 - parsing_err) * "; // Error gating multiplicative term + std::vector additive_terms; for (const auto& sel_layout : sel_layout_breakdowns[i]) { additive_terms.push_back( diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp index 235969655cfe..765f0e0f426a 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp @@ -13,7 +13,7 @@ template class instr_fetchingImpl { using FF = FF_; static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3, 3, 3, 4, 4, 3, 5, 3, 3, 5, 3, - 4, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3 }; + 4, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4 }; template inline static bool skip(const AllEntities& in) { @@ -142,7 +142,7 @@ template class instr_fetchingImpl { { using Accumulator = typename std::tuple_element_t<14, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_indirect - - (new_term.instr_fetching_sel_op_dc_0 * + ((FF(1) - new_term.instr_fetching_parsing_err) * new_term.instr_fetching_sel_op_dc_0 * (new_term.instr_fetching_bd1 * FF(256) + new_term.instr_fetching_bd2 * FF(1)) + instr_fetching_SEL_OP_DC_18 * new_term.instr_fetching_bd1 * FF(1))); tmp *= scaling_factor; @@ -151,7 +151,7 @@ template class instr_fetchingImpl { { using Accumulator = typename std::tuple_element_t<15, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op1 - - (new_term.instr_fetching_sel_op_dc_0 * + ((FF(1) - new_term.instr_fetching_parsing_err) * new_term.instr_fetching_sel_op_dc_0 * (new_term.instr_fetching_bd3 * FF(256) + new_term.instr_fetching_bd4 * FF(1)) + new_term.instr_fetching_sel_op_dc_2 * (new_term.instr_fetching_bd2 * FF(256) + new_term.instr_fetching_bd3 * FF(1)) + @@ -165,7 +165,7 @@ template class instr_fetchingImpl { { using Accumulator = typename std::tuple_element_t<16, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op2 - - (new_term.instr_fetching_sel_op_dc_0 * + ((FF(1) - new_term.instr_fetching_parsing_err) * new_term.instr_fetching_sel_op_dc_0 * (new_term.instr_fetching_bd5 * FF(256) + new_term.instr_fetching_bd6 * FF(1)) + new_term.instr_fetching_sel_op_dc_3 * (new_term.instr_fetching_bd4 * FF(256) + new_term.instr_fetching_bd5 * FF(1)) + @@ -180,7 +180,7 @@ template class instr_fetchingImpl { { using Accumulator = typename std::tuple_element_t<17, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op3 - - (new_term.instr_fetching_sel_op_dc_0 * + ((FF(1) - new_term.instr_fetching_parsing_err) * new_term.instr_fetching_sel_op_dc_0 * (new_term.instr_fetching_bd7 * FF(256) + new_term.instr_fetching_bd8 * FF(1)) + new_term.instr_fetching_sel_op_dc_4 * (new_term.instr_fetching_bd6 * FF(256) + new_term.instr_fetching_bd7 * FF(1)) + @@ -250,7 +250,7 @@ template class instr_fetchingImpl { { using Accumulator = typename std::tuple_element_t<18, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op4 - - (new_term.instr_fetching_sel_op_dc_0 * + ((FF(1) - new_term.instr_fetching_parsing_err) * new_term.instr_fetching_sel_op_dc_0 * (new_term.instr_fetching_bd9 * FF(256) + new_term.instr_fetching_bd10 * FF(1)) + new_term.instr_fetching_sel_op_dc_5 * (new_term.instr_fetching_bd8 * FF(256) + new_term.instr_fetching_bd9 * FF(1)) + @@ -261,7 +261,7 @@ template class instr_fetchingImpl { { using Accumulator = typename std::tuple_element_t<19, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op5 - - new_term.instr_fetching_sel_op_dc_0 * + (FF(1) - new_term.instr_fetching_parsing_err) * new_term.instr_fetching_sel_op_dc_0 * (new_term.instr_fetching_bd11 * FF(256) + new_term.instr_fetching_bd12 * FF(1))); tmp *= scaling_factor; std::get<19>(evals) += typename Accumulator::View(tmp); @@ -269,7 +269,7 @@ template class instr_fetchingImpl { { using Accumulator = typename std::tuple_element_t<20, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op6 - - new_term.instr_fetching_sel_op_dc_1 * + (FF(1) - new_term.instr_fetching_parsing_err) * new_term.instr_fetching_sel_op_dc_1 * (new_term.instr_fetching_bd13 * FF(256) + new_term.instr_fetching_bd14 * FF(1))); tmp *= scaling_factor; std::get<20>(evals) += typename Accumulator::View(tmp); @@ -277,7 +277,7 @@ template class instr_fetchingImpl { { using Accumulator = typename std::tuple_element_t<21, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op7 - - new_term.instr_fetching_sel_op_dc_1 * + (FF(1) - new_term.instr_fetching_parsing_err) * new_term.instr_fetching_sel_op_dc_1 * (new_term.instr_fetching_bd15 * FF(256) + new_term.instr_fetching_bd16 * FF(1))); tmp *= scaling_factor; std::get<21>(evals) += typename Accumulator::View(tmp); From 89b9ceda233006d98bd752d287e3360dc27e796c Mon Sep 17 00:00:00 2001 From: jeanmon Date: Tue, 18 Mar 2025 16:34:13 +0000 Subject: [PATCH 17/25] Gate operands relation by no parsing error and remove InstructionWithError structure in deserialization --- barretenberg/cpp/pil/vm2/instr_fetching.pil | 19 +- .../relations/instr_fetching.test.cpp | 8 - .../relations/op_decomposition.test.cpp | 4 +- .../generated/relations/instr_fetching.hpp | 186 +++++++++--------- .../vm2/simulation/bytecode_manager.cpp | 14 +- .../vm2/simulation/lib/serialization.cpp | 51 ++--- .../vm2/simulation/lib/serialization.hpp | 7 +- .../vm2/simulation/lib/serialization.test.cpp | 30 ++- 8 files changed, 161 insertions(+), 158 deletions(-) diff --git a/barretenberg/cpp/pil/vm2/instr_fetching.pil b/barretenberg/cpp/pil/vm2/instr_fetching.pil index a83108890d9b..b732a76c415f 100644 --- a/barretenberg/cpp/pil/vm2/instr_fetching.pil +++ b/barretenberg/cpp/pil/vm2/instr_fetching.pil @@ -199,24 +199,27 @@ pol commit indirect; // Operands. pol commit op1, op2, op3, op4, op5, op6, op7; +// We derive the operands only when no parsing error occurs. One might remove this gating but +// at a cost of some ugliness in the code (witgen would need a partially parsed instruction when +// the error instr_out_of_range is toggled). // The following relations decomposing operands (indirect, op1, ...) into bytes were code-generated by // a cpp test in op_decomposition.test.cpp. // Remark: Upper-casing the alias needs to be edited manually (not code-generated)! pol SEL_OP_DC_18 = sel_op_dc_2 + sel_op_dc_6; #[INDIRECT_BYTES_DECOMPOSITION] -indirect = (1 - parsing_err) * sel_op_dc_0 * (bd1 * 2**8 + bd2 * 2**0) + SEL_OP_DC_18 * (bd1 * 2**0); +indirect = (1 - parsing_err) * (sel_op_dc_0 * (bd1 * 2**8 + bd2 * 2**0) + SEL_OP_DC_18 * (bd1 * 2**0)); #[OP1_BYTES_DECOMPOSITION] -op1 = (1 - parsing_err) * sel_op_dc_0 * (bd3 * 2**8 + bd4 * 2**0) + sel_op_dc_2 * (bd2 * 2**8 + bd3 * 2**0) + sel_op_dc_6 * (bd2 * 2**0) + sel_op_dc_15 * (bd1 * 2**24 + bd2 * 2**16 + bd3 * 2**8 + bd4 * 2**0); +op1 = (1 - parsing_err) * (sel_op_dc_0 * (bd3 * 2**8 + bd4 * 2**0) + sel_op_dc_2 * (bd2 * 2**8 + bd3 * 2**0) + sel_op_dc_6 * (bd2 * 2**0) + sel_op_dc_15 * (bd1 * 2**24 + bd2 * 2**16 + bd3 * 2**8 + bd4 * 2**0)); #[OP2_BYTES_DECOMPOSITION] -op2 = (1 - parsing_err) * sel_op_dc_0 * (bd5 * 2**8 + bd6 * 2**0) + sel_op_dc_3 * (bd4 * 2**8 + bd5 * 2**0) + sel_op_dc_6 * (bd3 * 2**0) + sel_op_dc_8 * (bd4 * 2**0) + sel_op_dc_16 * (bd4 * 2**24 + bd5 * 2**16 + bd6 * 2**8 + bd7 * 2**0); +op2 = (1 - parsing_err) * (sel_op_dc_0 * (bd5 * 2**8 + bd6 * 2**0) + sel_op_dc_3 * (bd4 * 2**8 + bd5 * 2**0) + sel_op_dc_6 * (bd3 * 2**0) + sel_op_dc_8 * (bd4 * 2**0) + sel_op_dc_16 * (bd4 * 2**24 + bd5 * 2**16 + bd6 * 2**8 + bd7 * 2**0)); #[OP3_BYTES_DECOMPOSITION] -op3 = (1 - parsing_err) * sel_op_dc_0 * (bd7 * 2**8 + bd8 * 2**0) + sel_op_dc_4 * (bd6 * 2**8 + bd7 * 2**0) + sel_op_dc_9 * (bd5 * 2**248 + bd6 * 2**240 + bd7 * 2**232 + bd8 * 2**224 + bd9 * 2**216 + bd10 * 2**208 + bd11 * 2**200 + bd12 * 2**192 + bd13 * 2**184 + bd14 * 2**176 + bd15 * 2**168 + bd16 * 2**160 + bd17 * 2**152 + bd18 * 2**144 + bd19 * 2**136 + bd20 * 2**128 + bd21 * 2**120 + bd22 * 2**112 + bd23 * 2**104 + bd24 * 2**96 + bd25 * 2**88 + bd26 * 2**80 + bd27 * 2**72 + bd28 * 2**64 + bd29 * 2**56 + bd30 * 2**48 + bd31 * 2**40 + bd32 * 2**32 + bd33 * 2**24 + bd34 * 2**16 + bd35 * 2**8 + bd36 * 2**0) + sel_op_dc_10 * (bd5 * 2**120 + bd6 * 2**112 + bd7 * 2**104 + bd8 * 2**96 + bd9 * 2**88 + bd10 * 2**80 + bd11 * 2**72 + bd12 * 2**64 + bd13 * 2**56 + bd14 * 2**48 + bd15 * 2**40 + bd16 * 2**32 + bd17 * 2**24 + bd18 * 2**16 + bd19 * 2**8 + bd20 * 2**0) + sel_op_dc_11 * (bd5 * 2**56 + bd6 * 2**48 + bd7 * 2**40 + bd8 * 2**32 + bd9 * 2**24 + bd10 * 2**16 + bd11 * 2**8 + bd12 * 2**0) + sel_op_dc_12 * (bd5 * 2**24 + bd6 * 2**16 + bd7 * 2**8 + bd8 * 2**0) + sel_op_dc_13 * (bd5 * 2**8 + bd6 * 2**0) + sel_op_dc_14 * (bd4 * 2**0) + sel_op_dc_17 * (bd6 * 2**0); +op3 = (1 - parsing_err) * (sel_op_dc_0 * (bd7 * 2**8 + bd8 * 2**0) + sel_op_dc_4 * (bd6 * 2**8 + bd7 * 2**0) + sel_op_dc_9 * (bd5 * 2**248 + bd6 * 2**240 + bd7 * 2**232 + bd8 * 2**224 + bd9 * 2**216 + bd10 * 2**208 + bd11 * 2**200 + bd12 * 2**192 + bd13 * 2**184 + bd14 * 2**176 + bd15 * 2**168 + bd16 * 2**160 + bd17 * 2**152 + bd18 * 2**144 + bd19 * 2**136 + bd20 * 2**128 + bd21 * 2**120 + bd22 * 2**112 + bd23 * 2**104 + bd24 * 2**96 + bd25 * 2**88 + bd26 * 2**80 + bd27 * 2**72 + bd28 * 2**64 + bd29 * 2**56 + bd30 * 2**48 + bd31 * 2**40 + bd32 * 2**32 + bd33 * 2**24 + bd34 * 2**16 + bd35 * 2**8 + bd36 * 2**0) + sel_op_dc_10 * (bd5 * 2**120 + bd6 * 2**112 + bd7 * 2**104 + bd8 * 2**96 + bd9 * 2**88 + bd10 * 2**80 + bd11 * 2**72 + bd12 * 2**64 + bd13 * 2**56 + bd14 * 2**48 + bd15 * 2**40 + bd16 * 2**32 + bd17 * 2**24 + bd18 * 2**16 + bd19 * 2**8 + bd20 * 2**0) + sel_op_dc_11 * (bd5 * 2**56 + bd6 * 2**48 + bd7 * 2**40 + bd8 * 2**32 + bd9 * 2**24 + bd10 * 2**16 + bd11 * 2**8 + bd12 * 2**0) + sel_op_dc_12 * (bd5 * 2**24 + bd6 * 2**16 + bd7 * 2**8 + bd8 * 2**0) + sel_op_dc_13 * (bd5 * 2**8 + bd6 * 2**0) + sel_op_dc_14 * (bd4 * 2**0) + sel_op_dc_17 * (bd6 * 2**0)); #[OP4_BYTES_DECOMPOSITION] -op4 = (1 - parsing_err) * sel_op_dc_0 * (bd9 * 2**8 + bd10 * 2**0) + sel_op_dc_5 * (bd8 * 2**8 + bd9 * 2**0) + sel_op_dc_7 * (bd8 * 2**0); +op4 = (1 - parsing_err) * (sel_op_dc_0 * (bd9 * 2**8 + bd10 * 2**0) + sel_op_dc_5 * (bd8 * 2**8 + bd9 * 2**0) + sel_op_dc_7 * (bd8 * 2**0)); #[OP5_BYTES_DECOMPOSITION] -op5 = (1 - parsing_err) * sel_op_dc_0 * (bd11 * 2**8 + bd12 * 2**0); +op5 = (1 - parsing_err) * (sel_op_dc_0 * (bd11 * 2**8 + bd12 * 2**0)); #[OP6_BYTES_DECOMPOSITION] -op6 = (1 - parsing_err) * sel_op_dc_1 * (bd13 * 2**8 + bd14 * 2**0); +op6 = (1 - parsing_err) * (sel_op_dc_1 * (bd13 * 2**8 + bd14 * 2**0)); #[OP7_BYTES_DECOMPOSITION] -op7 = (1 - parsing_err) * sel_op_dc_1 * (bd15 * 2**8 + bd16 * 2**0); +op7 = (1 - parsing_err) * (sel_op_dc_1 * (bd15 * 2**8 + bd16 * 2**0)); diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp index 24484587cb3a..855acfcc9f7d 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp @@ -363,16 +363,12 @@ TEST(InstrFetchingConstrainingTest, SingleInstructionOutOfRange) std::vector bytecode = add_8_instruction.serialize(); bytecode.pop_back(); // Remove last byte - const auto instr_with_err = simulation::deserialize_instruction(bytecode, 0); const auto bytecode_ptr = std::make_shared>(std::move(bytecode)); - ASSERT_EQ(instr_with_err.error, InstrDeserializationError::INSTRUCTION_OUT_OF_RANGE); - const std::vector instr_events = { { .bytecode_id = 1, .pc = 0, - .instruction = instr_with_err.instruction, .bytecode = bytecode_ptr, .error = InstrDeserializationError::INSTRUCTION_OUT_OF_RANGE, }, @@ -404,16 +400,12 @@ TEST(InstrFetchingConstrainingTest, SingleInstructionOutOfRangeSplitOperand) std::vector bytecode = set_ff_instruction.serialize(); bytecode.resize(bytecode.size() - 2); // Remove last two bytes) - const auto instr_with_err = simulation::deserialize_instruction(bytecode, 0); const auto bytecode_ptr = std::make_shared>(std::move(bytecode)); - ASSERT_EQ(instr_with_err.error, InstrDeserializationError::INSTRUCTION_OUT_OF_RANGE); - const std::vector instr_events = { { .bytecode_id = 1, .pc = 0, - .instruction = instr_with_err.instruction, .bytecode = bytecode_ptr, .error = InstrDeserializationError::INSTRUCTION_OUT_OF_RANGE, }, diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/op_decomposition.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/op_decomposition.test.cpp index 2fcc0116fd52..aa9c904304ea 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/op_decomposition.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/op_decomposition.test.cpp @@ -177,7 +177,7 @@ std::string render_pil( : format("#[OP", static_cast(i), "_BYTES_DECOMPOSITION]\n"); pil_equations += (i == 0) ? "indirect = " : format(OPERAND_PREFIX, static_cast(i), " = "); - pil_equations += "(1 - parsing_err) * "; // Error gating multiplicative term + pil_equations += "(1 - parsing_err) * ("; // Error gating multiplicative term std::vector additive_terms; for (const auto& sel_layout : sel_layout_breakdowns[i]) { @@ -186,7 +186,7 @@ std::string render_pil( } pil_equations += std::accumulate(std::next(additive_terms.begin()), additive_terms.end(), additive_terms[0], add_fold); - pil_equations += ";\n"; + pil_equations += ");\n"; } return pil_equations; } diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp index 765f0e0f426a..2686b8535299 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp @@ -142,119 +142,125 @@ template class instr_fetchingImpl { { using Accumulator = typename std::tuple_element_t<14, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_indirect - - ((FF(1) - new_term.instr_fetching_parsing_err) * new_term.instr_fetching_sel_op_dc_0 * - (new_term.instr_fetching_bd1 * FF(256) + new_term.instr_fetching_bd2 * FF(1)) + - instr_fetching_SEL_OP_DC_18 * new_term.instr_fetching_bd1 * FF(1))); + (FF(1) - new_term.instr_fetching_parsing_err) * + (new_term.instr_fetching_sel_op_dc_0 * + (new_term.instr_fetching_bd1 * FF(256) + new_term.instr_fetching_bd2 * FF(1)) + + instr_fetching_SEL_OP_DC_18 * new_term.instr_fetching_bd1 * FF(1))); tmp *= scaling_factor; std::get<14>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<15, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op1 - - ((FF(1) - new_term.instr_fetching_parsing_err) * new_term.instr_fetching_sel_op_dc_0 * - (new_term.instr_fetching_bd3 * FF(256) + new_term.instr_fetching_bd4 * FF(1)) + - new_term.instr_fetching_sel_op_dc_2 * - (new_term.instr_fetching_bd2 * FF(256) + new_term.instr_fetching_bd3 * FF(1)) + - new_term.instr_fetching_sel_op_dc_6 * new_term.instr_fetching_bd2 * FF(1) + - new_term.instr_fetching_sel_op_dc_15 * - (new_term.instr_fetching_bd1 * FF(16777216) + new_term.instr_fetching_bd2 * FF(65536) + - new_term.instr_fetching_bd3 * FF(256) + new_term.instr_fetching_bd4 * FF(1)))); + (FF(1) - new_term.instr_fetching_parsing_err) * + (new_term.instr_fetching_sel_op_dc_0 * + (new_term.instr_fetching_bd3 * FF(256) + new_term.instr_fetching_bd4 * FF(1)) + + new_term.instr_fetching_sel_op_dc_2 * + (new_term.instr_fetching_bd2 * FF(256) + new_term.instr_fetching_bd3 * FF(1)) + + new_term.instr_fetching_sel_op_dc_6 * new_term.instr_fetching_bd2 * FF(1) + + new_term.instr_fetching_sel_op_dc_15 * + (new_term.instr_fetching_bd1 * FF(16777216) + new_term.instr_fetching_bd2 * FF(65536) + + new_term.instr_fetching_bd3 * FF(256) + new_term.instr_fetching_bd4 * FF(1)))); tmp *= scaling_factor; std::get<15>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<16, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op2 - - ((FF(1) - new_term.instr_fetching_parsing_err) * new_term.instr_fetching_sel_op_dc_0 * - (new_term.instr_fetching_bd5 * FF(256) + new_term.instr_fetching_bd6 * FF(1)) + - new_term.instr_fetching_sel_op_dc_3 * - (new_term.instr_fetching_bd4 * FF(256) + new_term.instr_fetching_bd5 * FF(1)) + - new_term.instr_fetching_sel_op_dc_6 * new_term.instr_fetching_bd3 * FF(1) + - new_term.instr_fetching_sel_op_dc_8 * new_term.instr_fetching_bd4 * FF(1) + - new_term.instr_fetching_sel_op_dc_16 * - (new_term.instr_fetching_bd4 * FF(16777216) + new_term.instr_fetching_bd5 * FF(65536) + - new_term.instr_fetching_bd6 * FF(256) + new_term.instr_fetching_bd7 * FF(1)))); + (FF(1) - new_term.instr_fetching_parsing_err) * + (new_term.instr_fetching_sel_op_dc_0 * + (new_term.instr_fetching_bd5 * FF(256) + new_term.instr_fetching_bd6 * FF(1)) + + new_term.instr_fetching_sel_op_dc_3 * + (new_term.instr_fetching_bd4 * FF(256) + new_term.instr_fetching_bd5 * FF(1)) + + new_term.instr_fetching_sel_op_dc_6 * new_term.instr_fetching_bd3 * FF(1) + + new_term.instr_fetching_sel_op_dc_8 * new_term.instr_fetching_bd4 * FF(1) + + new_term.instr_fetching_sel_op_dc_16 * + (new_term.instr_fetching_bd4 * FF(16777216) + new_term.instr_fetching_bd5 * FF(65536) + + new_term.instr_fetching_bd6 * FF(256) + new_term.instr_fetching_bd7 * FF(1)))); tmp *= scaling_factor; std::get<16>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<17, ContainerOverSubrelations>; - auto tmp = (new_term.instr_fetching_op3 - - ((FF(1) - new_term.instr_fetching_parsing_err) * new_term.instr_fetching_sel_op_dc_0 * - (new_term.instr_fetching_bd7 * FF(256) + new_term.instr_fetching_bd8 * FF(1)) + - new_term.instr_fetching_sel_op_dc_4 * - (new_term.instr_fetching_bd6 * FF(256) + new_term.instr_fetching_bd7 * FF(1)) + - new_term.instr_fetching_sel_op_dc_9 * - (new_term.instr_fetching_bd5 * FF(uint256_t{ 0UL, 0UL, 0UL, 72057594037927936UL }) + - new_term.instr_fetching_bd6 * FF(uint256_t{ 0UL, 0UL, 0UL, 281474976710656UL }) + - new_term.instr_fetching_bd7 * FF(uint256_t{ 0UL, 0UL, 0UL, 1099511627776UL }) + - new_term.instr_fetching_bd8 * FF(uint256_t{ 0UL, 0UL, 0UL, 4294967296UL }) + - new_term.instr_fetching_bd9 * FF(uint256_t{ 0UL, 0UL, 0UL, 16777216UL }) + - new_term.instr_fetching_bd10 * FF(uint256_t{ 0UL, 0UL, 0UL, 65536UL }) + - new_term.instr_fetching_bd11 * FF(uint256_t{ 0UL, 0UL, 0UL, 256UL }) + - new_term.instr_fetching_bd12 * FF(uint256_t{ 0UL, 0UL, 0UL, 1UL }) + - new_term.instr_fetching_bd13 * FF(uint256_t{ 0UL, 0UL, 72057594037927936UL, 0UL }) + - new_term.instr_fetching_bd14 * FF(uint256_t{ 0UL, 0UL, 281474976710656UL, 0UL }) + - new_term.instr_fetching_bd15 * FF(uint256_t{ 0UL, 0UL, 1099511627776UL, 0UL }) + - new_term.instr_fetching_bd16 * FF(uint256_t{ 0UL, 0UL, 4294967296UL, 0UL }) + - new_term.instr_fetching_bd17 * FF(uint256_t{ 0UL, 0UL, 16777216UL, 0UL }) + - new_term.instr_fetching_bd18 * FF(uint256_t{ 0UL, 0UL, 65536UL, 0UL }) + - new_term.instr_fetching_bd19 * FF(uint256_t{ 0UL, 0UL, 256UL, 0UL }) + - new_term.instr_fetching_bd20 * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }) + - new_term.instr_fetching_bd21 * FF(uint256_t{ 0UL, 72057594037927936UL, 0UL, 0UL }) + - new_term.instr_fetching_bd22 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }) + - new_term.instr_fetching_bd23 * FF(uint256_t{ 0UL, 1099511627776UL, 0UL, 0UL }) + - new_term.instr_fetching_bd24 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }) + - new_term.instr_fetching_bd25 * FF(uint256_t{ 0UL, 16777216UL, 0UL, 0UL }) + - new_term.instr_fetching_bd26 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }) + - new_term.instr_fetching_bd27 * FF(uint256_t{ 0UL, 256UL, 0UL, 0UL }) + - new_term.instr_fetching_bd28 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }) + - new_term.instr_fetching_bd29 * FF(72057594037927936UL) + - new_term.instr_fetching_bd30 * FF(281474976710656UL) + - new_term.instr_fetching_bd31 * FF(1099511627776UL) + - new_term.instr_fetching_bd32 * FF(4294967296UL) + - new_term.instr_fetching_bd33 * FF(16777216) + new_term.instr_fetching_bd34 * FF(65536) + - new_term.instr_fetching_bd35 * FF(256) + new_term.instr_fetching_bd36 * FF(1)) + - new_term.instr_fetching_sel_op_dc_10 * - (new_term.instr_fetching_bd5 * FF(uint256_t{ 0UL, 72057594037927936UL, 0UL, 0UL }) + - new_term.instr_fetching_bd6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }) + - new_term.instr_fetching_bd7 * FF(uint256_t{ 0UL, 1099511627776UL, 0UL, 0UL }) + - new_term.instr_fetching_bd8 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }) + - new_term.instr_fetching_bd9 * FF(uint256_t{ 0UL, 16777216UL, 0UL, 0UL }) + - new_term.instr_fetching_bd10 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }) + - new_term.instr_fetching_bd11 * FF(uint256_t{ 0UL, 256UL, 0UL, 0UL }) + - new_term.instr_fetching_bd12 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }) + - new_term.instr_fetching_bd13 * FF(72057594037927936UL) + - new_term.instr_fetching_bd14 * FF(281474976710656UL) + - new_term.instr_fetching_bd15 * FF(1099511627776UL) + - new_term.instr_fetching_bd16 * FF(4294967296UL) + - new_term.instr_fetching_bd17 * FF(16777216) + new_term.instr_fetching_bd18 * FF(65536) + - new_term.instr_fetching_bd19 * FF(256) + new_term.instr_fetching_bd20 * FF(1)) + - new_term.instr_fetching_sel_op_dc_11 * - (new_term.instr_fetching_bd5 * FF(72057594037927936UL) + - new_term.instr_fetching_bd6 * FF(281474976710656UL) + - new_term.instr_fetching_bd7 * FF(1099511627776UL) + - new_term.instr_fetching_bd8 * FF(4294967296UL) + - new_term.instr_fetching_bd9 * FF(16777216) + new_term.instr_fetching_bd10 * FF(65536) + - new_term.instr_fetching_bd11 * FF(256) + new_term.instr_fetching_bd12 * FF(1)) + - new_term.instr_fetching_sel_op_dc_12 * - (new_term.instr_fetching_bd5 * FF(16777216) + new_term.instr_fetching_bd6 * FF(65536) + - new_term.instr_fetching_bd7 * FF(256) + new_term.instr_fetching_bd8 * FF(1)) + - new_term.instr_fetching_sel_op_dc_13 * - (new_term.instr_fetching_bd5 * FF(256) + new_term.instr_fetching_bd6 * FF(1)) + - new_term.instr_fetching_sel_op_dc_14 * new_term.instr_fetching_bd4 * FF(1) + - new_term.instr_fetching_sel_op_dc_17 * new_term.instr_fetching_bd6 * FF(1))); + auto tmp = + (new_term.instr_fetching_op3 - + (FF(1) - new_term.instr_fetching_parsing_err) * + (new_term.instr_fetching_sel_op_dc_0 * + (new_term.instr_fetching_bd7 * FF(256) + new_term.instr_fetching_bd8 * FF(1)) + + new_term.instr_fetching_sel_op_dc_4 * + (new_term.instr_fetching_bd6 * FF(256) + new_term.instr_fetching_bd7 * FF(1)) + + new_term.instr_fetching_sel_op_dc_9 * + (new_term.instr_fetching_bd5 * FF(uint256_t{ 0UL, 0UL, 0UL, 72057594037927936UL }) + + new_term.instr_fetching_bd6 * FF(uint256_t{ 0UL, 0UL, 0UL, 281474976710656UL }) + + new_term.instr_fetching_bd7 * FF(uint256_t{ 0UL, 0UL, 0UL, 1099511627776UL }) + + new_term.instr_fetching_bd8 * FF(uint256_t{ 0UL, 0UL, 0UL, 4294967296UL }) + + new_term.instr_fetching_bd9 * FF(uint256_t{ 0UL, 0UL, 0UL, 16777216UL }) + + new_term.instr_fetching_bd10 * FF(uint256_t{ 0UL, 0UL, 0UL, 65536UL }) + + new_term.instr_fetching_bd11 * FF(uint256_t{ 0UL, 0UL, 0UL, 256UL }) + + new_term.instr_fetching_bd12 * FF(uint256_t{ 0UL, 0UL, 0UL, 1UL }) + + new_term.instr_fetching_bd13 * FF(uint256_t{ 0UL, 0UL, 72057594037927936UL, 0UL }) + + new_term.instr_fetching_bd14 * FF(uint256_t{ 0UL, 0UL, 281474976710656UL, 0UL }) + + new_term.instr_fetching_bd15 * FF(uint256_t{ 0UL, 0UL, 1099511627776UL, 0UL }) + + new_term.instr_fetching_bd16 * FF(uint256_t{ 0UL, 0UL, 4294967296UL, 0UL }) + + new_term.instr_fetching_bd17 * FF(uint256_t{ 0UL, 0UL, 16777216UL, 0UL }) + + new_term.instr_fetching_bd18 * FF(uint256_t{ 0UL, 0UL, 65536UL, 0UL }) + + new_term.instr_fetching_bd19 * FF(uint256_t{ 0UL, 0UL, 256UL, 0UL }) + + new_term.instr_fetching_bd20 * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }) + + new_term.instr_fetching_bd21 * FF(uint256_t{ 0UL, 72057594037927936UL, 0UL, 0UL }) + + new_term.instr_fetching_bd22 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }) + + new_term.instr_fetching_bd23 * FF(uint256_t{ 0UL, 1099511627776UL, 0UL, 0UL }) + + new_term.instr_fetching_bd24 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }) + + new_term.instr_fetching_bd25 * FF(uint256_t{ 0UL, 16777216UL, 0UL, 0UL }) + + new_term.instr_fetching_bd26 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }) + + new_term.instr_fetching_bd27 * FF(uint256_t{ 0UL, 256UL, 0UL, 0UL }) + + new_term.instr_fetching_bd28 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }) + + new_term.instr_fetching_bd29 * FF(72057594037927936UL) + + new_term.instr_fetching_bd30 * FF(281474976710656UL) + + new_term.instr_fetching_bd31 * FF(1099511627776UL) + + new_term.instr_fetching_bd32 * FF(4294967296UL) + + new_term.instr_fetching_bd33 * FF(16777216) + new_term.instr_fetching_bd34 * FF(65536) + + new_term.instr_fetching_bd35 * FF(256) + new_term.instr_fetching_bd36 * FF(1)) + + new_term.instr_fetching_sel_op_dc_10 * + (new_term.instr_fetching_bd5 * FF(uint256_t{ 0UL, 72057594037927936UL, 0UL, 0UL }) + + new_term.instr_fetching_bd6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }) + + new_term.instr_fetching_bd7 * FF(uint256_t{ 0UL, 1099511627776UL, 0UL, 0UL }) + + new_term.instr_fetching_bd8 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }) + + new_term.instr_fetching_bd9 * FF(uint256_t{ 0UL, 16777216UL, 0UL, 0UL }) + + new_term.instr_fetching_bd10 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }) + + new_term.instr_fetching_bd11 * FF(uint256_t{ 0UL, 256UL, 0UL, 0UL }) + + new_term.instr_fetching_bd12 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }) + + new_term.instr_fetching_bd13 * FF(72057594037927936UL) + + new_term.instr_fetching_bd14 * FF(281474976710656UL) + + new_term.instr_fetching_bd15 * FF(1099511627776UL) + + new_term.instr_fetching_bd16 * FF(4294967296UL) + + new_term.instr_fetching_bd17 * FF(16777216) + new_term.instr_fetching_bd18 * FF(65536) + + new_term.instr_fetching_bd19 * FF(256) + new_term.instr_fetching_bd20 * FF(1)) + + new_term.instr_fetching_sel_op_dc_11 * + (new_term.instr_fetching_bd5 * FF(72057594037927936UL) + + new_term.instr_fetching_bd6 * FF(281474976710656UL) + + new_term.instr_fetching_bd7 * FF(1099511627776UL) + + new_term.instr_fetching_bd8 * FF(4294967296UL) + new_term.instr_fetching_bd9 * FF(16777216) + + new_term.instr_fetching_bd10 * FF(65536) + new_term.instr_fetching_bd11 * FF(256) + + new_term.instr_fetching_bd12 * FF(1)) + + new_term.instr_fetching_sel_op_dc_12 * + (new_term.instr_fetching_bd5 * FF(16777216) + new_term.instr_fetching_bd6 * FF(65536) + + new_term.instr_fetching_bd7 * FF(256) + new_term.instr_fetching_bd8 * FF(1)) + + new_term.instr_fetching_sel_op_dc_13 * + (new_term.instr_fetching_bd5 * FF(256) + new_term.instr_fetching_bd6 * FF(1)) + + new_term.instr_fetching_sel_op_dc_14 * new_term.instr_fetching_bd4 * FF(1) + + new_term.instr_fetching_sel_op_dc_17 * new_term.instr_fetching_bd6 * FF(1))); tmp *= scaling_factor; std::get<17>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<18, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op4 - - ((FF(1) - new_term.instr_fetching_parsing_err) * new_term.instr_fetching_sel_op_dc_0 * - (new_term.instr_fetching_bd9 * FF(256) + new_term.instr_fetching_bd10 * FF(1)) + - new_term.instr_fetching_sel_op_dc_5 * - (new_term.instr_fetching_bd8 * FF(256) + new_term.instr_fetching_bd9 * FF(1)) + - new_term.instr_fetching_sel_op_dc_7 * new_term.instr_fetching_bd8 * FF(1))); + (FF(1) - new_term.instr_fetching_parsing_err) * + (new_term.instr_fetching_sel_op_dc_0 * + (new_term.instr_fetching_bd9 * FF(256) + new_term.instr_fetching_bd10 * FF(1)) + + new_term.instr_fetching_sel_op_dc_5 * + (new_term.instr_fetching_bd8 * FF(256) + new_term.instr_fetching_bd9 * FF(1)) + + new_term.instr_fetching_sel_op_dc_7 * new_term.instr_fetching_bd8 * FF(1))); tmp *= scaling_factor; std::get<18>(evals) += typename Accumulator::View(tmp); } diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.cpp index 7478b22bac88..79080e68d717 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.cpp @@ -62,20 +62,26 @@ Instruction TxBytecodeManager::read_instruction(BytecodeId bytecode_id, uint32_t auto bytecode_ptr = it->second; const auto& bytecode = *bytecode_ptr; + InstrDeserializationError instr_fetch_err = InstrDeserializationError::NO_ERROR; + Instruction instruction; // TODO: Propagate instruction fetching error to the upper layer (execution loop) - InstructionWithError instruction_with_err = deserialize_instruction(bytecode, pc); + try { + instruction = deserialize_instruction(bytecode, pc); + } catch (const InstrDeserializationError& error) { + instr_fetch_err = error; + } // The event will be deduplicated internally. fetching_events.emit({ .bytecode_id = bytecode_id, .pc = pc, - .instruction = instruction_with_err.instruction, + .instruction = instruction, .bytecode = bytecode_ptr, - .error = instruction_with_err.error, + .error = instr_fetch_err, }); - return instruction_with_err.instruction; + return instruction; } } // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.cpp index 334246860f8f..bb3e89e9f211 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.cpp @@ -363,21 +363,21 @@ std::string Operand::to_string() const __builtin_unreachable(); } -InstructionWithError deserialize_instruction(std::span bytecode, size_t pos) +Instruction deserialize_instruction(std::span bytecode, size_t pos) { const auto bytecode_length = bytecode.size(); if (pos >= bytecode_length) { info("PC is out of range. Position: " + std::to_string(pos) + " Bytecode length: " + std::to_string(bytecode_length)); - return { .error = InstrDeserializationError::PC_OUT_OF_RANGE }; + throw InstrDeserializationError::PC_OUT_OF_RANGE; } const uint8_t opcode_byte = bytecode[pos]; if (!is_wire_opcode_valid(opcode_byte)) { info("Invalid wire opcode byte: 0x" + to_hex(opcode_byte) + " at position: " + std::to_string(pos)); - return { .error = InstrDeserializationError::OPCODE_OUT_OF_RANGE }; + throw InstrDeserializationError::OPCODE_OUT_OF_RANGE; } const auto opcode = static_cast(opcode_byte); @@ -398,6 +398,7 @@ InstructionWithError deserialize_instruction(std::span bytecode, instruction_size, " bytecode length: ", bytecode_length); + throw InstrDeserializationError::INSTRUCTION_OUT_OF_RANGE; } pos++; // move after opcode byte @@ -406,25 +407,8 @@ InstructionWithError deserialize_instruction(std::span bytecode, std::vector operands; for (const OperandType op_type : inst_format) { const auto operand_size = OPERAND_TYPE_SIZE_BYTES.at(op_type); - - // No remaining byte to process - if (pos == bytecode_length) { - return { .instruction = { .opcode = opcode, .indirect = indirect, .operands = std::move(operands) }, - .error = InstrDeserializationError::INSTRUCTION_OUT_OF_RANGE }; - } - - uint8_t const* pos_ptr = &bytecode[pos]; - std::array operand_padded = { 0 }; // Fill with zeros - bool out_of_range = false; - - // Check whether we encounter the parsing error while processing this operand. - // In this case, we need to pad the operand to get the partial instruction required - // by witness generation. - if (pos + operand_size > bytecode_length) { - std::copy(bytecode.begin() + static_cast(pos), bytecode.end(), operand_padded.begin()); - pos_ptr = operand_padded.data(); - out_of_range = true; - } + assert(pos + operand_size <= bytecode_length); // Guaranteed to hold due to + // pos + instruction_size <= bytecode_length switch (op_type) { case OperandType::TAG: { @@ -451,55 +435,54 @@ InstructionWithError deserialize_instruction(std::span bytecode, } case OperandType::INDIRECT16: { uint16_t operand_u16 = 0; + uint8_t const* pos_ptr = &bytecode[pos]; serialize::read(pos_ptr, operand_u16); indirect = operand_u16; break; } case OperandType::UINT16: { uint16_t operand_u16 = 0; + uint8_t const* pos_ptr = &bytecode[pos]; serialize::read(pos_ptr, operand_u16); operands.emplace_back(operand_u16); break; } case OperandType::UINT32: { uint32_t operand_u32 = 0; + uint8_t const* pos_ptr = &bytecode[pos]; serialize::read(pos_ptr, operand_u32); operands.emplace_back(operand_u32); break; } case OperandType::UINT64: { uint64_t operand_u64 = 0; + uint8_t const* pos_ptr = &bytecode[pos]; serialize::read(pos_ptr, operand_u64); operands.emplace_back(operand_u64); break; } case OperandType::UINT128: { uint128_t operand_u128 = 0; + uint8_t const* pos_ptr = &bytecode[pos]; serialize::read(pos_ptr, operand_u128); operands.emplace_back(Operand::u128(operand_u128)); break; } case OperandType::FF: { FF operand_ff; + uint8_t const* pos_ptr = &bytecode[pos]; read(pos_ptr, operand_ff); operands.emplace_back(Operand::ff(operand_ff)); } } - - if (out_of_range) { - return { .instruction = { .opcode = opcode, .indirect = indirect, .operands = std::move(operands) }, - .error = InstrDeserializationError::INSTRUCTION_OUT_OF_RANGE }; - } - pos += operand_size; } - return { .instruction = { - .opcode = opcode, - .indirect = indirect, - .operands = std::move(operands), - }, - .error = InstrDeserializationError::NO_ERROR }; + return { + .opcode = opcode, + .indirect = indirect, + .operands = std::move(operands), + }; }; std::string Instruction::to_string() const diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp index 8405bde07d6b..1d460721de92 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp @@ -66,7 +66,7 @@ class Operand { }; struct Instruction { - WireOpCode opcode = WireOpCode::ADD_8; // Opcode which value 0 + WireOpCode opcode = WireOpCode::LAST_OPCODE_SENTINEL; uint16_t indirect = 0; std::vector operands; @@ -102,8 +102,9 @@ struct InstructionWithError { * * @param bytecode The bytecode to be parsed as a vector of bytes/uint8_t * @param pos Bytecode position - * @return The instruction enhanced with an error + * @throws runtime_error exception when the bytecode is invalid or pos is out-of-range + * @return The instruction */ -InstructionWithError deserialize_instruction(std::span bytecode, size_t pos); +Instruction deserialize_instruction(std::span bytecode, size_t pos); } // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.test.cpp index c201e2eb90af..a68458073384 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.test.cpp @@ -17,7 +17,7 @@ TEST(SerializationTest, Not8RoundTrip) const Instruction instr = { .opcode = WireOpCode::NOT_8, .indirect = 5, .operands = { Operand::u8(123), Operand::u8(45) } }; - const auto decoded = deserialize_instruction(instr.serialize(), 0).instruction; + const auto decoded = deserialize_instruction(instr.serialize(), 0); EXPECT_EQ(instr, decoded); } @@ -27,7 +27,7 @@ TEST(SerializationTest, Add16RoundTrip) const Instruction instr = { .opcode = WireOpCode::ADD_16, .indirect = 3, .operands = { Operand::u16(1000), Operand::u16(1001), Operand::u16(1002) } }; - const auto decoded = deserialize_instruction(instr.serialize(), 0).instruction; + const auto decoded = deserialize_instruction(instr.serialize(), 0); EXPECT_EQ(instr, decoded); } @@ -37,7 +37,7 @@ TEST(SerializationTest, Jumpi32RoundTrip) const Instruction instr = { .opcode = WireOpCode::JUMPI_32, .indirect = 7, .operands = { Operand::u16(12345), Operand::u32(678901234) } }; - const auto decoded = deserialize_instruction(instr.serialize(), 0).instruction; + const auto decoded = deserialize_instruction(instr.serialize(), 0); EXPECT_EQ(instr, decoded); } @@ -51,7 +51,7 @@ TEST(SerializationTest, Set64RoundTrip) .indirect = 2, .operands = { Operand::u16(1002), Operand::u8(static_cast(MemoryTag::U64)), Operand::u64(value_64) } }; - const auto decoded = deserialize_instruction(instr.serialize(), 0).instruction; + const auto decoded = deserialize_instruction(instr.serialize(), 0); EXPECT_EQ(instr, decoded); } @@ -65,7 +65,7 @@ TEST(SerializationTest, Set128RoundTrip) .indirect = 2, .operands = { Operand::u16(1002), Operand::u8(static_cast(MemoryTag::U128)), Operand::u128(value_128) } }; - const auto decoded = deserialize_instruction(instr.serialize(), 0).instruction; + const auto decoded = deserialize_instruction(instr.serialize(), 0); EXPECT_EQ(instr, decoded); } @@ -79,7 +79,7 @@ TEST(SerializationTest, SetFFRoundTrip) .indirect = 2, .operands = { Operand::u16(1002), Operand::u8(static_cast(MemoryTag::FF)), Operand::ff(large_ff) } }; - const auto decoded = deserialize_instruction(instr.serialize(), 0).instruction; + const auto decoded = deserialize_instruction(instr.serialize(), 0); EXPECT_EQ(instr, decoded); } @@ -89,7 +89,11 @@ TEST(SerializationTest, PCOutOfRange) std::vector bytecode; bytecode.resize(35, 0); - EXPECT_EQ(deserialize_instruction(bytecode, bytecode.size() + 1).error, InstrDeserializationError::PC_OUT_OF_RANGE); + try { + deserialize_instruction(bytecode, bytecode.size() + 1); + } catch (const InstrDeserializationError& error) { + EXPECT_EQ(error, InstrDeserializationError::PC_OUT_OF_RANGE); + } } // Testing deserialization wire opcode out of range error @@ -98,7 +102,11 @@ TEST(SerializationTest, OpcodeOutOfRange) std::vector bytecode; bytecode.push_back(static_cast(WireOpCode::LAST_OPCODE_SENTINEL) + 1); // Invalid opcode - EXPECT_EQ(deserialize_instruction(bytecode, 0).error, InstrDeserializationError::OPCODE_OUT_OF_RANGE); + try { + deserialize_instruction(bytecode, 0); + } catch (const InstrDeserializationError& error) { + EXPECT_EQ(error, InstrDeserializationError::OPCODE_OUT_OF_RANGE); + } } // Testing deserialization instruction out of range error @@ -116,7 +124,11 @@ TEST(SerializationTest, InstructionOutOfRange) // Truncate the bytecode bytecode.resize(bytecode.size() - 1); - EXPECT_EQ(deserialize_instruction(bytecode, 0).error, InstrDeserializationError::INSTRUCTION_OUT_OF_RANGE); + try { + deserialize_instruction(bytecode, 0); + } catch (const InstrDeserializationError& error) { + EXPECT_EQ(error, InstrDeserializationError::INSTRUCTION_OUT_OF_RANGE); + } } } // namespace From 7e0b556e68045520115fde348f62ece1a2f7819b Mon Sep 17 00:00:00 2001 From: jeanmon Date: Tue, 18 Mar 2025 18:55:09 +0000 Subject: [PATCH 18/25] Change relations to constrain bytecode_size --- barretenberg/cpp/pil/vm2/instr_fetching.pil | 43 +-- .../relations/instr_fetching.test.cpp | 286 ++++-------------- .../barretenberg/vm2/generated/columns.hpp | 16 +- .../src/barretenberg/vm2/generated/flavor.hpp | 7 +- .../generated/relations/instr_fetching.hpp | 154 +++------- .../relations/lookups_instr_fetching.hpp | 168 +++++++--- .../vm2/tracegen/bytecode_trace.cpp | 281 ++++++++--------- .../vm2/tracegen/bytecode_trace.test.cpp | 12 +- .../src/barretenberg/vm2/tracegen_helper.cpp | 1 + 9 files changed, 364 insertions(+), 604 deletions(-) diff --git a/barretenberg/cpp/pil/vm2/instr_fetching.pil b/barretenberg/cpp/pil/vm2/instr_fetching.pil index b732a76c415f..b51284f68bbc 100644 --- a/barretenberg/cpp/pil/vm2/instr_fetching.pil +++ b/barretenberg/cpp/pil/vm2/instr_fetching.pil @@ -28,44 +28,15 @@ pol commit parsing_err; parsing_err = 1 - (1 - pc_out_of_range) * (1 - instr_out_of_range) * (1 - opcode_out_of_range); // parsing_err is a boolean by definition (followed from above formula) -// If the current row is not active, then there are no more active rows after that. -// (not enforced for the first row) -// Gives guarantee that the active trace must start just after the first row (clk == 0) -// and from there it is contiguous. -#[TRACE_CONTINUITY] -(1 - precomputed.first_row) * (1 - sel) * sel' = 0; - -// Last row of a given bytecode portion (i.e., pertaining to a given bytecode_id) -pol commit last_of_bytecode; -last_of_bytecode * (1 - last_of_bytecode) = 0; - -// last_of_bytecode is toggled iff BC_ID_DIFF != 0 -// Standard non-zero inequality involving helper inverse column -pol BC_ID_DIFF = bytecode_id' - bytecode_id; -pol commit bc_id_diff_inv; -#[LAST_OF_BYTECODE_TOGGLE] -sel * (BC_ID_DIFF * ((1 - last_of_bytecode) * (1 - bc_id_diff_inv) + bc_id_diff_inv) - last_of_bytecode) = 0; - -// If last_of_bytecode OR precomputed.first_row then next row has pc == 0 -#[PC_IS_ZERO_IN_BYTECODE_FIRST_ROW] -(last_of_bytecode + precomputed.first_row) * pc' = 0; - // Retrieved from bc_decomposition.pil -pol commit bytes_remaining; pol commit bytes_to_read; +// Retrieved from bc_decomposition.pil based on bytecode_id with pc == 0 pol commit bytecode_size; -#[BYTECODE_SIZE_INIT] -(last_of_bytecode + precomputed.first_row) * (bytecode_size' - bytes_remaining') = 0; - -#[SAME_BYTECODE_SIZE] -sel * sel' * (1 - last_of_bytecode) * (bytecode_size - bytecode_size') = 0; -// Note that last_of_bytecode might not be toggled at the last active row (if bytecode_id == 0). -// For this reason, we need the factor sel' in the above relation. // Absolute difference variant where we compute: // bytes_to_read - instr_size if instr_size <= bytes_to_read -// instr_size - bytes_to_read - 1 if instr_size > bytes_to_read +// instr_size - bytes_to_read - 1 if instr_size > bytes_to_read (instr_out_of_range == 1) pol commit instr_abs_diff; // From the following relation, we have: instr_abs_diff >= 0 ==> [instr_size > bytes_to_read <==> instr_out_of_range == 1] @@ -97,6 +68,10 @@ sel { pc_abs_diff_lo } in precomputed.sel_range_16 { precomputed.clk }; #[PC_ABS_DIFF_POSITIVE_HI] sel { pc_abs_diff_hi } in precomputed.sel_range_16 { precomputed.clk }; +#[BYTECODE_SIZE_FROM_BC_DEC] +sel { bytecode_id, precomputed.zero, bytecode_size } in +bc_decomposition.sel { bc_decomposition.id, bc_decomposition.pc, bc_decomposition.bytes_remaining }; + // bytecode[pc] to bytecode[pc + 36] pol commit bd0, bd1, bd2, bd3, bd4, bd5, bd6, bd7, bd8, bd9, bd10, @@ -115,9 +90,8 @@ sel_opcode_defined = sel * (1 - pc_out_of_range); // Bring in the bytes from the bytecode columns. #[BYTES_FROM_BC_DEC] sel_opcode_defined { - pc, bytecode_id, - bytes_remaining, + pc, bytes_to_read, bd0, bd1, bd2, bd3, bd4, bd5, bd6, bd7, bd8, bd9, @@ -129,9 +103,8 @@ sel_opcode_defined { bd35, bd36 } in bc_decomposition.sel { - bc_decomposition.pc, bc_decomposition.id, - bc_decomposition.bytes_remaining, + bc_decomposition.pc, bc_decomposition.bytes_to_read, bc_decomposition.bytes, bc_decomposition.bytes_pc_plus_1, bc_decomposition.bytes_pc_plus_2, bc_decomposition.bytes_pc_plus_3, bc_decomposition.bytes_pc_plus_4, bc_decomposition.bytes_pc_plus_5, bc_decomposition.bytes_pc_plus_6, bc_decomposition.bytes_pc_plus_7, bc_decomposition.bytes_pc_plus_8, bc_decomposition.bytes_pc_plus_9, diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp index 855acfcc9f7d..698a9e0b7968 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp @@ -45,6 +45,7 @@ using pc_abs_diff_positive_lo_lookup = lookup_instr_fetching_pc_abs_diff_positiv using pc_abs_diff_positive_hi_lookup = lookup_instr_fetching_pc_abs_diff_positive_hi_relation; using wire_instr_spec_lookup = lookup_instr_fetching_wire_instruction_info_relation; using bc_decomposition_lookup = lookup_instr_fetching_bytes_from_bc_dec_relation; +using bytecode_size_bc_decomposition_lookup = lookup_instr_fetching_bytecode_size_from_bc_dec_relation; using testing::random_bytes; @@ -272,12 +273,14 @@ TEST(InstrFetchingConstrainingTest, BcDecompositionInteractions) precomputed_builder.process_misc(trace, trace.get_num_rows()); // Limit to the number of rows we need. LookupIntoDynamicTableGeneric().process(trace); + LookupIntoDynamicTableGeneric().process(trace); // BC Decomposition trace is the longest here. EXPECT_EQ(trace.get_num_rows(), instr_fetch_events.at(0).bytecode->size() + 1); check_relation(trace); check_interaction(trace); + check_interaction(trace); } void check_all(const std::vector& instr_events, @@ -299,6 +302,7 @@ void check_all(const std::vector& instr_events, LookupIntoIndexedByClk().process(trace); LookupIntoIndexedByClk().process(trace); LookupIntoDynamicTableGeneric().process(trace); + LookupIntoDynamicTableGeneric().process(trace); EXPECT_EQ(trace.get_num_rows(), 1 << 16); // 2^16 for range checks @@ -308,6 +312,7 @@ void check_all(const std::vector& instr_events, check_interaction(trace); check_interaction(trace); check_interaction(trace); + check_interaction(trace); } // Positive test with 5 five bytecodes and bytecode_id = 0,1,2,3,4 @@ -616,251 +621,62 @@ TEST(InstrFetchingConstrainingTest, NegativeWrongBcDecompositionInteractions) } } -// Negative test on trace continuity. Gap after first row. -TEST(InstrFetchingConstrainingTest, NegativeGapAfterFirstRow) +// Negative interaction test for #[BYTECODE_SIZE_FROM_BC_DEC] where bytecode_size has the wrong value. +// We set pc different from zero. +TEST(InstrFetchingConstrainingTest, NegativeWrongBytecodeSizeBcDecompositionInteractions) { - TestTraceContainer trace = TestTraceContainer::from_rows({ - { .precomputed_first_row = 1 }, - { - .instr_fetching_sel = 1, // Will be mutated to zero - }, - { - .instr_fetching_sel = 1, - }, - }); - - check_relation(trace, instr_fetching::SR_TRACE_CONTINUITY); - - trace.set(C::instr_fetching_sel, 1, 0); // Mutate to wrong value - EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_TRACE_CONTINUITY), - "TRACE_CONTINUITY"); -} - -// Negative test on trace continuity. Gap in the middle. -TEST(InstrFetchingConstrainingTest, NegativeGapInTheMiddle) -{ - TestTraceContainer trace = TestTraceContainer::from_rows({ - { .precomputed_first_row = 1 }, - { - .instr_fetching_sel = 1, - }, - { - .instr_fetching_sel = 1, // Will be mutated to 0 - }, - { - .instr_fetching_sel = 1, - }, - }); - - check_relation(trace, instr_fetching::SR_TRACE_CONTINUITY); - - trace.set(C::instr_fetching_sel, 2, 0); // Mutate to wrong value (row 2) - EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_TRACE_CONTINUITY), - "TRACE_CONTINUITY"); -} - -// Negative test on pc == 0 for first entry pertaining to a bytecode_id -// Pick a trace with two bytecode_id = 2 and 3. -// For first entry of bytecode_id == 3, we set pc = 23. -TEST(InstrFetchingConstrainingTest, NegativePcNotZeroFirstEntryBytecode1) -{ - TestTraceContainer trace = TestTraceContainer::from_rows({ - { .precomputed_first_row = 1 }, - { - .instr_fetching_bytecode_id = 2, - .instr_fetching_last_of_bytecode = 1, - .instr_fetching_pc = 0, - .instr_fetching_sel = 1, - }, - { - .instr_fetching_bytecode_id = 3, - .instr_fetching_pc = 0, // Will be mutated to 23 - .instr_fetching_sel = 1, - }, - { - .instr_fetching_bytecode_id = 3, - .instr_fetching_last_of_bytecode = 1, - .instr_fetching_sel = 1, - }, - }); - - check_relation(trace, instr_fetching::SR_PC_IS_ZERO_IN_BYTECODE_FIRST_ROW); - - trace.set(C::instr_fetching_pc, 2, 23); // Mutate to wrong value (row 2) - - EXPECT_THROW_WITH_MESSAGE( - check_relation(trace, instr_fetching::SR_PC_IS_ZERO_IN_BYTECODE_FIRST_ROW), - "PC_IS_ZERO_IN_BYTECODE_FIRST_ROW"); -} - -// Same as before but pc is wrongly set for the first bytecode -TEST(InstrFetchingConstrainingTest, NegativePcNotZeroFirstEntryBytecode2) -{ - TestTraceContainer trace = TestTraceContainer::from_rows({ - { .precomputed_first_row = 1 }, - { - .instr_fetching_bytecode_id = 2, - .instr_fetching_last_of_bytecode = 1, - .instr_fetching_pc = 0, // Will be mutated to 12 - .instr_fetching_sel = 1, - }, - { - .instr_fetching_bytecode_id = 3, - .instr_fetching_pc = 0, - .instr_fetching_sel = 1, - }, - { - .instr_fetching_bytecode_id = 3, - .instr_fetching_last_of_bytecode = 1, - .instr_fetching_sel = 1, - }, - }); - - check_relation(trace, instr_fetching::SR_PC_IS_ZERO_IN_BYTECODE_FIRST_ROW); - - trace.set(C::instr_fetching_pc, 1, 12); // Mutate to wrong value (row 1) - - EXPECT_THROW_WITH_MESSAGE( - check_relation(trace, instr_fetching::SR_PC_IS_ZERO_IN_BYTECODE_FIRST_ROW), - "PC_IS_ZERO_IN_BYTECODE_FIRST_ROW"); -} - -// Negative test on not toggling last_of_bytecode when bytecode_id changes -TEST(InstrFetchingConstrainingTest, NegativeNotTogglingLastOfBytecode) -{ - TestTraceContainer trace = TestTraceContainer::from_rows({ - { .precomputed_first_row = 1 }, - { - .instr_fetching_bc_id_diff_inv = 1, - .instr_fetching_bytecode_id = 2, - .instr_fetching_last_of_bytecode = 1, // Will be mutated to 0 - .instr_fetching_sel = 1, - }, - { - .instr_fetching_bc_id_diff_inv = FF(FF::modulus - 3).invert(), - .instr_fetching_bytecode_id = 3, - .instr_fetching_last_of_bytecode = 1, - .instr_fetching_sel = 1, - }, - }); - - check_relation(trace, instr_fetching::SR_LAST_OF_BYTECODE_TOGGLE); - - trace.set(C::instr_fetching_bytecode_id, 1, 0); // Mutate to wrong value (row 1) - - EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_LAST_OF_BYTECODE_TOGGLE), - "LAST_OF_BYTECODE_TOGGLE"); - - // Second attempt by mutating instr_fetching_bc_id_diff_inv to 0 - trace.set(C::instr_fetching_bc_id_diff_inv, 1, 0); - - EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_LAST_OF_BYTECODE_TOGGLE), - "LAST_OF_BYTECODE_TOGGLE"); -} - -// Negative test on wrongly toggling last_of_bytecod when bytecode_id remains constant (equal to 11) -TEST(InstrFetchingConstrainingTest, NegativeTogglingLastOfBytecode) -{ - TestTraceContainer trace = TestTraceContainer::from_rows({ - { .precomputed_first_row = 1 }, - { - .instr_fetching_bc_id_diff_inv = 0, - .instr_fetching_bytecode_id = 11, - .instr_fetching_last_of_bytecode = 0, // Will be mutated to 1 - .instr_fetching_sel = 1, - }, - { - .instr_fetching_bc_id_diff_inv = FF(FF::modulus - 11).invert(), - .instr_fetching_bytecode_id = 11, - .instr_fetching_last_of_bytecode = 1, - .instr_fetching_sel = 1, - }, - }); - - check_relation(trace, instr_fetching::SR_LAST_OF_BYTECODE_TOGGLE); - - trace.set(C::instr_fetching_last_of_bytecode, 1, 1); // Mutate to wrong value (row 1) - - EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_LAST_OF_BYTECODE_TOGGLE), - "LAST_OF_BYTECODE_TOGGLE"); -} - -// Negative test on not keeping same bytecode_size when bytecode_id is the same -TEST(InstrFetchingConstrainingTest, NegativeNotSameBytecodeSize) -{ - TestTraceContainer trace = TestTraceContainer::from_rows({ - { .precomputed_first_row = 1 }, - { - .instr_fetching_bytecode_id = 2, - .instr_fetching_bytecode_size = 12, - .instr_fetching_sel = 1, - }, - { - .instr_fetching_bytecode_id = 2, - .instr_fetching_bytecode_size = 12, // Will be mutated to 13 - .instr_fetching_last_of_bytecode = 1, - .instr_fetching_sel = 1, - }, - }); - - check_relation(trace, instr_fetching::SR_SAME_BYTECODE_SIZE); - - trace.set(C::instr_fetching_bytecode_size, 2, 13); // Mutate to wrong value + TestTraceContainer trace; + BytecodeTraceBuilder bytecode_builder; + PrecomputedTraceBuilder precomputed_builder; - EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_SAME_BYTECODE_SIZE), - "SAME_BYTECODE_SIZE"); -} + const uint32_t pc = 15; + std::vector bytecode(pc, 0x23); -// Negative test on not initializing bytecode_size in the first row of a given bytecode. -// Case first bytecode -TEST(InstrFetchingConstrainingTest, NegativeNotInitBytecodeSize1) -{ - TestTraceContainer trace = TestTraceContainer::from_rows({ - { .precomputed_first_row = 1 }, - { - .instr_fetching_bytecode_id = 2, - .instr_fetching_bytecode_size = 12, // Will be mutated to 17 - .instr_fetching_bytes_remaining = 12, - .instr_fetching_last_of_bytecode = 1, - .instr_fetching_sel = 1, - }, - }); + // Some arbitrary chosen opcodes. We limit to one as this unit test is costly. + // Test works if the following vector is extended to other opcodes though. + std::vector opcodes = { WireOpCode::KECCAKF1600 }; - check_relation(trace, instr_fetching::SR_BYTECODE_SIZE_INIT); + for (const auto& opcode : opcodes) { + TestTraceContainer trace; - trace.set(C::instr_fetching_bytecode_size, 1, 17); // Mutate to wrong value + const auto instr = testing::random_instruction(opcode); + const auto instr_bytecode = instr.serialize(); + bytecode.insert(bytecode.end(), + std::make_move_iterator(instr_bytecode.begin()), + std::make_move_iterator(instr_bytecode.end())); + auto bytecode_ptr = std::make_shared>(bytecode); - EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_BYTECODE_SIZE_INIT), - "BYTECODE_SIZE_INIT"); -} + bytecode_builder.process_instruction_fetching({ { + .bytecode_id = 1, + .pc = pc, + .instruction = instr, + .bytecode = bytecode_ptr, + } }, + trace); + bytecode_builder.process_decomposition({ { + .bytecode_id = 1, + .bytecode = bytecode_ptr, + } }, + trace); + precomputed_builder.process_misc(trace, trace.get_num_rows()); // Limit to the number of rows we need. -// Negative test on not initializing bytecode_size in the first row of a given bytecode. -// Case: a bytecode in the middle -TEST(InstrFetchingConstrainingTest, NegativeNotInitBytecodeSize2) -{ - TestTraceContainer trace = TestTraceContainer::from_rows({ - { .precomputed_first_row = 1 }, - { - .instr_fetching_bytecode_id = 2, - .instr_fetching_bytecode_size = 12, - .instr_fetching_bytes_remaining = 12, - .instr_fetching_last_of_bytecode = 1, - .instr_fetching_sel = 1, - }, - { - .instr_fetching_bytecode_id = 3, - .instr_fetching_bytecode_size = 14, // Will be mutated to zero - .instr_fetching_bytes_remaining = 14, - .instr_fetching_sel = 1, - }, - }); + auto valid_trace = trace; // Keep original trace before lookup processing + LookupIntoDynamicTableSequential().process(valid_trace); + check_interaction(valid_trace); - check_relation(trace, instr_fetching::SR_BYTECODE_SIZE_INIT); + auto mutated_trace = trace; + const FF mutated_value = trace.get(C::instr_fetching_bytecode_size, 1) + 1; // Mutate to value + 1 + mutated_trace.set(C::instr_fetching_bytecode_size, 1, mutated_value); - trace.set(C::instr_fetching_bytecode_size, 2, 0); // Mutate to wrong value + // This sets the length of the inverse polynomial via SetDummyInverses, so we still need to call this + // even though we know it will fail. + EXPECT_THROW_WITH_MESSAGE( + LookupIntoDynamicTableSequential().process(mutated_trace), + "Failed.*BYTECODE_SIZE_FROM_BC_DEC. Could not find tuple in destination."); - EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_BYTECODE_SIZE_INIT), - "BYTECODE_SIZE_INIT"); + EXPECT_THROW_WITH_MESSAGE(check_interaction(mutated_trace), + "Relation.*BYTECODE_SIZE_FROM_BC_DEC.* ACCUMULATION.* is non-zero"); + } } // Negative test on not toggling instr_out_of_range when instr_size > bytes_to_read diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp index 0bdb9de7d972..cae36e3982d6 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp @@ -10,16 +10,16 @@ namespace bb::avm2 { // The entities that will be used in the flavor. // clang-format off #define AVM2_PRECOMPUTED_ENTITIES precomputed_as_unary, precomputed_bitwise_input_a, precomputed_bitwise_input_b, precomputed_bitwise_op_id, precomputed_bitwise_output, precomputed_clk, precomputed_exec_opcode, precomputed_first_row, precomputed_instr_size, precomputed_integral_tag_length, precomputed_opcode_out_of_range, precomputed_p_decomposition_limb, precomputed_p_decomposition_limb_index, precomputed_p_decomposition_radix, precomputed_power_of_2, precomputed_sel_bitwise, precomputed_sel_integral_tag, precomputed_sel_op_dc_0, precomputed_sel_op_dc_1, precomputed_sel_op_dc_10, precomputed_sel_op_dc_11, precomputed_sel_op_dc_12, precomputed_sel_op_dc_13, precomputed_sel_op_dc_14, precomputed_sel_op_dc_15, precomputed_sel_op_dc_16, precomputed_sel_op_dc_17, precomputed_sel_op_dc_2, precomputed_sel_op_dc_3, precomputed_sel_op_dc_4, precomputed_sel_op_dc_5, precomputed_sel_op_dc_6, precomputed_sel_op_dc_7, precomputed_sel_op_dc_8, precomputed_sel_op_dc_9, precomputed_sel_p_decomposition, precomputed_sel_range_16, precomputed_sel_range_8, precomputed_sel_sha256_compression, precomputed_sel_to_radix_safe_limbs, precomputed_sel_unary, precomputed_sha256_compression_round_constant, precomputed_to_radix_safe_limbs, precomputed_zero -#define AVM2_WIRE_ENTITIES execution_input, address_derivation_address, address_derivation_address_y, address_derivation_class_id, address_derivation_deployer_addr, address_derivation_g1_x, address_derivation_g1_y, address_derivation_incoming_viewing_key_x, address_derivation_incoming_viewing_key_y, address_derivation_init_hash, address_derivation_nullifier_key_x, address_derivation_nullifier_key_y, address_derivation_outgoing_viewing_key_x, address_derivation_outgoing_viewing_key_y, address_derivation_partial_address, address_derivation_partial_address_domain_separator, address_derivation_preaddress, address_derivation_preaddress_domain_separator, address_derivation_preaddress_public_key_x, address_derivation_preaddress_public_key_y, address_derivation_public_keys_hash, address_derivation_public_keys_hash_domain_separator, address_derivation_salt, address_derivation_salted_init_hash, address_derivation_sel, address_derivation_tagging_key_x, address_derivation_tagging_key_y, alu_dst_addr, alu_ia, alu_ia_addr, alu_ib, alu_ib_addr, alu_ic, alu_op, alu_sel_op_add, bc_decomposition_abs_diff, bc_decomposition_bytes, bc_decomposition_bytes_pc_plus_1, bc_decomposition_bytes_pc_plus_10, bc_decomposition_bytes_pc_plus_11, bc_decomposition_bytes_pc_plus_12, bc_decomposition_bytes_pc_plus_13, bc_decomposition_bytes_pc_plus_14, bc_decomposition_bytes_pc_plus_15, bc_decomposition_bytes_pc_plus_16, bc_decomposition_bytes_pc_plus_17, bc_decomposition_bytes_pc_plus_18, bc_decomposition_bytes_pc_plus_19, bc_decomposition_bytes_pc_plus_2, bc_decomposition_bytes_pc_plus_20, bc_decomposition_bytes_pc_plus_21, bc_decomposition_bytes_pc_plus_22, bc_decomposition_bytes_pc_plus_23, bc_decomposition_bytes_pc_plus_24, bc_decomposition_bytes_pc_plus_25, bc_decomposition_bytes_pc_plus_26, bc_decomposition_bytes_pc_plus_27, bc_decomposition_bytes_pc_plus_28, bc_decomposition_bytes_pc_plus_29, bc_decomposition_bytes_pc_plus_3, bc_decomposition_bytes_pc_plus_30, bc_decomposition_bytes_pc_plus_31, bc_decomposition_bytes_pc_plus_32, bc_decomposition_bytes_pc_plus_33, bc_decomposition_bytes_pc_plus_34, bc_decomposition_bytes_pc_plus_35, bc_decomposition_bytes_pc_plus_36, bc_decomposition_bytes_pc_plus_4, bc_decomposition_bytes_pc_plus_5, bc_decomposition_bytes_pc_plus_6, bc_decomposition_bytes_pc_plus_7, bc_decomposition_bytes_pc_plus_8, bc_decomposition_bytes_pc_plus_9, bc_decomposition_bytes_rem_inv, bc_decomposition_bytes_rem_min_one_inv, bc_decomposition_bytes_remaining, bc_decomposition_bytes_to_read, bc_decomposition_bytes_to_read_unary, bc_decomposition_id, bc_decomposition_last_of_contract, bc_decomposition_packed_field, bc_decomposition_pc, bc_decomposition_sel, bc_decomposition_sel_overflow_correction_needed, bc_decomposition_sel_packed, bc_decomposition_sel_pc_plus_1, bc_decomposition_sel_pc_plus_10, bc_decomposition_sel_pc_plus_11, bc_decomposition_sel_pc_plus_12, bc_decomposition_sel_pc_plus_13, bc_decomposition_sel_pc_plus_14, bc_decomposition_sel_pc_plus_15, bc_decomposition_sel_pc_plus_16, bc_decomposition_sel_pc_plus_17, bc_decomposition_sel_pc_plus_18, bc_decomposition_sel_pc_plus_19, bc_decomposition_sel_pc_plus_2, bc_decomposition_sel_pc_plus_20, bc_decomposition_sel_pc_plus_21, bc_decomposition_sel_pc_plus_22, bc_decomposition_sel_pc_plus_23, bc_decomposition_sel_pc_plus_24, bc_decomposition_sel_pc_plus_25, bc_decomposition_sel_pc_plus_26, bc_decomposition_sel_pc_plus_27, bc_decomposition_sel_pc_plus_28, bc_decomposition_sel_pc_plus_29, bc_decomposition_sel_pc_plus_3, bc_decomposition_sel_pc_plus_30, bc_decomposition_sel_pc_plus_31, bc_decomposition_sel_pc_plus_32, bc_decomposition_sel_pc_plus_33, bc_decomposition_sel_pc_plus_34, bc_decomposition_sel_pc_plus_35, bc_decomposition_sel_pc_plus_36, bc_decomposition_sel_pc_plus_4, bc_decomposition_sel_pc_plus_5, bc_decomposition_sel_pc_plus_6, bc_decomposition_sel_pc_plus_7, bc_decomposition_sel_pc_plus_8, bc_decomposition_sel_pc_plus_9, bc_hashing_bytecode_id, bc_hashing_incremental_hash, bc_hashing_latch, bc_hashing_output_hash, bc_hashing_packed_field, bc_hashing_pc_index, bc_hashing_sel, bc_hashing_start, bc_retrieval_address, bc_retrieval_artifact_hash, bc_retrieval_bytecode_id, bc_retrieval_class_id, bc_retrieval_deployer_addr, bc_retrieval_err, bc_retrieval_incoming_viewing_key_x, bc_retrieval_incoming_viewing_key_y, bc_retrieval_init_hash, bc_retrieval_nullifier_key_x, bc_retrieval_nullifier_key_y, bc_retrieval_outgoing_viewing_key_x, bc_retrieval_outgoing_viewing_key_y, bc_retrieval_private_function_root, bc_retrieval_public_bytecode_commitment, bc_retrieval_salt, bc_retrieval_sel, bc_retrieval_siloed_address, bc_retrieval_tagging_key_x, bc_retrieval_tagging_key_y, bitwise_acc_ia, bitwise_acc_ib, bitwise_acc_ic, bitwise_ctr, bitwise_ctr_inv, bitwise_ctr_min_one_inv, bitwise_ia_byte, bitwise_ib_byte, bitwise_ic_byte, bitwise_last, bitwise_op_id, bitwise_sel, bitwise_start, bitwise_tag, class_id_derivation_artifact_hash, class_id_derivation_class_id, class_id_derivation_private_function_root, class_id_derivation_public_bytecode_commitment, class_id_derivation_sel, class_id_derivation_temp_constant_for_lookup, ecc_add_op, ecc_double_op, ecc_inv_2_p_y, ecc_inv_x_diff, ecc_inv_y_diff, ecc_lambda, ecc_p_is_inf, ecc_p_x, ecc_p_y, ecc_q_is_inf, ecc_q_x, ecc_q_y, ecc_r_is_inf, ecc_r_x, ecc_r_y, ecc_result_infinity, ecc_sel, ecc_x_match, ecc_y_match, execution_addressing_error_idx, execution_addressing_error_kind, execution_base_address_tag, execution_base_address_val, execution_bytecode_id, execution_clk, execution_ex_opcode, execution_indirect, execution_last, execution_op1, execution_op1_after_relative, execution_op2, execution_op2_after_relative, execution_op3, execution_op3_after_relative, execution_op4, execution_op4_after_relative, execution_pc, execution_rop1, execution_rop2, execution_rop3, execution_rop4, execution_sel, execution_sel_addressing_error, execution_sel_op1_is_address, execution_sel_op2_is_address, execution_sel_op3_is_address, execution_sel_op4_is_address, instr_fetching_bc_id_diff_inv, instr_fetching_bd0, instr_fetching_bd1, instr_fetching_bd10, instr_fetching_bd11, instr_fetching_bd12, instr_fetching_bd13, instr_fetching_bd14, instr_fetching_bd15, instr_fetching_bd16, instr_fetching_bd17, instr_fetching_bd18, instr_fetching_bd19, instr_fetching_bd2, instr_fetching_bd20, instr_fetching_bd21, instr_fetching_bd22, instr_fetching_bd23, instr_fetching_bd24, instr_fetching_bd25, instr_fetching_bd26, instr_fetching_bd27, instr_fetching_bd28, instr_fetching_bd29, instr_fetching_bd3, instr_fetching_bd30, instr_fetching_bd31, instr_fetching_bd32, instr_fetching_bd33, instr_fetching_bd34, instr_fetching_bd35, instr_fetching_bd36, instr_fetching_bd4, instr_fetching_bd5, instr_fetching_bd6, instr_fetching_bd7, instr_fetching_bd8, instr_fetching_bd9, instr_fetching_bytecode_id, instr_fetching_bytecode_size, instr_fetching_bytes_remaining, instr_fetching_bytes_to_read, instr_fetching_exec_opcode, instr_fetching_indirect, instr_fetching_instr_abs_diff, instr_fetching_instr_out_of_range, instr_fetching_instr_size, instr_fetching_last_of_bytecode, instr_fetching_op1, instr_fetching_op2, instr_fetching_op3, instr_fetching_op4, instr_fetching_op5, instr_fetching_op6, instr_fetching_op7, instr_fetching_opcode_out_of_range, instr_fetching_parsing_err, instr_fetching_pc, instr_fetching_pc_abs_diff, instr_fetching_pc_abs_diff_hi, instr_fetching_pc_abs_diff_lo, instr_fetching_pc_out_of_range, instr_fetching_sel, instr_fetching_sel_op_dc_0, instr_fetching_sel_op_dc_1, instr_fetching_sel_op_dc_10, instr_fetching_sel_op_dc_11, instr_fetching_sel_op_dc_12, instr_fetching_sel_op_dc_13, instr_fetching_sel_op_dc_14, instr_fetching_sel_op_dc_15, instr_fetching_sel_op_dc_16, instr_fetching_sel_op_dc_17, instr_fetching_sel_op_dc_2, instr_fetching_sel_op_dc_3, instr_fetching_sel_op_dc_4, instr_fetching_sel_op_dc_5, instr_fetching_sel_op_dc_6, instr_fetching_sel_op_dc_7, instr_fetching_sel_op_dc_8, instr_fetching_sel_op_dc_9, instr_fetching_sel_opcode_defined, poseidon2_hash_a_0, poseidon2_hash_a_1, poseidon2_hash_a_2, poseidon2_hash_a_3, poseidon2_hash_b_0, poseidon2_hash_b_1, poseidon2_hash_b_2, poseidon2_hash_b_3, poseidon2_hash_end, poseidon2_hash_input_0, poseidon2_hash_input_1, poseidon2_hash_input_2, poseidon2_hash_input_len, poseidon2_hash_num_perm_rounds_rem, poseidon2_hash_num_perm_rounds_rem_inv, poseidon2_hash_output, poseidon2_hash_padding, poseidon2_hash_sel, poseidon2_hash_start, poseidon2_perm_B_10_0, poseidon2_perm_B_10_1, poseidon2_perm_B_10_2, poseidon2_perm_B_10_3, poseidon2_perm_B_11_0, poseidon2_perm_B_11_1, poseidon2_perm_B_11_2, poseidon2_perm_B_11_3, poseidon2_perm_B_12_0, poseidon2_perm_B_12_1, poseidon2_perm_B_12_2, poseidon2_perm_B_12_3, poseidon2_perm_B_13_0, poseidon2_perm_B_13_1, poseidon2_perm_B_13_2, poseidon2_perm_B_13_3, poseidon2_perm_B_14_0, poseidon2_perm_B_14_1, poseidon2_perm_B_14_2, poseidon2_perm_B_14_3, poseidon2_perm_B_15_0, poseidon2_perm_B_15_1, poseidon2_perm_B_15_2, poseidon2_perm_B_15_3, poseidon2_perm_B_16_0, poseidon2_perm_B_16_1, poseidon2_perm_B_16_2, poseidon2_perm_B_16_3, poseidon2_perm_B_17_0, poseidon2_perm_B_17_1, poseidon2_perm_B_17_2, poseidon2_perm_B_17_3, poseidon2_perm_B_18_0, poseidon2_perm_B_18_1, poseidon2_perm_B_18_2, poseidon2_perm_B_18_3, poseidon2_perm_B_19_0, poseidon2_perm_B_19_1, poseidon2_perm_B_19_2, poseidon2_perm_B_19_3, poseidon2_perm_B_20_0, poseidon2_perm_B_20_1, poseidon2_perm_B_20_2, poseidon2_perm_B_20_3, poseidon2_perm_B_21_0, poseidon2_perm_B_21_1, poseidon2_perm_B_21_2, poseidon2_perm_B_21_3, poseidon2_perm_B_22_0, poseidon2_perm_B_22_1, poseidon2_perm_B_22_2, poseidon2_perm_B_22_3, poseidon2_perm_B_23_0, poseidon2_perm_B_23_1, poseidon2_perm_B_23_2, poseidon2_perm_B_23_3, poseidon2_perm_B_24_0, poseidon2_perm_B_24_1, poseidon2_perm_B_24_2, poseidon2_perm_B_24_3, poseidon2_perm_B_25_0, poseidon2_perm_B_25_1, poseidon2_perm_B_25_2, poseidon2_perm_B_25_3, poseidon2_perm_B_26_0, poseidon2_perm_B_26_1, poseidon2_perm_B_26_2, poseidon2_perm_B_26_3, poseidon2_perm_B_27_0, poseidon2_perm_B_27_1, poseidon2_perm_B_27_2, poseidon2_perm_B_27_3, poseidon2_perm_B_28_0, poseidon2_perm_B_28_1, poseidon2_perm_B_28_2, poseidon2_perm_B_28_3, poseidon2_perm_B_29_0, poseidon2_perm_B_29_1, poseidon2_perm_B_29_2, poseidon2_perm_B_29_3, poseidon2_perm_B_30_0, poseidon2_perm_B_30_1, poseidon2_perm_B_30_2, poseidon2_perm_B_30_3, poseidon2_perm_B_31_0, poseidon2_perm_B_31_1, poseidon2_perm_B_31_2, poseidon2_perm_B_31_3, poseidon2_perm_B_32_0, poseidon2_perm_B_32_1, poseidon2_perm_B_32_2, poseidon2_perm_B_32_3, poseidon2_perm_B_33_0, poseidon2_perm_B_33_1, poseidon2_perm_B_33_2, poseidon2_perm_B_33_3, poseidon2_perm_B_34_0, poseidon2_perm_B_34_1, poseidon2_perm_B_34_2, poseidon2_perm_B_34_3, poseidon2_perm_B_35_0, poseidon2_perm_B_35_1, poseidon2_perm_B_35_2, poseidon2_perm_B_35_3, poseidon2_perm_B_36_0, poseidon2_perm_B_36_1, poseidon2_perm_B_36_2, poseidon2_perm_B_36_3, poseidon2_perm_B_37_0, poseidon2_perm_B_37_1, poseidon2_perm_B_37_2, poseidon2_perm_B_37_3, poseidon2_perm_B_38_0, poseidon2_perm_B_38_1, poseidon2_perm_B_38_2, poseidon2_perm_B_38_3, poseidon2_perm_B_39_0, poseidon2_perm_B_39_1, poseidon2_perm_B_39_2, poseidon2_perm_B_39_3, poseidon2_perm_B_40_0, poseidon2_perm_B_40_1, poseidon2_perm_B_40_2, poseidon2_perm_B_40_3, poseidon2_perm_B_41_0, poseidon2_perm_B_41_1, poseidon2_perm_B_41_2, poseidon2_perm_B_41_3, poseidon2_perm_B_42_0, poseidon2_perm_B_42_1, poseidon2_perm_B_42_2, poseidon2_perm_B_42_3, poseidon2_perm_B_43_0, poseidon2_perm_B_43_1, poseidon2_perm_B_43_2, poseidon2_perm_B_43_3, poseidon2_perm_B_44_0, poseidon2_perm_B_44_1, poseidon2_perm_B_44_2, poseidon2_perm_B_44_3, poseidon2_perm_B_45_0, poseidon2_perm_B_45_1, poseidon2_perm_B_45_2, poseidon2_perm_B_45_3, poseidon2_perm_B_46_0, poseidon2_perm_B_46_1, poseidon2_perm_B_46_2, poseidon2_perm_B_46_3, poseidon2_perm_B_47_0, poseidon2_perm_B_47_1, poseidon2_perm_B_47_2, poseidon2_perm_B_47_3, poseidon2_perm_B_48_0, poseidon2_perm_B_48_1, poseidon2_perm_B_48_2, poseidon2_perm_B_48_3, poseidon2_perm_B_49_0, poseidon2_perm_B_49_1, poseidon2_perm_B_49_2, poseidon2_perm_B_49_3, poseidon2_perm_B_4_0, poseidon2_perm_B_4_1, poseidon2_perm_B_4_2, poseidon2_perm_B_4_3, poseidon2_perm_B_50_0, poseidon2_perm_B_50_1, poseidon2_perm_B_50_2, poseidon2_perm_B_50_3, poseidon2_perm_B_51_0, poseidon2_perm_B_51_1, poseidon2_perm_B_51_2, poseidon2_perm_B_51_3, poseidon2_perm_B_52_0, poseidon2_perm_B_52_1, poseidon2_perm_B_52_2, poseidon2_perm_B_52_3, poseidon2_perm_B_53_0, poseidon2_perm_B_53_1, poseidon2_perm_B_53_2, poseidon2_perm_B_53_3, poseidon2_perm_B_54_0, poseidon2_perm_B_54_1, poseidon2_perm_B_54_2, poseidon2_perm_B_54_3, poseidon2_perm_B_55_0, poseidon2_perm_B_55_1, poseidon2_perm_B_55_2, poseidon2_perm_B_55_3, poseidon2_perm_B_56_0, poseidon2_perm_B_56_1, poseidon2_perm_B_56_2, poseidon2_perm_B_56_3, poseidon2_perm_B_57_0, poseidon2_perm_B_57_1, poseidon2_perm_B_57_2, poseidon2_perm_B_57_3, poseidon2_perm_B_58_0, poseidon2_perm_B_58_1, poseidon2_perm_B_58_2, poseidon2_perm_B_58_3, poseidon2_perm_B_59_0, poseidon2_perm_B_59_1, poseidon2_perm_B_59_2, poseidon2_perm_B_59_3, poseidon2_perm_B_5_0, poseidon2_perm_B_5_1, poseidon2_perm_B_5_2, poseidon2_perm_B_5_3, poseidon2_perm_B_6_0, poseidon2_perm_B_6_1, poseidon2_perm_B_6_2, poseidon2_perm_B_6_3, poseidon2_perm_B_7_0, poseidon2_perm_B_7_1, poseidon2_perm_B_7_2, poseidon2_perm_B_7_3, poseidon2_perm_B_8_0, poseidon2_perm_B_8_1, poseidon2_perm_B_8_2, poseidon2_perm_B_8_3, poseidon2_perm_B_9_0, poseidon2_perm_B_9_1, poseidon2_perm_B_9_2, poseidon2_perm_B_9_3, poseidon2_perm_EXT_LAYER_4, poseidon2_perm_EXT_LAYER_5, poseidon2_perm_EXT_LAYER_6, poseidon2_perm_EXT_LAYER_7, poseidon2_perm_T_0_4, poseidon2_perm_T_0_5, poseidon2_perm_T_0_6, poseidon2_perm_T_0_7, poseidon2_perm_T_1_4, poseidon2_perm_T_1_5, poseidon2_perm_T_1_6, poseidon2_perm_T_1_7, poseidon2_perm_T_2_4, poseidon2_perm_T_2_5, poseidon2_perm_T_2_6, poseidon2_perm_T_2_7, poseidon2_perm_T_3_4, poseidon2_perm_T_3_5, poseidon2_perm_T_3_6, poseidon2_perm_T_3_7, poseidon2_perm_T_60_4, poseidon2_perm_T_60_5, poseidon2_perm_T_60_6, poseidon2_perm_T_60_7, poseidon2_perm_T_61_4, poseidon2_perm_T_61_5, poseidon2_perm_T_61_6, poseidon2_perm_T_61_7, poseidon2_perm_T_62_4, poseidon2_perm_T_62_5, poseidon2_perm_T_62_6, poseidon2_perm_T_62_7, poseidon2_perm_T_63_4, poseidon2_perm_T_63_5, poseidon2_perm_T_63_6, poseidon2_perm_T_63_7, poseidon2_perm_a_0, poseidon2_perm_a_1, poseidon2_perm_a_2, poseidon2_perm_a_3, poseidon2_perm_b_0, poseidon2_perm_b_1, poseidon2_perm_b_2, poseidon2_perm_b_3, poseidon2_perm_sel, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_rng_chk_bits, range_check_sel, range_check_sel_r0_16_bit_rng_lookup, range_check_sel_r1_16_bit_rng_lookup, range_check_sel_r2_16_bit_rng_lookup, range_check_sel_r3_16_bit_rng_lookup, range_check_sel_r4_16_bit_rng_lookup, range_check_sel_r5_16_bit_rng_lookup, range_check_sel_r6_16_bit_rng_lookup, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, scalar_mul_bit, scalar_mul_bit_idx, scalar_mul_bit_radix, scalar_mul_end, scalar_mul_not_end, scalar_mul_point_inf, scalar_mul_point_x, scalar_mul_point_y, scalar_mul_res_inf, scalar_mul_res_x, scalar_mul_res_y, scalar_mul_scalar, scalar_mul_sel, scalar_mul_should_add, scalar_mul_start, scalar_mul_temp_inf, scalar_mul_temp_x, scalar_mul_temp_y, sha256_a, sha256_a_and_b, sha256_a_and_b_xor_a_and_c, sha256_a_and_c, sha256_a_rotr_13, sha256_a_rotr_2, sha256_a_rotr_22, sha256_a_rotr_2_xor_a_rotr_13, sha256_and_sel, sha256_b, sha256_b_and_c, sha256_c, sha256_ch, sha256_clk, sha256_computed_w_lhs, sha256_computed_w_rhs, sha256_d, sha256_e, sha256_e_and_f, sha256_e_rotr_11, sha256_e_rotr_25, sha256_e_rotr_6, sha256_e_rotr_6_xor_e_rotr_11, sha256_f, sha256_g, sha256_h, sha256_helper_w0, sha256_helper_w1, sha256_helper_w10, sha256_helper_w11, sha256_helper_w12, sha256_helper_w13, sha256_helper_w14, sha256_helper_w15, sha256_helper_w2, sha256_helper_w3, sha256_helper_w4, sha256_helper_w5, sha256_helper_w6, sha256_helper_w7, sha256_helper_w8, sha256_helper_w9, sha256_init_a, sha256_init_b, sha256_init_c, sha256_init_d, sha256_init_e, sha256_init_f, sha256_init_g, sha256_init_h, sha256_input_offset, sha256_is_input_round, sha256_latch, sha256_lhs_a_13, sha256_lhs_a_2, sha256_lhs_a_22, sha256_lhs_e_11, sha256_lhs_e_25, sha256_lhs_e_6, sha256_lhs_w_10, sha256_lhs_w_17, sha256_lhs_w_18, sha256_lhs_w_19, sha256_lhs_w_3, sha256_lhs_w_7, sha256_maj, sha256_next_a_lhs, sha256_next_a_rhs, sha256_next_e_lhs, sha256_next_e_rhs, sha256_not_e, sha256_not_e_and_g, sha256_output_a_lhs, sha256_output_a_rhs, sha256_output_b_lhs, sha256_output_b_rhs, sha256_output_c_lhs, sha256_output_c_rhs, sha256_output_d_lhs, sha256_output_d_rhs, sha256_output_e_lhs, sha256_output_e_rhs, sha256_output_f_lhs, sha256_output_f_rhs, sha256_output_g_lhs, sha256_output_g_rhs, sha256_output_h_lhs, sha256_output_h_rhs, sha256_output_offset, sha256_perform_round, sha256_rhs_a_13, sha256_rhs_a_2, sha256_rhs_a_22, sha256_rhs_e_11, sha256_rhs_e_25, sha256_rhs_e_6, sha256_rhs_w_10, sha256_rhs_w_17, sha256_rhs_w_18, sha256_rhs_w_19, sha256_rhs_w_3, sha256_rhs_w_7, sha256_round_constant, sha256_round_count, sha256_rounds_remaining, sha256_rounds_remaining_inv, sha256_s_0, sha256_s_1, sha256_sel, sha256_start, sha256_state_offset, sha256_w, sha256_w_15_rotr_18, sha256_w_15_rotr_7, sha256_w_15_rotr_7_xor_w_15_rotr_18, sha256_w_15_rshift_3, sha256_w_2_rotr_17, sha256_w_2_rotr_17_xor_w_2_rotr_19, sha256_w_2_rotr_19, sha256_w_2_rshift_10, sha256_w_s_0, sha256_w_s_1, sha256_xor_sel, to_radix_acc, to_radix_acc_under_p, to_radix_end, to_radix_exponent, to_radix_found, to_radix_is_unsafe_limb, to_radix_limb, to_radix_limb_eq_p, to_radix_limb_index, to_radix_limb_lt_p, to_radix_limb_p_diff, to_radix_limb_radix_diff, to_radix_not_end, to_radix_not_padding_limb, to_radix_p_limb, to_radix_radix, to_radix_rem_inverse, to_radix_safe_limbs, to_radix_safety_diff_inverse, to_radix_sel, to_radix_start, to_radix_value, lookup_poseidon2_hash_poseidon2_perm_counts, lookup_range_check_dyn_rng_chk_pow_2_counts, lookup_range_check_dyn_diff_is_u16_counts, lookup_range_check_r0_is_u16_counts, lookup_range_check_r1_is_u16_counts, lookup_range_check_r2_is_u16_counts, lookup_range_check_r3_is_u16_counts, lookup_range_check_r4_is_u16_counts, lookup_range_check_r5_is_u16_counts, lookup_range_check_r6_is_u16_counts, lookup_range_check_r7_is_u16_counts, lookup_to_radix_limb_range_counts, lookup_to_radix_limb_less_than_radix_range_counts, lookup_to_radix_fetch_safe_limbs_counts, lookup_to_radix_fetch_p_limb_counts, lookup_to_radix_limb_p_diff_range_counts, lookup_scalar_mul_to_radix_counts, lookup_scalar_mul_double_counts, lookup_scalar_mul_add_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_0_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_1_counts, lookup_address_derivation_partial_address_poseidon2_counts, lookup_address_derivation_public_keys_hash_poseidon2_0_counts, lookup_address_derivation_public_keys_hash_poseidon2_1_counts, lookup_address_derivation_public_keys_hash_poseidon2_2_counts, lookup_address_derivation_public_keys_hash_poseidon2_3_counts, lookup_address_derivation_public_keys_hash_poseidon2_4_counts, lookup_address_derivation_preaddress_poseidon2_counts, lookup_address_derivation_preaddress_scalar_mul_counts, lookup_address_derivation_address_ecadd_counts, lookup_bc_decomposition_bytes_are_bytes_counts, lookup_bc_decomposition_abs_diff_is_u16_counts, lookup_bc_decomposition_bytes_to_read_as_unary_counts, lookup_bc_hashing_get_packed_field_counts, lookup_bc_hashing_iv_is_len_counts, lookup_bc_hashing_poseidon2_hash_counts, lookup_bc_retrieval_class_id_derivation_counts, lookup_bc_retrieval_bytecode_hash_is_correct_counts, lookup_instr_fetching_instr_abs_diff_positive_counts, lookup_instr_fetching_pc_abs_diff_positive_lo_counts, lookup_instr_fetching_pc_abs_diff_positive_hi_counts, lookup_instr_fetching_bytes_from_bc_dec_counts, lookup_instr_fetching_wire_instruction_info_counts, lookup_class_id_derivation_class_id_poseidon2_0_counts, lookup_class_id_derivation_class_id_poseidon2_1_counts, lookup_bitwise_integral_tag_length_counts, lookup_bitwise_byte_operations_counts, lookup_sha256_round_constant_counts -#define AVM2_DERIVED_WITNESS_ENTITIES lookup_poseidon2_hash_poseidon2_perm_inv, lookup_range_check_dyn_rng_chk_pow_2_inv, lookup_range_check_dyn_diff_is_u16_inv, lookup_range_check_r0_is_u16_inv, lookup_range_check_r1_is_u16_inv, lookup_range_check_r2_is_u16_inv, lookup_range_check_r3_is_u16_inv, lookup_range_check_r4_is_u16_inv, lookup_range_check_r5_is_u16_inv, lookup_range_check_r6_is_u16_inv, lookup_range_check_r7_is_u16_inv, lookup_to_radix_limb_range_inv, lookup_to_radix_limb_less_than_radix_range_inv, lookup_to_radix_fetch_safe_limbs_inv, lookup_to_radix_fetch_p_limb_inv, lookup_to_radix_limb_p_diff_range_inv, lookup_scalar_mul_to_radix_inv, lookup_scalar_mul_double_inv, lookup_scalar_mul_add_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_0_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_1_inv, lookup_address_derivation_partial_address_poseidon2_inv, lookup_address_derivation_public_keys_hash_poseidon2_0_inv, lookup_address_derivation_public_keys_hash_poseidon2_1_inv, lookup_address_derivation_public_keys_hash_poseidon2_2_inv, lookup_address_derivation_public_keys_hash_poseidon2_3_inv, lookup_address_derivation_public_keys_hash_poseidon2_4_inv, lookup_address_derivation_preaddress_poseidon2_inv, lookup_address_derivation_preaddress_scalar_mul_inv, lookup_address_derivation_address_ecadd_inv, lookup_bc_decomposition_bytes_are_bytes_inv, lookup_bc_decomposition_abs_diff_is_u16_inv, lookup_bc_decomposition_bytes_to_read_as_unary_inv, lookup_bc_hashing_get_packed_field_inv, lookup_bc_hashing_iv_is_len_inv, lookup_bc_hashing_poseidon2_hash_inv, lookup_bc_retrieval_class_id_derivation_inv, lookup_bc_retrieval_bytecode_hash_is_correct_inv, lookup_instr_fetching_instr_abs_diff_positive_inv, lookup_instr_fetching_pc_abs_diff_positive_lo_inv, lookup_instr_fetching_pc_abs_diff_positive_hi_inv, lookup_instr_fetching_bytes_from_bc_dec_inv, lookup_instr_fetching_wire_instruction_info_inv, lookup_class_id_derivation_class_id_poseidon2_0_inv, lookup_class_id_derivation_class_id_poseidon2_1_inv, lookup_bitwise_integral_tag_length_inv, lookup_bitwise_byte_operations_inv, lookup_sha256_round_constant_inv -#define AVM2_SHIFTED_ENTITIES bc_decomposition_bytes_shift, bc_decomposition_bytes_pc_plus_1_shift, bc_decomposition_bytes_pc_plus_10_shift, bc_decomposition_bytes_pc_plus_11_shift, bc_decomposition_bytes_pc_plus_12_shift, bc_decomposition_bytes_pc_plus_13_shift, bc_decomposition_bytes_pc_plus_14_shift, bc_decomposition_bytes_pc_plus_15_shift, bc_decomposition_bytes_pc_plus_16_shift, bc_decomposition_bytes_pc_plus_17_shift, bc_decomposition_bytes_pc_plus_18_shift, bc_decomposition_bytes_pc_plus_19_shift, bc_decomposition_bytes_pc_plus_2_shift, bc_decomposition_bytes_pc_plus_20_shift, bc_decomposition_bytes_pc_plus_21_shift, bc_decomposition_bytes_pc_plus_22_shift, bc_decomposition_bytes_pc_plus_23_shift, bc_decomposition_bytes_pc_plus_24_shift, bc_decomposition_bytes_pc_plus_25_shift, bc_decomposition_bytes_pc_plus_26_shift, bc_decomposition_bytes_pc_plus_27_shift, bc_decomposition_bytes_pc_plus_28_shift, bc_decomposition_bytes_pc_plus_29_shift, bc_decomposition_bytes_pc_plus_3_shift, bc_decomposition_bytes_pc_plus_30_shift, bc_decomposition_bytes_pc_plus_31_shift, bc_decomposition_bytes_pc_plus_32_shift, bc_decomposition_bytes_pc_plus_33_shift, bc_decomposition_bytes_pc_plus_34_shift, bc_decomposition_bytes_pc_plus_35_shift, bc_decomposition_bytes_pc_plus_4_shift, bc_decomposition_bytes_pc_plus_5_shift, bc_decomposition_bytes_pc_plus_6_shift, bc_decomposition_bytes_pc_plus_7_shift, bc_decomposition_bytes_pc_plus_8_shift, bc_decomposition_bytes_pc_plus_9_shift, bc_decomposition_bytes_remaining_shift, bc_decomposition_id_shift, bc_decomposition_pc_shift, bc_decomposition_sel_shift, bc_hashing_bytecode_id_shift, bc_hashing_incremental_hash_shift, bc_hashing_pc_index_shift, bc_hashing_sel_shift, bc_hashing_start_shift, bitwise_acc_ia_shift, bitwise_acc_ib_shift, bitwise_acc_ic_shift, bitwise_ctr_shift, bitwise_op_id_shift, execution_sel_shift, instr_fetching_bytecode_id_shift, instr_fetching_bytecode_size_shift, instr_fetching_bytes_remaining_shift, instr_fetching_pc_shift, instr_fetching_sel_shift, poseidon2_hash_a_0_shift, poseidon2_hash_a_1_shift, poseidon2_hash_a_2_shift, poseidon2_hash_a_3_shift, poseidon2_hash_input_0_shift, poseidon2_hash_input_1_shift, poseidon2_hash_input_2_shift, poseidon2_hash_num_perm_rounds_rem_shift, poseidon2_hash_output_shift, poseidon2_hash_sel_shift, poseidon2_hash_start_shift, scalar_mul_bit_idx_shift, scalar_mul_point_inf_shift, scalar_mul_point_x_shift, scalar_mul_point_y_shift, scalar_mul_res_inf_shift, scalar_mul_res_x_shift, scalar_mul_res_y_shift, scalar_mul_scalar_shift, scalar_mul_sel_shift, scalar_mul_start_shift, scalar_mul_temp_inf_shift, scalar_mul_temp_x_shift, scalar_mul_temp_y_shift, sha256_a_shift, sha256_b_shift, sha256_c_shift, sha256_d_shift, sha256_e_shift, sha256_f_shift, sha256_g_shift, sha256_h_shift, sha256_helper_w0_shift, sha256_helper_w1_shift, sha256_helper_w10_shift, sha256_helper_w11_shift, sha256_helper_w12_shift, sha256_helper_w13_shift, sha256_helper_w14_shift, sha256_helper_w15_shift, sha256_helper_w2_shift, sha256_helper_w3_shift, sha256_helper_w4_shift, sha256_helper_w5_shift, sha256_helper_w6_shift, sha256_helper_w7_shift, sha256_helper_w8_shift, sha256_helper_w9_shift, sha256_rounds_remaining_shift, sha256_sel_shift, sha256_start_shift, to_radix_acc_shift, to_radix_acc_under_p_shift, to_radix_exponent_shift, to_radix_limb_shift, to_radix_limb_eq_p_shift, to_radix_limb_index_shift, to_radix_limb_lt_p_shift, to_radix_not_padding_limb_shift, to_radix_radix_shift, to_radix_safe_limbs_shift, to_radix_sel_shift, to_radix_start_shift, to_radix_value_shift -#define AVM2_TO_BE_SHIFTED(e) e.bc_decomposition_bytes, e.bc_decomposition_bytes_pc_plus_1, e.bc_decomposition_bytes_pc_plus_10, e.bc_decomposition_bytes_pc_plus_11, e.bc_decomposition_bytes_pc_plus_12, e.bc_decomposition_bytes_pc_plus_13, e.bc_decomposition_bytes_pc_plus_14, e.bc_decomposition_bytes_pc_plus_15, e.bc_decomposition_bytes_pc_plus_16, e.bc_decomposition_bytes_pc_plus_17, e.bc_decomposition_bytes_pc_plus_18, e.bc_decomposition_bytes_pc_plus_19, e.bc_decomposition_bytes_pc_plus_2, e.bc_decomposition_bytes_pc_plus_20, e.bc_decomposition_bytes_pc_plus_21, e.bc_decomposition_bytes_pc_plus_22, e.bc_decomposition_bytes_pc_plus_23, e.bc_decomposition_bytes_pc_plus_24, e.bc_decomposition_bytes_pc_plus_25, e.bc_decomposition_bytes_pc_plus_26, e.bc_decomposition_bytes_pc_plus_27, e.bc_decomposition_bytes_pc_plus_28, e.bc_decomposition_bytes_pc_plus_29, e.bc_decomposition_bytes_pc_plus_3, e.bc_decomposition_bytes_pc_plus_30, e.bc_decomposition_bytes_pc_plus_31, e.bc_decomposition_bytes_pc_plus_32, e.bc_decomposition_bytes_pc_plus_33, e.bc_decomposition_bytes_pc_plus_34, e.bc_decomposition_bytes_pc_plus_35, e.bc_decomposition_bytes_pc_plus_4, e.bc_decomposition_bytes_pc_plus_5, e.bc_decomposition_bytes_pc_plus_6, e.bc_decomposition_bytes_pc_plus_7, e.bc_decomposition_bytes_pc_plus_8, e.bc_decomposition_bytes_pc_plus_9, e.bc_decomposition_bytes_remaining, e.bc_decomposition_id, e.bc_decomposition_pc, e.bc_decomposition_sel, e.bc_hashing_bytecode_id, e.bc_hashing_incremental_hash, e.bc_hashing_pc_index, e.bc_hashing_sel, e.bc_hashing_start, e.bitwise_acc_ia, e.bitwise_acc_ib, e.bitwise_acc_ic, e.bitwise_ctr, e.bitwise_op_id, e.execution_sel, e.instr_fetching_bytecode_id, e.instr_fetching_bytecode_size, e.instr_fetching_bytes_remaining, e.instr_fetching_pc, e.instr_fetching_sel, e.poseidon2_hash_a_0, e.poseidon2_hash_a_1, e.poseidon2_hash_a_2, e.poseidon2_hash_a_3, e.poseidon2_hash_input_0, e.poseidon2_hash_input_1, e.poseidon2_hash_input_2, e.poseidon2_hash_num_perm_rounds_rem, e.poseidon2_hash_output, e.poseidon2_hash_sel, e.poseidon2_hash_start, e.scalar_mul_bit_idx, e.scalar_mul_point_inf, e.scalar_mul_point_x, e.scalar_mul_point_y, e.scalar_mul_res_inf, e.scalar_mul_res_x, e.scalar_mul_res_y, e.scalar_mul_scalar, e.scalar_mul_sel, e.scalar_mul_start, e.scalar_mul_temp_inf, e.scalar_mul_temp_x, e.scalar_mul_temp_y, e.sha256_a, e.sha256_b, e.sha256_c, e.sha256_d, e.sha256_e, e.sha256_f, e.sha256_g, e.sha256_h, e.sha256_helper_w0, e.sha256_helper_w1, e.sha256_helper_w10, e.sha256_helper_w11, e.sha256_helper_w12, e.sha256_helper_w13, e.sha256_helper_w14, e.sha256_helper_w15, e.sha256_helper_w2, e.sha256_helper_w3, e.sha256_helper_w4, e.sha256_helper_w5, e.sha256_helper_w6, e.sha256_helper_w7, e.sha256_helper_w8, e.sha256_helper_w9, e.sha256_rounds_remaining, e.sha256_sel, e.sha256_start, e.to_radix_acc, e.to_radix_acc_under_p, e.to_radix_exponent, e.to_radix_limb, e.to_radix_limb_eq_p, e.to_radix_limb_index, e.to_radix_limb_lt_p, e.to_radix_not_padding_limb, e.to_radix_radix, e.to_radix_safe_limbs, e.to_radix_sel, e.to_radix_start, e.to_radix_value +#define AVM2_WIRE_ENTITIES execution_input, address_derivation_address, address_derivation_address_y, address_derivation_class_id, address_derivation_deployer_addr, address_derivation_g1_x, address_derivation_g1_y, address_derivation_incoming_viewing_key_x, address_derivation_incoming_viewing_key_y, address_derivation_init_hash, address_derivation_nullifier_key_x, address_derivation_nullifier_key_y, address_derivation_outgoing_viewing_key_x, address_derivation_outgoing_viewing_key_y, address_derivation_partial_address, address_derivation_partial_address_domain_separator, address_derivation_preaddress, address_derivation_preaddress_domain_separator, address_derivation_preaddress_public_key_x, address_derivation_preaddress_public_key_y, address_derivation_public_keys_hash, address_derivation_public_keys_hash_domain_separator, address_derivation_salt, address_derivation_salted_init_hash, address_derivation_sel, address_derivation_tagging_key_x, address_derivation_tagging_key_y, alu_dst_addr, alu_ia, alu_ia_addr, alu_ib, alu_ib_addr, alu_ic, alu_op, alu_sel_op_add, bc_decomposition_abs_diff, bc_decomposition_bytes, bc_decomposition_bytes_pc_plus_1, bc_decomposition_bytes_pc_plus_10, bc_decomposition_bytes_pc_plus_11, bc_decomposition_bytes_pc_plus_12, bc_decomposition_bytes_pc_plus_13, bc_decomposition_bytes_pc_plus_14, bc_decomposition_bytes_pc_plus_15, bc_decomposition_bytes_pc_plus_16, bc_decomposition_bytes_pc_plus_17, bc_decomposition_bytes_pc_plus_18, bc_decomposition_bytes_pc_plus_19, bc_decomposition_bytes_pc_plus_2, bc_decomposition_bytes_pc_plus_20, bc_decomposition_bytes_pc_plus_21, bc_decomposition_bytes_pc_plus_22, bc_decomposition_bytes_pc_plus_23, bc_decomposition_bytes_pc_plus_24, bc_decomposition_bytes_pc_plus_25, bc_decomposition_bytes_pc_plus_26, bc_decomposition_bytes_pc_plus_27, bc_decomposition_bytes_pc_plus_28, bc_decomposition_bytes_pc_plus_29, bc_decomposition_bytes_pc_plus_3, bc_decomposition_bytes_pc_plus_30, bc_decomposition_bytes_pc_plus_31, bc_decomposition_bytes_pc_plus_32, bc_decomposition_bytes_pc_plus_33, bc_decomposition_bytes_pc_plus_34, bc_decomposition_bytes_pc_plus_35, bc_decomposition_bytes_pc_plus_36, bc_decomposition_bytes_pc_plus_4, bc_decomposition_bytes_pc_plus_5, bc_decomposition_bytes_pc_plus_6, bc_decomposition_bytes_pc_plus_7, bc_decomposition_bytes_pc_plus_8, bc_decomposition_bytes_pc_plus_9, bc_decomposition_bytes_rem_inv, bc_decomposition_bytes_rem_min_one_inv, bc_decomposition_bytes_remaining, bc_decomposition_bytes_to_read, bc_decomposition_bytes_to_read_unary, bc_decomposition_id, bc_decomposition_last_of_contract, bc_decomposition_packed_field, bc_decomposition_pc, bc_decomposition_sel, bc_decomposition_sel_overflow_correction_needed, bc_decomposition_sel_packed, bc_decomposition_sel_pc_plus_1, bc_decomposition_sel_pc_plus_10, bc_decomposition_sel_pc_plus_11, bc_decomposition_sel_pc_plus_12, bc_decomposition_sel_pc_plus_13, bc_decomposition_sel_pc_plus_14, bc_decomposition_sel_pc_plus_15, bc_decomposition_sel_pc_plus_16, bc_decomposition_sel_pc_plus_17, bc_decomposition_sel_pc_plus_18, bc_decomposition_sel_pc_plus_19, bc_decomposition_sel_pc_plus_2, bc_decomposition_sel_pc_plus_20, bc_decomposition_sel_pc_plus_21, bc_decomposition_sel_pc_plus_22, bc_decomposition_sel_pc_plus_23, bc_decomposition_sel_pc_plus_24, bc_decomposition_sel_pc_plus_25, bc_decomposition_sel_pc_plus_26, bc_decomposition_sel_pc_plus_27, bc_decomposition_sel_pc_plus_28, bc_decomposition_sel_pc_plus_29, bc_decomposition_sel_pc_plus_3, bc_decomposition_sel_pc_plus_30, bc_decomposition_sel_pc_plus_31, bc_decomposition_sel_pc_plus_32, bc_decomposition_sel_pc_plus_33, bc_decomposition_sel_pc_plus_34, bc_decomposition_sel_pc_plus_35, bc_decomposition_sel_pc_plus_36, bc_decomposition_sel_pc_plus_4, bc_decomposition_sel_pc_plus_5, bc_decomposition_sel_pc_plus_6, bc_decomposition_sel_pc_plus_7, bc_decomposition_sel_pc_plus_8, bc_decomposition_sel_pc_plus_9, bc_hashing_bytecode_id, bc_hashing_incremental_hash, bc_hashing_latch, bc_hashing_output_hash, bc_hashing_packed_field, bc_hashing_pc_index, bc_hashing_sel, bc_hashing_start, bc_retrieval_address, bc_retrieval_artifact_hash, bc_retrieval_bytecode_id, bc_retrieval_class_id, bc_retrieval_deployer_addr, bc_retrieval_err, bc_retrieval_incoming_viewing_key_x, bc_retrieval_incoming_viewing_key_y, bc_retrieval_init_hash, bc_retrieval_nullifier_key_x, bc_retrieval_nullifier_key_y, bc_retrieval_outgoing_viewing_key_x, bc_retrieval_outgoing_viewing_key_y, bc_retrieval_private_function_root, bc_retrieval_public_bytecode_commitment, bc_retrieval_salt, bc_retrieval_sel, bc_retrieval_siloed_address, bc_retrieval_tagging_key_x, bc_retrieval_tagging_key_y, bitwise_acc_ia, bitwise_acc_ib, bitwise_acc_ic, bitwise_ctr, bitwise_ctr_inv, bitwise_ctr_min_one_inv, bitwise_ia_byte, bitwise_ib_byte, bitwise_ic_byte, bitwise_last, bitwise_op_id, bitwise_sel, bitwise_start, bitwise_tag, class_id_derivation_artifact_hash, class_id_derivation_class_id, class_id_derivation_private_function_root, class_id_derivation_public_bytecode_commitment, class_id_derivation_sel, class_id_derivation_temp_constant_for_lookup, ecc_add_op, ecc_double_op, ecc_inv_2_p_y, ecc_inv_x_diff, ecc_inv_y_diff, ecc_lambda, ecc_p_is_inf, ecc_p_x, ecc_p_y, ecc_q_is_inf, ecc_q_x, ecc_q_y, ecc_r_is_inf, ecc_r_x, ecc_r_y, ecc_result_infinity, ecc_sel, ecc_x_match, ecc_y_match, execution_addressing_error_idx, execution_addressing_error_kind, execution_base_address_tag, execution_base_address_val, execution_bytecode_id, execution_clk, execution_ex_opcode, execution_indirect, execution_last, execution_op1, execution_op1_after_relative, execution_op2, execution_op2_after_relative, execution_op3, execution_op3_after_relative, execution_op4, execution_op4_after_relative, execution_pc, execution_rop1, execution_rop2, execution_rop3, execution_rop4, execution_sel, execution_sel_addressing_error, execution_sel_op1_is_address, execution_sel_op2_is_address, execution_sel_op3_is_address, execution_sel_op4_is_address, instr_fetching_bd0, instr_fetching_bd1, instr_fetching_bd10, instr_fetching_bd11, instr_fetching_bd12, instr_fetching_bd13, instr_fetching_bd14, instr_fetching_bd15, instr_fetching_bd16, instr_fetching_bd17, instr_fetching_bd18, instr_fetching_bd19, instr_fetching_bd2, instr_fetching_bd20, instr_fetching_bd21, instr_fetching_bd22, instr_fetching_bd23, instr_fetching_bd24, instr_fetching_bd25, instr_fetching_bd26, instr_fetching_bd27, instr_fetching_bd28, instr_fetching_bd29, instr_fetching_bd3, instr_fetching_bd30, instr_fetching_bd31, instr_fetching_bd32, instr_fetching_bd33, instr_fetching_bd34, instr_fetching_bd35, instr_fetching_bd36, instr_fetching_bd4, instr_fetching_bd5, instr_fetching_bd6, instr_fetching_bd7, instr_fetching_bd8, instr_fetching_bd9, instr_fetching_bytecode_id, instr_fetching_bytecode_size, instr_fetching_bytes_to_read, instr_fetching_exec_opcode, instr_fetching_indirect, instr_fetching_instr_abs_diff, instr_fetching_instr_out_of_range, instr_fetching_instr_size, instr_fetching_op1, instr_fetching_op2, instr_fetching_op3, instr_fetching_op4, instr_fetching_op5, instr_fetching_op6, instr_fetching_op7, instr_fetching_opcode_out_of_range, instr_fetching_parsing_err, instr_fetching_pc, instr_fetching_pc_abs_diff, instr_fetching_pc_abs_diff_hi, instr_fetching_pc_abs_diff_lo, instr_fetching_pc_out_of_range, instr_fetching_sel, instr_fetching_sel_op_dc_0, instr_fetching_sel_op_dc_1, instr_fetching_sel_op_dc_10, instr_fetching_sel_op_dc_11, instr_fetching_sel_op_dc_12, instr_fetching_sel_op_dc_13, instr_fetching_sel_op_dc_14, instr_fetching_sel_op_dc_15, instr_fetching_sel_op_dc_16, instr_fetching_sel_op_dc_17, instr_fetching_sel_op_dc_2, instr_fetching_sel_op_dc_3, instr_fetching_sel_op_dc_4, instr_fetching_sel_op_dc_5, instr_fetching_sel_op_dc_6, instr_fetching_sel_op_dc_7, instr_fetching_sel_op_dc_8, instr_fetching_sel_op_dc_9, instr_fetching_sel_opcode_defined, poseidon2_hash_a_0, poseidon2_hash_a_1, poseidon2_hash_a_2, poseidon2_hash_a_3, poseidon2_hash_b_0, poseidon2_hash_b_1, poseidon2_hash_b_2, poseidon2_hash_b_3, poseidon2_hash_end, poseidon2_hash_input_0, poseidon2_hash_input_1, poseidon2_hash_input_2, poseidon2_hash_input_len, poseidon2_hash_num_perm_rounds_rem, poseidon2_hash_num_perm_rounds_rem_inv, poseidon2_hash_output, poseidon2_hash_padding, poseidon2_hash_sel, poseidon2_hash_start, poseidon2_perm_B_10_0, poseidon2_perm_B_10_1, poseidon2_perm_B_10_2, poseidon2_perm_B_10_3, poseidon2_perm_B_11_0, poseidon2_perm_B_11_1, poseidon2_perm_B_11_2, poseidon2_perm_B_11_3, poseidon2_perm_B_12_0, poseidon2_perm_B_12_1, poseidon2_perm_B_12_2, poseidon2_perm_B_12_3, poseidon2_perm_B_13_0, poseidon2_perm_B_13_1, poseidon2_perm_B_13_2, poseidon2_perm_B_13_3, poseidon2_perm_B_14_0, poseidon2_perm_B_14_1, poseidon2_perm_B_14_2, poseidon2_perm_B_14_3, poseidon2_perm_B_15_0, poseidon2_perm_B_15_1, poseidon2_perm_B_15_2, poseidon2_perm_B_15_3, poseidon2_perm_B_16_0, poseidon2_perm_B_16_1, poseidon2_perm_B_16_2, poseidon2_perm_B_16_3, poseidon2_perm_B_17_0, poseidon2_perm_B_17_1, poseidon2_perm_B_17_2, poseidon2_perm_B_17_3, poseidon2_perm_B_18_0, poseidon2_perm_B_18_1, poseidon2_perm_B_18_2, poseidon2_perm_B_18_3, poseidon2_perm_B_19_0, poseidon2_perm_B_19_1, poseidon2_perm_B_19_2, poseidon2_perm_B_19_3, poseidon2_perm_B_20_0, poseidon2_perm_B_20_1, poseidon2_perm_B_20_2, poseidon2_perm_B_20_3, poseidon2_perm_B_21_0, poseidon2_perm_B_21_1, poseidon2_perm_B_21_2, poseidon2_perm_B_21_3, poseidon2_perm_B_22_0, poseidon2_perm_B_22_1, poseidon2_perm_B_22_2, poseidon2_perm_B_22_3, poseidon2_perm_B_23_0, poseidon2_perm_B_23_1, poseidon2_perm_B_23_2, poseidon2_perm_B_23_3, poseidon2_perm_B_24_0, poseidon2_perm_B_24_1, poseidon2_perm_B_24_2, poseidon2_perm_B_24_3, poseidon2_perm_B_25_0, poseidon2_perm_B_25_1, poseidon2_perm_B_25_2, poseidon2_perm_B_25_3, poseidon2_perm_B_26_0, poseidon2_perm_B_26_1, poseidon2_perm_B_26_2, poseidon2_perm_B_26_3, poseidon2_perm_B_27_0, poseidon2_perm_B_27_1, poseidon2_perm_B_27_2, poseidon2_perm_B_27_3, poseidon2_perm_B_28_0, poseidon2_perm_B_28_1, poseidon2_perm_B_28_2, poseidon2_perm_B_28_3, poseidon2_perm_B_29_0, poseidon2_perm_B_29_1, poseidon2_perm_B_29_2, poseidon2_perm_B_29_3, poseidon2_perm_B_30_0, poseidon2_perm_B_30_1, poseidon2_perm_B_30_2, poseidon2_perm_B_30_3, poseidon2_perm_B_31_0, poseidon2_perm_B_31_1, poseidon2_perm_B_31_2, poseidon2_perm_B_31_3, poseidon2_perm_B_32_0, poseidon2_perm_B_32_1, poseidon2_perm_B_32_2, poseidon2_perm_B_32_3, poseidon2_perm_B_33_0, poseidon2_perm_B_33_1, poseidon2_perm_B_33_2, poseidon2_perm_B_33_3, poseidon2_perm_B_34_0, poseidon2_perm_B_34_1, poseidon2_perm_B_34_2, poseidon2_perm_B_34_3, poseidon2_perm_B_35_0, poseidon2_perm_B_35_1, poseidon2_perm_B_35_2, poseidon2_perm_B_35_3, poseidon2_perm_B_36_0, poseidon2_perm_B_36_1, poseidon2_perm_B_36_2, poseidon2_perm_B_36_3, poseidon2_perm_B_37_0, poseidon2_perm_B_37_1, poseidon2_perm_B_37_2, poseidon2_perm_B_37_3, poseidon2_perm_B_38_0, poseidon2_perm_B_38_1, poseidon2_perm_B_38_2, poseidon2_perm_B_38_3, poseidon2_perm_B_39_0, poseidon2_perm_B_39_1, poseidon2_perm_B_39_2, poseidon2_perm_B_39_3, poseidon2_perm_B_40_0, poseidon2_perm_B_40_1, poseidon2_perm_B_40_2, poseidon2_perm_B_40_3, poseidon2_perm_B_41_0, poseidon2_perm_B_41_1, poseidon2_perm_B_41_2, poseidon2_perm_B_41_3, poseidon2_perm_B_42_0, poseidon2_perm_B_42_1, poseidon2_perm_B_42_2, poseidon2_perm_B_42_3, poseidon2_perm_B_43_0, poseidon2_perm_B_43_1, poseidon2_perm_B_43_2, poseidon2_perm_B_43_3, poseidon2_perm_B_44_0, poseidon2_perm_B_44_1, poseidon2_perm_B_44_2, poseidon2_perm_B_44_3, poseidon2_perm_B_45_0, poseidon2_perm_B_45_1, poseidon2_perm_B_45_2, poseidon2_perm_B_45_3, poseidon2_perm_B_46_0, poseidon2_perm_B_46_1, poseidon2_perm_B_46_2, poseidon2_perm_B_46_3, poseidon2_perm_B_47_0, poseidon2_perm_B_47_1, poseidon2_perm_B_47_2, poseidon2_perm_B_47_3, poseidon2_perm_B_48_0, poseidon2_perm_B_48_1, poseidon2_perm_B_48_2, poseidon2_perm_B_48_3, poseidon2_perm_B_49_0, poseidon2_perm_B_49_1, poseidon2_perm_B_49_2, poseidon2_perm_B_49_3, poseidon2_perm_B_4_0, poseidon2_perm_B_4_1, poseidon2_perm_B_4_2, poseidon2_perm_B_4_3, poseidon2_perm_B_50_0, poseidon2_perm_B_50_1, poseidon2_perm_B_50_2, poseidon2_perm_B_50_3, poseidon2_perm_B_51_0, poseidon2_perm_B_51_1, poseidon2_perm_B_51_2, poseidon2_perm_B_51_3, poseidon2_perm_B_52_0, poseidon2_perm_B_52_1, poseidon2_perm_B_52_2, poseidon2_perm_B_52_3, poseidon2_perm_B_53_0, poseidon2_perm_B_53_1, poseidon2_perm_B_53_2, poseidon2_perm_B_53_3, poseidon2_perm_B_54_0, poseidon2_perm_B_54_1, poseidon2_perm_B_54_2, poseidon2_perm_B_54_3, poseidon2_perm_B_55_0, poseidon2_perm_B_55_1, poseidon2_perm_B_55_2, poseidon2_perm_B_55_3, poseidon2_perm_B_56_0, poseidon2_perm_B_56_1, poseidon2_perm_B_56_2, poseidon2_perm_B_56_3, poseidon2_perm_B_57_0, poseidon2_perm_B_57_1, poseidon2_perm_B_57_2, poseidon2_perm_B_57_3, poseidon2_perm_B_58_0, poseidon2_perm_B_58_1, poseidon2_perm_B_58_2, poseidon2_perm_B_58_3, poseidon2_perm_B_59_0, poseidon2_perm_B_59_1, poseidon2_perm_B_59_2, poseidon2_perm_B_59_3, poseidon2_perm_B_5_0, poseidon2_perm_B_5_1, poseidon2_perm_B_5_2, poseidon2_perm_B_5_3, poseidon2_perm_B_6_0, poseidon2_perm_B_6_1, poseidon2_perm_B_6_2, poseidon2_perm_B_6_3, poseidon2_perm_B_7_0, poseidon2_perm_B_7_1, poseidon2_perm_B_7_2, poseidon2_perm_B_7_3, poseidon2_perm_B_8_0, poseidon2_perm_B_8_1, poseidon2_perm_B_8_2, poseidon2_perm_B_8_3, poseidon2_perm_B_9_0, poseidon2_perm_B_9_1, poseidon2_perm_B_9_2, poseidon2_perm_B_9_3, poseidon2_perm_EXT_LAYER_4, poseidon2_perm_EXT_LAYER_5, poseidon2_perm_EXT_LAYER_6, poseidon2_perm_EXT_LAYER_7, poseidon2_perm_T_0_4, poseidon2_perm_T_0_5, poseidon2_perm_T_0_6, poseidon2_perm_T_0_7, poseidon2_perm_T_1_4, poseidon2_perm_T_1_5, poseidon2_perm_T_1_6, poseidon2_perm_T_1_7, poseidon2_perm_T_2_4, poseidon2_perm_T_2_5, poseidon2_perm_T_2_6, poseidon2_perm_T_2_7, poseidon2_perm_T_3_4, poseidon2_perm_T_3_5, poseidon2_perm_T_3_6, poseidon2_perm_T_3_7, poseidon2_perm_T_60_4, poseidon2_perm_T_60_5, poseidon2_perm_T_60_6, poseidon2_perm_T_60_7, poseidon2_perm_T_61_4, poseidon2_perm_T_61_5, poseidon2_perm_T_61_6, poseidon2_perm_T_61_7, poseidon2_perm_T_62_4, poseidon2_perm_T_62_5, poseidon2_perm_T_62_6, poseidon2_perm_T_62_7, poseidon2_perm_T_63_4, poseidon2_perm_T_63_5, poseidon2_perm_T_63_6, poseidon2_perm_T_63_7, poseidon2_perm_a_0, poseidon2_perm_a_1, poseidon2_perm_a_2, poseidon2_perm_a_3, poseidon2_perm_b_0, poseidon2_perm_b_1, poseidon2_perm_b_2, poseidon2_perm_b_3, poseidon2_perm_sel, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_rng_chk_bits, range_check_sel, range_check_sel_r0_16_bit_rng_lookup, range_check_sel_r1_16_bit_rng_lookup, range_check_sel_r2_16_bit_rng_lookup, range_check_sel_r3_16_bit_rng_lookup, range_check_sel_r4_16_bit_rng_lookup, range_check_sel_r5_16_bit_rng_lookup, range_check_sel_r6_16_bit_rng_lookup, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, scalar_mul_bit, scalar_mul_bit_idx, scalar_mul_bit_radix, scalar_mul_end, scalar_mul_not_end, scalar_mul_point_inf, scalar_mul_point_x, scalar_mul_point_y, scalar_mul_res_inf, scalar_mul_res_x, scalar_mul_res_y, scalar_mul_scalar, scalar_mul_sel, scalar_mul_should_add, scalar_mul_start, scalar_mul_temp_inf, scalar_mul_temp_x, scalar_mul_temp_y, sha256_a, sha256_a_and_b, sha256_a_and_b_xor_a_and_c, sha256_a_and_c, sha256_a_rotr_13, sha256_a_rotr_2, sha256_a_rotr_22, sha256_a_rotr_2_xor_a_rotr_13, sha256_and_sel, sha256_b, sha256_b_and_c, sha256_c, sha256_ch, sha256_clk, sha256_computed_w_lhs, sha256_computed_w_rhs, sha256_d, sha256_e, sha256_e_and_f, sha256_e_rotr_11, sha256_e_rotr_25, sha256_e_rotr_6, sha256_e_rotr_6_xor_e_rotr_11, sha256_f, sha256_g, sha256_h, sha256_helper_w0, sha256_helper_w1, sha256_helper_w10, sha256_helper_w11, sha256_helper_w12, sha256_helper_w13, sha256_helper_w14, sha256_helper_w15, sha256_helper_w2, sha256_helper_w3, sha256_helper_w4, sha256_helper_w5, sha256_helper_w6, sha256_helper_w7, sha256_helper_w8, sha256_helper_w9, sha256_init_a, sha256_init_b, sha256_init_c, sha256_init_d, sha256_init_e, sha256_init_f, sha256_init_g, sha256_init_h, sha256_input_offset, sha256_is_input_round, sha256_latch, sha256_lhs_a_13, sha256_lhs_a_2, sha256_lhs_a_22, sha256_lhs_e_11, sha256_lhs_e_25, sha256_lhs_e_6, sha256_lhs_w_10, sha256_lhs_w_17, sha256_lhs_w_18, sha256_lhs_w_19, sha256_lhs_w_3, sha256_lhs_w_7, sha256_maj, sha256_next_a_lhs, sha256_next_a_rhs, sha256_next_e_lhs, sha256_next_e_rhs, sha256_not_e, sha256_not_e_and_g, sha256_output_a_lhs, sha256_output_a_rhs, sha256_output_b_lhs, sha256_output_b_rhs, sha256_output_c_lhs, sha256_output_c_rhs, sha256_output_d_lhs, sha256_output_d_rhs, sha256_output_e_lhs, sha256_output_e_rhs, sha256_output_f_lhs, sha256_output_f_rhs, sha256_output_g_lhs, sha256_output_g_rhs, sha256_output_h_lhs, sha256_output_h_rhs, sha256_output_offset, sha256_perform_round, sha256_rhs_a_13, sha256_rhs_a_2, sha256_rhs_a_22, sha256_rhs_e_11, sha256_rhs_e_25, sha256_rhs_e_6, sha256_rhs_w_10, sha256_rhs_w_17, sha256_rhs_w_18, sha256_rhs_w_19, sha256_rhs_w_3, sha256_rhs_w_7, sha256_round_constant, sha256_round_count, sha256_rounds_remaining, sha256_rounds_remaining_inv, sha256_s_0, sha256_s_1, sha256_sel, sha256_start, sha256_state_offset, sha256_w, sha256_w_15_rotr_18, sha256_w_15_rotr_7, sha256_w_15_rotr_7_xor_w_15_rotr_18, sha256_w_15_rshift_3, sha256_w_2_rotr_17, sha256_w_2_rotr_17_xor_w_2_rotr_19, sha256_w_2_rotr_19, sha256_w_2_rshift_10, sha256_w_s_0, sha256_w_s_1, sha256_xor_sel, to_radix_acc, to_radix_acc_under_p, to_radix_end, to_radix_exponent, to_radix_found, to_radix_is_unsafe_limb, to_radix_limb, to_radix_limb_eq_p, to_radix_limb_index, to_radix_limb_lt_p, to_radix_limb_p_diff, to_radix_limb_radix_diff, to_radix_not_end, to_radix_not_padding_limb, to_radix_p_limb, to_radix_radix, to_radix_rem_inverse, to_radix_safe_limbs, to_radix_safety_diff_inverse, to_radix_sel, to_radix_start, to_radix_value, lookup_poseidon2_hash_poseidon2_perm_counts, lookup_range_check_dyn_rng_chk_pow_2_counts, lookup_range_check_dyn_diff_is_u16_counts, lookup_range_check_r0_is_u16_counts, lookup_range_check_r1_is_u16_counts, lookup_range_check_r2_is_u16_counts, lookup_range_check_r3_is_u16_counts, lookup_range_check_r4_is_u16_counts, lookup_range_check_r5_is_u16_counts, lookup_range_check_r6_is_u16_counts, lookup_range_check_r7_is_u16_counts, lookup_to_radix_limb_range_counts, lookup_to_radix_limb_less_than_radix_range_counts, lookup_to_radix_fetch_safe_limbs_counts, lookup_to_radix_fetch_p_limb_counts, lookup_to_radix_limb_p_diff_range_counts, lookup_scalar_mul_to_radix_counts, lookup_scalar_mul_double_counts, lookup_scalar_mul_add_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_0_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_1_counts, lookup_address_derivation_partial_address_poseidon2_counts, lookup_address_derivation_public_keys_hash_poseidon2_0_counts, lookup_address_derivation_public_keys_hash_poseidon2_1_counts, lookup_address_derivation_public_keys_hash_poseidon2_2_counts, lookup_address_derivation_public_keys_hash_poseidon2_3_counts, lookup_address_derivation_public_keys_hash_poseidon2_4_counts, lookup_address_derivation_preaddress_poseidon2_counts, lookup_address_derivation_preaddress_scalar_mul_counts, lookup_address_derivation_address_ecadd_counts, lookup_bc_decomposition_bytes_are_bytes_counts, lookup_bc_decomposition_abs_diff_is_u16_counts, lookup_bc_decomposition_bytes_to_read_as_unary_counts, lookup_bc_hashing_get_packed_field_counts, lookup_bc_hashing_iv_is_len_counts, lookup_bc_hashing_poseidon2_hash_counts, lookup_bc_retrieval_class_id_derivation_counts, lookup_bc_retrieval_bytecode_hash_is_correct_counts, lookup_instr_fetching_instr_abs_diff_positive_counts, lookup_instr_fetching_pc_abs_diff_positive_lo_counts, lookup_instr_fetching_pc_abs_diff_positive_hi_counts, lookup_instr_fetching_bytecode_size_from_bc_dec_counts, lookup_instr_fetching_bytes_from_bc_dec_counts, lookup_instr_fetching_wire_instruction_info_counts, lookup_class_id_derivation_class_id_poseidon2_0_counts, lookup_class_id_derivation_class_id_poseidon2_1_counts, lookup_bitwise_integral_tag_length_counts, lookup_bitwise_byte_operations_counts, lookup_sha256_round_constant_counts +#define AVM2_DERIVED_WITNESS_ENTITIES lookup_poseidon2_hash_poseidon2_perm_inv, lookup_range_check_dyn_rng_chk_pow_2_inv, lookup_range_check_dyn_diff_is_u16_inv, lookup_range_check_r0_is_u16_inv, lookup_range_check_r1_is_u16_inv, lookup_range_check_r2_is_u16_inv, lookup_range_check_r3_is_u16_inv, lookup_range_check_r4_is_u16_inv, lookup_range_check_r5_is_u16_inv, lookup_range_check_r6_is_u16_inv, lookup_range_check_r7_is_u16_inv, lookup_to_radix_limb_range_inv, lookup_to_radix_limb_less_than_radix_range_inv, lookup_to_radix_fetch_safe_limbs_inv, lookup_to_radix_fetch_p_limb_inv, lookup_to_radix_limb_p_diff_range_inv, lookup_scalar_mul_to_radix_inv, lookup_scalar_mul_double_inv, lookup_scalar_mul_add_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_0_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_1_inv, lookup_address_derivation_partial_address_poseidon2_inv, lookup_address_derivation_public_keys_hash_poseidon2_0_inv, lookup_address_derivation_public_keys_hash_poseidon2_1_inv, lookup_address_derivation_public_keys_hash_poseidon2_2_inv, lookup_address_derivation_public_keys_hash_poseidon2_3_inv, lookup_address_derivation_public_keys_hash_poseidon2_4_inv, lookup_address_derivation_preaddress_poseidon2_inv, lookup_address_derivation_preaddress_scalar_mul_inv, lookup_address_derivation_address_ecadd_inv, lookup_bc_decomposition_bytes_are_bytes_inv, lookup_bc_decomposition_abs_diff_is_u16_inv, lookup_bc_decomposition_bytes_to_read_as_unary_inv, lookup_bc_hashing_get_packed_field_inv, lookup_bc_hashing_iv_is_len_inv, lookup_bc_hashing_poseidon2_hash_inv, lookup_bc_retrieval_class_id_derivation_inv, lookup_bc_retrieval_bytecode_hash_is_correct_inv, lookup_instr_fetching_instr_abs_diff_positive_inv, lookup_instr_fetching_pc_abs_diff_positive_lo_inv, lookup_instr_fetching_pc_abs_diff_positive_hi_inv, lookup_instr_fetching_bytecode_size_from_bc_dec_inv, lookup_instr_fetching_bytes_from_bc_dec_inv, lookup_instr_fetching_wire_instruction_info_inv, lookup_class_id_derivation_class_id_poseidon2_0_inv, lookup_class_id_derivation_class_id_poseidon2_1_inv, lookup_bitwise_integral_tag_length_inv, lookup_bitwise_byte_operations_inv, lookup_sha256_round_constant_inv +#define AVM2_SHIFTED_ENTITIES bc_decomposition_bytes_shift, bc_decomposition_bytes_pc_plus_1_shift, bc_decomposition_bytes_pc_plus_10_shift, bc_decomposition_bytes_pc_plus_11_shift, bc_decomposition_bytes_pc_plus_12_shift, bc_decomposition_bytes_pc_plus_13_shift, bc_decomposition_bytes_pc_plus_14_shift, bc_decomposition_bytes_pc_plus_15_shift, bc_decomposition_bytes_pc_plus_16_shift, bc_decomposition_bytes_pc_plus_17_shift, bc_decomposition_bytes_pc_plus_18_shift, bc_decomposition_bytes_pc_plus_19_shift, bc_decomposition_bytes_pc_plus_2_shift, bc_decomposition_bytes_pc_plus_20_shift, bc_decomposition_bytes_pc_plus_21_shift, bc_decomposition_bytes_pc_plus_22_shift, bc_decomposition_bytes_pc_plus_23_shift, bc_decomposition_bytes_pc_plus_24_shift, bc_decomposition_bytes_pc_plus_25_shift, bc_decomposition_bytes_pc_plus_26_shift, bc_decomposition_bytes_pc_plus_27_shift, bc_decomposition_bytes_pc_plus_28_shift, bc_decomposition_bytes_pc_plus_29_shift, bc_decomposition_bytes_pc_plus_3_shift, bc_decomposition_bytes_pc_plus_30_shift, bc_decomposition_bytes_pc_plus_31_shift, bc_decomposition_bytes_pc_plus_32_shift, bc_decomposition_bytes_pc_plus_33_shift, bc_decomposition_bytes_pc_plus_34_shift, bc_decomposition_bytes_pc_plus_35_shift, bc_decomposition_bytes_pc_plus_4_shift, bc_decomposition_bytes_pc_plus_5_shift, bc_decomposition_bytes_pc_plus_6_shift, bc_decomposition_bytes_pc_plus_7_shift, bc_decomposition_bytes_pc_plus_8_shift, bc_decomposition_bytes_pc_plus_9_shift, bc_decomposition_bytes_remaining_shift, bc_decomposition_id_shift, bc_decomposition_pc_shift, bc_decomposition_sel_shift, bc_hashing_bytecode_id_shift, bc_hashing_incremental_hash_shift, bc_hashing_pc_index_shift, bc_hashing_sel_shift, bc_hashing_start_shift, bitwise_acc_ia_shift, bitwise_acc_ib_shift, bitwise_acc_ic_shift, bitwise_ctr_shift, bitwise_op_id_shift, execution_sel_shift, poseidon2_hash_a_0_shift, poseidon2_hash_a_1_shift, poseidon2_hash_a_2_shift, poseidon2_hash_a_3_shift, poseidon2_hash_input_0_shift, poseidon2_hash_input_1_shift, poseidon2_hash_input_2_shift, poseidon2_hash_num_perm_rounds_rem_shift, poseidon2_hash_output_shift, poseidon2_hash_sel_shift, poseidon2_hash_start_shift, scalar_mul_bit_idx_shift, scalar_mul_point_inf_shift, scalar_mul_point_x_shift, scalar_mul_point_y_shift, scalar_mul_res_inf_shift, scalar_mul_res_x_shift, scalar_mul_res_y_shift, scalar_mul_scalar_shift, scalar_mul_sel_shift, scalar_mul_start_shift, scalar_mul_temp_inf_shift, scalar_mul_temp_x_shift, scalar_mul_temp_y_shift, sha256_a_shift, sha256_b_shift, sha256_c_shift, sha256_d_shift, sha256_e_shift, sha256_f_shift, sha256_g_shift, sha256_h_shift, sha256_helper_w0_shift, sha256_helper_w1_shift, sha256_helper_w10_shift, sha256_helper_w11_shift, sha256_helper_w12_shift, sha256_helper_w13_shift, sha256_helper_w14_shift, sha256_helper_w15_shift, sha256_helper_w2_shift, sha256_helper_w3_shift, sha256_helper_w4_shift, sha256_helper_w5_shift, sha256_helper_w6_shift, sha256_helper_w7_shift, sha256_helper_w8_shift, sha256_helper_w9_shift, sha256_rounds_remaining_shift, sha256_sel_shift, sha256_start_shift, to_radix_acc_shift, to_radix_acc_under_p_shift, to_radix_exponent_shift, to_radix_limb_shift, to_radix_limb_eq_p_shift, to_radix_limb_index_shift, to_radix_limb_lt_p_shift, to_radix_not_padding_limb_shift, to_radix_radix_shift, to_radix_safe_limbs_shift, to_radix_sel_shift, to_radix_start_shift, to_radix_value_shift +#define AVM2_TO_BE_SHIFTED(e) e.bc_decomposition_bytes, e.bc_decomposition_bytes_pc_plus_1, e.bc_decomposition_bytes_pc_plus_10, e.bc_decomposition_bytes_pc_plus_11, e.bc_decomposition_bytes_pc_plus_12, e.bc_decomposition_bytes_pc_plus_13, e.bc_decomposition_bytes_pc_plus_14, e.bc_decomposition_bytes_pc_plus_15, e.bc_decomposition_bytes_pc_plus_16, e.bc_decomposition_bytes_pc_plus_17, e.bc_decomposition_bytes_pc_plus_18, e.bc_decomposition_bytes_pc_plus_19, e.bc_decomposition_bytes_pc_plus_2, e.bc_decomposition_bytes_pc_plus_20, e.bc_decomposition_bytes_pc_plus_21, e.bc_decomposition_bytes_pc_plus_22, e.bc_decomposition_bytes_pc_plus_23, e.bc_decomposition_bytes_pc_plus_24, e.bc_decomposition_bytes_pc_plus_25, e.bc_decomposition_bytes_pc_plus_26, e.bc_decomposition_bytes_pc_plus_27, e.bc_decomposition_bytes_pc_plus_28, e.bc_decomposition_bytes_pc_plus_29, e.bc_decomposition_bytes_pc_plus_3, e.bc_decomposition_bytes_pc_plus_30, e.bc_decomposition_bytes_pc_plus_31, e.bc_decomposition_bytes_pc_plus_32, e.bc_decomposition_bytes_pc_plus_33, e.bc_decomposition_bytes_pc_plus_34, e.bc_decomposition_bytes_pc_plus_35, e.bc_decomposition_bytes_pc_plus_4, e.bc_decomposition_bytes_pc_plus_5, e.bc_decomposition_bytes_pc_plus_6, e.bc_decomposition_bytes_pc_plus_7, e.bc_decomposition_bytes_pc_plus_8, e.bc_decomposition_bytes_pc_plus_9, e.bc_decomposition_bytes_remaining, e.bc_decomposition_id, e.bc_decomposition_pc, e.bc_decomposition_sel, e.bc_hashing_bytecode_id, e.bc_hashing_incremental_hash, e.bc_hashing_pc_index, e.bc_hashing_sel, e.bc_hashing_start, e.bitwise_acc_ia, e.bitwise_acc_ib, e.bitwise_acc_ic, e.bitwise_ctr, e.bitwise_op_id, e.execution_sel, e.poseidon2_hash_a_0, e.poseidon2_hash_a_1, e.poseidon2_hash_a_2, e.poseidon2_hash_a_3, e.poseidon2_hash_input_0, e.poseidon2_hash_input_1, e.poseidon2_hash_input_2, e.poseidon2_hash_num_perm_rounds_rem, e.poseidon2_hash_output, e.poseidon2_hash_sel, e.poseidon2_hash_start, e.scalar_mul_bit_idx, e.scalar_mul_point_inf, e.scalar_mul_point_x, e.scalar_mul_point_y, e.scalar_mul_res_inf, e.scalar_mul_res_x, e.scalar_mul_res_y, e.scalar_mul_scalar, e.scalar_mul_sel, e.scalar_mul_start, e.scalar_mul_temp_inf, e.scalar_mul_temp_x, e.scalar_mul_temp_y, e.sha256_a, e.sha256_b, e.sha256_c, e.sha256_d, e.sha256_e, e.sha256_f, e.sha256_g, e.sha256_h, e.sha256_helper_w0, e.sha256_helper_w1, e.sha256_helper_w10, e.sha256_helper_w11, e.sha256_helper_w12, e.sha256_helper_w13, e.sha256_helper_w14, e.sha256_helper_w15, e.sha256_helper_w2, e.sha256_helper_w3, e.sha256_helper_w4, e.sha256_helper_w5, e.sha256_helper_w6, e.sha256_helper_w7, e.sha256_helper_w8, e.sha256_helper_w9, e.sha256_rounds_remaining, e.sha256_sel, e.sha256_start, e.to_radix_acc, e.to_radix_acc_under_p, e.to_radix_exponent, e.to_radix_limb, e.to_radix_limb_eq_p, e.to_radix_limb_index, e.to_radix_limb_lt_p, e.to_radix_not_padding_limb, e.to_radix_radix, e.to_radix_safe_limbs, e.to_radix_sel, e.to_radix_start, e.to_radix_value #define AVM2_ALL_ENTITIES AVM2_PRECOMPUTED_ENTITIES, AVM2_WIRE_ENTITIES, AVM2_DERIVED_WITNESS_ENTITIES, AVM2_SHIFTED_ENTITIES #define AVM2_UNSHIFTED_ENTITIES AVM2_PRECOMPUTED_ENTITIES, AVM2_WIRE_ENTITIES, AVM2_DERIVED_WITNESS_ENTITIES #define AVM2_WITNESS_ENTITIES AVM2_WIRE_ENTITIES, AVM2_DERIVED_WITNESS_ENTITIES -#define AVM2_TO_BE_SHIFTED_COLUMNS Column::bc_decomposition_bytes, Column::bc_decomposition_bytes_pc_plus_1, Column::bc_decomposition_bytes_pc_plus_10, Column::bc_decomposition_bytes_pc_plus_11, Column::bc_decomposition_bytes_pc_plus_12, Column::bc_decomposition_bytes_pc_plus_13, Column::bc_decomposition_bytes_pc_plus_14, Column::bc_decomposition_bytes_pc_plus_15, Column::bc_decomposition_bytes_pc_plus_16, Column::bc_decomposition_bytes_pc_plus_17, Column::bc_decomposition_bytes_pc_plus_18, Column::bc_decomposition_bytes_pc_plus_19, Column::bc_decomposition_bytes_pc_plus_2, Column::bc_decomposition_bytes_pc_plus_20, Column::bc_decomposition_bytes_pc_plus_21, Column::bc_decomposition_bytes_pc_plus_22, Column::bc_decomposition_bytes_pc_plus_23, Column::bc_decomposition_bytes_pc_plus_24, Column::bc_decomposition_bytes_pc_plus_25, Column::bc_decomposition_bytes_pc_plus_26, Column::bc_decomposition_bytes_pc_plus_27, Column::bc_decomposition_bytes_pc_plus_28, Column::bc_decomposition_bytes_pc_plus_29, Column::bc_decomposition_bytes_pc_plus_3, Column::bc_decomposition_bytes_pc_plus_30, Column::bc_decomposition_bytes_pc_plus_31, Column::bc_decomposition_bytes_pc_plus_32, Column::bc_decomposition_bytes_pc_plus_33, Column::bc_decomposition_bytes_pc_plus_34, Column::bc_decomposition_bytes_pc_plus_35, Column::bc_decomposition_bytes_pc_plus_4, Column::bc_decomposition_bytes_pc_plus_5, Column::bc_decomposition_bytes_pc_plus_6, Column::bc_decomposition_bytes_pc_plus_7, Column::bc_decomposition_bytes_pc_plus_8, Column::bc_decomposition_bytes_pc_plus_9, Column::bc_decomposition_bytes_remaining, Column::bc_decomposition_id, Column::bc_decomposition_pc, Column::bc_decomposition_sel, Column::bc_hashing_bytecode_id, Column::bc_hashing_incremental_hash, Column::bc_hashing_pc_index, Column::bc_hashing_sel, Column::bc_hashing_start, Column::bitwise_acc_ia, Column::bitwise_acc_ib, Column::bitwise_acc_ic, Column::bitwise_ctr, Column::bitwise_op_id, Column::execution_sel, Column::instr_fetching_bytecode_id, Column::instr_fetching_bytecode_size, Column::instr_fetching_bytes_remaining, Column::instr_fetching_pc, Column::instr_fetching_sel, Column::poseidon2_hash_a_0, Column::poseidon2_hash_a_1, Column::poseidon2_hash_a_2, Column::poseidon2_hash_a_3, Column::poseidon2_hash_input_0, Column::poseidon2_hash_input_1, Column::poseidon2_hash_input_2, Column::poseidon2_hash_num_perm_rounds_rem, Column::poseidon2_hash_output, Column::poseidon2_hash_sel, Column::poseidon2_hash_start, Column::scalar_mul_bit_idx, Column::scalar_mul_point_inf, Column::scalar_mul_point_x, Column::scalar_mul_point_y, Column::scalar_mul_res_inf, Column::scalar_mul_res_x, Column::scalar_mul_res_y, Column::scalar_mul_scalar, Column::scalar_mul_sel, Column::scalar_mul_start, Column::scalar_mul_temp_inf, Column::scalar_mul_temp_x, Column::scalar_mul_temp_y, Column::sha256_a, Column::sha256_b, Column::sha256_c, Column::sha256_d, Column::sha256_e, Column::sha256_f, Column::sha256_g, Column::sha256_h, Column::sha256_helper_w0, Column::sha256_helper_w1, Column::sha256_helper_w10, Column::sha256_helper_w11, Column::sha256_helper_w12, Column::sha256_helper_w13, Column::sha256_helper_w14, Column::sha256_helper_w15, Column::sha256_helper_w2, Column::sha256_helper_w3, Column::sha256_helper_w4, Column::sha256_helper_w5, Column::sha256_helper_w6, Column::sha256_helper_w7, Column::sha256_helper_w8, Column::sha256_helper_w9, Column::sha256_rounds_remaining, Column::sha256_sel, Column::sha256_start, Column::to_radix_acc, Column::to_radix_acc_under_p, Column::to_radix_exponent, Column::to_radix_limb, Column::to_radix_limb_eq_p, Column::to_radix_limb_index, Column::to_radix_limb_lt_p, Column::to_radix_not_padding_limb, Column::to_radix_radix, Column::to_radix_safe_limbs, Column::to_radix_sel, Column::to_radix_start, Column::to_radix_value -#define AVM2_SHIFTED_COLUMNS ColumnAndShifts::bc_decomposition_bytes_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_1_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_10_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_11_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_12_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_13_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_14_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_15_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_16_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_17_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_18_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_19_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_2_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_20_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_21_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_22_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_23_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_24_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_25_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_26_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_27_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_28_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_29_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_3_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_30_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_31_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_32_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_33_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_34_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_35_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_4_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_5_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_6_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_7_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_8_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_9_shift, ColumnAndShifts::bc_decomposition_bytes_remaining_shift, ColumnAndShifts::bc_decomposition_id_shift, ColumnAndShifts::bc_decomposition_pc_shift, ColumnAndShifts::bc_decomposition_sel_shift, ColumnAndShifts::bc_hashing_bytecode_id_shift, ColumnAndShifts::bc_hashing_incremental_hash_shift, ColumnAndShifts::bc_hashing_pc_index_shift, ColumnAndShifts::bc_hashing_sel_shift, ColumnAndShifts::bc_hashing_start_shift, ColumnAndShifts::bitwise_acc_ia_shift, ColumnAndShifts::bitwise_acc_ib_shift, ColumnAndShifts::bitwise_acc_ic_shift, ColumnAndShifts::bitwise_ctr_shift, ColumnAndShifts::bitwise_op_id_shift, ColumnAndShifts::execution_sel_shift, ColumnAndShifts::instr_fetching_bytecode_id_shift, ColumnAndShifts::instr_fetching_bytecode_size_shift, ColumnAndShifts::instr_fetching_bytes_remaining_shift, ColumnAndShifts::instr_fetching_pc_shift, ColumnAndShifts::instr_fetching_sel_shift, ColumnAndShifts::poseidon2_hash_a_0_shift, ColumnAndShifts::poseidon2_hash_a_1_shift, ColumnAndShifts::poseidon2_hash_a_2_shift, ColumnAndShifts::poseidon2_hash_a_3_shift, ColumnAndShifts::poseidon2_hash_input_0_shift, ColumnAndShifts::poseidon2_hash_input_1_shift, ColumnAndShifts::poseidon2_hash_input_2_shift, ColumnAndShifts::poseidon2_hash_num_perm_rounds_rem_shift, ColumnAndShifts::poseidon2_hash_output_shift, ColumnAndShifts::poseidon2_hash_sel_shift, ColumnAndShifts::poseidon2_hash_start_shift, ColumnAndShifts::scalar_mul_bit_idx_shift, ColumnAndShifts::scalar_mul_point_inf_shift, ColumnAndShifts::scalar_mul_point_x_shift, ColumnAndShifts::scalar_mul_point_y_shift, ColumnAndShifts::scalar_mul_res_inf_shift, ColumnAndShifts::scalar_mul_res_x_shift, ColumnAndShifts::scalar_mul_res_y_shift, ColumnAndShifts::scalar_mul_scalar_shift, ColumnAndShifts::scalar_mul_sel_shift, ColumnAndShifts::scalar_mul_start_shift, ColumnAndShifts::scalar_mul_temp_inf_shift, ColumnAndShifts::scalar_mul_temp_x_shift, ColumnAndShifts::scalar_mul_temp_y_shift, ColumnAndShifts::sha256_a_shift, ColumnAndShifts::sha256_b_shift, ColumnAndShifts::sha256_c_shift, ColumnAndShifts::sha256_d_shift, ColumnAndShifts::sha256_e_shift, ColumnAndShifts::sha256_f_shift, ColumnAndShifts::sha256_g_shift, ColumnAndShifts::sha256_h_shift, ColumnAndShifts::sha256_helper_w0_shift, ColumnAndShifts::sha256_helper_w1_shift, ColumnAndShifts::sha256_helper_w10_shift, ColumnAndShifts::sha256_helper_w11_shift, ColumnAndShifts::sha256_helper_w12_shift, ColumnAndShifts::sha256_helper_w13_shift, ColumnAndShifts::sha256_helper_w14_shift, ColumnAndShifts::sha256_helper_w15_shift, ColumnAndShifts::sha256_helper_w2_shift, ColumnAndShifts::sha256_helper_w3_shift, ColumnAndShifts::sha256_helper_w4_shift, ColumnAndShifts::sha256_helper_w5_shift, ColumnAndShifts::sha256_helper_w6_shift, ColumnAndShifts::sha256_helper_w7_shift, ColumnAndShifts::sha256_helper_w8_shift, ColumnAndShifts::sha256_helper_w9_shift, ColumnAndShifts::sha256_rounds_remaining_shift, ColumnAndShifts::sha256_sel_shift, ColumnAndShifts::sha256_start_shift, ColumnAndShifts::to_radix_acc_shift, ColumnAndShifts::to_radix_acc_under_p_shift, ColumnAndShifts::to_radix_exponent_shift, ColumnAndShifts::to_radix_limb_shift, ColumnAndShifts::to_radix_limb_eq_p_shift, ColumnAndShifts::to_radix_limb_index_shift, ColumnAndShifts::to_radix_limb_lt_p_shift, ColumnAndShifts::to_radix_not_padding_limb_shift, ColumnAndShifts::to_radix_radix_shift, ColumnAndShifts::to_radix_safe_limbs_shift, ColumnAndShifts::to_radix_sel_shift, ColumnAndShifts::to_radix_start_shift, ColumnAndShifts::to_radix_value_shift +#define AVM2_TO_BE_SHIFTED_COLUMNS Column::bc_decomposition_bytes, Column::bc_decomposition_bytes_pc_plus_1, Column::bc_decomposition_bytes_pc_plus_10, Column::bc_decomposition_bytes_pc_plus_11, Column::bc_decomposition_bytes_pc_plus_12, Column::bc_decomposition_bytes_pc_plus_13, Column::bc_decomposition_bytes_pc_plus_14, Column::bc_decomposition_bytes_pc_plus_15, Column::bc_decomposition_bytes_pc_plus_16, Column::bc_decomposition_bytes_pc_plus_17, Column::bc_decomposition_bytes_pc_plus_18, Column::bc_decomposition_bytes_pc_plus_19, Column::bc_decomposition_bytes_pc_plus_2, Column::bc_decomposition_bytes_pc_plus_20, Column::bc_decomposition_bytes_pc_plus_21, Column::bc_decomposition_bytes_pc_plus_22, Column::bc_decomposition_bytes_pc_plus_23, Column::bc_decomposition_bytes_pc_plus_24, Column::bc_decomposition_bytes_pc_plus_25, Column::bc_decomposition_bytes_pc_plus_26, Column::bc_decomposition_bytes_pc_plus_27, Column::bc_decomposition_bytes_pc_plus_28, Column::bc_decomposition_bytes_pc_plus_29, Column::bc_decomposition_bytes_pc_plus_3, Column::bc_decomposition_bytes_pc_plus_30, Column::bc_decomposition_bytes_pc_plus_31, Column::bc_decomposition_bytes_pc_plus_32, Column::bc_decomposition_bytes_pc_plus_33, Column::bc_decomposition_bytes_pc_plus_34, Column::bc_decomposition_bytes_pc_plus_35, Column::bc_decomposition_bytes_pc_plus_4, Column::bc_decomposition_bytes_pc_plus_5, Column::bc_decomposition_bytes_pc_plus_6, Column::bc_decomposition_bytes_pc_plus_7, Column::bc_decomposition_bytes_pc_plus_8, Column::bc_decomposition_bytes_pc_plus_9, Column::bc_decomposition_bytes_remaining, Column::bc_decomposition_id, Column::bc_decomposition_pc, Column::bc_decomposition_sel, Column::bc_hashing_bytecode_id, Column::bc_hashing_incremental_hash, Column::bc_hashing_pc_index, Column::bc_hashing_sel, Column::bc_hashing_start, Column::bitwise_acc_ia, Column::bitwise_acc_ib, Column::bitwise_acc_ic, Column::bitwise_ctr, Column::bitwise_op_id, Column::execution_sel, Column::poseidon2_hash_a_0, Column::poseidon2_hash_a_1, Column::poseidon2_hash_a_2, Column::poseidon2_hash_a_3, Column::poseidon2_hash_input_0, Column::poseidon2_hash_input_1, Column::poseidon2_hash_input_2, Column::poseidon2_hash_num_perm_rounds_rem, Column::poseidon2_hash_output, Column::poseidon2_hash_sel, Column::poseidon2_hash_start, Column::scalar_mul_bit_idx, Column::scalar_mul_point_inf, Column::scalar_mul_point_x, Column::scalar_mul_point_y, Column::scalar_mul_res_inf, Column::scalar_mul_res_x, Column::scalar_mul_res_y, Column::scalar_mul_scalar, Column::scalar_mul_sel, Column::scalar_mul_start, Column::scalar_mul_temp_inf, Column::scalar_mul_temp_x, Column::scalar_mul_temp_y, Column::sha256_a, Column::sha256_b, Column::sha256_c, Column::sha256_d, Column::sha256_e, Column::sha256_f, Column::sha256_g, Column::sha256_h, Column::sha256_helper_w0, Column::sha256_helper_w1, Column::sha256_helper_w10, Column::sha256_helper_w11, Column::sha256_helper_w12, Column::sha256_helper_w13, Column::sha256_helper_w14, Column::sha256_helper_w15, Column::sha256_helper_w2, Column::sha256_helper_w3, Column::sha256_helper_w4, Column::sha256_helper_w5, Column::sha256_helper_w6, Column::sha256_helper_w7, Column::sha256_helper_w8, Column::sha256_helper_w9, Column::sha256_rounds_remaining, Column::sha256_sel, Column::sha256_start, Column::to_radix_acc, Column::to_radix_acc_under_p, Column::to_radix_exponent, Column::to_radix_limb, Column::to_radix_limb_eq_p, Column::to_radix_limb_index, Column::to_radix_limb_lt_p, Column::to_radix_not_padding_limb, Column::to_radix_radix, Column::to_radix_safe_limbs, Column::to_radix_sel, Column::to_radix_start, Column::to_radix_value +#define AVM2_SHIFTED_COLUMNS ColumnAndShifts::bc_decomposition_bytes_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_1_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_10_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_11_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_12_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_13_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_14_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_15_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_16_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_17_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_18_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_19_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_2_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_20_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_21_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_22_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_23_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_24_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_25_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_26_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_27_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_28_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_29_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_3_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_30_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_31_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_32_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_33_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_34_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_35_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_4_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_5_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_6_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_7_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_8_shift, ColumnAndShifts::bc_decomposition_bytes_pc_plus_9_shift, ColumnAndShifts::bc_decomposition_bytes_remaining_shift, ColumnAndShifts::bc_decomposition_id_shift, ColumnAndShifts::bc_decomposition_pc_shift, ColumnAndShifts::bc_decomposition_sel_shift, ColumnAndShifts::bc_hashing_bytecode_id_shift, ColumnAndShifts::bc_hashing_incremental_hash_shift, ColumnAndShifts::bc_hashing_pc_index_shift, ColumnAndShifts::bc_hashing_sel_shift, ColumnAndShifts::bc_hashing_start_shift, ColumnAndShifts::bitwise_acc_ia_shift, ColumnAndShifts::bitwise_acc_ib_shift, ColumnAndShifts::bitwise_acc_ic_shift, ColumnAndShifts::bitwise_ctr_shift, ColumnAndShifts::bitwise_op_id_shift, ColumnAndShifts::execution_sel_shift, ColumnAndShifts::poseidon2_hash_a_0_shift, ColumnAndShifts::poseidon2_hash_a_1_shift, ColumnAndShifts::poseidon2_hash_a_2_shift, ColumnAndShifts::poseidon2_hash_a_3_shift, ColumnAndShifts::poseidon2_hash_input_0_shift, ColumnAndShifts::poseidon2_hash_input_1_shift, ColumnAndShifts::poseidon2_hash_input_2_shift, ColumnAndShifts::poseidon2_hash_num_perm_rounds_rem_shift, ColumnAndShifts::poseidon2_hash_output_shift, ColumnAndShifts::poseidon2_hash_sel_shift, ColumnAndShifts::poseidon2_hash_start_shift, ColumnAndShifts::scalar_mul_bit_idx_shift, ColumnAndShifts::scalar_mul_point_inf_shift, ColumnAndShifts::scalar_mul_point_x_shift, ColumnAndShifts::scalar_mul_point_y_shift, ColumnAndShifts::scalar_mul_res_inf_shift, ColumnAndShifts::scalar_mul_res_x_shift, ColumnAndShifts::scalar_mul_res_y_shift, ColumnAndShifts::scalar_mul_scalar_shift, ColumnAndShifts::scalar_mul_sel_shift, ColumnAndShifts::scalar_mul_start_shift, ColumnAndShifts::scalar_mul_temp_inf_shift, ColumnAndShifts::scalar_mul_temp_x_shift, ColumnAndShifts::scalar_mul_temp_y_shift, ColumnAndShifts::sha256_a_shift, ColumnAndShifts::sha256_b_shift, ColumnAndShifts::sha256_c_shift, ColumnAndShifts::sha256_d_shift, ColumnAndShifts::sha256_e_shift, ColumnAndShifts::sha256_f_shift, ColumnAndShifts::sha256_g_shift, ColumnAndShifts::sha256_h_shift, ColumnAndShifts::sha256_helper_w0_shift, ColumnAndShifts::sha256_helper_w1_shift, ColumnAndShifts::sha256_helper_w10_shift, ColumnAndShifts::sha256_helper_w11_shift, ColumnAndShifts::sha256_helper_w12_shift, ColumnAndShifts::sha256_helper_w13_shift, ColumnAndShifts::sha256_helper_w14_shift, ColumnAndShifts::sha256_helper_w15_shift, ColumnAndShifts::sha256_helper_w2_shift, ColumnAndShifts::sha256_helper_w3_shift, ColumnAndShifts::sha256_helper_w4_shift, ColumnAndShifts::sha256_helper_w5_shift, ColumnAndShifts::sha256_helper_w6_shift, ColumnAndShifts::sha256_helper_w7_shift, ColumnAndShifts::sha256_helper_w8_shift, ColumnAndShifts::sha256_helper_w9_shift, ColumnAndShifts::sha256_rounds_remaining_shift, ColumnAndShifts::sha256_sel_shift, ColumnAndShifts::sha256_start_shift, ColumnAndShifts::to_radix_acc_shift, ColumnAndShifts::to_radix_acc_under_p_shift, ColumnAndShifts::to_radix_exponent_shift, ColumnAndShifts::to_radix_limb_shift, ColumnAndShifts::to_radix_limb_eq_p_shift, ColumnAndShifts::to_radix_limb_index_shift, ColumnAndShifts::to_radix_limb_lt_p_shift, ColumnAndShifts::to_radix_not_padding_limb_shift, ColumnAndShifts::to_radix_radix_shift, ColumnAndShifts::to_radix_safe_limbs_shift, ColumnAndShifts::to_radix_sel_shift, ColumnAndShifts::to_radix_start_shift, ColumnAndShifts::to_radix_value_shift // clang-format on // All columns minus shifts. @@ -31,8 +31,8 @@ enum class ColumnAndShifts { SENTINEL_DO_NOT_USE, }; -constexpr auto NUM_COLUMNS_WITH_SHIFTS = 1038; -constexpr auto NUM_COLUMNS_WITHOUT_SHIFTS = 918; +constexpr auto NUM_COLUMNS_WITH_SHIFTS = 1032; +constexpr auto NUM_COLUMNS_WITHOUT_SHIFTS = 917; constexpr auto TO_BE_SHIFTED_COLUMNS_ARRAY = []() { return std::array{ AVM2_TO_BE_SHIFTED_COLUMNS }; }(); constexpr auto SHIFTED_COLUMNS_ARRAY = []() { return std::array{ AVM2_SHIFTED_COLUMNS }; }(); static_assert(TO_BE_SHIFTED_COLUMNS_ARRAY.size() == SHIFTED_COLUMNS_ARRAY.size()); diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp index b7d28d0ab916..745d69c68243 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp @@ -90,12 +90,12 @@ class AvmFlavor { static constexpr bool HasZK = false; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 44; - static constexpr size_t NUM_WITNESS_ENTITIES = 874; - static constexpr size_t NUM_SHIFTED_ENTITIES = 120; + static constexpr size_t NUM_WITNESS_ENTITIES = 873; + static constexpr size_t NUM_SHIFTED_ENTITIES = 115; static constexpr size_t NUM_WIRES = NUM_WITNESS_ENTITIES + NUM_PRECOMPUTED_ENTITIES; // We have two copies of the witness entities, so we subtract the number of fixed ones (they have no shift), one for // the unshifted and one for the shifted - static constexpr size_t NUM_ALL_ENTITIES = 1038; + static constexpr size_t NUM_ALL_ENTITIES = 1032; // In the sumcheck univariate computation, we divide the trace in chunks and each chunk is // evenly processed by all the threads. This constant defines the maximum number of rows @@ -157,6 +157,7 @@ class AvmFlavor { lookup_bitwise_integral_tag_length_relation, lookup_class_id_derivation_class_id_poseidon2_0_relation, lookup_class_id_derivation_class_id_poseidon2_1_relation, + lookup_instr_fetching_bytecode_size_from_bc_dec_relation, lookup_instr_fetching_bytes_from_bc_dec_relation, lookup_instr_fetching_instr_abs_diff_positive_relation, lookup_instr_fetching_pc_abs_diff_positive_hi_relation, diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp index 2686b8535299..96d5b5cff31c 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp @@ -12,8 +12,8 @@ template class instr_fetchingImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3, 3, 3, 4, 4, 3, 5, 3, 3, 5, 3, - 4, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4 }; + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3, 3, 3, 4, 3, 4, 2, 3, + 4, 4, 4, 4, 4, 4, 4, 4 }; template inline static bool skip(const AllEntities& in) { @@ -27,8 +27,6 @@ template class instr_fetchingImpl { [[maybe_unused]] const RelationParameters&, [[maybe_unused]] const FF& scaling_factor) { - const auto instr_fetching_BC_ID_DIFF = - (new_term.instr_fetching_bytecode_id_shift - new_term.instr_fetching_bytecode_id); const auto instr_fetching_SEL_OP_DC_18 = new_term.instr_fetching_sel_op_dc_2 + new_term.instr_fetching_sel_op_dc_6; @@ -62,60 +60,15 @@ template class instr_fetchingImpl { } { using Accumulator = typename std::tuple_element_t<4, ContainerOverSubrelations>; - auto tmp = (FF(1) - new_term.precomputed_first_row) * (FF(1) - new_term.instr_fetching_sel) * - new_term.instr_fetching_sel_shift; - tmp *= scaling_factor; - std::get<4>(evals) += typename Accumulator::View(tmp); - } - { - using Accumulator = typename std::tuple_element_t<5, ContainerOverSubrelations>; - auto tmp = new_term.instr_fetching_last_of_bytecode * (FF(1) - new_term.instr_fetching_last_of_bytecode); - tmp *= scaling_factor; - std::get<5>(evals) += typename Accumulator::View(tmp); - } - { - using Accumulator = typename std::tuple_element_t<6, ContainerOverSubrelations>; - auto tmp = new_term.instr_fetching_sel * - (instr_fetching_BC_ID_DIFF * ((FF(1) - new_term.instr_fetching_last_of_bytecode) * - (FF(1) - new_term.instr_fetching_bc_id_diff_inv) + - new_term.instr_fetching_bc_id_diff_inv) - - new_term.instr_fetching_last_of_bytecode); - tmp *= scaling_factor; - std::get<6>(evals) += typename Accumulator::View(tmp); - } - { - using Accumulator = typename std::tuple_element_t<7, ContainerOverSubrelations>; - auto tmp = (new_term.instr_fetching_last_of_bytecode + new_term.precomputed_first_row) * - new_term.instr_fetching_pc_shift; - tmp *= scaling_factor; - std::get<7>(evals) += typename Accumulator::View(tmp); - } - { - using Accumulator = typename std::tuple_element_t<8, ContainerOverSubrelations>; - auto tmp = (new_term.instr_fetching_last_of_bytecode + new_term.precomputed_first_row) * - (new_term.instr_fetching_bytecode_size_shift - new_term.instr_fetching_bytes_remaining_shift); - tmp *= scaling_factor; - std::get<8>(evals) += typename Accumulator::View(tmp); - } - { - using Accumulator = typename std::tuple_element_t<9, ContainerOverSubrelations>; - auto tmp = new_term.instr_fetching_sel * new_term.instr_fetching_sel_shift * - (FF(1) - new_term.instr_fetching_last_of_bytecode) * - (new_term.instr_fetching_bytecode_size - new_term.instr_fetching_bytecode_size_shift); - tmp *= scaling_factor; - std::get<9>(evals) += typename Accumulator::View(tmp); - } - { - using Accumulator = typename std::tuple_element_t<10, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_instr_abs_diff - ((FF(2) * new_term.instr_fetching_instr_out_of_range - FF(1)) * (new_term.instr_fetching_instr_size - new_term.instr_fetching_bytes_to_read) - new_term.instr_fetching_instr_out_of_range)); tmp *= scaling_factor; - std::get<10>(evals) += typename Accumulator::View(tmp); + std::get<4>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<11, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<5, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_pc_abs_diff - new_term.instr_fetching_sel * (((FF(2) * new_term.instr_fetching_pc_out_of_range - FF(1)) * @@ -123,34 +76,34 @@ template class instr_fetchingImpl { FF(1)) + new_term.instr_fetching_pc_out_of_range)); tmp *= scaling_factor; - std::get<11>(evals) += typename Accumulator::View(tmp); + std::get<5>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<12, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<6, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_pc_abs_diff - (new_term.instr_fetching_pc_abs_diff_lo + FF(65536) * new_term.instr_fetching_pc_abs_diff_hi)); tmp *= scaling_factor; - std::get<12>(evals) += typename Accumulator::View(tmp); + std::get<6>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<13, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<7, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_sel_opcode_defined - new_term.instr_fetching_sel * (FF(1) - new_term.instr_fetching_pc_out_of_range)); tmp *= scaling_factor; - std::get<13>(evals) += typename Accumulator::View(tmp); + std::get<7>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<14, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<8, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_indirect - (FF(1) - new_term.instr_fetching_parsing_err) * (new_term.instr_fetching_sel_op_dc_0 * (new_term.instr_fetching_bd1 * FF(256) + new_term.instr_fetching_bd2 * FF(1)) + instr_fetching_SEL_OP_DC_18 * new_term.instr_fetching_bd1 * FF(1))); tmp *= scaling_factor; - std::get<14>(evals) += typename Accumulator::View(tmp); + std::get<8>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<15, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<9, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op1 - (FF(1) - new_term.instr_fetching_parsing_err) * (new_term.instr_fetching_sel_op_dc_0 * @@ -162,10 +115,10 @@ template class instr_fetchingImpl { (new_term.instr_fetching_bd1 * FF(16777216) + new_term.instr_fetching_bd2 * FF(65536) + new_term.instr_fetching_bd3 * FF(256) + new_term.instr_fetching_bd4 * FF(1)))); tmp *= scaling_factor; - std::get<15>(evals) += typename Accumulator::View(tmp); + std::get<9>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<16, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<10, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op2 - (FF(1) - new_term.instr_fetching_parsing_err) * (new_term.instr_fetching_sel_op_dc_0 * @@ -178,10 +131,10 @@ template class instr_fetchingImpl { (new_term.instr_fetching_bd4 * FF(16777216) + new_term.instr_fetching_bd5 * FF(65536) + new_term.instr_fetching_bd6 * FF(256) + new_term.instr_fetching_bd7 * FF(1)))); tmp *= scaling_factor; - std::get<16>(evals) += typename Accumulator::View(tmp); + std::get<10>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<17, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<11, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op3 - (FF(1) - new_term.instr_fetching_parsing_err) * @@ -250,10 +203,10 @@ template class instr_fetchingImpl { new_term.instr_fetching_sel_op_dc_14 * new_term.instr_fetching_bd4 * FF(1) + new_term.instr_fetching_sel_op_dc_17 * new_term.instr_fetching_bd6 * FF(1))); tmp *= scaling_factor; - std::get<17>(evals) += typename Accumulator::View(tmp); + std::get<11>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<18, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<12, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op4 - (FF(1) - new_term.instr_fetching_parsing_err) * (new_term.instr_fetching_sel_op_dc_0 * @@ -262,31 +215,31 @@ template class instr_fetchingImpl { (new_term.instr_fetching_bd8 * FF(256) + new_term.instr_fetching_bd9 * FF(1)) + new_term.instr_fetching_sel_op_dc_7 * new_term.instr_fetching_bd8 * FF(1))); tmp *= scaling_factor; - std::get<18>(evals) += typename Accumulator::View(tmp); + std::get<12>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<19, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<13, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op5 - (FF(1) - new_term.instr_fetching_parsing_err) * new_term.instr_fetching_sel_op_dc_0 * (new_term.instr_fetching_bd11 * FF(256) + new_term.instr_fetching_bd12 * FF(1))); tmp *= scaling_factor; - std::get<19>(evals) += typename Accumulator::View(tmp); + std::get<13>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<20, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<14, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op6 - (FF(1) - new_term.instr_fetching_parsing_err) * new_term.instr_fetching_sel_op_dc_1 * (new_term.instr_fetching_bd13 * FF(256) + new_term.instr_fetching_bd14 * FF(1))); tmp *= scaling_factor; - std::get<20>(evals) += typename Accumulator::View(tmp); + std::get<14>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<21, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<15, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op7 - (FF(1) - new_term.instr_fetching_parsing_err) * new_term.instr_fetching_sel_op_dc_1 * (new_term.instr_fetching_bd15 * FF(256) + new_term.instr_fetching_bd16 * FF(1))); tmp *= scaling_factor; - std::get<21>(evals) += typename Accumulator::View(tmp); + std::get<15>(evals) += typename Accumulator::View(tmp); } } }; @@ -299,58 +252,43 @@ template class instr_fetching : public Relation SRC_COLUMNS = { + ColumnAndShifts::instr_fetching_bytecode_id, + ColumnAndShifts::precomputed_zero, + ColumnAndShifts::instr_fetching_bytecode_size + }; + static constexpr std::array DST_COLUMNS = { + ColumnAndShifts::bc_decomposition_id, + ColumnAndShifts::bc_decomposition_pc, + ColumnAndShifts::bc_decomposition_bytes_remaining + }; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in._instr_fetching_sel() == 1 || in._bc_decomposition_sel() == 1); + } + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in._instr_fetching_sel()); + const auto is_table_entry = View(in._bc_decomposition_sel()); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + template static inline auto get_const_entities(const AllEntities& in) + { + return get_entities(in); + } + + template static inline auto get_nonconst_entities(AllEntities& in) + { + return get_entities(in); + } + + template static inline auto get_entities(AllEntities&& in) + { + return std::forward_as_tuple(in._lookup_instr_fetching_bytecode_size_from_bc_dec_inv(), + in._lookup_instr_fetching_bytecode_size_from_bc_dec_counts(), + in._instr_fetching_sel(), + in._bc_decomposition_sel(), + in._instr_fetching_bytecode_id(), + in._precomputed_zero(), + in._instr_fetching_bytecode_size(), + in._bc_decomposition_id(), + in._bc_decomposition_pc(), + in._bc_decomposition_bytes_remaining()); + } +}; + +template +class lookup_instr_fetching_bytecode_size_from_bc_dec_relation + : public GenericLookupRelation { + public: + using Settings = lookup_instr_fetching_bytecode_size_from_bc_dec_settings; + static constexpr std::string_view NAME = lookup_instr_fetching_bytecode_size_from_bc_dec_settings::NAME; + static constexpr std::string_view RELATION_NAME = + lookup_instr_fetching_bytecode_size_from_bc_dec_settings::RELATION_NAME; + + template inline static bool skip(const AllEntities& in) + { + return in.lookup_instr_fetching_bytecode_size_from_bc_dec_inv.is_zero(); + } + + static std::string get_subrelation_label(size_t index) + { + if (index == 0) { + return "INVERSES_ARE_CORRECT"; + } else if (index == 1) { + return "ACCUMULATION_IS_CORRECT"; + } + return std::to_string(index); + } +}; + /////////////////// lookup_instr_fetching_bytes_from_bc_dec /////////////////// class lookup_instr_fetching_bytes_from_bc_dec_settings { @@ -279,7 +375,7 @@ class lookup_instr_fetching_bytes_from_bc_dec_settings { static constexpr size_t WRITE_TERMS = 1; static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - static constexpr size_t LOOKUP_TUPLE_SIZE = 41; + static constexpr size_t LOOKUP_TUPLE_SIZE = 40; static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; static constexpr size_t READ_TERM_DEGREE = 0; static constexpr size_t WRITE_TERM_DEGREE = 0; @@ -290,52 +386,30 @@ class lookup_instr_fetching_bytes_from_bc_dec_settings { static constexpr Column COUNTS = Column::lookup_instr_fetching_bytes_from_bc_dec_counts; static constexpr Column INVERSES = Column::lookup_instr_fetching_bytes_from_bc_dec_inv; static constexpr std::array SRC_COLUMNS = { - ColumnAndShifts::instr_fetching_pc, - ColumnAndShifts::instr_fetching_bytecode_id, - ColumnAndShifts::instr_fetching_bytes_remaining, - ColumnAndShifts::instr_fetching_bytes_to_read, - ColumnAndShifts::instr_fetching_bd0, - ColumnAndShifts::instr_fetching_bd1, - ColumnAndShifts::instr_fetching_bd2, - ColumnAndShifts::instr_fetching_bd3, - ColumnAndShifts::instr_fetching_bd4, - ColumnAndShifts::instr_fetching_bd5, - ColumnAndShifts::instr_fetching_bd6, - ColumnAndShifts::instr_fetching_bd7, - ColumnAndShifts::instr_fetching_bd8, - ColumnAndShifts::instr_fetching_bd9, - ColumnAndShifts::instr_fetching_bd10, - ColumnAndShifts::instr_fetching_bd11, - ColumnAndShifts::instr_fetching_bd12, - ColumnAndShifts::instr_fetching_bd13, - ColumnAndShifts::instr_fetching_bd14, - ColumnAndShifts::instr_fetching_bd15, - ColumnAndShifts::instr_fetching_bd16, - ColumnAndShifts::instr_fetching_bd17, - ColumnAndShifts::instr_fetching_bd18, - ColumnAndShifts::instr_fetching_bd19, - ColumnAndShifts::instr_fetching_bd20, - ColumnAndShifts::instr_fetching_bd21, - ColumnAndShifts::instr_fetching_bd22, - ColumnAndShifts::instr_fetching_bd23, - ColumnAndShifts::instr_fetching_bd24, - ColumnAndShifts::instr_fetching_bd25, - ColumnAndShifts::instr_fetching_bd26, - ColumnAndShifts::instr_fetching_bd27, - ColumnAndShifts::instr_fetching_bd28, - ColumnAndShifts::instr_fetching_bd29, - ColumnAndShifts::instr_fetching_bd30, - ColumnAndShifts::instr_fetching_bd31, - ColumnAndShifts::instr_fetching_bd32, - ColumnAndShifts::instr_fetching_bd33, - ColumnAndShifts::instr_fetching_bd34, - ColumnAndShifts::instr_fetching_bd35, - ColumnAndShifts::instr_fetching_bd36 + ColumnAndShifts::instr_fetching_bytecode_id, ColumnAndShifts::instr_fetching_pc, + ColumnAndShifts::instr_fetching_bytes_to_read, ColumnAndShifts::instr_fetching_bd0, + ColumnAndShifts::instr_fetching_bd1, ColumnAndShifts::instr_fetching_bd2, + ColumnAndShifts::instr_fetching_bd3, ColumnAndShifts::instr_fetching_bd4, + ColumnAndShifts::instr_fetching_bd5, ColumnAndShifts::instr_fetching_bd6, + ColumnAndShifts::instr_fetching_bd7, ColumnAndShifts::instr_fetching_bd8, + ColumnAndShifts::instr_fetching_bd9, ColumnAndShifts::instr_fetching_bd10, + ColumnAndShifts::instr_fetching_bd11, ColumnAndShifts::instr_fetching_bd12, + ColumnAndShifts::instr_fetching_bd13, ColumnAndShifts::instr_fetching_bd14, + ColumnAndShifts::instr_fetching_bd15, ColumnAndShifts::instr_fetching_bd16, + ColumnAndShifts::instr_fetching_bd17, ColumnAndShifts::instr_fetching_bd18, + ColumnAndShifts::instr_fetching_bd19, ColumnAndShifts::instr_fetching_bd20, + ColumnAndShifts::instr_fetching_bd21, ColumnAndShifts::instr_fetching_bd22, + ColumnAndShifts::instr_fetching_bd23, ColumnAndShifts::instr_fetching_bd24, + ColumnAndShifts::instr_fetching_bd25, ColumnAndShifts::instr_fetching_bd26, + ColumnAndShifts::instr_fetching_bd27, ColumnAndShifts::instr_fetching_bd28, + ColumnAndShifts::instr_fetching_bd29, ColumnAndShifts::instr_fetching_bd30, + ColumnAndShifts::instr_fetching_bd31, ColumnAndShifts::instr_fetching_bd32, + ColumnAndShifts::instr_fetching_bd33, ColumnAndShifts::instr_fetching_bd34, + ColumnAndShifts::instr_fetching_bd35, ColumnAndShifts::instr_fetching_bd36 }; static constexpr std::array DST_COLUMNS = { - ColumnAndShifts::bc_decomposition_pc, ColumnAndShifts::bc_decomposition_id, - ColumnAndShifts::bc_decomposition_bytes_remaining, + ColumnAndShifts::bc_decomposition_pc, ColumnAndShifts::bc_decomposition_bytes_to_read, ColumnAndShifts::bc_decomposition_bytes, ColumnAndShifts::bc_decomposition_bytes_pc_plus_1, @@ -406,9 +480,8 @@ class lookup_instr_fetching_bytes_from_bc_dec_settings { in._lookup_instr_fetching_bytes_from_bc_dec_counts(), in._instr_fetching_sel_opcode_defined(), in._bc_decomposition_sel(), - in._instr_fetching_pc(), in._instr_fetching_bytecode_id(), - in._instr_fetching_bytes_remaining(), + in._instr_fetching_pc(), in._instr_fetching_bytes_to_read(), in._instr_fetching_bd0(), in._instr_fetching_bd1(), @@ -447,9 +520,8 @@ class lookup_instr_fetching_bytes_from_bc_dec_settings { in._instr_fetching_bd34(), in._instr_fetching_bd35(), in._instr_fetching_bd36(), - in._bc_decomposition_pc(), in._bc_decomposition_id(), - in._bc_decomposition_bytes_remaining(), + in._bc_decomposition_pc(), in._bc_decomposition_bytes_to_read(), in._bc_decomposition_bytes(), in._bc_decomposition_bytes_pc_plus_1(), diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp index c161e3166292..394a153139a6 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp @@ -256,166 +256,135 @@ void BytecodeTraceBuilder::process_instruction_fetching( // We start from row 1 because we need a row of zeroes for the shifts. uint32_t row = 1; - // Group and process events per bytecode_id. - // The trace is expecting all rows pertaining to a given bytecode_id to be contigous. - unordered_flat_map> bytecode_id_to_events; + for (const auto& event : events) { + const auto bytecode_id = event.bytecode_id; + const auto bytecode_size = event.bytecode->size(); - for (size_t i = 0; i < events.size(); i++) { - if (bytecode_id_to_events.contains(events.at(i).bytecode_id)) { - bytecode_id_to_events.at(events.at(i).bytecode_id).push_back(i); + auto get_operand = [&](size_t i) -> FF { + return i < event.instruction.operands.size() ? static_cast(event.instruction.operands[i]) : 0; + }; + auto bytecode_at = [&](size_t i) -> uint8_t { return i < bytecode_size ? (*event.bytecode)[i] : 0; }; + + const uint8_t wire_opcode = bytecode_at(event.pc); + const bool wire_opcode_in_range = + event.error != PC_OUT_OF_RANGE && wire_opcode < static_cast(WireOpCode::LAST_OPCODE_SENTINEL); + const auto wire_instr_spec = wire_opcode_in_range + ? WIRE_INSTRUCTION_SPEC.at(static_cast(wire_opcode)) + : WireInstructionSpec{ .exec_opcode = static_cast(0), + .size_in_bytes = 0, + .op_dc_selectors = {} }; + + const uint32_t bytes_remaining = + event.error == PC_OUT_OF_RANGE ? 0 : static_cast(bytecode_size - event.pc); + const uint32_t bytes_to_read = std::min(bytes_remaining, DECOMPOSE_WINDOW_SIZE); + + uint32_t instr_abs_diff = 0; + if (wire_instr_spec.size_in_bytes <= bytes_to_read) { + instr_abs_diff = bytes_to_read - wire_instr_spec.size_in_bytes; } else { - assert(events.at(i).pc == 0); - bytecode_id_to_events[events.at(i).bytecode_id] = { i }; + instr_abs_diff = wire_instr_spec.size_in_bytes - bytes_to_read - 1; } - } - - for (auto it = bytecode_id_to_events.begin(); it != bytecode_id_to_events.end(); it++) { - const auto& event_indices = it->second; - const auto& bytecode_id = it->first; - const BytecodeId next_bytecode_id = next(it) != bytecode_id_to_events.end() ? next(it)->first : 0; - - for (const auto& idx : event_indices) { - const auto& event = events.at(idx); - const auto bytecode_size = event.bytecode->size(); - auto get_operand = [&](size_t i) -> FF { - return i < event.instruction.operands.size() ? static_cast(event.instruction.operands[i]) : 0; - }; - auto bytecode_at = [&](size_t i) -> uint8_t { return i < bytecode_size ? (*event.bytecode)[i] : 0; }; - - const bool is_last_of_bytecode = event_indices.back() == idx && bytecode_id != next_bytecode_id; - // Note that bytecode_id == next_bytecode_id && event_indices.back() == idx only when bytecode_id == 0 - // and this is the last interation of outer loop (last bytecode_id). - - FF bytecode_id_diff_inv = 0; - if (is_last_of_bytecode) { - bytecode_id_diff_inv = (FF(next_bytecode_id) - FF(bytecode_id)).invert(); - } - - const uint8_t wire_opcode = bytecode_at(event.pc); - const bool wire_opcode_in_range = - event.error != PC_OUT_OF_RANGE && wire_opcode < static_cast(WireOpCode::LAST_OPCODE_SENTINEL); - const auto wire_instr_spec = wire_opcode_in_range - ? WIRE_INSTRUCTION_SPEC.at(static_cast(wire_opcode)) - : WireInstructionSpec{ .exec_opcode = static_cast(0), - .size_in_bytes = 0, - .op_dc_selectors = {} }; - - const uint32_t bytes_remaining = - event.error == PC_OUT_OF_RANGE ? 0 : static_cast(bytecode_size - event.pc); - const uint32_t bytes_to_read = std::min(bytes_remaining, DECOMPOSE_WINDOW_SIZE); - - uint32_t instr_abs_diff = 0; - if (wire_instr_spec.size_in_bytes <= bytes_to_read) { - instr_abs_diff = bytes_to_read - wire_instr_spec.size_in_bytes; - } else { - instr_abs_diff = wire_instr_spec.size_in_bytes - bytes_to_read - 1; - } - - uint32_t bytecode_size_u32 = static_cast(bytecode_size); - uint32_t pc_abs_diff = - bytecode_size_u32 > event.pc ? bytecode_size_u32 - event.pc - 1 : event.pc - bytecode_size_u32; - uint32_t pc_abs_diff_lo = pc_abs_diff & 0xFFFF; - uint32_t pc_abs_diff_hi = pc_abs_diff >> 16; - - trace.set(row, - { { - { C::instr_fetching_sel, 1 }, - { C::instr_fetching_bytecode_id, bytecode_id }, - { C::instr_fetching_pc, event.pc }, - // indirect + operands. - { C::instr_fetching_indirect, event.instruction.indirect }, - { C::instr_fetching_op1, get_operand(0) }, - { C::instr_fetching_op2, get_operand(1) }, - { C::instr_fetching_op3, get_operand(2) }, - { C::instr_fetching_op4, get_operand(3) }, - { C::instr_fetching_op5, get_operand(4) }, - { C::instr_fetching_op6, get_operand(5) }, - { C::instr_fetching_op7, get_operand(6) }, - // Single bytes. - { C::instr_fetching_bd0, wire_opcode }, - { C::instr_fetching_bd1, bytecode_at(event.pc + 1) }, - { C::instr_fetching_bd2, bytecode_at(event.pc + 2) }, - { C::instr_fetching_bd3, bytecode_at(event.pc + 3) }, - { C::instr_fetching_bd4, bytecode_at(event.pc + 4) }, - { C::instr_fetching_bd5, bytecode_at(event.pc + 5) }, - { C::instr_fetching_bd6, bytecode_at(event.pc + 6) }, - { C::instr_fetching_bd7, bytecode_at(event.pc + 7) }, - { C::instr_fetching_bd8, bytecode_at(event.pc + 8) }, - { C::instr_fetching_bd9, bytecode_at(event.pc + 9) }, - { C::instr_fetching_bd10, bytecode_at(event.pc + 10) }, - { C::instr_fetching_bd11, bytecode_at(event.pc + 11) }, - { C::instr_fetching_bd12, bytecode_at(event.pc + 12) }, - { C::instr_fetching_bd13, bytecode_at(event.pc + 13) }, - { C::instr_fetching_bd14, bytecode_at(event.pc + 14) }, - { C::instr_fetching_bd15, bytecode_at(event.pc + 15) }, - { C::instr_fetching_bd16, bytecode_at(event.pc + 16) }, - { C::instr_fetching_bd17, bytecode_at(event.pc + 17) }, - { C::instr_fetching_bd18, bytecode_at(event.pc + 18) }, - { C::instr_fetching_bd19, bytecode_at(event.pc + 19) }, - { C::instr_fetching_bd20, bytecode_at(event.pc + 20) }, - { C::instr_fetching_bd21, bytecode_at(event.pc + 21) }, - { C::instr_fetching_bd22, bytecode_at(event.pc + 22) }, - { C::instr_fetching_bd23, bytecode_at(event.pc + 23) }, - { C::instr_fetching_bd24, bytecode_at(event.pc + 24) }, - { C::instr_fetching_bd25, bytecode_at(event.pc + 25) }, - { C::instr_fetching_bd26, bytecode_at(event.pc + 26) }, - { C::instr_fetching_bd27, bytecode_at(event.pc + 27) }, - { C::instr_fetching_bd28, bytecode_at(event.pc + 28) }, - { C::instr_fetching_bd29, bytecode_at(event.pc + 29) }, - { C::instr_fetching_bd30, bytecode_at(event.pc + 30) }, - { C::instr_fetching_bd31, bytecode_at(event.pc + 31) }, - { C::instr_fetching_bd32, bytecode_at(event.pc + 32) }, - { C::instr_fetching_bd33, bytecode_at(event.pc + 33) }, - { C::instr_fetching_bd34, bytecode_at(event.pc + 34) }, - { C::instr_fetching_bd35, bytecode_at(event.pc + 35) }, - { C::instr_fetching_bd36, bytecode_at(event.pc + 36) }, - - // From instruction table. - { C::instr_fetching_exec_opcode, static_cast(wire_instr_spec.exec_opcode) }, - { C::instr_fetching_instr_size, wire_instr_spec.size_in_bytes }, - - // Fill operand decomposition selectors - { C::instr_fetching_sel_op_dc_0, wire_instr_spec.op_dc_selectors.at(0) }, - { C::instr_fetching_sel_op_dc_1, wire_instr_spec.op_dc_selectors.at(1) }, - { C::instr_fetching_sel_op_dc_2, wire_instr_spec.op_dc_selectors.at(2) }, - { C::instr_fetching_sel_op_dc_3, wire_instr_spec.op_dc_selectors.at(3) }, - { C::instr_fetching_sel_op_dc_4, wire_instr_spec.op_dc_selectors.at(4) }, - { C::instr_fetching_sel_op_dc_5, wire_instr_spec.op_dc_selectors.at(5) }, - { C::instr_fetching_sel_op_dc_6, wire_instr_spec.op_dc_selectors.at(6) }, - { C::instr_fetching_sel_op_dc_7, wire_instr_spec.op_dc_selectors.at(7) }, - { C::instr_fetching_sel_op_dc_8, wire_instr_spec.op_dc_selectors.at(8) }, - { C::instr_fetching_sel_op_dc_9, wire_instr_spec.op_dc_selectors.at(9) }, - { C::instr_fetching_sel_op_dc_10, wire_instr_spec.op_dc_selectors.at(10) }, - { C::instr_fetching_sel_op_dc_11, wire_instr_spec.op_dc_selectors.at(11) }, - { C::instr_fetching_sel_op_dc_12, wire_instr_spec.op_dc_selectors.at(12) }, - { C::instr_fetching_sel_op_dc_13, wire_instr_spec.op_dc_selectors.at(13) }, - { C::instr_fetching_sel_op_dc_14, wire_instr_spec.op_dc_selectors.at(14) }, - { C::instr_fetching_sel_op_dc_15, wire_instr_spec.op_dc_selectors.at(15) }, - { C::instr_fetching_sel_op_dc_16, wire_instr_spec.op_dc_selectors.at(16) }, - { C::instr_fetching_sel_op_dc_17, wire_instr_spec.op_dc_selectors.at(17) }, - - // Parsing errors - { C::instr_fetching_pc_out_of_range, event.error == PC_OUT_OF_RANGE ? 1 : 0 }, - { C::instr_fetching_opcode_out_of_range, event.error == OPCODE_OUT_OF_RANGE ? 1 : 0 }, - { C::instr_fetching_instr_out_of_range, event.error == INSTRUCTION_OUT_OF_RANGE ? 1 : 0 }, - { C::instr_fetching_parsing_err, event.error != NO_ERROR ? 1 : 0 }, - - // selector for lookups - { C::instr_fetching_sel_opcode_defined, event.error != PC_OUT_OF_RANGE ? 1 : 0 }, - - { C::instr_fetching_last_of_bytecode, is_last_of_bytecode ? 1 : 0 }, - { C::instr_fetching_bc_id_diff_inv, bytecode_id_diff_inv }, - { C::instr_fetching_bytecode_size, bytecode_size }, - { C::instr_fetching_bytes_remaining, bytes_remaining }, - { C::instr_fetching_bytes_to_read, bytes_to_read }, - { C::instr_fetching_instr_abs_diff, instr_abs_diff }, - { C::instr_fetching_pc_abs_diff, pc_abs_diff }, - { C::instr_fetching_pc_abs_diff_lo, pc_abs_diff_lo }, - { C::instr_fetching_pc_abs_diff_hi, pc_abs_diff_hi }, - } }); - row++; - } + uint32_t bytecode_size_u32 = static_cast(bytecode_size); + uint32_t pc_abs_diff = + bytecode_size_u32 > event.pc ? bytecode_size_u32 - event.pc - 1 : event.pc - bytecode_size_u32; + uint32_t pc_abs_diff_lo = pc_abs_diff & 0xFFFF; + uint32_t pc_abs_diff_hi = pc_abs_diff >> 16; + + trace.set(row, + { { + { C::instr_fetching_sel, 1 }, + { C::instr_fetching_bytecode_id, bytecode_id }, + { C::instr_fetching_pc, event.pc }, + // indirect + operands. + { C::instr_fetching_indirect, event.instruction.indirect }, + { C::instr_fetching_op1, get_operand(0) }, + { C::instr_fetching_op2, get_operand(1) }, + { C::instr_fetching_op3, get_operand(2) }, + { C::instr_fetching_op4, get_operand(3) }, + { C::instr_fetching_op5, get_operand(4) }, + { C::instr_fetching_op6, get_operand(5) }, + { C::instr_fetching_op7, get_operand(6) }, + // Single bytes. + { C::instr_fetching_bd0, wire_opcode }, + { C::instr_fetching_bd1, bytecode_at(event.pc + 1) }, + { C::instr_fetching_bd2, bytecode_at(event.pc + 2) }, + { C::instr_fetching_bd3, bytecode_at(event.pc + 3) }, + { C::instr_fetching_bd4, bytecode_at(event.pc + 4) }, + { C::instr_fetching_bd5, bytecode_at(event.pc + 5) }, + { C::instr_fetching_bd6, bytecode_at(event.pc + 6) }, + { C::instr_fetching_bd7, bytecode_at(event.pc + 7) }, + { C::instr_fetching_bd8, bytecode_at(event.pc + 8) }, + { C::instr_fetching_bd9, bytecode_at(event.pc + 9) }, + { C::instr_fetching_bd10, bytecode_at(event.pc + 10) }, + { C::instr_fetching_bd11, bytecode_at(event.pc + 11) }, + { C::instr_fetching_bd12, bytecode_at(event.pc + 12) }, + { C::instr_fetching_bd13, bytecode_at(event.pc + 13) }, + { C::instr_fetching_bd14, bytecode_at(event.pc + 14) }, + { C::instr_fetching_bd15, bytecode_at(event.pc + 15) }, + { C::instr_fetching_bd16, bytecode_at(event.pc + 16) }, + { C::instr_fetching_bd17, bytecode_at(event.pc + 17) }, + { C::instr_fetching_bd18, bytecode_at(event.pc + 18) }, + { C::instr_fetching_bd19, bytecode_at(event.pc + 19) }, + { C::instr_fetching_bd20, bytecode_at(event.pc + 20) }, + { C::instr_fetching_bd21, bytecode_at(event.pc + 21) }, + { C::instr_fetching_bd22, bytecode_at(event.pc + 22) }, + { C::instr_fetching_bd23, bytecode_at(event.pc + 23) }, + { C::instr_fetching_bd24, bytecode_at(event.pc + 24) }, + { C::instr_fetching_bd25, bytecode_at(event.pc + 25) }, + { C::instr_fetching_bd26, bytecode_at(event.pc + 26) }, + { C::instr_fetching_bd27, bytecode_at(event.pc + 27) }, + { C::instr_fetching_bd28, bytecode_at(event.pc + 28) }, + { C::instr_fetching_bd29, bytecode_at(event.pc + 29) }, + { C::instr_fetching_bd30, bytecode_at(event.pc + 30) }, + { C::instr_fetching_bd31, bytecode_at(event.pc + 31) }, + { C::instr_fetching_bd32, bytecode_at(event.pc + 32) }, + { C::instr_fetching_bd33, bytecode_at(event.pc + 33) }, + { C::instr_fetching_bd34, bytecode_at(event.pc + 34) }, + { C::instr_fetching_bd35, bytecode_at(event.pc + 35) }, + { C::instr_fetching_bd36, bytecode_at(event.pc + 36) }, + + // From instruction table. + { C::instr_fetching_exec_opcode, static_cast(wire_instr_spec.exec_opcode) }, + { C::instr_fetching_instr_size, wire_instr_spec.size_in_bytes }, + + // Fill operand decomposition selectors + { C::instr_fetching_sel_op_dc_0, wire_instr_spec.op_dc_selectors.at(0) }, + { C::instr_fetching_sel_op_dc_1, wire_instr_spec.op_dc_selectors.at(1) }, + { C::instr_fetching_sel_op_dc_2, wire_instr_spec.op_dc_selectors.at(2) }, + { C::instr_fetching_sel_op_dc_3, wire_instr_spec.op_dc_selectors.at(3) }, + { C::instr_fetching_sel_op_dc_4, wire_instr_spec.op_dc_selectors.at(4) }, + { C::instr_fetching_sel_op_dc_5, wire_instr_spec.op_dc_selectors.at(5) }, + { C::instr_fetching_sel_op_dc_6, wire_instr_spec.op_dc_selectors.at(6) }, + { C::instr_fetching_sel_op_dc_7, wire_instr_spec.op_dc_selectors.at(7) }, + { C::instr_fetching_sel_op_dc_8, wire_instr_spec.op_dc_selectors.at(8) }, + { C::instr_fetching_sel_op_dc_9, wire_instr_spec.op_dc_selectors.at(9) }, + { C::instr_fetching_sel_op_dc_10, wire_instr_spec.op_dc_selectors.at(10) }, + { C::instr_fetching_sel_op_dc_11, wire_instr_spec.op_dc_selectors.at(11) }, + { C::instr_fetching_sel_op_dc_12, wire_instr_spec.op_dc_selectors.at(12) }, + { C::instr_fetching_sel_op_dc_13, wire_instr_spec.op_dc_selectors.at(13) }, + { C::instr_fetching_sel_op_dc_14, wire_instr_spec.op_dc_selectors.at(14) }, + { C::instr_fetching_sel_op_dc_15, wire_instr_spec.op_dc_selectors.at(15) }, + { C::instr_fetching_sel_op_dc_16, wire_instr_spec.op_dc_selectors.at(16) }, + { C::instr_fetching_sel_op_dc_17, wire_instr_spec.op_dc_selectors.at(17) }, + + // Parsing errors + { C::instr_fetching_pc_out_of_range, event.error == PC_OUT_OF_RANGE ? 1 : 0 }, + { C::instr_fetching_opcode_out_of_range, event.error == OPCODE_OUT_OF_RANGE ? 1 : 0 }, + { C::instr_fetching_instr_out_of_range, event.error == INSTRUCTION_OUT_OF_RANGE ? 1 : 0 }, + { C::instr_fetching_parsing_err, event.error != NO_ERROR ? 1 : 0 }, + + // selector for lookups + { C::instr_fetching_sel_opcode_defined, event.error != PC_OUT_OF_RANGE ? 1 : 0 }, + + { C::instr_fetching_bytecode_size, bytecode_size }, + { C::instr_fetching_bytes_to_read, bytes_to_read }, + { C::instr_fetching_instr_abs_diff, instr_abs_diff }, + { C::instr_fetching_pc_abs_diff, pc_abs_diff }, + { C::instr_fetching_pc_abs_diff_lo, pc_abs_diff_lo }, + { C::instr_fetching_pc_abs_diff_hi, pc_abs_diff_hi }, + } }); + row++; } } diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp index a9192f16880f..676797f41f19 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp @@ -477,13 +477,11 @@ TEST(BytecodeTraceGenTest, InstrFetchingSingleBytecode) EXPECT_THAT(rows.at(i + 1), AllOf(ROW_FIELD_EQ(R, instr_fetching_sel, 1), - ROW_FIELD_EQ(R, instr_fetching_last_of_bytecode, i == num_of_opcodes - 1 ? 1 : 0), ROW_FIELD_EQ(R, instr_fetching_pc, pc), ROW_FIELD_EQ(R, instr_fetching_bd0, static_cast(opcodes.at(i))), ROW_FIELD_EQ(R, instr_fetching_bytecode_id, bytecode_id), ROW_FIELD_EQ(R, instr_fetching_bytes_to_read, bytes_to_read), ROW_FIELD_EQ(R, instr_fetching_bytecode_size, bytecode_size), - ROW_FIELD_EQ(R, instr_fetching_bytes_remaining, bytes_remaining), ROW_FIELD_EQ(R, instr_fetching_instr_size, instr_size), ROW_FIELD_EQ(R, instr_fetching_instr_abs_diff, instr_abs_diff), ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff, pc_abs_diff), @@ -493,9 +491,6 @@ TEST(BytecodeTraceGenTest, InstrFetchingSingleBytecode) ROW_FIELD_EQ(R, instr_fetching_opcode_out_of_range, 0), ROW_FIELD_EQ(R, instr_fetching_instr_out_of_range, 0), ROW_FIELD_EQ(R, instr_fetching_parsing_err, 0), - ROW_FIELD_EQ(R, - instr_fetching_bc_id_diff_inv, - i == num_of_opcodes - 1 ? FF(FF::modulus - bytecode_id).invert() : 0), ROW_FIELD_EQ(R, instr_fetching_sel_opcode_defined, 1))); } } @@ -531,9 +526,7 @@ TEST(BytecodeTraceGenTest, InstrFetchingMultipleBytecodes) EXPECT_EQ(rows.size(), 6 + 1); for (size_t i = 0; i < 3; i++) { - EXPECT_THAT(rows.at(2 * i + 1), - AllOf(ROW_FIELD_EQ(R, instr_fetching_last_of_bytecode, 0), ROW_FIELD_EQ(R, instr_fetching_pc, 0))); - EXPECT_THAT(rows.at(2 * i + 2), AllOf(ROW_FIELD_EQ(R, instr_fetching_last_of_bytecode, 1))); + EXPECT_THAT(rows.at(2 * i + 1), ROW_FIELD_EQ(R, instr_fetching_pc, 0)); } } @@ -595,7 +588,6 @@ TEST(BytecodeTraceGenTest, InstrFetchingParsingErrors) ROW_FIELD_EQ(R, instr_fetching_sel_opcode_defined, 1), ROW_FIELD_EQ(R, instr_fetching_pc, 0), ROW_FIELD_EQ(R, instr_fetching_bytes_to_read, 20), - ROW_FIELD_EQ(R, instr_fetching_bytes_remaining, 20), ROW_FIELD_EQ(R, instr_fetching_instr_size, 0), ROW_FIELD_EQ(R, instr_fetching_instr_abs_diff, @@ -611,7 +603,6 @@ TEST(BytecodeTraceGenTest, InstrFetchingParsingErrors) ROW_FIELD_EQ(R, instr_fetching_sel_opcode_defined, 1), ROW_FIELD_EQ(R, instr_fetching_pc, 19), // OR_16 opcode ROW_FIELD_EQ(R, instr_fetching_bytes_to_read, 1), - ROW_FIELD_EQ(R, instr_fetching_bytes_remaining, 1), ROW_FIELD_EQ(R, instr_fetching_instr_size, 8), // OR_16 is 8 bytes long ROW_FIELD_EQ(R, instr_fetching_instr_abs_diff, @@ -627,7 +618,6 @@ TEST(BytecodeTraceGenTest, InstrFetchingParsingErrors) ROW_FIELD_EQ(R, instr_fetching_sel_opcode_defined, 0), ROW_FIELD_EQ(R, instr_fetching_pc, 38), ROW_FIELD_EQ(R, instr_fetching_bytes_to_read, 0), - ROW_FIELD_EQ(R, instr_fetching_bytes_remaining, 0), ROW_FIELD_EQ(R, instr_fetching_instr_size, 0), ROW_FIELD_EQ(R, instr_fetching_instr_abs_diff, 0), ROW_FIELD_EQ(R, instr_fetching_parsing_err, 1), diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp index 002271026f03..1e4723c872e6 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp @@ -285,6 +285,7 @@ TraceContainer AvmTraceGenHelper::generate_trace(EventsContainer&& events) // (pc, bytecode_id) would define a unique key which is much shorter than this tuple which is about // 40 elements long. std::make_unique>(), + std::make_unique>(), std::make_unique>(), std::make_unique>(), std::make_unique>(), From 7eea13d70d0ca370f92f1688253f42c083df0130 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Wed, 19 Mar 2025 08:22:08 +0000 Subject: [PATCH 19/25] Typo in relations/utils.hpp --- barretenberg/cpp/src/barretenberg/relations/utils.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/relations/utils.hpp b/barretenberg/cpp/src/barretenberg/relations/utils.hpp index 8ef8e8bec577..c4a1c3bece8b 100644 --- a/barretenberg/cpp/src/barretenberg/relations/utils.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/utils.hpp @@ -64,7 +64,7 @@ template class RelationUtils { } /** - * @brief Scale Univaraites, each representing a subrelation, by different challenges + * @brief Scale Univariates, each representing a subrelation, by different challenges * * @param tuple Tuple of tuples of Univariates * @param challenge Array of NUM_SUBRELATIONS - 1 challenges (because the first subrelation doesn't need to be @@ -85,7 +85,7 @@ template class RelationUtils { } /** - * @brief Scale Univaraites by consecutive powers of the provided challenge + * @brief Scale Univariates by consecutive powers of the provided challenge * * @param tuple Tuple of tuples of Univariates * @param challenge From 43f9f5c149489469a6bc51f2c982fd27eee32b2d Mon Sep 17 00:00:00 2001 From: jeanmon Date: Wed, 19 Mar 2025 12:19:52 +0000 Subject: [PATCH 20/25] Use range check gadget for pc out of range check --- barretenberg/cpp/pil/avm/constants_gen.pil | 1 + barretenberg/cpp/pil/vm2/constants_gen.pil | 1 + barretenberg/cpp/pil/vm2/instr_fetching.pil | 17 +-- barretenberg/cpp/pil/vm2/precomputed.pil | 4 + barretenberg/cpp/pil/vm2/range_check.pil | 2 +- .../src/barretenberg/vm/aztec_constants.hpp | 1 + .../relations/instr_fetching.test.cpp | 85 +++++------ .../barretenberg/vm2/generated/columns.hpp | 10 +- .../src/barretenberg/vm2/generated/flavor.hpp | 10 +- .../generated/relations/instr_fetching.hpp | 81 +++++------ .../relations/lookups_instr_fetching.hpp | 132 ++++-------------- .../vm2/simulation/bytecode_manager.cpp | 5 + .../vm2/simulation/bytecode_manager.hpp | 8 +- .../vm2/simulation/events/memory_event.hpp | 1 - .../vm2/simulation/events/poseidon2_event.hpp | 3 +- .../simulation/events/range_check_event.hpp | 11 +- .../vm2/simulation/events/sha256_event.hpp | 2 - .../vm2/simulation/range_check.hpp | 3 - .../barretenberg/vm2/simulation_helper.cpp | 5 + .../vm2/tracegen/bytecode_trace.cpp | 4 - .../vm2/tracegen/bytecode_trace.test.cpp | 10 -- .../vm2/tracegen/precomputed_trace.cpp | 3 +- .../src/barretenberg/vm2/tracegen_helper.cpp | 3 +- .../crates/types/src/constants.nr | 2 + yarn-project/constants/src/constants.gen.ts | 18 +-- .../constants/src/scripts/constants.in.ts | 1 + 26 files changed, 165 insertions(+), 258 deletions(-) diff --git a/barretenberg/cpp/pil/avm/constants_gen.pil b/barretenberg/cpp/pil/avm/constants_gen.pil index 699f679ad95c..fea63fbf6bcb 100644 --- a/barretenberg/cpp/pil/avm/constants_gen.pil +++ b/barretenberg/cpp/pil/avm/constants_gen.pil @@ -43,6 +43,7 @@ namespace constants; pol START_EMIT_NULLIFIER_WRITE_OFFSET = 207; pol START_EMIT_L2_TO_L1_MSG_WRITE_OFFSET = 223; pol START_EMIT_UNENCRYPTED_LOG_WRITE_OFFSET = 225; + pol AVM_PC_SIZE_IN_BITS = 32; pol GRUMPKIN_ONE_X = 1; pol GRUMPKIN_ONE_Y = 17631683881184975370165255887551781615748388533673675138860; pol GENERATOR_INDEX__NOTE_HASH_NONCE = 2; diff --git a/barretenberg/cpp/pil/vm2/constants_gen.pil b/barretenberg/cpp/pil/vm2/constants_gen.pil index 699f679ad95c..fea63fbf6bcb 100644 --- a/barretenberg/cpp/pil/vm2/constants_gen.pil +++ b/barretenberg/cpp/pil/vm2/constants_gen.pil @@ -43,6 +43,7 @@ namespace constants; pol START_EMIT_NULLIFIER_WRITE_OFFSET = 207; pol START_EMIT_L2_TO_L1_MSG_WRITE_OFFSET = 223; pol START_EMIT_UNENCRYPTED_LOG_WRITE_OFFSET = 225; + pol AVM_PC_SIZE_IN_BITS = 32; pol GRUMPKIN_ONE_X = 1; pol GRUMPKIN_ONE_Y = 17631683881184975370165255887551781615748388533673675138860; pol GENERATOR_INDEX__NOTE_HASH_NONCE = 2; diff --git a/barretenberg/cpp/pil/vm2/instr_fetching.pil b/barretenberg/cpp/pil/vm2/instr_fetching.pil index b51284f68bbc..f1ffd51d34c9 100644 --- a/barretenberg/cpp/pil/vm2/instr_fetching.pil +++ b/barretenberg/cpp/pil/vm2/instr_fetching.pil @@ -1,4 +1,5 @@ include "bc_decomposition.pil"; +include "range_check.pil"; namespace instr_fetching; @@ -55,18 +56,10 @@ pol commit pc_abs_diff; #[PC_OUT_OF_RANGE_TOGGLE] pc_abs_diff = sel * ((2 * pc_out_of_range - 1) * (pc - bytecode_size) - 1 + pc_out_of_range); -// pc_abs_diff might take 32 bits and we decompose into 2 16-bit limbs -pol commit pc_abs_diff_lo; -pol commit pc_abs_diff_hi; - -#[PC_ABS_DIFF_LIMBS] -pc_abs_diff = pc_abs_diff_lo + 2**16 * pc_abs_diff_hi; - -#[PC_ABS_DIFF_POSITIVE_LO] -sel { pc_abs_diff_lo } in precomputed.sel_range_16 { precomputed.clk }; - -#[PC_ABS_DIFF_POSITIVE_HI] -sel { pc_abs_diff_hi } in precomputed.sel_range_16 { precomputed.clk }; +// pc_abs_diff is 32-bit long (pc is uint32_t) +// Use constant AVM_PC_SIZE_IN_BITS once we support constants in lookup tuples. +#[PC_ABS_DIFF_POSITIVE] +sel { pc_abs_diff, precomputed.thirty_two } in range_check.sel { range_check.value, range_check.rng_chk_bits }; #[BYTECODE_SIZE_FROM_BC_DEC] sel { bytecode_id, precomputed.zero, bytecode_size } in diff --git a/barretenberg/cpp/pil/vm2/precomputed.pil b/barretenberg/cpp/pil/vm2/precomputed.pil index cb925d2a7818..92e5dee6479b 100644 --- a/barretenberg/cpp/pil/vm2/precomputed.pil +++ b/barretenberg/cpp/pil/vm2/precomputed.pil @@ -7,6 +7,10 @@ pol constant clk; // A column of zeroes pol constant zero; +// TODO: Remove this one once we support constant in lookup tuples +// A column with 32 values +pol constant thirty_two; + // 1 only at row 0. pol constant first_row; diff --git a/barretenberg/cpp/pil/vm2/range_check.pil b/barretenberg/cpp/pil/vm2/range_check.pil index cedc806bf550..be0839d4a98f 100644 --- a/barretenberg/cpp/pil/vm2/range_check.pil +++ b/barretenberg/cpp/pil/vm2/range_check.pil @@ -1,4 +1,4 @@ -namespace range_check(256); +namespace range_check; // Range check selector pol commit sel; sel * (1 - sel) = 0; diff --git a/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp b/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp index 9f16ae5cbd15..a8c00195f179 100644 --- a/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp @@ -148,6 +148,7 @@ #define AVM_EMITNULLIFIER_BASE_DA_GAS 512 #define AVM_SENDL2TOL1MSG_BASE_DA_GAS 512 #define AVM_EMITUNENCRYPTEDLOG_DYN_DA_GAS 512 +#define AVM_PC_SIZE_IN_BITS 32 #define UPDATES_SHARED_MUTABLE_VALUES_LEN 3 #define GENERATOR_INDEX__NOTE_HASH_NONCE 2 #define GENERATOR_INDEX__UNIQUE_NOTE_HASH 3 diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp index 698a9e0b7968..9960e1b60a24 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/relations/instr_fetching.test.cpp @@ -10,12 +10,14 @@ #include "barretenberg/vm2/generated/columns.hpp" #include "barretenberg/vm2/generated/flavor_settings.hpp" #include "barretenberg/vm2/generated/relations/instr_fetching.hpp" +#include "barretenberg/vm2/simulation/events/range_check_event.hpp" #include "barretenberg/vm2/testing/fixtures.hpp" #include "barretenberg/vm2/testing/macros.hpp" #include "barretenberg/vm2/tracegen/bytecode_trace.hpp" #include "barretenberg/vm2/tracegen/lib/lookup_builder.hpp" #include "barretenberg/vm2/tracegen/lib/lookup_into_indexed_by_clk.hpp" #include "barretenberg/vm2/tracegen/precomputed_trace.hpp" +#include "barretenberg/vm2/tracegen/range_check_trace.hpp" #include "barretenberg/vm2/tracegen/test_trace_container.hpp" namespace bb::avm2::constraining { @@ -26,6 +28,7 @@ using tracegen::LookupIntoDynamicTableGeneric; using tracegen::LookupIntoDynamicTableSequential; using tracegen::LookupIntoIndexedByClk; using tracegen::PrecomputedTraceBuilder; +using tracegen::RangeCheckTraceBuilder; using tracegen::TestTraceContainer; using FF = AvmFlavorSettings::FF; @@ -39,10 +42,10 @@ using simulation::InstrDeserializationError; using simulation::Instruction; using simulation::InstructionFetchingEvent; using simulation::Operand; +using simulation::RangeCheckEvent; -using abs_diff_positive_lookup = lookup_instr_fetching_instr_abs_diff_positive_relation; -using pc_abs_diff_positive_lo_lookup = lookup_instr_fetching_pc_abs_diff_positive_lo_relation; -using pc_abs_diff_positive_hi_lookup = lookup_instr_fetching_pc_abs_diff_positive_hi_relation; +using instr_abs_diff_positive_lookup = lookup_instr_fetching_instr_abs_diff_positive_relation; +using pc_abs_diff_positive_lookup = lookup_instr_fetching_pc_abs_diff_positive_relation; using wire_instr_spec_lookup = lookup_instr_fetching_wire_instruction_info_relation; using bc_decomposition_lookup = lookup_instr_fetching_bytes_from_bc_dec_relation; using bytecode_size_bc_decomposition_lookup = lookup_instr_fetching_bytecode_size_from_bc_dec_relation; @@ -230,6 +233,22 @@ TEST(InstrFetchingConstrainingTest, WireInstructionSpecInteractions) check_interaction(trace); } +std::vector gen_range_check_events(const std::vector& instr_events) +{ + std::vector range_check_events; + range_check_events.reserve(instr_events.size()); + + for (const auto& instr_event : instr_events) { + range_check_events.emplace_back(RangeCheckEvent{ + .value = instr_event.error == InstrDeserializationError::PC_OUT_OF_RANGE + ? instr_event.pc - instr_event.bytecode->size() + : instr_event.bytecode->size() - instr_event.pc - 1, + .num_bits = AVM_PC_SIZE_IN_BITS, + }); + } + return range_check_events; +} + // Positive test for interaction with range checks using same events as for the test // EachOpcodeWithTraceGen, i.e., one event/row is generated per wire opcode. TEST(InstrFetchingConstrainingTest, RangeCheckInteractions) @@ -237,22 +256,25 @@ TEST(InstrFetchingConstrainingTest, RangeCheckInteractions) TestTraceContainer trace; BytecodeTraceBuilder bytecode_builder; PrecomputedTraceBuilder precomputed_builder; + RangeCheckTraceBuilder range_check_builder; + + const auto instr_fetch_events = gen_instr_events_each_opcode(); + const auto range_check_events = gen_range_check_events(instr_fetch_events); precomputed_builder.process_sel_range_8(trace); precomputed_builder.process_sel_range_16(trace); - bytecode_builder.process_instruction_fetching(gen_instr_events_each_opcode(), trace); + bytecode_builder.process_instruction_fetching(instr_fetch_events, trace); + range_check_builder.process(range_check_events, trace); precomputed_builder.process_misc(trace, trace.get_num_rows()); // Limit to the number of rows we need. - LookupIntoIndexedByClk().process(trace); - LookupIntoIndexedByClk().process(trace); - LookupIntoIndexedByClk().process(trace); + LookupIntoIndexedByClk().process(trace); + LookupIntoDynamicTableGeneric().process(trace); EXPECT_EQ(trace.get_num_rows(), 1 << 16); // 2^16 for range checks check_relation(trace); - check_interaction(trace); - check_interaction(trace); - check_interaction(trace); + check_interaction(trace); + check_interaction(trace); } // Positive test for the interaction with bytecode decomposition table. @@ -284,22 +306,24 @@ TEST(InstrFetchingConstrainingTest, BcDecompositionInteractions) } void check_all(const std::vector& instr_events, + const std::vector& range_check_events, const std::vector& decomposition_events) { TestTraceContainer trace; BytecodeTraceBuilder bytecode_builder; PrecomputedTraceBuilder precomputed_builder; + RangeCheckTraceBuilder range_check_builder; precomputed_builder.process_wire_instruction_spec(trace); precomputed_builder.process_sel_range_8(trace); precomputed_builder.process_sel_range_16(trace); bytecode_builder.process_instruction_fetching(instr_events, trace); bytecode_builder.process_decomposition(decomposition_events, trace); + range_check_builder.process(range_check_events, trace); precomputed_builder.process_misc(trace, trace.get_num_rows()); // Limit to the number of rows we need. - LookupIntoIndexedByClk().process(trace); - LookupIntoIndexedByClk().process(trace); - LookupIntoIndexedByClk().process(trace); + LookupIntoIndexedByClk().process(trace); + LookupIntoDynamicTableGeneric().process(trace); LookupIntoIndexedByClk().process(trace); LookupIntoDynamicTableGeneric().process(trace); LookupIntoDynamicTableGeneric().process(trace); @@ -307,9 +331,8 @@ void check_all(const std::vector& instr_events, EXPECT_EQ(trace.get_num_rows(), 1 << 16); // 2^16 for range checks check_relation(trace); - check_interaction(trace); - check_interaction(trace); - check_interaction(trace); + check_interaction(trace); + check_interaction(trace); check_interaction(trace); check_interaction(trace); check_interaction(trace); @@ -352,7 +375,7 @@ TEST(InstrFetchingConstrainingTest, MultipleBytecodes) }); } - check_all(instr_events, decomposition_events); + check_all(instr_events, gen_range_check_events(instr_events), decomposition_events); } // Positive test with one single instruction with error INSTRUCTION_OUT_OF_RANGE. @@ -386,7 +409,7 @@ TEST(InstrFetchingConstrainingTest, SingleInstructionOutOfRange) }, }; - check_all(instr_events, decomposition_events); + check_all(instr_events, gen_range_check_events(instr_events), decomposition_events); } // Positive test with one single instruction (SET_FF) with error INSTRUCTION_OUT_OF_RANGE. @@ -423,7 +446,7 @@ TEST(InstrFetchingConstrainingTest, SingleInstructionOutOfRangeSplitOperand) }, }; - check_all(instr_events, decomposition_events); + check_all(instr_events, gen_range_check_events(instr_events), decomposition_events); } // Positive test with error case PC_OUT_OF_RANGE. We pass a pc which is out of range. @@ -461,7 +484,7 @@ TEST(InstrFetchingConstrainingTest, SingleInstructionPcOutOfRange) }, }; - check_all(instr_events, decomposition_events); + check_all(instr_events, gen_range_check_events(instr_events), decomposition_events); } // Positive test with error case OPCODE_OUT_OF_RANGE. We generate bytecode of a SET_128 instruction and @@ -502,7 +525,7 @@ TEST(InstrFetchingConstrainingTest, SingleInstructionOpcodeOutOfRange) }, }; - check_all(instr_events, decomposition_events); + check_all(instr_events, gen_range_check_events(instr_events), decomposition_events); } // Negative interaction test with some values not matching the instruction spec table. @@ -767,25 +790,5 @@ TEST(InstrFetchingConstrainingTest, NegativeTogglingPcInRange) "PC_OUT_OF_RANGE_TOGGLE"); } -// Negative test on wrong decomposing pc_abs_diff into limbs -TEST(InstrFetchingConstrainingTest, NegativePcAbsDiffLimbs) -{ - TestTraceContainer trace = TestTraceContainer::from_rows({ - { .precomputed_first_row = 1 }, - { - .instr_fetching_pc_abs_diff = 7 * (1 << 16) + 347, - .instr_fetching_pc_abs_diff_hi = 7, - .instr_fetching_pc_abs_diff_lo = 347, // Will be mutated to 348 - }, - }); - - check_relation(trace, instr_fetching::SR_PC_ABS_DIFF_LIMBS); - - trace.set(C::instr_fetching_pc_abs_diff_lo, 1, 348); // Mutate to wrong value - - EXPECT_THROW_WITH_MESSAGE(check_relation(trace, instr_fetching::SR_PC_ABS_DIFF_LIMBS), - "PC_ABS_DIFF_LIMBS"); -} - } // namespace } // namespace bb::avm2::constraining diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp index cae36e3982d6..903c4c4ef59a 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp @@ -9,9 +9,9 @@ namespace bb::avm2 { // The entities that will be used in the flavor. // clang-format off -#define AVM2_PRECOMPUTED_ENTITIES precomputed_as_unary, precomputed_bitwise_input_a, precomputed_bitwise_input_b, precomputed_bitwise_op_id, precomputed_bitwise_output, precomputed_clk, precomputed_exec_opcode, precomputed_first_row, precomputed_instr_size, precomputed_integral_tag_length, precomputed_opcode_out_of_range, precomputed_p_decomposition_limb, precomputed_p_decomposition_limb_index, precomputed_p_decomposition_radix, precomputed_power_of_2, precomputed_sel_bitwise, precomputed_sel_integral_tag, precomputed_sel_op_dc_0, precomputed_sel_op_dc_1, precomputed_sel_op_dc_10, precomputed_sel_op_dc_11, precomputed_sel_op_dc_12, precomputed_sel_op_dc_13, precomputed_sel_op_dc_14, precomputed_sel_op_dc_15, precomputed_sel_op_dc_16, precomputed_sel_op_dc_17, precomputed_sel_op_dc_2, precomputed_sel_op_dc_3, precomputed_sel_op_dc_4, precomputed_sel_op_dc_5, precomputed_sel_op_dc_6, precomputed_sel_op_dc_7, precomputed_sel_op_dc_8, precomputed_sel_op_dc_9, precomputed_sel_p_decomposition, precomputed_sel_range_16, precomputed_sel_range_8, precomputed_sel_sha256_compression, precomputed_sel_to_radix_safe_limbs, precomputed_sel_unary, precomputed_sha256_compression_round_constant, precomputed_to_radix_safe_limbs, precomputed_zero -#define AVM2_WIRE_ENTITIES execution_input, address_derivation_address, address_derivation_address_y, address_derivation_class_id, address_derivation_deployer_addr, address_derivation_g1_x, address_derivation_g1_y, address_derivation_incoming_viewing_key_x, address_derivation_incoming_viewing_key_y, address_derivation_init_hash, address_derivation_nullifier_key_x, address_derivation_nullifier_key_y, address_derivation_outgoing_viewing_key_x, address_derivation_outgoing_viewing_key_y, address_derivation_partial_address, address_derivation_partial_address_domain_separator, address_derivation_preaddress, address_derivation_preaddress_domain_separator, address_derivation_preaddress_public_key_x, address_derivation_preaddress_public_key_y, address_derivation_public_keys_hash, address_derivation_public_keys_hash_domain_separator, address_derivation_salt, address_derivation_salted_init_hash, address_derivation_sel, address_derivation_tagging_key_x, address_derivation_tagging_key_y, alu_dst_addr, alu_ia, alu_ia_addr, alu_ib, alu_ib_addr, alu_ic, alu_op, alu_sel_op_add, bc_decomposition_abs_diff, bc_decomposition_bytes, bc_decomposition_bytes_pc_plus_1, bc_decomposition_bytes_pc_plus_10, bc_decomposition_bytes_pc_plus_11, bc_decomposition_bytes_pc_plus_12, bc_decomposition_bytes_pc_plus_13, bc_decomposition_bytes_pc_plus_14, bc_decomposition_bytes_pc_plus_15, bc_decomposition_bytes_pc_plus_16, bc_decomposition_bytes_pc_plus_17, bc_decomposition_bytes_pc_plus_18, bc_decomposition_bytes_pc_plus_19, bc_decomposition_bytes_pc_plus_2, bc_decomposition_bytes_pc_plus_20, bc_decomposition_bytes_pc_plus_21, bc_decomposition_bytes_pc_plus_22, bc_decomposition_bytes_pc_plus_23, bc_decomposition_bytes_pc_plus_24, bc_decomposition_bytes_pc_plus_25, bc_decomposition_bytes_pc_plus_26, bc_decomposition_bytes_pc_plus_27, bc_decomposition_bytes_pc_plus_28, bc_decomposition_bytes_pc_plus_29, bc_decomposition_bytes_pc_plus_3, bc_decomposition_bytes_pc_plus_30, bc_decomposition_bytes_pc_plus_31, bc_decomposition_bytes_pc_plus_32, bc_decomposition_bytes_pc_plus_33, bc_decomposition_bytes_pc_plus_34, bc_decomposition_bytes_pc_plus_35, bc_decomposition_bytes_pc_plus_36, bc_decomposition_bytes_pc_plus_4, bc_decomposition_bytes_pc_plus_5, bc_decomposition_bytes_pc_plus_6, bc_decomposition_bytes_pc_plus_7, bc_decomposition_bytes_pc_plus_8, bc_decomposition_bytes_pc_plus_9, bc_decomposition_bytes_rem_inv, bc_decomposition_bytes_rem_min_one_inv, bc_decomposition_bytes_remaining, bc_decomposition_bytes_to_read, bc_decomposition_bytes_to_read_unary, bc_decomposition_id, bc_decomposition_last_of_contract, bc_decomposition_packed_field, bc_decomposition_pc, bc_decomposition_sel, bc_decomposition_sel_overflow_correction_needed, bc_decomposition_sel_packed, bc_decomposition_sel_pc_plus_1, bc_decomposition_sel_pc_plus_10, bc_decomposition_sel_pc_plus_11, bc_decomposition_sel_pc_plus_12, bc_decomposition_sel_pc_plus_13, bc_decomposition_sel_pc_plus_14, bc_decomposition_sel_pc_plus_15, bc_decomposition_sel_pc_plus_16, bc_decomposition_sel_pc_plus_17, bc_decomposition_sel_pc_plus_18, bc_decomposition_sel_pc_plus_19, bc_decomposition_sel_pc_plus_2, bc_decomposition_sel_pc_plus_20, bc_decomposition_sel_pc_plus_21, bc_decomposition_sel_pc_plus_22, bc_decomposition_sel_pc_plus_23, bc_decomposition_sel_pc_plus_24, bc_decomposition_sel_pc_plus_25, bc_decomposition_sel_pc_plus_26, bc_decomposition_sel_pc_plus_27, bc_decomposition_sel_pc_plus_28, bc_decomposition_sel_pc_plus_29, bc_decomposition_sel_pc_plus_3, bc_decomposition_sel_pc_plus_30, bc_decomposition_sel_pc_plus_31, bc_decomposition_sel_pc_plus_32, bc_decomposition_sel_pc_plus_33, bc_decomposition_sel_pc_plus_34, bc_decomposition_sel_pc_plus_35, bc_decomposition_sel_pc_plus_36, bc_decomposition_sel_pc_plus_4, bc_decomposition_sel_pc_plus_5, bc_decomposition_sel_pc_plus_6, bc_decomposition_sel_pc_plus_7, bc_decomposition_sel_pc_plus_8, bc_decomposition_sel_pc_plus_9, bc_hashing_bytecode_id, bc_hashing_incremental_hash, bc_hashing_latch, bc_hashing_output_hash, bc_hashing_packed_field, bc_hashing_pc_index, bc_hashing_sel, bc_hashing_start, bc_retrieval_address, bc_retrieval_artifact_hash, bc_retrieval_bytecode_id, bc_retrieval_class_id, bc_retrieval_deployer_addr, bc_retrieval_err, bc_retrieval_incoming_viewing_key_x, bc_retrieval_incoming_viewing_key_y, bc_retrieval_init_hash, bc_retrieval_nullifier_key_x, bc_retrieval_nullifier_key_y, bc_retrieval_outgoing_viewing_key_x, bc_retrieval_outgoing_viewing_key_y, bc_retrieval_private_function_root, bc_retrieval_public_bytecode_commitment, bc_retrieval_salt, bc_retrieval_sel, bc_retrieval_siloed_address, bc_retrieval_tagging_key_x, bc_retrieval_tagging_key_y, bitwise_acc_ia, bitwise_acc_ib, bitwise_acc_ic, bitwise_ctr, bitwise_ctr_inv, bitwise_ctr_min_one_inv, bitwise_ia_byte, bitwise_ib_byte, bitwise_ic_byte, bitwise_last, bitwise_op_id, bitwise_sel, bitwise_start, bitwise_tag, class_id_derivation_artifact_hash, class_id_derivation_class_id, class_id_derivation_private_function_root, class_id_derivation_public_bytecode_commitment, class_id_derivation_sel, class_id_derivation_temp_constant_for_lookup, ecc_add_op, ecc_double_op, ecc_inv_2_p_y, ecc_inv_x_diff, ecc_inv_y_diff, ecc_lambda, ecc_p_is_inf, ecc_p_x, ecc_p_y, ecc_q_is_inf, ecc_q_x, ecc_q_y, ecc_r_is_inf, ecc_r_x, ecc_r_y, ecc_result_infinity, ecc_sel, ecc_x_match, ecc_y_match, execution_addressing_error_idx, execution_addressing_error_kind, execution_base_address_tag, execution_base_address_val, execution_bytecode_id, execution_clk, execution_ex_opcode, execution_indirect, execution_last, execution_op1, execution_op1_after_relative, execution_op2, execution_op2_after_relative, execution_op3, execution_op3_after_relative, execution_op4, execution_op4_after_relative, execution_pc, execution_rop1, execution_rop2, execution_rop3, execution_rop4, execution_sel, execution_sel_addressing_error, execution_sel_op1_is_address, execution_sel_op2_is_address, execution_sel_op3_is_address, execution_sel_op4_is_address, instr_fetching_bd0, instr_fetching_bd1, instr_fetching_bd10, instr_fetching_bd11, instr_fetching_bd12, instr_fetching_bd13, instr_fetching_bd14, instr_fetching_bd15, instr_fetching_bd16, instr_fetching_bd17, instr_fetching_bd18, instr_fetching_bd19, instr_fetching_bd2, instr_fetching_bd20, instr_fetching_bd21, instr_fetching_bd22, instr_fetching_bd23, instr_fetching_bd24, instr_fetching_bd25, instr_fetching_bd26, instr_fetching_bd27, instr_fetching_bd28, instr_fetching_bd29, instr_fetching_bd3, instr_fetching_bd30, instr_fetching_bd31, instr_fetching_bd32, instr_fetching_bd33, instr_fetching_bd34, instr_fetching_bd35, instr_fetching_bd36, instr_fetching_bd4, instr_fetching_bd5, instr_fetching_bd6, instr_fetching_bd7, instr_fetching_bd8, instr_fetching_bd9, instr_fetching_bytecode_id, instr_fetching_bytecode_size, instr_fetching_bytes_to_read, instr_fetching_exec_opcode, instr_fetching_indirect, instr_fetching_instr_abs_diff, instr_fetching_instr_out_of_range, instr_fetching_instr_size, instr_fetching_op1, instr_fetching_op2, instr_fetching_op3, instr_fetching_op4, instr_fetching_op5, instr_fetching_op6, instr_fetching_op7, instr_fetching_opcode_out_of_range, instr_fetching_parsing_err, instr_fetching_pc, instr_fetching_pc_abs_diff, instr_fetching_pc_abs_diff_hi, instr_fetching_pc_abs_diff_lo, instr_fetching_pc_out_of_range, instr_fetching_sel, instr_fetching_sel_op_dc_0, instr_fetching_sel_op_dc_1, instr_fetching_sel_op_dc_10, instr_fetching_sel_op_dc_11, instr_fetching_sel_op_dc_12, instr_fetching_sel_op_dc_13, instr_fetching_sel_op_dc_14, instr_fetching_sel_op_dc_15, instr_fetching_sel_op_dc_16, instr_fetching_sel_op_dc_17, instr_fetching_sel_op_dc_2, instr_fetching_sel_op_dc_3, instr_fetching_sel_op_dc_4, instr_fetching_sel_op_dc_5, instr_fetching_sel_op_dc_6, instr_fetching_sel_op_dc_7, instr_fetching_sel_op_dc_8, instr_fetching_sel_op_dc_9, instr_fetching_sel_opcode_defined, poseidon2_hash_a_0, poseidon2_hash_a_1, poseidon2_hash_a_2, poseidon2_hash_a_3, poseidon2_hash_b_0, poseidon2_hash_b_1, poseidon2_hash_b_2, poseidon2_hash_b_3, poseidon2_hash_end, poseidon2_hash_input_0, poseidon2_hash_input_1, poseidon2_hash_input_2, poseidon2_hash_input_len, poseidon2_hash_num_perm_rounds_rem, poseidon2_hash_num_perm_rounds_rem_inv, poseidon2_hash_output, poseidon2_hash_padding, poseidon2_hash_sel, poseidon2_hash_start, poseidon2_perm_B_10_0, poseidon2_perm_B_10_1, poseidon2_perm_B_10_2, poseidon2_perm_B_10_3, poseidon2_perm_B_11_0, poseidon2_perm_B_11_1, poseidon2_perm_B_11_2, poseidon2_perm_B_11_3, poseidon2_perm_B_12_0, poseidon2_perm_B_12_1, poseidon2_perm_B_12_2, poseidon2_perm_B_12_3, poseidon2_perm_B_13_0, poseidon2_perm_B_13_1, poseidon2_perm_B_13_2, poseidon2_perm_B_13_3, poseidon2_perm_B_14_0, poseidon2_perm_B_14_1, poseidon2_perm_B_14_2, poseidon2_perm_B_14_3, poseidon2_perm_B_15_0, poseidon2_perm_B_15_1, poseidon2_perm_B_15_2, poseidon2_perm_B_15_3, poseidon2_perm_B_16_0, poseidon2_perm_B_16_1, poseidon2_perm_B_16_2, poseidon2_perm_B_16_3, poseidon2_perm_B_17_0, poseidon2_perm_B_17_1, poseidon2_perm_B_17_2, poseidon2_perm_B_17_3, poseidon2_perm_B_18_0, poseidon2_perm_B_18_1, poseidon2_perm_B_18_2, poseidon2_perm_B_18_3, poseidon2_perm_B_19_0, poseidon2_perm_B_19_1, poseidon2_perm_B_19_2, poseidon2_perm_B_19_3, poseidon2_perm_B_20_0, poseidon2_perm_B_20_1, poseidon2_perm_B_20_2, poseidon2_perm_B_20_3, poseidon2_perm_B_21_0, poseidon2_perm_B_21_1, poseidon2_perm_B_21_2, poseidon2_perm_B_21_3, poseidon2_perm_B_22_0, poseidon2_perm_B_22_1, poseidon2_perm_B_22_2, poseidon2_perm_B_22_3, poseidon2_perm_B_23_0, poseidon2_perm_B_23_1, poseidon2_perm_B_23_2, poseidon2_perm_B_23_3, poseidon2_perm_B_24_0, poseidon2_perm_B_24_1, poseidon2_perm_B_24_2, poseidon2_perm_B_24_3, poseidon2_perm_B_25_0, poseidon2_perm_B_25_1, poseidon2_perm_B_25_2, poseidon2_perm_B_25_3, poseidon2_perm_B_26_0, poseidon2_perm_B_26_1, poseidon2_perm_B_26_2, poseidon2_perm_B_26_3, poseidon2_perm_B_27_0, poseidon2_perm_B_27_1, poseidon2_perm_B_27_2, poseidon2_perm_B_27_3, poseidon2_perm_B_28_0, poseidon2_perm_B_28_1, poseidon2_perm_B_28_2, poseidon2_perm_B_28_3, poseidon2_perm_B_29_0, poseidon2_perm_B_29_1, poseidon2_perm_B_29_2, poseidon2_perm_B_29_3, poseidon2_perm_B_30_0, poseidon2_perm_B_30_1, poseidon2_perm_B_30_2, poseidon2_perm_B_30_3, poseidon2_perm_B_31_0, poseidon2_perm_B_31_1, poseidon2_perm_B_31_2, poseidon2_perm_B_31_3, poseidon2_perm_B_32_0, poseidon2_perm_B_32_1, poseidon2_perm_B_32_2, poseidon2_perm_B_32_3, poseidon2_perm_B_33_0, poseidon2_perm_B_33_1, poseidon2_perm_B_33_2, poseidon2_perm_B_33_3, poseidon2_perm_B_34_0, poseidon2_perm_B_34_1, poseidon2_perm_B_34_2, poseidon2_perm_B_34_3, poseidon2_perm_B_35_0, poseidon2_perm_B_35_1, poseidon2_perm_B_35_2, poseidon2_perm_B_35_3, poseidon2_perm_B_36_0, poseidon2_perm_B_36_1, poseidon2_perm_B_36_2, poseidon2_perm_B_36_3, poseidon2_perm_B_37_0, poseidon2_perm_B_37_1, poseidon2_perm_B_37_2, poseidon2_perm_B_37_3, poseidon2_perm_B_38_0, poseidon2_perm_B_38_1, poseidon2_perm_B_38_2, poseidon2_perm_B_38_3, poseidon2_perm_B_39_0, poseidon2_perm_B_39_1, poseidon2_perm_B_39_2, poseidon2_perm_B_39_3, poseidon2_perm_B_40_0, poseidon2_perm_B_40_1, poseidon2_perm_B_40_2, poseidon2_perm_B_40_3, poseidon2_perm_B_41_0, poseidon2_perm_B_41_1, poseidon2_perm_B_41_2, poseidon2_perm_B_41_3, poseidon2_perm_B_42_0, poseidon2_perm_B_42_1, poseidon2_perm_B_42_2, poseidon2_perm_B_42_3, poseidon2_perm_B_43_0, poseidon2_perm_B_43_1, poseidon2_perm_B_43_2, poseidon2_perm_B_43_3, poseidon2_perm_B_44_0, poseidon2_perm_B_44_1, poseidon2_perm_B_44_2, poseidon2_perm_B_44_3, poseidon2_perm_B_45_0, poseidon2_perm_B_45_1, poseidon2_perm_B_45_2, poseidon2_perm_B_45_3, poseidon2_perm_B_46_0, poseidon2_perm_B_46_1, poseidon2_perm_B_46_2, poseidon2_perm_B_46_3, poseidon2_perm_B_47_0, poseidon2_perm_B_47_1, poseidon2_perm_B_47_2, poseidon2_perm_B_47_3, poseidon2_perm_B_48_0, poseidon2_perm_B_48_1, poseidon2_perm_B_48_2, poseidon2_perm_B_48_3, poseidon2_perm_B_49_0, poseidon2_perm_B_49_1, poseidon2_perm_B_49_2, poseidon2_perm_B_49_3, poseidon2_perm_B_4_0, poseidon2_perm_B_4_1, poseidon2_perm_B_4_2, poseidon2_perm_B_4_3, poseidon2_perm_B_50_0, poseidon2_perm_B_50_1, poseidon2_perm_B_50_2, poseidon2_perm_B_50_3, poseidon2_perm_B_51_0, poseidon2_perm_B_51_1, poseidon2_perm_B_51_2, poseidon2_perm_B_51_3, poseidon2_perm_B_52_0, poseidon2_perm_B_52_1, poseidon2_perm_B_52_2, poseidon2_perm_B_52_3, poseidon2_perm_B_53_0, poseidon2_perm_B_53_1, poseidon2_perm_B_53_2, poseidon2_perm_B_53_3, poseidon2_perm_B_54_0, poseidon2_perm_B_54_1, poseidon2_perm_B_54_2, poseidon2_perm_B_54_3, poseidon2_perm_B_55_0, poseidon2_perm_B_55_1, poseidon2_perm_B_55_2, poseidon2_perm_B_55_3, poseidon2_perm_B_56_0, poseidon2_perm_B_56_1, poseidon2_perm_B_56_2, poseidon2_perm_B_56_3, poseidon2_perm_B_57_0, poseidon2_perm_B_57_1, poseidon2_perm_B_57_2, poseidon2_perm_B_57_3, poseidon2_perm_B_58_0, poseidon2_perm_B_58_1, poseidon2_perm_B_58_2, poseidon2_perm_B_58_3, poseidon2_perm_B_59_0, poseidon2_perm_B_59_1, poseidon2_perm_B_59_2, poseidon2_perm_B_59_3, poseidon2_perm_B_5_0, poseidon2_perm_B_5_1, poseidon2_perm_B_5_2, poseidon2_perm_B_5_3, poseidon2_perm_B_6_0, poseidon2_perm_B_6_1, poseidon2_perm_B_6_2, poseidon2_perm_B_6_3, poseidon2_perm_B_7_0, poseidon2_perm_B_7_1, poseidon2_perm_B_7_2, poseidon2_perm_B_7_3, poseidon2_perm_B_8_0, poseidon2_perm_B_8_1, poseidon2_perm_B_8_2, poseidon2_perm_B_8_3, poseidon2_perm_B_9_0, poseidon2_perm_B_9_1, poseidon2_perm_B_9_2, poseidon2_perm_B_9_3, poseidon2_perm_EXT_LAYER_4, poseidon2_perm_EXT_LAYER_5, poseidon2_perm_EXT_LAYER_6, poseidon2_perm_EXT_LAYER_7, poseidon2_perm_T_0_4, poseidon2_perm_T_0_5, poseidon2_perm_T_0_6, poseidon2_perm_T_0_7, poseidon2_perm_T_1_4, poseidon2_perm_T_1_5, poseidon2_perm_T_1_6, poseidon2_perm_T_1_7, poseidon2_perm_T_2_4, poseidon2_perm_T_2_5, poseidon2_perm_T_2_6, poseidon2_perm_T_2_7, poseidon2_perm_T_3_4, poseidon2_perm_T_3_5, poseidon2_perm_T_3_6, poseidon2_perm_T_3_7, poseidon2_perm_T_60_4, poseidon2_perm_T_60_5, poseidon2_perm_T_60_6, poseidon2_perm_T_60_7, poseidon2_perm_T_61_4, poseidon2_perm_T_61_5, poseidon2_perm_T_61_6, poseidon2_perm_T_61_7, poseidon2_perm_T_62_4, poseidon2_perm_T_62_5, poseidon2_perm_T_62_6, poseidon2_perm_T_62_7, poseidon2_perm_T_63_4, poseidon2_perm_T_63_5, poseidon2_perm_T_63_6, poseidon2_perm_T_63_7, poseidon2_perm_a_0, poseidon2_perm_a_1, poseidon2_perm_a_2, poseidon2_perm_a_3, poseidon2_perm_b_0, poseidon2_perm_b_1, poseidon2_perm_b_2, poseidon2_perm_b_3, poseidon2_perm_sel, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_rng_chk_bits, range_check_sel, range_check_sel_r0_16_bit_rng_lookup, range_check_sel_r1_16_bit_rng_lookup, range_check_sel_r2_16_bit_rng_lookup, range_check_sel_r3_16_bit_rng_lookup, range_check_sel_r4_16_bit_rng_lookup, range_check_sel_r5_16_bit_rng_lookup, range_check_sel_r6_16_bit_rng_lookup, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, scalar_mul_bit, scalar_mul_bit_idx, scalar_mul_bit_radix, scalar_mul_end, scalar_mul_not_end, scalar_mul_point_inf, scalar_mul_point_x, scalar_mul_point_y, scalar_mul_res_inf, scalar_mul_res_x, scalar_mul_res_y, scalar_mul_scalar, scalar_mul_sel, scalar_mul_should_add, scalar_mul_start, scalar_mul_temp_inf, scalar_mul_temp_x, scalar_mul_temp_y, sha256_a, sha256_a_and_b, sha256_a_and_b_xor_a_and_c, sha256_a_and_c, sha256_a_rotr_13, sha256_a_rotr_2, sha256_a_rotr_22, sha256_a_rotr_2_xor_a_rotr_13, sha256_and_sel, sha256_b, sha256_b_and_c, sha256_c, sha256_ch, sha256_clk, sha256_computed_w_lhs, sha256_computed_w_rhs, sha256_d, sha256_e, sha256_e_and_f, sha256_e_rotr_11, sha256_e_rotr_25, sha256_e_rotr_6, sha256_e_rotr_6_xor_e_rotr_11, sha256_f, sha256_g, sha256_h, sha256_helper_w0, sha256_helper_w1, sha256_helper_w10, sha256_helper_w11, sha256_helper_w12, sha256_helper_w13, sha256_helper_w14, sha256_helper_w15, sha256_helper_w2, sha256_helper_w3, sha256_helper_w4, sha256_helper_w5, sha256_helper_w6, sha256_helper_w7, sha256_helper_w8, sha256_helper_w9, sha256_init_a, sha256_init_b, sha256_init_c, sha256_init_d, sha256_init_e, sha256_init_f, sha256_init_g, sha256_init_h, sha256_input_offset, sha256_is_input_round, sha256_latch, sha256_lhs_a_13, sha256_lhs_a_2, sha256_lhs_a_22, sha256_lhs_e_11, sha256_lhs_e_25, sha256_lhs_e_6, sha256_lhs_w_10, sha256_lhs_w_17, sha256_lhs_w_18, sha256_lhs_w_19, sha256_lhs_w_3, sha256_lhs_w_7, sha256_maj, sha256_next_a_lhs, sha256_next_a_rhs, sha256_next_e_lhs, sha256_next_e_rhs, sha256_not_e, sha256_not_e_and_g, sha256_output_a_lhs, sha256_output_a_rhs, sha256_output_b_lhs, sha256_output_b_rhs, sha256_output_c_lhs, sha256_output_c_rhs, sha256_output_d_lhs, sha256_output_d_rhs, sha256_output_e_lhs, sha256_output_e_rhs, sha256_output_f_lhs, sha256_output_f_rhs, sha256_output_g_lhs, sha256_output_g_rhs, sha256_output_h_lhs, sha256_output_h_rhs, sha256_output_offset, sha256_perform_round, sha256_rhs_a_13, sha256_rhs_a_2, sha256_rhs_a_22, sha256_rhs_e_11, sha256_rhs_e_25, sha256_rhs_e_6, sha256_rhs_w_10, sha256_rhs_w_17, sha256_rhs_w_18, sha256_rhs_w_19, sha256_rhs_w_3, sha256_rhs_w_7, sha256_round_constant, sha256_round_count, sha256_rounds_remaining, sha256_rounds_remaining_inv, sha256_s_0, sha256_s_1, sha256_sel, sha256_start, sha256_state_offset, sha256_w, sha256_w_15_rotr_18, sha256_w_15_rotr_7, sha256_w_15_rotr_7_xor_w_15_rotr_18, sha256_w_15_rshift_3, sha256_w_2_rotr_17, sha256_w_2_rotr_17_xor_w_2_rotr_19, sha256_w_2_rotr_19, sha256_w_2_rshift_10, sha256_w_s_0, sha256_w_s_1, sha256_xor_sel, to_radix_acc, to_radix_acc_under_p, to_radix_end, to_radix_exponent, to_radix_found, to_radix_is_unsafe_limb, to_radix_limb, to_radix_limb_eq_p, to_radix_limb_index, to_radix_limb_lt_p, to_radix_limb_p_diff, to_radix_limb_radix_diff, to_radix_not_end, to_radix_not_padding_limb, to_radix_p_limb, to_radix_radix, to_radix_rem_inverse, to_radix_safe_limbs, to_radix_safety_diff_inverse, to_radix_sel, to_radix_start, to_radix_value, lookup_poseidon2_hash_poseidon2_perm_counts, lookup_range_check_dyn_rng_chk_pow_2_counts, lookup_range_check_dyn_diff_is_u16_counts, lookup_range_check_r0_is_u16_counts, lookup_range_check_r1_is_u16_counts, lookup_range_check_r2_is_u16_counts, lookup_range_check_r3_is_u16_counts, lookup_range_check_r4_is_u16_counts, lookup_range_check_r5_is_u16_counts, lookup_range_check_r6_is_u16_counts, lookup_range_check_r7_is_u16_counts, lookup_to_radix_limb_range_counts, lookup_to_radix_limb_less_than_radix_range_counts, lookup_to_radix_fetch_safe_limbs_counts, lookup_to_radix_fetch_p_limb_counts, lookup_to_radix_limb_p_diff_range_counts, lookup_scalar_mul_to_radix_counts, lookup_scalar_mul_double_counts, lookup_scalar_mul_add_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_0_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_1_counts, lookup_address_derivation_partial_address_poseidon2_counts, lookup_address_derivation_public_keys_hash_poseidon2_0_counts, lookup_address_derivation_public_keys_hash_poseidon2_1_counts, lookup_address_derivation_public_keys_hash_poseidon2_2_counts, lookup_address_derivation_public_keys_hash_poseidon2_3_counts, lookup_address_derivation_public_keys_hash_poseidon2_4_counts, lookup_address_derivation_preaddress_poseidon2_counts, lookup_address_derivation_preaddress_scalar_mul_counts, lookup_address_derivation_address_ecadd_counts, lookup_bc_decomposition_bytes_are_bytes_counts, lookup_bc_decomposition_abs_diff_is_u16_counts, lookup_bc_decomposition_bytes_to_read_as_unary_counts, lookup_bc_hashing_get_packed_field_counts, lookup_bc_hashing_iv_is_len_counts, lookup_bc_hashing_poseidon2_hash_counts, lookup_bc_retrieval_class_id_derivation_counts, lookup_bc_retrieval_bytecode_hash_is_correct_counts, lookup_instr_fetching_instr_abs_diff_positive_counts, lookup_instr_fetching_pc_abs_diff_positive_lo_counts, lookup_instr_fetching_pc_abs_diff_positive_hi_counts, lookup_instr_fetching_bytecode_size_from_bc_dec_counts, lookup_instr_fetching_bytes_from_bc_dec_counts, lookup_instr_fetching_wire_instruction_info_counts, lookup_class_id_derivation_class_id_poseidon2_0_counts, lookup_class_id_derivation_class_id_poseidon2_1_counts, lookup_bitwise_integral_tag_length_counts, lookup_bitwise_byte_operations_counts, lookup_sha256_round_constant_counts -#define AVM2_DERIVED_WITNESS_ENTITIES lookup_poseidon2_hash_poseidon2_perm_inv, lookup_range_check_dyn_rng_chk_pow_2_inv, lookup_range_check_dyn_diff_is_u16_inv, lookup_range_check_r0_is_u16_inv, lookup_range_check_r1_is_u16_inv, lookup_range_check_r2_is_u16_inv, lookup_range_check_r3_is_u16_inv, lookup_range_check_r4_is_u16_inv, lookup_range_check_r5_is_u16_inv, lookup_range_check_r6_is_u16_inv, lookup_range_check_r7_is_u16_inv, lookup_to_radix_limb_range_inv, lookup_to_radix_limb_less_than_radix_range_inv, lookup_to_radix_fetch_safe_limbs_inv, lookup_to_radix_fetch_p_limb_inv, lookup_to_radix_limb_p_diff_range_inv, lookup_scalar_mul_to_radix_inv, lookup_scalar_mul_double_inv, lookup_scalar_mul_add_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_0_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_1_inv, lookup_address_derivation_partial_address_poseidon2_inv, lookup_address_derivation_public_keys_hash_poseidon2_0_inv, lookup_address_derivation_public_keys_hash_poseidon2_1_inv, lookup_address_derivation_public_keys_hash_poseidon2_2_inv, lookup_address_derivation_public_keys_hash_poseidon2_3_inv, lookup_address_derivation_public_keys_hash_poseidon2_4_inv, lookup_address_derivation_preaddress_poseidon2_inv, lookup_address_derivation_preaddress_scalar_mul_inv, lookup_address_derivation_address_ecadd_inv, lookup_bc_decomposition_bytes_are_bytes_inv, lookup_bc_decomposition_abs_diff_is_u16_inv, lookup_bc_decomposition_bytes_to_read_as_unary_inv, lookup_bc_hashing_get_packed_field_inv, lookup_bc_hashing_iv_is_len_inv, lookup_bc_hashing_poseidon2_hash_inv, lookup_bc_retrieval_class_id_derivation_inv, lookup_bc_retrieval_bytecode_hash_is_correct_inv, lookup_instr_fetching_instr_abs_diff_positive_inv, lookup_instr_fetching_pc_abs_diff_positive_lo_inv, lookup_instr_fetching_pc_abs_diff_positive_hi_inv, lookup_instr_fetching_bytecode_size_from_bc_dec_inv, lookup_instr_fetching_bytes_from_bc_dec_inv, lookup_instr_fetching_wire_instruction_info_inv, lookup_class_id_derivation_class_id_poseidon2_0_inv, lookup_class_id_derivation_class_id_poseidon2_1_inv, lookup_bitwise_integral_tag_length_inv, lookup_bitwise_byte_operations_inv, lookup_sha256_round_constant_inv +#define AVM2_PRECOMPUTED_ENTITIES precomputed_as_unary, precomputed_bitwise_input_a, precomputed_bitwise_input_b, precomputed_bitwise_op_id, precomputed_bitwise_output, precomputed_clk, precomputed_exec_opcode, precomputed_first_row, precomputed_instr_size, precomputed_integral_tag_length, precomputed_opcode_out_of_range, precomputed_p_decomposition_limb, precomputed_p_decomposition_limb_index, precomputed_p_decomposition_radix, precomputed_power_of_2, precomputed_sel_bitwise, precomputed_sel_integral_tag, precomputed_sel_op_dc_0, precomputed_sel_op_dc_1, precomputed_sel_op_dc_10, precomputed_sel_op_dc_11, precomputed_sel_op_dc_12, precomputed_sel_op_dc_13, precomputed_sel_op_dc_14, precomputed_sel_op_dc_15, precomputed_sel_op_dc_16, precomputed_sel_op_dc_17, precomputed_sel_op_dc_2, precomputed_sel_op_dc_3, precomputed_sel_op_dc_4, precomputed_sel_op_dc_5, precomputed_sel_op_dc_6, precomputed_sel_op_dc_7, precomputed_sel_op_dc_8, precomputed_sel_op_dc_9, precomputed_sel_p_decomposition, precomputed_sel_range_16, precomputed_sel_range_8, precomputed_sel_sha256_compression, precomputed_sel_to_radix_safe_limbs, precomputed_sel_unary, precomputed_sha256_compression_round_constant, precomputed_thirty_two, precomputed_to_radix_safe_limbs, precomputed_zero +#define AVM2_WIRE_ENTITIES execution_input, address_derivation_address, address_derivation_address_y, address_derivation_class_id, address_derivation_deployer_addr, address_derivation_g1_x, address_derivation_g1_y, address_derivation_incoming_viewing_key_x, address_derivation_incoming_viewing_key_y, address_derivation_init_hash, address_derivation_nullifier_key_x, address_derivation_nullifier_key_y, address_derivation_outgoing_viewing_key_x, address_derivation_outgoing_viewing_key_y, address_derivation_partial_address, address_derivation_partial_address_domain_separator, address_derivation_preaddress, address_derivation_preaddress_domain_separator, address_derivation_preaddress_public_key_x, address_derivation_preaddress_public_key_y, address_derivation_public_keys_hash, address_derivation_public_keys_hash_domain_separator, address_derivation_salt, address_derivation_salted_init_hash, address_derivation_sel, address_derivation_tagging_key_x, address_derivation_tagging_key_y, alu_dst_addr, alu_ia, alu_ia_addr, alu_ib, alu_ib_addr, alu_ic, alu_op, alu_sel_op_add, bc_decomposition_abs_diff, bc_decomposition_bytes, bc_decomposition_bytes_pc_plus_1, bc_decomposition_bytes_pc_plus_10, bc_decomposition_bytes_pc_plus_11, bc_decomposition_bytes_pc_plus_12, bc_decomposition_bytes_pc_plus_13, bc_decomposition_bytes_pc_plus_14, bc_decomposition_bytes_pc_plus_15, bc_decomposition_bytes_pc_plus_16, bc_decomposition_bytes_pc_plus_17, bc_decomposition_bytes_pc_plus_18, bc_decomposition_bytes_pc_plus_19, bc_decomposition_bytes_pc_plus_2, bc_decomposition_bytes_pc_plus_20, bc_decomposition_bytes_pc_plus_21, bc_decomposition_bytes_pc_plus_22, bc_decomposition_bytes_pc_plus_23, bc_decomposition_bytes_pc_plus_24, bc_decomposition_bytes_pc_plus_25, bc_decomposition_bytes_pc_plus_26, bc_decomposition_bytes_pc_plus_27, bc_decomposition_bytes_pc_plus_28, bc_decomposition_bytes_pc_plus_29, bc_decomposition_bytes_pc_plus_3, bc_decomposition_bytes_pc_plus_30, bc_decomposition_bytes_pc_plus_31, bc_decomposition_bytes_pc_plus_32, bc_decomposition_bytes_pc_plus_33, bc_decomposition_bytes_pc_plus_34, bc_decomposition_bytes_pc_plus_35, bc_decomposition_bytes_pc_plus_36, bc_decomposition_bytes_pc_plus_4, bc_decomposition_bytes_pc_plus_5, bc_decomposition_bytes_pc_plus_6, bc_decomposition_bytes_pc_plus_7, bc_decomposition_bytes_pc_plus_8, bc_decomposition_bytes_pc_plus_9, bc_decomposition_bytes_rem_inv, bc_decomposition_bytes_rem_min_one_inv, bc_decomposition_bytes_remaining, bc_decomposition_bytes_to_read, bc_decomposition_bytes_to_read_unary, bc_decomposition_id, bc_decomposition_last_of_contract, bc_decomposition_packed_field, bc_decomposition_pc, bc_decomposition_sel, bc_decomposition_sel_overflow_correction_needed, bc_decomposition_sel_packed, bc_decomposition_sel_pc_plus_1, bc_decomposition_sel_pc_plus_10, bc_decomposition_sel_pc_plus_11, bc_decomposition_sel_pc_plus_12, bc_decomposition_sel_pc_plus_13, bc_decomposition_sel_pc_plus_14, bc_decomposition_sel_pc_plus_15, bc_decomposition_sel_pc_plus_16, bc_decomposition_sel_pc_plus_17, bc_decomposition_sel_pc_plus_18, bc_decomposition_sel_pc_plus_19, bc_decomposition_sel_pc_plus_2, bc_decomposition_sel_pc_plus_20, bc_decomposition_sel_pc_plus_21, bc_decomposition_sel_pc_plus_22, bc_decomposition_sel_pc_plus_23, bc_decomposition_sel_pc_plus_24, bc_decomposition_sel_pc_plus_25, bc_decomposition_sel_pc_plus_26, bc_decomposition_sel_pc_plus_27, bc_decomposition_sel_pc_plus_28, bc_decomposition_sel_pc_plus_29, bc_decomposition_sel_pc_plus_3, bc_decomposition_sel_pc_plus_30, bc_decomposition_sel_pc_plus_31, bc_decomposition_sel_pc_plus_32, bc_decomposition_sel_pc_plus_33, bc_decomposition_sel_pc_plus_34, bc_decomposition_sel_pc_plus_35, bc_decomposition_sel_pc_plus_36, bc_decomposition_sel_pc_plus_4, bc_decomposition_sel_pc_plus_5, bc_decomposition_sel_pc_plus_6, bc_decomposition_sel_pc_plus_7, bc_decomposition_sel_pc_plus_8, bc_decomposition_sel_pc_plus_9, bc_hashing_bytecode_id, bc_hashing_incremental_hash, bc_hashing_latch, bc_hashing_output_hash, bc_hashing_packed_field, bc_hashing_pc_index, bc_hashing_sel, bc_hashing_start, bc_retrieval_address, bc_retrieval_artifact_hash, bc_retrieval_bytecode_id, bc_retrieval_class_id, bc_retrieval_deployer_addr, bc_retrieval_err, bc_retrieval_incoming_viewing_key_x, bc_retrieval_incoming_viewing_key_y, bc_retrieval_init_hash, bc_retrieval_nullifier_key_x, bc_retrieval_nullifier_key_y, bc_retrieval_outgoing_viewing_key_x, bc_retrieval_outgoing_viewing_key_y, bc_retrieval_private_function_root, bc_retrieval_public_bytecode_commitment, bc_retrieval_salt, bc_retrieval_sel, bc_retrieval_siloed_address, bc_retrieval_tagging_key_x, bc_retrieval_tagging_key_y, bitwise_acc_ia, bitwise_acc_ib, bitwise_acc_ic, bitwise_ctr, bitwise_ctr_inv, bitwise_ctr_min_one_inv, bitwise_ia_byte, bitwise_ib_byte, bitwise_ic_byte, bitwise_last, bitwise_op_id, bitwise_sel, bitwise_start, bitwise_tag, class_id_derivation_artifact_hash, class_id_derivation_class_id, class_id_derivation_private_function_root, class_id_derivation_public_bytecode_commitment, class_id_derivation_sel, class_id_derivation_temp_constant_for_lookup, ecc_add_op, ecc_double_op, ecc_inv_2_p_y, ecc_inv_x_diff, ecc_inv_y_diff, ecc_lambda, ecc_p_is_inf, ecc_p_x, ecc_p_y, ecc_q_is_inf, ecc_q_x, ecc_q_y, ecc_r_is_inf, ecc_r_x, ecc_r_y, ecc_result_infinity, ecc_sel, ecc_x_match, ecc_y_match, execution_addressing_error_idx, execution_addressing_error_kind, execution_base_address_tag, execution_base_address_val, execution_bytecode_id, execution_clk, execution_ex_opcode, execution_indirect, execution_last, execution_op1, execution_op1_after_relative, execution_op2, execution_op2_after_relative, execution_op3, execution_op3_after_relative, execution_op4, execution_op4_after_relative, execution_pc, execution_rop1, execution_rop2, execution_rop3, execution_rop4, execution_sel, execution_sel_addressing_error, execution_sel_op1_is_address, execution_sel_op2_is_address, execution_sel_op3_is_address, execution_sel_op4_is_address, instr_fetching_bd0, instr_fetching_bd1, instr_fetching_bd10, instr_fetching_bd11, instr_fetching_bd12, instr_fetching_bd13, instr_fetching_bd14, instr_fetching_bd15, instr_fetching_bd16, instr_fetching_bd17, instr_fetching_bd18, instr_fetching_bd19, instr_fetching_bd2, instr_fetching_bd20, instr_fetching_bd21, instr_fetching_bd22, instr_fetching_bd23, instr_fetching_bd24, instr_fetching_bd25, instr_fetching_bd26, instr_fetching_bd27, instr_fetching_bd28, instr_fetching_bd29, instr_fetching_bd3, instr_fetching_bd30, instr_fetching_bd31, instr_fetching_bd32, instr_fetching_bd33, instr_fetching_bd34, instr_fetching_bd35, instr_fetching_bd36, instr_fetching_bd4, instr_fetching_bd5, instr_fetching_bd6, instr_fetching_bd7, instr_fetching_bd8, instr_fetching_bd9, instr_fetching_bytecode_id, instr_fetching_bytecode_size, instr_fetching_bytes_to_read, instr_fetching_exec_opcode, instr_fetching_indirect, instr_fetching_instr_abs_diff, instr_fetching_instr_out_of_range, instr_fetching_instr_size, instr_fetching_op1, instr_fetching_op2, instr_fetching_op3, instr_fetching_op4, instr_fetching_op5, instr_fetching_op6, instr_fetching_op7, instr_fetching_opcode_out_of_range, instr_fetching_parsing_err, instr_fetching_pc, instr_fetching_pc_abs_diff, instr_fetching_pc_out_of_range, instr_fetching_sel, instr_fetching_sel_op_dc_0, instr_fetching_sel_op_dc_1, instr_fetching_sel_op_dc_10, instr_fetching_sel_op_dc_11, instr_fetching_sel_op_dc_12, instr_fetching_sel_op_dc_13, instr_fetching_sel_op_dc_14, instr_fetching_sel_op_dc_15, instr_fetching_sel_op_dc_16, instr_fetching_sel_op_dc_17, instr_fetching_sel_op_dc_2, instr_fetching_sel_op_dc_3, instr_fetching_sel_op_dc_4, instr_fetching_sel_op_dc_5, instr_fetching_sel_op_dc_6, instr_fetching_sel_op_dc_7, instr_fetching_sel_op_dc_8, instr_fetching_sel_op_dc_9, instr_fetching_sel_opcode_defined, poseidon2_hash_a_0, poseidon2_hash_a_1, poseidon2_hash_a_2, poseidon2_hash_a_3, poseidon2_hash_b_0, poseidon2_hash_b_1, poseidon2_hash_b_2, poseidon2_hash_b_3, poseidon2_hash_end, poseidon2_hash_input_0, poseidon2_hash_input_1, poseidon2_hash_input_2, poseidon2_hash_input_len, poseidon2_hash_num_perm_rounds_rem, poseidon2_hash_num_perm_rounds_rem_inv, poseidon2_hash_output, poseidon2_hash_padding, poseidon2_hash_sel, poseidon2_hash_start, poseidon2_perm_B_10_0, poseidon2_perm_B_10_1, poseidon2_perm_B_10_2, poseidon2_perm_B_10_3, poseidon2_perm_B_11_0, poseidon2_perm_B_11_1, poseidon2_perm_B_11_2, poseidon2_perm_B_11_3, poseidon2_perm_B_12_0, poseidon2_perm_B_12_1, poseidon2_perm_B_12_2, poseidon2_perm_B_12_3, poseidon2_perm_B_13_0, poseidon2_perm_B_13_1, poseidon2_perm_B_13_2, poseidon2_perm_B_13_3, poseidon2_perm_B_14_0, poseidon2_perm_B_14_1, poseidon2_perm_B_14_2, poseidon2_perm_B_14_3, poseidon2_perm_B_15_0, poseidon2_perm_B_15_1, poseidon2_perm_B_15_2, poseidon2_perm_B_15_3, poseidon2_perm_B_16_0, poseidon2_perm_B_16_1, poseidon2_perm_B_16_2, poseidon2_perm_B_16_3, poseidon2_perm_B_17_0, poseidon2_perm_B_17_1, poseidon2_perm_B_17_2, poseidon2_perm_B_17_3, poseidon2_perm_B_18_0, poseidon2_perm_B_18_1, poseidon2_perm_B_18_2, poseidon2_perm_B_18_3, poseidon2_perm_B_19_0, poseidon2_perm_B_19_1, poseidon2_perm_B_19_2, poseidon2_perm_B_19_3, poseidon2_perm_B_20_0, poseidon2_perm_B_20_1, poseidon2_perm_B_20_2, poseidon2_perm_B_20_3, poseidon2_perm_B_21_0, poseidon2_perm_B_21_1, poseidon2_perm_B_21_2, poseidon2_perm_B_21_3, poseidon2_perm_B_22_0, poseidon2_perm_B_22_1, poseidon2_perm_B_22_2, poseidon2_perm_B_22_3, poseidon2_perm_B_23_0, poseidon2_perm_B_23_1, poseidon2_perm_B_23_2, poseidon2_perm_B_23_3, poseidon2_perm_B_24_0, poseidon2_perm_B_24_1, poseidon2_perm_B_24_2, poseidon2_perm_B_24_3, poseidon2_perm_B_25_0, poseidon2_perm_B_25_1, poseidon2_perm_B_25_2, poseidon2_perm_B_25_3, poseidon2_perm_B_26_0, poseidon2_perm_B_26_1, poseidon2_perm_B_26_2, poseidon2_perm_B_26_3, poseidon2_perm_B_27_0, poseidon2_perm_B_27_1, poseidon2_perm_B_27_2, poseidon2_perm_B_27_3, poseidon2_perm_B_28_0, poseidon2_perm_B_28_1, poseidon2_perm_B_28_2, poseidon2_perm_B_28_3, poseidon2_perm_B_29_0, poseidon2_perm_B_29_1, poseidon2_perm_B_29_2, poseidon2_perm_B_29_3, poseidon2_perm_B_30_0, poseidon2_perm_B_30_1, poseidon2_perm_B_30_2, poseidon2_perm_B_30_3, poseidon2_perm_B_31_0, poseidon2_perm_B_31_1, poseidon2_perm_B_31_2, poseidon2_perm_B_31_3, poseidon2_perm_B_32_0, poseidon2_perm_B_32_1, poseidon2_perm_B_32_2, poseidon2_perm_B_32_3, poseidon2_perm_B_33_0, poseidon2_perm_B_33_1, poseidon2_perm_B_33_2, poseidon2_perm_B_33_3, poseidon2_perm_B_34_0, poseidon2_perm_B_34_1, poseidon2_perm_B_34_2, poseidon2_perm_B_34_3, poseidon2_perm_B_35_0, poseidon2_perm_B_35_1, poseidon2_perm_B_35_2, poseidon2_perm_B_35_3, poseidon2_perm_B_36_0, poseidon2_perm_B_36_1, poseidon2_perm_B_36_2, poseidon2_perm_B_36_3, poseidon2_perm_B_37_0, poseidon2_perm_B_37_1, poseidon2_perm_B_37_2, poseidon2_perm_B_37_3, poseidon2_perm_B_38_0, poseidon2_perm_B_38_1, poseidon2_perm_B_38_2, poseidon2_perm_B_38_3, poseidon2_perm_B_39_0, poseidon2_perm_B_39_1, poseidon2_perm_B_39_2, poseidon2_perm_B_39_3, poseidon2_perm_B_40_0, poseidon2_perm_B_40_1, poseidon2_perm_B_40_2, poseidon2_perm_B_40_3, poseidon2_perm_B_41_0, poseidon2_perm_B_41_1, poseidon2_perm_B_41_2, poseidon2_perm_B_41_3, poseidon2_perm_B_42_0, poseidon2_perm_B_42_1, poseidon2_perm_B_42_2, poseidon2_perm_B_42_3, poseidon2_perm_B_43_0, poseidon2_perm_B_43_1, poseidon2_perm_B_43_2, poseidon2_perm_B_43_3, poseidon2_perm_B_44_0, poseidon2_perm_B_44_1, poseidon2_perm_B_44_2, poseidon2_perm_B_44_3, poseidon2_perm_B_45_0, poseidon2_perm_B_45_1, poseidon2_perm_B_45_2, poseidon2_perm_B_45_3, poseidon2_perm_B_46_0, poseidon2_perm_B_46_1, poseidon2_perm_B_46_2, poseidon2_perm_B_46_3, poseidon2_perm_B_47_0, poseidon2_perm_B_47_1, poseidon2_perm_B_47_2, poseidon2_perm_B_47_3, poseidon2_perm_B_48_0, poseidon2_perm_B_48_1, poseidon2_perm_B_48_2, poseidon2_perm_B_48_3, poseidon2_perm_B_49_0, poseidon2_perm_B_49_1, poseidon2_perm_B_49_2, poseidon2_perm_B_49_3, poseidon2_perm_B_4_0, poseidon2_perm_B_4_1, poseidon2_perm_B_4_2, poseidon2_perm_B_4_3, poseidon2_perm_B_50_0, poseidon2_perm_B_50_1, poseidon2_perm_B_50_2, poseidon2_perm_B_50_3, poseidon2_perm_B_51_0, poseidon2_perm_B_51_1, poseidon2_perm_B_51_2, poseidon2_perm_B_51_3, poseidon2_perm_B_52_0, poseidon2_perm_B_52_1, poseidon2_perm_B_52_2, poseidon2_perm_B_52_3, poseidon2_perm_B_53_0, poseidon2_perm_B_53_1, poseidon2_perm_B_53_2, poseidon2_perm_B_53_3, poseidon2_perm_B_54_0, poseidon2_perm_B_54_1, poseidon2_perm_B_54_2, poseidon2_perm_B_54_3, poseidon2_perm_B_55_0, poseidon2_perm_B_55_1, poseidon2_perm_B_55_2, poseidon2_perm_B_55_3, poseidon2_perm_B_56_0, poseidon2_perm_B_56_1, poseidon2_perm_B_56_2, poseidon2_perm_B_56_3, poseidon2_perm_B_57_0, poseidon2_perm_B_57_1, poseidon2_perm_B_57_2, poseidon2_perm_B_57_3, poseidon2_perm_B_58_0, poseidon2_perm_B_58_1, poseidon2_perm_B_58_2, poseidon2_perm_B_58_3, poseidon2_perm_B_59_0, poseidon2_perm_B_59_1, poseidon2_perm_B_59_2, poseidon2_perm_B_59_3, poseidon2_perm_B_5_0, poseidon2_perm_B_5_1, poseidon2_perm_B_5_2, poseidon2_perm_B_5_3, poseidon2_perm_B_6_0, poseidon2_perm_B_6_1, poseidon2_perm_B_6_2, poseidon2_perm_B_6_3, poseidon2_perm_B_7_0, poseidon2_perm_B_7_1, poseidon2_perm_B_7_2, poseidon2_perm_B_7_3, poseidon2_perm_B_8_0, poseidon2_perm_B_8_1, poseidon2_perm_B_8_2, poseidon2_perm_B_8_3, poseidon2_perm_B_9_0, poseidon2_perm_B_9_1, poseidon2_perm_B_9_2, poseidon2_perm_B_9_3, poseidon2_perm_EXT_LAYER_4, poseidon2_perm_EXT_LAYER_5, poseidon2_perm_EXT_LAYER_6, poseidon2_perm_EXT_LAYER_7, poseidon2_perm_T_0_4, poseidon2_perm_T_0_5, poseidon2_perm_T_0_6, poseidon2_perm_T_0_7, poseidon2_perm_T_1_4, poseidon2_perm_T_1_5, poseidon2_perm_T_1_6, poseidon2_perm_T_1_7, poseidon2_perm_T_2_4, poseidon2_perm_T_2_5, poseidon2_perm_T_2_6, poseidon2_perm_T_2_7, poseidon2_perm_T_3_4, poseidon2_perm_T_3_5, poseidon2_perm_T_3_6, poseidon2_perm_T_3_7, poseidon2_perm_T_60_4, poseidon2_perm_T_60_5, poseidon2_perm_T_60_6, poseidon2_perm_T_60_7, poseidon2_perm_T_61_4, poseidon2_perm_T_61_5, poseidon2_perm_T_61_6, poseidon2_perm_T_61_7, poseidon2_perm_T_62_4, poseidon2_perm_T_62_5, poseidon2_perm_T_62_6, poseidon2_perm_T_62_7, poseidon2_perm_T_63_4, poseidon2_perm_T_63_5, poseidon2_perm_T_63_6, poseidon2_perm_T_63_7, poseidon2_perm_a_0, poseidon2_perm_a_1, poseidon2_perm_a_2, poseidon2_perm_a_3, poseidon2_perm_b_0, poseidon2_perm_b_1, poseidon2_perm_b_2, poseidon2_perm_b_3, poseidon2_perm_sel, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_rng_chk_bits, range_check_sel, range_check_sel_r0_16_bit_rng_lookup, range_check_sel_r1_16_bit_rng_lookup, range_check_sel_r2_16_bit_rng_lookup, range_check_sel_r3_16_bit_rng_lookup, range_check_sel_r4_16_bit_rng_lookup, range_check_sel_r5_16_bit_rng_lookup, range_check_sel_r6_16_bit_rng_lookup, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, scalar_mul_bit, scalar_mul_bit_idx, scalar_mul_bit_radix, scalar_mul_end, scalar_mul_not_end, scalar_mul_point_inf, scalar_mul_point_x, scalar_mul_point_y, scalar_mul_res_inf, scalar_mul_res_x, scalar_mul_res_y, scalar_mul_scalar, scalar_mul_sel, scalar_mul_should_add, scalar_mul_start, scalar_mul_temp_inf, scalar_mul_temp_x, scalar_mul_temp_y, sha256_a, sha256_a_and_b, sha256_a_and_b_xor_a_and_c, sha256_a_and_c, sha256_a_rotr_13, sha256_a_rotr_2, sha256_a_rotr_22, sha256_a_rotr_2_xor_a_rotr_13, sha256_and_sel, sha256_b, sha256_b_and_c, sha256_c, sha256_ch, sha256_clk, sha256_computed_w_lhs, sha256_computed_w_rhs, sha256_d, sha256_e, sha256_e_and_f, sha256_e_rotr_11, sha256_e_rotr_25, sha256_e_rotr_6, sha256_e_rotr_6_xor_e_rotr_11, sha256_f, sha256_g, sha256_h, sha256_helper_w0, sha256_helper_w1, sha256_helper_w10, sha256_helper_w11, sha256_helper_w12, sha256_helper_w13, sha256_helper_w14, sha256_helper_w15, sha256_helper_w2, sha256_helper_w3, sha256_helper_w4, sha256_helper_w5, sha256_helper_w6, sha256_helper_w7, sha256_helper_w8, sha256_helper_w9, sha256_init_a, sha256_init_b, sha256_init_c, sha256_init_d, sha256_init_e, sha256_init_f, sha256_init_g, sha256_init_h, sha256_input_offset, sha256_is_input_round, sha256_latch, sha256_lhs_a_13, sha256_lhs_a_2, sha256_lhs_a_22, sha256_lhs_e_11, sha256_lhs_e_25, sha256_lhs_e_6, sha256_lhs_w_10, sha256_lhs_w_17, sha256_lhs_w_18, sha256_lhs_w_19, sha256_lhs_w_3, sha256_lhs_w_7, sha256_maj, sha256_next_a_lhs, sha256_next_a_rhs, sha256_next_e_lhs, sha256_next_e_rhs, sha256_not_e, sha256_not_e_and_g, sha256_output_a_lhs, sha256_output_a_rhs, sha256_output_b_lhs, sha256_output_b_rhs, sha256_output_c_lhs, sha256_output_c_rhs, sha256_output_d_lhs, sha256_output_d_rhs, sha256_output_e_lhs, sha256_output_e_rhs, sha256_output_f_lhs, sha256_output_f_rhs, sha256_output_g_lhs, sha256_output_g_rhs, sha256_output_h_lhs, sha256_output_h_rhs, sha256_output_offset, sha256_perform_round, sha256_rhs_a_13, sha256_rhs_a_2, sha256_rhs_a_22, sha256_rhs_e_11, sha256_rhs_e_25, sha256_rhs_e_6, sha256_rhs_w_10, sha256_rhs_w_17, sha256_rhs_w_18, sha256_rhs_w_19, sha256_rhs_w_3, sha256_rhs_w_7, sha256_round_constant, sha256_round_count, sha256_rounds_remaining, sha256_rounds_remaining_inv, sha256_s_0, sha256_s_1, sha256_sel, sha256_start, sha256_state_offset, sha256_w, sha256_w_15_rotr_18, sha256_w_15_rotr_7, sha256_w_15_rotr_7_xor_w_15_rotr_18, sha256_w_15_rshift_3, sha256_w_2_rotr_17, sha256_w_2_rotr_17_xor_w_2_rotr_19, sha256_w_2_rotr_19, sha256_w_2_rshift_10, sha256_w_s_0, sha256_w_s_1, sha256_xor_sel, to_radix_acc, to_radix_acc_under_p, to_radix_end, to_radix_exponent, to_radix_found, to_radix_is_unsafe_limb, to_radix_limb, to_radix_limb_eq_p, to_radix_limb_index, to_radix_limb_lt_p, to_radix_limb_p_diff, to_radix_limb_radix_diff, to_radix_not_end, to_radix_not_padding_limb, to_radix_p_limb, to_radix_radix, to_radix_rem_inverse, to_radix_safe_limbs, to_radix_safety_diff_inverse, to_radix_sel, to_radix_start, to_radix_value, lookup_poseidon2_hash_poseidon2_perm_counts, lookup_range_check_dyn_rng_chk_pow_2_counts, lookup_range_check_dyn_diff_is_u16_counts, lookup_range_check_r0_is_u16_counts, lookup_range_check_r1_is_u16_counts, lookup_range_check_r2_is_u16_counts, lookup_range_check_r3_is_u16_counts, lookup_range_check_r4_is_u16_counts, lookup_range_check_r5_is_u16_counts, lookup_range_check_r6_is_u16_counts, lookup_range_check_r7_is_u16_counts, lookup_to_radix_limb_range_counts, lookup_to_radix_limb_less_than_radix_range_counts, lookup_to_radix_fetch_safe_limbs_counts, lookup_to_radix_fetch_p_limb_counts, lookup_to_radix_limb_p_diff_range_counts, lookup_scalar_mul_to_radix_counts, lookup_scalar_mul_double_counts, lookup_scalar_mul_add_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_0_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_1_counts, lookup_address_derivation_partial_address_poseidon2_counts, lookup_address_derivation_public_keys_hash_poseidon2_0_counts, lookup_address_derivation_public_keys_hash_poseidon2_1_counts, lookup_address_derivation_public_keys_hash_poseidon2_2_counts, lookup_address_derivation_public_keys_hash_poseidon2_3_counts, lookup_address_derivation_public_keys_hash_poseidon2_4_counts, lookup_address_derivation_preaddress_poseidon2_counts, lookup_address_derivation_preaddress_scalar_mul_counts, lookup_address_derivation_address_ecadd_counts, lookup_bc_decomposition_bytes_are_bytes_counts, lookup_bc_decomposition_abs_diff_is_u16_counts, lookup_bc_decomposition_bytes_to_read_as_unary_counts, lookup_bc_hashing_get_packed_field_counts, lookup_bc_hashing_iv_is_len_counts, lookup_bc_hashing_poseidon2_hash_counts, lookup_bc_retrieval_class_id_derivation_counts, lookup_bc_retrieval_bytecode_hash_is_correct_counts, lookup_instr_fetching_instr_abs_diff_positive_counts, lookup_instr_fetching_pc_abs_diff_positive_counts, lookup_instr_fetching_bytecode_size_from_bc_dec_counts, lookup_instr_fetching_bytes_from_bc_dec_counts, lookup_instr_fetching_wire_instruction_info_counts, lookup_class_id_derivation_class_id_poseidon2_0_counts, lookup_class_id_derivation_class_id_poseidon2_1_counts, lookup_bitwise_integral_tag_length_counts, lookup_bitwise_byte_operations_counts, lookup_sha256_round_constant_counts +#define AVM2_DERIVED_WITNESS_ENTITIES lookup_poseidon2_hash_poseidon2_perm_inv, lookup_range_check_dyn_rng_chk_pow_2_inv, lookup_range_check_dyn_diff_is_u16_inv, lookup_range_check_r0_is_u16_inv, lookup_range_check_r1_is_u16_inv, lookup_range_check_r2_is_u16_inv, lookup_range_check_r3_is_u16_inv, lookup_range_check_r4_is_u16_inv, lookup_range_check_r5_is_u16_inv, lookup_range_check_r6_is_u16_inv, lookup_range_check_r7_is_u16_inv, lookup_to_radix_limb_range_inv, lookup_to_radix_limb_less_than_radix_range_inv, lookup_to_radix_fetch_safe_limbs_inv, lookup_to_radix_fetch_p_limb_inv, lookup_to_radix_limb_p_diff_range_inv, lookup_scalar_mul_to_radix_inv, lookup_scalar_mul_double_inv, lookup_scalar_mul_add_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_0_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_1_inv, lookup_address_derivation_partial_address_poseidon2_inv, lookup_address_derivation_public_keys_hash_poseidon2_0_inv, lookup_address_derivation_public_keys_hash_poseidon2_1_inv, lookup_address_derivation_public_keys_hash_poseidon2_2_inv, lookup_address_derivation_public_keys_hash_poseidon2_3_inv, lookup_address_derivation_public_keys_hash_poseidon2_4_inv, lookup_address_derivation_preaddress_poseidon2_inv, lookup_address_derivation_preaddress_scalar_mul_inv, lookup_address_derivation_address_ecadd_inv, lookup_bc_decomposition_bytes_are_bytes_inv, lookup_bc_decomposition_abs_diff_is_u16_inv, lookup_bc_decomposition_bytes_to_read_as_unary_inv, lookup_bc_hashing_get_packed_field_inv, lookup_bc_hashing_iv_is_len_inv, lookup_bc_hashing_poseidon2_hash_inv, lookup_bc_retrieval_class_id_derivation_inv, lookup_bc_retrieval_bytecode_hash_is_correct_inv, lookup_instr_fetching_instr_abs_diff_positive_inv, lookup_instr_fetching_pc_abs_diff_positive_inv, lookup_instr_fetching_bytecode_size_from_bc_dec_inv, lookup_instr_fetching_bytes_from_bc_dec_inv, lookup_instr_fetching_wire_instruction_info_inv, lookup_class_id_derivation_class_id_poseidon2_0_inv, lookup_class_id_derivation_class_id_poseidon2_1_inv, lookup_bitwise_integral_tag_length_inv, lookup_bitwise_byte_operations_inv, lookup_sha256_round_constant_inv #define AVM2_SHIFTED_ENTITIES bc_decomposition_bytes_shift, bc_decomposition_bytes_pc_plus_1_shift, bc_decomposition_bytes_pc_plus_10_shift, bc_decomposition_bytes_pc_plus_11_shift, bc_decomposition_bytes_pc_plus_12_shift, bc_decomposition_bytes_pc_plus_13_shift, bc_decomposition_bytes_pc_plus_14_shift, bc_decomposition_bytes_pc_plus_15_shift, bc_decomposition_bytes_pc_plus_16_shift, bc_decomposition_bytes_pc_plus_17_shift, bc_decomposition_bytes_pc_plus_18_shift, bc_decomposition_bytes_pc_plus_19_shift, bc_decomposition_bytes_pc_plus_2_shift, bc_decomposition_bytes_pc_plus_20_shift, bc_decomposition_bytes_pc_plus_21_shift, bc_decomposition_bytes_pc_plus_22_shift, bc_decomposition_bytes_pc_plus_23_shift, bc_decomposition_bytes_pc_plus_24_shift, bc_decomposition_bytes_pc_plus_25_shift, bc_decomposition_bytes_pc_plus_26_shift, bc_decomposition_bytes_pc_plus_27_shift, bc_decomposition_bytes_pc_plus_28_shift, bc_decomposition_bytes_pc_plus_29_shift, bc_decomposition_bytes_pc_plus_3_shift, bc_decomposition_bytes_pc_plus_30_shift, bc_decomposition_bytes_pc_plus_31_shift, bc_decomposition_bytes_pc_plus_32_shift, bc_decomposition_bytes_pc_plus_33_shift, bc_decomposition_bytes_pc_plus_34_shift, bc_decomposition_bytes_pc_plus_35_shift, bc_decomposition_bytes_pc_plus_4_shift, bc_decomposition_bytes_pc_plus_5_shift, bc_decomposition_bytes_pc_plus_6_shift, bc_decomposition_bytes_pc_plus_7_shift, bc_decomposition_bytes_pc_plus_8_shift, bc_decomposition_bytes_pc_plus_9_shift, bc_decomposition_bytes_remaining_shift, bc_decomposition_id_shift, bc_decomposition_pc_shift, bc_decomposition_sel_shift, bc_hashing_bytecode_id_shift, bc_hashing_incremental_hash_shift, bc_hashing_pc_index_shift, bc_hashing_sel_shift, bc_hashing_start_shift, bitwise_acc_ia_shift, bitwise_acc_ib_shift, bitwise_acc_ic_shift, bitwise_ctr_shift, bitwise_op_id_shift, execution_sel_shift, poseidon2_hash_a_0_shift, poseidon2_hash_a_1_shift, poseidon2_hash_a_2_shift, poseidon2_hash_a_3_shift, poseidon2_hash_input_0_shift, poseidon2_hash_input_1_shift, poseidon2_hash_input_2_shift, poseidon2_hash_num_perm_rounds_rem_shift, poseidon2_hash_output_shift, poseidon2_hash_sel_shift, poseidon2_hash_start_shift, scalar_mul_bit_idx_shift, scalar_mul_point_inf_shift, scalar_mul_point_x_shift, scalar_mul_point_y_shift, scalar_mul_res_inf_shift, scalar_mul_res_x_shift, scalar_mul_res_y_shift, scalar_mul_scalar_shift, scalar_mul_sel_shift, scalar_mul_start_shift, scalar_mul_temp_inf_shift, scalar_mul_temp_x_shift, scalar_mul_temp_y_shift, sha256_a_shift, sha256_b_shift, sha256_c_shift, sha256_d_shift, sha256_e_shift, sha256_f_shift, sha256_g_shift, sha256_h_shift, sha256_helper_w0_shift, sha256_helper_w1_shift, sha256_helper_w10_shift, sha256_helper_w11_shift, sha256_helper_w12_shift, sha256_helper_w13_shift, sha256_helper_w14_shift, sha256_helper_w15_shift, sha256_helper_w2_shift, sha256_helper_w3_shift, sha256_helper_w4_shift, sha256_helper_w5_shift, sha256_helper_w6_shift, sha256_helper_w7_shift, sha256_helper_w8_shift, sha256_helper_w9_shift, sha256_rounds_remaining_shift, sha256_sel_shift, sha256_start_shift, to_radix_acc_shift, to_radix_acc_under_p_shift, to_radix_exponent_shift, to_radix_limb_shift, to_radix_limb_eq_p_shift, to_radix_limb_index_shift, to_radix_limb_lt_p_shift, to_radix_not_padding_limb_shift, to_radix_radix_shift, to_radix_safe_limbs_shift, to_radix_sel_shift, to_radix_start_shift, to_radix_value_shift #define AVM2_TO_BE_SHIFTED(e) e.bc_decomposition_bytes, e.bc_decomposition_bytes_pc_plus_1, e.bc_decomposition_bytes_pc_plus_10, e.bc_decomposition_bytes_pc_plus_11, e.bc_decomposition_bytes_pc_plus_12, e.bc_decomposition_bytes_pc_plus_13, e.bc_decomposition_bytes_pc_plus_14, e.bc_decomposition_bytes_pc_plus_15, e.bc_decomposition_bytes_pc_plus_16, e.bc_decomposition_bytes_pc_plus_17, e.bc_decomposition_bytes_pc_plus_18, e.bc_decomposition_bytes_pc_plus_19, e.bc_decomposition_bytes_pc_plus_2, e.bc_decomposition_bytes_pc_plus_20, e.bc_decomposition_bytes_pc_plus_21, e.bc_decomposition_bytes_pc_plus_22, e.bc_decomposition_bytes_pc_plus_23, e.bc_decomposition_bytes_pc_plus_24, e.bc_decomposition_bytes_pc_plus_25, e.bc_decomposition_bytes_pc_plus_26, e.bc_decomposition_bytes_pc_plus_27, e.bc_decomposition_bytes_pc_plus_28, e.bc_decomposition_bytes_pc_plus_29, e.bc_decomposition_bytes_pc_plus_3, e.bc_decomposition_bytes_pc_plus_30, e.bc_decomposition_bytes_pc_plus_31, e.bc_decomposition_bytes_pc_plus_32, e.bc_decomposition_bytes_pc_plus_33, e.bc_decomposition_bytes_pc_plus_34, e.bc_decomposition_bytes_pc_plus_35, e.bc_decomposition_bytes_pc_plus_4, e.bc_decomposition_bytes_pc_plus_5, e.bc_decomposition_bytes_pc_plus_6, e.bc_decomposition_bytes_pc_plus_7, e.bc_decomposition_bytes_pc_plus_8, e.bc_decomposition_bytes_pc_plus_9, e.bc_decomposition_bytes_remaining, e.bc_decomposition_id, e.bc_decomposition_pc, e.bc_decomposition_sel, e.bc_hashing_bytecode_id, e.bc_hashing_incremental_hash, e.bc_hashing_pc_index, e.bc_hashing_sel, e.bc_hashing_start, e.bitwise_acc_ia, e.bitwise_acc_ib, e.bitwise_acc_ic, e.bitwise_ctr, e.bitwise_op_id, e.execution_sel, e.poseidon2_hash_a_0, e.poseidon2_hash_a_1, e.poseidon2_hash_a_2, e.poseidon2_hash_a_3, e.poseidon2_hash_input_0, e.poseidon2_hash_input_1, e.poseidon2_hash_input_2, e.poseidon2_hash_num_perm_rounds_rem, e.poseidon2_hash_output, e.poseidon2_hash_sel, e.poseidon2_hash_start, e.scalar_mul_bit_idx, e.scalar_mul_point_inf, e.scalar_mul_point_x, e.scalar_mul_point_y, e.scalar_mul_res_inf, e.scalar_mul_res_x, e.scalar_mul_res_y, e.scalar_mul_scalar, e.scalar_mul_sel, e.scalar_mul_start, e.scalar_mul_temp_inf, e.scalar_mul_temp_x, e.scalar_mul_temp_y, e.sha256_a, e.sha256_b, e.sha256_c, e.sha256_d, e.sha256_e, e.sha256_f, e.sha256_g, e.sha256_h, e.sha256_helper_w0, e.sha256_helper_w1, e.sha256_helper_w10, e.sha256_helper_w11, e.sha256_helper_w12, e.sha256_helper_w13, e.sha256_helper_w14, e.sha256_helper_w15, e.sha256_helper_w2, e.sha256_helper_w3, e.sha256_helper_w4, e.sha256_helper_w5, e.sha256_helper_w6, e.sha256_helper_w7, e.sha256_helper_w8, e.sha256_helper_w9, e.sha256_rounds_remaining, e.sha256_sel, e.sha256_start, e.to_radix_acc, e.to_radix_acc_under_p, e.to_radix_exponent, e.to_radix_limb, e.to_radix_limb_eq_p, e.to_radix_limb_index, e.to_radix_limb_lt_p, e.to_radix_not_padding_limb, e.to_radix_radix, e.to_radix_safe_limbs, e.to_radix_sel, e.to_radix_start, e.to_radix_value #define AVM2_ALL_ENTITIES AVM2_PRECOMPUTED_ENTITIES, AVM2_WIRE_ENTITIES, AVM2_DERIVED_WITNESS_ENTITIES, AVM2_SHIFTED_ENTITIES @@ -31,8 +31,8 @@ enum class ColumnAndShifts { SENTINEL_DO_NOT_USE, }; -constexpr auto NUM_COLUMNS_WITH_SHIFTS = 1032; -constexpr auto NUM_COLUMNS_WITHOUT_SHIFTS = 917; +constexpr auto NUM_COLUMNS_WITH_SHIFTS = 1029; +constexpr auto NUM_COLUMNS_WITHOUT_SHIFTS = 914; constexpr auto TO_BE_SHIFTED_COLUMNS_ARRAY = []() { return std::array{ AVM2_TO_BE_SHIFTED_COLUMNS }; }(); constexpr auto SHIFTED_COLUMNS_ARRAY = []() { return std::array{ AVM2_SHIFTED_COLUMNS }; }(); static_assert(TO_BE_SHIFTED_COLUMNS_ARRAY.size() == SHIFTED_COLUMNS_ARRAY.size()); diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp index 745d69c68243..f4fb0c3fd61b 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp @@ -89,13 +89,13 @@ class AvmFlavor { // This flavor would not be used with ZK Sumcheck static constexpr bool HasZK = false; - static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 44; - static constexpr size_t NUM_WITNESS_ENTITIES = 873; + static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 45; + static constexpr size_t NUM_WITNESS_ENTITIES = 869; static constexpr size_t NUM_SHIFTED_ENTITIES = 115; static constexpr size_t NUM_WIRES = NUM_WITNESS_ENTITIES + NUM_PRECOMPUTED_ENTITIES; // We have two copies of the witness entities, so we subtract the number of fixed ones (they have no shift), one for // the unshifted and one for the shifted - static constexpr size_t NUM_ALL_ENTITIES = 1032; + static constexpr size_t NUM_ALL_ENTITIES = 1029; // In the sumcheck univariate computation, we divide the trace in chunks and each chunk is // evenly processed by all the threads. This constant defines the maximum number of rows @@ -160,8 +160,7 @@ class AvmFlavor { lookup_instr_fetching_bytecode_size_from_bc_dec_relation, lookup_instr_fetching_bytes_from_bc_dec_relation, lookup_instr_fetching_instr_abs_diff_positive_relation, - lookup_instr_fetching_pc_abs_diff_positive_hi_relation, - lookup_instr_fetching_pc_abs_diff_positive_lo_relation, + lookup_instr_fetching_pc_abs_diff_positive_relation, lookup_instr_fetching_wire_instruction_info_relation, lookup_poseidon2_hash_poseidon2_perm_relation, lookup_range_check_dyn_diff_is_u16_relation, @@ -474,6 +473,7 @@ class AvmFlavor { this->precomputed_sel_unary = verification_key->precomputed_sel_unary; this->precomputed_sha256_compression_round_constant = verification_key->precomputed_sha256_compression_round_constant; + this->precomputed_thirty_two = verification_key->precomputed_thirty_two; this->precomputed_to_radix_safe_limbs = verification_key->precomputed_to_radix_safe_limbs; this->precomputed_zero = verification_key->precomputed_zero; } diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp index 96d5b5cff31c..36f9f82a7be5 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/instr_fetching.hpp @@ -12,8 +12,9 @@ template class instr_fetchingImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3, 3, 3, 4, 3, 4, 2, 3, - 4, 4, 4, 4, 4, 4, 4, 4 }; + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { + 3, 3, 3, 4, 3, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4 + }; template inline static bool skip(const AllEntities& in) { @@ -80,30 +81,23 @@ template class instr_fetchingImpl { } { using Accumulator = typename std::tuple_element_t<6, ContainerOverSubrelations>; - auto tmp = (new_term.instr_fetching_pc_abs_diff - - (new_term.instr_fetching_pc_abs_diff_lo + FF(65536) * new_term.instr_fetching_pc_abs_diff_hi)); - tmp *= scaling_factor; - std::get<6>(evals) += typename Accumulator::View(tmp); - } - { - using Accumulator = typename std::tuple_element_t<7, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_sel_opcode_defined - new_term.instr_fetching_sel * (FF(1) - new_term.instr_fetching_pc_out_of_range)); tmp *= scaling_factor; - std::get<7>(evals) += typename Accumulator::View(tmp); + std::get<6>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<8, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<7, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_indirect - (FF(1) - new_term.instr_fetching_parsing_err) * (new_term.instr_fetching_sel_op_dc_0 * (new_term.instr_fetching_bd1 * FF(256) + new_term.instr_fetching_bd2 * FF(1)) + instr_fetching_SEL_OP_DC_18 * new_term.instr_fetching_bd1 * FF(1))); tmp *= scaling_factor; - std::get<8>(evals) += typename Accumulator::View(tmp); + std::get<7>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<9, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<8, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op1 - (FF(1) - new_term.instr_fetching_parsing_err) * (new_term.instr_fetching_sel_op_dc_0 * @@ -115,10 +109,10 @@ template class instr_fetchingImpl { (new_term.instr_fetching_bd1 * FF(16777216) + new_term.instr_fetching_bd2 * FF(65536) + new_term.instr_fetching_bd3 * FF(256) + new_term.instr_fetching_bd4 * FF(1)))); tmp *= scaling_factor; - std::get<9>(evals) += typename Accumulator::View(tmp); + std::get<8>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<10, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<9, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op2 - (FF(1) - new_term.instr_fetching_parsing_err) * (new_term.instr_fetching_sel_op_dc_0 * @@ -131,10 +125,10 @@ template class instr_fetchingImpl { (new_term.instr_fetching_bd4 * FF(16777216) + new_term.instr_fetching_bd5 * FF(65536) + new_term.instr_fetching_bd6 * FF(256) + new_term.instr_fetching_bd7 * FF(1)))); tmp *= scaling_factor; - std::get<10>(evals) += typename Accumulator::View(tmp); + std::get<9>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<11, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<10, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op3 - (FF(1) - new_term.instr_fetching_parsing_err) * @@ -203,10 +197,10 @@ template class instr_fetchingImpl { new_term.instr_fetching_sel_op_dc_14 * new_term.instr_fetching_bd4 * FF(1) + new_term.instr_fetching_sel_op_dc_17 * new_term.instr_fetching_bd6 * FF(1))); tmp *= scaling_factor; - std::get<11>(evals) += typename Accumulator::View(tmp); + std::get<10>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<12, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<11, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op4 - (FF(1) - new_term.instr_fetching_parsing_err) * (new_term.instr_fetching_sel_op_dc_0 * @@ -215,31 +209,31 @@ template class instr_fetchingImpl { (new_term.instr_fetching_bd8 * FF(256) + new_term.instr_fetching_bd9 * FF(1)) + new_term.instr_fetching_sel_op_dc_7 * new_term.instr_fetching_bd8 * FF(1))); tmp *= scaling_factor; - std::get<12>(evals) += typename Accumulator::View(tmp); + std::get<11>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<13, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<12, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op5 - (FF(1) - new_term.instr_fetching_parsing_err) * new_term.instr_fetching_sel_op_dc_0 * (new_term.instr_fetching_bd11 * FF(256) + new_term.instr_fetching_bd12 * FF(1))); tmp *= scaling_factor; - std::get<13>(evals) += typename Accumulator::View(tmp); + std::get<12>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<14, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<13, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op6 - (FF(1) - new_term.instr_fetching_parsing_err) * new_term.instr_fetching_sel_op_dc_1 * (new_term.instr_fetching_bd13 * FF(256) + new_term.instr_fetching_bd14 * FF(1))); tmp *= scaling_factor; - std::get<14>(evals) += typename Accumulator::View(tmp); + std::get<13>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<15, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<14, ContainerOverSubrelations>; auto tmp = (new_term.instr_fetching_op7 - (FF(1) - new_term.instr_fetching_parsing_err) * new_term.instr_fetching_sel_op_dc_1 * (new_term.instr_fetching_bd15 * FF(256) + new_term.instr_fetching_bd16 * FF(1))); tmp *= scaling_factor; - std::get<15>(evals) += typename Accumulator::View(tmp); + std::get<14>(evals) += typename Accumulator::View(tmp); } } }; @@ -255,23 +249,21 @@ template class instr_fetching : public Relation class instr_fetching : public Relation SRC_COLUMNS = { - ColumnAndShifts::instr_fetching_pc_abs_diff_lo + ColumnAndShifts::instr_fetching_pc_abs_diff, ColumnAndShifts::precomputed_thirty_two }; - static constexpr std::array DST_COLUMNS = { ColumnAndShifts::precomputed_clk }; - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { - return (in._instr_fetching_sel() == 1 || in._precomputed_sel_range_16() == 1); - } - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { - using View = typename Accumulator::View; - const auto is_operation = View(in._instr_fetching_sel()); - const auto is_table_entry = View(in._precomputed_sel_range_16()); - return (is_operation + is_table_entry - is_operation * is_table_entry); - } - - template static inline auto get_const_entities(const AllEntities& in) - { - return get_entities(in); - } - - template static inline auto get_nonconst_entities(AllEntities& in) - { - return get_entities(in); - } - - template static inline auto get_entities(AllEntities&& in) - { - return std::forward_as_tuple(in._lookup_instr_fetching_pc_abs_diff_positive_lo_inv(), - in._lookup_instr_fetching_pc_abs_diff_positive_lo_counts(), - in._instr_fetching_sel(), - in._precomputed_sel_range_16(), - in._instr_fetching_pc_abs_diff_lo(), - in._precomputed_clk()); - } -}; - -template -class lookup_instr_fetching_pc_abs_diff_positive_lo_relation - : public GenericLookupRelation { - public: - using Settings = lookup_instr_fetching_pc_abs_diff_positive_lo_settings; - static constexpr std::string_view NAME = lookup_instr_fetching_pc_abs_diff_positive_lo_settings::NAME; - static constexpr std::string_view RELATION_NAME = - lookup_instr_fetching_pc_abs_diff_positive_lo_settings::RELATION_NAME; - - template inline static bool skip(const AllEntities& in) - { - return in.lookup_instr_fetching_pc_abs_diff_positive_lo_inv.is_zero(); - } - - static std::string get_subrelation_label(size_t index) - { - if (index == 0) { - return "INVERSES_ARE_CORRECT"; - } else if (index == 1) { - return "ACCUMULATION_IS_CORRECT"; - } - return std::to_string(index); - } -}; - -/////////////////// lookup_instr_fetching_pc_abs_diff_positive_hi /////////////////// - -class lookup_instr_fetching_pc_abs_diff_positive_hi_settings { - public: - static constexpr std::string_view NAME = "LOOKUP_INSTR_FETCHING_PC_ABS_DIFF_POSITIVE_HI"; - static constexpr std::string_view RELATION_NAME = "instr_fetching"; - - static constexpr size_t READ_TERMS = 1; - static constexpr size_t WRITE_TERMS = 1; - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - static constexpr size_t READ_TERM_DEGREE = 0; - static constexpr size_t WRITE_TERM_DEGREE = 0; - - // Columns using the Column enum. - static constexpr Column SRC_SELECTOR = Column::instr_fetching_sel; - static constexpr Column DST_SELECTOR = Column::precomputed_sel_range_16; - static constexpr Column COUNTS = Column::lookup_instr_fetching_pc_abs_diff_positive_hi_counts; - static constexpr Column INVERSES = Column::lookup_instr_fetching_pc_abs_diff_positive_hi_inv; - static constexpr std::array SRC_COLUMNS = { - ColumnAndShifts::instr_fetching_pc_abs_diff_hi + static constexpr std::array DST_COLUMNS = { + ColumnAndShifts::range_check_value, ColumnAndShifts::range_check_rng_chk_bits }; - static constexpr std::array DST_COLUMNS = { ColumnAndShifts::precomputed_clk }; template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { - return (in._instr_fetching_sel() == 1 || in._precomputed_sel_range_16() == 1); + return (in._instr_fetching_sel() == 1 || in._range_check_sel() == 1); } template @@ -218,7 +134,7 @@ class lookup_instr_fetching_pc_abs_diff_positive_hi_settings { { using View = typename Accumulator::View; const auto is_operation = View(in._instr_fetching_sel()); - const auto is_table_entry = View(in._precomputed_sel_range_16()); + const auto is_table_entry = View(in._range_check_sel()); return (is_operation + is_table_entry - is_operation * is_table_entry); } @@ -234,27 +150,29 @@ class lookup_instr_fetching_pc_abs_diff_positive_hi_settings { template static inline auto get_entities(AllEntities&& in) { - return std::forward_as_tuple(in._lookup_instr_fetching_pc_abs_diff_positive_hi_inv(), - in._lookup_instr_fetching_pc_abs_diff_positive_hi_counts(), + return std::forward_as_tuple(in._lookup_instr_fetching_pc_abs_diff_positive_inv(), + in._lookup_instr_fetching_pc_abs_diff_positive_counts(), in._instr_fetching_sel(), - in._precomputed_sel_range_16(), - in._instr_fetching_pc_abs_diff_hi(), - in._precomputed_clk()); + in._range_check_sel(), + in._instr_fetching_pc_abs_diff(), + in._precomputed_thirty_two(), + in._range_check_value(), + in._range_check_rng_chk_bits()); } }; template -class lookup_instr_fetching_pc_abs_diff_positive_hi_relation - : public GenericLookupRelation { +class lookup_instr_fetching_pc_abs_diff_positive_relation + : public GenericLookupRelation { public: - using Settings = lookup_instr_fetching_pc_abs_diff_positive_hi_settings; - static constexpr std::string_view NAME = lookup_instr_fetching_pc_abs_diff_positive_hi_settings::NAME; + using Settings = lookup_instr_fetching_pc_abs_diff_positive_settings; + static constexpr std::string_view NAME = lookup_instr_fetching_pc_abs_diff_positive_settings::NAME; static constexpr std::string_view RELATION_NAME = - lookup_instr_fetching_pc_abs_diff_positive_hi_settings::RELATION_NAME; + lookup_instr_fetching_pc_abs_diff_positive_settings::RELATION_NAME; template inline static bool skip(const AllEntities& in) { - return in.lookup_instr_fetching_pc_abs_diff_positive_hi_inv.is_zero(); + return in.lookup_instr_fetching_pc_abs_diff_positive_inv.is_zero(); } static std::string get_subrelation_label(size_t index) diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.cpp index 79080e68d717..895483a97699 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.cpp @@ -5,6 +5,7 @@ #include "barretenberg/common/serialize.hpp" #include "barretenberg/vm/aztec_constants.hpp" #include "barretenberg/vm2/common/aztec_types.hpp" +#include "barretenberg/vm2/common/constants.hpp" #include "barretenberg/vm2/simulation/lib/contract_crypto.hpp" #include "barretenberg/vm2/simulation/lib/serialization.hpp" @@ -72,6 +73,10 @@ Instruction TxBytecodeManager::read_instruction(BytecodeId bytecode_id, uint32_t instr_fetch_err = error; } + const auto bytecode_size = bytecode_ptr->size(); + const uint128_t pc_diff = bytecode_size > pc ? bytecode_size - pc - 1 : pc - bytecode_size; + range_check.assert_range(pc_diff, AVM_PC_SIZE_IN_BITS); + // The event will be deduplicated internally. fetching_events.emit({ .bytecode_id = bytecode_id, diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.hpp index a3fc4add9755..ab8ed811cfe8 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.hpp @@ -17,6 +17,7 @@ #include "barretenberg/vm2/simulation/events/event_emitter.hpp" #include "barretenberg/vm2/simulation/lib/db_interfaces.hpp" #include "barretenberg/vm2/simulation/lib/serialization.hpp" +#include "barretenberg/vm2/simulation/range_check.hpp" #include "barretenberg/vm2/simulation/siloing.hpp" namespace bb::avm2::simulation { @@ -40,7 +41,8 @@ class TxBytecodeManager : public TxBytecodeManagerInterface { TxBytecodeManager(ContractDBInterface& contract_db, MerkleDBInterface& merkle_db, SiloingInterface& siloing, - BytecodeHasher& bytecode_hasher, + BytecodeHashingInterface& bytecode_hasher, + RangeCheckInterface& range_check, EventEmitterInterface& retrieval_events, EventEmitterInterface& decomposition_events, EventEmitterInterface& fetching_events) @@ -48,6 +50,7 @@ class TxBytecodeManager : public TxBytecodeManagerInterface { , merkle_db(merkle_db) , siloing(siloing) , bytecode_hasher(bytecode_hasher) + , range_check(range_check) , retrieval_events(retrieval_events) , decomposition_events(decomposition_events) , fetching_events(fetching_events) @@ -60,7 +63,8 @@ class TxBytecodeManager : public TxBytecodeManagerInterface { ContractDBInterface& contract_db; MerkleDBInterface& merkle_db; SiloingInterface& siloing; - BytecodeHasher& bytecode_hasher; + BytecodeHashingInterface& bytecode_hasher; + RangeCheckInterface& range_check; EventEmitterInterface& retrieval_events; EventEmitterInterface& decomposition_events; EventEmitterInterface& fetching_events; diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/memory_event.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/memory_event.hpp index a8eba158bec7..061246f63f48 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/memory_event.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/memory_event.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include #include "barretenberg/vm2/common/memory_types.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/poseidon2_event.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/poseidon2_event.hpp index ee354dc8cb9b..278145b82340 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/poseidon2_event.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/poseidon2_event.hpp @@ -3,8 +3,7 @@ #include #include -#include "barretenberg/vm2/common/memory_types.hpp" -#include "barretenberg/vm2/common/opcodes.hpp" +#include "barretenberg/vm2/common/field.hpp" namespace bb::avm2::simulation { diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/range_check_event.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/range_check_event.hpp index b5cdc3fea0e2..c78771f28f05 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/range_check_event.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/range_check_event.hpp @@ -1,11 +1,10 @@ #pragma once +#include + // TODO(dbanks12): what is Cpp best practice? Import this here or somewhere common/shared? // It is needed for uint128_t -#include "barretenberg/common/serialize.hpp" - -#include -#include +#include "barretenberg/numeric/uint128/uint128.hpp" namespace bb::avm2::simulation { @@ -14,6 +13,10 @@ struct RangeCheckEvent { uint8_t num_bits; bool operator==(const RangeCheckEvent& other) const { return value == other.value && num_bits == other.num_bits; } + + // To be used with deduplicating event emitters. + using Key = std::tuple; + Key get_key() const { return { value, num_bits }; } }; } // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/sha256_event.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/sha256_event.hpp index 6a6dcacca00c..5331a814ba79 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/sha256_event.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/sha256_event.hpp @@ -1,10 +1,8 @@ #pragma once #include -#include #include "barretenberg/vm2/common/memory_types.hpp" -#include "barretenberg/vm2/common/opcodes.hpp" namespace bb::avm2::simulation { diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/range_check.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/range_check.hpp index b5df2d7de1bf..e459db534283 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/range_check.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/range_check.hpp @@ -3,11 +3,8 @@ #include #include -#include "barretenberg/vm2/common/memory_types.hpp" -#include "barretenberg/vm2/simulation/context.hpp" #include "barretenberg/vm2/simulation/events/event_emitter.hpp" #include "barretenberg/vm2/simulation/events/range_check_event.hpp" -#include "barretenberg/vm2/simulation/memory.hpp" namespace bb::avm2::simulation { diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation_helper.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation_helper.cpp index ca9ced3519e8..41ee6e012fa4 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation_helper.cpp @@ -20,6 +20,7 @@ #include "barretenberg/vm2/simulation/events/event_emitter.hpp" #include "barretenberg/vm2/simulation/events/execution_event.hpp" #include "barretenberg/vm2/simulation/events/memory_event.hpp" +#include "barretenberg/vm2/simulation/events/range_check_event.hpp" #include "barretenberg/vm2/simulation/events/sha256_event.hpp" #include "barretenberg/vm2/simulation/events/siloing_event.hpp" #include "barretenberg/vm2/simulation/events/to_radix_event.hpp" @@ -28,6 +29,7 @@ #include "barretenberg/vm2/simulation/lib/instruction_info.hpp" #include "barretenberg/vm2/simulation/lib/raw_data_dbs.hpp" #include "barretenberg/vm2/simulation/poseidon2.hpp" +#include "barretenberg/vm2/simulation/range_check.hpp" #include "barretenberg/vm2/simulation/sha256.hpp" #include "barretenberg/vm2/simulation/siloing.hpp" #include "barretenberg/vm2/simulation/to_radix.hpp" @@ -72,10 +74,12 @@ template EventsContainer AvmSimulationHelper::simulate_with_setting typename S::template DefaultEventEmitter poseidon2_hash_emitter; typename S::template DefaultEventEmitter poseidon2_perm_emitter; typename S::template DefaultEventEmitter to_radix_emitter; + typename S::template DefaultDeduplicatingEventEmitter range_check_emitter; Poseidon2 poseidon2(poseidon2_hash_emitter, poseidon2_perm_emitter); ToRadix to_radix(to_radix_emitter); Ecc ecc(to_radix, ecc_add_emitter, scalar_mul_emitter); + RangeCheck range_check(range_check_emitter); AddressDerivation address_derivation(poseidon2, ecc, address_derivation_emitter); ClassIdDerivation class_id_derivation(poseidon2, class_id_derivation_emitter); @@ -91,6 +95,7 @@ template EventsContainer AvmSimulationHelper::simulate_with_setting merkle_db, siloing, bytecode_hasher, + range_check, bytecode_retrieval_emitter, bytecode_decomposition_emitter, instruction_fetching_emitter); diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp index 394a153139a6..bf33839858bd 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp @@ -288,8 +288,6 @@ void BytecodeTraceBuilder::process_instruction_fetching( uint32_t bytecode_size_u32 = static_cast(bytecode_size); uint32_t pc_abs_diff = bytecode_size_u32 > event.pc ? bytecode_size_u32 - event.pc - 1 : event.pc - bytecode_size_u32; - uint32_t pc_abs_diff_lo = pc_abs_diff & 0xFFFF; - uint32_t pc_abs_diff_hi = pc_abs_diff >> 16; trace.set(row, { { @@ -381,8 +379,6 @@ void BytecodeTraceBuilder::process_instruction_fetching( { C::instr_fetching_bytes_to_read, bytes_to_read }, { C::instr_fetching_instr_abs_diff, instr_abs_diff }, { C::instr_fetching_pc_abs_diff, pc_abs_diff }, - { C::instr_fetching_pc_abs_diff_lo, pc_abs_diff_lo }, - { C::instr_fetching_pc_abs_diff_hi, pc_abs_diff_hi }, } }); row++; } diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp index 676797f41f19..1aef21682b92 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp @@ -472,8 +472,6 @@ TEST(BytecodeTraceGenTest, InstrFetchingSingleBytecode) const auto pc_abs_diff = bytecode_size - pc - 1; ASSERT_LE(bytecode_size, UINT16_MAX); - const auto pc_abs_diff_lo = pc_abs_diff; - const auto pc_abs_diff_hi = 0; EXPECT_THAT(rows.at(i + 1), AllOf(ROW_FIELD_EQ(R, instr_fetching_sel, 1), @@ -485,8 +483,6 @@ TEST(BytecodeTraceGenTest, InstrFetchingSingleBytecode) ROW_FIELD_EQ(R, instr_fetching_instr_size, instr_size), ROW_FIELD_EQ(R, instr_fetching_instr_abs_diff, instr_abs_diff), ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff, pc_abs_diff), - ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff_lo, pc_abs_diff_lo), - ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff_hi, pc_abs_diff_hi), ROW_FIELD_EQ(R, instr_fetching_pc_out_of_range, 0), ROW_FIELD_EQ(R, instr_fetching_opcode_out_of_range, 0), ROW_FIELD_EQ(R, instr_fetching_instr_out_of_range, 0), @@ -594,8 +590,6 @@ TEST(BytecodeTraceGenTest, InstrFetchingParsingErrors) 20), // instr_size <= bytes_to_read: bytes_to_read - instr_size ROW_FIELD_EQ(R, instr_fetching_parsing_err, 1), ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff, 19), - ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff_lo, 19), - ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff_hi, 0), ROW_FIELD_EQ(R, instr_fetching_opcode_out_of_range, 1))); EXPECT_THAT(rows.at(2), @@ -609,8 +603,6 @@ TEST(BytecodeTraceGenTest, InstrFetchingParsingErrors) 6), // instr_size > bytes_to_read: instr_size - bytes_to_read - 1 ROW_FIELD_EQ(R, instr_fetching_parsing_err, 1), ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff, 0), - ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff_lo, 0), - ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff_hi, 0), ROW_FIELD_EQ(R, instr_fetching_instr_out_of_range, 1))); EXPECT_THAT(rows.at(3), @@ -622,8 +614,6 @@ TEST(BytecodeTraceGenTest, InstrFetchingParsingErrors) ROW_FIELD_EQ(R, instr_fetching_instr_abs_diff, 0), ROW_FIELD_EQ(R, instr_fetching_parsing_err, 1), ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff, 18), - ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff_lo, 18), - ROW_FIELD_EQ(R, instr_fetching_pc_abs_diff_hi, 0), ROW_FIELD_EQ(R, instr_fetching_pc_out_of_range, 1))); } diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/precomputed_trace.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/precomputed_trace.cpp index f7eb2fff42ae..2c10ba47bbc8 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/precomputed_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/precomputed_trace.cpp @@ -17,11 +17,12 @@ void PrecomputedTraceBuilder::process_misc(TraceContainer& trace, const uint32_t // First row. trace.set(C::precomputed_first_row, 0, 1); - // Clk. + // Clk and constant columns // TODO: What a waste of 64MB. Can we elegantly have a flag for this? trace.reserve_column(C::precomputed_clk, num_rows); for (uint32_t i = 0; i < num_rows; i++) { trace.set(C::precomputed_clk, i, i); + trace.set(C::precomputed_thirty_two, i, 32); } } diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp index 1e4723c872e6..e77d2a0a7414 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp @@ -288,8 +288,7 @@ TraceContainer AvmTraceGenHelper::generate_trace(EventsContainer&& events) std::make_unique>(), std::make_unique>(), std::make_unique>(), - std::make_unique>(), - std::make_unique>(), + std::make_unique>(), // Class Id Derivation std::make_unique< LookupIntoDynamicTableSequential>(), diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr index 75b8eeb70d3c..1cf15bf6f0e8 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr @@ -776,6 +776,8 @@ pub global PROOF_TYPE_AVM: u32 = 4; pub global PROOF_TYPE_ROLLUP_HONK: u32 = 5; pub global PROOF_TYPE_ROOT_ROLLUP_HONK: u32 = 6; +// AVM - misc constants +pub global AVM_PC_SIZE_IN_BITS: u8 = 32; pub global TWO_POW_64: Field = 18446744073709551616; // 24 hours with a slot duration of 24 seconds diff --git a/yarn-project/constants/src/constants.gen.ts b/yarn-project/constants/src/constants.gen.ts index 95be108b37d3..8ee0172dfa83 100644 --- a/yarn-project/constants/src/constants.gen.ts +++ b/yarn-project/constants/src/constants.gen.ts @@ -92,16 +92,11 @@ export const MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS = 3000; export const MAX_PACKED_BYTECODE_SIZE_PER_UNCONSTRAINED_FUNCTION_IN_FIELDS = 3000; export const REGISTERER_PRIVATE_FUNCTION_BROADCASTED_ADDITIONAL_FIELDS = 19; export const REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_ADDITIONAL_FIELDS = 12; -export const REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE = - 11121068431693264234253912047066709627593769337094408533543930778360n; -export const REGISTERER_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE = - 2889881020989534926461066592611988634597302675057895885580456197069n; -export const REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_MAGIC_VALUE = - 24399338136397901754495080759185489776044879232766421623673792970137n; -export const DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE = - 14061769416655647708490531650437236735160113654556896985372298487345n; -export const DEPLOYER_CONTRACT_INSTANCE_UPDATED_MAGIC_VALUE = - 1534834688047131268740281708431107902615560100979874281215533519862n; +export const REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE = 11121068431693264234253912047066709627593769337094408533543930778360n; +export const REGISTERER_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE = 2889881020989534926461066592611988634597302675057895885580456197069n; +export const REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_MAGIC_VALUE = 24399338136397901754495080759185489776044879232766421623673792970137n; +export const DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE = 14061769416655647708490531650437236735160113654556896985372298487345n; +export const DEPLOYER_CONTRACT_INSTANCE_UPDATED_MAGIC_VALUE = 1534834688047131268740281708431107902615560100979874281215533519862n; export const MAX_PROTOCOL_CONTRACTS = 7; export const CANONICAL_AUTH_REGISTRY_ADDRESS = 1; export const DEPLOYER_CONTRACT_ADDRESS = 2; @@ -357,6 +352,7 @@ export const PROOF_TYPE_PG = 3; export const PROOF_TYPE_AVM = 4; export const PROOF_TYPE_ROLLUP_HONK = 5; export const PROOF_TYPE_ROOT_ROLLUP_HONK = 6; +export const AVM_PC_SIZE_IN_BITS = 32; export const TWO_POW_64 = 18446744073709551616n; export const DEFAULT_UPDATE_DELAY = 3600; export const MINIMUM_UPDATE_DELAY = 25; @@ -416,4 +412,4 @@ export enum GeneratorIndex { SYMMETRIC_KEY_2 = 55, PUBLIC_TX_HASH = 56, PRIVATE_TX_HASH = 57, -} +} \ No newline at end of file diff --git a/yarn-project/constants/src/scripts/constants.in.ts b/yarn-project/constants/src/scripts/constants.in.ts index 45cad98c17ae..683081fba9f1 100644 --- a/yarn-project/constants/src/scripts/constants.in.ts +++ b/yarn-project/constants/src/scripts/constants.in.ts @@ -156,6 +156,7 @@ const PIL_CONSTANTS = [ 'MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS', 'GRUMPKIN_ONE_X', 'GRUMPKIN_ONE_Y', + 'AVM_PC_SIZE_IN_BITS', ]; const PIL_GENERATORS: string[] = [ From 4836de225e9b798595b5396a26c23d2707104cad Mon Sep 17 00:00:00 2001 From: jeanmon Date: Wed, 19 Mar 2025 15:04:02 +0000 Subject: [PATCH 21/25] Add Mock for range check --- .../simulation/testing/mock_range_check.hpp | 21 +++++++++++++++++++ .../testing/mock_range_check.test.cpp | 9 ++++++++ 2 files changed, 30 insertions(+) create mode 100644 barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_range_check.hpp create mode 100644 barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_range_check.test.cpp diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_range_check.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_range_check.hpp new file mode 100644 index 000000000000..448d90ad1f01 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_range_check.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include + +#include +#include + +#include "barretenberg/vm2/simulation/range_check.hpp" + +namespace bb::avm2::simulation { + +class MockRangeCheck : public RangeCheckInterface { + public: + // https://google.github.io/googletest/gmock_cook_book.html#making-the-compilation-faster + MockRangeCheck(); + ~MockRangeCheck() override; + + MOCK_METHOD(void, assert_range, (uint128_t value, uint8_t num_bits), (override)); +}; + +} // namespace bb::avm2::simulation \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_range_check.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_range_check.test.cpp new file mode 100644 index 000000000000..a34a2c05e2d0 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/testing/mock_range_check.test.cpp @@ -0,0 +1,9 @@ +// This is not a test file but we need to use .test.cpp so that it is not included in non-test builds. +#include "barretenberg/vm2/simulation/testing/mock_range_check.hpp" + +namespace bb::avm2::simulation { + +MockRangeCheck::MockRangeCheck() = default; +MockRangeCheck::~MockRangeCheck() = default; + +} // namespace bb::avm2::simulation \ No newline at end of file From bf1383ce0051fcca0ca1b5e7526048f6d713bd88 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Wed, 19 Mar 2025 16:22:50 +0000 Subject: [PATCH 22/25] Addressing review feedback --- barretenberg/cpp/pil/vm2/instr_fetching.pil | 7 +- barretenberg/cpp/pil/vm2/precomputed.pil | 4 - .../barretenberg/vm2/generated/columns.hpp | 4 +- .../src/barretenberg/vm2/generated/flavor.hpp | 5 +- .../relations/lookups_instr_fetching.hpp | 4 +- .../vm2/simulation/bytecode_manager.cpp | 27 ++- .../vm2/simulation/lib/serialization.cpp | 25 +-- .../vm2/simulation/lib/serialization.hpp | 6 - .../vm2/tracegen/bytecode_trace.cpp | 207 +++++++++--------- .../vm2/tracegen/bytecode_trace.test.cpp | 2 +- .../vm2/tracegen/precomputed_trace.cpp | 3 +- 11 files changed, 149 insertions(+), 145 deletions(-) diff --git a/barretenberg/cpp/pil/vm2/instr_fetching.pil b/barretenberg/cpp/pil/vm2/instr_fetching.pil index f1ffd51d34c9..dbd0558f9afd 100644 --- a/barretenberg/cpp/pil/vm2/instr_fetching.pil +++ b/barretenberg/cpp/pil/vm2/instr_fetching.pil @@ -56,11 +56,16 @@ pol commit pc_abs_diff; #[PC_OUT_OF_RANGE_TOGGLE] pc_abs_diff = sel * ((2 * pc_out_of_range - 1) * (pc - bytecode_size) - 1 + pc_out_of_range); +// TODO: Remove this one once we support constant in lookup tuples +// A column with the value 32 at each row. +pol commit thirty_two; + // pc_abs_diff is 32-bit long (pc is uint32_t) // Use constant AVM_PC_SIZE_IN_BITS once we support constants in lookup tuples. #[PC_ABS_DIFF_POSITIVE] -sel { pc_abs_diff, precomputed.thirty_two } in range_check.sel { range_check.value, range_check.rng_chk_bits }; +sel { pc_abs_diff, thirty_two } in range_check.sel { range_check.value, range_check.rng_chk_bits }; +// The size of the bytecode is bytes_remaining at pc == 0. #[BYTECODE_SIZE_FROM_BC_DEC] sel { bytecode_id, precomputed.zero, bytecode_size } in bc_decomposition.sel { bc_decomposition.id, bc_decomposition.pc, bc_decomposition.bytes_remaining }; diff --git a/barretenberg/cpp/pil/vm2/precomputed.pil b/barretenberg/cpp/pil/vm2/precomputed.pil index 92e5dee6479b..cb925d2a7818 100644 --- a/barretenberg/cpp/pil/vm2/precomputed.pil +++ b/barretenberg/cpp/pil/vm2/precomputed.pil @@ -7,10 +7,6 @@ pol constant clk; // A column of zeroes pol constant zero; -// TODO: Remove this one once we support constant in lookup tuples -// A column with 32 values -pol constant thirty_two; - // 1 only at row 0. pol constant first_row; diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp index 903c4c4ef59a..fd2568356e2d 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp @@ -9,8 +9,8 @@ namespace bb::avm2 { // The entities that will be used in the flavor. // clang-format off -#define AVM2_PRECOMPUTED_ENTITIES precomputed_as_unary, precomputed_bitwise_input_a, precomputed_bitwise_input_b, precomputed_bitwise_op_id, precomputed_bitwise_output, precomputed_clk, precomputed_exec_opcode, precomputed_first_row, precomputed_instr_size, precomputed_integral_tag_length, precomputed_opcode_out_of_range, precomputed_p_decomposition_limb, precomputed_p_decomposition_limb_index, precomputed_p_decomposition_radix, precomputed_power_of_2, precomputed_sel_bitwise, precomputed_sel_integral_tag, precomputed_sel_op_dc_0, precomputed_sel_op_dc_1, precomputed_sel_op_dc_10, precomputed_sel_op_dc_11, precomputed_sel_op_dc_12, precomputed_sel_op_dc_13, precomputed_sel_op_dc_14, precomputed_sel_op_dc_15, precomputed_sel_op_dc_16, precomputed_sel_op_dc_17, precomputed_sel_op_dc_2, precomputed_sel_op_dc_3, precomputed_sel_op_dc_4, precomputed_sel_op_dc_5, precomputed_sel_op_dc_6, precomputed_sel_op_dc_7, precomputed_sel_op_dc_8, precomputed_sel_op_dc_9, precomputed_sel_p_decomposition, precomputed_sel_range_16, precomputed_sel_range_8, precomputed_sel_sha256_compression, precomputed_sel_to_radix_safe_limbs, precomputed_sel_unary, precomputed_sha256_compression_round_constant, precomputed_thirty_two, precomputed_to_radix_safe_limbs, precomputed_zero -#define AVM2_WIRE_ENTITIES execution_input, address_derivation_address, address_derivation_address_y, address_derivation_class_id, address_derivation_deployer_addr, address_derivation_g1_x, address_derivation_g1_y, address_derivation_incoming_viewing_key_x, address_derivation_incoming_viewing_key_y, address_derivation_init_hash, address_derivation_nullifier_key_x, address_derivation_nullifier_key_y, address_derivation_outgoing_viewing_key_x, address_derivation_outgoing_viewing_key_y, address_derivation_partial_address, address_derivation_partial_address_domain_separator, address_derivation_preaddress, address_derivation_preaddress_domain_separator, address_derivation_preaddress_public_key_x, address_derivation_preaddress_public_key_y, address_derivation_public_keys_hash, address_derivation_public_keys_hash_domain_separator, address_derivation_salt, address_derivation_salted_init_hash, address_derivation_sel, address_derivation_tagging_key_x, address_derivation_tagging_key_y, alu_dst_addr, alu_ia, alu_ia_addr, alu_ib, alu_ib_addr, alu_ic, alu_op, alu_sel_op_add, bc_decomposition_abs_diff, bc_decomposition_bytes, bc_decomposition_bytes_pc_plus_1, bc_decomposition_bytes_pc_plus_10, bc_decomposition_bytes_pc_plus_11, bc_decomposition_bytes_pc_plus_12, bc_decomposition_bytes_pc_plus_13, bc_decomposition_bytes_pc_plus_14, bc_decomposition_bytes_pc_plus_15, bc_decomposition_bytes_pc_plus_16, bc_decomposition_bytes_pc_plus_17, bc_decomposition_bytes_pc_plus_18, bc_decomposition_bytes_pc_plus_19, bc_decomposition_bytes_pc_plus_2, bc_decomposition_bytes_pc_plus_20, bc_decomposition_bytes_pc_plus_21, bc_decomposition_bytes_pc_plus_22, bc_decomposition_bytes_pc_plus_23, bc_decomposition_bytes_pc_plus_24, bc_decomposition_bytes_pc_plus_25, bc_decomposition_bytes_pc_plus_26, bc_decomposition_bytes_pc_plus_27, bc_decomposition_bytes_pc_plus_28, bc_decomposition_bytes_pc_plus_29, bc_decomposition_bytes_pc_plus_3, bc_decomposition_bytes_pc_plus_30, bc_decomposition_bytes_pc_plus_31, bc_decomposition_bytes_pc_plus_32, bc_decomposition_bytes_pc_plus_33, bc_decomposition_bytes_pc_plus_34, bc_decomposition_bytes_pc_plus_35, bc_decomposition_bytes_pc_plus_36, bc_decomposition_bytes_pc_plus_4, bc_decomposition_bytes_pc_plus_5, bc_decomposition_bytes_pc_plus_6, bc_decomposition_bytes_pc_plus_7, bc_decomposition_bytes_pc_plus_8, bc_decomposition_bytes_pc_plus_9, bc_decomposition_bytes_rem_inv, bc_decomposition_bytes_rem_min_one_inv, bc_decomposition_bytes_remaining, bc_decomposition_bytes_to_read, bc_decomposition_bytes_to_read_unary, bc_decomposition_id, bc_decomposition_last_of_contract, bc_decomposition_packed_field, bc_decomposition_pc, bc_decomposition_sel, bc_decomposition_sel_overflow_correction_needed, bc_decomposition_sel_packed, bc_decomposition_sel_pc_plus_1, bc_decomposition_sel_pc_plus_10, bc_decomposition_sel_pc_plus_11, bc_decomposition_sel_pc_plus_12, bc_decomposition_sel_pc_plus_13, bc_decomposition_sel_pc_plus_14, bc_decomposition_sel_pc_plus_15, bc_decomposition_sel_pc_plus_16, bc_decomposition_sel_pc_plus_17, bc_decomposition_sel_pc_plus_18, bc_decomposition_sel_pc_plus_19, bc_decomposition_sel_pc_plus_2, bc_decomposition_sel_pc_plus_20, bc_decomposition_sel_pc_plus_21, bc_decomposition_sel_pc_plus_22, bc_decomposition_sel_pc_plus_23, bc_decomposition_sel_pc_plus_24, bc_decomposition_sel_pc_plus_25, bc_decomposition_sel_pc_plus_26, bc_decomposition_sel_pc_plus_27, bc_decomposition_sel_pc_plus_28, bc_decomposition_sel_pc_plus_29, bc_decomposition_sel_pc_plus_3, bc_decomposition_sel_pc_plus_30, bc_decomposition_sel_pc_plus_31, bc_decomposition_sel_pc_plus_32, bc_decomposition_sel_pc_plus_33, bc_decomposition_sel_pc_plus_34, bc_decomposition_sel_pc_plus_35, bc_decomposition_sel_pc_plus_36, bc_decomposition_sel_pc_plus_4, bc_decomposition_sel_pc_plus_5, bc_decomposition_sel_pc_plus_6, bc_decomposition_sel_pc_plus_7, bc_decomposition_sel_pc_plus_8, bc_decomposition_sel_pc_plus_9, bc_hashing_bytecode_id, bc_hashing_incremental_hash, bc_hashing_latch, bc_hashing_output_hash, bc_hashing_packed_field, bc_hashing_pc_index, bc_hashing_sel, bc_hashing_start, bc_retrieval_address, bc_retrieval_artifact_hash, bc_retrieval_bytecode_id, bc_retrieval_class_id, bc_retrieval_deployer_addr, bc_retrieval_err, bc_retrieval_incoming_viewing_key_x, bc_retrieval_incoming_viewing_key_y, bc_retrieval_init_hash, bc_retrieval_nullifier_key_x, bc_retrieval_nullifier_key_y, bc_retrieval_outgoing_viewing_key_x, bc_retrieval_outgoing_viewing_key_y, bc_retrieval_private_function_root, bc_retrieval_public_bytecode_commitment, bc_retrieval_salt, bc_retrieval_sel, bc_retrieval_siloed_address, bc_retrieval_tagging_key_x, bc_retrieval_tagging_key_y, bitwise_acc_ia, bitwise_acc_ib, bitwise_acc_ic, bitwise_ctr, bitwise_ctr_inv, bitwise_ctr_min_one_inv, bitwise_ia_byte, bitwise_ib_byte, bitwise_ic_byte, bitwise_last, bitwise_op_id, bitwise_sel, bitwise_start, bitwise_tag, class_id_derivation_artifact_hash, class_id_derivation_class_id, class_id_derivation_private_function_root, class_id_derivation_public_bytecode_commitment, class_id_derivation_sel, class_id_derivation_temp_constant_for_lookup, ecc_add_op, ecc_double_op, ecc_inv_2_p_y, ecc_inv_x_diff, ecc_inv_y_diff, ecc_lambda, ecc_p_is_inf, ecc_p_x, ecc_p_y, ecc_q_is_inf, ecc_q_x, ecc_q_y, ecc_r_is_inf, ecc_r_x, ecc_r_y, ecc_result_infinity, ecc_sel, ecc_x_match, ecc_y_match, execution_addressing_error_idx, execution_addressing_error_kind, execution_base_address_tag, execution_base_address_val, execution_bytecode_id, execution_clk, execution_ex_opcode, execution_indirect, execution_last, execution_op1, execution_op1_after_relative, execution_op2, execution_op2_after_relative, execution_op3, execution_op3_after_relative, execution_op4, execution_op4_after_relative, execution_pc, execution_rop1, execution_rop2, execution_rop3, execution_rop4, execution_sel, execution_sel_addressing_error, execution_sel_op1_is_address, execution_sel_op2_is_address, execution_sel_op3_is_address, execution_sel_op4_is_address, instr_fetching_bd0, instr_fetching_bd1, instr_fetching_bd10, instr_fetching_bd11, instr_fetching_bd12, instr_fetching_bd13, instr_fetching_bd14, instr_fetching_bd15, instr_fetching_bd16, instr_fetching_bd17, instr_fetching_bd18, instr_fetching_bd19, instr_fetching_bd2, instr_fetching_bd20, instr_fetching_bd21, instr_fetching_bd22, instr_fetching_bd23, instr_fetching_bd24, instr_fetching_bd25, instr_fetching_bd26, instr_fetching_bd27, instr_fetching_bd28, instr_fetching_bd29, instr_fetching_bd3, instr_fetching_bd30, instr_fetching_bd31, instr_fetching_bd32, instr_fetching_bd33, instr_fetching_bd34, instr_fetching_bd35, instr_fetching_bd36, instr_fetching_bd4, instr_fetching_bd5, instr_fetching_bd6, instr_fetching_bd7, instr_fetching_bd8, instr_fetching_bd9, instr_fetching_bytecode_id, instr_fetching_bytecode_size, instr_fetching_bytes_to_read, instr_fetching_exec_opcode, instr_fetching_indirect, instr_fetching_instr_abs_diff, instr_fetching_instr_out_of_range, instr_fetching_instr_size, instr_fetching_op1, instr_fetching_op2, instr_fetching_op3, instr_fetching_op4, instr_fetching_op5, instr_fetching_op6, instr_fetching_op7, instr_fetching_opcode_out_of_range, instr_fetching_parsing_err, instr_fetching_pc, instr_fetching_pc_abs_diff, instr_fetching_pc_out_of_range, instr_fetching_sel, instr_fetching_sel_op_dc_0, instr_fetching_sel_op_dc_1, instr_fetching_sel_op_dc_10, instr_fetching_sel_op_dc_11, instr_fetching_sel_op_dc_12, instr_fetching_sel_op_dc_13, instr_fetching_sel_op_dc_14, instr_fetching_sel_op_dc_15, instr_fetching_sel_op_dc_16, instr_fetching_sel_op_dc_17, instr_fetching_sel_op_dc_2, instr_fetching_sel_op_dc_3, instr_fetching_sel_op_dc_4, instr_fetching_sel_op_dc_5, instr_fetching_sel_op_dc_6, instr_fetching_sel_op_dc_7, instr_fetching_sel_op_dc_8, instr_fetching_sel_op_dc_9, instr_fetching_sel_opcode_defined, poseidon2_hash_a_0, poseidon2_hash_a_1, poseidon2_hash_a_2, poseidon2_hash_a_3, poseidon2_hash_b_0, poseidon2_hash_b_1, poseidon2_hash_b_2, poseidon2_hash_b_3, poseidon2_hash_end, poseidon2_hash_input_0, poseidon2_hash_input_1, poseidon2_hash_input_2, poseidon2_hash_input_len, poseidon2_hash_num_perm_rounds_rem, poseidon2_hash_num_perm_rounds_rem_inv, poseidon2_hash_output, poseidon2_hash_padding, poseidon2_hash_sel, poseidon2_hash_start, poseidon2_perm_B_10_0, poseidon2_perm_B_10_1, poseidon2_perm_B_10_2, poseidon2_perm_B_10_3, poseidon2_perm_B_11_0, poseidon2_perm_B_11_1, poseidon2_perm_B_11_2, poseidon2_perm_B_11_3, poseidon2_perm_B_12_0, poseidon2_perm_B_12_1, poseidon2_perm_B_12_2, poseidon2_perm_B_12_3, poseidon2_perm_B_13_0, poseidon2_perm_B_13_1, poseidon2_perm_B_13_2, poseidon2_perm_B_13_3, poseidon2_perm_B_14_0, poseidon2_perm_B_14_1, poseidon2_perm_B_14_2, poseidon2_perm_B_14_3, poseidon2_perm_B_15_0, poseidon2_perm_B_15_1, poseidon2_perm_B_15_2, poseidon2_perm_B_15_3, poseidon2_perm_B_16_0, poseidon2_perm_B_16_1, poseidon2_perm_B_16_2, poseidon2_perm_B_16_3, poseidon2_perm_B_17_0, poseidon2_perm_B_17_1, poseidon2_perm_B_17_2, poseidon2_perm_B_17_3, poseidon2_perm_B_18_0, poseidon2_perm_B_18_1, poseidon2_perm_B_18_2, poseidon2_perm_B_18_3, poseidon2_perm_B_19_0, poseidon2_perm_B_19_1, poseidon2_perm_B_19_2, poseidon2_perm_B_19_3, poseidon2_perm_B_20_0, poseidon2_perm_B_20_1, poseidon2_perm_B_20_2, poseidon2_perm_B_20_3, poseidon2_perm_B_21_0, poseidon2_perm_B_21_1, poseidon2_perm_B_21_2, poseidon2_perm_B_21_3, poseidon2_perm_B_22_0, poseidon2_perm_B_22_1, poseidon2_perm_B_22_2, poseidon2_perm_B_22_3, poseidon2_perm_B_23_0, poseidon2_perm_B_23_1, poseidon2_perm_B_23_2, poseidon2_perm_B_23_3, poseidon2_perm_B_24_0, poseidon2_perm_B_24_1, poseidon2_perm_B_24_2, poseidon2_perm_B_24_3, poseidon2_perm_B_25_0, poseidon2_perm_B_25_1, poseidon2_perm_B_25_2, poseidon2_perm_B_25_3, poseidon2_perm_B_26_0, poseidon2_perm_B_26_1, poseidon2_perm_B_26_2, poseidon2_perm_B_26_3, poseidon2_perm_B_27_0, poseidon2_perm_B_27_1, poseidon2_perm_B_27_2, poseidon2_perm_B_27_3, poseidon2_perm_B_28_0, poseidon2_perm_B_28_1, poseidon2_perm_B_28_2, poseidon2_perm_B_28_3, poseidon2_perm_B_29_0, poseidon2_perm_B_29_1, poseidon2_perm_B_29_2, poseidon2_perm_B_29_3, poseidon2_perm_B_30_0, poseidon2_perm_B_30_1, poseidon2_perm_B_30_2, poseidon2_perm_B_30_3, poseidon2_perm_B_31_0, poseidon2_perm_B_31_1, poseidon2_perm_B_31_2, poseidon2_perm_B_31_3, poseidon2_perm_B_32_0, poseidon2_perm_B_32_1, poseidon2_perm_B_32_2, poseidon2_perm_B_32_3, poseidon2_perm_B_33_0, poseidon2_perm_B_33_1, poseidon2_perm_B_33_2, poseidon2_perm_B_33_3, poseidon2_perm_B_34_0, poseidon2_perm_B_34_1, poseidon2_perm_B_34_2, poseidon2_perm_B_34_3, poseidon2_perm_B_35_0, poseidon2_perm_B_35_1, poseidon2_perm_B_35_2, poseidon2_perm_B_35_3, poseidon2_perm_B_36_0, poseidon2_perm_B_36_1, poseidon2_perm_B_36_2, poseidon2_perm_B_36_3, poseidon2_perm_B_37_0, poseidon2_perm_B_37_1, poseidon2_perm_B_37_2, poseidon2_perm_B_37_3, poseidon2_perm_B_38_0, poseidon2_perm_B_38_1, poseidon2_perm_B_38_2, poseidon2_perm_B_38_3, poseidon2_perm_B_39_0, poseidon2_perm_B_39_1, poseidon2_perm_B_39_2, poseidon2_perm_B_39_3, poseidon2_perm_B_40_0, poseidon2_perm_B_40_1, poseidon2_perm_B_40_2, poseidon2_perm_B_40_3, poseidon2_perm_B_41_0, poseidon2_perm_B_41_1, poseidon2_perm_B_41_2, poseidon2_perm_B_41_3, poseidon2_perm_B_42_0, poseidon2_perm_B_42_1, poseidon2_perm_B_42_2, poseidon2_perm_B_42_3, poseidon2_perm_B_43_0, poseidon2_perm_B_43_1, poseidon2_perm_B_43_2, poseidon2_perm_B_43_3, poseidon2_perm_B_44_0, poseidon2_perm_B_44_1, poseidon2_perm_B_44_2, poseidon2_perm_B_44_3, poseidon2_perm_B_45_0, poseidon2_perm_B_45_1, poseidon2_perm_B_45_2, poseidon2_perm_B_45_3, poseidon2_perm_B_46_0, poseidon2_perm_B_46_1, poseidon2_perm_B_46_2, poseidon2_perm_B_46_3, poseidon2_perm_B_47_0, poseidon2_perm_B_47_1, poseidon2_perm_B_47_2, poseidon2_perm_B_47_3, poseidon2_perm_B_48_0, poseidon2_perm_B_48_1, poseidon2_perm_B_48_2, poseidon2_perm_B_48_3, poseidon2_perm_B_49_0, poseidon2_perm_B_49_1, poseidon2_perm_B_49_2, poseidon2_perm_B_49_3, poseidon2_perm_B_4_0, poseidon2_perm_B_4_1, poseidon2_perm_B_4_2, poseidon2_perm_B_4_3, poseidon2_perm_B_50_0, poseidon2_perm_B_50_1, poseidon2_perm_B_50_2, poseidon2_perm_B_50_3, poseidon2_perm_B_51_0, poseidon2_perm_B_51_1, poseidon2_perm_B_51_2, poseidon2_perm_B_51_3, poseidon2_perm_B_52_0, poseidon2_perm_B_52_1, poseidon2_perm_B_52_2, poseidon2_perm_B_52_3, poseidon2_perm_B_53_0, poseidon2_perm_B_53_1, poseidon2_perm_B_53_2, poseidon2_perm_B_53_3, poseidon2_perm_B_54_0, poseidon2_perm_B_54_1, poseidon2_perm_B_54_2, poseidon2_perm_B_54_3, poseidon2_perm_B_55_0, poseidon2_perm_B_55_1, poseidon2_perm_B_55_2, poseidon2_perm_B_55_3, poseidon2_perm_B_56_0, poseidon2_perm_B_56_1, poseidon2_perm_B_56_2, poseidon2_perm_B_56_3, poseidon2_perm_B_57_0, poseidon2_perm_B_57_1, poseidon2_perm_B_57_2, poseidon2_perm_B_57_3, poseidon2_perm_B_58_0, poseidon2_perm_B_58_1, poseidon2_perm_B_58_2, poseidon2_perm_B_58_3, poseidon2_perm_B_59_0, poseidon2_perm_B_59_1, poseidon2_perm_B_59_2, poseidon2_perm_B_59_3, poseidon2_perm_B_5_0, poseidon2_perm_B_5_1, poseidon2_perm_B_5_2, poseidon2_perm_B_5_3, poseidon2_perm_B_6_0, poseidon2_perm_B_6_1, poseidon2_perm_B_6_2, poseidon2_perm_B_6_3, poseidon2_perm_B_7_0, poseidon2_perm_B_7_1, poseidon2_perm_B_7_2, poseidon2_perm_B_7_3, poseidon2_perm_B_8_0, poseidon2_perm_B_8_1, poseidon2_perm_B_8_2, poseidon2_perm_B_8_3, poseidon2_perm_B_9_0, poseidon2_perm_B_9_1, poseidon2_perm_B_9_2, poseidon2_perm_B_9_3, poseidon2_perm_EXT_LAYER_4, poseidon2_perm_EXT_LAYER_5, poseidon2_perm_EXT_LAYER_6, poseidon2_perm_EXT_LAYER_7, poseidon2_perm_T_0_4, poseidon2_perm_T_0_5, poseidon2_perm_T_0_6, poseidon2_perm_T_0_7, poseidon2_perm_T_1_4, poseidon2_perm_T_1_5, poseidon2_perm_T_1_6, poseidon2_perm_T_1_7, poseidon2_perm_T_2_4, poseidon2_perm_T_2_5, poseidon2_perm_T_2_6, poseidon2_perm_T_2_7, poseidon2_perm_T_3_4, poseidon2_perm_T_3_5, poseidon2_perm_T_3_6, poseidon2_perm_T_3_7, poseidon2_perm_T_60_4, poseidon2_perm_T_60_5, poseidon2_perm_T_60_6, poseidon2_perm_T_60_7, poseidon2_perm_T_61_4, poseidon2_perm_T_61_5, poseidon2_perm_T_61_6, poseidon2_perm_T_61_7, poseidon2_perm_T_62_4, poseidon2_perm_T_62_5, poseidon2_perm_T_62_6, poseidon2_perm_T_62_7, poseidon2_perm_T_63_4, poseidon2_perm_T_63_5, poseidon2_perm_T_63_6, poseidon2_perm_T_63_7, poseidon2_perm_a_0, poseidon2_perm_a_1, poseidon2_perm_a_2, poseidon2_perm_a_3, poseidon2_perm_b_0, poseidon2_perm_b_1, poseidon2_perm_b_2, poseidon2_perm_b_3, poseidon2_perm_sel, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_rng_chk_bits, range_check_sel, range_check_sel_r0_16_bit_rng_lookup, range_check_sel_r1_16_bit_rng_lookup, range_check_sel_r2_16_bit_rng_lookup, range_check_sel_r3_16_bit_rng_lookup, range_check_sel_r4_16_bit_rng_lookup, range_check_sel_r5_16_bit_rng_lookup, range_check_sel_r6_16_bit_rng_lookup, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, scalar_mul_bit, scalar_mul_bit_idx, scalar_mul_bit_radix, scalar_mul_end, scalar_mul_not_end, scalar_mul_point_inf, scalar_mul_point_x, scalar_mul_point_y, scalar_mul_res_inf, scalar_mul_res_x, scalar_mul_res_y, scalar_mul_scalar, scalar_mul_sel, scalar_mul_should_add, scalar_mul_start, scalar_mul_temp_inf, scalar_mul_temp_x, scalar_mul_temp_y, sha256_a, sha256_a_and_b, sha256_a_and_b_xor_a_and_c, sha256_a_and_c, sha256_a_rotr_13, sha256_a_rotr_2, sha256_a_rotr_22, sha256_a_rotr_2_xor_a_rotr_13, sha256_and_sel, sha256_b, sha256_b_and_c, sha256_c, sha256_ch, sha256_clk, sha256_computed_w_lhs, sha256_computed_w_rhs, sha256_d, sha256_e, sha256_e_and_f, sha256_e_rotr_11, sha256_e_rotr_25, sha256_e_rotr_6, sha256_e_rotr_6_xor_e_rotr_11, sha256_f, sha256_g, sha256_h, sha256_helper_w0, sha256_helper_w1, sha256_helper_w10, sha256_helper_w11, sha256_helper_w12, sha256_helper_w13, sha256_helper_w14, sha256_helper_w15, sha256_helper_w2, sha256_helper_w3, sha256_helper_w4, sha256_helper_w5, sha256_helper_w6, sha256_helper_w7, sha256_helper_w8, sha256_helper_w9, sha256_init_a, sha256_init_b, sha256_init_c, sha256_init_d, sha256_init_e, sha256_init_f, sha256_init_g, sha256_init_h, sha256_input_offset, sha256_is_input_round, sha256_latch, sha256_lhs_a_13, sha256_lhs_a_2, sha256_lhs_a_22, sha256_lhs_e_11, sha256_lhs_e_25, sha256_lhs_e_6, sha256_lhs_w_10, sha256_lhs_w_17, sha256_lhs_w_18, sha256_lhs_w_19, sha256_lhs_w_3, sha256_lhs_w_7, sha256_maj, sha256_next_a_lhs, sha256_next_a_rhs, sha256_next_e_lhs, sha256_next_e_rhs, sha256_not_e, sha256_not_e_and_g, sha256_output_a_lhs, sha256_output_a_rhs, sha256_output_b_lhs, sha256_output_b_rhs, sha256_output_c_lhs, sha256_output_c_rhs, sha256_output_d_lhs, sha256_output_d_rhs, sha256_output_e_lhs, sha256_output_e_rhs, sha256_output_f_lhs, sha256_output_f_rhs, sha256_output_g_lhs, sha256_output_g_rhs, sha256_output_h_lhs, sha256_output_h_rhs, sha256_output_offset, sha256_perform_round, sha256_rhs_a_13, sha256_rhs_a_2, sha256_rhs_a_22, sha256_rhs_e_11, sha256_rhs_e_25, sha256_rhs_e_6, sha256_rhs_w_10, sha256_rhs_w_17, sha256_rhs_w_18, sha256_rhs_w_19, sha256_rhs_w_3, sha256_rhs_w_7, sha256_round_constant, sha256_round_count, sha256_rounds_remaining, sha256_rounds_remaining_inv, sha256_s_0, sha256_s_1, sha256_sel, sha256_start, sha256_state_offset, sha256_w, sha256_w_15_rotr_18, sha256_w_15_rotr_7, sha256_w_15_rotr_7_xor_w_15_rotr_18, sha256_w_15_rshift_3, sha256_w_2_rotr_17, sha256_w_2_rotr_17_xor_w_2_rotr_19, sha256_w_2_rotr_19, sha256_w_2_rshift_10, sha256_w_s_0, sha256_w_s_1, sha256_xor_sel, to_radix_acc, to_radix_acc_under_p, to_radix_end, to_radix_exponent, to_radix_found, to_radix_is_unsafe_limb, to_radix_limb, to_radix_limb_eq_p, to_radix_limb_index, to_radix_limb_lt_p, to_radix_limb_p_diff, to_radix_limb_radix_diff, to_radix_not_end, to_radix_not_padding_limb, to_radix_p_limb, to_radix_radix, to_radix_rem_inverse, to_radix_safe_limbs, to_radix_safety_diff_inverse, to_radix_sel, to_radix_start, to_radix_value, lookup_poseidon2_hash_poseidon2_perm_counts, lookup_range_check_dyn_rng_chk_pow_2_counts, lookup_range_check_dyn_diff_is_u16_counts, lookup_range_check_r0_is_u16_counts, lookup_range_check_r1_is_u16_counts, lookup_range_check_r2_is_u16_counts, lookup_range_check_r3_is_u16_counts, lookup_range_check_r4_is_u16_counts, lookup_range_check_r5_is_u16_counts, lookup_range_check_r6_is_u16_counts, lookup_range_check_r7_is_u16_counts, lookup_to_radix_limb_range_counts, lookup_to_radix_limb_less_than_radix_range_counts, lookup_to_radix_fetch_safe_limbs_counts, lookup_to_radix_fetch_p_limb_counts, lookup_to_radix_limb_p_diff_range_counts, lookup_scalar_mul_to_radix_counts, lookup_scalar_mul_double_counts, lookup_scalar_mul_add_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_0_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_1_counts, lookup_address_derivation_partial_address_poseidon2_counts, lookup_address_derivation_public_keys_hash_poseidon2_0_counts, lookup_address_derivation_public_keys_hash_poseidon2_1_counts, lookup_address_derivation_public_keys_hash_poseidon2_2_counts, lookup_address_derivation_public_keys_hash_poseidon2_3_counts, lookup_address_derivation_public_keys_hash_poseidon2_4_counts, lookup_address_derivation_preaddress_poseidon2_counts, lookup_address_derivation_preaddress_scalar_mul_counts, lookup_address_derivation_address_ecadd_counts, lookup_bc_decomposition_bytes_are_bytes_counts, lookup_bc_decomposition_abs_diff_is_u16_counts, lookup_bc_decomposition_bytes_to_read_as_unary_counts, lookup_bc_hashing_get_packed_field_counts, lookup_bc_hashing_iv_is_len_counts, lookup_bc_hashing_poseidon2_hash_counts, lookup_bc_retrieval_class_id_derivation_counts, lookup_bc_retrieval_bytecode_hash_is_correct_counts, lookup_instr_fetching_instr_abs_diff_positive_counts, lookup_instr_fetching_pc_abs_diff_positive_counts, lookup_instr_fetching_bytecode_size_from_bc_dec_counts, lookup_instr_fetching_bytes_from_bc_dec_counts, lookup_instr_fetching_wire_instruction_info_counts, lookup_class_id_derivation_class_id_poseidon2_0_counts, lookup_class_id_derivation_class_id_poseidon2_1_counts, lookup_bitwise_integral_tag_length_counts, lookup_bitwise_byte_operations_counts, lookup_sha256_round_constant_counts +#define AVM2_PRECOMPUTED_ENTITIES precomputed_as_unary, precomputed_bitwise_input_a, precomputed_bitwise_input_b, precomputed_bitwise_op_id, precomputed_bitwise_output, precomputed_clk, precomputed_exec_opcode, precomputed_first_row, precomputed_instr_size, precomputed_integral_tag_length, precomputed_opcode_out_of_range, precomputed_p_decomposition_limb, precomputed_p_decomposition_limb_index, precomputed_p_decomposition_radix, precomputed_power_of_2, precomputed_sel_bitwise, precomputed_sel_integral_tag, precomputed_sel_op_dc_0, precomputed_sel_op_dc_1, precomputed_sel_op_dc_10, precomputed_sel_op_dc_11, precomputed_sel_op_dc_12, precomputed_sel_op_dc_13, precomputed_sel_op_dc_14, precomputed_sel_op_dc_15, precomputed_sel_op_dc_16, precomputed_sel_op_dc_17, precomputed_sel_op_dc_2, precomputed_sel_op_dc_3, precomputed_sel_op_dc_4, precomputed_sel_op_dc_5, precomputed_sel_op_dc_6, precomputed_sel_op_dc_7, precomputed_sel_op_dc_8, precomputed_sel_op_dc_9, precomputed_sel_p_decomposition, precomputed_sel_range_16, precomputed_sel_range_8, precomputed_sel_sha256_compression, precomputed_sel_to_radix_safe_limbs, precomputed_sel_unary, precomputed_sha256_compression_round_constant, precomputed_to_radix_safe_limbs, precomputed_zero +#define AVM2_WIRE_ENTITIES execution_input, address_derivation_address, address_derivation_address_y, address_derivation_class_id, address_derivation_deployer_addr, address_derivation_g1_x, address_derivation_g1_y, address_derivation_incoming_viewing_key_x, address_derivation_incoming_viewing_key_y, address_derivation_init_hash, address_derivation_nullifier_key_x, address_derivation_nullifier_key_y, address_derivation_outgoing_viewing_key_x, address_derivation_outgoing_viewing_key_y, address_derivation_partial_address, address_derivation_partial_address_domain_separator, address_derivation_preaddress, address_derivation_preaddress_domain_separator, address_derivation_preaddress_public_key_x, address_derivation_preaddress_public_key_y, address_derivation_public_keys_hash, address_derivation_public_keys_hash_domain_separator, address_derivation_salt, address_derivation_salted_init_hash, address_derivation_sel, address_derivation_tagging_key_x, address_derivation_tagging_key_y, alu_dst_addr, alu_ia, alu_ia_addr, alu_ib, alu_ib_addr, alu_ic, alu_op, alu_sel_op_add, bc_decomposition_abs_diff, bc_decomposition_bytes, bc_decomposition_bytes_pc_plus_1, bc_decomposition_bytes_pc_plus_10, bc_decomposition_bytes_pc_plus_11, bc_decomposition_bytes_pc_plus_12, bc_decomposition_bytes_pc_plus_13, bc_decomposition_bytes_pc_plus_14, bc_decomposition_bytes_pc_plus_15, bc_decomposition_bytes_pc_plus_16, bc_decomposition_bytes_pc_plus_17, bc_decomposition_bytes_pc_plus_18, bc_decomposition_bytes_pc_plus_19, bc_decomposition_bytes_pc_plus_2, bc_decomposition_bytes_pc_plus_20, bc_decomposition_bytes_pc_plus_21, bc_decomposition_bytes_pc_plus_22, bc_decomposition_bytes_pc_plus_23, bc_decomposition_bytes_pc_plus_24, bc_decomposition_bytes_pc_plus_25, bc_decomposition_bytes_pc_plus_26, bc_decomposition_bytes_pc_plus_27, bc_decomposition_bytes_pc_plus_28, bc_decomposition_bytes_pc_plus_29, bc_decomposition_bytes_pc_plus_3, bc_decomposition_bytes_pc_plus_30, bc_decomposition_bytes_pc_plus_31, bc_decomposition_bytes_pc_plus_32, bc_decomposition_bytes_pc_plus_33, bc_decomposition_bytes_pc_plus_34, bc_decomposition_bytes_pc_plus_35, bc_decomposition_bytes_pc_plus_36, bc_decomposition_bytes_pc_plus_4, bc_decomposition_bytes_pc_plus_5, bc_decomposition_bytes_pc_plus_6, bc_decomposition_bytes_pc_plus_7, bc_decomposition_bytes_pc_plus_8, bc_decomposition_bytes_pc_plus_9, bc_decomposition_bytes_rem_inv, bc_decomposition_bytes_rem_min_one_inv, bc_decomposition_bytes_remaining, bc_decomposition_bytes_to_read, bc_decomposition_bytes_to_read_unary, bc_decomposition_id, bc_decomposition_last_of_contract, bc_decomposition_packed_field, bc_decomposition_pc, bc_decomposition_sel, bc_decomposition_sel_overflow_correction_needed, bc_decomposition_sel_packed, bc_decomposition_sel_pc_plus_1, bc_decomposition_sel_pc_plus_10, bc_decomposition_sel_pc_plus_11, bc_decomposition_sel_pc_plus_12, bc_decomposition_sel_pc_plus_13, bc_decomposition_sel_pc_plus_14, bc_decomposition_sel_pc_plus_15, bc_decomposition_sel_pc_plus_16, bc_decomposition_sel_pc_plus_17, bc_decomposition_sel_pc_plus_18, bc_decomposition_sel_pc_plus_19, bc_decomposition_sel_pc_plus_2, bc_decomposition_sel_pc_plus_20, bc_decomposition_sel_pc_plus_21, bc_decomposition_sel_pc_plus_22, bc_decomposition_sel_pc_plus_23, bc_decomposition_sel_pc_plus_24, bc_decomposition_sel_pc_plus_25, bc_decomposition_sel_pc_plus_26, bc_decomposition_sel_pc_plus_27, bc_decomposition_sel_pc_plus_28, bc_decomposition_sel_pc_plus_29, bc_decomposition_sel_pc_plus_3, bc_decomposition_sel_pc_plus_30, bc_decomposition_sel_pc_plus_31, bc_decomposition_sel_pc_plus_32, bc_decomposition_sel_pc_plus_33, bc_decomposition_sel_pc_plus_34, bc_decomposition_sel_pc_plus_35, bc_decomposition_sel_pc_plus_36, bc_decomposition_sel_pc_plus_4, bc_decomposition_sel_pc_plus_5, bc_decomposition_sel_pc_plus_6, bc_decomposition_sel_pc_plus_7, bc_decomposition_sel_pc_plus_8, bc_decomposition_sel_pc_plus_9, bc_hashing_bytecode_id, bc_hashing_incremental_hash, bc_hashing_latch, bc_hashing_output_hash, bc_hashing_packed_field, bc_hashing_pc_index, bc_hashing_sel, bc_hashing_start, bc_retrieval_address, bc_retrieval_artifact_hash, bc_retrieval_bytecode_id, bc_retrieval_class_id, bc_retrieval_deployer_addr, bc_retrieval_err, bc_retrieval_incoming_viewing_key_x, bc_retrieval_incoming_viewing_key_y, bc_retrieval_init_hash, bc_retrieval_nullifier_key_x, bc_retrieval_nullifier_key_y, bc_retrieval_outgoing_viewing_key_x, bc_retrieval_outgoing_viewing_key_y, bc_retrieval_private_function_root, bc_retrieval_public_bytecode_commitment, bc_retrieval_salt, bc_retrieval_sel, bc_retrieval_siloed_address, bc_retrieval_tagging_key_x, bc_retrieval_tagging_key_y, bitwise_acc_ia, bitwise_acc_ib, bitwise_acc_ic, bitwise_ctr, bitwise_ctr_inv, bitwise_ctr_min_one_inv, bitwise_ia_byte, bitwise_ib_byte, bitwise_ic_byte, bitwise_last, bitwise_op_id, bitwise_sel, bitwise_start, bitwise_tag, class_id_derivation_artifact_hash, class_id_derivation_class_id, class_id_derivation_private_function_root, class_id_derivation_public_bytecode_commitment, class_id_derivation_sel, class_id_derivation_temp_constant_for_lookup, ecc_add_op, ecc_double_op, ecc_inv_2_p_y, ecc_inv_x_diff, ecc_inv_y_diff, ecc_lambda, ecc_p_is_inf, ecc_p_x, ecc_p_y, ecc_q_is_inf, ecc_q_x, ecc_q_y, ecc_r_is_inf, ecc_r_x, ecc_r_y, ecc_result_infinity, ecc_sel, ecc_x_match, ecc_y_match, execution_addressing_error_idx, execution_addressing_error_kind, execution_base_address_tag, execution_base_address_val, execution_bytecode_id, execution_clk, execution_ex_opcode, execution_indirect, execution_last, execution_op1, execution_op1_after_relative, execution_op2, execution_op2_after_relative, execution_op3, execution_op3_after_relative, execution_op4, execution_op4_after_relative, execution_pc, execution_rop1, execution_rop2, execution_rop3, execution_rop4, execution_sel, execution_sel_addressing_error, execution_sel_op1_is_address, execution_sel_op2_is_address, execution_sel_op3_is_address, execution_sel_op4_is_address, instr_fetching_bd0, instr_fetching_bd1, instr_fetching_bd10, instr_fetching_bd11, instr_fetching_bd12, instr_fetching_bd13, instr_fetching_bd14, instr_fetching_bd15, instr_fetching_bd16, instr_fetching_bd17, instr_fetching_bd18, instr_fetching_bd19, instr_fetching_bd2, instr_fetching_bd20, instr_fetching_bd21, instr_fetching_bd22, instr_fetching_bd23, instr_fetching_bd24, instr_fetching_bd25, instr_fetching_bd26, instr_fetching_bd27, instr_fetching_bd28, instr_fetching_bd29, instr_fetching_bd3, instr_fetching_bd30, instr_fetching_bd31, instr_fetching_bd32, instr_fetching_bd33, instr_fetching_bd34, instr_fetching_bd35, instr_fetching_bd36, instr_fetching_bd4, instr_fetching_bd5, instr_fetching_bd6, instr_fetching_bd7, instr_fetching_bd8, instr_fetching_bd9, instr_fetching_bytecode_id, instr_fetching_bytecode_size, instr_fetching_bytes_to_read, instr_fetching_exec_opcode, instr_fetching_indirect, instr_fetching_instr_abs_diff, instr_fetching_instr_out_of_range, instr_fetching_instr_size, instr_fetching_op1, instr_fetching_op2, instr_fetching_op3, instr_fetching_op4, instr_fetching_op5, instr_fetching_op6, instr_fetching_op7, instr_fetching_opcode_out_of_range, instr_fetching_parsing_err, instr_fetching_pc, instr_fetching_pc_abs_diff, instr_fetching_pc_out_of_range, instr_fetching_sel, instr_fetching_sel_op_dc_0, instr_fetching_sel_op_dc_1, instr_fetching_sel_op_dc_10, instr_fetching_sel_op_dc_11, instr_fetching_sel_op_dc_12, instr_fetching_sel_op_dc_13, instr_fetching_sel_op_dc_14, instr_fetching_sel_op_dc_15, instr_fetching_sel_op_dc_16, instr_fetching_sel_op_dc_17, instr_fetching_sel_op_dc_2, instr_fetching_sel_op_dc_3, instr_fetching_sel_op_dc_4, instr_fetching_sel_op_dc_5, instr_fetching_sel_op_dc_6, instr_fetching_sel_op_dc_7, instr_fetching_sel_op_dc_8, instr_fetching_sel_op_dc_9, instr_fetching_sel_opcode_defined, instr_fetching_thirty_two, poseidon2_hash_a_0, poseidon2_hash_a_1, poseidon2_hash_a_2, poseidon2_hash_a_3, poseidon2_hash_b_0, poseidon2_hash_b_1, poseidon2_hash_b_2, poseidon2_hash_b_3, poseidon2_hash_end, poseidon2_hash_input_0, poseidon2_hash_input_1, poseidon2_hash_input_2, poseidon2_hash_input_len, poseidon2_hash_num_perm_rounds_rem, poseidon2_hash_num_perm_rounds_rem_inv, poseidon2_hash_output, poseidon2_hash_padding, poseidon2_hash_sel, poseidon2_hash_start, poseidon2_perm_B_10_0, poseidon2_perm_B_10_1, poseidon2_perm_B_10_2, poseidon2_perm_B_10_3, poseidon2_perm_B_11_0, poseidon2_perm_B_11_1, poseidon2_perm_B_11_2, poseidon2_perm_B_11_3, poseidon2_perm_B_12_0, poseidon2_perm_B_12_1, poseidon2_perm_B_12_2, poseidon2_perm_B_12_3, poseidon2_perm_B_13_0, poseidon2_perm_B_13_1, poseidon2_perm_B_13_2, poseidon2_perm_B_13_3, poseidon2_perm_B_14_0, poseidon2_perm_B_14_1, poseidon2_perm_B_14_2, poseidon2_perm_B_14_3, poseidon2_perm_B_15_0, poseidon2_perm_B_15_1, poseidon2_perm_B_15_2, poseidon2_perm_B_15_3, poseidon2_perm_B_16_0, poseidon2_perm_B_16_1, poseidon2_perm_B_16_2, poseidon2_perm_B_16_3, poseidon2_perm_B_17_0, poseidon2_perm_B_17_1, poseidon2_perm_B_17_2, poseidon2_perm_B_17_3, poseidon2_perm_B_18_0, poseidon2_perm_B_18_1, poseidon2_perm_B_18_2, poseidon2_perm_B_18_3, poseidon2_perm_B_19_0, poseidon2_perm_B_19_1, poseidon2_perm_B_19_2, poseidon2_perm_B_19_3, poseidon2_perm_B_20_0, poseidon2_perm_B_20_1, poseidon2_perm_B_20_2, poseidon2_perm_B_20_3, poseidon2_perm_B_21_0, poseidon2_perm_B_21_1, poseidon2_perm_B_21_2, poseidon2_perm_B_21_3, poseidon2_perm_B_22_0, poseidon2_perm_B_22_1, poseidon2_perm_B_22_2, poseidon2_perm_B_22_3, poseidon2_perm_B_23_0, poseidon2_perm_B_23_1, poseidon2_perm_B_23_2, poseidon2_perm_B_23_3, poseidon2_perm_B_24_0, poseidon2_perm_B_24_1, poseidon2_perm_B_24_2, poseidon2_perm_B_24_3, poseidon2_perm_B_25_0, poseidon2_perm_B_25_1, poseidon2_perm_B_25_2, poseidon2_perm_B_25_3, poseidon2_perm_B_26_0, poseidon2_perm_B_26_1, poseidon2_perm_B_26_2, poseidon2_perm_B_26_3, poseidon2_perm_B_27_0, poseidon2_perm_B_27_1, poseidon2_perm_B_27_2, poseidon2_perm_B_27_3, poseidon2_perm_B_28_0, poseidon2_perm_B_28_1, poseidon2_perm_B_28_2, poseidon2_perm_B_28_3, poseidon2_perm_B_29_0, poseidon2_perm_B_29_1, poseidon2_perm_B_29_2, poseidon2_perm_B_29_3, poseidon2_perm_B_30_0, poseidon2_perm_B_30_1, poseidon2_perm_B_30_2, poseidon2_perm_B_30_3, poseidon2_perm_B_31_0, poseidon2_perm_B_31_1, poseidon2_perm_B_31_2, poseidon2_perm_B_31_3, poseidon2_perm_B_32_0, poseidon2_perm_B_32_1, poseidon2_perm_B_32_2, poseidon2_perm_B_32_3, poseidon2_perm_B_33_0, poseidon2_perm_B_33_1, poseidon2_perm_B_33_2, poseidon2_perm_B_33_3, poseidon2_perm_B_34_0, poseidon2_perm_B_34_1, poseidon2_perm_B_34_2, poseidon2_perm_B_34_3, poseidon2_perm_B_35_0, poseidon2_perm_B_35_1, poseidon2_perm_B_35_2, poseidon2_perm_B_35_3, poseidon2_perm_B_36_0, poseidon2_perm_B_36_1, poseidon2_perm_B_36_2, poseidon2_perm_B_36_3, poseidon2_perm_B_37_0, poseidon2_perm_B_37_1, poseidon2_perm_B_37_2, poseidon2_perm_B_37_3, poseidon2_perm_B_38_0, poseidon2_perm_B_38_1, poseidon2_perm_B_38_2, poseidon2_perm_B_38_3, poseidon2_perm_B_39_0, poseidon2_perm_B_39_1, poseidon2_perm_B_39_2, poseidon2_perm_B_39_3, poseidon2_perm_B_40_0, poseidon2_perm_B_40_1, poseidon2_perm_B_40_2, poseidon2_perm_B_40_3, poseidon2_perm_B_41_0, poseidon2_perm_B_41_1, poseidon2_perm_B_41_2, poseidon2_perm_B_41_3, poseidon2_perm_B_42_0, poseidon2_perm_B_42_1, poseidon2_perm_B_42_2, poseidon2_perm_B_42_3, poseidon2_perm_B_43_0, poseidon2_perm_B_43_1, poseidon2_perm_B_43_2, poseidon2_perm_B_43_3, poseidon2_perm_B_44_0, poseidon2_perm_B_44_1, poseidon2_perm_B_44_2, poseidon2_perm_B_44_3, poseidon2_perm_B_45_0, poseidon2_perm_B_45_1, poseidon2_perm_B_45_2, poseidon2_perm_B_45_3, poseidon2_perm_B_46_0, poseidon2_perm_B_46_1, poseidon2_perm_B_46_2, poseidon2_perm_B_46_3, poseidon2_perm_B_47_0, poseidon2_perm_B_47_1, poseidon2_perm_B_47_2, poseidon2_perm_B_47_3, poseidon2_perm_B_48_0, poseidon2_perm_B_48_1, poseidon2_perm_B_48_2, poseidon2_perm_B_48_3, poseidon2_perm_B_49_0, poseidon2_perm_B_49_1, poseidon2_perm_B_49_2, poseidon2_perm_B_49_3, poseidon2_perm_B_4_0, poseidon2_perm_B_4_1, poseidon2_perm_B_4_2, poseidon2_perm_B_4_3, poseidon2_perm_B_50_0, poseidon2_perm_B_50_1, poseidon2_perm_B_50_2, poseidon2_perm_B_50_3, poseidon2_perm_B_51_0, poseidon2_perm_B_51_1, poseidon2_perm_B_51_2, poseidon2_perm_B_51_3, poseidon2_perm_B_52_0, poseidon2_perm_B_52_1, poseidon2_perm_B_52_2, poseidon2_perm_B_52_3, poseidon2_perm_B_53_0, poseidon2_perm_B_53_1, poseidon2_perm_B_53_2, poseidon2_perm_B_53_3, poseidon2_perm_B_54_0, poseidon2_perm_B_54_1, poseidon2_perm_B_54_2, poseidon2_perm_B_54_3, poseidon2_perm_B_55_0, poseidon2_perm_B_55_1, poseidon2_perm_B_55_2, poseidon2_perm_B_55_3, poseidon2_perm_B_56_0, poseidon2_perm_B_56_1, poseidon2_perm_B_56_2, poseidon2_perm_B_56_3, poseidon2_perm_B_57_0, poseidon2_perm_B_57_1, poseidon2_perm_B_57_2, poseidon2_perm_B_57_3, poseidon2_perm_B_58_0, poseidon2_perm_B_58_1, poseidon2_perm_B_58_2, poseidon2_perm_B_58_3, poseidon2_perm_B_59_0, poseidon2_perm_B_59_1, poseidon2_perm_B_59_2, poseidon2_perm_B_59_3, poseidon2_perm_B_5_0, poseidon2_perm_B_5_1, poseidon2_perm_B_5_2, poseidon2_perm_B_5_3, poseidon2_perm_B_6_0, poseidon2_perm_B_6_1, poseidon2_perm_B_6_2, poseidon2_perm_B_6_3, poseidon2_perm_B_7_0, poseidon2_perm_B_7_1, poseidon2_perm_B_7_2, poseidon2_perm_B_7_3, poseidon2_perm_B_8_0, poseidon2_perm_B_8_1, poseidon2_perm_B_8_2, poseidon2_perm_B_8_3, poseidon2_perm_B_9_0, poseidon2_perm_B_9_1, poseidon2_perm_B_9_2, poseidon2_perm_B_9_3, poseidon2_perm_EXT_LAYER_4, poseidon2_perm_EXT_LAYER_5, poseidon2_perm_EXT_LAYER_6, poseidon2_perm_EXT_LAYER_7, poseidon2_perm_T_0_4, poseidon2_perm_T_0_5, poseidon2_perm_T_0_6, poseidon2_perm_T_0_7, poseidon2_perm_T_1_4, poseidon2_perm_T_1_5, poseidon2_perm_T_1_6, poseidon2_perm_T_1_7, poseidon2_perm_T_2_4, poseidon2_perm_T_2_5, poseidon2_perm_T_2_6, poseidon2_perm_T_2_7, poseidon2_perm_T_3_4, poseidon2_perm_T_3_5, poseidon2_perm_T_3_6, poseidon2_perm_T_3_7, poseidon2_perm_T_60_4, poseidon2_perm_T_60_5, poseidon2_perm_T_60_6, poseidon2_perm_T_60_7, poseidon2_perm_T_61_4, poseidon2_perm_T_61_5, poseidon2_perm_T_61_6, poseidon2_perm_T_61_7, poseidon2_perm_T_62_4, poseidon2_perm_T_62_5, poseidon2_perm_T_62_6, poseidon2_perm_T_62_7, poseidon2_perm_T_63_4, poseidon2_perm_T_63_5, poseidon2_perm_T_63_6, poseidon2_perm_T_63_7, poseidon2_perm_a_0, poseidon2_perm_a_1, poseidon2_perm_a_2, poseidon2_perm_a_3, poseidon2_perm_b_0, poseidon2_perm_b_1, poseidon2_perm_b_2, poseidon2_perm_b_3, poseidon2_perm_sel, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_rng_chk_bits, range_check_sel, range_check_sel_r0_16_bit_rng_lookup, range_check_sel_r1_16_bit_rng_lookup, range_check_sel_r2_16_bit_rng_lookup, range_check_sel_r3_16_bit_rng_lookup, range_check_sel_r4_16_bit_rng_lookup, range_check_sel_r5_16_bit_rng_lookup, range_check_sel_r6_16_bit_rng_lookup, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, scalar_mul_bit, scalar_mul_bit_idx, scalar_mul_bit_radix, scalar_mul_end, scalar_mul_not_end, scalar_mul_point_inf, scalar_mul_point_x, scalar_mul_point_y, scalar_mul_res_inf, scalar_mul_res_x, scalar_mul_res_y, scalar_mul_scalar, scalar_mul_sel, scalar_mul_should_add, scalar_mul_start, scalar_mul_temp_inf, scalar_mul_temp_x, scalar_mul_temp_y, sha256_a, sha256_a_and_b, sha256_a_and_b_xor_a_and_c, sha256_a_and_c, sha256_a_rotr_13, sha256_a_rotr_2, sha256_a_rotr_22, sha256_a_rotr_2_xor_a_rotr_13, sha256_and_sel, sha256_b, sha256_b_and_c, sha256_c, sha256_ch, sha256_clk, sha256_computed_w_lhs, sha256_computed_w_rhs, sha256_d, sha256_e, sha256_e_and_f, sha256_e_rotr_11, sha256_e_rotr_25, sha256_e_rotr_6, sha256_e_rotr_6_xor_e_rotr_11, sha256_f, sha256_g, sha256_h, sha256_helper_w0, sha256_helper_w1, sha256_helper_w10, sha256_helper_w11, sha256_helper_w12, sha256_helper_w13, sha256_helper_w14, sha256_helper_w15, sha256_helper_w2, sha256_helper_w3, sha256_helper_w4, sha256_helper_w5, sha256_helper_w6, sha256_helper_w7, sha256_helper_w8, sha256_helper_w9, sha256_init_a, sha256_init_b, sha256_init_c, sha256_init_d, sha256_init_e, sha256_init_f, sha256_init_g, sha256_init_h, sha256_input_offset, sha256_is_input_round, sha256_latch, sha256_lhs_a_13, sha256_lhs_a_2, sha256_lhs_a_22, sha256_lhs_e_11, sha256_lhs_e_25, sha256_lhs_e_6, sha256_lhs_w_10, sha256_lhs_w_17, sha256_lhs_w_18, sha256_lhs_w_19, sha256_lhs_w_3, sha256_lhs_w_7, sha256_maj, sha256_next_a_lhs, sha256_next_a_rhs, sha256_next_e_lhs, sha256_next_e_rhs, sha256_not_e, sha256_not_e_and_g, sha256_output_a_lhs, sha256_output_a_rhs, sha256_output_b_lhs, sha256_output_b_rhs, sha256_output_c_lhs, sha256_output_c_rhs, sha256_output_d_lhs, sha256_output_d_rhs, sha256_output_e_lhs, sha256_output_e_rhs, sha256_output_f_lhs, sha256_output_f_rhs, sha256_output_g_lhs, sha256_output_g_rhs, sha256_output_h_lhs, sha256_output_h_rhs, sha256_output_offset, sha256_perform_round, sha256_rhs_a_13, sha256_rhs_a_2, sha256_rhs_a_22, sha256_rhs_e_11, sha256_rhs_e_25, sha256_rhs_e_6, sha256_rhs_w_10, sha256_rhs_w_17, sha256_rhs_w_18, sha256_rhs_w_19, sha256_rhs_w_3, sha256_rhs_w_7, sha256_round_constant, sha256_round_count, sha256_rounds_remaining, sha256_rounds_remaining_inv, sha256_s_0, sha256_s_1, sha256_sel, sha256_start, sha256_state_offset, sha256_w, sha256_w_15_rotr_18, sha256_w_15_rotr_7, sha256_w_15_rotr_7_xor_w_15_rotr_18, sha256_w_15_rshift_3, sha256_w_2_rotr_17, sha256_w_2_rotr_17_xor_w_2_rotr_19, sha256_w_2_rotr_19, sha256_w_2_rshift_10, sha256_w_s_0, sha256_w_s_1, sha256_xor_sel, to_radix_acc, to_radix_acc_under_p, to_radix_end, to_radix_exponent, to_radix_found, to_radix_is_unsafe_limb, to_radix_limb, to_radix_limb_eq_p, to_radix_limb_index, to_radix_limb_lt_p, to_radix_limb_p_diff, to_radix_limb_radix_diff, to_radix_not_end, to_radix_not_padding_limb, to_radix_p_limb, to_radix_radix, to_radix_rem_inverse, to_radix_safe_limbs, to_radix_safety_diff_inverse, to_radix_sel, to_radix_start, to_radix_value, lookup_poseidon2_hash_poseidon2_perm_counts, lookup_range_check_dyn_rng_chk_pow_2_counts, lookup_range_check_dyn_diff_is_u16_counts, lookup_range_check_r0_is_u16_counts, lookup_range_check_r1_is_u16_counts, lookup_range_check_r2_is_u16_counts, lookup_range_check_r3_is_u16_counts, lookup_range_check_r4_is_u16_counts, lookup_range_check_r5_is_u16_counts, lookup_range_check_r6_is_u16_counts, lookup_range_check_r7_is_u16_counts, lookup_to_radix_limb_range_counts, lookup_to_radix_limb_less_than_radix_range_counts, lookup_to_radix_fetch_safe_limbs_counts, lookup_to_radix_fetch_p_limb_counts, lookup_to_radix_limb_p_diff_range_counts, lookup_scalar_mul_to_radix_counts, lookup_scalar_mul_double_counts, lookup_scalar_mul_add_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_0_counts, lookup_address_derivation_salted_initialization_hash_poseidon2_1_counts, lookup_address_derivation_partial_address_poseidon2_counts, lookup_address_derivation_public_keys_hash_poseidon2_0_counts, lookup_address_derivation_public_keys_hash_poseidon2_1_counts, lookup_address_derivation_public_keys_hash_poseidon2_2_counts, lookup_address_derivation_public_keys_hash_poseidon2_3_counts, lookup_address_derivation_public_keys_hash_poseidon2_4_counts, lookup_address_derivation_preaddress_poseidon2_counts, lookup_address_derivation_preaddress_scalar_mul_counts, lookup_address_derivation_address_ecadd_counts, lookup_bc_decomposition_bytes_are_bytes_counts, lookup_bc_decomposition_abs_diff_is_u16_counts, lookup_bc_decomposition_bytes_to_read_as_unary_counts, lookup_bc_hashing_get_packed_field_counts, lookup_bc_hashing_iv_is_len_counts, lookup_bc_hashing_poseidon2_hash_counts, lookup_bc_retrieval_class_id_derivation_counts, lookup_bc_retrieval_bytecode_hash_is_correct_counts, lookup_instr_fetching_instr_abs_diff_positive_counts, lookup_instr_fetching_pc_abs_diff_positive_counts, lookup_instr_fetching_bytecode_size_from_bc_dec_counts, lookup_instr_fetching_bytes_from_bc_dec_counts, lookup_instr_fetching_wire_instruction_info_counts, lookup_class_id_derivation_class_id_poseidon2_0_counts, lookup_class_id_derivation_class_id_poseidon2_1_counts, lookup_bitwise_integral_tag_length_counts, lookup_bitwise_byte_operations_counts, lookup_sha256_round_constant_counts #define AVM2_DERIVED_WITNESS_ENTITIES lookup_poseidon2_hash_poseidon2_perm_inv, lookup_range_check_dyn_rng_chk_pow_2_inv, lookup_range_check_dyn_diff_is_u16_inv, lookup_range_check_r0_is_u16_inv, lookup_range_check_r1_is_u16_inv, lookup_range_check_r2_is_u16_inv, lookup_range_check_r3_is_u16_inv, lookup_range_check_r4_is_u16_inv, lookup_range_check_r5_is_u16_inv, lookup_range_check_r6_is_u16_inv, lookup_range_check_r7_is_u16_inv, lookup_to_radix_limb_range_inv, lookup_to_radix_limb_less_than_radix_range_inv, lookup_to_radix_fetch_safe_limbs_inv, lookup_to_radix_fetch_p_limb_inv, lookup_to_radix_limb_p_diff_range_inv, lookup_scalar_mul_to_radix_inv, lookup_scalar_mul_double_inv, lookup_scalar_mul_add_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_0_inv, lookup_address_derivation_salted_initialization_hash_poseidon2_1_inv, lookup_address_derivation_partial_address_poseidon2_inv, lookup_address_derivation_public_keys_hash_poseidon2_0_inv, lookup_address_derivation_public_keys_hash_poseidon2_1_inv, lookup_address_derivation_public_keys_hash_poseidon2_2_inv, lookup_address_derivation_public_keys_hash_poseidon2_3_inv, lookup_address_derivation_public_keys_hash_poseidon2_4_inv, lookup_address_derivation_preaddress_poseidon2_inv, lookup_address_derivation_preaddress_scalar_mul_inv, lookup_address_derivation_address_ecadd_inv, lookup_bc_decomposition_bytes_are_bytes_inv, lookup_bc_decomposition_abs_diff_is_u16_inv, lookup_bc_decomposition_bytes_to_read_as_unary_inv, lookup_bc_hashing_get_packed_field_inv, lookup_bc_hashing_iv_is_len_inv, lookup_bc_hashing_poseidon2_hash_inv, lookup_bc_retrieval_class_id_derivation_inv, lookup_bc_retrieval_bytecode_hash_is_correct_inv, lookup_instr_fetching_instr_abs_diff_positive_inv, lookup_instr_fetching_pc_abs_diff_positive_inv, lookup_instr_fetching_bytecode_size_from_bc_dec_inv, lookup_instr_fetching_bytes_from_bc_dec_inv, lookup_instr_fetching_wire_instruction_info_inv, lookup_class_id_derivation_class_id_poseidon2_0_inv, lookup_class_id_derivation_class_id_poseidon2_1_inv, lookup_bitwise_integral_tag_length_inv, lookup_bitwise_byte_operations_inv, lookup_sha256_round_constant_inv #define AVM2_SHIFTED_ENTITIES bc_decomposition_bytes_shift, bc_decomposition_bytes_pc_plus_1_shift, bc_decomposition_bytes_pc_plus_10_shift, bc_decomposition_bytes_pc_plus_11_shift, bc_decomposition_bytes_pc_plus_12_shift, bc_decomposition_bytes_pc_plus_13_shift, bc_decomposition_bytes_pc_plus_14_shift, bc_decomposition_bytes_pc_plus_15_shift, bc_decomposition_bytes_pc_plus_16_shift, bc_decomposition_bytes_pc_plus_17_shift, bc_decomposition_bytes_pc_plus_18_shift, bc_decomposition_bytes_pc_plus_19_shift, bc_decomposition_bytes_pc_plus_2_shift, bc_decomposition_bytes_pc_plus_20_shift, bc_decomposition_bytes_pc_plus_21_shift, bc_decomposition_bytes_pc_plus_22_shift, bc_decomposition_bytes_pc_plus_23_shift, bc_decomposition_bytes_pc_plus_24_shift, bc_decomposition_bytes_pc_plus_25_shift, bc_decomposition_bytes_pc_plus_26_shift, bc_decomposition_bytes_pc_plus_27_shift, bc_decomposition_bytes_pc_plus_28_shift, bc_decomposition_bytes_pc_plus_29_shift, bc_decomposition_bytes_pc_plus_3_shift, bc_decomposition_bytes_pc_plus_30_shift, bc_decomposition_bytes_pc_plus_31_shift, bc_decomposition_bytes_pc_plus_32_shift, bc_decomposition_bytes_pc_plus_33_shift, bc_decomposition_bytes_pc_plus_34_shift, bc_decomposition_bytes_pc_plus_35_shift, bc_decomposition_bytes_pc_plus_4_shift, bc_decomposition_bytes_pc_plus_5_shift, bc_decomposition_bytes_pc_plus_6_shift, bc_decomposition_bytes_pc_plus_7_shift, bc_decomposition_bytes_pc_plus_8_shift, bc_decomposition_bytes_pc_plus_9_shift, bc_decomposition_bytes_remaining_shift, bc_decomposition_id_shift, bc_decomposition_pc_shift, bc_decomposition_sel_shift, bc_hashing_bytecode_id_shift, bc_hashing_incremental_hash_shift, bc_hashing_pc_index_shift, bc_hashing_sel_shift, bc_hashing_start_shift, bitwise_acc_ia_shift, bitwise_acc_ib_shift, bitwise_acc_ic_shift, bitwise_ctr_shift, bitwise_op_id_shift, execution_sel_shift, poseidon2_hash_a_0_shift, poseidon2_hash_a_1_shift, poseidon2_hash_a_2_shift, poseidon2_hash_a_3_shift, poseidon2_hash_input_0_shift, poseidon2_hash_input_1_shift, poseidon2_hash_input_2_shift, poseidon2_hash_num_perm_rounds_rem_shift, poseidon2_hash_output_shift, poseidon2_hash_sel_shift, poseidon2_hash_start_shift, scalar_mul_bit_idx_shift, scalar_mul_point_inf_shift, scalar_mul_point_x_shift, scalar_mul_point_y_shift, scalar_mul_res_inf_shift, scalar_mul_res_x_shift, scalar_mul_res_y_shift, scalar_mul_scalar_shift, scalar_mul_sel_shift, scalar_mul_start_shift, scalar_mul_temp_inf_shift, scalar_mul_temp_x_shift, scalar_mul_temp_y_shift, sha256_a_shift, sha256_b_shift, sha256_c_shift, sha256_d_shift, sha256_e_shift, sha256_f_shift, sha256_g_shift, sha256_h_shift, sha256_helper_w0_shift, sha256_helper_w1_shift, sha256_helper_w10_shift, sha256_helper_w11_shift, sha256_helper_w12_shift, sha256_helper_w13_shift, sha256_helper_w14_shift, sha256_helper_w15_shift, sha256_helper_w2_shift, sha256_helper_w3_shift, sha256_helper_w4_shift, sha256_helper_w5_shift, sha256_helper_w6_shift, sha256_helper_w7_shift, sha256_helper_w8_shift, sha256_helper_w9_shift, sha256_rounds_remaining_shift, sha256_sel_shift, sha256_start_shift, to_radix_acc_shift, to_radix_acc_under_p_shift, to_radix_exponent_shift, to_radix_limb_shift, to_radix_limb_eq_p_shift, to_radix_limb_index_shift, to_radix_limb_lt_p_shift, to_radix_not_padding_limb_shift, to_radix_radix_shift, to_radix_safe_limbs_shift, to_radix_sel_shift, to_radix_start_shift, to_radix_value_shift #define AVM2_TO_BE_SHIFTED(e) e.bc_decomposition_bytes, e.bc_decomposition_bytes_pc_plus_1, e.bc_decomposition_bytes_pc_plus_10, e.bc_decomposition_bytes_pc_plus_11, e.bc_decomposition_bytes_pc_plus_12, e.bc_decomposition_bytes_pc_plus_13, e.bc_decomposition_bytes_pc_plus_14, e.bc_decomposition_bytes_pc_plus_15, e.bc_decomposition_bytes_pc_plus_16, e.bc_decomposition_bytes_pc_plus_17, e.bc_decomposition_bytes_pc_plus_18, e.bc_decomposition_bytes_pc_plus_19, e.bc_decomposition_bytes_pc_plus_2, e.bc_decomposition_bytes_pc_plus_20, e.bc_decomposition_bytes_pc_plus_21, e.bc_decomposition_bytes_pc_plus_22, e.bc_decomposition_bytes_pc_plus_23, e.bc_decomposition_bytes_pc_plus_24, e.bc_decomposition_bytes_pc_plus_25, e.bc_decomposition_bytes_pc_plus_26, e.bc_decomposition_bytes_pc_plus_27, e.bc_decomposition_bytes_pc_plus_28, e.bc_decomposition_bytes_pc_plus_29, e.bc_decomposition_bytes_pc_plus_3, e.bc_decomposition_bytes_pc_plus_30, e.bc_decomposition_bytes_pc_plus_31, e.bc_decomposition_bytes_pc_plus_32, e.bc_decomposition_bytes_pc_plus_33, e.bc_decomposition_bytes_pc_plus_34, e.bc_decomposition_bytes_pc_plus_35, e.bc_decomposition_bytes_pc_plus_4, e.bc_decomposition_bytes_pc_plus_5, e.bc_decomposition_bytes_pc_plus_6, e.bc_decomposition_bytes_pc_plus_7, e.bc_decomposition_bytes_pc_plus_8, e.bc_decomposition_bytes_pc_plus_9, e.bc_decomposition_bytes_remaining, e.bc_decomposition_id, e.bc_decomposition_pc, e.bc_decomposition_sel, e.bc_hashing_bytecode_id, e.bc_hashing_incremental_hash, e.bc_hashing_pc_index, e.bc_hashing_sel, e.bc_hashing_start, e.bitwise_acc_ia, e.bitwise_acc_ib, e.bitwise_acc_ic, e.bitwise_ctr, e.bitwise_op_id, e.execution_sel, e.poseidon2_hash_a_0, e.poseidon2_hash_a_1, e.poseidon2_hash_a_2, e.poseidon2_hash_a_3, e.poseidon2_hash_input_0, e.poseidon2_hash_input_1, e.poseidon2_hash_input_2, e.poseidon2_hash_num_perm_rounds_rem, e.poseidon2_hash_output, e.poseidon2_hash_sel, e.poseidon2_hash_start, e.scalar_mul_bit_idx, e.scalar_mul_point_inf, e.scalar_mul_point_x, e.scalar_mul_point_y, e.scalar_mul_res_inf, e.scalar_mul_res_x, e.scalar_mul_res_y, e.scalar_mul_scalar, e.scalar_mul_sel, e.scalar_mul_start, e.scalar_mul_temp_inf, e.scalar_mul_temp_x, e.scalar_mul_temp_y, e.sha256_a, e.sha256_b, e.sha256_c, e.sha256_d, e.sha256_e, e.sha256_f, e.sha256_g, e.sha256_h, e.sha256_helper_w0, e.sha256_helper_w1, e.sha256_helper_w10, e.sha256_helper_w11, e.sha256_helper_w12, e.sha256_helper_w13, e.sha256_helper_w14, e.sha256_helper_w15, e.sha256_helper_w2, e.sha256_helper_w3, e.sha256_helper_w4, e.sha256_helper_w5, e.sha256_helper_w6, e.sha256_helper_w7, e.sha256_helper_w8, e.sha256_helper_w9, e.sha256_rounds_remaining, e.sha256_sel, e.sha256_start, e.to_radix_acc, e.to_radix_acc_under_p, e.to_radix_exponent, e.to_radix_limb, e.to_radix_limb_eq_p, e.to_radix_limb_index, e.to_radix_limb_lt_p, e.to_radix_not_padding_limb, e.to_radix_radix, e.to_radix_safe_limbs, e.to_radix_sel, e.to_radix_start, e.to_radix_value diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp index f4fb0c3fd61b..4af5010212f3 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp @@ -89,8 +89,8 @@ class AvmFlavor { // This flavor would not be used with ZK Sumcheck static constexpr bool HasZK = false; - static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 45; - static constexpr size_t NUM_WITNESS_ENTITIES = 869; + static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 44; + static constexpr size_t NUM_WITNESS_ENTITIES = 870; static constexpr size_t NUM_SHIFTED_ENTITIES = 115; static constexpr size_t NUM_WIRES = NUM_WITNESS_ENTITIES + NUM_PRECOMPUTED_ENTITIES; // We have two copies of the witness entities, so we subtract the number of fixed ones (they have no shift), one for @@ -473,7 +473,6 @@ class AvmFlavor { this->precomputed_sel_unary = verification_key->precomputed_sel_unary; this->precomputed_sha256_compression_round_constant = verification_key->precomputed_sha256_compression_round_constant; - this->precomputed_thirty_two = verification_key->precomputed_thirty_two; this->precomputed_to_radix_safe_limbs = verification_key->precomputed_to_radix_safe_limbs; this->precomputed_zero = verification_key->precomputed_zero; } diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_instr_fetching.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_instr_fetching.hpp index a1d20c6fe72c..03e481483302 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_instr_fetching.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_instr_fetching.hpp @@ -118,7 +118,7 @@ class lookup_instr_fetching_pc_abs_diff_positive_settings { static constexpr Column COUNTS = Column::lookup_instr_fetching_pc_abs_diff_positive_counts; static constexpr Column INVERSES = Column::lookup_instr_fetching_pc_abs_diff_positive_inv; static constexpr std::array SRC_COLUMNS = { - ColumnAndShifts::instr_fetching_pc_abs_diff, ColumnAndShifts::precomputed_thirty_two + ColumnAndShifts::instr_fetching_pc_abs_diff, ColumnAndShifts::instr_fetching_thirty_two }; static constexpr std::array DST_COLUMNS = { ColumnAndShifts::range_check_value, ColumnAndShifts::range_check_rng_chk_bits @@ -155,7 +155,7 @@ class lookup_instr_fetching_pc_abs_diff_positive_settings { in._instr_fetching_sel(), in._range_check_sel(), in._instr_fetching_pc_abs_diff(), - in._precomputed_thirty_two(), + in._instr_fetching_thirty_two(), in._range_check_value(), in._range_check_rng_chk_bits()); } diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.cpp index 895483a97699..a02f4d02e42f 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/bytecode_manager.cpp @@ -56,37 +56,40 @@ BytecodeId TxBytecodeManager::get_bytecode(const AztecAddress& address) Instruction TxBytecodeManager::read_instruction(BytecodeId bytecode_id, uint32_t pc) { + // We'll be filling in the event as we progress. + InstructionFetchingEvent instr_fetching_event; + auto it = bytecodes.find(bytecode_id); if (it == bytecodes.end()) { throw std::runtime_error("Bytecode not found"); } + instr_fetching_event.bytecode_id = bytecode_id; + instr_fetching_event.pc = pc; + auto bytecode_ptr = it->second; + instr_fetching_event.bytecode = bytecode_ptr; + const auto& bytecode = *bytecode_ptr; - InstrDeserializationError instr_fetch_err = InstrDeserializationError::NO_ERROR; - Instruction instruction; + instr_fetching_event.error = InstrDeserializationError::NO_ERROR; // TODO: Propagate instruction fetching error to the upper layer (execution loop) try { - instruction = deserialize_instruction(bytecode, pc); + instr_fetching_event.instruction = deserialize_instruction(bytecode, pc); } catch (const InstrDeserializationError& error) { - instr_fetch_err = error; + instr_fetching_event.error = error; } + // We are showing whether bytecode_size > pc or not. If there is no fetching error, + // we always have bytecode_size > pc. const auto bytecode_size = bytecode_ptr->size(); const uint128_t pc_diff = bytecode_size > pc ? bytecode_size - pc - 1 : pc - bytecode_size; range_check.assert_range(pc_diff, AVM_PC_SIZE_IN_BITS); // The event will be deduplicated internally. - fetching_events.emit({ - .bytecode_id = bytecode_id, - .pc = pc, - .instruction = instruction, - .bytecode = bytecode_ptr, - .error = instr_fetch_err, - }); + fetching_events.emit(InstructionFetchingEvent(instr_fetching_event)); - return instruction; + return instr_fetching_event.instruction; } } // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.cpp index bb3e89e9f211..0c5c3b84b2c5 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.cpp @@ -17,7 +17,6 @@ #include "barretenberg/vm2/common/stringify.hpp" namespace bb::avm2::simulation { -using avm2::to_hex; const std::unordered_map OPERAND_TYPE_SIZE_BYTES = { { OperandType::INDIRECT8, 1 }, { OperandType::INDIRECT16, 2 }, { OperandType::TAG, 1 }, @@ -368,15 +367,15 @@ Instruction deserialize_instruction(std::span bytecode, size_t po const auto bytecode_length = bytecode.size(); if (pos >= bytecode_length) { - info("PC is out of range. Position: " + std::to_string(pos) + - " Bytecode length: " + std::to_string(bytecode_length)); + vinfo("PC is out of range. Position: " + std::to_string(pos) + + " Bytecode length: " + std::to_string(bytecode_length)); throw InstrDeserializationError::PC_OUT_OF_RANGE; } const uint8_t opcode_byte = bytecode[pos]; if (!is_wire_opcode_valid(opcode_byte)) { - info("Invalid wire opcode byte: 0x" + to_hex(opcode_byte) + " at position: " + std::to_string(pos)); + vinfo("Invalid wire opcode byte: 0x" + to_hex(opcode_byte) + " at position: " + std::to_string(pos)); throw InstrDeserializationError::OPCODE_OUT_OF_RANGE; } @@ -390,14 +389,14 @@ Instruction deserialize_instruction(std::span bytecode, size_t po // We know we will encounter a parsing error, but continue processing because // we need the partial instruction to be parsed for witness generation. if (pos + instruction_size > bytecode_length) { - info("Instruction does not fit in remaining bytecode. Wire opcode: ", - opcode, - " pos: ", - pos, - " instruction size: ", - instruction_size, - " bytecode length: ", - bytecode_length); + vinfo("Instruction does not fit in remaining bytecode. Wire opcode: ", + opcode, + " pos: ", + pos, + " instruction size: ", + instruction_size, + " bytecode length: ", + bytecode_length); throw InstrDeserializationError::INSTRUCTION_OUT_OF_RANGE; } @@ -415,7 +414,7 @@ Instruction deserialize_instruction(std::span bytecode, size_t po uint8_t tag_u8 = bytecode[pos]; // TODO: To handle in a subsequent PR (not decided if handled in specific opcode gadgets) // if (tag_u8 > MAX_MEM_TAG) { - // info("Instruction tag is invalid at position " + std::to_string(pos) + + // vinfo("Instruction tag is invalid at position " + std::to_string(pos) + // " value: " + std::to_string(tag_u8) + " for WireOpCode: " + to_string(WireOpCode)); // return InstructionWithError{ // .instruction = Instruction(WireOpCode::LAST_WireOpCode_SENTINEL, {}), diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp index 1d460721de92..9452cf3fe7ed 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/serialization.hpp @@ -89,12 +89,6 @@ enum class InstrDeserializationError : uint8_t { INSTRUCTION_OUT_OF_RANGE, }; -// Structure to group an instruction and an error -struct InstructionWithError { - Instruction instruction; - InstrDeserializationError error = InstrDeserializationError::NO_ERROR; -}; - /** * @brief Parsing of an instruction in the supplied bytecode at byte position pos. This * checks that the WireOpCode value is in the defined range and extracts the operands diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp index bf33839858bd..cf06b1bbf8ae 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp @@ -8,6 +8,7 @@ #include #include "barretenberg/crypto/poseidon2/poseidon2.hpp" +#include "barretenberg/vm/aztec_constants.hpp" #include "barretenberg/vm2/common/instruction_spec.hpp" #include "barretenberg/vm2/simulation/events/bytecode_events.hpp" #include "barretenberg/vm2/simulation/events/event_emitter.hpp" @@ -268,118 +269,126 @@ void BytecodeTraceBuilder::process_instruction_fetching( const uint8_t wire_opcode = bytecode_at(event.pc); const bool wire_opcode_in_range = event.error != PC_OUT_OF_RANGE && wire_opcode < static_cast(WireOpCode::LAST_OPCODE_SENTINEL); - const auto wire_instr_spec = wire_opcode_in_range - ? WIRE_INSTRUCTION_SPEC.at(static_cast(wire_opcode)) - : WireInstructionSpec{ .exec_opcode = static_cast(0), - .size_in_bytes = 0, - .op_dc_selectors = {} }; + + uint32_t size_in_bytes = 0; + ExecutionOpCode exec_opcode = static_cast(0); + std::array op_dc_selectors{}; + + if (wire_opcode_in_range) { + const auto& wire_instr_spec = WIRE_INSTRUCTION_SPEC.at(static_cast(wire_opcode)); + size_in_bytes = wire_instr_spec.size_in_bytes; + exec_opcode = wire_instr_spec.exec_opcode; + op_dc_selectors = wire_instr_spec.op_dc_selectors; + } const uint32_t bytes_remaining = event.error == PC_OUT_OF_RANGE ? 0 : static_cast(bytecode_size - event.pc); const uint32_t bytes_to_read = std::min(bytes_remaining, DECOMPOSE_WINDOW_SIZE); uint32_t instr_abs_diff = 0; - if (wire_instr_spec.size_in_bytes <= bytes_to_read) { - instr_abs_diff = bytes_to_read - wire_instr_spec.size_in_bytes; + if (size_in_bytes <= bytes_to_read) { + instr_abs_diff = bytes_to_read - size_in_bytes; } else { - instr_abs_diff = wire_instr_spec.size_in_bytes - bytes_to_read - 1; + instr_abs_diff = size_in_bytes - bytes_to_read - 1; } uint32_t bytecode_size_u32 = static_cast(bytecode_size); uint32_t pc_abs_diff = bytecode_size_u32 > event.pc ? bytecode_size_u32 - event.pc - 1 : event.pc - bytecode_size_u32; - trace.set(row, - { { - { C::instr_fetching_sel, 1 }, - { C::instr_fetching_bytecode_id, bytecode_id }, - { C::instr_fetching_pc, event.pc }, - // indirect + operands. - { C::instr_fetching_indirect, event.instruction.indirect }, - { C::instr_fetching_op1, get_operand(0) }, - { C::instr_fetching_op2, get_operand(1) }, - { C::instr_fetching_op3, get_operand(2) }, - { C::instr_fetching_op4, get_operand(3) }, - { C::instr_fetching_op5, get_operand(4) }, - { C::instr_fetching_op6, get_operand(5) }, - { C::instr_fetching_op7, get_operand(6) }, - // Single bytes. - { C::instr_fetching_bd0, wire_opcode }, - { C::instr_fetching_bd1, bytecode_at(event.pc + 1) }, - { C::instr_fetching_bd2, bytecode_at(event.pc + 2) }, - { C::instr_fetching_bd3, bytecode_at(event.pc + 3) }, - { C::instr_fetching_bd4, bytecode_at(event.pc + 4) }, - { C::instr_fetching_bd5, bytecode_at(event.pc + 5) }, - { C::instr_fetching_bd6, bytecode_at(event.pc + 6) }, - { C::instr_fetching_bd7, bytecode_at(event.pc + 7) }, - { C::instr_fetching_bd8, bytecode_at(event.pc + 8) }, - { C::instr_fetching_bd9, bytecode_at(event.pc + 9) }, - { C::instr_fetching_bd10, bytecode_at(event.pc + 10) }, - { C::instr_fetching_bd11, bytecode_at(event.pc + 11) }, - { C::instr_fetching_bd12, bytecode_at(event.pc + 12) }, - { C::instr_fetching_bd13, bytecode_at(event.pc + 13) }, - { C::instr_fetching_bd14, bytecode_at(event.pc + 14) }, - { C::instr_fetching_bd15, bytecode_at(event.pc + 15) }, - { C::instr_fetching_bd16, bytecode_at(event.pc + 16) }, - { C::instr_fetching_bd17, bytecode_at(event.pc + 17) }, - { C::instr_fetching_bd18, bytecode_at(event.pc + 18) }, - { C::instr_fetching_bd19, bytecode_at(event.pc + 19) }, - { C::instr_fetching_bd20, bytecode_at(event.pc + 20) }, - { C::instr_fetching_bd21, bytecode_at(event.pc + 21) }, - { C::instr_fetching_bd22, bytecode_at(event.pc + 22) }, - { C::instr_fetching_bd23, bytecode_at(event.pc + 23) }, - { C::instr_fetching_bd24, bytecode_at(event.pc + 24) }, - { C::instr_fetching_bd25, bytecode_at(event.pc + 25) }, - { C::instr_fetching_bd26, bytecode_at(event.pc + 26) }, - { C::instr_fetching_bd27, bytecode_at(event.pc + 27) }, - { C::instr_fetching_bd28, bytecode_at(event.pc + 28) }, - { C::instr_fetching_bd29, bytecode_at(event.pc + 29) }, - { C::instr_fetching_bd30, bytecode_at(event.pc + 30) }, - { C::instr_fetching_bd31, bytecode_at(event.pc + 31) }, - { C::instr_fetching_bd32, bytecode_at(event.pc + 32) }, - { C::instr_fetching_bd33, bytecode_at(event.pc + 33) }, - { C::instr_fetching_bd34, bytecode_at(event.pc + 34) }, - { C::instr_fetching_bd35, bytecode_at(event.pc + 35) }, - { C::instr_fetching_bd36, bytecode_at(event.pc + 36) }, - - // From instruction table. - { C::instr_fetching_exec_opcode, static_cast(wire_instr_spec.exec_opcode) }, - { C::instr_fetching_instr_size, wire_instr_spec.size_in_bytes }, - - // Fill operand decomposition selectors - { C::instr_fetching_sel_op_dc_0, wire_instr_spec.op_dc_selectors.at(0) }, - { C::instr_fetching_sel_op_dc_1, wire_instr_spec.op_dc_selectors.at(1) }, - { C::instr_fetching_sel_op_dc_2, wire_instr_spec.op_dc_selectors.at(2) }, - { C::instr_fetching_sel_op_dc_3, wire_instr_spec.op_dc_selectors.at(3) }, - { C::instr_fetching_sel_op_dc_4, wire_instr_spec.op_dc_selectors.at(4) }, - { C::instr_fetching_sel_op_dc_5, wire_instr_spec.op_dc_selectors.at(5) }, - { C::instr_fetching_sel_op_dc_6, wire_instr_spec.op_dc_selectors.at(6) }, - { C::instr_fetching_sel_op_dc_7, wire_instr_spec.op_dc_selectors.at(7) }, - { C::instr_fetching_sel_op_dc_8, wire_instr_spec.op_dc_selectors.at(8) }, - { C::instr_fetching_sel_op_dc_9, wire_instr_spec.op_dc_selectors.at(9) }, - { C::instr_fetching_sel_op_dc_10, wire_instr_spec.op_dc_selectors.at(10) }, - { C::instr_fetching_sel_op_dc_11, wire_instr_spec.op_dc_selectors.at(11) }, - { C::instr_fetching_sel_op_dc_12, wire_instr_spec.op_dc_selectors.at(12) }, - { C::instr_fetching_sel_op_dc_13, wire_instr_spec.op_dc_selectors.at(13) }, - { C::instr_fetching_sel_op_dc_14, wire_instr_spec.op_dc_selectors.at(14) }, - { C::instr_fetching_sel_op_dc_15, wire_instr_spec.op_dc_selectors.at(15) }, - { C::instr_fetching_sel_op_dc_16, wire_instr_spec.op_dc_selectors.at(16) }, - { C::instr_fetching_sel_op_dc_17, wire_instr_spec.op_dc_selectors.at(17) }, - - // Parsing errors - { C::instr_fetching_pc_out_of_range, event.error == PC_OUT_OF_RANGE ? 1 : 0 }, - { C::instr_fetching_opcode_out_of_range, event.error == OPCODE_OUT_OF_RANGE ? 1 : 0 }, - { C::instr_fetching_instr_out_of_range, event.error == INSTRUCTION_OUT_OF_RANGE ? 1 : 0 }, - { C::instr_fetching_parsing_err, event.error != NO_ERROR ? 1 : 0 }, - - // selector for lookups - { C::instr_fetching_sel_opcode_defined, event.error != PC_OUT_OF_RANGE ? 1 : 0 }, - - { C::instr_fetching_bytecode_size, bytecode_size }, - { C::instr_fetching_bytes_to_read, bytes_to_read }, - { C::instr_fetching_instr_abs_diff, instr_abs_diff }, - { C::instr_fetching_pc_abs_diff, pc_abs_diff }, - } }); + trace.set( + row, + { { + { C::instr_fetching_sel, 1 }, + { C::instr_fetching_bytecode_id, bytecode_id }, + { C::instr_fetching_pc, event.pc }, + // indirect + operands. + { C::instr_fetching_indirect, event.instruction.indirect }, + { C::instr_fetching_op1, get_operand(0) }, + { C::instr_fetching_op2, get_operand(1) }, + { C::instr_fetching_op3, get_operand(2) }, + { C::instr_fetching_op4, get_operand(3) }, + { C::instr_fetching_op5, get_operand(4) }, + { C::instr_fetching_op6, get_operand(5) }, + { C::instr_fetching_op7, get_operand(6) }, + // Single bytes. + { C::instr_fetching_bd0, wire_opcode }, + { C::instr_fetching_bd1, bytecode_at(event.pc + 1) }, + { C::instr_fetching_bd2, bytecode_at(event.pc + 2) }, + { C::instr_fetching_bd3, bytecode_at(event.pc + 3) }, + { C::instr_fetching_bd4, bytecode_at(event.pc + 4) }, + { C::instr_fetching_bd5, bytecode_at(event.pc + 5) }, + { C::instr_fetching_bd6, bytecode_at(event.pc + 6) }, + { C::instr_fetching_bd7, bytecode_at(event.pc + 7) }, + { C::instr_fetching_bd8, bytecode_at(event.pc + 8) }, + { C::instr_fetching_bd9, bytecode_at(event.pc + 9) }, + { C::instr_fetching_bd10, bytecode_at(event.pc + 10) }, + { C::instr_fetching_bd11, bytecode_at(event.pc + 11) }, + { C::instr_fetching_bd12, bytecode_at(event.pc + 12) }, + { C::instr_fetching_bd13, bytecode_at(event.pc + 13) }, + { C::instr_fetching_bd14, bytecode_at(event.pc + 14) }, + { C::instr_fetching_bd15, bytecode_at(event.pc + 15) }, + { C::instr_fetching_bd16, bytecode_at(event.pc + 16) }, + { C::instr_fetching_bd17, bytecode_at(event.pc + 17) }, + { C::instr_fetching_bd18, bytecode_at(event.pc + 18) }, + { C::instr_fetching_bd19, bytecode_at(event.pc + 19) }, + { C::instr_fetching_bd20, bytecode_at(event.pc + 20) }, + { C::instr_fetching_bd21, bytecode_at(event.pc + 21) }, + { C::instr_fetching_bd22, bytecode_at(event.pc + 22) }, + { C::instr_fetching_bd23, bytecode_at(event.pc + 23) }, + { C::instr_fetching_bd24, bytecode_at(event.pc + 24) }, + { C::instr_fetching_bd25, bytecode_at(event.pc + 25) }, + { C::instr_fetching_bd26, bytecode_at(event.pc + 26) }, + { C::instr_fetching_bd27, bytecode_at(event.pc + 27) }, + { C::instr_fetching_bd28, bytecode_at(event.pc + 28) }, + { C::instr_fetching_bd29, bytecode_at(event.pc + 29) }, + { C::instr_fetching_bd30, bytecode_at(event.pc + 30) }, + { C::instr_fetching_bd31, bytecode_at(event.pc + 31) }, + { C::instr_fetching_bd32, bytecode_at(event.pc + 32) }, + { C::instr_fetching_bd33, bytecode_at(event.pc + 33) }, + { C::instr_fetching_bd34, bytecode_at(event.pc + 34) }, + { C::instr_fetching_bd35, bytecode_at(event.pc + 35) }, + { C::instr_fetching_bd36, bytecode_at(event.pc + 36) }, + + // From instruction table. + { C::instr_fetching_exec_opcode, static_cast(exec_opcode) }, + { C::instr_fetching_instr_size, size_in_bytes }, + + // Fill operand decomposition selectors + { C::instr_fetching_sel_op_dc_0, op_dc_selectors.at(0) }, + { C::instr_fetching_sel_op_dc_1, op_dc_selectors.at(1) }, + { C::instr_fetching_sel_op_dc_2, op_dc_selectors.at(2) }, + { C::instr_fetching_sel_op_dc_3, op_dc_selectors.at(3) }, + { C::instr_fetching_sel_op_dc_4, op_dc_selectors.at(4) }, + { C::instr_fetching_sel_op_dc_5, op_dc_selectors.at(5) }, + { C::instr_fetching_sel_op_dc_6, op_dc_selectors.at(6) }, + { C::instr_fetching_sel_op_dc_7, op_dc_selectors.at(7) }, + { C::instr_fetching_sel_op_dc_8, op_dc_selectors.at(8) }, + { C::instr_fetching_sel_op_dc_9, op_dc_selectors.at(9) }, + { C::instr_fetching_sel_op_dc_10, op_dc_selectors.at(10) }, + { C::instr_fetching_sel_op_dc_11, op_dc_selectors.at(11) }, + { C::instr_fetching_sel_op_dc_12, op_dc_selectors.at(12) }, + { C::instr_fetching_sel_op_dc_13, op_dc_selectors.at(13) }, + { C::instr_fetching_sel_op_dc_14, op_dc_selectors.at(14) }, + { C::instr_fetching_sel_op_dc_15, op_dc_selectors.at(15) }, + { C::instr_fetching_sel_op_dc_16, op_dc_selectors.at(16) }, + { C::instr_fetching_sel_op_dc_17, op_dc_selectors.at(17) }, + + // Parsing errors + { C::instr_fetching_pc_out_of_range, event.error == PC_OUT_OF_RANGE ? 1 : 0 }, + { C::instr_fetching_opcode_out_of_range, event.error == OPCODE_OUT_OF_RANGE ? 1 : 0 }, + { C::instr_fetching_instr_out_of_range, event.error == INSTRUCTION_OUT_OF_RANGE ? 1 : 0 }, + { C::instr_fetching_parsing_err, event.error != NO_ERROR ? 1 : 0 }, + + // selector for lookups + { C::instr_fetching_sel_opcode_defined, event.error != PC_OUT_OF_RANGE ? 1 : 0 }, + + { C::instr_fetching_bytecode_size, bytecode_size }, + { C::instr_fetching_bytes_to_read, bytes_to_read }, + { C::instr_fetching_instr_abs_diff, instr_abs_diff }, + { C::instr_fetching_pc_abs_diff, pc_abs_diff }, + { C::instr_fetching_thirty_two, AVM_PC_SIZE_IN_BITS }, // Remove when we support constants in lookups + } }); row++; } } diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp index 1aef21682b92..89b2b2b6b807 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.test.cpp @@ -346,7 +346,7 @@ std::vector create_instruction_fetching_events( return events; } -} // end of anonymous namespace +} // namespace // We build a random InstructionFetchingEvent for each wire opcode. // We then verify that the bytes (bd0, bd1, ...) correspond to the serialized instruction. diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/precomputed_trace.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/precomputed_trace.cpp index 2c10ba47bbc8..f2f500591740 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/precomputed_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/precomputed_trace.cpp @@ -17,12 +17,11 @@ void PrecomputedTraceBuilder::process_misc(TraceContainer& trace, const uint32_t // First row. trace.set(C::precomputed_first_row, 0, 1); - // Clk and constant columns + // Clk // TODO: What a waste of 64MB. Can we elegantly have a flag for this? trace.reserve_column(C::precomputed_clk, num_rows); for (uint32_t i = 0; i < num_rows; i++) { trace.set(C::precomputed_clk, i, i); - trace.set(C::precomputed_thirty_two, i, 32); } } From 91593c64ce2e42e114a83ae57b74a631214fbfd9 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Wed, 19 Mar 2025 16:56:49 +0000 Subject: [PATCH 23/25] Add comments to separate lookups --- barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp index e77d2a0a7414..8fa635c54d7a 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp @@ -254,7 +254,9 @@ TraceContainer AvmTraceGenHelper::generate_trace(EventsContainer&& events) // Now we can compute lookups and permutations. { auto jobs_interactions = make_jobs>( + // Poseidon2 std::make_unique>(), + // Range Check std::make_unique>(), std::make_unique>(), std::make_unique>(), @@ -265,8 +267,10 @@ TraceContainer AvmTraceGenHelper::generate_trace(EventsContainer&& events) std::make_unique>(), std::make_unique>(), std::make_unique>(), + // Bitwise std::make_unique>(), std::make_unique>(), + // SHA-256 std::make_unique>(), // Bytecode Hashing std::make_unique>(), From b5e9e6af23d3a1cd64eb87379d60ab3c3adbd44f Mon Sep 17 00:00:00 2001 From: jeanmon Date: Thu, 20 Mar 2025 07:59:50 +0000 Subject: [PATCH 24/25] Activate range_check in tracegen_helper --- .../barretenberg/vm2/simulation/events/events_container.hpp | 2 ++ barretenberg/cpp/src/barretenberg/vm2/simulation_helper.cpp | 3 ++- barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/events_container.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/events_container.hpp index 0c6fa383c011..6cad9c733208 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/events_container.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/events_container.hpp @@ -11,6 +11,7 @@ #include "barretenberg/vm2/simulation/events/execution_event.hpp" #include "barretenberg/vm2/simulation/events/memory_event.hpp" #include "barretenberg/vm2/simulation/events/poseidon2_event.hpp" +#include "barretenberg/vm2/simulation/events/range_check_event.hpp" #include "barretenberg/vm2/simulation/events/sha256_event.hpp" #include "barretenberg/vm2/simulation/events/siloing_event.hpp" #include "barretenberg/vm2/simulation/events/to_radix_event.hpp" @@ -35,6 +36,7 @@ struct EventsContainer { EventEmitterInterface::Container poseidon2_hash; EventEmitterInterface::Container poseidon2_permutation; EventEmitterInterface::Container to_radix; + EventEmitterInterface::Container range_check; }; } // namespace bb::avm2::simulation diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation_helper.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation_helper.cpp index 41ee6e012fa4..4b9ece7ef8c3 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation_helper.cpp @@ -124,7 +124,8 @@ template EventsContainer AvmSimulationHelper::simulate_with_setting scalar_mul_emitter.dump_events(), poseidon2_hash_emitter.dump_events(), poseidon2_perm_emitter.dump_events(), - to_radix_emitter.dump_events() }; + to_radix_emitter.dump_events(), + range_check_emitter.dump_events() }; } EventsContainer AvmSimulationHelper::simulate() diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp index 8fa635c54d7a..9dee5b65e8b2 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp @@ -39,6 +39,7 @@ #include "barretenberg/vm2/tracegen/lib/permutation_builder.hpp" #include "barretenberg/vm2/tracegen/poseidon2_trace.hpp" #include "barretenberg/vm2/tracegen/precomputed_trace.hpp" +#include "barretenberg/vm2/tracegen/range_check_trace.hpp" #include "barretenberg/vm2/tracegen/sha256_trace.hpp" #include "barretenberg/vm2/tracegen/to_radix_trace.hpp" #include "barretenberg/vm2/tracegen/trace_container.hpp" @@ -247,6 +248,11 @@ TraceContainer AvmTraceGenHelper::generate_trace(EventsContainer&& events) AVM_TRACK_TIME("tracegen/to_radix", to_radix_builder.process(events.to_radix, trace)); clear_events(events.to_radix); }, + [&]() { + RangeCheckTraceBuilder range_check_builder; + AVM_TRACK_TIME("tracegen/range_check", range_check_builder.process(events.range_check, trace)); + clear_events(events.range_check); + }, }); AVM_TRACK_TIME("tracegen/traces", execute_jobs(jobs)); } From ea7b5703513bfec2bf5c4ac3f459b1e42c75b8ce Mon Sep 17 00:00:00 2001 From: jeanmon Date: Thu, 20 Mar 2025 08:09:26 +0000 Subject: [PATCH 25/25] Typo --- .../src/barretenberg/vm2/simulation/events/event_emitter.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/event_emitter.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/event_emitter.hpp index f886dd973614..166a0a982881 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/event_emitter.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/event_emitter.hpp @@ -66,7 +66,7 @@ template class NoopEventEmitter : public EventEmitterInterface< EventEmitter::Container dump_events() { return {}; }; }; -// This is an event emmiter which only emits events once (it actually just _sets_ an event). +// This is an event emitter which only emits events once (it actually just _sets_ an event). // This is meant for a special Execution use case. template class OneShotEventEmitter : public EventEmitterInterface { public: