Skip to content

Commit 1d6c6e9

Browse files
committed
Merge bitcoin/bitcoin#31633: net: Disconnect message follow-ups to #28521
551a094 net: Switch to DisconnectMsg in CConnman (Hodlinator) bbac176 net: Bring back log message when resetting socket (Hodlinator) 04b848e net: Specify context in disconnecting log message (Hodlinator) 0c4954a net_processing: Add missing use of DisconnectMsg (Hodlinator) Pull request description: - Add missing calls to `DisconnectMsg()` - bitcoin/bitcoin#28521 (comment) - Specify context when stopping nodes - bitcoin/bitcoin#28521 (comment) - Bring back log message when resetting socket in case new entrypoints are added - bitcoin/bitcoin#28521 (comment) - Use `DisconnectMsg()` in `CConnman` as well - bitcoin/bitcoin#28521 (comment) ACKs for top commit: Sjors: re-utACK 551a094 l0rinc: utACK 551a094 davidgumberg: Tested and Review ACK bitcoin/bitcoin@551a094 achow101: ACK 551a094 danielabrozzoni: ACK 551a094 Tree-SHA512: 95ab8e7436e20ca3abc949ea09697facb6fbeb19981ddc7e0bf294e7ec914e72cbf836c21184a2a887f04cb264f26daf5b0cbcbebc9db633a7b1672b4e488063
2 parents ad2f932 + 551a094 commit 1d6c6e9

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/net.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ void CNode::CloseSocketDisconnect()
558558
fDisconnect = true;
559559
LOCK(m_sock_mutex);
560560
if (m_sock) {
561+
LogDebug(BCLog::NET, "Resetting socket for peer=%d%s", GetId(), LogIP(fLogIPs));
561562
m_sock.reset();
562563
}
563564
m_i2p_sam_session.reset();
@@ -1706,7 +1707,7 @@ bool CConnman::AttemptToEvictConnection()
17061707
LOCK(m_nodes_mutex);
17071708
for (CNode* pnode : m_nodes) {
17081709
if (pnode->GetId() == *node_id_to_evict) {
1709-
LogDebug(BCLog::NET, "selected %s connection for eviction peer=%d; disconnecting\n", pnode->ConnectionTypeAsString(), pnode->GetId());
1710+
LogDebug(BCLog::NET, "selected %s connection for eviction, %s", pnode->ConnectionTypeAsString(), pnode->DisconnectMsg(fLogIPs));
17101711
pnode->fDisconnect = true;
17111712
return true;
17121713
}
@@ -3443,7 +3444,7 @@ void CConnman::StopNodes()
34433444
std::vector<CNode*> nodes;
34443445
WITH_LOCK(m_nodes_mutex, nodes.swap(m_nodes));
34453446
for (CNode* pnode : nodes) {
3446-
LogDebug(BCLog::NET, "%s\n", pnode->DisconnectMsg(fLogIPs));
3447+
LogDebug(BCLog::NET, "Stopping node, %s", pnode->DisconnectMsg(fLogIPs));
34473448
pnode->CloseSocketDisconnect();
34483449
DeleteNode(pnode);
34493450
}
@@ -3607,7 +3608,7 @@ bool CConnman::DisconnectNode(const std::string& strNode)
36073608
{
36083609
LOCK(m_nodes_mutex);
36093610
if (CNode* pnode = FindNode(strNode)) {
3610-
LogDebug(BCLog::NET, "disconnect by address%s matched peer=%d; disconnecting\n", (fLogIPs ? strprintf("=%s", strNode) : ""), pnode->GetId());
3611+
LogDebug(BCLog::NET, "disconnect by address%s match, %s", (fLogIPs ? strprintf("=%s", strNode) : ""), pnode->DisconnectMsg(fLogIPs));
36113612
pnode->fDisconnect = true;
36123613
return true;
36133614
}
@@ -3620,7 +3621,7 @@ bool CConnman::DisconnectNode(const CSubNet& subnet)
36203621
LOCK(m_nodes_mutex);
36213622
for (CNode* pnode : m_nodes) {
36223623
if (subnet.Match(pnode->addr)) {
3623-
LogDebug(BCLog::NET, "disconnect by subnet%s matched peer=%d; disconnecting\n", (fLogIPs ? strprintf("=%s", subnet.ToString()) : ""), pnode->GetId());
3624+
LogDebug(BCLog::NET, "disconnect by subnet%s match, %s", (fLogIPs ? strprintf("=%s", subnet.ToString()) : ""), pnode->DisconnectMsg(fLogIPs));
36243625
pnode->fDisconnect = true;
36253626
disconnected = true;
36263627
}
@@ -3638,7 +3639,7 @@ bool CConnman::DisconnectNode(NodeId id)
36383639
LOCK(m_nodes_mutex);
36393640
for(CNode* pnode : m_nodes) {
36403641
if (id == pnode->GetId()) {
3641-
LogDebug(BCLog::NET, "disconnect by id peer=%d; disconnecting\n", pnode->GetId());
3642+
LogDebug(BCLog::NET, "disconnect by id, %s", pnode->DisconnectMsg(fLogIPs));
36423643
pnode->fDisconnect = true;
36433644
return true;
36443645
}

src/net_processing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4205,7 +4205,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
42054205

42064206
if (msg_type == NetMsgType::TX) {
42074207
if (RejectIncomingTxs(pfrom)) {
4208-
LogDebug(BCLog::NET, "transaction sent in violation of protocol peer=%d\n", pfrom.GetId());
4208+
LogDebug(BCLog::NET, "transaction sent in violation of protocol, %s", pfrom.DisconnectMsg(fLogIPs));
42094209
pfrom.fDisconnect = true;
42104210
return;
42114211
}
@@ -5207,7 +5207,7 @@ void PeerManagerImpl::MaybeSendPing(CNode& node_to, Peer& peer, std::chrono::mic
52075207
{
52085208
// The ping timeout is using mocktime. To disable the check during
52095209
// testing, increase -peertimeout.
5210-
LogDebug(BCLog::NET, "ping timeout: %fs peer=%d\n", 0.000001 * count_microseconds(now - peer.m_ping_start.load()), peer.m_id);
5210+
LogDebug(BCLog::NET, "ping timeout: %fs, %s", 0.000001 * count_microseconds(now - peer.m_ping_start.load()), node_to.DisconnectMsg(fLogIPs));
52115211
node_to.fDisconnect = true;
52125212
return;
52135213
}

test/functional/p2p_blocksonly.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def check_p2p_tx_violation(self):
115115
self.log.info('Check that txs from P2P are rejected and result in disconnect')
116116
spendtx = self.miniwallet.create_self_transfer()
117117

118-
with self.nodes[0].assert_debug_log(['transaction sent in violation of protocol peer=0']):
118+
with self.nodes[0].assert_debug_log(['transaction sent in violation of protocol, disconnecting peer=0']):
119119
self.nodes[0].p2ps[0].send_message(msg_tx(spendtx['tx']))
120120
self.nodes[0].p2ps[0].wait_for_disconnect()
121121
assert_equal(self.nodes[0].getmempoolinfo()['size'], 0)

0 commit comments

Comments
 (0)