blockstorage: keep snapshot base in normal blockfile range #35307

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

    The background chainstate connects the assumeutxo snapshot base block. If that block is stored before loadtxoutset() sets BlockManager::m_snapshot_height, it is written using the normal blockfile cursor.

    After snapshot activation, the base height was classified as ASSUMED. If background validation later connected the already-stored base block, WriteBlockUndo() could require an ASSUMED cursor that had not been initialized.

    Classify only blocks above the snapshot base height as ASSUMED. Keep the snapshot chainstate flush path from flushing the normal cursor while it is still at the base height.

    When loading a snapshot chainstate from disk, keep an already-stored base block in m_blocks_unlinked until its parents are processed, and avoid adding the historical target to setBlockIndexCandidates before then. VerifyDB also stops before disconnecting the snapshot base, where the snapshot database lacks the ancestor UTXO data.

    The functional test stores the snapshot base block before loading the snapshot, restarts after snapshot activation, then feeds the missing historical blocks and checks that background validation completes.

    Tested:

    test/functional/feature_assumeutxo.py --configfile=$PWD/build/test/config.ini --timeout-factor=4
    test/functional/wallet_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:

    • #35359 (blockstorage: Remove cs_LastBlockFile recursive mutex by sedited)

    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. shuv-amp force-pushed on May 17, 2026
  5. 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
  6. shuv-amp marked this as ready for review on May 17, 2026
  7. mzumsande commented at 1:45 PM on May 18, 2026: contributor

    why would someone load a snapshot when they already downloaded the block, which means that their tip must be no more than 1024 blocks behind that block.

  8. shuv-amp commented at 3:47 PM on May 18, 2026: none

    I don't think the normal P2P download path is a strong motivation here. In that case, as you say, the node would already be close to the snapshot height.

    The case covered here is that this blockstorage state is accepted through local block submission/import before snapshot activation. For example, submitblock can store the snapshot base block while m_snapshot_height is still unset, so it is accounted under the normal blockfile cursor. After loadtxoutset(), the same height maps to ASSUMED; if no assumed blockfile cursor exists yet, background validation can later connect that block and hit the cursor assertion in WriteBlockUndo().

    So I’d frame this as making an accepted blockstorage state not abort, rather than as an important/common assumeutxo path. If maintainers prefer not to support that state, rejecting it during snapshot activation would be another possible direction.

  9. shuv-amp commented at 7:28 PM on May 19, 2026: none

    Taking this back to draft for now.

  10. shuv-amp marked this as a draft on May 19, 2026
  11. blockstorage: keep snapshot base in normal blockfile range
    The background chainstate connects the assumeutxo snapshot base block. If
    that block is accepted before loadtxoutset() sets m_snapshot_height, it is
    written using the normal blockfile cursor.
    
    After snapshot activation, classify only blocks above the base height as
    ASSUMED. This keeps the already-stored base block and its undo data on the
    normal cursor, while snapshot-chainstate flushes at the base height still
    avoid flushing normal block data.
    
    On restart, keep an already-stored base block in m_blocks_unlinked until
    its parents are processed, and avoid adding the historical target to
    setBlockIndexCandidates before then. Stop VerifyDB before disconnecting the
    snapshot base, where the snapshot database lacks the ancestor UTXO data.
    
    Add functional coverage for the base block already being on disk before
    snapshot activation, including a restart before background validation
    completes. Adjust the wallet assumeutxo prune-height test so the backup at
    the snapshot base remains available.
    b520eabc04
  12. shuv-amp force-pushed on May 21, 2026
  13. shuv-amp renamed this:
    blockstorage: handle undo for assumeutxo base block already on disk
    blockstorage: keep snapshot base in normal blockfile range
    on May 21, 2026
  14. DrahtBot added the label CI failed on May 21, 2026
  15. shuv-amp marked this as ready for review on May 21, 2026
  16. DrahtBot removed the label CI failed on May 22, 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-06-07 11:53 UTC

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