Skip to content

Commit ea71726

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#21810: fuzz: Various RPC fuzzer follow-ups
5252f86 fuzz: Reduce maintenance requirements by allowing RPC annotations also for conditionally available RPC commands (such as wallet commands) without the fragility of #ifdef forests (practicalswift) 54549dd fuzz: RPC fuzzer post-merge follow-ups. Remove unused includes. Update list of fuzzed RPC commands. (practicalswift) Pull request description: Various RPC fuzzer follow-ups: * Remove unused includes. * Update list of fuzzed RPC commands. * Reduce maintenance requirements by allowing RPC annotations also for conditionally available RPC commands (such as wallet commands) without the fragility of `#ifdef` forests. Context: bitcoin/bitcoin#21169 (review) ACKs for top commit: MarcoFalke: Concept ACK 5252f86 Tree-SHA512: 286d70798131706ffb157758e1c73f7f00ed96ce120c7d9dc849e672b283f1362df47b206cfec9da44d5debb5869225e721761dcd5c38a7d5d1019dc6c912ab2
2 parents 3692097 + 5252f86 commit ea71726

File tree

1 file changed

+6
-26
lines changed

1 file changed

+6
-26
lines changed

src/test/fuzz/rpc.cpp

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

55
#include <base58.h>
6-
#include <chainparamsbase.h>
76
#include <core_io.h>
8-
#include <interfaces/chain.h>
97
#include <key.h>
108
#include <key_io.h>
119
#include <node/context.h>
@@ -70,18 +68,15 @@ const std::vector<std::string> RPC_COMMANDS_NOT_SAFE_FOR_FUZZING{
7068
"addpeeraddress", // avoid DNS lookups
7169
"analyzepsbt", // avoid signed integer overflow in CFeeRate::GetFee(unsigned long) (https://github.com/bitcoin/bitcoin/issues/20607)
7270
"dumptxoutset", // avoid writing to disk
73-
#ifdef ENABLE_WALLET
7471
"dumpwallet", // avoid writing to disk
75-
#endif
76-
"echoipc", // avoid assertion failure (Assertion `"EnsureAnyNodeContext(request.context).init" && check' failed.)
77-
"generatetoaddress", // avoid timeout
78-
"gettxoutproof", // avoid slow execution
79-
#ifdef ENABLE_WALLET
72+
"echoipc", // avoid assertion failure (Assertion `"EnsureAnyNodeContext(request.context).init" && check' failed.)
73+
"generatetoaddress", // avoid prohibitively slow execution (when `num_blocks` is large)
74+
"generatetodescriptor", // avoid prohibitively slow execution (when `nblocks` is large)
75+
"gettxoutproof", // avoid prohibitively slow execution
8076
"importwallet", // avoid reading from disk
8177
"loadwallet", // avoid reading from disk
82-
#endif
83-
"mockscheduler", // avoid assertion failure (Assertion `delta_seconds.count() > 0 && delta_seconds < std::chrono::hours{1}' failed.)
8478
"prioritisetransaction", // avoid signed integer overflow in CTxMemPool::PrioritiseTransaction(uint256 const&, long const&) (https://github.com/bitcoin/bitcoin/issues/20626)
79+
"savemempool", // disabled as a precautionary measure: may take a file path argument in the future
8580
"setban", // avoid DNS lookups
8681
"stop", // avoid shutdown state
8782
};
@@ -107,7 +102,6 @@ const std::vector<std::string> RPC_COMMANDS_SAFE_FOR_FUZZING{
107102
"finalizepsbt",
108103
"generate",
109104
"generateblock",
110-
"generatetodescriptor",
111105
"getaddednodeinfo",
112106
"getbestblockhash",
113107
"getblock",
@@ -145,11 +139,11 @@ const std::vector<std::string> RPC_COMMANDS_SAFE_FOR_FUZZING{
145139
"joinpsbts",
146140
"listbanned",
147141
"logging",
142+
"mockscheduler",
148143
"ping",
149144
"preciousblock",
150145
"pruneblockchain",
151146
"reconsiderblock",
152-
"savemempool",
153147
"scantxoutset",
154148
"sendrawtransaction",
155149
"setmocktime",
@@ -334,20 +328,6 @@ void initialize_rpc()
334328
std::terminate();
335329
}
336330
}
337-
for (const std::string& rpc_command : RPC_COMMANDS_SAFE_FOR_FUZZING) {
338-
const bool supported_rpc_command = std::find(supported_rpc_commands.begin(), supported_rpc_commands.end(), rpc_command) != supported_rpc_commands.end();
339-
if (!supported_rpc_command) {
340-
std::cerr << "Error: Unknown RPC command \"" << rpc_command << "\" found in RPC_COMMANDS_SAFE_FOR_FUZZING. Please update " << __FILE__ << ".\n";
341-
std::terminate();
342-
}
343-
}
344-
for (const std::string& rpc_command : RPC_COMMANDS_NOT_SAFE_FOR_FUZZING) {
345-
const bool supported_rpc_command = std::find(supported_rpc_commands.begin(), supported_rpc_commands.end(), rpc_command) != supported_rpc_commands.end();
346-
if (!supported_rpc_command) {
347-
std::cerr << "Error: Unknown RPC command \"" << rpc_command << "\" found in RPC_COMMANDS_NOT_SAFE_FOR_FUZZING. Please update " << __FILE__ << ".\n";
348-
std::terminate();
349-
}
350-
}
351331
const char* limit_to_rpc_command_env = std::getenv("LIMIT_TO_RPC_COMMAND");
352332
if (limit_to_rpc_command_env != nullptr) {
353333
g_limit_to_rpc_command = std::string{limit_to_rpc_command_env};

0 commit comments

Comments
 (0)