diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fc718297..d4be26923 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,7 @@ function(createBuildInfo) set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/msys") elseif (CMAKE_COMPILER_IS_GNUCXX) set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/g++") - elseif (CMAKE_COMPILER_IS_MSVC) + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/msvc") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/clang") @@ -59,8 +59,15 @@ function(createBuildInfo) set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/unknown") endif () + #cmake build type may be not specified when using msvc + if (${CMAKE_BUILD_TYPE}) + set(_cmake_build_type ${CMAKE_BUILD_TYPE}) + else() + set(_cmake_build_type "undefined") + endif() + # Generate header file containing useful build information - add_custom_target(BuildInfo.h ALL COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/BuildInfo.sh ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BUILD_TYPE} ${ETH_BUILD_PLATFORM}) + add_custom_target(BuildInfo.h ALL COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/BuildInfo.sh ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${_cmake_build_type} ${ETH_BUILD_PLATFORM}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_INCLUDE_CURRENT_DIR ON) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 0e7b0799b..6819e41ad 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -1285,6 +1285,7 @@ void Main::on_blocks_currentItemChanged() s << "
" << sha3(i.data()).abridged();// << ": " << i[1].toHash() << " [" << i[2].toInt() << " used]"; s << "
Post: " << info.stateRoot << ""; s << "
Dump: " << toHex(block[0].data()) << ""; + s << "
Receipts-Hex: " << toHex(ethereum()->blockChain().receipts(h).rlp()) << "
"; } else { diff --git a/cmake/EthCompilerSettings.cmake b/cmake/EthCompilerSettings.cmake index 8530a54b7..60ea3c90f 100644 --- a/cmake/EthCompilerSettings.cmake +++ b/cmake/EthCompilerSettings.cmake @@ -3,15 +3,17 @@ # C++11 check and activation if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") + set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wno-unknown-pragmas -Wextra -DSHAREDLIB") execute_process( COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) if (NOT (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7)) message(FATAL_ERROR "${PROJECT_NAME} requires g++ 4.7 or greater.") endif () elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wno-unknown-pragmas -Wextra -DSHAREDLIB") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + set(CMAKE_CXX_FLAGS "") + set(ETH_STATIC 1) else () message(FATAL_ERROR "Your C++ compiler does not support C++11. You have ${CMAKE_CXX_COMPILER_ID}") endif () @@ -19,43 +21,43 @@ endif () # Initialize CXXFLAGS -set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wno-unknown-pragmas -Wextra -DSHAREDLIB") +# CMAKE_CXX_FLAGS was set before set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DETH_DEBUG") set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG -DETH_RELEASE") set(CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG -DETH_RELEASE") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DETH_DEBUG") # Windows -if ("${TARGET_PLATFORM}" STREQUAL "w64") - set(CMAKE_SYSTEM_NAME Windows) - - set(CMAKE_CXX_LIBRARY_ARCHITECTURE x86_64-w64-mingw32) - set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) - set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) - set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) - set(CMAKE_AR x86_64-w64-mingw32-ar) - set(CMAKE_RANLIB x86_64-w64-mingw32-ranlib) - - set(CMAKE_EXECUTABLE_SUFFIX .exe) - - set(CMAKE_FIND_ROOT_PATH - /usr/x86_64-w64-mingw32 - ) - - include_directories(/usr/x86_64-w64-mingw32/include/cryptopp) - - set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) - set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) - set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) - - set(CMAKE_INSTALL_PREFIX /usr/x86_64-w64-mingw32) - set(ETH_BUILD_PLATFORM "windows") - set(ETH_STATIC 1) -else () - set(ETH_BUILD_PLATFORM ${CMAKE_SYSTEM_NAME}) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") - set(ETH_SHARED 1) -endif() +#if ("${TARGET_PLATFORM}" STREQUAL "w64") +# set(CMAKE_SYSTEM_NAME Windows) +# +# set(CMAKE_CXX_LIBRARY_ARCHITECTURE x86_64-w64-mingw32) +# set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) +# set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) +# set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) +# set(CMAKE_AR x86_64-w64-mingw32-ar) +# set(CMAKE_RANLIB x86_64-w64-mingw32-ranlib) +# +# set(CMAKE_EXECUTABLE_SUFFIX .exe) +# +# set(CMAKE_FIND_ROOT_PATH +# /usr/x86_64-w64-mingw32 +# ) +# +# include_directories(/usr/x86_64-w64-mingw32/include/cryptopp) +# +# set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +# set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +# +# set(CMAKE_INSTALL_PREFIX /usr/x86_64-w64-mingw32) +# set(ETH_BUILD_PLATFORM "windows") +# set(ETH_STATIC 1) +#else () +# set(ETH_BUILD_PLATFORM ${CMAKE_SYSTEM_NAME}) +# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") +# set(ETH_SHARED 1) +#endif() diff --git a/cmake/EthDependencies.cmake b/cmake/EthDependencies.cmake index 260d04751..223c14ce3 100644 --- a/cmake/EthDependencies.cmake +++ b/cmake/EthDependencies.cmake @@ -5,6 +5,10 @@ # this must be set to point to the same directory as $ETH_DEPENDENCY_INSTALL_DIR in /extdep directory string(TOLOWER ${CMAKE_SYSTEM_NAME} _system_name) set (CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/extdep/install/${_system_name}") +if (WIN32) + set (CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "C:/Program Files/Windows Kits/8.1/Lib/winv6.3/um/x86") + #set (CMAKE_PREFIX_PATH "C:/Program Files/Windows Kits/8.1/Lib/winv6.3/um/x64") +endif() # Dependencies must have a version number, to ensure reproducible build. The version provided here is the one that is in the extdep repository. If you use system libraries, version numbers may be different. @@ -40,6 +44,33 @@ find_package (Qt5WebKit REQUIRED) find_package (Qt5WebKitWidgets REQUIRED) +# we have to specify here if we want static and boost version, that is really important + +# win32 msvc 2013 boost +set(Boost_USE_STATIC_LIBS ON) +set(Boost_USE_MULTITHREADED ON) +set(Boost_COMPILER -vc120) + +find_package(Boost 1.55.0 REQUIRED COMPONENTS thread date_time system regex) + +if (Boost_FOUND) + message(" - boost header: ${Boost_INCLUDE_DIRS}") + message(" - boost lib : ${Boost_LIBRARIES}") +endif() + + + + + + + + + + + + + + diff --git a/cmake/EthDependenciesDeprecated.cmake b/cmake/EthDependenciesDeprecated.cmake index 47ad733e4..72ad9c769 100644 --- a/cmake/EthDependenciesDeprecated.cmake +++ b/cmake/EthDependenciesDeprecated.cmake @@ -82,11 +82,11 @@ else() message(STATUS "Failed to find the readline headers!") endif () - if (LANGUAGES) - find_package(Boost 1.53 REQUIRED COMPONENTS thread date_time) - else() - find_package(Boost 1.53 REQUIRED COMPONENTS thread date_time system regex) - endif() + #if (LANGUAGES) + # find_package(Boost 1.53 REQUIRED COMPONENTS thread date_time) + #else() + # find_package(Boost 1.53 REQUIRED COMPONENTS thread date_time system regex) + #endif() set(QTQML 1) endif() diff --git a/extdep/CMakeLists.txt b/extdep/CMakeLists.txt index 274f9755b..cea32c80f 100644 --- a/extdep/CMakeLists.txt +++ b/extdep/CMakeLists.txt @@ -30,15 +30,21 @@ if (ETH_COMPILE) # cryptopp include(compile/cryptopp.cmake) + + # boost + include(compile/boost.cmake) else() + eth_download(jsoncpp) eth_download(json-rpc-cpp OSX_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/scripts/json-rpc-cpp_osx.sh) - eth_download(snappy OSX_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/scripts/snappy_osx.sh) + + if (APPLE) + eth_download(snappy OSX_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/scripts/snappy_osx.sh) + endif() eth_download(leveldb OSX_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/scripts/leveldb_osx.sh) eth_download(qt) eth_download(cryptopp) + eth_download(boost) - #include(compile/leveldb.cmake) - #eth_download("leveldb") endif() # will be re-eanbled later diff --git a/extdep/compile/icu.cmake b/extdep/compile/icu.cmake index 3728280e1..c0c4d46fc 100644 --- a/extdep/compile/icu.cmake +++ b/extdep/compile/icu.cmake @@ -8,7 +8,8 @@ ExternalProject_Add(icu BINARY_DIR icu-prefix/src/icu CONFIGURE_COMMAND "" BUILD_COMMAND "" - INSTALL_COMMAND cmd /c cp lib/* ${ETH_DEPENDENCY_INSTALL_DIR}/lib && cp -R include/uni ${ETH_DEPENDENCY_INSTALL_DIR}/include && cp bin/* ${ETH_DEPENDENCY_INSTALL_DIR}/bin + #INSTALL_COMMAND cmd /c cp lib/* ${ETH_DEPENDENCY_INSTALL_DIR}/lib && cp -R include/uni ${ETH_DEPENDENCY_INSTALL_DIR}/include && cp bin/* ${ETH_DEPENDENCY_INSTALL_DIR}/bin + INSTALL_COMMAND cmake -E copy_directory . ${ETH_DEPENDENCY_INSTALL_DIR} ) else() diff --git a/extdep/compile/jom.cmake b/extdep/compile/jom.cmake index e5bc5542e..17ae6caab 100644 --- a/extdep/compile/jom.cmake +++ b/extdep/compile/jom.cmake @@ -8,7 +8,7 @@ ExternalProject_Add(jom BINARY_DIR jom-prefix/src/jom CONFIGURE_COMMAND "" BUILD_COMMAND "" - INSTALL_COMMAND cp jom.exe ${ETH_DEPENDENCY_INSTALL_DIR}/bin +INSTALL_COMMAND cmake -E copy jom.exe ${ETH_DEPENDENCY_INSTALL_DIR}/bin ) else() diff --git a/extdep/compile/qt.cmake b/extdep/compile/qt.cmake index 2ff0e1e5b..049b3ba94 100644 --- a/extdep/compile/qt.cmake +++ b/extdep/compile/qt.cmake @@ -10,12 +10,11 @@ ExternalProject_add(qt elseif(WIN32) ExternalProject_Add(qt DEPENDS icu jom - URL http://download.qt-project.org/official_releases/qt/5.2/5.2.1/single/qt-everywhere-opensource-src-5.2.1.tar.gz + URL http://qtmirror.ics.com/pub/qtproject/official_releases/qt/5.3/5.3.2/single/qt-everywhere-opensource-src-5.3.2.tar.gz BINARY_DIR qt-prefix/src/qt UPDATE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/compile/qt_tools.bat - PATCH_COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/compile/qt_configure.bat qtbase/configure.bat + #PATCH_COMMAND cmake -E copy ${CMAKE_CURRENT_SOURCE_DIR}/compile/qt_configure.bat qtbase/configure.bat CONFIGURE_COMMAND configure -prefix ${ETH_DEPENDENCY_INSTALL_DIR} -opensource -confirm-license -release -opengl desktop -platform win32-msvc2013 -icu -I ${ETH_DEPENDENCY_INSTALL_DIR}/include -L ${ETH_DEPENDENCY_INSTALL_DIR}/lib -nomake tests -nomake examples - BUILD_COMMAND nmake INSTALL_COMMAND nmake install ) diff --git a/libdevcore/CMakeLists.txt b/libdevcore/CMakeLists.txt index 3ff0733b4..3d103160c 100644 --- a/libdevcore/CMakeLists.txt +++ b/libdevcore/CMakeLists.txt @@ -6,6 +6,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSTATICLIB") aux_source_directory(. SRC_LIST) include_directories(${LEVELDB_INCLUDE_DIR}) +include_directories(${Boost_INCLUDE_DIRS}) include_directories(..) set(EXECUTABLE devcore) @@ -18,16 +19,13 @@ else() add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS}) endif() +target_link_libraries(${EXECUTABLE} ${Boost_SYSTEM_LIBRARY}) +target_link_libraries(${EXECUTABLE} ${Boost_THREAD_LIBRARY}) + if (APPLE) - # Latest mavericks boost libraries only come with -mt - target_link_libraries(${EXECUTABLE} boost_system-mt) - target_link_libraries(${EXECUTABLE} boost_filesystem-mt) - target_link_libraries(${EXECUTABLE} boost_thread-mt) find_package(Threads REQUIRED) target_link_libraries(${EXECUTABLE} ${CMAKE_THREAD_LIBS_INIT}) elseif (UNIX) - find_package(Boost 1.53 REQUIRED COMPONENTS thread system) - target_link_libraries(${EXECUTABLE} ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY}) find_package(Threads REQUIRED) target_link_libraries(${EXECUTABLE} ${CMAKE_THREAD_LIBS_INIT}) endif() diff --git a/libdevcore/CommonData.cpp b/libdevcore/CommonData.cpp index d34b565eb..215f9c4b3 100644 --- a/libdevcore/CommonData.cpp +++ b/libdevcore/CommonData.cpp @@ -89,13 +89,25 @@ bytes dev::fromHex(std::string const& _s) { ret.push_back(fromHex(_s[s++])); } - catch (...){ ret.push_back(0); cwarn << boost::current_exception_diagnostic_information(); } + catch (...) + { + ret.push_back(0); + // msvc does not support it +#ifndef BOOST_NO_EXCEPTIONS + cwarn << boost::current_exception_diagnostic_information(); +#endif + } for (unsigned i = s; i < _s.size(); i += 2) try { ret.push_back((byte)(fromHex(_s[i]) * 16 + fromHex(_s[i + 1]))); } - catch (...){ ret.push_back(0); cwarn << boost::current_exception_diagnostic_information(); } + catch (...){ + ret.push_back(0); +#ifndef BOOST_NO_EXCEPTIONS + cwarn << boost::current_exception_diagnostic_information(); +#endif + } return ret; } diff --git a/libdevcore/RLP.h b/libdevcore/RLP.h index 3101f63d6..2eedbaba2 100644 --- a/libdevcore/RLP.h +++ b/libdevcore/RLP.h @@ -28,10 +28,10 @@ #include #include #include -#include -#include -#include -#include +#include "vector_ref.h" +#include "Common.h" +#include "Exceptions.h" +#include "FixedHash.h" namespace dev { diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index 744e85a27..5f9332ad8 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -33,7 +33,7 @@ namespace dev namespace eth { -const unsigned c_protocolVersion = 46; +const unsigned c_protocolVersion = 48; const unsigned c_databaseVersion = 5; static const vector> g_units = diff --git a/libevm/ExtVMFace.h b/libevm/ExtVMFace.h index 9e6601d0a..4a175ff4e 100644 --- a/libevm/ExtVMFace.h +++ b/libevm/ExtVMFace.h @@ -36,20 +36,12 @@ namespace dev namespace eth { -template inline std::set toSet(std::vector const& _ts) -{ - std::set ret; - for (auto const& t: _ts) - ret.insert(t); - return ret; -} - using LogBloom = h512; struct LogEntry { LogEntry() {} - LogEntry(RLP const& _r) { address = (Address)_r[0]; topics = (h256s)_r[1]; data = _r[2].toBytes(); } + LogEntry(RLP const& _r) { address = (Address)_r[0]; topics = _r[1].toVector(); data = _r[2].toBytes(); } LogEntry(Address const& _address, h256s const& _ts, bytes&& _d): address(_address), topics(_ts), data(std::move(_d)) {} void streamRLP(RLPStream& _s) const { _s.appendList(3) << address << topics << data; } @@ -88,6 +80,7 @@ struct SubState { suicides += _s.suicides; refunds += _s.refunds; + logs += _s.logs; return *this; } }; diff --git a/libevmcore/CMakeLists.txt b/libevmcore/CMakeLists.txt index b889e7163..0f71dcd40 100644 --- a/libevmcore/CMakeLists.txt +++ b/libevmcore/CMakeLists.txt @@ -5,6 +5,9 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSTATICLIB") aux_source_directory(. SRC_LIST) +include_directories(${Boost_INCLUDE_DIRS}) +include_directories(..) + set(EXECUTABLE evmcore) file(GLOB HEADERS "*.h") @@ -14,8 +17,6 @@ else() add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS}) endif() -include_directories(..) - target_link_libraries(${EXECUTABLE} devcore) install( TARGETS ${EXECUTABLE} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) diff --git a/libevmcore/Instruction.cpp b/libevmcore/Instruction.cpp index 9062fd8ed..b4a4d9f3b 100644 --- a/libevmcore/Instruction.cpp +++ b/libevmcore/Instruction.cpp @@ -326,7 +326,11 @@ InstructionInfo dev::eth::instructionInfo(Instruction _inst) } catch (...) { +#ifndef BOOST_NO_EXCEPTIONS cwarn << "\n" << boost::current_exception_diagnostic_information(); +#else + cwarn << "\n"; +#endif return InstructionInfo({"", 0, 0, 0, false}); } } diff --git a/libjsqrc/CMakeLists.txt b/libjsqrc/CMakeLists.txt index 9c505df2b..b8beec2ff 100644 --- a/libjsqrc/CMakeLists.txt +++ b/libjsqrc/CMakeLists.txt @@ -1,20 +1,4 @@ cmake_policy(SET CMP0015 NEW) - -# Find Qt5 for Apple and update src_list for windows -if (APPLE) - # homebrew defaults to qt4 and installs qt5 as 'keg-only' - # which places it into /usr/local/opt insteadof /usr/local. - - set(CMAKE_PREFIX_PATH /usr/local/opt/qt5) - include_directories(/usr/local/opt/qt5/include /usr/local/include) -elseif ("${TARGET_PLATFORM}" STREQUAL "w64") - set(SRC_LIST ${SRC_LIST} ../windows/qt_plugin_import.cpp) -elseif (UNIX) - set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ";$ENV{QTDIR}/lib/cmake") -endif () - -find_package(Qt5Core) - set(CMAKE_AUTOMOC OFF) qt5_add_resources(JSQRC js.qrc) diff --git a/liblll/CMakeLists.txt b/liblll/CMakeLists.txt index 4e6941359..e2c000010 100644 --- a/liblll/CMakeLists.txt +++ b/liblll/CMakeLists.txt @@ -5,6 +5,9 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSTATICLIB") aux_source_directory(. SRC_LIST) +include_directories(${Boost_INCLUDE_DIRS}) +include_directories(..) + set(EXECUTABLE lll) file(GLOB HEADERS "*.h") @@ -14,36 +17,9 @@ else() add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS}) endif() -include_directories(..) - target_link_libraries(${EXECUTABLE} evmcore) target_link_libraries(${EXECUTABLE} devcore) - -if("${TARGET_PLATFORM}" STREQUAL "w64") - target_link_libraries(${EXECUTABLE} boost_system-mt-s) - target_link_libraries(${EXECUTABLE} boost_thread_win32-mt-s) - target_link_libraries(${EXECUTABLE} iphlpapi) - target_link_libraries(${EXECUTABLE} ws2_32) - target_link_libraries(${EXECUTABLE} mswsock) - target_link_libraries(${EXECUTABLE} shlwapi) -elseif (APPLE) - # Latest mavericks boost libraries only come with -mt - target_link_libraries(${EXECUTABLE} boost_system-mt) - target_link_libraries(${EXECUTABLE} boost_thread-mt) - find_package(Threads REQUIRED) - target_link_libraries(${EXECUTABLE} ${CMAKE_THREAD_LIBS_INIT}) -elseif (UNIX) - target_link_libraries(${EXECUTABLE} ${Boost_SYSTEM_LIBRARY}) - target_link_libraries(${EXECUTABLE} ${Boost_THREAD_LIBRARY}) - target_link_libraries(${EXECUTABLE} ${CMAKE_THREAD_LIBS_INIT}) -else () - target_link_libraries(${EXECUTABLE} boost_system) - target_link_libraries(${EXECUTABLE} boost_thread) - find_package(Threads REQUIRED) - target_link_libraries(${EXECUTABLE} ${CMAKE_THREAD_LIBS_INIT}) -endif () - install( TARGETS ${EXECUTABLE} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} ) diff --git a/libp2p/Host.cpp b/libp2p/Host.cpp index cad1b179c..7d08910aa 100644 --- a/libp2p/Host.cpp +++ b/libp2p/Host.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -199,7 +200,7 @@ Host::Host(std::string const& _clientVersion, NetworkPreferences const& _n, bool m_clientVersion(_clientVersion), m_netPrefs(_n), m_ifAddresses(getInterfaceAddresses()), - m_ioService(new ba::io_service), + m_ioService(new ba::io_service(2)), m_acceptor(new bi::tcp::acceptor(*m_ioService)), m_socket(new bi::tcp::socket(*m_ioService)), m_key(KeyPair::create()) @@ -227,7 +228,7 @@ void Host::stop() { { // prevent m_run from being set to false at same time as set to true by start() - lock_guard l(x_runtimer); + Guard l(x_runTimer); // once m_run is false the scheduler will shutdown network and stopWorking() m_run = false; } @@ -536,7 +537,16 @@ void Host::connect(std::shared_ptr const& _n) // if there's no ioService, it means we've had quit() called - bomb out - we're not allowed in here. if (!m_ioService) return; - + + // prevent concurrently connecting to a node; todo: better abstraction + Node *nptr = _n.get(); + { + Guard l(x_pendingNodeConns); + if (m_pendingNodeConns.count(nptr)) + return; + m_pendingNodeConns.insert(nptr); + } + clog(NetConnect) << "Attempting connection to node" << _n->id.abridged() << "@" << _n->address << "from" << id().abridged(); _n->lastAttempted = std::chrono::system_clock::now(); _n->failedAttempts++; @@ -559,6 +569,8 @@ void Host::connect(std::shared_ptr const& _n) p->start(); } delete s; + Guard l(x_pendingNodeConns); + m_pendingNodeConns.erase(nptr); }); } @@ -685,11 +697,10 @@ PeerInfos Host::peers(bool _updatePing) const ret.push_back(j->m_info); return ret; } - + void Host::run(boost::system::error_code const& error) { - static unsigned s_lasttick = 0; - s_lasttick += c_timerInterval; + m_lastTick += c_timerInterval; if (error || !m_ioService) { @@ -701,11 +712,11 @@ void Host::run(boost::system::error_code const& error) // network running if (m_run) { - if (s_lasttick >= c_timerInterval * 50) + if (m_lastTick >= c_timerInterval * 10) { growPeers(); prunePeers(); - s_lasttick = 0; + m_lastTick = 0; } if (m_hadNewNodes) @@ -771,7 +782,7 @@ void Host::run(boost::system::error_code const& error) m_socket->close(); // m_run is false, so we're stopping; kill timer - s_lasttick = 0; + m_lastTick = 0; // causes parent thread's stop() to continue which calls stopWorking() m_timer.reset(); @@ -794,7 +805,7 @@ void Host::startedWorking() // prevent m_run from being set to true at same time as set to false by stop() // don't release mutex until m_timer is set so in case stop() is called at same // time, stop will wait on m_timer and graceful network shutdown. - lock_guard l(x_runtimer); + Guard l(x_runTimer); // reset io service and create deadline timer m_timer.reset(new boost::asio::deadline_timer(*m_ioService)); m_run = true; diff --git a/libp2p/Host.h b/libp2p/Host.h index c82ecf84c..644afeb69 100644 --- a/libp2p/Host.h +++ b/libp2p/Host.h @@ -224,7 +224,7 @@ private: Nodes potentialPeers(RangeMask const& _known); bool m_run = false; ///< Whether network is running. - std::mutex x_runtimer; ///< Start/stop mutex. + std::mutex x_runTimer; ///< Start/stop mutex. std::string m_clientVersion; ///< Our version string. @@ -241,6 +241,10 @@ private: std::unique_ptr m_timer; ///< Timer which, when network is running, calls scheduler() every c_timerInterval ms. static const unsigned c_timerInterval = 100; ///< Interval which m_timer is run when network is connected. + unsigned m_lastTick = 0; ///< Used by run() for scheduling; must not be mutated outside of run(). + + std::set m_pendingNodeConns; /// Used only by connect(Node&) to limit concurrently connecting to same node. See connect(shared_ptrconst&). + Mutex x_pendingNodeConns; bi::tcp::endpoint m_public; ///< Our public listening endpoint. KeyPair m_key; ///< Our unique ID. diff --git a/libsolidity/CMakeLists.txt b/libsolidity/CMakeLists.txt index 260493b0e..8522130ee 100644 --- a/libsolidity/CMakeLists.txt +++ b/libsolidity/CMakeLists.txt @@ -5,6 +5,9 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSTATICLIB") aux_source_directory(. SRC_LIST) +include_directories(${Boost_INCLUDE_DIRS}) +include_directories(..) + set(EXECUTABLE solidity) file(GLOB HEADERS "*.h") @@ -14,8 +17,6 @@ else() add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS}) endif() -include_directories(..) - target_link_libraries(${EXECUTABLE} evmcore devcore) install( TARGETS ${EXECUTABLE} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) diff --git a/libsolidity/GlobalContext.cpp b/libsolidity/GlobalContext.cpp index d8b637076..b54b93c03 100644 --- a/libsolidity/GlobalContext.cpp +++ b/libsolidity/GlobalContext.cpp @@ -33,7 +33,7 @@ namespace solidity { GlobalContext::GlobalContext(): - m_magicVariables{make_shared("block", make_shared(MagicType::Kind::BLOCK)), +m_magicVariables(vector>{make_shared("block", make_shared(MagicType::Kind::BLOCK)), make_shared("msg", make_shared(MagicType::Kind::MSG)), make_shared("tx", make_shared(MagicType::Kind::TX)), make_shared("suicide", @@ -59,7 +59,7 @@ GlobalContext::GlobalContext(): make_shared("ripemd160", make_shared(TypePointers({std::make_shared(256, IntegerType::Modifier::HASH)}), TypePointers({std::make_shared(160, IntegerType::Modifier::HASH)}), - FunctionType::Location::RIPEMD160))} + FunctionType::Location::RIPEMD160))}) { } diff --git a/libwhisper/WhisperHost.cpp b/libwhisper/WhisperHost.cpp index 9b26e3260..769b39057 100644 --- a/libwhisper/WhisperHost.cpp +++ b/libwhisper/WhisperHost.cpp @@ -118,7 +118,6 @@ unsigned WhisperHost::installWatch(shh::TopicFilter const& _f) h256s WhisperHost::watchMessages(unsigned _watchId) { - cleanup(); h256s ret; auto wit = m_watches.find(_watchId); if (wit == m_watches.end()) @@ -160,6 +159,7 @@ void WhisperHost::doWork() { for (auto& i: peers()) i->cap()->sendMessages(); + cleanup(); } void WhisperHost::cleanup() diff --git a/libwhisper/WhisperPeer.cpp b/libwhisper/WhisperPeer.cpp index c3a28e3c3..0951a3726 100644 --- a/libwhisper/WhisperPeer.cpp +++ b/libwhisper/WhisperPeer.cpp @@ -82,33 +82,23 @@ bool WhisperPeer::interpret(unsigned _id, RLP const& _r) void WhisperPeer::sendMessages() { - RLPStream amalg; - unsigned n = 0; - + if (m_unseen.size()) { - Guard l(x_unseen); - while (m_unseen.size()) + RLPStream amalg; + unsigned msgCount; { - auto p = *m_unseen.begin(); - m_unseen.erase(m_unseen.begin()); - host()->streamMessage(p.second, amalg); - n++; + Guard l(x_unseen); + msgCount = m_unseen.size(); + while (m_unseen.size()) + { + auto p = *m_unseen.begin(); + m_unseen.erase(m_unseen.begin()); + host()->streamMessage(p.second, amalg); + } } - } - - // the message subsystem should really just keep pumping out messages while m_unseen.size() and there's bandwidth for them. - auto diff = chrono::duration_cast(chrono::system_clock::now() - m_timer); - if (n || diff.count() > 0) - { - RLPStream s; - prep(s, MessagesPacket, n).appendRaw(amalg.out(), n); - sealAndSend(s); - m_timer = chrono::system_clock::now(); - } - - { + RLPStream s; - prep(s, MessagesPacket, n).appendRaw(amalg.out(), n); + prep(s, MessagesPacket, msgCount).appendRaw(amalg.out(), msgCount); sealAndSend(s); } } diff --git a/lllc/CMakeLists.txt b/lllc/CMakeLists.txt index 3310354fb..0ca19fab9 100644 --- a/lllc/CMakeLists.txt +++ b/lllc/CMakeLists.txt @@ -3,31 +3,22 @@ set(CMAKE_AUTOMOC OFF) aux_source_directory(. SRC_LIST) +include_directories(${Boost_INCLUDE_DIRS}) include_directories(..) set(EXECUTABLE lllc) -add_executable(${EXECUTABLE} ${SRC_LIST}) +if(ETH_STATIC) + add_library(${EXECUTABLE} STATIC ${SRC_LIST} ${HEADERS}) +else() + add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS}) +endif() + +add_dependencies(${EXECUTABLE} BuildInfo.h) target_link_libraries(${EXECUTABLE} lll) target_link_libraries(${EXECUTABLE} evmcore) target_link_libraries(${EXECUTABLE} devcore) -if ("${TARGET_PLATFORM}" STREQUAL "w64") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++") - target_link_libraries(${EXECUTABLE} gcc) - target_link_libraries(${EXECUTABLE} gdi32) - target_link_libraries(${EXECUTABLE} ws2_32) - target_link_libraries(${EXECUTABLE} mswsock) - target_link_libraries(${EXECUTABLE} shlwapi) - target_link_libraries(${EXECUTABLE} iphlpapi) - target_link_libraries(${EXECUTABLE} boost_thread_win32-mt-s) - set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS) -elseif (UNIX) -else () - find_package(Threads REQUIRED) - target_link_libraries(${EXECUTABLE} ${CMAKE_THREAD_LIBS_INIT}) -endif () - install( TARGETS ${EXECUTABLE} DESTINATION bin )