Browse Source

Merge branch 'develop' into neighbours

cl-refactor
subtly 10 years ago
parent
commit
454795cb69
  1. 13
      CMakeLists.txt
  2. 18
      alethzero/Main.ui
  3. 3
      alethzero/MainWin.cpp
  4. 4
      eth/main.cpp
  5. 3
      exp/CMakeLists.txt
  6. 24
      libethcore/ProofOfWork.cpp
  7. 34
      libethcore/ProofOfWork.h
  8. 18
      libethereum/Client.cpp
  9. 20
      libethereum/Client.h
  10. 3
      libethereum/ClientBase.h
  11. 4
      libethereum/Interface.h
  12. 4
      libethereum/Miner.cpp
  13. 13
      libethereum/Miner.h
  14. 27
      libethereum/State.cpp
  15. 22
      libethereum/State.h
  16. 17
      libweb3jsonrpc/WebThreeStubServerBase.cpp
  17. 1
      libweb3jsonrpc/WebThreeStubServerBase.h
  18. 7
      libweb3jsonrpc/abstractwebthreestubserver.h
  19. 5
      libweb3jsonrpc/spec.json
  20. 10
      mix/MixClient.cpp
  21. 3
      mix/MixClient.h
  22. 34
      mix/qml/Debugger.qml
  23. 122
      mix/qml/StepActionImage.qml
  24. 7
      test/blockchain.cpp
  25. 5
      test/stateOriginal.cpp
  26. 10
      test/webthreestubclient.h

13
CMakeLists.txt

@ -62,6 +62,8 @@ function(configureProject)
if (GUI) if (GUI)
add_definitions(-DETH_GUI) add_definitions(-DETH_GUI)
endif() endif()
add_definitions(-DETH_TRUE)
endfunction() endfunction()
set(CPPETHEREUM 1) set(CPPETHEREUM 1)
@ -134,7 +136,6 @@ if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
endif () endif ()
createDefaultCacheConfig() createDefaultCacheConfig()
configureProject()
# Force chromium. # Force chromium.
set (ETH_HAVE_WEBENGINE 1) set (ETH_HAVE_WEBENGINE 1)
@ -261,6 +262,8 @@ elseif (BUNDLE STREQUAL "user")
set(TESTS OFF) set(TESTS OFF)
endif () endif ()
configureProject()
# Default CMAKE_BUILD_TYPE to "Release". # Default CMAKE_BUILD_TYPE to "Release".
set(CMAKE_BUILD_TYPE CACHE STRING "Release") set(CMAKE_BUILD_TYPE CACHE STRING "Release")
if ("x${CMAKE_BUILD_TYPE}" STREQUAL "x") if ("x${CMAKE_BUILD_TYPE}" STREQUAL "x")
@ -270,7 +273,11 @@ endif ()
# Default TARGET_PLATFORM to "linux". # Default TARGET_PLATFORM to "linux".
set(TARGET_PLATFORM CACHE STRING "linux") set(TARGET_PLATFORM CACHE STRING "linux")
if ("x${TARGET_PLATFORM}" STREQUAL "x") if ("x${TARGET_PLATFORM}" STREQUAL "x")
set(TARGET_PLATFORM "linux") if (WIN32)
set(TARGET_PLATFORM "windows")
else ()
set(TARGET_PLATFORM "linux")
endif ()
endif () endif ()
message("------------------------------------------------------------------------") message("------------------------------------------------------------------------")
@ -306,7 +313,7 @@ include(EthCompilerSettings)
message("-- CXXFLAGS: ${CMAKE_CXX_FLAGS}") message("-- CXXFLAGS: ${CMAKE_CXX_FLAGS}")
# this must be an include, as a function it would messs up with variable scope! # this must be an include, as a function it would mess up with variable scope!
include(EthDependencies) include(EthDependencies)
include(EthExecutableHelper) include(EthExecutableHelper)

18
alethzero/Main.ui

@ -150,6 +150,7 @@
<string>&amp;Tools</string> <string>&amp;Tools</string>
</property> </property>
<addaction name="mine"/> <addaction name="mine"/>
<addaction name="turboMining"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="newTransaction"/> <addaction name="newTransaction"/>
<addaction name="newAccount"/> <addaction name="newAccount"/>
@ -176,7 +177,6 @@
<addaction name="killBlockchain"/> <addaction name="killBlockchain"/>
<addaction name="inject"/> <addaction name="inject"/>
<addaction name="forceMining"/> <addaction name="forceMining"/>
<addaction name="turboMining"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="usePrivate"/> <addaction name="usePrivate"/>
<addaction name="jitvm"/> <addaction name="jitvm"/>
@ -1608,14 +1608,6 @@ font-size: 14pt</string>
<string>&amp;Enable LLL Optimizer</string> <string>&amp;Enable LLL Optimizer</string>
</property> </property>
</action> </action>
<action name="turboMining">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Reserved Debug 1</string>
</property>
</action>
<action name="localNetworking"> <action name="localNetworking">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
@ -1679,6 +1671,14 @@ font-size: 14pt</string>
<string>&amp;NatSpec Enabled</string> <string>&amp;NatSpec Enabled</string>
</property> </property>
</action> </action>
<action name="turboMining">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;GPU Mining</string>
</property>
</action>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<customwidgets> <customwidgets>

3
alethzero/MainWin.cpp

@ -707,6 +707,7 @@ void Main::writeSettings()
s.setValue("upnp", ui->upnp->isChecked()); s.setValue("upnp", ui->upnp->isChecked());
s.setValue("forceAddress", ui->forcePublicIP->text()); s.setValue("forceAddress", ui->forcePublicIP->text());
s.setValue("forceMining", ui->forceMining->isChecked()); s.setValue("forceMining", ui->forceMining->isChecked());
s.setValue("turboMining", ui->turboMining->isChecked());
s.setValue("paranoia", ui->paranoia->isChecked()); s.setValue("paranoia", ui->paranoia->isChecked());
s.setValue("natSpec", ui->natSpec->isChecked()); s.setValue("natSpec", ui->natSpec->isChecked());
s.setValue("showAll", ui->showAll->isChecked()); s.setValue("showAll", ui->showAll->isChecked());
@ -777,6 +778,8 @@ void Main::readSettings(bool _skipGeometry)
ui->dropPeers->setChecked(false); ui->dropPeers->setChecked(false);
ui->forceMining->setChecked(s.value("forceMining", false).toBool()); ui->forceMining->setChecked(s.value("forceMining", false).toBool());
on_forceMining_triggered(); on_forceMining_triggered();
ui->turboMining->setChecked(s.value("turboMining", false).toBool());
on_turboMining_triggered();
ui->paranoia->setChecked(s.value("paranoia", false).toBool()); ui->paranoia->setChecked(s.value("paranoia", false).toBool());
ui->natSpec->setChecked(s.value("natSpec", true).toBool()); ui->natSpec->setChecked(s.value("natSpec", true).toBool());
ui->showAll->setChecked(s.value("showAll", false).toBool()); ui->showAll->setChecked(s.value("showAll", false).toBool());

4
eth/main.cpp

@ -273,7 +273,6 @@ int main(int argc, char** argv)
unsigned mining = ~(unsigned)0; unsigned mining = ~(unsigned)0;
int miners = -1; int miners = -1;
bool forceMining = false; bool forceMining = false;
bool turboMining = false;
KeyPair us = KeyPair::create(); KeyPair us = KeyPair::create();
Address coinbase = us.address(); Address coinbase = us.address();
@ -466,8 +465,6 @@ int main(int argc, char** argv)
bootstrap = true; bootstrap = true;
else if (arg == "-f" || arg == "--force-mining") else if (arg == "-f" || arg == "--force-mining")
forceMining = true; forceMining = true;
else if (arg == "-T" || arg == "--turbo-mining")
turboMining = true;
else if (arg == "-i" || arg == "--interactive") else if (arg == "-i" || arg == "--interactive")
interactive = true; interactive = true;
#if ETH_JSONRPC #if ETH_JSONRPC
@ -632,7 +629,6 @@ int main(int argc, char** argv)
{ {
c->setGasPricer(gasPricer); c->setGasPricer(gasPricer);
c->setForceMining(forceMining); c->setForceMining(forceMining);
c->setTurboMining(turboMining);
c->setAddress(coinbase); c->setAddress(coinbase);
} }

3
exp/CMakeLists.txt

@ -23,10 +23,11 @@ endif()
target_link_libraries(${EXECUTABLE} webthree) target_link_libraries(${EXECUTABLE} webthree)
target_link_libraries(${EXECUTABLE} ethereum) target_link_libraries(${EXECUTABLE} ethereum)
target_link_libraries(${EXECUTABLE} p2p) target_link_libraries(${EXECUTABLE} p2p)
if (ETHASHCL)
target_link_libraries(${EXECUTABLE} ethash-cl) target_link_libraries(${EXECUTABLE} ethash-cl)
target_link_libraries(${EXECUTABLE} ethash) target_link_libraries(${EXECUTABLE} ethash)
target_link_libraries(${EXECUTABLE} OpenCL) target_link_libraries(${EXECUTABLE} OpenCL)
endif()
install( TARGETS ${EXECUTABLE} DESTINATION bin) install( TARGETS ${EXECUTABLE} DESTINATION bin)

24
libethcore/ProofOfWork.cpp

@ -45,12 +45,12 @@ namespace dev
namespace eth namespace eth
{ {
bool EthashCPU::verify(BlockInfo const& _header) bool EthashPoW::verify(BlockInfo const& _header)
{ {
return Ethasher::verify(_header); return Ethasher::verify(_header);
} }
std::pair<MineInfo, EthashCPU::Proof> EthashCPU::mine(BlockInfo const& _header, unsigned _msTimeout, bool _continue, bool _turbo) std::pair<MineInfo, EthashCPU::Proof> EthashCPU::mine(BlockInfo const& _header, unsigned _msTimeout, bool _continue)
{ {
Ethasher::Miner m(_header); Ethasher::Miner m(_header);
@ -67,8 +67,6 @@ std::pair<MineInfo, EthashCPU::Proof> EthashCPU::mine(BlockInfo const& _header,
// //
// evaluate until we run out of time // evaluate until we run out of time
auto startTime = std::chrono::steady_clock::now(); auto startTime = std::chrono::steady_clock::now();
if (!_turbo)
std::this_thread::sleep_for(std::chrono::milliseconds(_msTimeout * 90 / 100));
double best = 1e99; // high enough to be effectively infinity :) double best = 1e99; // high enough to be effectively infinity :)
Proof result; Proof result;
unsigned hashCount = 0; unsigned hashCount = 0;
@ -102,7 +100,7 @@ std::pair<MineInfo, EthashCPU::Proof> EthashCPU::mine(BlockInfo const& _header,
return ret; return ret;
} }
#if ETH_ETHASHCL #if ETH_ETHASHCL || !ETH_TRUE
/* /*
class ethash_cl_miner class ethash_cl_miner
@ -186,12 +184,7 @@ EthashCL::~EthashCL()
{ {
} }
bool EthashCL::verify(BlockInfo const& _header) std::pair<MineInfo, Ethash::Proof> EthashCL::mine(BlockInfo const& _header, unsigned _msTimeout, bool)
{
return Ethasher::verify(_header);
}
std::pair<MineInfo, Ethash::Proof> EthashCL::mine(BlockInfo const& _header, unsigned _msTimeout, bool, bool)
{ {
if (!m_lastHeader || m_lastHeader.seedHash() != _header.seedHash()) if (!m_lastHeader || m_lastHeader.seedHash() != _header.seedHash())
{ {
@ -201,16 +194,15 @@ std::pair<MineInfo, Ethash::Proof> EthashCL::mine(BlockInfo const& _header, unsi
auto cb = [&](void* d) { auto cb = [&](void* d) {
Ethasher::get()->readFull(_header, d); Ethasher::get()->readFull(_header, d);
}; };
m_miner->init(Ethasher::params(_header), cb); m_miner->init(Ethasher::params(_header), cb, 32);
} }
if (m_lastHeader != _header) if (m_lastHeader != _header)
{ {
m_hook->abort(); m_hook->abort();
static std::random_device s_eng; static std::random_device s_eng;
uint64_t tryNonce = (uint64_t)(u64)(m_last = Nonce::random(s_eng));
auto hh = _header.headerHash(WithoutNonce); auto hh = _header.headerHash(WithoutNonce);
cdebug << "Mining with headerhash" << hh << "from nonce" << m_last << "with boundary" << _header.boundary(); uint64_t upper64OfBoundary = (uint64_t)(u64)((u256)_header.boundary() >> 192);
m_miner->search(hh.data(), tryNonce, *m_hook); m_miner->search(hh.data(), upper64OfBoundary, *m_hook);
} }
m_lastHeader = _header; m_lastHeader = _header;
@ -221,11 +213,9 @@ std::pair<MineInfo, Ethash::Proof> EthashCL::mine(BlockInfo const& _header, unsi
for (auto const& n: found) for (auto const& n: found)
{ {
auto result = Ethasher::eval(_header, n); auto result = Ethasher::eval(_header, n);
cdebug << "Got nonce " << n << "gives result" << result.value;
if (result.value < _header.boundary()) if (result.value < _header.boundary())
return std::make_pair(MineInfo(true), EthashCL::Proof{n, result.mixHash}); return std::make_pair(MineInfo(true), EthashCL::Proof{n, result.mixHash});
} }
assert(false);
} }
return std::make_pair(MineInfo(false), EthashCL::Proof()); return std::make_pair(MineInfo(false), EthashCL::Proof());
} }

34
libethcore/ProofOfWork.h

@ -51,7 +51,7 @@ struct MineInfo
bool completed = false; bool completed = false;
}; };
class EthashCPU class EthashPoW
{ {
public: public:
struct Proof struct Proof
@ -61,31 +61,32 @@ public:
}; };
static bool verify(BlockInfo const& _header); static bool verify(BlockInfo const& _header);
std::pair<MineInfo, Proof> mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false);
static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r.nonce; _header.mixHash = _r.mixHash; } static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r.nonce; _header.mixHash = _r.mixHash; }
virtual unsigned defaultTimeout() const { return 100; }
virtual std::pair<MineInfo, Proof> mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true) = 0;
};
class EthashCPU: public EthashPoW
{
public:
std::pair<MineInfo, Proof> mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true) override;
protected: protected:
Nonce m_last; Nonce m_last;
}; };
#if ETH_ETHASHCL #if ETH_ETHASHCL || !ETH_TRUE
class EthashCLHook; class EthashCLHook;
class EthashCL class EthashCL: public EthashPoW
{ {
public: public:
struct Proof
{
Nonce nonce;
h256 mixHash;
};
EthashCL(); EthashCL();
~EthashCL(); ~EthashCL();
static bool verify(BlockInfo const& _header); std::pair<MineInfo, Proof> mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true) override;
std::pair<MineInfo, Proof> mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); unsigned defaultTimeout() const override { return 500; }
static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r.nonce; _header.mixHash = _r.mixHash; }
protected: protected:
Nonce m_last; Nonce m_last;
@ -107,8 +108,9 @@ public:
using Proof = Nonce; using Proof = Nonce;
static bool verify(BlockInfo const& _header) { return (bigint)(u256)Evaluator::eval(_header.headerHash(WithoutNonce), _header.nonce) <= (bigint(1) << 256) / _header.difficulty; } static bool verify(BlockInfo const& _header) { return (bigint)(u256)Evaluator::eval(_header.headerHash(WithoutNonce), _header.nonce) <= (bigint(1) << 256) / _header.difficulty; }
inline std::pair<MineInfo, Proof> mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); inline std::pair<MineInfo, Proof> mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true);
static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r; } static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r; }
unsigned defaultTimeout() const { return 100; }
protected: protected:
Nonce m_last; Nonce m_last;
@ -125,7 +127,7 @@ using SHA3ProofOfWork = ProofOfWorkEngine<SHA3Evaluator>;
using ProofOfWork = Ethash; using ProofOfWork = Ethash;
template <class Evaluator> template <class Evaluator>
std::pair<MineInfo, typename ProofOfWorkEngine<Evaluator>::Proof> ProofOfWorkEngine<Evaluator>::mine(BlockInfo const& _header, unsigned _msTimeout, bool _continue, bool _turbo) std::pair<MineInfo, typename ProofOfWorkEngine<Evaluator>::Proof> ProofOfWorkEngine<Evaluator>::mine(BlockInfo const& _header, unsigned _msTimeout, bool _continue)
{ {
auto headerHashWithoutNonce = _header.headerHash(WithoutNonce); auto headerHashWithoutNonce = _header.headerHash(WithoutNonce);
auto difficulty = _header.difficulty; auto difficulty = _header.difficulty;
@ -142,8 +144,6 @@ std::pair<MineInfo, typename ProofOfWorkEngine<Evaluator>::Proof> ProofOfWorkEng
// //
// evaluate until we run out of time // evaluate until we run out of time
auto startTime = std::chrono::steady_clock::now(); auto startTime = std::chrono::steady_clock::now();
if (!_turbo)
std::this_thread::sleep_for(std::chrono::milliseconds(_msTimeout * 90 / 100));
double best = 1e99; // high enough to be effectively infinity :) double best = 1e99; // high enough to be effectively infinity :)
ProofOfWorkEngine<Evaluator>::Proof solution; ProofOfWorkEngine<Evaluator>::Proof solution;
unsigned h = 0; unsigned h = 0;

18
libethereum/Client.cpp

@ -264,7 +264,7 @@ static string filtersToString(T const& _fs)
{ {
stringstream ret; stringstream ret;
ret << "{"; ret << "{";
bool i = false; unsigned i = 0;
for (h256 const& f: _fs) for (h256 const& f: _fs)
ret << (i++ ? ", " : "") << (f == PendingChangedFilter ? "pending" : f == ChainChangedFilter ? "chain" : f.abridged()); ret << (i++ ? ", " : "") << (f == PendingChangedFilter ? "pending" : f == ChainChangedFilter ? "chain" : f.abridged());
ret << "}"; ret << "}";
@ -345,11 +345,10 @@ void Client::setForceMining(bool _enable)
void Client::setMiningThreads(unsigned _threads) void Client::setMiningThreads(unsigned _threads)
{ {
stopMining(); stopMining();
#if ETH_ETHASHCL
(void)_threads;
unsigned t = 1;
#else
auto t = _threads ? _threads : thread::hardware_concurrency(); auto t = _threads ? _threads : thread::hardware_concurrency();
#if ETH_ETHASHCL || !ETH_TRUE
if (m_turboMining)
t = 1;
#endif #endif
WriteGuard l(x_localMiners); WriteGuard l(x_localMiners);
m_localMiners.clear(); m_localMiners.clear();
@ -368,6 +367,15 @@ MineProgress Client::miningProgress() const
return ret; return ret;
} }
uint64_t Client::hashrate() const
{
uint64_t ret = 0;
ReadGuard l(x_localMiners);
for (LocalMiner const& m: m_localMiners)
ret += m.miningProgress().hashes / m.miningProgress().ms;
return ret / 1000;
}
std::list<MineInfo> Client::miningHistory() std::list<MineInfo> Client::miningHistory()
{ {
std::list<MineInfo> ret; std::list<MineInfo> ret;

20
libethereum/Client.h

@ -188,25 +188,27 @@ public:
bool forceMining() const { return m_forceMining; } bool forceMining() const { return m_forceMining; }
/// Enable/disable forcing of mining to happen, even without transactions. /// Enable/disable forcing of mining to happen, even without transactions.
void setForceMining(bool _enable); void setForceMining(bool _enable);
/// Are we mining as fast as we can? /// Are we allowed to GPU mine?
bool turboMining() const { return m_turboMining; } bool turboMining() const { return m_turboMining; }
/// Enable/disable fast mining. /// Enable/disable GPU mining.
void setTurboMining(bool _enable = true) { m_turboMining = _enable; } void setTurboMining(bool _enable = true) { bool was = isMining(); stopMining(); m_turboMining = _enable; setMiningThreads(0); if (was) startMining(); }
/// Stops mining and sets the number of mining threads (0 for automatic). /// Stops mining and sets the number of mining threads (0 for automatic).
virtual void setMiningThreads(unsigned _threads = 0); void setMiningThreads(unsigned _threads = 0) override;
/// Get the effective number of mining threads. /// Get the effective number of mining threads.
virtual unsigned miningThreads() const { ReadGuard l(x_localMiners); return m_localMiners.size(); } unsigned miningThreads() const override { ReadGuard l(x_localMiners); return m_localMiners.size(); }
/// Start mining. /// Start mining.
/// NOT thread-safe - call it & stopMining only from a single thread /// NOT thread-safe - call it & stopMining only from a single thread
virtual void startMining() { startWorking(); { ReadGuard l(x_localMiners); for (auto& m: m_localMiners) m.start(); } } void startMining() override { startWorking(); { ReadGuard l(x_localMiners); for (auto& m: m_localMiners) m.start(); } }
/// Stop mining. /// Stop mining.
/// NOT thread-safe /// NOT thread-safe
virtual void stopMining() { { ReadGuard l(x_localMiners); for (auto& m: m_localMiners) m.stop(); } } void stopMining() override { { ReadGuard l(x_localMiners); for (auto& m: m_localMiners) m.stop(); } }
/// Are we mining now? /// Are we mining now?
virtual bool isMining() { { ReadGuard l(x_localMiners); if (!m_localMiners.empty() && m_localMiners[0].isRunning()) return true; } return false; } bool isMining() const override { { ReadGuard l(x_localMiners); if (!m_localMiners.empty() && m_localMiners[0].isRunning()) return true; } return false; }
/// Are we mining now?
uint64_t hashrate() const override;
/// Check the progress of the mining. /// Check the progress of the mining.
virtual MineProgress miningProgress() const; MineProgress miningProgress() const override;
/// Get and clear the mining history. /// Get and clear the mining history.
std::list<MineInfo> miningHistory(); std::list<MineInfo> miningHistory();

3
libethereum/ClientBase.h

@ -146,7 +146,8 @@ public:
virtual unsigned miningThreads() const override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("dev::eth::ClientBase::miningThreads")); } virtual unsigned miningThreads() const override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("dev::eth::ClientBase::miningThreads")); }
virtual void startMining() override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("dev::eth::ClientBase::startMining")); } virtual void startMining() override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("dev::eth::ClientBase::startMining")); }
virtual void stopMining() override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("dev::eth::ClientBase::stopMining")); } virtual void stopMining() override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("dev::eth::ClientBase::stopMining")); }
virtual bool isMining() override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("dev::eth::ClientBase::isMining")); } virtual bool isMining() const override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("dev::eth::ClientBase::isMining")); }
virtual uint64_t hashrate() const override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("dev::eth::ClientBase::hashrate")); }
virtual eth::MineProgress miningProgress() const override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("dev::eth::ClientBase::miningProgress")); } virtual eth::MineProgress miningProgress() const override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("dev::eth::ClientBase::miningProgress")); }
virtual std::pair<h256, u256> getWork() override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("dev::eth::ClientBase::getWork")); } virtual std::pair<h256, u256> getWork() override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("dev::eth::ClientBase::getWork")); }
virtual bool submitWork(eth::ProofOfWork::Proof const&) override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("dev::eth::ClientBase::submitWork")); } virtual bool submitWork(eth::ProofOfWork::Proof const&) override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("dev::eth::ClientBase::submitWork")); }

4
libethereum/Interface.h

@ -183,7 +183,9 @@ public:
/// NOT thread-safe /// NOT thread-safe
virtual void stopMining() = 0; virtual void stopMining() = 0;
/// Are we mining now? /// Are we mining now?
virtual bool isMining() = 0; virtual bool isMining() const = 0;
/// Current hash rate.
virtual uint64_t hashrate() const = 0;
/// Get hash of the current block to be mined minus the nonce (the 'work hash'). /// Get hash of the current block to be mined minus the nonce (the 'work hash').
virtual std::pair<h256, u256> getWork() = 0; virtual std::pair<h256, u256> getWork() = 0;

4
libethereum/Miner.cpp

@ -34,12 +34,14 @@ LocalMiner::LocalMiner(MinerHost* _host, unsigned _id):
AsyncMiner(_host, _id), AsyncMiner(_host, _id),
Worker("miner-" + toString(_id)) Worker("miner-" + toString(_id))
{ {
m_pow.reset(_host->turbo() ? new Ethash : (Ethash*)new EthashCPU);
} }
void LocalMiner::setup(MinerHost* _host, unsigned _id) void LocalMiner::setup(MinerHost* _host, unsigned _id)
{ {
AsyncMiner::setup(_host, _id); AsyncMiner::setup(_host, _id);
setName("miner-" + toString(m_id)); setName("miner-" + toString(m_id));
m_pow.reset(_host->turbo() ? new Ethash : (Ethash*)new EthashCPU);
} }
void LocalMiner::doWork() void LocalMiner::doWork()
@ -66,7 +68,7 @@ void LocalMiner::doWork()
if (m_miningStatus == Mining) if (m_miningStatus == Mining)
{ {
// Mine for a while. // Mine for a while.
MineInfo mineInfo = m_mineState.mine(100, m_host->turbo()); MineInfo mineInfo = m_mineState.mine(m_pow.get());
{ {
Guard l(x_mineInfo); Guard l(x_mineInfo);

13
libethereum/Miner.h

@ -60,8 +60,8 @@ public:
virtual void setupState(State& _s) = 0; ///< Reset the given State object to the one that should be being mined. virtual void setupState(State& _s) = 0; ///< Reset the given State object to the one that should be being mined.
virtual void onProgressed() {} ///< Called once some progress has been made. virtual void onProgressed() {} ///< Called once some progress has been made.
virtual void onComplete() {} ///< Called once a block is found. virtual void onComplete() {} ///< Called once a block is found.
virtual bool turbo() const = 0; ///< @returns true iff the Miner should mine as fast as possible.
virtual bool force() const = 0; ///< @returns true iff the Miner should mine regardless of the number of transactions. virtual bool force() const = 0; ///< @returns true iff the Miner should mine regardless of the number of transactions.
virtual bool turbo() const = 0; ///< @returns true iff the Miner should use GPU if possible.
}; };
class Miner class Miner
@ -93,7 +93,7 @@ public:
virtual void stop() {} virtual void stop() {}
/// @returns true iff the mining has been start()ed. It may still not be actually mining, depending on the host's turbo() & force(). /// @returns true iff the mining has been start()ed. It may still not be actually mining, depending on the host's turbo() & force().
virtual bool isRunning() { return false; } virtual bool isRunning() const { return false; }
protected: protected:
MinerHost* m_host = nullptr; ///< Our host. MinerHost* m_host = nullptr; ///< Our host.
@ -122,10 +122,10 @@ public:
LocalMiner(MinerHost* _host, unsigned _id = 0); LocalMiner(MinerHost* _host, unsigned _id = 0);
/// Move-constructor. /// Move-constructor.
LocalMiner(LocalMiner&& _m): Worker((Worker&&)_m) { std::swap(m_host, _m.m_host); } LocalMiner(LocalMiner&& _m): Worker((Worker&&)_m) { std::swap(m_host, _m.m_host); std::swap(m_pow, _m.m_pow); }
/// Move-assignment. /// Move-assignment.
LocalMiner& operator=(LocalMiner&& _m) { Worker::operator=((Worker&&)_m); std::swap(m_host, _m.m_host); return *this; } LocalMiner& operator=(LocalMiner&& _m) { Worker::operator=((Worker&&)_m); std::swap(m_host, _m.m_host); std::swap(m_pow, _m.m_pow); return *this; }
/// Destructor. Stops miner. /// Destructor. Stops miner.
~LocalMiner() { stop(); } ~LocalMiner() { stop(); }
@ -143,7 +143,7 @@ public:
virtual void noteStateChange() override { m_miningStatus = Preparing; } virtual void noteStateChange() override { m_miningStatus = Preparing; }
/// @returns true iff the mining has been start()ed. It may still not be actually mining, depending on the host's turbo() & force(). /// @returns true iff the mining has been start()ed. It may still not be actually mining, depending on the host's turbo() & force().
bool isRunning() { return isWorking(); } bool isRunning() const override { return isWorking(); }
/// @returns true if mining is complete. /// @returns true if mining is complete.
virtual bool isComplete() const override { return m_miningStatus == Mined; } virtual bool isComplete() const override { return m_miningStatus == Mined; }
@ -167,8 +167,9 @@ private:
enum MiningStatus { Waiting, Preparing, Mining, Mined, Stopping, Stopped }; enum MiningStatus { Waiting, Preparing, Mining, Mined, Stopping, Stopped };
MiningStatus m_miningStatus = Waiting; ///< TODO: consider mutex/atomic variable. MiningStatus m_miningStatus = Waiting; ///< TODO: consider mutex/atomic variable.
State m_mineState; ///< The state on which we are mining, generally equivalent to m_postMine. State m_mineState; ///< The state on which we are mining, generally equivalent to m_postMine.
std::unique_ptr<EthashPoW> m_pow; ///< Our miner.
mutable std::mutex x_mineInfo; ///< Lock for the mining progress & history. mutable Mutex x_mineInfo; ///< Lock for the mining progress & history.
MineProgress m_mineProgress; ///< What's our progress? MineProgress m_mineProgress; ///< What's our progress?
std::list<MineInfo> m_mineHistory; ///< What the history of our mining? std::list<MineInfo> m_mineHistory; ///< What the history of our mining?
}; };

27
libethereum/State.cpp

@ -451,7 +451,7 @@ bool State::cull(TransactionQueue& _tq) const
{ {
try try
{ {
if (i.second.nonce() <= transactionsFrom(i.second.sender())) if (i.second.nonce() < transactionsFrom(i.second.sender()))
{ {
_tq.drop(i.first); _tq.drop(i.first);
ret = true; ret = true;
@ -856,33 +856,12 @@ void State::commitToMine(BlockChain const& _bc)
m_committedToMine = true; m_committedToMine = true;
} }
MineInfo State::mine(unsigned _msTimeout, bool _turbo)
{
// Update difficulty according to timestamp.
m_currentBlock.difficulty = m_currentBlock.calculateDifficulty(m_previousBlock);
MineInfo ret;
// TODO: Miner class that keeps dagger between mine calls (or just non-polling mining).
ProofOfWork::Proof r;
tie(ret, r) = m_pow.mine(m_currentBlock, _msTimeout, true, _turbo);
if (!ret.completed)
m_currentBytes.clear();
else
{
ProofOfWork::assignResult(r, m_currentBlock);
cnote << "Completed" << m_currentBlock.headerHash(WithoutNonce).abridged() << m_currentBlock.nonce.abridged() << m_currentBlock.difficulty << ProofOfWork::verify(m_currentBlock);
}
return ret;
}
bool State::completeMine(ProofOfWork::Proof const& _nonce) bool State::completeMine(ProofOfWork::Proof const& _nonce)
{ {
ProofOfWork::assignResult(_nonce, m_currentBlock); ProofOfWork::assignResult(_nonce, m_currentBlock);
if (!m_pow.verify(m_currentBlock)) // if (!m_pow.verify(m_currentBlock))
return false; // return false;
cnote << "Completed" << m_currentBlock.headerHash(WithoutNonce).abridged() << m_currentBlock.nonce.abridged() << m_currentBlock.difficulty << ProofOfWork::verify(m_currentBlock); cnote << "Completed" << m_currentBlock.headerHash(WithoutNonce).abridged() << m_currentBlock.nonce.abridged() << m_currentBlock.difficulty << ProofOfWork::verify(m_currentBlock);

22
libethereum/State.h

@ -168,7 +168,25 @@ public:
/// This function is thread-safe. You can safely have other interactions with this object while it is happening. /// This function is thread-safe. You can safely have other interactions with this object while it is happening.
/// @param _msTimeout Timeout before return in milliseconds. /// @param _msTimeout Timeout before return in milliseconds.
/// @returns Information on the mining. /// @returns Information on the mining.
MineInfo mine(unsigned _msTimeout = 1000, bool _turbo = false); template <class ProofOfWork> MineInfo mine(ProofOfWork* _pow)
{
// Update difficulty according to timestamp.
m_currentBlock.difficulty = m_currentBlock.calculateDifficulty(m_previousBlock);
MineInfo ret;
typename ProofOfWork::Proof r;
std::tie(ret, r) = _pow->mine(m_currentBlock, _pow->defaultTimeout(), true);
if (!ret.completed)
m_currentBytes.clear();
else
{
ProofOfWork::assignResult(r, m_currentBlock);
cnote << "Completed" << m_currentBlock.headerHash(WithoutNonce).abridged() << m_currentBlock.nonce.abridged() << m_currentBlock.difficulty << ProofOfWork::verify(m_currentBlock);
}
return ret;
}
/** Commit to DB and build the final block if the previous call to mine()'s result is completion. /** Commit to DB and build the final block if the previous call to mine()'s result is completion.
* Typically looks like: * Typically looks like:
@ -371,8 +389,6 @@ private:
Address m_ourAddress; ///< Our address (i.e. the address to which fees go). Address m_ourAddress; ///< Our address (i.e. the address to which fees go).
ProofOfWork m_pow; ///< The PoW mining class.
u256 m_blockReward; u256 m_blockReward;
static std::string c_defaultPath; static std::string c_defaultPath;

17
libweb3jsonrpc/WebThreeStubServerBase.cpp

@ -26,7 +26,7 @@
#include <jsonrpccpp/common/exception.h> #include <jsonrpccpp/common/exception.h>
#include <libdevcore/CommonData.h> #include <libdevcore/CommonData.h>
#if ETH_SOLIDITY #if ETH_SOLIDITY || !ETH_TRUE
#include <libsolidity/CompilerStack.h> #include <libsolidity/CompilerStack.h>
#include <libsolidity/Scanner.h> #include <libsolidity/Scanner.h>
#include <libsolidity/SourceReferenceFormatter.h> #include <libsolidity/SourceReferenceFormatter.h>
@ -38,7 +38,7 @@
#include <libethcore/CommonJS.h> #include <libethcore/CommonJS.h>
#include <libwhisper/Message.h> #include <libwhisper/Message.h>
#include <libwhisper/WhisperHost.h> #include <libwhisper/WhisperHost.h>
#if ETH_SERPENT #if ETH_SERPENT || !ETH_TRUE
#include <libserpent/funcs.h> #include <libserpent/funcs.h>
#endif #endif
#include "WebThreeStubServerBase.h" #include "WebThreeStubServerBase.h"
@ -296,6 +296,11 @@ string WebThreeStubServerBase::eth_coinbase()
return toJS(client()->address()); return toJS(client()->address());
} }
string WebThreeStubServerBase::eth_hashrate()
{
return toJS(client()->hashrate());
}
bool WebThreeStubServerBase::eth_mining() bool WebThreeStubServerBase::eth_mining()
{ {
return client()->isMining(); return client()->isMining();
@ -602,10 +607,10 @@ Json::Value WebThreeStubServerBase::eth_getCompilers()
{ {
Json::Value ret(Json::arrayValue); Json::Value ret(Json::arrayValue);
ret.append("lll"); ret.append("lll");
#if SOLIDITY #if ETH_SOLIDITY || !TRUE
ret.append("solidity"); ret.append("solidity");
#endif #endif
#if SERPENT #if ETH_SERPENT || !TRUE
ret.append("serpent"); ret.append("serpent");
#endif #endif
return ret; return ret;
@ -627,7 +632,7 @@ string WebThreeStubServerBase::eth_compileSerpent(string const& _code)
// TODO throw here jsonrpc errors // TODO throw here jsonrpc errors
string res; string res;
(void)_code; (void)_code;
#if SERPENT #if ETH_SERPENT || !ETH_TRUE
try try
{ {
res = toJS(dev::asBytes(::compile(_code))); res = toJS(dev::asBytes(::compile(_code)));
@ -649,7 +654,7 @@ string WebThreeStubServerBase::eth_compileSolidity(string const& _code)
// TOOD throw here jsonrpc errors // TOOD throw here jsonrpc errors
(void)_code; (void)_code;
string res; string res;
#if SOLIDITY #if ETH_SOLIDITY || !ETH_TRUE
dev::solidity::CompilerStack compiler; dev::solidity::CompilerStack compiler;
try try
{ {

1
libweb3jsonrpc/WebThreeStubServerBase.h

@ -78,6 +78,7 @@ public:
virtual bool net_listening(); virtual bool net_listening();
virtual std::string eth_protocolVersion(); virtual std::string eth_protocolVersion();
virtual std::string eth_hashrate();
virtual std::string eth_coinbase(); virtual std::string eth_coinbase();
virtual bool eth_mining(); virtual bool eth_mining();
virtual std::string eth_gasPrice(); virtual std::string eth_gasPrice();

7
libweb3jsonrpc/abstractwebthreestubserver.h

@ -18,6 +18,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
this->bindAndAddMethod(jsonrpc::Procedure("net_peerCount", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::net_peerCountI); this->bindAndAddMethod(jsonrpc::Procedure("net_peerCount", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::net_peerCountI);
this->bindAndAddMethod(jsonrpc::Procedure("net_listening", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::net_listeningI); this->bindAndAddMethod(jsonrpc::Procedure("net_listening", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::net_listeningI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_protocolVersion", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_protocolVersionI); this->bindAndAddMethod(jsonrpc::Procedure("eth_protocolVersion", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_protocolVersionI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_hashrate", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_hashrateI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_coinbase", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_coinbaseI); this->bindAndAddMethod(jsonrpc::Procedure("eth_coinbase", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_coinbaseI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_mining", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_miningI); this->bindAndAddMethod(jsonrpc::Procedure("eth_mining", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_miningI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_gasPrice", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_gasPriceI); this->bindAndAddMethod(jsonrpc::Procedure("eth_gasPrice", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_gasPriceI);
@ -98,6 +99,11 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
(void)request; (void)request;
response = this->eth_protocolVersion(); response = this->eth_protocolVersion();
} }
inline virtual void eth_hashrateI(const Json::Value &request, Json::Value &response)
{
(void)request;
response = this->eth_hashrate();
}
inline virtual void eth_coinbaseI(const Json::Value &request, Json::Value &response) inline virtual void eth_coinbaseI(const Json::Value &request, Json::Value &response)
{ {
(void)request; (void)request;
@ -309,6 +315,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
virtual std::string net_peerCount() = 0; virtual std::string net_peerCount() = 0;
virtual bool net_listening() = 0; virtual bool net_listening() = 0;
virtual std::string eth_protocolVersion() = 0; virtual std::string eth_protocolVersion() = 0;
virtual std::string eth_hashrate() = 0;
virtual std::string eth_coinbase() = 0; virtual std::string eth_coinbase() = 0;
virtual bool eth_mining() = 0; virtual bool eth_mining() = 0;
virtual std::string eth_gasPrice() = 0; virtual std::string eth_gasPrice() = 0;

5
libweb3jsonrpc/spec.json

@ -6,8 +6,9 @@
{ "name": "net_peerCount", "params": [], "order": [], "returns" : "" }, { "name": "net_peerCount", "params": [], "order": [], "returns" : "" },
{ "name": "net_listening", "params": [], "order": [], "returns" : false }, { "name": "net_listening", "params": [], "order": [], "returns" : false },
{ "name": "eth_protocolVersion", "params": [], "order": [], "returns" : "" }, { "name": "eth_protocolVersion", "params": [], "order": [], "returns" : "" },
{ "name": "eth_coinbase", "params": [], "order": [], "returns" : "" }, { "name": "eth_hashrate", "params": [], "order": [], "returns" : "" },
{ "name": "eth_coinbase", "params": [], "order": [], "returns" : "" },
{ "name": "eth_mining", "params": [], "order": [], "returns" : false }, { "name": "eth_mining", "params": [], "order": [], "returns" : false },
{ "name": "eth_gasPrice", "params": [], "order": [], "returns" : "" }, { "name": "eth_gasPrice", "params": [], "order": [], "returns" : "" },
{ "name": "eth_accounts", "params": [], "order": [], "returns" : [] }, { "name": "eth_accounts", "params": [], "order": [], "returns" : [] },

10
mix/MixClient.cpp

@ -250,7 +250,8 @@ void MixClient::mine()
{ {
WriteGuard l(x_state); WriteGuard l(x_state);
m_state.commitToMine(bc()); m_state.commitToMine(bc());
while (!m_state.mine(100, true).completed) {} ProofOfWork pow;
while (!m_state.mine(&pow).completed) {}
m_state.completeMine(); m_state.completeMine();
bc().import(m_state.blockData(), m_stateDB); bc().import(m_state.blockData(), m_stateDB);
m_state.sync(bc()); m_state.sync(bc());
@ -391,11 +392,16 @@ void MixClient::stopMining()
//no-op //no-op
} }
bool MixClient::isMining() bool MixClient::isMining() const
{ {
return false; return false;
} }
uint64_t MixClient::hashrate() const
{
return 0;
}
eth::MineProgress MixClient::miningProgress() const eth::MineProgress MixClient::miningProgress() const
{ {
return eth::MineProgress(); return eth::MineProgress();

3
mix/MixClient.h

@ -67,7 +67,8 @@ public:
unsigned miningThreads() const override; unsigned miningThreads() const override;
void startMining() override; void startMining() override;
void stopMining() override; void stopMining() override;
bool isMining() override; bool isMining() const override;
uint64_t hashrate() const override;
eth::MineProgress miningProgress() const override; eth::MineProgress miningProgress() const override;
std::pair<h256, u256> getWork() override { return std::pair<h256, u256>(); } std::pair<h256, u256> getWork() override { return std::pair<h256, u256>(); }
bool submitWork(eth::ProofOfWork::Proof const&) override { return false; } bool submitWork(eth::ProofOfWork::Proof const&) override { return false; }

34
mix/qml/Debugger.qml

@ -4,6 +4,7 @@ import QtQuick.Controls.Styles 1.1
import QtQuick.Dialogs 1.1 import QtQuick.Dialogs 1.1
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import Qt.labs.settings 1.0 import Qt.labs.settings 1.0
import QtGraphicalEffects 1.0
import "js/Debugger.js" as Debugger import "js/Debugger.js" as Debugger
import "js/ErrorLocationFormater.js" as ErrorLocationFormater import "js/ErrorLocationFormater.js" as ErrorLocationFormater
import "." import "."
@ -231,9 +232,9 @@ Rectangle {
id: playAction id: playAction
enabledStateImg: "qrc:/qml/img/play_button.png" enabledStateImg: "qrc:/qml/img/play_button.png"
disableStateImg: "qrc:/qml/img/play_button.png" disableStateImg: "qrc:/qml/img/play_button.png"
buttonLeft: true
onClicked: projectModel.stateListModel.runState(transactionLog.selectedStateIndex) onClicked: projectModel.stateListModel.runState(transactionLog.selectedStateIndex)
width: 30 width: 23
height: 30
buttonShortcut: "Ctrl+Shift+F8" buttonShortcut: "Ctrl+Shift+F8"
buttonTooltip: qsTr("Start Debugging") buttonTooltip: qsTr("Start Debugging")
visible: true visible: true
@ -246,8 +247,7 @@ Rectangle {
enabledStateImg: "qrc:/qml/img/stop_button2x.png" enabledStateImg: "qrc:/qml/img/stop_button2x.png"
disableStateImg: "qrc:/qml/img/stop_button2x.png" disableStateImg: "qrc:/qml/img/stop_button2x.png"
onClicked: Debugger.init(null); onClicked: Debugger.init(null);
width: 30 width: 23
height: 30
buttonShortcut: "Ctrl+Shift+F9" buttonShortcut: "Ctrl+Shift+F9"
buttonTooltip: qsTr("Stop Debugging") buttonTooltip: qsTr("Stop Debugging")
visible: true visible: true
@ -259,8 +259,7 @@ Rectangle {
enabledStateImg: "qrc:/qml/img/jumpoutback.png" enabledStateImg: "qrc:/qml/img/jumpoutback.png"
disableStateImg: "qrc:/qml/img/jumpoutbackdisabled.png" disableStateImg: "qrc:/qml/img/jumpoutbackdisabled.png"
onClicked: Debugger.runBack() onClicked: Debugger.runBack()
width: 30 width: 23
height: 30
buttonShortcut: "Ctrl+Shift+F5" buttonShortcut: "Ctrl+Shift+F5"
buttonTooltip: qsTr("Run Back") buttonTooltip: qsTr("Run Back")
visible: false visible: false
@ -272,8 +271,7 @@ Rectangle {
enabledStateImg: "qrc:/qml/img/jumpoutback.png" enabledStateImg: "qrc:/qml/img/jumpoutback.png"
disableStateImg: "qrc:/qml/img/jumpoutbackdisabled.png" disableStateImg: "qrc:/qml/img/jumpoutbackdisabled.png"
onClicked: Debugger.stepOutBack() onClicked: Debugger.stepOutBack()
width: 30 width: 23
height: 30
buttonShortcut: "Ctrl+Shift+F11" buttonShortcut: "Ctrl+Shift+F11"
buttonTooltip: qsTr("Step Out Back") buttonTooltip: qsTr("Step Out Back")
} }
@ -284,8 +282,7 @@ Rectangle {
enabledStateImg: "qrc:/qml/img/jumpintoback.png" enabledStateImg: "qrc:/qml/img/jumpintoback.png"
disableStateImg: "qrc:/qml/img/jumpintobackdisabled.png" disableStateImg: "qrc:/qml/img/jumpintobackdisabled.png"
onClicked: Debugger.stepIntoBack() onClicked: Debugger.stepIntoBack()
width: 30 width: 23
height: 30
buttonShortcut: "Ctrl+F11" buttonShortcut: "Ctrl+F11"
buttonTooltip: qsTr("Step Into Back") buttonTooltip: qsTr("Step Into Back")
} }
@ -296,8 +293,7 @@ Rectangle {
enabledStateImg: "qrc:/qml/img/jumpoverback.png" enabledStateImg: "qrc:/qml/img/jumpoverback.png"
disableStateImg: "qrc:/qml/img/jumpoverbackdisabled.png" disableStateImg: "qrc:/qml/img/jumpoverbackdisabled.png"
onClicked: Debugger.stepOverBack() onClicked: Debugger.stepOverBack()
width: 30 width: 23
height: 30
buttonShortcut: "Ctrl+F10" buttonShortcut: "Ctrl+F10"
buttonTooltip: qsTr("Step Over Back") buttonTooltip: qsTr("Step Over Back")
} }
@ -308,8 +304,7 @@ Rectangle {
enabledStateImg: "qrc:/qml/img/jumpoverforward.png" enabledStateImg: "qrc:/qml/img/jumpoverforward.png"
disableStateImg: "qrc:/qml/img/jumpoverforwarddisabled.png" disableStateImg: "qrc:/qml/img/jumpoverforwarddisabled.png"
onClicked: Debugger.stepOverForward() onClicked: Debugger.stepOverForward()
width: 30 width: 23
height: 30
buttonShortcut: "F10" buttonShortcut: "F10"
buttonTooltip: qsTr("Step Over Forward") buttonTooltip: qsTr("Step Over Forward")
} }
@ -320,8 +315,7 @@ Rectangle {
enabledStateImg: "qrc:/qml/img/jumpintoforward.png" enabledStateImg: "qrc:/qml/img/jumpintoforward.png"
disableStateImg: "qrc:/qml/img/jumpintoforwarddisabled.png" disableStateImg: "qrc:/qml/img/jumpintoforwarddisabled.png"
onClicked: Debugger.stepIntoForward() onClicked: Debugger.stepIntoForward()
width: 30 width: 23
height: 30
buttonShortcut: "F11" buttonShortcut: "F11"
buttonTooltip: qsTr("Step Into Forward") buttonTooltip: qsTr("Step Into Forward")
} }
@ -332,10 +326,10 @@ Rectangle {
enabledStateImg: "qrc:/qml/img/jumpoutforward.png" enabledStateImg: "qrc:/qml/img/jumpoutforward.png"
disableStateImg: "qrc:/qml/img/jumpoutforwarddisabled.png" disableStateImg: "qrc:/qml/img/jumpoutforwarddisabled.png"
onClicked: Debugger.stepOutForward() onClicked: Debugger.stepOutForward()
width: 30 width: 45
height: 30
buttonShortcut: "Shift+F11" buttonShortcut: "Shift+F11"
buttonTooltip: qsTr("Step Out Forward") buttonTooltip: qsTr("Step Out Forward")
buttonRight: true
} }
StepActionImage StepActionImage
@ -344,11 +338,11 @@ Rectangle {
enabledStateImg: "qrc:/qml/img/jumpoutforward.png" enabledStateImg: "qrc:/qml/img/jumpoutforward.png"
disableStateImg: "qrc:/qml/img/jumpoutforwarddisabled.png" disableStateImg: "qrc:/qml/img/jumpoutforwarddisabled.png"
onClicked: Debugger.runForward() onClicked: Debugger.runForward()
width: 30 width: 45
height: 30
buttonShortcut: "Ctrl+F5" buttonShortcut: "Ctrl+F5"
buttonTooltip: qsTr("Run Forward") buttonTooltip: qsTr("Run Forward")
visible: false visible: false
buttonRight: true
} }
Rectangle { Rectangle {

122
mix/qml/StepActionImage.qml

@ -4,15 +4,22 @@ import QtQuick.Layouts 1.0
import QtQuick.Controls.Styles 1.1 import QtQuick.Controls.Styles 1.1
Rectangle { Rectangle {
id: buttonActionContainer id: buttonActionContainer
color: "transparent"
property string disableStateImg property string disableStateImg
property string enabledStateImg property string enabledStateImg
property string buttonTooltip property string buttonTooltip
property string buttonShortcut property string buttonShortcut
property bool buttonLeft
property bool buttonRight
signal clicked signal clicked
color: "transparent"
width: 35
height: 24
function enabled(state) function enabled(state)
{ {
buttonAction.enabled = state; buttonAction.enabled = state;
@ -22,29 +29,104 @@ Rectangle {
debugImage.source = disableStateImg; debugImage.source = disableStateImg;
} }
Button Rectangle {
{ color: "#DCDADA"
anchors.fill: parent width: 10
id: debugImg height: 24
/* iconSource: enabledStateImg radius: 4
*/ action: buttonAction x: 0
visible: buttonLeft
Rectangle {
anchors {
left: parent.left
right: parent.right
top: parent.top
bottom: parent.bottom
bottomMargin:debugImg.pressed? 0 : 1;
topMargin:debugImg.pressed? 1 : 0;
}
color: "#FCFBFC"
radius: 3
}
} }
Image { Rectangle {
id: debugImage color: "#DCDADA"
source: enabledStateImg width: 10
anchors.centerIn: parent height: 24
fillMode: Image.PreserveAspectFit radius: 4
width: 15 x: 25
height: 15 visible: buttonRight
Rectangle {
anchors {
left: parent.left
right: parent.right
top: parent.top
bottom: parent.bottom
bottomMargin:debugImg.pressed? 0 : 1;
topMargin:debugImg.pressed? 1 : 0;
}
color: "#FCFBFC"
radius: 3
}
} }
Action {
tooltip: buttonTooltip Rectangle {
id: buttonAction id: contentRectangle
shortcut: buttonShortcut width: 25
onTriggered: { height: 24
buttonActionContainer.clicked(); color: "#DCDADA"
x: 5
Rectangle {
anchors {
left: parent.left
right: parent.right
top: parent.top
bottom: parent.bottom
bottomMargin:debugImg.pressed? 0 : 1;
topMargin:debugImg.pressed? 1 : 0;
}
color: "#FCFBFC"
Image {
id: debugImage
source: enabledStateImg
anchors.centerIn: parent
anchors.topMargin: debugImg.pressed? 1 : 0;
fillMode: Image.PreserveAspectFit
width: 15
height: 15
}
}
Button {
anchors.fill: parent
id: debugImg
action: buttonAction
style: Rectangle {
color: "transparent"
}
}
Action {
tooltip: buttonTooltip
id: buttonAction
shortcut: buttonShortcut
onTriggered: {
// contentRectangle.anchors.bottomMargin = 0
// contentRectangle.anchors.topMargin = 1
buttonActionContainer.clicked();
}
} }
} }
} }

7
test/blockchain.cpp

@ -192,7 +192,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
state.sync(bc, txs, gp); state.sync(bc, txs, gp);
state.commitToMine(bc); state.commitToMine(bc);
MineInfo info; MineInfo info;
for (info.completed = false; !info.completed; info = state.mine()) {} ProofOfWork pow;
for (info.completed = false; !info.completed; info = state.mine(&pow)) {}
state.completeMine(); state.completeMine();
} }
catch (Exception const& _e) catch (Exception const& _e)
@ -577,7 +578,7 @@ void overwriteBlockHeader(BlockInfo& _currentBlockHeader, mObject& _blObj)
std::pair<MineInfo, Ethash::Proof> ret; std::pair<MineInfo, Ethash::Proof> ret;
while (!ProofOfWork::verify(_currentBlockHeader)) while (!ProofOfWork::verify(_currentBlockHeader))
{ {
ret = pow.mine(_currentBlockHeader, 1000, true, true); ret = pow.mine(_currentBlockHeader, 1000, true);
Ethash::assignResult(ret.second, _currentBlockHeader); Ethash::assignResult(ret.second, _currentBlockHeader);
} }
} }
@ -623,7 +624,7 @@ void updatePoW(BlockInfo& _bi)
std::pair<MineInfo, Ethash::Proof> ret; std::pair<MineInfo, Ethash::Proof> ret;
while (!ProofOfWork::verify(_bi)) while (!ProofOfWork::verify(_bi))
{ {
ret = pow.mine(_bi, 10000, true, true); ret = pow.mine(_bi, 10000, true);
Ethash::assignResult(ret.second, _bi); Ethash::assignResult(ret.second, _bi);
} }
_bi.noteDirty(); _bi.noteDirty();

5
test/stateOriginal.cpp

@ -68,7 +68,8 @@ BOOST_AUTO_TEST_CASE(Complex)
// Mine to get some ether! // Mine to get some ether!
s.commitToMine(bc); s.commitToMine(bc);
while (!s.mine(100, true).completed) {} ProofOfWork pow;
while (!s.mine(&pow).completed) {}
s.completeMine(); s.completeMine();
bc.attemptImport(s.blockData(), stateDB); bc.attemptImport(s.blockData(), stateDB);
@ -88,7 +89,7 @@ BOOST_AUTO_TEST_CASE(Complex)
// Mine to get some ether and set in stone. // Mine to get some ether and set in stone.
s.commitToMine(bc); s.commitToMine(bc);
s.commitToMine(bc); s.commitToMine(bc);
while (!s.mine(100, true).completed) {} while (!s.mine(&pow).completed) {}
s.completeMine(); s.completeMine();
bc.attemptImport(s.blockData(), stateDB); bc.attemptImport(s.blockData(), stateDB);

10
test/webthreestubclient.h

@ -72,6 +72,16 @@ class WebThreeStubClient : public jsonrpc::Client
else else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
} }
std::string eth_hashrate() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
Json::Value result = this->CallMethod("eth_hashrate",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string eth_coinbase() throw (jsonrpc::JsonRpcException) std::string eth_coinbase() throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;

Loading…
Cancel
Save