fuzz: don't set random state for private broadcast test #36404

Manually merged
andrewtoth merged 1 commit from private_broadcast_remove_fuzz_seed into master 2026-10-02 23:42:06 +00:00 AGit
andrewtoth commented 2026-10-01 20:10:12 +00:00 (Migrated from github.com)

The private broadcast fuzz test does not use any randomness.
This was added in #35129 based on a draft created in #29415. That draft was created when the state of #29415 was still using SaltedTxidHashers, but this usage was removed before it was merged.

Setting the random state while not using it is causing issues with nightly https://github.com/maflcko/bitcoin-core-nightly/issues/25.

The private broadcast fuzz test does not use any randomness. This was added in #35129 based on a draft created in #29415. That draft was created when the state of #29415 was still using `SaltedTxidHasher`s, but this usage was removed before it was merged. Setting the random state while not using it is causing issues with nightly https://github.com/maflcko/bitcoin-core-nightly/issues/25.
DrahtBot commented 2026-10-01 20:10:22 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK kevkevinpal, vasild, maflcko, achow101

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36404 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36404.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36404#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [kevkevinpal](https://github.com/bitcoin/bitcoin/pull/36404#issuecomment-5944926295), [vasild](https://github.com/bitcoin/bitcoin/pull/36404#pullrequestreview-5389584153), [maflcko](https://github.com/bitcoin/bitcoin/pull/36404#issuecomment-5953763880), [achow101](https://github.com/bitcoin/bitcoin/pull/36404#issuecomment-5963125599) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--5faf32d7da4f0f540f40219e4f7537a3-->
First-time contributor

Base: 7988380da987c0b860885853ace8149b84ac2ee8
Head: 1d19cca0761ab35eb46867df2aacdc9715fa5ae0

No verified findings are available from this partial review.

Review coverage was incomplete. The archaeology review had incomplete evidence.

Full review report

<!-- forgejo-review-bot:bitcoin/bitcoin --> Base: `7988380da987c0b860885853ace8149b84ac2ee8` Head: `1d19cca0761ab35eb46867df2aacdc9715fa5ae0` No verified findings are available from this partial review. Review coverage was incomplete. The archaeology review had incomplete evidence. [Full review report](<https://review.fish.foo/traces/36404-1d19cca0761ab35eb46867df2aacdc9715fa5ae0-209-1.html>)
kevkevinpal commented 2026-10-02 03:11:51 +00:00 (Migrated from github.com)

ACK 1d19cca

Normally this wouldn't fail but in maflcko's nightly build there is this check that causes the test to fail

g_ever_used_g_prng |= g_used_g_prng; // after each input

if (tested && !g_ever_used_g_prng && g_seeded_g_prng_zero) {
    Assert(false); // remove unused SeedRandomStateForTest(SeedRand::ZEROS)?
}

Link to this code

Nontheless this change makes sense because we do not need SeedRandomStateForTest(SeedRand::ZEROS);

ACK [1d19cca](https://github.com/bitcoin/bitcoin/pull/36404/commits/1d19cca0761ab35eb46867df2aacdc9715fa5ae0) Normally this wouldn't fail but in maflcko's nightly build there is this check that causes the test to fail ``` g_ever_used_g_prng |= g_used_g_prng; // after each input if (tested && !g_ever_used_g_prng && g_seeded_g_prng_zero) { Assert(false); // remove unused SeedRandomStateForTest(SeedRand::ZEROS)? } ``` [Link to this code](https://github.com/maflcko/bitcoin-core-with-ci/blob/2601-nightly-qa-mutations/src/test/fuzz/fuzz.cpp#L278-L280) Nontheless this change makes sense because we do not need `SeedRandomStateForTest(SeedRand::ZEROS);`
vasild (Migrated from github.com) approved these changes 2026-10-02 08:11:17 +00:00
vasild (Migrated from github.com) left a comment

ACK 1d19cca076

Is it possible to have this check run on PR CIs so that it is caught before the code is merged into master?

Is this harmful in any way more than being a useless code clutter?

Is there the reverse check either in master or elsewhere - to detect if a test does not set the random state and then uses random?

ACK 1d19cca0761ab35eb46867df2aacdc9715fa5ae0 Is it possible to have this check run on PR CIs so that it is caught before the code is merged into `master`? Is this harmful in any way more than being a useless code clutter? Is there the reverse check either in `master` or elsewhere - to detect if a test does not set the random state and then uses random?
andrewtoth commented 2026-10-02 12:36:05 +00:00 (Migrated from github.com)

Is it possible to have this check run on PR CIs so that it is caught before the code is merged into master?

cc @maflcko

Is this harmful in any way more than being a useless code clutter?

I don't think it's harmful, but not sure.

Is there the reverse check either in master or elsewhere - to detect if a test does not set the random state and then uses random?

Yes, if this line is missing and the harness or code under test accesses the global RNG the CI fails loudly for all fuzz jobs.

> Is it possible to have this check run on PR CIs so that it is caught before the code is merged into master? cc @maflcko > Is this harmful in any way more than being a useless code clutter? I don't think it's harmful, but not sure. > Is there the reverse check either in master or elsewhere - to detect if a test does not set the random state and then uses random? Yes, if this line is missing and the harness or code under test accesses the global RNG the CI fails loudly for all fuzz jobs.
maflcko commented 2026-10-02 13:45:04 +00:00 (Migrated from github.com)

Is it possible to have this check run on PR CIs so that it is caught before the code is merged into master?

cc @maflcko

No. Fuzz tests are similar to unit tests, because both describe a test case. However, unit tests have their input values hard-coded or hard-derived. Fuzz tests have their input values derived by a fuzz engine and mutable sets of inputs are stored in a folder: qa-assets.

Thus, to know that the fuzz test has "full" coverage and does not need randomness, the fuzz inputs have to be submitted before CI runs. However, usually the fuzz engine is only started after CI runs on a pull, usually even after a pull is merged.

Is this harmful in any way more than being a useless code clutter?

I don't think it's harmful, but not sure.

Right, it is just a stupid "linter". I think it makes sense to limit global setup, but no strong opinion.

lgtm ACK 1d19cca076

> > Is it possible to have this check run on PR CIs so that it is caught before the code is merged into master? > > cc @maflcko No. Fuzz tests are similar to unit tests, because both describe a test case. However, unit tests have their input values hard-coded or hard-derived. Fuzz tests have their input values derived by a fuzz engine and mutable sets of inputs are stored in a folder: qa-assets. Thus, to know that the fuzz test has "full" coverage and does not need randomness, the fuzz inputs have to be submitted *before* CI runs. However, usually the fuzz engine is only started *after* CI runs on a pull, usually even after a pull is merged. > > Is this harmful in any way more than being a useless code clutter? > > I don't think it's harmful, but not sure. Right, it is just a stupid "linter". I think it makes sense to limit global setup, but no strong opinion. lgtm ACK 1d19cca0761ab35eb46867df2aacdc9715fa5ae0
achow101 commented 2026-10-02 23:34:02 +00:00 (Migrated from github.com)
ACK 1d19cca0761ab35eb46867df2aacdc9715fa5ae0
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36404
No description provided.