Skip to content

Commit 1d4024b

Browse files
committed
net: remove -banscore configuration option
1 parent 42fe6aa commit 1d4024b

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

doc/release-notes.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ Build System
9999
Updated settings
100100
----------------
101101

102+
- The `-banscore` configuration option, which modified the default threshold for
103+
disconnecting and discouraging misbehaving peers, has been removed as part of
104+
changes in this release to the handling of misbehaving peers. Refer to the
105+
section, "Changes regarding misbehaving peers", for details. (#19464)
106+
102107
- The `-debug=db` logging category, which was deprecated in 0.20 and replaced by
103108
`-debug=walletdb` to distinguish it from `coindb`, has been removed. (#19202)
104109

src/init.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,6 @@ void SetupServerArgs(NodeContext& node)
431431

432432
gArgs.AddArg("-addnode=<ip>", "Add a node to connect to and attempt to keep the connection open (see the `addnode` RPC command help for more info). This option can be specified multiple times to add multiple nodes.", ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::CONNECTION);
433433
gArgs.AddArg("-asmap=<file>", strprintf("Specify asn mapping used for bucketing of the peers (default: %s). Relative paths will be prefixed by the net-specific datadir location.", DEFAULT_ASMAP_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
434-
gArgs.AddArg("-banscore=<n>", strprintf("Threshold for disconnecting and discouraging misbehaving peers (default: %u)", DEFAULT_BANSCORE_THRESHOLD), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
435434
gArgs.AddArg("-bantime=<n>", strprintf("Default duration (in seconds) of manually configured bans (default: %u)", DEFAULT_MISBEHAVING_BANTIME), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
436435
gArgs.AddArg("-bind=<addr>", "Bind to given address and always listen on it. Use [host]:port notation for IPv6", ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::CONNECTION);
437436
gArgs.AddArg("-connect=<ip>", "Connect only to the specified node; -noconnect disables automatic connections (the rules for this peer are the same as for -addnode). This option can be specified multiple times to connect to multiple nodes.", ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::CONNECTION);

src/net_processing.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,8 @@ unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans)
10161016
}
10171017

10181018
/**
1019-
* Increment peer's misbehavior score. If the new value surpasses banscore (specified on startup or by default), mark node to be discouraged, meaning the peer might be disconnected & added to the discouragement filter.
1019+
* Increment peer's misbehavior score. If the new value >= DEFAULT_BANSCORE_THRESHOLD, mark the node
1020+
* to be discouraged, meaning the peer might be disconnected and added to the discouragement filter.
10201021
*/
10211022
void Misbehaving(NodeId pnode, int howmuch, const std::string& message) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
10221023
{
@@ -1028,9 +1029,8 @@ void Misbehaving(NodeId pnode, int howmuch, const std::string& message) EXCLUSIV
10281029
return;
10291030

10301031
state->nMisbehavior += howmuch;
1031-
int banscore = gArgs.GetArg("-banscore", DEFAULT_BANSCORE_THRESHOLD);
10321032
std::string message_prefixed = message.empty() ? "" : (": " + message);
1033-
if (state->nMisbehavior >= banscore && state->nMisbehavior - howmuch < banscore)
1033+
if (state->nMisbehavior >= DEFAULT_BANSCORE_THRESHOLD && state->nMisbehavior - howmuch < DEFAULT_BANSCORE_THRESHOLD)
10341034
{
10351035
LogPrint(BCLog::NET, "%s: %s peer=%d (%d -> %d) DISCOURAGE THRESHOLD EXCEEDED%s\n", __func__, state->name, pnode, state->nMisbehavior-howmuch, state->nMisbehavior, message_prefixed);
10361036
state->m_should_discourage = true;

src/test/denialofservice_tests.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ BOOST_AUTO_TEST_CASE(DoS_banning)
232232
dummyNode1.fSuccessfullyConnected = true;
233233
{
234234
LOCK(cs_main);
235-
Misbehaving(dummyNode1.GetId(), 100); // Should get banned
235+
Misbehaving(dummyNode1.GetId(), DEFAULT_BANSCORE_THRESHOLD); // Should get banned
236236
}
237237
{
238238
LOCK2(cs_main, dummyNode1.cs_sendProcessing);
@@ -279,7 +279,6 @@ BOOST_AUTO_TEST_CASE(DoS_banscore)
279279
auto peerLogic = MakeUnique<PeerLogicValidation>(connman.get(), banman.get(), *m_node.scheduler, *m_node.chainman, *m_node.mempool);
280280

281281
banman->ClearBanned();
282-
gArgs.ForceSetArg("-banscore", "111"); // because 11 is my favorite number
283282
CAddress addr1(ip(0xa0b0c001), NODE_NONE);
284283
CNode dummyNode1(id++, NODE_NETWORK, 0, INVALID_SOCKET, addr1, 3, 1, CAddress(), "", true);
285284
dummyNode1.SetSendVersion(PROTOCOL_VERSION);
@@ -288,7 +287,7 @@ BOOST_AUTO_TEST_CASE(DoS_banscore)
288287
dummyNode1.fSuccessfullyConnected = true;
289288
{
290289
LOCK(cs_main);
291-
Misbehaving(dummyNode1.GetId(), 100);
290+
Misbehaving(dummyNode1.GetId(), DEFAULT_BANSCORE_THRESHOLD - 11);
292291
}
293292
{
294293
LOCK2(cs_main, dummyNode1.cs_sendProcessing);
@@ -313,7 +312,6 @@ BOOST_AUTO_TEST_CASE(DoS_banscore)
313312
BOOST_CHECK(peerLogic->SendMessages(&dummyNode1));
314313
}
315314
BOOST_CHECK(banman->IsDiscouraged(addr1));
316-
gArgs.ForceSetArg("-banscore", ToString(DEFAULT_BANSCORE_THRESHOLD));
317315

318316
bool dummy;
319317
peerLogic->FinalizeNode(dummyNode1.GetId(), dummy);
@@ -338,7 +336,7 @@ BOOST_AUTO_TEST_CASE(DoS_bantime)
338336

339337
{
340338
LOCK(cs_main);
341-
Misbehaving(dummyNode.GetId(), 100);
339+
Misbehaving(dummyNode.GetId(), DEFAULT_BANSCORE_THRESHOLD);
342340
}
343341
{
344342
LOCK2(cs_main, dummyNode.cs_sendProcessing);

src/validation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static const int64_t DEFAULT_MAX_TIP_AGE = 24 * 60 * 60;
7474
static const bool DEFAULT_CHECKPOINTS_ENABLED = true;
7575
static const bool DEFAULT_TXINDEX = false;
7676
static const char* const DEFAULT_BLOCKFILTERINDEX = "0";
77-
static const unsigned int DEFAULT_BANSCORE_THRESHOLD = 100;
77+
static const int DEFAULT_BANSCORE_THRESHOLD = 100;
7878
/** Default for -persistmempool */
7979
static const bool DEFAULT_PERSIST_MEMPOOL = true;
8080
/** Default for using fee filter */

test/functional/p2p_leak.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
wait_until,
2727
)
2828

29-
banscore = 10
29+
DEFAULT_BANSCORE_THRESHOLD = 100
3030

3131

3232
class CLazyNode(P2PInterface):
@@ -70,7 +70,7 @@ class CNodeNoVersionBan(CLazyNode):
7070
# NOTE: implementation-specific check here. Remove if bitcoind ban behavior changes
7171
def on_open(self):
7272
super().on_open()
73-
for i in range(banscore):
73+
for _ in range(DEFAULT_BANSCORE_THRESHOLD):
7474
self.send_message(msg_verack())
7575

7676
# Node that never sends a version. This one just sits idle and hopes to receive
@@ -106,7 +106,6 @@ def on_version(self, msg):
106106
class P2PLeakTest(BitcoinTestFramework):
107107
def set_test_params(self):
108108
self.num_nodes = 1
109-
self.extra_args = [['-banscore=' + str(banscore)]]
110109

111110
def run_test(self):
112111
no_version_bannode = self.nodes[0].add_p2p_connection(CNodeNoVersionBan(), send_version=False, wait_for_verack=False)

0 commit comments

Comments
 (0)