Skip to content

backport: Merge bitcoin/bitcoin#26048, 25976, 26087 #6623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

vijaydasmp
Copy link

BTC Backport

a10df7c build: prune BOOST_CPPFLAGS from libbitcoin_zmq (fanquake)

Pull request description:

  Rather than including `validation.h`, which ultimately means needing boost via `txmempool.h`, include `primitives/block.h` for `CBlock`, and remove `validation.h`, as we can get `cs_main` from `node/blockstorage.h`.

ACKs for top commit:
  theuni:
    Nice. ACK a10df7c.
  hebasto:
    ACK a10df7c, tested on Linux x86_64 using theuni's [patch](theuni@e131d8f) with depends.

Tree-SHA512: 792b6f9e7e7788d10333b4943609efbc798f3b187c324a0f2d5acbb2d44e3c67705dc54d698eb04c23e5af7b8b73a47f8e7974e819eac12f12ae62f28c807476
@vijaydasmp vijaydasmp force-pushed the Apr_2025_02 branch 2 times, most recently from 442c973 to 3fd01e8 Compare April 4, 2025 17:24
MacroFake added 2 commits April 10, 2025 08:17
4296dde Prevent data race for `pathHandlers` (Hennadii Stepanov)

Pull request description:

  Fixes bitcoin#19341.

ACKs for top commit:
  ryanofsky:
    Code review ACK 4296dde. This should protect the vector. It also seems to make the http_request_cb callback single threaded, but that seems ok, since it is just adding work queue items not actually processing requests.

Tree-SHA512: 1c3183100bbc80d8e83543da090b8f4521921cf30d444e3e4c87102bf7a1e67ccc4dfea7e9990ac49741b2a5708f259f4eced9d4049c20ae4e531461532a6aef
…lambdas

1b348d2 [mempool] replace update_descendant_state with lambda (glozow)

Pull request description:

  These were introduced in commit bitcoin@5add7a7, when the codebase was pre-C++11. We can use lambdas now.

ACKs for top commit:
  MarcoFalke:
    review ACK 1b348d2 👮
  w0xlt:
    ACK bitcoin@1b348d2

Tree-SHA512: b664425b395e39ecf1cfc1e731200378261cf58c3985075fdc6027731a5caf995de72ea25be99b4c0dbec2e3ee6cf940e7c577638844619c66c8494ead5da459
@vijaydasmp vijaydasmp changed the title backport: Merge bitcoin/bitcoin#26048, 25990, 25983, 25976, 26087 backport: Merge bitcoin/bitcoin#26048, 25976, 26087 Apr 10, 2025
@vijaydasmp
Copy link
Author

@vijaydasmp vijaydasmp marked this pull request as ready for review April 10, 2025 14:40
Copy link

coderabbitai bot commented Apr 10, 2025

Walkthrough

The changes span several modules. A mutex is introduced in the HTTP server component to synchronize access to the path handler list by guarding the vector with appropriate locking in functions that register, unregister, and process HTTP requests. In the transaction mempool module, two struct definitions for updating descendant and ancestor states are removed and replaced with inline lambda functions that perform the same updates directly. Additionally, modifications in the ZeroMQ modules update include directives: in one file, a header related to validation is replaced by one for block primitives, while in another, a validation header is swapped with a system utilities header. These adjustments focus on thread safety enhancements, code simplification, and dependency updates.


📜 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 bcd14b0 and 068f155.

📒 Files selected for processing (4)
  • src/httpserver.cpp (3 hunks)
  • src/txmempool.cpp (6 hunks)
  • src/zmq/zmqnotificationinterface.cpp (1 hunks)
  • src/zmq/zmqpublishnotifier.cpp (1 hunks)
🔇 Additional comments (13)
src/zmq/zmqpublishnotifier.cpp (1)

12-12: Clean header dependency change from validation.h to util/system.h

This change aligns with the broader refactoring effort in the ZMQ module to reduce dependencies on validation-related components. The switch from validation.h to util/system.h is appropriate as the code only needs system utilities and not validation functionality.

src/zmq/zmqnotificationinterface.cpp (1)

11-11: Appropriate header dependency change from validation.h to primitives/block.h

Similar to the change in zmqpublishnotifier.cpp, this modification correctly shifts from validation.h to a more focused primitives/block.h dependency. This helps reduce unnecessary coupling between components and improves modularity of the codebase.

src/httpserver.cpp (4)

160-161: Thread safety improvement for HTTP path handlers

Added mutex protection for the pathHandlers vector with the GUARDED_BY annotation, ensuring compile-time checking that the mutex is held when accessing this shared resource. This is an important thread safety enhancement to prevent race conditions when handling HTTP requests.


255-255: Added proper synchronization when accessing path handlers

The mutex lock ensures thread-safe access to the pathHandlers vector during HTTP request processing, preventing potential race conditions when iterating through handlers to find a matching path.


687-687: Added synchronization for handler registration

This lock correctly protects the pathHandlers vector during registration of new HTTP handlers, preventing potential race conditions with concurrent access from multiple threads.


693-693: Added synchronization for handler unregistration

This lock ensures thread-safe access to the pathHandlers vector during unregistration of HTTP handlers, completing the synchronization pattern across all access points.

src/txmempool.cpp (7)

135-137: Improved code clarity by replacing struct with lambda function

Replaced usage of the update_ancestor_state struct with an inline lambda function that directly calls UpdateAncestorState, which simplifies the code and makes the intent clearer.


146-146: Replaced struct with lambda for UpdateDescendantState

Simplified code by replacing the update_descendant_state struct with an inline lambda function, making the code more direct and easier to follow.


338-338: Simplified code with lambda for UpdateDescendantState

Replaced the update_descendant_state struct usage with a more concise lambda function, improving code readability and maintainability.


353-353: Used lambda function instead of struct for UpdateAncestorState

Streamlined the code by using a lambda function instead of the update_ancestor_state struct, which makes the implementation more direct.


384-384: Replaced struct with lambda for UpdateAncestorState

Improved code clarity by using a lambda function instead of the update_ancestor_state struct for modifying transaction entries.


1445-1445: Simplified UpdateDescendantState call with lambda

Replaced the update_descendant_state struct with a lambda function in PrioritiseTransaction, maintaining consistent code style throughout the file.


1452-1452: Used lambda for UpdateAncestorState in PrioritiseTransaction

Consistently replaced the update_ancestor_state struct with a lambda function, completing the refactoring pattern throughout the file.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@vijaydasmp
Copy link
Author

Hello @UdjinM6 @knst requesting review

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 068f155

@@ -9,7 +9,7 @@
#include <netbase.h>
#include <node/blockstorage.h>
#include <streams.h>
#include <validation.h>
#include <util/system.h>
Copy link
Collaborator

Choose a reason for hiding this comment

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

seems as unrelated, do you really need util/system.h here or that's copy-paste error?

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.

4 participants