Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: only take FF (and not Flavor) in compute_logderivative_inverse #11938

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void complete_proving_key_for_test(bb::RelationParameters<FF>& relation_paramete
relation_parameters.eccvm_set_permutation_delta = relation_parameters.eccvm_set_permutation_delta.invert();

// Compute z_perm and inverse polynomial for our logarithmic-derivative lookup method
compute_logderivative_inverse<ECCVMFlavor, ECCVMFlavor::LookupRelation>(
compute_logderivative_inverse<FF, ECCVMFlavor::LookupRelation>(
pk->polynomials, relation_parameters, pk->circuit_size);
compute_grand_products<ECCVMFlavor>(pk->polynomials, relation_parameters);

Expand Down
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void ECCVMProver::execute_log_derivative_commitments_round()
gamma * (gamma + beta_sqr) * (gamma + beta_sqr + beta_sqr) * (gamma + beta_sqr + beta_sqr + beta_sqr);
relation_parameters.eccvm_set_permutation_delta = relation_parameters.eccvm_set_permutation_delta.invert();
// Compute inverse polynomial for our logarithmic-derivative lookup method
compute_logderivative_inverse<Flavor, typename Flavor::LookupRelation>(
compute_logderivative_inverse<typename Flavor::FF, typename Flavor::LookupRelation>(
key->polynomials, relation_parameters, key->circuit_size);
transcript->send_to_verifier(commitment_labels.lookup_inverses,
key->commitment_key->commit(key->polynomials.lookup_inverses));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bool ECCVMTraceChecker::check(Builder& builder, numeric::RNG* engine_ptr)

ProverPolynomials polynomials(builder);
const size_t num_rows = polynomials.get_polynomial_size();
compute_logderivative_inverse<Flavor, ECCVMLookupRelation<FF>>(polynomials, params, num_rows);
compute_logderivative_inverse<FF, ECCVMLookupRelation<FF>>(polynomials, params, num_rows);
compute_grand_product<Flavor, ECCVMSetRelation<FF>>(polynomials, params);

polynomials.z_perm_shift = Polynomial(polynomials.z_perm.shifted());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#pragma once

#include "barretenberg/common/constexpr_utils.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fcarreiro Is this header really needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is and it was not included. Things were only working because every file where logderivative_library.hpp was being used was already including constexpr_utils.hpp. There are likely many more headers that are needed and not explicitly included. I found this one when I tried to use just this file in a very limited context.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent!


#include <typeinfo>

namespace bb {
Expand All @@ -22,10 +25,9 @@ namespace bb {
* The specific algebraic relations that define read terms and write terms are defined in Flavor::LookupRelation
*
*/
template <typename Flavor, typename Relation, typename Polynomials>
template <typename FF, typename Relation, typename Polynomials>
void compute_logderivative_inverse(Polynomials& polynomials, auto& relation_parameters, const size_t circuit_size)
{
using FF = typename Flavor::FF;
using Accumulator = typename Relation::ValueAccumulator0;
constexpr size_t READ_TERMS = Relation::READ_TERMS;
constexpr size_t WRITE_TERMS = Relation::WRITE_TERMS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ bool AvmCircuitBuilder::check_circuit() const
using Relation = std::tuple_element_t<i, AvmFlavor::LookupRelations>;
checks.push_back([&, num_rows](SignalErrorFn signal_error) {
// Check the logderivative relation
bb::compute_logderivative_inverse<Flavor, Relation>(polys, params, num_rows);
bb::compute_logderivative_inverse<typename Flavor::FF, Relation>(polys, params, num_rows);

typename Relation::SumcheckArrayOfValuesOverSubrelations lookup_result;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void AvmProver::execute_log_derivative_inverse_round()
using Relation = std::tuple_element_t<relation_idx, Flavor::LookupRelations>;
tasks.push_back([&]() {
AVM_TRACK_TIME(std::string("prove/execute_log_derivative_inverse_round/") + std::string(Relation::NAME),
(compute_logderivative_inverse<Flavor, Relation>(
(compute_logderivative_inverse<FF, Relation>(
prover_polynomials, relation_parameters, key->circuit_size)));
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ TEST(AvmFullPoseidon2, shouldHashCorrectly)
using PermRelations = perm_pos2_fixed_pos2_perm_relation<FF>;

// Check the logderivative relation
bb::compute_logderivative_inverse<AvmFlavor, PermRelations>(polys, params, num_rows);
bb::compute_logderivative_inverse<FF, PermRelations>(polys, params, num_rows);

typename PermRelations::SumcheckArrayOfValuesOverSubrelations lookup_result;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ TEST(AvmMerkleTree, shouldCheckMembership)
using PermRelations = perm_merkle_poseidon2_relation<FF>;

// Check the logderivative relation
bb::compute_logderivative_inverse<AvmFlavor, PermRelations>(polys, params, num_rows);
bb::compute_logderivative_inverse<FF, PermRelations>(polys, params, num_rows);

typename PermRelations::SumcheckArrayOfValuesOverSubrelations lookup_result;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ TEST(AvmRangeCheck, shouldRangeCheck)
using LookupRelations = std::tuple_element_t<i, AllLookupRelations>;

// Check the logderivative relation
bb::compute_logderivative_inverse<AvmFlavor, LookupRelations>(polys, params, num_rows);
bb::compute_logderivative_inverse<FF, LookupRelations>(polys, params, num_rows);

typename LookupRelations::SumcheckArrayOfValuesOverSubrelations lookup_result;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void run_check_circuit(AvmFlavor::ProverPolynomials& polys, size_t num_rows)
using Relation = std::tuple_element_t<i, typename AvmFlavor::LookupRelations>;
checks.push_back([&, num_rows]() {
// Compute logderivs.
bb::compute_logderivative_inverse<AvmFlavor, Relation>(polys, params, num_rows);
bb::compute_logderivative_inverse<typename AvmFlavor::FF, Relation>(polys, params, num_rows);

// Check the logderivative relation
typename Relation::SumcheckArrayOfValuesOverSubrelations lookup_result{};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void AvmProver::execute_log_derivative_inverse_round()
using Relation = std::tuple_element_t<relation_idx, Flavor::LookupRelations>;
tasks.push_back([&]() {
AVM_TRACK_TIME(std::string("prove/execute_log_derivative_inverse_round/") + std::string(Relation::NAME),
(compute_logderivative_inverse<Flavor, Relation>(
(compute_logderivative_inverse<FF, Relation>(
prover_polynomials, relation_parameters, key->circuit_size)));
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ bool AvmCircuitBuilder::check_circuit() const {
using Relation = std::tuple_element_t<i, AvmFlavor::LookupRelations>;
checks.push_back([&, num_rows](SignalErrorFn signal_error) {
// Check the logderivative relation
bb::compute_logderivative_inverse<Flavor, Relation>(polys, params, num_rows);
bb::compute_logderivative_inverse<typename Flavor::FF, Relation>(polys, params, num_rows);

typename Relation::SumcheckArrayOfValuesOverSubrelations lookup_result;

Expand Down
2 changes: 1 addition & 1 deletion bb-pilcom/bb-pil-backend/templates/prover.cpp.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void AvmProver::execute_log_derivative_inverse_round()
using Relation = std::tuple_element_t<relation_idx, Flavor::LookupRelations>;
tasks.push_back([&]() {
AVM_TRACK_TIME(std::string("prove/execute_log_derivative_inverse_round/") + std::string(Relation::NAME),
(compute_logderivative_inverse<Flavor, Relation>(
(compute_logderivative_inverse<FF, Relation>(
prover_polynomials, relation_parameters, key->circuit_size)));
});
});
Expand Down