Skip to content

Commit ed9a2a3

Browse files
committed
Merge #16631: net: The default whitelistrelay should be true
3b05f0f Reformat p2p_permissions.py (nicolas.dorier) ce7eac3 [Fix] The default whitelistrelay should be true (nicolas.dorier) Pull request description: I thought `whitelistrelay` default was `false` when it is `true`. The root of the issue come from the fact that all references to `DEFAULT_` are not in the scope of this file, so hard coding of default values are used everywhere in `net.cpp`. I think that in a separate PR we should fix that more fundamentally everywhere. ACKs for top commit: promag: ACK 3b05f0f. Sjors: re-ACK 3b05f0f Tree-SHA512: f4a75f986fa2adf1a5f1c91605e0d261f7ac5ac8535fb05437d83b8392dbcf5cc1a47d755adcf8ad8dc67a88de28060187200fd3ce06545261a5c7ec0fea831a
2 parents 91ed1b3 + 3b05f0f commit ed9a2a3

File tree

5 files changed

+43
-36
lines changed

5 files changed

+43
-36
lines changed

src/net.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,8 +909,8 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) {
909909
bool legacyWhitelisted = false;
910910
if (NetPermissions::HasFlag(permissionFlags, NetPermissionFlags::PF_ISIMPLICIT)) {
911911
NetPermissions::ClearFlag(permissionFlags, PF_ISIMPLICIT);
912-
if (gArgs.GetBoolArg("-whitelistforcerelay", false)) NetPermissions::AddFlag(permissionFlags, PF_FORCERELAY);
913-
if (gArgs.GetBoolArg("-whitelistrelay", false)) NetPermissions::AddFlag(permissionFlags, PF_RELAY);
912+
if (gArgs.GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY)) NetPermissions::AddFlag(permissionFlags, PF_FORCERELAY);
913+
if (gArgs.GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY)) NetPermissions::AddFlag(permissionFlags, PF_RELAY);
914914
NetPermissions::AddFlag(permissionFlags, PF_MEMPOOL);
915915
NetPermissions::AddFlag(permissionFlags, PF_NOBAN);
916916
legacyWhitelisted = true;

src/net.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ class CScheduler;
4040
class CNode;
4141
class BanMan;
4242

43+
/** Default for -whitelistrelay. */
44+
static const bool DEFAULT_WHITELISTRELAY = true;
45+
/** Default for -whitelistforcerelay. */
46+
static const bool DEFAULT_WHITELISTFORCERELAY = false;
47+
4348
/** Time between pings automatically sent out for latency probing and keepalive (in seconds). */
4449
static const int PING_INTERVAL = 2 * 60;
4550
/** Time after which to disconnect, after waiting for a ping response (or inactivity). */

src/validation.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ struct DisconnectedBlockTransactions;
5050
struct PrecomputedTransactionData;
5151
struct LockPoints;
5252

53-
/** Default for -whitelistrelay. */
54-
static const bool DEFAULT_WHITELISTRELAY = true;
55-
/** Default for -whitelistforcerelay. */
56-
static const bool DEFAULT_WHITELISTFORCERELAY = false;
5753
/** Default for -minrelaytxfee, minimum relay fee for transactions */
5854
static const unsigned int DEFAULT_MIN_RELAY_TX_FEE = 1000;
5955
/** Default for -limitancestorcount, max number of in-mempool ancestors */

test/functional/p2p_permissions.py

100644100755
Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,54 +23,60 @@ def set_test_params(self):
2323

2424
def run_test(self):
2525
self.checkpermission(
26-
# relay permission added
27-
["-whitelist=127.0.0.1", "-whitelistrelay"],
28-
["relay", "noban", "mempool"],
29-
True)
26+
# default permissions (no specific permissions)
27+
["-whitelist=127.0.0.1"],
28+
["relay", "noban", "mempool"],
29+
True)
3030

3131
self.checkpermission(
32-
# forcerelay and relay permission added
33-
# Legacy parameter interaction which set whitelistrelay to true
34-
# if whitelistforcerelay is true
35-
["-whitelist=127.0.0.1", "-whitelistforcerelay"],
36-
["forcerelay", "relay", "noban", "mempool"],
37-
True)
32+
# relay permission removed (no specific permissions)
33+
["-whitelist=127.0.0.1", "-whitelistrelay=0"],
34+
["noban", "mempool"],
35+
True)
36+
37+
self.checkpermission(
38+
# forcerelay and relay permission added
39+
# Legacy parameter interaction which set whitelistrelay to true
40+
# if whitelistforcerelay is true
41+
["-whitelist=127.0.0.1", "-whitelistforcerelay"],
42+
["forcerelay", "relay", "noban", "mempool"],
43+
True)
3844

3945
# Let's make sure permissions are merged correctly
4046
# For this, we need to use whitebind instead of bind
4147
# by modifying the configuration file.
4248
ip_port = "127.0.0.1:{}".format(p2p_port(1))
4349
self.replaceinconfig(1, "bind=127.0.0.1", "whitebind=bloomfilter,forcerelay@" + ip_port)
4450
self.checkpermission(
45-
46-
# Check parameter interaction forcerelay should activate relay
47-
["noban", "bloomfilter", "forcerelay", "relay" ],
48-
False)
51+
52+
# Check parameter interaction forcerelay should activate relay
53+
["noban", "bloomfilter", "forcerelay", "relay" ],
54+
False)
4955
self.replaceinconfig(1, "whitebind=bloomfilter,forcerelay@" + ip_port, "bind=127.0.0.1")
5056

5157
self.checkpermission(
52-
# legacy whitelistrelay should be ignored
53-
["-whitelist=noban,[email protected]", "-whitelistrelay"],
54-
["noban", "mempool"],
55-
False)
58+
# legacy whitelistrelay should be ignored
59+
["-whitelist=noban,[email protected]", "-whitelistrelay"],
60+
["noban", "mempool"],
61+
False)
5662

5763
self.checkpermission(
58-
# legacy whitelistforcerelay should be ignored
59-
["-whitelist=noban,[email protected]", "-whitelistforcerelay"],
60-
["noban", "mempool"],
61-
False)
64+
# legacy whitelistforcerelay should be ignored
65+
["-whitelist=noban,[email protected]", "-whitelistforcerelay"],
66+
["noban", "mempool"],
67+
False)
6268

6369
self.checkpermission(
64-
# missing mempool permission to be considered legacy whitelisted
65-
66-
["noban"],
67-
False)
70+
# missing mempool permission to be considered legacy whitelisted
71+
72+
["noban"],
73+
False)
6874

6975
self.checkpermission(
70-
# all permission added
71-
72-
["forcerelay", "noban", "mempool", "bloomfilter", "relay"],
73-
False)
76+
# all permission added
77+
78+
["forcerelay", "noban", "mempool", "bloomfilter", "relay"],
79+
False)
7480

7581
self.stop_node(1)
7682
self.nodes[1].assert_start_raises_init_error(["[email protected]"], "Invalid P2P permission", match=ErrorMatch.PARTIAL_REGEX)

test/functional/rpc_setban.py

100644100755
File mode changed.

0 commit comments

Comments
 (0)