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 }, {C::execution_last, 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 }, {C::execution_last, 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 }, {C::execution_last, 1}},
84TEST(ExecutionConstrainingTest, ContinuityMultipleLast)
87 TestTraceContainer
trace({
88 {{ C::execution_sel, 1 }},
89 {{ C::execution_sel, 1 }},
90 {{ C::execution_sel, 1 }},
91 {{ C::execution_sel, 1 }, {C::execution_last, 1}},
102TEST(ExecutionConstrainingTest, TreeStateNotChanged)
104 TestTraceContainer
trace({
106 { C::precomputed_first_row, 1 },
109 { C::execution_sel, 1 },
110 { C::execution_prev_note_hash_tree_root, 10 },
111 { C::execution_prev_note_hash_tree_size, 9 },
112 { C::execution_prev_num_note_hashes_emitted, 8 },
113 { C::execution_prev_nullifier_tree_root, 7 },
114 { C::execution_prev_nullifier_tree_size, 6 },
115 { C::execution_prev_num_nullifiers_emitted, 5 },
116 { C::execution_prev_public_data_tree_root, 4 },
117 { C::execution_prev_public_data_tree_size, 3 },
118 { C::execution_prev_written_public_data_slots_tree_root, 2 },
119 { C::execution_prev_written_public_data_slots_tree_size, 1 },
120 { C::execution_prev_retrieved_bytecodes_tree_root, 12 },
121 { C::execution_prev_retrieved_bytecodes_tree_size, 13 },
122 { C::execution_note_hash_tree_root, 10 },
123 { C::execution_note_hash_tree_size, 9 },
124 { C::execution_num_note_hashes_emitted, 8 },
125 { C::execution_nullifier_tree_root, 7 },
126 { C::execution_nullifier_tree_size, 6 },
127 { C::execution_num_nullifiers_emitted, 5 },
128 { C::execution_public_data_tree_root, 4 },
129 { C::execution_public_data_tree_size, 3 },
130 { C::execution_written_public_data_slots_tree_root, 2 },
131 { C::execution_written_public_data_slots_tree_size, 1 },
132 { C::execution_retrieved_bytecodes_tree_root, 12 },
133 { C::execution_retrieved_bytecodes_tree_size, 13 },
137 check_relation<execution>(
trace,
152 trace.
set(C::execution_note_hash_tree_root, 1, 100);
154 "NOTE_HASH_TREE_ROOT_NOT_CHANGED");
157 trace.
set(C::execution_note_hash_tree_size, 1, 100);
159 "NOTE_HASH_TREE_SIZE_NOT_CHANGED");
162 trace.
set(C::execution_num_note_hashes_emitted, 1, 100);
164 "NUM_NOTE_HASHES_EMITTED_NOT_CHANGED");
167 trace.
set(C::execution_nullifier_tree_root, 1, 100);
169 "NULLIFIER_TREE_ROOT_NOT_CHANGED");
172 trace.
set(C::execution_nullifier_tree_size, 1, 100);
174 "NULLIFIER_TREE_SIZE_NOT_CHANGED");
177 trace.
set(C::execution_prev_num_nullifiers_emitted, 1, 100);
179 "NUM_NULLIFIERS_EMITTED_NOT_CHANGED");
182 trace.
set(C::execution_public_data_tree_root, 1, 100);
184 "PUBLIC_DATA_TREE_ROOT_NOT_CHANGED");
187 trace.
set(C::execution_public_data_tree_size, 1, 100);
189 "PUBLIC_DATA_TREE_SIZE_NOT_CHANGED");
192 trace.
set(C::execution_written_public_data_slots_tree_root, 1, 100);
195 "WRITTEN_PUBLIC_DATA_SLOTS_TREE_ROOT_NOT_CHANGED");
198 trace.
set(C::execution_written_public_data_slots_tree_size, 1, 100);
201 "WRITTEN_PUBLIC_DATA_SLOTS_TREE_SIZE_NOT_CHANGED");
204 trace.
set(C::execution_retrieved_bytecodes_tree_root, 1, 100);
206 "RETRIEVED_BYTECODES_TREE_ROOT_NOT_CHANGED");
209 trace.
set(C::execution_retrieved_bytecodes_tree_size, 1, 100);
211 "RETRIEVED_BYTECODES_TREE_SIZE_NOT_CHANGED");
214TEST(ExecutionConstrainingTest, SideEffectStateNotChanged)
216 TestTraceContainer
trace({
218 { C::precomputed_first_row, 1 },
221 { C::execution_sel, 1 },
222 { C::execution_prev_num_unencrypted_log_fields, 10 },
223 { C::execution_prev_num_l2_to_l1_messages, 11 },
224 { C::execution_num_unencrypted_log_fields, 10 },
225 { C::execution_num_l2_to_l1_messages, 11 },
229 check_relation<execution>(
233 trace.
set(C::execution_num_unencrypted_log_fields, 1, 100);
235 "NUM_UNENCRYPTED_LOGS_NOT_CHANGED");
238 trace.
set(C::execution_num_l2_to_l1_messages, 1, 100);
240 "NUM_L2_TO_L1_MESSAGES_NOT_CHANGED");
243TEST(ExecutionConstrainingTest, SubtraceIdDecomposition)
249 TestTraceContainer
trace;
250 const uint8_t enum_length =
static_cast<uint8_t
>(SubtraceSel::MAX) + 1;
252 for (uint8_t i = 0; i < enum_length; i++) {
259 { subtrace_selector, 1 },
260 { C::execution_subtrace_id, subtrace_id },
261 { C::execution_sel_should_execute_opcode, 1 },
267 for (uint8_t i = 0; i < enum_length; i++) {
273 "SUBTRACE_ID_DECOMPOSITION");
279 "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_LAST_IS_LAST
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