diff --git a/CMakeLists.txt b/CMakeLists.txt index 289cecad8..aafdad099 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,7 @@ option(USENPM "Use npm to recompile ethereum.js if it was changed" OFF) option(PROFILING "Build in support for profiling" OFF) set(BUNDLE "none" CACHE STRING "Predefined bundle of software to build (none, full, user, tests, minimal).") +option(MINER "Build the miner component" ON) option(SOLIDITY "Build the Solidity language components" ON) option(SERPENT "Build the Serpent language components" ON) option(TOOLS "Build the tools components" ON) @@ -187,6 +188,7 @@ eth_format_option(VMTRACE) eth_format_option(EVMJIT) eth_format_option(FATDB) eth_format_option(JSONRPC) +eth_format_option(MINER) eth_format_option(USENPM) eth_format_option(PROFILING) eth_format_option(SOLIDITY) @@ -249,6 +251,16 @@ elseif (BUNDLE STREQUAL "user") set(NCURSES ${DECENT_PLATFORM}) set(TOOLS ON) set(TESTS OFF) +elseif (BUNDLE STREQUAL "miner") + set(SERPENT OFF) + set(SOLIDITY OFF) + set(USENPM OFF) + set(GUI OFF) + set(NCURSES OFF) + set(TOOLS OFF) + set(TESTS OFF) + set(MINER ON) + set(ETHASHCL ON) endif () # Default CMAKE_BUILD_TYPE to "Release". @@ -283,6 +295,7 @@ message("-- FATDB Full database exploring ${FATDB}") message("-- JSONRPC JSON-RPC support ${JSONRPC}") message("-- USENPM Javascript source building ${USENPM}") message("------------------------------------------------------------- components") +message("-- MINER Build miner ${MINER}") message("-- TOOLS Build basic tools ${TOOLS}") message("-- SOLIDITY Build Solidity language components ${SOLIDITY}") message("-- SERPENT Build Serpent language components ${SERPENT}") @@ -310,10 +323,20 @@ if (EVMJIT) add_subdirectory(evmjit) endif() +if (TOOLS OR GUI OR SOLIDITY OR NCURSES OR TESTS) + set(GENERAL 1) +else () + set(GENERAL 0) +endif () + +message("GENERAL ${GENERAL}") + add_subdirectory(libdevcore) -add_subdirectory(libevmcore) -add_subdirectory(libevmasm) -add_subdirectory(liblll) +if (GENERAL) + add_subdirectory(libevmcore) + add_subdirectory(libevmasm) + add_subdirectory(liblll) +endif () if (SERPENT) add_subdirectory(libserpent) @@ -329,31 +352,43 @@ if (TOOLS) if (SOLIDITY) add_subdirectory(solc) endif () -endif() +endif () -if (JSONRPC) +if (JSONRPC AND GENERAL) add_subdirectory(libweb3jsonrpc) -endif() +endif () if (JSCONSOLE) add_subdirectory(libjsengine) add_subdirectory(libjsconsole) -endif() +endif () add_subdirectory(secp256k1) -add_subdirectory(libp2p) add_subdirectory(libdevcrypto) -add_subdirectory(libwhisper) -add_subdirectory(libethash) -if (ETHASHCL) - add_subdirectory(libethash-cl) +if (GENERAL) + add_subdirectory(libp2p) + add_subdirectory(libwhisper) +endif () + +if (GENERAL OR MINER) + add_subdirectory(libethash) + if (ETHASHCL) + add_subdirectory(libethash-cl) + endif () endif () add_subdirectory(libethcore) -add_subdirectory(libevm) -add_subdirectory(libethereum) -add_subdirectory(libwebthree) + +if (GENERAL) + add_subdirectory(libevm) + add_subdirectory(libethereum) + add_subdirectory(libwebthree) +endif () + +if (MINER) + add_subdirectory(ethminer) +endif () if (TESTS) add_subdirectory(libtestutils) @@ -367,7 +402,6 @@ if (TOOLS) add_subdirectory(rlp) add_subdirectory(abi) - add_subdirectory(ethminer) add_subdirectory(eth) if("x${CMAKE_BUILD_TYPE}" STREQUAL "xDebug") diff --git a/eth/main.cpp b/eth/main.cpp index 3324afcdd..5f2349ae4 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -787,11 +787,14 @@ int main(int argc, char** argv) else if (arg == "-C" || arg == "--cpu") minerType = MinerType::CPU; else if (arg == "-G" || arg == "--opencl") + { minerType = MinerType::GPU; + miningThreads = 1; /*<< " -s,--import-secret Import a secret key into the key store and use as the default." << endl << " -S,--import-session-secret Import a secret key into the key store and use as the default for this session only." << endl << " --sign-key
Sign all transactions with the key of the given address." << endl << " --session-sign-key
Sign all transactions with the key of the given address for this session only." << endl*/ + } else if ((arg == "-s" || arg == "--import-secret") && i + 1 < argc) { Secret s(fromHex(argv[++i])); diff --git a/ethminer/CMakeLists.txt b/ethminer/CMakeLists.txt index af38c0c84..d364f6ed1 100644 --- a/ethminer/CMakeLists.txt +++ b/ethminer/CMakeLists.txt @@ -17,12 +17,7 @@ add_dependencies(${EXECUTABLE} BuildInfo.h) target_link_libraries(${EXECUTABLE} ${Boost_REGEX_LIBRARIES}) -if (READLINE_FOUND) - target_link_libraries(${EXECUTABLE} ${READLINE_LIBRARIES}) -endif() - if (JSONRPC) - target_link_libraries(${EXECUTABLE} web3jsonrpc) target_link_libraries(${EXECUTABLE} ${JSON_RPC_CPP_CLIENT_LIBRARIES}) target_link_libraries(${EXECUTABLE} ${CURL_LIBRARIES}) if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW) @@ -30,7 +25,7 @@ if (JSONRPC) endif() endif() -target_link_libraries(${EXECUTABLE} webthree) +target_link_libraries(${EXECUTABLE} ethcore) target_link_libraries(${EXECUTABLE} ethash) if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW) diff --git a/ethminer/main.cpp b/ethminer/main.cpp index 97e125e65..a19934ba0 100644 --- a/ethminer/main.cpp +++ b/ethminer/main.cpp @@ -32,12 +32,10 @@ #include #include #include +#include #include #include -#include -#include -#include -#include +#include #if ETH_JSONRPC || !ETH_TRUE #include #include @@ -50,7 +48,6 @@ #endif using namespace std; using namespace dev; -using namespace dev::p2p; using namespace dev::eth; using namespace boost::algorithm; using dev::eth::Instruction; @@ -143,7 +140,7 @@ enum class MinerType void doBenchmark(MinerType _m, bool _phoneHome, unsigned _warmupDuration = 15, unsigned _trialDuration = 3, unsigned _trials = 5) { - BlockInfo genesis = CanonBlockChain::genesis(); + BlockInfo genesis; genesis.difficulty = 1 << 18; cdebug << genesis.boundary(); @@ -294,9 +291,6 @@ void doFarm(MinerType _m, string const& _remote, unsigned _recheckPeriod) int main(int argc, char** argv) { - // Init defaults - Defaults::get(); - /// Operating mode. OperationMode mode = OperationMode::Farm; @@ -398,7 +392,10 @@ int main(int argc, char** argv) else if (arg == "-C" || arg == "--cpu") minerType = MinerType::CPU; else if (arg == "-G" || arg == "--opencl") + { minerType = MinerType::GPU; + miningThreads = 1; + } else if ((arg == "-D" || arg == "--create-dag") && i + 1 < argc) { string m = boost::to_lower_copy(string(argv[++i])); diff --git a/exp/main.cpp b/exp/main.cpp index 2bd0a741e..138ae76a4 100644 --- a/exp/main.cpp +++ b/exp/main.cpp @@ -45,10 +45,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include diff --git a/libethcore/CMakeLists.txt b/libethcore/CMakeLists.txt index 4dd626642..a527ad1f4 100644 --- a/libethcore/CMakeLists.txt +++ b/libethcore/CMakeLists.txt @@ -28,7 +28,7 @@ add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS}) target_link_libraries(${EXECUTABLE} ethash) target_link_libraries(${EXECUTABLE} devcrypto) -target_link_libraries(${EXECUTABLE} evmcore) +#target_link_libraries(${EXECUTABLE} evmcore) if (ETHASHCL) target_link_libraries(${EXECUTABLE} ethash-cl) diff --git a/libethcore/Common.cpp b/libethcore/Common.cpp index 0b36ca5fa..c74aeba5e 100644 --- a/libethcore/Common.cpp +++ b/libethcore/Common.cpp @@ -36,11 +36,12 @@ namespace eth { const unsigned c_protocolVersion = 60; -const unsigned c_minorProtocolVersion = 2; #if ETH_FATDB -const unsigned c_databaseBaseVersion = 10; +const unsigned c_minorProtocolVersion = 3; +const unsigned c_databaseBaseVersion = 9; const unsigned c_databaseVersionModifier = 1; #else +const unsigned c_minorProtocolVersion = 2; const unsigned c_databaseBaseVersion = 9; const unsigned c_databaseVersionModifier = 0; #endif diff --git a/libethcore/EthashAux.cpp b/libethcore/EthashAux.cpp index e01372452..a5fabcab0 100644 --- a/libethcore/EthashAux.cpp +++ b/libethcore/EthashAux.cpp @@ -116,6 +116,8 @@ EthashAux::LightAllocation::LightAllocation(h256 const& _seedHash) { uint64_t blockNumber = EthashAux::number(_seedHash); light = ethash_light_new(blockNumber); + if (!light) + BOOST_THROW_EXCEPTION(ExternalFunctionFailure("ethash_light_new()")); size = ethash_get_cachesize(blockNumber); } @@ -132,6 +134,8 @@ bytesConstRef EthashAux::LightAllocation::data() const EthashAux::FullAllocation::FullAllocation(ethash_light_t _light, ethash_callback_t _cb) { full = ethash_full_new(_light, _cb); + if (!full) + BOOST_THROW_EXCEPTION(ExternalFunctionFailure("ethash_full_new()")); } EthashAux::FullAllocation::~FullAllocation() diff --git a/libethereum/Farm.h b/libethcore/Farm.h similarity index 100% rename from libethereum/Farm.h rename to libethcore/Farm.h diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 6d934f3ad..6d5e39e39 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -461,13 +461,13 @@ ProofOfWork::WorkPackage Client::getWork() bool Client::submitWork(ProofOfWork::Solution const& _solution) { bytes newBlock; - DEV_TIMED(working) DEV_WRITE_GUARDED(x_working) + DEV_WRITE_GUARDED(x_working) if (!m_working.completeMine(_solution)) return false; DEV_READ_GUARDED(x_working) { - DEV_TIMED(post) DEV_WRITE_GUARDED(x_postMine) + DEV_WRITE_GUARDED(x_postMine) m_postMine = m_working; newBlock = m_working.blockData(); } @@ -499,14 +499,14 @@ void Client::syncTransactionQueue() h256Hash changeds; TransactionReceipts newPendingReceipts; - DEV_TIMED(working) DEV_WRITE_GUARDED(x_working) + DEV_WRITE_GUARDED(x_working) tie(newPendingReceipts, m_syncTransactionQueue) = m_working.sync(m_bc, m_tq, *m_gp); if (newPendingReceipts.empty()) return; DEV_READ_GUARDED(x_working) - DEV_TIMED(post) DEV_WRITE_GUARDED(x_postMine) + DEV_WRITE_GUARDED(x_postMine) m_postMine = m_working; DEV_READ_GUARDED(x_postMine) @@ -574,7 +574,7 @@ void Client::onChainChanged(ImportRoute const& _ir) DEV_WRITE_GUARDED(x_preMine) m_preMine = newPreMine; - DEV_TIMED(working) DEV_WRITE_GUARDED(x_working) + DEV_WRITE_GUARDED(x_working) m_working = newPreMine; DEV_READ_GUARDED(x_postMine) for (auto const& t: m_postMine.pending()) @@ -584,7 +584,7 @@ void Client::onChainChanged(ImportRoute const& _ir) if (ir != ImportResult::Success) onTransactionQueueReady(); } - DEV_READ_GUARDED(x_working) DEV_TIMED(post) DEV_WRITE_GUARDED(x_postMine) + DEV_READ_GUARDED(x_working) DEV_WRITE_GUARDED(x_postMine) m_postMine = m_working; changeds.insert(PendingChangedFilter); @@ -609,11 +609,11 @@ void Client::onPostStateChanged() cnote << "Post state changed: Restarting mining..."; if (isMining() || remoteActive()) { - DEV_TIMED(working) DEV_WRITE_GUARDED(x_working) + DEV_WRITE_GUARDED(x_working) m_working.commitToMine(m_bc); DEV_READ_GUARDED(x_working) { - DEV_TIMED(post) DEV_WRITE_GUARDED(x_postMine) + DEV_WRITE_GUARDED(x_postMine) m_postMine = m_working; m_miningInfo = m_postMine.info(); } diff --git a/libethereum/Client.h b/libethereum/Client.h index 674556a6e..7eeb7fb2d 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -37,12 +37,12 @@ #include #include #include +#include #include #include "CanonBlockChain.h" #include "TransactionQueue.h" #include "State.h" #include "CommonNet.h" -#include "Farm.h" #include "ClientBase.h" namespace dev diff --git a/libethereum/Farm.cpp b/libethereum/Farm.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/libethereum/TransactionQueue.cpp b/libethereum/TransactionQueue.cpp index 40a149ebf..e488805d9 100644 --- a/libethereum/TransactionQueue.cpp +++ b/libethereum/TransactionQueue.cpp @@ -97,7 +97,7 @@ std::unordered_map TransactionQueue::transactions() const ReadGuard l(m_lock); auto ret = m_current; for (auto const& i: m_future) - if (i.second.nonce() < maxNonce(i.second.sender())) + if (i.second.nonce() < maxNonce_WITH_LOCK(i.second.sender())) ret.insert(i); return ret; } @@ -136,6 +136,11 @@ u256 TransactionQueue::maxNonce(Address const& _a) const { // cdebug << "txQ::maxNonce" << _a; ReadGuard l(m_lock); + return maxNonce_WITH_LOCK(_a); +} + +u256 TransactionQueue::maxNonce_WITH_LOCK(Address const& _a) const +{ u256 ret = 0; auto r = m_senders.equal_range(_a); for (auto it = r.first; it != r.second; ++it) @@ -182,7 +187,7 @@ bool TransactionQueue::remove_WITH_LOCK(h256 const& _txHash) m_senders.erase(i); break; } - cdebug << "=> nonce" << pit->second.nonce(); +// cdebug << "=> nonce" << pit->second.nonce(); pool->erase(pit); return true; } diff --git a/libethereum/TransactionQueue.h b/libethereum/TransactionQueue.h index 6036caa83..a07efb848 100644 --- a/libethereum/TransactionQueue.h +++ b/libethereum/TransactionQueue.h @@ -72,6 +72,7 @@ private: void insertCurrent_WITH_LOCK(std::pair const& _p); bool remove_WITH_LOCK(h256 const& _txHash); + u256 maxNonce_WITH_LOCK(Address const& _a) const; mutable SharedMutex m_lock; ///< General lock. h256Hash m_known; ///< Hashes of transactions in both sets. diff --git a/libp2p/Host.cpp b/libp2p/Host.cpp index 2f139fd3d..9c3e629d4 100644 --- a/libp2p/Host.cpp +++ b/libp2p/Host.cpp @@ -392,7 +392,7 @@ string Host::pocHost() std::unordered_map const& Host::pocHosts() { static const std::unordered_map c_ret = { -// { Public(""), "poc-9.ethdev.com:30303" }, + { Public("487611428e6c99a11a9795a6abe7b529e81315ca6aad66e2a2fc76e3adf263faba0d35466c2f8f68d561dbefa8878d4df5f1f2ddb1fbeab7f42ffb8cd328bd4a"), "poc-9.ethdev.com:30303" }, { Public("a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c"), "52.16.188.185:30303" }, { Public("7f25d3eab333a6b98a8b5ed68d962bb22c876ffcd5561fca54e3c2ef27f754df6f7fd7c9b74cc919067abac154fb8e1f8385505954f161ae440abc355855e034"), "54.207.93.166:30303" } }; diff --git a/test/libethereum/stateOriginal.cpp b/test/libethereum/stateOriginal.cpp index 82d6288d6..e7a078182 100644 --- a/test/libethereum/stateOriginal.cpp +++ b/test/libethereum/stateOriginal.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include "../TestHelper.h" using namespace std;