From 54549dda310e2becee9cb4997d1408a90e91934f Mon Sep 17 00:00:00 2001 From: practicalswift Date: Wed, 28 Apr 2021 09:29:35 +0000 Subject: [PATCH 1/2] fuzz: RPC fuzzer post-merge follow-ups. Remove unused includes. Update list of fuzzed RPC commands. --- src/test/fuzz/rpc.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/test/fuzz/rpc.cpp b/src/test/fuzz/rpc.cpp index dae6f6b6a7694..22a305ca1781f 100644 --- a/src/test/fuzz/rpc.cpp +++ b/src/test/fuzz/rpc.cpp @@ -3,9 +3,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include -#include #include -#include #include #include #include @@ -73,15 +71,16 @@ const std::vector RPC_COMMANDS_NOT_SAFE_FOR_FUZZING{ #ifdef ENABLE_WALLET "dumpwallet", // avoid writing to disk #endif - "echoipc", // avoid assertion failure (Assertion `"EnsureAnyNodeContext(request.context).init" && check' failed.) - "generatetoaddress", // avoid timeout - "gettxoutproof", // avoid slow execution + "echoipc", // avoid assertion failure (Assertion `"EnsureAnyNodeContext(request.context).init" && check' failed.) + "generatetoaddress", // avoid prohibitively slow execution (when `num_blocks` is large) + "generatetodescriptor", // avoid prohibitively slow execution (when `nblocks` is large) + "gettxoutproof", // avoid prohibitively slow execution #ifdef ENABLE_WALLET "importwallet", // avoid reading from disk "loadwallet", // avoid reading from disk #endif - "mockscheduler", // avoid assertion failure (Assertion `delta_seconds.count() > 0 && delta_seconds < std::chrono::hours{1}' failed.) "prioritisetransaction", // avoid signed integer overflow in CTxMemPool::PrioritiseTransaction(uint256 const&, long const&) (https://github.com/bitcoin/bitcoin/issues/20626) + "savemempool", // disabled as a precautionary measure: may take a file path argument in the future "setban", // avoid DNS lookups "stop", // avoid shutdown state }; @@ -107,7 +106,6 @@ const std::vector RPC_COMMANDS_SAFE_FOR_FUZZING{ "finalizepsbt", "generate", "generateblock", - "generatetodescriptor", "getaddednodeinfo", "getbestblockhash", "getblock", @@ -145,11 +143,11 @@ const std::vector RPC_COMMANDS_SAFE_FOR_FUZZING{ "joinpsbts", "listbanned", "logging", + "mockscheduler", "ping", "preciousblock", "pruneblockchain", "reconsiderblock", - "savemempool", "scantxoutset", "sendrawtransaction", "setmocktime", From 5252f86eb616a1112e427c268c8e8825f2a63d67 Mon Sep 17 00:00:00 2001 From: practicalswift Date: Thu, 29 Apr 2021 18:41:16 +0000 Subject: [PATCH 2/2] fuzz: Reduce maintenance requirements by allowing RPC annotations also for conditionally available RPC commands (such as wallet commands) without the fragility of #ifdef forests --- src/test/fuzz/rpc.cpp | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/test/fuzz/rpc.cpp b/src/test/fuzz/rpc.cpp index 22a305ca1781f..cf32a79932860 100644 --- a/src/test/fuzz/rpc.cpp +++ b/src/test/fuzz/rpc.cpp @@ -68,17 +68,13 @@ const std::vector RPC_COMMANDS_NOT_SAFE_FOR_FUZZING{ "addpeeraddress", // avoid DNS lookups "analyzepsbt", // avoid signed integer overflow in CFeeRate::GetFee(unsigned long) (https://github.com/bitcoin/bitcoin/issues/20607) "dumptxoutset", // avoid writing to disk -#ifdef ENABLE_WALLET "dumpwallet", // avoid writing to disk -#endif "echoipc", // avoid assertion failure (Assertion `"EnsureAnyNodeContext(request.context).init" && check' failed.) "generatetoaddress", // avoid prohibitively slow execution (when `num_blocks` is large) "generatetodescriptor", // avoid prohibitively slow execution (when `nblocks` is large) "gettxoutproof", // avoid prohibitively slow execution -#ifdef ENABLE_WALLET "importwallet", // avoid reading from disk "loadwallet", // avoid reading from disk -#endif "prioritisetransaction", // avoid signed integer overflow in CTxMemPool::PrioritiseTransaction(uint256 const&, long const&) (https://github.com/bitcoin/bitcoin/issues/20626) "savemempool", // disabled as a precautionary measure: may take a file path argument in the future "setban", // avoid DNS lookups @@ -332,20 +328,6 @@ void initialize_rpc() std::terminate(); } } - for (const std::string& rpc_command : RPC_COMMANDS_SAFE_FOR_FUZZING) { - const bool supported_rpc_command = std::find(supported_rpc_commands.begin(), supported_rpc_commands.end(), rpc_command) != supported_rpc_commands.end(); - if (!supported_rpc_command) { - std::cerr << "Error: Unknown RPC command \"" << rpc_command << "\" found in RPC_COMMANDS_SAFE_FOR_FUZZING. Please update " << __FILE__ << ".\n"; - std::terminate(); - } - } - for (const std::string& rpc_command : RPC_COMMANDS_NOT_SAFE_FOR_FUZZING) { - const bool supported_rpc_command = std::find(supported_rpc_commands.begin(), supported_rpc_commands.end(), rpc_command) != supported_rpc_commands.end(); - if (!supported_rpc_command) { - std::cerr << "Error: Unknown RPC command \"" << rpc_command << "\" found in RPC_COMMANDS_NOT_SAFE_FOR_FUZZING. Please update " << __FILE__ << ".\n"; - std::terminate(); - } - } const char* limit_to_rpc_command_env = std::getenv("LIMIT_TO_RPC_COMMAND"); if (limit_to_rpc_command_env != nullptr) { g_limit_to_rpc_command = std::string{limit_to_rpc_command_env};