This change adds a new fuzz target wallet_rpc
,
this change was suggested in #29901
This change use some of the functionality of the fuzz target rpc
to also target the wallet rpc’s
This change adds a new fuzz target wallet_rpc
,
this change was suggested in #29901
This change use some of the functionality of the fuzz target rpc
to also target the wallet rpc’s
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/30570.
See the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
No conflicts as of last run.
202+const std::vector<std::string> WALLET_RPC_COMMANDS_NOT_SAFE_FOR_FUZZING{
203+ "importwallet",
204+ "loadwallet",
205+};
206+// RPC commands which are safe for fuzzing.
207+const std::vector<std::string> WALLET_RPC_COMMANDS_SAFE_FOR_FUZZING{
This is a screenshot of the coverage I was able to generate so far for ./src/wallet/rpc
🚧 At least one of the CI tasks failed. Debug: https://github.com/bitcoin/bitcoin/runs/28242205421
Make sure to run all tests locally, according to the documentation.
The failure may happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
src/wallet/test/fuzz/
.
201@@ -202,6 +202,7 @@ BITCOIN_TESTS += wallet/test/db_tests.cpp
202 endif
203
204 FUZZ_WALLET_SRC = \
205+ wallet/test/fuzz/rpc.cpp \
This change should be replaced with the following diff:
0--- a/src/wallet/test/fuzz/CMakeLists.txt
1+++ b/src/wallet/test/fuzz/CMakeLists.txt
2@@ -10,6 +10,7 @@ target_sources(fuzz
3 fees.cpp
4 $<$<BOOL:${USE_SQLITE}>:${CMAKE_CURRENT_LIST_DIR}/notifications.cpp>
5 parse_iso8601.cpp
6+ rpc.cpp
7 $<$<BOOL:${USE_SQLITE}>:${CMAKE_CURRENT_LIST_DIR}/scriptpubkeyman.cpp>
8 wallet_bdb_parser.cpp
9 )
Thanks!
Updated in 2c8cb2b
🚧 At least one of the CI tasks failed. Debug: https://github.com/bitcoin/bitcoin/runs/30049600088
Make sure to run all tests locally, according to the documentation.
The failure may happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
What is the state of this?
I have been busy for the last couple of weeks I can take a look at it and finish up to make it ready for review in the next week or so, sorry for the delay
By reusing some of the logic for the rpc fuzz target this new fuzz
target wallet_rpc adds coverage to the wallet rpc calls.
WALLET_RPC_COMMANDS_SAFE_FOR_FUZZING
and WALLET_RPC_COMMANDS_NOT_SAFE_FOR_FUZZING
37+ return supported_rpc_commands;
38+ }
39+};
40+
41+RPCWalletFuzzTestingSetup* rpc_wallet_testing_setup = nullptr;
42+std::string g_limit_to_rpc_command_wallet;
g_limit_to_rpc_command_wallet
is not being set, so LIMIT_TO_RPC_COMMAND
has no effect in this target. When using LIMIT_TO_RPC_COMMAND
for this target, it’s probably setting g_limit_to_rpc_command
in fuzz/rpc.cpp
.
@brunoerg I think this should be ready for review now, I think I just need to currate the list of WALLET_RPC_COMMANDS_SAFE_FOR_FUZZING and WALLET_RPC_COMMANDS_NOT_SAFE_FOR_FUZZING
Did you advance on curating the list? Is this the final list?
356+ std::cerr << "Error: RPC command \"" << rpc_command << "\" not found in rpc_commands_safe_for_fuzzing or RPC_COMMANDS_NOT_SAFE_FOR_FUZZING. Please update " << __FILE__ << ".\n";
357 std::terminate();
358 }
359 if (safe_for_fuzzing && not_safe_for_fuzzing) {
360- std::cerr << "Error: RPC command \"" << rpc_command << "\" found in *both* RPC_COMMANDS_SAFE_FOR_FUZZING and RPC_COMMANDS_NOT_SAFE_FOR_FUZZING. Please update " << __FILE__ << ".\n";
361+ std::cerr << "Error: RPC command \"" << rpc_command << "\" found in *both* rpc_commands_safe_for_fuzzing and RPC_COMMANDS_NOT_SAFE_FOR_FUZZING. Please update " << __FILE__ << ".\n";
wallet/test/fuzz/rpc.cpp
, this will ask to update the test/fuzz/rpc.cpp
file.
43+
44+// RPC commands which are safe for fuzzing.
45+const std::vector<std::string> WALLET_RPC_COMMANDS_NOT_SAFE_FOR_FUZZING{
46+ "importwallet",
47+ "loadwallet",
48+};
There are many more wallet rpcs that go to disk (e.g. createwallet
). I would assume a lot of the rpcs that modify a wallet also flush the changes to disk. And I don’t think it is possible to even have a wallet that doesn’t exist on disk, so trying to avoid disk access can’t work.
To work around this I would suggest to create (and delete at the end) a new wallet (e.g. /tmp/fuzz-wallet-xyz
) each iteration and call wallet rpcs on that specific wallet (could be more than one).
Are you still working on it?
Sorry I’ve been quite busy, I can close this PR and leave it up for grabs since I havent had a chance to make much progress lately