Skip to content

Commit 1ee8186

Browse files
author
winsvega
authored
Merge pull request #147 from ethereum/develop
version 0.2.1 development
2 parents 078dc86 + 113c67c commit 1ee8186

File tree

126 files changed

+2043
-516
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+2043
-516
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ HunterGate(
1414
LOCAL
1515
)
1616

17-
project(retesteth VERSION 0.2.0)
18-
set(VERSION_SUFFIX "memory")
17+
project(retesteth VERSION 0.2.1)
18+
set(VERSION_SUFFIX "difficulty")
1919

2020
set(Boost_USE_STATIC_LIBS ON)
2121
set(Boost_USE_MULTITHREADED ON)

retesteth/FileSystem.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#pragma once
2+
#include <boost/filesystem.hpp>
3+
4+
namespace test {
5+
namespace fsmacro {
6+
7+
// https://stackoverflow.com/questions/1872220/is-it-possible-to-iterate-over-arguments-in-variadic-macros
8+
// Make a FOREACH macro
9+
#define FE_0(WHAT)
10+
#define FE_1(WHAT, X) WHAT(X)
11+
#define FE_2(WHAT, X, ...) WHAT(X)FE_1(WHAT, __VA_ARGS__)
12+
#define FE_3(WHAT, X, ...) WHAT(X)FE_2(WHAT, __VA_ARGS__)
13+
#define FE_4(WHAT, X, ...) WHAT(X)FE_3(WHAT, __VA_ARGS__)
14+
#define FE_5(WHAT, X, ...) WHAT(X)FE_4(WHAT, __VA_ARGS__)
15+
//... repeat as needed
16+
17+
#define GET_MACRO(_0,_1,_2,_3,_4,_5,NAME,...) NAME
18+
#define FOR_EACH(action,...) \
19+
GET_MACRO(_0,__VA_ARGS__,FE_5,FE_4,FE_3,FE_2,FE_1,FE_0)(action,__VA_ARGS__)
20+
21+
#define OPENFILE(_path) boost::filesystem::ofstream file(_path);
22+
#define PUTTOFILE(_arg) file << _arg;
23+
#define CLOSEFILE() \
24+
file.close(); \
25+
}
26+
}
27+
28+
#define WRITEFILE(_path, ...) \
29+
{ \
30+
OPENFILE(_path) \
31+
FOR_EACH(PUTTOFILE, __VA_ARGS__) \
32+
CLOSEFILE()
33+
34+
#define WRITEFILEN(_path, ...) \
35+
{ \
36+
OPENFILE(_path) \
37+
FOR_EACH(PUTTOFILE, __VA_ARGS__)
38+
39+
#define ADDTOFILE(_arg) \
40+
PUTTOFILE(_arg)
41+
42+
}

retesteth/Options.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ void printHelp()
7575
cout << setw(30) << "-v <index>" << setw(25) << "Set the transaction value array index when running GeneralStateTests\n";
7676
cout << setw(30) << "--vmtrace" << setw(25) << "Trace transaction execution\n";
7777
cout << setw(30) << "--vmtraceraw" << setw(25) << "Trace transaction execution raw format\n";
78+
cout << setw(30) << "--vmtrace.nomemory" << setw(25) << "Disable memory in vmtrace/vmtraceraw\n";
79+
cout << setw(30) << "--vmtrace.nostack" << setw(25) << "Disable stack in vmtrace/vmtraceraw\n";
80+
cout << setw(30) << "--vmtrace.noreturndata" << setw(25) << "Disable returndata in vmtrace/vmtraceraw\n";
7881
cout << setw(30) << "--limitblocks" << setw(25) << "Limit the block exectuion in blockchain tests for debug\n";
7982
cout << setw(30) << "--limitrpc" << setw(25) << "Limit the rpc exectuion in tests for debug\n";
8083
cout << setw(30) << "--verbosity <level>" << setw(25) << "Set logs verbosity. 0 - silent, 1 - only errors, 2 - informative, >2 - detailed\n";
@@ -202,6 +205,18 @@ Options::Options(int argc, const char** argv)
202205
vmtrace = true;
203206
vmtraceraw = true;
204207
}
208+
else if (arg == "--vmtrace.nomemory")
209+
{
210+
vmtrace_nomemory = true;
211+
}
212+
else if (arg == "--vmtrace.nostack")
213+
{
214+
vmtrace_nostack = true;
215+
}
216+
else if (arg == "--vmtrace.noreturndata")
217+
{
218+
vmtrace_noreturndata = true;
219+
}
205220
else if (arg == "--jsontrace")
206221
{
207222
throwIfNoArgumentFollows();

retesteth/Options.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ class Options
3535

3636
size_t threadCount = 1; ///< Execute tests on threads
3737
bool enableClientsOutput = false; ///< Enable stderr from clients
38+
3839
bool vmtrace = false; ///< Create EVM execution tracer
3940
bool vmtraceraw = false; ///< Create EVM execution tracer. output raw info
41+
bool vmtrace_nomemory = false;
42+
bool vmtrace_nostack = false;
43+
bool vmtrace_noreturndata = false;
44+
4045
bool filltests = false; ///< Create JSON test files from execution results
4146
bool showhash = false; ///< Show filler hash for debug information
4247
bool checkhash = false; ///< Check that tests are updated from fillers

retesteth/TestHelper.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,4 +576,41 @@ fs::path createUniqueTmpDirectory() {
576576
return tpath / uuidStr;
577577
}
578578

579+
// RLPStream emulator
580+
void RLPStreamU::appendRaw(string const& _data)
581+
{
582+
m_data = &_data;
583+
}
584+
585+
// RLPStream emulator
586+
string RLPStreamU::outHeader() const
587+
{
588+
// For a single byte whose value is in the [0x00, 0x7f] range, that byte is its own RLP encoding.
589+
// Otherwise, if a string is 0-55 bytes long, the RLP encoding consists of a single byte with value 0x80 plus the length of
590+
// the string followed by the string. The range of the first byte is thus [0x80, 0xb7]. If a string is more than 55 bytes
591+
// long, the RLP encoding consists of a single byte with value 0xb7 plus the length in bytes of the length of the string in
592+
// binary form, followed by the length of the string, followed by the string. For example, a length-1024 string would be
593+
// encoded as \xb9\x04\x00 followed by the string. The range of the first byte is thus [0xb8, 0xbf].
594+
595+
// If the total payload of a list (i.e. the combined length of all its items being RLP encoded) is 0-55 bytes long, the RLP
596+
// encoding consists of a single byte with value 0xc0 plus the length of the list followed by the concatenation of the RLP
597+
// encodings of the items. The range of the first byte is thus [0xc0, 0xf7]. If the total payload of a list is more than 55
598+
// bytes long, the RLP encoding consists of a single byte with value 0xf7 plus the length in bytes of the length of the
599+
// payload in binary form, followed by the length of the payload, followed by the concatenation of the RLP encodings of the
600+
// items. The range of the first byte is thus [0xf8, 0xff].
601+
602+
(void)m_size;
603+
long const payloadSize = (m_data->size() / 2) - 1;
604+
size_t header;
605+
if (payloadSize > 55)
606+
{
607+
auto const payloadSizeHex = dev::toCompactHex(payloadSize);
608+
header = 247 + payloadSizeHex.size() / 2;
609+
return "0x" + dev::toCompactHex(header) + payloadSizeHex;
610+
}
611+
else
612+
header = 192 + payloadSize;
613+
return "0x" + dev::toCompactHex(header);
614+
}
615+
579616
}//namespace

retesteth/TestHelper.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,18 @@ string fto_string(t _val)
128128
{
129129
return std::to_string(_val);
130130
}
131+
132+
/// RLP header calculator / Stream Emulator
133+
class RLPStreamU
134+
{
135+
public:
136+
RLPStreamU(size_t _size) : m_size(_size) {}
137+
void appendRaw(string const& _data);
138+
string outHeader() const;
139+
140+
private:
141+
size_t m_size;
142+
string const* m_data;
143+
};
144+
131145
} // namespace test

retesteth/TestSuite.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,18 @@ bool addClientInfo(
136136
bool atLeastOneUpdate = false || Options::get().forceupdate;
137137
SessionInterface& session = RPCSession::instance(TestOutputHelper::getThreadID());
138138

139-
spDataObject filledTest(new DataObject());
139+
spDataObject filledTest;
140140
if ((Options::get().filltests && fs::exists(_existingFilledTest)) && !Options::get().forceupdate)
141141
filledTest = test::readJsonData(_existingFilledTest);
142-
for (auto& testInGenerated : _filledTest.getSubObjectsUnsafe())
142+
143+
for (spDataObject& testInGenerated : _filledTest.getSubObjectsUnsafe())
143144
{
144145
DataObject& testInGeneratedRef = testInGenerated.getContent();
145-
spDataObject clientinfo(new DataObject());
146+
spDataObject clientinfo;
147+
148+
// Since one gtest parsed into many bctests we need a copy
146149
if (testInGeneratedRef.count("_info"))
147-
clientinfo = testInGeneratedRef.atKeyPointerUnsafe("_info");
150+
clientinfo.getContent().copyFrom(testInGeneratedRef.atKey("_info"));
148151

149152
testInGeneratedRef.removeKey("_info");
150153
testInGeneratedRef.performModifier(mod_sortKeys);
@@ -163,6 +166,7 @@ bool addClientInfo(
163166
string const& existingHash = existingTest.atKey("_info").atKey("generatedTestHash").asString();
164167
if (existingHash != clientinfo->atKey("generatedTestHash").asString())
165168
atLeastOneUpdate = true;
169+
166170
string const& existingSrcHash = existingTest.atKey("_info").atKey("sourceHash").asString();
167171
if (existingSrcHash != clientinfo->atKey("sourceHash").asString())
168172
atLeastOneUpdate = true;
@@ -529,8 +533,10 @@ void TestSuite::runAllTestsInFolder(string const& _testFolder) const
529533
if (ExitHandler::receivedExitSignal())
530534
break;
531535

532-
thread testThread(&TestSuite::executeTest, this, _testFolder, file);
533-
ThreadManager::addTask(std::move(testThread));
536+
auto job = [this, &_testFolder, &file](){
537+
executeTest(_testFolder, file);
538+
};
539+
ThreadManager::addTask(job);
534540
}
535541
ThreadManager::joinThreads();
536542
testOutput.finishTest();

retesteth/compiler/Compiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ string encodeAbi(string const& _code);
2121
class solContracts
2222
{
2323
public:
24-
solContracts() { m_solContracts = spDataObject(new DataObject()); }
24+
solContracts() {}
2525
void insertCode(string const& _name, string const& _code) { m_solContracts.getContent()[_name] = _code; }
2626
string const& getCode(string const& _contractName) const;
2727
std::vector<spDataObject> const& Contracts() const { return m_solContracts->getSubObjects(); }

retesteth/configs/ClientConfig.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,17 @@ ClientConfig::ClientConfig(fs::path const& _clientConfigPath) : m_id(ClientConfi
5858
}
5959

6060
// Load correctmining Reward
61-
fs::path correctMiningRewardPath = genesisTemplatePath / "correctMiningReward.json";
62-
ETH_FAIL_REQUIRE_MESSAGE(fs::exists(correctMiningRewardPath),
61+
m_correctMiningRewardPath = genesisTemplatePath / "correctMiningReward.json";
62+
ETH_FAIL_REQUIRE_MESSAGE(fs::exists(m_correctMiningRewardPath),
6363
"correctMiningReward.json client config not found!");
64-
spDataObject correctMiningReward = test::readJsonData(correctMiningRewardPath);
64+
spDataObject correctMiningReward = test::readJsonData(m_correctMiningRewardPath);
6565
correctMiningReward.getContent().performModifier(mod_removeComments);
6666
correctMiningReward.getContent().performModifier(mod_valueToCompactEvenHexPrefixed);
6767
for (auto const& el : cfgFile().forks())
6868
{
6969
if (!correctMiningReward->count(el.asString()))
7070
ETH_FAIL_MESSAGE("Correct mining reward missing block reward record for fork: `" +
71-
el.asString() + "` (" + correctMiningRewardPath.string() + ")");
71+
el.asString() + "` (" + m_correctMiningRewardPath.string() + ")");
7272
}
7373
for (auto const& el : correctMiningReward->getSubObjects())
7474
m_correctReward[el->getKey()] = spVALUE(new VALUE(correctMiningReward->atKey(el->getKey())));

retesteth/configs/Options.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class genConstantinopleFixCfg { public: genConstantinopleFixCfg(); };
2424
class genIstanbulCfg { public: genIstanbulCfg(); };
2525
class genBerlinCfg { public: genBerlinCfg(); };
2626
class genLondonCfg { public: genLondonCfg(); };
27+
class genArrowGlacierCfg { public: genArrowGlacierCfg(); };
2728

2829
// Transition genesis configs
2930
class genFrontierToHomesteadCfg { public: genFrontierToHomesteadCfg(); };
@@ -58,6 +59,7 @@ class OptionsInit
5859
genIstanbulCfg genIstanbuil;
5960
genBerlinCfg genBerlin;
6061
genLondonCfg genLondon;
62+
genArrowGlacierCfg genArrowGlacier;
6163

6264
// Transition genesis configs
6365
genFrontierToHomesteadCfg genFrontierToHomestead;

0 commit comments

Comments
 (0)