ci, iwyu: Fix warnings in `src/zmq` and treat them as errors
What changed, and why it matters
This is a routine code cleanup that adjusts which C++ header files are included in the ZeroMQ (ZMQ) notification module. It also tells the project's automated style checker to treat missing or unnecessary includes in these files as errors going forward. There is no change to program logic, no bug fix, and no security-relevant behavior.
No security action needed. Treat as normal maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit is an Include-What-You-Use (IWYU) hygiene pass for src/zmq. It removes unused includes (e.g., chainparams.h, node/blockstorage.h, cassert), adds headers that were previously only implicitly available (e.g., util/check.h, cstddef, span), and updates the CI regex that decides which files get strict IWYU enforcement. A .clang-format rule is added so
Changed components
src/zmq/zmqnotificationinterface.cppsrc/zmq/zmqnotificationinterface.hsrc/zmq/zmqpublishnotifier.cppsrc/zmq/zmqpublishnotifier.hsrc/zmq/zmqrpc.cppsrc/zmq/zmqutil.cppci/test/03_test_script.shsrc/.clang-formatInspect captured patch +15 / −19
diff --git a/ci/test/03_test_script.sh b/ci/test/03_test_script.sh
index 7f605fb0..b85507f4 100755
--- a/ci/test/03_test_script.sh
+++ b/ci/test/03_test_script.sh
@@ -215,7 +215,7 @@ fi
if [[ "${RUN_IWYU}" == true ]]; then
# TODO: Consider enforcing IWYU across the entire codebase.
- FILES_WITH_ENFORCED_IWYU="/src/((crypto|index|kernel|primitives)/.*\\.cpp|node/blockstorage.cpp|node/utxo_snapshot.cpp|core_io.cpp|signet.cpp)"
+ FILES_WITH_ENFORCED_IWYU="/src/((crypto|index|kernel|primitives|zmq)/.*\\.cpp|node/blockstorage.cpp|node/utxo_snapshot.cpp|core_io.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"
diff --git a/src/.clang-format b/src/.clang-format
index 2b74e40b..72a20228 100644
--- a/src/.clang-format
+++ b/src/.clang-format
@@ -108,6 +108,9 @@ IncludeCategories:
- Regex: '^<Q'
Priority: 2
CaseSensitive: true
+ - Regex: '^<zmq.h>$'
+ Priority: 2
+ CaseSensitive: true
- Regex: '^<[^>.]*>'
Priority: 3
CaseSensitive: false
diff --git a/src/zmq/zmqnotificationinterface.cpp b/src/zmq/zmqnotificationinterface.cpp
index a341c47b..9efb3eb7 100644
--- a/src/zmq/zmqnotificationinterface.cpp
+++ b/src/zmq/zmqnotificationinterface.cpp
@@ -11,14 +11,13 @@
#include <netbase.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
-#include <validationinterface.h>
+#include <util/check.h>
#include <zmq/zmqabstractnotifier.h>
#include <zmq/zmqpublishnotifier.h>
#include <zmq/zmqutil.h>
#include <zmq.h>
-#include <cassert>
#include <map>
#include <string>
#include <utility>
diff --git a/src/zmq/zmqnotificationinterface.h b/src/zmq/zmqnotificationinterface.h
index 12d805c1..e2039df2 100644
--- a/src/zmq/zmqnotificationinterface.h
+++ b/src/zmq/zmqnotificationinterface.h
@@ -8,16 +8,15 @@
#include <primitives/transaction.h>
#include <validationinterface.h>
+#include <cstddef>
#include <cstdint>
#include <functional>
#include <list>
#include <memory>
#include <vector>
-class CBlock;
class CBlockIndex;
class CZMQAbstractNotifier;
-struct NewMempoolTransactionInfo;
class CZMQNotificationInterface final : public CValidationInterface
{
diff --git a/src/zmq/zmqpublishnotifier.cpp b/src/zmq/zmqpublishnotifier.cpp
index 44ef34b1..56cdea05 100644
--- a/src/zmq/zmqpublishnotifier.cpp
+++ b/src/zmq/zmqpublishnotifier.cpp
@@ -5,39 +5,30 @@
#include <zmq/zmqpublishnotifier.h>
#include <chain.h>
-#include <chainparams.h>
#include <crypto/common.h>
-#include <kernel/cs_main.h>
#include <logging.h>
#include <netaddress.h>
#include <netbase.h>
-#include <node/blockstorage.h>
-#include <primitives/block.h>
#include <primitives/transaction.h>
-#include <rpc/server.h>
#include <serialize.h>
#include <streams.h>
-#include <sync.h>
#include <uint256.h>
+#include <util/check.h>
#include <zmq/zmqutil.h>
#include <zmq.h>
-#include <cassert>
#include <cstdarg>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <map>
#include <optional>
+#include <span>
#include <string>
#include <utility>
#include <vector>
-namespace Consensus {
-struct Params;
-}
-
static std::multimap<std::string, CZMQAbstractPublishNotifier*> mapPublishNotifiers;
static const char *MSG_HASHBLOCK = "hashblock";
diff --git a/src/zmq/zmqpublishnotifier.h b/src/zmq/zmqpublishnotifier.h
index 226797e3..842403fa 100644
--- a/src/zmq/zmqpublishnotifier.h
+++ b/src/zmq/zmqpublishnotifier.h
@@ -10,10 +10,10 @@
#include <cstddef>
#include <cstdint>
#include <functional>
+#include <utility>
#include <vector>
class CBlockIndex;
-class CTransaction;
class CZMQAbstractPublishNotifier : public CZMQAbstractNotifier
{
diff --git a/src/zmq/zmqrpc.cpp b/src/zmq/zmqrpc.cpp
index 948ce2ba..9c8154a6 100644
--- a/src/zmq/zmqrpc.cpp
+++ b/src/zmq/zmqrpc.cpp
@@ -6,13 +6,15 @@
#include <rpc/server.h>
#include <rpc/util.h>
+#include <univalue.h>
#include <zmq/zmqabstractnotifier.h>
#include <zmq/zmqnotificationinterface.h>
-#include <univalue.h>
-
#include <list>
+#include <memory>
#include <string>
+#include <utility>
+#include <vector>
class JSONRPCRequest;
diff --git a/src/zmq/zmqutil.cpp b/src/zmq/zmqutil.cpp
index d3addaad..7f28f5e5 100644
--- a/src/zmq/zmqutil.cpp
+++ b/src/zmq/zmqutil.cpp
@@ -5,6 +5,8 @@
#include <zmq/zmqutil.h>
#include <logging.h>
+#include <util/check.h>
+
#include <zmq.h>
#include <cerrno>
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.