Skip to content

Conversation

@vijaydasmp
Copy link

bitcoin backports

@vijaydasmp vijaydasmp changed the title backport: Merge bitcoin/bitcoin#28218: backport: Merge bitcoin/bitcoin#28218 Dec 21, 2025
@github-actions
Copy link

github-actions bot commented Dec 21, 2025

✅ No Merge Conflicts Detected

This PR currently has no conflicts with other open PRs.

@vijaydasmp vijaydasmp changed the title backport: Merge bitcoin/bitcoin#28218 backport: Merge bitcoin#28218 Dec 21, 2025
@vijaydasmp vijaydasmp force-pushed the Jan_2026_4 branch 3 times, most recently from a726057 to aaed508 Compare December 25, 2025 02:39
@vijaydasmp vijaydasmp changed the title backport: Merge bitcoin#28218 backport: Merge bitcoin#26898, 25504, 25934, 26186 Dec 25, 2025
@vijaydasmp vijaydasmp force-pushed the Jan_2026_4 branch 3 times, most recently from 5926337 to 8e199c9 Compare December 26, 2025 09:47
@vijaydasmp vijaydasmp force-pushed the Jan_2026_4 branch 4 times, most recently from 7392062 to 18e5026 Compare January 7, 2026 00:00
9f265d8 fuzz: Detect deadlocks in process_message (dergoegge)
fae1e7e fuzz: p2p: Detect peer deadlocks (MarcoFalke)

Pull request description:

  It may be possible that a peer connection will deadlock, due to software bugs such as bitcoin#18808.

  Fix this by detecting them in the fuzz target.

  Can be tested by introducing a bug such as:

  ```diff
  diff --git a/src/net_processing.cpp b/src/net_processing.cpp
  index 1067341..97495a13df 100644
  --- a/src/net_processing.cpp
  +++ b/src/net_processing.cpp
  @@ -2436,3 +2436,3 @@ void PeerManagerImpl::ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic
       if (it != peer.m_getdata_requests.end() && !pfrom.fPauseSend) {
  -        const CInv &inv = *it++;
  +        const CInv& inv = *it;
           if (inv.IsGenBlkMsg()) {
  ```

  Using a fuzz input such as:

  ```
  $ base64 ./timeout-ada0fecaba2b8c46c6e970cf637d9625b01bf7e5
  kNptdNbW1tbWYghvXIpwb25vPQAA////////cwAjLv8AXAB2ZXJhY2sAQW5v/62tra3Pz///////
  //////////////////////9c8GZpbHRlcmxvYWQAAAEAAwAAAABVYwC2XABmaWx0ZXJhZGQAAAAX
  Fxdn/////2V0F861tcqvEmAAACEAAABjYXB0dXJldmUAAH4AgAA1PNfX11x0Z2V0ZGF0YQBDACOw
  AQMAAAAGIm5GERoLWcqvEmBD61u/KMNPOl4zKh/HKLK3PPGIkQ9eE/////////8AAAAAAAAAAFtb
  WyjDTzpeMSofx7K3PNfX11x0Z2V0ZGF0YQBDACMwAQMAAAAGIm5GERoLWcqvEmBD61u/KMNPOl4z
  Kh/Hsrc88YiRD2/Nzc3Nzc3Nzc3NTc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3N
  zWWj1NTUudTU1NTU1P///0j+P/9cdHR4AAAAAAAAy/4AAHR4AAAAAAAAP8v+AAD/+P//////////
  AX55bJl8HWnz/////wAgXGF0YVPxY2RkAAAA
  ```

  And running the fuzz target:

  ```
  $ FUZZ=process_messages ./src/test/fuzz/fuzz -runs=1 -timeout=18 ./timeout-ada0fecaba2b8c46c6e970cf637d9625b01bf7e5
  INFO: Running with entropic power schedule (0xFF, 100).
  INFO: Seed: 3436516708
  INFO: Loaded 1 modules   (390807 inline 8-bit counters): 390807 [0x55d0d6221e80, 0x55d0d6281517),
  INFO: Loaded 1 PC tables (390807 PCs): 390807 [0x55d0d6281518,0x55d0d6877e88),
  ./src/test/fuzz/fuzz: Running 1 inputs 1 time(s) each.
  Running: ./timeout-ada0fecaba2b8c46c6e970cf637d9625b01bf7e5
  ALARM: working on the last Unit for 19 seconds
         and the timeout value is 18 (use -timeout=N to change)
  ==375014== ERROR: libFuzzer: timeout after 19 seconds
  ```

ACKs for top commit:
  naumenkogs:
    ACK 9f265d8
  dergoegge:
    ACK 9f265d8
  brunoerg:
    ACK 9f265d8

Tree-SHA512: da83ff90962bb679aae00e8e9dba639c180b7aaba544e0c4d0978d36e28a9ff1cd7a2e13009d8ab407ef57767656aca1ebc767a7d2f1bc880284f8f57c197a50
…SAGE_LENGTH

fa769d3 fuzz: Limit p2p fuzz targets to MAX_PROTOCOL_MESSAGE_LENGTH (MarcoFalke)

Pull request description:

  Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65039

ACKs for top commit:
  dergoegge:
    utACK fa769d3
  brunoerg:
    crACK fa769d3

Tree-SHA512: 46f70d1acf4e2f95055c70162909010c6322f8504a810906e1ab4db470dc2525f9a494b8427b254279bc68b1c8b87338c943787fd5249df7113556740701a51a
@vijaydasmp vijaydasmp changed the title backport: Merge bitcoin#26898, 25504, 25934, 26186 backport: Merge bitcoin#29009 Jan 10, 2026
@vijaydasmp vijaydasmp changed the title backport: Merge bitcoin#29009 backport: Merge bitcoin#29009, 29079 Jan 10, 2026
@vijaydasmp vijaydasmp marked this pull request as ready for review January 14, 2026 17:01
@coderabbitai
Copy link

coderabbitai bot commented Jan 14, 2026

Walkthrough

This pull request refactors the fuzzing and test infrastructure for message processing. The primary change involves modifying ProcessMessagesOnce in the test utilities to return a boolean value indicating whether additional message processing is needed. The fuzz tests (process_message.cpp and process_messages.cpp) are updated to use this return value to drive a loop that continues processing until no further work remains. The message handling flow is restructured to use CSerializedNetMsg, ReceiveMsgFrom, and a processing loop with error handling, replacing the previous direct ProcessMessage invocation approach.

Sequence Diagram

sequenceDiagram
    participant FuzzTest as Fuzz Test
    participant ConnMan as ConnMan
    participant PeerMan as PeerMan
    participant MsgProc as Message Processor

    FuzzTest->>ConnMan: ReceiveMsgFrom(net_msg)
    activate ConnMan
    ConnMan->>ConnMan: Store message in queue
    deactivate ConnMan
    
    loop Process until no more work
        FuzzTest->>ConnMan: ProcessMessagesOnce(node)
        activate ConnMan
        ConnMan->>MsgProc: ProcessMessages(node)
        activate MsgProc
        MsgProc-->>ConnMan: bool (more work needed?)
        deactivate MsgProc
        ConnMan-->>FuzzTest: return bool
        deactivate ConnMan
        
        alt More messages to process
            FuzzTest->>PeerMan: SendMessages()
            activate PeerMan
            PeerMan->>PeerMan: Flush pending sends
            deactivate PeerMan
        else No more messages
            Note over FuzzTest: Exit loop
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title accurately describes the main change: backporting two specific Bitcoin commits (29009 and 29079).
Description check ✅ Passed The description is very brief but clearly related to the changeset, indicating it contains Bitcoin backports as confirmed by the objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings


📜 Recent review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7482956 and 34a9eeb.

📒 Files selected for processing (3)
  • src/test/fuzz/process_message.cpp
  • src/test/fuzz/process_messages.cpp
  • src/test/util/net.h
🧰 Additional context used
📓 Path-based instructions (2)
src/**/*.{cpp,h,hpp,cc}

📄 CodeRabbit inference engine (CLAUDE.md)

Dash Core implementation must be written in C++20, requiring at least Clang 16 or GCC 11.1

Files:

  • src/test/util/net.h
  • src/test/fuzz/process_message.cpp
  • src/test/fuzz/process_messages.cpp
src/{test,wallet/test}/**/*.{cpp,h}

📄 CodeRabbit inference engine (CLAUDE.md)

Unit tests in src/test/ and src/wallet/test/ must use Boost::Test framework

Files:

  • src/test/util/net.h
  • src/test/fuzz/process_message.cpp
  • src/test/fuzz/process_messages.cpp
🧠 Learnings (4)
📓 Common learnings
Learnt from: knst
Repo: dashpay/dash PR: 6916
File: src/univalue/include/univalue.h:81-88
Timestamp: 2025-10-25T07:08:51.918Z
Learning: For backport PRs from bitcoin/bitcoin, bitcoin-core/gui, etc., backported changes should match the original upstream PRs even if they appear strange, modify vendored code, or seem to violate coding guidelines. Still flag genuine issues like bugs, undefined behavior, crashes, compilation errors, or linter failures.
Learnt from: knst
Repo: dashpay/dash PR: 6871
File: contrib/guix/libexec/build.sh:358-360
Timestamp: 2025-10-05T20:38:28.457Z
Learning: In the Dash repository, when backporting code from Bitcoin Core, typos and minor issues in comments should be kept as-is to reduce merge conflicts in future backports, even if they remain unfixed in Bitcoin Core's master branch.
Learnt from: kwvg
Repo: dashpay/dash PR: 6543
File: src/wallet/receive.cpp:240-251
Timestamp: 2025-02-06T14:34:30.466Z
Learning: Pull request `#6543` is focused on move-only changes and refactoring, specifically backporting from Bitcoin. Behavior changes should be proposed in separate PRs.
Learnt from: knst
Repo: dashpay/dash PR: 6883
File: src/rpc/rawtransaction.cpp:1088-1125
Timestamp: 2025-10-13T12:37:12.357Z
Learning: In backport pull requests (especially from Bitcoin Core), treat "moved" or refactored code as out-of-scope for content-level review. Focus validation on verifying that code is moved correctly: no fields added, no fields removed, no fields reordered, and no unexpected changes beyond whitespace adjustments. Pre-existing issues in the upstream code should be preserved to maintain fidelity to the original implementation.
Learnt from: PastaPastaPasta
Repo: dashpay/dash PR: 6804
File: src/qt/proposalwizard.cpp:40-42
Timestamp: 2025-08-11T17:16:36.654Z
Learning: In the Dash repository, when a PR adds new files that are not from Bitcoin backports, these files must be added to the list in test/util/data/non-backported.txt. This applies to newly created files like qt/proposalwizard.{h,cpp} and forms/proposalwizard.ui. Limited exemptions may exist for subtrees and similar cases.
Learnt from: UdjinM6
Repo: dashpay/dash PR: 6786
File: ci/test/04_install.sh:99-101
Timestamp: 2025-08-01T07:46:37.840Z
Learning: In backport PRs like `#6786`, UdjinM6 prefers to defer non-critical fixes (such as shell command expansion issues) to separate commits/PRs to maintain focus on the primary backport objectives, consistent with the project's pattern of avoiding scope creep.
📚 Learning: 2025-12-22T15:42:48.595Z
Learnt from: kwvg
Repo: dashpay/dash PR: 7068
File: src/qt/guiutil_font.h:68-77
Timestamp: 2025-12-22T15:42:48.595Z
Learning: In C++/Qt codebases, use fail-fast asserts in setters to enforce invariants (e.g., ensuring internal maps contain necessary keys). Prefer assert() for programmer errors that should be caught in development and debugging, rather than defensive runtime checks with fallbacks. This helps catch invariant violations early during development. Apply to header and source files where invariant-driven state mutations occur, especially in setters like SetWeightBold/SetWeightNormal that assume established relationships or preconditions.

Applied to files:

  • src/test/util/net.h
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/{validation,txmempool}/**/*.{cpp,h} : Block validation and mempool handling must use extensions to Bitcoin Core mechanisms for special transaction validation and enhanced transaction relay

Applied to files:

  • src/test/fuzz/process_message.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/{validation,consensus,net_processing}/**/*.{cpp,h} : ValidationInterface callbacks must be used for event-driven architecture to coordinate subsystems during block/transaction processing

Applied to files:

  • src/test/fuzz/process_message.cpp
🧬 Code graph analysis (1)
src/test/util/net.h (1)
src/net.h (1)
  • NetEventsInterface (1143-1179)
🔇 Additional comments (6)
src/test/util/net.h (1)

73-76: LGTM!

The signature change from void to bool correctly propagates the return value from ProcessMessages, which indicates whether there is more work to be done. This aligns with the NetEventsInterface::ProcessMessages interface and enables the fuzz tests to loop until all messages are fully processed, supporting the deadlock detection objectives of this backport.

src/test/fuzz/process_messages.cpp (2)

65-65: LGTM!

Using MAX_PROTOCOL_MESSAGE_LENGTH as the maximum byte vector length addresses the OSS-Fuzz issue (bitcoin#29079) by constraining fuzz input to valid protocol message sizes.


72-81: LGTM!

The loop-based processing correctly implements the deadlock detection mechanism from bitcoin#29009:

  • Continues processing until ProcessMessagesOnce returns false (no more work)
  • Resets fPauseSend each iteration to prevent artificial blocking
  • The empty catch for std::ios_base::failure is appropriate for fuzz testing where malformed data is expected
  • Moving SendMessages inside the loop ensures complete send/receive cycles on each iteration
src/test/fuzz/process_message.cpp (3)

1-1: LGTM!

Copyright year updated to "2020-present" consistent with upstream Bitcoin Core convention.


72-77: LGTM!

The refactored message handling uses the proper public interface:


79-87: LGTM!

The processing loop correctly mirrors the pattern in process_messages.cpp:

  • Loops until ProcessMessagesOnce returns false, ensuring complete message processing
  • Resets fPauseSend to prevent artificial blocking
  • Empty catch for std::ios_base::failure handles expected malformed fuzz input
  • SendMessages inside the loop ensures proper send/receive cycle completion

This implements the deadlock detection mechanism from bitcoin#29009.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

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 34a9eeb

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