1#include <gmock/gmock.h>
2#include <gtest/gtest.h>
15using tracegen::TestTraceContainer;
20TEST(RegistersConstrainingTest, EmptyRow)
25TEST(RegistersConstrainingTest, EffectiveRegOpSelectorNoReadNoWrite)
28 TestTraceContainer
trace({ {
29 { C::execution_sel_read_registers, 0 },
30 { C::execution_sel_write_registers, 0 },
32 { C::execution_sel_mem_op_reg_0_, 1 },
33 { C::execution_rw_reg_0_, 0 },
34 { C::execution_sel_op_reg_effective_0_, 0 },
36 { C::execution_sel_mem_op_reg_1_, 1 },
37 { C::execution_rw_reg_1_, 1 },
38 { C::execution_sel_op_reg_effective_1_, 0 },
40 { C::execution_sel_mem_op_reg_2_, 0 },
41 { C::execution_rw_reg_2_, 0 },
42 { C::execution_sel_op_reg_effective_2_, 0 },
44 { C::execution_sel_mem_op_reg_3_, 0 },
45 { C::execution_rw_reg_3_, 1 },
46 { C::execution_sel_op_reg_effective_3_, 0 },
49 check_relation<registers>(trace,
58 { C::execution_sel_op_reg_effective_0_, 1 },
59 { C::execution_sel_op_reg_effective_1_, 1 },
60 { C::execution_sel_op_reg_effective_2_, 1 },
61 { C::execution_sel_op_reg_effective_3_, 1 },
73TEST(RegistersConstrainingTest, EffectiveRegOpSelectorOnlyRead)
76 TestTraceContainer
trace({ {
77 { C::execution_sel_read_registers, 1 },
78 { C::execution_sel_write_registers, 0 },
80 { C::execution_sel_mem_op_reg_0_, 1 },
81 { C::execution_rw_reg_0_, 0 },
82 { C::execution_sel_op_reg_effective_0_, 1 },
84 { C::execution_sel_mem_op_reg_1_, 1 },
85 { C::execution_rw_reg_1_, 1 },
86 { C::execution_sel_op_reg_effective_1_, 0 },
88 { C::execution_sel_mem_op_reg_2_, 0 },
89 { C::execution_rw_reg_2_, 0 },
90 { C::execution_sel_op_reg_effective_2_, 0 },
92 { C::execution_sel_mem_op_reg_3_, 0 },
93 { C::execution_rw_reg_3_, 1 },
94 { C::execution_sel_op_reg_effective_3_, 0 },
97 check_relation<registers>(trace,
106 { C::execution_sel_op_reg_effective_0_, 0 },
107 { C::execution_sel_op_reg_effective_1_, 1 },
108 { C::execution_sel_op_reg_effective_2_, 1 },
109 { C::execution_sel_op_reg_effective_3_, 1 },
121TEST(RegistersConstrainingTest, EffectiveRegOpSelectorReadThenWrite)
124 TestTraceContainer
trace({ {
125 { C::execution_sel_read_registers, 1 },
126 { C::execution_sel_write_registers, 1 },
128 { C::execution_sel_mem_op_reg_0_, 1 },
129 { C::execution_rw_reg_0_, 0 },
130 { C::execution_sel_op_reg_effective_0_, 1 },
132 { C::execution_sel_mem_op_reg_1_, 1 },
133 { C::execution_rw_reg_1_, 1 },
134 { C::execution_sel_op_reg_effective_1_, 1 },
136 { C::execution_sel_mem_op_reg_2_, 0 },
137 { C::execution_rw_reg_2_, 0 },
138 { C::execution_sel_op_reg_effective_2_, 0 },
140 { C::execution_sel_mem_op_reg_3_, 0 },
141 { C::execution_rw_reg_3_, 1 },
142 { C::execution_sel_op_reg_effective_3_, 0 },
145 check_relation<registers>(trace,
154 { C::execution_sel_op_reg_effective_0_, 0 },
155 { C::execution_sel_op_reg_effective_1_, 0 },
156 { C::execution_sel_op_reg_effective_2_, 1 },
157 { C::execution_sel_op_reg_effective_3_, 1 },
169TEST(RegistersConstrainingTest, TagCheckNoFailure)
171 TestTraceContainer
trace({
173 { C::execution_sel_read_registers, 1 },
175 { C::execution_sel_tag_check_reg_0_, 1 },
176 { C::execution_mem_tag_reg_0_,
static_cast<uint8_t
>(
MemoryTag::U8) },
177 { C::execution_expected_tag_reg_0_,
static_cast<uint8_t
>(
MemoryTag::U8) },
179 { C::execution_sel_tag_check_reg_1_, 1 },
180 { C::execution_mem_tag_reg_1_,
static_cast<uint8_t
>(
MemoryTag::U16) },
181 { C::execution_expected_tag_reg_1_,
static_cast<uint8_t
>(
MemoryTag::U16) },
183 { C::execution_sel_tag_check_reg_2_, 0 },
184 { C::execution_mem_tag_reg_2_,
static_cast<uint8_t
>(
MemoryTag::FF) },
185 { C::execution_expected_tag_reg_2_,
static_cast<uint8_t
>(
MemoryTag::U8) },
187 { C::execution_batched_tags_diff_inv_reg, 0 },
189 { C::execution_sel_register_read_error, 0 },
193 check_relation<registers>(trace);
196 trace.
set(C::execution_sel_register_read_error, 0, 1);
201TEST(RegistersConstrainingTest, TagCheckSingleFailure)
203 FF batched_tags_diff =
206 TestTraceContainer
trace({
208 { C::execution_sel_read_registers, 1 },
210 { C::execution_sel_tag_check_reg_0_, 1 },
211 { C::execution_mem_tag_reg_0_,
static_cast<uint8_t
>(
MemoryTag::FF) },
212 { C::execution_expected_tag_reg_0_,
static_cast<uint8_t
>(
MemoryTag::U8) },
214 { C::execution_sel_register_read_error, 1 },
215 { C::execution_batched_tags_diff_inv_reg, batched_tags_diff.
invert() },
219 check_relation<registers>(trace);
222 trace.
set(C::execution_sel_register_read_error, 0, 0);
227 trace.
set(C::execution_batched_tags_diff_inv_reg, 0, 0);
232TEST(RegistersConstrainingTest, TagCheckIgnoresFailureWhenNotReading)
234 TestTraceContainer
trace({
236 { C::execution_sel_read_registers, 0 },
238 { C::execution_sel_tag_check_reg_0_, 1 },
239 { C::execution_mem_tag_reg_0_,
static_cast<uint8_t
>(
MemoryTag::FF) },
240 { C::execution_expected_tag_reg_0_,
static_cast<uint8_t
>(
MemoryTag::U8) },
242 { C::execution_sel_register_read_error, 0 },
243 { C::execution_batched_tags_diff_inv_reg, 0 },
246 check_relation<registers>(trace);
249 trace.
set(C::execution_sel_register_read_error, 0, 1);
254TEST(RegistersConstrainingTest, TagCheckMultipleFailures)
256 FF batched_tags_diff =
260 TestTraceContainer
trace({
262 { C::execution_sel_read_registers, 1 },
264 { C::execution_sel_tag_check_reg_0_, 1 },
265 { C::execution_mem_tag_reg_0_,
static_cast<uint8_t
>(
MemoryTag::FF) },
266 { C::execution_expected_tag_reg_0_,
static_cast<uint8_t
>(
MemoryTag::U8) },
268 { C::execution_sel_tag_check_reg_1_, 1 },
269 { C::execution_mem_tag_reg_1_,
static_cast<uint8_t
>(
MemoryTag::U16) },
270 { C::execution_expected_tag_reg_1_,
static_cast<uint8_t
>(
MemoryTag::U32) },
272 { C::execution_sel_tag_check_reg_2_, 1 },
273 { C::execution_mem_tag_reg_2_,
static_cast<uint8_t
>(
MemoryTag::U8) },
274 { C::execution_expected_tag_reg_2_,
static_cast<uint8_t
>(
MemoryTag::U8) },
276 { C::execution_sel_register_read_error, 1 },
277 { C::execution_batched_tags_diff_inv_reg, batched_tags_diff.
invert() },
280 check_relation<registers>(trace);
283 trace.
set(C::execution_sel_register_read_error, 0, 0);
288 trace.
set(C::execution_batched_tags_diff_inv_reg, 0, 0);
#define EXPECT_THROW_WITH_MESSAGE(code, expectedMessageRegex)
static constexpr size_t SR_SEL_OP_REG_EFFECTIVE_1
static constexpr size_t SR_REGISTER_READ_TAG_CHECK
static constexpr size_t SR_SEL_OP_REG_EFFECTIVE_3
static std::string get_subrelation_label(size_t index)
static constexpr size_t SR_SEL_OP_REG_EFFECTIVE_0
static constexpr size_t SR_SEL_OP_REG_EFFECTIVE_2
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()
constexpr field invert() const noexcept