1#include <gmock/gmock.h>
2#include <gtest/gtest.h>
25using simulation::ExecutionEvent;
26using testing::InstructionBuilder;
27using tracegen::ExecutionTraceBuilder;
28using tracegen::PrecomputedTraceBuilder;
32using tracegen::TestTraceContainer;
73 C::execution_sel_execute_get_env_var,
74 C::execution_sel_execute_mov,
75 C::execution_sel_execute_mov,
76 C::execution_sel_execute_jump,
77 C::execution_sel_execute_jumpi,
78 C::execution_sel_execute_call,
79 C::execution_sel_execute_internal_call,
80 C::execution_sel_execute_internal_return,
81 C::execution_sel_execute_return,
82 C::execution_sel_execute_success_copy,
83 C::execution_sel_execute_static_call,
84 C::execution_sel_execute_revert,
85 C::execution_sel_execute_revert,
86 C::execution_sel_execute_returndata_size,
87 C::execution_sel_execute_debug_log,
88 C::execution_sel_execute_sload,
89 C::execution_sel_execute_sstore,
90 C::execution_sel_execute_notehash_exists,
91 C::execution_sel_execute_emit_notehash,
92 C::execution_sel_execute_l1_to_l2_message_exists,
93 C::execution_sel_execute_nullifier_exists,
94 C::execution_sel_execute_emit_nullifier,
95 C::execution_sel_execute_send_l2_to_l1_msg,
100TEST(ExecOpIdConstrainingTest, WireOpcodeListCompleteness)
103 const auto wire_opcode =
static_cast<WireOpCode>(opcode);
108 if (subtrace_info.subtrace_selector == SubtraceSel::EXECUTION) {
109 EXPECT_TRUE(
std::find(WIRE_OPCODES.begin(), WIRE_OPCODES.end(), wire_opcode) != WIRE_OPCODES.end());
118constexpr size_t INCREMENT_FOR_NEGATIVE_TEST = 6;
121TEST(ExecOpIdConstrainingTest, DISABLED_Decomposition)
123 for (
size_t i = 0; i < WIRE_OPCODES.size(); i++) {
124 TestTraceContainer
trace({
126 { C::execution_sel_execute_execution, 1 },
127 { C::execution_subtrace_operation_id, OPERATION_IDS.at(i) },
128 { SELECTOR_COLUMNS.at(i), 1 },
135 trace.
set(SELECTOR_COLUMNS.at(i), 0, 0);
137 "EXEC_OP_ID_DECOMPOSITION");
140 trace.
set(SELECTOR_COLUMNS.at((i + INCREMENT_FOR_NEGATIVE_TEST) % WIRE_OPCODES.size()), 0, 1);
142 "EXEC_OP_ID_DECOMPOSITION");
150TEST(ExecOpIdConstrainingTest, DISABLED_InteractionWithExecInstructionSpec)
155 events.reserve(WIRE_OPCODES.size());
156 for (
const auto& wire_opcode : WIRE_OPCODES) {
158 .wire_instruction = InstructionBuilder(wire_opcode).build(),
162 TestTraceContainer
trace;
163 ExecutionTraceBuilder exec_builder;
166 for (
const auto&
event : events) {
167 exec_builder.process_execution_spec(
event,
trace, row);
172 for (
size_t i = 0; i < WIRE_OPCODES.size(); i++) {
173 ASSERT_EQ(
trace.
get(C::execution_subtrace_operation_id,
static_cast<uint32_t
>(i + 1)), OPERATION_IDS.at(i));
175 ASSERT_EQ(
trace.
get(C::execution_sel_execute_execution,
static_cast<uint32_t
>(i + 1)), 1);
181 for (
size_t i = 0; i < WIRE_OPCODES.size(); i++) {
182 trace.
set(C::execution_sel_instruction_fetching_success,
static_cast<uint32_t
>(i + 1), 1);
183 trace.
set(C::execution_sel,
static_cast<uint32_t
>(i + 1), 1);
185 static_cast<uint32_t
>(i + 1),
186 static_cast<uint8_t
>(events.at(i).wire_instruction.get_exec_opcode()));
194 check_interaction<ExecutionTraceBuilder, lookup_execution_exec_spec_read_settings>(
trace);
197 for (
size_t i = 0; i < WIRE_OPCODES.size(); i++) {
198 auto mutated_trace =
trace;
199 mutated_trace.
set(C::execution_subtrace_operation_id,
200 static_cast<uint32_t
>(i + 1),
201 OPERATION_IDS.at((i + INCREMENT_FOR_NEGATIVE_TEST) % WIRE_OPCODES.size()));
203 (check_interaction<ExecutionTraceBuilder, lookup_execution_exec_spec_read_settings>(mutated_trace)),
204 "Failed.*LOOKUP_EXECUTION_EXEC_SPEC_READ.*Could not find tuple in destination.");
#define AVM_EXEC_OP_ID_SUCCESSCOPY
#define AVM_EXEC_OP_ID_NULLIFIER_EXISTS
#define AVM_EXEC_OP_ID_SSTORE
#define AVM_EXEC_OP_ID_EMIT_NULLIFIER
#define AVM_EXEC_OP_ID_NOTEHASH_EXISTS
#define AVM_EXEC_OP_ID_SLOAD
#define AVM_EXEC_OP_ID_RETURN
#define AVM_EXEC_OP_ID_INTERNALCALL
#define AVM_EXEC_OP_ID_STATICCALL
#define AVM_EXEC_OP_ID_JUMP
#define AVM_EXEC_OP_ID_DEBUGLOG
#define AVM_EXEC_OP_ID_EMIT_NOTEHASH
#define AVM_EXEC_OP_ID_REVERT
#define AVM_EXEC_OP_ID_MOV
#define AVM_EXEC_OP_ID_SENDL2TOL1MSG
#define AVM_EXEC_OP_ID_RETURNDATASIZE
#define AVM_EXEC_OP_ID_CALL
#define AVM_EXEC_OP_ID_JUMPI
#define AVM_EXEC_OP_ID_L1_TO_L2_MESSAGE_EXISTS
#define AVM_EXEC_OP_ID_GETENVVAR
#define AVM_EXEC_OP_ID_INTERNALRETURN
#define AVM_SUBTRACE_ID_EXECUTION
static constexpr size_t SR_EXEC_OP_ID_DECOMPOSITION
const FF & get(Column col, uint32_t row) const
void set(Column col, uint32_t row, const FF &value)
PrecomputedTraceBuilder precomputed_builder
#define EXPECT_THROW_WITH_MESSAGE(code, expectedMessage)
TEST(TxExecutionConstrainingTest, WriteTreeValue)
const std::unordered_map< ExecutionOpCode, SubtraceInfo > SUBTRACE_INFO_MAP
const std::unordered_map< WireOpCode, WireInstructionSpec > WIRE_INSTRUCTION_SPEC
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
simulation::PublicDataTreeReadWriteEvent event
NiceMock< MockExecution > execution