RPC: getpeerinfo: Deprecate "whitelisted" field (replaced by "permissions")
This commit is contained in:
1 parent
99a1d572ea
commit
d681a28219
3 files changed
+26
-4
No files matched your search
+6
-2
@@ -127,7 +127,8 @@ static RPCHelpMan getpeerinfo()
|
|||||||
{
|
{
|
||||||
{RPCResult::Type::NUM, "n", "The heights of blocks we're currently asking from this peer"},
|
{RPCResult::Type::NUM, "n", "The heights of blocks we're currently asking from this peer"},
|
||||||
}},
|
}},
|
||||||
{RPCResult::Type::BOOL, "whitelisted", "Whether the peer is whitelisted"},
|
{RPCResult::Type::BOOL, "whitelisted", /* optional */ true, "Whether the peer is whitelisted with default permissions\n"
|
||||||
|
"(DEPRECATED, returned only if config option -deprecatedrpc=whitelisted is passed)"},
|
||||||
{RPCResult::Type::NUM, "minfeefilter", "The minimum fee rate for transactions this peer accepts"},
|
{RPCResult::Type::NUM, "minfeefilter", "The minimum fee rate for transactions this peer accepts"},
|
||||||
{RPCResult::Type::OBJ_DYN, "bytessent_per_msg", "",
|
{RPCResult::Type::OBJ_DYN, "bytessent_per_msg", "",
|
||||||
{
|
{
|
||||||
@@ -216,7 +217,10 @@ static RPCHelpMan getpeerinfo()
|
|||||||
}
|
}
|
||||||
obj.pushKV("inflight", heights);
|
obj.pushKV("inflight", heights);
|
||||||
}
|
}
|
||||||
obj.pushKV("whitelisted", stats.m_legacyWhitelisted);
|
if (IsDeprecatedRPCEnabled("whitelisted")) {
|
||||||
|
// whitelisted is deprecated in v0.21 for removal in v0.22
|
||||||
|
obj.pushKV("whitelisted", stats.m_legacyWhitelisted);
|
||||||
|
}
|
||||||
UniValue permissions(UniValue::VARR);
|
UniValue permissions(UniValue::VARR);
|
||||||
for (const auto& permission : NetPermissions::ToStrings(stats.m_permissionFlags)) {
|
for (const auto& permission : NetPermissions::ToStrings(stats.m_permissionFlags)) {
|
||||||
permissions.push_back(permission);
|
permissions.push_back(permission);
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class P2PBlocksOnly(BitcoinTestFramework):
|
|||||||
|
|
||||||
self.log.info('Check that txs from peers with relay-permission are not rejected and relayed to others')
|
self.log.info('Check that txs from peers with relay-permission are not rejected and relayed to others')
|
||||||
self.log.info("Restarting node 0 with relay permission and blocksonly")
|
self.log.info("Restarting node 0 with relay permission and blocksonly")
|
||||||
self.restart_node(0, ["-persistmempool=0", "-whitelist=relay@127.0.0.1", "-blocksonly"])
|
self.restart_node(0, ["-persistmempool=0", "-whitelist=relay@127.0.0.1", "-blocksonly", '-deprecatedrpc=whitelisted'])
|
||||||
assert_equal(self.nodes[0].getrawmempool(), [])
|
assert_equal(self.nodes[0].getrawmempool(), [])
|
||||||
first_peer = self.nodes[0].add_p2p_connection(P2PInterface())
|
first_peer = self.nodes[0].add_p2p_connection(P2PInterface())
|
||||||
second_peer = self.nodes[0].add_p2p_connection(P2PInterface())
|
second_peer = self.nodes[0].add_p2p_connection(P2PInterface())
|
||||||
|
|||||||
@@ -42,6 +42,13 @@ class P2PPermissionsTests(BitcoinTestFramework):
|
|||||||
["relay", "noban", "mempool", "download"],
|
["relay", "noban", "mempool", "download"],
|
||||||
True)
|
True)
|
||||||
|
|
||||||
|
self.checkpermission(
|
||||||
|
# check without deprecatedrpc=whitelisted
|
||||||
|
["-whitelist=127.0.0.1"],
|
||||||
|
# Make sure the default values in the command line documentation match the ones here
|
||||||
|
["relay", "noban", "mempool", "download"],
|
||||||
|
None)
|
||||||
|
|
||||||
self.checkpermission(
|
self.checkpermission(
|
||||||
# no permission (even with forcerelay)
|
# no permission (even with forcerelay)
|
||||||
["-whitelist=@127.0.0.1", "-whitelistforcerelay=1"],
|
["-whitelist=@127.0.0.1", "-whitelistforcerelay=1"],
|
||||||
@@ -80,6 +87,12 @@ class P2PPermissionsTests(BitcoinTestFramework):
|
|||||||
["noban", "mempool", "download"],
|
["noban", "mempool", "download"],
|
||||||
False)
|
False)
|
||||||
|
|
||||||
|
self.checkpermission(
|
||||||
|
# check without deprecatedrpc=whitelisted
|
||||||
|
["-whitelist=noban,mempool@127.0.0.1", "-whitelistrelay"],
|
||||||
|
["noban", "mempool", "download"],
|
||||||
|
None)
|
||||||
|
|
||||||
self.checkpermission(
|
self.checkpermission(
|
||||||
# legacy whitelistforcerelay should be ignored
|
# legacy whitelistforcerelay should be ignored
|
||||||
["-whitelist=noban,mempool@127.0.0.1", "-whitelistforcerelay"],
|
["-whitelist=noban,mempool@127.0.0.1", "-whitelistforcerelay"],
|
||||||
@@ -149,10 +162,15 @@ class P2PPermissionsTests(BitcoinTestFramework):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def checkpermission(self, args, expectedPermissions, whitelisted):
|
def checkpermission(self, args, expectedPermissions, whitelisted):
|
||||||
|
if whitelisted is not None:
|
||||||
|
args = [*args, '-deprecatedrpc=whitelisted']
|
||||||
self.restart_node(1, args)
|
self.restart_node(1, args)
|
||||||
connect_nodes(self.nodes[0], 1)
|
connect_nodes(self.nodes[0], 1)
|
||||||
peerinfo = self.nodes[1].getpeerinfo()[0]
|
peerinfo = self.nodes[1].getpeerinfo()[0]
|
||||||
assert_equal(peerinfo['whitelisted'], whitelisted)
|
if whitelisted is None:
|
||||||
|
assert 'whitelisted' not in peerinfo
|
||||||
|
else:
|
||||||
|
assert_equal(peerinfo['whitelisted'], whitelisted)
|
||||||
assert_equal(len(expectedPermissions), len(peerinfo['permissions']))
|
assert_equal(len(expectedPermissions), len(peerinfo['permissions']))
|
||||||
for p in expectedPermissions:
|
for p in expectedPermissions:
|
||||||
if not p in peerinfo['permissions']:
|
if not p in peerinfo['permissions']:
|
||||||
|
|||||||
Reference in new issue
Block a user