@@ -36,13 +36,9 @@ class AvmExecutionTests : public ::testing::Test {
36
36
Execution::set_trace_builder_constructor ([](VmPublicInputsNT public_inputs,
37
37
ExecutionHints execution_hints,
38
38
uint32_t side_effect_counter,
39
- std::vector<FF> calldata,
40
- const std::vector<std::vector<uint8_t >>& all_contracts_bytecode) {
41
- return AvmTraceBuilder (std::move (public_inputs),
42
- std::move (execution_hints),
43
- side_effect_counter,
44
- std::move (calldata),
45
- all_contracts_bytecode)
39
+ std::vector<FF> calldata) {
40
+ return AvmTraceBuilder (
41
+ std::move (public_inputs), std::move (execution_hints), side_effect_counter, std::move (calldata))
46
42
.set_full_precomputed_tables (false )
47
43
.set_range_check_required (false );
48
44
});
@@ -57,7 +53,8 @@ class AvmExecutionTests : public ::testing::Test {
57
53
srs::init_crs_factory (" ../srs_db/ignition" );
58
54
public_inputs_vec.at (DA_START_GAS_LEFT_PCPI_OFFSET) = DEFAULT_INITIAL_DA_GAS;
59
55
public_inputs_vec.at (L2_START_GAS_LEFT_PCPI_OFFSET) = DEFAULT_INITIAL_L2_GAS;
60
- public_inputs = convert_public_inputs (public_inputs_vec);
56
+ public_inputs_vec.at (ADDRESS_KERNEL_INPUTS_COL_OFFSET) = 0xdeadbeef ;
57
+ public_inputs = avm_trace::convert_public_inputs (public_inputs_vec);
61
58
};
62
59
63
60
/* *
@@ -71,7 +68,21 @@ class AvmExecutionTests : public ::testing::Test {
71
68
std::vector<FF> calldata{};
72
69
std::vector<FF> returndata{};
73
70
74
- return Execution::gen_trace (bytecode, calldata, public_inputs_vec, returndata, ExecutionHints ());
71
+ auto execution_hints = ExecutionHints ().with_avm_contract_bytecode ({ bytecode });
72
+ execution_hints.all_contract_bytecode [0 ].contract_instance .address = 0xdeadbeef ;
73
+
74
+ return AvmExecutionTests::gen_trace (bytecode, calldata, public_inputs_vec, returndata, execution_hints);
75
+ }
76
+
77
+ std::vector<Row> gen_trace (std::vector<uint8_t > bytecode,
78
+ std::vector<FF> const & calldata,
79
+ std::vector<FF> const & public_inputs_vec,
80
+ std::vector<FF>& returndata,
81
+ ExecutionHints& execution_hints) const
82
+ {
83
+ execution_hints.all_contract_bytecode = { bytecode };
84
+ execution_hints.all_contract_bytecode [0 ].contract_instance .address = 0xdeadbeef ;
85
+ return Execution::gen_trace (calldata, public_inputs_vec, returndata, execution_hints);
75
86
}
76
87
77
88
void feed_output (uint32_t output_offset, FF const & value, FF const & side_effect_counter, FF const & metadata)
@@ -474,8 +485,8 @@ TEST_F(AvmExecutionTests, jumpAndCalldatacopy)
474
485
Field (&Instruction::operands, ElementsAre (VariantWith<uint16_t >(5 )))));
475
486
476
487
std::vector<FF> returndata;
477
- auto trace =
478
- Execution:: gen_trace (bytecode, std::vector<FF>{ 13 , 156 }, public_inputs_vec, returndata, ExecutionHints () );
488
+ ExecutionHints execution_hints;
489
+ auto trace = gen_trace (bytecode, std::vector<FF>{ 13 , 156 }, public_inputs_vec, returndata, execution_hints );
479
490
480
491
// Expected sequence of PCs during execution
481
492
std::vector<FF> pc_sequence{
@@ -564,10 +575,9 @@ TEST_F(AvmExecutionTests, jumpiAndCalldatacopy)
564
575
ElementsAre (VariantWith<uint8_t >(0 ), VariantWith<uint16_t >(6 ), VariantWith<uint16_t >(10 )))));
565
576
566
577
std::vector<FF> returndata;
567
- auto trace_jump =
568
- Execution::gen_trace (bytecode, std::vector<FF>{ 9873123 }, public_inputs_vec, returndata, ExecutionHints ());
569
- auto trace_no_jump =
570
- Execution::gen_trace (bytecode, std::vector<FF>{ 0 }, public_inputs_vec, returndata, ExecutionHints ());
578
+ ExecutionHints execution_hints;
579
+ auto trace_jump = gen_trace (bytecode, std::vector<FF>{ 9873123 }, public_inputs_vec, returndata, execution_hints);
580
+ auto trace_no_jump = gen_trace (bytecode, std::vector<FF>{ 0 }, public_inputs_vec, returndata, execution_hints);
571
581
572
582
// Expected sequence of PCs during execution with jump
573
583
std::vector<FF> pc_sequence_jump{ 0 , 1 , 2 , 3 , 4 , 6 , 7 };
@@ -774,8 +784,9 @@ TEST_F(AvmExecutionTests, toRadixLeOpcode)
774
784
775
785
// Assign a vector that we will mutate internally in gen_trace to store the return values;
776
786
std::vector<FF> returndata;
777
- auto trace = Execution::gen_trace (
778
- bytecode, std::vector<FF>{ FF::modulus - FF (1 ) }, public_inputs_vec, returndata, ExecutionHints ());
787
+ ExecutionHints execution_hints;
788
+ auto trace =
789
+ gen_trace (bytecode, std::vector<FF>{ FF::modulus - FF (1 ) }, public_inputs_vec, returndata, execution_hints);
779
790
780
791
// Find the first row enabling the TORADIXLE selector
781
792
// Expected output is bitwise decomposition of MODULUS - 1..could hardcode the result but it's a bit long
@@ -840,8 +851,9 @@ TEST_F(AvmExecutionTests, toRadixLeOpcodeBitsMode)
840
851
841
852
// Assign a vector that we will mutate internally in gen_trace to store the return values;
842
853
std::vector<FF> returndata;
843
- auto trace = Execution::gen_trace (
844
- bytecode, std::vector<FF>{ FF::modulus - FF (1 ) }, public_inputs_vec, returndata, ExecutionHints ());
854
+ ExecutionHints execution_hints;
855
+ auto trace =
856
+ gen_trace (bytecode, std::vector<FF>{ FF::modulus - FF (1 ) }, public_inputs_vec, returndata, execution_hints);
845
857
846
858
// Find the first row enabling the TORADIXLE selector
847
859
// Expected output is bitwise decomposition of MODULUS - 1..could hardcode the result but it's a bit long
@@ -915,7 +927,8 @@ TEST_F(AvmExecutionTests, sha256CompressionOpcode)
915
927
// 4091010797,3974542186]),
916
928
std::vector<FF> expected_output = { 1862536192 , 526086805 , 2067405084 , 593147560 ,
917
929
726610467 , 813867028 , 4091010797ULL , 3974542186ULL };
918
- auto trace = Execution::gen_trace (bytecode, calldata, public_inputs_vec, returndata, ExecutionHints ());
930
+ ExecutionHints execution_hints;
931
+ auto trace = gen_trace (bytecode, calldata, public_inputs_vec, returndata, execution_hints);
919
932
920
933
EXPECT_EQ (returndata, expected_output);
921
934
@@ -976,7 +989,8 @@ TEST_F(AvmExecutionTests, poseidon2PermutationOpCode)
976
989
FF (std::string (" 0x018555a8eb50cf07f64b019ebaf3af3c925c93e631f3ecd455db07bbb52bbdd3" )),
977
990
FF (std::string (" 0x0cbea457c91c22c6c31fd89afd2541efc2edf31736b9f721e823b2165c90fd41" ))
978
991
};
979
- auto trace = Execution::gen_trace (bytecode, calldata, public_inputs_vec, returndata, ExecutionHints ());
992
+ ExecutionHints execution_hints;
993
+ auto trace = gen_trace (bytecode, calldata, public_inputs_vec, returndata, execution_hints);
980
994
981
995
EXPECT_EQ (returndata, expected_output);
982
996
@@ -1043,7 +1057,8 @@ TEST_F(AvmExecutionTests, keccakf1600OpCode)
1043
1057
// Assign a vector that we will mutate internally in gen_trace to store the return values;
1044
1058
std::vector<FF> calldata = std::vector<FF>();
1045
1059
std::vector<FF> returndata = std::vector<FF>();
1046
- auto trace = Execution::gen_trace (bytecode, calldata, public_inputs_vec, returndata, ExecutionHints ());
1060
+ ExecutionHints execution_hints;
1061
+ auto trace = gen_trace (bytecode, calldata, public_inputs_vec, returndata, execution_hints);
1047
1062
1048
1063
EXPECT_EQ (returndata, expected_output);
1049
1064
@@ -1110,7 +1125,8 @@ TEST_F(AvmExecutionTests, embeddedCurveAddOpCode)
1110
1125
// Assign a vector that we will mutate internally in gen_trace to store the return values;
1111
1126
std::vector<FF> returndata;
1112
1127
std::vector<FF> calldata = { a.x , a.y , FF (a_is_inf ? 1 : 0 ), b.x , b.y , FF (b_is_inf ? 1 : 0 ) };
1113
- auto trace = Execution::gen_trace (bytecode, calldata, public_inputs_vec, returndata, ExecutionHints ());
1128
+ ExecutionHints execution_hints;
1129
+ auto trace = gen_trace (bytecode, calldata, public_inputs_vec, returndata, execution_hints);
1114
1130
1115
1131
EXPECT_EQ (returndata, expected_output);
1116
1132
@@ -1197,7 +1213,8 @@ TEST_F(AvmExecutionTests, msmOpCode)
1197
1213
1198
1214
// Assign a vector that we will mutate internally in gen_trace to store the return values;
1199
1215
std::vector<FF> returndata;
1200
- auto trace = Execution::gen_trace (bytecode, calldata, public_inputs_vec, returndata, ExecutionHints ());
1216
+ ExecutionHints execution_hints;
1217
+ auto trace = gen_trace (bytecode, calldata, public_inputs_vec, returndata, execution_hints);
1201
1218
1202
1219
EXPECT_EQ (returndata, expected_output);
1203
1220
@@ -1355,16 +1372,16 @@ TEST_F(AvmExecutionTests, kernelInputOpcodes)
1355
1372
std::vector<FF> calldata;
1356
1373
1357
1374
FF sender = 1 ;
1358
- FF address = 2 ;
1359
- FF function_selector = 3 ;
1360
- FF transaction_fee = 4 ;
1361
- FF chainid = 5 ;
1362
- FF version = 6 ;
1363
- FF blocknumber = 7 ;
1364
- FF timestamp = 8 ;
1365
- FF feeperl2gas = 9 ;
1366
- FF feeperdagas = 10 ;
1367
- FF is_static_call = 11 ;
1375
+ FF address = 0xdeadbeef ;
1376
+ FF function_selector = 4 ;
1377
+ FF transaction_fee = 5 ;
1378
+ FF chainid = 6 ;
1379
+ FF version = 7 ;
1380
+ FF blocknumber = 8 ;
1381
+ FF timestamp = 9 ;
1382
+ FF feeperl2gas = 10 ;
1383
+ FF feeperdagas = 11 ;
1384
+ FF is_static_call = 12 ;
1368
1385
1369
1386
// The return data for this test should be a the opcodes in sequence, as the opcodes dst address lines up with
1370
1387
// this array The returndata call above will then return this array
@@ -1393,7 +1410,8 @@ TEST_F(AvmExecutionTests, kernelInputOpcodes)
1393
1410
public_inputs_vec[FEE_PER_L2_GAS_PCPI_OFFSET] = feeperl2gas;
1394
1411
1395
1412
std::vector<FF> returndata;
1396
- auto trace = Execution::gen_trace (bytecode, calldata, public_inputs_vec, returndata, ExecutionHints ());
1413
+ ExecutionHints execution_hints;
1414
+ auto trace = gen_trace (bytecode, calldata, public_inputs_vec, returndata, execution_hints);
1397
1415
1398
1416
// Validate returndata
1399
1417
EXPECT_EQ (returndata, expected_returndata);
@@ -1559,7 +1577,8 @@ TEST_F(AvmExecutionTests, ExecutorThrowsWithTooMuchGasAllocated)
1559
1577
auto bytecode = hex_to_bytes (bytecode_hex);
1560
1578
auto instructions = Deserialization::parse (bytecode);
1561
1579
1562
- EXPECT_THROW_WITH_MESSAGE (Execution::gen_trace (bytecode, calldata, public_inputs_vec, returndata, ExecutionHints ()),
1580
+ ExecutionHints execution_hints;
1581
+ EXPECT_THROW_WITH_MESSAGE (gen_trace (bytecode, calldata, public_inputs_vec, returndata, execution_hints),
1563
1582
" Cannot allocate more than MAX_L2_GAS_PER_ENQUEUED_CALL to the AVM for "
1564
1583
" execution of an enqueued call" );
1565
1584
}
@@ -1578,7 +1597,8 @@ TEST_F(AvmExecutionTests, ExecutorThrowsWithIncorrectNumberOfPublicInputs)
1578
1597
auto bytecode = hex_to_bytes (bytecode_hex);
1579
1598
auto instructions = Deserialization::parse (bytecode);
1580
1599
1581
- EXPECT_THROW_WITH_MESSAGE (Execution::gen_trace (bytecode, calldata, public_inputs_vec, returndata, ExecutionHints ()),
1600
+ ExecutionHints execution_hints;
1601
+ EXPECT_THROW_WITH_MESSAGE (gen_trace (bytecode, calldata, public_inputs_vec, returndata, execution_hints),
1582
1602
" Public inputs vector is not of PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH" );
1583
1603
}
1584
1604
@@ -1621,7 +1641,8 @@ TEST_F(AvmExecutionTests, kernelOutputEmitOpcodes)
1621
1641
1622
1642
std::vector<FF> calldata = {};
1623
1643
std::vector<FF> returndata = {};
1624
- auto trace = Execution::gen_trace (bytecode, calldata, public_inputs_vec, returndata, ExecutionHints ());
1644
+ ExecutionHints execution_hints;
1645
+ auto trace = gen_trace (bytecode, calldata, public_inputs_vec, returndata, execution_hints);
1625
1646
1626
1647
// CHECK EMIT NOTE HASH
1627
1648
// Check output data + side effect counters have been set correctly
@@ -1656,7 +1677,7 @@ TEST_F(AvmExecutionTests, kernelOutputEmitOpcodes)
1656
1677
auto emit_log_row =
1657
1678
std::ranges::find_if (trace.begin (), trace.end (), [](Row r) { return r.main_sel_op_emit_unencrypted_log == 1 ; });
1658
1679
// Trust me bro for now, this is the truncated sha output
1659
- FF expected_hash = FF (std::string (" 0x006db65fd59fd356f6729140571b5bcd6bb3b83492a16e1bf0a3884442fc3c8a " ));
1680
+ FF expected_hash = FF (std::string (" 0x003383cbb254941b33c0aaf8476c4b9b532d70a2fb105ee908dd332f7d942df6 " ));
1660
1681
EXPECT_EQ (emit_log_row->main_ia , expected_hash);
1661
1682
EXPECT_EQ (emit_log_row->main_side_effect_counter , 2 );
1662
1683
// Value is 40 = 32 * log_length + 40 (and log_length is 0 in this case).
@@ -1722,7 +1743,7 @@ TEST_F(AvmExecutionTests, kernelOutputStorageLoadOpcodeSimple)
1722
1743
// side effect counter 0 = value 42
1723
1744
auto execution_hints = ExecutionHints ().with_storage_value_hints ({ { 0 , 42 } });
1724
1745
1725
- auto trace = Execution:: gen_trace (bytecode, calldata, public_inputs_vec, returndata, execution_hints);
1746
+ auto trace = gen_trace (bytecode, calldata, public_inputs_vec, returndata, execution_hints);
1726
1747
1727
1748
// CHECK SLOAD
1728
1749
// Check output data + side effect counters have been set correctly
@@ -1776,7 +1797,8 @@ TEST_F(AvmExecutionTests, kernelOutputStorageStoreOpcodeSimple)
1776
1797
1777
1798
std::vector<FF> returndata;
1778
1799
1779
- auto trace = Execution::gen_trace (bytecode, calldata, public_inputs_vec, returndata, ExecutionHints ());
1800
+ ExecutionHints execution_hints;
1801
+ auto trace = gen_trace (bytecode, calldata, public_inputs_vec, returndata, execution_hints);
1780
1802
// CHECK SSTORE
1781
1803
auto sstore_row = std::ranges::find_if (trace.begin (), trace.end (), [](Row r) { return r.main_sel_op_sstore == 1 ; });
1782
1804
EXPECT_EQ (sstore_row->main_ia , 42 ); // Read value
@@ -1839,7 +1861,7 @@ TEST_F(AvmExecutionTests, kernelOutputStorageOpcodes)
1839
1861
// side effect counter 0 = value 42
1840
1862
auto execution_hints = ExecutionHints ().with_storage_value_hints ({ { 0 , 42 } });
1841
1863
1842
- auto trace = Execution:: gen_trace (bytecode, calldata, public_inputs_vec, returndata, execution_hints);
1864
+ auto trace = gen_trace (bytecode, calldata, public_inputs_vec, returndata, execution_hints);
1843
1865
1844
1866
// CHECK SLOAD
1845
1867
// Check output data + side effect counters have been set correctly
@@ -1922,7 +1944,7 @@ TEST_F(AvmExecutionTests, kernelOutputHashExistsOpcodes)
1922
1944
.with_storage_value_hints ({ { 0 , 1 }, { 1 , 1 }, { 2 , 1 } })
1923
1945
.with_note_hash_exists_hints ({ { 0 , 1 }, { 1 , 1 }, { 2 , 1 } });
1924
1946
1925
- auto trace = Execution:: gen_trace (bytecode, calldata, public_inputs_vec, returndata, execution_hints);
1947
+ auto trace = gen_trace (bytecode, calldata, public_inputs_vec, returndata, execution_hints);
1926
1948
1927
1949
// CHECK NOTEHASHEXISTS
1928
1950
auto note_hash_row =
@@ -2056,10 +2078,10 @@ TEST_F(AvmExecutionTests, opCallOpcodes)
2056
2078
.l2_gas_used = 0 ,
2057
2079
.da_gas_used = 0 ,
2058
2080
.end_side_effect_counter = 0 ,
2059
- .bytecode = {} ,
2081
+ .contract_address = 0 ,
2060
2082
} });
2061
2083
2062
- auto trace = Execution:: gen_trace (bytecode, calldata, public_inputs_vec, returndata, execution_hints);
2084
+ auto trace = gen_trace (bytecode, calldata, public_inputs_vec, returndata, execution_hints);
2063
2085
EXPECT_EQ (returndata, std::vector<FF>({ 9 , 8 , 1 })); // The 1 represents the success
2064
2086
2065
2087
validate_trace (std::move (trace), public_inputs, calldata, returndata);
@@ -2116,7 +2138,7 @@ TEST_F(AvmExecutionTests, opGetContractInstanceOpcodes)
2116
2138
auto execution_hints =
2117
2139
ExecutionHints ().with_contract_instance_hints ({ { address, { address, 1 , 2 , 3 , 4 , 5 , public_keys_hints } } });
2118
2140
2119
- auto trace = Execution:: gen_trace (bytecode, calldata, public_inputs_vec, returndata, execution_hints);
2141
+ auto trace = gen_trace (bytecode, calldata, public_inputs_vec, returndata, execution_hints);
2120
2142
EXPECT_EQ (returndata, std::vector<FF>({ 1 , 2 , 3 , 4 , 5 , returned_point.x })); // The first one represents true
2121
2143
2122
2144
validate_trace (std::move (trace), public_inputs, calldata, returndata);
0 commit comments