Efficient isolated fuzzing of our message processing code (net processing) would be very valuable. However, to make that deterministic, fast and fuzzer friendly it appears that extensive refactoring is required. There are three main blockers: module separation (net/net processing/validation split), determinism, performance.
I am gonna use this issue to track and motivate the work that needs to be done. It would be great if we can achieve the same outcome with less refactoring but I don’t see how at the moment. Open to suggestions and feedback.
Module separation
Once we have a clean separation between our net, net processing and validation modules, we can fuzz/test them in isolation to maximize the bug yield (🐛, 🪲, 🪳). By design, most fuzzing engines are not great at finding bugs when the scope of the targets is too large (e.g. fuzzing net, net processing and validation all at once).
- net / net processing split (https://github.com/bitcoin/bitcoin/pull/28252)
- net processing / validation split (lots of overlap with kernel)
Determinism
Non-deterministic fuzz targets are less efficient at finding bugs and debugging non-reproducible bugs is annoying/costly.
- All required components should be newly setup for each target execution
- Can be done currently using our testing setup suite but that’s waaaay too slow for fuzzing.
- Avoid
GetRand()
(mock it?) - Avoid globals (are there any globals left in net processing?)
Performance
Fuzzing is a search, the faster the search - the better.
- LevelDB (is in memory but still slow?)
- Probably solved by mocking out validation?
- PeerManager construction is expensive because it requires multi megabyte allocations each time (mostly due to large bloom filters)
- Disk usage
- Block storage
- #27125
- Create a mock of BlockManager for in memory block storage?
- BanMan (banlist is written to disk)
- Block storage
Misc
- Decouple net processing from ArgsMan (args setup is slow)
- Allows to fuzz the peerman options without depending on the global args man
Please let me know if you think there are PRs that aren’t listed here but should be.