1#include <gmock/gmock.h>
2#include <gtest/gtest.h>
17using tracegen::TestTraceContainer;
22TEST(TxDiscardConstrainingTest, EmptyRow)
27TEST(TxDiscardConstrainingTest, CanOnlyDiscardInRevertiblePhases)
30 TestTraceContainer
trace({
31 { { C::precomputed_first_row, 1 } },
33 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 0 }, { C::tx_reverted, 0 } },
35 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
37 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 1 } },
42 check_relation<tx_discard_relation>(trace, tx_discard_relation::SR_CAN_ONLY_DISCARD_IN_REVERTIBLE_PHASES);
46 trace.
set(C::tx_is_revertible, 1, 0);
48 check_relation<tx_discard_relation>(trace, tx_discard_relation::SR_CAN_ONLY_DISCARD_IN_REVERTIBLE_PHASES),
49 tx_discard_relation::get_subrelation_label(tx_discard_relation::SR_CAN_ONLY_DISCARD_IN_REVERTIBLE_PHASES));
52TEST(TxDiscardConstrainingTest, FailureMustDiscard)
55 TestTraceContainer
trace({
56 { { C::precomputed_first_row, 1 } },
58 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
60 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 1 } },
62 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
67 check_relation<tx_discard_relation>(trace, tx_discard_relation::SR_REVERTED_MUST_DISCARD);
73 check_relation<tx_discard_relation>(trace, tx_discard_relation::SR_REVERTED_MUST_DISCARD),
74 tx_discard_relation::get_subrelation_label(tx_discard_relation::SR_REVERTED_MUST_DISCARD));
77TEST(TxDiscardConstrainingTest, LastRowOfSetupCalculation)
80 TestTraceContainer
trace({
81 { { C::precomputed_first_row, 1 } },
83 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 0 }, { C::tx_reverted, 0 } },
85 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 0 }, { C::tx_reverted, 0 } },
87 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 0 }, { C::tx_reverted, 0 } },
89 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
91 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
96 check_relation<tx_discard_relation>(trace, tx_discard_relation::SR_DISCARD_PROPAGATION);
99TEST(TxDiscardConstrainingTest, DiscardPropagationNormal)
102 TestTraceContainer
trace({
103 { { C::precomputed_first_row, 1 } },
105 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
107 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
109 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 1 } },
111 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
112 { { C::tx_sel, 0 } },
115 check_relation<tx_discard_relation>(trace, tx_discard_relation::SR_DISCARD_PROPAGATION);
120 tx_discard_relation::get_subrelation_label(tx_discard_relation::SR_DISCARD_PROPAGATION));
125TEST(TxDiscardConstrainingTest, DiscardPropagationLiftedAtSetupEnd)
128 TestTraceContainer
trace({
129 { { C::precomputed_first_row, 1 } },
131 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 0 }, { C::tx_reverted, 0 } },
133 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 0 }, { C::tx_reverted, 0 } },
135 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
136 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 1 } },
137 { { C::tx_sel, 0 } },
141 check_relation<tx_discard_relation>(trace, tx_discard_relation::SR_DISCARD_PROPAGATION);
144TEST(TxDiscardConstrainingTest, DiscardPropagationLiftedOnFailure)
147 TestTraceContainer
trace({
148 { { C::precomputed_first_row, 1 } },
150 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
152 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 1 } },
154 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
155 { { C::tx_sel, 0 } },
158 check_relation<tx_discard_relation>(trace, tx_discard_relation::SR_DISCARD_PROPAGATION);
161TEST(TxDiscardConstrainingTest, FailureOnlyInRevertibles)
163 TestTraceContainer
trace({
164 { { C::precomputed_first_row, 1 } },
169 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 0 }, { C::tx_reverted, 0 } },
170 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 0 }, { C::tx_reverted, 0 } },
174 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
175 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 1 } },
179 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
181 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
182 { { C::tx_sel, 0 } },
186 check_relation<tx_discard_relation>(trace);
189TEST(TxDiscardConstrainingTest, FailureOnlyInAppLogic)
191 TestTraceContainer
trace({
192 { { C::precomputed_first_row, 1 } },
197 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 0 }, { C::tx_reverted, 0 } },
198 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 0 }, { C::tx_reverted, 0 } },
202 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
203 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
205 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 1 } },
208 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
209 { { C::tx_sel, 0 } },
213 check_relation<tx_discard_relation>(trace);
216TEST(TxDiscardConstrainingTest, FailureOnlyInTeardown)
218 TestTraceContainer
trace({
219 { { C::precomputed_first_row, 1 } },
224 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 0 }, { C::tx_reverted, 0 } },
225 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 0 }, { C::tx_reverted, 0 } },
229 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
230 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
231 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
233 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 1 } },
234 { { C::tx_sel, 0 } },
238 check_relation<tx_discard_relation>(trace);
243 tx_discard_relation::get_subrelation_label(tx_discard_relation::SR_DISCARD_PROPAGATION));
248TEST(TxDiscardConstrainingTest, FailureInRevertiblesAndTeardown)
250 TestTraceContainer
trace({
251 { { C::precomputed_first_row, 1 } },
256 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 0 }, { C::tx_reverted, 0 } },
257 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 0 }, { C::tx_reverted, 0 } },
261 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
262 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
263 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 1 } },
266 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 1 } },
267 { { C::tx_sel, 0 } },
271 check_relation<tx_discard_relation>(trace);
274TEST(TxDiscardConstrainingTest, DiscardButFailureNeverEncountered)
276 TestTraceContainer
trace({
277 { { C::precomputed_first_row, 1 } },
282 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 0 }, { C::tx_reverted, 0 } },
283 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 0 }, { C::tx_reverted, 0 } },
286 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
287 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
288 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 0 } },
291 { { C::tx_sel, 1 }, { C::tx_discard, 1 }, { C::tx_is_revertible, 1 }, { C::tx_reverted, 1 } },
295 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 0 }, { C::tx_reverted, 0 } },
296 { { C::tx_sel, 1 }, { C::tx_discard, 0 }, { C::tx_is_revertible, 0 }, { C::tx_reverted, 0 } },
297 { { C::tx_sel, 0 } },
301 check_relation<tx_discard_relation>(trace);
306 tx_discard_relation::get_subrelation_label(tx_discard_relation::SR_DISCARD_PROPAGATION));
313 check_relation<tx_discard_relation>(trace, tx_discard_relation::SR_CAN_ONLY_DISCARD_IN_REVERTIBLE_PHASES),
314 tx_discard_relation::get_subrelation_label(tx_discard_relation::SR_CAN_ONLY_DISCARD_IN_REVERTIBLE_PHASES));
#define EXPECT_THROW_WITH_MESSAGE(code, expectedMessageRegex)
void set(Column col, uint32_t row, const FF &value, bool use_atomic_limbs=false)
TEST(AvmFixedVKTests, FixedVKCommitments)
Test that the fixed VK commitments agree with the ones computed from precomputed columns.
TestTraceContainer empty_trace()