[31.x] Backport #35168 #36361

pull fametrano wants to merge 2 commits into bitcoin:31.x from fametrano:31.x-backport-35168 changing 3 files +43 −1
  1. fametrano commented at 9:35 PM on September 27, 2026: contributor

    Backports:

    v31.1 still has the pre-fix LoadBlockIndex. It re-adds a pruned block to m_blocks_unlinked when its parent is header-only (#35050). When the next block connects, CheckBlockIndex fails with Assertion failed: (!foundInUnlinked). -checkblockindex is on by default only on regtest, so this crashes functional-test suites run against 31.x. With default settings, nodes on mainnet, testnet and signet do not run this check, so they do not crash.

    Both commits are clean cherry-picks (-x). The only difference from master is context in test_runner.py. The new feature_prune_stale_fork.py fails on the v31.1 release binary with the assertion above. It passes on this branch, built from depends. Two runs each, on macOS arm64.

    Made with my usual tools: a computer, the Internet and an LLM. The mistakes, as usual, are all mine.

  2. validation: Don't add pruned blocks to m_blocks_unlinked on startup
    LoadBlockIndex() adds to m_blocks_unlinked based only on nTx > 0, without
    checking BLOCK_HAVE_DATA. Pruning preserves nTx but clears BLOCK_HAVE_DATA,
    so a pruned block whose parent was header-only gets re-added on every
    restart, causing the CheckBlockIndex() assertion that entries must have
    data on disk to fail.
    
    Check that BLOCK_HAVE_DATA is set before inserting into m_blocks_unlinked.
    
    Fixes #35050.
    
    (cherry picked from commit 0e4b0bacecf94063342c7f9eb9b03dac8a7a7936)
    6cedc5d47e
  3. test: Add coverage for m_blocks_unlinked invariant in LoadBlockIndex
    A pruned stale-fork block whose parent doesn't have any transactions
    shouldn't be added to m_blocks_unlinked when starting up a node.
    
    (cherry picked from commit 3f44f9aef7ccd0417fcd0c2f33f20615ea5c11e6)
    5ec487b9ae
  4. DrahtBot added the label Backport on Sep 27, 2026
  5. DrahtBot commented at 9:35 PM on September 27, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/36361.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

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

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  6. fanquake added this to the milestone 31.2 on Oct 21, 2026

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-24 20:51 UTC

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