Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v 0.1.0 Development #114

Merged
merged 45 commits into from
Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
03569fd
change blockchain test filler format
winsvega Nov 1, 2020
f44ddbc
debug raw transaction data in state tests
winsvega Nov 6, 2020
9ad0d5d
select transaction data by value
winsvega Nov 6, 2020
f9877bc
support data ranges in gstate tests expect section
winsvega Nov 8, 2020
7f9c460
expect section select gstate trdata by value (unit tests required)
winsvega Nov 8, 2020
e829eaa
unit tests for expect section indexes select + bugfixes
winsvega Nov 9, 2020
81bb70a
expect section search transaction by label, not by value
winsvega Nov 16, 2020
b296723
option select transaction by label
winsvega Nov 16, 2020
bdf34dc
disable generated gtest run if filter is set with --filltests
winsvega Nov 16, 2020
2d26b44
check unfilled tests
winsvega Nov 22, 2020
35df9e0
a few data/code compilation tests
winsvega Nov 22, 2020
019acce
more compilation label tests
winsvega Nov 22, 2020
20fc4f0
check fillers
winsvega Nov 22, 2020
c430071
gstate test tr data preview in error logs
winsvega Nov 22, 2020
832e909
fix state dumps with --poststate option
winsvega Dec 12, 2020
1a634e6
tx.nonce: "auto" field in bc test fillers
winsvega Dec 12, 2020
065505f
trace yellow color fix wip
winsvega Dec 24, 2020
1cf6472
remove comments when running filltests on a single test file
winsvega Jan 9, 2021
2d234ae
add VMTests folders as subfolder to GTests
winsvega Jan 19, 2021
56904b1
support labels in filled tests for better debug
winsvega Jan 19, 2021
83f3113
more debug when lll compilation fails
winsvega Jan 19, 2021
ecf83d6
refactoring: combine tr.data related data into box
winsvega Jan 23, 2021
482598b
Access Lists transactions in gState tests WIP
winsvega Jan 23, 2021
47318cf
access list support in gstate tests
winsvega Jan 23, 2021
a4ba805
version 0.1.0 prefix
winsvega Jan 23, 2021
f55dbaa
YOLOv3
winsvega Jan 31, 2021
9f92d85
--fillchain support for accesslist transactions on t8ntool
winsvega Feb 1, 2021
cfdb6c1
transaction access list support in blockchain test fillers
winsvega Feb 1, 2021
ff15263
add stEIP2930 gtest folder
winsvega Feb 2, 2021
dfeae58
always mark VMTests subfolder when running VMTest gtests subfolder tests
winsvega Feb 2, 2021
de4bfc1
enable VMTests in BCGeneralStateTests
winsvega Feb 2, 2021
fe84511
fixes
winsvega Feb 3, 2021
145d1d3
make t8ntool a default config
winsvega Feb 3, 2021
ae137c2
Change Access List Format
winsvega Feb 4, 2021
4873b94
fix VRS for accessList transactions
winsvega Feb 11, 2021
37e87c4
fix
winsvega Feb 13, 2021
56617b0
legacy accessLists are null
winsvega Feb 21, 2021
f179d53
t8ntool support. receipt types
winsvega Feb 24, 2021
4804afb
fix null access list, export transaction rlp into gstate tests
winsvega Feb 26, 2021
3b32b8b
fix nonce being size_t
winsvega Mar 8, 2021
4f3b735
blockchain filler nonce:auto as VALUE type not size_t
winsvega Mar 9, 2021
c309cb1
disable progiling in debug
winsvega Mar 9, 2021
ed7a941
vmTrace all transactions in blockchain test (WIP)
winsvega Mar 9, 2021
47c69eb
better check up on transansaction mining in blockchain tests
winsvega Mar 9, 2021
931a191
Optimize transaction
winsvega Mar 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ HunterGate(
LOCAL
)

project(retesteth VERSION 0.0.9)
set(VERSION_SUFFIX "berlin")
project(retesteth VERSION 0.1.0)
set(VERSION_SUFFIX "accesslist")

set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ RUN apt-get install wget && wget https://github.com/ethereum/solidity/releases/d
# Geth
RUN git clone --depth 1 -b master https://github.com/ethereum/go-ethereum.git /geth
RUN cd /geth && apt-get install wget \
&& wget https://dl.google.com/go/go1.13.3.linux-amd64.tar.gz \
&& tar -xvf go1.13.3.linux-amd64.tar.gz \
&& wget https://dl.google.com/go/go1.15.7.linux-amd64.tar.gz \
&& tar -xvf go1.15.7.linux-amd64.tar.gz \
&& mv go /usr/local && ln -s /usr/local/go/bin/go /bin/go \
&& make all && cp /geth/build/bin/evm /bin/evm \
&& cp /geth/build/bin/geth /bin/geth \
Expand Down
2 changes: 1 addition & 1 deletion cmake/EthCompilerSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
add_compile_options(-Wno-unknown-pragmas)

# Configuration-specific compiler settings.
set(CMAKE_CXX_FLAGS_DEBUG "-Og -pg -DETH_DEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g -DETH_DEBUG")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
Expand Down
28 changes: 27 additions & 1 deletion retesteth/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <dataObject/ConvertFile.h>
#include <retesteth/Options.h>
#include <retesteth/TestHelper.h>
#include <testStructures/Common.h>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>

Expand Down Expand Up @@ -65,6 +66,7 @@ void printHelp()
cout << setw(40) << "--singletest <TestName>" << setw(0)
<< "Run on a single test. `Testname` is filename without Filler.json\n";
cout << setw(40) << "--singletest <TestName>/<Subtest>" << setw(0) << "`Subtest` is a test name inside the file\n";
cout << setw(40) << "--singlenet <ForkName>" << setw(0) << "Run only specific fork configuration\n";

cout << "\nDebugging\n";
cout << setw(30) << "-d <index>" << setw(25) << "Set the transaction data array index when running GeneralStateTests\n";
Expand Down Expand Up @@ -331,7 +333,22 @@ Options::Options(int argc, const char** argv)
else if (arg == "-d")
{
throwIfNoArgumentFollows();
trDataIndex = atoi(argv[++i]);
string const& argValue = argv[++i];
DigitsType type = stringIntegerType(argValue);
switch (type)
{
case DigitsType::Decimal:
trDataIndex = atoi(argValue.c_str());
break;
case DigitsType::String:
trDataLabel = argValue;
break;
default:
{
ETH_STDERROR_MESSAGE("Wrong argument format: " + argValue);
exit(0);
}
}
}
else if (arg == "-g")
{
Expand Down Expand Up @@ -476,3 +493,12 @@ void displayTestSuites()
cout << "\n";
}

string Options::getGStateTransactionFilter() const
{
string filter;
filter += trDataIndex == -1 ? string() : " dInd: " + to_string(trDataIndex);
filter += trDataLabel.empty() ? string() : " dLbl: " + trDataLabel;
filter += trGasIndex == -1 ? string() : " gInd: " + to_string(trGasIndex);
filter += trValueIndex == -1 ? string() : " vInd: " + to_string(trValueIndex);
return filter;
}
2 changes: 2 additions & 0 deletions retesteth/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class Options
std::string singleTestName; // A test name (usually a file.json test)
std::string singleSubTestName; // A test name inside a file.json (for blockchain tests)
std::string singleTestNet;
std::string trDataLabel; ///< GeneralState data
int trDataIndex; ///< GeneralState data
int trGasIndex; ///< GeneralState gas
int trValueIndex; ///< GeneralState value
Expand All @@ -82,6 +83,7 @@ class Options
/// The first time used, options are parsed with argc, argv
static Options const& get(int argc = 0, const char** argv = 0);
static DynamicOptions& getDynamicOptions() { return m_dynamicOptions; }
string getGStateTransactionFilter() const;

private:
Options(int argc = 0, const char** argv = 0);
Expand Down
78 changes: 76 additions & 2 deletions retesteth/TestHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,47 @@ vector<string> levenshteinDistance(std::string const& _needle, std::vector<std::
return ret;
}

std::mutex g_strFindMutex;
DigitsType stringIntegerType(std::string const& _string, bool _wasPrefix)
{
if (_string[0] == '0' && _string[1] == 'x' && !_wasPrefix)
{
DigitsType substringType = stringIntegerType(_string, true);
if (substringType == DigitsType::Hex)
return DigitsType::HexPrefixed;

if (substringType == DigitsType::Decimal)
{
if (_string.size() % 2 == 0)
return DigitsType::HexPrefixed;
else
return DigitsType::UnEvenHexPrefixed;
}

if (substringType == DigitsType::UnEvenHex)
return DigitsType::UnEvenHexPrefixed;
}

bool isDecimalOnly = true;
std::lock_guard<std::mutex> lock(g_strFindMutex); // string.find is not thread safe + static
for (size_t i = _wasPrefix ? 2 : 0; i < _string.length(); i++)
{
if (!isxdigit(_string[i]))
return DigitsType::String;

if (isDecimalOnly && !isdigit(_string[i]))
isDecimalOnly = false;
}

if (isDecimalOnly)
return DigitsType::Decimal;

if (_string.size() % 2 == 0)
return DigitsType::Hex;

return DigitsType::UnEvenHex;
}

void parseJsonStrValueIntoSet(DataObject const& _json, set<string>& _out)
{
if (_json.type() == DataType::Array)
Expand All @@ -194,19 +235,52 @@ void parseJsonStrValueIntoSet(DataObject const& _json, set<string>& _out)

void parseJsonIntValueIntoSet(DataObject const& _json, set<int>& _out)
{
auto parseRange = [&_out](DataObject const& a) {
string const& s = a.asString();
size_t delimeter = s.find('-');
if (delimeter != string::npos)
{
string const firstPartString = s.substr(0, delimeter);
if (stringIntegerType(firstPartString) != DigitsType::Decimal)
ETH_ERROR_MESSAGE("parseJsonIntValueIntoSet require x to be decimal in `x-y` range! `" + firstPartString);

string const secondPartString = s.substr(delimeter + 1);
if (stringIntegerType(secondPartString) != DigitsType::Decimal)
ETH_ERROR_MESSAGE("parseJsonIntValueIntoSet require y to be decimal in `x-y` range! `" + secondPartString);

size_t const indexStart = atoi(firstPartString.c_str());
size_t const indexEnd = atoi(secondPartString.c_str());
for (size_t i = indexStart; i <= indexEnd; i++)
_out.emplace(i);
}
else
ETH_ERROR_MESSAGE("parseJsonIntValueIntoSet: Error parsing integer range string! format: \"x-y\", got: `" + s);
};

if (_json.type() == DataType::Array)
{
for (auto const& val: _json.getSubObjects())
{
ETH_ERROR_REQUIRE_MESSAGE(val.type() == DataType::Integer, "parseJsonIntValueIntoSet expected value type = int!");
_out.emplace(val.asInt());
if (val.type() == DataType::Integer)
_out.emplace(val.asInt());
else
{
ETH_ERROR_REQUIRE_MESSAGE(
val.type() == DataType::String, "parseJsonIntValueIntoSet expected value type = int, \"int-int\" range!");
parseRange(val);
}
}
}
else if (_json.type() == DataType::Integer)
{
ETH_ERROR_REQUIRE_MESSAGE(_json.type() == DataType::Integer, "parseJsonIntValueIntoSet expected json type = int!");
_out.emplace(_json.asInt());
}
else if (_json.type() == DataType::String)
{
// Try to parse range into values "x-y"
parseRange(_json);
}
}

string prepareVersionString()
Expand Down
14 changes: 13 additions & 1 deletion retesteth/TestHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <dataObject/DataObject.h>
#include <retesteth/EthChecks.h>
#include <retesteth/compiler/Compiler.h>
#include <retesteth/testStructures/basetypes/BYTES.h>

using namespace dataobject;
namespace fs = boost::filesystem;
Expand Down Expand Up @@ -94,6 +95,18 @@ bool inArray(std::list<T> const& _array, const T& _val)
/// Explode string into array of strings by `delim`
std::vector<std::string> explode(std::string const& s, char delim);

/// See what kind of a string is str
enum class DigitsType
{
Decimal,
Hex,
UnEvenHex,
HexPrefixed,
UnEvenHexPrefixed,
String
};
DigitsType stringIntegerType(std::string const& _string, bool _wasPrefix = false);

/// popen with pid at return
enum popenOutput
{
Expand All @@ -114,5 +127,4 @@ string fto_string(t _val)
{
return std::to_string(_val);
}

} // namespace test
6 changes: 5 additions & 1 deletion retesteth/TestOutputHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,5 +399,9 @@ std::string TestInfo::errorDebug() const
message += ", block: " + to_string(m_blockNumber);
else if (m_isStateTransactionInfo)
message += ", TrInfo: d: " + to_string(m_trD) + ", g: " + to_string(m_trG) + ", v: " + to_string(m_trV);
return message + ")" + cRed;

if (!m_sTransactionData.empty())
message += ", TrData: `" + m_sTransactionData + "`";

return message + ")" + cDefault;
}
9 changes: 5 additions & 4 deletions retesteth/TestOutputHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,15 @@ struct TestInfo

TestInfo(): m_isStateTransactionInfo(false), m_isBlockchainTestInfo(false) {}
std::string errorDebug() const;
static std::string caseName()
{
return boost::unit_test::framework::current_test_case().p_name;
}
static std::string caseName() { return boost::unit_test::framework::current_test_case().p_name; }

void setTrDataDebug(std::string const& _data) { m_sTransactionData = _data; }

private:
std::string m_sFork, m_sChainName;
std::string m_currentTestCaseName;
std::string m_sTransactionData;

int m_trD, m_trG, m_trV;
size_t m_blockNumber;
bool m_isStateTransactionInfo = false;
Expand Down
49 changes: 45 additions & 4 deletions retesteth/TestSuite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,24 @@ void addClientInfo(DataObject& _v, fs::path const& _testSource, h256 const& _tes
{
string comment;
DataObject clientinfo;
clientinfo.setKey("_info");
if (o.count("_info"))
{
DataObject const& existingInfo = o.atKey("_info");
if (existingInfo.count("comment"))
comment = existingInfo.atKey("comment").asString();
if (existingInfo.count("labels"))
clientinfo["labels"] = existingInfo.atKey("labels");
}

clientinfo.setKey("_info");
clientinfo["comment"] = comment;
clientinfo["filling-rpc-server"] = session.web3_clientVersion();
clientinfo["filling-tool-version"] = test::prepareVersionString();
clientinfo["lllcversion"] = test::prepareLLLCVersionString();
clientinfo["source"] = _testSource.string();
clientinfo["sourceHash"] = toString(_testSourceHash);
if (clientinfo.count("labels"))
clientinfo.setKeyPos("labels", clientinfo.getSubObjects().size() - 1);

o["_info"].replace(clientinfo);
o.setKeyPos("_info", 0);
Expand Down Expand Up @@ -224,6 +228,8 @@ void TestSuite::runTestWithoutFiller(boost::filesystem::path const& _file) const
if (Options::get().filltests)
{
TestFileData testData = readTestFile(_file);
removeComments(testData.data);

string fileName = _file.stem().c_str();
if (fileName.find("Filler") == string::npos)
ETH_ERROR_MESSAGE("Trying to fill `" + string(_file.c_str()) + "`, but file does not have Filler suffix!");
Expand Down Expand Up @@ -261,9 +267,7 @@ string TestSuite::checkFillerExistance(string const& _testFolder) const
string const testNameFilter = opt.singleTestName.empty() ? string() : opt.singleTestName;
string filter = testNameFilter;
filter += opt.singleTestNet.empty() ? string() : " " + opt.singleTestNet;
filter += opt.trDataIndex == -1 ? string() : " dInd: " + to_string(opt.trDataIndex);
filter += opt.trGasIndex == -1 ? string() : " gInd: " + to_string(opt.trGasIndex);
filter += opt.trValueIndex == -1 ? string() : " vInd: " + to_string(opt.trValueIndex);
filter += opt.getGStateTransactionFilter();
ETH_LOG("Checking test filler hashes for " + boost::unit_test::framework::current_test_case().full_name(), 4);
if (!filter.empty())
ETH_LOG("Filter: '" + filter + "'", 0);
Expand All @@ -276,6 +280,32 @@ string TestSuite::checkFillerExistance(string const& _testFolder) const
vector<fs::path> compiledFiles = test::getFiles(testsPath.path(), {".json", ".yml"}, testNameFilter);
AbsoluteFillerPath fullPathToFillers = getFullPathFiller(_testFolder);

// Check unfilled tests
if (Options::get().checkhash)
{
vector<fs::path> fillerFiles = test::getFiles(fullPathToFillers.path(), {".json", ".yml"}, testNameFilter);
if (fillerFiles.size() > compiledFiles.size())
{
string message = "Tests are not generated: ";
for (auto const& filler : fillerFiles)
{
bool found = false;
for (auto const& filled : compiledFiles)
{
string const fillerName = filler.stem().string();
if (fillerName.substr(0, fillerName.size() - 6) == filled.stem().string())
{
found = true;
break;
}
}
if (!found)
message += "\n " + string(filler.c_str());
}
ETH_ERROR_MESSAGE(message + "\n");
}
}

bool checkFillerWhenFilterIsSetButNoTestsFilled = false;
if (compiledFiles.size() == 0)
{
Expand Down Expand Up @@ -370,6 +400,7 @@ void TestSuite::runAllTestsInFolder(string const& _testFolder) const
string filter;
try
{
TestOutputHelper::get().setCurrentTestInfo(TestInfo("checkFillerExistance", _testFolder));
filter = checkFillerExistance(_testFolder);
}
catch (std::exception const&)
Expand Down Expand Up @@ -544,6 +575,12 @@ void TestSuite::executeTest(string const& _testFolder, fs::path const& _testFile
// Add client info for all of the tests in output
addClientInfo(output, boostRelativeTestPath, testData.hash);
writeFile(boostTestPath.path(), asBytes(output.asJson()));

if (!Options::get().getGStateTransactionFilter().empty())
{
ETH_WARNING("GState transaction filter is set. Disabling generated test run!");
opt.disableSecondRun = true;
}
}
catch (test::EthError const& _ex)
{
Expand Down Expand Up @@ -606,6 +643,10 @@ void TestSuite::executeFile(boost::filesystem::path const& _file) const
TestSuiteOptions opt;
opt.isLegacyTests = Options::get().rCurrentTestSuite.find("LegacyTests") != string::npos;
opt.isLegacyTests = opt.isLegacyTests || legacyTestSuiteFlag();

if (_file.extension() != ".json")
ETH_ERROR_MESSAGE("The generated test must have `.json` format!");

doTests(test::readJsonData(_file), opt);
}
}
Loading