1#include <gmock/gmock.h>
2#include <gtest/gtest.h>
19using tracegen::TestTraceContainer;
24TEST(ExecutionConstrainingTest, EmptyRow)
42TEST(ExecutionConstrainingTest, Continuity)
45 TestTraceContainer
trace({
46 {{ C::precomputed_first_row, 1 }},
47 {{ C::execution_sel, 1 }},
48 {{ C::execution_sel, 1 }},
49 {{ C::execution_sel, 1 }},
56TEST(ExecutionConstrainingTest, ContinuityBrokenFirstRow)
59 TestTraceContainer
trace({
60 {{ C::execution_sel, 0 }},
61 {{ C::execution_sel, 1 }},
62 {{ C::execution_sel, 1 }},
63 {{ C::execution_sel, 1 }},
70TEST(ExecutionConstrainingTest, ContinuityBrokenInMiddle)
73 TestTraceContainer
trace({
74 {{ C::execution_sel, 1 }},
75 {{ C::execution_sel, 0 }},
76 {{ C::execution_sel, 1 }},
77 {{ C::execution_sel, 1 }},
84TEST(ExecutionConstrainingTest, TreeStateNotChanged)
86 TestTraceContainer
trace({
88 { C::precomputed_first_row, 1 },
91 { C::execution_sel, 1 },
92 { C::execution_prev_note_hash_tree_root, 10 },
93 { C::execution_prev_note_hash_tree_size, 9 },
94 { C::execution_prev_num_note_hashes_emitted, 8 },
95 { C::execution_prev_nullifier_tree_root, 7 },
96 { C::execution_prev_nullifier_tree_size, 6 },
97 { C::execution_prev_num_nullifiers_emitted, 5 },
98 { C::execution_prev_public_data_tree_root, 4 },
99 { C::execution_prev_public_data_tree_size, 3 },
100 { C::execution_prev_written_public_data_slots_tree_root, 2 },
101 { C::execution_prev_written_public_data_slots_tree_size, 1 },
102 { C::execution_prev_retrieved_bytecodes_tree_root, 12 },
103 { C::execution_prev_retrieved_bytecodes_tree_size, 13 },
104 { C::execution_note_hash_tree_root, 10 },
105 { C::execution_note_hash_tree_size, 9 },
106 { C::execution_num_note_hashes_emitted, 8 },
107 { C::execution_nullifier_tree_root, 7 },
108 { C::execution_nullifier_tree_size, 6 },
109 { C::execution_num_nullifiers_emitted, 5 },
110 { C::execution_public_data_tree_root, 4 },
111 { C::execution_public_data_tree_size, 3 },
112 { C::execution_written_public_data_slots_tree_root, 2 },
113 { C::execution_written_public_data_slots_tree_size, 1 },
114 { C::execution_retrieved_bytecodes_tree_root, 12 },
115 { C::execution_retrieved_bytecodes_tree_size, 13 },
119 check_relation<execution>(trace,
134 trace.
set(C::execution_note_hash_tree_root, 1, 100);
136 "NOTE_HASH_TREE_ROOT_NOT_CHANGED");
139 trace.
set(C::execution_note_hash_tree_size, 1, 100);
141 "NOTE_HASH_TREE_SIZE_NOT_CHANGED");
144 trace.
set(C::execution_num_note_hashes_emitted, 1, 100);
146 "NUM_NOTE_HASHES_EMITTED_NOT_CHANGED");
149 trace.
set(C::execution_nullifier_tree_root, 1, 100);
151 "NULLIFIER_TREE_ROOT_NOT_CHANGED");
154 trace.
set(C::execution_nullifier_tree_size, 1, 100);
156 "NULLIFIER_TREE_SIZE_NOT_CHANGED");
159 trace.
set(C::execution_prev_num_nullifiers_emitted, 1, 100);
161 "NUM_NULLIFIERS_EMITTED_NOT_CHANGED");
164 trace.
set(C::execution_public_data_tree_root, 1, 100);
166 "PUBLIC_DATA_TREE_ROOT_NOT_CHANGED");
169 trace.
set(C::execution_public_data_tree_size, 1, 100);
171 "PUBLIC_DATA_TREE_SIZE_NOT_CHANGED");
174 trace.
set(C::execution_written_public_data_slots_tree_root, 1, 100);
177 "WRITTEN_PUBLIC_DATA_SLOTS_TREE_ROOT_NOT_CHANGED");
180 trace.
set(C::execution_written_public_data_slots_tree_size, 1, 100);
183 "WRITTEN_PUBLIC_DATA_SLOTS_TREE_SIZE_NOT_CHANGED");
186 trace.
set(C::execution_retrieved_bytecodes_tree_root, 1, 100);
188 "RETRIEVED_BYTECODES_TREE_ROOT_NOT_CHANGED");
191 trace.
set(C::execution_retrieved_bytecodes_tree_size, 1, 100);
193 "RETRIEVED_BYTECODES_TREE_SIZE_NOT_CHANGED");
196TEST(ExecutionConstrainingTest, SideEffectStateNotChanged)
198 TestTraceContainer
trace({
200 { C::precomputed_first_row, 1 },
203 { C::execution_sel, 1 },
204 { C::execution_prev_num_unencrypted_log_fields, 10 },
205 { C::execution_prev_num_l2_to_l1_messages, 11 },
206 { C::execution_num_unencrypted_log_fields, 10 },
207 { C::execution_num_l2_to_l1_messages, 11 },
211 check_relation<execution>(
215 trace.
set(C::execution_num_unencrypted_log_fields, 1, 100);
217 "NUM_UNENCRYPTED_LOGS_NOT_CHANGED");
220 trace.
set(C::execution_num_l2_to_l1_messages, 1, 100);
222 "NUM_L2_TO_L1_MESSAGES_NOT_CHANGED");
225TEST(ExecutionConstrainingTest, SubtraceIdDecomposition)
231 TestTraceContainer
trace;
232 const uint8_t enum_length =
static_cast<uint8_t
>(SubtraceSel::MAX) + 1;
234 for (uint8_t i = 0; i < enum_length; i++) {
241 { subtrace_selector, 1 },
242 { C::execution_subtrace_id, subtrace_id },
243 { C::execution_sel_should_execute_opcode, 1 },
249 for (uint8_t i = 0; i < enum_length; i++) {
255 "SUBTRACE_ID_DECOMPOSITION");
261 "SUBTRACE_ID_DECOMPOSITION");
static constexpr size_t SR_NUM_L2_TO_L1_MESSAGES_NOT_CHANGED
static constexpr size_t SR_RETRIEVED_BYTECODES_TREE_ROOT_NOT_CHANGED
static constexpr size_t SR_WRITTEN_PUBLIC_DATA_SLOTS_TREE_SIZE_NOT_CHANGED
static constexpr size_t SR_NULLIFIER_TREE_SIZE_NOT_CHANGED
static constexpr size_t SR_NUM_NULLIFIERS_EMITTED_NOT_CHANGED
static constexpr size_t SR_PUBLIC_DATA_TREE_SIZE_NOT_CHANGED
static constexpr size_t SR_NOTE_HASH_TREE_ROOT_NOT_CHANGED
static constexpr size_t SR_TRACE_CONTINUITY
static constexpr size_t SR_SUBTRACE_ID_DECOMPOSITION
static constexpr size_t SR_NULLIFIER_TREE_ROOT_NOT_CHANGED
static constexpr size_t SR_NUM_UNENCRYPTED_LOGS_NOT_CHANGED
static constexpr size_t SR_PUBLIC_DATA_TREE_ROOT_NOT_CHANGED
static constexpr size_t SR_WRITTEN_PUBLIC_DATA_SLOTS_TREE_ROOT_NOT_CHANGED
static constexpr size_t SR_NOTE_HASH_TREE_SIZE_NOT_CHANGED
static constexpr size_t SR_RETRIEVED_BYTECODES_TREE_SIZE_NOT_CHANGED
static constexpr size_t SR_NUM_NOTE_HASHES_EMITTED_NOT_CHANGED
void set(Column col, uint32_t row, const FF &value)
#define EXPECT_THROW_WITH_MESSAGE(code, expectedMessage)
TEST(TxExecutionConstrainingTest, WriteTreeValue)
TestTraceContainer empty_trace()
Column get_subtrace_selector(SubtraceSel subtrace_sel)
Get the column selector for a given subtrace selector.
FF get_subtrace_id(SubtraceSel subtrace_sel)
Get the subtrace ID for a given subtrace enum.
NiceMock< MockExecution > execution