Skip to content

Commit e3dd0a5

Browse files
author
MarcoFalke
committed
Merge #20755: [rpc] Remove deprecated fields from getpeerinfo
454a408 [doc] Add release notes for removed getpeerinfo fields. (Amiti Uttarwar) b1a936d [rpc] Remove deprecated "whitelisted" field from getpeerinfo (Amiti Uttarwar) 094c3be [rpc] Remove deprecated "banscore" field from getpeerinfo (Amiti Uttarwar) 5370533 [rpc] Remove deprecated "addnode" field from getpeerinfo (Amiti Uttarwar) Pull request description: This PR removes support for 3 fields on the `getpeerinfo` RPC that were deprecated in v0.21- `addnode`, `banscore` & `whitelisted`. ACKs for top commit: sipa: utACK 454a408 jnewbery: ACK 454a408. Tree-SHA512: ccc0e90c0763eeb8529cf0c46162dbaca3f7773981b3b52d9925166ea7421aed086795d56b320e16c9340f68862388785f52a9b78314865070917b33180d7cd6
2 parents 7f9ae87 + 454a408 commit e3dd0a5

File tree

10 files changed

+17
-106
lines changed

10 files changed

+17
-106
lines changed

doc/release-notes.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ P2P and network changes
6363

6464
Updated RPCs
6565
------------
66+
- `getpeerinfo` no longer returns the following fields: `addnode`, `banscore`,
67+
and `whitelisted`, which were previously deprecated in 0.21. Instead of
68+
`addnode`, the `connection_type` field returns manual. Instead of
69+
`whitelisted`, the `permissions` field indicates if the peer has special
70+
privileges. The `banscore` field has simply been removed. (#20755)
6671

6772
Changes to Wallet or GUI related RPCs can be found in the GUI or Wallet section below.
6873

src/net.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,6 @@ void CNode::copyStats(CNodeStats &stats, const std::vector<bool> &m_asmap)
587587
X(cleanSubVer);
588588
}
589589
stats.fInbound = IsInboundConn();
590-
stats.m_manual_connection = IsManualConn();
591590
X(m_bip152_highbandwidth_to);
592591
X(m_bip152_highbandwidth_from);
593592
{
@@ -600,7 +599,6 @@ void CNode::copyStats(CNodeStats &stats, const std::vector<bool> &m_asmap)
600599
X(mapRecvBytesPerMsgCmd);
601600
X(nRecvBytes);
602601
}
603-
X(m_legacyWhitelisted);
604602
X(m_permissionFlags);
605603
if (m_tx_relay != nullptr) {
606604
LOCK(m_tx_relay->cs_feeFilter);
@@ -1123,8 +1121,6 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) {
11231121
CNode* pnode = new CNode(id, nodeServices, GetBestHeight(), hSocket, addr, CalculateKeyedNetGroup(addr), nonce, addr_bind, "", ConnectionType::INBOUND, inbound_onion);
11241122
pnode->AddRef();
11251123
pnode->m_permissionFlags = permissionFlags;
1126-
// If this flag is present, the user probably expect that RPC and QT report it as whitelisted (backward compatibility)
1127-
pnode->m_legacyWhitelisted = legacyWhitelisted;
11281124
pnode->m_prefer_evict = discouraged;
11291125
m_msgproc->InitializeNode(pnode);
11301126

src/net.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,6 @@ class CNodeStats
702702
int nVersion;
703703
std::string cleanSubVer;
704704
bool fInbound;
705-
bool m_manual_connection;
706705
bool m_bip152_highbandwidth_to;
707706
bool m_bip152_highbandwidth_from;
708707
int m_starting_height;
@@ -711,7 +710,6 @@ class CNodeStats
711710
uint64_t nRecvBytes;
712711
mapMsgCmdSize mapRecvBytesPerMsgCmd;
713712
NetPermissionFlags m_permissionFlags;
714-
bool m_legacyWhitelisted;
715713
int64_t m_ping_usec;
716714
int64_t m_ping_wait_usec;
717715
int64_t m_min_ping_usec;
@@ -892,8 +890,6 @@ class CNode
892890
bool HasPermission(NetPermissionFlags permission) const {
893891
return NetPermissions::HasFlag(m_permissionFlags, permission);
894892
}
895-
// This boolean is unusued in actual processing, only present for backward compatibility at RPC/QT level
896-
bool m_legacyWhitelisted{false};
897893
bool fClient{false}; // set by version message
898894
bool m_limited_node{false}; //after BIP159, set by version message
899895
/**

src/net_processing.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,6 @@ bool PeerManager::GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats) {
874874

875875
PeerRef peer = GetPeerRef(nodeid);
876876
if (peer == nullptr) return false;
877-
stats.m_misbehavior_score = WITH_LOCK(peer->m_misbehavior_mutex, return peer->m_misbehavior_score);
878877
stats.m_starting_height = peer->m_starting_height;
879878

880879
return true;

src/net_processing.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ static const bool DEFAULT_PEERBLOCKFILTERS = false;
3333
static const int DISCOURAGEMENT_THRESHOLD{100};
3434

3535
struct CNodeStateStats {
36-
int m_misbehavior_score = 0;
3736
int nSyncHeight = -1;
3837
int nCommonHeight = -1;
3938
int m_starting_height = -1;

src/rpc/net.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -128,21 +128,16 @@ static RPCHelpMan getpeerinfo()
128128
{RPCResult::Type::BOOL, "inbound", "Inbound (true) or Outbound (false)"},
129129
{RPCResult::Type::BOOL, "bip152_hb_to", "Whether we selected peer as (compact blocks) high-bandwidth peer"},
130130
{RPCResult::Type::BOOL, "bip152_hb_from", "Whether peer selected us as (compact blocks) high-bandwidth peer"},
131-
{RPCResult::Type::BOOL, "addnode", "Whether connection was due to addnode/-connect or if it was an automatic/inbound connection\n"
132-
"(DEPRECATED, returned only if the config option -deprecatedrpc=getpeerinfo_addnode is passed)"},
133131
{RPCResult::Type::STR, "connection_type", "Type of connection: \n" + Join(CONNECTION_TYPE_DOC, ",\n") + ".\n"
134132
"Please note this output is unlikely to be stable in upcoming releases as we iterate to\n"
135133
"best capture connection behaviors."},
136-
{RPCResult::Type::NUM, "banscore", "The ban score (DEPRECATED, returned only if config option -deprecatedrpc=banscore is passed)"},
137134
{RPCResult::Type::NUM, "startingheight", "The starting height (block) of the peer"},
138135
{RPCResult::Type::NUM, "synced_headers", "The last header we have in common with this peer"},
139136
{RPCResult::Type::NUM, "synced_blocks", "The last block we have in common with this peer"},
140137
{RPCResult::Type::ARR, "inflight", "",
141138
{
142139
{RPCResult::Type::NUM, "n", "The heights of blocks we're currently asking from this peer"},
143140
}},
144-
{RPCResult::Type::BOOL, "whitelisted", /* optional */ true, "Whether the peer is whitelisted with default permissions\n"
145-
"(DEPRECATED, returned only if config option -deprecatedrpc=whitelisted is passed)"},
146141
{RPCResult::Type::ARR, "permissions", "Any special permissions that have been granted to this peer",
147142
{
148143
{RPCResult::Type::STR, "permission_type", Join(NET_PERMISSIONS_DOC, ",\n") + ".\n"},
@@ -224,15 +219,7 @@ static RPCHelpMan getpeerinfo()
224219
obj.pushKV("inbound", stats.fInbound);
225220
obj.pushKV("bip152_hb_to", stats.m_bip152_highbandwidth_to);
226221
obj.pushKV("bip152_hb_from", stats.m_bip152_highbandwidth_from);
227-
if (IsDeprecatedRPCEnabled("getpeerinfo_addnode")) {
228-
// addnode is deprecated in v0.21 for removal in v0.22
229-
obj.pushKV("addnode", stats.m_manual_connection);
230-
}
231222
if (fStateStats) {
232-
if (IsDeprecatedRPCEnabled("banscore")) {
233-
// banscore is deprecated in v0.21 for removal in v0.22
234-
obj.pushKV("banscore", statestats.m_misbehavior_score);
235-
}
236223
obj.pushKV("startingheight", statestats.m_starting_height);
237224
obj.pushKV("synced_headers", statestats.nSyncHeight);
238225
obj.pushKV("synced_blocks", statestats.nCommonHeight);
@@ -242,10 +229,6 @@ static RPCHelpMan getpeerinfo()
242229
}
243230
obj.pushKV("inflight", heights);
244231
}
245-
if (IsDeprecatedRPCEnabled("whitelisted")) {
246-
// whitelisted is deprecated in v0.21 for removal in v0.22
247-
obj.pushKV("whitelisted", stats.m_legacyWhitelisted);
248-
}
249232
UniValue permissions(UniValue::VARR);
250233
for (const auto& permission : NetPermissions::ToStrings(stats.m_permissionFlags)) {
251234
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):

test/functional/rpc_getpeerinfo_deprecation.py

Lines changed: 0 additions & 38 deletions
This file was deleted.

test/functional/test_runner.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@
279279
'feature_config_args.py',
280280
'feature_settings.py',
281281
'rpc_getdescriptorinfo.py',
282-
'rpc_getpeerinfo_deprecation.py',
283282
'rpc_help.py',
284283
'feature_help.py',
285284
'feature_shutdown.py',

0 commit comments

Comments
 (0)