AssumeUTXO custom-network snapshot mismatches fail with `bad_optional_access` #37065

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

    Loading a snapshot made for another network should fail with a message naming both networks. When the node's own message start isn't one of the built-in networks (as on a custom signet), naming it calls .value() on an empty lookup, and loadtxoutset fails with a bare bad_optional_access instead.

    <details> <summary>Reproducer</summary>

    diff --git a/src/test/validation_chainstatemanager_tests.cpp b/src/test/validation_chainstatemanager_tests.cpp
    index d8463f5dc3..6425952e87 100644
    --- a/src/test/validation_chainstatemanager_tests.cpp
    +++ b/src/test/validation_chainstatemanager_tests.cpp
    @@ -11,6 +11,7 @@
     #include <node/utxo_snapshot.h>
     #include <random.h>
     #include <rpc/blockchain.h>
    +#include <streams.h>
     #include <sync.h>
     #include <test/util/chainstate.h>
     #include <test/util/common.h>
    @@ -27,6 +28,7 @@
     
     #include <tinyformat.h>
     
    +#include <optional>
     #include <vector>
     
     #include <boost/test/unit_test.hpp>
    @@ -37,6 +39,16 @@ using node::SnapshotMetadata;
     
     BOOST_FIXTURE_TEST_SUITE(validation_chainstatemanager_tests, TestingSetup)
     
    +BOOST_AUTO_TEST_CASE(snapshot_metadata_custom_network_mismatch)
    +{
    +    DataStream stream;
    +    stream << SnapshotMetadata{CChainParams::Main()->MessageStart()};
    +    SnapshotMetadata metadata{MessageStartChars{0x01, 0x02, 0x03, 0x04}};
    +
    +    // TODO: Report the network mismatch instead of throwing from the missing network name.
    +    BOOST_CHECK_THROW(stream >> metadata, std::bad_optional_access);
    +}
    +
     //! Basic tests for ChainstateManager.
     //!
     //! First create a legacy (IBD) chainstate, then create a snapshot chainstate.
    

    </details>

    The direct fix would be to fall back to a placeholder name for the node's network (the closed #36568 used custom signet), but given that this parser 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