Skip to content

Commit fad8c5b

Browse files
committed
net: allow unconnected headerannouncements only once
1 parent bdc5776 commit fad8c5b

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/net_processing.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static constexpr double BLOCK_DOWNLOAD_TIMEOUT_PER_PEER = 0.5;
130130
/** Maximum number of headers to announce when relaying blocks with headers message.*/
131131
static const unsigned int MAX_BLOCKS_TO_ANNOUNCE = 8;
132132
/** Maximum number of unconnecting headers announcements before DoS score */
133-
static const int MAX_NUM_UNCONNECTING_HEADERS_MSGS = 10;
133+
static const int MAX_NUM_UNCONNECTING_HEADERS_MSGS = 2;
134134
/** Minimum blocks required to signal NODE_NETWORK_LIMITED */
135135
static const unsigned int NODE_NETWORK_LIMITED_MIN_BLOCKS = 288;
136136
/** Window, in blocks, for connecting to NODE_NETWORK_LIMITED peers */
@@ -2544,8 +2544,7 @@ arith_uint256 PeerManagerImpl::GetAntiDoSWorkThreshold()
25442544
*
25452545
* We'll send a getheaders message in response to try to connect the chain.
25462546
*
2547-
* The peer can send up to MAX_NUM_UNCONNECTING_HEADERS_MSGS in a row that
2548-
* don't connect before given DoS points.
2547+
* Allow this only once.
25492548
*
25502549
* Once a headers message is received that is valid and does connect,
25512550
* m_num_unconnecting_headers_msgs gets reset back to 0.

test/functional/p2p_sendheaders.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def test_nonnull_locators(self, test_node, inv_node):
546546
blocks = []
547547
# Now we test that if we repeatedly don't send connecting headers, we
548548
# don't go into an infinite loop trying to get them to connect.
549-
MAX_NUM_UNCONNECTING_HEADERS_MSGS = 10
549+
MAX_NUM_UNCONNECTING_HEADERS_MSGS = 2
550550
for _ in range(MAX_NUM_UNCONNECTING_HEADERS_MSGS + 1):
551551
blocks.append(create_block(tip, create_coinbase(height), block_time))
552552
blocks[-1].solve()
@@ -568,7 +568,7 @@ def test_nonnull_locators(self, test_node, inv_node):
568568
blocks = blocks[2:]
569569

570570
# Now try to see how many unconnecting headers we can send
571-
# before we get disconnected. Should be 5*MAX_NUM_UNCONNECTING_HEADERS_MSGS
571+
# before we get disconnected. Should be MAX_NUM_UNCONNECTING_HEADERS_MSGS
572572
for i in range(MAX_NUM_UNCONNECTING_HEADERS_MSGS - 1):
573573
# Send a header that doesn't connect, check that we get a getheaders.
574574
with p2p_lock:

0 commit comments

Comments
 (0)