1#include <gmock/gmock.h>
2#include <gtest/gtest.h>
22using tracegen::TestTraceContainer;
30TEST(ExecutionConstrainingTest, EmptyRow)
48TEST(ExecutionConstrainingTest, Continuity)
51 TestTraceContainer
trace({
52 {{ C::precomputed_first_row, 1 }},
53 {{ C::execution_sel, 1 }},
54 {{ C::execution_sel, 1 }},
55 {{ C::execution_sel, 1 }, { C::execution_enqueued_call_end, 1 }},
62 trace.
set(C::execution_enqueued_call_end, 3, 0);
67TEST(ExecutionConstrainingTest, ContinuityBrokenFirstRow)
70 TestTraceContainer
trace({
71 {{ C::execution_sel, 0 }},
72 {{ C::execution_sel, 1 }},
73 {{ C::execution_sel, 1 }},
74 {{ C::execution_sel, 1 }, { C::execution_enqueued_call_end, 1 }},
82TEST(ExecutionConstrainingTest, ContinuityBrokenInMiddle)
85 TestTraceContainer
trace({
86 {{ C::execution_sel, 1 }},
87 {{ C::execution_sel, 0 }},
88 {{ C::execution_sel, 1 }},
89 {{ C::execution_sel, 1 }, { C::execution_enqueued_call_end, 1 }},
97TEST(ExecutionConstrainingTest, TreeStateNotChanged)
99 TestTraceContainer
trace({
101 { C::precomputed_first_row, 1 },
104 { C::execution_sel, 1 },
105 { C::execution_prev_note_hash_tree_root, 10 },
106 { C::execution_prev_note_hash_tree_size, 9 },
107 { C::execution_prev_num_note_hashes_emitted, 8 },
108 { C::execution_prev_nullifier_tree_root, 7 },
109 { C::execution_prev_nullifier_tree_size, 6 },
110 { C::execution_prev_num_nullifiers_emitted, 5 },
111 { C::execution_prev_public_data_tree_root, 4 },
112 { C::execution_prev_public_data_tree_size, 3 },
113 { C::execution_prev_written_public_data_slots_tree_root, 2 },
114 { C::execution_prev_written_public_data_slots_tree_size, 1 },
115 { C::execution_prev_retrieved_bytecodes_tree_root, 12 },
116 { C::execution_prev_retrieved_bytecodes_tree_size, 13 },
117 { C::execution_note_hash_tree_root, 10 },
118 { C::execution_note_hash_tree_size, 9 },
119 { C::execution_num_note_hashes_emitted, 8 },
120 { C::execution_nullifier_tree_root, 7 },
121 { C::execution_nullifier_tree_size, 6 },
122 { C::execution_num_nullifiers_emitted, 5 },
123 { C::execution_public_data_tree_root, 4 },
124 { C::execution_public_data_tree_size, 3 },
125 { C::execution_written_public_data_slots_tree_root, 2 },
126 { C::execution_written_public_data_slots_tree_size, 1 },
127 { C::execution_retrieved_bytecodes_tree_root, 12 },
128 { C::execution_retrieved_bytecodes_tree_size, 13 },
132 check_relation<execution>(trace,
147 trace.
set(C::execution_note_hash_tree_root, 1, 100);
152 trace.
set(C::execution_note_hash_tree_size, 1, 100);
157 trace.
set(C::execution_num_note_hashes_emitted, 1, 100);
162 trace.
set(C::execution_nullifier_tree_root, 1, 100);
167 trace.
set(C::execution_nullifier_tree_size, 1, 100);
172 trace.
set(C::execution_prev_num_nullifiers_emitted, 1, 100);
177 trace.
set(C::execution_public_data_tree_root, 1, 100);
182 trace.
set(C::execution_public_data_tree_size, 1, 100);
187 trace.
set(C::execution_written_public_data_slots_tree_root, 1, 100);
193 trace.
set(C::execution_written_public_data_slots_tree_size, 1, 100);
199 trace.
set(C::execution_retrieved_bytecodes_tree_root, 1, 100);
205 trace.
set(C::execution_retrieved_bytecodes_tree_size, 1, 100);
211TEST(ExecutionConstrainingTest, SideEffectStateNotChanged)
213 TestTraceContainer
trace({
215 { C::precomputed_first_row, 1 },
218 { C::execution_sel, 1 },
219 { C::execution_prev_num_public_log_fields, 10 },
220 { C::execution_prev_num_l2_to_l1_messages, 11 },
221 { C::execution_num_public_log_fields, 10 },
222 { C::execution_num_l2_to_l1_messages, 11 },
226 check_relation<execution>(
230 trace.
set(C::execution_num_public_log_fields, 1, 100);
235 trace.
set(C::execution_num_l2_to_l1_messages, 1, 100);
240TEST(ExecutionConstrainingTest, NoFetchingNoInstrFetchError)
243 TestTraceContainer
trace({
244 { { C::execution_sel_bytecode_retrieval_success, 0 }, { C::execution_sel_instruction_fetching_failure, 0 } },
250 trace.
set(C::execution_sel_instruction_fetching_failure, 0, 1);
255 trace.
set(C::execution_sel_bytecode_retrieval_success, 0, 1);
259TEST(ExecutionConstrainingTest, NoAddressingErrorIfNotResolving)
263 TestTraceContainer
trace({
264 { { C::execution_sel_instruction_fetching_success, 0 }, { C::execution_sel_addressing_error, 0 } },
270 trace.
set(C::execution_sel_addressing_error, 0, 1);
275 trace.
set(C::execution_sel_instruction_fetching_success, 0, 1);
279TEST(ExecutionConstrainingTest, NoRegisterReadErrorIfNotReading)
284 TestTraceContainer
trace({
285 { { C::execution_sel_read_registers, 0 }, { C::execution_sel_register_read_error, 0 } },
291 trace.
set(C::execution_sel_register_read_error, 0, 1);
296TEST(ExecutionConstrainingTest, NoOogIfNoGasCheck)
299 TestTraceContainer
trace({
300 { { C::execution_sel_check_gas, 0 }, { C::execution_sel_out_of_gas, 0 } },
306 trace.
set(C::execution_sel_out_of_gas, 0, 1);
311 trace.
set(C::execution_sel_check_gas, 0, 1);
315TEST(ExecutionConstrainingTest, NoOpcodeErrorIfNotExecuting)
318 TestTraceContainer
trace({
319 { { C::execution_sel_execute_opcode, 0 }, { C::execution_sel_opcode_error, 0 } },
325 trace.
set(C::execution_sel_opcode_error, 0, 1);
330 trace.
set(C::execution_sel_execute_opcode, 0, 1);
334TEST(ExecutionConstrainingTest, SubtraceIdDecomposition)
340 TestTraceContainer
trace;
341 const uint8_t enum_length =
static_cast<uint8_t
>(SubtraceSel::MAX) + 1;
343 for (uint8_t i = 0; i < enum_length; i++) {
350 { subtrace_selector, 1 },
351 { C::execution_subtrace_id, subtrace_id },
352 { C::execution_sel_execute_opcode, 1 },
358 for (uint8_t i = 0; i < enum_length; i++) {
#define EXPECT_THROW_WITH_MESSAGE(code, expectedMessageRegex)
static std::string get_subrelation_label(size_t index)
static constexpr size_t SR_NO_ADDRESSING_ERROR_IF_NOT_RESOLVING
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 std::string get_subrelation_label(size_t index)
static constexpr size_t SR_NO_OPCODE_ERROR_IF_NOT_EXECUTING
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_NO_FETCHING_NO_INSTR_FETCH_ERROR
static constexpr size_t SR_SUBTRACE_ID_DECOMPOSITION
static constexpr size_t SR_NULLIFIER_TREE_ROOT_NOT_CHANGED
static constexpr size_t SR_NUM_PUBLIC_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
static std::string get_subrelation_label(size_t index)
static constexpr size_t SR_NO_OOG_IF_NO_GAS_CHECK
static constexpr size_t SR_REGISTER_READ_TAG_CHECK
static std::string get_subrelation_label(size_t index)
void set(Column col, uint32_t row, const FF &value, bool use_atomic_limbs=false)
TEST(AvmFixedVKTests, FixedVKCommitments)
Test that the fixed VK commitments agree with the ones computed from precomputed columns.
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