Startup checks the snapshot's base hash against the AssumeUTXO chain parameters, but not whether the local block index contains that header. If the block index is lost while a snapshot chainstate remains, startup dereferences the missing entry and crashes with a segmentation fault on every restart, without recovery guidance.
<details> <summary>Reproducer</summary>
diff --git a/test/functional/feature_assumeutxo.py b/test/functional/feature_assumeutxo.py
index fa9466f2d8..1732e87a26 100755
--- a/test/functional/feature_assumeutxo.py
+++ b/test/functional/feature_assumeutxo.py
@@ -10,6 +10,7 @@ The assumeutxo value generated and used here is committed to in
`CRegTestParams::m_assumeutxo_data` in `src/kernel/chainparams.cpp`.
"""
import contextlib
+import shutil
from dataclasses import dataclass
from test_framework.blocktools import (
@@ -391,6 +392,20 @@ class AssumeutxoTest(BitcoinTestFramework):
assert not (node.datadir_path / node.chain / "chainstate_snapshot").exists()
+ def test_block_index_missing_base_block(self):
+ self.log.info("Test that a snapshot base block missing from the block index crashes startup")
+ node = self.nodes[2]
+ # This node still runs on a snapshot-based chainstate at this point.
+ assert (node.chain_path / "chainstate_snapshot").exists()
+
+ node.stop_node()
+ # Deleting the block index is a common remedy for block index corruption. The freshly
+ # created index then no longer contains the block the snapshot chainstate is based on.
+ shutil.rmtree(node.blocks_path / "index")
+
+ node.start()
+ node.wait_until_stopped(expected_ret_code=-11) # TODO: Explain how to recover instead of crashing on the missing base block
+
def run_test(self):
"""
Bring up two (disconnected) nodes, mine some new blocks on the first,
@@ -811,6 +826,8 @@ class AssumeutxoTest(BitcoinTestFramework):
self.test_sync_to_most_work_chain_after_background_validation()
+ self.test_block_index_missing_base_block()
+ [@dataclass](/bitcoin-bitcoin/contributor/dataclass/)
class Block:
hash: str
</details>
The direct fix would be to reject the missing header and explain how to rebuild the index or discard the snapshot, but given that this persisted dependency disappears with snapshot loading, I'm proposing to remove AssumeUTXO entirely in #36598 instead.