Skip to content

Commit b1a936d

Browse files
committed
[rpc] Remove deprecated "whitelisted" field from getpeerinfo
1 parent 094c3be commit b1a936d

File tree

5 files changed

+12
-52
lines changed

5 files changed

+12
-52
lines changed

src/net.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,6 @@ void CNode::copyStats(CNodeStats &stats, const std::vector<bool> &m_asmap)
599599
X(mapRecvBytesPerMsgCmd);
600600
X(nRecvBytes);
601601
}
602-
X(m_legacyWhitelisted);
603602
X(m_permissionFlags);
604603
if (m_tx_relay != nullptr) {
605604
LOCK(m_tx_relay->cs_feeFilter);
@@ -1122,8 +1121,6 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) {
11221121
CNode* pnode = new CNode(id, nodeServices, GetBestHeight(), hSocket, addr, CalculateKeyedNetGroup(addr), nonce, addr_bind, "", ConnectionType::INBOUND, inbound_onion);
11231122
pnode->AddRef();
11241123
pnode->m_permissionFlags = permissionFlags;
1125-
// If this flag is present, the user probably expect that RPC and QT report it as whitelisted (backward compatibility)
1126-
pnode->m_legacyWhitelisted = legacyWhitelisted;
11271124
pnode->m_prefer_evict = discouraged;
11281125
m_msgproc->InitializeNode(pnode);
11291126

src/net.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,6 @@ class CNodeStats
710710
uint64_t nRecvBytes;
711711
mapMsgCmdSize mapRecvBytesPerMsgCmd;
712712
NetPermissionFlags m_permissionFlags;
713-
bool m_legacyWhitelisted;
714713
int64_t m_ping_usec;
715714
int64_t m_ping_wait_usec;
716715
int64_t m_min_ping_usec;
@@ -891,8 +890,6 @@ class CNode
891890
bool HasPermission(NetPermissionFlags permission) const {
892891
return NetPermissions::HasFlag(m_permissionFlags, permission);
893892
}
894-
// This boolean is unusued in actual processing, only present for backward compatibility at RPC/QT level
895-
bool m_legacyWhitelisted{false};
896893
bool fClient{false}; // set by version message
897894
bool m_limited_node{false}; //after BIP159, set by version message
898895
/**

src/rpc/net.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ static RPCHelpMan getpeerinfo()
138138
{
139139
{RPCResult::Type::NUM, "n", "The heights of blocks we're currently asking from this peer"},
140140
}},
141-
{RPCResult::Type::BOOL, "whitelisted", /* optional */ true, "Whether the peer is whitelisted with default permissions\n"
142-
"(DEPRECATED, returned only if config option -deprecatedrpc=whitelisted is passed)"},
143141
{RPCResult::Type::ARR, "permissions", "Any special permissions that have been granted to this peer",
144142
{
145143
{RPCResult::Type::STR, "permission_type", Join(NET_PERMISSIONS_DOC, ",\n") + ".\n"},
@@ -231,10 +229,6 @@ static RPCHelpMan getpeerinfo()
231229
}
232230
obj.pushKV("inflight", heights);
233231
}
234-
if (IsDeprecatedRPCEnabled("whitelisted")) {
235-
// whitelisted is deprecated in v0.21 for removal in v0.22
236-
obj.pushKV("whitelisted", stats.m_legacyWhitelisted);
237-
}
238232
UniValue permissions(UniValue::VARR);
239233
for (const auto& permission : NetPermissions::ToStrings(stats.m_permissionFlags)) {
240234
permissions.push_back(permission);

test/functional/p2p_blocksonly.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def run_test(self):
5959

6060
self.log.info('Check that txs from peers with relay-permission are not rejected and relayed to others')
6161
self.log.info("Restarting node 0 with relay permission and blocksonly")
62-
self.restart_node(0, ["-persistmempool=0", "[email protected]", "-blocksonly", '-deprecatedrpc=whitelisted'])
62+
self.restart_node(0, ["-persistmempool=0", "[email protected]", "-blocksonly"])
6363
assert_equal(self.nodes[0].getrawmempool(), [])
6464
first_peer = self.nodes[0].add_p2p_connection(P2PInterface())
6565
second_peer = self.nodes[0].add_p2p_connection(P2PInterface())

test/functional/p2p_permissions.py

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -38,35 +38,24 @@ def run_test(self):
3838
# default permissions (no specific permissions)
3939
["-whitelist=127.0.0.1"],
4040
# Make sure the default values in the command line documentation match the ones here
41-
["relay", "noban", "mempool", "download"],
42-
True)
43-
44-
self.checkpermission(
45-
# check without deprecatedrpc=whitelisted
46-
["-whitelist=127.0.0.1"],
47-
# Make sure the default values in the command line documentation match the ones here
48-
["relay", "noban", "mempool", "download"],
49-
None)
41+
["relay", "noban", "mempool", "download"])
5042

5143
self.checkpermission(
5244
# no permission (even with forcerelay)
5345
["[email protected]", "-whitelistforcerelay=1"],
54-
[],
55-
False)
46+
[])
5647

5748
self.checkpermission(
5849
# relay permission removed (no specific permissions)
5950
["-whitelist=127.0.0.1", "-whitelistrelay=0"],
60-
["noban", "mempool", "download"],
61-
True)
51+
["noban", "mempool", "download"])
6252

6353
self.checkpermission(
6454
# forcerelay and relay permission added
6555
# Legacy parameter interaction which set whitelistrelay to true
6656
# if whitelistforcerelay is true
6757
["-whitelist=127.0.0.1", "-whitelistforcerelay"],
68-
["forcerelay", "relay", "noban", "mempool", "download"],
69-
True)
58+
["forcerelay", "relay", "noban", "mempool", "download"])
7059

7160
# Let's make sure permissions are merged correctly
7261
# For this, we need to use whitebind instead of bind
@@ -76,39 +65,28 @@ def run_test(self):
7665
self.checkpermission(
7766
7867
# Check parameter interaction forcerelay should activate relay
79-
["noban", "bloomfilter", "forcerelay", "relay", "download"],
80-
False)
68+
["noban", "bloomfilter", "forcerelay", "relay", "download"])
8169
self.replaceinconfig(1, "whitebind=bloomfilter,forcerelay@" + ip_port, "bind=127.0.0.1")
8270

8371
self.checkpermission(
8472
# legacy whitelistrelay should be ignored
8573
["-whitelist=noban,[email protected]", "-whitelistrelay"],
86-
["noban", "mempool", "download"],
87-
False)
88-
89-
self.checkpermission(
90-
# check without deprecatedrpc=whitelisted
91-
["-whitelist=noban,[email protected]", "-whitelistrelay"],
92-
["noban", "mempool", "download"],
93-
None)
74+
["noban", "mempool", "download"])
9475

9576
self.checkpermission(
9677
# legacy whitelistforcerelay should be ignored
9778
["-whitelist=noban,[email protected]", "-whitelistforcerelay"],
98-
["noban", "mempool", "download"],
99-
False)
79+
["noban", "mempool", "download"])
10080

10181
self.checkpermission(
10282
# missing mempool permission to be considered legacy whitelisted
10383
104-
["noban", "download"],
105-
False)
84+
["noban", "download"])
10685

10786
self.checkpermission(
10887
# all permission added
10988
110-
["forcerelay", "noban", "mempool", "bloomfilter", "relay", "download", "addr"],
111-
False)
89+
["forcerelay", "noban", "mempool", "bloomfilter", "relay", "download", "addr"])
11290

11391
self.stop_node(1)
11492
self.nodes[1].assert_start_raises_init_error(["[email protected]"], "Invalid P2P permission", match=ErrorMatch.PARTIAL_REGEX)
@@ -169,19 +147,13 @@ def check_tx_relay(self):
169147
reject_reason='Not relaying non-mempool transaction {} from forcerelay peer=0'.format(txid)
170148
)
171149

172-
def checkpermission(self, args, expectedPermissions, whitelisted):
173-
if whitelisted is not None:
174-
args = [*args, '-deprecatedrpc=whitelisted']
150+
def checkpermission(self, args, expectedPermissions):
175151
self.restart_node(1, args)
176152
self.connect_nodes(0, 1)
177153
peerinfo = self.nodes[1].getpeerinfo()[0]
178-
if whitelisted is None:
179-
assert 'whitelisted' not in peerinfo
180-
else:
181-
assert_equal(peerinfo['whitelisted'], whitelisted)
182154
assert_equal(len(expectedPermissions), len(peerinfo['permissions']))
183155
for p in expectedPermissions:
184-
if not p in peerinfo['permissions']:
156+
if p not in peerinfo['permissions']:
185157
raise AssertionError("Expected permissions %r is not granted." % p)
186158

187159
def replaceinconfig(self, nodeid, old, new):

0 commit comments

Comments
 (0)