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
69
69
70
70
static void SignSchnorrTapTweakBenchmark (benchmark::Bench& bench, bool use_null_merkle_root)
71
71
{
72
+ FastRandomContext rng;
72
73
ECC_Context ecc_context{};
73
74
74
75
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 ();
78
79
std::vector<unsigned char > sig (64 );
79
80
80
81
bench.minEpochIterations (100 ).run ([&] {
Original file line number Diff line number Diff line change @@ -107,7 +107,6 @@ void initialize()
107
107
// - GetStrongRandBytes(), which is used for the creation of private key material.
108
108
// - Creating a BasicTestingSetup or derived class will switch to a random seed.
109
109
SeedRandomStateForTest (SeedRand::ZEROS);
110
- g_insecure_rand_ctx.Reseed (GetRandHash ());
111
110
112
111
// Terminate immediately if a fuzzing harness ever tries to create a socket.
113
112
// Individual tests can override this by pointing CreateSock to a mocked alternative.
Original file line number Diff line number Diff line change 11
11
#include < cstdlib>
12
12
#include < string>
13
13
14
- FastRandomContext g_insecure_rand_ctx;
15
-
16
14
extern void MakeRandDeterministicDANGEROUS (const uint256& seed) noexcept ;
17
15
18
16
void SeedRandomStateForTest (SeedRand seedtype)
Original file line number Diff line number Diff line change 11
11
12
12
#include < cstdint>
13
13
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
-
22
14
enum class SeedRand {
23
15
ZEROS, // !< Seed with a compile time constant of zeros
24
16
SEED, // !< Use (and report) random seed from environment, or a (truly) random one.
@@ -27,31 +19,6 @@ enum class SeedRand {
27
19
/* * Seed the global RNG state for testing and log the seed value. This affects all randomness, except GetStrongRandBytes(). */
28
20
void SeedRandomStateForTest (SeedRand seed);
29
21
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
-
55
22
template <RandomNumberGenerator Rng>
56
23
inline CAmount RandMoney (Rng&& rng)
57
24
{
Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ struct BasicTestingSetup {
66
66
util::SignalInterrupt m_interrupt;
67
67
node::NodeContext m_node; // keep as first member to be destructed last
68
68
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;
70
70
/* * Seed the global RNG state and m_rng for testing and log the seed value. This affects all randomness, except GetStrongRandBytes(). */
71
71
void SeedRandomForTest (SeedRand seed = SeedRand::SEED)
72
72
{
You can’t perform that action at this time.
0 commit comments