Skip to content

Conversation

@kwvg
Copy link
Collaborator

@kwvg kwvg commented Feb 6, 2025

Additional Information

  • While linting is generally reserved for our arm_linux build variant, utilizing IWYU (which in turns relies on bear for the compilation database, also relied upon by clang-tidy) requires a version paired to the Clang version (source) used to build the target codebase.

    This means it has to be run on a build variant that uses Clang. We have opted to use linux64_multiprocess as it the most lightweight Clang build variant available (compared to fuzz, UBSan and TSan variants which come with sanitizers tacked on).

  • An earlier version of this PR (source) attempted to apply IWYU to Dash-specific code. This attempt was aborted because IWYU was found to behave non-deterministically.

    Furthermore, while IWYU will tell you what headers to use, it will not do the following:

    • Respect the usage of angle brackets for source headers (it will almost always suggest quotation marks)
    • Use C++-style headers (it will prefer string.h over cstring and changing it is a manual errand)
    • Apply its suggestions in alphabetical order (they will pool up at the bottom)
    • Respect newlines meant to separate sets of headers
    • Remain consistent (even if IWYU passes locally, there is no guarantee that it would translate to a green CI run)

    But it will do the following:

    • Change its suggestions based on the ordering of headers
    • Make suggestions to add headers/forward declarations and then when run a second time, urge you to remove them
    • Pull in implementation headers that shouldn't be directly included. IWYU currently ships with mappings to avoid this for the standard library (source), Qt (source) and Boost (source) but for all else, you're on your own.

    It was determined for now that we will simply take guidance from upstream on the matter and extend it to Dash code at some point in the future.

  • Both bitcoin#25029 and bitcoin#25013 made sure they pass IWYU, changes needed to ensure that the linter is satisfied were made in this PR.

Breaking Changes

None expected.

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas (note: N/A)
  • I have added or updated relevant unit/integration/functional/e2e tests (note: N/A)
  • I have made corresponding changes to the documentation (note: N/A)
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

@kwvg kwvg added this to the 23 milestone Feb 6, 2025
@kwvg kwvg force-pushed the enable_iwyu branch 2 times, most recently from 48eff4e to 02613a5 Compare February 6, 2025 10:39
@kwvg kwvg changed the title backport: merge bitcoin#22903, #24753, #24831 (use clang-tidy in CI, IWYU for src/{bls,coinjoin,compat,evo,governance,init,stats}) backport: merge bitcoin#22903, #24753, #24831, #28240 (use clang-tidy in CI, IWYU for src/{bls,coinjoin,compat,evo,governance,init,stats}) Feb 6, 2025
@github-actions
Copy link

github-actions bot commented Feb 6, 2025

This pull request has conflicts, please rebase.

@kwvg kwvg changed the title backport: merge bitcoin#22903, #24753, #24831, #28240 (use clang-tidy in CI, IWYU for src/{bls,coinjoin,compat,evo,governance,init,stats}) backport: merge bitcoin#22903, #24753, #24831, #28240, #27012, #25713, #24971, #25047 (clang-tidy and IWYU) Feb 10, 2025
@kwvg kwvg marked this pull request as ready for review February 10, 2025 12:48
@coderabbitai
Copy link

coderabbitai bot commented Feb 10, 2025

Walkthrough

This pull request consolidates updates across the codebase that include changes to CI and Docker scripts, build configurations, and source code modernizations. The CI scripts now support an additional environment variable to enable code quality checks. Build scripts and Dockerfiles have been modified to install and configure tools such as Bear, LLVM, Clang-Tidy, and Include-What-You-Use. Multiple source files are updated to use modern C++ practices, including replacing NULL or 0 with nullptr and switching from C-style headers (e.g., <stdint.h>) to their C++ counterparts (). There are also several minor changes in parameter names, comments, and header inclusion formats in various modules such as networking, wallet operations, and RPC commands. Additionally, some outdated constants and external declarations have been removed or updated. Overall, these changes adjust the build and coding practices without altering the core functionality of the system.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c7cb1d98d4aac64b329e8c00f0396f85fb88ec44 and 4009777.

📒 Files selected for processing (37)
  • ci/dash/build_src.sh (2 hunks)
  • ci/test/00_setup_env.sh (1 hunks)
  • ci/test/00_setup_env_native_multiprocess.sh (1 hunks)
  • configure.ac (1 hunks)
  • contrib/containers/ci/Dockerfile (3 hunks)
  • contrib/devtools/iwyu/bitcoin.core.imp (1 hunks)
  • src/.bear-tidy-config (1 hunks)
  • src/.clang-tidy (1 hunks)
  • src/bench/coin_selection.cpp (1 hunks)
  • src/compat/byteswap.h (1 hunks)
  • src/compat/compat.h (1 hunks)
  • src/compat/cpuid.h (1 hunks)
  • src/compat/endian.h (1 hunks)
  • src/compat/stdin.cpp (1 hunks)
  • src/governance/governance.cpp (1 hunks)
  • src/init/common.cpp (1 hunks)
  • src/llmq/signing_shares.cpp (1 hunks)
  • src/mapport.cpp (2 hunks)
  • src/masternode/sync.cpp (1 hunks)
  • src/net.cpp (3 hunks)
  • src/net_processing.cpp (1 hunks)
  • src/netaddress.cpp (0 hunks)
  • src/netbase.cpp (1 hunks)
  • src/qt/bitcoin.cpp (9 hunks)
  • src/qt/intro.cpp (1 hunks)
  • src/randomenv.cpp (1 hunks)
  • src/rpc/fees.cpp (1 hunks)
  • src/rpc/misc.cpp (1 hunks)
  • src/rpc/quorums.cpp (0 hunks)
  • src/rpc/signmessage.cpp (1 hunks)
  • src/support/allocators/secure.h (1 hunks)
  • src/test/fuzz/crypto_diff_fuzz_chacha20.cpp (1 hunks)
  • src/torcontrol.cpp (3 hunks)
  • src/torcontrol.h (1 hunks)
  • src/validation.cpp (1 hunks)
  • src/wallet/test/psbt_wallet_tests.cpp (0 hunks)
  • src/wallet/wallet.cpp (1 hunks)
💤 Files with no reviewable changes (3)
  • src/netaddress.cpp
  • src/wallet/test/psbt_wallet_tests.cpp
  • src/rpc/quorums.cpp
🚧 Files skipped from review as they are similar to previous changes (34)
  • src/compat/cpuid.h
  • ci/test/00_setup_env.sh
  • src/.clang-tidy
  • src/compat/byteswap.h
  • src/test/fuzz/crypto_diff_fuzz_chacha20.cpp
  • src/bench/coin_selection.cpp
  • src/qt/bitcoin.cpp
  • src/randomenv.cpp
  • ci/dash/build_src.sh
  • src/governance/governance.cpp
  • contrib/devtools/iwyu/bitcoin.core.imp
  • src/rpc/signmessage.cpp
  • src/compat/stdin.cpp
  • src/qt/intro.cpp
  • src/masternode/sync.cpp
  • src/compat/endian.h
  • src/rpc/fees.cpp
  • src/torcontrol.h
  • src/rpc/misc.cpp
  • contrib/containers/ci/Dockerfile
  • src/.bear-tidy-config
  • configure.ac
  • src/init/common.cpp
  • src/mapport.cpp
  • src/torcontrol.cpp
  • src/netbase.cpp
  • src/compat/compat.h
  • ci/test/00_setup_env_native_multiprocess.sh
  • src/support/allocators/secure.h
  • src/wallet/wallet.cpp
  • src/net_processing.cpp
  • src/validation.cpp
  • src/llmq/signing_shares.cpp
  • src/net.cpp
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build container / Build container

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
ci/dash/build_src.sh (1)

68-84: Consider improving error handling in the clang-tidy section.

While the script uses set -eo pipefail for proper error handling, the clang-tidy output filtering could be improved.

Consider this alternative that captures all errors, not just those with 5 lines of context:

-  ( run-clang-tidy -quiet "${MAKEJOBS}" ) | grep -C5 "error"
+  output=$(run-clang-tidy -quiet "${MAKEJOBS}")
+  if echo "$output" | grep -q "error:"; then
+    echo "$output" | grep -C5 "error:"
+    exit 1
+  fi
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e8e6b92 and 0b42caa2e84636e9a2901b485ea87627014a013b.

📒 Files selected for processing (39)
  • ci/dash/build_src.sh (2 hunks)
  • ci/test/00_setup_env.sh (1 hunks)
  • ci/test/00_setup_env_native_multiprocess.sh (1 hunks)
  • configure.ac (1 hunks)
  • contrib/containers/ci/Dockerfile (3 hunks)
  • contrib/devtools/iwyu/bitcoin.core.imp (1 hunks)
  • src/.bear-tidy-config (1 hunks)
  • src/.clang-tidy (1 hunks)
  • src/bench/coin_selection.cpp (1 hunks)
  • src/compat/byteswap.h (1 hunks)
  • src/compat/compat.h (1 hunks)
  • src/compat/cpuid.h (1 hunks)
  • src/compat/endian.h (1 hunks)
  • src/compat/stdin.cpp (1 hunks)
  • src/governance/governance.cpp (1 hunks)
  • src/init/bitcoin-node.cpp (1 hunks)
  • src/init/common.cpp (1 hunks)
  • src/llmq/signing_shares.cpp (1 hunks)
  • src/mapport.cpp (2 hunks)
  • src/masternode/sync.cpp (1 hunks)
  • src/net.cpp (3 hunks)
  • src/net_processing.cpp (1 hunks)
  • src/netaddress.cpp (0 hunks)
  • src/netbase.cpp (1 hunks)
  • src/qt/bitcoin.cpp (9 hunks)
  • src/qt/intro.cpp (1 hunks)
  • src/randomenv.cpp (1 hunks)
  • src/rpc/fees.cpp (1 hunks)
  • src/rpc/misc.cpp (1 hunks)
  • src/rpc/quorums.cpp (0 hunks)
  • src/rpc/signmessage.cpp (1 hunks)
  • src/support/allocators/secure.h (1 hunks)
  • src/test/fuzz/crypto_diff_fuzz_chacha20.cpp (1 hunks)
  • src/torcontrol.cpp (3 hunks)
  • src/torcontrol.h (1 hunks)
  • src/validation.cpp (1 hunks)
  • src/wallet/test/coinselector_tests.cpp (3 hunks)
  • src/wallet/test/psbt_wallet_tests.cpp (0 hunks)
  • src/wallet/wallet.cpp (1 hunks)
💤 Files with no reviewable changes (3)
  • src/netaddress.cpp
  • src/rpc/quorums.cpp
  • src/wallet/test/psbt_wallet_tests.cpp
✅ Files skipped from review due to trivial changes (21)
  • src/compat/endian.h
  • src/.bear-tidy-config
  • src/init/bitcoin-node.cpp
  • src/masternode/sync.cpp
  • src/compat/byteswap.h
  • src/rpc/signmessage.cpp
  • src/compat/cpuid.h
  • src/.clang-tidy
  • src/compat/stdin.cpp
  • src/bench/coin_selection.cpp
  • src/randomenv.cpp
  • src/rpc/fees.cpp
  • src/test/fuzz/crypto_diff_fuzz_chacha20.cpp
  • src/llmq/signing_shares.cpp
  • src/wallet/wallet.cpp
  • configure.ac
  • src/rpc/misc.cpp
  • src/net.cpp
  • src/compat/compat.h
  • src/wallet/test/coinselector_tests.cpp
  • src/validation.cpp
🧰 Additional context used
🪛 GitHub Actions: Check Potential Conflicts
src/governance/governance.cpp

[error] 1-1: File has conflicts with multiple pull requests.

src/net_processing.cpp

[error] 1-1: File has conflicts with multiple pull requests.

🔇 Additional comments (22)
src/net_processing.cpp (3)

4766-4766: LGTM! Parameter name change improves clarity

The parameter name change from punish_duplicate_invalid to via_compact_block better reflects the parameter's purpose and aligns with BIP 152's specification for compact block validation rules.


713-713: LGTM! Consistent parameter naming

The function signature parameter name change matches the call site change, maintaining consistency throughout the codebase.


1-6364: Please resolve conflicts with other PRs

The pipeline indicates this file has conflicts with multiple pull requests. Please rebase your changes on the latest master and resolve any conflicts to ensure clean integration.

🧰 Tools
🪛 Cppcheck (2.10-2)

[error] 2760-2760: syntax error

(syntaxError)

🪛 GitHub Actions: Check Potential Conflicts

[error] 1-1: File has conflicts with multiple pull requests.

contrib/devtools/iwyu/bitcoin.core.imp (1)

1-6: LGTM! Well-structured IWYU mappings for termios headers.

The configuration correctly maps implementation-specific headers to their public interface, ensuring proper encapsulation of system-specific details.

src/support/allocators/secure.h (1)

41-41: LGTM! Good modernization of null pointer syntax.

Using nullptr instead of 0 improves type safety and readability, aligning with modern C++ practices.

src/torcontrol.h (2)

16-20: LGTM! Good header organization.

The header includes are well-organized, with system headers grouped separately from project headers.


14-14: Verify the migration from Boost.Signals2 to libevent.

The removal of Boost.Signals2 in favor of libevent represents a significant architectural change. Let's verify that all asynchronous operations have been properly migrated.

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Search for any remaining Boost.Signals2 usage
rg "boost::signals2" -A 5

# Search for new event handling patterns
rg "event_base" -A 5

Length of output: 21538


Asynchronous Migration Verified in TorControl Module

  • In src/torcontrol.h and accompanying implementation files, asynchronous operations are now managed by libevent (e.g., using event_base_new, event_base_dispatch, and event_base_free), with the libevent header <event2/util.h> included.
  • No references to Boost.Signals2 appear in the torcontrol component, confirming that network-related asynchronous tasks have been fully migrated.
  • The remaining Boost.Signals2 usages in the repository (e.g., in UI signaling and callbacks) serve different roles and are not related to the asynchronous operations for Tor control.
src/init/common.cpp (1)

12-25: LGTM! Improved header organization.

The header includes have been updated to better reflect actual usage, following IWYU recommendations:

  • Added necessary headers for filesystem, formatting, and container operations
  • Removed unused memory header
  • Properly organized system vs. project headers
src/mapport.cpp (1)

198-198: LGTM! Improved type safety by using nullptr.

The changes replace integer literal 0 with nullptr in UPnP function calls, which is a better practice in modern C++ as it:

  • Makes the pointer nature of the parameter more explicit
  • Prevents accidental implicit conversions
  • Improves code readability

Also applies to: 211-211

src/qt/intro.cpp (1)

232-232: LGTM! Improved Qt widget initialization.

The change from 0 to nullptr for the parent widget parameter follows Qt best practices by:

  • Making it explicit that the widget has no parent
  • Aligning with Qt's modern coding style
  • Improving type safety in widget hierarchy management
src/netbase.cpp (1)

661-661: LGTM! Improved proxy authentication parameter handling.

The change from 0 to nullptr for the auth parameter in Socks5 function:

  • Better represents the absence of proxy credentials
  • Matches the ProxyCredentials* parameter type
  • Enhances code clarity and type safety
src/torcontrol.cpp (2)

15-35: LGTM! Enhanced header organization.

Added necessary headers to support:

  • Random number generation (random.h)
  • String formatting (tinyformat.h)
  • Error checking (util/check.h)
  • String utilities (util/string.h)
  • Standard library components

317-317: LGTM! Improved event pointer initialization.

Changed reconnect_ev initialization from 0 to nullptr:

  • Better represents the uninitialized event pointer
  • Follows modern C++ practices
  • Improves type safety
src/qt/bitcoin.cpp (1)

535-535: LGTM! Improved code safety by using nullptr instead of 0.

The changes consistently replace the use of 0 with nullptr for parent window pointers in QMessageBox constructor calls. This is a good practice in modern C++ as it makes the code's intent clearer and provides better type safety.

Also applies to: 633-633, 646-646, 656-656, 666-666, 677-677, 691-691, 711-711

src/governance/governance.cpp (1)

1548-1548: LGTM! Improved comment clarity.

The comment update from /* filter = */ to /* cond = */ better reflects the parameter's purpose in the NodesSnapshot constructor. This change maintains consistency with similar updates across the codebase.

ci/test/00_setup_env_native_multiprocess.sh (1)

12-12: LGTM! Enabled code quality checks.

Setting RUN_TIDY=true enables additional code quality checks using clang-tidy and include-what-you-use tools.

ci/dash/build_src.sh (1)

54-58: LGTM! Well-structured integration of the bear tool.

The conditional block properly sets up the bear tool configuration when RUN_TIDY is enabled.

ci/test/00_setup_env.sh (1)

41-41: Add default RUN_TIDY environment variable.
Introducing RUN_TIDY=${RUN_TIDY:-false} provides a clear, fallback value for controlling tidy checks in CI. This aligns well with the PR’s objectives of enabling conditional static analysis.

contrib/containers/ci/Dockerfile (4)

24-24: Include the 'bear' static analysis tool.
Adding the bear package (line 24) enhances the build environment by enabling command tracing during compilation. This is useful for integrating further analysis (e.g., with clang-tidy and IWYU).


69-72: Enhance Clang/LLVM development package installation.
The additions of "libclang-${LLVM_VERSION}-dev" (line 69), "lld-${LLVM_VERSION}" (line 71), and "llvm-${LLVM_VERSION}-dev" (line 72) ensure that the necessary development files for Clang and LLVM are installed. This modification supports the static analysis tools and is consistent with aligning with upstream practices.


75-82: Update alternatives to include extended Clang tools.
The updated alternative setup (starting at line 75 with the assignment and extended in line 76) now incorporates binaries like clang-apply-replacements and run-clang-tidy. This ensures that calls to these tools point to the version corresponding to ${LLVM_VERSION}. The approach is sound; just verify that all paths resolve correctly in your CI environment.


138-145: Automate installation of include-what-you-use (IWYU).
The new block (lines 138–145) clones and builds IWYU from the branch clang_${LLVM_VERSION}. This integration helps maintain consistency with upstream static analysis practices. Consider verifying that the built tool meets the version expectations and that cleanup of /opt/iwyu is effective to avoid residual files.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improved error handling in message code parsing.

Changed from LocaleIndependentAtoi to ToIntegral with value_or(0) which:

  • Provides better error handling for invalid inputs
  • Returns a default value of 0 if parsing fails
  • Uses modern C++ optional type

Comment on lines +16 to +18
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify the security implications of disabling hardening.

The changes disable hardening and set optimization levels to zero. While this might be necessary for the tidy checks, please confirm that:

  1. This is only used in development/CI environments
  2. The security impact of disabling hardening has been assessed

🏁 Script executed:

#!/bin/bash
# Check if these flags are only used in development/CI environments
git grep -l "disable-hardening" -- ":(exclude)ci/*"

Length of output: 82


Security Alert: Hardening Flags Not Isolated to CI Environments

The shell script result shows that the --disable-hardening flag is also referenced in configure.ac and doc/build-unix.md, meaning it isn’t exclusive to the CI/development environment. This raises two concerns:

  • Scope of Usage: The flag appears outside the confines of CI scripts. Please ensure that production and release builds do not inadvertently inherit these disabled hardening settings.
  • Security Assessment: Confirm that the use of --disable-hardening (and the zero optimization flags) in non-CI contexts is intentional and that any production build configurations indeed enforce proper security hardening.

It’s advisable to review the build configuration (especially in configure.ac) and related documentation (doc/build-unix.md) to determine under what conditions these flags are applied. If they are meant solely for development/CI routines, consider isolating them to avoid risks in production builds.

@github-actions
Copy link

This pull request has conflicts, please rebase.

@github-actions
Copy link

This pull request has conflicts, please rebase.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
ci/dash/build_src.sh (1)

54-58: Verify Bear config file existence.

Consider adding a check for the Bear config file existence before proceeding:

 if [ "${RUN_TIDY}" = "true" ]; then
+  if [ ! -f "src/.bear-tidy-config" ]; then
+    echo "Error: Bear config file not found at src/.bear-tidy-config"
+    exit 1
+  fi
   MAYBE_BEAR="bear --config src/.bear-tidy-config"
   MAYBE_TOKEN="--"
 fi
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0eefc5618b6e33c11b48197c96af2009fcf1ab1c and c7cb1d98d4aac64b329e8c00f0396f85fb88ec44.

📒 Files selected for processing (37)
  • ci/dash/build_src.sh (2 hunks)
  • ci/test/00_setup_env.sh (1 hunks)
  • ci/test/00_setup_env_native_multiprocess.sh (1 hunks)
  • configure.ac (1 hunks)
  • contrib/containers/ci/Dockerfile (3 hunks)
  • contrib/devtools/iwyu/bitcoin.core.imp (1 hunks)
  • src/.bear-tidy-config (1 hunks)
  • src/.clang-tidy (1 hunks)
  • src/bench/coin_selection.cpp (1 hunks)
  • src/compat/byteswap.h (1 hunks)
  • src/compat/compat.h (1 hunks)
  • src/compat/cpuid.h (1 hunks)
  • src/compat/endian.h (1 hunks)
  • src/compat/stdin.cpp (1 hunks)
  • src/governance/governance.cpp (1 hunks)
  • src/init/common.cpp (1 hunks)
  • src/llmq/signing_shares.cpp (1 hunks)
  • src/mapport.cpp (2 hunks)
  • src/masternode/sync.cpp (1 hunks)
  • src/net.cpp (3 hunks)
  • src/net_processing.cpp (1 hunks)
  • src/netaddress.cpp (0 hunks)
  • src/netbase.cpp (1 hunks)
  • src/qt/bitcoin.cpp (9 hunks)
  • src/qt/intro.cpp (1 hunks)
  • src/randomenv.cpp (1 hunks)
  • src/rpc/fees.cpp (1 hunks)
  • src/rpc/misc.cpp (1 hunks)
  • src/rpc/quorums.cpp (0 hunks)
  • src/rpc/signmessage.cpp (1 hunks)
  • src/support/allocators/secure.h (1 hunks)
  • src/test/fuzz/crypto_diff_fuzz_chacha20.cpp (1 hunks)
  • src/torcontrol.cpp (3 hunks)
  • src/torcontrol.h (1 hunks)
  • src/validation.cpp (1 hunks)
  • src/wallet/test/psbt_wallet_tests.cpp (0 hunks)
  • src/wallet/wallet.cpp (1 hunks)
💤 Files with no reviewable changes (3)
  • src/netaddress.cpp
  • src/wallet/test/psbt_wallet_tests.cpp
  • src/rpc/quorums.cpp
🚧 Files skipped from review as they are similar to previous changes (33)
  • src/bench/coin_selection.cpp
  • src/.clang-tidy
  • src/masternode/sync.cpp
  • src/test/fuzz/crypto_diff_fuzz_chacha20.cpp
  • src/rpc/fees.cpp
  • src/rpc/signmessage.cpp
  • src/compat/endian.h
  • contrib/devtools/iwyu/bitcoin.core.imp
  • src/compat/byteswap.h
  • src/.bear-tidy-config
  • ci/test/00_setup_env.sh
  • src/randomenv.cpp
  • src/init/common.cpp
  • src/compat/stdin.cpp
  • src/compat/cpuid.h
  • src/qt/intro.cpp
  • contrib/containers/ci/Dockerfile
  • src/support/allocators/secure.h
  • ci/test/00_setup_env_native_multiprocess.sh
  • src/netbase.cpp
  • src/torcontrol.h
  • src/qt/bitcoin.cpp
  • src/mapport.cpp
  • src/llmq/signing_shares.cpp
  • src/torcontrol.cpp
  • src/compat/compat.h
  • src/rpc/misc.cpp
  • src/validation.cpp
  • src/net_processing.cpp
  • src/wallet/wallet.cpp
  • src/governance/governance.cpp
  • configure.ac
  • src/net.cpp
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build container / Build container
🔇 Additional comments (1)
ci/dash/build_src.sh (1)

59-59: LGTM! Clean integration of Bear with make.

The modification elegantly integrates Bear while maintaining the existing error handling and verbose build fallback.

Comment on lines +68 to +84
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance robustness of code quality checks.

Several improvements could make the code quality checks more robust:

  1. Capture all clang-tidy output, not just errors
  2. Use a more secure location for temporary files
  3. Clean up temporary files
  4. Consider committing IWYU changes
 if [ "${RUN_TIDY}" = "true" ]; then
   set -eo pipefail
   cd src
-  ( run-clang-tidy -quiet "${MAKEJOBS}" ) | grep -C5 "error"
+  TIDY_OUTPUT="$(mktemp -t dash_tidy.XXXXXX)"
+  ( run-clang-tidy -quiet "${MAKEJOBS}" ) | tee "${TIDY_OUTPUT}"
+  if grep -q "error:" "${TIDY_OUTPUT}"; then
+    echo "Found clang-tidy errors:"
+    grep -C5 "error:" "${TIDY_OUTPUT}"
+    rm "${TIDY_OUTPUT}"
+    exit 1
+  fi
+  rm "${TIDY_OUTPUT}"
   cd ..
+  IWYU_OUTPUT="$(mktemp -t dash_iwyu.XXXXXX)"
   iwyu_tool.py \
     "src/compat" \
     "src/init" \
     "src/rpc/fees.cpp" \
     "src/rpc/signmessage.cpp" \
     -p . "${MAKEJOBS}" \
     -- -Xiwyu --cxx17ns -Xiwyu --mapping_file="${BASE_ROOT_DIR}/contrib/devtools/iwyu/bitcoin.core.imp" \
-    |& tee "/tmp/iwyu_ci.out"
+    |& tee "${IWYU_OUTPUT}"
   cd src
-  fix_includes.py --nosafe_headers < /tmp/iwyu_ci.out
+  fix_includes.py --nosafe_headers < "${IWYU_OUTPUT}"
   git --no-pager diff
+  rm "${IWYU_OUTPUT}"
+  # Optionally commit IWYU changes:
+  # if ! git diff --quiet; then
+  #   git add -u
+  #   git commit -m "style: apply IWYU fixes"
+  # fi
 fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ "${RUN_TIDY}" = "true" ]; then
set -eo pipefail
cd src
( run-clang-tidy -quiet "${MAKEJOBS}" ) | grep -C5 "error"
cd ..
iwyu_tool.py \
"src/compat" \
"src/init" \
"src/rpc/fees.cpp" \
"src/rpc/signmessage.cpp" \
-p . "${MAKEJOBS}" \
-- -Xiwyu --cxx17ns -Xiwyu --mapping_file="${BASE_ROOT_DIR}/contrib/devtools/iwyu/bitcoin.core.imp" \
|& tee "/tmp/iwyu_ci.out"
cd src
fix_includes.py --nosafe_headers < /tmp/iwyu_ci.out
git --no-pager diff
fi
if [ "${RUN_TIDY}" = "true" ]; then
set -eo pipefail
cd src
TIDY_OUTPUT="$(mktemp -t dash_tidy.XXXXXX)"
( run-clang-tidy -quiet "${MAKEJOBS}" ) | tee "${TIDY_OUTPUT}"
if grep -q "error:" "${TIDY_OUTPUT}"; then
echo "Found clang-tidy errors:"
grep -C5 "error:" "${TIDY_OUTPUT}"
rm "${TIDY_OUTPUT}"
exit 1
fi
rm "${TIDY_OUTPUT}"
cd ..
IWYU_OUTPUT="$(mktemp -t dash_iwyu.XXXXXX)"
iwyu_tool.py \
"src/compat" \
"src/init" \
"src/rpc/fees.cpp" \
"src/rpc/signmessage.cpp" \
-p . "${MAKEJOBS}" \
-- -Xiwyu --cxx17ns -Xiwyu --mapping_file="${BASE_ROOT_DIR}/contrib/devtools/iwyu/bitcoin.core.imp" \
|& tee "${IWYU_OUTPUT}"
cd src
fix_includes.py --nosafe_headers < "${IWYU_OUTPUT}"
git --no-pager diff
rm "${IWYU_OUTPUT}"
# Optionally commit IWYU changes:
# if ! git diff --quiet; then
# git add -u
# git commit -m "style: apply IWYU fixes"
# fi
fi

@github-actions
Copy link

This pull request has conflicts, please rebase.

Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 4009777

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 4009777

@PastaPastaPasta PastaPastaPasta merged commit bb46968 into dashpay:develop Feb 17, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants