Runtime AssumeUTXO loading can leave undo writes without a block-file cursor #37077

issue l0rinc opened this issue on December 2, 2026
  1. l0rinc commented at 9:13 PM on December 2, 2026: contributor

    Runtime snapshot activation can classify existing blocks as snapshot-file blocks without initializing that block-file cursor. WriteBlockUndo() asserts that the cursor exists before checking whether the block already has undo data, so even a no-op call aborts the node.

    <details> <summary>Reproducer</summary>

    This sets the snapshot height directly to reach the state left by runtime activation.

    diff --git a/src/test/blockmanager_tests.cpp b/src/test/blockmanager_tests.cpp
    index f6df5aa9f6..933b0b6dbe 100644
    --- a/src/test/blockmanager_tests.cpp
    +++ b/src/test/blockmanager_tests.cpp
    @@ -5,11 +5,13 @@
     #include <chain.h>
     #include <chainparams.h>
     #include <clientversion.h>
    +#include <consensus/validation.h>
     #include <node/blockstorage.h>
     #include <node/context.h>
     #include <node/kernel_notifications.h>
     #include <script/solver.h>
     #include <primitives/block.h>
    +#include <undo.h>
     #include <util/chaintype.h>
     #include <validation.h>
     
    @@ -348,4 +350,19 @@ BOOST_FIXTURE_TEST_CASE(blockmanager_add_to_block_index_best_header, TestingSetu
         BOOST_CHECK_EQUAL(best_header, first);
     }
     
    +BOOST_FIXTURE_TEST_CASE(blockmanager_writeblockundo_unset_cursor, TestChain100Setup)
    +{
    +    auto& blockman{m_node.chainman->m_blockman};
    +    LOCK(::cs_main);
    +    CBlockIndex& block{*Assert(m_node.chainman->ActiveChain().Tip())};
    +    BOOST_REQUIRE(!block.GetUndoPos().IsNull());
    +
    +    const auto old_snapshot_height{blockman.m_snapshot_height};
    +    blockman.m_snapshot_height = block.nHeight;
    +    BlockValidationState state;
    +    const bool no_op{blockman.WriteBlockUndo(CBlockUndo{}, state, block)};
    +    blockman.m_snapshot_height = old_snapshot_height;
    +    BOOST_CHECK(no_op); // TODO: Existing undo data needs no cursor
    +}
    +
     BOOST_AUTO_TEST_SUITE_END()
    

    </details>

    The direct fix would be to return before cursor access when undo already exists and initialize new writes safely (#35307 instead kept the snapshot base in the normal block-file range), but given that the split block-file cursor exists only for AssumeUTXO, I'm proposing to remove AssumeUTXO entirely in #36598 instead.


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-12-03 02:51 UTC

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