diff --git a/CMakeLists.txt b/CMakeLists.txt index 20203b6f9..9a29ecc14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # cmake global cmake_minimum_required(VERSION 2.8.12) -set(PROJECT_VERSION "0.9.35") +set(PROJECT_VERSION "0.9.36") if (${CMAKE_VERSION} VERSION_GREATER 3.0) cmake_policy(SET CMP0048 NEW) # allow VERSION argument in project() project(ethereum VERSION ${PROJECT_VERSION}) @@ -28,29 +28,124 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") ###################################################################################################### -# user defined, defaults -# Normally, set(...CACHE...) creates cache variables, but does not modify them. -option(VMTRACE "VM tracing and run-time checks (useful for cross-implementation VM debugging)" OFF) -option(PARANOID "Additional run-time checks" OFF) -option(JSONRPC "Build with jsonprc. default on" ON) -option(FATDB "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents." OFF) -option(USENPM "Use npm to recompile ethereum.js if it was changed" OFF) -option(PROFILING "Build in support for profiling" OFF) -option(ROCKSDB "Use rocksdb rather than leveldb" OFF) - -set(BUNDLE "none" CACHE STRING "Predefined bundle of software to build (none, full, user, tests, minimal).") -option(MINER "Build the CLI miner component" ON) -option(ETHKEY "Build the CLI key manager 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) -option(GUI "Build GUI components (AlethZero, Mix)" ON) -option(TESTS "Build the tests." ON) -option(NOBOOST "No use of boost macros in test functions" OFF) -option(EVMJIT "Build just-in-time compiler for EVM code (requires LLVM)" ON) -option(ETHASHCL "Build in support for GPU mining via OpenCL" ON) -option(JSCONSOLE "Build in javascript console" ON) -option(FRONTIER "Build for Frontier network" OFF) +# note: The value "default" which provides the defaults is just a fake value +# which lets us keep the default values of all build options and is set at +# the beginning of this file. + +# TODO: Abstract into something sensible and move into a function. +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + set(DECENT_PLATFORM OFF) +else () + set(DECENT_PLATFORM ON) +endif () + +#defaults: +set(D_CMAKE_BUILD_TYPE "RelWithDebInfo") +set(D_SERPENT ${DECENT_PLATFORM}) +set(D_SOLIDITY ON) +set(D_USENPM OFF) +set(D_GUI ON) +set(D_TOOLS ON) +set(D_TESTS ON) +set(D_FATDB ON) +set(D_ETHASHCL ON) +set(D_EVMJIT ON) +set(D_JSCONSOLE ON) +set(D_JSONRPC ON) +set(D_VMTRACE OFF) +set(D_PARANOID OFF) +set(D_PROFILING OFF) +set(D_ROCKSDB OFF) +set(D_NOBOOST OFF) +set(D_FRONTIER OFF) +set(D_MINER ON) +set(D_ETHKEY ON) + +if (BUNDLE STREQUAL "minimal") + set(D_SERPENT OFF) + set(D_SOLIDITY OFF) + set(D_USENPM OFF) + set(D_GUI OFF) + set(D_TOOLS ON) + set(D_TESTS OFF) +elseif (BUNDLE STREQUAL "full") + set(D_SERPENT ${DECENT_PLATFORM}) + set(D_SOLIDITY ON) + set(D_USENPM ON) + set(D_GUI ON) + set(D_TOOLS ON) + set(D_TESTS ON) + set(D_FATDB ON) +elseif (BUNDLE STREQUAL "cli") + set(D_SERPENT ${DECENT_PLATFORM}) + set(D_SOLIDITY ON) + set(D_USENPM ON) + set(D_GUI OFF) + set(D_TOOLS ON) + set(D_TESTS ON) + set(D_FATDB ON) +elseif (BUNDLE STREQUAL "core") + set(D_SERPENT OFF) + set(D_SOLIDITY ON) + set(D_USENPM OFF) + set(D_GUI ON) + set(D_TOOLS ON) + set(D_TESTS OFF) + set(D_FATDB ON) +elseif (BUNDLE STREQUAL "tests") + set(D_SERPENT ${DECENT_PLATFORM}) + set(D_SOLIDITY ON) + set(D_USENPM OFF) + set(D_GUI OFF) + set(D_TOOLS OFF) + set(D_TESTS ON) + set(D_FATDB ON) +elseif (BUNDLE STREQUAL "user") + set(D_SERPENT OFF) + set(D_SOLIDITY OFF) + set(D_USENPM OFF) + set(D_GUI ON) + set(D_TOOLS ON) + set(D_TESTS OFF) +elseif (BUNDLE STREQUAL "wallet") + set(D_SERPENT OFF) + set(D_SOLIDITY OFF) + set(D_USENPM OFF) + set(D_GUI OFF) + set(D_TOOLS OFF) + set(D_TESTS OFF) + set(D_ETHKEY ON) + set(D_MINER OFF) + set(D_ETHASHCL ON) +elseif (BUNDLE STREQUAL "miner") + set(D_SERPENT OFF) + set(D_SOLIDITY OFF) + set(D_USENPM OFF) + set(D_GUI OFF) + set(D_TOOLS OFF) + set(D_TESTS OFF) + set(D_ETHKEY OFF) + set(D_MINER ON) + set(D_ETHASHCL ON) +elseif (BUNDLE STREQUAL "release") # release builds + set(D_SERPENT ${DECENT_PLATFORM}) + set(D_SOLIDITY ON) + set(D_USENPM OFF) + set(D_GUI ON) + set(D_TOOLS ON) + set(D_TESTS OFF) + set(D_FATDB OFF) + set(D_ETHASHCL ON) + set(D_EVMJIT ON) + set(D_JSCONSOLE ON) + set(D_JSONRPC ON) + set(D_FRONTIER ON) + set(D_CMAKE_BUILD_TYPE "Release") +endif () + +if ("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE ${D_CMAKE_BUILD_TYPE}) +endif () # propagates CMake configuration options to the compiler function(configureProject) @@ -177,24 +272,11 @@ if (HEADLESS) set(GUI OFF) endif () -# TODO: Abstract into something sensible and move into a function. -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - set(DECENT_PLATFORM OFF) -else () - set(DECENT_PLATFORM ON) -endif () - macro(eth_format_option O) if (${${O}}) set(${O} ON) - else() - set(${O} OFF) - endif() -endmacro() - -macro(eth_format_option_on_decent_platform O) - if (${${O}}) - set(${O} ${DECENT_PLATFORM}) + elseif ("${${O}}" STREQUAL "" AND ${D_${O}}) + set(${O} ON) else() set(${O} OFF) endif() @@ -220,7 +302,7 @@ eth_format_option(ETHKEY) eth_format_option(ETHASHCL) eth_format_option(JSCONSOLE) eth_format_option(FRONTIER) -eth_format_option_on_decent_platform(SERPENT) +eth_format_option(SERPENT) if (JSCONSOLE) set(JSONRPC ON) @@ -231,110 +313,11 @@ if (GUI) endif() # Default CMAKE_BUILD_TYPE to "Release". -set(CMAKE_BUILD_TYPE CACHE STRING "Release") - -# note: The value "default" which provides the defaults is just a fake value -# which lets us keep the default values of all build options and is set at -# the beginning of this file. -if (BUNDLE STREQUAL "minimal") - set(SERPENT OFF) - set(SOLIDITY OFF) - set(USENPM OFF) - set(GUI OFF) - set(TOOLS ON) - set(TESTS OFF) -elseif (BUNDLE STREQUAL "full") - set(SERPENT ${DECENT_PLATFORM}) - set(SOLIDITY ON) - set(USENPM ON) - set(GUI ON) - set(TOOLS ON) - set(TESTS ON) - set(FATDB ON) -elseif (BUNDLE STREQUAL "cli") - set(SERPENT ${DECENT_PLATFORM}) - set(SOLIDITY ON) - set(USENPM ON) - set(GUI OFF) - set(TOOLS ON) - set(TESTS ON) - set(FATDB ON) -elseif (BUNDLE STREQUAL "core") - set(SERPENT OFF) - set(SOLIDITY ON) - set(USENPM OFF) - set(GUI ON) - set(TOOLS ON) - set(TESTS OFF) - set(FATDB ON) -elseif (BUNDLE STREQUAL "tests") - set(SERPENT ${DECENT_PLATFORM}) - set(SOLIDITY ON) - set(USENPM OFF) - set(GUI OFF) - set(TOOLS OFF) - set(TESTS ON) - set(FATDB ON) -elseif (BUNDLE STREQUAL "user") - set(SERPENT OFF) - set(SOLIDITY OFF) - set(USENPM OFF) - set(GUI ON) - set(TOOLS ON) - set(TESTS OFF) -elseif (BUNDLE STREQUAL "wallet") - set(SERPENT OFF) - set(SOLIDITY OFF) - set(USENPM OFF) - set(GUI OFF) - set(TOOLS OFF) - set(TESTS OFF) - set(ETHKEY ON) - set(MINER OFF) - set(ETHASHCL ON) -elseif (BUNDLE STREQUAL "miner") - set(SERPENT OFF) - set(SOLIDITY OFF) - set(USENPM OFF) - set(GUI OFF) - set(TOOLS OFF) - set(TESTS OFF) - set(ETHKEY OFF) - set(MINER ON) - set(ETHASHCL ON) -elseif (BUNDLE STREQUAL "default") # development builds - set(SERPENT ${DECENT_PLATFORM}) - set(SOLIDITY ON) - set(USENPM OFF) - set(GUI ON) - set(TOOLS ON) - set(TESTS ON) - set(FATDB ON) - set(ETHASHCL ON) - set(EVMJIT ON) - set(JSCONSOLE ON) - set(JSONRPC ON) - if ("x${CMAKE_BUILD_TYPE}" STREQUAL "x") - set(CMAKE_BUILD_TYPE "RelWithDebInfo") - endif () -elseif (BUNDLE STREQUAL "release") # release builds - set(SERPENT ${DECENT_PLATFORM}) - set(SOLIDITY ON) - set(USENPM OFF) - set(GUI ON) - set(TOOLS ON) - set(TESTS OFF) - set(FATDB OFF) - set(ETHASHCL ON) - set(EVMJIT ON) - set(JSCONSOLE ON) - set(JSONRPC ON) - set(FRONTIER ON) -endif () +set(CMAKE_BUILD_TYPE CACHE STRING ${D_CMAKE_BUILD_TYPE}) -if ("x${CMAKE_BUILD_TYPE}" STREQUAL "x") - set(CMAKE_BUILD_TYPE "Release") -endif () +#if ("x${CMAKE_BUILD_TYPE}" STREQUAL "x") +# set(CMAKE_BUILD_TYPE ${D_CMAKE_BUILD_TYPE}) +#endif () # Default TARGET_PLATFORM to ${CMAKE_SYSTEM_NAME} # change this once we support cross compiling diff --git a/libdevcore/CommonData.cpp b/libdevcore/CommonData.cpp index a2d4ce1e0..7a6e7ff55 100644 --- a/libdevcore/CommonData.cpp +++ b/libdevcore/CommonData.cpp @@ -20,7 +20,7 @@ */ #include "CommonData.h" - +#include #include "Exceptions.h" #include "Log.h" @@ -58,9 +58,9 @@ std::string dev::escaped(std::string const& _s, bool _all) std::string dev::randomWord() { static std::mt19937_64 s_eng(0); - std::string ret(std::uniform_int_distribution(1, 5)(s_eng), ' '); + std::string ret(boost::random::uniform_int_distribution(1, 5)(s_eng), ' '); char const n[] = "qwertyuiop";//asdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890"; - std::uniform_int_distribution d(0, sizeof(n) - 2); + boost::random::uniform_int_distribution d(0, sizeof(n) - 2); for (char& c: ret) c = n[d(s_eng)]; return ret; diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index 7c612970a..af67269a1 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -27,6 +27,7 @@ #include #include #include +#include #include "CommonData.h" namespace dev @@ -154,7 +155,7 @@ public: { FixedHash ret; for (auto& i: ret.m_data) - i = (uint8_t)std::uniform_int_distribution(0, 255)(_eng); + i = (uint8_t)boost::random::uniform_int_distribution(0, 255)(_eng); return ret; } diff --git a/libdevcore/vector_ref.h b/libdevcore/vector_ref.h index ca5ac3753..c7ba3a437 100644 --- a/libdevcore/vector_ref.h +++ b/libdevcore/vector_ref.h @@ -7,6 +7,7 @@ #include #include #include +#include namespace dev { @@ -76,7 +77,7 @@ public: { uint8_t* e = (uint8_t*)end(); for (uint8_t* i = (uint8_t*)begin(); i != e; ++i) - *i = (uint8_t)std::uniform_int_distribution(0, 255)(_eng); + *i = (uint8_t)boost::random::uniform_int_distribution(0, 255)(_eng); } /// @returns a random valued object. void randomize() { randomize(s_vectorRefEngine); } diff --git a/libethash-cl/ethash_cl_miner.cpp b/libethash-cl/ethash_cl_miner.cpp index 7e2573303..fa1dda8eb 100644 --- a/libethash-cl/ethash_cl_miner.cpp +++ b/libethash-cl/ethash_cl_miner.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -472,7 +473,7 @@ void ethash_cl_miner::search(uint8_t const* header, uint64_t target, search_hook unsigned buf = 0; boost::random_device engine; - uint64_t start_nonce = uniform_int_distribution()(engine); + uint64_t start_nonce = boost::random::uniform_int_distribution()(engine); for (;; start_nonce += m_globalWorkSize) { auto t = chrono::high_resolution_clock::now(); diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index c60482817..c08faaa22 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -450,6 +450,10 @@ public: try { h.populateFromHeader(RLP(uncle.data()), (_ir & ImportRequirements::UncleSeals) ? Strictness::CheckEverything : Strictness::IgnoreSeal); + bytes parentHeader(headerData(h.parentHash())); + if (parentHeader.empty()) + BOOST_THROW_EXCEPTION(InvalidParentHash()); + h.verifyParent(typename Sealer::BlockHeader(parentHeader, IgnoreSeal, h.parentHash(), HeaderData)); } catch (Exception& ex) {