Repository navigation
Description
The wallet has poor fuzz coverage. Hopefully, some work is being done to improve it. The goal of this issue is to actively track current work and work that needs to be done to improve fuzz coverage for the wallet.
Open PRs / Ready to review
- fuzz: several improvements to scriptpubkeyman harness #34969
- fuzz: wallet: add target for
TransactionCanBeBumped#33916 - fuzz: wallet: add target for tx scanning #32993
- fuzz: Add tests for
CCoinControlmethods #34026 - fuzz: wallet: add target for
MigrateToDescriptor#32624 - fuzz: Reject too large descriptor leaf sizes in scriptpubkeyman target #34230
- fuzz: split
coinselectionharness #31870 - fuzz: coinselection: cover
SetBumpFeeDiscount#31806 - fuzz: wallet: add target for spkm migration #29694
- fuzz: wallet: add target for
CreateTransaction#29936 - fuzz: add more coverage for
ScriptPubKeyMan#30134 - fuzz: wallet, add target for
Crypter#28074 - fuzz: wallet: remove
FundTxfromFuzzedWallet#32772 - fuzz: enhance wallet_fees by mocking mempool stuff #33210
Current wallet targets
See src/wallet/test/fuzz to see the existing wallet targets and https://maflcko.github.io/b-c-cov/fuzz.coverage/src/wallet/index.html for coverage.
Won't/Can't cover/Known issues
Legacy wallet removal
The goal is to remove legacy wallets and migrate them to descriptor ones. There is an open issue with a proposed timeline for Legacy Wallet and BDB removal (#20160). For this reason, we do not aim to increase fuzz coverage for legacy stuff. See that the scriptpubkeyman target only uses descriptor ones.
edit: legacy wallet has been removed.
External signer
I do believe we can't have fuzz coverage for external signer code.
Performance and determinism
Unfortunately, some aspects of the wallet may affect the fuzzing performance. E.g.:
SetupDescriptorScriptPubKeyMans(it might also be non-deterministic due to key generation)- Wallet encryption
- Keypool (we usually set it to 1 to avoid any issue)
- DB interactions
Wallet RPC
There were some PRs attempting to create a fuzz target for wallet RPCs. However, it's not straightforward to do it since many RPCs depend on other contexts (e.g. fuzzing the listsinceblock RPC without producing any blocks does not seem too efficient). Also, the performance is another issue to take in consideration.
Any ideas about it or PRs to add let me know.
Activity
maflcko commentedon Apr 17, 2024
Coverage is nice, but if the fuzz test never finds any real user-facing issues, it will be useless. I don't think any wallet fuzz target found a real issue yet? Obviously coverage is the first step toward adding regression fuzz tests, so here are some ideas:
I wrote the
ImportDescriptorshelper, which should be deterministic.Edit: Also links to the current coverage:
brunoerg commentedon Apr 18, 2024
I think we found a real issue with the coin selection target after the rework. But yes, it would be the only one.
I'm working on a target to cover and reproduce #27271.
brunoerg commentedon Apr 22, 2024
Just added #29936 to the list. It's a regression to #27271.
brunoerg commentedon May 17, 2024
Added #30134 to the list for review. It adds more coverage for
ScriptPubKeyMan.edit: merged
kevkevinpal commentedon Jul 23, 2024
I started to take a look at the Wallet RPC issue, I'm still fairly new to fuzz testing so it might take longer but I am working off of this branch if you would like to track my progress.
kevkevinpal commentedon Jul 30, 2024
I was able to get the coverage to
I think I just need to run the fuzzer for longer to get better coverage but I can do more testing and also cleanup my branch. If you would like the qa-assets for
wallet-rpcplease let me know.murchandamus commentedon Jul 30, 2024
Given that the first segment of your seeds need to correspond to an RPC command, a dictionary might help with bootstrapping.
I’m also not particularly knowledgeable about building fuzz tests, but it seems to me that it might be better to build a separate harness for each RPC?
maflcko commentedon Jul 30, 2024
Most fuzz engines will create the dictionary themselves, by extracting the string literals. If not,
-use_value_profile=1may be useful to "recover" the RPC name.If you look at the coverage line-by-line, you will be able to see where the fuzz engine returns early. The right fix will then usually be obvious.
brunoerg commentedon Nov 11, 2024
Removed #30570 since it's closed.
brunoerg commentedon Dec 18, 2024
Not sure about performance issues, but a fuzz target to cover #31474 would be great?
brunoerg commentedon Feb 15, 2025
I'm working on it.
brunoerg commentedon Nov 1, 2025
wallet_create_transactionandscriptpubkeymanare two targets that I'm taking a look to try to speed them up. I'm getting less than 10 exec/s for both of them on my personal server which is bad. Just added to the "Nice to have" section the "Speed up current targets".brunoerg commentedon Nov 20, 2025
Just added #33916 to the review list. This PR adds a fuzz target for the
TransactionCanBeBumpedfunction fromfeebumper.