From acfe1a1694cc8febd8e5dbac83fd7968b611e517 Mon Sep 17 00:00:00 2001 From: SharpCoiner Date: Wed, 12 Mar 2014 21:56:28 +0100 Subject: [PATCH 1/7] Fixed cast warning causing 64-bit Windows vcproj build stop." --- libethereum/Instruction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libethereum/Instruction.cpp b/libethereum/Instruction.cpp index 55371bbd6..e7362fc89 100644 --- a/libethereum/Instruction.cpp +++ b/libethereum/Instruction.cpp @@ -507,7 +507,7 @@ static int compileLispFragment(char const*& d, char const* e, bool _quiet, u256s break; } - unsigned datan = codes.size() - 3; + unsigned datan = (unsigned)codes.size() - 3; unsigned i = 0; for (auto it = codes.rbegin(); it != codes.rend(); ++it, ++i) { From acafd8f843b40d117fc1febd786cf6f13811c838 Mon Sep 17 00:00:00 2001 From: Vincent Gariepy Date: Thu, 13 Mar 2014 13:22:36 -0400 Subject: [PATCH 2/7] Add 'inspect' command that writes contracts to file --- eth/main.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/eth/main.cpp b/eth/main.cpp index 75395ffc0..0831a1924 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -83,6 +83,7 @@ void interactiveHelp() << " balance Gives the current balance." << endl << " transact Executes a given transaction." << endl << " send Executes a given transaction with current secret." << endl + << " inspect Dumps a contract to /.evm." << endl << " exit Exits the application." << endl; } @@ -288,6 +289,62 @@ int main(int argc, char** argv) Address dest = h160(fromHex(rechex)); c.transact(us.secret(), dest, amount); } + else if (cmd == "inspect") + { + string rechex; + iss >> rechex; + + c.lock(); + auto hba = h160(fromHex(rechex)); + auto h = h160((byte const*)hba.data(), h160::ConstructFromPointer); + + stringstream s; + auto mem = c.state().contractMemory(h); + u256 next = 0; + unsigned numerics = 0; + bool unexpectedNumeric = false; + for (auto i: mem) + { + if (next < i.first) + { + unsigned j; + for (j = 0; j <= numerics && next + j < i.first; ++j) + s << (j < numerics || unexpectedNumeric ? " 0" : " STOP"); + unexpectedNumeric = false; + numerics -= min(numerics, j); + if (next + j < i.first) + s << "\n@" << showbase << hex << i.first << " "; + } + else if (!next) + { + s << "@" << showbase << hex << i.first << " "; + } + auto iit = c_instructionInfo.find((Instruction)(unsigned)i.second); + if (numerics || iit == c_instructionInfo.end() || (u256)(unsigned)iit->first != i.second) // not an instruction or expecting an argument... + { + if (numerics) + numerics--; + else + unexpectedNumeric = true; + s << " " << showbase << hex << i.second; + } + else + { + auto const& ii = iit->second; + s << " " << ii.name; + numerics = ii.additional; + } + next = i.first + 1; + } + + string outFile = getDataDir() + "/" + rechex + ".evm"; + ofstream ofs; + ofs.open(outFile, ofstream::binary); + ofs.write(s.str().c_str(), s.str().length()); + ofs.close(); + + c.unlock(); + } else if (cmd == "help") { interactiveHelp(); From 3dc7757b146b6489272ada3b805d262e6e437441 Mon Sep 17 00:00:00 2001 From: Vincent Gariepy Date: Thu, 13 Mar 2014 13:52:39 -0400 Subject: [PATCH 3/7] it's cin not iss... leftover from ncurses patch.. --- eth/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth/main.cpp b/eth/main.cpp index 0831a1924..ef3e589b9 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -292,7 +292,7 @@ int main(int argc, char** argv) else if (cmd == "inspect") { string rechex; - iss >> rechex; + cin >> rechex; c.lock(); auto hba = h160(fromHex(rechex)); From 982e4054ff5ee222c102c40aa6a698cd4ef10c15 Mon Sep 17 00:00:00 2001 From: Vincent Gariepy Date: Thu, 13 Mar 2014 13:54:58 -0400 Subject: [PATCH 4/7] headers... --- eth/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eth/main.cpp b/eth/main.cpp index ef3e589b9..b69e11dc5 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -29,9 +29,12 @@ #include "BlockChain.h" #include "State.h" #include "FileSystem.h" +#include "Instruction.h" #include "BuildInfo.h" using namespace std; using namespace eth; +using eth::Instruction; +using eth::c_instructionInfo; bool isTrue(std::string const& _m) { From fbd3e8b000cc5bf0cb424935f485403e29b39a63 Mon Sep 17 00:00:00 2001 From: Marko Simovic Date: Thu, 13 Mar 2014 16:28:41 -0400 Subject: [PATCH 5/7] Modified cmake to generate 'make test' target: runs testeth binary --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4574ed621..de45df4c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,6 +153,9 @@ if (NOT HEADLESS) add_subdirectory(walleth) endif () +enable_testing() +add_test(NAME alltests WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/test COMMAND testeth) + unset(HEADLESS CACHE) #unset(TARGET_PLATFORM CACHE) From 93e25c51e5adac8c7f59e96ceca4c395aec04738 Mon Sep 17 00:00:00 2001 From: Vincent Gariepy Date: Fri, 14 Mar 2014 15:42:03 -0400 Subject: [PATCH 6/7] remove unnecessary replication of the contract's address --- eth/main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/eth/main.cpp b/eth/main.cpp index b69e11dc5..b3ba4c4fc 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -298,8 +298,7 @@ int main(int argc, char** argv) cin >> rechex; c.lock(); - auto hba = h160(fromHex(rechex)); - auto h = h160((byte const*)hba.data(), h160::ConstructFromPointer); + auto h = h160(fromHex(rechex)); stringstream s; auto mem = c.state().contractMemory(h); From 5a55955be01789388ba2d4034789c2497ec194fd Mon Sep 17 00:00:00 2001 From: Vincent Gariepy Date: Mon, 17 Mar 2014 04:33:59 -0400 Subject: [PATCH 7/7] connect with settings in interactive mode --- eth/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eth/main.cpp b/eth/main.cpp index b3ba4c4fc..cbae6cab6 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -217,6 +217,9 @@ int main(int argc, char** argv) cout << " Code by Gav Wood, (c) 2013, 2014." << endl; cout << " Based on a design by Vitalik Buterin." << endl << endl; + if (!remoteHost.empty()) + c.startNetwork(listenPort, remoteHost, remotePort, mode, peers, publicIP, upnp); + while (true) { cout << "> " << flush;