bench: use deterministic `HexStr` payload
What changed, and why it matters
This is a harmless internal cleanup of a performance benchmark. It swaps the test data used to measure a hex-encoding function from a real historical block file to computer-generated random bytes. There is no change to how Bitcoin Core handles real network data, no bug fix, and no security relevance.
No action required. This is a benchmark-only refactor with no security implications.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies src/bench/strencodings.cpp’s HexStrBench. It removes the inclusion of bench/data/block413567.raw.h and instead uses a deterministic FastRandomContext to generate MAX_BLOCK_WEIGHT pseudo-random bytes. The benchmark still exercises HexStr over a large byte span; only the input source and size (~1 MB fixture to 4 MB generated) change. No runtime code, consensus code, or network-facing code is touched.
Changed components
src/bench/strencodings.cppInspect captured patch +4 / −2
diff --git a/src/bench/strencodings.cpp b/src/bench/strencodings.cpp
index a0767b49..7d4e1887 100644
--- a/src/bench/strencodings.cpp
+++ b/src/bench/strencodings.cpp
@@ -3,7 +3,8 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <bench/bench.h>
-#include <bench/data/block413567.raw.h>
+#include <consensus/consensus.h>
+#include <random.h>
#include <span.h>
#include <util/strencodings.h>
@@ -11,7 +12,8 @@
static void HexStrBench(benchmark::Bench& bench)
{
- auto const& data = benchmark::data::block413567;
+ FastRandomContext rng{/*fDeterministic=*/true};
+ auto data{rng.randbytes<std::byte>(MAX_BLOCK_WEIGHT)};
bench.batch(data.size()).unit("byte").run([&] {
auto hex = HexStr(data);
ankerl::nanobench::doNotOptimizeAway(hex);
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.