From fbc8c0e864b10d2265373688457a33d61517bbb4 Mon Sep 17 00:00:00 2001 From: Facundo Date: Mon, 9 Dec 2024 22:03:39 +0000 Subject: [PATCH] chore(avm): pilcom compatibility changes (#10544) For compatibility with upcoming design. * Creates a columns file * Relations now have subrelation constexpr * Relative includes for generated files * Now you can specify output path for generated files with `-o path` * Full row uses macro list of columns!* *warning: GCC didn't like this so I added ``` "CXXFLAGS": "-Wno-missing-field-initializers" ``` the reason is that I'm now defining the AvmFullRow as `FF ALL_ENTITIES;` but GCC prefers it if I do `FF col1{}; FF col2{};...` with the explicit `{}`. If I need to do that, then I need to codegen and repeat again all names. To be honest IDK why it complains so much, if you Google this, you'll find other people running into it. This should NOT be a problem since any field not specified in aggregate initialization WILL be value-initialized. Now, FF's are special in that they don't initialize themselves by default, to accommodate array/other uses cases. (this is a BAD choice if you ask me, there are other ways to avoid explicit initialization if and only when you want to, especially for arrays etc). Let's see what tests say. In our case the AvmFullRow is only used in a vector, which does somehow force full initialization of all the fields (or at least it did). --- barretenberg/cpp/CMakePresets.json | 9 +- .../vm/avm/generated/circuit_builder.cpp | 2 +- .../vm/avm/generated/circuit_builder.hpp | 4 +- .../barretenberg/vm/avm/generated/columns.hpp | 38 + .../vm/avm/generated/composer.cpp | 2 +- .../vm/avm/generated/composer.hpp | 6 +- .../barretenberg/vm/avm/generated/flavor.cpp | 2 +- .../barretenberg/vm/avm/generated/flavor.hpp | 183 ++-- .../vm/avm/generated/full_row.cpp | 8 +- .../vm/avm/generated/full_row.hpp | 793 +----------------- .../barretenberg/vm/avm/generated/prover.cpp | 2 +- .../barretenberg/vm/avm/generated/prover.hpp | 2 +- .../vm/avm/generated/relations/alu.hpp | 9 +- .../vm/avm/generated/relations/binary.hpp | 11 +- .../vm/avm/generated/relations/bytecode.hpp | 4 +- .../vm/avm/generated/relations/cmp.hpp | 22 +- .../vm/avm/generated/relations/conversion.hpp | 4 +- .../vm/avm/generated/relations/gas.hpp | 10 +- .../avm/generated/relations/keccakf1600.hpp | 4 +- .../vm/avm/generated/relations/main.hpp | 25 +- .../vm/avm/generated/relations/mem.hpp | 22 +- .../vm/avm/generated/relations/mem_slice.hpp | 15 +- .../avm/generated/relations/merkle_tree.hpp | 4 +- .../vm/avm/generated/relations/poseidon2.hpp | 4 +- .../generated/relations/poseidon2_full.hpp | 4 +- .../avm/generated/relations/range_check.hpp | 6 +- .../vm/avm/generated/relations/sha256.hpp | 4 +- .../vm/avm/generated/verifier.cpp | 2 +- .../vm/avm/generated/verifier.hpp | 2 +- .../vm/avm/tests/full_poseidon2.test.cpp | 4 +- .../vm/avm/tests/fuzz_skippable.test.cpp | 2 +- .../vm/avm/tests/merkle_tree.test.cpp | 4 +- .../vm/avm/tests/range_check.test.cpp | 4 +- .../bb-pil-backend/src/flavor_builder.rs | 59 ++ bb-pilcom/bb-pil-backend/src/vm_builder.rs | 21 +- .../templates/circuit_builder.cpp.hbs | 2 +- .../templates/circuit_builder.hpp.hbs | 4 +- .../bb-pil-backend/templates/columns.hpp.hbs | 38 + .../bb-pil-backend/templates/composer.cpp.hbs | 4 +- .../bb-pil-backend/templates/composer.hpp.hbs | 6 +- .../bb-pil-backend/templates/flavor.cpp.hbs | 6 +- .../bb-pil-backend/templates/flavor.hpp.hbs | 21 +- .../bb-pil-backend/templates/full_row.cpp.hbs | 6 +- .../bb-pil-backend/templates/full_row.hpp.hbs | 34 +- .../bb-pil-backend/templates/prover.cpp.hbs | 2 +- .../bb-pil-backend/templates/prover.hpp.hbs | 2 +- .../bb-pil-backend/templates/relation.hpp.hbs | 20 +- .../bb-pil-backend/templates/verifier.cpp.hbs | 4 +- .../bb-pil-backend/templates/verifier.hpp.hbs | 2 +- bb-pilcom/cli/src/main.rs | 9 +- 50 files changed, 478 insertions(+), 979 deletions(-) create mode 100644 barretenberg/cpp/src/barretenberg/vm/avm/generated/columns.hpp create mode 100644 bb-pilcom/bb-pil-backend/templates/columns.hpp.hbs diff --git a/barretenberg/cpp/CMakePresets.json b/barretenberg/cpp/CMakePresets.json index 615125bd51e..4b2d7b981ef 100644 --- a/barretenberg/cpp/CMakePresets.json +++ b/barretenberg/cpp/CMakePresets.json @@ -223,7 +223,8 @@ "binaryDir": "build-gcc", "environment": { "CC": "gcc", - "CXX": "g++" + "CXX": "g++", + "CXXFLAGS": "-Wno-missing-field-initializers" } }, { @@ -233,7 +234,8 @@ "inherits": "default", "environment": { "CC": "gcc-10", - "CXX": "g++-10" + "CXX": "g++-10", + "CXXFLAGS": "-Wno-missing-field-initializers" } }, { @@ -243,7 +245,8 @@ "inherits": "default", "environment": { "CC": "gcc-13", - "CXX": "g++-13" + "CXX": "g++-13", + "CXXFLAGS": "-Wno-missing-field-initializers" } }, { diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/circuit_builder.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/circuit_builder.cpp index cc096543dc7..7139fda3f19 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/circuit_builder.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/circuit_builder.cpp @@ -1,5 +1,5 @@ // AUTOGENERATED FILE -#include "barretenberg/vm/avm/generated/circuit_builder.hpp" +#include "circuit_builder.hpp" #include #include diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/circuit_builder.hpp index a59e1044b0b..a152da7a2dc 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/circuit_builder.hpp @@ -3,8 +3,8 @@ #include -#include "barretenberg/vm/avm/generated/flavor.hpp" -#include "barretenberg/vm/avm/generated/full_row.hpp" +#include "flavor.hpp" +#include "full_row.hpp" namespace bb { diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/columns.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/columns.hpp new file mode 100644 index 00000000000..0fd71f8e1a3 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/columns.hpp @@ -0,0 +1,38 @@ +#pragma once + +#include +#include + +namespace bb::avm { + +// The entities that will be used in the flavor. +// clang-format off +#define PRECOMPUTED_ENTITIES byte_lookup_sel_bin, byte_lookup_table_byte_lengths, byte_lookup_table_in_tags, byte_lookup_table_input_a, byte_lookup_table_input_b, byte_lookup_table_op_id, byte_lookup_table_output, gas_base_da_gas_fixed_table, gas_base_l2_gas_fixed_table, gas_dyn_da_gas_fixed_table, gas_dyn_l2_gas_fixed_table, gas_sel_gas_cost, main_clk, main_sel_da_end_gas_kernel_input, main_sel_da_start_gas_kernel_input, main_sel_first, main_sel_l2_end_gas_kernel_input, main_sel_l2_start_gas_kernel_input, main_sel_start_exec, main_zeroes, powers_power_of_2 +#define WIRE_ENTITIES main_kernel_inputs, main_kernel_value_out, main_kernel_side_effect_out, main_kernel_metadata_out, main_calldata, main_returndata, alu_a_hi, alu_a_lo, alu_b_hi, alu_b_lo, alu_b_pow, alu_c_hi, alu_c_lo, alu_cf, alu_clk, alu_cmp_gadget_gt, alu_cmp_gadget_input_a, alu_cmp_gadget_input_b, alu_cmp_gadget_non_ff_gt, alu_cmp_gadget_result, alu_cmp_gadget_sel, alu_ff_tag, alu_ia, alu_ib, alu_ic, alu_in_tag, alu_max_bits_sub_b_bits, alu_max_bits_sub_b_pow, alu_op_add, alu_op_cast, alu_op_div, alu_op_eq, alu_op_lt, alu_op_lte, alu_op_mul, alu_op_not, alu_op_shl, alu_op_shr, alu_op_sub, alu_partial_prod_hi, alu_partial_prod_lo, alu_range_check_input_value, alu_range_check_num_bits, alu_range_check_sel, alu_remainder, alu_sel_alu, alu_sel_cmp, alu_sel_shift_which, alu_u128_tag, alu_u16_tag, alu_u1_tag, alu_u32_tag, alu_u64_tag, alu_u8_tag, alu_zero_shift, binary_acc_ia, binary_acc_ib, binary_acc_ic, binary_clk, binary_ia_bytes, binary_ib_bytes, binary_ic_bytes, binary_in_tag, binary_mem_tag_ctr, binary_mem_tag_ctr_inv, binary_op_id, binary_sel_bin, binary_start, bytecode_arifact_hash, bytecode_as_fields, bytecode_bytes, bytecode_bytes_pc, bytecode_class_id, bytecode_contract_address, bytecode_decomposed, bytecode_deployer_addr, bytecode_end_latch, bytecode_incoming_viewing_key_x, bytecode_incoming_viewing_key_y, bytecode_initialization_hash, bytecode_length_remaining, bytecode_nullifier_key_x, bytecode_nullifier_key_y, bytecode_outgoing_viewing_key_x, bytecode_outgoing_viewing_key_y, bytecode_private_fn_root, bytecode_public_key_hash, bytecode_running_hash, bytecode_salt, bytecode_tagging_key_x, bytecode_tagging_key_y, cmp_a_hi, cmp_a_lo, cmp_b_hi, cmp_b_lo, cmp_borrow, cmp_clk, cmp_cmp_rng_ctr, cmp_diff, cmp_input_a, cmp_input_b, cmp_op_eq, cmp_op_eq_diff_inv, cmp_op_gt, cmp_op_non_ff_gt, cmp_p_a_borrow, cmp_p_b_borrow, cmp_p_sub_a_hi, cmp_p_sub_a_lo, cmp_p_sub_b_hi, cmp_p_sub_b_lo, cmp_range_chk_clk, cmp_res_hi, cmp_res_lo, cmp_result, cmp_sel_cmp, cmp_sel_rng_chk, cmp_shift_sel, conversion_clk, conversion_input, conversion_num_limbs, conversion_output_bits, conversion_radix, conversion_sel_to_radix_be, keccakf1600_clk, keccakf1600_input, keccakf1600_output, keccakf1600_sel_keccakf1600, main_abs_da_rem_gas, main_abs_l2_rem_gas, main_alu_in_tag, main_base_da_gas_op_cost, main_base_l2_gas_op_cost, main_bin_op_id, main_call_ptr, main_da_gas_remaining, main_da_gas_u16_r0, main_da_gas_u16_r1, main_da_out_of_gas, main_dyn_da_gas_op_cost, main_dyn_gas_multiplier, main_dyn_l2_gas_op_cost, main_ia, main_ib, main_ic, main_id, main_id_zero, main_ind_addr_a, main_ind_addr_b, main_ind_addr_c, main_ind_addr_d, main_internal_return_ptr, main_inv, main_is_fake_row, main_is_gas_accounted, main_l2_gas_remaining, main_l2_gas_u16_r0, main_l2_gas_u16_r1, main_l2_out_of_gas, main_mem_addr_a, main_mem_addr_b, main_mem_addr_c, main_mem_addr_d, main_op_err, main_opcode_val, main_pc, main_r_in_tag, main_rwa, main_rwb, main_rwc, main_rwd, main_sel_alu, main_sel_bin, main_sel_calldata, main_sel_execution_end, main_sel_execution_row, main_sel_mem_op_a, main_sel_mem_op_b, main_sel_mem_op_c, main_sel_mem_op_d, main_sel_mov_ia_to_ic, main_sel_mov_ib_to_ic, main_sel_op_add, main_sel_op_address, main_sel_op_and, main_sel_op_block_number, main_sel_op_calldata_copy, main_sel_op_cast, main_sel_op_chain_id, main_sel_op_dagasleft, main_sel_op_debug_log, main_sel_op_div, main_sel_op_ecadd, main_sel_op_emit_l2_to_l1_msg, main_sel_op_emit_note_hash, main_sel_op_emit_nullifier, main_sel_op_emit_unencrypted_log, main_sel_op_eq, main_sel_op_external_call, main_sel_op_external_return, main_sel_op_external_revert, main_sel_op_fdiv, main_sel_op_fee_per_da_gas, main_sel_op_fee_per_l2_gas, main_sel_op_get_contract_instance, main_sel_op_internal_call, main_sel_op_internal_return, main_sel_op_is_static_call, main_sel_op_jump, main_sel_op_jumpi, main_sel_op_keccak, main_sel_op_l1_to_l2_msg_exists, main_sel_op_l2gasleft, main_sel_op_lt, main_sel_op_lte, main_sel_op_mov, main_sel_op_msm, main_sel_op_mul, main_sel_op_not, main_sel_op_note_hash_exists, main_sel_op_nullifier_exists, main_sel_op_or, main_sel_op_poseidon2, main_sel_op_radix_be, main_sel_op_returndata_copy, main_sel_op_returndata_size, main_sel_op_sender, main_sel_op_set, main_sel_op_sha256, main_sel_op_shl, main_sel_op_shr, main_sel_op_sload, main_sel_op_sstore, main_sel_op_static_call, main_sel_op_sub, main_sel_op_timestamp, main_sel_op_transaction_fee, main_sel_op_version, main_sel_op_xor, main_sel_q_kernel_lookup, main_sel_q_kernel_output_lookup, main_sel_resolve_ind_addr_a, main_sel_resolve_ind_addr_b, main_sel_resolve_ind_addr_c, main_sel_resolve_ind_addr_d, main_sel_returndata, main_sel_rng_16, main_sel_rng_8, main_sel_slice_gadget, main_space_id, main_tag_err, main_w_in_tag, mem_addr, mem_clk, mem_diff, mem_glob_addr, mem_last, mem_lastAccess, mem_one_min_inv, mem_r_in_tag, mem_rw, mem_sel_mem, mem_sel_mov_ia_to_ic, mem_sel_mov_ib_to_ic, mem_sel_op_a, mem_sel_op_b, mem_sel_op_c, mem_sel_op_d, mem_sel_op_poseidon_read_a, mem_sel_op_poseidon_read_b, mem_sel_op_poseidon_read_c, mem_sel_op_poseidon_read_d, mem_sel_op_poseidon_write_a, mem_sel_op_poseidon_write_b, mem_sel_op_poseidon_write_c, mem_sel_op_poseidon_write_d, mem_sel_op_slice, mem_sel_resolve_ind_addr_a, mem_sel_resolve_ind_addr_b, mem_sel_resolve_ind_addr_c, mem_sel_resolve_ind_addr_d, mem_sel_rng_chk, mem_skip_check_tag, mem_space_id, mem_tag, mem_tag_err, mem_tsp, mem_u16_r0, mem_u16_r1, mem_u8_r0, mem_val, mem_w_in_tag, merkle_tree_clk, merkle_tree_expected_tree_root, merkle_tree_latch, merkle_tree_leaf_index, merkle_tree_leaf_index_is_even, merkle_tree_leaf_value, merkle_tree_left_hash, merkle_tree_output_hash, merkle_tree_path_len, merkle_tree_path_len_inv, merkle_tree_right_hash, merkle_tree_sel_merkle_tree, merkle_tree_sibling_value, poseidon2_B_10_0, poseidon2_B_10_1, poseidon2_B_10_2, poseidon2_B_10_3, poseidon2_B_11_0, poseidon2_B_11_1, poseidon2_B_11_2, poseidon2_B_11_3, poseidon2_B_12_0, poseidon2_B_12_1, poseidon2_B_12_2, poseidon2_B_12_3, poseidon2_B_13_0, poseidon2_B_13_1, poseidon2_B_13_2, poseidon2_B_13_3, poseidon2_B_14_0, poseidon2_B_14_1, poseidon2_B_14_2, poseidon2_B_14_3, poseidon2_B_15_0, poseidon2_B_15_1, poseidon2_B_15_2, poseidon2_B_15_3, poseidon2_B_16_0, poseidon2_B_16_1, poseidon2_B_16_2, poseidon2_B_16_3, poseidon2_B_17_0, poseidon2_B_17_1, poseidon2_B_17_2, poseidon2_B_17_3, poseidon2_B_18_0, poseidon2_B_18_1, poseidon2_B_18_2, poseidon2_B_18_3, poseidon2_B_19_0, poseidon2_B_19_1, poseidon2_B_19_2, poseidon2_B_19_3, poseidon2_B_20_0, poseidon2_B_20_1, poseidon2_B_20_2, poseidon2_B_20_3, poseidon2_B_21_0, poseidon2_B_21_1, poseidon2_B_21_2, poseidon2_B_21_3, poseidon2_B_22_0, poseidon2_B_22_1, poseidon2_B_22_2, poseidon2_B_22_3, poseidon2_B_23_0, poseidon2_B_23_1, poseidon2_B_23_2, poseidon2_B_23_3, poseidon2_B_24_0, poseidon2_B_24_1, poseidon2_B_24_2, poseidon2_B_24_3, poseidon2_B_25_0, poseidon2_B_25_1, poseidon2_B_25_2, poseidon2_B_25_3, poseidon2_B_26_0, poseidon2_B_26_1, poseidon2_B_26_2, poseidon2_B_26_3, poseidon2_B_27_0, poseidon2_B_27_1, poseidon2_B_27_2, poseidon2_B_27_3, poseidon2_B_28_0, poseidon2_B_28_1, poseidon2_B_28_2, poseidon2_B_28_3, poseidon2_B_29_0, poseidon2_B_29_1, poseidon2_B_29_2, poseidon2_B_29_3, poseidon2_B_30_0, poseidon2_B_30_1, poseidon2_B_30_2, poseidon2_B_30_3, poseidon2_B_31_0, poseidon2_B_31_1, poseidon2_B_31_2, poseidon2_B_31_3, poseidon2_B_32_0, poseidon2_B_32_1, poseidon2_B_32_2, poseidon2_B_32_3, poseidon2_B_33_0, poseidon2_B_33_1, poseidon2_B_33_2, poseidon2_B_33_3, poseidon2_B_34_0, poseidon2_B_34_1, poseidon2_B_34_2, poseidon2_B_34_3, poseidon2_B_35_0, poseidon2_B_35_1, poseidon2_B_35_2, poseidon2_B_35_3, poseidon2_B_36_0, poseidon2_B_36_1, poseidon2_B_36_2, poseidon2_B_36_3, poseidon2_B_37_0, poseidon2_B_37_1, poseidon2_B_37_2, poseidon2_B_37_3, poseidon2_B_38_0, poseidon2_B_38_1, poseidon2_B_38_2, poseidon2_B_38_3, poseidon2_B_39_0, poseidon2_B_39_1, poseidon2_B_39_2, poseidon2_B_39_3, poseidon2_B_40_0, poseidon2_B_40_1, poseidon2_B_40_2, poseidon2_B_40_3, poseidon2_B_41_0, poseidon2_B_41_1, poseidon2_B_41_2, poseidon2_B_41_3, poseidon2_B_42_0, poseidon2_B_42_1, poseidon2_B_42_2, poseidon2_B_42_3, poseidon2_B_43_0, poseidon2_B_43_1, poseidon2_B_43_2, poseidon2_B_43_3, poseidon2_B_44_0, poseidon2_B_44_1, poseidon2_B_44_2, poseidon2_B_44_3, poseidon2_B_45_0, poseidon2_B_45_1, poseidon2_B_45_2, poseidon2_B_45_3, poseidon2_B_46_0, poseidon2_B_46_1, poseidon2_B_46_2, poseidon2_B_46_3, poseidon2_B_47_0, poseidon2_B_47_1, poseidon2_B_47_2, poseidon2_B_47_3, poseidon2_B_48_0, poseidon2_B_48_1, poseidon2_B_48_2, poseidon2_B_48_3, poseidon2_B_49_0, poseidon2_B_49_1, poseidon2_B_49_2, poseidon2_B_49_3, poseidon2_B_4_0, poseidon2_B_4_1, poseidon2_B_4_2, poseidon2_B_4_3, poseidon2_B_50_0, poseidon2_B_50_1, poseidon2_B_50_2, poseidon2_B_50_3, poseidon2_B_51_0, poseidon2_B_51_1, poseidon2_B_51_2, poseidon2_B_51_3, poseidon2_B_52_0, poseidon2_B_52_1, poseidon2_B_52_2, poseidon2_B_52_3, poseidon2_B_53_0, poseidon2_B_53_1, poseidon2_B_53_2, poseidon2_B_53_3, poseidon2_B_54_0, poseidon2_B_54_1, poseidon2_B_54_2, poseidon2_B_54_3, poseidon2_B_55_0, poseidon2_B_55_1, poseidon2_B_55_2, poseidon2_B_55_3, poseidon2_B_56_0, poseidon2_B_56_1, poseidon2_B_56_2, poseidon2_B_56_3, poseidon2_B_57_0, poseidon2_B_57_1, poseidon2_B_57_2, poseidon2_B_57_3, poseidon2_B_58_0, poseidon2_B_58_1, poseidon2_B_58_2, poseidon2_B_58_3, poseidon2_B_59_0, poseidon2_B_59_1, poseidon2_B_59_2, poseidon2_B_59_3, poseidon2_B_5_0, poseidon2_B_5_1, poseidon2_B_5_2, poseidon2_B_5_3, poseidon2_B_6_0, poseidon2_B_6_1, poseidon2_B_6_2, poseidon2_B_6_3, poseidon2_B_7_0, poseidon2_B_7_1, poseidon2_B_7_2, poseidon2_B_7_3, poseidon2_B_8_0, poseidon2_B_8_1, poseidon2_B_8_2, poseidon2_B_8_3, poseidon2_B_9_0, poseidon2_B_9_1, poseidon2_B_9_2, poseidon2_B_9_3, poseidon2_EXT_LAYER_4, poseidon2_EXT_LAYER_5, poseidon2_EXT_LAYER_6, poseidon2_EXT_LAYER_7, poseidon2_T_0_4, poseidon2_T_0_5, poseidon2_T_0_6, poseidon2_T_0_7, poseidon2_T_1_4, poseidon2_T_1_5, poseidon2_T_1_6, poseidon2_T_1_7, poseidon2_T_2_4, poseidon2_T_2_5, poseidon2_T_2_6, poseidon2_T_2_7, poseidon2_T_3_4, poseidon2_T_3_5, poseidon2_T_3_6, poseidon2_T_3_7, poseidon2_T_60_4, poseidon2_T_60_5, poseidon2_T_60_6, poseidon2_T_60_7, poseidon2_T_61_4, poseidon2_T_61_5, poseidon2_T_61_6, poseidon2_T_61_7, poseidon2_T_62_4, poseidon2_T_62_5, poseidon2_T_62_6, poseidon2_T_62_7, poseidon2_T_63_4, poseidon2_T_63_5, poseidon2_T_63_6, poseidon2_T_63_7, poseidon2_a_0, poseidon2_a_1, poseidon2_a_2, poseidon2_a_3, poseidon2_b_0, poseidon2_b_1, poseidon2_b_2, poseidon2_b_3, poseidon2_clk, poseidon2_full_a_0, poseidon2_full_a_1, poseidon2_full_a_2, poseidon2_full_a_3, poseidon2_full_b_0, poseidon2_full_b_1, poseidon2_full_b_2, poseidon2_full_b_3, poseidon2_full_clk, poseidon2_full_end_poseidon, poseidon2_full_execute_poseidon_perm, poseidon2_full_input_0, poseidon2_full_input_1, poseidon2_full_input_2, poseidon2_full_input_len, poseidon2_full_num_perm_rounds_rem, poseidon2_full_num_perm_rounds_rem_inv, poseidon2_full_output, poseidon2_full_padding, poseidon2_full_sel_merkle_tree, poseidon2_full_sel_poseidon, poseidon2_full_start_poseidon, poseidon2_input_addr, poseidon2_mem_addr_read_a, poseidon2_mem_addr_read_b, poseidon2_mem_addr_read_c, poseidon2_mem_addr_read_d, poseidon2_mem_addr_write_a, poseidon2_mem_addr_write_b, poseidon2_mem_addr_write_c, poseidon2_mem_addr_write_d, poseidon2_output_addr, poseidon2_sel_poseidon_perm, poseidon2_sel_poseidon_perm_immediate, poseidon2_sel_poseidon_perm_mem_op, poseidon2_space_id, range_check_alu_rng_chk, range_check_clk, range_check_cmp_hi_bits_rng_chk, range_check_cmp_lo_bits_rng_chk, range_check_cmp_non_ff_rng_chk, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_gas_da_rng_chk, range_check_gas_l2_rng_chk, 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_lookup_0, range_check_sel_lookup_1, range_check_sel_lookup_2, range_check_sel_lookup_3, range_check_sel_lookup_4, range_check_sel_lookup_5, range_check_sel_lookup_6, range_check_sel_rng_chk, 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, sha256_clk, sha256_input, sha256_output, sha256_sel_sha256_compression, sha256_state, slice_addr, slice_clk, slice_cnt, slice_col_offset, slice_one_min_inv, slice_sel_cd_cpy, slice_sel_mem_active, slice_sel_return, slice_sel_start, slice_space_id, slice_val, lookup_rng_chk_pow_2_counts, lookup_rng_chk_diff_counts, lookup_rng_chk_0_counts, lookup_rng_chk_1_counts, lookup_rng_chk_2_counts, lookup_rng_chk_3_counts, lookup_rng_chk_4_counts, lookup_rng_chk_5_counts, lookup_rng_chk_6_counts, lookup_rng_chk_7_counts, lookup_mem_rng_chk_0_counts, lookup_mem_rng_chk_1_counts, lookup_mem_rng_chk_2_counts, lookup_pow_2_0_counts, lookup_pow_2_1_counts, lookup_byte_lengths_counts, lookup_byte_operations_counts, lookup_opcode_gas_counts, lookup_l2_gas_rng_chk_0_counts, lookup_l2_gas_rng_chk_1_counts, lookup_da_gas_rng_chk_0_counts, lookup_da_gas_rng_chk_1_counts, lookup_cd_value_counts, lookup_ret_value_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts +#define DERIVED_WITNESS_ENTITIES perm_rng_non_ff_cmp_inv, perm_rng_cmp_lo_inv, perm_rng_cmp_hi_inv, perm_rng_alu_inv, perm_cmp_alu_inv, perm_pos_mem_read_a_inv, perm_pos_mem_read_b_inv, perm_pos_mem_read_c_inv, perm_pos_mem_read_d_inv, perm_pos_mem_write_a_inv, perm_pos_mem_write_b_inv, perm_pos_mem_write_c_inv, perm_pos_mem_write_d_inv, perm_pos2_fixed_pos2_perm_inv, perm_slice_mem_inv, perm_merkle_poseidon2_inv, perm_main_alu_inv, perm_main_bin_inv, perm_main_conv_inv, perm_main_sha256_inv, perm_main_pos2_perm_inv, perm_main_mem_a_inv, perm_main_mem_b_inv, perm_main_mem_c_inv, perm_main_mem_d_inv, perm_main_mem_ind_addr_a_inv, perm_main_mem_ind_addr_b_inv, perm_main_mem_ind_addr_c_inv, perm_main_mem_ind_addr_d_inv, lookup_rng_chk_pow_2_inv, lookup_rng_chk_diff_inv, lookup_rng_chk_0_inv, lookup_rng_chk_1_inv, lookup_rng_chk_2_inv, lookup_rng_chk_3_inv, lookup_rng_chk_4_inv, lookup_rng_chk_5_inv, lookup_rng_chk_6_inv, lookup_rng_chk_7_inv, lookup_mem_rng_chk_0_inv, lookup_mem_rng_chk_1_inv, lookup_mem_rng_chk_2_inv, lookup_pow_2_0_inv, lookup_pow_2_1_inv, lookup_byte_lengths_inv, lookup_byte_operations_inv, lookup_opcode_gas_inv, lookup_l2_gas_rng_chk_0_inv, lookup_l2_gas_rng_chk_1_inv, lookup_da_gas_rng_chk_0_inv, lookup_da_gas_rng_chk_1_inv, lookup_cd_value_inv, lookup_ret_value_inv, incl_main_tag_err_inv, incl_mem_tag_err_inv +#define SHIFTED_ENTITIES binary_acc_ia_shift, binary_acc_ib_shift, binary_acc_ic_shift, binary_mem_tag_ctr_shift, binary_op_id_shift, cmp_a_hi_shift, cmp_a_lo_shift, cmp_b_hi_shift, cmp_b_lo_shift, cmp_cmp_rng_ctr_shift, cmp_op_gt_shift, cmp_p_sub_a_hi_shift, cmp_p_sub_a_lo_shift, cmp_p_sub_b_hi_shift, cmp_p_sub_b_lo_shift, cmp_sel_rng_chk_shift, main_da_gas_remaining_shift, main_l2_gas_remaining_shift, main_pc_shift, main_sel_execution_end_shift, main_sel_execution_row_shift, mem_glob_addr_shift, mem_rw_shift, mem_sel_mem_shift, mem_tag_shift, mem_tsp_shift, mem_val_shift, merkle_tree_leaf_index_shift, merkle_tree_leaf_value_shift, merkle_tree_path_len_shift, poseidon2_full_a_0_shift, poseidon2_full_a_1_shift, poseidon2_full_a_2_shift, poseidon2_full_a_3_shift, poseidon2_full_execute_poseidon_perm_shift, poseidon2_full_input_0_shift, poseidon2_full_input_1_shift, poseidon2_full_input_2_shift, poseidon2_full_num_perm_rounds_rem_shift, poseidon2_full_sel_poseidon_shift, poseidon2_full_start_poseidon_shift, slice_addr_shift, slice_clk_shift, slice_cnt_shift, slice_col_offset_shift, slice_sel_cd_cpy_shift, slice_sel_mem_active_shift, slice_sel_return_shift, slice_sel_start_shift, slice_space_id_shift +#define TO_BE_SHIFTED(e) e.binary_acc_ia, e.binary_acc_ib, e.binary_acc_ic, e.binary_mem_tag_ctr, e.binary_op_id, e.cmp_a_hi, e.cmp_a_lo, e.cmp_b_hi, e.cmp_b_lo, e.cmp_cmp_rng_ctr, e.cmp_op_gt, e.cmp_p_sub_a_hi, e.cmp_p_sub_a_lo, e.cmp_p_sub_b_hi, e.cmp_p_sub_b_lo, e.cmp_sel_rng_chk, e.main_da_gas_remaining, e.main_l2_gas_remaining, e.main_pc, e.main_sel_execution_end, e.main_sel_execution_row, e.mem_glob_addr, e.mem_rw, e.mem_sel_mem, e.mem_tag, e.mem_tsp, e.mem_val, e.merkle_tree_leaf_index, e.merkle_tree_leaf_value, e.merkle_tree_path_len, e.poseidon2_full_a_0, e.poseidon2_full_a_1, e.poseidon2_full_a_2, e.poseidon2_full_a_3, e.poseidon2_full_execute_poseidon_perm, e.poseidon2_full_input_0, e.poseidon2_full_input_1, e.poseidon2_full_input_2, e.poseidon2_full_num_perm_rounds_rem, e.poseidon2_full_sel_poseidon, e.poseidon2_full_start_poseidon, e.slice_addr, e.slice_clk, e.slice_cnt, e.slice_col_offset, e.slice_sel_cd_cpy, e.slice_sel_mem_active, e.slice_sel_return, e.slice_sel_start, e.slice_space_id +#define ALL_ENTITIES PRECOMPUTED_ENTITIES, WIRE_ENTITIES, DERIVED_WITNESS_ENTITIES, SHIFTED_ENTITIES + +#define TO_BE_SHIFTED_COLUMNS Column::binary_acc_ia, Column::binary_acc_ib, Column::binary_acc_ic, Column::binary_mem_tag_ctr, Column::binary_op_id, Column::cmp_a_hi, Column::cmp_a_lo, Column::cmp_b_hi, Column::cmp_b_lo, Column::cmp_cmp_rng_ctr, Column::cmp_op_gt, Column::cmp_p_sub_a_hi, Column::cmp_p_sub_a_lo, Column::cmp_p_sub_b_hi, Column::cmp_p_sub_b_lo, Column::cmp_sel_rng_chk, Column::main_da_gas_remaining, Column::main_l2_gas_remaining, Column::main_pc, Column::main_sel_execution_end, Column::main_sel_execution_row, Column::mem_glob_addr, Column::mem_rw, Column::mem_sel_mem, Column::mem_tag, Column::mem_tsp, Column::mem_val, Column::merkle_tree_leaf_index, Column::merkle_tree_leaf_value, Column::merkle_tree_path_len, Column::poseidon2_full_a_0, Column::poseidon2_full_a_1, Column::poseidon2_full_a_2, Column::poseidon2_full_a_3, Column::poseidon2_full_execute_poseidon_perm, Column::poseidon2_full_input_0, Column::poseidon2_full_input_1, Column::poseidon2_full_input_2, Column::poseidon2_full_num_perm_rounds_rem, Column::poseidon2_full_sel_poseidon, Column::poseidon2_full_start_poseidon, Column::slice_addr, Column::slice_clk, Column::slice_cnt, Column::slice_col_offset, Column::slice_sel_cd_cpy, Column::slice_sel_mem_active, Column::slice_sel_return, Column::slice_sel_start, Column::slice_space_id +#define SHIFTED_COLUMNS ColumnAndShifts::binary_acc_ia_shift, ColumnAndShifts::binary_acc_ib_shift, ColumnAndShifts::binary_acc_ic_shift, ColumnAndShifts::binary_mem_tag_ctr_shift, ColumnAndShifts::binary_op_id_shift, ColumnAndShifts::cmp_a_hi_shift, ColumnAndShifts::cmp_a_lo_shift, ColumnAndShifts::cmp_b_hi_shift, ColumnAndShifts::cmp_b_lo_shift, ColumnAndShifts::cmp_cmp_rng_ctr_shift, ColumnAndShifts::cmp_op_gt_shift, ColumnAndShifts::cmp_p_sub_a_hi_shift, ColumnAndShifts::cmp_p_sub_a_lo_shift, ColumnAndShifts::cmp_p_sub_b_hi_shift, ColumnAndShifts::cmp_p_sub_b_lo_shift, ColumnAndShifts::cmp_sel_rng_chk_shift, ColumnAndShifts::main_da_gas_remaining_shift, ColumnAndShifts::main_l2_gas_remaining_shift, ColumnAndShifts::main_pc_shift, ColumnAndShifts::main_sel_execution_end_shift, ColumnAndShifts::main_sel_execution_row_shift, ColumnAndShifts::mem_glob_addr_shift, ColumnAndShifts::mem_rw_shift, ColumnAndShifts::mem_sel_mem_shift, ColumnAndShifts::mem_tag_shift, ColumnAndShifts::mem_tsp_shift, ColumnAndShifts::mem_val_shift, ColumnAndShifts::merkle_tree_leaf_index_shift, ColumnAndShifts::merkle_tree_leaf_value_shift, ColumnAndShifts::merkle_tree_path_len_shift, ColumnAndShifts::poseidon2_full_a_0_shift, ColumnAndShifts::poseidon2_full_a_1_shift, ColumnAndShifts::poseidon2_full_a_2_shift, ColumnAndShifts::poseidon2_full_a_3_shift, ColumnAndShifts::poseidon2_full_execute_poseidon_perm_shift, ColumnAndShifts::poseidon2_full_input_0_shift, ColumnAndShifts::poseidon2_full_input_1_shift, ColumnAndShifts::poseidon2_full_input_2_shift, ColumnAndShifts::poseidon2_full_num_perm_rounds_rem_shift, ColumnAndShifts::poseidon2_full_sel_poseidon_shift, ColumnAndShifts::poseidon2_full_start_poseidon_shift, ColumnAndShifts::slice_addr_shift, ColumnAndShifts::slice_clk_shift, ColumnAndShifts::slice_cnt_shift, ColumnAndShifts::slice_col_offset_shift, ColumnAndShifts::slice_sel_cd_cpy_shift, ColumnAndShifts::slice_sel_mem_active_shift, ColumnAndShifts::slice_sel_return_shift, ColumnAndShifts::slice_sel_start_shift, ColumnAndShifts::slice_space_id_shift + +#define ALL_ENTITIES PRECOMPUTED_ENTITIES, WIRE_ENTITIES, DERIVED_WITNESS_ENTITIES, SHIFTED_ENTITIES +#define UNSHIFTED_ENTITIES PRECOMPUTED_ENTITIES, WIRE_ENTITIES, DERIVED_WITNESS_ENTITIES +// clang-format on + +// All columns minus shifts. +enum class Column { UNSHIFTED_ENTITIES }; + +// C++ doesn't allow enum extension, so we'll have to cast. +enum class ColumnAndShifts { + ALL_ENTITIES, + // Sentinel. + NUM_COLUMNS, +}; + +constexpr auto TO_BE_SHIFTED_COLUMNS_ARRAY = []() { return std::array{ TO_BE_SHIFTED_COLUMNS }; }(); +constexpr auto SHIFTED_COLUMNS_ARRAY = []() { return std::array{ SHIFTED_COLUMNS }; }(); +static_assert(TO_BE_SHIFTED_COLUMNS_ARRAY.size() == SHIFTED_COLUMNS_ARRAY.size()); + +} // namespace bb::avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/composer.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/composer.cpp index 0f9a66a557d..1c47215b094 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/composer.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/composer.cpp @@ -1,5 +1,5 @@ // AUTOGENERATED FILE -#include "barretenberg/vm/avm/generated/composer.hpp" +#include "composer.hpp" #include "barretenberg/vm/stats.hpp" namespace bb { diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/composer.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/composer.hpp index 4fde11c2f33..2dc53e31a99 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/composer.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/composer.hpp @@ -2,9 +2,9 @@ #pragma once #include "barretenberg/srs/global_crs.hpp" -#include "barretenberg/vm/avm/generated/circuit_builder.hpp" -#include "barretenberg/vm/avm/generated/prover.hpp" -#include "barretenberg/vm/avm/generated/verifier.hpp" +#include "circuit_builder.hpp" +#include "prover.hpp" +#include "verifier.hpp" namespace bb { diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp index ff71f710172..c36b40050fd 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp @@ -1,5 +1,5 @@ // AUTOGENERATED FILE -#include "barretenberg/vm/avm/generated/flavor.hpp" +#include "flavor.hpp" namespace bb { diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp index ca55350407a..2a0a90c2603 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp @@ -12,96 +12,87 @@ #include "barretenberg/polynomials/evaluation_domain.hpp" #include "barretenberg/transcript/transcript.hpp" -#include "barretenberg/vm/avm/generated/flavor_settings.hpp" #include "barretenberg/vm/aztec_constants.hpp" +#include "columns.hpp" +#include "flavor_settings.hpp" // Relations -#include "barretenberg/vm/avm/generated/relations/alu.hpp" -#include "barretenberg/vm/avm/generated/relations/binary.hpp" -#include "barretenberg/vm/avm/generated/relations/bytecode.hpp" -#include "barretenberg/vm/avm/generated/relations/cmp.hpp" -#include "barretenberg/vm/avm/generated/relations/conversion.hpp" -#include "barretenberg/vm/avm/generated/relations/gas.hpp" -#include "barretenberg/vm/avm/generated/relations/keccakf1600.hpp" -#include "barretenberg/vm/avm/generated/relations/main.hpp" -#include "barretenberg/vm/avm/generated/relations/mem.hpp" -#include "barretenberg/vm/avm/generated/relations/mem_slice.hpp" -#include "barretenberg/vm/avm/generated/relations/merkle_tree.hpp" -#include "barretenberg/vm/avm/generated/relations/poseidon2.hpp" -#include "barretenberg/vm/avm/generated/relations/poseidon2_full.hpp" -#include "barretenberg/vm/avm/generated/relations/range_check.hpp" -#include "barretenberg/vm/avm/generated/relations/sha256.hpp" +#include "relations/alu.hpp" +#include "relations/binary.hpp" +#include "relations/bytecode.hpp" +#include "relations/cmp.hpp" +#include "relations/conversion.hpp" +#include "relations/gas.hpp" +#include "relations/keccakf1600.hpp" +#include "relations/main.hpp" +#include "relations/mem.hpp" +#include "relations/mem_slice.hpp" +#include "relations/merkle_tree.hpp" +#include "relations/poseidon2.hpp" +#include "relations/poseidon2_full.hpp" +#include "relations/range_check.hpp" +#include "relations/sha256.hpp" // Lookup and permutation relations -#include "barretenberg/vm/avm/generated/relations/incl_main_tag_err.hpp" -#include "barretenberg/vm/avm/generated/relations/incl_mem_tag_err.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_byte_lengths.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_byte_operations.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_cd_value.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_da_gas_rng_chk_0.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_da_gas_rng_chk_1.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_l2_gas_rng_chk_0.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_l2_gas_rng_chk_1.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_mem_rng_chk_0.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_mem_rng_chk_1.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_mem_rng_chk_2.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_opcode_gas.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_pow_2_0.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_pow_2_1.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_ret_value.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_rng_chk_0.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_rng_chk_1.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_rng_chk_2.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_rng_chk_3.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_rng_chk_4.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_rng_chk_5.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_rng_chk_6.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_rng_chk_7.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_rng_chk_diff.hpp" -#include "barretenberg/vm/avm/generated/relations/lookup_rng_chk_pow_2.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_cmp_alu.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_main_alu.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_main_bin.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_main_conv.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_main_mem_a.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_main_mem_b.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_main_mem_c.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_main_mem_d.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_main_mem_ind_addr_a.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_main_mem_ind_addr_b.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_main_mem_ind_addr_c.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_main_mem_ind_addr_d.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_main_pos2_perm.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_main_sha256.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_merkle_poseidon2.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_pos2_fixed_pos2_perm.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_pos_mem_read_a.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_pos_mem_read_b.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_pos_mem_read_c.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_pos_mem_read_d.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_pos_mem_write_a.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_pos_mem_write_b.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_pos_mem_write_c.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_pos_mem_write_d.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_rng_alu.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_rng_cmp_hi.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_rng_cmp_lo.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_rng_non_ff_cmp.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_slice_mem.hpp" +#include "relations/incl_main_tag_err.hpp" +#include "relations/incl_mem_tag_err.hpp" +#include "relations/lookup_byte_lengths.hpp" +#include "relations/lookup_byte_operations.hpp" +#include "relations/lookup_cd_value.hpp" +#include "relations/lookup_da_gas_rng_chk_0.hpp" +#include "relations/lookup_da_gas_rng_chk_1.hpp" +#include "relations/lookup_l2_gas_rng_chk_0.hpp" +#include "relations/lookup_l2_gas_rng_chk_1.hpp" +#include "relations/lookup_mem_rng_chk_0.hpp" +#include "relations/lookup_mem_rng_chk_1.hpp" +#include "relations/lookup_mem_rng_chk_2.hpp" +#include "relations/lookup_opcode_gas.hpp" +#include "relations/lookup_pow_2_0.hpp" +#include "relations/lookup_pow_2_1.hpp" +#include "relations/lookup_ret_value.hpp" +#include "relations/lookup_rng_chk_0.hpp" +#include "relations/lookup_rng_chk_1.hpp" +#include "relations/lookup_rng_chk_2.hpp" +#include "relations/lookup_rng_chk_3.hpp" +#include "relations/lookup_rng_chk_4.hpp" +#include "relations/lookup_rng_chk_5.hpp" +#include "relations/lookup_rng_chk_6.hpp" +#include "relations/lookup_rng_chk_7.hpp" +#include "relations/lookup_rng_chk_diff.hpp" +#include "relations/lookup_rng_chk_pow_2.hpp" +#include "relations/perm_cmp_alu.hpp" +#include "relations/perm_main_alu.hpp" +#include "relations/perm_main_bin.hpp" +#include "relations/perm_main_conv.hpp" +#include "relations/perm_main_mem_a.hpp" +#include "relations/perm_main_mem_b.hpp" +#include "relations/perm_main_mem_c.hpp" +#include "relations/perm_main_mem_d.hpp" +#include "relations/perm_main_mem_ind_addr_a.hpp" +#include "relations/perm_main_mem_ind_addr_b.hpp" +#include "relations/perm_main_mem_ind_addr_c.hpp" +#include "relations/perm_main_mem_ind_addr_d.hpp" +#include "relations/perm_main_pos2_perm.hpp" +#include "relations/perm_main_sha256.hpp" +#include "relations/perm_merkle_poseidon2.hpp" +#include "relations/perm_pos2_fixed_pos2_perm.hpp" +#include "relations/perm_pos_mem_read_a.hpp" +#include "relations/perm_pos_mem_read_b.hpp" +#include "relations/perm_pos_mem_read_c.hpp" +#include "relations/perm_pos_mem_read_d.hpp" +#include "relations/perm_pos_mem_write_a.hpp" +#include "relations/perm_pos_mem_write_b.hpp" +#include "relations/perm_pos_mem_write_c.hpp" +#include "relations/perm_pos_mem_write_d.hpp" +#include "relations/perm_rng_alu.hpp" +#include "relations/perm_rng_cmp_hi.hpp" +#include "relations/perm_rng_cmp_lo.hpp" +#include "relations/perm_rng_non_ff_cmp.hpp" +#include "relations/perm_slice_mem.hpp" // Metaprogramming to concatenate tuple types. template using tuple_cat_t = decltype(std::tuple_cat(std::declval()...)); -// The entities that will be used in the flavor. -// clang-format off -#define PRECOMPUTED_ENTITIES byte_lookup_sel_bin, byte_lookup_table_byte_lengths, byte_lookup_table_in_tags, byte_lookup_table_input_a, byte_lookup_table_input_b, byte_lookup_table_op_id, byte_lookup_table_output, gas_base_da_gas_fixed_table, gas_base_l2_gas_fixed_table, gas_dyn_da_gas_fixed_table, gas_dyn_l2_gas_fixed_table, gas_sel_gas_cost, main_clk, main_sel_da_end_gas_kernel_input, main_sel_da_start_gas_kernel_input, main_sel_first, main_sel_l2_end_gas_kernel_input, main_sel_l2_start_gas_kernel_input, main_sel_start_exec, main_zeroes, powers_power_of_2 -#define WIRE_ENTITIES main_kernel_inputs, main_kernel_value_out, main_kernel_side_effect_out, main_kernel_metadata_out, main_calldata, main_returndata, alu_a_hi, alu_a_lo, alu_b_hi, alu_b_lo, alu_b_pow, alu_c_hi, alu_c_lo, alu_cf, alu_clk, alu_cmp_gadget_gt, alu_cmp_gadget_input_a, alu_cmp_gadget_input_b, alu_cmp_gadget_non_ff_gt, alu_cmp_gadget_result, alu_cmp_gadget_sel, alu_ff_tag, alu_ia, alu_ib, alu_ic, alu_in_tag, alu_max_bits_sub_b_bits, alu_max_bits_sub_b_pow, alu_op_add, alu_op_cast, alu_op_div, alu_op_eq, alu_op_lt, alu_op_lte, alu_op_mul, alu_op_not, alu_op_shl, alu_op_shr, alu_op_sub, alu_partial_prod_hi, alu_partial_prod_lo, alu_range_check_input_value, alu_range_check_num_bits, alu_range_check_sel, alu_remainder, alu_sel_alu, alu_sel_cmp, alu_sel_shift_which, alu_u128_tag, alu_u16_tag, alu_u1_tag, alu_u32_tag, alu_u64_tag, alu_u8_tag, alu_zero_shift, binary_acc_ia, binary_acc_ib, binary_acc_ic, binary_clk, binary_ia_bytes, binary_ib_bytes, binary_ic_bytes, binary_in_tag, binary_mem_tag_ctr, binary_mem_tag_ctr_inv, binary_op_id, binary_sel_bin, binary_start, bytecode_arifact_hash, bytecode_as_fields, bytecode_bytes, bytecode_bytes_pc, bytecode_class_id, bytecode_contract_address, bytecode_decomposed, bytecode_deployer_addr, bytecode_end_latch, bytecode_incoming_viewing_key_x, bytecode_incoming_viewing_key_y, bytecode_initialization_hash, bytecode_length_remaining, bytecode_nullifier_key_x, bytecode_nullifier_key_y, bytecode_outgoing_viewing_key_x, bytecode_outgoing_viewing_key_y, bytecode_private_fn_root, bytecode_public_key_hash, bytecode_running_hash, bytecode_salt, bytecode_tagging_key_x, bytecode_tagging_key_y, cmp_a_hi, cmp_a_lo, cmp_b_hi, cmp_b_lo, cmp_borrow, cmp_clk, cmp_cmp_rng_ctr, cmp_diff, cmp_input_a, cmp_input_b, cmp_op_eq, cmp_op_eq_diff_inv, cmp_op_gt, cmp_op_non_ff_gt, cmp_p_a_borrow, cmp_p_b_borrow, cmp_p_sub_a_hi, cmp_p_sub_a_lo, cmp_p_sub_b_hi, cmp_p_sub_b_lo, cmp_range_chk_clk, cmp_res_hi, cmp_res_lo, cmp_result, cmp_sel_cmp, cmp_sel_rng_chk, cmp_shift_sel, conversion_clk, conversion_input, conversion_num_limbs, conversion_output_bits, conversion_radix, conversion_sel_to_radix_be, keccakf1600_clk, keccakf1600_input, keccakf1600_output, keccakf1600_sel_keccakf1600, main_abs_da_rem_gas, main_abs_l2_rem_gas, main_alu_in_tag, main_base_da_gas_op_cost, main_base_l2_gas_op_cost, main_bin_op_id, main_call_ptr, main_da_gas_remaining, main_da_gas_u16_r0, main_da_gas_u16_r1, main_da_out_of_gas, main_dyn_da_gas_op_cost, main_dyn_gas_multiplier, main_dyn_l2_gas_op_cost, main_ia, main_ib, main_ic, main_id, main_id_zero, main_ind_addr_a, main_ind_addr_b, main_ind_addr_c, main_ind_addr_d, main_internal_return_ptr, main_inv, main_is_fake_row, main_is_gas_accounted, main_l2_gas_remaining, main_l2_gas_u16_r0, main_l2_gas_u16_r1, main_l2_out_of_gas, main_mem_addr_a, main_mem_addr_b, main_mem_addr_c, main_mem_addr_d, main_op_err, main_opcode_val, main_pc, main_r_in_tag, main_rwa, main_rwb, main_rwc, main_rwd, main_sel_alu, main_sel_bin, main_sel_calldata, main_sel_execution_end, main_sel_execution_row, main_sel_mem_op_a, main_sel_mem_op_b, main_sel_mem_op_c, main_sel_mem_op_d, main_sel_mov_ia_to_ic, main_sel_mov_ib_to_ic, main_sel_op_add, main_sel_op_address, main_sel_op_and, main_sel_op_block_number, main_sel_op_calldata_copy, main_sel_op_cast, main_sel_op_chain_id, main_sel_op_dagasleft, main_sel_op_debug_log, main_sel_op_div, main_sel_op_ecadd, main_sel_op_emit_l2_to_l1_msg, main_sel_op_emit_note_hash, main_sel_op_emit_nullifier, main_sel_op_emit_unencrypted_log, main_sel_op_eq, main_sel_op_external_call, main_sel_op_external_return, main_sel_op_external_revert, main_sel_op_fdiv, main_sel_op_fee_per_da_gas, main_sel_op_fee_per_l2_gas, main_sel_op_get_contract_instance, main_sel_op_internal_call, main_sel_op_internal_return, main_sel_op_is_static_call, main_sel_op_jump, main_sel_op_jumpi, main_sel_op_keccak, main_sel_op_l1_to_l2_msg_exists, main_sel_op_l2gasleft, main_sel_op_lt, main_sel_op_lte, main_sel_op_mov, main_sel_op_msm, main_sel_op_mul, main_sel_op_not, main_sel_op_note_hash_exists, main_sel_op_nullifier_exists, main_sel_op_or, main_sel_op_poseidon2, main_sel_op_radix_be, main_sel_op_returndata_copy, main_sel_op_returndata_size, main_sel_op_sender, main_sel_op_set, main_sel_op_sha256, main_sel_op_shl, main_sel_op_shr, main_sel_op_sload, main_sel_op_sstore, main_sel_op_static_call, main_sel_op_sub, main_sel_op_timestamp, main_sel_op_transaction_fee, main_sel_op_version, main_sel_op_xor, main_sel_q_kernel_lookup, main_sel_q_kernel_output_lookup, main_sel_resolve_ind_addr_a, main_sel_resolve_ind_addr_b, main_sel_resolve_ind_addr_c, main_sel_resolve_ind_addr_d, main_sel_returndata, main_sel_rng_16, main_sel_rng_8, main_sel_slice_gadget, main_space_id, main_tag_err, main_w_in_tag, mem_addr, mem_clk, mem_diff, mem_glob_addr, mem_last, mem_lastAccess, mem_one_min_inv, mem_r_in_tag, mem_rw, mem_sel_mem, mem_sel_mov_ia_to_ic, mem_sel_mov_ib_to_ic, mem_sel_op_a, mem_sel_op_b, mem_sel_op_c, mem_sel_op_d, mem_sel_op_poseidon_read_a, mem_sel_op_poseidon_read_b, mem_sel_op_poseidon_read_c, mem_sel_op_poseidon_read_d, mem_sel_op_poseidon_write_a, mem_sel_op_poseidon_write_b, mem_sel_op_poseidon_write_c, mem_sel_op_poseidon_write_d, mem_sel_op_slice, mem_sel_resolve_ind_addr_a, mem_sel_resolve_ind_addr_b, mem_sel_resolve_ind_addr_c, mem_sel_resolve_ind_addr_d, mem_sel_rng_chk, mem_skip_check_tag, mem_space_id, mem_tag, mem_tag_err, mem_tsp, mem_u16_r0, mem_u16_r1, mem_u8_r0, mem_val, mem_w_in_tag, merkle_tree_clk, merkle_tree_expected_tree_root, merkle_tree_latch, merkle_tree_leaf_index, merkle_tree_leaf_index_is_even, merkle_tree_leaf_value, merkle_tree_left_hash, merkle_tree_output_hash, merkle_tree_path_len, merkle_tree_path_len_inv, merkle_tree_right_hash, merkle_tree_sel_merkle_tree, merkle_tree_sibling_value, poseidon2_B_10_0, poseidon2_B_10_1, poseidon2_B_10_2, poseidon2_B_10_3, poseidon2_B_11_0, poseidon2_B_11_1, poseidon2_B_11_2, poseidon2_B_11_3, poseidon2_B_12_0, poseidon2_B_12_1, poseidon2_B_12_2, poseidon2_B_12_3, poseidon2_B_13_0, poseidon2_B_13_1, poseidon2_B_13_2, poseidon2_B_13_3, poseidon2_B_14_0, poseidon2_B_14_1, poseidon2_B_14_2, poseidon2_B_14_3, poseidon2_B_15_0, poseidon2_B_15_1, poseidon2_B_15_2, poseidon2_B_15_3, poseidon2_B_16_0, poseidon2_B_16_1, poseidon2_B_16_2, poseidon2_B_16_3, poseidon2_B_17_0, poseidon2_B_17_1, poseidon2_B_17_2, poseidon2_B_17_3, poseidon2_B_18_0, poseidon2_B_18_1, poseidon2_B_18_2, poseidon2_B_18_3, poseidon2_B_19_0, poseidon2_B_19_1, poseidon2_B_19_2, poseidon2_B_19_3, poseidon2_B_20_0, poseidon2_B_20_1, poseidon2_B_20_2, poseidon2_B_20_3, poseidon2_B_21_0, poseidon2_B_21_1, poseidon2_B_21_2, poseidon2_B_21_3, poseidon2_B_22_0, poseidon2_B_22_1, poseidon2_B_22_2, poseidon2_B_22_3, poseidon2_B_23_0, poseidon2_B_23_1, poseidon2_B_23_2, poseidon2_B_23_3, poseidon2_B_24_0, poseidon2_B_24_1, poseidon2_B_24_2, poseidon2_B_24_3, poseidon2_B_25_0, poseidon2_B_25_1, poseidon2_B_25_2, poseidon2_B_25_3, poseidon2_B_26_0, poseidon2_B_26_1, poseidon2_B_26_2, poseidon2_B_26_3, poseidon2_B_27_0, poseidon2_B_27_1, poseidon2_B_27_2, poseidon2_B_27_3, poseidon2_B_28_0, poseidon2_B_28_1, poseidon2_B_28_2, poseidon2_B_28_3, poseidon2_B_29_0, poseidon2_B_29_1, poseidon2_B_29_2, poseidon2_B_29_3, poseidon2_B_30_0, poseidon2_B_30_1, poseidon2_B_30_2, poseidon2_B_30_3, poseidon2_B_31_0, poseidon2_B_31_1, poseidon2_B_31_2, poseidon2_B_31_3, poseidon2_B_32_0, poseidon2_B_32_1, poseidon2_B_32_2, poseidon2_B_32_3, poseidon2_B_33_0, poseidon2_B_33_1, poseidon2_B_33_2, poseidon2_B_33_3, poseidon2_B_34_0, poseidon2_B_34_1, poseidon2_B_34_2, poseidon2_B_34_3, poseidon2_B_35_0, poseidon2_B_35_1, poseidon2_B_35_2, poseidon2_B_35_3, poseidon2_B_36_0, poseidon2_B_36_1, poseidon2_B_36_2, poseidon2_B_36_3, poseidon2_B_37_0, poseidon2_B_37_1, poseidon2_B_37_2, poseidon2_B_37_3, poseidon2_B_38_0, poseidon2_B_38_1, poseidon2_B_38_2, poseidon2_B_38_3, poseidon2_B_39_0, poseidon2_B_39_1, poseidon2_B_39_2, poseidon2_B_39_3, poseidon2_B_40_0, poseidon2_B_40_1, poseidon2_B_40_2, poseidon2_B_40_3, poseidon2_B_41_0, poseidon2_B_41_1, poseidon2_B_41_2, poseidon2_B_41_3, poseidon2_B_42_0, poseidon2_B_42_1, poseidon2_B_42_2, poseidon2_B_42_3, poseidon2_B_43_0, poseidon2_B_43_1, poseidon2_B_43_2, poseidon2_B_43_3, poseidon2_B_44_0, poseidon2_B_44_1, poseidon2_B_44_2, poseidon2_B_44_3, poseidon2_B_45_0, poseidon2_B_45_1, poseidon2_B_45_2, poseidon2_B_45_3, poseidon2_B_46_0, poseidon2_B_46_1, poseidon2_B_46_2, poseidon2_B_46_3, poseidon2_B_47_0, poseidon2_B_47_1, poseidon2_B_47_2, poseidon2_B_47_3, poseidon2_B_48_0, poseidon2_B_48_1, poseidon2_B_48_2, poseidon2_B_48_3, poseidon2_B_49_0, poseidon2_B_49_1, poseidon2_B_49_2, poseidon2_B_49_3, poseidon2_B_4_0, poseidon2_B_4_1, poseidon2_B_4_2, poseidon2_B_4_3, poseidon2_B_50_0, poseidon2_B_50_1, poseidon2_B_50_2, poseidon2_B_50_3, poseidon2_B_51_0, poseidon2_B_51_1, poseidon2_B_51_2, poseidon2_B_51_3, poseidon2_B_52_0, poseidon2_B_52_1, poseidon2_B_52_2, poseidon2_B_52_3, poseidon2_B_53_0, poseidon2_B_53_1, poseidon2_B_53_2, poseidon2_B_53_3, poseidon2_B_54_0, poseidon2_B_54_1, poseidon2_B_54_2, poseidon2_B_54_3, poseidon2_B_55_0, poseidon2_B_55_1, poseidon2_B_55_2, poseidon2_B_55_3, poseidon2_B_56_0, poseidon2_B_56_1, poseidon2_B_56_2, poseidon2_B_56_3, poseidon2_B_57_0, poseidon2_B_57_1, poseidon2_B_57_2, poseidon2_B_57_3, poseidon2_B_58_0, poseidon2_B_58_1, poseidon2_B_58_2, poseidon2_B_58_3, poseidon2_B_59_0, poseidon2_B_59_1, poseidon2_B_59_2, poseidon2_B_59_3, poseidon2_B_5_0, poseidon2_B_5_1, poseidon2_B_5_2, poseidon2_B_5_3, poseidon2_B_6_0, poseidon2_B_6_1, poseidon2_B_6_2, poseidon2_B_6_3, poseidon2_B_7_0, poseidon2_B_7_1, poseidon2_B_7_2, poseidon2_B_7_3, poseidon2_B_8_0, poseidon2_B_8_1, poseidon2_B_8_2, poseidon2_B_8_3, poseidon2_B_9_0, poseidon2_B_9_1, poseidon2_B_9_2, poseidon2_B_9_3, poseidon2_EXT_LAYER_4, poseidon2_EXT_LAYER_5, poseidon2_EXT_LAYER_6, poseidon2_EXT_LAYER_7, poseidon2_T_0_4, poseidon2_T_0_5, poseidon2_T_0_6, poseidon2_T_0_7, poseidon2_T_1_4, poseidon2_T_1_5, poseidon2_T_1_6, poseidon2_T_1_7, poseidon2_T_2_4, poseidon2_T_2_5, poseidon2_T_2_6, poseidon2_T_2_7, poseidon2_T_3_4, poseidon2_T_3_5, poseidon2_T_3_6, poseidon2_T_3_7, poseidon2_T_60_4, poseidon2_T_60_5, poseidon2_T_60_6, poseidon2_T_60_7, poseidon2_T_61_4, poseidon2_T_61_5, poseidon2_T_61_6, poseidon2_T_61_7, poseidon2_T_62_4, poseidon2_T_62_5, poseidon2_T_62_6, poseidon2_T_62_7, poseidon2_T_63_4, poseidon2_T_63_5, poseidon2_T_63_6, poseidon2_T_63_7, poseidon2_a_0, poseidon2_a_1, poseidon2_a_2, poseidon2_a_3, poseidon2_b_0, poseidon2_b_1, poseidon2_b_2, poseidon2_b_3, poseidon2_clk, poseidon2_full_a_0, poseidon2_full_a_1, poseidon2_full_a_2, poseidon2_full_a_3, poseidon2_full_b_0, poseidon2_full_b_1, poseidon2_full_b_2, poseidon2_full_b_3, poseidon2_full_clk, poseidon2_full_end_poseidon, poseidon2_full_execute_poseidon_perm, poseidon2_full_input_0, poseidon2_full_input_1, poseidon2_full_input_2, poseidon2_full_input_len, poseidon2_full_num_perm_rounds_rem, poseidon2_full_num_perm_rounds_rem_inv, poseidon2_full_output, poseidon2_full_padding, poseidon2_full_sel_merkle_tree, poseidon2_full_sel_poseidon, poseidon2_full_start_poseidon, poseidon2_input_addr, poseidon2_mem_addr_read_a, poseidon2_mem_addr_read_b, poseidon2_mem_addr_read_c, poseidon2_mem_addr_read_d, poseidon2_mem_addr_write_a, poseidon2_mem_addr_write_b, poseidon2_mem_addr_write_c, poseidon2_mem_addr_write_d, poseidon2_output_addr, poseidon2_sel_poseidon_perm, poseidon2_sel_poseidon_perm_immediate, poseidon2_sel_poseidon_perm_mem_op, poseidon2_space_id, range_check_alu_rng_chk, range_check_clk, range_check_cmp_hi_bits_rng_chk, range_check_cmp_lo_bits_rng_chk, range_check_cmp_non_ff_rng_chk, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_gas_da_rng_chk, range_check_gas_l2_rng_chk, 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_lookup_0, range_check_sel_lookup_1, range_check_sel_lookup_2, range_check_sel_lookup_3, range_check_sel_lookup_4, range_check_sel_lookup_5, range_check_sel_lookup_6, range_check_sel_rng_chk, 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, sha256_clk, sha256_input, sha256_output, sha256_sel_sha256_compression, sha256_state, slice_addr, slice_clk, slice_cnt, slice_col_offset, slice_one_min_inv, slice_sel_cd_cpy, slice_sel_mem_active, slice_sel_return, slice_sel_start, slice_space_id, slice_val, lookup_rng_chk_pow_2_counts, lookup_rng_chk_diff_counts, lookup_rng_chk_0_counts, lookup_rng_chk_1_counts, lookup_rng_chk_2_counts, lookup_rng_chk_3_counts, lookup_rng_chk_4_counts, lookup_rng_chk_5_counts, lookup_rng_chk_6_counts, lookup_rng_chk_7_counts, lookup_mem_rng_chk_0_counts, lookup_mem_rng_chk_1_counts, lookup_mem_rng_chk_2_counts, lookup_pow_2_0_counts, lookup_pow_2_1_counts, lookup_byte_lengths_counts, lookup_byte_operations_counts, lookup_opcode_gas_counts, lookup_l2_gas_rng_chk_0_counts, lookup_l2_gas_rng_chk_1_counts, lookup_da_gas_rng_chk_0_counts, lookup_da_gas_rng_chk_1_counts, lookup_cd_value_counts, lookup_ret_value_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts -#define DERIVED_WITNESS_ENTITIES perm_rng_non_ff_cmp_inv, perm_rng_cmp_lo_inv, perm_rng_cmp_hi_inv, perm_rng_alu_inv, perm_cmp_alu_inv, perm_pos_mem_read_a_inv, perm_pos_mem_read_b_inv, perm_pos_mem_read_c_inv, perm_pos_mem_read_d_inv, perm_pos_mem_write_a_inv, perm_pos_mem_write_b_inv, perm_pos_mem_write_c_inv, perm_pos_mem_write_d_inv, perm_pos2_fixed_pos2_perm_inv, perm_slice_mem_inv, perm_merkle_poseidon2_inv, perm_main_alu_inv, perm_main_bin_inv, perm_main_conv_inv, perm_main_sha256_inv, perm_main_pos2_perm_inv, perm_main_mem_a_inv, perm_main_mem_b_inv, perm_main_mem_c_inv, perm_main_mem_d_inv, perm_main_mem_ind_addr_a_inv, perm_main_mem_ind_addr_b_inv, perm_main_mem_ind_addr_c_inv, perm_main_mem_ind_addr_d_inv, lookup_rng_chk_pow_2_inv, lookup_rng_chk_diff_inv, lookup_rng_chk_0_inv, lookup_rng_chk_1_inv, lookup_rng_chk_2_inv, lookup_rng_chk_3_inv, lookup_rng_chk_4_inv, lookup_rng_chk_5_inv, lookup_rng_chk_6_inv, lookup_rng_chk_7_inv, lookup_mem_rng_chk_0_inv, lookup_mem_rng_chk_1_inv, lookup_mem_rng_chk_2_inv, lookup_pow_2_0_inv, lookup_pow_2_1_inv, lookup_byte_lengths_inv, lookup_byte_operations_inv, lookup_opcode_gas_inv, lookup_l2_gas_rng_chk_0_inv, lookup_l2_gas_rng_chk_1_inv, lookup_da_gas_rng_chk_0_inv, lookup_da_gas_rng_chk_1_inv, lookup_cd_value_inv, lookup_ret_value_inv, incl_main_tag_err_inv, incl_mem_tag_err_inv -#define SHIFTED_ENTITIES binary_acc_ia_shift, binary_acc_ib_shift, binary_acc_ic_shift, binary_mem_tag_ctr_shift, binary_op_id_shift, cmp_a_hi_shift, cmp_a_lo_shift, cmp_b_hi_shift, cmp_b_lo_shift, cmp_cmp_rng_ctr_shift, cmp_op_gt_shift, cmp_p_sub_a_hi_shift, cmp_p_sub_a_lo_shift, cmp_p_sub_b_hi_shift, cmp_p_sub_b_lo_shift, cmp_sel_rng_chk_shift, main_da_gas_remaining_shift, main_l2_gas_remaining_shift, main_pc_shift, main_sel_execution_end_shift, main_sel_execution_row_shift, mem_glob_addr_shift, mem_rw_shift, mem_sel_mem_shift, mem_tag_shift, mem_tsp_shift, mem_val_shift, merkle_tree_leaf_index_shift, merkle_tree_leaf_value_shift, merkle_tree_path_len_shift, poseidon2_full_a_0_shift, poseidon2_full_a_1_shift, poseidon2_full_a_2_shift, poseidon2_full_a_3_shift, poseidon2_full_execute_poseidon_perm_shift, poseidon2_full_input_0_shift, poseidon2_full_input_1_shift, poseidon2_full_input_2_shift, poseidon2_full_num_perm_rounds_rem_shift, poseidon2_full_sel_poseidon_shift, poseidon2_full_start_poseidon_shift, slice_addr_shift, slice_clk_shift, slice_cnt_shift, slice_col_offset_shift, slice_sel_cd_cpy_shift, slice_sel_mem_active_shift, slice_sel_return_shift, slice_sel_start_shift, slice_space_id_shift -#define TO_BE_SHIFTED(e) e.binary_acc_ia, e.binary_acc_ib, e.binary_acc_ic, e.binary_mem_tag_ctr, e.binary_op_id, e.cmp_a_hi, e.cmp_a_lo, e.cmp_b_hi, e.cmp_b_lo, e.cmp_cmp_rng_ctr, e.cmp_op_gt, e.cmp_p_sub_a_hi, e.cmp_p_sub_a_lo, e.cmp_p_sub_b_hi, e.cmp_p_sub_b_lo, e.cmp_sel_rng_chk, e.main_da_gas_remaining, e.main_l2_gas_remaining, e.main_pc, e.main_sel_execution_end, e.main_sel_execution_row, e.mem_glob_addr, e.mem_rw, e.mem_sel_mem, e.mem_tag, e.mem_tsp, e.mem_val, e.merkle_tree_leaf_index, e.merkle_tree_leaf_value, e.merkle_tree_path_len, e.poseidon2_full_a_0, e.poseidon2_full_a_1, e.poseidon2_full_a_2, e.poseidon2_full_a_3, e.poseidon2_full_execute_poseidon_perm, e.poseidon2_full_input_0, e.poseidon2_full_input_1, e.poseidon2_full_input_2, e.poseidon2_full_num_perm_rounds_rem, e.poseidon2_full_sel_poseidon, e.poseidon2_full_start_poseidon, e.slice_addr, e.slice_clk, e.slice_cnt, e.slice_col_offset, e.slice_sel_cd_cpy, e.slice_sel_mem_active, e.slice_sel_return, e.slice_sel_start, e.slice_space_id -#define ALL_ENTITIES PRECOMPUTED_ENTITIES, WIRE_ENTITIES, DERIVED_WITNESS_ENTITIES, SHIFTED_ENTITIES -// clang-format on - namespace bb { class AvmFlavor { @@ -137,21 +128,21 @@ class AvmFlavor { template using MainRelations_ = std::tuple< // Relations - Avm_vm::alu, - Avm_vm::binary, - Avm_vm::bytecode, - Avm_vm::cmp, - Avm_vm::conversion, - Avm_vm::gas, - Avm_vm::keccakf1600, - Avm_vm::main, - Avm_vm::mem, - Avm_vm::mem_slice, - Avm_vm::merkle_tree, - Avm_vm::poseidon2, - Avm_vm::poseidon2_full, - Avm_vm::range_check, - Avm_vm::sha256>; + avm::alu, + avm::binary, + avm::bytecode, + avm::cmp, + avm::conversion, + avm::gas, + avm::keccakf1600, + avm::main, + avm::mem, + avm::mem_slice, + avm::merkle_tree, + avm::poseidon2, + avm::poseidon2_full, + avm::range_check, + avm::sha256>; using MainRelations = MainRelations_; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.cpp index 4b0dc7342a6..35b10f6d03f 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.cpp @@ -1,8 +1,8 @@ // AUTOGENERATED FILE -#include "barretenberg/vm/avm/generated/full_row.hpp" -#include "barretenberg/vm/avm/generated/flavor_settings.hpp" +#include "full_row.hpp" +#include "flavor_settings.hpp" -namespace bb { +namespace bb::avm { namespace { template std::string field_to_string(const FF& ff) @@ -1568,4 +1568,4 @@ template std::ostream& operator<<(std::ostream& os, AvmFullRow AvmFullRow::names(); template RefVector AvmFullRow::as_vector() const; -} // namespace bb +} // namespace bb::avm diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.hpp index 8da7a889d75..5b720a84471 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.hpp @@ -6,781 +6,40 @@ #include #include "barretenberg/common/ref_vector.hpp" +#include "columns.hpp" -namespace bb { +namespace bb::avm { -template struct AvmFullRow { - FF byte_lookup_sel_bin{}; - FF byte_lookup_table_byte_lengths{}; - FF byte_lookup_table_in_tags{}; - FF byte_lookup_table_input_a{}; - FF byte_lookup_table_input_b{}; - FF byte_lookup_table_op_id{}; - FF byte_lookup_table_output{}; - FF gas_base_da_gas_fixed_table{}; - FF gas_base_l2_gas_fixed_table{}; - FF gas_dyn_da_gas_fixed_table{}; - FF gas_dyn_l2_gas_fixed_table{}; - FF gas_sel_gas_cost{}; - FF main_clk{}; - FF main_sel_da_end_gas_kernel_input{}; - FF main_sel_da_start_gas_kernel_input{}; - FF main_sel_first{}; - FF main_sel_l2_end_gas_kernel_input{}; - FF main_sel_l2_start_gas_kernel_input{}; - FF main_sel_start_exec{}; - FF main_zeroes{}; - FF powers_power_of_2{}; - FF main_kernel_inputs{}; - FF main_kernel_value_out{}; - FF main_kernel_side_effect_out{}; - FF main_kernel_metadata_out{}; - FF main_calldata{}; - FF main_returndata{}; - FF alu_a_hi{}; - FF alu_a_lo{}; - FF alu_b_hi{}; - FF alu_b_lo{}; - FF alu_b_pow{}; - FF alu_c_hi{}; - FF alu_c_lo{}; - FF alu_cf{}; - FF alu_clk{}; - FF alu_cmp_gadget_gt{}; - FF alu_cmp_gadget_input_a{}; - FF alu_cmp_gadget_input_b{}; - FF alu_cmp_gadget_non_ff_gt{}; - FF alu_cmp_gadget_result{}; - FF alu_cmp_gadget_sel{}; - FF alu_ff_tag{}; - FF alu_ia{}; - FF alu_ib{}; - FF alu_ic{}; - FF alu_in_tag{}; - FF alu_max_bits_sub_b_bits{}; - FF alu_max_bits_sub_b_pow{}; - FF alu_op_add{}; - FF alu_op_cast{}; - FF alu_op_div{}; - FF alu_op_eq{}; - FF alu_op_lt{}; - FF alu_op_lte{}; - FF alu_op_mul{}; - FF alu_op_not{}; - FF alu_op_shl{}; - FF alu_op_shr{}; - FF alu_op_sub{}; - FF alu_partial_prod_hi{}; - FF alu_partial_prod_lo{}; - FF alu_range_check_input_value{}; - FF alu_range_check_num_bits{}; - FF alu_range_check_sel{}; - FF alu_remainder{}; - FF alu_sel_alu{}; - FF alu_sel_cmp{}; - FF alu_sel_shift_which{}; - FF alu_u128_tag{}; - FF alu_u16_tag{}; - FF alu_u1_tag{}; - FF alu_u32_tag{}; - FF alu_u64_tag{}; - FF alu_u8_tag{}; - FF alu_zero_shift{}; - FF binary_acc_ia{}; - FF binary_acc_ib{}; - FF binary_acc_ic{}; - FF binary_clk{}; - FF binary_ia_bytes{}; - FF binary_ib_bytes{}; - FF binary_ic_bytes{}; - FF binary_in_tag{}; - FF binary_mem_tag_ctr{}; - FF binary_mem_tag_ctr_inv{}; - FF binary_op_id{}; - FF binary_sel_bin{}; - FF binary_start{}; - FF bytecode_arifact_hash{}; - FF bytecode_as_fields{}; - FF bytecode_bytes{}; - FF bytecode_bytes_pc{}; - FF bytecode_class_id{}; - FF bytecode_contract_address{}; - FF bytecode_decomposed{}; - FF bytecode_deployer_addr{}; - FF bytecode_end_latch{}; - FF bytecode_incoming_viewing_key_x{}; - FF bytecode_incoming_viewing_key_y{}; - FF bytecode_initialization_hash{}; - FF bytecode_length_remaining{}; - FF bytecode_nullifier_key_x{}; - FF bytecode_nullifier_key_y{}; - FF bytecode_outgoing_viewing_key_x{}; - FF bytecode_outgoing_viewing_key_y{}; - FF bytecode_private_fn_root{}; - FF bytecode_public_key_hash{}; - FF bytecode_running_hash{}; - FF bytecode_salt{}; - FF bytecode_tagging_key_x{}; - FF bytecode_tagging_key_y{}; - FF cmp_a_hi{}; - FF cmp_a_lo{}; - FF cmp_b_hi{}; - FF cmp_b_lo{}; - FF cmp_borrow{}; - FF cmp_clk{}; - FF cmp_cmp_rng_ctr{}; - FF cmp_diff{}; - FF cmp_input_a{}; - FF cmp_input_b{}; - FF cmp_op_eq{}; - FF cmp_op_eq_diff_inv{}; - FF cmp_op_gt{}; - FF cmp_op_non_ff_gt{}; - FF cmp_p_a_borrow{}; - FF cmp_p_b_borrow{}; - FF cmp_p_sub_a_hi{}; - FF cmp_p_sub_a_lo{}; - FF cmp_p_sub_b_hi{}; - FF cmp_p_sub_b_lo{}; - FF cmp_range_chk_clk{}; - FF cmp_res_hi{}; - FF cmp_res_lo{}; - FF cmp_result{}; - FF cmp_sel_cmp{}; - FF cmp_sel_rng_chk{}; - FF cmp_shift_sel{}; - FF conversion_clk{}; - FF conversion_input{}; - FF conversion_num_limbs{}; - FF conversion_output_bits{}; - FF conversion_radix{}; - FF conversion_sel_to_radix_be{}; - FF keccakf1600_clk{}; - FF keccakf1600_input{}; - FF keccakf1600_output{}; - FF keccakf1600_sel_keccakf1600{}; - FF main_abs_da_rem_gas{}; - FF main_abs_l2_rem_gas{}; - FF main_alu_in_tag{}; - FF main_base_da_gas_op_cost{}; - FF main_base_l2_gas_op_cost{}; - FF main_bin_op_id{}; - FF main_call_ptr{}; - FF main_da_gas_remaining{}; - FF main_da_gas_u16_r0{}; - FF main_da_gas_u16_r1{}; - FF main_da_out_of_gas{}; - FF main_dyn_da_gas_op_cost{}; - FF main_dyn_gas_multiplier{}; - FF main_dyn_l2_gas_op_cost{}; - FF main_ia{}; - FF main_ib{}; - FF main_ic{}; - FF main_id{}; - FF main_id_zero{}; - FF main_ind_addr_a{}; - FF main_ind_addr_b{}; - FF main_ind_addr_c{}; - FF main_ind_addr_d{}; - FF main_internal_return_ptr{}; - FF main_inv{}; - FF main_is_fake_row{}; - FF main_is_gas_accounted{}; - FF main_l2_gas_remaining{}; - FF main_l2_gas_u16_r0{}; - FF main_l2_gas_u16_r1{}; - FF main_l2_out_of_gas{}; - FF main_mem_addr_a{}; - FF main_mem_addr_b{}; - FF main_mem_addr_c{}; - FF main_mem_addr_d{}; - FF main_op_err{}; - FF main_opcode_val{}; - FF main_pc{}; - FF main_r_in_tag{}; - FF main_rwa{}; - FF main_rwb{}; - FF main_rwc{}; - FF main_rwd{}; - FF main_sel_alu{}; - FF main_sel_bin{}; - FF main_sel_calldata{}; - FF main_sel_execution_end{}; - FF main_sel_execution_row{}; - FF main_sel_mem_op_a{}; - FF main_sel_mem_op_b{}; - FF main_sel_mem_op_c{}; - FF main_sel_mem_op_d{}; - FF main_sel_mov_ia_to_ic{}; - FF main_sel_mov_ib_to_ic{}; - FF main_sel_op_add{}; - FF main_sel_op_address{}; - FF main_sel_op_and{}; - FF main_sel_op_block_number{}; - FF main_sel_op_calldata_copy{}; - FF main_sel_op_cast{}; - FF main_sel_op_chain_id{}; - FF main_sel_op_dagasleft{}; - FF main_sel_op_debug_log{}; - FF main_sel_op_div{}; - FF main_sel_op_ecadd{}; - FF main_sel_op_emit_l2_to_l1_msg{}; - FF main_sel_op_emit_note_hash{}; - FF main_sel_op_emit_nullifier{}; - FF main_sel_op_emit_unencrypted_log{}; - FF main_sel_op_eq{}; - FF main_sel_op_external_call{}; - FF main_sel_op_external_return{}; - FF main_sel_op_external_revert{}; - FF main_sel_op_fdiv{}; - FF main_sel_op_fee_per_da_gas{}; - FF main_sel_op_fee_per_l2_gas{}; - FF main_sel_op_get_contract_instance{}; - FF main_sel_op_internal_call{}; - FF main_sel_op_internal_return{}; - FF main_sel_op_is_static_call{}; - FF main_sel_op_jump{}; - FF main_sel_op_jumpi{}; - FF main_sel_op_keccak{}; - FF main_sel_op_l1_to_l2_msg_exists{}; - FF main_sel_op_l2gasleft{}; - FF main_sel_op_lt{}; - FF main_sel_op_lte{}; - FF main_sel_op_mov{}; - FF main_sel_op_msm{}; - FF main_sel_op_mul{}; - FF main_sel_op_not{}; - FF main_sel_op_note_hash_exists{}; - FF main_sel_op_nullifier_exists{}; - FF main_sel_op_or{}; - FF main_sel_op_poseidon2{}; - FF main_sel_op_radix_be{}; - FF main_sel_op_returndata_copy{}; - FF main_sel_op_returndata_size{}; - FF main_sel_op_sender{}; - FF main_sel_op_set{}; - FF main_sel_op_sha256{}; - FF main_sel_op_shl{}; - FF main_sel_op_shr{}; - FF main_sel_op_sload{}; - FF main_sel_op_sstore{}; - FF main_sel_op_static_call{}; - FF main_sel_op_sub{}; - FF main_sel_op_timestamp{}; - FF main_sel_op_transaction_fee{}; - FF main_sel_op_version{}; - FF main_sel_op_xor{}; - FF main_sel_q_kernel_lookup{}; - FF main_sel_q_kernel_output_lookup{}; - FF main_sel_resolve_ind_addr_a{}; - FF main_sel_resolve_ind_addr_b{}; - FF main_sel_resolve_ind_addr_c{}; - FF main_sel_resolve_ind_addr_d{}; - FF main_sel_returndata{}; - FF main_sel_rng_16{}; - FF main_sel_rng_8{}; - FF main_sel_slice_gadget{}; - FF main_space_id{}; - FF main_tag_err{}; - FF main_w_in_tag{}; - FF mem_addr{}; - FF mem_clk{}; - FF mem_diff{}; - FF mem_glob_addr{}; - FF mem_last{}; - FF mem_lastAccess{}; - FF mem_one_min_inv{}; - FF mem_r_in_tag{}; - FF mem_rw{}; - FF mem_sel_mem{}; - FF mem_sel_mov_ia_to_ic{}; - FF mem_sel_mov_ib_to_ic{}; - FF mem_sel_op_a{}; - FF mem_sel_op_b{}; - FF mem_sel_op_c{}; - FF mem_sel_op_d{}; - FF mem_sel_op_poseidon_read_a{}; - FF mem_sel_op_poseidon_read_b{}; - FF mem_sel_op_poseidon_read_c{}; - FF mem_sel_op_poseidon_read_d{}; - FF mem_sel_op_poseidon_write_a{}; - FF mem_sel_op_poseidon_write_b{}; - FF mem_sel_op_poseidon_write_c{}; - FF mem_sel_op_poseidon_write_d{}; - FF mem_sel_op_slice{}; - FF mem_sel_resolve_ind_addr_a{}; - FF mem_sel_resolve_ind_addr_b{}; - FF mem_sel_resolve_ind_addr_c{}; - FF mem_sel_resolve_ind_addr_d{}; - FF mem_sel_rng_chk{}; - FF mem_skip_check_tag{}; - FF mem_space_id{}; - FF mem_tag{}; - FF mem_tag_err{}; - FF mem_tsp{}; - FF mem_u16_r0{}; - FF mem_u16_r1{}; - FF mem_u8_r0{}; - FF mem_val{}; - FF mem_w_in_tag{}; - FF merkle_tree_clk{}; - FF merkle_tree_expected_tree_root{}; - FF merkle_tree_latch{}; - FF merkle_tree_leaf_index{}; - FF merkle_tree_leaf_index_is_even{}; - FF merkle_tree_leaf_value{}; - FF merkle_tree_left_hash{}; - FF merkle_tree_output_hash{}; - FF merkle_tree_path_len{}; - FF merkle_tree_path_len_inv{}; - FF merkle_tree_right_hash{}; - FF merkle_tree_sel_merkle_tree{}; - FF merkle_tree_sibling_value{}; - FF poseidon2_B_10_0{}; - FF poseidon2_B_10_1{}; - FF poseidon2_B_10_2{}; - FF poseidon2_B_10_3{}; - FF poseidon2_B_11_0{}; - FF poseidon2_B_11_1{}; - FF poseidon2_B_11_2{}; - FF poseidon2_B_11_3{}; - FF poseidon2_B_12_0{}; - FF poseidon2_B_12_1{}; - FF poseidon2_B_12_2{}; - FF poseidon2_B_12_3{}; - FF poseidon2_B_13_0{}; - FF poseidon2_B_13_1{}; - FF poseidon2_B_13_2{}; - FF poseidon2_B_13_3{}; - FF poseidon2_B_14_0{}; - FF poseidon2_B_14_1{}; - FF poseidon2_B_14_2{}; - FF poseidon2_B_14_3{}; - FF poseidon2_B_15_0{}; - FF poseidon2_B_15_1{}; - FF poseidon2_B_15_2{}; - FF poseidon2_B_15_3{}; - FF poseidon2_B_16_0{}; - FF poseidon2_B_16_1{}; - FF poseidon2_B_16_2{}; - FF poseidon2_B_16_3{}; - FF poseidon2_B_17_0{}; - FF poseidon2_B_17_1{}; - FF poseidon2_B_17_2{}; - FF poseidon2_B_17_3{}; - FF poseidon2_B_18_0{}; - FF poseidon2_B_18_1{}; - FF poseidon2_B_18_2{}; - FF poseidon2_B_18_3{}; - FF poseidon2_B_19_0{}; - FF poseidon2_B_19_1{}; - FF poseidon2_B_19_2{}; - FF poseidon2_B_19_3{}; - FF poseidon2_B_20_0{}; - FF poseidon2_B_20_1{}; - FF poseidon2_B_20_2{}; - FF poseidon2_B_20_3{}; - FF poseidon2_B_21_0{}; - FF poseidon2_B_21_1{}; - FF poseidon2_B_21_2{}; - FF poseidon2_B_21_3{}; - FF poseidon2_B_22_0{}; - FF poseidon2_B_22_1{}; - FF poseidon2_B_22_2{}; - FF poseidon2_B_22_3{}; - FF poseidon2_B_23_0{}; - FF poseidon2_B_23_1{}; - FF poseidon2_B_23_2{}; - FF poseidon2_B_23_3{}; - FF poseidon2_B_24_0{}; - FF poseidon2_B_24_1{}; - FF poseidon2_B_24_2{}; - FF poseidon2_B_24_3{}; - FF poseidon2_B_25_0{}; - FF poseidon2_B_25_1{}; - FF poseidon2_B_25_2{}; - FF poseidon2_B_25_3{}; - FF poseidon2_B_26_0{}; - FF poseidon2_B_26_1{}; - FF poseidon2_B_26_2{}; - FF poseidon2_B_26_3{}; - FF poseidon2_B_27_0{}; - FF poseidon2_B_27_1{}; - FF poseidon2_B_27_2{}; - FF poseidon2_B_27_3{}; - FF poseidon2_B_28_0{}; - FF poseidon2_B_28_1{}; - FF poseidon2_B_28_2{}; - FF poseidon2_B_28_3{}; - FF poseidon2_B_29_0{}; - FF poseidon2_B_29_1{}; - FF poseidon2_B_29_2{}; - FF poseidon2_B_29_3{}; - FF poseidon2_B_30_0{}; - FF poseidon2_B_30_1{}; - FF poseidon2_B_30_2{}; - FF poseidon2_B_30_3{}; - FF poseidon2_B_31_0{}; - FF poseidon2_B_31_1{}; - FF poseidon2_B_31_2{}; - FF poseidon2_B_31_3{}; - FF poseidon2_B_32_0{}; - FF poseidon2_B_32_1{}; - FF poseidon2_B_32_2{}; - FF poseidon2_B_32_3{}; - FF poseidon2_B_33_0{}; - FF poseidon2_B_33_1{}; - FF poseidon2_B_33_2{}; - FF poseidon2_B_33_3{}; - FF poseidon2_B_34_0{}; - FF poseidon2_B_34_1{}; - FF poseidon2_B_34_2{}; - FF poseidon2_B_34_3{}; - FF poseidon2_B_35_0{}; - FF poseidon2_B_35_1{}; - FF poseidon2_B_35_2{}; - FF poseidon2_B_35_3{}; - FF poseidon2_B_36_0{}; - FF poseidon2_B_36_1{}; - FF poseidon2_B_36_2{}; - FF poseidon2_B_36_3{}; - FF poseidon2_B_37_0{}; - FF poseidon2_B_37_1{}; - FF poseidon2_B_37_2{}; - FF poseidon2_B_37_3{}; - FF poseidon2_B_38_0{}; - FF poseidon2_B_38_1{}; - FF poseidon2_B_38_2{}; - FF poseidon2_B_38_3{}; - FF poseidon2_B_39_0{}; - FF poseidon2_B_39_1{}; - FF poseidon2_B_39_2{}; - FF poseidon2_B_39_3{}; - FF poseidon2_B_40_0{}; - FF poseidon2_B_40_1{}; - FF poseidon2_B_40_2{}; - FF poseidon2_B_40_3{}; - FF poseidon2_B_41_0{}; - FF poseidon2_B_41_1{}; - FF poseidon2_B_41_2{}; - FF poseidon2_B_41_3{}; - FF poseidon2_B_42_0{}; - FF poseidon2_B_42_1{}; - FF poseidon2_B_42_2{}; - FF poseidon2_B_42_3{}; - FF poseidon2_B_43_0{}; - FF poseidon2_B_43_1{}; - FF poseidon2_B_43_2{}; - FF poseidon2_B_43_3{}; - FF poseidon2_B_44_0{}; - FF poseidon2_B_44_1{}; - FF poseidon2_B_44_2{}; - FF poseidon2_B_44_3{}; - FF poseidon2_B_45_0{}; - FF poseidon2_B_45_1{}; - FF poseidon2_B_45_2{}; - FF poseidon2_B_45_3{}; - FF poseidon2_B_46_0{}; - FF poseidon2_B_46_1{}; - FF poseidon2_B_46_2{}; - FF poseidon2_B_46_3{}; - FF poseidon2_B_47_0{}; - FF poseidon2_B_47_1{}; - FF poseidon2_B_47_2{}; - FF poseidon2_B_47_3{}; - FF poseidon2_B_48_0{}; - FF poseidon2_B_48_1{}; - FF poseidon2_B_48_2{}; - FF poseidon2_B_48_3{}; - FF poseidon2_B_49_0{}; - FF poseidon2_B_49_1{}; - FF poseidon2_B_49_2{}; - FF poseidon2_B_49_3{}; - FF poseidon2_B_4_0{}; - FF poseidon2_B_4_1{}; - FF poseidon2_B_4_2{}; - FF poseidon2_B_4_3{}; - FF poseidon2_B_50_0{}; - FF poseidon2_B_50_1{}; - FF poseidon2_B_50_2{}; - FF poseidon2_B_50_3{}; - FF poseidon2_B_51_0{}; - FF poseidon2_B_51_1{}; - FF poseidon2_B_51_2{}; - FF poseidon2_B_51_3{}; - FF poseidon2_B_52_0{}; - FF poseidon2_B_52_1{}; - FF poseidon2_B_52_2{}; - FF poseidon2_B_52_3{}; - FF poseidon2_B_53_0{}; - FF poseidon2_B_53_1{}; - FF poseidon2_B_53_2{}; - FF poseidon2_B_53_3{}; - FF poseidon2_B_54_0{}; - FF poseidon2_B_54_1{}; - FF poseidon2_B_54_2{}; - FF poseidon2_B_54_3{}; - FF poseidon2_B_55_0{}; - FF poseidon2_B_55_1{}; - FF poseidon2_B_55_2{}; - FF poseidon2_B_55_3{}; - FF poseidon2_B_56_0{}; - FF poseidon2_B_56_1{}; - FF poseidon2_B_56_2{}; - FF poseidon2_B_56_3{}; - FF poseidon2_B_57_0{}; - FF poseidon2_B_57_1{}; - FF poseidon2_B_57_2{}; - FF poseidon2_B_57_3{}; - FF poseidon2_B_58_0{}; - FF poseidon2_B_58_1{}; - FF poseidon2_B_58_2{}; - FF poseidon2_B_58_3{}; - FF poseidon2_B_59_0{}; - FF poseidon2_B_59_1{}; - FF poseidon2_B_59_2{}; - FF poseidon2_B_59_3{}; - FF poseidon2_B_5_0{}; - FF poseidon2_B_5_1{}; - FF poseidon2_B_5_2{}; - FF poseidon2_B_5_3{}; - FF poseidon2_B_6_0{}; - FF poseidon2_B_6_1{}; - FF poseidon2_B_6_2{}; - FF poseidon2_B_6_3{}; - FF poseidon2_B_7_0{}; - FF poseidon2_B_7_1{}; - FF poseidon2_B_7_2{}; - FF poseidon2_B_7_3{}; - FF poseidon2_B_8_0{}; - FF poseidon2_B_8_1{}; - FF poseidon2_B_8_2{}; - FF poseidon2_B_8_3{}; - FF poseidon2_B_9_0{}; - FF poseidon2_B_9_1{}; - FF poseidon2_B_9_2{}; - FF poseidon2_B_9_3{}; - FF poseidon2_EXT_LAYER_4{}; - FF poseidon2_EXT_LAYER_5{}; - FF poseidon2_EXT_LAYER_6{}; - FF poseidon2_EXT_LAYER_7{}; - FF poseidon2_T_0_4{}; - FF poseidon2_T_0_5{}; - FF poseidon2_T_0_6{}; - FF poseidon2_T_0_7{}; - FF poseidon2_T_1_4{}; - FF poseidon2_T_1_5{}; - FF poseidon2_T_1_6{}; - FF poseidon2_T_1_7{}; - FF poseidon2_T_2_4{}; - FF poseidon2_T_2_5{}; - FF poseidon2_T_2_6{}; - FF poseidon2_T_2_7{}; - FF poseidon2_T_3_4{}; - FF poseidon2_T_3_5{}; - FF poseidon2_T_3_6{}; - FF poseidon2_T_3_7{}; - FF poseidon2_T_60_4{}; - FF poseidon2_T_60_5{}; - FF poseidon2_T_60_6{}; - FF poseidon2_T_60_7{}; - FF poseidon2_T_61_4{}; - FF poseidon2_T_61_5{}; - FF poseidon2_T_61_6{}; - FF poseidon2_T_61_7{}; - FF poseidon2_T_62_4{}; - FF poseidon2_T_62_5{}; - FF poseidon2_T_62_6{}; - FF poseidon2_T_62_7{}; - FF poseidon2_T_63_4{}; - FF poseidon2_T_63_5{}; - FF poseidon2_T_63_6{}; - FF poseidon2_T_63_7{}; - FF poseidon2_a_0{}; - FF poseidon2_a_1{}; - FF poseidon2_a_2{}; - FF poseidon2_a_3{}; - FF poseidon2_b_0{}; - FF poseidon2_b_1{}; - FF poseidon2_b_2{}; - FF poseidon2_b_3{}; - FF poseidon2_clk{}; - FF poseidon2_full_a_0{}; - FF poseidon2_full_a_1{}; - FF poseidon2_full_a_2{}; - FF poseidon2_full_a_3{}; - FF poseidon2_full_b_0{}; - FF poseidon2_full_b_1{}; - FF poseidon2_full_b_2{}; - FF poseidon2_full_b_3{}; - FF poseidon2_full_clk{}; - FF poseidon2_full_end_poseidon{}; - FF poseidon2_full_execute_poseidon_perm{}; - FF poseidon2_full_input_0{}; - FF poseidon2_full_input_1{}; - FF poseidon2_full_input_2{}; - FF poseidon2_full_input_len{}; - FF poseidon2_full_num_perm_rounds_rem{}; - FF poseidon2_full_num_perm_rounds_rem_inv{}; - FF poseidon2_full_output{}; - FF poseidon2_full_padding{}; - FF poseidon2_full_sel_merkle_tree{}; - FF poseidon2_full_sel_poseidon{}; - FF poseidon2_full_start_poseidon{}; - FF poseidon2_input_addr{}; - FF poseidon2_mem_addr_read_a{}; - FF poseidon2_mem_addr_read_b{}; - FF poseidon2_mem_addr_read_c{}; - FF poseidon2_mem_addr_read_d{}; - FF poseidon2_mem_addr_write_a{}; - FF poseidon2_mem_addr_write_b{}; - FF poseidon2_mem_addr_write_c{}; - FF poseidon2_mem_addr_write_d{}; - FF poseidon2_output_addr{}; - FF poseidon2_sel_poseidon_perm{}; - FF poseidon2_sel_poseidon_perm_immediate{}; - FF poseidon2_sel_poseidon_perm_mem_op{}; - FF poseidon2_space_id{}; - FF range_check_alu_rng_chk{}; - FF range_check_clk{}; - FF range_check_cmp_hi_bits_rng_chk{}; - FF range_check_cmp_lo_bits_rng_chk{}; - FF range_check_cmp_non_ff_rng_chk{}; - FF range_check_dyn_diff{}; - FF range_check_dyn_rng_chk_bits{}; - FF range_check_dyn_rng_chk_pow_2{}; - FF range_check_gas_da_rng_chk{}; - FF range_check_gas_l2_rng_chk{}; - FF range_check_is_lte_u112{}; - FF range_check_is_lte_u128{}; - FF range_check_is_lte_u16{}; - FF range_check_is_lte_u32{}; - FF range_check_is_lte_u48{}; - FF range_check_is_lte_u64{}; - FF range_check_is_lte_u80{}; - FF range_check_is_lte_u96{}; - FF range_check_rng_chk_bits{}; - FF range_check_sel_lookup_0{}; - FF range_check_sel_lookup_1{}; - FF range_check_sel_lookup_2{}; - FF range_check_sel_lookup_3{}; - FF range_check_sel_lookup_4{}; - FF range_check_sel_lookup_5{}; - FF range_check_sel_lookup_6{}; - FF range_check_sel_rng_chk{}; - FF range_check_u16_r0{}; - FF range_check_u16_r1{}; - FF range_check_u16_r2{}; - FF range_check_u16_r3{}; - FF range_check_u16_r4{}; - FF range_check_u16_r5{}; - FF range_check_u16_r6{}; - FF range_check_u16_r7{}; - FF range_check_value{}; - FF sha256_clk{}; - FF sha256_input{}; - FF sha256_output{}; - FF sha256_sel_sha256_compression{}; - FF sha256_state{}; - FF slice_addr{}; - FF slice_clk{}; - FF slice_cnt{}; - FF slice_col_offset{}; - FF slice_one_min_inv{}; - FF slice_sel_cd_cpy{}; - FF slice_sel_mem_active{}; - FF slice_sel_return{}; - FF slice_sel_start{}; - FF slice_space_id{}; - FF slice_val{}; - FF perm_rng_non_ff_cmp_inv{}; - FF perm_rng_cmp_lo_inv{}; - FF perm_rng_cmp_hi_inv{}; - FF perm_rng_alu_inv{}; - FF perm_cmp_alu_inv{}; - FF perm_pos_mem_read_a_inv{}; - FF perm_pos_mem_read_b_inv{}; - FF perm_pos_mem_read_c_inv{}; - FF perm_pos_mem_read_d_inv{}; - FF perm_pos_mem_write_a_inv{}; - FF perm_pos_mem_write_b_inv{}; - FF perm_pos_mem_write_c_inv{}; - FF perm_pos_mem_write_d_inv{}; - FF perm_pos2_fixed_pos2_perm_inv{}; - FF perm_slice_mem_inv{}; - FF perm_merkle_poseidon2_inv{}; - FF perm_main_alu_inv{}; - FF perm_main_bin_inv{}; - FF perm_main_conv_inv{}; - FF perm_main_sha256_inv{}; - FF perm_main_pos2_perm_inv{}; - FF perm_main_mem_a_inv{}; - FF perm_main_mem_b_inv{}; - FF perm_main_mem_c_inv{}; - FF perm_main_mem_d_inv{}; - FF perm_main_mem_ind_addr_a_inv{}; - FF perm_main_mem_ind_addr_b_inv{}; - FF perm_main_mem_ind_addr_c_inv{}; - FF perm_main_mem_ind_addr_d_inv{}; - FF lookup_rng_chk_pow_2_inv{}; - FF lookup_rng_chk_diff_inv{}; - FF lookup_rng_chk_0_inv{}; - FF lookup_rng_chk_1_inv{}; - FF lookup_rng_chk_2_inv{}; - FF lookup_rng_chk_3_inv{}; - FF lookup_rng_chk_4_inv{}; - FF lookup_rng_chk_5_inv{}; - FF lookup_rng_chk_6_inv{}; - FF lookup_rng_chk_7_inv{}; - FF lookup_mem_rng_chk_0_inv{}; - FF lookup_mem_rng_chk_1_inv{}; - FF lookup_mem_rng_chk_2_inv{}; - FF lookup_pow_2_0_inv{}; - FF lookup_pow_2_1_inv{}; - FF lookup_byte_lengths_inv{}; - FF lookup_byte_operations_inv{}; - FF lookup_opcode_gas_inv{}; - FF lookup_l2_gas_rng_chk_0_inv{}; - FF lookup_l2_gas_rng_chk_1_inv{}; - FF lookup_da_gas_rng_chk_0_inv{}; - FF lookup_da_gas_rng_chk_1_inv{}; - FF lookup_cd_value_inv{}; - FF lookup_ret_value_inv{}; - FF incl_main_tag_err_inv{}; - FF incl_mem_tag_err_inv{}; - FF lookup_rng_chk_pow_2_counts{}; - FF lookup_rng_chk_diff_counts{}; - FF lookup_rng_chk_0_counts{}; - FF lookup_rng_chk_1_counts{}; - FF lookup_rng_chk_2_counts{}; - FF lookup_rng_chk_3_counts{}; - FF lookup_rng_chk_4_counts{}; - FF lookup_rng_chk_5_counts{}; - FF lookup_rng_chk_6_counts{}; - FF lookup_rng_chk_7_counts{}; - FF lookup_mem_rng_chk_0_counts{}; - FF lookup_mem_rng_chk_1_counts{}; - FF lookup_mem_rng_chk_2_counts{}; - FF lookup_pow_2_0_counts{}; - FF lookup_pow_2_1_counts{}; - FF lookup_byte_lengths_counts{}; - FF lookup_byte_operations_counts{}; - FF lookup_opcode_gas_counts{}; - FF lookup_l2_gas_rng_chk_0_counts{}; - FF lookup_l2_gas_rng_chk_1_counts{}; - FF lookup_da_gas_rng_chk_0_counts{}; - FF lookup_da_gas_rng_chk_1_counts{}; - FF lookup_cd_value_counts{}; - FF lookup_ret_value_counts{}; - FF incl_main_tag_err_counts{}; - FF incl_mem_tag_err_counts{}; +template struct AvmFullRow { + using FF = FF_; - RefVector as_vector() const; + FF ALL_ENTITIES; + RefVector as_vector() const; static std::vector names(); static constexpr size_t SIZE = 764; + + // Risky but oh so efficient. + FF& get_column(ColumnAndShifts col) + { + static_assert(sizeof(*this) == sizeof(FF) * static_cast(ColumnAndShifts::NUM_COLUMNS)); + return reinterpret_cast(this)[static_cast(col)]; + } + + const FF& get_column(ColumnAndShifts col) const + { + static_assert(sizeof(*this) == sizeof(FF) * static_cast(ColumnAndShifts::NUM_COLUMNS)); + return reinterpret_cast(this)[static_cast(col)]; + } }; template std::ostream& operator<<(std::ostream& os, AvmFullRow const& row); +} // namespace bb::avm + +namespace bb { + +// Expose this in the bb namespace. For compatibility with the old witgen. +using avm::AvmFullRow; + } // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/prover.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/prover.cpp index 07bbd42bd1d..2391e9de912 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/prover.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/prover.cpp @@ -1,5 +1,5 @@ // AUTOGENERATED FILE -#include "barretenberg/vm/avm/generated/prover.hpp" +#include "prover.hpp" #include "barretenberg/commitment_schemes/claim.hpp" #include "barretenberg/commitment_schemes/commitment_key.hpp" #include "barretenberg/commitment_schemes/shplonk/shplemini.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/prover.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/prover.hpp index 57b7991a417..a1e90e389a2 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/prover.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/prover.hpp @@ -5,7 +5,7 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/sumcheck/sumcheck_output.hpp" #include "barretenberg/transcript/transcript.hpp" -#include "barretenberg/vm/avm/generated/flavor.hpp" +#include "flavor.hpp" namespace bb { diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/alu.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/alu.hpp index bde7a1f816a..4cddae88e89 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/alu.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/alu.hpp @@ -4,7 +4,7 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/relations/relation_types.hpp" -namespace bb::Avm_vm { +namespace bb::avm { template class aluImpl { public: @@ -441,6 +441,11 @@ template class alu : public Relation> { } return std::to_string(index); } + + static constexpr size_t SR_ALU_MULTIPLICATION_FF = 20; + static constexpr size_t SR_ALU_PROD_MUL = 24; + static constexpr size_t SR_DIVISION_RELATION = 31; + static constexpr size_t SR_ALU_OP_NOT = 32; }; -} // namespace bb::Avm_vm \ No newline at end of file +} // namespace bb::avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/binary.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/binary.hpp index 11d51a5a226..6de22ff6c45 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/binary.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/binary.hpp @@ -4,7 +4,7 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/relations/relation_types.hpp" -namespace bb::Avm_vm { +namespace bb::avm { template class binaryImpl { public: @@ -114,6 +114,13 @@ template class binary : public Relation> { } return std::to_string(index); } + + static constexpr size_t SR_OP_ID_REL = 1; + static constexpr size_t SR_MEM_TAG_REL = 2; + static constexpr size_t SR_SEL_BIN_CTR_REL = 3; + static constexpr size_t SR_ACC_REL_A = 7; + static constexpr size_t SR_ACC_REL_B = 8; + static constexpr size_t SR_ACC_REL_C = 9; }; -} // namespace bb::Avm_vm \ No newline at end of file +} // namespace bb::avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/bytecode.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/bytecode.hpp index 0180f977d24..586390b7f06 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/bytecode.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/bytecode.hpp @@ -4,7 +4,7 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/relations/relation_types.hpp" -namespace bb::Avm_vm { +namespace bb::avm { template class bytecodeImpl { public: @@ -39,4 +39,4 @@ template class bytecode : public Relation> { } }; -} // namespace bb::Avm_vm \ No newline at end of file +} // namespace bb::avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/cmp.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/cmp.hpp index 51748bd9661..835258bd902 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/cmp.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/cmp.hpp @@ -4,7 +4,7 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/relations/relation_types.hpp" -namespace bb::Avm_vm { +namespace bb::avm { template class cmpImpl { public: @@ -265,6 +265,24 @@ template class cmp : public Relation> { } return std::to_string(index); } + + static constexpr size_t SR_CMP_RES_IS_BOOL = 3; + static constexpr size_t SR_CMP_OP_EQ = 4; + static constexpr size_t SR_INPUT_DECOMP_1 = 5; + static constexpr size_t SR_INPUT_DECOMP_2 = 6; + static constexpr size_t SR_SUB_LO_1 = 8; + static constexpr size_t SR_SUB_HI_1 = 9; + static constexpr size_t SR_SUB_LO_2 = 11; + static constexpr size_t SR_SUB_HI_2 = 12; + static constexpr size_t SR_RES_LO = 13; + static constexpr size_t SR_RES_HI = 14; + static constexpr size_t SR_CMP_CTR_REL_1 = 17; + static constexpr size_t SR_CMP_CTR_REL_2 = 18; + static constexpr size_t SR_CTR_NON_ZERO_REL = 19; + static constexpr size_t SR_SHIFT_RELS_0 = 20; + static constexpr size_t SR_SHIFT_RELS_1 = 22; + static constexpr size_t SR_SHIFT_RELS_2 = 24; + static constexpr size_t SR_SHIFT_RELS_3 = 26; }; -} // namespace bb::Avm_vm \ No newline at end of file +} // namespace bb::avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/conversion.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/conversion.hpp index e39957ed8bb..7a6779a0ac6 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/conversion.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/conversion.hpp @@ -4,7 +4,7 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/relations/relation_types.hpp" -namespace bb::Avm_vm { +namespace bb::avm { template class conversionImpl { public: @@ -39,4 +39,4 @@ template class conversion : public Relation> { } }; -} // namespace bb::Avm_vm \ No newline at end of file +} // namespace bb::avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/gas.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/gas.hpp index 57c198089db..62e1c32a6fc 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/gas.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/gas.hpp @@ -4,7 +4,7 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/relations/relation_types.hpp" -namespace bb::Avm_vm { +namespace bb::avm { template class gasImpl { public: @@ -131,6 +131,12 @@ template class gas : public Relation> { } return std::to_string(index); } + + static constexpr size_t SR_IS_GAS_ACCOUNTED = 0; + static constexpr size_t SR_L2_GAS_NO_DECREMENT_FAKE_ROW = 4; + static constexpr size_t SR_DA_GAS_NO_DECREMENT_FAKE_ROW = 5; + static constexpr size_t SR_L2_GAS_REMAINING_DECREMENT_NOT_CALL = 6; + static constexpr size_t SR_DA_GAS_REMAINING_DECREMENT_NOT_CALL = 7; }; -} // namespace bb::Avm_vm \ No newline at end of file +} // namespace bb::avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/keccakf1600.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/keccakf1600.hpp index fe4e4c44610..59e53de3495 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/keccakf1600.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/keccakf1600.hpp @@ -4,7 +4,7 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/relations/relation_types.hpp" -namespace bb::Avm_vm { +namespace bb::avm { template class keccakf1600Impl { public: @@ -39,4 +39,4 @@ template class keccakf1600 : public Relation> } }; -} // namespace bb::Avm_vm \ No newline at end of file +} // namespace bb::avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/main.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/main.hpp index d493e1604f7..1fe74358457 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/main.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/main.hpp @@ -4,7 +4,7 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/relations/relation_types.hpp" -namespace bb::Avm_vm { +namespace bb::avm { template class mainImpl { public: @@ -739,6 +739,27 @@ template class main : public Relation> { } return std::to_string(index); } + + static constexpr size_t SR_OPCODE_SELECTORS = 0; + static constexpr size_t SR_OUTPUT_U1 = 75; + static constexpr size_t SR_SUBOP_FDIV = 76; + static constexpr size_t SR_SUBOP_FDIV_ZERO_ERR1 = 77; + static constexpr size_t SR_SUBOP_FDIV_ZERO_ERR2 = 78; + static constexpr size_t SR_SUBOP_FDIV_R_IN_TAG_FF = 79; + static constexpr size_t SR_SUBOP_FDIV_W_IN_TAG_FF = 80; + static constexpr size_t SR_TAG_ERR_IMPLIES_OP_ERR = 81; + static constexpr size_t SR_PC_JUMP = 82; + static constexpr size_t SR_PC_JUMPI = 83; + static constexpr size_t SR_SPACE_ID_STANDARD_OPCODES = 84; + static constexpr size_t SR_JMP_CONDITION_RES_1 = 85; + static constexpr size_t SR_JMP_CONDITION_RES_2 = 86; + static constexpr size_t SR_MOV_SAME_VALUE_A = 88; + static constexpr size_t SR_MOV_SAME_VALUE_B = 89; + static constexpr size_t SR_MOV_MAIN_SAME_TAG = 90; + static constexpr size_t SR_L2GASLEFT = 94; + static constexpr size_t SR_DAGASLEFT = 95; + static constexpr size_t SR_BIN_SEL_1 = 96; + static constexpr size_t SR_BIN_SEL_2 = 97; }; -} // namespace bb::Avm_vm \ No newline at end of file +} // namespace bb::avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/mem.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/mem.hpp index 2c7a7570949..ce3ad1351d5 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/mem.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/mem.hpp @@ -4,7 +4,7 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/relations/relation_types.hpp" -namespace bb::Avm_vm { +namespace bb::avm { template class memImpl { public: @@ -429,6 +429,24 @@ template class mem : public Relation> { } return std::to_string(index); } + + static constexpr size_t SR_MEM_CONTIGUOUS = 15; + static constexpr size_t SR_MEM_FIRST_EMPTY = 16; + static constexpr size_t SR_MEM_LAST = 17; + static constexpr size_t SR_TIMESTAMP = 19; + static constexpr size_t SR_GLOBAL_ADDR = 20; + static constexpr size_t SR_LAST_ACCESS_FIRST_ROW = 21; + static constexpr size_t SR_MEM_LAST_ACCESS_DELIMITER = 22; + static constexpr size_t SR_MEM_READ_WRITE_VAL_CONSISTENCY = 24; + static constexpr size_t SR_MEM_READ_WRITE_TAG_CONSISTENCY = 25; + static constexpr size_t SR_MEM_ZERO_INIT = 26; + static constexpr size_t SR_MEM_ZERO_INIT_TAG_FF = 27; + static constexpr size_t SR_SKIP_CHECK_TAG = 28; + static constexpr size_t SR_MEM_IN_TAG_CONSISTENCY_1 = 29; + static constexpr size_t SR_MEM_IN_TAG_CONSISTENCY_2 = 30; + static constexpr size_t SR_NO_TAG_ERR_WRITE_OR_SKIP = 31; + static constexpr size_t SR_NO_TAG_ERR_WRITE = 33; + static constexpr size_t SR_MOV_SAME_TAG = 52; }; -} // namespace bb::Avm_vm \ No newline at end of file +} // namespace bb::avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/mem_slice.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/mem_slice.hpp index 537b30b0d32..c097ba8c398 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/mem_slice.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/mem_slice.hpp @@ -4,7 +4,7 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/relations/relation_types.hpp" -namespace bb::Avm_vm { +namespace bb::avm { template class mem_sliceImpl { public: @@ -122,6 +122,17 @@ template class mem_slice : public Relation> { } return std::to_string(index); } + + static constexpr size_t SR_SLICE_CNT_ZERO_TEST1 = 1; + static constexpr size_t SR_SLICE_CNT_ZERO_TEST2 = 2; + static constexpr size_t SR_SLICE_CNT_DECREMENT = 3; + static constexpr size_t SR_ADDR_INCREMENT = 4; + static constexpr size_t SR_COL_OFFSET_INCREMENT = 5; + static constexpr size_t SR_SAME_CLK = 6; + static constexpr size_t SR_SAME_SPACE_ID = 7; + static constexpr size_t SR_SAME_SEL_RETURN = 8; + static constexpr size_t SR_SAME_SEL_CD_CPY = 9; + static constexpr size_t SR_SEL_MEM_INACTIVE = 10; }; -} // namespace bb::Avm_vm \ No newline at end of file +} // namespace bb::avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/merkle_tree.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/merkle_tree.hpp index 0e9411d0634..1b68b2d8d34 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/merkle_tree.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/merkle_tree.hpp @@ -4,7 +4,7 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/relations/relation_types.hpp" -namespace bb::Avm_vm { +namespace bb::avm { template class merkle_treeImpl { public: @@ -103,4 +103,4 @@ template class merkle_tree : public Relation> } }; -} // namespace bb::Avm_vm \ No newline at end of file +} // namespace bb::avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/poseidon2.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/poseidon2.hpp index d71c6962ca1..9503f383c3b 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/poseidon2.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/poseidon2.hpp @@ -4,7 +4,7 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/relations/relation_types.hpp" -namespace bb::Avm_vm { +namespace bb::avm { template class poseidon2Impl { public: @@ -3085,4 +3085,4 @@ template class poseidon2 : public Relation> { } }; -} // namespace bb::Avm_vm \ No newline at end of file +} // namespace bb::avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/poseidon2_full.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/poseidon2_full.hpp index 7c8e5c33758..3b7b0f45c35 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/poseidon2_full.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/poseidon2_full.hpp @@ -4,7 +4,7 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/relations/relation_types.hpp" -namespace bb::Avm_vm { +namespace bb::avm { template class poseidon2_fullImpl { public: @@ -186,4 +186,4 @@ template class poseidon2_full : public Relation class range_checkImpl { public: @@ -264,6 +264,8 @@ template class range_check : public Relation> } return std::to_string(index); } + + static constexpr size_t SR_CHECK_RECOMPOSITION = 10; }; -} // namespace bb::Avm_vm \ No newline at end of file +} // namespace bb::avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/sha256.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/sha256.hpp index 226b15f852a..e72cc1550a0 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/sha256.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/sha256.hpp @@ -4,7 +4,7 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/relations/relation_types.hpp" -namespace bb::Avm_vm { +namespace bb::avm { template class sha256Impl { public: @@ -39,4 +39,4 @@ template class sha256 : public Relation> { } }; -} // namespace bb::Avm_vm \ No newline at end of file +} // namespace bb::avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/verifier.cpp index 1e55f43e7b6..6c33c2c73a1 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/verifier.cpp @@ -1,5 +1,5 @@ // AUTOGENERATED FILE -#include "barretenberg/vm/avm/generated/verifier.hpp" +#include "verifier.hpp" #include "barretenberg/commitment_schemes/shplonk/shplemini.hpp" #include "barretenberg/common/log.hpp" #include "barretenberg/numeric/bitop/get_msb.hpp" diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/verifier.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/verifier.hpp index e3b242c96f9..4c887230c4a 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/verifier.hpp @@ -3,7 +3,7 @@ #include "barretenberg/plonk/proof_system/types/proof.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" -#include "barretenberg/vm/avm/generated/flavor.hpp" +#include "flavor.hpp" namespace bb { diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/tests/full_poseidon2.test.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/tests/full_poseidon2.test.cpp index e98a924aa7e..61110c04744 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/tests/full_poseidon2.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/tests/full_poseidon2.test.cpp @@ -13,7 +13,7 @@ namespace tests_avm { using namespace bb; -using namespace bb::Avm_vm; +using namespace bb::avm; TEST(AvmFullPoseidon2, shouldHashCorrectly) { @@ -58,7 +58,7 @@ TEST(AvmFullPoseidon2, shouldHashCorrectly) std::cerr << "Done computing polynomials..." << std::endl; std::cerr << "Accumulating relations..." << std::endl; - using Relation = Avm_vm::poseidon2_full; + using Relation = avm::poseidon2_full; typename Relation::SumcheckArrayOfValuesOverSubrelations result; for (auto& r : result) { diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/tests/fuzz_skippable.test.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/tests/fuzz_skippable.test.cpp index 6dc6e89bac7..b29b4a7ce29 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/tests/fuzz_skippable.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/tests/fuzz_skippable.test.cpp @@ -10,7 +10,7 @@ namespace tests_avm { using namespace bb; -using namespace bb::Avm_vm; +using namespace bb::avm; TEST(AvmSkippableTests, shouldSkipCorrectly) { diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/tests/merkle_tree.test.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/tests/merkle_tree.test.cpp index 3c77ed80b74..87156305e67 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/tests/merkle_tree.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/tests/merkle_tree.test.cpp @@ -14,7 +14,7 @@ namespace tests_avm { using namespace bb; -using namespace bb::Avm_vm; +using namespace bb::avm; TEST(AvmMerkleTree, shouldCheckMembership) { @@ -76,7 +76,7 @@ TEST(AvmMerkleTree, shouldCheckMembership) std::cerr << "Done computing polynomials..." << std::endl; std::cerr << "Accumulating relations..." << std::endl; - using AllRelations = std::tuple, Avm_vm::poseidon2_full, Avm_vm::poseidon2>; + using AllRelations = std::tuple, avm::poseidon2_full, avm::poseidon2>; bb::constexpr_for<0, std::tuple_size_v, 1>([&]() { using Relation = std::tuple_element_t; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/tests/range_check.test.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/tests/range_check.test.cpp index 9b0dee86959..9664717369c 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/tests/range_check.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/tests/range_check.test.cpp @@ -14,7 +14,7 @@ namespace tests_avm { using namespace bb; -using namespace bb::Avm_vm; +using namespace bb::avm; TEST(AvmRangeCheck, shouldRangeCheck) { @@ -74,7 +74,7 @@ TEST(AvmRangeCheck, shouldRangeCheck) std::cerr << "Done computing polynomials..." << std::endl; std::cerr << "Accumulating relations..." << std::endl; - using Relation = Avm_vm::range_check; + using Relation = avm::range_check; typename Relation::SumcheckArrayOfValuesOverSubrelations result; for (auto& r : result) { diff --git a/bb-pilcom/bb-pil-backend/src/flavor_builder.rs b/bb-pilcom/bb-pil-backend/src/flavor_builder.rs index 9c72c957256..241b432033b 100644 --- a/bb-pilcom/bb-pil-backend/src/flavor_builder.rs +++ b/bb-pilcom/bb-pil-backend/src/flavor_builder.rs @@ -35,6 +35,20 @@ pub trait FlavorBuilder { ); fn create_flavor_settings_hpp(&mut self, name: &str); + + fn create_columns_hpp( + &mut self, + name: &str, + lookups: &[String], + inverses: &[String], + fixed: &[String], + witness: &[String], + witness_without_inverses: &[String], + all_cols: &[String], + to_be_shifted: &[String], + shifted: &[String], + all_cols_and_shifts: &[String], + ); } /// Build the boilerplate for the flavor file @@ -150,4 +164,49 @@ impl FlavorBuilder for BBFiles { self.write_file(None, "flavor_settings.hpp", &flavor_hpp); } + + fn create_columns_hpp( + &mut self, + name: &str, + lookups: &[String], + inverses: &[String], + fixed: &[String], + witness: &[String], + witness_without_inverses: &[String], + all_cols: &[String], + to_be_shifted: &[String], + shifted: &[String], + all_cols_and_shifts: &[String], + ) { + let mut handlebars = Handlebars::new(); + + let data = &json!({ + "name": name, + "lookups": lookups, + "inverses": inverses, + "fixed": fixed, + "witness": witness, + "all_cols": all_cols, + "to_be_shifted": to_be_shifted, + "shifted": shifted, + "all_cols_and_shifts": all_cols_and_shifts, + "witness_without_inverses": witness_without_inverses, + }); + + handlebars_helper!(join: |*args| + args.iter().map(|v| v.as_array().unwrap().to_owned()).collect_vec().concat() + ); + handlebars.register_helper("join", Box::new(join)); + + handlebars + .register_template_string( + "columns.hpp", + std::str::from_utf8(include_bytes!("../templates/columns.hpp.hbs")).unwrap(), + ) + .unwrap(); + + let hpp = handlebars.render("columns.hpp", data).unwrap(); + + self.write_file(None, "columns.hpp", &hpp); + } } diff --git a/bb-pilcom/bb-pil-backend/src/vm_builder.rs b/bb-pilcom/bb-pil-backend/src/vm_builder.rs index 8ce849595d1..1bee48223c8 100644 --- a/bb-pilcom/bb-pil-backend/src/vm_builder.rs +++ b/bb-pilcom/bb-pil-backend/src/vm_builder.rs @@ -45,8 +45,13 @@ struct ColumnGroups { /// Analyzed to cpp /// /// Converts an analyzed pil AST into a set of cpp files that can be used to generate a proof -pub fn analyzed_to_cpp(analyzed: &Analyzed, vm_name: &str, delete_dir: bool) { - let mut bb_files = BBFiles::default(&snake_case(&vm_name)); +pub fn analyzed_to_cpp( + analyzed: &Analyzed, + generated_dir: Option<&str>, + vm_name: &str, + delete_dir: bool, +) { + let mut bb_files = BBFiles::new(&snake_case(&vm_name), generated_dir, None); // Remove the generated directory if it exists. // Pass `-y` as parameter if you want to skip the confirmation prompt. @@ -124,6 +129,18 @@ pub fn analyzed_to_cpp(analyzed: &Analyzed, vm_name: &str, d ); bb_files.create_flavor_settings_hpp(vm_name); + bb_files.create_columns_hpp( + vm_name, + &lookup_and_permutations_names, + &inverses, + &fixed, + &witness, + &witnesses_without_inverses, + &all_cols, + &to_be_shifted, + &shifted, + &all_cols_with_shifts, + ); // ----------------------- Create the composer files ----------------------- bb_files.create_composer_cpp(vm_name); diff --git a/bb-pilcom/bb-pil-backend/templates/circuit_builder.cpp.hbs b/bb-pilcom/bb-pil-backend/templates/circuit_builder.cpp.hbs index 4eb311cd210..c3f2ab7e5b2 100644 --- a/bb-pilcom/bb-pil-backend/templates/circuit_builder.cpp.hbs +++ b/bb-pilcom/bb-pil-backend/templates/circuit_builder.cpp.hbs @@ -1,5 +1,5 @@ // AUTOGENERATED FILE -#include "barretenberg/vm/{{snakeCase name}}/generated/circuit_builder.hpp" +#include "circuit_builder.hpp" #include #include diff --git a/bb-pilcom/bb-pil-backend/templates/circuit_builder.hpp.hbs b/bb-pilcom/bb-pil-backend/templates/circuit_builder.hpp.hbs index 21f51569bcc..695c127ae30 100644 --- a/bb-pilcom/bb-pil-backend/templates/circuit_builder.hpp.hbs +++ b/bb-pilcom/bb-pil-backend/templates/circuit_builder.hpp.hbs @@ -3,8 +3,8 @@ #include -#include "barretenberg/vm/{{snakeCase name}}/generated/full_row.hpp" -#include "barretenberg/vm/{{snakeCase name}}/generated/flavor.hpp" +#include "full_row.hpp" +#include "flavor.hpp" namespace bb { diff --git a/bb-pilcom/bb-pil-backend/templates/columns.hpp.hbs b/bb-pilcom/bb-pil-backend/templates/columns.hpp.hbs new file mode 100644 index 00000000000..0e0909c23fe --- /dev/null +++ b/bb-pilcom/bb-pil-backend/templates/columns.hpp.hbs @@ -0,0 +1,38 @@ +#pragma once + +#include +#include + +namespace bb::avm { + +// The entities that will be used in the flavor. +// clang-format off +#define PRECOMPUTED_ENTITIES {{#each fixed as |item|}}{{#if @index}}, {{/if}}{{item}}{{/each}} +#define WIRE_ENTITIES {{#each witness_without_inverses as |item|}}{{#if @index}}, {{/if}}{{item}}{{/each}} +#define DERIVED_WITNESS_ENTITIES {{#each inverses as |item|}}{{#if @index}}, {{/if}}{{item}}{{/each}} +#define SHIFTED_ENTITIES {{#each shifted as |item|}}{{#if @index}}, {{/if}}{{item}}{{/each}} +#define TO_BE_SHIFTED(e) {{#each to_be_shifted as |item|}}{{#if @index}}, {{/if}}e.{{item}}{{/each}} +#define ALL_ENTITIES {{#if (len fixed)}}PRECOMPUTED_ENTITIES{{/if}}{{#if (len witness_without_inverses)}}, WIRE_ENTITIES{{/if}}{{#if (len lookups)}}, DERIVED_WITNESS_ENTITIES{{/if}}{{#if (len shifted)}}, SHIFTED_ENTITIES{{/if}} + +#define TO_BE_SHIFTED_COLUMNS {{#each to_be_shifted as |item|}}{{#if @index}}, {{/if}}Column::{{item}}{{/each}} +#define SHIFTED_COLUMNS {{#each shifted as |item|}}{{#if @index}}, {{/if}}ColumnAndShifts::{{item}}{{/each}} + +#define ALL_ENTITIES PRECOMPUTED_ENTITIES, WIRE_ENTITIES, DERIVED_WITNESS_ENTITIES, SHIFTED_ENTITIES +#define UNSHIFTED_ENTITIES PRECOMPUTED_ENTITIES, WIRE_ENTITIES, DERIVED_WITNESS_ENTITIES +// clang-format on + +// All columns minus shifts. +enum class Column { UNSHIFTED_ENTITIES }; + +// C++ doesn't allow enum extension, so we'll have to cast. +enum class ColumnAndShifts { + ALL_ENTITIES, + // Sentinel. + NUM_COLUMNS, +}; + +constexpr auto TO_BE_SHIFTED_COLUMNS_ARRAY = []() { return std::array{ TO_BE_SHIFTED_COLUMNS }; }(); +constexpr auto SHIFTED_COLUMNS_ARRAY = []() { return std::array{ SHIFTED_COLUMNS }; }(); +static_assert(TO_BE_SHIFTED_COLUMNS_ARRAY.size() == SHIFTED_COLUMNS_ARRAY.size()); + +} // namespace bb::avm \ No newline at end of file diff --git a/bb-pilcom/bb-pil-backend/templates/composer.cpp.hbs b/bb-pilcom/bb-pil-backend/templates/composer.cpp.hbs index 17b826f5c83..fa9ca2e4daf 100644 --- a/bb-pilcom/bb-pil-backend/templates/composer.cpp.hbs +++ b/bb-pilcom/bb-pil-backend/templates/composer.cpp.hbs @@ -1,5 +1,5 @@ // AUTOGENERATED FILE -#include "barretenberg/vm/{{snakeCase name}}/generated/composer.hpp" +#include "composer.hpp" #include "barretenberg/vm/stats.hpp" namespace bb { @@ -28,7 +28,7 @@ void {{name}}Composer::compute_witness(CircuitConstructor& circuit) AVM_TRACK_TIME("composer/create_prover:commitment_key", compute_commitment_key(circuit_constructor.get_circuit_subgroup_size())); auto output_state = AVM_TRACK_TIME_V("composer/create_prover:construct_prover", - AvmProver(proving_key, proving_key->commitment_key)); + {{name}}Prover(proving_key, proving_key->commitment_key)); return output_state; } diff --git a/bb-pilcom/bb-pil-backend/templates/composer.hpp.hbs b/bb-pilcom/bb-pil-backend/templates/composer.hpp.hbs index 870ca82595e..22e5b52d257 100644 --- a/bb-pilcom/bb-pil-backend/templates/composer.hpp.hbs +++ b/bb-pilcom/bb-pil-backend/templates/composer.hpp.hbs @@ -2,9 +2,9 @@ #pragma once #include "barretenberg/srs/global_crs.hpp" -#include "barretenberg/vm/{{snakeCase name}}/generated/circuit_builder.hpp" -#include "barretenberg/vm/{{snakeCase name}}/generated/prover.hpp" -#include "barretenberg/vm/{{snakeCase name}}/generated/verifier.hpp" +#include "circuit_builder.hpp" +#include "prover.hpp" +#include "verifier.hpp" namespace bb { diff --git a/bb-pilcom/bb-pil-backend/templates/flavor.cpp.hbs b/bb-pilcom/bb-pil-backend/templates/flavor.cpp.hbs index e434426b265..57464923bb8 100644 --- a/bb-pilcom/bb-pil-backend/templates/flavor.cpp.hbs +++ b/bb-pilcom/bb-pil-backend/templates/flavor.cpp.hbs @@ -1,5 +1,5 @@ // AUTOGENERATED FILE -#include "barretenberg/vm/{{snakeCase name}}/generated/flavor.hpp" +#include "flavor.hpp" namespace bb { @@ -115,7 +115,7 @@ void {{name}}Flavor::Transcript::serialize_full_transcript() { } } -AvmFlavor::ProvingKey::ProvingKey(const size_t circuit_size, const size_t num_public_inputs) +{{name}}Flavor::ProvingKey::ProvingKey(const size_t circuit_size, const size_t num_public_inputs) : circuit_size(circuit_size) , evaluation_domain(bb::EvaluationDomain(circuit_size, circuit_size)) , commitment_key(std::make_shared(circuit_size + 1)) @@ -133,7 +133,7 @@ AvmFlavor::ProvingKey::ProvingKey(const size_t circuit_size, const size_t num_pu * * @return std::vector */ -std::vector AvmFlavor::VerificationKey::to_field_elements() const +std::vector<{{name}}Flavor::VerificationKey::FF> {{name}}Flavor::VerificationKey::to_field_elements() const { std::vector elements = { FF(circuit_size), FF(num_public_inputs) }; diff --git a/bb-pilcom/bb-pil-backend/templates/flavor.hpp.hbs b/bb-pilcom/bb-pil-backend/templates/flavor.hpp.hbs index a31cdd55fdd..6c542d90aae 100644 --- a/bb-pilcom/bb-pil-backend/templates/flavor.hpp.hbs +++ b/bb-pilcom/bb-pil-backend/templates/flavor.hpp.hbs @@ -12,32 +12,23 @@ #include "barretenberg/polynomials/evaluation_domain.hpp" #include "barretenberg/flavor/flavor.hpp" -#include "barretenberg/vm/{{snakeCase name}}/generated/flavor_settings.hpp" +#include "flavor_settings.hpp" +#include "columns.hpp" #include "barretenberg/vm/aztec_constants.hpp" // Relations {{#each relation_file_names as |r|}} -#include "barretenberg/vm/{{snakeCase ../name}}/generated/relations/{{r}}.hpp" +#include "relations/{{r}}.hpp" {{/each}} // Lookup and permutation relations {{#each lookups as |r|}} -#include "barretenberg/vm/{{snakeCase ../name}}/generated/relations/{{r}}.hpp" +#include "relations/{{r}}.hpp" {{/each}} // Metaprogramming to concatenate tuple types. template using tuple_cat_t = decltype(std::tuple_cat(std::declval()...)); -// The entities that will be used in the flavor. -// clang-format off -#define PRECOMPUTED_ENTITIES {{#each fixed as |item|}}{{#if @index}}, {{/if}}{{item}}{{/each}} -#define WIRE_ENTITIES {{#each witness_without_inverses as |item|}}{{#if @index}}, {{/if}}{{item}}{{/each}} -#define DERIVED_WITNESS_ENTITIES {{#each inverses as |item|}}{{#if @index}}, {{/if}}{{item}}{{/each}} -#define SHIFTED_ENTITIES {{#each shifted as |item|}}{{#if @index}}, {{/if}}{{item}}{{/each}} -#define TO_BE_SHIFTED(e) {{#each to_be_shifted as |item|}}{{#if @index}}, {{/if}}e.{{item}}{{/each}} -#define ALL_ENTITIES {{#if (len fixed)}}PRECOMPUTED_ENTITIES{{/if}}{{#if (len witness_without_inverses)}}, WIRE_ENTITIES{{/if}}{{#if (len lookups)}}, DERIVED_WITNESS_ENTITIES{{/if}}{{#if (len shifted)}}, SHIFTED_ENTITIES{{/if}} -// clang-format on - namespace bb { class {{name}}Flavor { @@ -72,7 +63,7 @@ class {{name}}Flavor { template using MainRelations_ = std::tuple< // Relations - {{#each relation_file_names as |item|}}{{#if @index}},{{/if}}{{../name}}_vm::{{item}}{{/each}} + {{#each relation_file_names as |item|}}{{#if @index}},{{/if}}{{snakeCase ../name}}::{{item}}{{/each}} >; using MainRelations = MainRelations_; @@ -220,7 +211,7 @@ class {{name}}Flavor { auto get_witness_polynomials() { return WitnessEntities::get_all(); } auto get_precomputed_polynomials() { return PrecomputedEntities::get_all(); } auto get_selectors() { return PrecomputedEntities::get_all(); } - auto get_to_be_shifted() { return AvmFlavor::get_to_be_shifted(*this); } + auto get_to_be_shifted() { return {{name}}Flavor::get_to_be_shifted(*this); } // This order matters! must match get_unshifted in entity classes auto get_all() { return concatenate(get_precomputed_polynomials(), get_witness_polynomials()); } }; diff --git a/bb-pilcom/bb-pil-backend/templates/full_row.cpp.hbs b/bb-pilcom/bb-pil-backend/templates/full_row.cpp.hbs index a6df0dfc729..133f8a5d433 100644 --- a/bb-pilcom/bb-pil-backend/templates/full_row.cpp.hbs +++ b/bb-pilcom/bb-pil-backend/templates/full_row.cpp.hbs @@ -1,8 +1,8 @@ // AUTOGENERATED FILE -#include "barretenberg/vm/{{snakeCase name}}/generated/full_row.hpp" -#include "barretenberg/vm/{{snakeCase name}}/generated/flavor_settings.hpp" +#include "full_row.hpp" +#include "flavor_settings.hpp" -namespace bb { +namespace bb::avm { namespace { template std::string field_to_string(const FF& ff) diff --git a/bb-pilcom/bb-pil-backend/templates/full_row.hpp.hbs b/bb-pilcom/bb-pil-backend/templates/full_row.hpp.hbs index fe79a16f252..b32e4e54059 100644 --- a/bb-pilcom/bb-pil-backend/templates/full_row.hpp.hbs +++ b/bb-pilcom/bb-pil-backend/templates/full_row.hpp.hbs @@ -6,21 +6,41 @@ #include #include "barretenberg/common/ref_vector.hpp" +#include "columns.hpp" -namespace bb { +namespace bb::avm { -template +template struct {{name}}FullRow { - {{#each all_cols as |col|}} - FF {{col}}{}; - {{/each}} - - RefVector as_vector() const; + using FF = FF_; + + FF ALL_ENTITIES; + RefVector as_vector() const; static std::vector names(); static constexpr size_t SIZE = {{len all_cols}}; + + // Risky but oh so efficient. + FF& get_column(ColumnAndShifts col) + { + static_assert(sizeof(*this) == sizeof(FF) * static_cast(ColumnAndShifts::NUM_COLUMNS)); + return reinterpret_cast(this)[static_cast(col)]; + } + + const FF& get_column(ColumnAndShifts col) const + { + static_assert(sizeof(*this) == sizeof(FF) * static_cast(ColumnAndShifts::NUM_COLUMNS)); + return reinterpret_cast(this)[static_cast(col)]; + } }; template std::ostream& operator<<(std::ostream& os, {{name}}FullRow const& row); +} // namespace bb::avm + +namespace bb { + +// Expose this in the bb namespace. For compatibility with the old witgen. +using avm::{{name}}FullRow; + } // namespace bb \ No newline at end of file diff --git a/bb-pilcom/bb-pil-backend/templates/prover.cpp.hbs b/bb-pilcom/bb-pil-backend/templates/prover.cpp.hbs index b2e194af043..db8a7e1faf4 100644 --- a/bb-pilcom/bb-pil-backend/templates/prover.cpp.hbs +++ b/bb-pilcom/bb-pil-backend/templates/prover.cpp.hbs @@ -1,5 +1,5 @@ // AUTOGENERATED FILE -#include "barretenberg/vm/{{snakeCase name}}/generated/prover.hpp" +#include "prover.hpp" #include "barretenberg/commitment_schemes/claim.hpp" #include "barretenberg/commitment_schemes/commitment_key.hpp" #include "barretenberg/commitment_schemes/shplonk/shplemini.hpp" diff --git a/bb-pilcom/bb-pil-backend/templates/prover.hpp.hbs b/bb-pilcom/bb-pil-backend/templates/prover.hpp.hbs index 3b185c59635..313c9c649e7 100644 --- a/bb-pilcom/bb-pil-backend/templates/prover.hpp.hbs +++ b/bb-pilcom/bb-pil-backend/templates/prover.hpp.hbs @@ -5,7 +5,7 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/sumcheck/sumcheck_output.hpp" #include "barretenberg/transcript/transcript.hpp" -#include "barretenberg/vm/{{snakeCase name}}/generated/flavor.hpp" +#include "flavor.hpp" namespace bb { diff --git a/bb-pilcom/bb-pil-backend/templates/relation.hpp.hbs b/bb-pilcom/bb-pil-backend/templates/relation.hpp.hbs index efa7d204f62..9a6f067017b 100644 --- a/bb-pilcom/bb-pil-backend/templates/relation.hpp.hbs +++ b/bb-pilcom/bb-pil-backend/templates/relation.hpp.hbs @@ -4,25 +4,17 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/relations/relation_types.hpp" -namespace bb::{{root_name}}_vm { - -{{!-- -template struct {{upperCamelCase name}}Row { - {{#each all_cols as |col|}} - FF {{col}}{}; - {{/each}} -}; ---}} +namespace bb::{{snakeCase root_name}} { template class {{name}}Impl { public: using FF = FF_; - + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { {{#each degrees as |degree|}}{{degree}}{{#unless @last}},{{/unless}}{{/each}} }; - {{#if skippable_if}} + {{#if skippable_if}} template inline static bool skip(const AllEntities& in) { const auto& new_term = in; @@ -65,6 +57,10 @@ template class {{name}} : public Relation<{{name}}Impl> { } return std::to_string(index); } + + {{#each labels as |label|}} + static constexpr size_t SR_{{label.1}} = {{label.0}}; + {{/each}} }; -} // namespace bb::{{root_name}}_vm \ No newline at end of file +} // namespace bb::{{snakeCase root_name}} \ No newline at end of file diff --git a/bb-pilcom/bb-pil-backend/templates/verifier.cpp.hbs b/bb-pilcom/bb-pil-backend/templates/verifier.cpp.hbs index 90656956600..b68e916939f 100644 --- a/bb-pilcom/bb-pil-backend/templates/verifier.cpp.hbs +++ b/bb-pilcom/bb-pil-backend/templates/verifier.cpp.hbs @@ -1,5 +1,5 @@ // AUTOGENERATED FILE -#include "barretenberg/vm/{{snakeCase name}}/generated/verifier.hpp" +#include "verifier.hpp" #include "barretenberg/commitment_schemes/shplonk/shplemini.hpp" #include "barretenberg/common/log.hpp" #include "barretenberg/numeric/bitop/get_msb.hpp" @@ -26,7 +26,7 @@ namespace bb { using FF = {{name}}Flavor::FF; // Evaluate the given public input column over the multivariate challenge points -inline FF AvmVerifier::evaluate_public_input_column(const std::vector& points, std::vector challenges) +inline FF {{name}}Verifier::evaluate_public_input_column(const std::vector& points, std::vector challenges) { Polynomial polynomial(points, key->circuit_size); return polynomial.evaluate_mle(challenges); diff --git a/bb-pilcom/bb-pil-backend/templates/verifier.hpp.hbs b/bb-pilcom/bb-pil-backend/templates/verifier.hpp.hbs index 40c6f0f891d..e9be87d278d 100644 --- a/bb-pilcom/bb-pil-backend/templates/verifier.hpp.hbs +++ b/bb-pilcom/bb-pil-backend/templates/verifier.hpp.hbs @@ -3,7 +3,7 @@ #include "barretenberg/plonk/proof_system/types/proof.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" -#include "barretenberg/vm/{{snakeCase name}}/generated/flavor.hpp" +#include "flavor.hpp" namespace bb { diff --git a/bb-pilcom/cli/src/main.rs b/bb-pilcom/cli/src/main.rs index 0cb70cb2624..a4325508d6f 100644 --- a/bb-pilcom/cli/src/main.rs +++ b/bb-pilcom/cli/src/main.rs @@ -12,12 +12,11 @@ struct Cli { /// Input file file: String, - /// Output directory for the PIL file, json file and fixed and witness column data. + /// Output directory for the generated files #[arg(short, long)] - #[arg(default_value_t = String::from("."))] - output_directory: String, + output_directory: Option, - /// BBerg: Name of the output file for bberg + /// BBerg: Name of the VM #[arg(long)] name: Option, @@ -34,7 +33,7 @@ fn main() -> Result<(), io::Error> { let name = args.name.unwrap(); let analyzed: Analyzed = analyze_file(Path::new(&file_name)); - analyzed_to_cpp(&analyzed, &name, args.yes); + analyzed_to_cpp(&analyzed, args.output_directory.as_deref(), &name, args.yes); Ok(()) }