Skip to content

Commit

Permalink
chore: Name change: gen perm sort to delta range constraint (#5378)
Browse files Browse the repository at this point in the history
Change the naming convention "gen perm sort" to "delta range
constraint". The name GenPermSort is misleading. The relation actually
is checking that the difference (delta) between wire values is no more
than 3. The original name stems from the context in which this relation
is used but says nothing about the actual constraint being applied.

Closes AztecProtocol/barretenberg#919
  • Loading branch information
ledwards2225 authored and sklppy88 committed Mar 22, 2024
1 parent 0ef7367 commit 5d1a478
Show file tree
Hide file tree
Showing 22 changed files with 125 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ template <typename Flavor, typename Relation> void execute_relation(::benchmark:
}
}
BENCHMARK(execute_relation<UltraFlavor, UltraArithmeticRelation<Fr>>);
BENCHMARK(execute_relation<UltraFlavor, GenPermSortRelation<Fr>>);
BENCHMARK(execute_relation<UltraFlavor, DeltaRangeConstraintRelation<Fr>>);
BENCHMARK(execute_relation<UltraFlavor, EllipticRelation<Fr>>);
BENCHMARK(execute_relation<UltraFlavor, AuxiliaryRelation<Fr>>);
BENCHMARK(execute_relation<UltraFlavor, LookupRelation<Fr>>);
Expand All @@ -43,7 +43,7 @@ BENCHMARK(execute_relation<GoblinUltraFlavor, EccOpQueueRelation<Fr>>);
BENCHMARK(execute_relation<GoblinTranslatorFlavor, GoblinTranslatorDecompositionRelation<Fr>>);
BENCHMARK(execute_relation<GoblinTranslatorFlavor, GoblinTranslatorOpcodeConstraintRelation<Fr>>);
BENCHMARK(execute_relation<GoblinTranslatorFlavor, GoblinTranslatorAccumulatorTransferRelation<Fr>>);
BENCHMARK(execute_relation<GoblinTranslatorFlavor, GoblinTranslatorGenPermSortRelation<Fr>>);
BENCHMARK(execute_relation<GoblinTranslatorFlavor, GoblinTranslatorDeltaRangeConstraintRelation<Fr>>);
BENCHMARK(execute_relation<GoblinTranslatorFlavor, GoblinTranslatorNonNativeFieldRelation<Fr>>);
BENCHMARK(execute_relation<GoblinTranslatorFlavor, GoblinTranslatorPermutationRelation<Fr>>);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ bool UltraCircuitChecker::check_block(Builder& builder,
info("Failed Auxiliary relation at row idx = ", idx);
return false;
}
result = result && check_relation<GenPermSort>(values, params);
result = result && check_relation<DeltaRangeConstraint>(values, params);
if (result == false) {
info("Failed GenPermSort relation at row idx = ", idx);
info("Failed DeltaRangeConstraint relation at row idx = ", idx);
return false;
}
result = result && check_lookup(values, lookup_hash_table);
Expand Down Expand Up @@ -234,7 +234,7 @@ void UltraCircuitChecker::populate_values(
values.q_o = block.q_3()[idx];
values.q_4 = block.q_4()[idx];
values.q_arith = block.q_arith()[idx];
values.q_sort = block.q_sort()[idx];
values.q_delta_range = block.q_delta_range()[idx];
values.q_elliptic = block.q_elliptic()[idx];
values.q_aux = block.q_aux()[idx];
values.q_lookup = block.q_lookup_type()[idx];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include "barretenberg/proof_system/circuit_builder/standard_circuit_builder.hpp"
#include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp"
#include "barretenberg/relations/auxiliary_relation.hpp"
#include "barretenberg/relations/delta_range_constraint_relation.hpp"
#include "barretenberg/relations/ecc_op_queue_relation.hpp"
#include "barretenberg/relations/elliptic_relation.hpp"
#include "barretenberg/relations/gen_perm_sort_relation.hpp"
#include "barretenberg/relations/poseidon2_external_relation.hpp"
#include "barretenberg/relations/poseidon2_internal_relation.hpp"
#include "barretenberg/relations/relation_parameters.hpp"
Expand All @@ -21,7 +21,7 @@ class UltraCircuitChecker {
using Arithmetic = UltraArithmeticRelation<FF>;
using Elliptic = EllipticRelation<FF>;
using Auxiliary = AuxiliaryRelation<FF>;
using GenPermSort = GenPermSortRelation<FF>;
using DeltaRangeConstraint = DeltaRangeConstraintRelation<FF>;
using PoseidonExternal = Poseidon2ExternalRelation<FF>;
using PoseidonInternal = Poseidon2InternalRelation<FF>;
using Params = RelationParameters<FF>;
Expand Down
24 changes: 12 additions & 12 deletions barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include "barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.hpp"
#include "barretenberg/relations/relation_parameters.hpp"
#include "barretenberg/relations/translator_vm/translator_decomposition_relation.hpp"
#include "barretenberg/relations/translator_vm/translator_delta_range_constraint_relation.hpp"
#include "barretenberg/relations/translator_vm/translator_extra_relations.hpp"
#include "barretenberg/relations/translator_vm/translator_gen_perm_sort_relation.hpp"
#include "barretenberg/relations/translator_vm/translator_non_native_field_relation.hpp"
#include "barretenberg/relations/translator_vm/translator_permutation_relation.hpp"
#include "relation_definitions.hpp"
Expand All @@ -38,7 +38,7 @@ class GoblinTranslatorFlavor {
static constexpr size_t MINIMUM_MINI_CIRCUIT_SIZE = 2048;

// The size of the circuit which is filled with non-zero values for most polynomials. Most relations (everything
// except for Permutation and GenPermSort) can be evaluated just on the first chunk
// except for Permutation and DeltaRangeConstraint) can be evaluated just on the first chunk
// It is also the only parameter that can be changed without updating relations or structures in the flavor
static constexpr size_t MINI_CIRCUIT_SIZE = mini_circuit_size;

Expand All @@ -56,7 +56,7 @@ class GoblinTranslatorFlavor {
// Number of wires
static constexpr size_t NUM_WIRES = CircuitBuilder::NUM_WIRES;

// The step in the GenPermSort relation
// The step in the DeltaRangeConstraint relation
static constexpr size_t SORT_STEP = 3;

// The bitness of the range constraint
Expand All @@ -82,7 +82,7 @@ class GoblinTranslatorFlavor {
using GrandProductRelations = std::tuple<GoblinTranslatorPermutationRelation<FF>>;
// define the tuple of Relations that comprise the Sumcheck relation
using Relations = std::tuple<GoblinTranslatorPermutationRelation<FF>,
GoblinTranslatorGenPermSortRelation<FF>,
GoblinTranslatorDeltaRangeConstraintRelation<FF>,
GoblinTranslatorOpcodeConstraintRelation<FF>,
GoblinTranslatorAccumulatorTransferRelation<FF>,
GoblinTranslatorDecompositionRelation<FF>,
Expand All @@ -99,13 +99,13 @@ class GoblinTranslatorFlavor {
static constexpr size_t NUM_RELATIONS = std::tuple_size_v<Relations>;

// define the containers for storing the contributions from each relation in Sumcheck
using SumcheckTupleOfTuplesOfUnivariates =
std::tuple<typename GoblinTranslatorPermutationRelation<FF>::SumcheckTupleOfUnivariatesOverSubrelations,
typename GoblinTranslatorGenPermSortRelation<FF>::SumcheckTupleOfUnivariatesOverSubrelations,
typename GoblinTranslatorOpcodeConstraintRelation<FF>::SumcheckTupleOfUnivariatesOverSubrelations,
typename GoblinTranslatorAccumulatorTransferRelation<FF>::SumcheckTupleOfUnivariatesOverSubrelations,
typename GoblinTranslatorDecompositionRelation<FF>::SumcheckTupleOfUnivariatesOverSubrelations,
typename GoblinTranslatorNonNativeFieldRelation<FF>::SumcheckTupleOfUnivariatesOverSubrelations>;
using SumcheckTupleOfTuplesOfUnivariates = std::tuple<
typename GoblinTranslatorPermutationRelation<FF>::SumcheckTupleOfUnivariatesOverSubrelations,
typename GoblinTranslatorDeltaRangeConstraintRelation<FF>::SumcheckTupleOfUnivariatesOverSubrelations,
typename GoblinTranslatorOpcodeConstraintRelation<FF>::SumcheckTupleOfUnivariatesOverSubrelations,
typename GoblinTranslatorAccumulatorTransferRelation<FF>::SumcheckTupleOfUnivariatesOverSubrelations,
typename GoblinTranslatorDecompositionRelation<FF>::SumcheckTupleOfUnivariatesOverSubrelations,
typename GoblinTranslatorNonNativeFieldRelation<FF>::SumcheckTupleOfUnivariatesOverSubrelations>;
using TupleOfArraysOfValues = decltype(create_tuple_of_arrays_of_values<Relations>());

private:
Expand Down Expand Up @@ -157,7 +157,7 @@ class GoblinTranslatorFlavor {
* @details Goblin proves that several polynomials contain only values in a certain range through 2 relations:
* 1) A grand product which ignores positions of elements (GoblinTranslatorPermutationRelation)
* 2) A relation enforcing a certain ordering on the elements of the given polynomial
* (GoblinTranslatorGenPermSortRelation)
* (GoblinTranslatorDeltaRangeConstraintRelation)
*
* We take the values from 4 polynomials, and spread them into 5 polynomials + add all the steps from MAX_VALUE
* to 0. We order these polynomials and use them in the denominator of the grand product, at the same time
Expand Down
12 changes: 6 additions & 6 deletions barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#include "barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp"
#include "barretenberg/relations/auxiliary_relation.hpp"
#include "barretenberg/relations/databus_lookup_relation.hpp"
#include "barretenberg/relations/delta_range_constraint_relation.hpp"
#include "barretenberg/relations/ecc_op_queue_relation.hpp"
#include "barretenberg/relations/elliptic_relation.hpp"
#include "barretenberg/relations/gen_perm_sort_relation.hpp"
#include "barretenberg/relations/lookup_relation.hpp"
#include "barretenberg/relations/permutation_relation.hpp"
#include "barretenberg/relations/poseidon2_external_relation.hpp"
Expand Down Expand Up @@ -53,7 +53,7 @@ class GoblinUltraFlavor {
using Relations_ = std::tuple<bb::UltraArithmeticRelation<FF>,
bb::UltraPermutationRelation<FF>,
bb::LookupRelation<FF>,
bb::GenPermSortRelation<FF>,
bb::DeltaRangeConstraintRelation<FF>,
bb::EllipticRelation<FF>,
bb::AuxiliaryRelation<FF>,
bb::EccOpQueueRelation<FF>,
Expand Down Expand Up @@ -103,7 +103,7 @@ class GoblinUltraFlavor {
q_o, // column 4
q_4, // column 5
q_arith, // column 6
q_sort, // column 7
q_delta_range, // column 7
q_elliptic, // column 8
q_aux, // column 9
q_lookup, // column 10
Expand Down Expand Up @@ -139,7 +139,7 @@ class GoblinUltraFlavor {
q_o,
q_4,
q_arith,
q_sort,
q_delta_range,
q_elliptic,
q_aux,
q_lookup,
Expand Down Expand Up @@ -386,7 +386,7 @@ class GoblinUltraFlavor {
q_4 = "Q_4";
q_m = "Q_M";
q_arith = "Q_ARITH";
q_sort = "Q_SORT";
q_delta_range = "Q_SORT";
q_elliptic = "Q_ELLIPTIC";
q_aux = "Q_AUX";
q_lookup = "Q_LOOKUP";
Expand Down Expand Up @@ -427,7 +427,7 @@ class GoblinUltraFlavor {
this->q_4 = verification_key->q_4;
this->q_c = verification_key->q_c;
this->q_arith = verification_key->q_arith;
this->q_sort = verification_key->q_sort;
this->q_delta_range = verification_key->q_delta_range;
this->q_elliptic = verification_key->q_elliptic;
this->q_aux = verification_key->q_aux;
this->q_lookup = verification_key->q_lookup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ template <typename BuilderType> class GoblinUltraRecursiveFlavor_ {
this->q_4 = Commitment::from_witness(builder, native_key->q_4);
this->q_c = Commitment::from_witness(builder, native_key->q_c);
this->q_arith = Commitment::from_witness(builder, native_key->q_arith);
this->q_sort = Commitment::from_witness(builder, native_key->q_sort);
this->q_delta_range = Commitment::from_witness(builder, native_key->q_delta_range);
this->q_elliptic = Commitment::from_witness(builder, native_key->q_elliptic);
this->q_aux = Commitment::from_witness(builder, native_key->q_aux);
this->q_lookup = Commitment::from_witness(builder, native_key->q_lookup);
Expand Down
18 changes: 9 additions & 9 deletions barretenberg/cpp/src/barretenberg/flavor/ultra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include "barretenberg/polynomials/univariate.hpp"
#include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp"
#include "barretenberg/relations/auxiliary_relation.hpp"
#include "barretenberg/relations/delta_range_constraint_relation.hpp"
#include "barretenberg/relations/elliptic_relation.hpp"
#include "barretenberg/relations/gen_perm_sort_relation.hpp"
#include "barretenberg/relations/lookup_relation.hpp"
#include "barretenberg/relations/permutation_relation.hpp"
#include "barretenberg/relations/ultra_arithmetic_relation.hpp"
Expand Down Expand Up @@ -46,7 +46,7 @@ class UltraFlavor {
using Relations = std::tuple<bb::UltraArithmeticRelation<FF>,
bb::UltraPermutationRelation<FF>,
bb::LookupRelation<FF>,
bb::GenPermSortRelation<FF>,
bb::DeltaRangeConstraintRelation<FF>,
bb::EllipticRelation<FF>,
bb::AuxiliaryRelation<FF>>;

Expand Down Expand Up @@ -94,7 +94,7 @@ class UltraFlavor {
q_o, // column 4
q_4, // column 5
q_arith, // column 6
q_sort, // column 7
q_delta_range, // column 7
q_elliptic, // column 8
q_aux, // column 9
q_lookup, // column 10
Expand All @@ -117,7 +117,7 @@ class UltraFlavor {

auto get_selectors()
{
return RefArray{ q_m, q_c, q_l, q_r, q_o, q_4, q_arith, q_sort, q_elliptic, q_aux, q_lookup };
return RefArray{ q_m, q_c, q_l, q_r, q_o, q_4, q_arith, q_delta_range, q_elliptic, q_aux, q_lookup };
};
auto get_sigma_polynomials() { return RefArray{ sigma_1, sigma_2, sigma_3, sigma_4 }; };
auto get_id_polynomials() { return RefArray{ id_1, id_2, id_3, id_4 }; };
Expand Down Expand Up @@ -187,7 +187,7 @@ class UltraFlavor {
q_4, // column 4
q_m, // column 5
q_arith, // column 6
q_sort, // column 7
q_delta_range, // column 7
q_elliptic, // column 8
q_aux, // column 9
q_lookup, // column 10
Expand Down Expand Up @@ -228,7 +228,7 @@ class UltraFlavor {
// Gemini-specific getters.
auto get_unshifted()
{
return RefArray{ q_m, q_c, q_l, q_r, q_o, q_4, q_arith, q_sort,
return RefArray{ q_m, q_c, q_l, q_r, q_o, q_4, q_arith, q_delta_range,
q_elliptic, q_aux, q_lookup, 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, w_l, w_r, w_o, w_4, sorted_accum, z_perm, z_lookup
Expand All @@ -238,7 +238,7 @@ class UltraFlavor {

auto get_precomputed()
{
return RefArray{ q_m, q_c, q_l, q_r, q_o, q_4, q_arith, q_sort,
return RefArray{ q_m, q_c, q_l, q_r, q_o, q_4, q_arith, q_delta_range,
q_elliptic, q_aux, q_lookup, 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
Expand Down Expand Up @@ -382,7 +382,7 @@ class UltraFlavor {
q_4 = "Q_4";
q_m = "Q_M";
q_arith = "Q_ARITH";
q_sort = "Q_SORT";
q_delta_range = "Q_SORT";
q_elliptic = "Q_ELLIPTIC";
q_aux = "Q_AUX";
q_lookup = "Q_LOOKUP";
Expand Down Expand Up @@ -420,7 +420,7 @@ class UltraFlavor {
q_o = verification_key->q_o;
q_4 = verification_key->q_4;
q_arith = verification_key->q_arith;
q_sort = verification_key->q_sort;
q_delta_range = verification_key->q_delta_range;
q_elliptic = verification_key->q_elliptic;
q_aux = verification_key->q_aux;
q_lookup = verification_key->q_lookup;
Expand Down
Loading

0 comments on commit 5d1a478

Please sign in to comment.