Skip to content

Commit e5ee2db

Browse files
author
notnotraju
committed
add static_assert(NUM_SUBRELATIONS == SUBRELATION_PARTIAL_LENGTHS.size())
Adds a NUM_SUBRELATIONS sentinel to each SubrelationIndex enum and a static_assert to catch enum/array size mismatches at compile time.
1 parent b0c625c commit e5ee2db

7 files changed

Lines changed: 14 additions & 0 deletions

File tree

barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_bools_relation.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,13 @@ template <typename FF_> class ECCVMBoolsRelationImpl {
4949
BOOL_MSM_ADD2 = 20,
5050
BOOL_MSM_ADD3 = 21,
5151
BOOL_MSM_ADD4 = 22,
52+
NUM_SUBRELATIONS,
5253
};
5354

5455
static constexpr std::array<size_t, 23> SUBRELATION_PARTIAL_LENGTHS{
5556
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
5657
};
58+
static_assert(NUM_SUBRELATIONS == SUBRELATION_PARTIAL_LENGTHS.size());
5759

5860
template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
5961
static void accumulate(ContainerOverSubrelations& accumulator,

barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_lookup_relation.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ template <typename FF_> class ECCVMLookupRelationImpl {
2626
enum SubrelationIndex : size_t {
2727
GRAND_PRODUCT = 0,
2828
LEFT_SHIFTABLE = 1,
29+
NUM_SUBRELATIONS,
2930
};
3031

3132
static constexpr std::array<size_t, 2> SUBRELATION_PARTIAL_LENGTHS{
3233
LENGTH, // grand product construction sub-relation
3334
LENGTH // left-shiftable polynomial sub-relation
3435
};
36+
static_assert(NUM_SUBRELATIONS == SUBRELATION_PARTIAL_LENGTHS.size());
3537

3638
static constexpr std::array<bool, 2> SUBRELATION_LINEARLY_INDEPENDENT = { true, false };
3739

barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_msm_relation.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,13 @@ template <typename FF_> class ECCVMMSMRelationImpl {
122122
// No-op row: accumulator preservation when no selector is active
123123
NO_OP_ACC_X = 45,
124124
NO_OP_ACC_Y = 46,
125+
NUM_SUBRELATIONS,
125126
};
126127

127128
static constexpr std::array<size_t, 47> SUBRELATION_PARTIAL_LENGTHS{ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
128129
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
129130
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 };
131+
static_assert(NUM_SUBRELATIONS == SUBRELATION_PARTIAL_LENGTHS.size());
130132

131133
template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
132134
static void accumulate(ContainerOverSubrelations& accumulator,

barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_point_table_relation.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ template <typename FF_> class ECCVMPointTableRelationImpl {
3636
// Point addition: T = T_shift + D when not at transition
3737
ADD_X = 4,
3838
ADD_Y = 5,
39+
NUM_SUBRELATIONS,
3940
};
4041

4142
static constexpr std::array<size_t, 6> SUBRELATION_PARTIAL_LENGTHS{ 6, 6, 6, 6, 6, 6 };
43+
static_assert(NUM_SUBRELATIONS == SUBRELATION_PARTIAL_LENGTHS.size());
4244

4345
template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
4446
static void accumulate(ContainerOverSubrelations& accumulator,

barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_set_relation.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ template <typename FF_> class ECCVMSetRelationImpl {
3030
enum SubrelationIndex : size_t {
3131
GRAND_PRODUCT = 0,
3232
LEFT_SHIFTABLE = 1,
33+
NUM_SUBRELATIONS,
3334
};
3435

3536
static constexpr std::array<size_t, 2> SUBRELATION_PARTIAL_LENGTHS{
3637
22, // grand product construction sub-relation
3738
3 // left-shiftable polynomial sub-relation
3839
};
40+
static_assert(NUM_SUBRELATIONS == SUBRELATION_PARTIAL_LENGTHS.size());
3941
// prover optimization to allow for skipping the computation of sub-relations at certain points in sumcheck.
4042
template <typename AllEntities> inline static bool skip(const AllEntities& in)
4143
{

barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_transcript_relation.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,13 @@ template <typename FF_> class ECCVMTranscriptRelationImpl {
9999
INFINITY_ACC_X = 29,
100100
// Infinity flag consistency: acc_y = 0 when accumulator empty
101101
INFINITY_ACC_Y = 30,
102+
NUM_SUBRELATIONS,
102103
};
103104

104105
static constexpr std::array<size_t, 31> SUBRELATION_PARTIAL_LENGTHS{
105106
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
106107
};
108+
static_assert(NUM_SUBRELATIONS == SUBRELATION_PARTIAL_LENGTHS.size());
107109

108110
template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
109111
static void accumulate(ContainerOverSubrelations& accumulator,

barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_wnaf_relation.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,12 @@ template <typename FF_> class ECCVMWnafRelationImpl {
8585
INACTIVE_POINT_TRANSITION = 21,
8686
// Precompute select shape: monotonically non-decreasing after first row
8787
PRECOMPUTE_SELECT_SHAPE = 22,
88+
NUM_SUBRELATIONS,
8889
};
8990

9091
static constexpr std::array<size_t, 23> SUBRELATION_PARTIAL_LENGTHS{ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
9192
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 };
93+
static_assert(NUM_SUBRELATIONS == SUBRELATION_PARTIAL_LENGTHS.size());
9294

9395
template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
9496
static void accumulate(ContainerOverSubrelations& accumulator,

0 commit comments

Comments
 (0)