File tree Expand file tree Collapse file tree 5 files changed +5
-40
lines changed Expand file tree Collapse file tree 5 files changed +5
-40
lines changed Original file line number Diff line number Diff line change @@ -69,12 +69,13 @@ static void SignTransactionSchnorr(benchmark::Bench& bench) { SignTransactionSin
6969
7070static void SignSchnorrTapTweakBenchmark (benchmark::Bench& bench, bool use_null_merkle_root)
7171{
72+ FastRandomContext rng;
7273 ECC_Context ecc_context{};
7374
7475 auto key = GenerateRandomKey ();
75- auto msg = InsecureRand256 ();
76- auto merkle_root = use_null_merkle_root ? uint256 () : InsecureRand256 ();
77- auto aux = InsecureRand256 ();
76+ auto msg = rng. rand256 ();
77+ auto merkle_root = use_null_merkle_root ? uint256 () : rng. rand256 ();
78+ auto aux = rng. rand256 ();
7879 std::vector<unsigned char > sig (64 );
7980
8081 bench.minEpochIterations (100 ).run ([&] {
Original file line number Diff line number Diff line change @@ -107,7 +107,6 @@ void initialize()
107107 // - GetStrongRandBytes(), which is used for the creation of private key material.
108108 // - Creating a BasicTestingSetup or derived class will switch to a random seed.
109109 SeedRandomStateForTest (SeedRand::ZEROS);
110- g_insecure_rand_ctx.Reseed (GetRandHash ());
111110
112111 // Terminate immediately if a fuzzing harness ever tries to create a socket.
113112 // Individual tests can override this by pointing CreateSock to a mocked alternative.
Original file line number Diff line number Diff line change 1111#include < cstdlib>
1212#include < string>
1313
14- FastRandomContext g_insecure_rand_ctx;
15-
1614extern void MakeRandDeterministicDANGEROUS (const uint256& seed) noexcept ;
1715
1816void SeedRandomStateForTest (SeedRand seedtype)
Original file line number Diff line number Diff line change 1111
1212#include < cstdint>
1313
14- /* *
15- * This global and the helpers that use it are not thread-safe.
16- *
17- * If thread-safety is needed, a per-thread instance could be
18- * used in the multi-threaded test.
19- */
20- extern FastRandomContext g_insecure_rand_ctx;
21-
2214enum class SeedRand {
2315 ZEROS, // !< Seed with a compile time constant of zeros
2416 SEED, // !< Use (and report) random seed from environment, or a (truly) random one.
@@ -27,31 +19,6 @@ enum class SeedRand {
2719/* * Seed the global RNG state for testing and log the seed value. This affects all randomness, except GetStrongRandBytes(). */
2820void SeedRandomStateForTest (SeedRand seed);
2921
30- static inline uint32_t InsecureRand32 ()
31- {
32- return g_insecure_rand_ctx.rand32 ();
33- }
34-
35- static inline uint256 InsecureRand256 ()
36- {
37- return g_insecure_rand_ctx.rand256 ();
38- }
39-
40- static inline uint64_t InsecureRandBits (int bits)
41- {
42- return g_insecure_rand_ctx.randbits (bits);
43- }
44-
45- static inline uint64_t InsecureRandRange (uint64_t range)
46- {
47- return g_insecure_rand_ctx.randrange (range);
48- }
49-
50- static inline bool InsecureRandBool ()
51- {
52- return g_insecure_rand_ctx.randbool ();
53- }
54-
5522template <RandomNumberGenerator Rng>
5623inline CAmount RandMoney (Rng&& rng)
5724{
Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ struct BasicTestingSetup {
6666 util::SignalInterrupt m_interrupt;
6767 node::NodeContext m_node; // keep as first member to be destructed last
6868
69- FastRandomContext& m_rng{g_insecure_rand_ctx}; // Alias (reference) for the global, to allow easy removal of the global in the future.
69+ FastRandomContext m_rng;
7070 /* * Seed the global RNG state and m_rng for testing and log the seed value. This affects all randomness, except GetStrongRandBytes(). */
7171 void SeedRandomForTest (SeedRand seed = SeedRand::SEED)
7272 {
You can’t perform that action at this time.
0 commit comments