From 6548ba68e85298c01b983c2392aab86e88e447d3 Mon Sep 17 00:00:00 2001 From: Martin Zumsande Date: Fri, 27 Jan 2023 15:28:11 -0500 Subject: [PATCH 1/2] test: fix intermittent errors in p2p_ibd_stalling.py Using is_connected instead of num_test_p2p_connections ensures that python has taken notice that the p2p was disconnected. --- test/functional/p2p_ibd_stalling.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/functional/p2p_ibd_stalling.py b/test/functional/p2p_ibd_stalling.py index 9bd07be7b91..aca98ceb3f7 100755 --- a/test/functional/p2p_ibd_stalling.py +++ b/test/functional/p2p_ibd_stalling.py @@ -115,7 +115,7 @@ class P2PIBDStallingTest(BitcoinTestFramework): self.mocktime += 2 node.setmocktime(self.mocktime) - self.wait_until(lambda: node.num_test_p2p_connections() == NUM_PEERS - 2) + self.wait_until(lambda: sum(x.is_connected for x in node.p2ps) == NUM_PEERS - 2) self.wait_until(lambda: self.is_block_requested(peers, stall_block)) self.all_sync_send_with_ping(peers) @@ -128,7 +128,7 @@ class P2PIBDStallingTest(BitcoinTestFramework): self.mocktime += 2 node.setmocktime(self.mocktime) - self.wait_until(lambda: node.num_test_p2p_connections() == NUM_PEERS - 3) + self.wait_until(lambda: sum(x.is_connected for x in node.p2ps) == NUM_PEERS - 3) self.wait_until(lambda: self.is_block_requested(peers, stall_block)) self.all_sync_send_with_ping(peers) From b2a1e477444bfb90328b353e89967ace6ef10918 Mon Sep 17 00:00:00 2001 From: Martin Zumsande Date: Fri, 27 Jan 2023 15:46:20 -0500 Subject: [PATCH 2/2] net_processing: simplify logging statement Also use count_seconds() instead of count() for type safety. --- src/net_processing.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index d496cad3175..a659300a0d3 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1845,7 +1845,7 @@ void PeerManagerImpl::BlockConnected(const std::shared_ptr& pblock if (stalling_timeout != BLOCK_STALLING_TIMEOUT_DEFAULT) { const auto new_timeout = std::max(std::chrono::duration_cast(stalling_timeout * 0.85), BLOCK_STALLING_TIMEOUT_DEFAULT); if (m_block_stalling_timeout.compare_exchange_strong(stalling_timeout, new_timeout)) { - LogPrint(BCLog::NET, "Decreased stalling timeout to %d seconds\n", new_timeout.count()); + LogPrint(BCLog::NET, "Decreased stalling timeout to %d seconds\n", count_seconds(new_timeout)); } } } @@ -5736,7 +5736,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto) // bandwidth is insufficient. const auto new_timeout = std::min(2 * stalling_timeout, BLOCK_STALLING_TIMEOUT_MAX); if (stalling_timeout != new_timeout && m_block_stalling_timeout.compare_exchange_strong(stalling_timeout, new_timeout)) { - LogPrint(BCLog::NET, "Increased stalling timeout temporarily to %d seconds\n", m_block_stalling_timeout.load().count()); + LogPrint(BCLog::NET, "Increased stalling timeout temporarily to %d seconds\n", count_seconds(new_timeout)); } return true; }