Failed AssumeUTXO snapshot activation leaves shared block-index metadata changed #37078

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

    PopulateAndValidateSnapshot() changes shared block-index fields before ActivateSnapshot() has finished. If activation later fails (as when writing base_blockhash fails), the snapshot chainstate is discarded but the base block keeps its snapshot transaction count and the modified entries remain dirty. With block-index checks enabled, the next connected block then aborts the node in CheckBlockIndex().

    <details> <summary>Reproducer</summary>

    diff --git a/src/test/validation_chainstate_tests.cpp b/src/test/validation_chainstate_tests.cpp
    index d8fb378171..b841f3aac7 100644
    --- a/src/test/validation_chainstate_tests.cpp
    +++ b/src/test/validation_chainstate_tests.cpp
    @@ -173,4 +173,19 @@ BOOST_FIXTURE_TEST_CASE(chainstate_update_tip, TestChain100Setup)
         BOOST_CHECK_EQUAL(curr_tip, get_notify_tip());
     }
     
    +BOOST_FIXTURE_TEST_CASE(failed_snapshot_activation_changes_block_index, TestChain100Setup)
    +{
    +    ChainstateManager& chainman{*Assert(m_node.chainman)};
    +    mineBlocks(10);
    +    CBlockIndex* base{WITH_LOCK(::cs_main, return chainman.ActiveTip())};
    +
    +    BOOST_REQUIRE(!CreateAndActivateUTXOSnapshot(this, [&](AutoFile&, node::SnapshotMetadata&) {
    +        fs::create_directories(chainman.m_options.datadir / "chainstate_snapshot" / node::SNAPSHOT_BLOCKHASH_FILENAME);
    +    }, /*reset_chainstate=*/true));
    +
    +    LOCK(::cs_main);
    +    BOOST_CHECK(chainman.CurrentChainstate().SnapshotBase() == nullptr);
    +    BOOST_CHECK_NE(base->m_chain_tx_count, 0); // TODO: Leave the shared block index unchanged after a failed activation
    +}
    +
     BOOST_AUTO_TEST_SUITE_END()
    

    </details>

    The direct fix would be to apply the shared block-index changes only after activation succeeds, but given that AssumeUTXO fixes haven't attracted much review, 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