diff --git a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_rounds_bench/protogalaxy_rounds.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_rounds_bench/protogalaxy_rounds.bench.cpp index da79a67adb5..3fa5518ab1d 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_rounds_bench/protogalaxy_rounds.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_rounds_bench/protogalaxy_rounds.bench.cpp @@ -9,7 +9,8 @@ using namespace benchmark; namespace bb { -template +using Flavor = MegaFlavor; + void _bench_round(::benchmark::State& state, void (*F)(ProtogalaxyProver_>&)) { using Builder = typename Flavor::CircuitBuilder; @@ -48,7 +49,7 @@ void _bench_round(::benchmark::State& state, void (*F)(ProtogalaxyProver_>&)) { - _bench_round(state, F); + _bench_round(state, F); } BENCHMARK_CAPTURE(bench_round_mega, oink, [](auto& prover) { prover.run_oink_prover_on_each_incomplete_key(); }) diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp index 1fd8a652371..a4f0f41cbd3 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp @@ -1,13 +1,13 @@ #include "barretenberg/honk/utils/testing.hpp" #include "barretenberg/protogalaxy/protogalaxy_prover_internal.hpp" #include "barretenberg/relations/ultra_arithmetic_relation.hpp" -#include "barretenberg/stdlib_circuit_builders/ultra_flavor.hpp" +#include "barretenberg/stdlib_circuit_builders/mega_flavor.hpp" #include "barretenberg/ultra_honk/decider_keys.hpp" #include using namespace bb; -using Flavor = UltraFlavor; +using Flavor = MegaFlavor; using Polynomial = typename Flavor::Polynomial; using FF = typename Flavor::FF; @@ -34,7 +34,7 @@ TEST(Protogalaxy, CombinerOn2Keys) }; auto run_test = [&](bool is_random_input) { - // Combiner test on prover polynomisls containing random values, restricted to only the standard arithmetic + // Combiner test on prover polynomials containing random values, restricted to only the standard arithmetic // relation. if (is_random_input) { std::vector> keys_data(NUM_KEYS); @@ -58,18 +58,18 @@ TEST(Protogalaxy, CombinerOn2Keys) auto result_no_skipping = Fun::compute_combiner_no_optimistic_skipping( keys, gate_separators, univariate_relation_parameters_no_skpping, alphas); // The expected_result values are computed by running the python script combiner_example_gen.py - auto expected_result = Univariate(std::array{ 9704UL, - 13245288UL, - 75534568UL, - 224626280UL, - 498269160UL, - 934211944UL, - 1570203368UL, - 2443992168UL, - 3593327080UL, - 5055956840UL, - 6869630184UL, - 9072095848UL }); + auto expected_result = Univariate(std::array{ 11480UL, + 14117208UL, + 78456280UL, + 230777432UL, + 508829400UL, + 950360920UL, + 1593120728UL, + 2474857560UL, + 3633320152UL, + 5106257240UL, + 6931417560UL, + 9146549848UL }); EXPECT_EQ(result_no_skipping, expected_result); } else { std::vector> keys_data(NUM_KEYS); diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/combiner_example_gen.py b/barretenberg/cpp/src/barretenberg/protogalaxy/combiner_example_gen.py index dee82425aa6..19577972e5b 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/combiner_example_gen.py +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/combiner_example_gen.py @@ -1,80 +1,62 @@ # TODO(https://github.com/AztecProtocol/barretenberg/issues/760): Delete this? -import numpy as np # np.set_printoptions(formatter={'int': hex}) +import numpy as np + EXTENDED_RELATION_LENGTH = 12 class Row: - # Construct a set of 'all' polynomials with a very simple structure def __init__(self, base_poly): - # Constuct polys by adding increasing factors of 2 to an input poly - self.q_m = base_poly + 2 * 0 - self.q_c = base_poly + 2 * 1 - self.q_l = base_poly + 2 * 2 - self.q_r = base_poly + 2 * 3 - self.q_o = base_poly + 2 * 4 - self.q_4 = base_poly + 2 * 5 - self.q_arith = base_poly + 2 * 6 - self.q_delta_range = base_poly + 2 * 7 - self.q_elliptic = base_poly + 2 * 8 - self.q_aux = base_poly + 2 * 9 - self.q_lookup = base_poly + 2 * 10 - self.q_poseidon2_external_1 = base_poly + 2 * 11 - self.q_poseidon2_external_2 = base_poly + 2 * 12 - self.sigma_1 = base_poly + 2 * 13 - self.sigma_2 = base_poly + 2 * 14 - self.sigma_3 = base_poly + 2 * 15 - self.sigma_4 = base_poly + 2 * 16 - self.id_1 = base_poly + 2 * 17 - self.id_2 = base_poly + 2 * 18 - self.id_3 = base_poly + 2 * 19 - self.id_4 = base_poly + 2 * 20 - self.table_1 = base_poly + 2 * 21 - self.table_2 = base_poly + 2 * 22 - self.table_3 = base_poly + 2 * 23 - self.table_4 = base_poly + 2 * 24 - self.lagrange_first = base_poly + 2 * 25 - self.lagrange_last = base_poly + 2 * 26 - self.w_l = base_poly + 2 * 27 - self.w_r = base_poly + 2 * 28 - self.w_o = base_poly + 2 * 29 - self.w_4 = base_poly + 2 * 30 - self.sorted_accum = base_poly + 2 * 31 - self.z_perm = base_poly + 2 * 32 - self.z_lookup = base_poly + 2 * 33 - self.table_1_shift = base_poly + 2 * 34 - self.table_2_shift = base_poly + 2 * 35 - self.table_3_shift = base_poly + 2 * 36 - self.table_4_shift = base_poly + 2 * 37 - self.w_l_shift = base_poly + 2 * 38 - self.w_r_shift = base_poly + 2 * 39 - self.w_o_shift = base_poly + 2 * 40 - self.w_4_shift = base_poly + 2 * 41 - self.sorted_accum_shift = base_poly + 2 * 42 - self.z_perm_shift = base_poly + 2 * 43 - self.z_lookup_shift = base_poly + 2 * 44 + # List of all entities in the correct order + self.entity_names = [ + 'q_m', 'q_c', 'q_l', 'q_r', 'q_o', 'q_4', 'q_arith', 'q_delta_range', 'q_elliptic', 'q_aux', + 'q_lookup', 'q_busread', 'q_poseidon2_external_1', 'q_poseidon2_external_2', + 'sigma_1', 'sigma_2', 'sigma_3', 'sigma_4', + 'id_1', 'id_2', 'id_3', 'id_4', + 'table_1', 'table_2', 'table_3', 'table_4', + 'lagrange_first', 'lagrange_last', 'lagrange_ecc_op', 'databus_id', + 'w_l', 'w_r', 'w_o', 'w_4', 'z_perm', + 'lookup_inverses', 'lookup_read_counts', 'lookup_read_tags', + 'ecc_op_wire_1', 'ecc_op_wire_2', 'ecc_op_wire_3', 'ecc_op_wire_4', + 'calldata', 'calldata_read_counts', 'calldata_read_tags', 'calldata_inverses', + 'secondary_calldata', 'secondary_calldata_read_counts', 'secondary_calldata_read_tags', + 'secondary_calldata_inverses', 'return_data', 'return_data_read_counts', + 'return_data_read_tags', 'return_data_inverses', + 'table_1_shift', 'table_2_shift', 'table_3_shift', 'table_4_shift', + 'w_l_shift', 'w_r_shift', 'w_o_shift', 'w_4_shift', 'z_perm_shift' + ] + + # Initialize each entity + for i, name in enumerate(self.entity_names): + setattr(self, name, np.int64(base_poly + 2 * i)) # Convert result to avoid round ups + print(f"{name}: {getattr(self, name)}") def arith_relation(self): - return self.q_m * self.w_l * self.w_r + self.q_l * self.w_l + self.q_r * self.w_r + self.q_o * self.w_o + self.q_c + return (self.q_m * self.w_l * self.w_r + + self.q_l * self.w_l + + self.q_r * self.w_r + + self.q_o * self.w_o + + self.q_c) + def extend_one_entity(input): - result = input - delta = input[1]-input[0] + result = list(input) # Start with the input as a list + delta = input[1] - input[0] for _ in range(2, EXTENDED_RELATION_LENGTH): result.append(delta + result[-1]) return result def compute_first_example(): # Construct baseline extensions for the two rows; extentions for all polys will be computed via the Row constructor - baseline_extension_0 = np.array(extend_one_entity([0, 128])) + baseline_extension_0 = np.array(extend_one_entity([0, 200])) baseline_extension_1 = baseline_extension_0 + 1 # Construct extensions for all polys for the two rows in consideration row_0_extended = Row(baseline_extension_0) row_1_extended = Row(baseline_extension_1) - accumulator = np.array([0 for _ in range(EXTENDED_RELATION_LENGTH)]) + accumulator = np.zeros(EXTENDED_RELATION_LENGTH, dtype=np.int64) # Use np.int64 for the accumulator zeta_pow = 1 zeta = 2 for row in [row_0_extended, row_1_extended]: @@ -88,7 +70,7 @@ def arith_relation(w_l, w_r, w_o, q_m, q_l, q_r, q_o, q_c): return q_m * w_l * w_r + q_l * w_l + q_r * w_r + q_o * w_o + q_c result = 0 - # 0 1 2 3 4 5 6 7 8 9 10 11 12 + # 0 1 2 3 4 5 6 7 8 9 10 11 12 w_l = np.array([ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) w_r = np.array([ 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26]) w_o = np.array([ 3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51]) @@ -98,7 +80,7 @@ def arith_relation(w_l, w_r, w_o, q_m, q_l, q_r, q_o, q_c): q_o = np.array([-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) q_c = np.array([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) # contribution is zero, but why not? - result += arith_relation(w_l, w_r, w_o, q_m, q_l, q_r, q_o, q_c) + result += arith_relation(w_l, w_r, w_o, q_m, q_l, q_r, q_o, q_c) w_l = np.array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) w_r = np.array([ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover_ultra.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover_ultra.cpp deleted file mode 100644 index 22882e27693..00000000000 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover_ultra.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// Note: this is split up from protogalaxy_prover_impl.hpp for compile performance reasons -#include "barretenberg/ultra_honk/decider_keys.hpp" -#include "protogalaxy_prover_impl.hpp" - -// TODO(https://github.com/AztecProtocol/barretenberg/issues/1076) Remove this instantiation. -namespace bb { -template class ProtogalaxyProver_>; -} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp index 351596b7552..342286270cb 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp @@ -137,7 +137,6 @@ std::shared_ptr ProtogalaxyVerifier return next_accumulator; } -template class ProtogalaxyVerifier_>; template class ProtogalaxyVerifier_>; } // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.hpp index 7e1ed7c989f..c1b57127af5 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.hpp @@ -2,7 +2,6 @@ #include "barretenberg/flavor/flavor.hpp" #include "barretenberg/protogalaxy/folding_result.hpp" #include "barretenberg/stdlib_circuit_builders/mega_flavor.hpp" -#include "barretenberg/stdlib_circuit_builders/ultra_flavor.hpp" #include "barretenberg/transcript/transcript.hpp" #include "barretenberg/ultra_honk/decider_keys.hpp" diff --git a/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.cpp index 36a27699d38..67199413f86 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.cpp @@ -109,16 +109,10 @@ std::shared_ptr ProtogalaxyRecursiv } // Instantiate the template with specific flavors and builders -template class ProtogalaxyRecursiveVerifier_< - RecursiveDeciderVerificationKeys_, 2>>; template class ProtogalaxyRecursiveVerifier_< RecursiveDeciderVerificationKeys_, 2>>; -template class ProtogalaxyRecursiveVerifier_< - RecursiveDeciderVerificationKeys_, 2>>; template class ProtogalaxyRecursiveVerifier_< RecursiveDeciderVerificationKeys_, 2>>; -template class ProtogalaxyRecursiveVerifier_< - RecursiveDeciderVerificationKeys_, 2>>; template class ProtogalaxyRecursiveVerifier_< RecursiveDeciderVerificationKeys_, 2>>; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.hpp index 4cde2740f6d..5dcd59716c3 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.hpp @@ -5,7 +5,6 @@ #include "barretenberg/stdlib/protogalaxy_verifier/recursive_decider_verification_keys.hpp" #include "barretenberg/stdlib/transcript/transcript.hpp" #include "barretenberg/stdlib_circuit_builders/mega_recursive_flavor.hpp" -#include "barretenberg/stdlib_circuit_builders/ultra_recursive_flavor.hpp" #include "barretenberg/ultra_honk/decider_keys.hpp" namespace bb::stdlib::recursion::honk {