kernel: Remove some unnecessary non-kernel includes

Specifically gets rid of batchpriority, chainparams, script/sign.h and
system includes.

Also take the opportunity of cleaning up the headers for the effected
files and adding them to the iwyu-enforced set.
This commit is contained in:
TheCharlatan
2025-06-01 18:31:40 +02:00
committed by sedited
parent 7f295e1d9b
commit d69a582e72
8 changed files with 50 additions and 19 deletions

View File

@@ -209,7 +209,7 @@ if [ "${RUN_TIDY}" = "true" ]; then
fi
# TODO: Consider enforcing IWYU across the entire codebase.
FILES_WITH_ENFORCED_IWYU="/src/(crypto|index)/.*\\.cpp"
FILES_WITH_ENFORCED_IWYU="/src/((crypto|index)/.*\\.cpp|node/blockstorage.cpp|node/utxo_snapshot.cpp|core_read.cpp|signet.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"

View File

@@ -4,17 +4,27 @@
#include <core_io.h>
#include <primitives/block.h>
#include <primitives/block.h> // IWYU pragma: keep
#include <primitives/transaction.h>
#include <script/interpreter.h>
#include <script/script.h>
#include <script/sign.h>
#include <serialize.h>
#include <streams.h>
#include <util/result.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <util/translation.h>
#include <algorithm>
#include <string>
#include <compare>
#include <cstdint>
#include <exception>
#include <map>
#include <optional>
#include <span>
#include <stdexcept>
#include <utility>
#include <vector>
using util::SplitString;

View File

@@ -7,12 +7,10 @@
#include <arith_uint256.h>
#include <chain.h>
#include <consensus/params.h>
#include <consensus/validation.h>
#include <dbwrapper.h>
#include <flatfile.h>
#include <hash.h>
#include <kernel/blockmanager_opts.h>
#include <kernel/chain.h>
#include <kernel/chainparams.h>
#include <kernel/messagestartchars.h>
#include <kernel/notifications_interface.h>
@@ -24,16 +22,17 @@
#include <random.h>
#include <serialize.h>
#include <signet.h>
#include <span.h>
#include <streams.h>
#include <sync.h>
#include <tinyformat.h>
#include <uint256.h>
#include <undo.h>
#include <util/batchpriority.h>
#include <util/check.h>
#include <util/expected.h>
#include <util/fs.h>
#include <util/obfuscation.h>
#include <util/overflow.h>
#include <util/result.h>
#include <util/signalinterrupt.h>
#include <util/strencodings.h>
#include <util/syserror.h>
@@ -41,9 +40,17 @@
#include <util/translation.h>
#include <validation.h>
#include <cerrno>
#include <compare>
#include <cstddef>
#include <cstdio>
#include <exception>
#include <map>
#include <optional>
#include <ostream>
#include <span>
#include <stdexcept>
#include <system_error>
#include <unordered_map>
namespace kernel {

View File

@@ -14,17 +14,22 @@
#include <kernel/cs_main.h>
#include <kernel/messagestartchars.h>
#include <primitives/block.h>
#include <serialize.h>
#include <streams.h>
#include <sync.h>
#include <uint256.h>
#include <util/expected.h>
#include <util/fs.h>
#include <util/hasher.h>
#include <util/obfuscation.h>
#include <algorithm>
#include <array>
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <iosfwd>
#include <limits>
#include <map>
#include <memory>

View File

@@ -8,7 +8,6 @@
#include <streams.h>
#include <sync.h>
#include <tinyformat.h>
#include <txdb.h>
#include <uint256.h>
#include <util/fs.h>
#include <validation.h>
@@ -16,6 +15,7 @@
#include <cassert>
#include <cstdio>
#include <optional>
#include <span>
#include <string>
namespace node {

View File

@@ -6,18 +6,22 @@
#ifndef BITCOIN_NODE_UTXO_SNAPSHOT_H
#define BITCOIN_NODE_UTXO_SNAPSHOT_H
#include <chainparams.h>
#include <kernel/chainparams.h>
#include <kernel/cs_main.h>
#include <serialize.h>
#include <kernel/messagestartchars.h>
#include <sync.h>
#include <tinyformat.h>
#include <uint256.h>
#include <util/chaintype.h>
#include <util/check.h>
#include <util/fs.h>
#include <algorithm>
#include <array>
#include <cstdint>
#include <ios>
#include <optional>
#include <set>
#include <string>
#include <string_view>
// UTXO set snapshot magic bytes

View File

@@ -4,24 +4,25 @@
#include <signet.h>
#include <common/system.h>
#include <consensus/merkle.h>
#include <consensus/params.h>
#include <consensus/validation.h>
#include <core_io.h>
#include <hash.h>
#include <logging.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <script/interpreter.h>
#include <span.h>
#include <script/script.h>
#include <streams.h>
#include <uint256.h>
#include <util/strencodings.h>
#include <util/check.h>
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <exception>
#include <memory>
#include <span>
#include <utility>
#include <vector>
static constexpr uint8_t SIGNET_HEADER[4] = {0xec, 0xc7, 0xda, 0xa2};

View File

@@ -5,12 +5,16 @@
#ifndef BITCOIN_SIGNET_H
#define BITCOIN_SIGNET_H
#include <consensus/params.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <optional>
class CScript;
namespace Consensus {
struct Params;
} // namespace Consensus
/**
* Extract signature and check whether a block has a valid solution
*/