mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:47:36 +00:00
fuzz: Cover block filter P2P messages #36337
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36337
Loading…
Reference in a new issue
No description provided.
Delete branch "2609-fuzz-block-filter-p2p"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The BIP157 P2P messages are not covered by any fuzz targets at all.
Fix this to cover them via the P2P targets.
Should be possible to test by verifying the integer sanitizer is triggered (https://github.com/bitcoin/bitcoin/pull/36321#issuecomment-5810977529):
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
No conflicts as of last run.
LLM Linter (✨ experimental)
Possible places where named args for integral literals may be used (e.g.
func(x, /*named_arg=*/0)in C++, andfunc(x, named_arg=0)in Python):src/test/util/validation.cpp:InitBlockFilterIndex(..., BlockFilterType::BASIC, 1_MiB, /*f_memory=*/true, /*f_wipe=*/true)2026-10-08 05:10:07
🚧 At least one of the CI tasks failed.
Task
MSan, fuzz: https://github.com/bitcoin/bitcoin/actions/runs/36168019330/job/108180422242LLM reason (✨ experimental): MemorySanitizer (fuzz test) reported a use of an uninitialized value in
BaseIndex::Stop()(base.cpp:479), causing exit code 1 and the CI failure.Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
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.
I think CI failures are because in process_message(s) the
static testing_setupis destructed beforestatic g_filter_indexessoBaseIndex::Stopwill try to accesstesting_setup.m_node.Can you explain why it deadlocks? I couldn't figure this bit out
cc @marcofleon
Base:
db0bde16b910f43e37252d4172d97f01653ae0f1Head:
fab64c032c1a0c997c6ec398cc5578df36b33b7dDesign and approach
Measure filter-index sync cost on dirty resets (src/test/util/validation.cpp:145, head)
Both P2P targets rebuild the 200-block fixture after an input changes the block index or mempool, and this sync generates and writes filters for that chain. Please compare fuzz executions per second on the dirty-reset path with and without this setup. If it materially reduces throughput, scope index setup to relevant inputs or use a focused target, recognizing that the latter reduces multi-message interaction coverage. If the measured impact is negligible, the current setup is reasonable.
Review coverage was incomplete. adversarial: BaseIndex::Stop() was not inspected before the review limit, leaving callback unregistration and repeated-stop safety unverified for the newly created, stopped, and later destroyed indexes. adversarial: The remaining ProcessGetCFCheckPt() body and existing blockfilter_index_tests.cpp lifecycle tests were not inspected, leaving the complete newly reachable checkpoint path and compatibility of fixture-wide index destruction unverified.
Full review report
Sure. I guess the "fuzzed block" explanation is a bit confusing, because this is a general unit test utility, not limited to fuzzing.
The idea is:
github.com/bitcoin/bitcoin@3b9768a07a/src/validation.cpp (L3367-L3408)ImmediateBackgroundTaskRunnera new thread is spawned to handle it, which obviously can't take cs_main again.github.com/bitcoin/bitcoin@3b9768a07a/src/kernel/chain.cpp (L25)will deadlock via callback thread: BaseIndex::BlockConnected() → ProcessBlock() → kernel::MakeBlockInfo() → tries to lock cs_mainI guess in theory one could use
ImmediateTaskRunner(reverting https://github.com/bitcoin/bitcoin/pull/36046), but that would bring back the issues from there.Thx, fixed by destroying the indexes in the testing dtor, which seems useful generally, unrelated to the changes here.
crACK
fa47c22f7aChecked this didn't introduce non-determinism using qa-assets corpus. I think new seeds for
process_message(s)are needed since no seeds currently reach pastPrepareBlockFilterRequest.I had my LLM-based fuzz engine (based on inverse fdp: https://github.com/maflcko/DrahtBot/blob/main/inverse_fdp/build.rs#L1) create the one in the pull description, and I can submit some more later
Might be off-topic, but could you explain how this works? I've been trying to come up with ways to have LLMs help with fuzzing and haven't come up with anything that I like. Does the LLM see coverage is stuck and then generate a test case with inverse-fdp to unblock the fuzzer?
It is pretty primitive. I selected a fuzz input manually to start with and then asked the LLM to modify it.
LLM prompt (experimental)
Maybe if someone is bored they can generalize it, so that the LLM decides itself where to start and what coverage to add, but this seems too open ended for me to work on.
🐙 This pull request conflicts with the target branch and needs rebase.
rebased. Should be trivial to re-ack via
git range-diff bitcoin-core/master fa47c22f7a fa09c6c140ACK
fa09c6c140Coverage from this PR running from scratch:
process message
process messages
I didn't run these for super long (only a couple days) but you can see new coverage easily in
blockfilterindex.cpp.nit: Could use the new
StopIndex()here.thx, done.
re-ACK
fab64c032cre-ACK
fab64c032c