validation: stop reindex on invalid genesis block #36646

pull fametrano wants to merge 1 commits into bitcoin:master from fametrano:validation-reindex-corrupt-genesis changing 2 files +31 −0
  1. fametrano commented at 8:03 AM on October 24, 2026: none

    -reindex leaves the node unable to start when the genesis block in blk00000.dat has a valid header but an invalid body. With -checkblockindex, the default on regtest, it aborts on an assert in CheckBlockIndex. Without it, it stays in RPC warmup.

    I stop the reindex with a fatal error when the genesis block is found invalid. Its header is already in the block index by then, so the blocks after it could not connect. A new case in feature_reindex.py flips a bit in the genesis block and expects the error, and on master it hits the assert instead. The reindex, loadblock, pruning and assumeutxo functional tests and the unit tests pass.

    This is one of several PRs from a large audit of Bitcoin Core that I did with the help of LLM tools. The audit produced its evidence all at once, which is why the PRs arrive together. I understand each change fully and will answer review questions myself.

  2. validation: stop reindex on invalid genesis block
    If the genesis block in blk00000.dat has an intact header but an invalid
    body, -reindex adds the header to the block index and rejects the block.
    The header of block 1 is then added too. With -checkblockindex, which is
    on by default for regtest, CheckBlockIndex asserts that an index without
    an active chain has at most one entry. Without it, the node stays in RPC
    warmup.
    
    I stop the reindex with a fatal error when the genesis block is read but
    found invalid. The functional test flips a bit in the genesis block and
    expects that error.
    3e65b0eaa9
  3. DrahtBot added the label Validation on Oct 24, 2026
  4. DrahtBot commented at 8:03 AM on October 24, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #36000 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36000.svg"></sub> (validation: prefetch blocks while connecting by l0rinc)
    • #35071 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35071.svg"></sub> (Reindex: save progress to continue after interruption by pinheadmz)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

Contributors

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: 2026-10-27 17:51 UTC

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