Skip to content

Commit 265d9b5

Browse files
Merge #6482: feat!: remove deprecated command-line option -platform-user
254f126 docs: added release notes for removal of -platform-user (Konstantin Akimov) 404656c feat!: remove deprecated command-line option `-platform-user` (Konstantin Akimov) ebca98b chore: removed functional test rpc_deprecated_platform_filter.py (Konstantin Akimov) Pull request description: ## Issue being fixed or feature implemented This command-line option has never been used for platform, marked as deprecated in v22. Time to remove it. ## What was done? Removed deprecated command line option `-platform-user` and related code ## How Has This Been Tested? ## Breaking Changes Removed deprecated command line option `-platform-user` and related code ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: utACK 254f126 PastaPastaPasta: utACK 254f126 Tree-SHA512: 57c50085b0727f3579c167bbccee4bc544932cf26f10ea321afa3b36d353e454c093c0690d15de4d661b9f52739b3e88929aa1ccb8e12f9205046a395bd6b28d
2 parents 5a0fd83 + 254f126 commit 265d9b5

File tree

9 files changed

+14
-221
lines changed

9 files changed

+14
-221
lines changed

doc/release-notes-6482.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Command-line Options
2+
3+
### Changes in Existing Command-line Options
4+
5+
- **`-platform-user`**
6+
- Removed in v23, since deprecated in v22 and has never been used by platform
7+

src/httprpc.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,6 @@ static bool JSONErrorReply(RpcHttpRequest& rpcRequest, const UniValue& objError,
122122
nStatus = HTTP_BAD_REQUEST;
123123
else if (code == RPC_METHOD_NOT_FOUND)
124124
nStatus = HTTP_NOT_FOUND;
125-
else if (code == RPC_PLATFORM_RESTRICTION) {
126-
nStatus = HTTP_FORBIDDEN;
127-
}
128125

129126
std::string strReply = JSONRPCReply(NullUniValue, objError, id);
130127

src/init.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
15111511
/* Register RPC commands regardless of -server setting so they will be
15121512
* available in the GUI RPC console even if external calls are disabled.
15131513
*/
1514-
tableRPC.InitPlatformRestrictions();
15151514
RegisterAllCoreRPCCommands(tableRPC);
15161515
for (const auto& client : node.chain_clients) {
15171516
client->registerRpcs();

src/rpc/protocol.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ enum RPCErrorCode
4848
RPC_VERIFY_ALREADY_IN_CHAIN = -27, //!< Transaction already in chain
4949
RPC_IN_WARMUP = -28, //!< Client still warming up
5050
RPC_METHOD_DEPRECATED = -32, //!< RPC method is deprecated
51-
RPC_PLATFORM_RESTRICTION = -33, //!< This RPC command cannot be run by platform-user
5251

5352
//! Aliases for backward compatibility
5453
RPC_TRANSACTION_ERROR = RPC_VERIFY_ERROR,

src/rpc/server.cpp

Lines changed: 7 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66

77
#include <rpc/server.h>
88

9-
#include <chainparams.h>
10-
#include <node/context.h>
11-
#include <rpc/blockchain.h>
12-
#include <rpc/server_util.h>
139
#include <rpc/util.h>
1410
#include <shutdown.h>
1511
#include <sync.h>
@@ -20,7 +16,6 @@
2016

2117
#include <boost/signals2/signal.hpp>
2218

23-
#include <algorithm>
2419
#include <atomic>
2520
#include <cassert>
2621
#include <chrono>
@@ -37,10 +32,7 @@ static RPCTimerInterface* timerInterface = nullptr;
3732
/* Map of name to timer. */
3833
static Mutex g_deadline_timers_mutex;
3934
static std::map<std::string, std::unique_ptr<RPCTimerBase> > deadlineTimers GUARDED_BY(g_deadline_timers_mutex);
40-
static bool ExecuteCommand(const CRPCCommand& command, const JSONRPCRequest& request, UniValue& result, bool last_handler, const std::multimap<std::string, std::vector<UniValue>>& mapPlatformRestrictions);
41-
42-
// Any commands submitted by this user will have their commands filtered based on the mapPlatformRestrictions
43-
static const std::string defaultPlatformUser = "platform-user";
35+
static bool ExecuteCommand(const CRPCCommand& command, const JSONRPCRequest& request, UniValue& result, bool last_handler);
4436

4537
struct RPCCommandExecutionInfo
4638
{
@@ -150,21 +142,6 @@ std::string CRPCTable::help(const std::string& strCommand, const JSONRPCRequest&
150142
return strRet;
151143
}
152144

153-
void CRPCTable::InitPlatformRestrictions()
154-
{
155-
mapPlatformRestrictions = {
156-
{"getassetunlockstatuses", {}},
157-
{"getbestblockhash", {}},
158-
{"getblockhash", {}},
159-
{"getblockcount", {}},
160-
{"getbestchainlock", {}},
161-
{"quorum sign", {static_cast<uint8_t>(Params().GetConsensus().llmqTypePlatform)}},
162-
{"quorum verify", {}},
163-
{"submitchainlock", {}},
164-
{"verifyislock", {}},
165-
};
166-
}
167-
168145
static RPCHelpMan help()
169146
{
170147
return RPCHelpMan{"help",
@@ -507,10 +484,10 @@ static inline JSONRPCRequest transformNamedArguments(const JSONRPCRequest& in, c
507484
return out;
508485
}
509486

510-
static bool ExecuteCommands(const std::vector<const CRPCCommand*>& commands, const JSONRPCRequest& request, UniValue& result, const std::multimap<std::string, std::vector<UniValue>>& mapPlatformRestrictions)
487+
static bool ExecuteCommands(const std::vector<const CRPCCommand*>& commands, const JSONRPCRequest& request, UniValue& result)
511488
{
512489
for (const auto& command : commands) {
513-
if (ExecuteCommand(*command, request, result, &command == &commands.back(), mapPlatformRestrictions)) {
490+
if (ExecuteCommand(*command, request, result, &command == &commands.back())) {
514491
return true;
515492
}
516493
}
@@ -542,78 +519,15 @@ UniValue CRPCTable::execute(const JSONRPCRequest &request) const
542519
if (it != mapCommands.end()) {
543520
UniValue result;
544521
const JSONRPCRequest new_request{subcommand.empty() ? request : request.squashed() };
545-
if (ExecuteCommands(it->second, new_request, result, mapPlatformRestrictions)) {
522+
if (ExecuteCommands(it->second, new_request, result)) {
546523
return result;
547524
}
548525
}
549526
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found");
550527
}
551528

552-
static bool ExecuteCommand(const CRPCCommand& command, const JSONRPCRequest& request, UniValue& result, bool last_handler, const std::multimap<std::string, std::vector<UniValue>>& mapPlatformRestrictions)
553-
{
554-
const NodeContext& node = EnsureAnyNodeContext(request.context);
555-
// Before executing the RPC Command, filter commands from platform rpc user
556-
if (node.mn_activeman && request.authUser == gArgs.GetArg("-deprecated-platform-user", defaultPlatformUser)) {
557-
// replace this with structured binding in c++20
558-
std::string command_name = command.name;
559-
const auto& it = mapPlatformRestrictions.equal_range(command_name);
560-
const auto& allowed_begin = it.first;
561-
const auto& allowed_end = it.second;
562-
/**
563-
* allowed_begin and allowed_end are iterators that represent a range of [method_name, vec_params]
564-
* For example, assume allowed = `quorum sign platformLlmqType`, `quorum verify` and `verifyislock`
565-
* this range will look like:
566-
*
567-
* if request.strMethod == "quorum":
568-
* [
569-
* "quorum sign", [platformLlmqType],
570-
* "quorum verify", []
571-
* ]
572-
* if request.strMethod == "verifyislock"
573-
* [
574-
* "verifyislock", []
575-
* ]
576-
*/
577-
578-
// If the requested method is not available in mapPlatformRestrictions
579-
if (allowed_begin == allowed_end) {
580-
throw JSONRPCError(RPC_PLATFORM_RESTRICTION, strprintf("Method \"%s\" prohibited", request.strMethod));
581-
}
582-
583-
auto isValidRequest = [&request, &allowed_begin, &allowed_end]() {
584-
for (auto itRequest = allowed_begin; itRequest != allowed_end; ++itRequest) {
585-
// This is an individual group of parameters that is valid
586-
// This will look something like `["sign", platformLlmqType]` from above.
587-
const auto& vecAllowedParam = itRequest->second;
588-
// An empty vector of allowed parameters represents that any parameter is allowed.
589-
if (vecAllowedParam.empty()) {
590-
return true;
591-
}
592-
if (request.params.empty()) {
593-
throw JSONRPCError(RPC_PLATFORM_RESTRICTION, strprintf("Method \"%s\" has parameter restrictions.", request.strMethod));
594-
}
595-
596-
if (request.params.size() < vecAllowedParam.size()) {
597-
continue;
598-
}
599-
600-
if (std::equal(vecAllowedParam.begin(), vecAllowedParam.end(),
601-
request.params.getValues().begin(),
602-
[](const UniValue& left, const UniValue& right) {
603-
return left.type() == right.type() && left.getValStr() == right.getValStr();
604-
})) {
605-
return true;
606-
}
607-
}
608-
return false;
609-
};
610-
611-
// Try if any of the mapPlatformRestrictions entries matches the current request
612-
if (!isValidRequest()) {
613-
throw JSONRPCError(RPC_PLATFORM_RESTRICTION, "Request doesn't comply with the parameter restrictions.");
614-
}
615-
}
616-
529+
static bool ExecuteCommand(const CRPCCommand& command, const JSONRPCRequest& request, UniValue& result, bool last_handler)
530+
{
617531
try
618532
{
619533
RPCCommandExecution execution(request.strMethod);
@@ -647,7 +561,7 @@ UniValue CRPCTable::dumpArgMap(const JSONRPCRequest& args_request) const
647561
// TODO: implement mapping argument to type for composite commands
648562
if (cmd.first.find(' ') != std::string::npos) continue;
649563
UniValue result;
650-
if (ExecuteCommands(cmd.second, request, result, mapPlatformRestrictions)) {
564+
if (ExecuteCommands(cmd.second, request, result)) {
651565
for (const auto& values : result.getValues()) {
652566
ret.push_back(values);
653567
}

src/rpc/server.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,10 @@ class CRPCTable
124124
{
125125
private:
126126
std::map<std::string, std::vector<const CRPCCommand*>> mapCommands;
127-
std::multimap<std::string, std::vector<UniValue>> mapPlatformRestrictions;
128127
public:
129128
CRPCTable();
130129
std::string help(const std::string& name, const JSONRPCRequest& helpreq) const;
131130

132-
void InitPlatformRestrictions();
133-
134131
/**
135132
* Execute a method.
136133
* @param request The JSONRPCRequest to execute

test/functional/rpc_deprecated_platform_filter.py

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

test/functional/test_runner.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@
340340
'wallet_send.py --descriptors',
341341
'wallet_create_tx.py --descriptors',
342342
'p2p_fingerprint.py',
343-
'rpc_deprecated_platform_filter.py',
344343
'rpc_external_queue.py',
345344
'rpc_wipewallettxes.py',
346345
'feature_uacomment.py',

test/lint/lint-circular-dependencies.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@
8989
"qt/guiutil -> qt/optionsdialog -> qt/guiutil",
9090
"qt/guiutil -> qt/optionsdialog -> qt/optionsmodel -> qt/guiutil",
9191
"qt/guiutil -> qt/qvalidatedlineedit -> qt/guiutil",
92-
"rpc/blockchain -> rpc/server -> rpc/blockchain"
9392
)
9493

9594
CODE_DIR = "src"

0 commit comments

Comments
 (0)