From faa3ce31998cdbdcb888132b0d38ee7a1e743682 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 9 Apr 2025 17:58:20 +0200 Subject: [PATCH] fuzz: Avoid influence on the global RNG from peerman m_rng This should avoid the remaining non-determistic code coverage paths. Without this patch, the tool would report a diff (only when running without libFuzzer): cargo run --manifest-path ./contrib/devtools/deterministic-fuzz-coverage/Cargo.toml -- $PWD/bld-cmake/ $PWD/../qa-assets/fuzz_corpora/ p2p_headers_presync 32 --- src/test/fuzz/p2p_headers_presync.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test/fuzz/p2p_headers_presync.cpp b/src/test/fuzz/p2p_headers_presync.cpp index 3a7146df8fe..b31b74ee4fe 100644 --- a/src/test/fuzz/p2p_headers_presync.cpp +++ b/src/test/fuzz/p2p_headers_presync.cpp @@ -32,6 +32,12 @@ public: PeerManager::Options peerman_opts; node::ApplyArgsManOptions(*m_node.args, peerman_opts); peerman_opts.max_headers_result = FUZZ_MAX_HEADERS_RESULTS; + // The peerman's rng is a global that is re-used, so it will be re-used + // and may cause non-determinism between runs. This may even influence + // the global RNG, because seeding may be done from the gloabl one. For + // now, avoid it influencing the global RNG, and initialize it with a + // constant instead. + peerman_opts.deterministic_rng = true; // No txs are relayed. Disable irrelevant and possibly // non-deterministic code paths. peerman_opts.ignore_incoming_txs = true;