Skip to content

Commit 560dea9

Browse files
author
MarcoFalke
committed
Merge #19770: RPC: getpeerinfo: Deprecate "whitelisted" field (replaced by "permissions")
5b57dc5 RPC: getpeerinfo: Wrap long help line for bytesrecv_per_msg (Luke Dashjr) d681a28 RPC: getpeerinfo: Deprecate "whitelisted" field (replaced by "permissions") (Luke Dashjr) Pull request description: If we were going to continue support for "whitelisted", we should have probably made it true if any permission flag was set, rather than only if "default permissions" were used. This corrects the description, and deprecates it. ACKs for top commit: laanwj: ACK 5b57dc5 Tree-SHA512: a2e2137f8be8110357c1b2fef2c923fa8c7c4a49b0b2b3a2d78aedf12f8ed5cc7e140018a21b37e6ec7770ed4007542aeef7ad4558973901b107e8e0f81d6003
2 parents e3b474c + 5b57dc5 commit 560dea9

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

src/rpc/net.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ static RPCHelpMan getpeerinfo()
127127
{
128128
{RPCResult::Type::NUM, "n", "The heights of blocks we're currently asking from this peer"},
129129
}},
130-
{RPCResult::Type::BOOL, "whitelisted", "Whether the peer is whitelisted"},
130+
{RPCResult::Type::BOOL, "whitelisted", /* optional */ true, "Whether the peer is whitelisted with default permissions\n"
131+
"(DEPRECATED, returned only if config option -deprecatedrpc=whitelisted is passed)"},
131132
{RPCResult::Type::NUM, "minfeefilter", "The minimum fee rate for transactions this peer accepts"},
132133
{RPCResult::Type::OBJ_DYN, "bytessent_per_msg", "",
133134
{
@@ -139,7 +140,8 @@ static RPCHelpMan getpeerinfo()
139140
{
140141
{RPCResult::Type::NUM, "msg", "The total bytes received aggregated by message type\n"
141142
"When a message type is not listed in this json object, the bytes received are 0.\n"
142-
"Only known message types can appear as keys in the object and all bytes received of unknown message types are listed under '"+NET_MESSAGE_COMMAND_OTHER+"'."}
143+
"Only known message types can appear as keys in the object and all bytes received\n"
144+
"of unknown message types are listed under '"+NET_MESSAGE_COMMAND_OTHER+"'."}
143145
}},
144146
}},
145147
}},
@@ -216,7 +218,10 @@ static RPCHelpMan getpeerinfo()
216218
}
217219
obj.pushKV("inflight", heights);
218220
}
219-
obj.pushKV("whitelisted", stats.m_legacyWhitelisted);
221+
if (IsDeprecatedRPCEnabled("whitelisted")) {
222+
// whitelisted is deprecated in v0.21 for removal in v0.22
223+
obj.pushKV("whitelisted", stats.m_legacyWhitelisted);
224+
}
220225
UniValue permissions(UniValue::VARR);
221226
for (const auto& permission : NetPermissions::ToStrings(stats.m_permissionFlags)) {
222227
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"])
62+
self.restart_node(0, ["-persistmempool=0", "[email protected]", "-blocksonly", '-deprecatedrpc=whitelisted'])
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: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ def run_test(self):
4242
["relay", "noban", "mempool", "download"],
4343
True)
4444

45+
self.checkpermission(
46+
# check without deprecatedrpc=whitelisted
47+
["-whitelist=127.0.0.1"],
48+
# Make sure the default values in the command line documentation match the ones here
49+
["relay", "noban", "mempool", "download"],
50+
None)
51+
4552
self.checkpermission(
4653
# no permission (even with forcerelay)
4754
["[email protected]", "-whitelistforcerelay=1"],
@@ -80,6 +87,12 @@ def run_test(self):
8087
["noban", "mempool", "download"],
8188
False)
8289

90+
self.checkpermission(
91+
# check without deprecatedrpc=whitelisted
92+
["-whitelist=noban,[email protected]", "-whitelistrelay"],
93+
["noban", "mempool", "download"],
94+
None)
95+
8396
self.checkpermission(
8497
# legacy whitelistforcerelay should be ignored
8598
["-whitelist=noban,[email protected]", "-whitelistforcerelay"],
@@ -149,10 +162,15 @@ def check_tx_relay(self):
149162
)
150163

151164
def checkpermission(self, args, expectedPermissions, whitelisted):
165+
if whitelisted is not None:
166+
args = [*args, '-deprecatedrpc=whitelisted']
152167
self.restart_node(1, args)
153168
connect_nodes(self.nodes[0], 1)
154169
peerinfo = self.nodes[1].getpeerinfo()[0]
155-
assert_equal(peerinfo['whitelisted'], whitelisted)
170+
if whitelisted is None:
171+
assert 'whitelisted' not in peerinfo
172+
else:
173+
assert_equal(peerinfo['whitelisted'], whitelisted)
156174
assert_equal(len(expectedPermissions), len(peerinfo['permissions']))
157175
for p in expectedPermissions:
158176
if not p in peerinfo['permissions']:

0 commit comments

Comments
 (0)