WIP: iwyu: Fix warnings in src/test/fuzz and treat them as errors #36808

Draft
hebasto wants to merge 3 commits from 261108-iwyu-fuzz into master AGit
hebasto commented 2026-11-08 19:03:27 +00:00 (Migrated from github.com)
This PR continues the ongoing effort to enforce IWYU warnings. See [Developer Notes](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#using-iwyu). Based on https://github.com/bitcoin/bitcoin/pull/36844.
DrahtBot commented 2026-11-08 19:03:38 +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.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #37015 (Use O(log n) skiplist construction in CBlockIndex by sipa)
  • #36996 (fuzz: fix timelock range in miniscript_smart by erickcestari)
  • #36946 (scripted-diff: [test] Add util/check.h includes for assertions by maflcko)
  • #36897 (wallet, migration: Contain all legacy wallet and migration related things in its own subdirectory, namespace, and classes by achow101)
  • #36885 (wallet, rpc: Add analyzedescriptor for multisig setups by pablomartin4btc)
  • #36822 (fuzz: torcontrol: drive the control connection over a mocked socket by erickcestari)
  • #36812 (crypto: copy HMAC state instead of rehashing key pads by l0rinc)
  • #36786 (fuzz: report more events, and check more invariants in connman target by darosior)
  • #36635 (fuzz: Add a target that feeds arbitrary bytes to V2Transport by fametrano)
  • #36603 (Improve loadtxoutset performance by ajtowns)
  • #36598 ([Demo] validation: remove AssumeUTXO by l0rinc)
  • #36548 (net: serve MSG_BLOCK by stripping witnesses in place by l0rinc)
  • #36188 (crypto: plug hardware optimized SHA256 into libsecp256k1's context by furszy)
  • #36122 (BIP460: CISA for Taproot key path spends by fjahr)
  • #36114 (wallet: harden external signer psbt processing, revamp mock by Sjors)
  • #36033 ([wip,nomerge,rfc] build: Require C++23 compiler by maflcko)
  • #35888 (net: reject oversized outbound messages by l0rinc)
  • #35229 (refactor: Use CBlockIndex parameters as reference by optout21)
  • #29491 ([EXPERIMENTAL] Schnorr batch verification for blocks by fjahr)
  • #27260 (Enhanced error messages for invalid network prefix during address parsing. by portlandhodl)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

<!--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/36808 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36808.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36808#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. A summary of reviews will appear here. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#37015](https://github.com/bitcoin/bitcoin/pull/37015) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/37015.svg"></sub> (Use O(log n) skiplist construction in CBlockIndex by sipa) * [#36996](https://github.com/bitcoin/bitcoin/pull/36996) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36996.svg"></sub> (fuzz: fix timelock range in miniscript_smart by erickcestari) * [#36946](https://github.com/bitcoin/bitcoin/pull/36946) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36946.svg"></sub> (scripted-diff: [test] Add util/check.h includes for assertions by maflcko) * [#36897](https://github.com/bitcoin/bitcoin/pull/36897) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36897.svg"></sub> (wallet, migration: Contain all legacy wallet and migration related things in its own subdirectory, namespace, and classes by achow101) * [#36885](https://github.com/bitcoin/bitcoin/pull/36885) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36885.svg"></sub> (wallet, rpc: Add analyzedescriptor for multisig setups by pablomartin4btc) * [#36822](https://github.com/bitcoin/bitcoin/pull/36822) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36822.svg"></sub> (fuzz: torcontrol: drive the control connection over a mocked socket by erickcestari) * [#36812](https://github.com/bitcoin/bitcoin/pull/36812) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36812.svg"></sub> (crypto: copy HMAC state instead of rehashing key pads by l0rinc) * [#36786](https://github.com/bitcoin/bitcoin/pull/36786) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36786.svg"></sub> (fuzz: report more events, and check more invariants in connman target by darosior) * [#36635](https://github.com/bitcoin/bitcoin/pull/36635) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36635.svg"></sub> (fuzz: Add a target that feeds arbitrary bytes to V2Transport by fametrano) * [#36603](https://github.com/bitcoin/bitcoin/pull/36603) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36603.svg"></sub> (Improve loadtxoutset performance by ajtowns) * [#36598](https://github.com/bitcoin/bitcoin/pull/36598) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36598.svg"></sub> ([Demo] validation: remove AssumeUTXO by l0rinc) * [#36548](https://github.com/bitcoin/bitcoin/pull/36548) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36548.svg"></sub> (net: serve `MSG_BLOCK` by stripping witnesses in place by l0rinc) * [#36188](https://github.com/bitcoin/bitcoin/pull/36188) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36188.svg"></sub> (crypto: plug hardware optimized SHA256 into libsecp256k1's context by furszy) * [#36122](https://github.com/bitcoin/bitcoin/pull/36122) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36122.svg"></sub> (BIP460: CISA for Taproot key path spends by fjahr) * [#36114](https://github.com/bitcoin/bitcoin/pull/36114) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36114.svg"></sub> (wallet: harden external signer psbt processing, revamp mock by Sjors) * [#36033](https://github.com/bitcoin/bitcoin/pull/36033) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36033.svg"></sub> ([wip,nomerge,rfc] build: Require C++23 compiler by maflcko) * [#35888](https://github.com/bitcoin/bitcoin/pull/35888) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35888.svg"></sub> (net: reject oversized outbound messages by l0rinc) * [#35229](https://github.com/bitcoin/bitcoin/pull/35229) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35229.svg"></sub> (refactor: Use CBlockIndex parameters as reference by optout21) * [#29491](https://github.com/bitcoin/bitcoin/pull/29491) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/29491.svg"></sub> ([EXPERIMENTAL] Schnorr batch verification for blocks by fjahr) * [#27260](https://github.com/bitcoin/bitcoin/pull/27260) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/27260.svg"></sub> (Enhanced error messages for invalid network prefix during address parsing. by portlandhodl) If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. <!--5faf32d7da4f0f540f40219e4f7537a3-->
First-time contributor

Earlier concerns neither republished nor resolved: 1 suggestion. See the Run archive linked from the Review report for their assessments.

🔵 Suggestion · The new wallet.h check is report-only

The new --check_also reports suggestions for test/fuzz/util/wallet.h only through a non-enforced wallet fuzz target, so those suggestions do not fail CI.

Location: ci/test/03_test_script.sh:271 (head).

🔵 Suggestion · The fuzz-enforcement commit leaves shared-header changes unexplained

The fuzz-enforcement commit has no message body explaining its shared-header, downstream-consumer and tooling changes, making their relationship to the new enforcement harder to review.

Location: src/private_broadcast.h:21 (commit).

Review coverage was incomplete.


Reviewed: 3d224a742c87 · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:806938d40e279b6d701b2e78128bb1a09b55193a0b697245a1dce6241d3081c1:3607c760b63c01fb7f1f349adfc3fd0614b148a7df02e42f2f0edc2d448925a1 --> <!-- ralph-base:dd96035e031edf56fcf66a09d443f257a346af1f --> <!-- ralph-head:3d224a742c8767065ad2cb8db79f9f7b4653f485 --> <!-- ralph-case:174ff9c5990b1946b32c110c6b4eb1a3e1eef0efb0aa8e39cab8c5dbc6da1236 --> Earlier concerns neither republished nor resolved: 1 suggestion. See the Run archive linked from the Review report for their assessments. **🔵 Suggestion · The new `wallet.h` check is report-only** The new `--check_also` reports suggestions for `test/fuzz/util/wallet.h` only through a non-enforced wallet fuzz target, so those suggestions do not fail CI. Location: [`ci/test/03_test_script.sh:271`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/3d224a742c8767065ad2cb8db79f9f7b4653f485/ci/test/03_test_script.sh#L271>) (head). **🔵 Suggestion · The fuzz-enforcement commit leaves shared-header changes unexplained** The fuzz-enforcement commit has no message body explaining its shared-header, downstream-consumer and tooling changes, making their relationship to the new enforcement harder to review. Location: src/private_broadcast.h:21 (commit). Review coverage was incomplete. <!-- Review tier: standard --> --- Reviewed: [`3d224a742c87`](<https://git.fish.foo/bitcoin/bitcoin/commit/3d224a742c8767065ad2cb8db79f9f7b4653f485>) · [Review report](<https://review.fish.foo/report/36808-3d224a742c8767065ad2cb8db79f9f7b4653f485-3213-17.html>) · [Previous reports](<https://review.fish.foo/traces/36808/>) [permalink](<https://review.fish.foo/report/36808-3d224a742c8767065ad2cb8db79f9f7b4653f485-3213-17.html>)
DrahtBot commented 2026-11-08 19:17:07 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task Alpine (musl): https://github.com/bitcoin/bitcoin/actions/runs/42513074263/job/128830134615
LLM reason (✨ experimental): CI failed during compilation: headerssync.cpp has missing declarations/includes, causing incomplete CBlockIndex and undefined symbols.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `Alpine (musl)`: https://github.com/bitcoin/bitcoin/actions/runs/42513074263/job/128830134615</sub> <sub>LLM reason (✨ experimental): CI failed during compilation: `headerssync.cpp` has missing declarations/includes, causing incomplete `CBlockIndex` and undefined symbols.</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
maflcko (Migrated from github.com) reviewed 2026-11-10 09:03:40 +00:00
maflcko (Migrated from github.com) commented 2026-11-10 09:03:40 +00:00

this should be left as-is. Also, I am unsure how to review the non-fuzz header changes? How do I know they are enforced by iwyu? I think it would be easier if the header changes are addition-only for now?

this should be left as-is. Also, I am unsure how to review the non-fuzz header changes? How do I know they are enforced by iwyu? I think it would be easier if the header changes are addition-only for now?
fanquake (Migrated from github.com) reviewed 2026-11-10 11:42:46 +00:00
fanquake (Migrated from github.com) commented 2026-11-10 11:42:46 +00:00

Why is this needed? Has it been upstreamed?

Why is this needed? Has it been upstreamed?
hebasto (Migrated from github.com) reviewed 2026-11-10 11:44:25 +00:00
hebasto (Migrated from github.com) commented 2026-11-10 11:44:25 +00:00

Has it been upstreamed?

Working on this.

> Has it been upstreamed? Working on this.
DrahtBot commented 2026-11-10 13:47:54 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
hebasto (Migrated from github.com) reviewed 2026-11-10 14:53:38 +00:00
hebasto (Migrated from github.com) commented 2026-11-10 14:53:38 +00:00

this should be left as-is.

Thanks! Fixed.

> this should be left as-is. Thanks! Fixed.
hebasto commented 2026-11-10 15:03:01 +00:00 (Migrated from github.com)

Also, I am unsure how to review the non-fuzz header changes? How do I know they are enforced by iwyu?

The changes in non-fuzz headers are enforced by IWYU because, due to the stem name coincidence, it considers them associated headers of the corresponding fuzz sources. For example, src/test/fuzz/protocol.cpp and src/protocol.h. However, they are not, because the fuzz sources contain no definitions for any declarations from those headers.

This, in turn, requires adding includes to some non-fuzz sources for headers that were previously included transitively.

I think it would be easier if the header changes are addition-only for now?

I'm going to split out the non-fuzz changes so that they can be reviewed separately.

> Also, I am unsure how to review the non-fuzz header changes? How do I know they are enforced by iwyu? The changes in non-fuzz headers are enforced by IWYU because, due to the stem name coincidence, it considers them associated headers of the corresponding fuzz sources. For example, `src/test/fuzz/protocol.cpp` and `src/protocol.h`. However, they are not, because the fuzz sources contain no definitions for any declarations from those headers. This, in turn, requires adding includes to some non-fuzz sources for headers that were previously included transitively. > I think it would be easier if the header changes are addition-only for now? I'm going to split out the non-fuzz changes so that they can be reviewed separately.
hebasto commented 2026-11-12 10:29:06 +00:00 (Migrated from github.com)

I think it would be easier if the header changes are addition-only for now?

I'm going to split out the non-fuzz changes so that they can be reviewed separately.

See https://github.com/bitcoin/bitcoin/pull/36844.

> > I think it would be easier if the header changes are addition-only for now? > > I'm going to split out the non-fuzz changes so that they can be reviewed separately. See https://github.com/bitcoin/bitcoin/pull/36844.
DrahtBot commented 2026-11-16 17:06:34 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-11-20 22:36:14 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-11-26 17:39:06 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
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!36808
No description provided.