Browse Source

Make all exceptions dervie virtual

cl-refactor
Christoph Jentzsch 10 years ago
parent
commit
611377f7cc
  1. 7
      CodingStandards.txt
  2. 5
      alethzero/CMakeLists.txt
  3. 4
      alethzero/MainWin.cpp
  4. 3
      eth/CMakeLists.txt
  5. 2
      eth/main.cpp
  6. 15
      exp/main.cpp
  7. 7
      libdevcore/CMakeLists.txt
  8. 8
      libdevcrypto/CMakeLists.txt
  9. 5
      libdevcrypto/Common.cpp
  10. 2
      libdevcrypto/CryptoHeaders.h
  11. 4
      libdevcrypto/MemoryDB.cpp
  12. 3
      libdevcrypto/MemoryDB.h
  13. 4
      libdevcrypto/OverlayDB.cpp
  14. 3
      libdevcrypto/OverlayDB.h
  15. 4
      libdevcrypto/SHA3.cpp
  16. 3
      libdevcrypto/SHA3.h
  17. 3
      libdevcrypto/TrieCommon.cpp
  18. 22
      libdevcrypto/TrieCommon.h
  19. 3
      libdevcrypto/TrieDB.cpp
  20. 168
      libdevcrypto/TrieDB.h
  21. 2
      libethcore/BlockInfo.cpp
  22. 8
      libethcore/CMakeLists.txt
  23. 2
      libethcore/CommonEth.cpp
  24. 16
      libethcore/Exceptions.h
  25. 4
      libethereum/BlockChain.h
  26. 8
      libethereum/CMakeLists.txt
  27. 5
      libethereum/CommonNet.h
  28. 2
      libethereum/MessageFilter.cpp
  29. 15
      libethereum/State.cpp
  30. 5
      libethereum/State.h
  31. 2
      libethereum/Transaction.cpp
  32. 4
      libethereum/Transaction.h
  33. 8
      libevm/CMakeLists.txt
  34. 2
      libevm/VM.h
  35. 8
      libevmface/CMakeLists.txt
  36. 8
      liblll/CMakeLists.txt
  37. 8
      libp2p/CMakeLists.txt
  38. 5
      libqethereum/CMakeLists.txt
  39. 8
      libqethereum/QEthereum.cpp
  40. 31
      libqethereum/QEthereum.h
  41. 8
      libserpent/CMakeLists.txt
  42. 8
      libwebthree/CMakeLists.txt
  43. 8
      libwhisper/CMakeLists.txt
  44. 2
      libwhisper/Common.h
  45. 13
      libwhisper/Interface.cpp
  46. 19
      libwhisper/Interface.h
  47. 8
      libwhisper/Message.h
  48. 2
      libwhisper/WhisperHost.h
  49. 2
      neth/main.cpp
  50. 39
      qtcreator-style.xml
  51. 4
      test/CMakeLists.txt
  52. 4
      test/MemTrie.cpp
  53. 11
      test/TestHelperCrypto.h
  54. 2
      test/crypto.cpp
  55. 1
      test/hexPrefix.cpp
  56. 2
      test/rlp.cpp
  57. 46
      test/trie.cpp
  58. 11
      test/vm.cpp
  59. 5
      third/CMakeLists.txt

7
CodingStandards.txt

@ -1,7 +1,7 @@
0. Formatting
a. Use tabs for indentation!
- 1 tab is 4 spaces wide.
- tab stops are every 4 characters.
- One indentation level -> exactly one byte (i.e. a tab character) in the source file.
b. Line widths:
- Don't worry about having lines of code > 80-char wide.
@ -11,8 +11,9 @@ d. Never place condition bodies on same line as condition.
e. Space between first paren and keyword, but *not* following first paren or preceeding final paren.
f. No spaces when fewer than intra-expression three parens together; when three or more, space according to clarity.
g. No spaces for subscripting.
h. Space all other operators.
i. Braces, when used, always have their own lines and are at same indentation level as "parent" scope.
h. No space before ':' but one after it, except in the ternary operator: one on both sides.
i. Space all other operators.
j. Braces, when used, always have their own lines and are at same indentation level as "parent" scope.
(WRONG)
if( a==b[ i ] ) { printf ("Hello\n"); }

5
alethzero/CMakeLists.txt

@ -25,6 +25,7 @@ find_package(Qt5WebKitWidgets REQUIRED)
qt5_wrap_ui(ui_Main.h Main.ui)
# Set name of binary and add_executable()
file(GLOB HEADERS "*.h")
if (APPLE)
set(EXECUTEABLE AlethZero)
set(BIN_INSTALL_DIR ".")
@ -41,14 +42,14 @@ if (APPLE)
set(MACOSX_BUNDLE_ICON_FILE alethzero)
include(BundleUtilities)
add_executable(${EXECUTEABLE} MACOSX_BUNDLE alethzero.icns Main.ui ${SRC_LIST})
add_executable(${EXECUTEABLE} MACOSX_BUNDLE alethzero.icns Main.ui ${SRC_LIST} ${HEADERS})
set_target_properties(${EXECUTEABLE} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/EthereumMacOSXBundleInfo.plist.in")
SET_SOURCE_FILES_PROPERTIES(${EXECUTEABLE} PROPERTIES MACOSX_PACKAGE_LOCATION MacOS)
SET_SOURCE_FILES_PROPERTIES(${MACOSX_BUNDLE_ICON_FILE}.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
else ()
set(EXECUTEABLE alethzero)
add_executable(${EXECUTEABLE} Main.ui ${SRC_LIST})
add_executable(${EXECUTEABLE} Main.ui ${SRC_LIST} ${HEADERS})
endif ()
qt5_use_modules(${EXECUTEABLE} Core)# Gui Widgets Network WebKit WebKitWidgets)

4
alethzero/MainWin.cpp

@ -1327,7 +1327,7 @@ void Main::on_contracts_currentItemChanged()
s << "<h4>Body Code</h4>" << disassemble(ethereum()->codeAt(address));
ui->contractInfo->appendHtml(QString::fromStdString(s.str()));
}
catch (dev::eth::InvalidTrie)
catch (dev::InvalidTrie)
{
ui->contractInfo->appendHtml("Corrupted trie.");
}
@ -1864,7 +1864,7 @@ QString Main::prettyU256(dev::u256 _n) const
s << "<span style=\"color: #008\">" << (uint64_t)_n << "</span> <span style=\"color: #448\">(0x" << hex << (uint64_t)_n << ")</span>";
else if (!~(_n >> 64))
s << "<span style=\"color: #008\">" << (int64_t)_n << "</span> <span style=\"color: #448\">(0x" << hex << (int64_t)_n << ")</span>";
else if ((_n >> 200) == 0)
else if ((_n >> 160) == 0)
{
Address a = right160(_n);
QString n = pretty(a);

3
eth/CMakeLists.txt

@ -8,7 +8,8 @@ link_directories(../libwebthree)
set(EXECUTABLE eth)
add_executable(${EXECUTABLE} ${SRC_LIST})
file(GLOB HEADERS "*.h")
add_executable(${EXECUTABLE} ${SRC_LIST} ${HEADERS})
target_link_libraries(${EXECUTABLE} webthree)
target_link_libraries(${EXECUTABLE} secp256k1)

2
eth/main.cpp

@ -700,7 +700,7 @@ int main(int argc, char** argv)
cnote << "Saved" << rechex << "to" << outFile;
}
catch (dev::eth::InvalidTrie)
catch (dev::InvalidTrie)
{
cwarn << "Corrupted trie.";
}

15
exp/main.cpp

@ -29,12 +29,14 @@
#include <libdevcore/RangeMask.h>
#include <libethereum/DownloadMan.h>
#include <libwhisper/WhisperPeer.h>
#include <libwhisper/WhisperHost.h>
using namespace std;
using namespace dev;
using namespace dev::eth;
using namespace dev::p2p;
using namespace dev::shh;
#if 0
int main()
{
DownloadMan man;
@ -69,8 +71,8 @@ int main()
cnote << i;*/
return 0;
}
#endif
/*
int main(int argc, char** argv)
{
g_logVerbosity = 20;
@ -102,15 +104,16 @@ int main(int argc, char** argv)
ph.connect(remoteHost, remotePort);
/// Only interested in the packet if the lowest bit is 1
auto w = wh->installWatch(MessageFilter(std::vector<std::pair<bytes, bytes> >({{fromHex("0000000000000000000000000000000000000000000000000000000000000001"), fromHex("0000000000000000000000000000000000000000000000000000000000000001")}})));
auto w = wh->installWatch(MessageFilter(TopicMasks({{Topic("0000000000000000000000000000000000000000000000000000000000000001"), Topic("0000000000000000000000000000000000000000000000000000000000000001")}})));
for (int i = 0; ; ++i)
{
wh->sendRaw(h256(u256(i * i)).asBytes(), h256(u256(i)).asBytes(), 1000);
wh->sendRaw(RLPStream().append(i * i).out(), Topic(u256(i)), 1000);
for (auto i: wh->checkWatch(w))
cnote << "New message:" << (u256)h256(wh->message(i).payload);
{
auto p = wh->message(i).payload;
cnote << "New message:" << RLP(p).toInt<unsigned>();
}
}
return 0;
}
*/

7
libdevcore/CMakeLists.txt

@ -10,13 +10,12 @@ aux_source_directory(. SRC_LIST)
set(EXECUTABLE devcore)
# set(CMAKE_INSTALL_PREFIX ../lib)
file(GLOB HEADERS "*.h")
if(ETH_STATIC)
add_library(${EXECUTABLE} STATIC ${SRC_LIST})
add_library(${EXECUTABLE} STATIC ${SRC_LIST} ${HEADERS})
else()
add_library(${EXECUTABLE} SHARED ${SRC_LIST})
add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS})
endif()
file(GLOB HEADERS "*.h")
include_directories(..)

8
libdevcrypto/CMakeLists.txt

@ -4,15 +4,13 @@ aux_source_directory(. SRC_LIST)
set(EXECUTABLE devcrypto)
# set(CMAKE_INSTALL_PREFIX ../lib)
file(GLOB HEADERS "*.h")
if(ETH_STATIC)
add_library(${EXECUTABLE} STATIC ${SRC_LIST})
add_library(${EXECUTABLE} STATIC ${SRC_LIST} ${HEADERS})
else()
add_library(${EXECUTABLE} SHARED ${SRC_LIST})
add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS})
endif()
file(GLOB HEADERS "*.h")
include_directories(..)
target_link_libraries(${EXECUTABLE} devcore)

5
libdevcrypto/Common.cpp

@ -25,7 +25,6 @@
#include "SHA3.h"
using namespace std;
using namespace dev;
using namespace dev::eth;
//#define ETH_ADDRESS_DEBUG 1
@ -46,7 +45,7 @@ Address dev::toAddress(Secret _private)
ok = secp256k1_ecdsa_pubkey_verify(pubkey, 65);
if (!ok)
return Address();
auto ret = right160(dev::eth::sha3(bytesConstRef(&(pubkey[1]), 64)));
auto ret = right160(dev::sha3(bytesConstRef(&(pubkey[1]), 64)));
#if ETH_ADDRESS_DEBUG
cout << "---- ADDRESS -------------------------------" << endl;
cout << "SEC: " << _private << endl;
@ -94,7 +93,7 @@ KeyPair::KeyPair(h256 _sec):
m_secret = m_secret;
memcpy(m_public.data(), &(pubkey[1]), 64);
m_address = right160(dev::eth::sha3(bytesConstRef(&(pubkey[1]), 64)));
m_address = right160(dev::sha3(bytesConstRef(&(pubkey[1]), 64)));
#if ETH_ADDRESS_DEBUG
cout << "---- ADDRESS -------------------------------" << endl;

2
libdevcrypto/CryptoHeaders.h

@ -29,6 +29,8 @@
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
#pragma GCC diagnostic ignored "-Wextra"
#include <sha.h>
#include <sha3.h>
#include <ripemd.h>

4
libdevcrypto/MemoryDB.cpp

@ -23,12 +23,9 @@
#include "MemoryDB.h"
using namespace std;
using namespace dev;
using namespace dev::eth;
namespace dev
{
namespace eth
{
std::map<h256, std::string> MemoryDB::get() const
{
@ -116,4 +113,3 @@ set<h256> MemoryDB::keys() const
}
}
}

3
libdevcrypto/MemoryDB.h

@ -29,8 +29,6 @@
namespace dev
{
namespace eth
{
struct DBChannel: public LogChannel { static const char* name() { return "TDB"; } static const int verbosity = 18; };
@ -85,4 +83,3 @@ inline std::ostream& operator<<(std::ostream& _out, MemoryDB const& _m)
}
}
}

4
libdevcrypto/OverlayDB.cpp

@ -23,12 +23,9 @@
#include "OverlayDB.h"
using namespace std;
using namespace dev;
using namespace dev::eth;
namespace dev
{
namespace eth
{
OverlayDB::~OverlayDB()
{
@ -100,4 +97,3 @@ void OverlayDB::kill(h256 _h)
}
}
}

3
libdevcrypto/OverlayDB.h

@ -34,8 +34,6 @@ namespace ldb = leveldb;
namespace dev
{
namespace eth
{
class OverlayDB: public MemoryDB
{
@ -63,4 +61,3 @@ private:
};
}
}

4
libdevcrypto/SHA3.cpp

@ -24,12 +24,9 @@
using namespace std;
using namespace dev;
using namespace dev::eth;
namespace dev
{
namespace eth
{
h256 EmptySHA3 = sha3(bytesConstRef());
@ -118,4 +115,3 @@ bytes aesDecrypt(bytesConstRef _ivCipher, std::string const& _password, unsigned
}
}
}

3
libdevcrypto/SHA3.h

@ -29,8 +29,6 @@
namespace dev
{
namespace eth
{
// SHA-3 convenience routines.
@ -69,4 +67,3 @@ void sha256(bytesConstRef _input, bytesRef _output);
void ripemd160(bytesConstRef _input, bytesRef _output);
}
}

3
libdevcrypto/TrieCommon.cpp

@ -23,8 +23,6 @@
namespace dev
{
namespace eth
{
/*
* Hex-prefix Notation. First nibble has flags: oddness = 2^0 & termination = 2^1
@ -127,4 +125,3 @@ byte uniqueInUse(RLP const& _orig, byte except)
}
}
}

22
libdevcrypto/TrieCommon.h

@ -26,8 +26,6 @@
namespace dev
{
namespace eth
{
inline byte nibble(bytesConstRef _data, unsigned _i)
{
@ -49,10 +47,29 @@ struct NibbleSlice
NibbleSlice(bytesConstRef _d = bytesConstRef(), unsigned _o = 0): data(_d), offset(_o) {}
byte operator[](unsigned _index) const { return nibble(data, offset + _index); }
unsigned size() const { return data.size() * 2 - offset; }
bool empty() const { return !size(); }
NibbleSlice mid(unsigned _index) const { return NibbleSlice(data, offset + _index); }
void clear() { data.reset(); offset = 0; }
bool contains(NibbleSlice _k) const { return shared(_k) == _k.size(); }
unsigned shared(NibbleSlice _k) const { return sharedNibbles(data, offset, offset + size(), _k.data, _k.offset, _k.offset + _k.size()); }
/**
* @brief Determine if we, a full key, are situated prior to a particular key-prefix.
* @param _k The prefix.
* @return true if we are strictly prior to the prefix.
*/
bool isEarlierThan(NibbleSlice _k) const
{
unsigned i;
for (i = 0; i < _k.size() && i < size(); ++i)
if (operator[](i) < _k[i]) // Byte is lower - we're earlier..
return true;
else if (operator[](i) > _k[i]) // Byte is higher - we're not earlier.
return false;
if (i >= _k.size()) // Ran past the end of the prefix - we're == for the entire prefix - we're not earlier.
return false;
return true; // Ran out before the prefix had finished - we're earlier.
}
bool operator==(NibbleSlice _k) const { return _k.size() == size() && shared(_k) == _k.size(); }
bool operator!=(NibbleSlice _s) const { return !operator==(_s); }
};
@ -102,4 +119,3 @@ inline std::string hexPrefixEncode(NibbleSlice _s1, NibbleSlice _s2, bool _leaf)
}
}
}

3
libdevcrypto/TrieDB.cpp

@ -23,10 +23,9 @@
#include "TrieDB.h"
using namespace std;
using namespace dev;
using namespace dev::eth;
#if !ETH_LANGUAGES
const h256 dev::eth::c_shaNull = sha3(rlp(""));
const h256 dev::c_shaNull = sha3(rlp(""));
#endif

168
libdevcrypto/TrieDB.h

@ -39,8 +39,6 @@ namespace ldb = leveldb;
namespace dev
{
namespace eth
{
struct TrieDBChannel: public LogChannel { static const char* name() { return "-T-"; } static const int verbosity = 17; };
#define tdebug clog(TrieDBChannel)
@ -171,6 +169,7 @@ public:
iterator() {}
iterator(GenericTrieDB const* _db);
iterator(GenericTrieDB const* _db, bytesConstRef _key);
iterator& operator++() { next(); return *this; }
@ -184,13 +183,17 @@ public:
private:
void next();
void next(NibbleSlice _key);
struct Node
{
std::string rlp;
std::string key; // as hexPrefixEncoding.
byte child; // 255 -> entering
byte child; // 255 -> entering, 16 -> actually at the node, 17 -> exiting, 0-15 -> actual children.
// 255 -> 16 -> 0 -> 1 -> ... -> 15 -> 17
void setChild(unsigned _i) { child = _i; }
void setFirstChild() { child = 16; }
void incrementChild() { child = child == 16 ? 0 : child == 15 ? 17 : (child + 1); }
@ -205,6 +208,8 @@ public:
iterator begin() const { return this; }
iterator end() const { return iterator(); }
iterator lower_bound(bytesConstRef _key) const { return iterator(this, _key); }
private:
RLPStream& streamNode(RLPStream& _s, bytes const& _b);
@ -298,6 +303,7 @@ public:
iterator() {}
iterator(TrieDB const* _db): Super(_db) {}
iterator(TrieDB const* _db, bytesConstRef _k): Super(_db, _k) {}
value_type operator*() const { return at(); }
value_type operator->() const { return at(); }
@ -307,6 +313,7 @@ public:
iterator begin() const { return this; }
iterator end() const { return iterator(); }
iterator lower_bound(KeyType _k) const { return iterator(this, bytesConstRef((byte const*)&_k, sizeof(KeyType))); }
};
template <class KeyType, class DB>
@ -317,14 +324,11 @@ std::ostream& operator<<(std::ostream& _out, TrieDB<KeyType, DB> const& _db)
return _out;
}
}
}
// Template implementations...
namespace dev
{
namespace eth
{
template <class DB> GenericTrieDB<DB>::iterator::iterator(GenericTrieDB const* _db)
{
@ -333,6 +337,13 @@ template <class DB> GenericTrieDB<DB>::iterator::iterator(GenericTrieDB const* _
next();
}
template <class DB> GenericTrieDB<DB>::iterator::iterator(GenericTrieDB const* _db, bytesConstRef _fullKey)
{
m_that = _db;
m_trail.push_back({_db->node(_db->m_root), std::string(1, '\0'), 255}); // one null byte is the HPE for the empty key.
next(_fullKey);
}
template <class DB> typename GenericTrieDB<DB>::iterator::value_type GenericTrieDB<DB>::iterator::at() const
{
assert(m_trail.size());
@ -341,10 +352,145 @@ template <class DB> typename GenericTrieDB<DB>::iterator::value_type GenericTrie
assert(!(b.key[0] & 0x10)); // should be an integer number of bytes (i.e. not an odd number of nibbles).
RLP rlp(b.rlp);
if (rlp.itemCount() == 2)
return std::make_pair(bytesConstRef(b.key).cropped(1), rlp[1].payload());
else
return std::make_pair(bytesConstRef(b.key).cropped(1), rlp[16].payload());
return std::make_pair(bytesConstRef(b.key).cropped(1), rlp[rlp.itemCount() == 2 ? 1 : 16].payload());
}
template <class DB> void GenericTrieDB<DB>::iterator::next(NibbleSlice _key)
{
NibbleSlice k = _key;
while (true)
{
if (m_trail.empty())
{
m_that = nullptr;
return;
}
Node const& b = m_trail.back();
RLP rlp(b.rlp);
if (m_trail.back().child == 255)
{
// Entering. Look for first...
if (rlp.isEmpty())
{
// Kill our search as soon as we hit an empty node.
k.clear();
m_trail.pop_back();
continue;
}
if (!rlp.isList() || (rlp.itemCount() != 2 && rlp.itemCount() != 17))
{
#if ETH_PARANOIA
cwarn << "BIG FAT ERROR. STATE TRIE CORRUPTED!!!!!";
cwarn << b.rlp.size() << toHex(b.rlp);
cwarn << rlp;
auto c = rlp.itemCount();
cwarn << c;
BOOST_THROW_EXCEPTION(InvalidTrie());
#else
m_that = nullptr;
return;
#endif
}
if (rlp.itemCount() == 2)
{
// Just turn it into a valid Branch
auto keyOfRLP = keyOf(rlp);
// TODO: do something different depending on how keyOfRLP compares to k.mid(0, std::min(k.size(), keyOfRLP.size()));
// if == all is good - continue descent.
// if > discard key and continue descent.
// if < discard key and skip node.
if (!k.contains(keyOfRLP))
{
if (!k.isEarlierThan(keyOfRLP))
{
k.clear();
m_trail.pop_back();
continue;
}
k.clear();
}
k = k.mid(std::min(k.size(), keyOfRLP.size()));
m_trail.back().key = hexPrefixEncode(keyOf(m_trail.back().key), keyOfRLP, false);
if (isLeaf(rlp))
{
// leaf - exit now.
if (k.empty())
{
m_trail.back().child = 0;
return;
}
// Still data in key we're supposed to be looking for when we're at a leaf. Go for next one.
k.clear();
m_trail.pop_back();
continue;
}
// enter child.
m_trail.back().rlp = m_that->deref(rlp[1]);
// no need to set .child as 255 - it's already done.
continue;
}
else
{
// Already a branch - look for first valid.
if (k.size())
{
m_trail.back().setChild(k[0]);
k = k.mid(1);
}
else
m_trail.back().setChild(16);
// run through to...
}
}
else
{
// Continuing/exiting. Look for next...
if (!(rlp.isList() && rlp.itemCount() == 17))
{
k.clear();
m_trail.pop_back();
continue;
}
// else run through to...
m_trail.back().incrementChild();
}
// ...here. should only get here if we're a list.
assert(rlp.isList() && rlp.itemCount() == 17);
for (;; m_trail.back().incrementChild())
if (m_trail.back().child == 17)
{
// finished here.
k.clear();
m_trail.pop_back();
break;
}
else if (!rlp[m_trail.back().child].isEmpty())
{
if (m_trail.back().child == 16)
return; // have a value at this node - exit now.
else
{
// lead-on to another node - enter child.
// fixed so that Node passed into push_back is constructed *before* m_trail is potentially resized (which invalidates back and rlp)
Node const& back = m_trail.back();
m_trail.push_back(Node{
m_that->deref(rlp[back.child]),
hexPrefixEncode(keyOf(back.key), NibbleSlice(bytesConstRef(&back.child, 1), 1), false),
255
});
break;
}
}
else
k.clear();
}
}
template <class DB> void GenericTrieDB<DB>::iterator::next()
@ -923,5 +1069,3 @@ template <class DB> bytes GenericTrieDB<DB>::branch(RLP const& _orig)
}
}
}

2
libethcore/BlockInfo.cpp

@ -72,7 +72,7 @@ h256 BlockInfo::headerHash(bytesConstRef _block)
void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce)
{
hash = dev::eth::sha3(_header.data());
hash = dev::sha3(_header.data());
int field = 0;
try

8
libethcore/CMakeLists.txt

@ -4,15 +4,13 @@ aux_source_directory(. SRC_LIST)
set(EXECUTABLE ethcore)
# set(CMAKE_INSTALL_PREFIX ../lib)
file(GLOB HEADERS "*.h")
if(ETH_STATIC)
add_library(${EXECUTABLE} STATIC ${SRC_LIST})
add_library(${EXECUTABLE} STATIC ${SRC_LIST} ${HEADERS})
else()
add_library(${EXECUTABLE} SHARED ${SRC_LIST})
add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS})
endif()
file(GLOB HEADERS "*.h")
include_directories(..)
target_link_libraries(${EXECUTABLE} devcrypto)

2
libethcore/CommonEth.cpp

@ -100,7 +100,7 @@ Address toAddress(Secret _private)
ok = secp256k1_ecdsa_pubkey_verify(pubkey, 65);
if (!ok)
return Address();
auto ret = right160(dev::eth::sha3(bytesConstRef(&(pubkey[1]), 64)));
auto ret = right160(dev::sha3(bytesConstRef(&(pubkey[1]), 64)));
#if ETH_ADDRESS_DEBUG
cout << "---- ADDRESS -------------------------------" << endl;
cout << "SEC: " << _private << endl;

16
libethcore/Exceptions.h

@ -44,26 +44,26 @@ struct FeeTooSmall: virtual dev::Exception {};
struct TooMuchGasUsed: virtual dev::Exception {};
struct ExtraDataTooBig: virtual dev::Exception {};
struct InvalidSignature: virtual dev::Exception {};
class InvalidBlockFormat: public dev::Exception { public: InvalidBlockFormat(int _f, bytesConstRef _d): m_f(_f), m_d(_d.toBytes()) {} int m_f; bytes m_d; virtual const char* what() const noexcept; };
class InvalidBlockFormat: virtual public dev::Exception { public: InvalidBlockFormat(int _f, bytesConstRef _d): m_f(_f), m_d(_d.toBytes()) {} int m_f; bytes m_d; virtual const char* what() const noexcept; };
struct InvalidUnclesHash: virtual dev::Exception {};
struct InvalidUncle: virtual dev::Exception {};
struct UncleTooOld: virtual dev::Exception {};
class UncleInChain: public dev::Exception { public: UncleInChain(h256Set _uncles, h256 _block): m_uncles(_uncles), m_block(_block) {} h256Set m_uncles; h256 m_block; virtual const char* what() const noexcept; };
class UncleInChain: virtual public dev::Exception { public: UncleInChain(h256Set _uncles, h256 _block): m_uncles(_uncles), m_block(_block) {} h256Set m_uncles; h256 m_block; virtual const char* what() const noexcept; };
struct DuplicateUncleNonce: virtual dev::Exception {};
struct InvalidStateRoot: virtual dev::Exception {};
class InvalidTransactionsHash: public dev::Exception { public: InvalidTransactionsHash(h256 _head, h256 _real): m_head(_head), m_real(_real) {} h256 m_head; h256 m_real; virtual const char* what() const noexcept; };
class InvalidTransactionsHash: virtual public dev::Exception { public: InvalidTransactionsHash(h256 _head, h256 _real): m_head(_head), m_real(_real) {} h256 m_head; h256 m_real; virtual const char* what() const noexcept; };
struct InvalidTransaction: virtual dev::Exception {};
struct InvalidDifficulty: virtual dev::Exception {};
class InvalidGasLimit: public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0): provided(_provided), valid(_valid) {} u256 provided; u256 valid; virtual const char* what() const noexcept; };
class InvalidMinGasPrice: public dev::Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0): provided(_provided), limit(_limit) {} u256 provided; u256 limit; virtual const char* what() const noexcept; };
class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0): provided(_provided), valid(_valid) {} u256 provided; u256 valid; virtual const char* what() const noexcept; };
class InvalidMinGasPrice: virtual public dev::Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0): provided(_provided), limit(_limit) {} u256 provided; u256 limit; virtual const char* what() const noexcept; };
struct InvalidTransactionGasUsed: virtual dev::Exception {};
struct InvalidTransactionStateRoot: virtual dev::Exception {};
struct InvalidTimestamp: virtual dev::Exception {};
class InvalidNonce: public dev::Exception { public: InvalidNonce(u256 _required = 0, u256 _candidate = 0): required(_required), candidate(_candidate) {} u256 required; u256 candidate; virtual const char* what() const noexcept; };
class InvalidBlockNonce: public dev::Exception { public: InvalidBlockNonce(h256 _h = h256(), h256 _n = h256(), u256 _d = 0): h(_h), n(_n), d(_d) {} h256 h; h256 n; u256 d; virtual const char* what() const noexcept; };
class InvalidNonce: virtual public dev::Exception { public: InvalidNonce(u256 _required = 0, u256 _candidate = 0): required(_required), candidate(_candidate) {} u256 required; u256 candidate; virtual const char* what() const noexcept; };
class InvalidBlockNonce: virtual public dev::Exception { public: InvalidBlockNonce(h256 _h = h256(), h256 _n = h256(), u256 _d = 0): h(_h), n(_n), d(_d) {} h256 h; h256 n; u256 d; virtual const char* what() const noexcept; };
struct InvalidParentHash: virtual dev::Exception {};
struct InvalidNumber: virtual dev::Exception {};
struct InvalidContractAddress: virtual dev::Exception {};
struct InvalidContractAddress: virtual public dev::Exception {};
}
}

4
libethereum/BlockChain.h

@ -39,13 +39,15 @@ namespace ldb = leveldb;
namespace dev
{
class OverlayDB;
namespace eth
{
static const h256s NullH256s;
class State;
class OverlayDB;
struct AlreadyHaveBlock: virtual Exception {};
struct UnknownParent: virtual Exception {};

8
libethereum/CMakeLists.txt

@ -6,15 +6,13 @@ aux_source_directory(. SRC_LIST)
set(EXECUTABLE ethereum)
# set(CMAKE_INSTALL_PREFIX ../lib)
file(GLOB HEADERS "*.h")
if(ETH_STATIC)
add_library(${EXECUTABLE} STATIC ${SRC_LIST})
add_library(${EXECUTABLE} STATIC ${SRC_LIST} ${HEADERS})
else()
add_library(${EXECUTABLE} SHARED ${SRC_LIST})
add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS})
endif()
file(GLOB HEADERS "*.h")
include_directories(..)
target_link_libraries(${EXECUTABLE} evm)

5
libethereum/CommonNet.h

@ -30,6 +30,9 @@
namespace dev
{
class OverlayDB;
namespace eth
{
@ -44,7 +47,7 @@ static const unsigned c_maxHashesAsk = 256; ///< Maximum number of hashes GetBl
static const unsigned c_maxBlocks = 128; ///< Maximum number of blocks Blocks will ever send.
static const unsigned c_maxBlocksAsk = 128; ///< Maximum number of blocks we ask to receive in Blocks (when using GetChain).
#endif
class OverlayDB;
class BlockChain;
class TransactionQueue;
class EthereumHost;

2
libethereum/MessageFilter.cpp

@ -36,7 +36,7 @@ h256 MessageFilter::sha3() const
{
RLPStream s;
fillStream(s);
return dev::eth::sha3(s.out());
return dev::sha3(s.out());
}
bool MessageFilter::matches(h256 _bloom) const

15
libethereum/State.cpp

@ -58,7 +58,7 @@ void ecrecoverCode(bytesConstRef _in, bytesRef _out)
int pubkeylen = 65;
secp256k1_start();
if (secp256k1_ecdsa_recover_compact(in.hash.data(), 32, in.r.data(), pubkey, &pubkeylen, 0, (int)(u256)in.v - 27))
ret = dev::eth::sha3(bytesConstRef(&(pubkey[1]), 64));
ret = dev::sha3(bytesConstRef(&(pubkey[1]), 64));
memcpy(_out.data(), &ret, min(_out.size(), sizeof(ret)));
}
@ -207,6 +207,19 @@ State::~State()
{
}
Address State::nextActiveAddress(Address _a) const
{
auto it = m_state.lower_bound(_a);
if ((*it).first == _a)
++it;
if (it == m_state.end())
// exchange comments if we want to wraparound
// it = m_state.begin();
return Address();
return (*it).first;
}
// TODO: repot
struct CachedAddressState
{
CachedAddressState(std::string const& _rlp, AddressState const* _s, OverlayDB const* _o): rS(_rlp), r(rS), s(_s), o(_o) {}

5
libethereum/State.h

@ -40,7 +40,8 @@
namespace dev
{
namespace test{ class FakeExtVM; class FakeState;}
namespace test { class FakeExtVM; class FakeState; }
namespace eth
{
@ -116,6 +117,8 @@ public:
/// @returns the set containing all addresses currently in use in Ethereum.
std::map<Address, u256> addresses() const;
Address nextActiveAddress(Address _a) const;
BlockInfo const& info() const { return m_currentBlock; }
/// @brief Checks that mining the current object will result in a valid block.

2
libethereum/Transaction.cpp

@ -81,7 +81,7 @@ Address Transaction::sender() const
BOOST_THROW_EXCEPTION(InvalidSignature());
// TODO: check right160 is correct and shouldn't be left160.
m_sender = right160(dev::eth::sha3(bytesConstRef(&(pubkey[1]), 64)));
m_sender = right160(dev::sha3(bytesConstRef(&(pubkey[1]), 64)));
#if ETH_ADDRESS_DEBUG
cout << "---- RECOVER -------------------------------" << endl;

4
libethereum/Transaction.h

@ -67,8 +67,8 @@ struct Transaction
void fillStream(RLPStream& _s, bool _sig = true) const;
bytes rlp(bool _sig = true) const { RLPStream s; fillStream(s, _sig); return s.out(); }
std::string rlpString(bool _sig = true) const { return asString(rlp(_sig)); }
h256 sha3(bool _sig = true) const { RLPStream s; fillStream(s, _sig); return dev::eth::sha3(s.out()); }
bytes sha3Bytes(bool _sig = true) const { RLPStream s; fillStream(s, _sig); return dev::eth::sha3Bytes(s.out()); }
h256 sha3(bool _sig = true) const { RLPStream s; fillStream(s, _sig); return dev::sha3(s.out()); }
bytes sha3Bytes(bool _sig = true) const { RLPStream s; fillStream(s, _sig); return dev::sha3Bytes(s.out()); }
private:
mutable Address m_sender;

8
libevm/CMakeLists.txt

@ -6,15 +6,13 @@ aux_source_directory(. SRC_LIST)
set(EXECUTABLE evm)
# set(CMAKE_INSTALL_PREFIX ../lib)
file(GLOB HEADERS "*.h")
if(ETH_STATIC)
add_library(${EXECUTABLE} STATIC ${SRC_LIST})
add_library(${EXECUTABLE} STATIC ${SRC_LIST} ${HEADERS})
else()
add_library(${EXECUTABLE} SHARED ${SRC_LIST})
add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS})
endif()
file(GLOB HEADERS "*.h")
include_directories(..)
target_link_libraries(${EXECUTABLE} ethcore)

2
libevm/VM.h

@ -41,7 +41,7 @@ struct BreakPointHit: virtual VMException {};
struct BadInstruction: virtual VMException {};
struct BadJumpDestination: virtual VMException {};
struct OutOfGas: virtual VMException {};
class StackTooSmall: public VMException { public: StackTooSmall(u256 _req, u256 _got): req(_req), got(_got) {} u256 req; u256 got; };
class StackTooSmall: virtual public VMException { public: StackTooSmall(u256 _req, u256 _got): req(_req), got(_got) {} u256 req; u256 got; };
// Convert from a 256-bit integer stack/memory entry into a 160-bit Address hash.
// Currently we just pull out the right (low-order in BE) 160-bits.

8
libevmface/CMakeLists.txt

@ -6,15 +6,13 @@ aux_source_directory(. SRC_LIST)
set(EXECUTABLE evmface)
# set(CMAKE_INSTALL_PREFIX ../lib)
file(GLOB HEADERS "*.h")
if(ETH_STATIC)
add_library(${EXECUTABLE} STATIC ${SRC_LIST})
add_library(${EXECUTABLE} STATIC ${SRC_LIST} ${HEADERS})
else()
add_library(${EXECUTABLE} SHARED ${SRC_LIST})
add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS})
endif()
file(GLOB HEADERS "*.h")
include_directories(..)
target_link_libraries(${EXECUTABLE} devcore)

8
liblll/CMakeLists.txt

@ -6,15 +6,13 @@ aux_source_directory(. SRC_LIST)
set(EXECUTABLE lll)
# set(CMAKE_INSTALL_PREFIX ../lib)
file(GLOB HEADERS "*.h")
if(ETH_STATIC)
add_library(${EXECUTABLE} STATIC ${SRC_LIST})
add_library(${EXECUTABLE} STATIC ${SRC_LIST} ${HEADERS})
else()
add_library(${EXECUTABLE} SHARED ${SRC_LIST})
add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS})
endif()
file(GLOB HEADERS "*.h")
include_directories(..)
target_link_libraries(${EXECUTABLE} evmface)

8
libp2p/CMakeLists.txt

@ -6,15 +6,13 @@ aux_source_directory(. SRC_LIST)
set(EXECUTABLE p2p)
# set(CMAKE_INSTALL_PREFIX ../lib)
file(GLOB HEADERS "*.h")
if(ETH_STATIC)
add_library(${EXECUTABLE} STATIC ${SRC_LIST})
add_library(${EXECUTABLE} STATIC ${SRC_LIST} ${HEADERS})
else()
add_library(${EXECUTABLE} SHARED ${SRC_LIST})
add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS})
endif()
file(GLOB HEADERS "*.h")
include_directories(..)
target_link_libraries(${EXECUTABLE} devcrypto)

5
libqethereum/CMakeLists.txt

@ -51,10 +51,11 @@ if (APPLE)
include(BundleUtilities)
endif ()
file(GLOB HEADERS "*.h")
if(ETH_STATIC)
add_library(${EXECUTABLE} STATIC ${RESOURCE_ADDED} ${SRC_LIST})
add_library(${EXECUTABLE} STATIC ${RESOURCE_ADDED} ${SRC_LIST} ${HEADERS})
else()
add_library(${EXECUTABLE} SHARED ${RESOURCE_ADDED} ${SRC_LIST})
add_library(${EXECUTABLE} SHARED ${RESOURCE_ADDED} ${SRC_LIST} ${HEADERS})
endif()
include_directories(/)

8
libqethereum/QEthereum.cpp

@ -98,22 +98,22 @@ QString QEthereum::lll(QString _s) const
QString QEthereum::sha3(QString _s) const
{
return toQJS(dev::eth::sha3(toBytes(_s)));
return toQJS(dev::sha3(toBytes(_s)));
}
QString QEthereum::sha3(QString _s1, QString _s2) const
{
return toQJS(dev::eth::sha3(asBytes(padded(_s1, 32)) + asBytes(padded(_s2, 32))));
return toQJS(dev::sha3(asBytes(padded(_s1, 32)) + asBytes(padded(_s2, 32))));
}
QString QEthereum::sha3(QString _s1, QString _s2, QString _s3) const
{
return toQJS(dev::eth::sha3(asBytes(padded(_s1, 32)) + asBytes(padded(_s2, 32)) + asBytes(padded(_s3, 32))));
return toQJS(dev::sha3(asBytes(padded(_s1, 32)) + asBytes(padded(_s2, 32)) + asBytes(padded(_s3, 32))));
}
QString QEthereum::sha3old(QString _s) const
{
return toQJS(dev::eth::sha3(asBytes(_s)));
return toQJS(dev::sha3(asBytes(_s)));
}
QString QEthereum::offset(QString _s, int _i) const

31
libqethereum/QEthereum.h

@ -251,22 +251,29 @@ private:
std::vector<unsigned> m_watches;
};
// TODO: add p2p object
#define QETH_INSTALL_JS_NAMESPACE(frame, eth, shh, env) [frame, eth, shh, env]() \
{ \
frame->disconnect(); \
frame->addToJavaScriptWindowObject("env", env, QWebFrame::QtOwnership); \
frame->addToJavaScriptWindowObject("eth", eth, QWebFrame::ScriptOwnership); \
frame->addToJavaScriptWindowObject("shh", eth, QWebFrame::ScriptOwnership); \
frame->evaluateJavaScript("eth.makeWatch = function(a) { var ww = eth.newWatch(a); var ret = { w: ww }; ret.uninstall = function() { eth.killWatch(w); }; ret.changed = function(f) { eth.watchChanged.connect(function(nw) { if (nw == ww) f() }); }; ret.messages = function() { return JSON.parse(eth.watchMessages(this.w)) }; return ret; }"); \
frame->evaluateJavaScript("eth.watch = function(a) { return eth.makeWatch(JSON.stringify(a)) }"); \
frame->evaluateJavaScript("eth.transact = function(a, f) { var r = eth.doTransact(JSON.stringify(a)); if (f) f(r); }"); \
frame->evaluateJavaScript("eth.call = function(a, f) { var ret = eth.doCallJson(JSON.stringify(a)); if (f) f(ret); return ret; }"); \
frame->evaluateJavaScript("eth.messages = function(a) { return JSON.parse(eth.getMessages(JSON.stringify(a))); }"); \
frame->evaluateJavaScript("eth.block = function(a) { return JSON.parse(eth.getBlock(a)); }"); \
frame->evaluateJavaScript("eth.transaction = function(a) { return JSON.parse(eth.getTransaction(a)); }"); \
frame->evaluateJavaScript("eth.uncle = function(a) { return JSON.parse(eth.getUncle(a)); }"); \
frame->evaluateJavaScript("shh.makeWatch = function(a) { var ww = shh.newWatch(a); var ret = { w: ww }; ret.uninstall = function() { shh.killWatch(w); }; ret.changed = function(f) { shh.watchChanged.connect(function(nw) { if (nw == ww) f() }); }; ret.messages = function() { return JSON.parse(shh.watchMessages(this.w)) }; return ret; }"); \
frame->evaluateJavaScript("shh.watch = function(a) { return shh.makeWatch(JSON.stringify(a)) }"); \
if (eth) \
{ \
frame->addToJavaScriptWindowObject("eth", eth, QWebFrame::ScriptOwnership); \
frame->evaluateJavaScript("eth.makeWatch = function(a) { var ww = eth.newWatch(a); var ret = { w: ww }; ret.uninstall = function() { eth.killWatch(w); }; ret.changed = function(f) { eth.watchChanged.connect(function(nw) { if (nw == ww) f() }); }; ret.messages = function() { return JSON.parse(eth.watchMessages(this.w)) }; return ret; }"); \
frame->evaluateJavaScript("eth.watch = function(a) { return eth.makeWatch(JSON.stringify(a)) }"); \
frame->evaluateJavaScript("eth.transact = function(a, f) { var r = eth.doTransact(JSON.stringify(a)); if (f) f(r); }"); \
frame->evaluateJavaScript("eth.call = function(a, f) { var ret = eth.doCallJson(JSON.stringify(a)); if (f) f(ret); return ret; }"); \
frame->evaluateJavaScript("eth.messages = function(a) { return JSON.parse(eth.getMessages(JSON.stringify(a))); }"); \
frame->evaluateJavaScript("eth.block = function(a) { return JSON.parse(eth.getBlock(a)); }"); \
frame->evaluateJavaScript("eth.transaction = function(a) { return JSON.parse(eth.getTransaction(a)); }"); \
frame->evaluateJavaScript("eth.uncle = function(a) { return JSON.parse(eth.getUncle(a)); }"); \
} \
if (shh) \
{ \
frame->addToJavaScriptWindowObject("shh", shh, QWebFrame::ScriptOwnership); \
frame->evaluateJavaScript("shh.makeWatch = function(a) { var ww = shh.newWatch(a); var ret = { w: ww }; ret.uninstall = function() { shh.killWatch(w); }; ret.changed = function(f) { shh.watchChanged.connect(function(nw) { if (nw == ww) f() }); }; ret.messages = function() { return JSON.parse(shh.watchMessages(this.w)) }; return ret; }"); \
frame->evaluateJavaScript("shh.watch = function(a) { return shh.makeWatch(JSON.stringify(a)) }"); \
} \
}
template <unsigned N> inline boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N * 8, N * 8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>> toInt(QString const& _s)

8
libserpent/CMakeLists.txt

@ -6,15 +6,13 @@ aux_source_directory(. SRC_LIST)
set(EXECUTABLE serpent)
# set(CMAKE_INSTALL_PREFIX ../lib)
file(GLOB HEADERS "*.h")
if(ETH_STATIC)
add_library(${EXECUTABLE} STATIC ${SRC_LIST})
add_library(${EXECUTABLE} STATIC ${SRC_LIST} ${HEADERS})
else()
add_library(${EXECUTABLE} SHARED ${SRC_LIST})
add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS})
endif()
file(GLOB HEADERS "*.h")
include_directories(..)
target_link_libraries(${EXECUTABLE} lll)

8
libwebthree/CMakeLists.txt

@ -6,15 +6,13 @@ aux_source_directory(. SRC_LIST)
set(EXECUTABLE webthree)
# set(CMAKE_INSTALL_PREFIX ../lib)
file(GLOB HEADERS "*.h")
if(ETH_STATIC)
add_library(${EXECUTABLE} STATIC ${SRC_LIST})
add_library(${EXECUTABLE} STATIC ${SRC_LIST} ${HEADERS})
else()
add_library(${EXECUTABLE} SHARED ${SRC_LIST})
add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS})
endif()
file(GLOB HEADERS "*.h")
include_directories(..)
target_link_libraries(${EXECUTABLE} ethereum)

8
libwhisper/CMakeLists.txt

@ -6,15 +6,13 @@ aux_source_directory(. SRC_LIST)
set(EXECUTABLE whisper)
# set(CMAKE_INSTALL_PREFIX ../lib)
file(GLOB HEADERS "*.h")
if(ETH_STATIC)
add_library(${EXECUTABLE} STATIC ${SRC_LIST})
add_library(${EXECUTABLE} STATIC ${SRC_LIST} ${HEADERS})
else()
add_library(${EXECUTABLE} SHARED ${SRC_LIST})
add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS})
endif()
file(GLOB HEADERS "*.h")
include_directories(..)
target_link_libraries(${EXECUTABLE} ethcore)

2
libwhisper/Common.h

@ -57,5 +57,7 @@ enum WhisperPacket
PacketCount
};
using Topic = h256;
}
}

13
libwhisper/Interface.cpp

@ -36,15 +36,8 @@ using namespace dev::shh;
bool MessageFilter::matches(Message const& _m) const
{
for (auto const& t: m_topicMasks)
{
if (t.first.size() != t.second.size() || _m.topic.size() < t.first.size())
continue;
for (unsigned i = 0; i < t.first.size(); ++i)
if (((t.first[i] ^ _m.topic[i]) & t.second[i]) != 0)
goto NEXT;
return true;
NEXT:;
}
for (TopicMask const& t: m_topicMasks)
if (((t.first ^ _m.topic) & t.second) == 0)
return true;
return false;
}

19
libwhisper/Interface.h

@ -37,20 +37,29 @@ namespace dev
namespace shh
{
/*struct TopicMask
{
Topic data;
Topic mask;
};*/
using TopicMask = std::pair<Topic, Topic>;
using TopicMasks = std::vector<TopicMask>;
class MessageFilter
{
public:
MessageFilter() {}
MessageFilter(std::vector<std::pair<bytes, bytes> > const& _m): m_topicMasks(_m) {}
MessageFilter(RLP const& _r): m_topicMasks((std::vector<std::pair<bytes, bytes>>)_r) {}
MessageFilter(TopicMasks const& _m): m_topicMasks(_m) {}
MessageFilter(RLP const& _r): m_topicMasks((TopicMasks)_r) {}
void fillStream(RLPStream& _s) const { _s << m_topicMasks; }
h256 sha3() const { RLPStream s; fillStream(s); return dev::eth::sha3(s.out()); }
h256 sha3() const { RLPStream s; fillStream(s); return dev::sha3(s.out()); }
bool matches(Message const& _m) const;
private:
std::vector<std::pair<bytes, bytes> > m_topicMasks;
TopicMasks m_topicMasks;
};
struct InstalledFilter
@ -85,7 +94,7 @@ public:
virtual Message message(h256 _m) const = 0;
virtual void sendRaw(bytes const& _payload, bytes const& _topic, unsigned _ttl) = 0;
virtual void sendRaw(bytes const& _payload, h256 _topic, unsigned _ttl) = 0;
};
struct WatshhChannel: public dev::LogChannel { static const char* name() { return "shh"; } static const int verbosity = 1; };

8
libwhisper/Message.h

@ -40,23 +40,23 @@ struct Message
{
unsigned expiry = 0;
unsigned ttl = 0;
bytes topic; // TODO: change to h256
Topic topic; // TODO: change to h256
bytes payload;
Message() {}
Message(unsigned _exp, unsigned _ttl, bytes const& _topic, bytes const& _payload): expiry(_exp), ttl(_ttl), topic(_topic), payload(_payload) {}
Message(unsigned _exp, unsigned _ttl, Topic const& _topic, bytes const& _payload): expiry(_exp), ttl(_ttl), topic(_topic), payload(_payload) {}
Message(RLP const& _m)
{
expiry = _m[0].toInt<unsigned>();
ttl = _m[1].toInt<unsigned>();
topic = _m[2].toBytes();
topic = (Topic)_m[2];
payload = _m[3].toBytes();
}
operator bool () const { return !!expiry; }
void streamOut(RLPStream& _s) const { _s.appendList(4) << expiry << ttl << topic << payload; }
h256 sha3() const { RLPStream s; streamOut(s); return dev::eth::sha3(s.out()); }
h256 sha3() const { RLPStream s; streamOut(s); return dev::sha3(s.out()); }
};
}

2
libwhisper/WhisperHost.h

@ -58,7 +58,7 @@ public:
virtual Message message(h256 _m) const { try { dev::ReadGuard l(x_messages); return m_messages.at(_m); } catch (...) { return Message(); } }
virtual void sendRaw(bytes const& _payload, bytes const& _topic, unsigned _ttl) { inject(Message(time(0) + _ttl, _ttl, _topic, _payload)); }
virtual void sendRaw(bytes const& _payload, Topic _topic, unsigned _ttl) { inject(Message(time(0) + _ttl, _ttl, _topic, _payload)); }
private:
void streamMessage(h256 _m, RLPStream& _s) const;

2
neth/main.cpp

@ -805,7 +805,7 @@ int main(int argc, char** argv)
cnote << "Saved" << rechex << "to" << outFile;
}
catch (dev::eth::InvalidTrie const& _e)
catch (dev::InvalidTrie const& _e)
{
cwarn << "Corrupted trie.\n" << diagnostic_information(_e);
}

39
qtcreator-style.xml

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorCodeStyle>
<!-- Written by QtCreator 3.0.1, 2014-10-16T20:02:31. -->
<qtcreator>
<data>
<variable>CodeStyleData</variable>
<valuemap type="QVariantMap">
<value type="bool" key="AlignAssignments">false</value>
<value type="bool" key="AutoSpacesForTabs">false</value>
<value type="bool" key="BindStarToIdentifier">true</value>
<value type="bool" key="BindStarToLeftSpecifier">false</value>
<value type="bool" key="BindStarToRightSpecifier">false</value>
<value type="bool" key="BindStarToTypeName">false</value>
<value type="bool" key="ExtraPaddingForConditionsIfConfusingAlign">true</value>
<value type="bool" key="IndentAccessSpecifiers">false</value>
<value type="bool" key="IndentBlockBody">true</value>
<value type="bool" key="IndentBlockBraces">false</value>
<value type="bool" key="IndentBlocksRelativeToSwitchLabels">false</value>
<value type="bool" key="IndentClassBraces">false</value>
<value type="bool" key="IndentControlFlowRelativeToSwitchLabels">true</value>
<value type="bool" key="IndentDeclarationsRelativeToAccessSpecifiers">true</value>
<value type="bool" key="IndentEnumBraces">false</value>
<value type="bool" key="IndentFunctionBody">true</value>
<value type="bool" key="IndentFunctionBraces">false</value>
<value type="bool" key="IndentNamespaceBody">false</value>
<value type="bool" key="IndentNamespaceBraces">false</value>
<value type="int" key="IndentSize">4</value>
<value type="bool" key="IndentStatementsRelativeToSwitchLabels">true</value>
<value type="bool" key="IndentSwitchLabels">false</value>
<value type="int" key="PaddingMode">2</value>
<value type="bool" key="SpacesForTabs">false</value>
<value type="int" key="TabSize">4</value>
</valuemap>
</data>
<data>
<variable>DisplayName</variable>
<value type="QString">Gav</value>
</data>
</qtcreator>

4
test/CMakeLists.txt

@ -7,7 +7,8 @@ include_directories(..)
link_directories(../libethcore)
link_directories(../libethereum)
add_executable(testeth ${SRC_LIST})
file(GLOB HEADERS "*.h")
add_executable(testeth ${SRC_LIST} ${HEADERS})
add_executable(createRandomTest createRandomTest.cpp vm.cpp)
target_link_libraries(testeth ethereum)
@ -22,7 +23,6 @@ target_link_libraries(createRandomTest boost_chrono)
target_link_libraries(createRandomTest boost_unit_test_framework)
if ("${TARGET_PLATFORM}" STREQUAL "w64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
target_link_libraries(testeth boost_system-mt-s)

4
test/MemTrie.cpp

@ -55,7 +55,7 @@ public:
#endif
/// 256-bit hash of the node - this is a SHA-3/256 hash of the RLP of the node.
h256 hash256() const { RLPStream s; makeRLP(s); return dev::eth::sha3(s.out()); }
h256 hash256() const { RLPStream s; makeRLP(s); return dev::sha3(s.out()); }
bytes rlp() const { RLPStream s; makeRLP(s); return s.out(); }
void mark() { m_hash256 = h256(); }
@ -200,7 +200,7 @@ void MemTrieNode::putRLP(RLPStream& _parentStream) const
if (s.out().size() < 32)
_parentStream.APPEND_CHILD(s.out());
else
_parentStream << dev::eth::sha3(s.out());
_parentStream << dev::sha3(s.out());
}
void TrieBranchNode::makeRLP(RLPStream& _intoStream) const

11
test/TestHelperCrypto.h

@ -22,11 +22,22 @@
#pragma once
//#include <ostream>
#pragma warning(push)
#pragma warning(disable:4100 4244)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
#pragma GCC diagnostic ignored "-Wextra"
#include <eccrypto.h>
#include <ecp.h>
#include <files.h>
#include <osrng.h>
#include <oids.h>
#pragma warning(pop)
#pragma GCC diagnostic pop
using namespace std;
using namespace CryptoPP;

2
test/crypto.cpp

@ -307,7 +307,7 @@ int cryptoTest()
int ret = secp256k1_ecdsa_recover_compact((byte const*)hmsg.data(), (int)hmsg.size(), (byte const*)sig64.data(), pubkey.data(), &pubkeylen, 0, (int)t.vrs.v - 27);
pubkey.resize(pubkeylen);
cout << "RECPUB: " << dec << ret << " " << pubkeylen << " " << toHex(pubkey) << endl;
cout << "SENDER: " << hex << toAddress(dev::eth::sha3(bytesConstRef(&pubkey).cropped(1))) << dec << endl;
cout << "SENDER: " << hex << toAddress(dev::sha3(bytesConstRef(&pubkey).cropped(1))) << dec << endl;
}
#endif
return 0;

1
test/hexPrefix.cpp

@ -29,7 +29,6 @@
using namespace std;
using namespace dev;
using namespace dev::eth;
namespace js = json_spirit;
BOOST_AUTO_TEST_CASE(hexPrefix_test)

2
test/rlp.cpp

@ -79,7 +79,7 @@ namespace dev
if ( v.type() == js::str_type )
{
const std::string& expectedText = v.get_str();
if ( expectedText.front() == '#' )
if ( !expectedText.empty() && expectedText.front() == '#' )
{
// Deal with bigint instead of a raw string
std::string bigIntStr = expectedText.substr(1,expectedText.length()-1);

46
test/trie.cpp

@ -31,7 +31,6 @@
using namespace std;
using namespace dev;
using namespace dev::eth;
namespace js = json_spirit;
@ -236,6 +235,51 @@ BOOST_AUTO_TEST_CASE(moreTrieTests)
}
}
BOOST_AUTO_TEST_CASE(trieLowerBound)
{
cnote << "Stress-testing Trie.lower_bound...";
{
MemoryDB dm;
EnforceRefs e(dm, true);
GenericTrieDB<MemoryDB> d(&dm);
d.init(); // initialise as empty tree.
for (int a = 0; a < 20; ++a)
{
StringMap m;
for (int i = 0; i < 50; ++i)
{
auto k = randomWord();
auto v = toString(i);
m[k] = v;
d.insert(k, v);
}
for (auto i: d)
{
auto it = d.lower_bound(i.first);
for (auto iit = d.begin(); iit != d.end(); ++iit)
if ((*iit).first.toString() >= i.first.toString())
{
BOOST_REQUIRE(it == iit);
break;
}
}
for (unsigned i = 0; i < 100; ++i)
{
auto k = randomWord();
auto it = d.lower_bound(k);
for (auto iit = d.begin(); iit != d.end(); ++iit)
if ((*iit).first.toString() >= k)
{
BOOST_REQUIRE(it == iit);
break;
}
}
}
}
}
BOOST_AUTO_TEST_CASE(trieStess)
{
cnote << "Stress-testing Trie...";

11
test/vm.cpp

@ -497,7 +497,6 @@ void doTests(json_spirit::mValue& v, bool _fillin)
BOOST_REQUIRE(o.count("pre") > 0);
BOOST_REQUIRE(o.count("exec") > 0);
VM vm;
dev::test::FakeExtVM fev;
fev.importEnv(o["env"].get_obj());
fev.importState(o["pre"].get_obj());
@ -512,11 +511,13 @@ void doTests(json_spirit::mValue& v, bool _fillin)
fev.code = &fev.thisTxCode;
}
vm.reset(fev.gas);
bytes output;
u256 gas;
try
{
output = vm.go(fev).toBytes();
VM vm(fev.gas);
output = vm.go(fev).toVector();
gas = vm.gas(); // Get the remaining gas
}
catch (Exception const& _e)
{
@ -553,7 +554,7 @@ void doTests(json_spirit::mValue& v, bool _fillin)
o["post"] = mValue(fev.exportState());
o["callcreates"] = fev.exportCallCreates();
o["out"] = "0x" + toHex(output);
fev.push(o, "gas", vm.gas());
fev.push(o, "gas", gas);
}
else
{
@ -577,7 +578,7 @@ void doTests(json_spirit::mValue& v, bool _fillin)
else
BOOST_CHECK(output == fromHex(o["out"].get_str()));
BOOST_CHECK(test.toInt(o["gas"]) == vm.gas());
BOOST_CHECK(test.toInt(o["gas"]) == gas);
BOOST_CHECK(test.addresses == fev.addresses);
BOOST_CHECK(test.callcreates == fev.callcreates);
}

5
third/CMakeLists.txt

@ -25,6 +25,7 @@ find_package(Qt5WebKitWidgets REQUIRED)
qt5_wrap_ui(ui_Main.h Main.ui)
# Set name of binary and add_executable()
file(GLOB HEADERS "*.h")
if (APPLE)
set(EXECUTEABLE Third)
set(BIN_INSTALL_DIR ".")
@ -41,14 +42,14 @@ if (APPLE)
set(MACOSX_BUNDLE_ICON_FILE third)
include(BundleUtilities)
add_executable(${EXECUTEABLE} MACOSX_BUNDLE third.icns Main.ui ${SRC_LIST})
add_executable(${EXECUTEABLE} MACOSX_BUNDLE third.icns Main.ui ${SRC_LIST} ${HEADERS})
set_target_properties(${EXECUTEABLE} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/EthereumMacOSXBundleInfo.plist.in")
SET_SOURCE_FILES_PROPERTIES(${EXECUTEABLE} PROPERTIES MACOSX_PACKAGE_LOCATION MacOS)
SET_SOURCE_FILES_PROPERTIES(${MACOSX_BUNDLE_ICON_FILE}.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
else ()
set(EXECUTEABLE third)
add_executable(${EXECUTEABLE} Main.ui ${SRC_LIST})
add_executable(${EXECUTEABLE} Main.ui ${SRC_LIST} ${HEADERS})
endif ()
qt5_use_modules(${EXECUTEABLE} Core)# Gui Widgets Network WebKit WebKitWidgets)

Loading…
Cancel
Save