1010#include " barretenberg/common/thread.hpp"
1111#include " barretenberg/honk/proof_system/logderivative_library.hpp"
1212#include " barretenberg/relations/relation_parameters.hpp"
13+ #include " barretenberg/vm2/constraining/testing/check_relation.hpp"
1314#include " barretenberg/vm2/generated/columns.hpp"
1415
1516namespace bb ::avm2::constraining {
1617
17- void run_check_circuit (AvmFlavor::ProverPolynomials& polys, size_t num_rows)
18+ void run_check_circuit (AvmFlavor::ProverPolynomials& polys, size_t num_rows, bool skippable_enabled )
1819{
1920 bb::RelationParameters<AvmFlavor::FF> params = {
2021 .eta = 0 ,
@@ -37,9 +38,18 @@ void run_check_circuit(AvmFlavor::ProverPolynomials& polys, size_t num_rows)
3738 typename Relation::SumcheckArrayOfValuesOverSubrelations result{};
3839
3940 for (size_t r = 0 ; r < num_rows; ++r) {
40- Relation::accumulate (result, polys.get_row (r), {}, 1 );
41+ auto row = polys.get_row (r);
42+ if constexpr (isSkippable<Relation, decltype (row)>) {
43+ if (skippable_enabled && Relation::skip (row)) {
44+ continue ;
45+ }
46+ }
47+
48+ Relation::accumulate (result, row, {}, 1 );
49+
50+ // Check the linearly independent part of the relation.
4151 for (size_t j = 0 ; j < result.size (); ++j) {
42- if (!result[j].is_zero ()) {
52+ if (detail::subrelation_is_linearly_independent<Relation>(j) && !result[j].is_zero ()) {
4353 throw std::runtime_error (format (" Relation " ,
4454 Relation::NAME,
4555 " , subrelation " ,
@@ -49,6 +59,13 @@ void run_check_circuit(AvmFlavor::ProverPolynomials& polys, size_t num_rows)
4959 }
5060 }
5161 }
62+ // Do final check for the linearly dependent part of the relation.
63+ for (size_t j = 0 ; j < result.size (); ++j) {
64+ if (!result[j].is_zero ()) {
65+ throw std::runtime_error (format (
66+ " Relation " , Relation::NAME, " , subrelation " , Relation::get_subrelation_label (j), " failed." ));
67+ }
68+ }
5269 });
5370 });
5471
@@ -62,8 +79,29 @@ void run_check_circuit(AvmFlavor::ProverPolynomials& polys, size_t num_rows)
6279 // Check the logderivative relation
6380 typename Relation::SumcheckArrayOfValuesOverSubrelations lookup_result{};
6481 for (size_t r = 0 ; r < num_rows; ++r) {
65- Relation::accumulate (lookup_result, polys.get_row (r), params, 1 );
82+ auto row = polys.get_row (r);
83+ if constexpr (isSkippable<Relation, decltype (row)>) {
84+ if (skippable_enabled && Relation::skip (row)) {
85+ continue ;
86+ }
87+ }
88+
89+ Relation::accumulate (lookup_result, row, params, 1 );
90+
91+ for (size_t subrelation_idx = 0 ; subrelation_idx < lookup_result.size (); ++subrelation_idx) {
92+ // We need to check the linearly independent part of the relation.
93+ if (detail::subrelation_is_linearly_independent<Relation>(subrelation_idx) &&
94+ !lookup_result[subrelation_idx].is_zero ()) {
95+ throw std::runtime_error (format (" Lookup " ,
96+ Relation::NAME,
97+ " , subrelation " ,
98+ Relation::get_subrelation_label (subrelation_idx),
99+ " failed at row " ,
100+ r));
101+ }
102+ }
66103 }
104+ // Do final check for the linearly dependent part of the relation.
67105 for (auto r : lookup_result) {
68106 if (!r.is_zero ()) {
69107 throw std::runtime_error (format (" Lookup " , Relation::NAME, " failed." ));
0 commit comments