Repository navigation
feat: load AssumeUTXO snapshots with loadtxoutset (regtest) and stall on missing Evo state - #8078
Open
PastaPastaPasta wants to merge 29 commits into
Open
PastaPastaPasta wants to merge 29 commits into
PastaPastaPasta wants to merge 29 commits into
Conversation
4 tasks done
Collaborator
|
🔍 Review in progress (commit d4f96d9) · live progress
|
|
This pull request has conflicts, please rebase. |
PastaPastaPasta
force-pushed
the
feat/assumeutxo-loader
branch
from
November 9, 2026 19:14
9957dfa to
23122e9
Compare
PastaPastaPasta
force-pushed
the
feat/assumeutxo-loader
branch
from
November 9, 2026 23:07
23122e9 to
3fc404a
Compare
This was referenced Nov 10, 2026
|
This pull request has conflicts, please rebase. |
PastaPastaPasta
force-pushed
the
feat/assumeutxo-loader
branch
from
November 10, 2026 17:28
3fc404a to
b15e459
Compare
|
This pull request has conflicts, please rebase. |
PastaPastaPasta
force-pushed
the
feat/assumeutxo-loader
branch
from
November 10, 2026 22:48
b15e459 to
307bd3f
Compare
|
This pull request has conflicts, please rebase. |
PastaPastaPasta
force-pushed
the
feat/assumeutxo-loader
branch
from
November 11, 2026 03:40
307bd3f to
f8551ed
Compare
|
This pull request has conflicts, please rebase. |
edbed31 chainparams: add signet assumeutxo param at height 160_000 b8cafe3 chainparams: add testnet assumeutxo param at height 2_500_000 99839bb doc: add note about confusing HaveTxsDownloaded name 7ee46a7 contrib: add script to demo/test assumeutxo 42cae39 test: add feature_assumeutxo functional test 0f64bac rpc: add getchainstates bb05857 refuse to activate a UTXO snapshot if mempool not empty ce585a9 rpc: add loadtxoutset 62ac519 validation: do not activate snapshot if behind active chain 9511fb3 validation: assumeutxo: swap m_mempool on snapshot activation 7fcd215 blockstorage: segment normal/assumedvalid blockfiles 4c3b8ca validation: populate nChainTx value for assumedvalid chainstates 49ef778 test: adjust chainstate tests to use recognized snapshot base 1019c39 validation: pruning for multiple chainstates 373cf91 validation: indexing changes for assumeutxo 1fffdd7 net_processing: validationinterface: ignore some events for bg chain fbe0a7d wallet: validationinterface: only handle active chain notifications f073917 validationinterface: only send zmq notifications for active 4d8f4dc validation: pass ChainstateRole for validationinterface calls 1e59acd validation: only call UpdatedBlockTip for active chainstate c6af23c validation: add ChainstateRole 9f2318c validation: MaybeRebalanceCaches when chain leaves IBD 434495a chainparams: add blockhash to AssumeutxoData c711ca1 assumeutxo: remove snapshot during -reindex{-chainstate} c93ef43 bugfix: correct is_snapshot_cs in VerifyDB b73d3bb net_processing: Request assumeutxo background chain blocks Pull request description: Part of the assumeutxo project: the loadtxoutset RPC, background block download, ChainstateRole on validation-interface notifications, indexing and pruning across two chainstates. Dash adaptations: - loadtxoutset and getchainstates are hidden and regtest-only, and dumptxoutset stays hidden: no network but regtest authorizes a snapshot. - Validation-interface events of the background chainstate, which used to be suppressed, now carry their role. The Dash subscribers (ChainLock handler and signer, InstantSend, CoinJoin and masternode notifications, the coinbase ChainLock check in net_processing) ignore background events, as the wallet and zmq do, so they see only the active chain as before. - Indexes, the governance collateral index included, follow the indexing chainstate. GovCollateralIndex::CanSync is evaluated on it at startup, so a restart while the background chainstate is syncing keeps governance on. The indexes are restarted from init's list of running indexes. - Snapshot activation needs strictly more work than the active tip, at load and at the switch, where it replaces the switch's interim rule. The work comparator would let a base through that has the same work as an active tip on another branch: it breaks the tie by nSequenceId, which is assigned only when a block's data is received, so a headers-only base keeps its initial value and ranks ahead of any equal-work block received in this run. Startup completion would then find the active tip at the base height and reject the honest snapshot. The unit fixtures that load the snapshot of their own tip hide it from the active chain for the whole activation call, as upstream's helpers do. - AssumeutxoData keeps its evo pin. The regtest entries at 110 and 200 get their block hashes. feature_assumeutxo.py authorizes its snapshot with -assumeutxodata instead of an entry at 299: the blocks it mines depend on how long its syncs take, which move the mock time on, so the snapshot differs between runs. It checks the dump's nChainTx and coin count against the node rather than fixed values, and expects txindex and the governance collateral index, which Dash nodes keep by default, among the synced indexes. Two of the blocks the loading nodes lack below the base carry a transaction besides the coinbase, so that their background sync meets the nChainTx case below. A fourth node lets its snapshot chainstate connect the blocks above the base, drops the snapshot with -reindex-chainstate before it is validated and then syncs normally, which meets the second nChainTx case below. - CheckBlockIndex skips 4c3b8ca's monotonic nChainTx check for blocks at or below the snapshot base while a snapshot chainstate exists. Their nTx and nChainTx can still be the values faked at activation, or derived from them: receiving a block recomputes its own nChainTx but not that of a faked child, so the check aborted a node whose downloaded blocks below the base held two or more transactions more than were faked. Above the base the counts never exceed the real ones and start from the pinned nChainTx at the base, so the check stays there. The faked counts are persisted, though: a snapshot chainstate dropped by -reindex-chainstate, or by a rejection and a restart, leaves them in the block index, and the plain sync that follows failed the check the same way. BlockManager::LoadBlockIndex() therefore records the highest block it loads with a faked count (nTx set without BLOCK_VALID_TRANSACTIONS, the compatibility case bitcoin#29370 describes), and the check also skips a block whose parent is at or below it. After the load a block's count changes only when the block itself or its parent is received, so a pair that went stale has a faked parent, which also covers the block right above the highest faked one. A fork that branches below the base, crosses the base height and arrives out of order can still fail the check, until bitcoin#29370 stops faking the counts and replaces these exceptions. - A local Evo stall of the active chainstate does not stop the background chainstate, as in the import loops: ProcessNewBlock() still runs the background chainstate's ActivateBestChain() after the active one stalls, and then returns false. Every other failure returns early, as upstream does. A stall lasts until a restart, so returning early on it would freeze background validation, and with it the promotion that ends the stall. - ChainstateRole's kernel/chain.h, now included by validation and node/blockstorage, closes an include cycle through Dash's blockfilter -> evo/specialtx_filter -> evo/assetlocktx path; it is listed in lint-circular-dependencies.py. - The nChainTx bootstrap at startup skips a base missing from the block index, which ChainstateManager::LoadBlockIndex() reports as a startup error. - The mempool swap and the -reindex snapshot deletion are already in place: ActivateSnapshot() moves the mempool at the switch, and startup deletes a snapshot chainstate before detecting it when reindexing. The VerifyDB fix is already present. - FindFilesToPrune() caps the minimum share of each chainstate at the -prune budget itself. Upstream's MIN_DISK_SPACE_FOR_BLOCK_FILES equals its -prune minimum. Dash's is 945 MiB, but regtest accepts -prune=550, so a single regtest chainstate's target rose to 945 MiB and it stopped pruning (wallet_pruning.py). One chainstate again prunes to exactly its budget. With two, mainnet and testnet split the budget as upstream does, using Dash's constant. - Dropped: the blockfile segmentation (7fcd215), which only serves pruning each chainstate separately, while a node with a snapshot chainstate does not prune; the testnet and signet parameters; the demo script, for lack of a network with a snapshot; and the release notes, as the RPCs are hidden. Co-Authored-By: Claude Opus 5.5 <[email protected]> Adapted to per-chainstate Evo state: the snapshot chainstate's Evo state is created with it, so ActivateExistingSnapshot() and the switch need no view or generation handling; the final more-work check runs in ActivateSnapshot() before the switch. The unit helpers disconnect the active tip during activation, as upstream's do. Signal subscribers keep iterating synchronously as before.
7e40032 tests: assumeutxo: accept final height from either chainstate 5bd2010 test: assumeutxo: avoid race in functional test 7005a01 test: add wait_for_connect to BitcoinTestFramework.connect_nodes Pull request description: Fixes some races in the assumeutxo functional test. Dash adaptations: - DashTestFramework.connect_nodes() takes the new wait_for_connect and passes it on. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…a list of chainstates a9ef702 assumeutxo: change getchainstates RPC to return a list of chainstates Pull request description: Current `getchainstates` RPC returns "normal" and "snapshot" fields which are not ideal because it requires new "normal" and "snapshot" terms to explain, and the field names will be confusing when a snapshot chainstate becomes validated. Return a list of chainstates ordered by work with a "validated" field for each. Co-Authored-By: Claude Opus 5.5 <[email protected]>
5d227a6 rpc: Use Ensure(Any)Chainman in assumeutxo related RPCs 710e5db doc: Drop references to assumevalid in assumeutxo docs 1ff1c34 test: Rename wait_until_helper to wait_until_helper_internal a482f86 chain: Rename HaveTxsDownloaded to HaveNumChainTxs 82e48d2 blockstorage: Let FlushChainstateBlockFile return true in case of missing cursor 73700fb validation, test: Improve and document nChainTx check for testability 2c9354f doc: Add snapshot chainstate removal warning to reindexing documentation 4e915e9 test: Improvements of feature_assumeutxo a47fbe7 doc: Add and edit some comments around assumeutxo 0a39b8c validation: remove unused mempool param in DetectSnapshotChainstate Pull request description: Addressing comments from bitcoin#27596 Dash adaptations: - 82e48d2 is dropped: it changes FlushChainstateBlockFile, which comes with the blockfile segmentation this tree does not take from bitcoin#27596. - 73700fb keeps bitcoin#27596's monotonic nChainTx check in CheckBlockIndex instead of requiring nChainTx to equal the sum of nTx. Until bitcoin#29370 removes the faking of nTx at snapshot activation, a headers-only chain below a base whose blocks hold more than one transaction each fails the stricter check. The corrected regtest nChainTx values (counting the genesis coinbase) are taken, for the 200 entry too. - The wait_until_helper rename covers the Dash-only functional tests as well. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ssumeUTXO parameters fails 2e31250 test: check that loading snapshot not matching AssumeUTXO parameters fails Pull request description: This PR adds a first test for loading an invalid snapshot: the snapshot base block is not in the assumeutxo parameters. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tadata constructor, fix test, add test fafde92 test: Check snapshot file with wrong number of coins faa90f6 refactor: Remove unused nchaintx from SnapshotMetadata constructor Pull request description: Remove unused nchaintx from SnapshotMetadata constructor and add a test. develop's partial merge of this PR (ed19c19) already removed nchaintx from the SnapshotMetadata constructor and dumptxoutset; this adds the feature_assumeutxo.py test it left out. Dash adaptation: the evo section follows the coins, so with one coin too many the last one is read from the section and fails one of the coin checks rather than at the end of the file; the test matches the common part of those logs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…esn't match AssumeUTXO parameters 9620cb4 assumeutxo: fail early if snapshot block hash doesn't match AssumeUTXO parameters Pull request description: Fail early in `loadtxoutset` if the snapshot block hash is not one of the AssumeUTXO parameters, instead of waiting up to ten minutes for its header. Co-Authored-By: Claude Opus 5.5 <[email protected]>
fa68571 test: Add assumeutxo test for wrong hash Pull request description: Add a test for a snapshot file whose first outpoint hash was changed, so its content hash does not match the AssumeUTXO parameters. Dash adaptation: the snapshot differs between runs (see bitcoin#27596's port), so the test checks the expected content hash in the log, not the changed file's. Co-Authored-By: Claude Opus 5.5 <[email protected]>
621db2f test: assumeutxo file with unknown block hash Pull request description: Check that a snapshot file whose base block hash is unknown is refused right away as well. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… index + de-duplications d322368 test: De-dublicate/optimize assumeutxo test for further extensions 0a576d6 test: check au file with changed outpoint index Pull request description: Extend the invalid-snapshot cases with a changed outpoint index and share the error checking between the cases. Dash adaptation: as for bitcoin#28647, the cases do not list the content hash of each changed file. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Two cases of bitcoin#28685's "assumeutxo: Check deserialized coins for out of range values" commit, which change a coin's height and coinbase flag in the snapshot file: the UTXO set hash commits to both since bitcoin#28685 (in the base of this stack), so the snapshot is refused. The backport of bitcoin#28685 left these hunks out because this test did not exist yet. As for bitcoin#28647, the test checks the expected content hash only. The first coin differs between runs, so instead of upstream's fixed bytes, which may equal the original or change the code's length, the cases flip the coinbase flag and the height's lowest bit in the code's last byte. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nvalid hash 811067c test: add coverage for snapshot chainstate not matching AssumeUTXO parameters 4a5be10 assumeutxo, blockstorage: prevent core dump on invalid hash Pull request description: A snapshot chainstate whose base block hash is not in the AssumeUTXO parameters stops startup with an error instead of an Assert crash. Dash adaptations: startup finds the bogus chainstate_snapshot directory of the test earlier, because the node has no EvoDB state for it, so the test expects that error. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…on the assumeutxo invalid hash dump - follow-up bitcoin#28698 7de7685 test, assumeutxo: Use assert_debug_log for error details Pull request description: Check the logged error details of the invalid snapshot chainstate case with assert_debug_log. Co-Authored-By: Claude Opus 5.5 <[email protected]>
997b9a7 test: add assumeutxo wallet test Pull request description: Add a wallet test for assumeutxo: a wallet backup cannot be restored while the background chainstate is still syncing, and can once it is done. Dash adaptation: node 1 authorizes node 0's snapshot with -assumeutxodata, as in feature_assumeutxo.py, instead of the test checking a fixed UTXO set hash. The wallet already writes its best block before a backup (the wallet hunk of bitcoin#30678), so a backup taken at the snapshot base needs no rescan and loads during the background sync. The test takes bitcoin#30678's test change with it: that backup loads, and one taken before the base is refused until the background sync is done. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pshot completion bc43eca test: add functional test for balance after snapshot completion 226d03d validation: Send correct notification during snapshot completion Pull request description: When background validation completes during an ActivateBestChain() call, GetRole() returns NORMAL instead of BACKGROUND for the background chainstate when its BlockConnected notifications are sent. The wallet, which ignores background notifications, then sets its last processed block to the old snapshot height. The role is now captured before ActivateBestChainStep(). Dash adaptations: - The role is captured right before each ActivateBestChainStep() call inside Dash's inner loop, which can run more than one step after a stall. - The Dash subscribers that ignore background notifications (the ChainLock handler and signer, InstantSend, CoinJoin, net_processing) no longer handle the blocks of the background chainstate's final step either. - wallet_assumeutxo.py checks the third node's wallet by its last processed block instead of its balance: the test does not fund the wallet, which needs bitcoin#29354, and ensure_for() needs bitcoin#30893. The third node authorizes the snapshot with -assumeutxodata like node 1. Its snapshot chain reaches the tip by submitblock before it connects to node 0: without the snapshot-first block download of bitcoin#29519, active blocks arriving after completion would set the wallet's last processed block again and hide the bug. Co-Authored-By: Claude Opus 5.5 <[email protected]>
5555d8d test: Use blocks_path where possible fa91089 rpc: Fix race in loadtxoutset Pull request description: The tip may have advanced, also if it did not, there is no reason to have two variables point to the same block. Fixes bitcoin#27596 (comment) The test framework part of 5555d8d (has_blockfile using blocks_path) is already on develop via dashpay#8280 (partial bitcoin#29262); this commit carries the remaining loadtxoutset fix from fa91089, which needs the loadtxoutset RPC from bitcoin#27596. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…check in ActivateSnapshot 33c48c1 validation: Check if mempool exists before asserting in ActivateSnapshot (TheCharlatan) Pull request description: The mempool is an optional component of the chainstate manager, so don't assume its presence and instead check if it is there first. Dash: pulled forward from the later assumeutxo backports. After a snapshot rejection the active chainstate has no mempool (next commit), so a second activation in the same run must reach the "a snapshot chainstate already exists" refusal instead of this assert. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A snapshot chainstate's Evo state is its own directory here, not a marker in the shared EvoDB, so startup reports a bogus chainstate_snapshot directory as a missing Evo state. Startup now also logs the base block it lacks the Evo state for, which the test matches.
…ock before validation A snapshot chainstate that has not been validated in the background cannot fully check the blocks it would reconnect after invalidating one, and undoing a block can need Evo state it does not have yet. An InstantSend lock that conflicts with a block on it therefore no longer invalidates the block: the chain wins, as it does against a ChainLocked conflict, and the lock is discarded. That is the only difference from the ChainLock rule of dashpay#8199, which removes a lock only for a ChainLocked conflict: here the conflicting block is not ChainLocked, and the lock goes because the chainstate cannot act on it yet. The rule applies only while the active chainstate is a snapshot chainstate that background validation has not completed (IsSnapshotActiveAndUnvalidated); afterwards such a lock invalidates the conflicting blocks as before. The check comes before the ChainLock rule, so a lock whose conflict is ChainLocked is discarded the same way rather than announced, relayed and served after its removal. A discarded lock is removed from the database, archived so it is not requested again, and, when it still waits for its transaction, removed from the pending entries, so GetInstantSendLockByHash no longer serves it. ResolveBlockConflicts returns false then, and ProcessInstantSendLock stops before removing mempool conflicts, notifying the lock and relaying it. Without a snapshot, a pruned node that cannot undo a conflicting block because block data it needs was pruned stalls instead of asserting: InstantSend logs it, keeps the lock and gives up on that lock's conflicts. It clears the failure flags of an invalidation that was only temporary (a lock without its transaction) on every exit, also when the invalidation stopped partway, so no block it disconnected keeps a failure flag. A node that cannot read a block is shutting down, and ResolveBlockConflicts returns false. discarded_lock_is_not_served covers a stored lock and one that waits for its transaction. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ith legacy indexes A pruned node keeps neither the blocks the background chainstate needs nor those Evo state below the snapshot base is read from, a masternode cannot run its duties from an unvalidated snapshot chainstate, and the -addressindex, -spentindex and -timestampindex indexes are not supported together with a snapshot chainstate. Snapshot activation now refuses all of these, in any prune mode, together with the conditions the switch already re-checked: a non-empty mempool, a base without more work than the active tip, and an invalid or ChainLock-conflicting block in the base's chain. They are checked when the snapshot is loaded, before any state is set up, and again at the switch. The load check also refuses a second snapshot after one was rejected in this run, which used to reach the switch and abort on assert(!m_snapshot_chainstate), and a snapshot while the chainstate of one rejected earlier is still in chainstate_snapshot_INVALID. A rejection moves the snapshot chainstate there and tells the user it is kept, but a second rejection could not move its own there, and startup recovery then deleted it. At startup, a node with a snapshot chainstate directory, validated or not, refuses to start with -prune, one of those indexes or -masternodeblsprivkey until a restart has promoted the snapshot. -assumeutxodata is refused off regtest. Co-Authored-By: Claude Opus 5.5 <[email protected]> Adapted to per-chainstate Evo state: the switch check runs in ActivateSnapshot() before the snapshot chainstate takes over. The unit scenario chainstatemanager_evo_snapshot_refused_when_loaded relies on test hooks this tree does not have and is not taken; feature_assumeutxo_refusals.py covers the refusals.
This reverts commit 8010353. A masternode refuses to start with a snapshot chainstate until a restart has promoted it, and snapshot activation refuses a masternode, so DKG participation and quorum signing never run beside an unvalidated snapshot: the production gate, its RPC error and the masternode status field are dead code.
…ion is incomplete" This reverts commit 7230da6 (dashpay#8049), together with the phase abort dashpay#7456 put in WaitForNextPhase for the same case. A masternode refuses to start with a snapshot chainstate until a restart has promoted it, and snapshot activation refuses a masternode, so the DKG phase threads never run beside an unvalidated snapshot and both gates are dead code.
…s first Startup starts the index threads after the block import. The import activates the best chain of every chainstate, so it completes background validation of a snapshot whose remaining blocks it reads, from -loadblock or from blocks stored before a restart. The completion then rebinds the indexes to the snapshot chainstate and starts their threads, and startup starts them again: assigning to a still joinable m_thread_sync calls std::terminate. Bitcoin Core has the same order, but only with an index opted in. Dash enables txindex by default and always keeps the governance collateral index in node.indexes. Startup and the completion now start the threads under index_start_mutex. Until startup has started them, the completion only rebinds the indexes, and startup starts them on the chainstate they are bound to. The mutex also orders a completion in the message handler against startup starting the threads. feature_assumeutxo.py has node 3 load the snapshot with only the headers and restart with the blocks below the base in a -loadblock file. Without the fix the node aborts during startup. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Snapshot activation moves the active tip without a block connection, and told only the deterministic masternode list about it. The other Dash consumers of the tip learned of it from the next block the snapshot chainstate connected. A snapshot loaded at the best header may have none to connect for a while: CMasternodeSync never saw the node reach the best header and kept masternode sync in its blockchain stage, and InstantSend kept the tip height it cached before the load, by which it picks the signing cycle of rotating quorums. The snapshot base may have only its header, so activation must not raise UpdatedBlockTip: ZMQ's raw block notifier would fail to read the block and drop itself for the rest of the run, and block relay would announce a block it cannot serve. Bitcoin's activation raises no tip event either. Activation now seeds the InstantSend tip height and the MN list tip directly under cs_main, and queues InitializeSnapshotTip, a variant of the startup fan-out InitializeCurrentBlockTip that reaches the masternode sync, governance, DSTX and quorum observer state but not ZMQ, block relay or wallets. It is ordered before the events of any later block, and is skipped once such a block has moved the tip, since that block's own events reach the same consumers. A block can still connect between that check and the fan-out and set the MN list tip synchronously, so the fan-out must not set it again: CDSNotificationInterface answers InitializeSnapshotTip with its queued tip consumers only, where InitializeCurrentBlockTip would also put the base back as the MN list tip. The other subscribers hold only state that block connection sets from the queue, after this fan-out, and answer it as InitializeCurrentBlockTip. The previous chainstate keeps connecting blocks while the snapshot is prepared, and a BlockConnected of one of them may still be queued at the switch. NetInstantSend would then put its tip height back below the base, and it does not answer the fan-out, so the fan-out sets that height again under cs_main, right after its check of the active tip. feature_assumeutxo.py checks that masternode sync leaves the blockchain stage once node 2, with a peer and no block to connect, has loaded the snapshot at its best header, and that node 2's raw block notifier survives the load at a headers-only base and publishes the next tip. Without the fan-out masternode sync stays in its blockchain stage; with an UpdatedBlockTip at activation the notifier is gone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…services The DS notification interface, the InstantSend and quorum net handlers, governance, the CoinJoin client, the connection threads and the masternode maintenance task took the Evo managers of the chainstate that was active when they were constructed. Loading a snapshot at runtime makes another chainstate active, with its own managers: these services kept reading the background chainstate's, which stops at the snapshot base. The masternode list tip in particular was moved on the background chainstate's manager, so the list at the tip of the snapshot chain stayed at the block the snapshot was activated on, and InstantSend locks were verified against quorums the background chainstate has not derived. They now hold the ChainstateManager and read ActiveEvo() per call, as PeerManager does; CConnman, which does not know validation, takes a callback returning the list at the tip. The masternode and quorum-watching contexts keep their references, as such a node never has a second chainstate: a masternode already refused a snapshot at startup and in loadtxoutset, and a node with -watchquorums now does too. feature_assumeutxo_refusals.py checks the -watchquorums refusals. The end-to-end test added later, feature_assumeutxo_dash.py, checks the list at the tip after blocks connected on a snapshot loaded without a restart.
…he switch under one cs_main hold ActivateSnapshot() released cs_main between the final refusal checks and publishing the snapshot chainstate. In that gap the active chainstate could connect the base or pass it, and a transaction could enter the mempool against the old tip, spending a coin the snapshot already has spent. The switch then made an older tip active, or carried an invalid entry into the snapshot chainstate's mempool. Hold cs_main from the final SnapshotActivationRefusal() check through writing the base marker and publishing the chainstate, as upstream does since 62ac519, and write the marker only after the checks pass, so a refused snapshot never leaves one behind. A marker write that throws is cleaned up as a refused load. The snapshot chainstate's MN list tip and the InstantSend tip height are now seeded before SetActiveChainstate() publishes the new Evo state, so a reader of the active Evo state never sees a tip MN list that is still empty. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s to The startup thread reads the active tip and then notifies it, without holding cs_main between the two. RPC warmup can end before that thread does, so a loadtxoutset in the gap activates a snapshot and seeds the snapshot Evo state's masternode list tip at its base. The notification then resolved the Evo state per call and moved the snapshot's list tip back to the old tip, whose list the snapshot need not carry. Startup's GetListAtChainTip() could then throw BlockDataUnavailableError out of the thread and terminate the node. Under one cs_main hold, update the list tip only if the notified tip is still the active one. A snapshot activated in between keeps the tip that its activation seeded. The rest of the startup fan-out runs without the lock, as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…briefly The lock is stored, or parked waiting for its transaction, before the conflict check removes it, so a peer that asks for it in that interval can still be sent it. Say so in the comment and the release note instead of promising that it is never served. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… when a later one stalls When an InstantSend lock conflicts with several blocks, ResolveBlockConflicts invalidates them one by one and then calls ActivateBestChain. If a later invalidation stopped on a local Evo state error (a pruned node that lacks the data to undo a block), it returned before that call. The blocks invalidated before it had already moved the tip back, and the tip stayed there until the next block arrived. Stop the loop at the stall, run ActivateBestChain for the conflicts already invalidated, and then give up as before. A failure that is not a local Evo state error still gives up at once. Co-Authored-By: Claude Opus 5.5 <[email protected]>
3 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue being fixed or feature implemented
This is the first layer where a node can load an AssumeUTXO snapshot. It ports the upstream loader (
loadtxoutset,getchainstates,ChainstateRole, background block download, indexing and pruning across chainstates, and their follow-ups). The loader stays regtest-only and hidden until the network pins (#8276) land. It then adds the Dash commits that the backports make reachable: refusing unsafe nodes, the InstantSend rule while a snapshot is unvalidated, index start-up and tip notifications.AssumeUTXO stack (merge in this order; each PR holds the commits of the ones below it; #8272 has merged): #8078 → #8273 → #8079 → #8276. Review only the commits listed as new.
Restack (2026-12-04). This PR now sits on develop at the #8272 merge (
5a235f9e15), on the per-chainstate Evo design that #8286 put on develop. Its commits are the versions knst ported onto that design in #8284. After #8272 merged, they were rebased onto the merge commit so that the PR lists only its own commits; the trees are unchanged. Compared with the previous head:AssumeutxoForHeight(), which assumeutxo (2) bitcoin/bitcoin#27596 introduces in place ofExpectedAssumeutxo().cs_mainhold from the final checks through the switch. After the second review, a commit keeps the startup notification from moving a snapshot's masternode list tip back, and two more answer CodeRabbit's InstantSend findings. Three commit messages were corrected to describe the code they now contain. The design doc drops the pruning passages that a refused pruned node makes moot.InstantSend while a snapshot is unvalidated. Until background validation completes, an InstantSend lock that conflicts with a block on the snapshot chain does not invalidate that block. The block is kept and the lock is discarded: it is removed from the database (and archived, so it is not requested again), dropped from the locks still waiting for their transaction, and never applied, announced or relayed, and it is removed from the locks the node serves once the conflict is found. Once background validation completes, a conflicting lock invalidates the blocks as before. The rule is gated on
IsSnapshotActiveAndUnvalidated(), so a node without a snapshot, or with a validated one, keeps today's behaviour.What was done?
New on top of develop:
42467eef8e, assumeutxo (2)):loadtxoutset,getchainstates,ChainstateRole, background download. The Dash adaptations are listed in the commit message: the RPCs stay hidden and regtest-only, Dash subscribers ignore background events, indexes follow the indexing chainstate, and activation needs strictly more work than the active tip.a2e0b2a887..9c3d541bc8): follow-ups and tests.3e664f5400test: add the feature_assumeutxo.py cases of coinstats, assumeutxo: fix hash_serialized2 calculation bitcoin/bitcoin#28685.a1a8db3b22..572ca73d7a).5ad4adb684test: expect a missing snapshot Evo state at startup (knst). A snapshot chainstate's Evo state is its own directory, so startup reports a boguschainstate_snapshotdirectory as missing Evo state and logs the base block it lacks.83b12aca89fix(instantsend): keep the snapshot chain and discard a conflicting lock before validation. Implements the rule above.80f891fe86feat(validation): refuse snapshots on pruned nodes, masternodes and with legacy indexes. These are refused at load, at the switch, and at startup until a restart has promoted the snapshot.c50de54f14,bc425bd925Revert the masternode-duty gate and the DKG phase idling for unvalidated snapshots (knst). Since commit 7 refuses a masternode with a snapshot chainstate, those gates are dead code.b7d53812fffix(init): start the index threads once when snapshot completion comes first.52a7574090fix(validation): tell Dash tip consumers the snapshot tip at activation.7fdaa48c7cevo: resolve the active chainstate's Evo state per call in node-wide services (knst, moved down from fix: refuse unsafe AssumeUTXO snapshot loads and harden rejection, with a Dash end-to-end test #8273). The DS notification interface, the InstantSend and quorum net handlers, governance, the CoinJoin client, the connection threads and the masternode maintenance task readActiveEvo()per call. Before, they read the Evo state of whichever chainstate was active when they were constructed. A snapshot loaded at runtime makes another chainstate active, so without this the masternode list tip stayed at the base and InstantSend locks were checked against quorums the background chainstate has not derived. A node with-watchquorumsnow refuses a snapshot, as a masternode does.743f7758b2fix(validation): run the final snapshot checks, the base marker and the switch under one cs_main hold. As upstream does since62ac519e718. No block can connect and no transaction can enter the mempool between the last refusal check and the switch. The base marker is written only after the checks pass, and a marker write that throws is cleaned up as a refused load. The snapshot chainstate's MN list tip and InstantSend tip height are seeded before the switch publishes its Evo state.544d06b7aafix(evo): give the startup tip only to the chainstate it still belongs to. The startup thread reads the tip and notifies it without holdingcs_mainbetween the two, and RPC warmup can end first. If aloadtxoutsetactivates a snapshot in that gap, the notification no longer moves the snapshot's masternode list tip back to the old tip: it updates the list tip only if that tip is still the active one, under onecs_mainhold.32279a60a3doc: a lock discarded before snapshot validation can still be served briefly. The lock is stored before the conflict check removes it, so the comment and the release note no longer promise that it is never served.d4f96d9a97fix(instantsend): move the tip past the conflicts already invalidated when a later one stalls. When a later conflict's invalidation stops on a local Evo state error,ActivateBestChainstill runs for the conflicts invalidated before it, so the tip does not wait for the next block.What to focus on: commits 6–8, 11 and 12, and the Dash adaptations in each backport's commit message. The backported code is otherwise upstream's.
How Has This Been Tested?
On Linux x86_64 (Debug, GCC, depends,
-DWERROR=ON), this head builds.validation_chainstatemanager_tests,validation_chainstate_tests,evo_snapshot_tests,evo_db_testsandevo_islock_testspass at this head.At the top of the stack (#8276), the full
test_dashpasses, and so dofeature_assumeutxo,feature_assumeutxo_dash,feature_assumeutxo_refusals,wallet_assumeutxoandrpc_dumptxoutset.To test:
test/functional/test_runner.py feature_assumeutxo.py wallet_assumeutxo.py p2p_instantsend.py feature_llmq_is_cl_conflicts.py.Breaking Changes
None on mainnet or testnet: the loader is reachable only on regtest until the network pins (#8276) land.
Checklist:
🤖 Generated with Claude Code