From e6d2200ccacb16997eb855b8d84a62c0fdc2246a Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 16 Jul 2015 16:45:23 +0200 Subject: [PATCH] mix working --- CMakeLists.txt | 28 +++++++------- alethzero/MainWin.cpp | 53 ++++++++++++++------------- alethzero/MiningView.cpp | 4 +- alethzero/MiningView.h | 4 +- exp/CMakeLists.txt | 4 +- libethereum/BlockChain.cpp | 1 - libtestutils/BlockChainLoader.cpp | 3 +- libtestutils/StateLoader.cpp | 2 +- libtestutils/StateLoader.h | 2 + libweb3jsonrpc/JsonHelper.cpp | 8 ++-- libweb3jsonrpc/WebThreeStubServer.cpp | 2 +- libweb3jsonrpc/WebThreeStubServer.h | 4 +- libwebthree/WebThree.cpp | 2 +- mix/ClientModel.cpp | 4 +- mix/MixClient.cpp | 36 +++++++++--------- mix/MixClient.h | 36 +++++++++++++++--- 16 files changed, 112 insertions(+), 81 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 421dd1bb7..271f3ed65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -400,13 +400,13 @@ if (TOOLS) endif () if (JSONRPC AND GENERAL) -# add_subdirectory(libweb3jsonrpc) + add_subdirectory(libweb3jsonrpc) endif () if (JSCONSOLE) -# add_subdirectory(libjsengine) -# add_subdirectory(libjsconsole) -# add_subdirectory(ethconsole) + add_subdirectory(libjsengine) + add_subdirectory(libjsconsole) + add_subdirectory(ethconsole) endif () if (NOT WIN32) @@ -434,31 +434,31 @@ add_subdirectory(libethcore) if (GENERAL) add_subdirectory(libevm) add_subdirectory(libethereum) -# add_subdirectory(libwebthree) + add_subdirectory(libwebthree) endif () if (MINER OR TOOLS) -# add_subdirectory(ethminer) + add_subdirectory(ethminer) endif () if (ETHKEY OR TOOLS) -# add_subdirectory(ethkey) + add_subdirectory(ethkey) endif () if (TESTS) -# add_subdirectory(libtestutils) -# add_subdirectory(test) + add_subdirectory(libtestutils) + add_subdirectory(test) if (JSONRPC) -# add_subdirectory(ethrpctest) + add_subdirectory(ethrpctest) endif () endif () if (TOOLS) -# add_subdirectory(rlp) -# add_subdirectory(abi) -# add_subdirectory(ethvm) -# add_subdirectory(eth) + add_subdirectory(rlp) + add_subdirectory(abi) + add_subdirectory(ethvm) + add_subdirectory(eth) if("x${CMAKE_BUILD_TYPE}" STREQUAL "xDebug") add_subdirectory(exp) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index ad8f5528c..181772ddb 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -189,9 +189,9 @@ Main::Main(QWidget *parent) : #endif m_servers.append(QString::fromStdString(Host::pocHost() + ":30303")); - cerr << "State root: " << CanonBlockChain::genesis().stateRoot() << endl; - auto block = CanonBlockChain::createGenesisBlock(); - cerr << "Block Hash: " << CanonBlockChain::genesis().hash() << endl; + cerr << "State root: " << CanonBlockChain::genesis().stateRoot() << endl; + auto block = CanonBlockChain::createGenesisBlock(); + cerr << "Block Hash: " << CanonBlockChain::genesis().hash() << endl; cerr << "Block RLP: " << RLP(block) << endl; cerr << "Block Hex: " << toHex(block) << endl; cerr << "eth Network protocol version: " << eth::c_protocolVersion << endl; @@ -208,13 +208,14 @@ Main::Main(QWidget *parent) : statusBar()->addPermanentWidget(ui->chainStatus); statusBar()->addPermanentWidget(ui->blockCount); - ui->blockCount->setText(QString("PV%1.%2 D%3 %4-%5 v%6").arg(eth::c_protocolVersion).arg(eth::c_minorProtocolVersion).arg(c_databaseVersion).arg(QString::fromStdString(ethereum()->sealEngine()->name())).arg(ethereum()->sealEngine()->revision()).arg(dev::Version)); QSettings s("ethereum", "alethzero"); m_networkConfig = s.value("peers").toByteArray(); bytesConstRef network((byte*)m_networkConfig.data(), m_networkConfig.size()); m_webThree.reset(new WebThreeDirect(string("AlethZero/v") + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM), getDataDir(), WithExisting::Trust, {"eth"/*, "shh"*/}, p2p::NetworkPreferences(), network)); + ui->blockCount->setText(QString("PV%1.%2 D%3 %4-%5 v%6").arg(eth::c_protocolVersion).arg(eth::c_minorProtocolVersion).arg(c_databaseVersion).arg(QString::fromStdString(ethereum()->sealEngine()->name())).arg(ethereum()->sealEngine()->revision()).arg(dev::Version)); + m_httpConnector.reset(new jsonrpc::HttpServer(SensibleHttpPort, "", "", dev::SensibleHttpThreads)); auto w3ss = new OurWebThreeStubServer(*m_httpConnector, this); m_server.reset(w3ss); @@ -1124,7 +1125,7 @@ void Main::refreshMining() QString t; if (gp.first != EthashAux::NotGenerating) t = QString("DAG for #%1-#%2: %3% complete; ").arg(gp.first).arg(gp.first + ETHASH_EPOCH_LENGTH - 1).arg(gp.second); - MiningProgress p = ethereum()->miningProgress(); + WorkingProgress p = ethereum()->miningProgress(); ui->mineStatus->setText(t + (ethereum()->isMining() ? p.hashes > 0 ? QString("%1s @ %2kH/s").arg(p.ms / 1000).arg(p.ms ? p.hashes / p.ms : 0) : "Awaiting DAG" : "Not mining")); if (ethereum()->isMining() && p.hashes > 0) { @@ -1629,7 +1630,7 @@ void Main::on_transactionQueue_currentItemChanged() else s << "
Log Bloom: Uneventful
"; s << "
Gas Used: " << receipt.gasUsed() << "
"; - s << "
End State: " << receipt.stateRoot()().abridged() << "
"; + s << "
End State: " << receipt.stateRoot().abridged() << "
"; auto r = receipt.rlp(); s << "
Receipt: " << toString(RLP(r)) << "
"; s << "
Receipt-Hex: " Span(Mono) << toHex(receipt.rlp()) << "
"; @@ -1699,7 +1700,7 @@ void Main::on_blocks_currentItemChanged() auto details = ethereum()->blockChain().details(h); auto blockData = ethereum()->blockChain().block(h); auto block = RLP(blockData); - BlockInfo info(blockData); + Ethash::BlockHeader info(blockData); stringstream s; @@ -1709,21 +1710,21 @@ void Main::on_blocks_currentItemChanged() time_t rawTime = (time_t)(uint64_t)info.timestamp(); strftime(timestamp, 64, "%c", localtime(&rawTime)); s << "

" << h << "

"; - s << "

#" << info.number; + s << "

#" << info.number(); s << "   " << timestamp << "

"; - s << "
D/TD: " << info.difficulty << "/" << details.totalDifficulty << " = 2^" << log2((double)info.difficulty) << "/2^" << log2((double)details.totalDifficulty) << "
"; + s << "
D/TD: " << info.difficulty() << "/" << details.totalDifficulty << " = 2^" << log2((double)info.difficulty()) << "/2^" << log2((double)details.totalDifficulty) << "
"; s << "   Children: " << details.children.size() << ""; - s << "
Gas used/limit: " << info.gasUsed << "/" << info.gasLimit << "" << "
"; + s << "
Gas used/limit: " << info.gasUsed() << "/" << info.gasLimit() << "" << "
"; s << "
Beneficiary: " << htmlEscaped(pretty(info.coinbaseAddress())) << " " << info.coinbaseAddress() << "" << "
"; s << "
Seed hash: " << info.seedHash() << "" << "
"; - s << "
Mix hash: " << info.mixHash << "" << "
"; - s << "
Nonce: " << info.nonce << "" << "
"; - s << "
Hash w/o nonce: " << info.headerHash(WithoutProof) << "" << "
"; - s << "
Difficulty: " << info.difficulty << "" << "
"; - if (info.number) + s << "
Mix hash: " << info.mixHash() << "" << "
"; + s << "
Nonce: " << info.nonce() << "" << "
"; + s << "
Hash w/o nonce: " << info.hashWithout() << "" << "
"; + s << "
Difficulty: " << info.difficulty() << "" << "
"; + if (info.number()) { - auto e = EthashAux::eval(info); - s << "
Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")" << "
"; + auto e = EthashAux::eval(info.seedHash(), info.hashWithout(), info.nonce()); + s << "
Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty()) << " (mixhash: " << e.mixHash.abridged() << ")" << "
"; s << "
Parent: " << info.parentHash() << "" << "
"; } else @@ -1740,19 +1741,19 @@ void Main::on_blocks_currentItemChanged() s << "
Uncles: " << block[2].itemCount() << " @" << info.sha3Uncles() << "" << "
"; for (auto u: block[2]) { - BlockInfo uncle = BlockInfo::fromHeader(u.data()); + Ethash::BlockHeader uncle(u.data(), CheckNothing, h256(), HeaderData); char const* line = "
 "; s << line << "Hash: " << uncle.hash() << "" << "
"; s << line << "Parent: " << uncle.parentHash() << "" << ""; - s << line << "Number: " << uncle.number << "" << ""; + s << line << "Number: " << uncle.number() << "" << ""; s << line << "Coinbase: " << htmlEscaped(pretty(uncle.coinbaseAddress())) << " " << uncle.coinbaseAddress() << "" << ""; s << line << "Seed hash: " << uncle.seedHash() << "" << ""; - s << line << "Mix hash: " << uncle.mixHash << "" << ""; - s << line << "Nonce: " << uncle.nonce << "" << ""; + s << line << "Mix hash: " << uncle.mixHash() << "" << ""; + s << line << "Nonce: " << uncle.nonce() << "" << ""; s << line << "Hash w/o nonce: " << uncle.headerHash(WithoutProof) << "" << ""; - s << line << "Difficulty: " << uncle.difficulty << "" << ""; - auto e = EthashAux::eval(uncle); - s << line << "Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / uncle.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")" << ""; + s << line << "Difficulty: " << uncle.difficulty() << "" << ""; + auto e = EthashAux::eval(uncle.seedHash(), uncle.hashWithout(), uncle.nonce()); + s << line << "Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / uncle.difficulty()) << " (mixhash: " << e.mixHash.abridged() << ")" << ""; } if (info.parentHash()) s << "
Pre: " << BlockInfo(ethereum()->blockChain().block(info.parentHash())).stateRoot() << "" << "
"; @@ -1764,7 +1765,7 @@ void Main::on_blocks_currentItemChanged() unsigned ii = 0; for (auto const& i: block[1]) { - s << "
" << sha3(i.data()).abridged() << ": " << receipts.receipts[ii].stateRoot()() << " [" << receipts.receipts[ii].gasUsed() << " used]" << "
"; + s << "
" << sha3(i.data()).abridged() << ": " << receipts.receipts[ii].stateRoot() << " [" << receipts.receipts[ii].gasUsed() << " used]" << "
"; ++ii; } s << "
Post: " << info.stateRoot() << "" << "
"; @@ -1807,7 +1808,7 @@ void Main::on_blocks_currentItemChanged() else s << "
Log Bloom: Uneventful
"; s << "
Gas Used: " << receipt.gasUsed() << "
"; - s << "
End State: " << receipt.stateRoot()().abridged() << "
"; + s << "
End State: " << receipt.stateRoot().abridged() << "
"; auto r = receipt.rlp(); s << "
Receipt: " << toString(RLP(r)) << "
"; s << "
Receipt-Hex: " Span(Mono) << toHex(receipt.rlp()) << "
"; diff --git a/alethzero/MiningView.cpp b/alethzero/MiningView.cpp index e020408ea..fb9de0346 100644 --- a/alethzero/MiningView.cpp +++ b/alethzero/MiningView.cpp @@ -36,7 +36,7 @@ using namespace dev::eth; // types using dev::eth::MineInfo; -using dev::eth::MiningProgress; +using dev::eth::WorkingProgress; // functions using dev::toString; @@ -50,7 +50,7 @@ MiningView::MiningView(QWidget* _p): QWidget(_p) { } -void MiningView::appendStats(list const& _i, MiningProgress const& _p) +void MiningView::appendStats(list const& _i, WorkingProgress const& _p) { (void)_p; if (_i.empty()) diff --git a/alethzero/MiningView.h b/alethzero/MiningView.h index 65b9f2ec9..ae81a7cc4 100644 --- a/alethzero/MiningView.h +++ b/alethzero/MiningView.h @@ -42,14 +42,14 @@ class MiningView: public QWidget public: MiningView(QWidget* _p = nullptr); - void appendStats(std::list const& _l, dev::eth::MiningProgress const& _p); + void appendStats(std::list const& _l, dev::eth::WorkingProgress const& _p); void resetStats(); protected: virtual void paintEvent(QPaintEvent*); private: - dev::eth::MiningProgress m_progress; + dev::eth::WorkingProgress m_progress; unsigned m_duration = 300; std::vector m_values; std::vector m_bests; diff --git a/exp/CMakeLists.txt b/exp/CMakeLists.txt index b9f477385..0e19ac84d 100644 --- a/exp/CMakeLists.txt +++ b/exp/CMakeLists.txt @@ -21,10 +21,10 @@ if (READLINE_FOUND) endif() if (JSONRPC) -# target_link_libraries(${EXECUTABLE} web3jsonrpc) + target_link_libraries(${EXECUTABLE} web3jsonrpc) endif() -#target_link_libraries(${EXECUTABLE} webthree) +target_link_libraries(${EXECUTABLE} webthree) target_link_libraries(${EXECUTABLE} ethereum) target_link_libraries(${EXECUTABLE} p2p) if (ETHASHCL) diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index b696c77bd..03ab1b46a 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -137,7 +137,6 @@ BlockChain::BlockChain(bytes const& _genesisBlock, std::unordered_map #include "BlockChainLoader.h" #include "StateLoader.h" #include "Common.h" @@ -35,7 +36,7 @@ BlockChainLoader::BlockChainLoader(Json::Value const& _json) m_state = sl.state(); // load genesisBlock - m_bc.reset(new BlockChain(fromHex(_json["genesisRLP"].asString()), m_dir.path(), WithExisting::Kill)); + m_bc.reset(new FullBlockChain(fromHex(_json["genesisRLP"].asString()), sl.stateDefinition(), m_dir.path(), WithExisting::Kill)); assert(m_state.rootHash() == m_bc->info().stateRoot()); // load blocks diff --git a/libtestutils/StateLoader.cpp b/libtestutils/StateLoader.cpp index 235f1c573..cd5c37e96 100644 --- a/libtestutils/StateLoader.cpp +++ b/libtestutils/StateLoader.cpp @@ -27,7 +27,7 @@ using namespace dev::eth; using namespace dev::test; StateLoader::StateLoader(Json::Value const& _json, std::string const& _dbPath): - m_state(State::openDB(_dbPath, WithExisting::Kill), BaseState::Empty) + m_state(State::openDB(_dbPath, h256{}, WithExisting::Kill), BaseState::Empty) { for (string const& name: _json.getMemberNames()) { diff --git a/libtestutils/StateLoader.h b/libtestutils/StateLoader.h index 47eb26900..c66f53148 100644 --- a/libtestutils/StateLoader.h +++ b/libtestutils/StateLoader.h @@ -24,6 +24,7 @@ #include #include #include +#include namespace dev { @@ -38,6 +39,7 @@ class StateLoader public: StateLoader(Json::Value const& _json, std::string const& _dbPath); eth::State const& state() const { return m_state; } + eth::StateDefinition const& stateDefinition() const { return m_state.m_cache; } private: eth::State m_state; diff --git a/libweb3jsonrpc/JsonHelper.cpp b/libweb3jsonrpc/JsonHelper.cpp index fae12708c..54fde52e8 100644 --- a/libweb3jsonrpc/JsonHelper.cpp +++ b/libweb3jsonrpc/JsonHelper.cpp @@ -93,10 +93,10 @@ Json::Value toJson(dev::eth::BlockInfo const& _bi) res["miner"] = toJS(_bi.coinbaseAddress()); res["stateRoot"] = toJS(_bi.stateRoot()); res["transactionsRoot"] = toJS(_bi.transactionsRoot()); - res["difficulty"] = toJS(_bi.difficulty); + res["difficulty"] = toJS(_bi.difficulty()); res["number"] = toJS(_bi.number()); - res["gasUsed"] = toJS(_bi.gasUsed); - res["gasLimit"] = toJS(_bi.gasLimit); + res["gasUsed"] = toJS(_bi.gasUsed()); + res["gasLimit"] = toJS(_bi.gasLimit()); res["timestamp"] = toJS(_bi.timestamp()); res["extraData"] = toJS(_bi.extraData()); res["logsBloom"] = toJS(_bi.logBloom()); @@ -176,7 +176,7 @@ Json::Value toJson(dev::eth::TransactionSkeleton const& _t) Json::Value toJson(dev::eth::TransactionReceipt const& _t) { Json::Value res; - res["stateRoot"] = toJS(_t.stateRoot()()); + res["stateRoot"] = toJS(_t.stateRoot()); res["gasUsed"] = toJS(_t.gasUsed()); res["bloom"] = toJS(_t.bloom()); res["log"] = dev::toJson(_t.log()); diff --git a/libweb3jsonrpc/WebThreeStubServer.cpp b/libweb3jsonrpc/WebThreeStubServer.cpp index 3aff9cf23..bf49d3322 100644 --- a/libweb3jsonrpc/WebThreeStubServer.cpp +++ b/libweb3jsonrpc/WebThreeStubServer.cpp @@ -106,7 +106,7 @@ bool WebThreeStubServer::admin_eth_setBidPrice(std::string const& _wei, std::str return true; } -dev::eth::CanonBlockChain const& WebThreeStubServer::bc() const +dev::eth::BlockChain const& WebThreeStubServer::bc() const { return m_web3.ethereum()->blockChain(); } diff --git a/libweb3jsonrpc/WebThreeStubServer.h b/libweb3jsonrpc/WebThreeStubServer.h index 4d545c90e..2860f852b 100644 --- a/libweb3jsonrpc/WebThreeStubServer.h +++ b/libweb3jsonrpc/WebThreeStubServer.h @@ -34,7 +34,7 @@ namespace eth { class KeyManager; class TrivialGasPricer; -class CanonBlockChain; +class BlockChain; class BlockQueue; } @@ -89,7 +89,7 @@ private: private: h256 blockHash(std::string const& _blockNumberOrHash) const; - dev::eth::CanonBlockChain const& bc() const; + dev::eth::BlockChain const& bc() const; dev::eth::BlockQueue const& bq() const; dev::WebThreeDirect& m_web3; diff --git a/libwebthree/WebThree.cpp b/libwebthree/WebThree.cpp index 3c1dea40f..7889b5935 100644 --- a/libwebthree/WebThree.cpp +++ b/libwebthree/WebThree.cpp @@ -52,7 +52,7 @@ WebThreeDirect::WebThreeDirect( Defaults::setDBPath(_dbPath); if (_interfaces.count("eth")) { - m_ethereum.reset(new eth::Client(&m_net, _dbPath, _we, 0)); + m_ethereum.reset(new eth::EthashClient(&m_net, shared_ptr(), _dbPath, _we, 0)); m_ethereum->setExtraData(rlpList(0, _clientVersion, m_net.id())); } diff --git a/mix/ClientModel.cpp b/mix/ClientModel.cpp index 90ff19feb..5c5f2f4cd 100644 --- a/mix/ClientModel.cpp +++ b/mix/ClientModel.cpp @@ -686,9 +686,9 @@ RecordLogEntry* ClientModel::lastBlock() const { eth::BlockInfo blockInfo = m_client->blockInfo(); stringstream strGas; - strGas << blockInfo.gasUsed; + strGas << blockInfo.gasUsed(); stringstream strNumber; - strNumber << blockInfo.number; + strNumber << blockInfo.number(); RecordLogEntry* record = new RecordLogEntry(0, QString::fromStdString(strNumber.str()), tr(" - Block - "), tr("Hash: ") + QString(QString::fromStdString(dev::toHex(blockInfo.hash().ref()))), QString(), QString(), QString(), false, RecordLogEntry::RecordType::Block, QString::fromStdString(strGas.str()), QString(), tr("Block"), QVariantMap(), QVariantMap(), QVariantList()); QQmlEngine::setObjectOwnership(record, QQmlEngine::JavaScriptOwnership); return record; diff --git a/mix/MixClient.cpp b/mix/MixClient.cpp index ea4686601..eef6ad6ec 100644 --- a/mix/MixClient.cpp +++ b/mix/MixClient.cpp @@ -24,12 +24,13 @@ #include #include #include +#include +#include #include #include #include #include #include -#include #include #include "Exceptions.h" using namespace std; @@ -45,22 +46,20 @@ u256 const c_mixGenesisDifficulty = 131072; //TODO: make it lower for Mix someho namespace { +} -struct MixPow //dummy POW +MixBlockChain::MixBlockChain(std::string const& _path, h256 _stateRoot): + FullBlockChain(createGenesisBlock(_stateRoot), std::unordered_map(), _path, WithExisting::Kill) { - typedef int Solution; - static bool verify(BlockInfo const&) { return true; } -}; - } bytes MixBlockChain::createGenesisBlock(h256 _stateRoot) { RLPStream block(3); - block.appendList(15) + block.appendList(13) << h256() << EmptyListSHA3 << h160() << _stateRoot << EmptyTrie << EmptyTrie << LogBloom() << c_mixGenesisDifficulty << 0 << c_genesisGasLimit << 0 << (unsigned)0 - << std::string() << h256() << h64(u64(42)); + << std::string(); block.appendRaw(RLPEmptyList); block.appendRaw(RLPEmptyList); return block.out(); @@ -78,7 +77,6 @@ MixClient::~MixClient() void MixClient::resetState(std::unordered_map const& _accounts, Secret const& _miner) { - WriteGuard l(x_state); Guard fl(x_filtersWatches); @@ -91,12 +89,13 @@ void MixClient::resetState(std::unordered_map const& _accounts SecureTrieDB accountState(&m_stateDB); accountState.init(); - dev::eth::commit(_accounts, static_cast(m_stateDB), accountState); + dev::eth::commit(_accounts, accountState); h256 stateRoot = accountState.root(); m_bc.reset(); m_bc.reset(new MixBlockChain(m_dbPath, stateRoot)); - m_state = eth::State(m_stateDB, BaseState::PreExisting, KeyPair(_miner).address()); - m_state.sync(bc()); + State s(m_stateDB, BaseState::PreExisting, KeyPair(_miner).address()); + s.sync(bc()); + m_state = s; m_startState = m_state; WriteGuard lx(x_executions); m_executions.clear(); @@ -275,11 +274,14 @@ void MixClient::mine() { WriteGuard l(x_state); m_state.commitToMine(bc()); - m_state.completeMine(0); - bc().import(m_state.blockData(), m_state.db(), ImportRequirements::Default & ~ImportRequirements::ValidNonce); + + NoProof::BlockHeader h(m_state.info()); + RLPStream header; + h.streamRLP(header); + m_state.sealBlock(header.out()); + bc().import(m_state.blockData(), m_state.db(), ImportRequirements::Default & ~ImportRequirements::ValidSeal); m_state.sync(bc()); m_startState = m_state; - h256Set changed { dev::eth::PendingChangedFilter, dev::eth::ChainChangedFilter }; } ExecutionResult MixClient::lastExecution() const @@ -383,9 +385,9 @@ uint64_t MixClient::hashrate() const return 0; } -eth::MiningProgress MixClient::miningProgress() const +eth::WorkingProgress MixClient::miningProgress() const { - return eth::MiningProgress(); + return eth::WorkingProgress(); } } diff --git a/mix/MixClient.h b/mix/MixClient.h index f9574e90a..279692de5 100644 --- a/mix/MixClient.h +++ b/mix/MixClient.h @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -32,13 +33,40 @@ namespace dev { + namespace mix { -class MixBlockChain: public dev::eth::BlockChain +class NoProof +{ + class BlockHeaderRaw: public dev::eth::BlockInfo + { + public: + static const unsigned SealFields = 0; + + protected: + BlockHeaderRaw() = default; + BlockHeaderRaw(BlockInfo const& _bi): BlockInfo(_bi) {} + + void populateFromHeader(RLP const& _header, dev::eth::Strictness _s) { (void) _header; (void) _s; } + void populateFromParent(BlockHeaderRaw const& _parent) { (void)_parent; } + void streamRLPFields(RLPStream& _s) const { (void) _s; } + }; + +public: + + static std::string name() { return "NoProof"; } + static unsigned revision() { return 0; } + using BlockHeader = dev::eth::BlockHeaderPolished; + +private: + static AddressHash s_authorities; +}; + +class MixBlockChain: public dev::eth::FullBlockChain { public: - MixBlockChain(std::string const& _path, h256 _stateRoot): BlockChain(createGenesisBlock(_stateRoot), _path, WithExisting::Kill) {} + MixBlockChain(std::string const& _path, h256 _stateRoot); static bytes createGenesisBlock(h256 _stateRoot); }; @@ -67,9 +95,7 @@ public: void stopMining() override; bool isMining() const override; uint64_t hashrate() const override; - eth::MiningProgress miningProgress() const override; - eth::ProofOfWork::WorkPackage getWork() override { return eth::ProofOfWork::WorkPackage(); } - bool submitWork(eth::ProofOfWork::Solution const&) override { return false; } + eth::WorkingProgress miningProgress() const override; virtual void flushTransactions() override {} /// @returns the last mined block information