Truncated AssumeUTXO metadata blocks node startup #37066

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

    Startup throws if an active snapshot's base_blockhash file is shorter than 32 bytes, which a crash can leave behind because the file is written in place without a sync. Every restart then fails with "Error loading databases", even with the suggested -reindex, until the snapshot directory is removed, although the ordinary chainstate is still usable.

    <details> <summary>Reproducer</summary>

    diff --git a/src/test/validation_chainstatemanager_tests.cpp b/src/test/validation_chainstatemanager_tests.cpp
    index d8463f5dc3..b804d4ed8a 100644
    --- a/src/test/validation_chainstatemanager_tests.cpp
    +++ b/src/test/validation_chainstatemanager_tests.cpp
    @@ -20,6 +20,7 @@
     #include <test/util/validation.h>
     #include <uint256.h>
     #include <util/byte_units.h>
    +#include <util/readwritefile.h>
     #include <util/result.h>
     #include <util/vector.h>
     #include <validation.h>
    @@ -37,6 +38,15 @@ using node::SnapshotMetadata;
     
     BOOST_FIXTURE_TEST_SUITE(validation_chainstatemanager_tests, TestingSetup)
     
    +BOOST_AUTO_TEST_CASE(read_snapshot_base_blockhash_truncated)
    +{
    +    const fs::path dir{m_path_root / "chainstate_snapshot"};
    +    fs::create_directories(dir);
    +    BOOST_REQUIRE(WriteBinaryFile(dir / node::SNAPSHOT_BLOCKHASH_FILENAME, "short"));
    +    LOCK(::cs_main);
    +    BOOST_CHECK_THROW(node::ReadSnapshotBaseBlockhash(dir), std::ios_base::failure); // TODO: Ignore truncated snapshot metadata
    +}
    +
     //! Basic tests for ChainstateManager.
     //!
     //! First create a legacy (IBD) chainstate, then create a snapshot chainstate.
    

    </details>

    The direct fix would be to treat unreadable snapshot metadata as malformed and commit new metadata durably, but given that this startup state disappears with snapshot loading, 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