1#include <gmock/gmock.h>
2#include <gtest/gtest.h>
22using ::testing::TestWithParam;
25using simulation::UpdateCheckEvent;
27using tracegen::TestTraceContainer;
28using tracegen::UpdateCheckTraceBuilder;
36TEST(UpdateCheckConstrainingTest, EmptyRow)
41UpdateCheckEvent never_written = {
42 .address = 0xdeadbeef,
43 .current_class_id = 1,
44 .original_class_id = 1,
45 .current_timestamp = 100,
48UpdateCheckEvent never_updated = {
49 .address = 0xdeadbeef,
50 .current_class_id = 1,
51 .original_class_id = 1,
52 .current_timestamp = 100,
56UpdateCheckEvent update_from_original_next_timestamp = {
57 .address = 0xdeadbeef,
58 .current_class_id = 1,
59 .original_class_id = 1,
60 .current_timestamp = 100,
62 .update_preimage_metadata =
FF(
static_cast<uint64_t
>(1234) << 32) + 101,
63 .update_preimage_pre_class_id = 0,
64 .update_preimage_post_class_id = 2,
67UpdateCheckEvent update_next_timestamp = {
68 .address = 0xdeadbeef,
69 .current_class_id = 2,
70 .original_class_id = 1,
71 .current_timestamp = 100,
73 .update_preimage_metadata =
FF(
static_cast<uint64_t
>(1234) << 32) + 101,
74 .update_preimage_pre_class_id = 2,
75 .update_preimage_post_class_id = 3,
78UpdateCheckEvent update_previous_timestamp = {
79 .address = 0xdeadbeef,
80 .current_class_id = 3,
81 .original_class_id = 1,
82 .current_timestamp = 100,
84 .update_preimage_metadata =
FF(
static_cast<uint64_t
>(1234) << 32) + 99,
85 .update_preimage_pre_class_id = 2,
86 .update_preimage_post_class_id = 3,
89UpdateCheckEvent update_current_timestamp = {
90 .address = 0xdeadbeef,
91 .current_class_id = 3,
92 .original_class_id = 1,
93 .current_timestamp = 100,
95 .update_preimage_metadata =
FF(
static_cast<uint64_t
>(1234) << 32) + 100,
96 .update_preimage_pre_class_id = 2,
97 .update_preimage_post_class_id = 3,
103 update_from_original_next_timestamp,
104 update_next_timestamp,
105 update_previous_timestamp,
106 update_current_timestamp,
109class UpdateCheckPositiveConstrainingTest :
public TestWithParam<UpdateCheckEvent> {};
111TEST_P(UpdateCheckPositiveConstrainingTest, PositiveTest)
113 const auto&
event = GetParam();
114 TestTraceContainer
trace({ { { C::precomputed_first_row, 1 } } });
115 UpdateCheckTraceBuilder update_check_builder;
116 update_check_builder.process({
event },
trace);
117 check_relation<update_check_relation>(trace);
121 UpdateCheckPositiveConstrainingTest,
122 ::testing::ValuesIn(positive_tests));
124TEST(UpdateCheckConstrainingTest, HashIsZeroCheck)
127 TestTraceContainer
trace({
129 { C::precomputed_first_row, 1 },
130 { C::update_check_sel, 1 },
131 { C::update_check_update_hash, 27 },
132 { C::update_check_hash_not_zero, 1 },
133 { C::update_check_update_hash_inv,
FF(27).invert() },
137 check_relation<update_check_relation>(trace, update_check_relation::SR_HASH_IS_ZERO_CHECK);
140 trace.
set(C::update_check_hash_not_zero, 0, 0);
143 check_relation<update_check_relation>(trace, update_check_relation::SR_HASH_IS_ZERO_CHECK),
144 "HASH_IS_ZERO_CHECK");
147TEST(UpdateCheckConstrainingTest, NeverUpdatedCheck)
150 TestTraceContainer
trace({
152 { C::precomputed_first_row, 1 },
153 { C::update_check_hash_not_zero, 0 },
154 { C::update_check_current_class_id, 1 },
155 { C::update_check_original_class_id, 1 },
159 check_relation<update_check_relation>(trace, update_check_relation::SR_NEVER_UPDATED_CHECK);
162 trace.
set(C::update_check_current_class_id, 0, 2);
165 check_relation<update_check_relation>(trace, update_check_relation::SR_NEVER_UPDATED_CHECK),
166 "NEVER_UPDATED_CHECK");
169TEST(UpdateCheckConstrainingTest, UpdateMetadataDecomposition)
172 TestTraceContainer
trace({
174 { C::precomputed_first_row, 1 },
175 { C::update_check_hash_not_zero, 1 },
176 { C::update_check_update_hi_metadata, 1234 },
177 { C::update_check_timestamp_of_change, 101 },
178 { C::update_check_update_preimage_metadata,
FF(
static_cast<uint64_t
>(1234) << 32) + 101 },
182 check_relation<update_check_relation>(trace, update_check_relation::SR_UPDATE_METADATA_DECOMPOSITION);
185 trace.
set(C::update_check_timestamp_of_change, 0, 102);
188 check_relation<update_check_relation>(trace, update_check_relation::SR_UPDATE_METADATA_DECOMPOSITION),
189 "UPDATE_METADATA_DECOMPOSITION");
192TEST(UpdateCheckConstrainingTest, UpdatePreClassIsZero)
196 TestTraceContainer
trace({
198 { C::precomputed_first_row, 1 },
199 { C::update_check_hash_not_zero, 1 },
200 { C::update_check_update_preimage_pre_class_id, 27 },
201 { C::update_check_update_pre_class_id_is_zero, 0 },
202 { C::update_check_update_pre_class_inv,
FF(27).invert() },
206 check_relation<update_check_relation>(trace, update_check_relation::SR_UPDATE_PRE_CLASS_IS_ZERO);
209 trace.
set(C::update_check_update_pre_class_id_is_zero, 0, 1);
212 check_relation<update_check_relation>(trace, update_check_relation::SR_UPDATE_PRE_CLASS_IS_ZERO),
213 "UPDATE_PRE_CLASS_IS_ZERO");
216TEST(UpdateCheckConstrainingTest, UpdatePostClassIsZero)
220 TestTraceContainer
trace({
222 { C::precomputed_first_row, 1 },
223 { C::update_check_hash_not_zero, 1 },
224 { C::update_check_update_preimage_post_class_id, 27 },
225 { C::update_check_update_post_class_id_is_zero, 0 },
226 { C::update_check_update_post_class_inv,
FF(27).invert() },
230 check_relation<update_check_relation>(trace, update_check_relation::SR_UPDATE_POST_CLASS_IS_ZERO);
233 trace.
set(C::update_check_update_post_class_id_is_zero, 0, 1);
236 check_relation<update_check_relation>(trace, update_check_relation::SR_UPDATE_POST_CLASS_IS_ZERO),
237 "UPDATE_POST_CLASS_IS_ZERO");
240TEST(UpdateCheckConstrainingTest, FutureUpdateClassIdAssignment)
244 TestTraceContainer
trace({
246 { C::precomputed_first_row, 1 },
247 { C::update_check_hash_not_zero, 1 },
248 { C::update_check_timestamp_is_lt_timestamp_of_change, 1 },
249 { C::update_check_original_class_id, 42 },
250 { C::update_check_update_preimage_pre_class_id, 27 },
251 { C::update_check_update_pre_class_id_is_zero, 0 },
252 { C::update_check_current_class_id, 27 },
256 check_relation<update_check_relation>(trace, update_check_relation::SR_FUTURE_UPDATE_CLASS_ID_ASSIGNMENT);
259 trace.
set(C::update_check_update_pre_class_id_is_zero, 0, 1);
260 trace.
set(C::update_check_update_preimage_pre_class_id, 0, 0);
263 check_relation<update_check_relation>(trace, update_check_relation::SR_FUTURE_UPDATE_CLASS_ID_ASSIGNMENT),
264 "FUTURE_UPDATE_CLASS_ID_ASSIGNMENT");
267 trace.
set(C::update_check_current_class_id, 0, 42);
268 check_relation<update_check_relation>(trace, update_check_relation::SR_FUTURE_UPDATE_CLASS_ID_ASSIGNMENT);
271TEST(UpdateCheckConstrainingTest, PastUpdateClassIdAssignment)
276 TestTraceContainer
trace({
278 { C::precomputed_first_row, 1 },
279 { C::update_check_hash_not_zero, 1 },
280 { C::update_check_timestamp_is_lt_timestamp_of_change, 0 },
281 { C::update_check_original_class_id, 42 },
282 { C::update_check_update_preimage_post_class_id, 27 },
283 { C::update_check_update_post_class_id_is_zero, 0 },
284 { C::update_check_current_class_id, 27 },
288 check_relation<update_check_relation>(trace, update_check_relation::SR_PAST_UPDATE_CLASS_ID_ASSIGNMENT);
291 trace.
set(C::update_check_update_post_class_id_is_zero, 0, 1);
292 trace.
set(C::update_check_update_preimage_post_class_id, 0, 0);
295 check_relation<update_check_relation>(trace, update_check_relation::SR_PAST_UPDATE_CLASS_ID_ASSIGNMENT),
296 "PAST_UPDATE_CLASS_ID_ASSIGNMENT");
299 trace.
set(C::update_check_current_class_id, 0, 42);
300 check_relation<update_check_relation>(trace, update_check_relation::SR_PAST_UPDATE_CLASS_ID_ASSIGNMENT);
#define EXPECT_THROW_WITH_MESSAGE(code, expectedMessageRegex)
void set(Column col, uint32_t row, const FF &value)
INSTANTIATE_TEST_SUITE_P(PaddingVariants, AvmRecursiveTestsParameterized, ::testing::Values(false, true), [](const auto &info) { return info.param ? "Padded" :"Unpadded";})
TEST_P(AvmRecursiveTestsParameterized, GoblinRecursion)
A test of the Goblinized AVM recursive verifier.
TEST(AvmFixedVKTests, FixedVKCommitments)
Test that the fixed VK commitments agree with the ones computed from precomputed columns.
IndexedLeaf< PublicDataLeafValue > PublicDataTreeLeafPreimage
TestTraceContainer empty_trace()
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept