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_parent_l2_gas_limit, 2000 },
145 { C::execution_parent_da_gas_limit, 4000 },
146 { C::execution_parent_l2_gas_used, 500 },
147 { C::execution_parent_da_gas_used, 1500 },
150 { C::execution_sel, 0 },
153 check_relation<context>(trace);
161TEST(ContextConstrainingTest, ContextSwitchingExceptionalHalt)
163 constexpr uint32_t top_bytecode_id = 0x12345678;
164 constexpr uint32_t nested_bytecode_id = 0x456789ab;
166 TestTraceContainer
trace(
168 { C::execution_next_context_id, 0 },
169 { C::precomputed_first_row, 1 },
171 { C::context_stack_sel, 1 },
172 { C::context_stack_entered_context_id, 2 },
173 { C::context_stack_context_id, 1 },
174 { C::context_stack_parent_id, 0 },
175 { C::context_stack_next_pc, 2 },
176 { C::context_stack_msg_sender, 0 },
177 { C::context_stack_contract_address, 0 },
178 { C::context_stack_bytecode_id, top_bytecode_id },
179 { C::context_stack_is_static, 0 },
180 { C::context_stack_parent_calldata_addr, 0 },
181 { C::context_stack_parent_calldata_size, 0 },
182 { C::context_stack_parent_l2_gas_limit, 2000 },
183 { C::context_stack_parent_da_gas_limit, 4000 },
184 { C::context_stack_parent_l2_gas_used, 500 },
185 { C::context_stack_parent_da_gas_used, 1500 },
189 { C::execution_sel, 1 },
190 { C::execution_pc, 0 },
191 { C::execution_next_pc, 1 },
192 { C::execution_context_id, 1 },
193 { C::execution_next_context_id, 2 },
194 { C::execution_bytecode_id, top_bytecode_id },
195 { C::execution_parent_l2_gas_limit, 2000 },
196 { C::execution_parent_da_gas_limit, 4000 },
197 { C::execution_parent_l2_gas_used, 500 },
198 { C::execution_parent_da_gas_used, 1500 },
199 { C::execution_enqueued_call_start, 1 },
203 { C::execution_sel, 1 },
204 { C::execution_pc, 1 },
205 { C::execution_next_pc, 2 },
206 { C::execution_sel_execute_call, 1 },
207 { C::execution_sel_enter_call, 1 },
208 { C::execution_context_id, 1 },
209 { C::execution_next_context_id, 2 },
210 { C::execution_bytecode_id, top_bytecode_id },
211 { C::execution_rop_4_, 10 },
212 { C::execution_register_2_, 0xdeadbeef },
213 { C::execution_register_3_, 1 },
214 { C::execution_parent_l2_gas_limit, 2000 },
215 { C::execution_parent_da_gas_limit, 4000 },
216 { C::execution_parent_l2_gas_used, 500 },
217 { C::execution_parent_da_gas_used, 1500 },
221 { C::execution_sel, 1 },
222 { C::execution_pc, 0 },
223 { C::execution_next_pc, 20 },
224 { C::execution_context_id, 2 },
225 { C::execution_next_context_id, 3 },
226 { C::execution_parent_id, 1 },
227 { C::execution_is_parent_id_inv, 1 },
228 { C::execution_has_parent_ctx, 1 },
229 { C::execution_contract_address, 0xdeadbeef },
230 { C::execution_bytecode_id, nested_bytecode_id },
231 { C::execution_parent_calldata_addr, 10 },
232 { C::execution_parent_calldata_size, 1 },
236 { C::execution_sel, 1 },
237 { C::execution_pc, 20 },
238 { C::execution_next_pc, 30 },
239 { C::execution_sel_execute_return, 1 },
240 { C::execution_rop_0_, 500 },
241 { C::execution_rop_1_, 600 },
242 { C::execution_register_0_, 200 },
243 { C::execution_sel_exit_call, 1 },
244 { C::execution_nested_exit_call, 1 },
245 { C::execution_sel_error, 1 },
246 { C::execution_context_id, 2 },
247 { C::execution_next_context_id, 3 },
248 { C::execution_parent_id, 1 },
249 { C::execution_is_parent_id_inv, 1 },
250 { C::execution_has_parent_ctx, 1 },
251 { C::execution_contract_address, 0xdeadbeef },
252 { C::execution_bytecode_id, nested_bytecode_id },
253 { C::execution_parent_calldata_addr, 10 },
254 { C::execution_parent_calldata_size, 1 },
257 { C::execution_sel, 1 },
258 { C::execution_next_context_id, 3 },
259 { C::execution_context_id, 1 },
260 { C::execution_parent_id, 0 },
261 { C::execution_last_child_id, 2 },
262 { C::execution_pc, 2 },
263 { C::execution_next_pc, 3 },
264 { C::execution_msg_sender, 0 },
265 { C::execution_contract_address, 0 },
266 { C::execution_bytecode_id, top_bytecode_id },
267 { C::execution_is_static, 0 },
268 { C::execution_parent_calldata_addr, 0 },
269 { C::execution_parent_calldata_size, 0 },
270 { C::execution_last_child_returndata_size, 0 },
271 { C::execution_last_child_returndata_addr, 0 },
272 { C::execution_parent_l2_gas_limit, 2000 },
273 { C::execution_parent_da_gas_limit, 4000 },
274 { C::execution_parent_l2_gas_used, 500 },
275 { C::execution_parent_da_gas_used, 1500 },
278 { C::execution_sel, 0 },
281 check_relation<context>(trace);
289TEST(ContextConstrainingTest, GasNextRow)
291 TestTraceContainer
trace({ { { C::precomputed_first_row, 1 } },
294 { C::execution_sel, 1 },
295 { C::execution_l2_gas_limit, 1000 },
296 { C::execution_da_gas_limit, 2000 },
297 { C::execution_parent_l2_gas_limit, 2000 },
298 { C::execution_parent_da_gas_limit, 4000 },
299 { C::execution_parent_l2_gas_used, 500 },
300 { C::execution_parent_da_gas_used, 1500 },
304 { C::execution_sel, 1 },
305 { C::execution_sel_enter_call, 1 },
306 { C::execution_l2_gas_used, 200 },
307 { C::execution_da_gas_used, 300 },
308 { C::execution_l2_gas_limit, 1000 },
309 { C::execution_da_gas_limit, 2000 },
310 { C::execution_parent_l2_gas_limit, 2000 },
311 { C::execution_parent_da_gas_limit, 4000 },
312 { C::execution_parent_l2_gas_used, 500 },
313 { C::execution_parent_da_gas_used, 1500 },
317 { C::execution_sel, 1 },
318 { C::execution_sel_exit_call, 1 },
319 { C::execution_nested_exit_call, 1 },
320 { C::execution_parent_l2_gas_limit, 1000 },
321 { C::execution_parent_da_gas_limit, 2000 },
322 { C::execution_parent_l2_gas_used, 200 },
323 { C::execution_parent_da_gas_used, 300 },
327 { C::execution_sel, 1 },
328 { C::execution_l2_gas_limit, 1000 },
329 { C::execution_da_gas_limit, 2000 },
330 { C::execution_parent_l2_gas_limit, 2000 },
331 { C::execution_parent_da_gas_limit, 4000 },
334 { C::execution_sel, 0 },
337 check_relation<context>(trace,
352 trace.
set(C::execution_l2_gas_limit, 4, 1001);
354 "L2_GAS_LIMIT_RESTORE_ON_EXIT");
355 trace.
set(C::execution_da_gas_limit, 4, 2001);
357 "DA_GAS_LIMIT_RESTORE_ON_EXIT");
360 trace.
set(C::execution_parent_l2_gas_limit, 3, 2001);
362 "PARENT_L2_GAS_LIMIT_STORE_ON_ENTER");
363 trace.
set(C::execution_parent_da_gas_limit, 3, 4001);
365 "PARENT_DA_GAS_LIMIT_STORE_ON_ENTER");
366 trace.
set(C::execution_parent_l2_gas_used, 3, 201);
368 "PARENT_L2_GAS_USED_STORE_ON_ENTER");
369 trace.
set(C::execution_parent_da_gas_used, 3, 301);
371 "PARENT_DA_GAS_USED_STORE_ON_ENTER");
374 trace.
set(C::execution_l2_gas_limit, 2, 1001);
376 "L2_GAS_LIMIT_NEXT_ROW");
377 trace.
set(C::execution_da_gas_limit, 2, 2001);
379 "DA_GAS_LIMIT_NEXT_ROW");
381 trace.
set(C::execution_parent_l2_gas_limit, 2, 2001);
383 "PARENT_L2_GAS_LIMIT_NEXT_ROW");
384 trace.
set(C::execution_parent_da_gas_limit, 2, 4001);
386 "PARENT_DA_GAS_LIMIT_NEXT_ROW");
388 trace.
set(C::execution_parent_l2_gas_used, 2, 501);
390 "PARENT_L2_GAS_USED_NEXT_ROW");
391 trace.
set(C::execution_parent_da_gas_used, 2, 1501);
393 "PARENT_DA_GAS_USED_NEXT_ROW");
396TEST(ContextConstrainingTest, GasUsedContinuity)
398 TestTraceContainer
trace({ { { C::precomputed_first_row, 1 } },
401 { C::execution_sel, 1 },
402 { C::execution_l2_gas_used, 100 },
403 { C::execution_da_gas_used, 200 },
407 { C::execution_sel, 1 },
408 { C::execution_sel_enter_call, 1 },
409 { C::execution_l2_gas_used, 110 },
410 { C::execution_da_gas_used, 200 },
411 { C::execution_prev_l2_gas_used, 100 },
412 { C::execution_prev_da_gas_used, 200 },
416 { C::execution_sel, 1 },
417 { C::execution_sel_exit_call, 1 },
418 { C::execution_nested_exit_call, 1 },
419 { C::execution_l2_gas_used, 50 },
420 { C::execution_da_gas_used, 60 },
421 { C::execution_parent_l2_gas_used, 110 },
422 { C::execution_parent_da_gas_used, 200 },
423 { C::execution_prev_l2_gas_used, 0 },
424 { C::execution_prev_da_gas_used, 0 },
428 { C::execution_sel, 1 },
429 { C::execution_l2_gas_used, 170 },
430 { C::execution_da_gas_used, 260 },
431 { C::execution_prev_l2_gas_used, 160 },
432 { C::execution_prev_da_gas_used, 260 },
435 { C::execution_sel, 0 },
438 check_relation<context>(trace,
447 trace.
set(C::execution_prev_l2_gas_used, 4, 110);
450 "L2_GAS_USED_INGEST_AFTER_EXIT");
452 trace.
set(C::execution_prev_da_gas_used, 4, 60);
454 "DA_GAS_USED_INGEST_AFTER_EXIT");
457 trace.
set(C::execution_prev_l2_gas_used, 3, 110);
459 "L2_GAS_USED_ZERO_AFTER_CALL");
461 trace.
set(C::execution_prev_da_gas_used, 3, 200);
463 "DA_GAS_USED_ZERO_AFTER_CALL");
466 trace.
set(C::execution_prev_l2_gas_used, 2, 0);
468 "L2_GAS_USED_CONTINUITY");
470 trace.
set(C::execution_prev_da_gas_used, 2, 0);
472 "DA_GAS_USED_CONTINUITY");
475TEST(ContextConstrainingTest, TreeStateContinuity)
477 TestTraceContainer
trace({ { { C::precomputed_first_row, 1 } },
480 { C::execution_sel, 1 },
481 { C::execution_note_hash_tree_root, 10 },
482 { C::execution_note_hash_tree_size, 9 },
483 { C::execution_num_note_hashes_emitted, 8 },
484 { C::execution_nullifier_tree_root, 7 },
485 { C::execution_nullifier_tree_size, 6 },
486 { C::execution_num_nullifiers_emitted, 5 },
487 { C::execution_public_data_tree_root, 4 },
488 { C::execution_public_data_tree_size, 3 },
489 { C::execution_written_public_data_slots_tree_root, 2 },
490 { C::execution_written_public_data_slots_tree_size, 1 },
491 { C::execution_l1_l2_tree_root, 27 },
492 { C::execution_retrieved_bytecodes_tree_root, 26 },
493 { C::execution_retrieved_bytecodes_tree_size, 25 },
497 { C::execution_sel, 1 },
498 { C::execution_prev_note_hash_tree_root, 10 },
499 { C::execution_prev_note_hash_tree_size, 9 },
500 { C::execution_prev_num_note_hashes_emitted, 8 },
501 { C::execution_prev_nullifier_tree_root, 7 },
502 { C::execution_prev_nullifier_tree_size, 6 },
503 { C::execution_prev_num_nullifiers_emitted, 5 },
504 { C::execution_prev_public_data_tree_root, 4 },
505 { C::execution_prev_public_data_tree_size, 3 },
506 { C::execution_prev_written_public_data_slots_tree_root, 2 },
507 { C::execution_prev_written_public_data_slots_tree_size, 1 },
508 { C::execution_l1_l2_tree_root, 27 },
509 { C::execution_prev_retrieved_bytecodes_tree_root, 26 },
510 { C::execution_prev_retrieved_bytecodes_tree_size, 25 },
511 { C::execution_enqueued_call_end, 1 },
512 { C::execution_sel_exit_call, 1 },
516 { C::execution_sel, 1 },
517 { C::execution_prev_note_hash_tree_root, 100 },
518 { C::execution_prev_note_hash_tree_size, 90 },
519 { C::execution_prev_num_note_hashes_emitted, 80 },
520 { C::execution_prev_nullifier_tree_root, 70 },
521 { C::execution_prev_nullifier_tree_size, 60 },
522 { C::execution_prev_num_nullifiers_emitted, 50 },
523 { C::execution_prev_public_data_tree_root, 40 },
524 { C::execution_prev_public_data_tree_size, 30 },
525 { C::execution_prev_written_public_data_slots_tree_root, 20 },
526 { C::execution_prev_written_public_data_slots_tree_size, 10 },
527 { C::execution_l1_l2_tree_root, 27 },
528 { C::execution_prev_retrieved_bytecodes_tree_root, 260 },
529 { C::execution_prev_retrieved_bytecodes_tree_size, 250 },
532 check_relation<context>(trace,
548 trace.
set(C::execution_prev_note_hash_tree_root, 2, 100);
550 "NOTE_HASH_TREE_ROOT_CONTINUITY");
553 trace.
set(C::execution_prev_note_hash_tree_size, 2, 100);
555 "NOTE_HASH_TREE_SIZE_CONTINUITY");
558 trace.
set(C::execution_prev_num_note_hashes_emitted, 2, 10);
560 "NUM_NOTE_HASHES_EMITTED_CONTINUITY");
563 trace.
set(C::execution_prev_nullifier_tree_root, 2, 100);
565 "NULLIFIER_TREE_ROOT_CONTINUITY");
568 trace.
set(C::execution_prev_nullifier_tree_size, 2, 100);
570 "NULLIFIER_TREE_SIZE_CONTINUITY");
573 trace.
set(C::execution_prev_num_nullifiers_emitted, 2, 100);
575 "NUM_NULLIFIERS_EMITTED_CONTINUITY");
578 trace.
set(C::execution_prev_public_data_tree_root, 2, 100);
580 "PUBLIC_DATA_TREE_ROOT_CONTINUITY");
583 trace.
set(C::execution_prev_public_data_tree_size, 2, 100);
585 "PUBLIC_DATA_TREE_SIZE_CONTINUITY");
588 trace.
set(C::execution_prev_written_public_data_slots_tree_root, 2, 100);
591 "WRITTEN_PUBLIC_DATA_SLOTS_TREE_ROOT_CONTINUITY");
594 trace.
set(C::execution_prev_written_public_data_slots_tree_size, 2, 100);
597 "WRITTEN_PUBLIC_DATA_SLOTS_TREE_SIZE_CONTINUITY");
600 trace.
set(C::execution_l1_l2_tree_root, 2, 100);
602 "L1_L2_TREE_ROOT_CONTINUITY");
605 trace.
set(C::execution_prev_retrieved_bytecodes_tree_root, 2, 100);
607 "RETRIEVED_BYTECODES_TREE_ROOT_CONTINUITY");
610 trace.
set(C::execution_prev_retrieved_bytecodes_tree_size, 2, 100);
612 "RETRIEVED_BYTECODES_TREE_SIZE_CONTINUITY");
615TEST(ContextConstrainingTest, SideEffectStateContinuity)
617 TestTraceContainer
trace({
618 { { C::precomputed_first_row, 1 } },
621 { C::execution_sel, 1 },
622 { C::execution_num_unencrypted_log_fields, 10 },
623 { C::execution_num_l2_to_l1_messages, 11 },
627 { C::execution_sel, 1 },
628 { C::execution_prev_num_unencrypted_log_fields, 10 },
629 { C::execution_prev_num_l2_to_l1_messages, 11 },
633 check_relation<context>(
637 trace.
set(C::execution_prev_num_unencrypted_log_fields, 2, 100);
639 "NUM_UNENCRYPTED_LOGS_CONTINUITY");
642 trace.
set(C::execution_prev_num_l2_to_l1_messages, 2, 100);
644 "NUM_L2_TO_L1_MESSAGES_CONTINUITY");
647TEST(ContextConstrainingTest, BytecodeIdPropagation)
649 TestTraceContainer
trace({
651 { C::precomputed_first_row, 1 },
652 { C::execution_sel, 1 },
653 { C::execution_context_id, 1 },
654 { C::execution_next_context_id, 1 },
655 { C::execution_bytecode_id, 42 },
659 { C::execution_sel, 1 },
660 { C::execution_context_id, 1 },
661 { C::execution_next_context_id, 1 },
662 { C::execution_bytecode_id, 42 },
665 check_relation<context>(trace);
667 trace.
set(C::execution_bytecode_id, 1, 99);
669 "BYTECODE_ID_NEXT_ROW");
672TEST(ContextConstrainingTest, IsStaticRegularCallFromNonStaticContext)
675 TestTraceContainer
trace({
676 { { C::precomputed_first_row, 1 } },
678 { C::execution_sel, 1 },
679 { C::execution_context_id, 1 },
680 { C::execution_next_context_id, 2 },
681 { C::execution_is_static, 0 },
682 { C::execution_sel_enter_call, 1 },
683 { C::execution_sel_execute_call, 1 },
684 { C::execution_sel_execute_static_call, 0 },
687 { C::execution_sel, 1 },
688 { C::execution_context_id, 2 },
689 { C::execution_next_context_id, 3 },
690 { C::execution_is_static, 0 },
693 check_relation<context>(
698 trace.
set(C::execution_is_static, 2, 1);
700 "IS_STATIC_IF_STATIC_CALL");
703 trace.
set(C::execution_is_static, 2, 0);
706TEST(ContextConstrainingTest, IsStaticStaticCallFromNonStaticContext)
709 TestTraceContainer
trace({
710 { { C::precomputed_first_row, 1 } },
712 { C::execution_sel, 1 },
713 { C::execution_context_id, 1 },
714 { C::execution_next_context_id, 2 },
715 { C::execution_is_static, 0 },
716 { C::execution_sel_enter_call, 1 },
717 { C::execution_sel_execute_call, 0 },
718 { C::execution_sel_execute_static_call, 1 },
721 { C::execution_sel, 1 },
722 { C::execution_context_id, 2 },
723 { C::execution_next_context_id, 3 },
724 { C::execution_is_static, 1 },
727 check_relation<context>(
732 trace.
set(C::execution_is_static, 2, 0);
734 "IS_STATIC_IF_STATIC_CALL");
737 trace.
set(C::execution_is_static, 2, 1);
740TEST(ContextConstrainingTest, IsStaticCallFromStaticContext)
743 TestTraceContainer
trace({
744 { { C::precomputed_first_row, 1 } },
746 { C::execution_sel, 1 },
747 { C::execution_context_id, 1 },
748 { C::execution_next_context_id, 2 },
749 { C::execution_is_static, 1 },
750 { C::execution_sel_enter_call, 1 },
751 { C::execution_sel_execute_call, 1 },
752 { C::execution_sel_execute_static_call, 0 },
755 { C::execution_sel, 1 },
756 { C::execution_context_id, 2 },
757 { C::execution_next_context_id, 3 },
758 { C::execution_is_static, 1 },
761 check_relation<context>(
766 trace.
set(C::execution_is_static, 2, 0);
768 "IS_STATIC_IF_CALL_FROM_STATIC_CONTEXT");
771 trace.
set(C::execution_is_static, 2, 1);
774TEST(ContextConstrainingTest, IsStaticPropagationWithoutCalls)
777 TestTraceContainer
trace({
778 { { C::precomputed_first_row, 1 } },
780 { C::execution_sel, 1 },
781 { C::execution_context_id, 1 },
782 { C::execution_next_context_id, 1 },
783 { C::execution_is_static, 1 },
786 { C::execution_sel, 1 },
787 { C::execution_context_id, 1 },
788 { C::execution_next_context_id, 1 },
789 { C::execution_is_static, 1 },
796 trace.
set(C::execution_is_static, 2, 0);
800 trace.
set(C::execution_is_static, 2, 1);
803TEST(ContextConstrainingTest, ContextIdPropagation)
805 TestTraceContainer
trace({
807 { C::precomputed_first_row, 1 },
810 { C::execution_sel, 1 },
811 { C::execution_enqueued_call_start, 1 },
812 { C::execution_context_id, 1 },
813 { C::execution_next_context_id, 2 },
814 { C::execution_sel_enter_call, 1 },
817 { C::execution_sel, 1 },
818 { C::execution_context_id, 2 },
819 { C::execution_next_context_id, 3 },
820 { C::execution_sel_exit_call, 1 },
821 { C::execution_nested_exit_call, 1 },
822 { C::execution_parent_id, 1 },
825 { C::execution_sel, 1 },
826 { C::execution_context_id, 1 },
827 { C::execution_next_context_id, 3 },
830 { C::execution_sel, 1 },
831 { C::execution_context_id, 1 },
832 { C::execution_next_context_id, 3 },
835 check_relation<context>(trace,
843 trace.
set(C::execution_next_context_id, 1, 3);
845 "ENQUEUED_CALL_START_NEXT_CTX_ID");
846 trace.
set(C::execution_next_context_id, 1, 2);
849 trace.
set(C::execution_next_context_id, 2, 2);
851 trace.
set(C::execution_next_context_id, 2, 3);
854 trace.
set(C::execution_next_context_id, 4, 4);
856 trace.
set(C::execution_next_context_id, 4, 3);
859 trace.
set(C::execution_context_id, 4, 2);
861 trace.
set(C::execution_context_id, 4, 1);
864 trace.
set(C::execution_context_id, 2, 1);
866 trace.
set(C::execution_context_id, 2, 2);
869 trace.
set(C::execution_context_id, 3, 2);
871 "CONTEXT_ID_NESTED_EXIT");
872 trace.
set(C::execution_context_id, 3, 1);
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
#define EXPECT_THROW_WITH_MESSAGE(code, expectedMessage)
void check_interaction(tracegen::TestTraceContainer &trace)
TEST(TxExecutionConstrainingTest, WriteTreeValue)
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
lookup_settings< lookup_context_ctx_stack_call_settings_ > lookup_context_ctx_stack_call_settings