1#include <gmock/gmock.h>
2#include <gtest/gtest.h>
21using tracegen::ExecutionTraceBuilder;
22using tracegen::TestTraceContainer;
30TEST(AddressingConstrainingTest, EmptyRow)
39TEST(AddressingConstrainingTest, BaseAddressGating)
42 TestTraceContainer
trace({ {
45 { C::execution_sel_bytecode_retrieval_success, 1 },
46 { C::execution_sel_instruction_fetching_success, 1 },
53 { C::execution_sel_op_is_address_0_, 1 },
54 { C::execution_sel_op_is_address_1_, 1 },
55 { C::execution_sel_op_is_address_2_, 1 },
56 { C::execution_sel_op_is_address_3_, 1 },
57 { C::execution_sel_op_is_address_4_, 0 },
58 { C::execution_sel_op_is_address_5_, 0 },
59 { C::execution_sel_op_is_address_6_, 0 },
61 { C::execution_sel_op_is_relative_wire_0_, 1 },
62 { C::execution_sel_op_is_relative_wire_1_, 0 },
63 { C::execution_sel_op_is_relative_wire_2_, 1 },
64 { C::execution_sel_op_is_relative_wire_3_, 0 },
65 { C::execution_sel_op_is_relative_wire_4_, 1 },
66 { C::execution_sel_op_is_relative_wire_5_, 0 },
67 { C::execution_sel_op_is_relative_wire_6_, 0 },
69 { C::execution_sel_do_base_check, 0 },
72 "NUM_RELATIVE_INV_CHECK");
75 trace.
set(C::execution_num_relative_operands_inv, 0,
FF(2).invert());
77 "NUM_RELATIVE_INV_CHECK");
80 trace.
set(C::execution_sel_do_base_check, 0, 1);
84TEST(AddressingConstrainingTest, BaseAddressTagIsU32)
87 FF base_address_tag_diff_inv = 0;
89 TestTraceContainer
trace({
91 { C::execution_base_address_tag, base_address_tag },
92 { C::execution_base_address_tag_diff_inv, base_address_tag_diff_inv },
93 { C::execution_sel_base_address_failure, 0 },
96 { C::execution_sel_bytecode_retrieval_success, 1 },
97 { C::execution_sel_instruction_fetching_success, 1 },
98 { C::execution_sel_do_base_check, 1 },
105 trace.
set(C::execution_sel_base_address_failure, 0, 1);
107 "BASE_ADDRESS_CHECK");
112 { C::execution_base_address_tag_diff_inv, 44 },
113 { C::execution_sel_base_address_failure, 0 },
118TEST(AddressingConstrainingTest, BaseAddressTagIsNotU32)
120 FF base_address_tag = 1234567;
122 FF base_address_tag_diff_inv =
FF(base_address_tag - u32_tag).invert();
124 TestTraceContainer
trace({
126 { C::execution_base_address_tag, base_address_tag },
127 { C::execution_base_address_tag_diff_inv, base_address_tag_diff_inv },
128 { C::execution_sel_base_address_failure, 1 },
131 { C::execution_sel_bytecode_retrieval_success, 1 },
132 { C::execution_sel_instruction_fetching_success, 1 },
133 { C::execution_sel_do_base_check, 1 },
140 trace.
set(C::execution_sel_base_address_failure, 0, 0);
142 "BASE_ADDRESS_CHECK");
147 { C::execution_base_address_tag_diff_inv, 0 },
148 { C::execution_sel_base_address_failure, 0 },
151 "BASE_ADDRESS_CHECK");
154TEST(AddressingConstrainingTest, BaseAddressTagNoCheckImpliesNoError)
156 FF base_address_tag = 1234567;
158 FF base_address_tag_diff_inv =
FF(base_address_tag - u32_tag).invert();
160 TestTraceContainer
trace({
162 { C::execution_base_address_tag, base_address_tag },
163 { C::execution_base_address_tag_diff_inv, base_address_tag_diff_inv },
164 { C::execution_sel_base_address_failure, 0 },
167 { C::execution_sel_bytecode_retrieval_success, 1 },
168 { C::execution_sel_instruction_fetching_success, 1 },
169 { C::execution_sel_do_base_check, 0 },
176 trace.
set(C::execution_sel_base_address_failure, 0, 1);
178 "BASE_ADDRESS_CHECK");
185 { C::execution_sel_bytecode_retrieval_success, 0 },
186 { C::execution_sel_instruction_fetching_success, 0 },
188 { C::execution_sel_do_base_check, 1 },
197TEST(AddressingConstrainingTest, RelativeAddressPropagation)
199 FF base_address_val = 100;
201 TestTraceContainer
trace({
203 { C::execution_base_address_val, base_address_val },
204 { C::execution_sel_base_address_failure, 0 },
206 { C::execution_op_0_, 123 },
207 { C::execution_op_1_, 456 },
208 { C::execution_op_2_, 0xFFFFFFFF },
209 { C::execution_op_3_, 101112 },
210 { C::execution_op_4_, 131415 },
211 { C::execution_op_5_, 161718 },
212 { C::execution_op_6_, 192021 },
214 { C::execution_op_after_relative_0_,
FF(123) + base_address_val },
215 { C::execution_op_after_relative_1_, 456 },
216 { C::execution_op_after_relative_2_,
FF(0xFFFFFFFF) + base_address_val },
217 { C::execution_op_after_relative_3_, 101112 },
218 { C::execution_op_after_relative_4_,
FF(131415) + base_address_val },
219 { C::execution_op_after_relative_5_, 161718 },
220 { C::execution_op_after_relative_6_,
FF(192021) + base_address_val },
222 { C::execution_sel_op_is_address_0_, 1 },
223 { C::execution_sel_op_is_address_1_, 1 },
224 { C::execution_sel_op_is_address_2_, 1 },
225 { C::execution_sel_op_is_address_3_, 1 },
226 { C::execution_sel_op_is_address_4_, 1 },
227 { C::execution_sel_op_is_address_5_, 1 },
228 { C::execution_sel_op_is_address_6_, 1 },
230 { C::execution_sel_op_is_relative_wire_0_, 1 },
231 { C::execution_sel_op_is_relative_wire_1_, 0 },
232 { C::execution_sel_op_is_relative_wire_2_, 1 },
233 { C::execution_sel_op_is_relative_wire_3_, 0 },
234 { C::execution_sel_op_is_relative_wire_4_, 1 },
235 { C::execution_sel_op_is_relative_wire_5_, 0 },
236 { C::execution_sel_op_is_relative_wire_6_, 1 },
240 check_relation<addressing>(
trace,
252 { C::execution_op_after_relative_0_, 7 },
253 { C::execution_op_after_relative_1_,
FF(456) + base_address_val },
254 { C::execution_op_after_relative_2_, 0xFFFFFFFF },
255 { C::execution_op_after_relative_3_, 7 },
256 { C::execution_op_after_relative_4_, 7 },
257 { C::execution_op_after_relative_5_,
FF(161718) + base_address_val },
258 { C::execution_op_after_relative_6_, 192021 },
261 "RELATIVE_RESOLUTION_0");
263 "RELATIVE_RESOLUTION_1");
265 "RELATIVE_RESOLUTION_2");
267 "RELATIVE_RESOLUTION_3");
269 "RELATIVE_RESOLUTION_4");
271 "RELATIVE_RESOLUTION_5");
273 "RELATIVE_RESOLUTION_6");
276TEST(AddressingConstrainingTest, RelativeAddressPropagationWhenBaseAddressIsInvalid)
278 FF base_address_val = 0x123456789012345ULL;
280 TestTraceContainer
trace({
282 { C::execution_base_address_val, base_address_val },
283 { C::execution_sel_base_address_failure, 1 },
285 { C::execution_op_0_, 123 },
286 { C::execution_op_1_, 456 },
287 { C::execution_op_2_, 0xFFFFFFFF },
288 { C::execution_op_3_, 101112 },
289 { C::execution_op_4_, 131415 },
290 { C::execution_op_5_, 161718 },
291 { C::execution_op_6_, 192021 },
293 { C::execution_op_after_relative_0_, 123 },
294 { C::execution_op_after_relative_1_, 456 },
295 { C::execution_op_after_relative_2_, 0xFFFFFFFF },
296 { C::execution_op_after_relative_3_, 101112 },
297 { C::execution_op_after_relative_4_, 131415 },
298 { C::execution_op_after_relative_5_, 161718 },
299 { C::execution_op_after_relative_6_, 192021 },
301 { C::execution_sel_op_is_address_0_, 1 },
302 { C::execution_sel_op_is_address_1_, 1 },
303 { C::execution_sel_op_is_address_2_, 1 },
304 { C::execution_sel_op_is_address_3_, 1 },
305 { C::execution_sel_op_is_address_4_, 1 },
306 { C::execution_sel_op_is_address_5_, 1 },
307 { C::execution_sel_op_is_address_6_, 1 },
309 { C::execution_sel_op_is_relative_wire_0_, 1 },
310 { C::execution_sel_op_is_relative_wire_1_, 0 },
311 { C::execution_sel_op_is_relative_wire_2_, 1 },
312 { C::execution_sel_op_is_relative_wire_3_, 0 },
313 { C::execution_sel_op_is_relative_wire_4_, 1 },
314 { C::execution_sel_op_is_relative_wire_5_, 0 },
315 { C::execution_sel_op_is_relative_wire_6_, 1 },
317 { C::execution_sel_bytecode_retrieval_success, 1 },
318 { C::execution_sel_instruction_fetching_success, 1 },
322 check_relation<addressing>(
trace,
332 trace.
set(C::execution_op_after_relative_0_, 0,
FF(123) + base_address_val);
334 "RELATIVE_RESOLUTION_0");
337TEST(AddressingConstrainingTest, RelativeOverflowCheck)
339 FF base_address_val = 100;
342 FF(123) + base_address_val,
FF(456),
FF(0xFFFFFFFF) + base_address_val,
FF(101112),
343 FF(131415) + base_address_val,
FF(161718),
FF(192021) + base_address_val,
346 TestTraceContainer
trace({
349 { C::execution_sel_op_is_relative_wire_0_, 1 },
350 { C::execution_sel_op_is_relative_wire_2_, 1 },
351 { C::execution_sel_op_is_relative_wire_4_, 1 },
352 { C::execution_sel_op_is_relative_wire_6_, 1 },
353 { C::execution_sel_op_is_address_0_, 1 },
354 { C::execution_sel_op_is_address_2_, 1 },
355 { C::execution_sel_op_is_address_4_, 1 },
356 { C::execution_sel_op_is_address_6_, 1 },
357 { C::execution_sel_op_do_overflow_check_0_, 1 },
358 { C::execution_sel_op_do_overflow_check_2_, 1 },
359 { C::execution_sel_op_do_overflow_check_4_, 1 },
360 { C::execution_sel_op_do_overflow_check_6_, 1 },
362 { C::execution_op_after_relative_0_, resolved_addrs[0] },
363 { C::execution_op_after_relative_1_, resolved_addrs[1] },
364 { C::execution_op_after_relative_2_, resolved_addrs[2] },
365 { C::execution_op_after_relative_3_, resolved_addrs[3] },
366 { C::execution_op_after_relative_4_, resolved_addrs[4] },
367 { C::execution_op_after_relative_5_, resolved_addrs[5] },
368 { C::execution_op_after_relative_6_, resolved_addrs[6] },
370 { C::execution_sel_relative_overflow_0_, 0 },
371 { C::execution_sel_relative_overflow_1_, 0 },
372 { C::execution_sel_relative_overflow_2_, 1 },
373 { C::execution_sel_relative_overflow_3_, 0 },
374 { C::execution_sel_relative_overflow_4_, 0 },
375 { C::execution_sel_relative_overflow_5_, 0 },
376 { C::execution_sel_relative_overflow_6_, 0 },
383 for (uint32_t i = 0; i < 7; i++) {
385 trace.
set(C::gt_input_a, i, resolved_addrs[i]);
390 check_relation<addressing>(
trace,
412 { C::execution_sel_relative_overflow_0_, 1 },
413 { C::execution_sel_relative_overflow_1_, 1 },
414 { C::execution_sel_relative_overflow_2_, 0 },
415 { C::execution_sel_relative_overflow_3_, 1 },
416 { C::execution_sel_relative_overflow_4_, 1 },
417 { C::execution_sel_relative_overflow_5_, 1 },
418 { C::execution_sel_relative_overflow_6_, 1 },
422 (check_interaction<ExecutionTraceBuilder, lookup_addressing_relative_overflow_result_0_settings>(
trace)),
423 "Failed.*LOOKUP_ADDRESSING_RELATIVE_OVERFLOW_RESULT_0.*Could not find tuple in destination.");
426 "NOT_RELATIVE_OR_BASE_FAILURE_NO_OVERFLOW_1");
428 (check_interaction<ExecutionTraceBuilder, lookup_addressing_relative_overflow_result_2_settings>(
trace)),
429 "Failed.*LOOKUP_ADDRESSING_RELATIVE_OVERFLOW_RESULT_2.*Could not find tuple in destination.");
432 "NOT_RELATIVE_OR_BASE_FAILURE_NO_OVERFLOW_3");
434 (check_interaction<ExecutionTraceBuilder, lookup_addressing_relative_overflow_result_4_settings>(
trace)),
435 "Failed.*LOOKUP_ADDRESSING_RELATIVE_OVERFLOW_RESULT_4.*Could not find tuple in destination.");
438 "NOT_RELATIVE_OR_BASE_FAILURE_NO_OVERFLOW_5");
440 (check_interaction<ExecutionTraceBuilder, lookup_addressing_relative_overflow_result_6_settings>(
trace)),
441 "Failed.*LOOKUP_ADDRESSING_RELATIVE_OVERFLOW_RESULT_6.*Could not find tuple in destination.");
448TEST(AddressingConstrainingTest, IndirectReconstruction)
450 TestTraceContainer
trace({
452 { C::execution_indirect, 0b11'00'01'00'01'11'01'01 },
453 { C::execution_sel_op_is_indirect_wire_0_, 1 },
454 { C::execution_sel_op_is_relative_wire_0_, 0 },
455 { C::execution_sel_op_is_indirect_wire_1_, 1 },
456 { C::execution_sel_op_is_relative_wire_1_, 0 },
457 { C::execution_sel_op_is_indirect_wire_2_, 1 },
458 { C::execution_sel_op_is_relative_wire_2_, 1 },
459 { C::execution_sel_op_is_indirect_wire_3_, 1 },
460 { C::execution_sel_op_is_relative_wire_3_, 0 },
461 { C::execution_sel_op_is_indirect_wire_4_, 0 },
462 { C::execution_sel_op_is_relative_wire_4_, 0 },
463 { C::execution_sel_op_is_indirect_wire_5_, 1 },
464 { C::execution_sel_op_is_relative_wire_5_, 0 },
465 { C::execution_sel_op_is_indirect_wire_6_, 0 },
466 { C::execution_sel_op_is_relative_wire_6_, 0 },
467 { C::execution_sel_op_is_relative_wire_7_, 1 },
468 { C::execution_sel_op_is_indirect_wire_7_, 1 },
470 { C::execution_sel_bytecode_retrieval_success, 1 },
471 { C::execution_sel_instruction_fetching_success, 1 },
478TEST(AddressingConstrainingTest, IndirectReconstructionZeroWhenAddressingDisabled)
480 TestTraceContainer
trace({
482 { C::execution_indirect, 123456 },
486 { C::execution_sel_bytecode_retrieval_success, 0 },
487 { C::execution_sel_instruction_fetching_success, 0 },
495 C::execution_sel_op_is_indirect_wire_0_, C::execution_sel_op_is_relative_wire_0_,
496 C::execution_sel_op_is_indirect_wire_1_, C::execution_sel_op_is_relative_wire_1_,
497 C::execution_sel_op_is_indirect_wire_2_, C::execution_sel_op_is_relative_wire_2_,
498 C::execution_sel_op_is_indirect_wire_3_, C::execution_sel_op_is_relative_wire_3_,
499 C::execution_sel_op_is_indirect_wire_4_, C::execution_sel_op_is_relative_wire_4_,
500 C::execution_sel_op_is_indirect_wire_5_, C::execution_sel_op_is_relative_wire_5_,
501 C::execution_sel_op_is_indirect_wire_6_, C::execution_sel_op_is_relative_wire_6_,
502 C::execution_sel_op_is_relative_wire_7_, C::execution_sel_op_is_indirect_wire_7_
504 for (
Column sel_on : decomposition_columns) {
506 for (
Column c : decomposition_columns) {
512 "INDIRECT_RECONSTRUCTION");
516TEST(AddressingConstrainingTest, IndirectGating)
518 TestTraceContainer
trace({
522 { C::execution_sel_bytecode_retrieval_success, 1 },
523 { C::execution_sel_instruction_fetching_success, 1 },
525 { C::execution_sel_op_is_indirect_wire_0_, 0 },
526 { C::execution_sel_op_is_indirect_wire_1_, 1 },
527 { C::execution_sel_op_is_indirect_wire_2_, 0 },
528 { C::execution_sel_op_is_indirect_wire_3_, 1 },
529 { C::execution_sel_op_is_indirect_wire_4_, 0 },
530 { C::execution_sel_op_is_indirect_wire_5_, 1 },
531 { C::execution_sel_op_is_indirect_wire_6_, 1 },
533 { C::execution_sel_op_is_address_0_, 1 },
534 { C::execution_sel_op_is_address_1_, 1 },
535 { C::execution_sel_op_is_address_2_, 1 },
536 { C::execution_sel_op_is_address_3_, 1 },
537 { C::execution_sel_op_is_address_4_, 1 },
538 { C::execution_sel_op_is_address_5_, 1 },
539 { C::execution_sel_op_is_address_6_, 0 },
541 { C::execution_sel_relative_overflow_0_, 0 },
542 { C::execution_sel_relative_overflow_1_, 0 },
543 { C::execution_sel_relative_overflow_2_, 1 },
544 { C::execution_sel_relative_overflow_3_, 1 },
545 { C::execution_sel_relative_overflow_4_, 0 },
546 { C::execution_sel_relative_overflow_5_, 0 },
547 { C::execution_sel_relative_overflow_6_, 0 },
549 { C::execution_sel_should_apply_indirection_0_, 0 },
550 { C::execution_sel_should_apply_indirection_1_, 1 },
551 { C::execution_sel_should_apply_indirection_2_, 0 },
552 { C::execution_sel_should_apply_indirection_3_, 0 },
553 { C::execution_sel_should_apply_indirection_4_, 0 },
554 { C::execution_sel_should_apply_indirection_5_, 1 },
555 { C::execution_sel_should_apply_indirection_6_, 0 },
559 check_relation<addressing>(
trace,
572 { C::execution_sel_should_apply_indirection_0_, 1 },
573 { C::execution_sel_should_apply_indirection_1_, 0 },
574 { C::execution_sel_should_apply_indirection_2_, 1 },
575 { C::execution_sel_should_apply_indirection_3_, 1 },
576 { C::execution_sel_should_apply_indirection_4_, 1 },
577 { C::execution_sel_should_apply_indirection_5_, 0 },
578 { C::execution_sel_should_apply_indirection_6_, 1 },
590 trace.
set(C::execution_sel_bytecode_retrieval_success, 0, 0);
591 trace.
set(C::execution_sel_instruction_fetching_success, 0, 0);
601TEST(AddressingConstrainingTest, IndirectGatingIfBaseAddressIsInvalid)
603 TestTraceContainer
trace({
607 { C::execution_sel_bytecode_retrieval_success, 1 },
608 { C::execution_sel_instruction_fetching_success, 1 },
610 { C::execution_sel_base_address_failure, 1 },
612 { C::execution_sel_op_is_indirect_wire_0_, 0 },
613 { C::execution_sel_op_is_indirect_wire_1_, 1 },
614 { C::execution_sel_op_is_indirect_wire_2_, 0 },
615 { C::execution_sel_op_is_indirect_wire_3_, 1 },
616 { C::execution_sel_op_is_indirect_wire_4_, 0 },
617 { C::execution_sel_op_is_indirect_wire_5_, 1 },
618 { C::execution_sel_op_is_indirect_wire_6_, 1 },
620 { C::execution_sel_op_is_address_0_, 1 },
621 { C::execution_sel_op_is_address_1_, 1 },
622 { C::execution_sel_op_is_address_2_, 1 },
623 { C::execution_sel_op_is_address_3_, 1 },
624 { C::execution_sel_op_is_address_4_, 1 },
625 { C::execution_sel_op_is_address_5_, 1 },
626 { C::execution_sel_op_is_address_6_, 0 },
628 { C::execution_sel_relative_overflow_0_, 0 },
629 { C::execution_sel_relative_overflow_1_, 0 },
630 { C::execution_sel_relative_overflow_2_, 1 },
631 { C::execution_sel_relative_overflow_3_, 1 },
632 { C::execution_sel_relative_overflow_4_, 0 },
633 { C::execution_sel_relative_overflow_5_, 0 },
634 { C::execution_sel_relative_overflow_6_, 0 },
636 { C::execution_sel_should_apply_indirection_0_, 0 },
637 { C::execution_sel_should_apply_indirection_1_, 0 },
638 { C::execution_sel_should_apply_indirection_2_, 0 },
639 { C::execution_sel_should_apply_indirection_3_, 0 },
640 { C::execution_sel_should_apply_indirection_4_, 0 },
641 { C::execution_sel_should_apply_indirection_5_, 0 },
642 { C::execution_sel_should_apply_indirection_6_, 0 },
646 check_relation<addressing>(
trace,
659 { C::execution_sel_should_apply_indirection_0_, 1 },
660 { C::execution_sel_should_apply_indirection_1_, 1 },
661 { C::execution_sel_should_apply_indirection_2_, 1 },
662 { C::execution_sel_should_apply_indirection_3_, 1 },
663 { C::execution_sel_should_apply_indirection_4_, 1 },
664 { C::execution_sel_should_apply_indirection_5_, 1 },
665 { C::execution_sel_should_apply_indirection_6_, 1 },
676TEST(AddressingConstrainingTest, IndirectPropagationWhenNoIndirection)
680 TestTraceContainer
trace({
682 { C::execution_sel_should_apply_indirection_0_, 0 },
683 { C::execution_sel_should_apply_indirection_1_, 1 },
684 { C::execution_sel_should_apply_indirection_2_, 0 },
685 { C::execution_sel_should_apply_indirection_3_, 1 },
686 { C::execution_sel_should_apply_indirection_4_, 0 },
687 { C::execution_sel_should_apply_indirection_5_, 1 },
688 { C::execution_sel_should_apply_indirection_6_, 0 },
690 { C::execution_op_after_relative_0_, 123 },
691 { C::execution_op_after_relative_1_, 456 },
692 { C::execution_op_after_relative_2_, 789 },
693 { C::execution_op_after_relative_3_, 101112 },
694 { C::execution_op_after_relative_4_, 131415 },
695 { C::execution_op_after_relative_5_, 161718 },
696 { C::execution_op_after_relative_6_, 192021 },
698 { C::execution_rop_0_, 123 },
699 { C::execution_rop_1_, 99001 },
700 { C::execution_rop_2_, 789 },
701 { C::execution_rop_3_, 99002 },
702 { C::execution_rop_4_, 131415 },
703 { C::execution_rop_5_, 99003 },
704 { C::execution_rop_6_, 192021 },
707 { C::execution_sel_bytecode_retrieval_success, 1 },
708 { C::execution_sel_instruction_fetching_success, 1 },
712 check_relation<addressing>(
trace,
722 trace.
set(C::execution_sel_bytecode_retrieval_success, 0, 0);
723 trace.
set(C::execution_sel_instruction_fetching_success, 0, 0);
724 check_relation<addressing>(
trace,
736 { C::execution_rop_0_, 7 },
737 { C::execution_rop_2_, 7 },
738 { C::execution_rop_4_, 7 },
739 { C::execution_rop_6_, 7 },
742 "INDIRECT_PROPAGATION_0");
744 "INDIRECT_PROPAGATION_2");
746 "INDIRECT_PROPAGATION_4");
748 "INDIRECT_PROPAGATION_6");
751TEST(AddressingConstrainingTest, IndirectPropagationWhenIndirection)
760TEST(AddressingConstrainingTest, FinalCheckNoFailure)
766 auto get_tag_diff_inv = [&]() {
767 FF batched_tags_diff = 0;
771 should_apply_indirection[i] * power_of_2 * (
FF(
static_cast<uint8_t
>(rop_tag[i])) -
FF(
MEM_TAG_U32));
774 return batched_tags_diff != 0 ? batched_tags_diff.invert() : 0;
777 TestTraceContainer
trace({
780 { C::execution_sel_should_apply_indirection_0_, should_apply_indirection[0] },
781 { C::execution_sel_should_apply_indirection_1_, should_apply_indirection[1] },
782 { C::execution_sel_should_apply_indirection_2_, should_apply_indirection[2] },
783 { C::execution_sel_should_apply_indirection_3_, should_apply_indirection[3] },
784 { C::execution_sel_should_apply_indirection_4_, should_apply_indirection[4] },
785 { C::execution_sel_should_apply_indirection_5_, should_apply_indirection[5] },
786 { C::execution_sel_should_apply_indirection_6_, should_apply_indirection[6] },
788 { C::execution_rop_tag_0_,
static_cast<uint8_t
>(rop_tag[0]) },
789 { C::execution_rop_tag_1_,
static_cast<uint8_t
>(rop_tag[1]) },
790 { C::execution_rop_tag_2_,
static_cast<uint8_t
>(rop_tag[2]) },
791 { C::execution_rop_tag_3_,
static_cast<uint8_t
>(rop_tag[3]) },
792 { C::execution_rop_tag_4_,
static_cast<uint8_t
>(rop_tag[4]) },
793 { C::execution_rop_tag_5_,
static_cast<uint8_t
>(rop_tag[5]) },
794 { C::execution_rop_tag_6_,
static_cast<uint8_t
>(rop_tag[6]) },
797 { C::execution_batched_tags_diff_inv, get_tag_diff_inv() },
798 { C::execution_sel_some_final_check_failed, 0 },
805 trace.
set(C::execution_sel_some_final_check_failed, 0, 1);
807 "BATCHED_TAGS_DIFF_CHECK");
810TEST(AddressingConstrainingTest, FinalCheckSingleFailure)
816 auto get_tag_diff_inv = [&]() {
817 FF batched_tags_diff = 0;
821 should_apply_indirection[i] * power_of_2 * (
FF(
static_cast<uint8_t
>(rop_tag[i])) -
FF(
MEM_TAG_U32));
824 return batched_tags_diff != 0 ? batched_tags_diff.invert() : 0;
827 TestTraceContainer
trace({
830 { C::execution_sel_should_apply_indirection_0_, should_apply_indirection[0] },
831 { C::execution_sel_should_apply_indirection_1_, should_apply_indirection[1] },
832 { C::execution_sel_should_apply_indirection_2_, should_apply_indirection[2] },
833 { C::execution_sel_should_apply_indirection_3_, should_apply_indirection[3] },
834 { C::execution_sel_should_apply_indirection_4_, should_apply_indirection[4] },
835 { C::execution_sel_should_apply_indirection_5_, should_apply_indirection[5] },
836 { C::execution_sel_should_apply_indirection_6_, should_apply_indirection[6] },
838 { C::execution_rop_tag_0_,
static_cast<uint8_t
>(rop_tag[0]) },
839 { C::execution_rop_tag_1_,
static_cast<uint8_t
>(rop_tag[1]) },
840 { C::execution_rop_tag_2_,
static_cast<uint8_t
>(rop_tag[2]) },
841 { C::execution_rop_tag_3_,
static_cast<uint8_t
>(rop_tag[3]) },
842 { C::execution_rop_tag_4_,
static_cast<uint8_t
>(rop_tag[4]) },
843 { C::execution_rop_tag_5_,
static_cast<uint8_t
>(rop_tag[5]) },
844 { C::execution_rop_tag_6_,
static_cast<uint8_t
>(rop_tag[6]) },
847 { C::execution_batched_tags_diff_inv, get_tag_diff_inv() },
848 { C::execution_sel_some_final_check_failed, 1 },
855 trace.
set(C::execution_sel_some_final_check_failed, 0, 0);
857 "BATCHED_TAGS_DIFF_CHECK");
858 trace.
set(C::execution_batched_tags_diff_inv, 0, 0);
860 "BATCHED_TAGS_DIFF_CHECK");
863TEST(AddressingConstrainingTest, FinalCheckMultipleFailures)
869 auto get_tag_diff_inv = [&]() {
870 FF batched_tags_diff = 0;
874 should_apply_indirection[i] * power_of_2 * (
FF(
static_cast<uint8_t
>(rop_tag[i])) -
FF(
MEM_TAG_U32));
877 return batched_tags_diff != 0 ? batched_tags_diff.invert() : 0;
880 TestTraceContainer
trace({
883 { C::execution_sel_should_apply_indirection_0_, should_apply_indirection[0] },
884 { C::execution_sel_should_apply_indirection_1_, should_apply_indirection[1] },
885 { C::execution_sel_should_apply_indirection_2_, should_apply_indirection[2] },
886 { C::execution_sel_should_apply_indirection_3_, should_apply_indirection[3] },
887 { C::execution_sel_should_apply_indirection_4_, should_apply_indirection[4] },
888 { C::execution_sel_should_apply_indirection_5_, should_apply_indirection[5] },
889 { C::execution_sel_should_apply_indirection_6_, should_apply_indirection[6] },
891 { C::execution_rop_tag_0_,
static_cast<uint8_t
>(rop_tag[0]) },
892 { C::execution_rop_tag_1_,
static_cast<uint8_t
>(rop_tag[1]) },
893 { C::execution_rop_tag_2_,
static_cast<uint8_t
>(rop_tag[2]) },
894 { C::execution_rop_tag_3_,
static_cast<uint8_t
>(rop_tag[3]) },
895 { C::execution_rop_tag_4_,
static_cast<uint8_t
>(rop_tag[4]) },
896 { C::execution_rop_tag_5_,
static_cast<uint8_t
>(rop_tag[5]) },
897 { C::execution_rop_tag_6_,
static_cast<uint8_t
>(rop_tag[6]) },
900 { C::execution_batched_tags_diff_inv, get_tag_diff_inv() },
901 { C::execution_sel_some_final_check_failed, 1 },
908 trace.
set(C::execution_sel_some_final_check_failed, 0, 0);
910 "BATCHED_TAGS_DIFF_CHECK");
911 trace.
set(C::execution_batched_tags_diff_inv, 0, 0);
913 "BATCHED_TAGS_DIFF_CHECK");
#define AVM_HIGHEST_MEM_ADDRESS
static constexpr size_t SR_RELATIVE_RESOLUTION_4
static constexpr size_t SR_NOT_RELATIVE_OR_BASE_FAILURE_NO_OVERFLOW_6
static constexpr size_t SR_INDIRECT_PROPAGATION_4
static constexpr size_t SR_NOT_RELATIVE_OR_BASE_FAILURE_NO_OVERFLOW_5
static constexpr size_t SR_INDIRECT_RECONSTRUCTION
static constexpr size_t SR_BATCHED_TAGS_DIFF_CHECK
static constexpr size_t SR_INDIRECT_PROPAGATION_0
static constexpr size_t SR_INDIRECT_PROPAGATION_2
static constexpr size_t SR_RELATIVE_RESOLUTION_5
static constexpr size_t SR_NOT_RELATIVE_OR_BASE_FAILURE_NO_OVERFLOW_2
static constexpr size_t SR_INDIRECT_GATING_5
static constexpr size_t SR_RELATIVE_RESOLUTION_3
static constexpr size_t SR_BASE_ADDRESS_CHECK
static constexpr size_t SR_INDIRECT_GATING_6
static constexpr size_t SR_RELATIVE_RESOLUTION_2
static constexpr size_t SR_INDIRECT_GATING_0
static constexpr size_t SR_INDIRECT_GATING_3
static constexpr size_t SR_INDIRECT_PROPAGATION_6
static constexpr size_t SR_NOT_RELATIVE_OR_BASE_FAILURE_NO_OVERFLOW_3
static constexpr size_t SR_NOT_RELATIVE_OR_BASE_FAILURE_NO_OVERFLOW_1
static constexpr size_t SR_RELATIVE_RESOLUTION_0
static constexpr size_t SR_RELATIVE_RESOLUTION_6
static constexpr size_t SR_INDIRECT_GATING_2
static constexpr size_t SR_INDIRECT_PROPAGATION_5
static constexpr size_t SR_INDIRECT_PROPAGATION_1
static constexpr size_t SR_INDIRECT_PROPAGATION_3
static constexpr size_t SR_INDIRECT_GATING_4
static constexpr size_t SR_NOT_RELATIVE_OR_BASE_FAILURE_NO_OVERFLOW_4
static constexpr size_t SR_INDIRECT_GATING_1
static constexpr size_t SR_NOT_RELATIVE_OR_BASE_FAILURE_NO_OVERFLOW_0
static constexpr size_t SR_RELATIVE_RESOLUTION_1
static constexpr size_t SR_NUM_RELATIVE_INV_CHECK
void set(Column col, uint32_t row, const FF &value)
#define EXPECT_THROW_WITH_MESSAGE(code, expectedMessage)
void check_interaction(tracegen::TestTraceContainer &trace)
TEST(TxExecutionConstrainingTest, WriteTreeValue)
TestTraceContainer empty_trace()
lookup_settings< lookup_addressing_relative_overflow_result_1_settings_ > lookup_addressing_relative_overflow_result_1_settings
lookup_settings< lookup_addressing_relative_overflow_result_2_settings_ > lookup_addressing_relative_overflow_result_2_settings
lookup_settings< lookup_addressing_relative_overflow_result_4_settings_ > lookup_addressing_relative_overflow_result_4_settings
lookup_settings< lookup_addressing_relative_overflow_result_5_settings_ > lookup_addressing_relative_overflow_result_5_settings
lookup_settings< lookup_addressing_relative_overflow_result_0_settings_ > lookup_addressing_relative_overflow_result_0_settings
lookup_settings< lookup_addressing_relative_overflow_result_6_settings_ > lookup_addressing_relative_overflow_result_6_settings
lookup_settings< lookup_addressing_relative_overflow_result_3_settings_ > lookup_addressing_relative_overflow_result_3_settings
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
unsigned __int128 uint128_t