From 8cc8b8009c5ff5924c7ca5812d8b0a0c66cbf34a Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sat, 8 Aug 2015 01:38:32 +0200 Subject: [PATCH 1/5] Don't rely on file for nonce data. --- libdevcrypto/Common.cpp | 21 +-------------------- libdevcrypto/Common.h | 6 ------ 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/libdevcrypto/Common.cpp b/libdevcrypto/Common.cpp index a2907d2ed..e1ea2d6ec 100644 --- a/libdevcrypto/Common.cpp +++ b/libdevcrypto/Common.cpp @@ -308,33 +308,14 @@ h256 crypto::kdf(Secret const& _priv, h256 const& _hash) return s; } -string const& Nonce::seedFilePath(string const& _filePath) -{ - static mutex x_seedFile; - static string s_seedFile; - - Guard l(x_seedFile); - if (s_seedFile.empty()) - s_seedFile = _filePath.empty() ? getDataDir() + "/seed" : _filePath; - return s_seedFile; -} - Secret Nonce::next() { Guard l(x_value); if (!m_value) { - bytesSec b = contentsSec(seedFilePath()); - if (b.size() == 32) - b.ref().populate(m_value.writable().ref()); - else - m_value = Secret::random(); + m_value = Secret::random(); if (!m_value) BOOST_THROW_EXCEPTION(InvalidState()); - - // prevent seed reuse if process terminates abnormally - // this might throw - writeFile(seedFilePath(), bytes()); } m_value = sha3Secure(m_value.ref()); return sha3(~m_value); diff --git a/libdevcrypto/Common.h b/libdevcrypto/Common.h index debeee8d6..22460e940 100644 --- a/libdevcrypto/Common.h +++ b/libdevcrypto/Common.h @@ -203,14 +203,8 @@ public: /// Returns the next nonce (might be read from a file). static Secret get() { static Nonce s; return s.next(); } - /// @returns path of the seed file. FOR TESTS ONLY: optionally set path to @_filePath. - static std::string const& seedFilePath(std::string const& _filePath = std::string()); - private: Nonce() = default; - - /// Destructor. IO operation may throw. - ~Nonce() { if (m_value && next()) dev::writeFile(seedFilePath(), m_value.ref()); } /// @returns the next nonce. Secret next(); From 02cf8c8f2030b71c051624c0f5c1c7c99b704d8a Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sat, 8 Aug 2015 20:08:27 +0200 Subject: [PATCH 2/5] =?UTF-8?q?Fix=20compile=20issue.=C2=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libethereum/BlockChain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 546f29b3e..14d199369 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -394,7 +394,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::Everything & ~ImportRequirements::ValidSeal & ~ImportRequirements::CheckUncles != 0); + r = import(block.verified, _stateDB, (ImportRequirements::Everything & ~ImportRequirements::ValidSeal & ~ImportRequirements::CheckUncles) != 0); fresh += r.liveBlocks; dead += r.deadBlocks; goodTransactions.reserve(goodTransactions.size() + r.goodTranactions.size()); From b65ca8d2541cf562c423234ad08603c3c1954aac Mon Sep 17 00:00:00 2001 From: subtly Date: Mon, 10 Aug 2015 11:18:32 +0200 Subject: [PATCH 3/5] remove MoveNonceToTempDir --- test/TestUtils.cpp | 5 ----- test/TestUtils.h | 8 -------- test/libdevcrypto/SecretStore.cpp | 2 -- test/libdevcrypto/crypto.cpp | 2 -- 4 files changed, 17 deletions(-) diff --git a/test/TestUtils.cpp b/test/TestUtils.cpp index 0ec76386b..5e0619c0e 100644 --- a/test/TestUtils.cpp +++ b/test/TestUtils.cpp @@ -120,8 +120,3 @@ void ParallelClientBaseFixture::enumerateClients(std::function Date: Mon, 10 Aug 2015 11:25:36 +0200 Subject: [PATCH 4/5] Remove (++). --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f0b313164..55aefe335 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -527,8 +527,8 @@ endif () if (WIN32) # packaging stuff include(InstallRequiredSystemLibraries) - set(CPACK_PACKAGE_NAME "Ethereum (++)") - set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Ethereum (++) Toolset") + set(CPACK_PACKAGE_NAME "Ethereum") + set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Ethereum Toolset") set(CPACK_PACKAGE_VENDOR "ethereum.org") set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") @@ -557,7 +557,7 @@ if (WIN32) set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}") endif() - set(CPACK_NSIS_DISPLAY_NAME "Ethereum (++)") + set(CPACK_NSIS_DISPLAY_NAME "Ethereum") set(CPACK_NSIS_HELP_LINK "https://github.com/ethereum/cpp-ethereum") set(CPACK_NSIS_URL_INFO_ABOUT "https://github.com/ethereum/cpp-ethereum") set(CPACK_NSIS_CONTACT "ethereum.org") From db0bcb9f8c9fad28617d2f22d7d7daff958efd89 Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 10 Aug 2015 11:59:06 +0200 Subject: [PATCH 5/5] Fixed creation of shared_ptr in RLPXSocket. --- libp2p/Host.cpp | 4 ++-- libp2p/RLPXSocket.h | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/libp2p/Host.cpp b/libp2p/Host.cpp index b3b3d5bf3..64d10b172 100644 --- a/libp2p/Host.cpp +++ b/libp2p/Host.cpp @@ -396,7 +396,7 @@ void Host::runAcceptor() clog(NetConnect) << "Listening on local port " << m_listenPort << " (public: " << m_tcpPublic << ")"; m_accepting = true; - auto socket = make_shared(new bi::tcp::socket(m_ioService)); + auto socket = make_shared(m_ioService); m_tcp4Acceptor.async_accept(socket->ref(), [=](boost::system::error_code ec) { m_accepting = false; @@ -552,7 +552,7 @@ void Host::connect(std::shared_ptr const& _p) bi::tcp::endpoint ep(_p->endpoint); clog(NetConnect) << "Attempting connection to node" << _p->id << "@" << ep << "from" << id(); - auto socket = make_shared(new bi::tcp::socket(m_ioService)); + auto socket = make_shared(m_ioService); socket->ref().async_connect(ep, [=](boost::system::error_code const& ec) { _p->m_lastAttempted = std::chrono::system_clock::now(); diff --git a/libp2p/RLPXSocket.h b/libp2p/RLPXSocket.h index 58613bf82..171a7b35b 100644 --- a/libp2p/RLPXSocket.h +++ b/libp2p/RLPXSocket.h @@ -39,8 +39,7 @@ namespace p2p class RLPXSocket: public std::enable_shared_from_this { public: - /// Constructor. Dereferences and takes ownership of _socket. - RLPXSocket(bi::tcp::socket* _socket): m_socket(std::move(*_socket)) {} + RLPXSocket(ba::io_service& _ioService): m_socket(_ioService) {} ~RLPXSocket() { close(); } bool isConnected() const { return m_socket.is_open(); }