Skip to content

backport: Merge bitcoin#28172, 28464 - #7186

Open
vijaydasmp wants to merge 2 commits into
dashpay:developfrom
vijaydasmp:March_2026_4
Open

backport: Merge bitcoin#28172, 28464#7186
vijaydasmp wants to merge 2 commits into
dashpay:developfrom
vijaydasmp:March_2026_4

Conversation

@vijaydasmp

Copy link
Copy Markdown

Bitcoin Backporting work

@github-actions

github-actions Bot commented Feb 28, 2026

Copy link
Copy Markdown

✅ No Merge Conflicts Detected

This PR currently has no conflicts with other open PRs.

@vijaydasmp
vijaydasmp force-pushed the March_2026_4 branch 5 times, most recently from a0ab1c7 to 8d656d4 Compare March 4, 2026 08:28
@vijaydasmp vijaydasmp changed the title backport: Merge bitcoin#28172, 28649, 25065, 28224, 28464 backport: Merge bitcoin#28172, 28649, 28464 Mar 6, 2026
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

This pull request has conflicts, please rebase.

@thepastaclaw

Copy link
Copy Markdown
Collaborator

@vijaydasmp could you please rebase this PR, or close it if it’s no longer needed? Thanks!

@vijaydasmp
vijaydasmp marked this pull request as ready for review July 5, 2026 17:36
@thepastaclaw

thepastaclaw commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

⛔ Blockers found — Opus deferred (commit b6412af)
Canonical validated blockers: 1

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 36a3679f-7c41-41fa-92bc-821df7ad4cc5

📥 Commits

Reviewing files that changed from the base of the PR and between 25cb4de and b6412af.

📒 Files selected for processing (1)
  • src/net.h
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/net.h

Walkthrough

This PR consolidates CConnman connection limits into m_max_automatic_connections and derives inbound and outbound limits internally. It updates network limit consumers, initialization wiring, and denial-of-service tests. RPC hash and hexadecimal parsing helpers now use std::string_view and strprintf. A documentation comment URL is removed.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested reviewers: udjinm6

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the pull request as a backport of Bitcoin changes #28172 and #28464.
Description check ✅ Passed The description identifies the work as Bitcoin backporting, which matches the pull request changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/init.cpp`:
- Around line 2553-2554: Assign m_max_automatic_connections before computing
m_max_outbound_onion in the init logic, since the current ordering in the
connection setup leaves connOptions.m_max_automatic_connections at its default
when the onion budget is derived. Update the code around the connOptions
assignments so m_max_automatic_connections is set from nMaxConnections first,
then use that value to calculate m_max_outbound_onion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d71e2c47-6e6d-42e0-b4e9-685b035d5fa7

📥 Commits

Reviewing files that changed from the base of the PR and between d1eab6c and fa96c9e4c8112928d0904e663ba25303a2d9d75c.

📒 Files selected for processing (7)
  • src/init.cpp
  • src/net.cpp
  • src/net.h
  • src/rpc/util.cpp
  • src/rpc/util.h
  • src/test/denialofservice_tests.cpp
  • src/util/strencodings.h
💤 Files with no reviewable changes (1)
  • src/util/strencodings.h

Comment thread src/init.cpp Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fa96c9e4c8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/init.cpp Outdated
connOptions.m_max_outbound_onion = std::min(MAX_DESIRED_ONION_CONNECTIONS, connOptions.nMaxConnections / 2);
connOptions.nMaxAddnode = MAX_ADDNODE_CONNECTIONS;
connOptions.nMaxFeeler = MAX_FEELER_CONNECTIONS;
connOptions.m_max_outbound_onion = std::min(MAX_DESIRED_ONION_CONNECTIONS, connOptions.m_max_automatic_connections / 2);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Set automatic cap before computing onion limit

When Tor/onion is reachable, this computes m_max_outbound_onion from connOptions.m_max_automatic_connections while that option is still its default 0, so the onion target is always initialized to 0 before the real nMaxConnections value is assigned on the next line. As a result the onion-only branch in ThreadOpenConnections() never runs and existing outbound onion peers get no reserved protection, regressing the intended default of up to two onion outbound peers; assign m_max_automatic_connections first or compute from nMaxConnections.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Probably this line should be removed from init.cpp

-connOptions.m_max_outbound_onion = std::min(MAX_DESIRED_ONION_CONNECTIONS, connOptions.m_max_automatic_connections / 2);

and added in net.h along these:

         m_max_automatic_connections = connOptions.m_max_automatic_connections;
         m_max_outbound_full_relay = std::min(MAX_OUTBOUND_FULL_RELAY_CONNECTIONS, m_max_automatic_connections);
         m_max_outbound_block_relay = std::min(MAX_BLOCK_RELAY_ONLY_CONNECTIONS, m_max_automatic_connections - m_max_outbound_full_relay);
         m_max_automatic_outbound = m_max_outbound_full_relay + m_max_outbound_block_relay + m_max_feeler;
         m_max_inbound = std::max(0, m_max_automatic_connections - m_max_automatic_outbound);
+        m_max_outbound_onion = std::min(MAX_DESIRED_ONION_CONNECTIONS, m_max_automatic_connections / 2);

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code Review

Policy gate: an agent-reported missing upstream prerequisite was restored as a blocking finding. This PR is a full Bitcoin backport, and omitted upstream hunks require their prerequisite PRs unless the finding is explicitly allowlisted (intentional_exclusion / policy_override). The agent's original evidence is preserved in the finding(s) below.

Prior verifier summary (overridden by policy gate): Verified one blocking merge-resolution bug: at src/init.cpp:2553 the Dash-specific line initializing connOptions.m_max_outbound_onion reads connOptions.m_max_automatic_connections before it is assigned on line 2554. Because Options::m_max_automatic_connections defaults to 0 (src/net.h:1189), m_max_outbound_onion is silently forced to 0, and CConnman propagates this into m_max_outbound_onion at src/net.h:1223, disabling Dash's outbound-onion preference in CConnman::ThreadOpenConnections. Also flagging a stale comment and a PR-title/scope mismatch (bitcoin#28649 is advertised but was already backported in 0528cfd, not in this PR). Reviewer coverage note: all three codex lanes (codex-general, codex-dash-core-commit-history, codex-backport-reviewer) failed to run due to a model configuration error and produced no output; only the three Claude lanes were successful.

4 blocking | 2 nitpick(s)

Source: reviewers: opus (backport-reviewer), opus (dash-core-commit-history), opus (general), gpt-5.5[high] (backport-reviewer) [failed], gpt-5.5[high] (dash-core-commit-history) [failed], gpt-5.5[high] (general) [failed]; verifier: opus; specialists: dash-core-commit-history, backport-reviewer.

Reviewer coverage note: the Claude/Opus lanes completed for general, dash-core-commit-history, and backport-reviewer. The three Codex lanes failed before review because ACP rejected the configured gpt-5.5[high] model override, so their outputs were not used.

Policy gate actions:

  • Promoted from claude-backport-reviewer: bitcoin#28464 merge resolution: m_max_outbound_onion uses m_max_automatic_connections before it is assigned
  • Promoted from claude-backport-reviewer: Comment references pre-rename member m_max_outbound after 28464 rename
  • Promoted from claude-backport-reviewer: PR title advertises bitcoin#28649 but the commit is not in the branch
  • summary_overridden
Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `src/init.cpp`:
- [BLOCKING] src/init.cpp:2553-2554: m_max_outbound_onion computed before m_max_automatic_connections is assigned — value is always 0 (source: claude)
  The bitcoin#28464 merge resolution swapped the initialization order of two adjacent fields on `connOptions`:
  
  ```cpp
  CConnman::Options connOptions;
  connOptions.nLocalServices = nLocalServices;
  connOptions.m_max_outbound_onion = std::min(MAX_DESIRED_ONION_CONNECTIONS, connOptions.m_max_automatic_connections / 2);
  connOptions.m_max_automatic_connections = nMaxConnections;

Options::m_max_automatic_connections default-initializes to 0 (src/net.h:1189), and the assignment on line 2554 happens after the read on line 2553. So m_max_outbound_onion is always std::min(MAX_DESIRED_ONION_CONNECTIONS, 0 / 2) == 0.

That zero is then copied verbatim into CConnman::m_max_outbound_onion in CConnman::Init (src/net.h:1223). The outbound-onion preference in CConnman::ThreadOpenConnections (nOutboundOnionRelay < m_max_outbound_onion at src/net.cpp:3128) can never be true, and GetMaxOutboundOnionNodeCount() returns 0. The dedicated "prefer onion" outbound path Dash provided pre-backport is silently disabled — a functional regression not covered by any test.

Pre-backport, the analogous line read connOptions.nMaxConnections / 2 after nMaxConnections had been assigned on the preceding line, so it worked. Upstream Bitcoin sidesteps the whole issue by removing m_max_outbound_onion from Options and deriving it inside CConnman::Init(); the Dash merge kept it in Options but reversed the two assignments.

Fix by swapping the order (so m_max_automatic_connections is assigned first) or by referencing the local nMaxConnections directly.

  • [NITPICK] src/init.cpp:2551-2555: PR title advertises bitcoin#28649 but it is not in this PR (source: claude)
    The PR title is backport: Merge bitcoin#28172, 28649, 28464, but the branch relative to develop contains only two merges: adfe38a4f4 (bitcoin#28172) and fa96c9e4c8 (bitcoin#28464). bitcoin#28649 ("Do the SOCKS5 handshake reliably") was already backported separately in commit 0528cfd and is not part of this stack. Update the PR title/description to accurately reflect the two contained backports so upstream-tracking metadata stays consistent.

  • [BLOCKING] src/init.cpp:2553-2554: bitcoin#28464 merge resolution: m_max_outbound_onion uses m_max_automatic_connections before it is assigned [policy-gated] (source: claude-backport-reviewer)
    Upstream bitcoin#28464 replaced the block

    connOptions.nMaxConnections = nMaxConnections;
    connOptions.m_max_outbound_full_relay = std::min(MAX_OUTBOUND_FULL_RELAY_CONNECTIONS, connOptions.nMaxConnections);
    connOptions.m_max_outbound_block_relay = std::min(MAX_BLOCK_RELAY_ONLY_CONNECTIONS, connOptions.nMaxConnections-connOptions.m_max_outbound_full_relay);
    connOptions.nMaxAddnode = MAX_ADDNODE_CONNECTIONS;
    connOptions.nMaxFeeler = MAX_FEELER_CONNECTIONS;
    

    with a single assignment:

    connOptions.m_max_automatic_connections = nMaxConnections;
    

    Dash has an extra Dash-specific line for outbound onion:

    connOptions.m_max_outbound_onion = std::min(MAX_DESIRED_ONION_CONNECTIONS, connOptions.nMaxConnections / 2);
    

    Pre-merge this was safe because connOptions.nMaxConnections had already been set on the preceding line. In the merge resolution, the onion line was updated to reference connOptions.m_max_automatic_connections and placed BEFORE that field is assigned:

    connOptions.m_max_outbound_onion = std::min(MAX_DESIRED_ONION_CONNECTIONS, connOptions.m_max_automatic_connections / 2);
    connOptions.m_max_automatic_connections = nMaxConnections;
    

    At this point connOptions.m_max_automatic_connections is still 0 (the default-constructed value in the Options struct after 28464), so this evaluates to std::min(MAX_DESIRED_ONION_CONNECTIONS, 0) = 0. The value 0 is then propagated into CConnman::m_max_outbound_onion by CConnman::Init, and the outbound-onion preference in CConnman::ThreadOpenConnections (nOutboundOnionRelay < m_max_outbound_onion, src/net.cpp:3128) becomes a permanently-false condition. Effectively the Dash-specific onion-outbound preference is silently disabled after this backport.

    Fix: either swap the two lines so m_max_automatic_connections is assigned first, or reference the local nMaxConnections variable directly (std::min(MAX_DESIRED_ONION_CONNECTIONS, nMaxConnections / 2)). Not a missing upstream prerequisite — a Dash merge-resolution error interacting with a Dash-only line.


    Policy gate (backport-prereq-restore): For full upstream backport PRs, a missing prerequisite is blocking unless the finding is explicitly allowlisted (e.g. intentional_exclusion: true or a matching entry in policy_overrides). The agent's original evidence above is the basis for this block; either backport the prerequisite or annotate the intentional exclusion in the PR description.

  • [BLOCKING] src/init.cpp:2551-2554: PR title advertises bitcoin#28649 but the commit is not in the branch [policy-gated] (source: claude-backport-reviewer)
    The PR title 'backport: Merge bitcoin#28172, 28649, 28464' claims three upstream backports, but git log origin/develop..HEAD on the head SHA (fa96c9e4c8) shows only two merge commits (adfe38a4f4 for bitcoin#28172 and fa96c9e4c8 for bitcoin#28464). bitcoin#28649 (netbase: reliable SOCKS5 handshake via SendComplete + Sock::SendComplete Span refactor) is absent. Not a code-completeness issue for what is here, but reviewers/mergers should either drop bitcoin#28649 from the PR title/description or add the commit before merging so upstream-tracking metadata stays accurate.


    Policy gate (backport-prereq-restore): For full upstream backport PRs, a missing prerequisite is blocking unless the finding is explicitly allowlisted (e.g. intentional_exclusion: true or a matching entry in policy_overrides). The agent's original evidence above is the basis for this block; either backport the prerequisite or annotate the intentional exclusion in the PR description.

In src/net.h:

  • [NITPICK] src/net.h:1847: Comment references pre-rename member m_max_outbound (source: claude)
    The bitcoin#28464 scripted-diff renamed m_max_outboundm_max_automatic_outbound throughout net.h/net.cpp. The comment on the m_max_outbound_onion field still reads // ... does not increase m_max_outbound. Upstream updated this comment via the scripted-diff; the Dash cherry-pick left it referencing the now-nonexistent member. Cosmetic only.

  • [BLOCKING] src/net.h:1847: Comment references pre-rename member m_max_outbound after 28464 rename [policy-gated] (source: claude-backport-reviewer)
    The scripted-diff commit in bitcoin#28464 renamed m_max_outbound to m_max_automatic_outbound throughout net.h/net.cpp. The comment on the m_max_outbound_onion field still says '...does not increase m_max_outbound'. Upstream updated all occurrences (including this comment) via the scripted-diff; the Dash cherry-pick left the comment referencing the now-nonexistent member. Cosmetic only, no functional impact.


    Policy gate (backport-prereq-restore): For full upstream backport PRs, a missing prerequisite is blocking unless the finding is explicitly allowlisted (e.g. intentional_exclusion: true or a matching entry in policy_overrides). The agent's original evidence above is the basis for this block; either backport the prerequisite or annotate the intentional exclusion in the PR description.

</details>

Comment thread src/init.cpp Outdated
Comment on lines +2553 to +2554
connOptions.m_max_outbound_onion = std::min(MAX_DESIRED_ONION_CONNECTIONS, connOptions.m_max_automatic_connections / 2);
connOptions.m_max_automatic_connections = nMaxConnections;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔴 Blocking: m_max_outbound_onion computed before m_max_automatic_connections is assigned — value is always 0

The bitcoin#28464 merge resolution swapped the initialization order of two adjacent fields on connOptions:

CConnman::Options connOptions;
connOptions.nLocalServices = nLocalServices;
connOptions.m_max_outbound_onion = std::min(MAX_DESIRED_ONION_CONNECTIONS, connOptions.m_max_automatic_connections / 2);
connOptions.m_max_automatic_connections = nMaxConnections;

Options::m_max_automatic_connections default-initializes to 0 (src/net.h:1189), and the assignment on line 2554 happens after the read on line 2553. So m_max_outbound_onion is always std::min(MAX_DESIRED_ONION_CONNECTIONS, 0 / 2) == 0.

That zero is then copied verbatim into CConnman::m_max_outbound_onion in CConnman::Init (src/net.h:1223). The outbound-onion preference in CConnman::ThreadOpenConnections (nOutboundOnionRelay < m_max_outbound_onion at src/net.cpp:3128) can never be true, and GetMaxOutboundOnionNodeCount() returns 0. The dedicated "prefer onion" outbound path Dash provided pre-backport is silently disabled — a functional regression not covered by any test.

Pre-backport, the analogous line read connOptions.nMaxConnections / 2 after nMaxConnections had been assigned on the preceding line, so it worked. Upstream Bitcoin sidesteps the whole issue by removing m_max_outbound_onion from Options and deriving it inside CConnman::Init(); the Dash merge kept it in Options but reversed the two assignments.

Fix by swapping the order (so m_max_automatic_connections is assigned first) or by referencing the local nMaxConnections directly.

Suggested change
connOptions.m_max_outbound_onion = std::min(MAX_DESIRED_ONION_CONNECTIONS, connOptions.m_max_automatic_connections / 2);
connOptions.m_max_automatic_connections = nMaxConnections;
connOptions.m_max_automatic_connections = nMaxConnections;
connOptions.m_max_outbound_onion = std::min(MAX_DESIRED_ONION_CONNECTIONS, connOptions.m_max_automatic_connections / 2);

source: ['claude']

@thepastaclaw thepastaclaw Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Correction: this prior finding is still valid at 062b3c5c40, not resolved. The current head still reads connOptions.m_max_automatic_connections for the onion limit one line before assigning that member from nMaxConnections, so the prior zero-value initialization bug remains.

Corrected after the exact-SHA verifier reconciliation; the earlier auto-resolved text was produced by duplicate-thread suppression and was wrong.

Comment thread src/net.h Outdated
@@ -1841,9 +1847,11 @@ friend class CNode;
// How many onion outbound peers we want; don't care if full or block only; does not increase m_max_outbound

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

💬 Nitpick: Comment references pre-rename member m_max_outbound

The bitcoin#28464 scripted-diff renamed m_max_outboundm_max_automatic_outbound throughout net.h/net.cpp. The comment on the m_max_outbound_onion field still reads // ... does not increase m_max_outbound. Upstream updated this comment via the scripted-diff; the Dash cherry-pick left it referencing the now-nonexistent member. Cosmetic only.

Suggested change
// How many onion outbound peers we want; don't care if full or block only; does not increase m_max_outbound
// How many onion outbound peers we want; don't care if full or block only; does not increase m_max_automatic_outbound

source: ['claude']

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Resolved in this update — Comment references pre-rename member m_max_outbound no longer present.

Auto-resolved by the review system based on the latest commit diff. If you believe this was closed in error, reopen the thread.

Comment thread src/init.cpp
Comment thread src/init.cpp Outdated
Comment on lines +2553 to +2554
connOptions.m_max_outbound_onion = std::min(MAX_DESIRED_ONION_CONNECTIONS, connOptions.m_max_automatic_connections / 2);
connOptions.m_max_automatic_connections = nMaxConnections;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔴 Blocking: bitcoin#28464 merge resolution: m_max_outbound_onion uses m_max_automatic_connections before it is assigned

Upstream bitcoin#28464 replaced the block

connOptions.nMaxConnections = nMaxConnections;
connOptions.m_max_outbound_full_relay = std::min(MAX_OUTBOUND_FULL_RELAY_CONNECTIONS, connOptions.nMaxConnections);
connOptions.m_max_outbound_block_relay = std::min(MAX_BLOCK_RELAY_ONLY_CONNECTIONS, connOptions.nMaxConnections-connOptions.m_max_outbound_full_relay);
connOptions.nMaxAddnode = MAX_ADDNODE_CONNECTIONS;
connOptions.nMaxFeeler = MAX_FEELER_CONNECTIONS;

with a single assignment:

connOptions.m_max_automatic_connections = nMaxConnections;

Dash has an extra Dash-specific line for outbound onion:

connOptions.m_max_outbound_onion = std::min(MAX_DESIRED_ONION_CONNECTIONS, connOptions.nMaxConnections / 2);

Pre-merge this was safe because connOptions.nMaxConnections had already been set on the preceding line. In the merge resolution, the onion line was updated to reference connOptions.m_max_automatic_connections and placed BEFORE that field is assigned:

connOptions.m_max_outbound_onion = std::min(MAX_DESIRED_ONION_CONNECTIONS, connOptions.m_max_automatic_connections / 2);
connOptions.m_max_automatic_connections = nMaxConnections;

At this point connOptions.m_max_automatic_connections is still 0 (the default-constructed value in the Options struct after 28464), so this evaluates to std::min(MAX_DESIRED_ONION_CONNECTIONS, 0) = 0. The value 0 is then propagated into CConnman::m_max_outbound_onion by CConnman::Init, and the outbound-onion preference in CConnman::ThreadOpenConnections (nOutboundOnionRelay < m_max_outbound_onion, src/net.cpp:3128) becomes a permanently-false condition. Effectively the Dash-specific onion-outbound preference is silently disabled after this backport.

Fix: either swap the two lines so m_max_automatic_connections is assigned first, or reference the local nMaxConnections variable directly (std::min(MAX_DESIRED_ONION_CONNECTIONS, nMaxConnections / 2)). Not a missing upstream prerequisite — a Dash merge-resolution error interacting with a Dash-only line.


Policy gate (backport-prereq-restore): For full upstream backport PRs, a missing prerequisite is blocking unless the finding is explicitly allowlisted (e.g. intentional_exclusion: true or a matching entry in policy_overrides). The agent's original evidence above is the basis for this block; either backport the prerequisite or annotate the intentional exclusion in the PR description.

source: ['claude-backport-reviewer']

@thepastaclaw thepastaclaw Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Correction: this prior finding is still valid at 062b3c5c40, not resolved. The current head still computes connOptions.m_max_outbound_onion from connOptions.m_max_automatic_connections at src/init.cpp:2622 before assigning m_max_automatic_connections = nMaxConnections at src/init.cpp:2623, so the onion outbound target is derived from the default zero value.

Corrected after the exact-SHA verifier reconciliation; the earlier auto-resolved text was produced by duplicate-thread suppression and was wrong.

Comment thread src/net.h Outdated
@@ -1841,9 +1847,11 @@ friend class CNode;
// How many onion outbound peers we want; don't care if full or block only; does not increase m_max_outbound

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔴 Blocking: Comment references pre-rename member m_max_outbound after 28464 rename

The scripted-diff commit in bitcoin#28464 renamed m_max_outbound to m_max_automatic_outbound throughout net.h/net.cpp. The comment on the m_max_outbound_onion field still says '...does not increase m_max_outbound'. Upstream updated all occurrences (including this comment) via the scripted-diff; the Dash cherry-pick left the comment referencing the now-nonexistent member. Cosmetic only, no functional impact.


Policy gate (backport-prereq-restore): For full upstream backport PRs, a missing prerequisite is blocking unless the finding is explicitly allowlisted (e.g. intentional_exclusion: true or a matching entry in policy_overrides). The agent's original evidence above is the basis for this block; either backport the prerequisite or annotate the intentional exclusion in the PR description.

source: ['claude-backport-reviewer']

@thepastaclaw thepastaclaw Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Correction: this prior finding is still valid at 062b3c5c40, not resolved. The comment at src/net.h:1862 still says the onion preference does not increase m_max_outbound, but bitcoin#28464 renamed the corresponding field to m_max_automatic_outbound.

Corrected after the exact-SHA verifier reconciliation; the earlier auto-resolved text was produced by duplicate-thread suppression and was wrong.

Comment thread src/init.cpp
@vijaydasmp vijaydasmp changed the title backport: Merge bitcoin#28172, 28649, 28464 backport: Merge bitcoin#28172, 28464 Jul 6, 2026
@vijaydasmp
vijaydasmp requested a review from thepastaclaw July 6, 2026 06:21

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code Review

Cumulative re-review for 062b3c5c40d5816b71a84199c7712448e074497a after the push from fa96c9e4. The title cleanup is fixed, and the latest delta did not introduce new findings, but the two substantive bitcoin#28464 carry-forward issues remain in the current head.

Source: reviewers = claude/opus + codex/gpt-5.5 for general, dash-core-commit-history, and backport-reviewer; verifier = claude/opus; policy gate = review_policy.enforce_backport_prereq_policy.

Carried-forward prior findings still valid

  • [blocking] src/init.cpp:2622-2623m_max_outbound_onion is still computed before m_max_automatic_connections is assigned. The current code reads connOptions.m_max_automatic_connections for the onion outbound target at line 2622, then assigns connOptions.m_max_automatic_connections = nMaxConnections at line 2623. Since CConnman::Options default-initializes this member to 0, Dash's onion outbound preference is still disabled unless the assignment is moved before the onion calculation.
  • [nitpick / policy-carried] src/net.h:1862 — the comment still references the pre-rename m_max_outbound member after the bitcoin#28464 rename. The field is now m_max_automatic_outbound at line 1867, so the comment should say it does not increase m_max_automatic_outbound.

Prior findings fixed at this head

New findings in the latest delta: none beyond the carried-forward items above.

@knst knst left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

28172 - OK
28464 requires changes

Comment thread src/rpc/util.h Outdated
#include <string>
#include <type_traits>
#include <utility>
#include <string_view>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit:

 #include <string>
+#include <string_view>
 #include <type_traits>
 #include <utility>
-#include <string_view>

Comment thread src/init.cpp Outdated
connOptions.m_max_outbound_onion = std::min(MAX_DESIRED_ONION_CONNECTIONS, connOptions.nMaxConnections / 2);
connOptions.nMaxAddnode = MAX_ADDNODE_CONNECTIONS;
connOptions.nMaxFeeler = MAX_FEELER_CONNECTIONS;
connOptions.m_max_outbound_onion = std::min(MAX_DESIRED_ONION_CONNECTIONS, connOptions.m_max_automatic_connections / 2);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Probably this line should be removed from init.cpp

-connOptions.m_max_outbound_onion = std::min(MAX_DESIRED_ONION_CONNECTIONS, connOptions.m_max_automatic_connections / 2);

and added in net.h along these:

         m_max_automatic_connections = connOptions.m_max_automatic_connections;
         m_max_outbound_full_relay = std::min(MAX_OUTBOUND_FULL_RELAY_CONNECTIONS, m_max_automatic_connections);
         m_max_outbound_block_relay = std::min(MAX_BLOCK_RELAY_ONLY_CONNECTIONS, m_max_automatic_connections - m_max_outbound_full_relay);
         m_max_automatic_outbound = m_max_outbound_full_relay + m_max_outbound_block_relay + m_max_feeler;
         m_max_inbound = std::max(0, m_max_automatic_connections - m_max_automatic_outbound);
+        m_max_outbound_onion = std::min(MAX_DESIRED_ONION_CONNECTIONS, m_max_automatic_connections / 2);

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

dash/src/init.cpp

Line 1272 in bb29ffc

nMaxConnections = std::min(nFD - MIN_CORE_FILEDESCRIPTORS - MAX_ADDNODE_CONNECTIONS - NUM_FDS_MESSAGE_CAPTURE, nMaxConnections);

P2 Badge Clamp the post-reservation connection limit

On Unix nodes whose RLIMIT_NOFILE remains between 151 and 158 after RaiseFileDescriptorLimit (MIN_CORE_FILEDESCRIPTORS is 150 and this patch reserves 8 addnode FDs plus the message-capture FD), the clamp above sets nMaxConnections to 0, but this second min turns it negative. That negative value is passed to CConnman::Init(), producing negative outbound limits and a negative semaphore size; Interrupt() then posts zero grants because the loop bound is negative, so the open-connections thread can remain blocked during shutdown. Clamp this result to 0 like the previous calculation.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/net.h
nMaxConnections = connOptions.nMaxConnections;
m_max_outbound_full_relay = std::min(connOptions.m_max_outbound_full_relay, connOptions.nMaxConnections);
m_max_outbound_block_relay = connOptions.m_max_outbound_block_relay;
m_max_automatic_connections = connOptions.m_max_automatic_connections;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Derive the onion outbound budget from maxconnections

When this newly-derived automatic limit is set, m_max_outbound_onion is still copied from Options unchanged later, and AppInit now only assigns connOptions.m_max_automatic_connections = nMaxConnections; fresh evidence in this revision is that Options::m_max_outbound_onion still defaults to 0 and is never derived from this value. With Tor reachable, the onion-only branch in ThreadOpenConnections() and the onion eviction protection both see a zero budget, so the default up-to-two onion outbound peers are never opened or protected.

Useful? React with 👍 / 👎.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Preliminary review — Codex only

At exact head bb29ffc, the latest delta removes the old read-before-assignment sequence but also removes Dash's only onion outbound-limit calculation, so the production option remains defaulted to zero and the same functional regression persists through a new omission mechanism. The stale renamed-member comment is carried forward, while no additional in-scope issue was confirmed. The descriptor-clamp edge case is valid but byte-identical to the merge base and both sides of upstream bitcoin#28464, so it is outside this PR.

Validated blockers were found in the Codex precheck. Sonnet is deferred until a fresh Codex revalidation clears the blocker gate.

Review provenance

  • Codex reviewers: gpt-5.6-sol — general (completed), gpt-5.6-sol — dash-core-commit-history (completed), gpt-5.6-sol — backport-reviewer (failed), gpt-5.6-sol — backport-reviewer (completed)
  • Verifier: gpt-5.6-sol — verifier
  • Sonnet: not run (deferred by blocker gate)

🔴 1 blocking

1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `src/init.cpp`:
- [BLOCKING] src/init.cpp:2622: bitcoin#28464 merge resolution drops Dash's onion outbound-limit calculation
  New in the latest delta, superseding the assignment-order mechanism reported by prior-1, prior-2, and prior-4. Before this backport, `AppInitMain()` assigned `connOptions.nMaxConnections` and then derived `m_max_outbound_onion` as `min(MAX_DESIRED_ONION_CONNECTIONS, nMaxConnections / 2)`. Upstream bitcoin#28464 moved its per-type connection-limit calculations into `CConnman::Init()`, and the current merge resolution removes Dash's additional onion calculation without moving it there. `CConnman::Options::m_max_outbound_onion` consequently remains at its default zero in `src/net.h:1201`, and `CConnman::Init()` copies that zero unchanged at line 1236. There are no other assignments in the tree, so the onion-preferred branch in `ThreadOpenConnections()` cannot request a peer and the Tor-peer eviction protection receives a limit of zero. Initialize the onion budget from the automatic connection limit, preferably alongside the other derived limits in `CConnman::Init()`.

Comment thread src/init.cpp
connOptions.m_max_outbound_onion = std::min(MAX_DESIRED_ONION_CONNECTIONS, connOptions.nMaxConnections / 2);
connOptions.nMaxAddnode = MAX_ADDNODE_CONNECTIONS;
connOptions.nMaxFeeler = MAX_FEELER_CONNECTIONS;
connOptions.m_max_automatic_connections = nMaxConnections;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔴 Blocking: bitcoin#28464 merge resolution drops Dash's onion outbound-limit calculation

New in the latest delta, superseding the assignment-order mechanism reported by prior-1, prior-2, and prior-4. Before this backport, AppInitMain() assigned connOptions.nMaxConnections and then derived m_max_outbound_onion as min(MAX_DESIRED_ONION_CONNECTIONS, nMaxConnections / 2). Upstream bitcoin#28464 moved its per-type connection-limit calculations into CConnman::Init(), and the current merge resolution removes Dash's additional onion calculation without moving it there. CConnman::Options::m_max_outbound_onion consequently remains at its default zero in src/net.h:1201, and CConnman::Init() copies that zero unchanged at line 1236. There are no other assignments in the tree, so the onion-preferred branch in ThreadOpenConnections() cannot request a peer and the Tor-peer eviction protection receives a limit of zero. Initialize the onion budget from the automatic connection limit, preferably alongside the other derived limits in CConnman::Init().

Suggested change
connOptions.m_max_automatic_connections = nMaxConnections;
connOptions.m_max_automatic_connections = nMaxConnections;
connOptions.m_max_outbound_onion = std::min(MAX_DESIRED_ONION_CONNECTIONS, connOptions.m_max_automatic_connections / 2);

source: ['codex']

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Resolved in this update — bitcoin#28464 merge resolution drops Dash's onion outbound-limit calculation no longer present.

Auto-resolved by the review system based on the latest commit diff. If you believe this was closed in error, reopen the thread.

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

This pull request has conflicts, please rebase.

…erals to Parse{Hash,Hex}

bb91131 doc: remove out-of-date external link in src/util/strencodings.h (Jon Atack)
7d494a4 refactor: use string_view to pass string literals to Parse{Hash,Hex} (Jon Atack)

Pull request description:

  as `string_view` is optimized to be trivially copiable, whereas the current code creates a `std::string` copy at each call.

  These utility methods are called by quite a few RPCs and tests, as well as by each other.

  ```
  $ git grep "ParseHashV\|ParseHashO\|ParseHexV\|ParseHexO" | wc -l
  61
  ```

  Also remove an out-of-date external link.

ACKs for top commit:
  jonatack:
    Rebased per `git range-diff c9273f6 b94581a bb91131` for an include header from the merge of bitcoin#28230. Should be trivial to re-ACK.
  maflcko:
    lgtm ACK bb91131
  ns-xvrn:
    ACK bitcoin@bb91131
  achow101:
    ACK bb91131
  brunoerg:
    crACK bb91131

Tree-SHA512: 9734fe022c9e43fd93c23a917770d332dbbd3132c80a234059714c32faa6469391e59349954749fc86c4ef0b18d5fd99bf8f4b7b82d9f799943799c1253272ae
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

df69b22 doc: improve documentation around connection limit maximums (Amiti Uttarwar)
adc171e scripted-diff: Rename connection limit variables (Amiti Uttarwar)
e9fd9c0 net: add m_max_inbound to connman (Amiti Uttarwar)
c25e0e0 net, refactor: move calculations for connection type limits into connman (Amiti Uttarwar)

Pull request description:

  This is joint work with amitiuttarwar.

  This has the first few commits of bitcoin#28463. It is not strictly a prerequisite for that, but has changes that in our opinion make sense on their own.
  It improves the handling of maximum numbers for different connection types (that are set during init and don’t change after) by:
  * moving all calculations into one place, `CConnMan::Init()`. Before, they were dispersed between `Init`, `CConnman::Init` and other parts of `CConnman`, resulting in some duplicated test code.
  * removing the possibility of having a negative maximum of inbound connections, which is hard to argue about
  * renaming of variables and doc improvements

ACKs for top commit:
  amitiuttarwar:
    co-author review ACK df69b22
  naumenkogs:
    ACK df69b22
  achow101:
    ACK df69b22

Tree-SHA512: 913d56136bc1df739978de50db67302f88bac2a9d34748ae96763288d97093e998fc0f94f9b6eff12867712d7e86225af6128f4170bf2b5b8ab76f024870a22c

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Preliminary review — Codex only

The bitcoin#28172 string_view backport appears correctly adapted, but bitcoin#28464 still removes Dash's production initialization of the onion outbound budget, disabling onion-preferred connection attempts and onion eviction protection. The previously stale connection-member comment is fixed at this head.
Source: reviewers: gpt-5.6-sol (general), gpt-5.6-sol (dash-core-commit-history), and gpt-5.6-sol (backport-reviewer); final verifier: gpt-5.6-sol. openclaw-agent/cliproxy/gpt-5.6-sol was orchestration-only and is not reviewer evidence.

Validated blockers were found in the Codex precheck. Opus is deferred until a fresh Codex revalidation clears the blocker gate.

Review provenance

  • Codex reviewers: gpt-5.6-sol — general (completed), gpt-5.6-sol — dash-core-commit-history (completed), gpt-5.6-sol — backport-reviewer (completed)
  • Verifier: gpt-5.6-sol — verifier
  • Sonnet: not run (deferred by blocker gate)

🔴 1 blocking

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `src/net.h`:
- [BLOCKING] src/net.h:1256: bitcoin#28464 merge resolution drops Dash's onion outbound-limit calculation
  Before this backport, `AppInitMain()` derived `m_max_outbound_onion` as `min(MAX_DESIRED_ONION_CONNECTIONS, nMaxConnections / 2)`. The backport now initializes only `connOptions.m_max_automatic_connections`, while `Options::m_max_outbound_onion` remains at its default zero and this line copies that zero into `CConnman`. No other production assignment exists. Consequently, the onion-preferred branch in `ThreadOpenConnections()` can never request an onion peer, and `GetMaxOutboundOnionNodeCount()` returns zero to the outbound eviction logic instead of preserving up to two onion peers. Derive the Dash-specific onion budget from `m_max_automatic_connections` alongside the other connection limits in `CConnman::Init()`.

Comment thread src/net.h
m_max_outbound_block_relay = std::min(MAX_BLOCK_RELAY_ONLY_CONNECTIONS, m_max_automatic_connections - m_max_outbound_full_relay);
m_max_automatic_outbound = m_max_outbound_full_relay + m_max_outbound_block_relay + m_max_feeler;
m_max_inbound = std::max(0, m_max_automatic_connections - m_max_automatic_outbound);
m_max_outbound_onion = connOptions.m_max_outbound_onion;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔴 Blocking: bitcoin#28464 merge resolution drops Dash's onion outbound-limit calculation

Before this backport, AppInitMain() derived m_max_outbound_onion as min(MAX_DESIRED_ONION_CONNECTIONS, nMaxConnections / 2). The backport now initializes only connOptions.m_max_automatic_connections, while Options::m_max_outbound_onion remains at its default zero and this line copies that zero into CConnman. No other production assignment exists. Consequently, the onion-preferred branch in ThreadOpenConnections() can never request an onion peer, and GetMaxOutboundOnionNodeCount() returns zero to the outbound eviction logic instead of preserving up to two onion peers. Derive the Dash-specific onion budget from m_max_automatic_connections alongside the other connection limits in CConnman::Init().

Suggested change
m_max_outbound_onion = connOptions.m_max_outbound_onion;
m_max_outbound_onion = std::min(MAX_DESIRED_ONION_CONNECTIONS, m_max_automatic_connections / 2);

source: ['codex']

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