Browse Source

Merge branch 'develop' into rpcfix

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
803503e311
  1. 55
      alethzero/DappLoader.cpp
  2. 7
      alethzero/DappLoader.h
  3. 27
      alethzero/MainWin.cpp
  4. 1
      alethzero/MainWin.h
  5. 4
      evmjit/libevmjit/ExecutionEngine.cpp
  6. 18
      exp/CMakeLists.txt
  7. 29
      exp/main.cpp
  8. 1
      libdevcore/CMakeLists.txt
  9. 6
      libdevcore/CommonIO.cpp
  10. 2
      libdevcore/CommonIO.h
  11. 1
      libdevcore/RangeMask.h
  12. 4
      libdevcore/TransientDirectory.cpp
  13. 4
      libdevcore/TransientDirectory.h
  14. 2
      libethash/util.h
  15. 38
      libethcore/Ethasher.cpp
  16. 2
      libethcore/Ethasher.h
  17. 117
      libethcore/ProofOfWork.cpp
  18. 6
      libethcore/ProofOfWork.h
  19. 7
      libethereum/CMakeLists.txt
  20. 1
      libethereum/Client.cpp
  21. 2
      libethereum/ClientBase.cpp
  22. 2
      libtestutils/BlockChainLoader.h
  23. 2
      libtestutils/StateLoader.h
  24. 67
      libweb3jsonrpc/WebThreeStubServerBase.cpp
  25. 4
      mix/qml/DebugInfoList.qml
  26. 75
      mix/qml/Debugger.qml
  27. 21
      mix/qml/StatusPane.qml
  28. 12
      mix/qml/html/cm/solarized.css
  29. BIN
      mix/qml/img/closedtriangleindicator.png
  30. BIN
      mix/qml/img/closedtriangleindicator@2x.png
  31. BIN
      mix/qml/img/opentriangleindicator.png
  32. BIN
      mix/qml/img/opentriangleindicator@2x.png
  33. BIN
      mix/qml/img/signerroricon32.png
  34. BIN
      mix/qml/img/warningicon.png
  35. BIN
      mix/qml/img/warningicon@2x.png
  36. 5
      mix/res.qrc
  37. 1
      test/TestUtils.cpp
  38. 2
      test/blockchain.cpp
  39. 2
      test/state.cpp
  40. 2
      test/vm.cpp

55
alethzero/DappLoader.cpp

@ -25,6 +25,7 @@
#include <QStringList>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QMimeDatabase>
#include <libdevcore/Common.h>
#include <libdevcore/RLP.h>
#include <libdevcrypto/CryptoPP.h>
@ -96,13 +97,31 @@ DappLocation DappLoader::resolveAppUri(QString const& _uri)
void DappLoader::downloadComplete(QNetworkReply* _reply)
{
QUrl requestUrl = _reply->request().url();
if (m_pageUrls.count(requestUrl) != 0)
{
//inject web3 js
QByteArray content = "<script>\n";
content.append(web3Content());
content.append("</script>\n");
content.append(_reply->readAll());
QString contentType = _reply->header(QNetworkRequest::ContentTypeHeader).toString();
if (contentType.isEmpty())
{
QMimeDatabase db;
contentType = db.mimeTypeForUrl(requestUrl).name();
}
pageReady(content, contentType, requestUrl);
return;
}
try
{
//try to interpret as rlp
QByteArray data = _reply->readAll();
_reply->deleteLater();
h256 expected = m_uriHashes[_reply->request().url()];
h256 expected = m_uriHashes[requestUrl];
bytes package(reinterpret_cast<unsigned char const*>(data.constData()), reinterpret_cast<unsigned char const*>(data.constData() + data.size()));
Secp256k1 dec;
dec.decrypt(expected, package);
@ -144,15 +163,7 @@ void DappLoader::loadDapp(RLP const& _rlp)
if (entry->path == "/deployment.js")
{
//inject web3 code
QString code;
code += contentsOfQResource(":/js/bignumber.min.js");
code += "\n";
code += contentsOfQResource(":/js/webthree.js");
code += "\n";
code += contentsOfQResource(":/js/setup.js");
code += "\n";
QByteArray res = code.toLatin1();
bytes b(res.data(), res.data() + res.size());
bytes b(web3Content().data(), web3Content().data() + web3Content().size());
b.insert(b.end(), content.begin(), content.end());
dapp.content[hash] = b;
}
@ -165,6 +176,22 @@ void DappLoader::loadDapp(RLP const& _rlp)
emit dappReady(dapp);
}
QByteArray const& DappLoader::web3Content()
{
if (m_web3Js.isEmpty())
{
QString code;
code += contentsOfQResource(":/js/bignumber.min.js");
code += "\n";
code += contentsOfQResource(":/js/webthree.js");
code += "\n";
code += contentsOfQResource(":/js/setup.js");
code += "\n";
m_web3Js = code.toLatin1();
}
return m_web3Js;
}
Manifest DappLoader::loadManifest(std::string const& _manifest)
{
/// https://github.com/ethereum/go-ethereum/wiki/URL-Scheme
@ -216,3 +243,11 @@ void DappLoader::loadDapp(QString const& _uri)
m_net.get(request);
}
void DappLoader::loadPage(QString const& _uri)
{
QUrl uri(_uri);
QNetworkRequest request(uri);
m_pageUrls.insert(uri);
m_net.get(request);
}

7
alethzero/DappLoader.h

@ -73,9 +73,13 @@ public:
///Load a new DApp. Resolves a name with a name reg contract. Asynchronous. dappReady is emitted once everything is read, dappError othervise
///@param _uri Eth name path
void loadDapp(QString const& _uri);
///Load a regular html page
///@param _uri Page Uri
void loadPage(QString const& _uri);
signals:
void dappReady(Dapp& _dapp);
void pageReady(QByteArray const& _content, QString const& _mimeType, QUrl const& _uri);
void dappError();
private slots:
@ -86,9 +90,12 @@ private:
DappLocation resolveAppUri(QString const& _uri);
void loadDapp(dev::RLP const& _rlp);
Manifest loadManifest(std::string const& _manifest);
QByteArray const& web3Content();
dev::WebThreeDirect* m_web3;
QNetworkAccessManager m_net;
std::map<QUrl, dev::h256> m_uriHashes;
std::set<QUrl> m_pageUrls;
QByteArray m_web3Js;
};

27
alethzero/MainWin.cpp

@ -183,13 +183,6 @@ Main::Main(QWidget *parent) :
m_webPage = webPage;
connect(webPage, &WebPage::consoleMessage, [this](QString const& _msg) { Main::addConsoleMessage(_msg, QString()); });
ui->webView->setPage(m_webPage);
connect(ui->webView, &QWebEngineView::loadFinished, [this]()
{
auto f = ui->webView->page();
f->runJavaScript(contentsOfQResource(":/js/bignumber.min.js"));
f->runJavaScript(contentsOfQResource(":/js/webthree.js"));
f->runJavaScript(contentsOfQResource(":/js/setup.js"));
});
connect(ui->webView, &QWebEngineView::titleChanged, [=]()
{
@ -199,6 +192,7 @@ Main::Main(QWidget *parent) :
m_dappHost.reset(new DappHost(8081));
m_dappLoader = new DappLoader(this, web3());
connect(m_dappLoader, &DappLoader::dappReady, this, &Main::dappLoaded);
connect(m_dappLoader, &DappLoader::pageReady, this, &Main::pageLoaded);
// ui->webView->page()->settings()->setAttribute(QWebEngineSettings::DeveloperExtrasEnabled, true);
// QWebEngineInspector* inspector = new QWebEngineInspector();
// inspector->setPage(page);
@ -264,7 +258,7 @@ NetworkPreferences Main::netPrefs() const
{
listenIP.clear();
}
auto publicIP = ui->forcePublicIP->text().toStdString();
try
{
@ -274,7 +268,7 @@ NetworkPreferences Main::netPrefs() const
{
publicIP.clear();
}
if (isPublicAddress(publicIP))
return NetworkPreferences(publicIP, listenIP, ui->port->value(), ui->upnp->isChecked());
else
@ -918,6 +912,7 @@ void Main::on_urlEdit_returnPressed()
{
//try do resolve dapp url
m_dappLoader->loadDapp(s);
return;
}
catch (...)
{
@ -931,8 +926,7 @@ void Main::on_urlEdit_returnPressed()
else
url.setScheme("http");
else {}
qDebug() << url.toString();
ui->webView->page()->setUrl(url);
m_dappLoader->loadPage(url.toString());
}
void Main::on_nameReg_textChanged()
@ -1799,7 +1793,7 @@ void Main::on_connect_triggered()
ui->net->setChecked(true);
on_net_triggered();
}
m_connect.setEnvironment(m_servers);
if (m_connect.exec() == QDialog::Accepted)
{
@ -1811,9 +1805,9 @@ void Main::on_connect_triggered()
nodeID = NodeId(fromHex(m_connect.nodeId().toStdString()));
}
catch (BadHexCharacter&) {}
m_connect.reset();
if (required)
web3()->requirePeer(nodeID, host);
else
@ -2016,3 +2010,8 @@ void Main::dappLoaded(Dapp& _dapp)
QUrl url = m_dappHost->hostDapp(std::move(_dapp));
ui->webView->page()->setUrl(url);
}
void Main::pageLoaded(QByteArray const& _content, QString const& _mimeType, QUrl const& _uri)
{
ui->webView->page()->setContent(_content, _mimeType, _uri);
}

1
alethzero/MainWin.h

@ -179,6 +179,7 @@ private slots:
// Dapps
void dappLoaded(Dapp& _dapp); //qt does not support rvalue refs for signals
void pageLoaded(QByteArray const& _content, QString const& _mimeType, QUrl const& _uri);
signals:
void poll();

4
evmjit/libevmjit/ExecutionEngine.cpp

@ -88,10 +88,10 @@ void parseOptions()
//cl::ParseEnvironmentOptions("evmjit", "EVMJIT", "Ethereum EVM JIT Compiler");
// FIXME: LLVM workaround:
// Manually select instruction scheduler other than "source".
// Manually select instruction scheduler. Confirmed bad schedulers: source, list-burr, list-hybrid.
// "source" scheduler has a bug: http://llvm.org/bugs/show_bug.cgi?id=22304
auto envLine = std::getenv("EVMJIT");
auto commandLine = std::string{"evmjit "} + (envLine ? envLine : "") + " -pre-RA-sched=list-burr\0";
auto commandLine = std::string{"evmjit "} + (envLine ? envLine : "") + " -pre-RA-sched=list-ilp\0";
static const auto c_maxArgs = 20;
char const* argv[c_maxArgs] = {nullptr, };
auto arg = std::strtok(&*commandLine.begin(), " ");

18
exp/CMakeLists.txt

@ -10,8 +10,26 @@ set(EXECUTABLE exp)
add_executable(${EXECUTABLE} ${SRC_LIST})
target_link_libraries(${EXECUTABLE} ${Boost_REGEX_LIBRARIES})
if (READLINE_FOUND)
target_link_libraries(${EXECUTABLE} ${READLINE_LIBRARIES})
endif()
if (JSONRPC)
target_link_libraries(${EXECUTABLE} web3jsonrpc)
endif()
target_link_libraries(${EXECUTABLE} webthree)
target_link_libraries(${EXECUTABLE} ethereum)
target_link_libraries(${EXECUTABLE} p2p)
target_link_libraries(${EXECUTABLE} ethash-cl)
target_link_libraries(${EXECUTABLE} ethash)
target_link_libraries(${EXECUTABLE} OpenCL)
install( TARGETS ${EXECUTABLE} DESTINATION bin)

29
exp/main.cpp

@ -19,18 +19,25 @@
* @date 2014
* Ethereum client.
*/
#define __CL_ENABLE_EXCEPTIONS
#define CL_USE_DEPRECATED_OPENCL_2_0_APIS
#include "libethash-cl/cl.hpp"
#include <functional>
#include <libethereum/AccountDiff.h>
#include <libdevcore/RangeMask.h>
#include <libdevcore/Log.h>
#include <libdevcore/Common.h>
#include <libdevcore/CommonData.h>
#include <libdevcore/RLP.h>
#include <libdevcrypto/TrieDB.h>
#include <libdevcore/TransientDirectory.h>
#include <libdevcore/CommonIO.h>
#include <libdevcrypto/TrieDB.h>
#include <libp2p/All.h>
#include <libethereum/DownloadMan.h>
#include <libethcore/Ethasher.h>
#include <libethcore/ProofOfWork.h>
#include <libethereum/All.h>
#include <libethereum/AccountDiff.h>
#include <libethereum/DownloadMan.h>
#include <liblll/All.h>
#include <libwhisper/WhisperPeer.h>
#include <libwhisper/WhisperHost.h>
@ -101,6 +108,22 @@ int main()
#else
int main()
{
std::vector<cl::Platform> platforms;
cl::Platform::get(&platforms);
if (platforms.empty())
{
cdebug << "No OpenCL platforms found.";
return false;
}
EthashCL ecl;
BlockInfo genesis = CanonBlockChain::genesis();
TransientDirectory td;
std::pair<MineInfo, Ethash::Proof> r;
while (!r.first.completed)
r = ecl.mine(genesis, 1000);
EthashCL::assignResult(r.second, genesis);
assert(EthashCPU::verify(genesis));
return 0;
}
#endif

1
libdevcore/CMakeLists.txt

@ -28,6 +28,7 @@ endif()
target_link_libraries(${EXECUTABLE} ${Boost_THREAD_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${Boost_SYSTEM_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${Boost_FILESYSTEM_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${JSONCPP_LIBRARIES})
# transitive dependencies for windows executables

6
libdevcore/CommonIO.cpp

@ -58,7 +58,7 @@ string dev::memDump(bytes const& _bytes, unsigned _width, bool _html)
}
// Don't forget to delete[] later.
bytesRef dev::contentsNew(std::string const& _file)
bytesRef dev::contentsNew(std::string const& _file, bytesRef _dest)
{
std::ifstream is(_file, std::ifstream::binary);
if (!is)
@ -68,8 +68,10 @@ bytesRef dev::contentsNew(std::string const& _file)
streamoff length = is.tellg();
if (length == 0) // return early, MSVC does not like reading 0 bytes
return bytesRef();
if (!_dest.empty() && _dest.size() != (unsigned)length)
return bytesRef();
is.seekg (0, is.beg);
bytesRef ret(new byte[length], length);
bytesRef ret = _dest.empty() ? bytesRef(new byte[length], length) : _dest;
is.read((char*)ret.data(), length);
is.close();
return ret;

2
libdevcore/CommonIO.h

@ -46,7 +46,7 @@ namespace dev
bytes contents(std::string const& _file);
std::string contentsString(std::string const& _file);
/// Retrieve and returns the allocated contents of the given file. If the file doesn't exist or isn't readable, returns nullptr. Don't forget to delete [] when finished.
bytesRef contentsNew(std::string const& _file);
bytesRef contentsNew(std::string const& _file, bytesRef _dest = bytesRef());
/// Write the given binary data into the given file, replacing the file if it pre-exists.
void writeFile(std::string const& _file, bytesConstRef _data);

1
libdevcore/RangeMask.h

@ -25,6 +25,7 @@
#include <utility>
#include <vector>
#include <iostream>
#include <assert.h>
namespace dev
{

4
libtestutils/TransientDirectory.cpp → libdevcore/TransientDirectory.cpp

@ -20,11 +20,11 @@
*/
#include <boost/filesystem.hpp>
#include <libdevcore/Exceptions.h>
#include "Exceptions.h"
#include "TransientDirectory.h"
#include "CommonIO.h"
using namespace std;
using namespace dev;
using namespace dev::test;
TransientDirectory::TransientDirectory():
TransientDirectory((boost::filesystem::temp_directory_path() / "eth_transient" / toString(FixedHash<4>::random())).string())

4
libtestutils/TransientDirectory.h → libdevcore/TransientDirectory.h

@ -22,12 +22,9 @@
#pragma once
#include <string>
#include "Common.h"
namespace dev
{
namespace test
{
/**
* @brief temporary directory implementation
@ -48,4 +45,3 @@ private:
};
}
}

2
libethash/util.h

@ -29,7 +29,7 @@ extern "C" {
#ifdef _MSC_VER
void debugf(const char *str, ...);
#else
#define debugf printf
#define debugf(...) fprintf(stderr, __VA_ARGS__)
#endif
static inline uint32_t min_u32(uint32_t a, uint32_t b)

38
libethcore/Ethasher.cpp

@ -123,6 +123,44 @@ ethash_params Ethasher::params(BlockInfo const& _header)
return params((unsigned)_header.number);
}
void Ethasher::readFull(BlockInfo const& _header, void* _dest)
{
if (!m_fulls.count(_header.seedHash()))
{
// @memoryleak @bug place it on a pile for deletion - perhaps use shared_ptr.
/* if (!m_fulls.empty())
{
delete [] m_fulls.begin()->second.data();
m_fulls.erase(m_fulls.begin());
}*/
try {
boost::filesystem::create_directories(getDataDir("ethash"));
} catch (...) {}
auto info = rlpList(c_ethashRevision, _header.seedHash());
std::string oldMemoFile = getDataDir("ethash") + "/full";
std::string memoFile = getDataDir("ethash") + "/full-R" + toString(c_ethashRevision) + "-" + toHex(_header.seedHash().ref().cropped(0, 8));
if (boost::filesystem::exists(oldMemoFile) && contents(oldMemoFile + ".info") == info)
{
// memofile valid - rename.
boost::filesystem::rename(oldMemoFile, memoFile);
}
IGNORE_EXCEPTIONS(boost::filesystem::remove(oldMemoFile));
IGNORE_EXCEPTIONS(boost::filesystem::remove(oldMemoFile + ".info"));
ethash_params p = params((unsigned)_header.number);
bytesRef r = contentsNew(memoFile, bytesRef((byte*)_dest, p.full_size));
if (!r)
{
auto c = light(_header);
ethash_prep_full(_dest, &p, c);
writeFile(memoFile, bytesConstRef((byte*)_dest, p.full_size));
}
}
}
ethash_params Ethasher::params(unsigned _n)
{
ethash_params p;

2
libethcore/Ethasher.h

@ -56,6 +56,8 @@ public:
static ethash_params params(BlockInfo const& _header);
static ethash_params params(unsigned _n);
void readFull(BlockInfo const& _header, void* _dest);
struct Result
{
h256 value;

117
libethcore/ProofOfWork.cpp

@ -33,32 +33,6 @@
#include <libdevcore/Common.h>
#if ETH_ETHASHCL
#include <libethash-cl/ethash_cl_miner.h>
#define ETHASH_REVISION REVISION
#define ETHASH_DATASET_BYTES_INIT DATASET_BYTES_INIT
#define ETHASH_DATASET_BYTES_GROWTH DATASET_BYTES_GROWTH
#define ETHASH_CACHE_BYTES_INIT CACHE_BYTES_INIT
#define ETHASH_CACHE_BYTES_GROWTH CACHE_BYTES_GROWTH
#define ETHASH_DAGSIZE_BYTES_INIT DAGSIZE_BYTES_INIT
#define ETHASH_DAG_GROWTH DAG_GROWTH
#define ETHASH_EPOCH_LENGTH EPOCH_LENGTH
#define ETHASH_MIX_BYTES MIX_BYTES
#define ETHASH_HASH_BYTES HASH_BYTES
#define ETHASH_DATASET_PARENTS DATASET_PARENTS
#define ETHASH_CACHE_ROUNDS CACHE_ROUNDS
#define ETHASH_ACCESSES ACCESSES
#undef REVISION
#undef DATASET_BYTES_INIT
#undef DATASET_BYTES_GROWTH
#undef CACHE_BYTES_INIT
#undef CACHE_BYTES_GROWTH
#undef DAGSIZE_BYTES_INIT
#undef DAG_GROWTH
#undef EPOCH_LENGTH
#undef MIX_BYTES
#undef HASH_BYTES
#undef DATASET_PARENTS
#undef CACHE_ROUNDS
#undef ACCESSES
#endif
#include "BlockInfo.h"
#include "Ethasher.h"
@ -131,16 +105,16 @@ std::pair<MineInfo, EthashCPU::Proof> EthashCPU::mine(BlockInfo const& _header,
#if ETH_ETHASHCL
/*
struct ethash_cl_search_hook
{
// reports progress, return true to abort
virtual bool found(uint64_t const* nonces, uint32_t count) = 0;
virtual bool searched(uint64_t start_nonce, uint32_t count) = 0;
};
class ethash_cl_miner
{
public:
struct search_hook
{
// reports progress, return true to abort
virtual bool found(uint64_t const* nonces, uint32_t count) = 0;
virtual bool searched(uint64_t start_nonce, uint32_t count) = 0;
};
ethash_cl_miner();
bool init(ethash_params const& params, const uint8_t seed[32], unsigned workgroup_size = 64);
@ -150,58 +124,63 @@ public:
};
*/
struct EthashCLHook: public ethash_cl_search_hook
struct EthashCLHook: public ethash_cl_miner::search_hook
{
virtual bool found(uint64_t const* _nonces, uint32_t _count)
void abort()
{
if (m_aborted)
return;
m_abort = true;
for (unsigned timeout = 0; timeout < 100 && !m_aborted; ++timeout)
std::this_thread::sleep_for(chrono::milliseconds(30));
if (!m_aborted)
cwarn << "Couldn't abort. Abandoning OpenCL process.";
m_aborted = m_abort = false;
m_found.clear();
}
vector<Nonce> fetchFound() { vector<Nonce> ret; Guard l(x_all); std::swap(ret, m_found); return ret; }
uint64_t fetchTotal() { Guard l(x_all); auto ret = m_total; m_total = 0; return ret; }
protected:
virtual bool found(uint64_t const* _nonces, uint32_t _count) override
{
Guard l(x_all);
for (unsigned i = 0; i < _count; ++i)
found.push_back((Nonce)(u64)_nonces[i]);
if (abort)
{
aborted = true;
return true;
}
return false;
m_found.push_back((Nonce)(u64)_nonces[i]);
m_aborted = true;
return true;
}
virtual bool searched(uint64_t _startNonce, uint32_t _count)
virtual bool searched(uint64_t _startNonce, uint32_t _count) override
{
Guard l(x_all);
total += _count;
last = _startNonce + _count;
if (abort)
m_total += _count;
m_last = _startNonce + _count;
if (m_abort)
{
aborted = true;
m_aborted = true;
return true;
}
return false;
}
vector<Nonce> fetchFound() { vector<Nonce> ret; Guard l(x_all); std::swap(ret, found); return ret; }
uint64_t fetchTotal() { Guard l(x_all); auto ret = total; total = 0; return ret; }
private:
Mutex x_all;
vector<Nonce> found;
uint64_t total;
uint64_t last;
bool abort = false;
bool aborted = false;
vector<Nonce> m_found;
uint64_t m_total;
uint64_t m_last;
bool m_abort = false;
bool m_aborted = true;
};
EthashCL::EthashCL():
m_miner(new ethash_cl_miner),
m_hook(new EthashCLHook)
{
}
EthashCL::~EthashCL()
{
m_hook->abort = true;
for (unsigned timeout = 0; timeout < 100 && !m_hook->aborted; ++timeout)
std::this_thread::sleep_for(chrono::milliseconds(30));
if (!m_hook->aborted)
cwarn << "Couldn't abort. Abandoning OpenCL process.";
}
bool EthashCL::verify(BlockInfo const& _header)
@ -211,13 +190,16 @@ bool EthashCL::verify(BlockInfo const& _header)
std::pair<MineInfo, Ethash::Proof> EthashCL::mine(BlockInfo const& _header, unsigned _msTimeout, bool, bool)
{
if (m_lastHeader.seedHash() != _header.seedHash())
if (!m_lastHeader || m_lastHeader.seedHash() != _header.seedHash())
{
m_miner->init(Ethasher::params(_header), _header.seedHash().data());
// TODO: reinit probably won't work when seed changes.
if (m_miner)
m_hook->abort();
m_miner.reset(new ethash_cl_miner);
m_miner->init(Ethasher::params(_header), [&](void* d){ Ethasher::get()->readFull(_header, d); });
}
if (m_lastHeader != _header)
{
m_hook->abort();
static std::random_device s_eng;
uint64_t tryNonce = (uint64_t)(u64)(m_last = Nonce::random(s_eng));
m_miner->search(_header.headerHash(WithoutNonce).data(), tryNonce, *m_hook);
@ -228,10 +210,11 @@ std::pair<MineInfo, Ethash::Proof> EthashCL::mine(BlockInfo const& _header, unsi
auto found = m_hook->fetchFound();
if (!found.empty())
{
h256 mixHash; // ?????
return std::make_pair(MineInfo{0.0, 1e99, 0, true}, EthashCL::Proof((Nonce)(u64)found[0], mixHash));
Nonce n = (Nonce)(u64)found[0];
auto result = Ethasher::eval(_header, n);
return std::make_pair(MineInfo(true), EthashCL::Proof{n, result.mixHash});
}
return std::make_pair(MineInfo{0.0, 1e99, 0, false}, EthashCL::Proof());
return std::make_pair(MineInfo(false), EthashCL::Proof());
}
#endif

6
libethcore/ProofOfWork.h

@ -42,6 +42,8 @@ namespace eth
struct MineInfo
{
MineInfo() = default;
MineInfo(bool _completed): completed(_completed) {}
void combine(MineInfo const& _m) { requirement = std::max(requirement, _m.requirement); best = std::min(best, _m.best); hashes += _m.hashes; completed = completed || _m.completed; }
double requirement = 0;
double best = 1e99;
@ -67,6 +69,8 @@ protected:
};
#if ETH_ETHASHCL
class EthashCLHook;
class EthashCL
{
public:
@ -88,7 +92,7 @@ protected:
BlockInfo m_lastHeader;
Nonce m_mined;
std::unique_ptr<ethash_cl_miner> m_miner;
std::unique_ptr<ethash_cl_search_hook> m_hook;
std::unique_ptr<EthashCLHook> m_hook;
};
using Ethash = EthashCL;

7
libethereum/CMakeLists.txt

@ -25,19 +25,18 @@ else()
add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS})
endif()
target_link_libraries(${EXECUTABLE} ${LEVELDB_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${Boost_REGEX_LIBRARIES})
target_link_libraries(${EXECUTABLE} evm)
target_link_libraries(${EXECUTABLE} lll)
target_link_libraries(${EXECUTABLE} whisper)
target_link_libraries(${EXECUTABLE} p2p)
target_link_libraries(${EXECUTABLE} devcrypto)
target_link_libraries(${EXECUTABLE} ethcore)
target_link_libraries(${EXECUTABLE} ${LEVELDB_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${Boost_REGEX_LIBRARIES})
target_link_libraries(${EXECUTABLE} secp256k1)
if (ETHASHCL)
target_link_libraries(${EXECUTABLE} ethash-cl)
target_link_libraries(${EXECUTABLE} OpenCL)
endif ()
if (CMAKE_COMPILER_IS_MINGW)

1
libethereum/Client.cpp

@ -334,6 +334,7 @@ void Client::setMiningThreads(unsigned _threads)
{
stopMining();
#if ETH_ETHASHCL
(void)_threads;
unsigned t = 1;
#else
auto t = _threads ? _threads : thread::hardware_concurrency();

2
libethereum/ClientBase.cpp

@ -75,7 +75,7 @@ ExecutionResult ClientBase::call(Secret _secret, u256 _value, Address _dest, byt
u256 n = temp.transactionsFrom(a);
Transaction t(_value, _gasPrice, _gas, _dest, _data, n, _secret);
if (_ff == FudgeFactor::Lenient)
temp.addBalance(a, (u256)(t.gasRequired() * t.gasPrice() + t.value()));
temp.addBalance(a, (u256)(t.gas() * t.gasPrice() + t.value()));
ret = temp.execute(bc().lastHashes(), t, Permanence::Reverted);
}
catch (...)

2
libtestutils/BlockChainLoader.h

@ -22,9 +22,9 @@
#pragma once
#include <string>
#include <json/json.h>
#include <libdevcore/TransientDirectory.h>
#include <libethereum/BlockChain.h>
#include <libethereum/State.h>
#include "TransientDirectory.h"
namespace dev
{

2
libtestutils/StateLoader.h

@ -22,8 +22,8 @@
#pragma once
#include <json/json.h>
#include <libdevcore/TransientDirectory.h>
#include <libethereum/State.h>
#include "TransientDirectory.h"
namespace dev
{

67
libweb3jsonrpc/WebThreeStubServerBase.cpp

@ -452,64 +452,55 @@ static TransactionSkeleton toTransaction(Json::Value const& _json)
string WebThreeStubServerBase::eth_sendTransaction(Json::Value const& _json)
{
TransactionSkeleton t;
try
{
t = toTransaction(_json);
string ret;
TransactionSkeleton t = toTransaction(_json);
if (!t.from)
t.from = m_accounts->getDefaultTransactAccount();
if (t.creation)
ret = toJS(right160(sha3(rlpList(t.from, client()->countAt(t.from)))));;
if (!t.gasPrice)
t.gasPrice = 10 * dev::eth::szabo; // TODO: should be determined by user somehow.
if (!t.gas)
t.gas = min<u256>(client()->gasLimitRemaining(), client()->balanceAt(t.from) / t.gasPrice);
if (m_accounts->isRealAccount(t.from))
authenticate(t, false);
else if (m_accounts->isProxyAccount(t.from))
authenticate(t, true);
return ret;
}
catch (...)
{
BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
}
string ret;
if (!t.from)
t.from = m_accounts->getDefaultTransactAccount();
if (t.creation)
ret = toJS(right160(sha3(rlpList(t.from, client()->countAt(t.from)))));;
if (!t.gasPrice)
t.gasPrice = 10 * dev::eth::szabo; // TODO: should be determined by user somehow.
if (!t.gas)
t.gas = min<u256>(client()->gasLimitRemaining(), client()->balanceAt(t.from) / t.gasPrice);
if (m_accounts->isRealAccount(t.from))
authenticate(t, false);
else if (m_accounts->isProxyAccount(t.from))
authenticate(t, true);
return ret;
}
string WebThreeStubServerBase::eth_call(Json::Value const& _json, string const& _blockNumber)
{
TransactionSkeleton t;
int number;
try
{
t = toTransaction(_json);
number = jsToBlockNumber(_blockNumber);
TransactionSkeleton t = toTransaction(_json);
if (!t.from)
t.from = m_accounts->getDefaultTransactAccount();
// if (!m_accounts->isRealAccount(t.from))
// return ret;
if (!t.gasPrice)
t.gasPrice = 10 * dev::eth::szabo;
if (!t.gas)
t.gas = client()->gasLimitRemaining();
return toJS(client()->call(m_accounts->secretKey(t.from), t.value, t.to, t.data, t.gas, t.gasPrice, jsToBlockNumber(_blockNumber), FudgeFactor::Lenient).output);
}
catch (...)
{
BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
}
string ret;
if (!t.from)
t.from = m_accounts->getDefaultTransactAccount();
// if (!m_accounts->isRealAccount(t.from))
// return ret;
if (!t.gasPrice)
t.gasPrice = 10 * dev::eth::szabo;
if (!t.gas)
t.gas = client()->gasLimitRemaining();
ret = toJS(client()->call(m_accounts->secretKey(t.from), t.value, t.to, t.data, t.gas, t.gasPrice, number).output);
return ret;
}
bool WebThreeStubServerBase::eth_flush()

4
mix/qml/DebugInfoList.qml

@ -40,11 +40,9 @@ ColumnLayout {
height: 25
id: header
Image {
source: "qrc:/qml/img/opentriangleindicator.png"
source: "img/closedtriangleindicator.png"
width: 15
height: 15
sourceSize.width: 15
sourceSize.height: 15
id: storageImgArrow
}

75
mix/qml/Debugger.qml

@ -206,8 +206,8 @@ Rectangle {
anchors.top: parent.top
anchors.topMargin: 15
anchors.left: parent.left;
anchors.leftMargin: machineStates.sideMargin
width: debugScrollArea.width - machineStates.sideMargin * 2 - 20;
anchors.leftMargin: machineStates.sideMargin
width: debugScrollArea.width - machineStates.sideMargin * 2 - 20 ;
spacing: machineStates.sideMargin
Rectangle {
@ -218,15 +218,13 @@ Rectangle {
color: "transparent"
Rectangle {
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.fill: parent
color: "transparent"
width: parent.width * 0.4
RowLayout {
anchors.horizontalCenter: parent.horizontalCenter
anchors.fill: parent
id: jumpButtons
spacing: 3
layoutDirection: Qt.LeftToRight
StepActionImage
{
@ -239,6 +237,7 @@ Rectangle {
buttonShortcut: "Ctrl+Shift+F8"
buttonTooltip: qsTr("Start Debugging")
visible: true
Layout.alignment: Qt.AlignLeft
}
StepActionImage
@ -351,35 +350,38 @@ Rectangle {
buttonTooltip: qsTr("Run Forward")
visible: false
}
}
}
Rectangle {
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.right: parent.right
width: parent.width * 0.6
color: "transparent"
Slider {
id: statesSlider
anchors.fill: parent
tickmarksEnabled: true
stepSize: 1.0
onValueChanged: Debugger.jumpTo(value);
style: SliderStyle {
groove: Rectangle {
implicitHeight: 3
color: "#7da4cd"
radius: 8
}
handle: Rectangle {
anchors.centerIn: parent
color: control.pressed ? "white" : "lightgray"
border.color: "gray"
border.width: 2
implicitWidth: 10
implicitHeight: 10
radius: 12
Rectangle {
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.right: parent.right
color: "transparent"
Layout.fillWidth: true
Layout.minimumWidth: parent.width * 0.2
Layout.alignment: Qt.AlignRight
Slider {
id: statesSlider
anchors.fill: parent
tickmarksEnabled: true
stepSize: 1.0
onValueChanged: Debugger.jumpTo(value);
style: SliderStyle {
groove: Rectangle {
implicitHeight: 3
color: "#7da4cd"
radius: 8
}
handle: Rectangle {
anchors.centerIn: parent
color: control.pressed ? "white" : "lightgray"
border.color: "gray"
border.width: 2
implicitWidth: 10
implicitHeight: 10
radius: 12
}
}
}
}
}
@ -480,7 +482,7 @@ Rectangle {
anchors.top : parent.top
anchors.bottom: parent.bottom
anchors.right: parent.right
height: parent.height //- 2 * stateListContainer.border.width
height: parent.height
color: "transparent"
ColumnLayout
{
@ -520,7 +522,6 @@ Rectangle {
title : qsTr("Stack")
itemDelegate: Item {
id: renderedItem
//height: 25
width: parent.width
RowLayout
{

21
mix/qml/StatusPane.qml

@ -230,13 +230,26 @@ Rectangle {
Button
{
z: 4
anchors.right: parent.right
anchors.rightMargin: 9
anchors.verticalCenter: parent.verticalCenter
anchors.centerIn: parent
id: goToLineBtn
text: ""
iconSource: "qrc:/qml/img/signerroricon32.png"
width: 30
height: 30
action: goToCompilationError
style: ButtonStyle {
background: Rectangle {
color: "transparent"
Image {
source: "qrc:/qml/img/warningicon.png"
height: 30
width: 30
sourceSize.width: 30
sourceSize.height: 30
anchors.centerIn: parent
}
}
}
}
}
}

12
mix/qml/html/cm/solarized.css

@ -154,8 +154,10 @@ http://ethanschoonover.com/solarized/img/solarized-palette.png
}
/*
Active line. Negative margin compensates left padding of the text in the
view-port
*/
.cm-s-solarized.cm-s-dark .CodeMirror-activeline-background {
background: rgba(255, 255, 255, 0.10);
@ -166,20 +168,24 @@ view-port
/* Code execution */
.CodeMirror-exechighlight {
background: #eee8d5;
border-bottom: double 1px #94A2A2;
}
/* Error annotation */
.CodeMirror-errorannotation {
border-bottom: 1px solid #b58900;
border-bottom: 1px solid #DD3330;
margin-bottom: 4px;
}
.CodeMirror-errorannotation-context {
font-family: monospace;
font-size: small;
color: #586e75;
color: #EEE9D5;
background: #b58900;
padding: 2px;
text-shadow: none !important;
border-top: solid 2px #063742;
}
span.CodeMirror-selectedtext { color: #586e75 !important; }

BIN
mix/qml/img/closedtriangleindicator.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 422 B

After

Width:  |  Height:  |  Size: 242 B

BIN
mix/qml/img/closedtriangleindicator@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 B

BIN
mix/qml/img/opentriangleindicator.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 425 B

After

Width:  |  Height:  |  Size: 257 B

BIN
mix/qml/img/opentriangleindicator@2x.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 836 B

After

Width:  |  Height:  |  Size: 429 B

BIN
mix/qml/img/signerroricon32.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

BIN
mix/qml/img/warningicon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 B

BIN
mix/qml/img/warningicon@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

5
mix/res.qrc

@ -20,6 +20,7 @@
<file>qml/img/bugiconactive.png</file>
<file>qml/img/bugiconinactive.png</file>
<file>qml/img/closedtriangleindicator.png</file>
<file>qml/img/closedtriangleindicator@2x.png</file>
<file>qml/img/closedtriangleindicator_filesproject.png</file>
<file>qml/img/console.png</file>
<file>qml/img/copy.png</file>
@ -43,6 +44,7 @@
<file>qml/img/note.png</file>
<file>qml/img/openedfolder.png</file>
<file>qml/img/opentriangleindicator.png</file>
<file>qml/img/opentriangleindicator@2x.png</file>
<file>qml/img/opentriangleindicator_filesproject.png</file>
<file>qml/img/plus.png</file>
<file>qml/img/projecticon.png</file>
@ -63,6 +65,7 @@
<file>qml/img/copyiconactive.png</file>
<file>qml/img/searchicon.png</file>
<file>qml/img/stop_button2x.png</file>
<file>qml/img/signerroricon32.png</file>
<file>qml/img/warningicon.png</file>
<file>qml/img/warningicon@2x.png</file>
</qresource>
</RCC>

1
test/TestUtils.cpp

@ -22,6 +22,7 @@
#include <thread>
#include <boost/test/unit_test.hpp>
#include <boost/filesystem.hpp>
#include <libtestutils/Common.h>
#include <libtestutils/BlockChainLoader.h>
#include <libtestutils/FixedClient.h>
#include "TestUtils.h"

2
test/blockchain.cpp

@ -22,7 +22,7 @@
#include <boost/filesystem.hpp>
#include <libdevcrypto/FileSystem.h>
#include <libtestutils/TransientDirectory.h>
#include <libdevcore/TransientDirectory.h>
#include <libethereum/CanonBlockChain.h>
#include "TestHelper.h"

2
test/state.cpp

@ -218,6 +218,8 @@ BOOST_AUTO_TEST_CASE(stCreateTest)
BOOST_AUTO_TEST_CASE(stRandom)
{
test::Options::get(); // parse command line options, e.g. to enable JIT
string testPath = dev::test::getTestPath();
testPath += "/StateTests/RandomTests";

2
test/vm.cpp

@ -524,6 +524,8 @@ BOOST_AUTO_TEST_CASE(vmInputLimitsLightTest)
BOOST_AUTO_TEST_CASE(vmRandom)
{
test::Options::get(); // parse command line options, e.g. to enable JIT
string testPath = getTestPath();
testPath += "/VMTests/RandomTests";

Loading…
Cancel
Save