From 659858f6c0045f76507916b8d5d06fe84663eab2 Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 16 Jul 2015 11:43:23 +0200 Subject: [PATCH 1/4] fixed build --- evmjit/libevmjit-cpp/JitVM.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/evmjit/libevmjit-cpp/JitVM.cpp b/evmjit/libevmjit-cpp/JitVM.cpp index 4e1fb66ea..d96da87c1 100644 --- a/evmjit/libevmjit-cpp/JitVM.cpp +++ b/evmjit/libevmjit-cpp/JitVM.cpp @@ -23,8 +23,8 @@ bytesConstRef JitVM::execImpl(u256& io_gas, ExtVMFace& _ext, OnOpFunc const& _on // TODO: Rejecting transactions with gas limit > 2^63 can be used by attacker to take JIT out of scope rejected |= io_gas > std::numeric_limits::max(); // Do not accept requests with gas > 2^63 (int64 max) rejected |= _ext.gasPrice > std::numeric_limits::max(); - rejected |= _ext.currentBlock.number > std::numeric_limits::max(); - rejected |= _ext.currentBlock.timestamp() > std::numeric_limits::max(); + rejected |= _ext.currentBlock.number() > std::numeric_limits::max(); + rejected |= _ext.currentBlock.timestamp() > std::numeric_limits::max(); if (rejected) { @@ -42,10 +42,10 @@ bytesConstRef JitVM::execImpl(u256& io_gas, ExtVMFace& _ext, OnOpFunc const& _on m_data.origin = eth2jit(fromAddress(_ext.origin)); m_data.callValue = eth2jit(_ext.value); m_data.coinBase = eth2jit(fromAddress(_ext.currentBlock.coinbaseAddress())); - m_data.difficulty = eth2jit(_ext.currentBlock.difficulty); - m_data.gasLimit = eth2jit(_ext.currentBlock.gasLimit); - m_data.number = static_cast(_ext.currentBlock.number); - m_data.timestamp() = static_cast(_ext.currentBlock.timestamp()); + m_data.difficulty = eth2jit(_ext.currentBlock.difficulty()); + m_data.gasLimit = eth2jit(_ext.currentBlock.gasLimit()); + m_data.number = static_cast(_ext.currentBlock.number()); + m_data.timestamp = static_cast(_ext.currentBlock.timestamp()); m_data.code = _ext.code.data(); m_data.codeSize = _ext.code.size(); m_data.codeHash = eth2jit(_ext.codeHash); From 0431a97ecbf3588bbefa9c6c651658dfb0bc0636 Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 16 Jul 2015 16:45:23 +0200 Subject: [PATCH 2/4] 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 From 907ea3c8002545e4a9ccdee0f6d588dcbd2e9f85 Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 16 Jul 2015 18:11:08 +0200 Subject: [PATCH 3/4] started tests refactoring --- libethcore/Common.h | 3 ++- libethereum/BlockChain.cpp | 2 +- libethereum/BlockChain.h | 9 +++++---- libethereum/BlockQueue.cpp | 2 +- libethereum/Client.cpp | 3 +-- mix/MixClient.cpp | 2 +- test/TestHelper.cpp | 2 +- test/libethcore/dagger.cpp | 4 ++-- test/libethereum/ClientBase.cpp | 14 +++++++------- test/libethereum/genesis.cpp | 6 +++--- test/libethereum/stateOriginal.cpp | 5 +++-- 11 files changed, 27 insertions(+), 25 deletions(-) diff --git a/libethcore/Common.h b/libethcore/Common.h index 5c0a0cc79..116e1d5ed 100644 --- a/libethcore/Common.h +++ b/libethcore/Common.h @@ -130,9 +130,10 @@ struct ImportRequirements TransactionBasic = 8, ///< Check the basic structure of the transactions. UncleSeals = 16, ///< Check the basic structure of the uncles. TransactionSignatures = 32, ///< Check the basic structure of the transactions. + Parent = 64, ///< Check parent block header CheckUncles = UncleBasic | UncleSeals, ///< Check uncle seals CheckTransactions = TransactionBasic | TransactionSignatures, ///< Check transaction signatures - Default = ValidSeal | DontHave | CheckUncles | CheckTransactions, + Everything = ValidSeal | DontHave | CheckUncles | CheckTransactions | Parent, None = 0 }; }; diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 03ab1b46a..8a654fa51 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -355,7 +355,7 @@ tuple BlockChain::sync(BlockQueue& _bq, OverlayDB c // Nonce & uncle nonces already verified in verification thread at this point. ImportRoute r; DEV_TIMED_ABOVE("Block import " + toString(block.verified.info.number()), 500) - r = import(block.verified, _stateDB, ImportRequirements::Default & ~ImportRequirements::ValidSeal & ~ImportRequirements::CheckUncles); + r = import(block.verified, _stateDB, ImportRequirements::Everything & ~ImportRequirements::ValidSeal & ~ImportRequirements::CheckUncles); fresh += r.liveBlocks; dead += r.deadBlocks; goodTransactions += r.goodTranactions; diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index 3ff85c8a6..811da8609 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -118,12 +118,12 @@ public: /// Attempt to import the given block directly into the CanonBlockChain and sync with the state DB. /// @returns the block hashes of any blocks that came into/went out of the canonical block chain. - std::pair attemptImport(bytes const& _block, OverlayDB const& _stateDB, ImportRequirements::value _ir = ImportRequirements::Default) noexcept; + std::pair attemptImport(bytes const& _block, OverlayDB const& _stateDB, ImportRequirements::value _ir = ImportRequirements::Everything) noexcept; /// Import block into disk-backed DB /// @returns the block hashes of any blocks that came into/went out of the canonical block chain. - ImportRoute import(bytes const& _block, OverlayDB const& _stateDB, ImportRequirements::value _ir = ImportRequirements::Default); - ImportRoute import(VerifiedBlockRef const& _block, OverlayDB const& _db, ImportRequirements::value _ir = ImportRequirements::Default); + ImportRoute import(bytes const& _block, OverlayDB const& _stateDB, ImportRequirements::value _ir = ImportRequirements::Everything); + ImportRoute import(VerifiedBlockRef const& _block, OverlayDB const& _db, ImportRequirements::value _ir = ImportRequirements::Everything); /// Returns true if the given block is known (though not necessarily a part of the canon chain). bool isKnown(h256 const& _hash) const; @@ -391,7 +391,8 @@ public: { BlockHeader h(_block, (_ir & ImportRequirements::ValidSeal) ? Strictness::CheckEverything : Strictness::QuickNonce); h.verifyInternals(_block); - h.verifyParent(header(h.parentHash())); + if ((_ir & ImportRequirements::Parent) != 0) + h.verifyParent(header(h.parentHash())); res.info = static_cast(h); } catch (Exception& ex) diff --git a/libethereum/BlockQueue.cpp b/libethereum/BlockQueue.cpp index c9ee4c1cf..d0ca34b1c 100644 --- a/libethereum/BlockQueue.cpp +++ b/libethereum/BlockQueue.cpp @@ -110,7 +110,7 @@ void BlockQueue::verifierBody() swap(work.block, res.blockData); try { - res.verified = m_bc->verifyBlock(&res.blockData, m_onBad, CheckEverything); + res.verified = m_bc->verifyBlock(&res.blockData, m_onBad, ImportRequirements::Everything & ~ImportRequirements::Parent); } catch (...) { diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 357926d03..d43f240b7 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -84,10 +84,9 @@ void Client::init(p2p::Host* _extNet, std::string const& _dbPath, WithExisting _ // TODO: consider returning the upgrade mechanism here. will delaying the opening of the blockchain database // until after the construction. m_stateDB = State::openDB(_dbPath, bc().genesisHash(), _forceAction); - m_preMine = State(m_stateDB); - m_postMine = State(m_stateDB); // LAZY. TODO: move genesis state construction/commiting to stateDB openning and have this just take the root from the genesis block. m_preMine = bc().genesisState(m_stateDB); + m_postMine = m_preMine; m_bq.setChain(bc()); diff --git a/mix/MixClient.cpp b/mix/MixClient.cpp index eef6ad6ec..67f2a2507 100644 --- a/mix/MixClient.cpp +++ b/mix/MixClient.cpp @@ -279,7 +279,7 @@ void MixClient::mine() RLPStream header; h.streamRLP(header); m_state.sealBlock(header.out()); - bc().import(m_state.blockData(), m_state.db(), ImportRequirements::Default & ~ImportRequirements::ValidSeal); + bc().import(m_state.blockData(), m_state.db(), ImportRequirements::Everything & ~ImportRequirements::ValidSeal); m_state.sync(bc()); m_startState = m_state; } diff --git a/test/TestHelper.cpp b/test/TestHelper.cpp index bae980a7e..30f323369 100644 --- a/test/TestHelper.cpp +++ b/test/TestHelper.cpp @@ -63,7 +63,7 @@ void connectClients(Client& c1, Client& c2) void mine(State& s, BlockChain const& _bc) { s.commitToMine(_bc); - GenericFarm f; + GenericFarm f; bool completed = false; f.onSolutionFound([&](ProofOfWork::Solution sol) { diff --git a/test/libethcore/dagger.cpp b/test/libethcore/dagger.cpp index 061b5ae79..8d4cba933 100644 --- a/test/libethcore/dagger.cpp +++ b/test/libethcore/dagger.cpp @@ -54,10 +54,10 @@ BOOST_AUTO_TEST_CASE(basic_test) cnote << i.first; js::mObject& o = i.second.get_obj(); vector> ss; - BlockInfo header = BlockInfo::fromHeader(fromHex(o["header"].get_str()), CheckNothing); + Ethash::BlockHeader header(fromHex(o["header"].get_str()), CheckNothing); h256 headerHash(o["header_hash"].get_str()); Nonce nonce(o["nonce"].get_str()); - BOOST_REQUIRE_EQUAL(headerHash, header.headerHash(WithoutNonce)); + BOOST_REQUIRE_EQUAL(headerHash, header.hashWithout()); BOOST_REQUIRE_EQUAL(nonce, header.nonce); unsigned cacheSize(o["cache_size"].get_int()); diff --git a/test/libethereum/ClientBase.cpp b/test/libethereum/ClientBase.cpp index 7dbc5c91e..a426ff53f 100644 --- a/test/libethereum/ClientBase.cpp +++ b/test/libethereum/ClientBase.cpp @@ -119,21 +119,21 @@ BOOST_AUTO_TEST_CASE(blocks) h256 expectedBlockInfoUncldeHash = h256(fromHex(_b["uncleHash"].asString())); ETH_CHECK_EQUAL(expectedBlockInfoBloom, _blockInfo.logBloom()); ETH_CHECK_EQUAL(expectedBlockInfoCoinbase, _blockInfo.coinbaseAddress()); - ETH_CHECK_EQUAL(expectedBlockInfoDifficulty, _blockInfo.difficulty); + ETH_CHECK_EQUAL(expectedBlockInfoDifficulty, _blockInfo.difficulty()); ETH_CHECK_EQUAL_COLLECTIONS( expectedBlockInfoExtraData.begin(), expectedBlockInfoExtraData.end(), _blockInfo.extraData().begin(), _blockInfo.extraData().end() ); - ETH_CHECK_EQUAL(expectedBlockInfoGasLimit, _blockInfo.gasLimit); - ETH_CHECK_EQUAL(expectedBlockInfoGasUsed, _blockInfo.gasUsed); + ETH_CHECK_EQUAL(expectedBlockInfoGasLimit, _blockInfo.gasLimit()); + ETH_CHECK_EQUAL(expectedBlockInfoGasUsed, _blockInfo.gasUsed()); ETH_CHECK_EQUAL(expectedBlockInfoHash, _blockInfo.hash()); - ETH_CHECK_EQUAL(expectedBlockInfoMixHash, _blockInfo.mixHash); - ETH_CHECK_EQUAL(expectedBlockInfoNonce, _blockInfo.nonce); - ETH_CHECK_EQUAL(expectedBlockInfoNumber, _blockInfo.number); + ETH_CHECK_EQUAL(expectedBlockInfoMixHash, _blockInfo.mixHash()); + ETH_CHECK_EQUAL(expectedBlockInfoNonce, _blockInfo.nonce()); + ETH_CHECK_EQUAL(expectedBlockInfoNumber, _blockInfo.number()); ETH_CHECK_EQUAL(expectedBlockInfoParentHash, _blockInfo.parentHash()); - ETH_CHECK_EQUAL(expectedBlockInfoReceiptsRoot, _blockInfo..receiptsRoot()); + ETH_CHECK_EQUAL(expectedBlockInfoReceiptsRoot, _blockInfo.receiptsRoot()); ETH_CHECK_EQUAL(expectedBlockInfoTimestamp, _blockInfo.timestamp()); ETH_CHECK_EQUAL(expectedBlockInfoTransactionsRoot, _blockInfo.transactionsRoot()); ETH_CHECK_EQUAL(expectedBlockInfoUncldeHash, _blockInfo.sha3Uncles()); diff --git a/test/libethereum/genesis.cpp b/test/libethereum/genesis.cpp index 2d5a2faa6..39997572f 100644 --- a/test/libethereum/genesis.cpp +++ b/test/libethereum/genesis.cpp @@ -60,9 +60,9 @@ BOOST_AUTO_TEST_CASE(genesis_tests) js::mObject o = v.get_obj(); - BOOST_CHECK_EQUAL(CanonBlockChain::genesis().stateRoot(), h256(o["genesis_state_root"].get_str())); - BOOST_CHECK_EQUAL(toHex(CanonBlockChain::createGenesisBlock()), toHex(fromHex(o["genesis_rlp_hex"].get_str()))); - BOOST_CHECK_EQUAL(BlockInfo::headerHash(CanonBlockChain::createGenesisBlock()), h256(o["genesis_hash"].get_str())); + BOOST_CHECK_EQUAL(CanonBlockChain::genesis().stateRoot(), h256(o["genesis_state_root"].get_str())); + BOOST_CHECK_EQUAL(toHex(CanonBlockChain::createGenesisBlock()), toHex(fromHex(o["genesis_rlp_hex"].get_str()))); + BOOST_CHECK_EQUAL(Ethash::BlockHeader(CanonBlockChain::createGenesisBlock()).hashWithout(), h256(o["genesis_hash"].get_str())); } BOOST_AUTO_TEST_SUITE_END() diff --git a/test/libethereum/stateOriginal.cpp b/test/libethereum/stateOriginal.cpp index e3f8ac29f..163c89e50 100644 --- a/test/libethereum/stateOriginal.cpp +++ b/test/libethereum/stateOriginal.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -59,8 +60,8 @@ BOOST_AUTO_TEST_CASE(Complex) Defaults::setDBPath(boost::filesystem::temp_directory_path().string() + "/" + toString(chrono::system_clock::now().time_since_epoch().count())); - OverlayDB stateDB = State::openDB(); - CanonBlockChain bc; + OverlayDB stateDB = State::openDB(h256()); + CanonBlockChain bc; cout << bc; State s = bc.genesisState(stateDB); From 9d8f9e3517f8e96ad10286a8ba7cf773e04bf39a Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 16 Jul 2015 20:53:58 +0200 Subject: [PATCH 4/4] eth working --- eth/main.cpp | 2 +- ethminer/MinerAux.h | 26 ++++++++++++-------------- libethcore/BlockInfo.h | 1 + libethereum/Client.h | 6 +++++- test/TestHelper.cpp | 17 ++++++++++++----- test/libethcore/dagger.cpp | 6 +++--- test/libethereum/ClientBase.cpp | 4 ++-- test/libethereum/gaspricer.cpp | 3 ++- test/libevm/vm.cpp | 10 +++++----- 9 files changed, 43 insertions(+), 32 deletions(-) diff --git a/eth/main.cpp b/eth/main.cpp index 8bbec9f00..4a8501a97 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -1311,7 +1311,7 @@ int main(int argc, char** argv) { try { - CanonBlockChain::setGenesisNonce(Nonce(argv[++i])); + CanonBlockChain::setGenesisNonce(Nonce(argv[++i])); } catch (...) { diff --git a/ethminer/MinerAux.h b/ethminer/MinerAux.h index 0d227b1ef..01083012f 100644 --- a/ethminer/MinerAux.h +++ b/ethminer/MinerAux.h @@ -397,17 +397,16 @@ public: private: void doInitDAG(unsigned _n) { - BlockInfo bi; - bi.number() = _n; - cout << "Initializing DAG for epoch beginning #" << (bi.number() / 30000 * 30000) << " (seedhash " << bi.proofCache().abridged() << "). This will take a while." << endl; - Ethash::prep(bi); + h256 seedHash = EthashAux::seedHash(_n); + cout << "Initializing DAG for epoch beginning #" << (_n / 30000 * 30000) << " (seedhash " << seedHash.abridged() << "). This will take a while." << endl; + EthashAux::full(seedHash, true); exit(0); } void doBenchmark(MinerType _m, bool _phoneHome, unsigned _warmupDuration = 15, unsigned _trialDuration = 3, unsigned _trials = 5) { - BlockInfo genesis; - genesis.difficulty = 1 << 18; + Ethash::BlockHeader genesis; + genesis.setDifficulty(1 << 18); cdebug << genesis.boundary(); GenericFarm f; @@ -417,17 +416,16 @@ private: cout << "Benchmarking on platform: " << platformInfo << endl; cout << "Preparing DAG..." << endl; - Ethash::prep(genesis); + genesis.prep(); - genesis.difficulty = u256(1) << 63; - genesis.noteDirty(); + genesis.setDifficulty(u256(1) << 63); f.setWork(genesis); if (_m == MinerType::CPU) - f.startCPU(); + f.start("cpu"); else if (_m == MinerType::GPU) - f.startGPU(); + f.start("opencl"); - map results; + map results; uint64_t mean = 0; uint64_t innerMean = 0; for (unsigned i = 0; i <= _trials; ++i) @@ -488,9 +486,9 @@ private: Farm rpc(client); GenericFarm f; if (_m == MinerType::CPU) - f.startCPU(); + f.start("cpu"); else if (_m == MinerType::GPU) - f.startGPU(); + f.start("opencl"); EthashProofOfWork::WorkPackage current; EthashAux::FullType dag; diff --git a/libethcore/BlockInfo.h b/libethcore/BlockInfo.h index 67a5397f4..c310b3dd9 100644 --- a/libethcore/BlockInfo.h +++ b/libethcore/BlockInfo.h @@ -128,6 +128,7 @@ public: void setGasUsed(u256 const& _v) { m_gasUsed = _v; noteDirty(); } void setExtraData(bytes const& _v) { m_extraData = _v; noteDirty(); } void setLogBloom(LogBloom const& _v) { m_logBloom = _v; noteDirty(); } + void setDifficulty(u256 const& _v) { m_difficulty = _v; noteDirty(); } Address const& coinbaseAddress() const { return m_coinbaseAddress; } h256 const& stateRoot() const { return m_stateRoot; } diff --git a/libethereum/Client.h b/libethereum/Client.h index 73609bd71..4523d324b 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -77,7 +77,7 @@ std::ostream& operator<<(std::ostream& _out, ActivityReport const& _r); * @brief Main API hub for interfacing with Ethereum. * Not to be used directly - subclass. */ -class Client: public ClientBase, Worker +class Client: public ClientBase, protected Worker { public: /// New-style Constructor. @@ -342,6 +342,8 @@ public: init(_host, _dbPath, _forceAction, _networkId); } + virtual ~SpecialisedClient() { stopWorking(); } + /// Get the object representing the current canonical blockchain. CanonBlockChain const& blockChain() const { return m_bc; } @@ -365,6 +367,8 @@ public: u256 _networkId = 0 ): SpecialisedClient(_host, _gpForAdoption, _dbPath, _forceAction, _networkId) {} + virtual ~EthashClient() { stopWorking(); } + /// Update to the latest transactions and get hash of the current block to be mined minus the /// nonce (the 'work hash') and the difficulty to be met. virtual std::tuple getEthashWork() override; diff --git a/test/TestHelper.cpp b/test/TestHelper.cpp index 30f323369..c29788b9f 100644 --- a/test/TestHelper.cpp +++ b/test/TestHelper.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -63,11 +64,17 @@ void connectClients(Client& c1, Client& c2) void mine(State& s, BlockChain const& _bc) { s.commitToMine(_bc); - GenericFarm f; + GenericFarm f; bool completed = false; - f.onSolutionFound([&](ProofOfWork::Solution sol) + Ethash::BlockHeader header(s.info); + f.onSolutionFound([&](EthashProofOfWork::Solution sol) { - return completed = s.completeMine(sol); + header.m_mixHash = sol.mixHash; + header.m_nonce = sol.nonce; + RLPStream ret; + header.streamRLP(ret); + s.sealBlock(ret); + return true; }); f.setWork(s.info()); f.startCPU(); @@ -77,9 +84,9 @@ void mine(State& s, BlockChain const& _bc) void mine(BlockInfo& _bi) { - GenericFarm f; + GenericFarm f; bool completed = false; - f.onSolutionFound([&](ProofOfWork::Solution sol) + f.onSolutionFound([&](EthashProofOfWork::Solution sol) { _bi.proof = sol; return completed = true; diff --git a/test/libethcore/dagger.cpp b/test/libethcore/dagger.cpp index 8d4cba933..c3cd75b0d 100644 --- a/test/libethcore/dagger.cpp +++ b/test/libethcore/dagger.cpp @@ -58,7 +58,7 @@ BOOST_AUTO_TEST_CASE(basic_test) h256 headerHash(o["header_hash"].get_str()); Nonce nonce(o["nonce"].get_str()); BOOST_REQUIRE_EQUAL(headerHash, header.hashWithout()); - BOOST_REQUIRE_EQUAL(nonce, header.nonce); + BOOST_REQUIRE_EQUAL(nonce, header.nonce()); unsigned cacheSize(o["cache_size"].get_int()); h256 cacheHash(o["cache_hash"].get_str()); @@ -73,9 +73,9 @@ BOOST_AUTO_TEST_CASE(basic_test) #endif h256 result(o["result"].get_str()); - EthashProofOfWork::Result r = EthashAux::eval(header); + EthashProofOfWork::Result r = EthashAux::eval(header.seedHash(), header.hashWithout(), header.nonce()); BOOST_REQUIRE_EQUAL(r.value, result); - BOOST_REQUIRE_EQUAL(r.mixHash, header.mixHash); + BOOST_REQUIRE_EQUAL(r.mixHash, header.mixHash()); } } diff --git a/test/libethereum/ClientBase.cpp b/test/libethereum/ClientBase.cpp index a426ff53f..f9d83e9c6 100644 --- a/test/libethereum/ClientBase.cpp +++ b/test/libethereum/ClientBase.cpp @@ -100,7 +100,7 @@ BOOST_AUTO_TEST_CASE(blocks) ETH_CHECK_EQUAL(expectedHashFromNumber, hashFromNumber); // blockInfo - auto compareBlockInfos = [](Json::Value const& _b, BlockInfo _blockInfo) -> void + auto compareBlockInfos = [](Json::Value const& _b, Ethash::BlockHeader _blockInfo) -> void { LogBloom expectedBlockInfoBloom = LogBloom(fromHex(_b["bloom"].asString())); Address expectedBlockInfoCoinbase = Address(fromHex(_b["coinbase"].asString())); @@ -139,7 +139,7 @@ BOOST_AUTO_TEST_CASE(blocks) ETH_CHECK_EQUAL(expectedBlockInfoUncldeHash, _blockInfo.sha3Uncles()); }; - BlockInfo blockInfo = _client.blockInfo(blockHash); + Ethash::BlockHeader blockInfo(_client.bc().headerData(blockHash)); compareBlockInfos(blockHeader, blockInfo); // blockDetails diff --git a/test/libethereum/gaspricer.cpp b/test/libethereum/gaspricer.cpp index ce49a4a20..050ab2d25 100644 --- a/test/libethereum/gaspricer.cpp +++ b/test/libethereum/gaspricer.cpp @@ -20,6 +20,7 @@ */ #include +#include #include #include #include @@ -54,7 +55,7 @@ BOOST_AUTO_TEST_CASE(trivialGasPricer) std::shared_ptr gp(new TrivialGasPricer); BOOST_CHECK_EQUAL(gp->ask(State()), 10 * szabo); BOOST_CHECK_EQUAL(gp->bid(), 10 * szabo); - gp->update(BlockChain(bytes(), TransientDirectory().path(), WithExisting::Kill)); + gp->update(FullBlockChain(bytes(), StateDefinition(), TransientDirectory().path(), WithExisting::Kill)); BOOST_CHECK_EQUAL(gp->ask(State()), 10 * szabo); BOOST_CHECK_EQUAL(gp->bid(), 10 * szabo); } diff --git a/test/libevm/vm.cpp b/test/libevm/vm.cpp index 28b2e43ab..badabd70c 100644 --- a/test/libevm/vm.cpp +++ b/test/libevm/vm.cpp @@ -33,7 +33,7 @@ using namespace dev::eth; using namespace dev::test; FakeExtVM::FakeExtVM(eth::BlockInfo const& _previousBlock, eth::BlockInfo const& _currentBlock, unsigned _depth): /// TODO: XXX: remove the default argument & fix. - ExtVMFace(Address(), Address(), Address(), 0, 1, bytesConstRef(), bytes(), EmptySHA3, _previousBlock, _currentBlock, test::lastHashes(_currentBlock.number), _depth) {} + ExtVMFace(Address(), Address(), Address(), 0, 1, bytesConstRef(), bytes(), EmptySHA3, _previousBlock, _currentBlock, test::lastHashes(_currentBlock.number()), _depth) {} h160 FakeExtVM::create(u256 _endowment, u256& io_gas, bytesConstRef _init, OnOpFunc const&) { @@ -84,11 +84,11 @@ mObject FakeExtVM::exportEnv() { mObject ret; ret["previousHash"] = toString(currentBlock.parentHash()); - ret["currentDifficulty"] = toCompactHex(currentBlock.difficulty, HexPrefix::Add, 1); + ret["currentDifficulty"] = toCompactHex(currentBlock.difficulty(), HexPrefix::Add, 1); ret["currentTimestamp"] = toCompactHex(currentBlock.timestamp(), HexPrefix::Add, 1); ret["currentCoinbase"] = toString(currentBlock.coinbaseAddress()); - ret["currentNumber"] = toCompactHex(currentBlock.number, HexPrefix::Add, 1); - ret["currentGasLimit"] = toCompactHex(currentBlock.gasLimit, HexPrefix::Add, 1); + ret["currentNumber"] = toCompactHex(currentBlock.number(), HexPrefix::Add, 1); + ret["currentGasLimit"] = toCompactHex(currentBlock.gasLimit(), HexPrefix::Add, 1); return ret; } @@ -107,7 +107,7 @@ void FakeExtVM::importEnv(mObject& _o) lastHashes = test::lastHashes(currentBlock.number); currentBlock.gasLimit = toInt(_o["currentGasLimit"]); currentBlock.difficulty = toInt(_o["currentDifficulty"]); - currentBlock.timestamp() = toInt(_o["currentTimestamp"]); + currentBlock.timestamp = toInt(_o["currentTimestamp"]); currentBlock.coinbaseAddress() = Address(_o["currentCoinbase"].get_str()); }