Skip to content

Conversation

kevkevinpal
Copy link
Contributor

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

@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 1, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/30570.

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept ACK maflcko, dergoegge, brunoerg

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

No conflicts as of last run.

"loadwallet",
};
// RPC commands which are safe for fuzzing.
const std::vector<std::string> WALLET_RPC_COMMANDS_SAFE_FOR_FUZZING{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will need to move some of these over due to the rpc accessing the disk or network activity

@kevkevinpal
Copy link
Contributor Author

This is a screenshot of the coverage I was able to generate so far for ./src/wallet/rpc

Screenshot 2024-08-01 at 6 47 13 PM

@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 2, 2024

🚧 At least one of the CI tasks failed.
Debug: https://github.com/bitcoin/bitcoin/runs/28242205421

Hints

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.

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK. To fix the CI failure, you'll have to move the new file to src/wallet/test/fuzz/.

@dergoegge
Copy link
Member

Concept ACK

1 similar comment
@brunoerg
Copy link
Contributor

brunoerg commented Aug 2, 2024

Concept ACK

@DrahtBot
Copy link
Contributor

🚧 At least one of the CI tasks failed.
Debug: https://github.com/bitcoin/bitcoin/runs/30049600088

Hints

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.

@brunoerg
Copy link
Contributor

What is the state of this?

@kevkevinpal
Copy link
Contributor Author

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.
@kevkevinpal kevkevinpal marked this pull request as ready for review September 25, 2024 13:15
@kevkevinpal
Copy link
Contributor Author

@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

@brunoerg brunoerg mentioned this pull request Oct 17, 2024
13 tasks
};

RPCWalletFuzzTestingSetup* rpc_wallet_testing_setup = nullptr;
std::string g_limit_to_rpc_command_wallet;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 26591de: 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
Copy link
Contributor

@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?

std::terminate();
}
if (safe_for_fuzzing && not_safe_for_fuzzing) {
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";
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";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 26591de: nit: If something got wrong with wallet/test/fuzz/rpc.cpp, this will ask to update the test/fuzz/rpc.cpp file.

Comment on lines +45 to +48
const std::vector<std::string> WALLET_RPC_COMMANDS_NOT_SAFE_FOR_FUZZING{
"importwallet",
"loadwallet",
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@brunoerg
Copy link
Contributor

I think we will have here the same problems that we usually have for other wallet targets. The size of keypool, wallet encryption, etc... may cause timeout issues.

@brunoerg
Copy link
Contributor

brunoerg commented Nov 5, 2024

Are you still working on it?

@kevkevinpal
Copy link
Contributor Author

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

@kevkevinpal kevkevinpal closed this Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants