Skip to content

Commit

Permalink
5542: rename set opcode method in avm_trace.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanmon committed Apr 3, 2024
1 parent 0249737 commit 971a2c2
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ std::vector<Row> Execution::gen_trace(std::vector<Instruction> const& instructio
break;
}

trace_builder.set(val, dst_offset, in_tag);
trace_builder.op_set(val, dst_offset, in_tag);
break;
}
case OpCode::MOV:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ void AvmTraceBuilder::op_xor(
* @param dst_offset Memory destination offset where val is written to
* @param in_tag The instruction memory tag
*/
void AvmTraceBuilder::set(uint128_t val, uint32_t dst_offset, AvmMemoryTag in_tag)
void AvmTraceBuilder::op_set(uint128_t val, uint32_t dst_offset, AvmMemoryTag in_tag)
{
auto clk = static_cast<uint32_t>(main_trace.size());
auto val_ff = FF{ uint256_t::from_uint128(val) };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class AvmTraceBuilder {
void op_xor(uint8_t indirect, uint32_t a_offset, uint32_t b_offset, uint32_t dst_offset, AvmMemoryTag in_tag);

// Set a constant from bytecode with direct memory access.
void set(uint128_t val, uint32_t dst_offset, AvmMemoryTag in_tag);
void op_set(uint128_t val, uint32_t dst_offset, AvmMemoryTag in_tag);

// Move (copy) the value and tag of a memory cell to another one.
void op_mov(uint8_t indirect, uint32_t src_offset, uint32_t dst_offset);
Expand Down
140 changes: 70 additions & 70 deletions barretenberg/cpp/src/barretenberg/vm/tests/avm_arithmetic.test.cpp

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions barretenberg/cpp/src/barretenberg/vm/tests/avm_bitwise.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void common_validate_bit_op(std::vector<Row> const& trace,
std::vector<Row> gen_mutated_trace_not(FF const& a, FF const& c_mutated, avm_trace::AvmMemoryTag tag)
{
auto trace_builder = avm_trace::AvmTraceBuilder();
trace_builder.set(uint128_t{ a }, 0, tag);
trace_builder.op_set(uint128_t{ a }, 0, tag);
trace_builder.op_not(0, 0, 1, tag);
trace_builder.halt();
auto trace = trace_builder.finalize();
Expand Down Expand Up @@ -348,7 +348,7 @@ TEST_P(AvmBitwiseTestsNot, ParamTest)
{
const auto [operands, mem_tag] = GetParam();
const auto [a, output] = operands;
trace_builder.set(a, 0, mem_tag);
trace_builder.op_set(a, 0, mem_tag);
trace_builder.op_not(0, 0, 1, mem_tag); // [1,254,0,0,....]
trace_builder.return_op(0, 0, 0);
auto trace = trace_builder.finalize();
Expand All @@ -366,8 +366,8 @@ TEST_P(AvmBitwiseTestsAnd, AllAndTest)
{
const auto [operands, mem_tag] = GetParam();
const auto [a, b, output] = operands;
trace_builder.set(a, 0, mem_tag);
trace_builder.set(b, 1, mem_tag);
trace_builder.op_set(a, 0, mem_tag);
trace_builder.op_set(b, 1, mem_tag);
trace_builder.op_and(0, 0, 1, 2, mem_tag);
trace_builder.return_op(0, 2, 1);

Expand All @@ -387,8 +387,8 @@ TEST_P(AvmBitwiseTestsOr, AllOrTest)
{
const auto [operands, mem_tag] = GetParam();
const auto [a, b, output] = operands;
trace_builder.set(a, 0, mem_tag);
trace_builder.set(b, 1, mem_tag);
trace_builder.op_set(a, 0, mem_tag);
trace_builder.op_set(b, 1, mem_tag);
trace_builder.op_or(0, 0, 1, 2, mem_tag);
trace_builder.return_op(0, 2, 1);
auto trace = trace_builder.finalize();
Expand All @@ -408,8 +408,8 @@ TEST_P(AvmBitwiseTestsXor, AllXorTest)
{
const auto [operands, mem_tag] = GetParam();
const auto [a, b, output] = operands;
trace_builder.set(a, 0, mem_tag);
trace_builder.set(b, 1, mem_tag);
trace_builder.op_set(a, 0, mem_tag);
trace_builder.op_set(b, 1, mem_tag);
trace_builder.op_xor(0, 0, 1, 2, mem_tag);
trace_builder.return_op(0, 2, 1);
auto trace = trace_builder.finalize();
Expand Down Expand Up @@ -473,8 +473,8 @@ TEST_P(AvmBitwiseNegativeTestsAnd, AllNegativeTests)
const auto [operands, mem_tag] = params;
const auto [a, b, output] = operands;
auto trace_builder = avm_trace::AvmTraceBuilder();
trace_builder.set(uint128_t{ a }, 0, mem_tag);
trace_builder.set(uint128_t{ b }, 1, mem_tag);
trace_builder.op_set(uint128_t{ a }, 0, mem_tag);
trace_builder.op_set(uint128_t{ b }, 1, mem_tag);
trace_builder.op_and(0, 0, 1, 2, mem_tag);
trace_builder.halt();
auto trace = trace_builder.finalize();
Expand All @@ -494,8 +494,8 @@ TEST_P(AvmBitwiseNegativeTestsOr, AllNegativeTests)
const auto [operands, mem_tag] = params;
const auto [a, b, output] = operands;
auto trace_builder = avm_trace::AvmTraceBuilder();
trace_builder.set(uint128_t{ a }, 0, mem_tag);
trace_builder.set(uint128_t{ b }, 1, mem_tag);
trace_builder.op_set(uint128_t{ a }, 0, mem_tag);
trace_builder.op_set(uint128_t{ b }, 1, mem_tag);
trace_builder.op_or(0, 0, 1, 2, mem_tag);
trace_builder.halt();
auto trace = trace_builder.finalize();
Expand All @@ -514,8 +514,8 @@ TEST_P(AvmBitwiseNegativeTestsXor, AllNegativeTests)
const auto [operands, mem_tag] = params;
const auto [a, b, output] = operands;
auto trace_builder = avm_trace::AvmTraceBuilder();
trace_builder.set(uint128_t{ a }, 0, mem_tag);
trace_builder.set(uint128_t{ b }, 1, mem_tag);
trace_builder.op_set(uint128_t{ a }, 0, mem_tag);
trace_builder.op_set(uint128_t{ b }, 1, mem_tag);
trace_builder.op_xor(0, 0, 1, 2, mem_tag);
trace_builder.halt();
auto trace = trace_builder.finalize();
Expand All @@ -532,7 +532,7 @@ TEST_F(AvmBitwiseNegativeTestsFF, UndefinedOverFF)
{
auto trace_builder = avm_trace::AvmTraceBuilder();
// Triggers a write row 1 of mem_trace and alu_trace
trace_builder.set(10, 0, AvmMemoryTag::U8);
trace_builder.op_set(10, 0, AvmMemoryTag::U8);
// Triggers a write in row 2 of alu_trace
trace_builder.op_not(0, 0, 1, AvmMemoryTag::U8);
// Finally, we will have a write in row 3 of the mem_trace to copy the result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ class AvmIndirectMemTests : public ::testing::Test {
TEST_F(AvmIndirectMemTests, allIndirectAdd)
{
// Set direct addresses
trace_builder.set(10, 0, AvmMemoryTag::U32);
trace_builder.set(11, 1, AvmMemoryTag::U32);
trace_builder.set(12, 2, AvmMemoryTag::U32);
trace_builder.op_set(10, 0, AvmMemoryTag::U32);
trace_builder.op_set(11, 1, AvmMemoryTag::U32);
trace_builder.op_set(12, 2, AvmMemoryTag::U32);

// Set input values
trace_builder.set(100, 10, AvmMemoryTag::U16);
trace_builder.set(101, 11, AvmMemoryTag::U16);
trace_builder.op_set(100, 10, AvmMemoryTag::U16);
trace_builder.op_set(101, 11, AvmMemoryTag::U16);

// All indirect flags are encoded as 7 = 1 + 2 + 4
trace_builder.op_add(7, 0, 1, 2, AvmMemoryTag::U16);
Expand Down Expand Up @@ -74,11 +74,11 @@ TEST_F(AvmIndirectMemTests, allIndirectAdd)
TEST_F(AvmIndirectMemTests, indirectOutputSub)
{
// Set direct output address
trace_builder.set(52, 5, AvmMemoryTag::U32);
trace_builder.op_set(52, 5, AvmMemoryTag::U32);

// Set input values
trace_builder.set(600, 50, AvmMemoryTag::U128);
trace_builder.set(500, 51, AvmMemoryTag::U128);
trace_builder.op_set(600, 50, AvmMemoryTag::U128);
trace_builder.op_set(500, 51, AvmMemoryTag::U128);

// The indirect flag is encoded as 4
trace_builder.op_sub(4, 50, 51, 5, AvmMemoryTag::U128);
Expand Down Expand Up @@ -120,11 +120,11 @@ TEST_F(AvmIndirectMemTests, indirectOutputSub)
TEST_F(AvmIndirectMemTests, indirectInputAMul)
{
// Set direct input address for a
trace_builder.set(100, 1000, AvmMemoryTag::U32);
trace_builder.op_set(100, 1000, AvmMemoryTag::U32);

// Set input values
trace_builder.set(4, 100, AvmMemoryTag::U64);
trace_builder.set(7, 101, AvmMemoryTag::U64);
trace_builder.op_set(4, 100, AvmMemoryTag::U64);
trace_builder.op_set(7, 101, AvmMemoryTag::U64);

// The indirect flag is encoded as 1
trace_builder.op_mul(1, 1000, 101, 102, AvmMemoryTag::U64);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class AvmInterTableTests : public ::testing::Test {
TEST_F(AvmInterTableTests, tagErrNotCopiedInMain)
{
// Equality operation on U128 and second operand is of type U16.
trace_builder.set(32, 18, AvmMemoryTag::U128);
trace_builder.set(32, 76, AvmMemoryTag::U16);
trace_builder.op_set(32, 18, AvmMemoryTag::U128);
trace_builder.op_set(32, 76, AvmMemoryTag::U16);
trace_builder.op_eq(0, 18, 76, 65, AvmMemoryTag::U128);
trace_builder.halt();
auto trace = trace_builder.finalize();
Expand Down Expand Up @@ -87,8 +87,8 @@ class AvmPermMainAluNegativeTests : public AvmInterTableTests {
{
AvmInterTableTests::SetUp();

trace_builder.set(19, 0, AvmMemoryTag::U64);
trace_builder.set(15, 1, AvmMemoryTag::U64);
trace_builder.op_set(19, 0, AvmMemoryTag::U64);
trace_builder.op_set(15, 1, AvmMemoryTag::U64);
trace_builder.op_add(0, 0, 1, 1, AvmMemoryTag::U64); // 19 + 15 = 34
trace_builder.op_add(0, 0, 1, 1, AvmMemoryTag::U64); // 19 + 34 = 53
trace_builder.op_mul(0, 0, 1, 2, AvmMemoryTag::U64); // 19 * 53 = 1007
Expand Down Expand Up @@ -187,8 +187,8 @@ class AvmPermMainMemNegativeTests : public AvmInterTableTests {
// for c = a - b at arbitray chosen addresses 52 (a), 11 (b), 55 (c).
void executeSub(uint128_t const a, uint128_t const b)
{
trace_builder.set(a, 52, AvmMemoryTag::U8);
trace_builder.set(b, 11, AvmMemoryTag::U8);
trace_builder.op_set(a, 52, AvmMemoryTag::U8);
trace_builder.op_set(b, 11, AvmMemoryTag::U8);
trace_builder.op_sub(0, 52, 11, 55, AvmMemoryTag::U8);
trace_builder.return_op(0, 0, 0);

Expand Down
20 changes: 10 additions & 10 deletions barretenberg/cpp/src/barretenberg/vm/tests/avm_mem_opcodes.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ class AvmMemOpcodeTests : public ::testing::Test {
uint32_t dir_dst_offset = 0)
{
if (indirect) {
trace_builder.set(dir_src_offset, src_offset, AvmMemoryTag::U32);
trace_builder.set(dir_dst_offset, dst_offset, AvmMemoryTag::U32);
trace_builder.set(val, dir_src_offset, tag);
trace_builder.op_set(dir_src_offset, src_offset, AvmMemoryTag::U32);
trace_builder.op_set(dir_dst_offset, dst_offset, AvmMemoryTag::U32);
trace_builder.op_set(val, dir_src_offset, tag);
} else {
trace_builder.set(val, src_offset, tag);
trace_builder.op_set(val, src_offset, tag);
}

trace_builder.op_mov(indirect ? 3 : 0, src_offset, dst_offset);
Expand Down Expand Up @@ -174,7 +174,7 @@ TEST_F(AvmMemOpcodeTests, sameAddressMov)
TEST_F(AvmMemOpcodeTests, uninitializedValueMov)
{
auto trace_builder = AvmTraceBuilder();
trace_builder.set(4, 1, AvmMemoryTag::U32);
trace_builder.op_set(4, 1, AvmMemoryTag::U32);
trace_builder.op_mov(0, 0, 1);
trace_builder.return_op(0, 0, 0);
trace = trace_builder.finalize();
Expand All @@ -185,8 +185,8 @@ TEST_F(AvmMemOpcodeTests, uninitializedValueMov)
TEST_F(AvmMemOpcodeTests, indUninitializedValueMov)
{
auto trace_builder = AvmTraceBuilder();
trace_builder.set(1, 3, AvmMemoryTag::U32);
trace_builder.set(4, 1, AvmMemoryTag::U32);
trace_builder.op_set(1, 3, AvmMemoryTag::U32);
trace_builder.op_set(4, 1, AvmMemoryTag::U32);
trace_builder.op_mov(3, 2, 3);
trace_builder.return_op(0, 0, 0);
trace = trace_builder.finalize();
Expand All @@ -202,9 +202,9 @@ TEST_F(AvmMemOpcodeTests, indirectMov)

TEST_F(AvmMemOpcodeTests, indirectMovInvalidAddressTag)
{
trace_builder.set(15, 100, AvmMemoryTag::U32);
trace_builder.set(16, 101, AvmMemoryTag::U128); // This will make the indirect load failing.
trace_builder.set(5, 15, AvmMemoryTag::FF);
trace_builder.op_set(15, 100, AvmMemoryTag::U32);
trace_builder.op_set(16, 101, AvmMemoryTag::U128); // This will make the indirect load failing.
trace_builder.op_set(5, 15, AvmMemoryTag::FF);
trace_builder.op_mov(3, 100, 101);
trace_builder.return_op(0, 0, 0);
trace = trace_builder.finalize();
Expand Down
16 changes: 8 additions & 8 deletions barretenberg/cpp/src/barretenberg/vm/tests/avm_memory.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ TEST_F(AvmMemoryTests, mismatchedTagAddOperation)
// The proof must pass and we check that the AVM error is raised.
TEST_F(AvmMemoryTests, mismatchedTagEqOperation)
{
trace_builder.set(3, 0, AvmMemoryTag::U32);
trace_builder.set(5, 1, AvmMemoryTag::U16);
trace_builder.op_set(3, 0, AvmMemoryTag::U32);
trace_builder.op_set(5, 1, AvmMemoryTag::U16);

trace_builder.op_eq(0, 0, 1, 2, AvmMemoryTag::U32);
trace_builder.halt();
Expand Down Expand Up @@ -119,8 +119,8 @@ TEST_F(AvmMemoryTests, mismatchedTagEqOperation)
// in the memory trace
TEST_F(AvmMemoryTests, mLastAccessViolation)
{
trace_builder.set(4, 0, AvmMemoryTag::U8);
trace_builder.set(9, 1, AvmMemoryTag::U8);
trace_builder.op_set(4, 0, AvmMemoryTag::U8);
trace_builder.op_set(9, 1, AvmMemoryTag::U8);

// Memory layout: [4,9,0,0,0,0,....]
trace_builder.op_sub(0, 1, 0, 2, AvmMemoryTag::U8); // [4,9,5,0,0,0.....]
Expand Down Expand Up @@ -150,8 +150,8 @@ TEST_F(AvmMemoryTests, mLastAccessViolation)
// written into memory
TEST_F(AvmMemoryTests, readWriteConsistencyValViolation)
{
trace_builder.set(4, 0, AvmMemoryTag::U8);
trace_builder.set(9, 1, AvmMemoryTag::U8);
trace_builder.op_set(4, 0, AvmMemoryTag::U8);
trace_builder.op_set(9, 1, AvmMemoryTag::U8);

// Memory layout: [4,9,0,0,0,0,....]
trace_builder.op_mul(0, 1, 0, 2, AvmMemoryTag::U8); // [4,9,36,0,0,0.....]
Expand Down Expand Up @@ -180,8 +180,8 @@ TEST_F(AvmMemoryTests, readWriteConsistencyValViolation)
// written into memory
TEST_F(AvmMemoryTests, readWriteConsistencyTagViolation)
{
trace_builder.set(4, 0, AvmMemoryTag::U8);
trace_builder.set(9, 1, AvmMemoryTag::U8);
trace_builder.op_set(4, 0, AvmMemoryTag::U8);
trace_builder.op_set(9, 1, AvmMemoryTag::U8);

// Memory layout: [4,9,0,0,0,0,....]
trace_builder.op_mul(0, 1, 0, 2, AvmMemoryTag::U8); // [4,9,36,0,0,0.....]
Expand Down

0 comments on commit 971a2c2

Please sign in to comment.