Skip to content

Commit bbcd9d5

Browse files
committed
rpc: remove -deprecatedrpc=service gating for service
Due to transitional concerns, while the fields are still considered deprecated, they will currently remain unenforced through gating. Also, don't use the word 'field' and 'key' interchangeably.
1 parent 8b5310a commit bbcd9d5

File tree

10 files changed

+21
-91
lines changed

10 files changed

+21
-91
lines changed

doc/release-notes-6665.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Updated RPCs
66

77
* The key `service` has been deprecated for some RPCs (`decoderawtransaction`, `decodepsbt`, `getblock`, `getrawtransaction`,
88
`gettransaction`, `masternode status` (only for the `dmnState` key), `protx diff`, `protx listdiff`) and has been replaced
9-
with the field `addresses`.
10-
* The deprecated field can be re-enabled using `-deprecatedrpc=service` but is liable to be removed in future versions
9+
with the key `addresses`.
10+
* The deprecated key is still available without additional runtime arguments but is liable to be removed in future versions
1111
of Dash Core.
1212
* This change does not affect `masternode status` (except for the `dmnState` key) as `service` does not represent a payload
1313
value but the external address advertised by the active masternode.

src/coinjoin/client.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,9 +1873,7 @@ void CCoinJoinClientSession::GetJsonInfo(UniValue& obj) const
18731873
assert(mixingMasternode->pdmnState);
18741874
obj.pushKV("protxhash", mixingMasternode->proTxHash.ToString());
18751875
obj.pushKV("outpoint", mixingMasternode->collateralOutpoint.ToStringShort());
1876-
if (m_wallet->chain().rpcEnableDeprecated("service")) {
1877-
obj.pushKV("service", mixingMasternode->pdmnState->netInfo->GetPrimary().ToStringAddrPort());
1878-
}
1876+
obj.pushKV("service", mixingMasternode->pdmnState->netInfo->GetPrimary().ToStringAddrPort());
18791877
obj.pushKV("addrs_core_p2p", mixingMasternode->pdmnState->netInfo->ToJson(NetInfoPurpose::CORE_P2P));
18801878
}
18811879
obj.pushKV("denomination", ValueFromAmount(CoinJoin::DenominationToAmount(nSessionDenom)));

src/evo/core_write.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@
7272
ret.pushKV("type", ToUnderlying(nType));
7373
ret.pushKV("collateralHash", collateralOutpoint.hash.ToString());
7474
ret.pushKV("collateralIndex", collateralOutpoint.n);
75-
if (IsServiceDeprecatedRPCEnabled()) {
76-
ret.pushKV("service", netInfo->GetPrimary().ToStringAddrPort());
77-
}
75+
ret.pushKV("service", netInfo->GetPrimary().ToStringAddrPort());
7876
ret.pushKV("addresses", GetNetInfoWithLegacyFields(*this, nType));
7977
ret.pushKV("ownerAddress", EncodeDestination(PKHash(keyIDOwner)));
8078
ret.pushKV("votingAddress", EncodeDestination(PKHash(keyIDVoting)));
@@ -122,9 +120,7 @@
122120
ret.pushKV("version", nVersion);
123121
ret.pushKV("type", ToUnderlying(nType));
124122
ret.pushKV("proTxHash", proTxHash.ToString());
125-
if (IsServiceDeprecatedRPCEnabled()) {
126-
ret.pushKV("service", netInfo->GetPrimary().ToStringAddrPort());
127-
}
123+
ret.pushKV("service", netInfo->GetPrimary().ToStringAddrPort());
128124
ret.pushKV("addresses", GetNetInfoWithLegacyFields(*this, nType));
129125
if (CTxDestination dest; ExtractDestination(scriptOperatorPayout, dest)) {
130126
ret.pushKV("operatorPayoutAddress", EncodeDestination(dest));
@@ -162,9 +158,7 @@
162158
obj.pushKV("nType", ToUnderlying(nType));
163159
obj.pushKV("proRegTxHash", proRegTxHash.ToString());
164160
obj.pushKV("confirmedHash", confirmedHash.ToString());
165-
if (IsServiceDeprecatedRPCEnabled()) {
166-
obj.pushKV("service", netInfo->GetPrimary().ToStringAddrPort());
167-
}
161+
obj.pushKV("service", netInfo->GetPrimary().ToStringAddrPort());
168162
obj.pushKV("addresses", GetNetInfoWithLegacyFields(*this, nType));
169163
obj.pushKV("pubKeyOperator", pubKeyOperator.ToString());
170164
obj.pushKV("votingAddress", EncodeDestination(PKHash(keyIDVoting)));

src/evo/dmnstate.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ UniValue CDeterministicMNState::ToJson(MnType nType) const
3636
{
3737
UniValue obj(UniValue::VOBJ);
3838
obj.pushKV("version", nVersion);
39-
if (IsServiceDeprecatedRPCEnabled()) {
40-
obj.pushKV("service", netInfo->GetPrimary().ToStringAddrPort());
41-
}
39+
obj.pushKV("service", netInfo->GetPrimary().ToStringAddrPort());
4240
obj.pushKV("addresses", GetNetInfoWithLegacyFields(*this, nType));
4341
obj.pushKV("registeredHeight", nRegisteredHeight);
4442
obj.pushKV("lastPaidHeight", nLastPaidHeight);
@@ -73,9 +71,7 @@ UniValue CDeterministicMNStateDiff::ToJson(MnType nType) const
7371
obj.pushKV("version", state.nVersion);
7472
}
7573
if (fields & Field_netInfo) {
76-
if (IsServiceDeprecatedRPCEnabled()) {
77-
obj.pushKV("service", state.netInfo->GetPrimary().ToStringAddrPort());
78-
}
74+
obj.pushKV("service", state.netInfo->GetPrimary().ToStringAddrPort());
7975
}
8076
if (fields & Field_nRegisteredHeight) {
8177
obj.pushKV("registeredHeight", state.nRegisteredHeight);

src/evo/netinfo.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ UniValue ArrFromService(const CService& addr)
4242
return obj;
4343
}
4444

45-
bool IsServiceDeprecatedRPCEnabled()
46-
{
47-
const auto args = gArgs.GetArgs("-deprecatedrpc");
48-
return std::find(args.begin(), args.end(), "service") != args.end();
49-
}
50-
5145
bool NetInfoEntry::operator==(const NetInfoEntry& rhs) const
5246
{
5347
if (m_type != rhs.m_type) return false;

src/evo/netinfo.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@ constexpr std::string_view PurposeToString(const NetInfoPurpose purpose)
100100
/** Will return true if node is running on mainnet */
101101
bool IsNodeOnMainnet();
102102

103-
/** Identical to IsDeprecatedRPCEnabled("service"). For use outside of RPC code */
104-
bool IsServiceDeprecatedRPCEnabled();
105-
106103
/** Creates a one-element array using CService::ToStringPortAddr() output */
107104
UniValue ArrFromService(const CService& addr);
108105

src/rpc/coinjoin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ static RPCHelpMan getcoinjoininfo()
433433
{
434434
{RPCResult::Type::STR_HEX, "protxhash", "The ProTxHash of the masternode"},
435435
{RPCResult::Type::STR_HEX, "outpoint", "The outpoint of the masternode"},
436-
{RPCResult::Type::STR, "service", "The IP address and port of the masternode (DEPRECATED, returned only if config option -deprecatedrpc=service is passed)"},
436+
{RPCResult::Type::STR, "service", "(DEPRECATED) The IP address and port of the masternode"},
437437
{RPCResult::Type::ARR, "addrs_core_p2p", "Network addresses of the masternode used for protocol P2P",
438438
{
439439
{RPCResult::Type::STR, "address", ""},

src/rpc/masternode.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -614,9 +614,7 @@ static RPCHelpMan masternodelist_helper(bool is_composite)
614614
strOutpoint.find(strFilter) == std::string::npos) return;
615615
UniValue objMN(UniValue::VOBJ);
616616
objMN.pushKV("proTxHash", dmn.proTxHash.ToString());
617-
if (IsDeprecatedRPCEnabled("service")) {
618-
objMN.pushKV("address", dmn.pdmnState->netInfo->GetPrimary().ToStringAddrPort());
619-
}
617+
objMN.pushKV("address", dmn.pdmnState->netInfo->GetPrimary().ToStringAddrPort());
620618
objMN.pushKV("addresses", GetNetInfoWithLegacyFields(*dmn.pdmnState, dmn.nType));
621619
objMN.pushKV("payee", payeeStr);
622620
objMN.pushKV("status", dmnToStatus(dmn));

src/rpc/quorums.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,7 @@ static UniValue BuildQuorumInfo(const llmq::CQuorumBlockProcessor& quorum_block_
205205
const auto& dmn = quorum->members[i];
206206
UniValue mo(UniValue::VOBJ);
207207
mo.pushKV("proTxHash", dmn->proTxHash.ToString());
208-
if (IsDeprecatedRPCEnabled("service")) {
209-
mo.pushKV("service", dmn->pdmnState->netInfo->GetPrimary().ToStringAddrPort());
210-
}
208+
mo.pushKV("service", dmn->pdmnState->netInfo->GetPrimary().ToStringAddrPort());
211209
mo.pushKV("addresses", GetNetInfoWithLegacyFields(*dmn->pdmnState, dmn->nType));
212210
mo.pushKV("pubKeyOperator", dmn->pdmnState->pubKeyOperator.ToString());
213211
mo.pushKV("valid", static_cast<bool>(quorum->qc->validMembers[i]));

test/functional/rpc_netinfo.py

Lines changed: 10 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,10 @@ def destroy_mn(self, test: BitcoinTestFramework):
135135

136136
class NetInfoTest(BitcoinTestFramework):
137137
def set_test_params(self):
138-
self.num_nodes = 3
138+
self.num_nodes = 2
139139
self.extra_args = [[
140140
"-dip3params=2:2", f"-vbparams=v23:{self.mocktime}:999999999999:{V23_ACTIVATION_THRESHOLD}:10:8:6:5:0"
141141
] for _ in range(self.num_nodes)]
142-
self.extra_args[2] += ["-deprecatedrpc=service"]
143142

144143
def skip_test_if_missing_module(self):
145144
self.skip_if_no_wallet()
@@ -177,14 +176,12 @@ def run_test(self):
177176
self.node_two: EvoNode = EvoNode(self.nodes[1])
178177
self.node_two.generate_collateral(self)
179178
self.node_two.register_mn(self, True, "", DEFAULT_PORT_PLATFORM_P2P, DEFAULT_PORT_PLATFORM_HTTP)
180-
# Used to check deprecated field behavior
181-
self.node_simple: TestNode = self.nodes[2]
182179
# Test routines
183180
self.log.info("Test input validation for masternode address fields (pre-fork)")
184181
self.test_validation_common()
185182
self.test_validation_legacy()
186183
self.log.info("Test output masternode address fields for consistency (pre-fork)")
187-
self.test_deprecation()
184+
self.test_fields()
188185
self.log.info("Mine blocks to activate DEPLOYMENT_V23")
189186
self.activate_v23()
190187
self.log.info("Test input validation for masternode address fields (post-fork)")
@@ -361,7 +358,7 @@ def test_validation_extended(self):
361358
self.node_evo.register_mn(self, False, "127.0.0.1", DEFAULT_PORT_PLATFORM_P2P, DEFAULT_PORT_PLATFORM_HTTP,
362359
-8, "Error setting coreP2PAddrs[0] to '127.0.0.1' (invalid port)")
363360

364-
def test_deprecation(self):
361+
def test_fields(self):
365362
# netInfo is represented with JSON in CProRegTx, CProUpServTx, CDeterministicMNState and CSimplifiedMNListEntry,
366363
# so we need to test calls that rely on these underlying implementations. Start by collecting RPC responses.
367364
self.log.info("Collect JSON RPC responses from node")
@@ -374,12 +371,7 @@ def test_deprecation(self):
374371
self.node_evo.set_active_state(self, True)
375372
masternode_status = self.node_evo.node.masternode('status')
376373

377-
# Generate deprecation-disabled response to avoid having to re-create a masternode again later on
378-
self.node_evo.set_active_state(self, True, ['-deprecatedrpc=service'])
379-
self.reconnect_nodes()
380-
masternode_status_depr = self.node_evo.node.masternode('status')
381-
382-
# Stop actively running the masternode so we can issue a CProUpServTx (and enable the deprecation)
374+
# Stop actively running the masternode so we can issue a CProUpServTx
383375
self.node_evo.set_active_state(self, False)
384376
self.reconnect_nodes()
385377

@@ -411,13 +403,6 @@ def test_deprecation(self):
411403
protx_listdiff_rpc_pl = self.node_evo.node.protx('listdiff', proupservtx_height_pl - 1, proupservtx_height_pl)
412404
protx_listdiff_rpc_pl = self.extract_from_listdiff(protx_listdiff_rpc_pl, proregtx_hash)
413405

414-
self.log.info("Test RPCs return an 'addresses' field")
415-
assert "addresses" in proregtx_rpc['proRegTx'].keys()
416-
assert "addresses" in masternode_status['dmnState'].keys()
417-
assert "addresses" in proupservtx_rpc['proUpServTx'].keys()
418-
assert "addresses" in protx_diff_rpc['mnList'][0].keys()
419-
assert "addresses" in protx_listdiff_rpc.keys()
420-
421406
self.log.info("Test 'addresses' report correctly")
422407
self.check_netinfo_fields(proregtx_rpc['proRegTx']['addresses'], self.node_evo.mn.nodePort, DEFAULT_PORT_PLATFORM_HTTP, DEFAULT_PORT_PLATFORM_P2P)
423408
self.check_netinfo_fields(masternode_status['dmnState']['addresses'], self.node_evo.mn.nodePort, DEFAULT_PORT_PLATFORM_HTTP, DEFAULT_PORT_PLATFORM_P2P)
@@ -431,37 +416,10 @@ def test_deprecation(self):
431416
assert_equal(protx_listdiff_rpc_pl['addresses']['platform_https'][0], f"{DMNSTATE_DIFF_DUMMY_ADDR}:{DEFAULT_PORT_PLATFORM_HTTP + 10}")
432417
assert_equal(protx_listdiff_rpc_pl['addresses']['platform_p2p'][0], f"{DMNSTATE_DIFF_DUMMY_ADDR}:{DEFAULT_PORT_PLATFORM_P2P + 10}")
433418

434-
self.log.info("Test RPCs by default no longer return a 'service' field")
435-
assert "service" not in proregtx_rpc['proRegTx'].keys()
436-
assert "service" not in masternode_status['dmnState'].keys()
437-
assert "service" not in proupservtx_rpc['proUpServTx'].keys()
438-
assert "service" not in protx_diff_rpc['mnList'][0].keys()
439-
assert "service" not in protx_listdiff_rpc.keys()
440-
# "service" in "masternode status" is exempt from the deprecation as the primary address is
441-
# relevant on the host node as opposed to expressing payload information in most other RPCs.
442-
assert "service" in masternode_status.keys()
443-
444419
# Shut down masternode
445420
self.node_evo.destroy_mn(self)
446421
self.reconnect_nodes()
447422

448-
self.log.info("Collect RPC responses from node with -deprecatedrpc=service")
449-
450-
# Re-use chain activity from earlier
451-
proregtx_rpc = self.node_simple.getrawtransaction(proregtx_hash, True)
452-
proupservtx_rpc = self.node_simple.getrawtransaction(proupservtx_hash, True)
453-
protx_diff_rpc = self.node_simple.protx('diff', masternode_active_height - 1, masternode_active_height)
454-
masternode_status = masternode_status_depr # Pull in response generated from earlier
455-
protx_listdiff_rpc = self.node_simple.protx('listdiff', proupservtx_height - 1, proupservtx_height)
456-
protx_listdiff_rpc = self.extract_from_listdiff(protx_listdiff_rpc, proregtx_hash)
457-
458-
self.log.info("Test RPCs return 'service' with -deprecatedrpc=service")
459-
assert "service" in proregtx_rpc['proRegTx'].keys()
460-
assert "service" in masternode_status['dmnState'].keys()
461-
assert "service" in proupservtx_rpc['proUpServTx'].keys()
462-
assert "service" in protx_diff_rpc['mnList'][0].keys()
463-
assert "service" in protx_listdiff_rpc.keys()
464-
465423
def test_empty_fields(self):
466424
def empty_common(grt_dict):
467425
# Even if '[::]:0' is reported by 'service', 'addresses' should always be blank if we have nothing to report
@@ -471,7 +429,7 @@ def empty_common(grt_dict):
471429
assert_equal(grt_dict['service'], "[::]:0")
472430

473431
# Validate that our masternode was registered before the fork
474-
grt_proregtx = self.node_simple.getrawtransaction(self.node_two.mn.proTxHash, True)['proRegTx']
432+
grt_proregtx = self.node_two.node.getrawtransaction(self.node_two.mn.proTxHash, True)['proRegTx']
475433
assert_equal(grt_proregtx['version'], PROTXVER_BASIC)
476434

477435
# Test reporting on legacy address (i.e. basic BLS and earlier) nodes
@@ -487,7 +445,7 @@ def empty_common(grt_dict):
487445
self.node_two.register_mn(self, True, "", "", "")
488446

489447
# Validate that masternode uses extended addresses
490-
grt_proregtx = self.node_simple.getrawtransaction(self.node_two.mn.proTxHash, True)['proRegTx']
448+
grt_proregtx = self.node_two.node.getrawtransaction(self.node_two.mn.proTxHash, True)['proRegTx']
491449
assert_equal(grt_proregtx['version'], PROTXVER_EXTADDR)
492450

493451
# Test reporting for extended addresses
@@ -507,7 +465,7 @@ def empty_common(grt_dict):
507465
def test_shims(self):
508466
# There are two shims there to help with migrating between legacy and extended addresses, one reads from legacy platform
509467
# fields to ensure 'addresses' is adequately populated. The other, reads from netInfo to populate platform{HTTP,P2P}Port.
510-
# As the fork is now active, we can now evaluate the test cases that couldn't be evaluated in test_deprecation().
468+
# As the fork is now active, we can now evaluate the test cases that couldn't be evaluated in test_fields().
511469
self.log.info("Collect JSON RPC responses from node")
512470

513471
# Create an masternode that clearly uses extended addresses (hello IPv6!)
@@ -545,16 +503,13 @@ def test_shims(self):
545503
# platform{HTTP,P2P}Port *won't* be populated by listdiff as that *field* is now unused and it's dangerous to report "updates" to disused fields
546504
assert "platformP2PPort" not in protx_listdiff_rpc.keys()
547505
assert "platformHTTPPort" not in protx_listdiff_rpc.keys()
506+
# Check that 'service' correctly reports as coreP2PAddrs[0]
507+
assert_equal(proregtx_rpc['proRegTx']['service'], f"127.0.0.1:{self.node_evo.mn.nodePort}")
508+
assert_equal(proupservtx_rpc['proUpServTx']['service'], f"127.0.0.1:{self.node_evo.mn.nodePort}")
548509

549510
# Restart the client to see if (de)ser works as intended (CDeterministicMNStateDiff is a special case and we just made an update)
550511
self.node_evo.set_active_state(self, False)
551512
self.reconnect_nodes()
552513

553-
# Check that 'service' correctly reports as coreP2PAddrs[0]
554-
proregtx_rpc = self.node_simple.getrawtransaction(proregtx_hash, True)
555-
proupservtx_rpc = self.node_simple.getrawtransaction(proupservtx_hash, True)
556-
assert_equal(proregtx_rpc['proRegTx']['service'], f"127.0.0.1:{self.node_evo.mn.nodePort}")
557-
assert_equal(proupservtx_rpc['proUpServTx']['service'], f"127.0.0.1:{self.node_evo.mn.nodePort}")
558-
559514
if __name__ == "__main__":
560515
NetInfoTest().main()

0 commit comments

Comments
 (0)