From c36266c5ff11fd3cf897a29a34720df47ab468b8 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Fri, 21 Jun 2024 15:43:55 +0000 Subject: [PATCH] fix build and cleanup --- .../src/barretenberg/plonk/composer/composer_lib.hpp | 2 +- .../plonk_honk_shared/composer/composer_lib.hpp | 9 ++++----- .../src/barretenberg/protogalaxy/protogalaxy.test.cpp | 5 +++-- .../relations/logderiv_lookup_relation.hpp | 11 ++++++----- .../stdlib_circuit_builders/plookup_tables/types.hpp | 7 ++++--- .../stdlib_circuit_builders/ultra_circuit_builder.hpp | 1 - 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.hpp b/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.hpp index ee319334d73..88c518cb4b3 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.hpp @@ -112,7 +112,7 @@ std::array construct_sorted_list_polynomials(typ #endif for (const auto& entry : lookup_gates) { - const auto components = entry.to_sorted_list_components(table.use_twin_keys); + const auto components = entry.to_table_components(table.use_twin_keys); sorted_polynomials[0][s_index] = components[0]; sorted_polynomials[1][s_index] = components[1]; sorted_polynomials[2][s_index] = components[2]; diff --git a/barretenberg/cpp/src/barretenberg/plonk_honk_shared/composer/composer_lib.hpp b/barretenberg/cpp/src/barretenberg/plonk_honk_shared/composer/composer_lib.hpp index 1bf7425ad89..d4e75dc9e14 100644 --- a/barretenberg/cpp/src/barretenberg/plonk_honk_shared/composer/composer_lib.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk_honk_shared/composer/composer_lib.hpp @@ -59,13 +59,12 @@ void construct_lookup_read_counts(typename Flavor::Polynomial& read_counts, for (auto& table : circuit.lookup_tables) { table.initialize_index_map(); - for (auto& entry : table.lookup_gates) { - // convert lookup entry to an array of three field elements, one for each of the 3 columns - // WORKTODO change name of this method - auto data = entry.to_sorted_list_components(table.use_twin_keys); + for (auto& gate_data : table.lookup_gates) { + // convert lookup gate data to an array of three field elements, one for each of the 3 columns + auto table_entry = gate_data.to_table_components(table.use_twin_keys); // find the index of the entry in the table - auto index_in_table = table.index_map[data]; + auto index_in_table = table.index_map[table_entry]; // increment the read count at the corresponding index in the full polynomial size_t index_in_poly = table_offset + index_in_table; diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy.test.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy.test.cpp index cfb06a1d796..98b02eda176 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy.test.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy.test.cpp @@ -408,8 +408,9 @@ template class ProtoGalaxyTests : public testing::Test { auto [prover_accumulator, verifier_accumulator] = fold_and_verify(get<0>(instances), get<1>(instances)); // Expect failure in manual target sum check and decider - bool expected_result check_accumulator_target_sum_manual(prover_accumulator, false); - decide_and_verify(prover_accumulator, verifier_accumulator, false); + bool expected_result = false; + check_accumulator_target_sum_manual(prover_accumulator, expected_result); + decide_and_verify(prover_accumulator, verifier_accumulator, expected_result); } /** diff --git a/barretenberg/cpp/src/barretenberg/relations/logderiv_lookup_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/logderiv_lookup_relation.hpp index 9d65181aa29..0510b93fab2 100644 --- a/barretenberg/cpp/src/barretenberg/relations/logderiv_lookup_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/logderiv_lookup_relation.hpp @@ -23,7 +23,8 @@ template class LogDerivLookupRelationImpl { LENGTH // log derivative lookup argument sub-relation }; - // WORKTODO: shouldnt first one be 2? code doesnt compile that way + // WORKTODO: shouldnt first one be 2? Why do tests pass with 1? (Note: if setting to 2, both need to be 2 due to + // structure of relation algebra) static constexpr std::array TOTAL_LENGTH_ADJUSTMENTS{ 1, // inverse construction sub-relation 1 // log derivative lookup argument sub-relation @@ -144,10 +145,10 @@ template class LogDerivLookupRelationImpl { * * where write_term = table_col_1 + \gamma + table_col_2 * \eta_1 + table_col_3 * \eta_2 + table_index * \eta_3 * and read_term = derived_table_entry_1 + \gamma + derived_table_entry_2 * \eta_1 + derived_table_entry_3 * \eta_2 - * + table_index * \eta_3, with derived_table_entry_i = w_i - col_step_size\cdot w_i_shift. (The table entries must - * be 'derived' from wire values in this way since the stored witnesses are actually successive accumulators, the - * differences of which are equal to entries in a table. This is an efficiency trick to avoid using additional gates - * to reconstruct full size values from the limbs contained in tables). + * + table_index * \eta_3, with derived_table_entry_i = w_i - col_step_size_i\cdot w_i_shift. (The table entries + * must be 'derived' from wire values in this way since the stored witnesses are actually successive accumulators, + * the differences of which are equal to entries in a table. This is an efficiency trick to avoid using additional + * gates to reconstruct full size values from the limbs contained in tables). * * In practice this identity is expressed in terms of polynomials by defining a polynomial of inverses I_i = * \frac{1}{read_term_i\cdot write_term_i} then rewriting the above identity as diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/plookup_tables/types.hpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/plookup_tables/types.hpp index a68da31b1b6..4111817ba7a 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/plookup_tables/types.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/plookup_tables/types.hpp @@ -213,7 +213,7 @@ struct MultiTable { // std::array value{ bb::fr(0), bb::fr(0) }; // bool operator<(const KeyEntry& other) const { return key < other.key; } -// std::array to_sorted_list_components(const bool use_two_keys) const +// std::array to_table_components(const bool use_two_keys) const // { // return { // key[0], @@ -248,7 +248,7 @@ struct MultiTable { // return (key.from_montgomery_form() < other.key.from_montgomery_form()); // } -// std::array to_sorted_list_components() const { return { key, values[0], values[0] }; } +// std::array to_table_components() const { return { key, values[0], values[0] }; } // } // BasicTableId id; @@ -349,7 +349,8 @@ struct BasicTable { return key[0] < other.key[0] || ((key[0] == other.key[0]) && key[1] < other.key[1]); } - std::array to_sorted_list_components(const bool use_two_keys) const + // Express the key-value pair as the entries of a 3-column row in a table + std::array to_table_components(const bool use_two_keys) const { return { bb::fr(key[0]), diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp index 7d3198dfc70..ce1a8b8aebf 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp @@ -659,7 +659,6 @@ class UltraCircuitBuilder_ : public CircuitBuilderBasepublic_inputs.size(); return std::max(minimum_circuit_size, num_filled_gates) + NUM_RESERVED_GATES;