Skip to content

Commit 3201187

Browse files
author
jeanmon
committed
7080: repair unit tests related to unitialized indirect memory in a MOV
1 parent 7447b6c commit 3201187

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

barretenberg/cpp/pil/avm/main.pil

+5
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,11 @@ namespace main(256);
487487
sel_gas_accounting_active - OPCODE_SELECTORS - SEL_ALL_CTRL_FLOW - sel_op_sload - sel_op_sstore - sel_mem_op_activate_gas = 0;
488488

489489
// Program counter must increment if not jumping or returning
490+
// TODO: support for muli-rows opcode in execution trace such as
491+
// radix, hash gadgets operations. At the moment, we have to increment
492+
// the pc in witness generation for all rows pertaining to the original
493+
// opcode. This is misleading. Ultimately, we want the pc to be incremented
494+
// just after the last row of a given opcode.
490495
#[PC_INCREMENT]
491496
(1 - sel_first) * (1 - sel_op_halt) * OPCODE_SELECTORS * (pc' - (pc + 1)) = 0;
492497

barretenberg/cpp/src/barretenberg/vm/tests/avm_mem_opcodes.test.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ class AvmMemOpcodeTests : public ::testing::Test {
173173
uint32_t dst_offset,
174174
AvmMemoryTag tag,
175175
uint32_t dir_src_offset = 0,
176-
uint32_t dir_dst_offset = 0)
176+
uint32_t dir_dst_offset = 0,
177+
bool indirect_uninitialized = false)
177178
{
178179
compute_mov_indices(indirect);
179180
FF const val_ff = uint256_t::from_uint128(val);
@@ -220,7 +221,9 @@ class AvmMemOpcodeTests : public ::testing::Test {
220221
EXPECT_THAT(mem_ind_a_row,
221222
AllOf(MEM_ROW_FIELD_EQ(tag_err, 0),
222223
MEM_ROW_FIELD_EQ(r_in_tag, static_cast<uint32_t>(AvmMemoryTag::U32)),
223-
MEM_ROW_FIELD_EQ(tag, static_cast<uint32_t>(AvmMemoryTag::U32)),
224+
MEM_ROW_FIELD_EQ(tag,
225+
indirect_uninitialized ? static_cast<uint32_t>(AvmMemoryTag::U0)
226+
: static_cast<uint32_t>(AvmMemoryTag::U32)),
224227
MEM_ROW_FIELD_EQ(addr, src_offset),
225228
MEM_ROW_FIELD_EQ(val, dir_src_offset),
226229
MEM_ROW_FIELD_EQ(sel_resolve_ind_addr_a, 1)));
@@ -376,7 +379,7 @@ TEST_F(AvmMemOpcodeTests, indUninitializedValueMov)
376379
trace_builder.return_op(0, 0, 0);
377380
trace = trace_builder.finalize();
378381

379-
validate_mov_trace(true, 0, 2, 3, AvmMemoryTag::U0, 0, 1);
382+
validate_mov_trace(true, 0, 2, 3, AvmMemoryTag::U0, 0, 1, true);
380383
}
381384

382385
TEST_F(AvmMemOpcodeTests, indirectMov)

0 commit comments

Comments
 (0)