iwyu: Fix warnings in `src/bench` and treat them as error
What changed, and why it matters
This commit is a code cleanup that adjusts which C++ header files are included in the project's benchmark code and a few related source files. It enables a stricter 'include what you use' (IWYU) check for the benchmark directory so missing or unnecessary #include lines are treated as errors in continuous integration. There is no change to program logic, no bug fix, and no security-relevant behavior.
No security action needed. This is a normal maintainability/tooling commit. Reviewers can verify the CI IWYU job passes and that the header changes compile cleanly.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff consists entirely of #include additions, removals, and reordering across src/bench/ and a handful of other files (addrman.cpp/h, base58.h, bech32.h, prevector.h, src/test/addrman_tests.cpp). It also updates ci/test/03_test_script.sh to expand the IWYU enforcement regex to cover all of src/bench/.cpp. Some includes are kept despite IWYU suggestions via IWYU pragma: keep comments, and nanobench.h has IWYU pragma blocks added. No functional code is modified.
Changed components
src/bench/* benchmark source filesci/test/03_test_script.sh IWYU enforcement regexsrc/addrman.cppsrc/addrman.hsrc/base58.hsrc/bech32.hsrc/prevector.hsrc/test/addrman_tests.cppInspect captured patch +211 / −100
diff --git a/ci/test/03_test_script.sh b/ci/test/03_test_script.sh
index 980583d0..9e7ee951 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 92178f30..3050beb7 100644
--- a/src/addrman.cpp
+++ b/src/addrman.cpp
@@ -11,6 +11,7 @@
#include <hash.h>
#include <logging/timer.h>
#include <netaddress.h>
+#include <netgroup.h>
#include <protocol.h>
#include <random.h>
#include <serialize.h>
diff --git a/src/addrman.h b/src/addrman.h
index 94e7d3e6..f7143386 100644
--- a/src/addrman.h
+++ b/src/addrman.h
@@ -7,18 +7,22 @@
#define BITCOIN_ADDRMAN_H
#include <netaddress.h>
-#include <netgroup.h>
#include <protocol.h>
-#include <streams.h>
#include <util/time.h>
+#include <cstddef>
#include <cstdint>
+#include <ios>
#include <memory>
#include <optional>
+#include <string>
+#include <tuple>
#include <unordered_set>
#include <utility>
#include <vector>
+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 f258163b..1656cbe1 100644
--- a/src/base58.h
+++ b/src/base58.h
@@ -14,8 +14,7 @@
#ifndef BITCOIN_BASE58_H
#define BITCOIN_BASE58_H
-#include <span.h>
-
+#include <span>
#include <string>
#include <vector>
diff --git a/src/bech32.h b/src/bech32.h
index ba4c79bb..9a43a58f 100644
--- a/src/bech32.h
+++ b/src/bech32.h
@@ -14,8 +14,10 @@
#ifndef BITCOIN_BECH32_H
#define BITCOIN_BECH32_H
+#include <cstddef>
#include <cstdint>
#include <string>
+#include <utility>
#include <vector>
namespace bech32
diff --git a/src/bench/addrman.cpp b/src/bench/addrman.cpp
index 703b4d24..5ce7893d 100644
--- a/src/bench/addrman.cpp
+++ b/src/bench/addrman.cpp
@@ -10,13 +10,13 @@
#include <netgroup.h>
#include <protocol.h>
#include <random.h>
-#include <span.h>
#include <uint256.h>
#include <util/check.h>
#include <util/time.h>
#include <cstring>
#include <optional>
+#include <span>
#include <vector>
/* 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 e834ea04..92b048f7 100644
--- a/src/bench/asmap.cpp
+++ b/src/bench/asmap.cpp
@@ -8,10 +8,10 @@
#include <node/data/ip_asn.dat.h>
#include <random.h>
#include <util/asmap.h>
+#include <util/check.h>
#include <algorithm>
#include <array>
-#include <cassert>
#include <span>
#include <string>
diff --git a/src/bench/base58.cpp b/src/bench/base58.cpp
index 0be16439..ed36dc32 100644
--- a/src/bench/base58.cpp
+++ b/src/bench/base58.cpp
@@ -4,7 +4,6 @@
#include <base58.h>
#include <bench/bench.h>
-#include <span.h>
#include <array>
#include <cstring>
diff --git a/src/bench/bech32.cpp b/src/bench/bech32.cpp
index c5e864ae..1147bd6d 100644
--- a/src/bench/bech32.cpp
+++ b/src/bench/bech32.cpp
@@ -6,6 +6,7 @@
#include <bench/bench.h>
#include <util/strencodings.h>
+#include <array>
#include <vector>
using namespace util::hex_literals;
diff --git a/src/bench/bench.cpp b/src/bench/bench.cpp
index 7ed425c4..4d1f4da0 100644
--- a/src/bench/bench.cpp
+++ b/src/bench/bench.cpp
@@ -7,8 +7,8 @@
#include <test/util/setup_common.h> // IWYU pragma: keep
#include <util/check.h>
#include <util/fs.h>
+#include <util/time.h>
-#include <chrono>
#include <compare>
#include <fstream>
#include <functional>
@@ -19,8 +19,6 @@
#include <utility>
#include <vector>
-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 9212c81d..54c75bc2 100644
--- a/src/bench/bench.h
+++ b/src/bench/bench.h
@@ -8,8 +8,8 @@
#include <bench/nanobench.h> // IWYU pragma: export
#include <util/fs.h>
#include <util/macros.h>
+#include <util/time.h>
-#include <chrono>
#include <functional>
#include <map>
#include <string>
diff --git a/src/bench/bench_bitcoin.cpp b/src/bench/bench_bitcoin.cpp
index 987523a1..fa0c170f 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 <bench/bench.h>
-#include <common/args.h>
#include <crypto/sha256.h>
+#include <test/util/setup_common.h>
#include <tinyformat.h>
#include <util/fs.h>
-#include <util/string.h>
-#include <test/util/setup_common.h>
+#include <util/time.h>
-#include <chrono>
#include <cstdint>
#include <cstdlib>
#include <exception>
#include <iostream>
+#include <optional>
#include <sstream>
+#include <string>
#include <vector>
static const char* DEFAULT_BENCH_FILTER = ".*";
diff --git a/src/bench/bip324_ecdh.cpp b/src/bench/bip324_ecdh.cpp
index 65deb8b7..c8d3a35e 100644
--- a/src/bench/bip324_ecdh.cpp
+++ b/src/bench/bip324_ecdh.cpp
@@ -11,6 +11,7 @@
#include <algorithm>
#include <array>
#include <cstddef>
+#include <span>
static void BIP324_ECDH(benchmark::Bench& bench)
{
diff --git a/src/bench/block_assemble.cpp b/src/bench/block_assemble.cpp
index be039174..45052ecf 100644
--- a/src/bench/block_assemble.cpp
+++ b/src/bench/block_assemble.cpp
@@ -12,13 +12,12 @@
#include <test/util/mining.h>
#include <test/util/script.h>
#include <test/util/setup_common.h>
+#include <util/check.h>
#include <validation.h>
#include <array>
-#include <cassert>
#include <cstddef>
#include <memory>
-#include <string>
#include <vector>
using node::BlockCreateOptions;
diff --git a/src/bench/blockencodings.cpp b/src/bench/blockencodings.cpp
index ce968dbc..274474d4 100644
--- a/src/bench/blockencodings.cpp
+++ b/src/bench/blockencodings.cpp
@@ -7,15 +7,23 @@
#include <consensus/amount.h>
#include <kernel/cs_main.h>
#include <net_processing.h>
+#include <primitives/block.h>
#include <primitives/transaction.h>
+#include <random.h>
#include <script/script.h>
#include <sync.h>
#include <test/util/setup_common.h>
#include <test/util/txmempool.h>
#include <txmempool.h>
+#include <uint256.h>
#include <util/check.h>
+#include <algorithm>
+#include <array>
+#include <cstddef>
#include <memory>
+#include <span>
+#include <utility>
#include <vector>
diff --git a/src/bench/ccoins_caching.cpp b/src/bench/ccoins_caching.cpp
index 12ea0760..ec44e663 100644
--- a/src/bench/ccoins_caching.cpp
+++ b/src/bench/ccoins_caching.cpp
@@ -5,14 +5,16 @@
#include <bench/bench.h>
#include <coins.h>
#include <consensus/amount.h>
+#include <consensus/validation.h>
#include <key.h>
#include <policy/policy.h>
#include <primitives/transaction.h>
#include <script/script.h>
#include <script/signingprovider.h>
#include <test/util/transaction_utils.h>
+#include <util/check.h>
-#include <cassert>
+#include <span>
#include <vector>
// Microbenchmark for simple accesses to a CCoinsViewCache database. Note from
diff --git a/src/bench/chacha20.cpp b/src/bench/chacha20.cpp
index b5a333d0..cc2b57eb 100644
--- a/src/bench/chacha20.cpp
+++ b/src/bench/chacha20.cpp
@@ -2,15 +2,16 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-
#include <bench/bench.h>
#include <crypto/chacha20.h>
#include <crypto/chacha20poly1305.h>
-#include <span.h>
-#include <util/byte_units.h>
+// IWYU incorrectly suggests removing this header.
+// See https://github.com/include-what-you-use/include-what-you-use/issues/2014.
+#include <util/byte_units.h> // IWYU pragma: keep
#include <cstddef>
#include <cstdint>
+#include <span>
#include <vector>
/* Number of bytes to process per iteration */
diff --git a/src/bench/checkblock.cpp b/src/bench/checkblock.cpp
index b943dc0f..a35f5e9d 100644
--- a/src/bench/checkblock.cpp
+++ b/src/bench/checkblock.cpp
@@ -5,13 +5,17 @@
#include <bench/bench.h>
#include <bench/data/block413567.raw.h>
#include <consensus/validation.h>
+#include <kernel/chainparams.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
+#include <serialize.h>
#include <streams.h>
+#include <util/check.h>
#include <validation.h>
-#include <cassert>
-#include <cstddef>
+#include <memory>
+#include <span>
+#include <vector>
// These are the two major time-sinks which happen after we have fully received
// a block off the wire, but before we can relay the block on to peers using
diff --git a/src/bench/checkqueue.cpp b/src/bench/checkqueue.cpp
index 2c9126dd..20f3094b 100644
--- a/src/bench/checkqueue.cpp
+++ b/src/bench/checkqueue.cpp
@@ -12,6 +12,7 @@
#include <cstddef>
#include <cstdint>
+#include <optional>
#include <utility>
#include <vector>
diff --git a/src/bench/cluster_linearize.cpp b/src/bench/cluster_linearize.cpp
index 0799cc2c..6d4c8382 100644
--- a/src/bench/cluster_linearize.cpp
+++ b/src/bench/cluster_linearize.cpp
@@ -4,13 +4,18 @@
#include <bench/bench.h>
#include <cluster_linearize.h>
+#include <serialize.h>
+#include <streams.h>
#include <test/util/cluster_linearize.h>
+#include <tinyformat.h>
#include <util/bitset.h>
+#include <util/check.h>
#include <util/strencodings.h>
-#include <algorithm>
-#include <cassert>
#include <cstdint>
+#include <span>
+#include <string>
+#include <tuple>
#include <vector>
using namespace cluster_linearize;
diff --git a/src/bench/coin_selection.cpp b/src/bench/coin_selection.cpp
index ff682720..4f203fe8 100644
--- a/src/bench/coin_selection.cpp
+++ b/src/bench/coin_selection.cpp
@@ -4,8 +4,6 @@
#include <bench/bench.h>
#include <consensus/amount.h>
-#include <interfaces/chain.h>
-#include <node/context.h>
#include <outputtype.h>
#include <policy/feerate.h>
#include <policy/policy.h>
@@ -13,19 +11,21 @@
#include <random.h>
#include <sync.h>
#include <test/util/setup_common.h>
+#include <util/check.h>
#include <util/result.h>
#include <wallet/coinselection.h>
-#include <wallet/context.h>
+#include <wallet/db.h>
#include <wallet/spend.h>
#include <wallet/test/util.h>
#include <wallet/transaction.h>
#include <wallet/wallet.h>
-#include <cassert>
+#include <cstddef>
+#include <cstdint>
#include <map>
#include <memory>
#include <optional>
-#include <set>
+#include <string>
#include <utility>
#include <vector>
diff --git a/src/bench/connectblock.cpp b/src/bench/connectblock.cpp
index 0c7470b5..5d530a5a 100644
--- a/src/bench/connectblock.cpp
+++ b/src/bench/connectblock.cpp
@@ -17,13 +17,12 @@
#include <script/script.h>
#include <sync.h>
#include <test/util/setup_common.h>
+#include <util/check.h>
#include <validation.h>
-#include <cassert>
#include <cstddef>
#include <memory>
#include <optional>
-#include <string>
#include <utility>
#include <vector>
diff --git a/src/bench/crypto_hash.cpp b/src/bench/crypto_hash.cpp
index 666ff3c0..4d0660db 100644
--- a/src/bench/crypto_hash.cpp
+++ b/src/bench/crypto_hash.cpp
@@ -2,7 +2,6 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-
#include <bench/bench.h>
#include <crypto/muhash.h>
#include <crypto/ripemd160.h>
@@ -12,11 +11,12 @@
#include <crypto/sha512.h>
#include <crypto/siphash.h>
#include <random.h>
-#include <span.h>
#include <tinyformat.h>
#include <uint256.h>
#include <cstdint>
+#include <span>
+#include <string>
#include <vector>
/* Number of bytes to hash per iteration */
diff --git a/src/bench/descriptors.cpp b/src/bench/descriptors.cpp
index c375d312..af5dc46b 100644
--- a/src/bench/descriptors.cpp
+++ b/src/bench/descriptors.cpp
@@ -7,8 +7,8 @@
#include <script/descriptor.h>
#include <script/script.h>
#include <script/signingprovider.h>
+#include <util/check.h>
-#include <cassert>
#include <cstdint>
#include <memory>
#include <string>
diff --git a/src/bench/disconnected_transactions.cpp b/src/bench/disconnected_transactions.cpp
index 4dd5de42..1ab2ec6c 100644
--- a/src/bench/disconnected_transactions.cpp
+++ b/src/bench/disconnected_transactions.cpp
@@ -8,13 +8,12 @@
#include <primitives/transaction.h>
#include <script/script.h>
#include <test/util/setup_common.h>
+#include <util/check.h>
#include <algorithm>
-#include <cassert>
#include <cstddef>
#include <cstdint>
#include <iterator>
-#include <memory>
#include <vector>
constexpr size_t BLOCK_VTX_COUNT{4000};
diff --git a/src/bench/duplicate_inputs.cpp b/src/bench/duplicate_inputs.cpp
index 5b1ca5f5..a5280667 100644
--- a/src/bench/duplicate_inputs.cpp
+++ b/src/bench/duplicate_inputs.cpp
@@ -16,9 +16,9 @@
#include <sync.h>
#include <test/util/setup_common.h>
#include <uint256.h>
+#include <util/check.h>
#include <validation.h>
-#include <cassert>
#include <cstdint>
#include <memory>
#include <string>
diff --git a/src/bench/ellswift.cpp b/src/bench/ellswift.cpp
index 2daf1a9e..2951ca9b 100644
--- a/src/bench/ellswift.cpp
+++ b/src/bench/ellswift.cpp
@@ -8,9 +8,10 @@
#include <random.h>
#include <span.h>
#include <uint256.h>
+#include <util/check.h>
#include <algorithm>
-#include <cassert>
+#include <span>
static void EllSwiftCreate(benchmark::Bench& bench)
{
diff --git a/src/bench/index_blockfilter.cpp b/src/bench/index_blockfilter.cpp
index 781aa097..b0931a5b 100644
--- a/src/bench/index_blockfilter.cpp
+++ b/src/bench/index_blockfilter.cpp
@@ -13,17 +13,16 @@
#include <primitives/transaction.h>
#include <pubkey.h>
#include <script/script.h>
-#include <span.h>
#include <sync.h>
#include <test/util/setup_common.h>
#include <test/util/time.h>
#include <uint256.h>
+#include <util/check.h>
#include <util/strencodings.h>
-#include <util/time.h>
#include <validation.h>
-#include <cassert>
#include <memory>
+#include <span>
#include <vector>
using namespace util::hex_literals;
diff --git a/src/bench/load_external.cpp b/src/bench/load_external.cpp
index 8e7201ea..77c229f1 100644
--- a/src/bench/load_external.cpp
+++ b/src/bench/load_external.cpp
@@ -7,7 +7,6 @@
#include <chainparams.h>
#include <flatfile.h>
#include <node/blockstorage.h>
-#include <span.h>
#include <streams.h>
#include <test/util/setup_common.h>
#include <uint256.h>
@@ -18,8 +17,8 @@
#include <cstdio>
#include <map>
#include <memory>
+#include <span>
#include <stdexcept>
-#include <vector>
/**
* The LoadExternalBlockFile() function is used during -reindex and -loadblock.
diff --git a/src/bench/lockedpool.cpp b/src/bench/lockedpool.cpp
index 61b35cce..0a924a72 100644
--- a/src/bench/lockedpool.cpp
+++ b/src/bench/lockedpool.cpp
@@ -4,10 +4,12 @@
#include <bench/bench.h>
#include <support/lockedpool.h>
+// IWYU incorrectly suggests removing this header.
+// See https://github.com/include-what-you-use/include-what-you-use/issues/2014.
+#include <util/byte_units.h> // IWYU pragma: keep
#include <cstddef>
#include <cstdint>
-#include <util/byte_units.h>
#include <vector>
#define ASIZE 2048
diff --git a/src/bench/mempool_ephemeral_spends.cpp b/src/bench/mempool_ephemeral_spends.cpp
index 1c069287..f88643c5 100644
--- a/src/bench/mempool_ephemeral_spends.cpp
+++ b/src/bench/mempool_ephemeral_spends.cpp
@@ -4,9 +4,10 @@
#include <bench/bench.h>
#include <consensus/amount.h>
+#include <consensus/validation.h>
#include <kernel/cs_main.h>
#include <policy/ephemeral_policy.h>
-#include <policy/policy.h>
+#include <policy/feerate.h>
#include <primitives/transaction.h>
#include <script/script.h>
#include <sync.h>
@@ -15,6 +16,7 @@
#include <txmempool.h>
#include <util/check.h>
+#include <cstddef>
#include <cstdint>
#include <memory>
#include <vector>
diff --git a/src/bench/mempool_stress.cpp b/src/bench/mempool_stress.cpp
index 1f582081..ab1146e1 100644
--- a/src/bench/mempool_stress.cpp
+++ b/src/bench/mempool_stress.cpp
@@ -4,7 +4,6 @@
#include <bench/bench.h>
#include <consensus/amount.h>
-#include <policy/policy.h>
#include <primitives/transaction.h>
#include <random.h>
#include <script/script.h>
@@ -17,6 +16,7 @@
#include <cstddef>
#include <cstdint>
#include <memory>
+#include <optional>
#include <vector>
class CCoinsViewCache;
diff --git a/src/bench/merkle_root.cpp b/src/bench/merkle_root.cpp
index 17f7fa86..d80ddb21 100644
--- a/src/bench/merkle_root.cpp
+++ b/src/bench/merkle_root.cpp
@@ -6,8 +6,10 @@
#include <consensus/merkle.h>
#include <random.h>
#include <uint256.h>
+#include <util/check.h>
-#include <cassert>
+#include <initializer_list>
+#include <utility>
#include <vector>
static void MerkleRoot(benchmark::Bench& bench)
diff --git a/src/bench/nanobench.h b/src/bench/nanobench.h
index 79a384aa..78512908 100644
--- a/src/bench/nanobench.h
+++ b/src/bench/nanobench.h
@@ -41,10 +41,19 @@
#include <chrono> // high_resolution_clock
#include <cassert> // assert
+#include <cstdint>
#include <cstring> // memcpy
+// IWYU will only see this header with ANKERL_NANOBENCH_IMPLEMENT defined, which
+// makes it suggest removing forward declarations for the Input/output library.
+// IWYU pragma: begin_keep
#include <iosfwd> // for std::ostream* custom output target in Config
+// IWYU pragma: end_keep
+#include <limits>
+#include <ratio>
#include <string> // all names
+#include <type_traits>
#include <unordered_map> // holds context information of results
+#include <utility>
#include <vector> // holds all results
#define ANKERL_NANOBENCH(x) ANKERL_NANOBENCH_PRIVATE_##x()
@@ -127,6 +136,11 @@
// declarations ///////////////////////////////////////////////////////////////////////////////////
+// As definitions follow these declarations within this
+// header, IWYU considers some of them redundant and
+// suggests removing them. Disable this IWYU behavior.
+// IWYU pragma: begin_keep
+
namespace ankerl {
namespace nanobench {
@@ -370,6 +384,8 @@ class LinuxPerformanceCounters;
} // namespace nanobench
} // namespace ankerl
+// IWYU pragma: end_keep
+
// definitions ////////////////////////////////////////////////////////////////////////////////////
namespace ankerl {
@@ -1359,12 +1375,15 @@ void doNotOptimizeAway(T const& val) {
///////////////////////////////////////////////////////////////////////////////////////////////////
# include <algorithm> // sort, reverse
-# include <atomic> // compare_exchange_strong in loop overhead
+# include <cmath>
+# include <compare>
# include <cstdlib> // getenv
-# include <cstring> // strstr, strncmp
# include <fstream> // ifstream to parse proc files
+# include <functional>
# include <iomanip> // setw, setprecision
# include <iostream> // cout
+# include <iterator>
+# include <locale>
# include <numeric> // accumulate
# include <random> // random_device
# include <sstream> // to_s in Number
@@ -1379,18 +1398,22 @@ void doNotOptimizeAway(T const& val) {
# include <linux/perf_event.h>
# include <sys/ioctl.h>
# include <sys/syscall.h>
+# include <sys/types.h>
# endif
// declarations ///////////////////////////////////////////////////////////////////////////////////
+// As definitions follow these declarations within this
+// header, IWYU considers some of them redundant and
+// suggests removing them. Disable this IWYU behavior.
+// IWYU pragma: begin_keep
+
namespace ankerl {
namespace nanobench {
// helper stuff that is only intended to be used internally
namespace detail {
-struct TableInfo;
-
// formatting utilities
namespace fmt {
@@ -1405,6 +1428,8 @@ class MarkDownCode;
} // namespace nanobench
} // namespace ankerl
+// IWYU pragma: end_keep
+
// definitions ////////////////////////////////////////////////////////////////////////////////////
namespace ankerl {
diff --git a/src/bench/obfuscation.cpp b/src/bench/obfuscation.cpp
index c7392e03..1587b734 100644
--- a/src/bench/obfuscation.cpp
+++ b/src/bench/obfuscation.cpp
@@ -7,6 +7,7 @@
#include <util/obfuscation.h>
#include <cstddef>
+#include <span>
#include <vector>
static void ObfuscationBench(benchmark::Bench& bench)
diff --git a/src/bench/parse_hex.cpp b/src/bench/parse_hex.cpp
index 928176bd..846009a3 100644
--- a/src/bench/parse_hex.cpp
+++ b/src/bench/parse_hex.cpp
@@ -4,11 +4,12 @@
#include <bench/bench.h>
#include <random.h>
+#include <util/check.h>
#include <util/strencodings.h>
-#include <cassert>
#include <cstddef>
#include <optional>
+#include <string>
#include <vector>
std::string generateHexString(size_t length) {
diff --git a/src/bench/peer_eviction.cpp b/src/bench/peer_eviction.cpp
index 24b78e31..b9c1c9b3 100644
--- a/src/bench/peer_eviction.cpp
+++ b/src/bench/peer_eviction.cpp
@@ -7,8 +7,8 @@
#include <node/eviction.h>
#include <random.h>
#include <test/util/net.h>
+#include <util/time.h>
-#include <chrono>
#include <functional>
#include <vector>
diff --git a/src/bench/poly1305.cpp b/src/bench/poly1305.cpp
index ef5a573d..a3d0f94b 100644
--- a/src/bench/poly1305.cpp
+++ b/src/bench/poly1305.cpp
@@ -2,14 +2,15 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-
#include <bench/bench.h>
#include <crypto/poly1305.h>
-#include <span.h>
-#include <util/byte_units.h>
+// IWYU incorrectly suggests removing this header.
+// See https://github.com/include-what-you-use/include-what-you-use/issues/2014.
+#include <util/byte_units.h> // IWYU pragma: keep
#include <cstddef>
#include <cstdint>
+#include <span>
#include <vector>
/* Number of bytes to process per iteration */
diff --git a/src/bench/pool.cpp b/src/bench/pool.cpp
index cf4ba132..f5cfb99a 100644
--- a/src/bench/pool.cpp
+++ b/src/bench/pool.cpp
@@ -10,6 +10,7 @@
#include <functional>
#include <unordered_map>
#include <utility>
+#include <variant>
template <typename Map>
void BenchFillClearMap(benchmark::Bench& bench, Map& map)
diff --git a/src/bench/prevector.cpp b/src/bench/prevector.cpp
index e842aec4..2b5544fe 100644
--- a/src/bench/prevector.cpp
+++ b/src/bench/prevector.cpp
@@ -9,6 +9,7 @@
#include <serialize.h>
#include <streams.h>
+#include <span>
#include <type_traits>
#include <vector>
diff --git a/src/bench/readwriteblock.cpp b/src/bench/readwriteblock.cpp
index f1ad24a6..984936db 100644
--- a/src/bench/readwriteblock.cpp
+++ b/src/bench/readwriteblock.cpp
@@ -9,15 +9,16 @@
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <serialize.h>
-#include <span.h>
#include <streams.h>
+#include <sync.h>
#include <test/util/setup_common.h>
+#include <uint256.h>
+#include <util/check.h>
#include <validation.h>
-#include <cassert>
-#include <cstdint>
#include <memory>
-#include <vector>
+#include <optional>
+#include <span>
static CBlock CreateTestBlock()
{
diff --git a/src/bench/rollingbloom.cpp b/src/bench/rollingbloom.cpp
index 8331eb6a..0f9bc9e8 100644
--- a/src/bench/rollingbloom.cpp
+++ b/src/bench/rollingbloom.cpp
@@ -2,13 +2,12 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-
#include <bench/bench.h>
#include <common/bloom.h>
#include <crypto/common.h>
-#include <span.h>
#include <cstdint>
+#include <span>
#include <vector>
static void RollingBloom(benchmark::Bench& bench)
diff --git a/src/bench/rpc_blockchain.cpp b/src/bench/rpc_blockchain.cpp
index fe83c4a2..b09eae64 100644
--- a/src/bench/rpc_blockchain.cpp
+++ b/src/bench/rpc_blockchain.cpp
@@ -5,21 +5,22 @@
#include <bench/bench.h>
#include <bench/data/block413567.raw.h>
#include <chain.h>
+#include <consensus/params.h>
#include <core_io.h>
+#include <kernel/chainparams.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <rpc/blockchain.h>
#include <serialize.h>
-#include <span.h>
#include <streams.h>
#include <test/util/setup_common.h>
#include <uint256.h>
#include <univalue.h>
#include <validation.h>
-#include <cstddef>
#include <memory>
-#include <vector>
+#include <span>
+#include <string>
namespace {
diff --git a/src/bench/sign_transaction.cpp b/src/bench/sign_transaction.cpp
index 63a5d97f..38955595 100644
--- a/src/bench/sign_transaction.cpp
+++ b/src/bench/sign_transaction.cpp
@@ -8,17 +8,17 @@
#include <key.h>
#include <primitives/transaction.h>
#include <pubkey.h>
+#include <random.h>
#include <script/interpreter.h>
#include <script/script.h>
#include <script/sign.h>
#include <script/signingprovider.h>
-#include <span.h>
-#include <test/util/random.h>
#include <uint256.h>
+#include <util/check.h>
#include <util/translation.h>
-#include <cassert>
#include <map>
+#include <span>
#include <vector>
enum class InputType {
diff --git a/src/bench/streams_findbyte.cpp b/src/bench/streams_findbyte.cpp
index c9ea486c..456f5aef 100644
--- a/src/bench/streams_findbyte.cpp
+++ b/src/bench/streams_findbyte.cpp
@@ -5,11 +5,13 @@
#include <bench/bench.h>
#include <streams.h>
#include <test/util/setup_common.h>
+#include <util/check.h>
#include <util/fs.h>
#include <cstddef>
#include <cstdint>
#include <cstdio>
+#include <memory>
static void FindByte(benchmark::Bench& bench)
{
diff --git a/src/bench/strencodings.cpp b/src/bench/strencodings.cpp
index c00de181..4b52b744 100644
--- a/src/bench/strencodings.cpp
+++ b/src/bench/strencodings.cpp
@@ -6,9 +6,10 @@
#include <consensus/consensus.h>
#include <crypto/hex_base.h>
#include <random.h>
-#include <span.h>
-#include <util/strencodings.h>
+#include <cstddef>
+#include <span>
+#include <string>
#include <vector>
static void HexStrBench(benchmark::Bench& bench)
diff --git a/src/bench/txgraph.cpp b/src/bench/txgraph.cpp
index c56a284a..57081dd9 100644
--- a/src/bench/txgraph.cpp
+++ b/src/bench/txgraph.cpp
@@ -5,10 +5,17 @@
#include <bench/bench.h>
#include <random.h>
#include <txgraph.h>
+#include <util/check.h>
#include <util/feefrac.h>
-#include <cassert>
+#include <algorithm>
+#include <compare>
+#include <cstddef>
#include <cstdint>
+#include <functional>
+#include <memory>
+#include <utility>
+#include <vector>
namespace {
diff --git a/src/bench/txorphanage.cpp b/src/bench/txorphanage.cpp
index 1f94553b..8765a7b9 100644
--- a/src/bench/txorphanage.cpp
+++ b/src/bench/txorphanage.cpp
@@ -3,19 +3,24 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <bench/bench.h>
-#include <consensus/amount.h>
+#include <consensus/consensus.h>
+#include <consensus/validation.h>
#include <net.h>
#include <policy/policy.h>
+#include <primitives/block.h>
#include <primitives/transaction.h>
-#include <pubkey.h>
-#include <script/sign.h>
-#include <test/util/setup_common.h>
#include <node/txorphanage.h>
-#include <util/check.h>
+#include <random.h>
#include <test/util/transaction_utils.h>
+#include <threadsafety.h>
+#include <util/check.h>
+#include <algorithm>
+#include <cstddef>
#include <cstdint>
#include <memory>
+#include <numeric>
+#include <vector>
static constexpr node::TxOrphanage::Usage TINY_TX_WEIGHT{240};
static constexpr int64_t APPROX_WEIGHT_PER_INPUT{200};
diff --git a/src/bench/verify_script.cpp b/src/bench/verify_script.cpp
index 63a9544a..b6d73b86 100644
--- a/src/bench/verify_script.cpp
+++ b/src/bench/verify_script.cpp
@@ -11,14 +11,19 @@
#include <pubkey.h>
#include <script/interpreter.h>
#include <script/script.h>
+#include <script/script_error.h>
+#include <script/sign.h>
+#include <script/signingprovider.h>
+#include <script/verify_flags.h>
#include <span.h>
#include <test/util/transaction_utils.h>
#include <uint256.h>
+#include <util/check.h>
#include <util/translation.h>
-#include <array>
-#include <cassert>
-#include <cstdint>
+#include <cstddef>
+#include <map>
+#include <span>
#include <vector>
enum class ScriptType {
diff --git a/src/bench/wallet_balance.cpp b/src/bench/wallet_balance.cpp
index dd04a5c1..958044e2 100644
--- a/src/bench/wallet_balance.cpp
+++ b/src/bench/wallet_balance.cpp
@@ -4,6 +4,7 @@
#include <bench/bench.h>
#include <interfaces/chain.h>
+#include <interfaces/handler.h>
#include <kernel/chainparams.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
@@ -12,14 +13,14 @@
#include <test/util/setup_common.h>
#include <test/util/time.h>
#include <uint256.h>
-#include <util/time.h>
+#include <util/check.h>
#include <validation.h>
+#include <wallet/db.h>
#include <wallet/receive.h>
#include <wallet/test/util.h>
#include <wallet/wallet.h>
#include <wallet/walletutil.h>
-#include <cassert>
#include <memory>
#include <optional>
#include <string>
diff --git a/src/bench/wallet_create.cpp b/src/bench/wallet_create.cpp
index 11244fe8..13e8ee14 100644
--- a/src/bench/wallet_create.cpp
+++ b/src/bench/wallet_create.cpp
@@ -4,9 +4,9 @@
#include <bench/bench.h>
#include <random.h>
-#include <support/allocators/secure.h>
#include <test/util/setup_common.h>
#include <uint256.h>
+#include <util/check.h>
#include <util/fs.h>
#include <util/translation.h>
#include <wallet/context.h>
@@ -14,7 +14,6 @@
#include <wallet/wallet.h>
#include <wallet/walletutil.h>
-#include <cassert>
#include <memory>
#include <optional>
#include <string>
diff --git a/src/bench/wallet_create_tx.cpp b/src/bench/wallet_create_tx.cpp
index 68bbc3d6..394f21ce 100644
--- a/src/bench/wallet_create_tx.cpp
+++ b/src/bench/wallet_create_tx.cpp
@@ -9,7 +9,6 @@
#include <consensus/amount.h>
#include <consensus/consensus.h>
#include <consensus/merkle.h>
-#include <interfaces/chain.h>
#include <kernel/chain.h>
#include <kernel/types.h>
#include <node/blockstorage.h>
@@ -22,22 +21,24 @@
#include <test/util/setup_common.h>
#include <test/util/time.h>
#include <uint256.h>
+#include <util/check.h>
#include <util/result.h>
-#include <util/time.h>
#include <validation.h>
#include <versionbits.h>
#include <wallet/coincontrol.h>
#include <wallet/coinselection.h>
+#include <wallet/db.h>
#include <wallet/spend.h>
#include <wallet/test/util.h>
+#include <wallet/types.h>
#include <wallet/wallet.h>
#include <wallet/walletutil.h>
-#include <cassert>
#include <cstdint>
#include <map>
#include <memory>
#include <optional>
+#include <string>
#include <utility>
#include <vector>
diff --git a/src/bench/wallet_encrypt.cpp b/src/bench/wallet_encrypt.cpp
index 58646013..81e64a28 100644
--- a/src/bench/wallet_encrypt.cpp
+++ b/src/bench/wallet_encrypt.cpp
@@ -3,19 +3,29 @@
// file COPYING or https://www.opensource.org/licenses/mit-license.php.
#include <bench/bench.h>
+#include <key.h>
#include <key_io.h>
-#include <outputtype.h>
#include <random.h>
+#include <script/descriptor.h>
+#include <script/signingprovider.h>
#include <support/allocators/secure.h>
+#include <sync.h>
#include <test/util/setup_common.h>
#include <test/util/time.h>
-#include <util/time.h>
+#include <util/check.h>
#include <wallet/context.h>
+#include <wallet/crypter.h>
+#include <wallet/db.h>
#include <wallet/test/util.h>
#include <wallet/wallet.h>
#include <wallet/walletutil.h>
-#include <cassert>
+#include <cstdint>
+#include <functional>
+#include <memory>
+#include <string>
+#include <utility>
+#include <vector>
namespace wallet {
static void WalletEncrypt(benchmark::Bench& bench, unsigned int key_count)
diff --git a/src/bench/wallet_ismine.cpp b/src/bench/wallet_ismine.cpp
index 6bfbb42d..572a2717 100644
--- a/src/bench/wallet_ismine.cpp
+++ b/src/bench/wallet_ismine.cpp
@@ -11,17 +11,19 @@
#include <script/signingprovider.h>
#include <sync.h>
#include <test/util/setup_common.h>
+#include <util/check.h>
#include <wallet/context.h>
#include <wallet/db.h>
#include <wallet/test/util.h>
#include <wallet/wallet.h>
#include <wallet/walletutil.h>
-#include <cassert>
#include <cstdint>
+#include <functional>
#include <memory>
#include <string>
#include <utility>
+#include <vector>
namespace wallet {
static void WalletIsMine(benchmark::Bench& bench, int num_combo = 0)
diff --git a/src/bench/wallet_loading.cpp b/src/bench/wallet_loading.cpp
index 09028acd..6b1208ea 100644
--- a/src/bench/wallet_loading.cpp
+++ b/src/bench/wallet_loading.cpp
@@ -7,8 +7,10 @@
#include <consensus/amount.h>
#include <outputtype.h>
#include <primitives/transaction.h>
+#include <script/script.h>
#include <test/util/setup_common.h>
#include <util/check.h>
+#include <util/translation.h>
#include <wallet/context.h>
#include <wallet/db.h>
#include <wallet/test/util.h>
@@ -18,6 +20,8 @@
#include <cstdint>
#include <memory>
+#include <optional>
+#include <string>
#include <utility>
#include <vector>
diff --git a/src/bench/wallet_migration.cpp b/src/bench/wallet_migration.cpp
index 578fdb50..22caec75 100644
--- a/src/bench/wallet_migration.cpp
+++ b/src/bench/wallet_migration.cpp
@@ -2,20 +2,34 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php.
+#include <addresstype.h>
#include <bench/bench.h>
-#include <interfaces/chain.h>
+#include <consensus/amount.h>
#include <interfaces/wallet.h>
-#include <kernel/chain.h>
-#include <kernel/types.h>
-#include <node/context.h>
-#include <test/util/mining.h>
+#include <key.h>
+#include <primitives/block.h>
+#include <primitives/transaction.h>
+#include <pubkey.h>
+#include <script/script.h>
+#include <sync.h>
#include <test/util/setup_common.h>
-#include <wallet/context.h>
-#include <wallet/receive.h>
+#include <tinyformat.h>
+#include <util/check.h>
+#include <util/result.h>
+#include <wallet/db.h>
+#include <wallet/scriptpubkeyman.h>
#include <wallet/test/util.h>
+#include <wallet/transaction.h>
#include <wallet/wallet.h>
+#include <wallet/walletdb.h>
+#include <algorithm>
+#include <cstddef>
+#include <memory>
#include <optional>
+#include <string>
+#include <utility>
+#include <vector>
namespace wallet{
diff --git a/src/prevector.h b/src/prevector.h
index 91be4880..e8a71bc9 100644
--- a/src/prevector.h
+++ b/src/prevector.h
@@ -7,11 +7,11 @@
#include <algorithm>
#include <cassert>
-#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <iterator>
+#include <new>
#include <type_traits>
#include <utility>
diff --git a/src/test/addrman_tests.cpp b/src/test/addrman_tests.cpp
index 117ca8c6..0348a87f 100644
--- a/src/test/addrman_tests.cpp
+++ b/src/test/addrman_tests.cpp
@@ -9,6 +9,7 @@
#include <clientversion.h>
#include <hash.h>
#include <netbase.h>
+#include <netgroup.h>
#include <random.h>
#include <test/data/asmap.raw.h>
#include <test/util/setup_common.h>
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.