Remove assumeutxo / UTXO-snapshot feature
Removes the dumptxoutset RPC, -loadutxosnapshot / -loadutxosnapshotunsafe, the CCoinsViewDB Dump/LoadSnapshot machinery + CUTXOSnapshotHeader, the AssumeutxoData chainparams anchor, the LoadSnapshotChainstate activation + reorg-below-H guard, the persisted assumeutxo-height flag, and the gtest. Rationale: it duplicated the existing bootstrap (same skip-the-genesis-grind fast-sync, no speed advantage), its only real edge was a trust model we don't need for this chain, and it was inert anyway (no published snapshot hash in chainparams). The -loadutxosnapshot load path adopted an external UTXO set and bypassed genesis validation, so removing it also drops that attack surface. Builds clean (no dangling references); the kept IBD speedups (RandomX pre-verify, adaptive dbcache, tlsmanager) are untouched. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
40
src/init.cpp
40
src/init.cpp
@@ -390,8 +390,6 @@ std::string HelpMessage(HelpMessageMode mode)
|
||||
strUsage += HelpMessageOpt("-exportdir=<dir>", _("Specify directory to be used when exporting data"));
|
||||
strUsage += HelpMessageOpt("-dbcache=<n>", strprintf(_("Set database cache size in megabytes (%d to %d). Default: adaptive - uses most free RAM to speed up initial block download (far fewer UTXO flushes to disk) and automatically shrinks if other applications need memory, always leaving a reserve free. Setting a fixed value disables adaptive sizing."), nMinDbCache, nMaxDbCache));
|
||||
strUsage += HelpMessageOpt("-loadblock=<file>", _("Imports blocks from external blk000??.dat file") + " " + _("on startup"));
|
||||
strUsage += HelpMessageOpt("-loadutxosnapshot=<file>", _("On a fresh node (empty chainstate), load a trusted UTXO snapshot produced by 'dumptxoutset' and fast-forward the tip to its height, skipping replay of earlier blocks. Block headers up to that height must already be present (e.g. via header sync or bootstrap). Blocks above the snapshot are still fully validated."));
|
||||
strUsage += HelpMessageOpt("-loadutxosnapshotunsafe", _("Allow -loadutxosnapshot even when no trusted snapshot hash is hardcoded for this network (verifies file integrity only, not authenticity). Testing/regtest only."));
|
||||
strUsage += HelpMessageOpt("-maxdebugfilesize=<n>", strprintf(_("Set the max size of the debug.log file (default: %u)"), 15));
|
||||
strUsage += HelpMessageOpt("-maxorphantx=<n>", strprintf(_("Keep at most <n> unconnectable transactions in memory (default: %u)"), DEFAULT_MAX_ORPHAN_TRANSACTIONS));
|
||||
strUsage += HelpMessageOpt("-maxreorg=<n>", _("Specify the maximum length of a blockchain re-organization"));
|
||||
@@ -2099,44 +2097,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
break;
|
||||
}
|
||||
|
||||
// Trusted UTXO snapshot fast-sync (assumeutxo-style). If -loadutxosnapshot is given
|
||||
// and the chainstate is still empty, load the verified snapshot and fast-forward the
|
||||
// tip to height H; blocks above H then sync with full PoW/script/Sapling validation.
|
||||
{
|
||||
std::string snapPath = GetArg("-loadutxosnapshot", "");
|
||||
if (!snapPath.empty()) {
|
||||
if (!pcoinsdbview->GetBestBlock().IsNull()) {
|
||||
LogPrintf("%s: -loadutxosnapshot ignored, chainstate is not empty\n", __func__);
|
||||
} else {
|
||||
const CChainParams::AssumeutxoData& au = chainparams.Assumeutxo();
|
||||
bool unsafe = GetBoolArg("-loadutxosnapshotunsafe", false);
|
||||
if (au.IsNull() && !unsafe) {
|
||||
strLoadError = _("-loadutxosnapshot: no trusted snapshot hash is configured for this network; refusing (use -loadutxosnapshotunsafe for testing only)");
|
||||
break;
|
||||
}
|
||||
CUTXOSnapshotHeader hdr; uint256 gotHash; std::string snapErr;
|
||||
bool requireExpected = !au.IsNull() && !unsafe;
|
||||
if (!pcoinsdbview->LoadSnapshot(snapPath, au.hash, requireExpected, hdr, gotHash, snapErr)) {
|
||||
strLoadError = strprintf(_("Failed to load UTXO snapshot: %s"), snapErr);
|
||||
break;
|
||||
}
|
||||
if (!au.IsNull() && hdr.nHeight != au.height) {
|
||||
strLoadError = _("UTXO snapshot height does not match the trusted value for this network");
|
||||
break;
|
||||
}
|
||||
pcoinsTip->SetBestBlock(hdr.baseBlockHash); // refresh cache view of the freshly-written chainstate
|
||||
std::string fixErr;
|
||||
if (!LoadSnapshotChainstate(hdr, fixErr)) {
|
||||
strLoadError = strprintf(_("Failed to activate UTXO snapshot tip: %s"), fixErr);
|
||||
break;
|
||||
}
|
||||
pblocktree->WriteAssumeutxoHeight(hdr.nHeight); // persist reorg-below-H guard across restarts
|
||||
LogPrintf("%s: loaded trusted UTXO snapshot at height %d (hash %s); syncing forward with full validation\n",
|
||||
__func__, hdr.nHeight, gotHash.GetHex());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HUSH_LOADINGBLOCKS = 0;
|
||||
// Check for changed -txindex state
|
||||
if (fTxIndex != GetBoolArg("-txindex", true)) {
|
||||
|
||||
Reference in New Issue
Block a user