fuzz: Add fuzz target for block index tree and related validation events #31533

pull mzumsande wants to merge 1 commits into bitcoin:master from mzumsande:202412_fuzz_checkblockindex_pr changing 5 files +214 −3
  1. mzumsande commented at 5:53 pm on December 18, 2024: contributor

    This adds a fuzz target for the block index and various events in validation that interact with it.

    It can create arbitrary tree-like structure of block indexes, simulating (so far) the following events:

    • Adding a header
    • Receiving the full block (may be valid or not)
    • ActivateBestChain() - Reorging the chain to a new chain tip (possibly encountering invalid blocks on the way)
    • Pruning

    It might be interesting / possible to extend this to more events, such as dealing with more than one chainstate (assumeutxo).

    The test skips all actual validation of header/ block / transaction data by just simulating the outcome, and also doesn’t interact with the data directory. The main goal is to ensure the integrity of the block index tree in all fuzzed constellations, by calling CheckBlockIndex() at the end of each iteration.

    Compared to #29158 this approach has a more limited scope (by skipping all actual validation), but it is fast - it doesn’t do a full init sequence on each iteration, but “cleans up” after itself by resetting the global validation state after each iteration. One downside of this approach is that it needs to have public access to a few members / functions in Chainstate(Manager) / BlockManager.

    Looking for conceptual feedback for now, so will leave as draft for a bit - this was helpful while working on #31405 and found the problem described in #31512.

  2. fuzz: Add fuzzer for block index
    This fuzz target creates arbitrary tree-like structure of indices,
    simulating the following events:
    - Adding a header to the block tree db
    - Receiving the full block (may be valid or not)
    - Reorging to a new chain tip (possibly encountering invalid blocks on
      the way)
    - pruning
    The test skips all actual validation of header/ block / transaction data
    by just simulating the outcome, and also doesn't interact with the data directory.
    
    The main goal is to test the integrity of the block index tree in
    all fuzzed constellations, by calling CheckBlockIndex()
    at the end of each iteration.
    0e0322767c
  3. DrahtBot commented at 5:53 pm on December 18, 2024: contributor

    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/31533.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

  4. DrahtBot added the label Tests on Dec 18, 2024
  5. mzumsande marked this as a draft on Dec 18, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-21 12:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me