Hi Bitcoin Core maintainers.
This PR is a remastered version of fuzzing harnesses developed during a Bitcoin Core audit. It includes three different fuzzing harnesses which motivation was the following:
connect_block: Test the ConnectBlock() function responsible of validating the block and all its transaction with consensus rules. Thanks tojustCheckparameter no side effect is performed on the internal state enabling relatively fast fuzzing.activate_best_chain_step: Test the ActivateBestChainStep() function responsible of activating the most worked-chain (not selecting it). The harness is written in a way that enable the fuzzer triggering a chain reorganization if it generates two valid branches.activate_best_chain: Test the ActivateBestChain() function responsible of selecting and activating the most worked-chain.
In the two later harnesses, some internal state cleaning is required to avoid non-reproducibility issues. Also they might produce file artifacts on disk by means of writing blocks.
Besides pre-mining blocks, the harness initialization intends to bring a bit more of diversity by introducing additional transactions in blocks (otherwise only coinbases), and put some transactions in the mempool so that they can be ‘picked’ and put in a block by means of input mutation.
These harnesses enables improving function coverage on ActivateBestChainStep, removeForBlock and to
cover function uncovered by fuzzing at the time of fuzzing harness development (mid-2025).
Functions newly covered include DisconnectTip, DisconnectBlock, ApplyTxInUndo, MaybeUpdateMempoolForReorg, removeForReorg etc. The attached figure shows in red function previously uncovered. (This might have slightly changed since then).
We tried to make the implementation as lean as possible but we are eager of any improvement feedbacks.
Authored by @RobinDavid and @nsurbay