iwyu: Fix warnings in `src/interfaces` and treat them as errors #35900

pull hebasto wants to merge 2 commits into bitcoin:master from hebasto:260805-iwyu-interfaces changing 7 files +22 −27
  1. hebasto commented at 3:15 PM on August 5, 2026: member

    This PR continues the ongoing effort to enforce IWYU warnings.

    See Developer Notes.

  2. DrahtBot commented at 3:15 PM on August 5, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35900.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

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

    Type Reviewers
    ACK maflcko
    Stale ACK BrandonOdiwuor

    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:

    • #36070 (wallet: Add deriveHDKey interface by PraneethGunas)
    • #35436 (wallet: Add addHDkey interface by pseudoramdom)
    • #33117 (Interfaces: Expose UTXO Snapshot Loading and Add Progress Notifications by D33r-Gee)
    • #24230 (indexes: Stop using node internal types and locking cs_main, improve sync logic by ryanofsky)

    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-->

  3. hebasto force-pushed on Aug 10, 2026
  4. hebasto commented at 1:21 PM on August 10, 2026: member

    Rebased to refresh the CI.

  5. BrandonOdiwuor commented at 3:36 AM on August 14, 2026: contributor

    ACK ca15a2260d1dcb5162da27cefac25a0398436cf6

    I reviewed the changes and manually tested IWYU enforcement on src/interface (enabled on base commit ca15a2260d1dcb5162da27cefac25a0398436cf6 and compared before/after this PR).

    I have noted the following and they are reasonable:

    • #include <chrono> was replaced by #include <util/time.h>
    • The #include <variant> suggestion related to std::tuple was fixed

    <details> <summary>Suggestions after IWYU enforcement before ca15a2260d1dcb5162da27cefac25a0398436cf6 </summary>

    2026-08-13T07:23:23.3594712Z diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h
    2026-08-13T07:23:23.3594959Z index 20369fd..edbba25 100644
    2026-08-13T07:23:23.3595089Z --- a/src/interfaces/chain.h
    2026-08-13T07:23:23.3595202Z +++ b/src/interfaces/chain.h
    2026-08-13T07:23:23.3595364Z @@ -7,11 +7,12 @@
    2026-08-13T07:23:23.3595449Z  
    2026-08-13T07:23:23.3595594Z  #include <blockfilter.h>
    2026-08-13T07:23:23.3595715Z  #include <common/settings.h>
    2026-08-13T07:23:23.3596174Z +#include <consensus/amount.h>
    2026-08-13T07:23:23.3596358Z  #include <kernel/chain.h> // IWYU pragma: export
    2026-08-13T07:23:23.3596485Z -#include <node/types.h>
    2026-08-13T07:23:23.3596628Z  #include <primitives/transaction.h>
    2026-08-13T07:23:23.3596753Z  #include <util/result.h>
    2026-08-13T07:23:23.3596848Z  
    2026-08-13T07:23:23.3596967Z +#include <chrono>
    2026-08-13T07:23:23.3597120Z  #include <cstddef>
    2026-08-13T07:23:23.3597262Z  #include <cstdint>
    2026-08-13T07:23:23.3597370Z  #include <functional>
    2026-08-13T07:23:23.3597471Z @@ -21,9 +22,7 @@
    2026-08-13T07:23:23.3597569Z  #include <string>
    2026-08-13T07:23:23.3597665Z  #include <vector>
    2026-08-13T07:23:23.3597744Z  
    2026-08-13T07:23:23.3597857Z -class ArgsManager;
    2026-08-13T07:23:23.3597959Z  class CBlock;
    2026-08-13T07:23:23.3598098Z -class CBlockUndo;
    2026-08-13T07:23:23.3598212Z  class CFeeRate;
    2026-08-13T07:23:23.3598323Z  class CRPCCommand;
    2026-08-13T07:23:23.3598417Z  class CScheduler;
    2026-08-13T07:23:23.3598590Z @@ -34,17 +33,18 @@ enum class RBFTransactionState;
    2026-08-13T07:23:23.3598704Z  struct bilingual_str;
    2026-08-13T07:23:23.3598826Z  struct CBlockLocator;
    2026-08-13T07:23:23.3598913Z  struct FeeCalculation;
    2026-08-13T07:23:23.3598994Z +
    2026-08-13T07:23:23.3599076Z  namespace kernel {
    2026-08-13T07:23:23.3599166Z  struct ChainstateRole;
    2026-08-13T07:23:23.3599249Z  } // namespace kernel
    2026-08-13T07:23:23.3599369Z  namespace node {
    2026-08-13T07:23:23.3599471Z  struct NodeContext;
    2026-08-13T07:23:23.3599578Z +enum class TxBroadcast : uint8_t;
    2026-08-13T07:23:23.3599657Z  } // namespace node
    2026-08-13T07:23:23.3599737Z  
    2026-08-13T07:23:23.3599819Z  namespace interfaces {
    2026-08-13T07:23:23.3599898Z  
    2026-08-13T07:23:23.3600002Z  class Handler;
    2026-08-13T07:23:23.3600120Z -class Wallet;
    2026-08-13T07:23:23.3600204Z  
    2026-08-13T07:23:23.3600486Z  //! Helper for findBlock to selectively return pieces of block data. If block is
    2026-08-13T07:23:23.3600727Z  //! found, data will be returned by setting specified output variables. If block
    2026-08-13T07:23:23.3600920Z diff --git a/src/interfaces/node.h b/src/interfaces/node.h
    2026-08-13T07:23:23.3601033Z index 8b8402e..415f493 100644
    2026-08-13T07:23:23.3601138Z --- a/src/interfaces/node.h
    2026-08-13T07:23:23.3601246Z +++ b/src/interfaces/node.h
    2026-08-13T07:23:23.3601486Z @@ -11,35 +11,32 @@
    2026-08-13T07:23:23.3601605Z  #include <net_types.h>
    2026-08-13T07:23:23.3601708Z  #include <netaddress.h>
    2026-08-13T07:23:23.3601829Z  #include <netbase.h>
    2026-08-13T07:23:23.3601954Z -#include <support/allocators/secure.h>
    2026-08-13T07:23:23.3602094Z +#include <primitives/transaction.h>
    2026-08-13T07:23:23.3602191Z +#include <uint256.h>
    2026-08-13T07:23:23.3602299Z  #include <util/log.h>
    2026-08-13T07:23:23.3602408Z  #include <util/translation.h>
    2026-08-13T07:23:23.3602499Z  
    2026-08-13T07:23:23.3602596Z  #include <cstddef>
    2026-08-13T07:23:23.3602704Z  #include <cstdint>
    2026-08-13T07:23:23.3602797Z  #include <functional>
    2026-08-13T07:23:23.3602910Z +#include <map>
    2026-08-13T07:23:23.3603012Z  #include <memory>
    2026-08-13T07:23:23.3603120Z  #include <optional>
    2026-08-13T07:23:23.3603208Z  #include <string>
    2026-08-13T07:23:23.3603315Z  #include <tuple>
    2026-08-13T07:23:23.3603416Z +#include <variant>
    2026-08-13T07:23:23.3603516Z  #include <vector>
    2026-08-13T07:23:23.3603607Z  
    2026-08-13T07:23:23.3603705Z -class BanMan;
    2026-08-13T07:23:23.3603799Z  class CFeeRate;
    2026-08-13T07:23:23.3604141Z -class CNodeStats;
    2026-08-13T07:23:23.3604270Z  class Coin;
    2026-08-13T07:23:23.3604412Z  class UniValue;
    2026-08-13T07:23:23.3604523Z -class Proxy;
    2026-08-13T07:23:23.3604651Z  enum class SynchronizationState;
    2026-08-13T07:23:23.3604758Z  struct CNodeStateStats;
    2026-08-13T07:23:23.3604878Z -struct bilingual_str;
    2026-08-13T07:23:23.3604972Z +
    2026-08-13T07:23:23.3605076Z  namespace node {
    2026-08-13T07:23:23.3605197Z  enum class TransactionError;
    2026-08-13T07:23:23.3605308Z  struct NodeContext;
    2026-08-13T07:23:23.3605395Z  } // namespace node
    2026-08-13T07:23:23.3605655Z -namespace wallet {
    2026-08-13T07:23:23.3605761Z -class CCoinControl;
    2026-08-13T07:23:23.3605876Z -} // namespace wallet
    2026-08-13T07:23:23.3605973Z  
    2026-08-13T07:23:23.3606096Z  namespace interfaces {
    2026-08-13T07:23:23.3606193Z  class Handler;
    2026-08-13T07:23:23.3606377Z diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h
    2026-08-13T07:23:23.3606469Z index f78e3da..16ee952 100644
    2026-08-13T07:23:23.3606600Z --- a/src/interfaces/wallet.h
    2026-08-13T07:23:23.3606727Z +++ b/src/interfaces/wallet.h
    2026-08-13T07:23:23.3606826Z @@ -10,36 +10,36 @@
    2026-08-13T07:23:23.3606934Z  #include <common/types.h>
    2026-08-13T07:23:23.3607075Z  #include <consensus/amount.h>
    2026-08-13T07:23:23.3607166Z  #include <interfaces/chain.h>
    2026-08-13T07:23:23.3607365Z -#include <primitives/transaction_identifier.h>
    2026-08-13T07:23:23.3607493Z -#include <pubkey.h>
    2026-08-13T07:23:23.3607609Z -#include <script/script.h>
    2026-08-13T07:23:23.3607743Z +#include <primitives/transaction.h>
    2026-08-13T07:23:23.3607876Z  #include <support/allocators/secure.h>
    2026-08-13T07:23:23.3607992Z  #include <util/fs.h>
    2026-08-13T07:23:23.3608097Z  #include <util/result.h>
    2026-08-13T07:23:23.3608228Z  #include <util/ui_change_type.h>
    2026-08-13T07:23:23.3608307Z  
    2026-08-13T07:23:23.3608409Z +#include <compare>
    2026-08-13T07:23:23.3608509Z +#include <cstddef>
    2026-08-13T07:23:23.3608623Z  #include <cstdint>
    2026-08-13T07:23:23.3608727Z  #include <functional>
    2026-08-13T07:23:23.3608842Z  #include <map>
    2026-08-13T07:23:23.3608939Z  #include <memory>
    2026-08-13T07:23:23.3609053Z +#include <optional>
    2026-08-13T07:23:23.3609154Z +#include <set>
    2026-08-13T07:23:23.3609267Z  #include <string>
    2026-08-13T07:23:23.3609366Z  #include <tuple>
    2026-08-13T07:23:23.3609474Z -#include <type_traits>
    2026-08-13T07:23:23.3609575Z  #include <utility>
    2026-08-13T07:23:23.3609687Z +#include <variant>
    2026-08-13T07:23:23.3609784Z  #include <vector>
    2026-08-13T07:23:23.3609873Z  
    2026-08-13T07:23:23.3609974Z -class CFeeRate;
    2026-08-13T07:23:23.3610079Z -class CKey;
    2026-08-13T07:23:23.3610174Z  enum class FeeReason;
    2026-08-13T07:23:23.3610281Z  enum class OutputType;
    2026-08-13T07:23:23.3610407Z  class PartiallySignedTransaction;
    2026-08-13T07:23:23.3610514Z  struct bilingual_str;
    2026-08-13T07:23:23.3610613Z -namespace common {
    2026-08-13T07:23:23.3610717Z -enum class PSBTError;
    2026-08-13T07:23:23.3610818Z -} // namespace common
    2026-08-13T07:23:23.3610917Z -namespace node {
    2026-08-13T07:23:23.3611036Z -enum class TransactionError;
    2026-08-13T07:23:23.3611145Z -} // namespace node
    2026-08-13T07:23:23.3611249Z +class ArgsManager;
    2026-08-13T07:23:23.3611482Z +class CKeyID;
    2026-08-13T07:23:23.3611596Z +class CPubKey;
    2026-08-13T07:23:23.3611705Z +class CScript;
    2026-08-13T07:23:23.3611801Z +class uint256;
    2026-08-13T07:23:23.3611900Z +
    2026-08-13T07:23:23.3612005Z  namespace wallet {
    2026-08-13T07:23:23.3612149Z  struct CreatedTransactionResult;
    2026-08-13T07:23:23.3612277Z  class CCoinControl;
    

    </details>

  6. fanquake closed this on Aug 18, 2026

  7. fanquake reopened this on Aug 18, 2026

  8. DrahtBot added the label Needs rebase on Aug 21, 2026
  9. iwyu: Add temporary mapping to work around upstream bug d564b0255f
  10. iwyu: Fix warnings in `src/interfaces` and treat them as errors b3ff9c4d68
  11. hebasto force-pushed on Aug 22, 2026
  12. hebasto commented at 9:53 AM on August 22, 2026: member

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

  13. DrahtBot removed the label Needs rebase on Aug 22, 2026
  14. in contrib/devtools/iwyu/bitcoin.core.imp:11 in d564b0255f
       4 | @@ -5,4 +5,8 @@
       5 |    { "include": [ "<mmintrin.h>", "private", "<immintrin.h>", "public" ] },
       6 |    { "include": [ "<smmintrin.h>", "private", "<immintrin.h>", "public" ] },
       7 |    { "include": [ "<tmmintrin.h>", "private", "<immintrin.h>", "public" ] },
       8 | +
       9 | +  # Workaround for IWYU issue.
      10 | +  # See: https://github.com/include-what-you-use/include-what-you-use/issues/2084.
      11 | +  { "symbol": ["std::tuple", "private", "<tuple>", "public"] },
    


    maflcko commented at 12:08 PM on August 27, 2026:

    nit in d564b0255f7ec984b1c788910a113a2533dd4d6a: Seems fine, but stdlib headers are extremely thin (compared to our headers), so an extra include should be harmless. Seems fine to include commit d564b0255f7ec984b1c788910a113a2533dd4d6a or drop it, either is fine.


    hebasto commented at 12:38 PM on August 27, 2026:

    Anyway, it will be reverted during the next IWYU version bump.

  15. maflcko commented at 12:19 PM on August 27, 2026: member

    review ACK b3ff9c4d683fdcd0530b7c76c408b4a6e9e0830e 🖋

    <details><summary>Show signature</summary>

    Signature:

    untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
    RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
    trusted comment: review ACK b3ff9c4d683fdcd0530b7c76c408b4a6e9e0830e 🖋
    5HTK1DSDIxcgjj8QPP5Bwb24ft5k4fYnjmXefiuLEwVDvCkkvYt0GDfVy7dWReqFay1AZWc2Md0XvhTKN+opCQ==
    

    </details>

    Maybe the next one could be univalue, while also fixing the two leftover non-present copyright headers?

    diff --git a/src/univalue/lib/univalue.cpp b/src/univalue/lib/univalue.cpp
    index 6aeff00..39dcfdc 100644
    --- a/src/univalue/lib/univalue.cpp
    +++ b/src/univalue/lib/univalue.cpp
    @@ -1,3 +1,3 @@
     // Copyright 2014 BitPay Inc.
    -// Copyright 2015 Bitcoin Core Developers
    +// Copyright (c) 2015-present The Bitcoin Core developers
     // Distributed under the MIT software license, see the accompanying
    diff --git a/src/univalue/lib/univalue_get.cpp b/src/univalue/lib/univalue_get.cpp
    index e82ac4c..5fd33ad 100644
    --- a/src/univalue/lib/univalue_get.cpp
    +++ b/src/univalue/lib/univalue_get.cpp
    @@ -1,3 +1,3 @@
     // Copyright 2014 BitPay Inc.
    -// Copyright 2015 Bitcoin Core Developers
    +// Copyright (c) 2015-present The Bitcoin Core developers
     // Distributed under the MIT software license, see the accompanying
    
  16. DrahtBot requested review from BrandonOdiwuor on Aug 27, 2026
  17. fanquake merged this on Aug 27, 2026
  18. fanquake closed this on Aug 27, 2026

  19. hebasto deleted the branch on Aug 27, 2026
  20. hebasto commented at 2:13 PM on August 27, 2026: member

    Maybe the next one could be univalue...

    That was already done in #34455.

  21. maflcko commented at 4:58 PM on August 27, 2026: member

    Maybe the next one could be univalue...

    That was already done in #34455.

    Ok, I see. Fixed the headers in #36104

    I guess the next one could be larger? Maybe ./src/test/fuzz/*?

  22. hebasto commented at 9:45 PM on August 27, 2026: member

    I guess the next one could be larger? Maybe ./src/test/fuzz/*?

    That might be challenging to put first. Not due to the number of files, but due to the chosen naming convention, where the basename of a fuzz source coincides with the basename of the module being fuzzed. That means that IWYU considers src/<name>.h as associated with src/test/fuzz/<name>.cpp, which in turn necessitate changes in the src directory. A related problem is that src/minisketch/include/minisketch.h would be treated as associated with src/test/fuzz/minisketch.cpp, and that header belongs to a subtree.

  23. maflcko commented at 10:20 AM on August 28, 2026: member

    subtree

    Yeah, that looks like a pre-existing bug. E.g. https://github.com/bitcoin/bitcoin/actions/runs/33121512611/job/98689249842#step:11:39828 prints a diff of:

    diff --git a/src/minisketch/include/minisketch.h b/src/minisketch/include/minisketch.h
    index f222f23..2443fd0 100644
    --- a/src/minisketch/include/minisketch.h
    +++ b/src/minisketch/include/minisketch.h
    @@ -1,14 +1,16 @@
     #ifndef _MINISKETCH_H_
     #define _MINISKETCH_H_ 1
     
    -#include <stdint.h>
    -#include <stdlib.h>
    +#include <sys/types.h>
     
    +#include <cstddef>
    +#include <cstdint>
    +#include <type_traits>
     #ifdef _MSC_VER
    -#  include <BaseTsd.h>
    -   typedef SSIZE_T ssize_t;
    +#include <BaseTsd.h>
    +
    +typedef SSIZE_T ssize_t;
     #else
    -#  include <unistd.h>
     #endif
     
     #ifndef MINISKETCH_API
    

    Subtrees obviously can't be modified and need to be excluded. Fixed in https://github.com/bitcoin/bitcoin/pull/36112


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-09-09 07:56 UTC