Browse Source

Use boost's guaranteed non-deterministic random number generator. If it

compiles, it's safe.
cl-refactor
Gav Wood 9 years ago
parent
commit
09e5dbfa06
  1. 2
      cmake/EthDependencies.cmake
  2. 1
      libdevcore/CMakeLists.txt
  3. 1
      libdevcore/CommonData.cpp
  4. 2
      libdevcore/FixedHash.cpp
  5. 4
      libdevcore/FixedHash.h
  6. 3
      libdevcore/vector_ref.h
  7. 1
      libdevcrypto/Common.cpp
  8. 5
      libethash-cl/ethash_cl_miner.cpp
  9. 1
      libethcore/Common.cpp
  10. 1
      libethcore/Ethash.cpp
  11. 1
      libethcore/EthashAux.cpp
  12. 1
      libethereum/State.cpp
  13. 1
      test/libdevcrypto/SecretStore.cpp
  14. 1
      test/libdevcrypto/crypto.cpp
  15. 3
      test/libdevcrypto/trie.cpp
  16. 1
      test/libethcore/dagger.cpp
  17. 3
      test/libethereum/genesis.cpp
  18. 1
      test/libp2p/rlpx.cpp

2
cmake/EthDependencies.cmake

@ -213,7 +213,7 @@ elseif (UNIX)
endif()
find_package(Boost 1.54.0 REQUIRED COMPONENTS thread date_time system regex chrono filesystem unit_test_framework program_options)
find_package(Boost 1.54.0 REQUIRED COMPONENTS thread date_time system regex chrono filesystem unit_test_framework program_options random)
message(" - boost header: ${Boost_INCLUDE_DIRS}")
message(" - boost lib : ${Boost_LIBRARIES}")

1
libdevcore/CMakeLists.txt

@ -26,6 +26,7 @@ add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS})
target_link_libraries(${EXECUTABLE} ${Boost_THREAD_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${Boost_SYSTEM_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${Boost_FILESYSTEM_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${Boost_RANDOM_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${JSONCPP_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${DB_LIBRARIES})

1
libdevcore/CommonData.cpp

@ -21,7 +21,6 @@
#include "CommonData.h"
#include <random>
#include "Exceptions.h"
#include "Log.h"

2
libdevcore/FixedHash.cpp

@ -26,7 +26,7 @@
using namespace std;
using namespace dev;
std::random_device dev::s_fixedHashEngine;
boost::random_device dev::s_fixedHashEngine;
h128 dev::fromUUID(std::string const& _uuid)
{

4
libdevcore/FixedHash.h

@ -25,8 +25,8 @@
#include <array>
#include <cstdint>
#include <random>
#include <algorithm>
#include <boost/random/random_device.hpp>
#include "CommonData.h"
namespace dev
@ -36,7 +36,7 @@ namespace dev
template <unsigned N> struct StaticLog2 { enum { result = 1 + StaticLog2<N/2>::result }; };
template <> struct StaticLog2<1> { enum { result = 0 }; };
extern std::random_device s_fixedHashEngine;
extern boost::random_device s_fixedHashEngine;
/// Fixed-size raw-byte array container type, with an API optimised for storing hashes.
/// Transparently converts to/from the corresponding arithmetic type; this will

3
libdevcore/vector_ref.h

@ -6,12 +6,13 @@
#include <vector>
#include <string>
#include <random>
#include <boost/random/random_device.hpp>
namespace dev
{
static unsigned char s_cleanseCounter = 0;
static std::random_device s_vectorRefEngine;
static boost::random_device s_vectorRefEngine;
/**
* A modifiable reference to an existing object or vector in memory.

1
libdevcrypto/Common.cpp

@ -21,7 +21,6 @@
*/
#include "Common.h"
#include <random>
#include <cstdint>
#include <chrono>
#include <thread>

5
libethash-cl/ethash_cl_miner.cpp

@ -29,8 +29,9 @@
#include <iostream>
#include <assert.h>
#include <queue>
#include <random>
#include <vector>
#include <random>
#include <boost/random/random_device.hpp>
#include <libethash/util.h>
#include <libethash/ethash.h>
#include <libethash/internal.h>
@ -470,7 +471,7 @@ void ethash_cl_miner::search(uint8_t const* header, uint64_t target, search_hook
m_searchKernel.setArg(argPos + 2, ~0u);
unsigned buf = 0;
random_device engine;
boost::random_device engine;
uint64_t start_nonce = uniform_int_distribution<uint64_t>()(engine);
for (;; start_nonce += m_globalWorkSize)
{

1
libethcore/Common.cpp

@ -20,7 +20,6 @@
*/
#include "Common.h"
#include <random>
#include <boost/algorithm/string/case_conv.hpp>
#include <libdevcore/Base64.h>
#include <libdevcore/Terminal.h>

1
libethcore/Ethash.cpp

@ -26,7 +26,6 @@
#include <chrono>
#include <array>
#include <thread>
#include <random>
#include <thread>
#include <libdevcore/Guards.h>
#include <libdevcore/Log.h>

1
libethcore/EthashAux.cpp

@ -25,7 +25,6 @@
#include <boost/filesystem.hpp>
#include <chrono>
#include <array>
#include <random>
#include <thread>
#include <libdevcore/Common.h>
#include <libdevcore/Guards.h>

1
libethereum/State.cpp

@ -22,7 +22,6 @@
#include "State.h"
#include <ctime>
#include <random>
#include <boost/filesystem.hpp>
#include <boost/timer.hpp>
#include <libdevcore/CommonIO.h>

1
test/libdevcrypto/SecretStore.cpp

@ -21,7 +21,6 @@
*/
#include <fstream>
#include <random>
#include <boost/test/unit_test.hpp>
#include "../JsonSpiritHeaders.h"
#include <libdevcrypto/SecretStore.h>

1
test/libdevcrypto/crypto.cpp

@ -21,7 +21,6 @@
* Crypto test functions.
*/
#include <random>
#if ETH_HAVE_SECP256K1
#include <secp256k1/include/secp256k1.h>
#endif

3
test/libdevcrypto/trie.cpp

@ -21,10 +21,7 @@
*/
#include <fstream>
#include <random>
#include <boost/test/unit_test.hpp>
#include "../JsonSpiritHeaders.h"
#include <libdevcore/CommonIO.h>
#include <libdevcore/TrieDB.h>

1
test/libethcore/dagger.cpp

@ -21,7 +21,6 @@
*/
#include <fstream>
#include <random>
#include "../JsonSpiritHeaders.h"
#include <libdevcore/CommonIO.h>
#include <libethcore/EthashAux.h>

3
test/libethereum/genesis.cpp

@ -21,10 +21,7 @@
*/
#include <fstream>
#include <random>
#include <boost/test/unit_test.hpp>
#include "../JsonSpiritHeaders.h"
#include <libdevcore/CommonIO.h>
#include <libethereum/CanonBlockChain.h>

1
test/libp2p/rlpx.cpp

@ -20,7 +20,6 @@
* RLPx test functions.
*/
#include <random>
#include <libdevcore/Common.h>
#include <libdevcore/RLP.h>
#include <libdevcore/Log.h>

Loading…
Cancel
Save