Skip to content

Commit b1284ef

Browse files
authored
fix(avm): use the correct number of rows in check_interaction (#12519)
It was wrongly using `polys.size()` which is the number of columns and not rows.
1 parent 5502901 commit b1284ef

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

barretenberg/cpp/src/barretenberg/vm2/constraining/testing/check_relation.hpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,16 @@ template <typename Relation> constexpr bool subrelation_is_linearly_independent(
2727
}
2828

2929
template <typename Relation, typename Trace, typename RowGetter>
30-
void check_relation_internal(const Trace& trace, std::span<const size_t> subrelations, RowGetter get_row)
30+
void check_relation_internal(const Trace& trace,
31+
std::span<const size_t> subrelations,
32+
uint32_t num_rows,
33+
RowGetter get_row)
3134
{
3235
typename Relation::SumcheckArrayOfValuesOverSubrelations result{};
3336

3437
// Accumulate the trace over the subrelations and check the result
3538
// if the subrelation is linearly independent.
36-
for (size_t r = 0; r < trace.size(); ++r) {
39+
for (size_t r = 0; r < num_rows; ++r) {
3740
Relation::accumulate(result, get_row(trace, r), get_test_params(), 1);
3841
for (size_t j : subrelations) {
3942
if (subrelation_is_linearly_independent<Relation>(j) && !result[j].is_zero()) {
@@ -65,7 +68,7 @@ void check_relation(const tracegen::TestTraceContainer& trace, Ts... subrelation
6568
{
6669
std::array<size_t, sizeof...(Ts)> subrelations = { subrelation... };
6770
detail::check_relation_internal<Relation>(
68-
trace.as_rows(), subrelations, [](const auto& trace, size_t r) { return trace.at(r); });
71+
trace.as_rows(), subrelations, trace.get_num_rows(), [](const auto& trace, size_t r) { return trace.at(r); });
6972
}
7073

7174
template <typename Relation> void check_relation(const tracegen::TestTraceContainer& trace)
@@ -93,8 +96,8 @@ template <typename Lookup> void check_interaction(const tracegen::TestTraceConta
9396
[&]<size_t... Is>(std::index_sequence<Is...>) {
9497
constexpr std::array<size_t, sizeof...(Is)> subrels = { Is... };
9598
detail::check_relation_internal<Lookup>(
96-
polys, subrels, [](const auto& polys, size_t r) { return polys.get_row(r); });
99+
polys, subrels, num_rows, [](const auto& polys, size_t r) { return polys.get_row(r); });
97100
}(std::make_index_sequence<Lookup::SUBRELATION_PARTIAL_LENGTHS.size()>());
98101
}
99102

100-
} // namespace bb::avm2::constraining
103+
} // namespace bb::avm2::constraining

0 commit comments

Comments
 (0)