-
Notifications
You must be signed in to change notification settings - Fork 1.2k
backport: Merge bitcoin#28172, 28464 #7186
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -631,7 +631,7 @@ void SetupServerArgs(ArgsManager& argsman) | |||||||||
| argsman.AddArg("-forcednsseed", strprintf("Always query for peer addresses via DNS lookup (default: %u)", DEFAULT_FORCEDNSSEED), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); | ||||||||||
| argsman.AddArg("-listen", strprintf("Accept connections from outside (default: %u if no -proxy, -connect or -maxconnections=0)", DEFAULT_LISTEN), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); | ||||||||||
| argsman.AddArg("-listenonion", strprintf("Automatically create Tor onion service (default: %d)", DEFAULT_LISTEN_ONION), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); | ||||||||||
| argsman.AddArg("-maxconnections=<n>", strprintf("Maintain at most <n> connections to peers (temporary service connections excluded) (default: %u). This limit does not apply to connections manually added via -addnode or the addnode RPC, which have a separate limit of %u.", DEFAULT_MAX_PEER_CONNECTIONS, MAX_ADDNODE_CONNECTIONS), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); | ||||||||||
| argsman.AddArg("-maxconnections=<n>", strprintf("Maintain at most <n> automatic connections to peers (temporary service connections excluded) (default: %u). This limit does not apply to connections manually added via -addnode or the addnode RPC, which have a separate limit of %u.", DEFAULT_MAX_PEER_CONNECTIONS, MAX_ADDNODE_CONNECTIONS), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); | ||||||||||
| argsman.AddArg("-maxreceivebuffer=<n>", strprintf("Maximum per-connection receive buffer, <n>*1000 bytes (default: %u)", DEFAULT_MAXRECEIVEBUFFER), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); | ||||||||||
| argsman.AddArg("-maxsendbuffer=<n>", strprintf("Maximum per-connection memory usage for the send buffer, <n>*1000 bytes (default: %u)", DEFAULT_MAXSENDBUFFER), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); | ||||||||||
| argsman.AddArg("-maxtimeadjustment", strprintf("Maximum allowed median peer time offset adjustment. Local perspective of time may be influenced by outbound peers forward or backward by this amount (default: %u seconds).", DEFAULT_MAX_TIME_ADJUSTMENT), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); | ||||||||||
|
|
@@ -2619,12 +2619,8 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) | |||||||||
|
|
||||||||||
| CConnman::Options connOptions; | ||||||||||
| connOptions.nLocalServices = nLocalServices; | ||||||||||
| 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.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); | ||||||||||
| connOptions.m_max_automatic_connections = nMaxConnections; | ||||||||||
|
Comment on lines
+2622
to
+2623
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== src/init.cpp around the reported lines =="
sed -n '2538,2562p' src/init.cpp | cat -n
echo
echo "== m_max_outbound_onion declaration/initialization =="
rg -n "m_max_outbound_onion|m_max_automatic_connections" src/net.h src -g '!src/leveldb/**' -g '!src/secp256k1/**'
echo
echo "== call sites / consumers =="
rg -n "GetMaxOutboundOnionNodeCount|m_max_outbound_onion|nOutboundOnionRelay" src -g '!src/leveldb/**' -g '!src/secp256k1/**'Repository: dashpay/dash Length of output: 5311 Assign
🤖 Prompt for AI Agents
Comment on lines
+2622
to
+2623
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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;
That zero is then copied verbatim into Pre-backport, the analogous line read Fix by swapping the order (so
Suggested change
source: ['claude'] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correction: this prior finding is still valid at Corrected after the exact-SHA verifier reconciliation; the earlier auto-resolved text was produced by duplicate-thread suppression and was wrong.
Comment on lines
+2622
to
+2623
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 with a single assignment: Dash has an extra Dash-specific line for outbound onion: Pre-merge this was safe because At this point Fix: either swap the two lines so Policy gate (backport-prereq-restore): For full upstream backport PRs, a missing prerequisite is blocking unless the finding is explicitly allowlisted (e.g. source: ['claude-backport-reviewer'] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correction: this prior finding is still valid at Corrected after the exact-SHA verifier reconciliation; the earlier auto-resolved text was produced by duplicate-thread suppression and was wrong.
Comment on lines
2620
to
+2623
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Blocking: PR title advertises bitcoin#28649 but the commit is not in the branch The PR title 'backport: Merge bitcoin#28172, 28649, 28464' claims three upstream backports, but Policy gate (backport-prereq-restore): For full upstream backport PRs, a missing prerequisite is blocking unless the finding is explicitly allowlisted (e.g. source: ['claude-backport-reviewer'] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved in this update — PR title advertises bitcoin#28649 but the commit is not in the branch 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. |
||||||||||
| connOptions.uiInterface = &uiInterface; | ||||||||||
|
Comment on lines
2620
to
2624
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💬 Nitpick: PR title advertises bitcoin#28649 but it is not in this PR The PR title is source: ['claude'] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved in this update — PR title advertises bitcoin#28649 but it is not in this PR 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. |
||||||||||
| connOptions.m_banman = node.banman.get(); | ||||||||||
| connOptions.m_msgproc = node.peerman.get(); | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1198,12 +1198,8 @@ friend class CNode; | |||||
| struct Options | ||||||
| { | ||||||
| ServiceFlags nLocalServices = NODE_NONE; | ||||||
| int nMaxConnections = 0; | ||||||
| int m_max_outbound_full_relay = 0; | ||||||
| int m_max_outbound_block_relay = 0; | ||||||
| int m_max_outbound_onion = 0; | ||||||
| int nMaxAddnode = 0; | ||||||
| int nMaxFeeler = 0; | ||||||
| int m_max_automatic_connections = 0; | ||||||
| CClientUIInterface* uiInterface = nullptr; | ||||||
| NetEventsInterface* m_msgproc = nullptr; | ||||||
| BanMan* m_banman = nullptr; | ||||||
|
|
@@ -1232,14 +1228,13 @@ friend class CNode; | |||||
| AssertLockNotHeld(m_total_bytes_sent_mutex); | ||||||
|
|
||||||
| nLocalServices = connOptions.nLocalServices; | ||||||
| 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; | ||||||
| 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 = connOptions.m_max_outbound_onion; | ||||||
| m_use_addrman_outgoing = connOptions.m_use_addrman_outgoing; | ||||||
| nMaxAddnode = connOptions.nMaxAddnode; | ||||||
| nMaxFeeler = connOptions.nMaxFeeler; | ||||||
| m_max_outbound = m_max_outbound_full_relay + m_max_outbound_block_relay + nMaxFeeler; | ||||||
| m_client_interface = connOptions.uiInterface; | ||||||
| m_banman = connOptions.m_banman; | ||||||
| m_msgproc = connOptions.m_msgproc; | ||||||
|
|
@@ -1844,7 +1839,18 @@ friend class CNode; | |||||
|
|
||||||
| std::unique_ptr<CSemaphore> semOutbound; | ||||||
| std::unique_ptr<CSemaphore> semAddnode; | ||||||
| int nMaxConnections; | ||||||
|
|
||||||
| /** | ||||||
| * Maximum number of automatic connections permitted, excluding manual | ||||||
| * connections but including inbounds. May be changed by the user and is | ||||||
| * potentially limited by the operating system (number of file descriptors). | ||||||
| */ | ||||||
| int m_max_automatic_connections; | ||||||
|
|
||||||
| /* | ||||||
| * Maximum number of peers by connection type. Might vary from defaults | ||||||
| * based on -maxconnections init value. | ||||||
| */ | ||||||
|
|
||||||
| // How many full-relay (tx, block, addr) outbound peers we want | ||||||
| int m_max_outbound_full_relay; | ||||||
|
|
@@ -1856,9 +1862,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 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
source: ['claude'] There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Policy gate (backport-prereq-restore): For full upstream backport PRs, a missing prerequisite is blocking unless the finding is explicitly allowlisted (e.g. source: ['claude-backport-reviewer'] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correction: this prior finding is still valid at Corrected after the exact-SHA verifier reconciliation; the earlier auto-resolved text was produced by duplicate-thread suppression and was wrong. |
||||||
| int m_max_outbound_onion; | ||||||
|
|
||||||
| int nMaxAddnode; | ||||||
| int nMaxFeeler; | ||||||
| int m_max_outbound; | ||||||
| int m_max_addnode{MAX_ADDNODE_CONNECTIONS}; | ||||||
| int m_max_feeler{MAX_FEELER_CONNECTIONS}; | ||||||
| int m_max_automatic_outbound; | ||||||
| int m_max_inbound; | ||||||
|
|
||||||
| bool m_use_addrman_outgoing; | ||||||
| CClientUIInterface* m_client_interface; | ||||||
| NetEventsInterface* m_msgproc; | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When Tor/onion is reachable, this computes
m_max_outbound_onionfromconnOptions.m_max_automatic_connectionswhile that option is still its default0, so the onion target is always initialized to0before the realnMaxConnectionsvalue is assigned on the next line. As a result the onion-only branch inThreadOpenConnections()never runs and existing outbound onion peers get no reserved protection, regressing the intended default of up to two onion outbound peers; assignm_max_automatic_connectionsfirst or compute fromnMaxConnections.Useful? React with 👍 / 👎.