refactoring: [Net Processing] Follow-ups to #21160 #24692
pull jnewbery wants to merge 3 commits into bitcoin:master from jnewbery:202202_21160_followups changing 2 files +22 −12-
jnewbery commented at 8:18 am on March 28, 2022: member#21160 ([net/net processing]: Move tx inventory into net_processing) had some unaddressed review comments when it was merged. This branch addresses those comments.
-
net_processing: move CNode data access out of lock
CNode::m_relays_tx and CNode::m_bloom_filter_loaded access don't require the Peer::TxRelay::m_bloom_filter_mutex lock, so move them out of the lock scope. See https://github.com/bitcoin/bitcoin/pull/21160#discussion_r736785417 and https://github.com/bitcoin/bitcoin/pull/21160#discussion_r736785662.
-
fanquake added the label P2P on Mar 28, 2022
-
fanquake commented at 8:32 am on March 28, 2022: membercc @dergoegge
-
in src/net_processing.cpp:450 in 2432ec4af8 outdated
446@@ -447,7 +447,7 @@ class PeerManagerImpl final : public PeerManager 447 void RelayAddress(NodeId originator, const CAddress& addr, bool fReachable); 448 449 /** Send `feefilter` message. */ 450- void MaybeSendFeefilter(CNode& node, Peer& peer, std::chrono::microseconds current_time); 451+ void MaybeSendFeefilter(CNode& node, Peer::TxRelay* tx_relay, std::chrono::microseconds current_time);
ajtowns commented at 9:08 am on March 28, 2022:Perhaps pass inPeer:TxRelay&
and leave it to the caller to checktx_relay != nullptr
?
jnewbery commented at 2:56 pm on March 29, 2022:Reverted change so this passes in aPeer&
.in src/net_processing.cpp:1239 in 2432ec4af8 outdated
1235@@ -1236,7 +1236,7 @@ void PeerManagerImpl::InitializeNode(CNode *pnode) 1236 m_peer_map.emplace_hint(m_peer_map.end(), nodeid, peer); 1237 } 1238 if (!pnode->IsInboundConn()) { 1239- PushNodeVersion(*pnode, *peer); 1240+ PushNodeVersion(*pnode, peer->m_tx_relay != nullptr);
dergoegge commented at 11:33 am on March 28, 2022:0 PushNodeVersion(*pnode, peer->m_tx_relay == nullptr);
jnewbery commented at 8:27 pm on March 28, 2022:Fixed. Thanks!in src/net_processing.cpp:2678 in 2432ec4af8 outdated
2674@@ -2675,7 +2675,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, 2675 // Inbound peers send us their version message when they connect. 2676 // We send our version message in response. 2677 if (pfrom.IsInboundConn()) { 2678- PushNodeVersion(pfrom, *peer); 2679+ PushNodeVersion(pfrom, peer->m_tx_relay != nullptr);
dergoegge commented at 11:33 am on March 28, 2022:0 PushNodeVersion(pfrom, peer->m_tx_relay == nullptr);
jnewbery commented at 8:27 pm on March 28, 2022:Fixed. Thanks!dergoegge changes_requesteddergoegge commented at 11:40 am on March 28, 2022: memberThe tests are failing because the wrong value is being passed toPushNodeVersion
for theblock_relay_only
param.jnewbery force-pushed on Mar 28, 2022jnewbery commented at 8:27 pm on March 28, 2022: memberThe tests are failing because the wrong value is being passed to PushNodeVersion for the block_relay_only param.
Oops. Now fixed. Thank you!
in src/net_processing.cpp:2678 in 08071168b4 outdated
2674@@ -2675,7 +2675,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, 2675 // Inbound peers send us their version message when they connect. 2676 // We send our version message in response. 2677 if (pfrom.IsInboundConn()) { 2678- PushNodeVersion(pfrom, *peer); 2679+ PushNodeVersion(pfrom, peer->m_tx_relay == nullptr);
ajtowns commented at 10:50 pm on March 28, 2022:Duplicatingpeer->m_tx_relay == nullptr
at both call sites rather than just leaving it in the function seems kind of backwards? Also seems demonstrably a bit bug-prone, presumably warranting a/*block_relay_only=*/
at least.
MarcoFalke commented at 9:08 am on March 29, 2022:Alternatively, pass the tx_relay pointer?
jnewbery commented at 2:56 pm on March 29, 2022:Reverted change so this passes in aconst Peer&
MarcoFalke commented at 9:08 am on March 29, 2022: memberSee also suggestion in #21160 (review)DrahtBot commented at 2:28 pm on March 29, 2022: memberThe following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Conflicts
Reviewers, this pull request conflicts with the following ones:
- #24474 (Additional thread safety annotations for CNode/Peer by ajtowns)
- #22778 (net processing: Reduce resource usage for inbound block-relay-only connections by jnewbery)
- #21527 (net_processing: lock clean up by ajtowns)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
[net processing] PushNodeVersion() takes a const Peer&
The peer object is not mutated by PushNodeVersion, so pass a const reference
[fuzz] Assert that Peer.m_tx_relay.m_relay_txs has been set correctly a40978dcbdjnewbery commented at 2:55 pm on March 29, 2022: memberSee also suggestion in #21160 (review)
Added.
I’ve removed the net_processing: MaybeSendFeeFilter() takes a Peer::TxFilter* and net_processing: PushNodeVersion() takes a bool instead of a Peer& commits. There doesn’t seem to be agreement on what should be passed down to these functions, and in the absence of agreement, continuing to pass just a reference to the
Peer
object seems fine. I have however changed the function signature ofPushNodeVersion()
to take a const reference to Peer. That seems like an uncontroversial improvement.MarcoFalke commented at 3:17 pm on March 29, 2022: memberI think you forgot to force push your local branch?jnewbery force-pushed on Mar 29, 2022MarcoFalke renamed this:
[Net Processing] Follow-ups to #21160
refactoring: [Net Processing] Follow-ups to #21160
on Mar 29, 2022MarcoFalke added the label Refactoring on Mar 29, 2022MarcoFalke commented at 3:28 pm on March 29, 2022: memberreview ACK a40978dcbd6608695bc7f5191c4d0a3e48cbca0bdergoegge commented at 4:08 pm on March 29, 2022: memberACK a40978dcbd6608695bc7f5191c4d0a3e48cbca0bajtowns commented at 3:08 am on March 30, 2022: memberACK a40978dcbd6608695bc7f5191c4d0a3e48cbca0bfanquake merged this on Mar 30, 2022fanquake closed this on Mar 30, 2022
jnewbery deleted the branch on Mar 30, 2022sidhujag referenced this in commit 7a50d84190 on Apr 3, 2022DrahtBot locked this on Mar 30, 2023
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-21 21:12 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me