iwyu: Fix warnings in more modules in src/ and treat them as errors #36844

Open
hebasto wants to merge 2 commits from 261112-iwyu-src into master AGit
hebasto commented 2026-11-12 10:27:21 +00:00 (Migrated from github.com)

Split from #36808.

This PR fixes IWYU warnings in the following source files and their associated headers, and add them to IWYU_SRC_FILES, so that any new warnings there fail CI:

  • chain.cpp
  • headerssync.cpp
  • key_io.cpp
  • merkleblock.cpp
  • pow.cpp

The changes in other files add includes of headers that were previously included transitively.

Split from #36808. This PR fixes IWYU warnings in the following source files and their associated headers, and add them to `IWYU_SRC_FILES`, so that any new warnings there fail CI: - `chain.cpp` - `headerssync.cpp` - `key_io.cpp` - `merkleblock.cpp` - `pow.cpp` The changes in other files add includes of headers that were previously included transitively.
DrahtBot commented 2026-11-12 10:27:30 +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
Stale ACK jeanpablojp

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #37015 (Use O(log n) skiplist construction in CBlockIndex by sipa)
  • #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)
  • #36114 (wallet: harden external signer psbt processing, revamp mock by Sjors)
  • #35229 (refactor: Use CBlockIndex parameters as reference by optout21)
  • #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/36844 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36844.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36844#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 | | ---- | --------- | | Stale ACK | [jeanpablojp](https://github.com/bitcoin/bitcoin/pull/36844#pullrequestreview-5984372321) | 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. <!--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) * [#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) * [#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) * [#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) * [#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

No findings were published from this review.

Review coverage was incomplete.


Reviewed: 9214667bdfe3 · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:806938d40e279b6d701b2e78128bb1a09b55193a0b697245a1dce6241d3081c1:3607c760b63c01fb7f1f349adfc3fd0614b148a7df02e42f2f0edc2d448925a1 --> <!-- ralph-base:dd96035e031edf56fcf66a09d443f257a346af1f --> <!-- ralph-head:9214667bdfe3357d9c375d8b2554889f26ca5742 --> <!-- ralph-case:adc20acf8ca12c388ccd02c0cff6f1c3cda2e3008544e48765d745be01bd8492 --> No findings were published from this review. Review coverage was incomplete. <!-- Review tier: standard --> --- Reviewed: [`9214667bdfe3`](<https://git.fish.foo/bitcoin/bitcoin/commit/9214667bdfe3357d9c375d8b2554889f26ca5742>) · [Review report](<https://review.fish.foo/report/36844-9214667bdfe3357d9c375d8b2554889f26ca5742-3212-6.html>) · [Previous reports](<https://review.fish.foo/traces/36844/>) [permalink](<https://review.fish.foo/report/36844-9214667bdfe3357d9c375d8b2554889f26ca5742-3212-6.html>)
jeanpablojp (Migrated from github.com) reviewed 2026-11-19 22:23:09 +00:00
jeanpablojp (Migrated from github.com) left a comment

tACK 24a91c966e

Checked with Apple clang that the PR only changes line numbers in the code.

small nit: since the only change outside src/ is the CI script, maybe the description could say "The changes in other files"

tACK 24a91c966e08906c450128393da28867ef3dc946 Checked with Apple clang that the PR only changes line numbers in the code. small nit: since the only change outside `src/` is the CI script, maybe the description could say "The changes in other files"
hebasto commented 2026-11-20 18:15:11 +00:00 (Migrated from github.com)

small nit: since the only change outside src/ is the CI script, maybe the description could say "The changes in other files"

Thanks! The commit message and the PR description have been updated.

> small nit: since the only change outside `src/` is the CI script, maybe the description could say "The changes in other files" Thanks! The commit message and the PR description have been updated.
fanquake commented 2026-11-25 12:19:49 +00:00 (Migrated from github.com)

This needs a fixup:

[53](https://github.com/bitcoin/bitcoin/actions/runs/45612297545/job/139198659864?pr=36844#step:11:1654)
/home/runner/work/_temp/src/wallet/migration.cpp:207:19: error: variable has incomplete type 'CBlockLocator'
  207 |     CBlockLocator best_block_locator;
      |                   ^
/home/runner/work/_temp/src/interfaces/chain.h:36:8: note: forward declaration of 'CBlockLocator'
   36 | struct CBlockLocator;
      |        ^
1 error generated.
This needs a fixup: ```bash [53](https://github.com/bitcoin/bitcoin/actions/runs/45612297545/job/139198659864?pr=36844#step:11:1654) /home/runner/work/_temp/src/wallet/migration.cpp:207:19: error: variable has incomplete type 'CBlockLocator' 207 | CBlockLocator best_block_locator; | ^ /home/runner/work/_temp/src/interfaces/chain.h:36:8: note: forward declaration of 'CBlockLocator' 36 | struct CBlockLocator; | ^ 1 error generated. ```
DrahtBot commented 2026-11-25 12:32:25 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task macOS-cross to x86_64: https://github.com/bitcoin/bitcoin/actions/runs/45612297545/job/139198659201
LLM reason (✨ experimental): CI failed during compilation: migration.cpp instantiates CBlockLocator while only its forward declaration is visible, causing an incomplete-type error.

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 `macOS-cross to x86_64`: https://github.com/bitcoin/bitcoin/actions/runs/45612297545/job/139198659201</sub> <sub>LLM reason (✨ experimental): CI failed during compilation: `migration.cpp` instantiates `CBlockLocator` while only its forward declaration is visible, causing an incomplete-type error.</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>
hebasto commented 2026-11-25 13:03:12 +00:00 (Migrated from github.com)

This needs a fixup:

[53](https://github.com/bitcoin/bitcoin/actions/runs/45612297545/job/139198659864?pr=36844#step:11:1654)
/home/runner/work/_temp/src/wallet/migration.cpp:207:19: error: variable has incomplete type 'CBlockLocator'
207 | CBlockLocator best_block_locator;
| ^
/home/runner/work/_temp/src/interfaces/chain.h:36:8: note: forward declaration of 'CBlockLocator'
36 | struct CBlockLocator;
| ^
1 error generated.

Rebased to resolve a conflict with the recently merged https://github.com/bitcoin/bitcoin/pull/34909, which caused the error above.

> This needs a fixup: > > \[53\](https://github.com/bitcoin/bitcoin/actions/runs/45612297545/job/139198659864?pr=36844#step:11:1654) > /home/runner/work/_temp/src/wallet/migration.cpp:207:19: error: variable has incomplete type 'CBlockLocator' > 207 | CBlockLocator best_block_locator; > | ^ > /home/runner/work/_temp/src/interfaces/chain.h:36:8: note: forward declaration of 'CBlockLocator' > 36 | struct CBlockLocator; > | ^ > 1 error generated. Rebased to resolve a conflict with the recently merged https://github.com/bitcoin/bitcoin/pull/34909, which caused the error above.
DrahtBot commented 2026-11-26 17:38:42 +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 commented 2026-11-26 17:42:52 +00:00 (Migrated from github.com)

Rebased to resolve a conflict with the merged bitcoin/bitcoin#36967.

Rebased to resolve a conflict with the merged bitcoin/bitcoin#36967.
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!36844
No description provided.