1#include <gmock/gmock.h>
2#include <gtest/gtest.h>
19using tracegen::TestTraceContainer;
24TEST(ContextConstrainingTest, EmptyRow)
30TEST(ContextConstrainingTest, ContextSwitchingCallReturn)
32 constexpr uint32_t top_bytecode_id = 0x12345678;
33 constexpr uint32_t nested_bytecode_id = 0x456789ab;
35 TestTraceContainer
trace(
37 { C::execution_next_context_id, 0 },
38 { C::precomputed_first_row, 1 },
40 { C::context_stack_sel, 1 },
41 { C::context_stack_entered_context_id, 2 },
42 { C::context_stack_context_id, 1 },
43 { C::context_stack_parent_id, 0 },
44 { C::context_stack_next_pc, 2 },
45 { C::context_stack_msg_sender, 0 },
46 { C::context_stack_contract_address, 0 },
47 { C::context_stack_bytecode_id, top_bytecode_id },
48 { C::context_stack_is_static, 0 },
49 { C::context_stack_parent_calldata_addr, 0 },
50 { C::context_stack_parent_calldata_size, 0 },
51 { C::context_stack_parent_l2_gas_limit, 2000 },
52 { C::context_stack_parent_da_gas_limit, 4000 },
53 { C::context_stack_parent_l2_gas_used, 500 },
54 { C::context_stack_parent_da_gas_used, 1500 },
58 { C::execution_sel, 1 },
59 { C::execution_pc, 0 },
60 { C::execution_next_pc, 1 },
61 { C::execution_context_id, 1 },
62 { C::execution_next_context_id, 2 },
63 { C::execution_bytecode_id, top_bytecode_id },
64 { C::execution_is_static, 0 },
65 { C::execution_parent_l2_gas_limit, 2000 },
66 { C::execution_parent_da_gas_limit, 4000 },
67 { C::execution_parent_l2_gas_used, 500 },
68 { C::execution_parent_da_gas_used, 1500 },
69 { C::execution_enqueued_call_start, 1 },
73 { C::execution_sel, 1 },
74 { C::execution_pc, 1 },
75 { C::execution_next_pc, 2 },
76 { C::execution_sel_execute_call, 1 },
77 { C::execution_sel_execute_static_call, 0 },
78 { C::execution_sel_enter_call, 1 },
79 { C::execution_context_id, 1 },
80 { C::execution_next_context_id, 2 },
81 { C::execution_bytecode_id, top_bytecode_id },
82 { C::execution_is_static, 0 },
83 { C::execution_rop_4_, 10 },
84 { C::execution_register_2_, 0xdeadbeef },
85 { C::execution_register_3_, 1 },
86 { C::execution_parent_l2_gas_limit, 2000 },
87 { C::execution_parent_da_gas_limit, 4000 },
88 { C::execution_parent_l2_gas_used, 500 },
89 { C::execution_parent_da_gas_used, 1500 },
93 { C::execution_sel, 1 },
94 { C::execution_pc, 0 },
95 { C::execution_next_pc, 20 },
96 { C::execution_context_id, 2 },
97 { C::execution_next_context_id, 3 },
98 { C::execution_parent_id, 1 },
99 { C::execution_is_parent_id_inv, 1 },
100 { C::execution_has_parent_ctx, 1 },
101 { C::execution_contract_address, 0xdeadbeef },
102 { C::execution_bytecode_id, nested_bytecode_id },
103 { C::execution_is_static, 0 },
104 { C::execution_parent_calldata_addr, 10 },
105 { C::execution_parent_calldata_size, 1 },
109 { C::execution_sel, 1 },
110 { C::execution_pc, 20 },
111 { C::execution_next_pc, 30 },
112 { C::execution_sel_execute_return, 1 },
113 { C::execution_rop_0_, 500 },
114 { C::execution_rop_1_, 600 },
115 { C::execution_register_0_, 200 },
116 { C::execution_sel_exit_call, 1 },
117 { C::execution_nested_exit_call, 1 },
118 { C::execution_nested_return, 1 },
119 { C::execution_context_id, 2 },
120 { C::execution_next_context_id, 3 },
121 { C::execution_parent_id, 1 },
122 { C::execution_is_parent_id_inv, 1 },
123 { C::execution_has_parent_ctx, 1 },
124 { C::execution_contract_address, 0xdeadbeef },
125 { C::execution_bytecode_id, nested_bytecode_id },
126 { C::execution_parent_calldata_addr, 10 },
127 { C::execution_parent_calldata_size, 1 },
130 { C::execution_sel, 1 },
131 { C::execution_next_context_id, 3 },
132 { C::execution_context_id, 1 },
133 { C::execution_parent_id, 0 },
134 { C::execution_last_child_id, 2 },
135 { C::execution_pc, 2 },
136 { C::execution_msg_sender, 0 },
137 { C::execution_contract_address, 0 },
138 { C::execution_bytecode_id, top_bytecode_id },
139 { C::execution_is_static, 0 },
140 { C::execution_parent_calldata_addr, 0 },
141 { C::execution_parent_calldata_size, 0 },
142 { C::execution_last_child_returndata_size, 200 },
143 { C::execution_last_child_returndata_addr, 600 },
144 { C::execution_last_child_success, 1 },
145 { C::execution_parent_l2_gas_limit, 2000 },
146 { C::execution_parent_da_gas_limit, 4000 },
147 { C::execution_parent_l2_gas_used, 500 },
148 { C::execution_parent_da_gas_used, 1500 },
151 { C::execution_sel, 0 },
154 check_relation<context>(trace);
162TEST(ContextConstrainingTest, ContextSwitchingExceptionalHalt)
164 constexpr uint32_t top_bytecode_id = 0x12345678;
165 constexpr uint32_t nested_bytecode_id = 0x456789ab;
167 TestTraceContainer
trace(
169 { C::execution_next_context_id, 0 },
170 { C::precomputed_first_row, 1 },
172 { C::context_stack_sel, 1 },
173 { C::context_stack_entered_context_id, 2 },
174 { C::context_stack_context_id, 1 },
175 { C::context_stack_parent_id, 0 },
176 { C::context_stack_next_pc, 2 },
177 { C::context_stack_msg_sender, 0 },
178 { C::context_stack_contract_address, 0 },
179 { C::context_stack_bytecode_id, top_bytecode_id },
180 { C::context_stack_is_static, 0 },
181 { C::context_stack_parent_calldata_addr, 0 },
182 { C::context_stack_parent_calldata_size, 0 },
183 { C::context_stack_parent_l2_gas_limit, 2000 },
184 { C::context_stack_parent_da_gas_limit, 4000 },
185 { C::context_stack_parent_l2_gas_used, 500 },
186 { C::context_stack_parent_da_gas_used, 1500 },
190 { C::execution_sel, 1 },
191 { C::execution_pc, 0 },
192 { C::execution_next_pc, 1 },
193 { C::execution_context_id, 1 },
194 { C::execution_next_context_id, 2 },
195 { C::execution_bytecode_id, top_bytecode_id },
196 { C::execution_parent_l2_gas_limit, 2000 },
197 { C::execution_parent_da_gas_limit, 4000 },
198 { C::execution_parent_l2_gas_used, 500 },
199 { C::execution_parent_da_gas_used, 1500 },
200 { C::execution_enqueued_call_start, 1 },
204 { C::execution_sel, 1 },
205 { C::execution_pc, 1 },
206 { C::execution_next_pc, 2 },
207 { C::execution_sel_execute_call, 1 },
208 { C::execution_sel_enter_call, 1 },
209 { C::execution_context_id, 1 },
210 { C::execution_next_context_id, 2 },
211 { C::execution_bytecode_id, top_bytecode_id },
212 { C::execution_rop_4_, 10 },
213 { C::execution_register_2_, 0xdeadbeef },
214 { C::execution_register_3_, 1 },
215 { C::execution_parent_l2_gas_limit, 2000 },
216 { C::execution_parent_da_gas_limit, 4000 },
217 { C::execution_parent_l2_gas_used, 500 },
218 { C::execution_parent_da_gas_used, 1500 },
222 { C::execution_sel, 1 },
223 { C::execution_pc, 0 },
224 { C::execution_next_pc, 20 },
225 { C::execution_context_id, 2 },
226 { C::execution_next_context_id, 3 },
227 { C::execution_parent_id, 1 },
228 { C::execution_is_parent_id_inv, 1 },
229 { C::execution_has_parent_ctx, 1 },
230 { C::execution_contract_address, 0xdeadbeef },
231 { C::execution_bytecode_id, nested_bytecode_id },
232 { C::execution_parent_calldata_addr, 10 },
233 { C::execution_parent_calldata_size, 1 },
237 { C::execution_sel, 1 },
238 { C::execution_pc, 20 },
239 { C::execution_next_pc, 30 },
241 { C::execution_rop_0_, 500 },
242 { C::execution_rop_1_, 600 },
243 { C::execution_register_0_, 200 },
244 { C::execution_sel_exit_call, 1 },
245 { C::execution_nested_exit_call, 1 },
246 { C::execution_sel_error, 1 },
247 { C::execution_sel_failure, 1 },
248 { C::execution_nested_failure, 1 },
249 { C::execution_context_id, 2 },
250 { C::execution_next_context_id, 3 },
251 { C::execution_parent_id, 1 },
252 { C::execution_is_parent_id_inv, 1 },
253 { C::execution_has_parent_ctx, 1 },
254 { C::execution_contract_address, 0xdeadbeef },
255 { C::execution_bytecode_id, nested_bytecode_id },
256 { C::execution_parent_calldata_addr, 10 },
257 { C::execution_parent_calldata_size, 1 },
260 { C::execution_sel, 1 },
261 { C::execution_next_context_id, 3 },
262 { C::execution_context_id, 1 },
263 { C::execution_parent_id, 0 },
264 { C::execution_last_child_id, 2 },
265 { C::execution_pc, 2 },
266 { C::execution_next_pc, 3 },
267 { C::execution_msg_sender, 0 },
268 { C::execution_contract_address, 0 },
269 { C::execution_bytecode_id, top_bytecode_id },
270 { C::execution_is_static, 0 },
271 { C::execution_parent_calldata_addr, 0 },
272 { C::execution_parent_calldata_size, 0 },
273 { C::execution_last_child_returndata_size, 0 },
274 { C::execution_last_child_returndata_addr, 0 },
275 { C::execution_parent_l2_gas_limit, 2000 },
276 { C::execution_parent_da_gas_limit, 4000 },
277 { C::execution_parent_l2_gas_used, 500 },
278 { C::execution_parent_da_gas_used, 1500 },
281 { C::execution_sel, 0 },
284 check_relation<context>(trace);
292TEST(ContextConstrainingTest, GasNextRow)
294 TestTraceContainer
trace({ { { C::precomputed_first_row, 1 } },
297 { C::execution_sel, 1 },
298 { C::execution_l2_gas_limit, 1000 },
299 { C::execution_da_gas_limit, 2000 },
300 { C::execution_parent_l2_gas_limit, 2000 },
301 { C::execution_parent_da_gas_limit, 4000 },
302 { C::execution_parent_l2_gas_used, 500 },
303 { C::execution_parent_da_gas_used, 1500 },
307 { C::execution_sel, 1 },
308 { C::execution_sel_enter_call, 1 },
309 { C::execution_l2_gas_used, 200 },
310 { C::execution_da_gas_used, 300 },
311 { C::execution_l2_gas_limit, 1000 },
312 { C::execution_da_gas_limit, 2000 },
313 { C::execution_parent_l2_gas_limit, 2000 },
314 { C::execution_parent_da_gas_limit, 4000 },
315 { C::execution_parent_l2_gas_used, 500 },
316 { C::execution_parent_da_gas_used, 1500 },
320 { C::execution_sel, 1 },
321 { C::execution_sel_exit_call, 1 },
322 { C::execution_nested_exit_call, 1 },
323 { C::execution_parent_l2_gas_limit, 1000 },
324 { C::execution_parent_da_gas_limit, 2000 },
325 { C::execution_parent_l2_gas_used, 200 },
326 { C::execution_parent_da_gas_used, 300 },
330 { C::execution_sel, 1 },
331 { C::execution_l2_gas_limit, 1000 },
332 { C::execution_da_gas_limit, 2000 },
333 { C::execution_parent_l2_gas_limit, 2000 },
334 { C::execution_parent_da_gas_limit, 4000 },
337 { C::execution_sel, 0 },
340 check_relation<context>(trace,
355 trace.
set(C::execution_l2_gas_limit, 4, 1001);
357 "L2_GAS_LIMIT_RESTORE_ON_EXIT");
358 trace.
set(C::execution_da_gas_limit, 4, 2001);
360 "DA_GAS_LIMIT_RESTORE_ON_EXIT");
363 trace.
set(C::execution_parent_l2_gas_limit, 3, 2001);
365 "PARENT_L2_GAS_LIMIT_STORE_ON_ENTER");
366 trace.
set(C::execution_parent_da_gas_limit, 3, 4001);
368 "PARENT_DA_GAS_LIMIT_STORE_ON_ENTER");
369 trace.
set(C::execution_parent_l2_gas_used, 3, 201);
371 "PARENT_L2_GAS_USED_STORE_ON_ENTER");
372 trace.
set(C::execution_parent_da_gas_used, 3, 301);
374 "PARENT_DA_GAS_USED_STORE_ON_ENTER");
377 trace.
set(C::execution_l2_gas_limit, 2, 1001);
379 "L2_GAS_LIMIT_NEXT_ROW");
380 trace.
set(C::execution_da_gas_limit, 2, 2001);
382 "DA_GAS_LIMIT_NEXT_ROW");
384 trace.
set(C::execution_parent_l2_gas_limit, 2, 2001);
386 "PARENT_L2_GAS_LIMIT_NEXT_ROW");
387 trace.
set(C::execution_parent_da_gas_limit, 2, 4001);
389 "PARENT_DA_GAS_LIMIT_NEXT_ROW");
391 trace.
set(C::execution_parent_l2_gas_used, 2, 501);
393 "PARENT_L2_GAS_USED_NEXT_ROW");
394 trace.
set(C::execution_parent_da_gas_used, 2, 1501);
396 "PARENT_DA_GAS_USED_NEXT_ROW");
399TEST(ContextConstrainingTest, GasUsedContinuity)
401 TestTraceContainer
trace({ { { C::precomputed_first_row, 1 } },
404 { C::execution_sel, 1 },
405 { C::execution_l2_gas_used, 100 },
406 { C::execution_da_gas_used, 200 },
410 { C::execution_sel, 1 },
411 { C::execution_sel_enter_call, 1 },
412 { C::execution_l2_gas_used, 110 },
413 { C::execution_da_gas_used, 200 },
414 { C::execution_prev_l2_gas_used, 100 },
415 { C::execution_prev_da_gas_used, 200 },
419 { C::execution_sel, 1 },
420 { C::execution_sel_exit_call, 1 },
421 { C::execution_nested_exit_call, 1 },
422 { C::execution_l2_gas_used, 50 },
423 { C::execution_da_gas_used, 60 },
424 { C::execution_parent_l2_gas_used, 110 },
425 { C::execution_parent_da_gas_used, 200 },
426 { C::execution_prev_l2_gas_used, 0 },
427 { C::execution_prev_da_gas_used, 0 },
431 { C::execution_sel, 1 },
432 { C::execution_l2_gas_used, 170 },
433 { C::execution_da_gas_used, 260 },
434 { C::execution_prev_l2_gas_used, 160 },
435 { C::execution_prev_da_gas_used, 260 },
438 { C::execution_sel, 0 },
441 check_relation<context>(trace,
450 trace.
set(C::execution_prev_l2_gas_used, 4, 110);
453 "L2_GAS_USED_INGEST_AFTER_EXIT");
455 trace.
set(C::execution_prev_da_gas_used, 4, 60);
457 "DA_GAS_USED_INGEST_AFTER_EXIT");
460 trace.
set(C::execution_prev_l2_gas_used, 3, 110);
462 "L2_GAS_USED_ZERO_AFTER_CALL");
464 trace.
set(C::execution_prev_da_gas_used, 3, 200);
466 "DA_GAS_USED_ZERO_AFTER_CALL");
469 trace.
set(C::execution_prev_l2_gas_used, 2, 0);
471 "L2_GAS_USED_CONTINUITY");
473 trace.
set(C::execution_prev_da_gas_used, 2, 0);
475 "DA_GAS_USED_CONTINUITY");
478TEST(ContextConstrainingTest, TreeStateContinuity)
480 TestTraceContainer
trace({ { { C::precomputed_first_row, 1 } },
483 { C::execution_sel, 1 },
484 { C::execution_note_hash_tree_root, 10 },
485 { C::execution_note_hash_tree_size, 9 },
486 { C::execution_num_note_hashes_emitted, 8 },
487 { C::execution_nullifier_tree_root, 7 },
488 { C::execution_nullifier_tree_size, 6 },
489 { C::execution_num_nullifiers_emitted, 5 },
490 { C::execution_public_data_tree_root, 4 },
491 { C::execution_public_data_tree_size, 3 },
492 { C::execution_written_public_data_slots_tree_root, 2 },
493 { C::execution_written_public_data_slots_tree_size, 1 },
494 { C::execution_l1_l2_tree_root, 27 },
495 { C::execution_retrieved_bytecodes_tree_root, 26 },
496 { C::execution_retrieved_bytecodes_tree_size, 25 },
500 { C::execution_sel, 1 },
501 { C::execution_prev_note_hash_tree_root, 10 },
502 { C::execution_prev_note_hash_tree_size, 9 },
503 { C::execution_prev_num_note_hashes_emitted, 8 },
504 { C::execution_prev_nullifier_tree_root, 7 },
505 { C::execution_prev_nullifier_tree_size, 6 },
506 { C::execution_prev_num_nullifiers_emitted, 5 },
507 { C::execution_prev_public_data_tree_root, 4 },
508 { C::execution_prev_public_data_tree_size, 3 },
509 { C::execution_prev_written_public_data_slots_tree_root, 2 },
510 { C::execution_prev_written_public_data_slots_tree_size, 1 },
511 { C::execution_l1_l2_tree_root, 27 },
512 { C::execution_prev_retrieved_bytecodes_tree_root, 26 },
513 { C::execution_prev_retrieved_bytecodes_tree_size, 25 },
514 { C::execution_enqueued_call_end, 1 },
515 { C::execution_sel_exit_call, 1 },
519 { C::execution_sel, 1 },
520 { C::execution_prev_note_hash_tree_root, 100 },
521 { C::execution_prev_note_hash_tree_size, 90 },
522 { C::execution_prev_num_note_hashes_emitted, 80 },
523 { C::execution_prev_nullifier_tree_root, 70 },
524 { C::execution_prev_nullifier_tree_size, 60 },
525 { C::execution_prev_num_nullifiers_emitted, 50 },
526 { C::execution_prev_public_data_tree_root, 40 },
527 { C::execution_prev_public_data_tree_size, 30 },
528 { C::execution_prev_written_public_data_slots_tree_root, 20 },
529 { C::execution_prev_written_public_data_slots_tree_size, 10 },
530 { C::execution_l1_l2_tree_root, 27 },
531 { C::execution_prev_retrieved_bytecodes_tree_root, 260 },
532 { C::execution_prev_retrieved_bytecodes_tree_size, 250 },
535 check_relation<context>(trace,
551 trace.
set(C::execution_prev_note_hash_tree_root, 2, 100);
553 "NOTE_HASH_TREE_ROOT_CONTINUITY");
556 trace.
set(C::execution_prev_note_hash_tree_size, 2, 100);
558 "NOTE_HASH_TREE_SIZE_CONTINUITY");
561 trace.
set(C::execution_prev_num_note_hashes_emitted, 2, 10);
563 "NUM_NOTE_HASHES_EMITTED_CONTINUITY");
566 trace.
set(C::execution_prev_nullifier_tree_root, 2, 100);
568 "NULLIFIER_TREE_ROOT_CONTINUITY");
571 trace.
set(C::execution_prev_nullifier_tree_size, 2, 100);
573 "NULLIFIER_TREE_SIZE_CONTINUITY");
576 trace.
set(C::execution_prev_num_nullifiers_emitted, 2, 100);
578 "NUM_NULLIFIERS_EMITTED_CONTINUITY");
581 trace.
set(C::execution_prev_public_data_tree_root, 2, 100);
583 "PUBLIC_DATA_TREE_ROOT_CONTINUITY");
586 trace.
set(C::execution_prev_public_data_tree_size, 2, 100);
588 "PUBLIC_DATA_TREE_SIZE_CONTINUITY");
591 trace.
set(C::execution_prev_written_public_data_slots_tree_root, 2, 100);
594 "WRITTEN_PUBLIC_DATA_SLOTS_TREE_ROOT_CONTINUITY");
597 trace.
set(C::execution_prev_written_public_data_slots_tree_size, 2, 100);
600 "WRITTEN_PUBLIC_DATA_SLOTS_TREE_SIZE_CONTINUITY");
603 trace.
set(C::execution_l1_l2_tree_root, 2, 100);
605 "L1_L2_TREE_ROOT_CONTINUITY");
608 trace.
set(C::execution_prev_retrieved_bytecodes_tree_root, 2, 100);
610 "RETRIEVED_BYTECODES_TREE_ROOT_CONTINUITY");
613 trace.
set(C::execution_prev_retrieved_bytecodes_tree_size, 2, 100);
615 "RETRIEVED_BYTECODES_TREE_SIZE_CONTINUITY");
618TEST(ContextConstrainingTest, SideEffectStateContinuity)
620 TestTraceContainer
trace({
621 { { C::precomputed_first_row, 1 } },
624 { C::execution_sel, 1 },
625 { C::execution_num_unencrypted_log_fields, 10 },
626 { C::execution_num_l2_to_l1_messages, 11 },
630 { C::execution_sel, 1 },
631 { C::execution_prev_num_unencrypted_log_fields, 10 },
632 { C::execution_prev_num_l2_to_l1_messages, 11 },
636 check_relation<context>(
640 trace.
set(C::execution_prev_num_unencrypted_log_fields, 2, 100);
642 "NUM_UNENCRYPTED_LOGS_CONTINUITY");
645 trace.
set(C::execution_prev_num_l2_to_l1_messages, 2, 100);
647 "NUM_L2_TO_L1_MESSAGES_CONTINUITY");
650TEST(ContextConstrainingTest, BytecodeIdPropagation)
652 TestTraceContainer
trace({
654 { C::precomputed_first_row, 1 },
655 { C::execution_sel, 1 },
656 { C::execution_context_id, 1 },
657 { C::execution_next_context_id, 1 },
658 { C::execution_bytecode_id, 42 },
662 { C::execution_sel, 1 },
663 { C::execution_context_id, 1 },
664 { C::execution_next_context_id, 1 },
665 { C::execution_bytecode_id, 42 },
668 check_relation<context>(trace);
670 trace.
set(C::execution_bytecode_id, 1, 99);
672 "BYTECODE_ID_NEXT_ROW");
675TEST(ContextConstrainingTest, IsStaticRegularCallFromNonStaticContext)
678 TestTraceContainer
trace({
679 { { C::precomputed_first_row, 1 } },
681 { C::execution_sel, 1 },
682 { C::execution_context_id, 1 },
683 { C::execution_next_context_id, 2 },
684 { C::execution_is_static, 0 },
685 { C::execution_sel_enter_call, 1 },
686 { C::execution_sel_execute_call, 1 },
687 { C::execution_sel_execute_static_call, 0 },
690 { C::execution_sel, 1 },
691 { C::execution_context_id, 2 },
692 { C::execution_next_context_id, 3 },
693 { C::execution_is_static, 0 },
696 check_relation<context>(
701 trace.
set(C::execution_is_static, 2, 1);
703 "IS_STATIC_IF_STATIC_CALL");
706 trace.
set(C::execution_is_static, 2, 0);
709TEST(ContextConstrainingTest, IsStaticStaticCallFromNonStaticContext)
712 TestTraceContainer
trace({
713 { { C::precomputed_first_row, 1 } },
715 { C::execution_sel, 1 },
716 { C::execution_context_id, 1 },
717 { C::execution_next_context_id, 2 },
718 { C::execution_is_static, 0 },
719 { C::execution_sel_enter_call, 1 },
720 { C::execution_sel_execute_call, 0 },
721 { C::execution_sel_execute_static_call, 1 },
724 { C::execution_sel, 1 },
725 { C::execution_context_id, 2 },
726 { C::execution_next_context_id, 3 },
727 { C::execution_is_static, 1 },
730 check_relation<context>(
735 trace.
set(C::execution_is_static, 2, 0);
737 "IS_STATIC_IF_STATIC_CALL");
740 trace.
set(C::execution_is_static, 2, 1);
743TEST(ContextConstrainingTest, IsStaticCallFromStaticContext)
746 TestTraceContainer
trace({
747 { { C::precomputed_first_row, 1 } },
749 { C::execution_sel, 1 },
750 { C::execution_context_id, 1 },
751 { C::execution_next_context_id, 2 },
752 { C::execution_is_static, 1 },
753 { C::execution_sel_enter_call, 1 },
754 { C::execution_sel_execute_call, 1 },
755 { C::execution_sel_execute_static_call, 0 },
758 { C::execution_sel, 1 },
759 { C::execution_context_id, 2 },
760 { C::execution_next_context_id, 3 },
761 { C::execution_is_static, 1 },
764 check_relation<context>(
769 trace.
set(C::execution_is_static, 2, 0);
771 "IS_STATIC_IF_CALL_FROM_STATIC_CONTEXT");
774 trace.
set(C::execution_is_static, 2, 1);
777TEST(ContextConstrainingTest, IsStaticPropagationWithoutCalls)
780 TestTraceContainer
trace({
781 { { C::precomputed_first_row, 1 } },
783 { C::execution_sel, 1 },
784 { C::execution_context_id, 1 },
785 { C::execution_next_context_id, 1 },
786 { C::execution_is_static, 1 },
789 { C::execution_sel, 1 },
790 { C::execution_context_id, 1 },
791 { C::execution_next_context_id, 1 },
792 { C::execution_is_static, 1 },
799 trace.
set(C::execution_is_static, 2, 0);
803 trace.
set(C::execution_is_static, 2, 1);
806TEST(ContextConstrainingTest, ContextIdPropagation)
808 TestTraceContainer
trace({
810 { C::precomputed_first_row, 1 },
813 { C::execution_sel, 1 },
814 { C::execution_enqueued_call_start, 1 },
815 { C::execution_context_id, 1 },
816 { C::execution_next_context_id, 2 },
817 { C::execution_sel_enter_call, 1 },
820 { C::execution_sel, 1 },
821 { C::execution_context_id, 2 },
822 { C::execution_next_context_id, 3 },
823 { C::execution_sel_exit_call, 1 },
824 { C::execution_nested_exit_call, 1 },
825 { C::execution_parent_id, 1 },
828 { C::execution_sel, 1 },
829 { C::execution_context_id, 1 },
830 { C::execution_next_context_id, 3 },
833 { C::execution_sel, 1 },
834 { C::execution_context_id, 1 },
835 { C::execution_next_context_id, 3 },
838 check_relation<context>(trace,
846 trace.
set(C::execution_next_context_id, 1, 3);
848 "ENQUEUED_CALL_START_NEXT_CTX_ID");
849 trace.
set(C::execution_next_context_id, 1, 2);
852 trace.
set(C::execution_next_context_id, 2, 2);
854 trace.
set(C::execution_next_context_id, 2, 3);
857 trace.
set(C::execution_next_context_id, 4, 4);
859 trace.
set(C::execution_next_context_id, 4, 3);
862 trace.
set(C::execution_context_id, 4, 2);
864 trace.
set(C::execution_context_id, 4, 1);
867 trace.
set(C::execution_context_id, 2, 1);
869 trace.
set(C::execution_context_id, 2, 2);
872 trace.
set(C::execution_context_id, 3, 2);
874 "CONTEXT_ID_NESTED_EXIT");
875 trace.
set(C::execution_context_id, 3, 1);
#define EXPECT_THROW_WITH_MESSAGE(code, expectedMessageRegex)
static constexpr size_t SR_PARENT_DA_GAS_USED_NEXT_ROW
static constexpr size_t SR_INCR_NEXT_CONTEXT_ID
static constexpr size_t SR_L1_L2_TREE_ROOT_CONTINUITY
static constexpr size_t SR_DA_GAS_USED_INGEST_AFTER_EXIT
static constexpr size_t SR_L2_GAS_USED_ZERO_AFTER_CALL
static constexpr size_t SR_PARENT_L2_GAS_LIMIT_STORE_ON_ENTER
static constexpr size_t SR_PARENT_L2_GAS_USED_STORE_ON_ENTER
static constexpr size_t SR_NOTE_HASH_TREE_SIZE_CONTINUITY
static constexpr size_t SR_IS_STATIC_IF_CALL_FROM_STATIC_CONTEXT
static constexpr size_t SR_RETRIEVED_BYTECODES_TREE_ROOT_CONTINUITY
static constexpr size_t SR_WRITTEN_PUBLIC_DATA_SLOTS_TREE_ROOT_CONTINUITY
static constexpr size_t SR_L2_GAS_LIMIT_RESTORE_ON_EXIT
static constexpr size_t SR_DA_GAS_USED_CONTINUITY
static constexpr size_t SR_L2_GAS_USED_INGEST_AFTER_EXIT
static constexpr size_t SR_PUBLIC_DATA_TREE_SIZE_CONTINUITY
static constexpr size_t SR_PARENT_DA_GAS_USED_STORE_ON_ENTER
static constexpr size_t SR_NUM_NOTE_HASHES_EMITTED_CONTINUITY
static constexpr size_t SR_PARENT_L2_GAS_LIMIT_NEXT_ROW
static constexpr size_t SR_NULLIFIER_TREE_SIZE_CONTINUITY
static constexpr size_t SR_CONTEXT_ID_EXT_CALL
static constexpr size_t SR_DA_GAS_USED_ZERO_AFTER_CALL
static constexpr size_t SR_NUM_L2_TO_L1_MESSAGES_CONTINUITY
static constexpr size_t SR_ENQUEUED_CALL_START_NEXT_CTX_ID
static constexpr size_t SR_PARENT_DA_GAS_LIMIT_STORE_ON_ENTER
static constexpr size_t SR_NOTE_HASH_TREE_ROOT_CONTINUITY
static constexpr size_t SR_CONTEXT_ID_NESTED_EXIT
static constexpr size_t SR_WRITTEN_PUBLIC_DATA_SLOTS_TREE_SIZE_CONTINUITY
static constexpr size_t SR_BYTECODE_ID_NEXT_ROW
static constexpr size_t SR_CONTEXT_ID_NEXT_ROW
static constexpr size_t SR_RETRIEVED_BYTECODES_TREE_SIZE_CONTINUITY
static constexpr size_t SR_PUBLIC_DATA_TREE_ROOT_CONTINUITY
static constexpr size_t SR_NUM_NULLIFIERS_EMITTED_CONTINUITY
static constexpr size_t SR_L2_GAS_LIMIT_NEXT_ROW
static constexpr size_t SR_NUM_UNENCRYPTED_LOGS_CONTINUITY
static constexpr size_t SR_DA_GAS_LIMIT_RESTORE_ON_EXIT
static constexpr size_t SR_DA_GAS_LIMIT_NEXT_ROW
static constexpr size_t SR_PARENT_DA_GAS_LIMIT_NEXT_ROW
static constexpr size_t SR_IS_STATIC_IF_STATIC_CALL
static constexpr size_t SR_IS_STATIC_NEXT_ROW
static constexpr size_t SR_NULLIFIER_TREE_ROOT_CONTINUITY
static constexpr size_t SR_PARENT_L2_GAS_USED_NEXT_ROW
static constexpr size_t SR_L2_GAS_USED_CONTINUITY
void set(Column col, uint32_t row, const FF &value)
StrictMock< MockContext > context
void check_interaction(tracegen::TestTraceContainer &trace)
TEST(AvmFixedVKTests, FixedVKCommitments)
Test that the fixed VK commitments agree with the ones computed from precomputed columns.
TestTraceContainer empty_trace()
lookup_settings< lookup_context_ctx_stack_rollback_settings_ > lookup_context_ctx_stack_rollback_settings
lookup_settings< lookup_context_ctx_stack_return_settings_ > lookup_context_ctx_stack_return_settings
permutation_settings< perm_context_ctx_stack_call_settings_ > perm_context_ctx_stack_call_settings