Skip to content

Commit

Permalink
7080: repair unit tests related to unitialized indirect memory in a MOV
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanmon committed Jun 20, 2024
1 parent 7447b6c commit 3201187
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions barretenberg/cpp/pil/avm/main.pil
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,11 @@ namespace main(256);
sel_gas_accounting_active - OPCODE_SELECTORS - SEL_ALL_CTRL_FLOW - sel_op_sload - sel_op_sstore - sel_mem_op_activate_gas = 0;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ class AvmMemOpcodeTests : public ::testing::Test {
uint32_t dst_offset,
AvmMemoryTag tag,
uint32_t dir_src_offset = 0,
uint32_t dir_dst_offset = 0)
uint32_t dir_dst_offset = 0,
bool indirect_uninitialized = false)
{
compute_mov_indices(indirect);
FF const val_ff = uint256_t::from_uint128(val);
Expand Down Expand Up @@ -220,7 +221,9 @@ class AvmMemOpcodeTests : public ::testing::Test {
EXPECT_THAT(mem_ind_a_row,
AllOf(MEM_ROW_FIELD_EQ(tag_err, 0),
MEM_ROW_FIELD_EQ(r_in_tag, static_cast<uint32_t>(AvmMemoryTag::U32)),
MEM_ROW_FIELD_EQ(tag, static_cast<uint32_t>(AvmMemoryTag::U32)),
MEM_ROW_FIELD_EQ(tag,
indirect_uninitialized ? static_cast<uint32_t>(AvmMemoryTag::U0)
: static_cast<uint32_t>(AvmMemoryTag::U32)),
MEM_ROW_FIELD_EQ(addr, src_offset),
MEM_ROW_FIELD_EQ(val, dir_src_offset),
MEM_ROW_FIELD_EQ(sel_resolve_ind_addr_a, 1)));
Expand Down Expand Up @@ -376,7 +379,7 @@ TEST_F(AvmMemOpcodeTests, indUninitializedValueMov)
trace_builder.return_op(0, 0, 0);
trace = trace_builder.finalize();

validate_mov_trace(true, 0, 2, 3, AvmMemoryTag::U0, 0, 1);
validate_mov_trace(true, 0, 2, 3, AvmMemoryTag::U0, 0, 1, true);
}

TEST_F(AvmMemOpcodeTests, indirectMov)
Expand Down

0 comments on commit 3201187

Please sign in to comment.