Skip to content

Commit

Permalink
3791: rename call_data_copy to calldata_copy
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanmon committed Jan 25, 2024
1 parent eb01dbd commit d028db6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ std::vector<Row> Execution::gen_trace(std::vector<Instruction> const& instructio
trace_builder.div(inst.operands.at(0), inst.operands.at(1), inst.operands.at(2), inst.in_tag);
break;
case OpCode::CALLDATACOPY:
trace_builder.call_data_copy(inst.operands.at(0), inst.operands.at(1), inst.operands.at(2), calldata);
trace_builder.calldata_copy(inst.operands.at(0), inst.operands.at(1), inst.operands.at(2), calldata);
break;
case OpCode::JUMP:
trace_builder.jump(inst.operands.at(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,10 @@ void AvmMiniTraceBuilder::set(uint128_t val, uint32_t dst_offset, AvmMemoryTag i
* @param dst_offset The starting index of memory where calldata will be copied to.
* @param call_data_mem The vector containing calldata.
*/
void AvmMiniTraceBuilder::call_data_copy(uint32_t cd_offset,
uint32_t copy_size,
uint32_t dst_offset,
std::vector<FF> const& call_data_mem)
void AvmMiniTraceBuilder::calldata_copy(uint32_t cd_offset,
uint32_t copy_size,
uint32_t dst_offset,
std::vector<FF> const& call_data_mem)
{
// We parallelize storing memory operations in chunk of 3, i.e., 1 per intermediate register.
// The variable pos is an index pointing to the first storing operation (pertaining to intermediate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ class AvmMiniTraceBuilder {

// CALLDATACOPY opcode with direct memory access, i.e.,
// M[dst_offset:dst_offset+copy_size] = calldata[cd_offset:cd_offset+copy_size]
void call_data_copy(uint32_t cd_offset,
uint32_t copy_size,
uint32_t dst_offset,
std::vector<FF> const& call_data_mem);
void calldata_copy(uint32_t cd_offset,
uint32_t copy_size,
uint32_t dst_offset,
std::vector<FF> const& call_data_mem);

// RETURN opcode with direct memory access, i.e.,
// return(M[ret_offset:ret_offset+ret_size])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class AvmMiniArithmeticNegativeTestsU128 : public AvmMiniArithmeticTests {};
TEST_F(AvmMiniArithmeticTestsFF, addition)
{
// trace_builder
trace_builder.call_data_copy(0, 3, 0, std::vector<FF>{ 37, 4, 11 });
trace_builder.calldata_copy(0, 3, 0, std::vector<FF>{ 37, 4, 11 });

// Memory layout: [37,4,11,0,0,0,....]
trace_builder.add(0, 1, 4, AvmMemoryTag::FF); // [37,4,11,0,41,0,....]
Expand All @@ -265,7 +265,7 @@ TEST_F(AvmMiniArithmeticTestsFF, addition)
// Test on basic subtraction over finite field type.
TEST_F(AvmMiniArithmeticTestsFF, subtraction)
{
trace_builder.call_data_copy(0, 3, 0, std::vector<FF>{ 8, 4, 17 });
trace_builder.calldata_copy(0, 3, 0, std::vector<FF>{ 8, 4, 17 });

// Memory layout: [8,4,17,0,0,0,....]
trace_builder.sub(2, 0, 1, AvmMemoryTag::FF); // [8,9,17,0,0,0....]
Expand All @@ -284,7 +284,7 @@ TEST_F(AvmMiniArithmeticTestsFF, subtraction)
// Test on basic multiplication over finite field type.
TEST_F(AvmMiniArithmeticTestsFF, multiplication)
{
trace_builder.call_data_copy(0, 3, 0, std::vector<FF>{ 5, 0, 20 });
trace_builder.calldata_copy(0, 3, 0, std::vector<FF>{ 5, 0, 20 });

// Memory layout: [5,0,20,0,0,0,....]
trace_builder.mul(2, 0, 1, AvmMemoryTag::FF); // [5,100,20,0,0,0....]
Expand All @@ -304,7 +304,7 @@ TEST_F(AvmMiniArithmeticTestsFF, multiplication)
// Test on multiplication by zero over finite field type.
TEST_F(AvmMiniArithmeticTestsFF, multiplicationByZero)
{
trace_builder.call_data_copy(0, 1, 0, std::vector<FF>{ 127 });
trace_builder.calldata_copy(0, 1, 0, std::vector<FF>{ 127 });

// Memory layout: [127,0,0,0,0,0,....]
trace_builder.mul(0, 1, 2, AvmMemoryTag::FF); // [127,0,0,0,0,0....]
Expand All @@ -324,7 +324,7 @@ TEST_F(AvmMiniArithmeticTestsFF, multiplicationByZero)
// Test on basic division over finite field type.
TEST_F(AvmMiniArithmeticTestsFF, division)
{
trace_builder.call_data_copy(0, 2, 0, std::vector<FF>{ 15, 315 });
trace_builder.calldata_copy(0, 2, 0, std::vector<FF>{ 15, 315 });

// Memory layout: [15,315,0,0,0,0,....]
trace_builder.div(1, 0, 2, AvmMemoryTag::FF); // [15,315,21,0,0,0....]
Expand All @@ -347,7 +347,7 @@ TEST_F(AvmMiniArithmeticTestsFF, division)
// Test on division with zero numerator over finite field type.
TEST_F(AvmMiniArithmeticTestsFF, divisionNumeratorZero)
{
trace_builder.call_data_copy(0, 1, 0, std::vector<FF>{ 15 });
trace_builder.calldata_copy(0, 1, 0, std::vector<FF>{ 15 });

// Memory layout: [15,0,0,0,0,0,....]
trace_builder.div(1, 0, 0, AvmMemoryTag::FF); // [0,0,0,0,0,0....]
Expand All @@ -371,7 +371,7 @@ TEST_F(AvmMiniArithmeticTestsFF, divisionNumeratorZero)
// We check that the operator error flag is raised.
TEST_F(AvmMiniArithmeticTestsFF, divisionByZeroError)
{
trace_builder.call_data_copy(0, 1, 0, std::vector<FF>{ 15 });
trace_builder.calldata_copy(0, 1, 0, std::vector<FF>{ 15 });

// Memory layout: [15,0,0,0,0,0,....]
trace_builder.div(0, 1, 2, AvmMemoryTag::FF); // [15,0,0,0,0,0....]
Expand Down Expand Up @@ -421,7 +421,7 @@ TEST_F(AvmMiniArithmeticTestsFF, divisionZeroByZeroError)
// No check on the evaluation is performed here.
TEST_F(AvmMiniArithmeticTestsFF, mixedOperationsWithError)
{
trace_builder.call_data_copy(0, 3, 2, std::vector<FF>{ 45, 23, 12 });
trace_builder.calldata_copy(0, 3, 2, std::vector<FF>{ 45, 23, 12 });

// Memory layout: [0,0,45,23,12,0,0,0,....]
trace_builder.add(2, 3, 4, AvmMemoryTag::FF); // [0,0,45,23,68,0,0,0,....]
Expand Down Expand Up @@ -1399,7 +1399,7 @@ TEST_F(AvmMiniArithmeticNegativeTestsFF, multiplication)
// Test on basic incorrect division over finite field type.
TEST_F(AvmMiniArithmeticNegativeTestsFF, divisionFF)
{
trace_builder.call_data_copy(0, 2, 0, std::vector<FF>{ 15, 315 });
trace_builder.calldata_copy(0, 2, 0, std::vector<FF>{ 15, 315 });

// Memory layout: [15,315,0,0,0,0,....]
trace_builder.div(1, 0, 2, AvmMemoryTag::FF); // [15,315,21,0,0,0....]
Expand All @@ -1416,7 +1416,7 @@ TEST_F(AvmMiniArithmeticNegativeTestsFF, divisionFF)
// in the trace.
TEST_F(AvmMiniArithmeticNegativeTestsFF, divisionNoZeroButError)
{
trace_builder.call_data_copy(0, 2, 0, std::vector<FF>{ 15, 315 });
trace_builder.calldata_copy(0, 2, 0, std::vector<FF>{ 15, 315 });

// Memory layout: [15,315,0,0,0,0,....]
trace_builder.div(1, 0, 2, AvmMemoryTag::FF); // [15,315,21,0,0,0....]
Expand All @@ -1442,7 +1442,7 @@ TEST_F(AvmMiniArithmeticNegativeTestsFF, divisionNoZeroButError)
// Test with division by zero occurs and no error is raised (remove error flag)
TEST_F(AvmMiniArithmeticNegativeTestsFF, divisionByZeroNoError)
{
trace_builder.call_data_copy(0, 1, 0, std::vector<FF>{ 15 });
trace_builder.calldata_copy(0, 1, 0, std::vector<FF>{ 15 });

// Memory layout: [15,0,0,0,0,0,....]
trace_builder.div(0, 1, 2, AvmMemoryTag::FF); // [15,0,0,0,0,0....]
Expand Down Expand Up @@ -1479,7 +1479,7 @@ TEST_F(AvmMiniArithmeticNegativeTestsFF, divisionZeroByZeroNoError)
// the addition, subtraction, multiplication.
TEST_F(AvmMiniArithmeticNegativeTestsFF, operationWithErrorFlag)
{
trace_builder.call_data_copy(0, 3, 0, std::vector<FF>{ 37, 4, 11 });
trace_builder.calldata_copy(0, 3, 0, std::vector<FF>{ 37, 4, 11 });

// Memory layout: [37,4,11,0,0,0,....]
trace_builder.add(0, 1, 4, AvmMemoryTag::FF); // [37,4,11,0,41,0,....]
Expand All @@ -1497,7 +1497,7 @@ TEST_F(AvmMiniArithmeticNegativeTestsFF, operationWithErrorFlag)

trace_builder.reset();

trace_builder.call_data_copy(0, 3, 0, std::vector<FF>{ 8, 4, 17 });
trace_builder.calldata_copy(0, 3, 0, std::vector<FF>{ 8, 4, 17 });

// Memory layout: [8,4,17,0,0,0,....]
trace_builder.sub(2, 0, 1, AvmMemoryTag::FF); // [8,9,17,0,0,0....]
Expand All @@ -1514,7 +1514,7 @@ TEST_F(AvmMiniArithmeticNegativeTestsFF, operationWithErrorFlag)

trace_builder.reset();

trace_builder.call_data_copy(0, 3, 0, std::vector<FF>{ 5, 0, 20 });
trace_builder.calldata_copy(0, 3, 0, std::vector<FF>{ 5, 0, 20 });

// Memory layout: [5,0,20,0,0,0,....]
trace_builder.mul(2, 0, 1, AvmMemoryTag::FF); // [5,100,20,0,0,0....]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class AvmMiniMemoryTests : public ::testing::Test {
// The proof must pass and we check that the AVM error is raised.
TEST_F(AvmMiniMemoryTests, mismatchedTag)
{
trace_builder.call_data_copy(0, 2, 0, std::vector<FF>{ 98, 12 });
trace_builder.calldata_copy(0, 2, 0, std::vector<FF>{ 98, 12 });

trace_builder.add(0, 1, 4, AvmMemoryTag::U8);
trace_builder.halt();
Expand Down Expand Up @@ -79,7 +79,7 @@ TEST_F(AvmMiniMemoryTests, mismatchedTag)
// in the memory trace
TEST_F(AvmMiniMemoryTests, mLastAccessViolation)
{
trace_builder.call_data_copy(0, 2, 0, std::vector<FF>{ 4, 9 });
trace_builder.calldata_copy(0, 2, 0, std::vector<FF>{ 4, 9 });

// Memory layout: [4,9,0,0,0,0,....]
trace_builder.sub(1, 0, 2, AvmMemoryTag::U8); // [4,9,5,0,0,0.....]
Expand Down Expand Up @@ -109,7 +109,7 @@ TEST_F(AvmMiniMemoryTests, mLastAccessViolation)
// written into memory
TEST_F(AvmMiniMemoryTests, readWriteConsistencyValViolation)
{
trace_builder.call_data_copy(0, 2, 0, std::vector<FF>{ 4, 9 });
trace_builder.calldata_copy(0, 2, 0, std::vector<FF>{ 4, 9 });

// Memory layout: [4,9,0,0,0,0,....]
trace_builder.mul(1, 0, 2, AvmMemoryTag::U8); // [4,9,36,0,0,0.....]
Expand Down Expand Up @@ -139,7 +139,7 @@ TEST_F(AvmMiniMemoryTests, readWriteConsistencyValViolation)
// written into memory
TEST_F(AvmMiniMemoryTests, readWriteConsistencyTagViolation)
{
trace_builder.call_data_copy(0, 2, 0, std::vector<FF>{ 4, 9 });
trace_builder.calldata_copy(0, 2, 0, std::vector<FF>{ 4, 9 });

// Memory layout: [4,9,0,0,0,0,....]
trace_builder.mul(1, 0, 2, AvmMemoryTag::U8); // [4,9,36,0,0,0.....]
Expand Down Expand Up @@ -180,7 +180,7 @@ TEST_F(AvmMiniMemoryTests, readUninitializedMemoryViolation)
// must raise a VM error.
TEST_F(AvmMiniMemoryTests, mismatchedTagErrorViolation)
{
trace_builder.call_data_copy(0, 2, 0, std::vector<FF>{ 98, 12 });
trace_builder.calldata_copy(0, 2, 0, std::vector<FF>{ 98, 12 });

trace_builder.sub(0, 1, 4, AvmMemoryTag::U8);
trace_builder.halt();
Expand Down Expand Up @@ -214,7 +214,7 @@ TEST_F(AvmMiniMemoryTests, mismatchedTagErrorViolation)
// must not set a VM error.
TEST_F(AvmMiniMemoryTests, consistentTagNoErrorViolation)
{
trace_builder.call_data_copy(0, 2, 0, std::vector<FF>{ 84, 7 });
trace_builder.calldata_copy(0, 2, 0, std::vector<FF>{ 84, 7 });

trace_builder.div(0, 1, 4, AvmMemoryTag::FF);
trace_builder.halt();
Expand Down

0 comments on commit d028db6

Please sign in to comment.