From 6751a323c0130310880c84e03f7104f6bb86385d Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Thu, 4 Jun 2026 18:16:25 +0100 Subject: [PATCH] iwyu: Fix warnings in `src/bench` and treat them as error --- ci/test/03_test_script.sh | 2 +- src/addrman.cpp | 1 + src/addrman.h | 8 ++++-- src/base58.h | 3 +-- src/bech32.h | 2 ++ src/bench/addrman.cpp | 2 +- src/bench/asmap.cpp | 2 +- src/bench/base58.cpp | 1 - src/bench/bech32.cpp | 1 + src/bench/bench.cpp | 4 +-- src/bench/bench.h | 2 +- src/bench/bench_bitcoin.cpp | 8 +++--- src/bench/bip324_ecdh.cpp | 1 + src/bench/block_assemble.cpp | 3 +-- src/bench/blockencodings.cpp | 8 ++++++ src/bench/ccoins_caching.cpp | 4 ++- src/bench/chacha20.cpp | 7 +++--- src/bench/checkblock.cpp | 8 ++++-- src/bench/checkqueue.cpp | 1 + src/bench/cluster_linearize.cpp | 9 +++++-- src/bench/coin_selection.cpp | 10 ++++---- src/bench/connectblock.cpp | 3 +-- src/bench/crypto_hash.cpp | 4 +-- src/bench/descriptors.cpp | 2 +- src/bench/disconnected_transactions.cpp | 3 +-- src/bench/duplicate_inputs.cpp | 2 +- src/bench/ellswift.cpp | 3 ++- src/bench/index_blockfilter.cpp | 5 ++-- src/bench/load_external.cpp | 3 +-- src/bench/lockedpool.cpp | 4 ++- src/bench/mempool_ephemeral_spends.cpp | 4 ++- src/bench/mempool_stress.cpp | 2 +- src/bench/merkle_root.cpp | 4 ++- src/bench/nanobench.h | 33 ++++++++++++++++++++++--- src/bench/obfuscation.cpp | 1 + src/bench/parse_hex.cpp | 3 ++- src/bench/peer_eviction.cpp | 2 +- src/bench/poly1305.cpp | 7 +++--- src/bench/pool.cpp | 1 + src/bench/prevector.cpp | 1 + src/bench/readwriteblock.cpp | 9 ++++--- src/bench/rollingbloom.cpp | 3 +-- src/bench/rpc_blockchain.cpp | 7 +++--- src/bench/sign_transaction.cpp | 6 ++--- src/bench/streams_findbyte.cpp | 2 ++ src/bench/strencodings.cpp | 5 ++-- src/bench/txgraph.cpp | 9 ++++++- src/bench/txorphanage.cpp | 15 +++++++---- src/bench/verify_script.cpp | 11 ++++++--- src/bench/wallet_balance.cpp | 5 ++-- src/bench/wallet_create.cpp | 3 +-- src/bench/wallet_create_tx.cpp | 7 +++--- src/bench/wallet_encrypt.cpp | 16 +++++++++--- src/bench/wallet_ismine.cpp | 4 ++- src/bench/wallet_loading.cpp | 4 +++ src/bench/wallet_migration.cpp | 28 +++++++++++++++------ src/prevector.h | 2 +- src/test/addrman_tests.cpp | 1 + 58 files changed, 211 insertions(+), 100 deletions(-) diff --git a/ci/test/03_test_script.sh b/ci/test/03_test_script.sh index 980583d00b5..9e7ee951b40 100755 --- a/ci/test/03_test_script.sh +++ b/ci/test/03_test_script.sh @@ -229,7 +229,7 @@ fi if [[ "${RUN_IWYU}" == true ]]; then # TODO: Consider enforcing IWYU across the entire codebase. - FILES_WITH_ENFORCED_IWYU="/src/(((crypto|index|kernel|primitives|script|univalue/(lib|test)|util|zmq)/.*|bench/(block_assemble|connectblock)|common/license_info|node/(blockstorage|interfaces|miner|mining_args|utxo_snapshot)|rpc/mining|clientversion|core_io|signet|init)\\.cpp)" + FILES_WITH_ENFORCED_IWYU="/src/(((bench|crypto|index|kernel|primitives|script|univalue/(lib|test)|util|zmq)/.*|common/license_info|node/(blockstorage|interfaces|miner|mining_args|utxo_snapshot)|rpc/mining|clientversion|core_io|signet|init)\\.cpp)" jq --arg patterns "$FILES_WITH_ENFORCED_IWYU" 'map(select(.file | test($patterns)))' "${BASE_BUILD_DIR}/compile_commands.json" > "${BASE_BUILD_DIR}/compile_commands_iwyu_errors.json" jq --arg patterns "$FILES_WITH_ENFORCED_IWYU" 'map(select(.file | test($patterns) | not))' "${BASE_BUILD_DIR}/compile_commands.json" > "${BASE_BUILD_DIR}/compile_commands_iwyu_warnings.json" diff --git a/src/addrman.cpp b/src/addrman.cpp index 92178f30089..3050beb7968 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/src/addrman.h b/src/addrman.h index 94e7d3e6537..f714338610c 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -7,18 +7,22 @@ #define BITCOIN_ADDRMAN_H #include -#include #include -#include #include +#include #include +#include #include #include +#include +#include #include #include #include +class NetGroupManager; + /** Over how many buckets entries with tried addresses from a single group (/16 for IPv4) are spread */ static constexpr uint32_t ADDRMAN_TRIED_BUCKETS_PER_GROUP{8}; /** Over how many buckets entries with new addresses originating from a single group are spread */ diff --git a/src/base58.h b/src/base58.h index f258163bc3d..1656cbe1d39 100644 --- a/src/base58.h +++ b/src/base58.h @@ -14,8 +14,7 @@ #ifndef BITCOIN_BASE58_H #define BITCOIN_BASE58_H -#include - +#include #include #include diff --git a/src/bech32.h b/src/bech32.h index ba4c79bb869..9a43a58f396 100644 --- a/src/bech32.h +++ b/src/bech32.h @@ -14,8 +14,10 @@ #ifndef BITCOIN_BECH32_H #define BITCOIN_BECH32_H +#include #include #include +#include #include namespace bech32 diff --git a/src/bench/addrman.cpp b/src/bench/addrman.cpp index 703b4d245db..5ce7893d536 100644 --- a/src/bench/addrman.cpp +++ b/src/bench/addrman.cpp @@ -10,13 +10,13 @@ #include #include #include -#include #include #include #include #include #include +#include #include /* A "source" is a source address from which we have received a bunch of other addresses. */ diff --git a/src/bench/asmap.cpp b/src/bench/asmap.cpp index e834ea04a27..92b048f746e 100644 --- a/src/bench/asmap.cpp +++ b/src/bench/asmap.cpp @@ -8,10 +8,10 @@ #include #include #include +#include #include #include -#include #include #include diff --git a/src/bench/base58.cpp b/src/bench/base58.cpp index 0be16439c3c..ed36dc32cfb 100644 --- a/src/bench/base58.cpp +++ b/src/bench/base58.cpp @@ -4,7 +4,6 @@ #include #include -#include #include #include diff --git a/src/bench/bech32.cpp b/src/bench/bech32.cpp index c5e864aed03..1147bd6d2f6 100644 --- a/src/bench/bech32.cpp +++ b/src/bench/bech32.cpp @@ -6,6 +6,7 @@ #include #include +#include #include using namespace util::hex_literals; diff --git a/src/bench/bench.cpp b/src/bench/bench.cpp index 7ed425c4a53..4d1f4da0329 100644 --- a/src/bench/bench.cpp +++ b/src/bench/bench.cpp @@ -7,8 +7,8 @@ #include // IWYU pragma: keep #include #include +#include -#include #include #include #include @@ -19,8 +19,6 @@ #include #include -using namespace std::chrono_literals; - /** * Retrieves the available test setup command line arguments that may be used * in the benchmark. They will be used only if the benchmark utilizes a diff --git a/src/bench/bench.h b/src/bench/bench.h index 9212c81d5bf..54c75bc21ca 100644 --- a/src/bench/bench.h +++ b/src/bench/bench.h @@ -8,8 +8,8 @@ #include // IWYU pragma: export #include #include +#include -#include #include #include #include diff --git a/src/bench/bench_bitcoin.cpp b/src/bench/bench_bitcoin.cpp index 987523a128b..fa0c170f93f 100644 --- a/src/bench/bench_bitcoin.cpp +++ b/src/bench/bench_bitcoin.cpp @@ -3,19 +3,19 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include -#include #include +#include #include #include -#include -#include +#include -#include #include #include #include #include +#include #include +#include #include static const char* DEFAULT_BENCH_FILTER = ".*"; diff --git a/src/bench/bip324_ecdh.cpp b/src/bench/bip324_ecdh.cpp index 65deb8b74e9..c8d3a35efc5 100644 --- a/src/bench/bip324_ecdh.cpp +++ b/src/bench/bip324_ecdh.cpp @@ -11,6 +11,7 @@ #include #include #include +#include static void BIP324_ECDH(benchmark::Bench& bench) { diff --git a/src/bench/block_assemble.cpp b/src/bench/block_assemble.cpp index be03917417e..45052ecf71c 100644 --- a/src/bench/block_assemble.cpp +++ b/src/bench/block_assemble.cpp @@ -12,13 +12,12 @@ #include #include #include +#include #include #include -#include #include #include -#include #include using node::BlockCreateOptions; diff --git a/src/bench/blockencodings.cpp b/src/bench/blockencodings.cpp index ce968dbc651..274474d498c 100644 --- a/src/bench/blockencodings.cpp +++ b/src/bench/blockencodings.cpp @@ -7,15 +7,23 @@ #include #include #include +#include #include +#include #include