blockstorage: handle undo for assumeutxo base block already on disk #35307

pull shuv-amp wants to merge 1 commits into bitcoin:master from shuv-amp:blockstorage-assumeutxo-base-range changing 4 files +68 −22
  1. shuv-amp commented at 3:57 PM on May 17, 2026: none

    A node can receive the assumeutxo snapshot base block before loading the snapshot. In that case the block data is written before BlockManager::m_snapshot_height is set, so it is tracked by the normal blockfile cursor.

    After loadtxoutset() sets m_snapshot_height, the same height maps to the ASSUMED blockfile range. If background validation later connects the base block that was already on disk, WriteBlockUndo() could require an ASSUMED cursor even though no post-snapshot block data had created one yet.

    Handle this by writing undo data to the block's existing file when the height-derived cursor is not present. Keep the existing cursor finalization logic when a cursor exists.

    FlushChainstateBlockFile() now receives the tip block index, so it can flush the file where the tip is actually stored when needed.

    The functional test stores the snapshot base block before loading the snapshot, then feeds the missing historical blocks and waits for background validation to complete.

    Tested:

    test/functional/feature_assumeutxo.py --configfile=$PWD/build/test/config.ini --timeout-factor=4
    
  2. DrahtBot added the label Block storage on May 17, 2026
  3. DrahtBot commented at 3:57 PM on May 17, 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/35307.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #30342 (kernel, logging: Pass Logger instances to kernel objects by ryanofsky)

    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-->

  4. blockstorage: handle undo for pre-stored assumeutxo base
    An assumeutxo snapshot base block can be stored before loadtxoutset()
    sets BlockManager::m_snapshot_height. After the snapshot is loaded,
    BlockfileTypeForHeight() classifies that height as ASSUMED, but the
    ASSUMED blockfile cursor may not exist yet.
    
    When background validation connects the already-stored base block, write
    undo data to the block's existing file without requiring the
    height-derived cursor to exist. Keep the existing cursor finalization
    logic when the cursor is present.
    
    FlushChainstateBlockFile now receives the tip block index, so it can
    flush the file where the tip is actually stored if no height-derived
    cursor exists. A snapshot chainstate at the base height can still return
    without flushing because it has not written post-snapshot block data.
    
    Add functional coverage for storing the snapshot base block before
    loading the snapshot, then completing background validation.
    1a22546ccf
  5. shuv-amp force-pushed on May 17, 2026
  6. shuv-amp renamed this:
    blockstorage: keep assumeutxo base block in normal blockfile range
    blockstorage: handle undo for assumeutxo base block already on disk
    on May 17, 2026
  7. shuv-amp marked this as ready for review on May 17, 2026
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-05-18 06:12 UTC

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