Browse Source

Merge remote-tracking branch 'upstream/develop' into SEC019

cl-refactor
CJentzsch 9 years ago
parent
commit
0d0b759e3e
  1. 10
      CMakeLists.txt
  2. 6
      alethzero/MainWin.cpp
  3. 3
      alethzero/Transact.cpp
  4. 2
      alethzero/plugins/special/InjectTransactions.cpp
  5. 2
      cmake/EthDependencies.cmake
  6. 2
      cmake/EthExecutableHelper.cmake
  7. 35
      cmake/FindEth.cmake
  8. 2
      ethminer/FarmClient.h
  9. 11
      ethminer/MinerAux.h
  10. 2
      ethminer/farm.json
  11. 4
      libdevcore/CMakeLists.txt
  12. 1
      libdevcore/CommonData.cpp
  13. 8
      libdevcore/CommonJS.h
  14. 12
      libdevcore/FixedHash.h
  15. 15
      libdevcore/RLP.cpp
  16. 60
      libdevcore/StructuredLogger.cpp
  17. 17
      libdevcore/vector_ref.h
  18. 7
      libethcore/Common.h
  19. 3
      libethcore/EthashCPUMiner.cpp
  20. 6
      libethereum/Client.cpp
  21. 2
      libethereum/Client.h
  22. 6
      libethereum/ClientBase.cpp
  23. 10
      libethereum/ClientBase.h
  24. 6
      libethereum/Interface.h
  25. 5
      libethereum/TransactionQueue.cpp
  26. 7
      libethereum/TransactionQueue.h
  27. 5
      libevmasm/Assembly.cpp
  28. 1
      libevmasm/CMakeLists.txt
  29. 11
      libevmasm/CommonSubexpressionEliminator.cpp
  30. 1
      libevmasm/Exceptions.h
  31. 8
      libp2p/Host.cpp
  32. 4
      libp2p/Host.h
  33. 6
      libp2p/Session.cpp
  34. 4
      libweb3jsonrpc/WebThreeStubServerBase.cpp
  35. 2
      libweb3jsonrpc/WebThreeStubServerBase.h
  36. 6
      libweb3jsonrpc/abstractwebthreestubserver.h
  37. 2
      libweb3jsonrpc/spec.json
  38. 2
      mix/MixClient.cpp
  39. 2
      mix/MixClient.h
  40. 39
      templates/plugindialog.cpp
  41. 46
      templates/plugindialog.h
  42. 88
      templates/plugindialog.ui
  43. 25
      test/libdevcrypto/SecretStore.cpp
  44. 39
      test/libethereum/StateTestsFiller/stSpecialTestFiller.json
  45. 2
      test/libweb3jsonrpc/webthreestubclient.h
  46. 2
      third/MainWin.cpp

10
CMakeLists.txt

@ -117,7 +117,11 @@ elseif (BUNDLE STREQUAL "wallet")
set(D_TESTS OFF)
set(D_ETHKEY ON)
set(D_MINER OFF)
set(D_ETHASHCL ON)
set(D_ETHASHCL OFF)
set(D_FATDB OFF)
set(D_JSONRPC OFF)
set(D_JSCONSOLE OFF)
set(D_EVMJIT OFF)
elseif (BUNDLE STREQUAL "miner")
set(D_SERPENT OFF)
set(D_SOLIDITY OFF)
@ -128,6 +132,10 @@ elseif (BUNDLE STREQUAL "miner")
set(D_ETHKEY OFF)
set(D_MINER ON)
set(D_ETHASHCL ON)
set(D_FATDB OFF)
set(D_JSONRPC OFF)
set(D_JSCONSOLE OFF)
set(D_EVMJIT OFF)
elseif (BUNDLE STREQUAL "release") # release builds
set(D_SERPENT ${DECENT_PLATFORM})
set(D_SOLIDITY ON)

6
alethzero/MainWin.cpp

@ -158,10 +158,8 @@ Main::Main(QWidget* _parent):
m_keyManager.import(ICAP::createDirect(), "Default identity");
}
#if ETH_DEBUG
m_servers.append("127.0.0.1:30300");
#endif
m_servers.append(QString::fromStdString(Host::pocHost() + ":30303"));
for (auto const& i: Host::pocHosts())
m_servers.append(QString::fromStdString("enode://" + i.first.hex() + "@" + i.second));
if (!dev::contents(dbPath + "/genesis.json").empty())
CanonBlockChain<Ethash>::setGenesis(contentsString(dbPath + "/genesis.json"));

3
alethzero/Transact.cpp

@ -363,7 +363,8 @@ void Transact::timerEvent(QTimerEvent*)
updateBounds();
}
finaliseBounds();
else
finaliseBounds();
}
void Transact::updateBounds()

2
alethzero/plugins/special/InjectTransactions.cpp

@ -67,7 +67,7 @@ void InjectTransactions::doInject(QString _txHex)
try
{
bytes b = fromHex(_txHex.toStdString(), WhenError::Throw);
main()->ethereum()->injectTransaction(b);
main()->ethereum()->injectTransaction(b, IfDropped::Retry);
}
catch (BadHexCharacter& _e)
{

2
cmake/EthDependencies.cmake

@ -17,7 +17,7 @@ set(ETH_GENERATED_DIR "${PROJECT_BINARY_DIR}/gen")
include_directories(${ETH_GENERATED_DIR})
# custom cmake scripts
set(ETH_SCRIPTS_DIR ${CMAKE_SOURCE_DIR}/cmake/scripts)
set(ETH_SCRIPTS_DIR ${CMAKE_CURRENT_LIST_DIR}/scripts)
# Qt5 requires opengl
# TODO use proper version of windows SDK (32 vs 64)

2
cmake/EthExecutableHelper.cmake

@ -95,7 +95,7 @@ macro(eth_install_executable EXECUTABLE)
add_custom_command(TARGET ${EXECUTABLE} POST_BUILD
COMMAND ${MACDEPLOYQT_APP} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${EXECUTABLE}.app -executable=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${EXECUTABLE}.app/Contents/MacOS/${EXECUTABLE} ${eth_qml_dir}
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND sh ${CMAKE_SOURCE_DIR}/cmake/scripts/macdeployfix.sh ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${EXECUTABLE}.app/Contents
COMMAND sh ${ETH_SCRIPTS_DIR}/macdeployfix.sh ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${EXECUTABLE}.app/Contents
)
# This tool and next will inspect linked libraries in order to determine which dependencies are required

35
cmake/FindEth.cmake

@ -0,0 +1,35 @@
# Find ethereum
#
# Find the ethereum includes and library
#
# This module defines
# ETH_CORE_LIBRARIES, the libraries needed to use ethereum.
# ETH_FOUND, If false, do not try to use ethereum.
# TODO: ETH_INCLUDE_DIRS
set(CORE_LIBS web3jsonrpc;webthree;whisper;ethereum;evm;ethcore;lll;p2p;evmasm;devcrypto;evmcore;natspec;devcore;ethash-cl;ethash;secp256k1;scrypt;jsqrc)
set(ALL_LIBS ${CORE_LIBS};evmjit;solidity;secp256k1)
set(ETH_INCLUDE_DIRS ${ETH_INCLUDE_DIR})
set(ETH_CORE_LIBRARIES ${ETH_LIBRARY})
foreach (l ${ALL_LIBS})
string(TOUPPER ${l} L)
find_library(ETH_${L}_LIBRARY
NAMES ${l}
PATH_SUFFIXES "lib${l}" "${l}"
)
endforeach()
foreach (l ${CORE_LIBS})
string(TOUPPER ${l} L)
list(APPEND ETH_CORE_LIBRARIES ${ETH_${L}_LIBRARY})
endforeach()
# handle the QUIETLY and REQUIRED arguments and set ETH_FOUND to TRUE
# if all listed variables are TRUE, hide their existence from configuration view
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ethereum DEFAULT_MSG
ETH_CORE_LIBRARIES)
mark_as_advanced (ETH_CORE_LIBRARIES)

2
ethminer/FarmClient.h

@ -34,7 +34,7 @@ class FarmClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
bool eth_submitHashrate(int param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
bool eth_submitHashrate(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);

11
ethminer/MinerAux.h

@ -37,6 +37,7 @@
#include <libdevcore/StructuredLogger.h>
#include <libethcore/Exceptions.h>
#include <libdevcore/SHA3.h>
#include <libdevcore/CommonJS.h>
#include <libethcore/EthashAux.h>
#include <libethcore/EthashGPUMiner.h>
#include <libethcore/EthashCPUMiner.h>
@ -513,7 +514,15 @@ private:
minelog << "Getting work package...";
auto rate = mp.rate();
rpc.eth_submitHashrate((int)rate, "0x" + id.hex());
try
{
rpc.eth_submitHashrate(toJS((u256)rate), "0x" + id.hex());
}
catch (jsonrpc::JsonRpcException const& _e)
{
cwarn << "Failed to submit hashrate.";
cwarn << boost::diagnostic_information(_e);
}
Json::Value v = rpc.eth_getWork();
h256 hh(v[0].asString());

2
ethminer/farm.json

@ -1,7 +1,7 @@
[
{ "name": "eth_getWork", "params": [], "order": [], "returns": []},
{ "name": "eth_submitWork", "params": ["", "", ""], "order": [], "returns": true},
{ "name": "eth_submitHashrate", "params": [0, ""], "order": [], "returns": true},
{ "name": "eth_submitHashrate", "params": ["", ""], "order": [], "returns": true},
{ "name": "eth_awaitNewWork", "params": [], "order": [], "returns": []},
{ "name": "eth_progress", "params": [], "order": [], "returns": true}
]

4
libdevcore/CMakeLists.txt

@ -20,7 +20,9 @@ target_link_libraries(${EXECUTABLE} ${Boost_THREAD_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${Boost_RANDOM_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${Boost_FILESYSTEM_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${Boost_SYSTEM_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${JSONCPP_LIBRARIES})
if (JSONRPC)
target_link_libraries(${EXECUTABLE} ${JSONCPP_LIBRARIES})
endif()
target_link_libraries(${EXECUTABLE} ${DB_LIBRARIES})
# transitive dependencies for windows executables

1
libdevcore/CommonData.cpp

@ -20,6 +20,7 @@
*/
#include "CommonData.h"
#include <random>
#include <boost/random/uniform_int_distribution.hpp>
#include "Exceptions.h"
#include "Log.h"

8
libdevcore/CommonJS.h

@ -67,9 +67,9 @@ template<typename T> std::string toJS(T const& _i)
/// Convert string to byte array. Input parameters can be hex or dec. Returns empty array if invalid input e.g neither dec or hex.
bytes jsToBytes(std::string const& _s);
/// Add '0' on the head of @a _b until @a _l.
/// Add '0' on, or remove items from, the front of @a _b until it is of length @a _l.
bytes padded(bytes _b, unsigned _l);
/// Add '0' on the queue of @a _b until @a _l.
/// Add '0' on, or remove items from, the back of @a _b until it is of length @a _l.
bytes paddedRight(bytes _b, unsigned _l);
/// Removing all trailing '0'. Returns empty array if input contains only '0' char.
bytes unpadded(bytes _s);
@ -113,9 +113,7 @@ inline u256 jsToU256(std::string const& _s) { return jsToInt<32>(_s); }
inline int jsToInt(std::string const& _s)
{
if (_s.size() > 2 && _s.substr(0, 2).compare("0x") == 0)
return std::stoi(_s, nullptr, 16);
return std::stoi(_s, nullptr, 10);
return std::stoi(_s, nullptr, 0);
}
inline std::string jsToDecimal(std::string const& _s)

12
libdevcore/FixedHash.h

@ -149,18 +149,16 @@ public:
/// @returns a constant reference to the object's data as an STL array.
std::array<byte, N> const& asArray() const { return m_data; }
/// @returns a randomly-valued hash
/// Populate with random data.
template <class Engine>
static FixedHash random(Engine& _eng)
void randomize(Engine& _eng)
{
FixedHash ret;
for (auto& i: ret.m_data)
for (auto& i: m_data)
i = (uint8_t)boost::random::uniform_int_distribution<uint16_t>(0, 255)(_eng);
return ret;
}
/// @returns a random valued object.
static FixedHash random() { return random(s_fixedHashEngine); }
static FixedHash random() { FixedHash ret; ret.randomize(s_fixedHashEngine); return ret; }
struct hash
{
@ -293,7 +291,7 @@ public:
bytesConstRef ref() const { return FixedHash<T>::ref(); }
byte const* data() const { return FixedHash<T>::data(); }
static SecureFixedHash<T> random() { SecureFixedHash<T> ret; ret.FixedHash<T>::ref().randomize(); return ret; }
static SecureFixedHash<T> random() { SecureFixedHash<T> ret; ret.randomize(s_fixedHashEngine); return ret; }
using FixedHash<T>::firstBitSet;
void clear() { ref().cleanse(); }

15
libdevcore/RLP.cpp

@ -343,9 +343,11 @@ void RLPStream::pushCount(size_t _count, byte _base)
pushInt(_count, br);
}
std::ostream& dev::operator<<(std::ostream& _out, RLP const& _d)
static void streamOut(std::ostream& _out, dev::RLP const& _d, unsigned _depth = 0)
{
if (_d.isNull())
if (_depth > 64)
_out << "<max-depth-reached>";
else if (_d.isNull())
_out << "null";
else if (_d.isInt())
_out << std::showbase << std::hex << std::nouppercase << _d.toInt<bigint>(RLP::LaissezFaire) << dec;
@ -356,9 +358,16 @@ std::ostream& dev::operator<<(std::ostream& _out, RLP const& _d)
_out << "[";
int j = 0;
for (auto i: _d)
_out << (j++ ? ", " : " ") << i;
{
_out << (j++ ? ", " : " ");
streamOut(_out, i, _depth + 1);
}
_out << " ]";
}
}
std::ostream& dev::operator<<(std::ostream& _out, RLP const& _d)
{
streamOut(_out, _d);
return _out;
}

60
libdevcore/StructuredLogger.cpp

@ -23,8 +23,9 @@
#include "StructuredLogger.h"
#include <boost/asio/ip/tcp.hpp>
#if ETH_JSONRPC
#include <json/json.h>
#endif
#include <libdevcore/CommonIO.h>
#include "Guards.h"
@ -45,16 +46,22 @@ void StructuredLogger::initialize(bool _enabled, std::string const& _timeFormat,
void StructuredLogger::outputJson(Json::Value const& _value, std::string const& _name) const
{
#if ETH_JSONRPC
Json::Value event;
static Mutex s_lock;
Json::FastWriter fastWriter;
Guard l(s_lock);
event[_name] = _value;
(m_out.is_open() ? m_out : cout) << fastWriter.write(event) << endl;
#else
(void)_value;
(void)_name;
#endif
}
void StructuredLogger::starting(string const& _clientImpl, const char* _ethVersion)
{
#if ETH_JSONRPC
if (get().m_enabled)
{
Json::Value event;
@ -65,10 +72,15 @@ void StructuredLogger::starting(string const& _clientImpl, const char* _ethVersi
get().outputJson(event, "starting");
}
#else
(void)_clientImpl;
(void)_ethVersion;
#endif
}
void StructuredLogger::stopping(string const& _clientImpl, const char* _ethVersion)
{
#if ETH_JSONRPC
if (get().m_enabled)
{
Json::Value event;
@ -79,6 +91,10 @@ void StructuredLogger::stopping(string const& _clientImpl, const char* _ethVersi
get().outputJson(event, "stopping");
}
#else
(void)_clientImpl;
(void)_ethVersion;
#endif
}
void StructuredLogger::p2pConnected(
@ -88,6 +104,7 @@ void StructuredLogger::p2pConnected(
string const& _remoteVersion,
unsigned int _numConnections)
{
#if ETH_JSONRPC
if (get().m_enabled)
{
std::stringstream addrStream;
@ -101,10 +118,18 @@ void StructuredLogger::p2pConnected(
get().outputJson(event, "p2p.connected");
}
#else
(void)_id;
(void)_addr;
(void)_ts;
(void)_remoteVersion;
(void)_numConnections;
#endif
}
void StructuredLogger::p2pDisconnected(string const& _id, bi::tcp::endpoint const& _addr, unsigned int _numConnections)
{
#if ETH_JSONRPC
if (get().m_enabled)
{
std::stringstream addrStream;
@ -117,6 +142,11 @@ void StructuredLogger::p2pDisconnected(string const& _id, bi::tcp::endpoint cons
get().outputJson(event, "p2p.disconnected");
}
#else
(void)_id;
(void)_addr;
(void)_numConnections;
#endif
}
void StructuredLogger::minedNewBlock(
@ -125,6 +155,7 @@ void StructuredLogger::minedNewBlock(
string const& _chainHeadHash,
string const& _prevHash)
{
#if ETH_JSONRPC
if (get().m_enabled)
{
Json::Value event;
@ -136,6 +167,12 @@ void StructuredLogger::minedNewBlock(
get().outputJson(event, "eth.miner.new_block");
}
#else
(void)_hash;
(void)_blockNumber;
(void)_chainHeadHash;
(void)_prevHash;
#endif
}
void StructuredLogger::chainReceivedNewBlock(
@ -145,6 +182,7 @@ void StructuredLogger::chainReceivedNewBlock(
string const& _remoteID,
string const& _prevHash)
{
#if ETH_JSONRPC
if (get().m_enabled)
{
Json::Value event;
@ -157,6 +195,13 @@ void StructuredLogger::chainReceivedNewBlock(
get().outputJson(event, "eth.chain.received.new_block");
}
#else
(void)_hash;
(void)_blockNumber;
(void)_chainHeadHash;
(void)_remoteID;
(void)_prevHash;
#endif
}
void StructuredLogger::chainNewHead(
@ -165,6 +210,7 @@ void StructuredLogger::chainNewHead(
string const& _chainHeadHash,
string const& _prevHash)
{
#if ETH_JSONRPC
if (get().m_enabled)
{
Json::Value event;
@ -176,10 +222,17 @@ void StructuredLogger::chainNewHead(
get().outputJson(event, "eth.miner.new_block");
}
#else
(void)_hash;
(void)_blockNumber;
(void)_chainHeadHash;
(void)_prevHash;
#endif
}
void StructuredLogger::transactionReceived(string const& _hash, string const& _remoteId)
{
#if ETH_JSONRPC
if (get().m_enabled)
{
Json::Value event;
@ -189,7 +242,10 @@ void StructuredLogger::transactionReceived(string const& _hash, string const& _r
get().outputJson(event, "eth.tx.received");
}
#else
(void)_hash;
(void)_remoteId;
#endif
}
}

17
libdevcore/vector_ref.h

@ -5,16 +5,10 @@
#include <type_traits>
#include <vector>
#include <string>
#include <random>
#include <boost/random/random_device.hpp>
#include <boost/random/uniform_int_distribution.hpp>
namespace dev
{
static unsigned char s_cleanseCounter = 0;
static boost::random_device s_vectorRefEngine;
/**
* A modifiable reference to an existing object or vector in memory.
*/
@ -71,20 +65,11 @@ public:
void copyTo(vector_ref<typename std::remove_const<_T>::type> _t) const { if (overlapsWith(_t)) memmove(_t.data(), m_data, std::min(_t.size(), m_count) * sizeof(_T)); else memcpy(_t.data(), m_data, std::min(_t.size(), m_count) * sizeof(_T)); }
/// Copies the contents of this vector_ref to the contents of @a _t, and zeros further trailing elements in @a _t.
void populate(vector_ref<typename std::remove_const<_T>::type> _t) const { copyTo(_t); memset(_t.data() + m_count, 0, std::max(_t.size(), m_count) - m_count); }
/// Populate with random data.
template <class Engine>
void randomize(Engine& _eng)
{
uint8_t* e = (uint8_t*)end();
for (uint8_t* i = (uint8_t*)begin(); i != e; ++i)
*i = (uint8_t)boost::random::uniform_int_distribution<uint16_t>(0, 255)(_eng);
}
/// @returns a random valued object.
void randomize() { randomize(s_vectorRefEngine); }
/// Securely overwrite the memory.
/// @note adapted from OpenSSL's implementation.
void cleanse()
{
static unsigned char s_cleanseCounter = 0;
uint8_t* p = (uint8_t*)begin();
size_t const len = (uint8_t*)end() - p;
size_t loop = len;

7
libethcore/Common.h

@ -226,5 +226,12 @@ struct WorkingProgress
uint64_t rate() const { return ms == 0 ? 0 : hashes * 1000 / ms; }
};
/// Import transaction policy
enum class IfDropped
{
Ignore, ///< Don't import transaction that was previously dropped.
Retry ///< Import transaction even if it was dropped before.
};
}
}

3
libethcore/EthashCPUMiner.cpp

@ -25,6 +25,7 @@
#include <thread>
#include <chrono>
#include <boost/algorithm/string.hpp>
#include <random>
#if ETH_CPUID || !ETH_TRUE
#define HAVE_STDINT_H
#include <libcpuid/libcpuid.h>
@ -78,7 +79,7 @@ void EthashCPUMiner::workLoop()
auto tid = std::this_thread::get_id();
static std::mt19937_64 s_eng((time(0) + std::hash<decltype(tid)>()(tid)));
uint64_t tryNonce = (uint64_t)(u64)Nonce::random(s_eng);
uint64_t tryNonce = s_eng();
ethash_return_value ethashReturn;
WorkPackage w = work();

6
libethereum/Client.cpp

@ -507,9 +507,9 @@ WorkingProgress Client::miningProgress() const
return WorkingProgress();
}
uint64_t Client::hashrate() const
u256 Client::hashrate() const
{
uint64_t r = externalHashrate();
u256 r = externalHashrate();
if (Ethash::isWorking(m_sealEngine.get()))
r += Ethash::workingProgress(m_sealEngine.get()).rate();
return r;
@ -790,7 +790,7 @@ void Client::doWork()
}
t = true;
if (m_syncTransactionQueue.compare_exchange_strong(t, false) && !m_remoteWorking && !isSyncing())
if (!isSyncing() && !m_remoteWorking && m_syncTransactionQueue.compare_exchange_strong(t, false))
syncTransactionQueue();
tick();

2
libethereum/Client.h

@ -171,7 +171,7 @@ public:
/// Are we mining now?
bool wouldMine() const override { return m_wouldMine; }
/// The hashrate...
uint64_t hashrate() const override;
u256 hashrate() const override;
/// Check the progress of the mining.
WorkingProgress miningProgress() const override;
/// Get and clear the mining history.

6
libethereum/ClientBase.cpp

@ -524,14 +524,14 @@ bool ClientBase::isKnownTransaction(h256 const& _blockHash, unsigned _i) const
return isKnown(_blockHash) && bc().transactions().size() > _i;
}
void ClientBase::submitExternalHashrate(int _rate, h256 const& _id)
void ClientBase::submitExternalHashrate(u256 const& _rate, h256 const& _id)
{
m_externalRates[_id] = make_pair(_rate, chrono::steady_clock::now());
}
uint64_t ClientBase::externalHashrate() const
u256 ClientBase::externalHashrate() const
{
uint64_t ret = 0;
u256 ret = 0;
for (auto i = m_externalRates.begin(); i != m_externalRates.end();)
if (chrono::steady_clock::now() - i->second.second > chrono::seconds(5))
i = m_externalRates.erase(i);

10
libethereum/ClientBase.h

@ -138,7 +138,7 @@ public:
virtual Transactions pending() const override;
virtual h256s pendingHashes() const override;
virtual ImportResult injectTransaction(bytes const& _rlp) override { prepareForTransaction(); return m_tq.import(_rlp); }
virtual ImportResult injectTransaction(bytes const& _rlp, IfDropped _id = IfDropped::Ignore) override { prepareForTransaction(); return m_tq.import(_rlp, _id); }
virtual ImportResult injectBlock(bytes const& _block) override;
using Interface::diff;
@ -164,10 +164,10 @@ public:
virtual void stopMining() override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("ClientBase::stopMining")); }
virtual bool isMining() const override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("ClientBase::isMining")); }
virtual bool wouldMine() const override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("ClientBase::wouldMine")); }
virtual uint64_t hashrate() const override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("ClientBase::hashrate")); }
virtual u256 hashrate() const override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("ClientBase::hashrate")); }
virtual WorkingProgress miningProgress() const override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("ClientBase::miningProgress")); }
virtual void submitExternalHashrate(int _rate, h256 const& _id) override;
virtual void submitExternalHashrate(u256 const& _rate, h256 const& _id) override;
Block asOf(BlockNumber _h) const;
@ -182,7 +182,7 @@ protected:
virtual void prepareForTransaction() = 0;
/// }
uint64_t externalHashrate() const;
u256 externalHashrate() const;
TransactionQueue m_tq; ///< Maintains a list of incoming transactions not yet in a block on the blockchain.
@ -194,7 +194,7 @@ protected:
std::map<unsigned, ClientWatch> m_watches; ///< Each and every watch - these reference a filter.
// external hashrate
mutable std::unordered_map<h256, std::pair<uint64_t, std::chrono::steady_clock::time_point>> m_externalRates;
mutable std::unordered_map<h256, std::pair<u256, std::chrono::steady_clock::time_point>> m_externalRates;
};
}}

6
libethereum/Interface.h

@ -94,7 +94,7 @@ public:
ExecutionResult create(Secret const& _secret, u256 _value, bytes const& _data, u256 _gas, u256 _gasPrice, FudgeFactor _ff = FudgeFactor::Strict) { return create(toAddress(_secret), _value, _data, _gas, _gasPrice, _ff); }
/// Injects the RLP-encoded transaction given by the _rlp into the transaction queue directly.
virtual ImportResult injectTransaction(bytes const& _rlp) = 0;
virtual ImportResult injectTransaction(bytes const& _rlp, IfDropped _id = IfDropped::Ignore) = 0;
/// Injects the RLP-encoded block given by the _rlp into the block queue directly.
virtual ImportResult injectBlock(bytes const& _block) = 0;
@ -211,14 +211,14 @@ public:
/// Would we like to mine now?
virtual bool wouldMine() const = 0;
/// Current hash rate.
virtual uint64_t hashrate() const = 0;
virtual u256 hashrate() const = 0;
/// Get hash of the current block to be mined minus the nonce (the 'work hash').
virtual std::tuple<h256, h256, h256> getEthashWork() { BOOST_THROW_EXCEPTION(InterfaceNotSupported("Interface::getEthashWork")); }
/// Submit the nonce for the proof-of-work.
virtual bool submitEthashWork(h256 const&, h64 const&) { BOOST_THROW_EXCEPTION(InterfaceNotSupported("Interface::submitEthashWork")); }
/// Submit the ongoing hashrate of a particular external miner.
virtual void submitExternalHashrate(int, h256 const&) { BOOST_THROW_EXCEPTION(InterfaceNotSupported("Interface::submitExternalHashrate")); }
virtual void submitExternalHashrate(u256 const&, h256 const&) { BOOST_THROW_EXCEPTION(InterfaceNotSupported("Interface::submitExternalHashrate")); }
/// Check the progress of the mining.
virtual WorkingProgress miningProgress() const = 0;

5
libethereum/TransactionQueue.cpp

@ -294,6 +294,7 @@ void TransactionQueue::setFuture(h256 const& _txHash)
void TransactionQueue::makeCurrent_WITH_LOCK(Transaction const& _t)
{
bool newCurrent = false;
auto fs = m_future.find(_t.from());
if (fs != m_future.end())
{
@ -311,6 +312,7 @@ void TransactionQueue::makeCurrent_WITH_LOCK(Transaction const& _t)
--m_futureSize;
++ft;
++nonce;
newCurrent = true;
}
fs->second.erase(fb, ft);
if (fs->second.empty())
@ -328,6 +330,9 @@ void TransactionQueue::makeCurrent_WITH_LOCK(Transaction const& _t)
if (m_future.begin()->second.empty())
m_future.erase(m_future.begin());
}
if (newCurrent)
m_onReady();
}
void TransactionQueue::drop(h256 const& _txHash)

7
libethereum/TransactionQueue.h

@ -42,13 +42,6 @@ struct TransactionQueueChannel: public LogChannel { static const char* name(); s
struct TransactionQueueTraceChannel: public LogChannel { static const char* name(); static const int verbosity = 7; };
#define ctxq dev::LogOutputStream<dev::eth::TransactionQueueTraceChannel, true>()
/// Import transaction policy
enum class IfDropped
{
Ignore, ///< Don't import transaction that was previously dropped.
Retry ///< Import transaction even if it was dropped before.
};
/**
* @brief A queue of Transactions, each stored as RLP.
* Maintains a transaction queue sorted by nonce diff and gas price.

5
libevmasm/Assembly.cpp

@ -337,6 +337,11 @@ Assembly& Assembly::optimise(bool _enable, bool _isCreation, size_t _runs)
// This might happen if the opcode reconstruction is not as efficient
// as the hand-crafted code.
}
catch (ItemNotAvailableException const&)
{
// This might happen if e.g. associativity and commutativity rules
// reorganise the expression tree, but not all leaves are available.
}
if (shouldReplace)
{

1
libevmasm/CMakeLists.txt

@ -20,7 +20,6 @@ else()
endif()
target_link_libraries(${EXECUTABLE} evmcore)
target_link_libraries(${EXECUTABLE} devcrypto)
install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib )
install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} )

11
libevmasm/CommonSubexpressionEliminator.cpp

@ -220,6 +220,12 @@ void CSECodeGenerator::addDependencies(Id _c)
if (m_neededBy.count(_c))
return; // we already computed the dependencies for _c
ExpressionClasses::Expression expr = m_expressionClasses.representative(_c);
if (expr.item->type() == UndefinedItem)
BOOST_THROW_EXCEPTION(
// If this exception happens, we need to find a different way to generate the
// compound expression.
ItemNotAvailableException() << errinfo_comment("Undefined item requested but not available.")
);
for (Id argument: expr.arguments)
{
addDependencies(argument);
@ -317,6 +323,11 @@ void CSECodeGenerator::generateClassElement(Id _c, bool _allowSequenced)
"Sequence constrained operation requested out of sequence."
);
assertThrow(expr.item, OptimizerException, "Non-generated expression without item.");
assertThrow(
expr.item->type() != UndefinedItem,
OptimizerException,
"Undefined item requested but not available."
);
vector<Id> const& arguments = expr.arguments;
for (Id arg: boost::adaptors::reverse(arguments))
generateClassElement(arg);

1
libevmasm/Exceptions.h

@ -31,6 +31,7 @@ namespace eth
struct AssemblyException: virtual Exception {};
struct OptimizerException: virtual AssemblyException {};
struct StackTooDeepException: virtual OptimizerException {};
struct ItemNotAvailableException: virtual OptimizerException {};
}
}

8
libp2p/Host.cpp

@ -439,16 +439,10 @@ void Host::runAcceptor()
}
}
string Host::pocHost()
{
vector<string> strs;
boost::split(strs, dev::Version, boost::is_any_of("."));
return "poc-" + strs[1] + ".ethdev.com";
}
std::unordered_map<Public, std::string> const& Host::pocHosts()
{
static const std::unordered_map<Public, std::string> c_ret = {
{ Public("5374c1bff8df923d3706357eeb4983cd29a63be40a269aaa2296ee5f3b2119a8978c0ed68b8f6fc84aad0df18790417daadf91a4bfbb786a16c9b0a199fa254a"), "gav.ethdev.com:30300" },
{ Public("979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba81760f39d0701ef1d8f89cc1fbd2cacba0710a12cd5314d5e0c9021aa3637f9"), "poc-9.ethdev.com:30303" },
{ Public("a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c"), "52.16.188.185:30303" },
{ Public("7f25d3eab333a6b98a8b5ed68d962bb22c876ffcd5561fca54e3c2ef27f754df6f7fd7c9b74cc919067abac154fb8e1f8385505954f161ae440abc355855e034"), "54.207.93.166:30303" }

4
libp2p/Host.h

@ -145,9 +145,7 @@ public:
/// Will block on network process events.
virtual ~Host();
/// Default host for current version of client.
static std::string pocHost();
/// Default hosts for current version of client.
static std::unordered_map<Public, std::string> const& pocHosts();
/// Register a peer-capability; all new peer connections will have this capability.

6
libp2p/Session.cpp

@ -419,8 +419,12 @@ void Session::doRead()
{
auto packetType = (PacketType)RLP(frame.cropped(0, 1)).toInt<unsigned>();
RLP r(frame.cropped(1));
if (!readPacket(hProtocolId, packetType, r))
bool ok = readPacket(hProtocolId, packetType, r);
(void)ok;
#if ETH_DEBUG
if (!ok)
clog(NetWarn) << "Couldn't interpret packet." << RLP(r);
#endif
}
doRead();
});

4
libweb3jsonrpc/WebThreeStubServerBase.cpp

@ -780,9 +780,9 @@ bool WebThreeStubServerBase::eth_submitWork(string const& _nonce, string const&,
}
}
bool WebThreeStubServerBase::eth_submitHashrate(int _hashes, string const& _id)
bool WebThreeStubServerBase::eth_submitHashrate(string const& _hashes, string const& _id)
{
client()->submitExternalHashrate(_hashes, jsToFixed<32>(_id));
client()->submitExternalHashrate(jsToInt<32>(_hashes), jsToFixed<32>(_id));
return true;
}

2
libweb3jsonrpc/WebThreeStubServerBase.h

@ -139,7 +139,7 @@ public:
virtual Json::Value eth_getLogsEx(Json::Value const& _json);
virtual Json::Value eth_getWork();
virtual bool eth_submitWork(std::string const& _nonce, std::string const&, std::string const& _mixHash);
virtual bool eth_submitHashrate(int _hashes, std::string const& _id);
virtual bool eth_submitHashrate(std::string const& _hashes, std::string const& _id);
virtual std::string eth_register(std::string const& _address);
virtual bool eth_unregister(std::string const& _accountId);
virtual Json::Value eth_fetchQueuedTransactions(std::string const& _accountId);

6
libweb3jsonrpc/abstractwebthreestubserver.h

@ -60,7 +60,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
this->bindAndAddMethod(jsonrpc::Procedure("eth_getLogsEx", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_getLogsExI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getWork", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, NULL), &AbstractWebThreeStubServer::eth_getWorkI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_submitWork", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING,"param3",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_submitWorkI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_submitHashrate", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_INTEGER,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_submitHashrateI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_submitHashrate", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_submitHashrateI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_register", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_registerI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_unregister", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_unregisterI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_fetchQueuedTransactions", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_fetchQueuedTransactionsI);
@ -315,7 +315,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
}
inline virtual void eth_submitHashrateI(const Json::Value &request, Json::Value &response)
{
response = this->eth_submitHashrate(request[0u].asInt(), request[1u].asString());
response = this->eth_submitHashrate(request[0u].asString(), request[1u].asString());
}
inline virtual void eth_registerI(const Json::Value &request, Json::Value &response)
{
@ -534,7 +534,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
virtual Json::Value eth_getLogsEx(const Json::Value& param1) = 0;
virtual Json::Value eth_getWork() = 0;
virtual bool eth_submitWork(const std::string& param1, const std::string& param2, const std::string& param3) = 0;
virtual bool eth_submitHashrate(int param1, const std::string& param2) = 0;
virtual bool eth_submitHashrate(const std::string& param1, const std::string& param2) = 0;
virtual std::string eth_register(const std::string& param1) = 0;
virtual bool eth_unregister(const std::string& param1) = 0;
virtual Json::Value eth_fetchQueuedTransactions(const std::string& param1) = 0;

2
libweb3jsonrpc/spec.json

@ -49,7 +49,7 @@
{ "name": "eth_getLogsEx", "params": [{}], "order": [], "returns": []},
{ "name": "eth_getWork", "params": [], "order": [], "returns": []},
{ "name": "eth_submitWork", "params": ["", "", ""], "order": [], "returns": true},
{ "name": "eth_submitHashrate", "params": [0, ""], "order": [], "returns": true},
{ "name": "eth_submitHashrate", "params": ["", ""], "order": [], "returns": true},
{ "name": "eth_register", "params": [""], "order": [], "returns": ""},
{ "name": "eth_unregister", "params": [""], "order": [], "returns": true},
{ "name": "eth_fetchQueuedTransactions", "params": [""], "order": [], "returns": []},

2
mix/MixClient.cpp

@ -370,7 +370,7 @@ bool MixClient::isMining() const
return false;
}
uint64_t MixClient::hashrate() const
u256 MixClient::hashrate() const
{
return 0;
}

2
mix/MixClient.h

@ -95,7 +95,7 @@ public:
void startMining() override;
void stopMining() override;
bool isMining() const override;
uint64_t hashrate() const override;
u256 hashrate() const override;
eth::WorkingProgress miningProgress() const override;
virtual void flushTransactions() override {}

39
templates/plugindialog.cpp

@ -0,0 +1,39 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file $NAME.cpp
* @author Gav Wood <i@gavwood.com>
* @date 2015
*/
#include "$NAME.h"
#include <libdevcore/Log.h>
#include <libethereum/Client.h>
using namespace std;
using namespace dev;
using namespace az;
using namespace eth;
DEV_AZ_NOTE_PLUGIN($NAME);
$NAME::$NAME(MainFace* _m):
Plugin(_m, "$NAME")
{
}
$NAME::~$NAME()
{
}

46
templates/plugindialog.h

@ -0,0 +1,46 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file $NAME.h
* @author Gav Wood <i@gavwood.com>
* @date 2015
*/
#pragma once
#include "MainFace.h"
namespace dev
{
namespace az
{
class $NAME: public QObject, public Plugin
{
Q_OBJECT
public:
$NAME(MainFace* _m);
~$NAME();
private:
void onAllChange() override {}
void readSettings(QSettings const&) override {}
void writeSettings(QSettings&) override {}
};
}
}

88
templates/plugindialog.ui

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>$NAME</class>
<widget class="QDialog" name="$NAME">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>511</width>
<height>508</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="cancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="create">
<property name="text">
<string>OK</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>create</sender>
<signal>clicked()</signal>
<receiver>$NAME</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>462</x>
<y>484</y>
</hint>
<hint type="destinationlabel">
<x>449</x>
<y>504</y>
</hint>
</hints>
</connection>
<connection>
<sender>cancel</sender>
<signal>clicked()</signal>
<receiver>$NAME</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>381</x>
<y>483</y>
</hint>
<hint type="destinationlabel">
<x>351</x>
<y>506</y>
</hint>
</hints>
</connection>
</connections>
</ui>

25
test/libdevcrypto/SecretStore.cpp

@ -131,6 +131,31 @@ BOOST_AUTO_TEST_CASE(import_secret)
}
}
BOOST_AUTO_TEST_CASE(import_secret_bytesConstRef)
{
for (string const& password: {"foobar", ""})
{
TransientDirectory storeDir;
string priv = "0202020202020202020202020202020202020202020202020202020202020202";
h128 uuid;
{
SecretStore store(storeDir.path());
BOOST_CHECK_EQUAL(store.keys().size(), 0);
bytes privateBytes = fromHex(priv);
uuid = store.importSecret(&privateBytes, password);
BOOST_CHECK(!!uuid);
BOOST_CHECK_EQUAL(priv, toHex(store.secret(uuid, [&](){ return password; }).makeInsecure()));
BOOST_CHECK_EQUAL(store.keys().size(), 1);
}
{
SecretStore store(storeDir.path());
BOOST_CHECK_EQUAL(store.keys().size(), 1);
BOOST_CHECK_EQUAL(priv, toHex(store.secret(uuid, [&](){ return password; }).makeInsecure()));
}
}
}
BOOST_AUTO_TEST_CASE(wrong_password)
{
TransientDirectory storeDir;

39
test/libethereum/StateTestsFiller/stSpecialTestFiller.json

@ -531,5 +531,44 @@
"to" : "1baf27b88c48dd02b744999cf3522766929d2b2a",
"value" : "0"
}
},
"StackDepthLimitSEC" : {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"expect" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000"
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "771500"
},
"aaaaaaaaace5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000000000000000000"
}
},
"pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "100000000",
"nonce" : "0",
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "1000000",
"to" : "",
"value" : "10",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : "305032503350600460006000396000515060046000600037600051506f600060006000600060003060405a03f160005260106010f3"
}
}
}

2
test/libweb3jsonrpc/webthreestubclient.h

@ -506,7 +506,7 @@ class WebThreeStubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
bool eth_submitHashrate(int param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
bool eth_submitHashrate(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);

2
third/MainWin.cpp

@ -119,7 +119,7 @@ Main::Main(QWidget *parent) :
bytesConstRef networkConfig((byte*)m_networkConfig.data(), m_networkConfig.size());
m_web3.reset(new WebThreeDirect("Third", getDataDir() + "/Third", false, {"eth", "shh"}, NetworkPreferences(), networkConfig));
m_web3->connect(Host::pocHost());
// m_web3->connect(Host::pocHost());
m_httpConnector.reset(new jsonrpc::HttpServer(8080));
m_server.reset(new WebThreeStubServer(*m_httpConnector, *web3(), keysAsVector(m_myKeys)));

Loading…
Cancel
Save