Conversation
Collaborator
|
🔍 Review in progress (commit 208fc03) · live progress
|
|
This pull request has conflicts, please rebase. |
PastaPastaPasta
force-pushed
the
feat/assumeutxo-hardening
branch
from
November 9, 2026 19:14
dc81f37 to
91294b1
Compare
Open
4 tasks done
PastaPastaPasta
force-pushed
the
feat/assumeutxo-hardening
branch
2 times, most recently
from
November 10, 2026 03:31
2b55ab3 to
cc9c8e7
Compare
This was referenced Nov 10, 2026
|
This pull request has conflicts, please rebase. |
PastaPastaPasta
force-pushed
the
feat/assumeutxo-hardening
branch
from
November 10, 2026 17:28
cc9c8e7 to
82ec5b8
Compare
|
This pull request has conflicts, please rebase. |
PastaPastaPasta
force-pushed
the
feat/assumeutxo-hardening
branch
from
November 10, 2026 22:48
82ec5b8 to
bca9621
Compare
|
This pull request has conflicts, please rebase. |
PastaPastaPasta
force-pushed
the
feat/assumeutxo-hardening
branch
from
November 11, 2026 03:40
bca9621 to
00300d3
Compare
…lues 9d9a745 assumeutxo: Remove BLOCK_ASSUMED_VALID flag ef174e9 test: assumeutxo snapshot block CheckBlockIndex crash test 0391458 test: assumeutxo stale block CheckBlockIndex crash test ef29c8b assumeutxo: Get rid of faked nTx and nChainTx values 9b97d5b doc: Improve comments describing setBlockIndexCandidates checks 0fd915e validation: Check GuessVerificationProgress is not called with disconnected block 63e8fc9 ci: add getchaintxstats ubsan suppressions f252e68 assumeutxo test: Add RPC test for fake nTx and nChainTx values Pull request description: Snapshot activation no longer fakes nTx and nChainTx for the blocks below the base, and BLOCK_ASSUMED_VALID goes. nTx and nChainTx stay 0 until a block's transactions are known; only the base gets the pinned nChainTx. CheckBlockIndex() checks the exact nChainTx sum and restarts its "first missing/invalid" tracking at the snapshot base. Dash adaptations: - This removes the interim the bitcoin#27596 commit added while counts were faked: CheckBlockIndex()'s two exceptions to the monotonic nChainTx check and BlockManager::m_faked_tx_height. The monotonic check gives way to bitcoin#28562's exact sum check (73700fb), which the bitcoin#28562 commit left out, in its bitcoin#29370 form. - BLOCK_ASSUMED_VALID also covered the block index a dropped snapshot leaves behind (-reindex-chainstate, or a restart after a rejection): blocks it connected above a base whose ancestors were never validated keep CHAIN and SCRIPTS validity, which CheckBlockIndex now rejects. LoadBlockIndex lowers such blocks to the level their ancestors back up, and never below TRANSACTIONS. bitcoin/master has the same gap after -reindex-chainstate. - CheckBlockIndex() keeps tracking ChainLock-conflicting ancestors beside the invalid ones, and the candidate checks skip both. - BLOCK_STATUS_RESERVED keeps the value 256. No released version of this tree loads a snapshot, so no block index on disk has faked counts and no compatibility code is needed (upstream's compatibility note). - The loop at the snapshot switch keeps marking the chain's entries dirty but changes none of them: the BLOCK_OPT_WITNESS faking that upstream keeps there is SegWit-only. - clientversion.h is included for FormatFullVersion() in the new warnings. - Dash unit tests: the cold-importer fixture (ForgetBlocks) resets the forgotten entries as CreateAndActivateUTXOSnapshot() now does; the switch-recheck case no longer looks for the removed flag; the failed- preparation case checks that only the switch sets a count, the base's pinned nChainTx. - feature_assumeutxo.py counts the transactions of each block from its EXTRA_TX_HEIGHTS rows rather than upstream's every third block, checks the dump's nChainTx against that count, and adds the stale block as upstream. - The ubsan suppressions use this tree's file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Adapted to per-chainstate Evo state: the faking loop removed here runs in PopulateAndValidateSnapshot(), where this tree updates the block index; the unit fixture changes for the cold importer are not taken.
2342b46 test: Add coverage for getchaintxstats in assumeutxo context faf2a67 rpc: Reorder getchaintxstats output fa2dada rpc: Avoid getchaintxstats invalid results Pull request description: getchaintxstats computed its window from nChainTx values that are unset while an assumeutxo snapshot is being validated, and reported wrong or wrapped counts. Omit txcount, window_tx_count and txrate when they are unknown, and drop the ubsan suppressions bitcoin#29370 added for this RPC. Dash adaptations: - The window count is a plain value with a flag instead of std::optional: gcc-11 reports -Wmaybe-uninitialized on upstream's form, which --enable-werror turns into an error. - The RPC holds cs_main while it reads the window's nChainTx values, not only while it selects the block: a rejected snapshot's base and the blocks above it get their counts rewritten under cs_main here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…idated b7ba60f test: add coverage for -reindex and assumeutxo e57f951 init, validation: Fix -reindex option with an existing snapshot Pull request description: Restarting with -reindex or -reindex-chainstate while a snapshot chainstate exists must delete it, and a snapshot can be loaded again afterwards. Dash adaptations: - e57f951 is equivalent in this tree and not applied: node::LoadChainstate() deletes the snapshot chainstate directory with DeleteSnapshotChainstateFromDisk() before it detects a snapshot, when reindexing, so no snapshot chainstate is created that would need deleting, and the validated chainstate is initialized with the node's mempool from the start. Upstream's DeleteSnapshotChainstate() and its mempool handover therefore have no counterpart. - The test's coin count comes from the dump, as in the rest of the file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…not open file ee67bba test: added test coverage to loadtxoutset Pull request description: Check that loadtxoutset fails with a clear error for a path that does not exist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
faa30a4 rpc: Do not wait for headers inside loadtxoutset Pull request description: loadtxoutset waited up to ten minutes for the snapshot base's header before activating. Fail immediately instead, asking the caller to sync headers and call it again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1ec6684 test: Add test for loadtxoutset when headers are not synced 2bc1ecf test: Remove unnecessary sync_blocks in assumeutxo tests Pull request description: Test that loadtxoutset fails right away when the node lacks the snapshot base's header, which bitcoin#29345 changed from a ten-minute wait. Also drop a sync_blocks call that compared the disconnected nodes' identical cached chains. Dash adaptations: - The loading nodes here receive the new headers while n0 mines the snapshot chain, so the check runs on n3 after its datadir is wiped for the startup block import scenario, before it gets the headers, instead of on nodes 1 and 2 before the headers are ferried over. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a snapshot twice b259b0e [Test] Assumeutxo: ensure failure when importing a snapshot twice (Alfonso Roman Zubeldia) Pull request description: I am getting familiar with the `assume_utxo` tests and I found that the scenario of trying to activate a snapshot twice is not covered. This test is to ensure failure when loading a snapshot if there is already a snapshot-based chainstate. ACKs for top commit: fjahr: Code review ACK b259b0e kevkevinpal: tACK [b259b0e](bitcoin@b259b0e) achow101: ACK b259b0e rkrux: tACK [b259b0e](bitcoin@b259b0e) Tree-SHA512: 3510861390d0e40cdad6861b728df04827a1b63e642f3d956aee66ed2770b1cb7e3aa3eb00c62eb9da0544703c943cc5296936c9ebfcac18c719741c354421bb
… of dumptxoutset output 542e13b rpc: Enhance metadata of the dumptxoutset output (Fabian Jahr) 4d8e5ed assumeutxo: Add documentation on dumptxoutset serialization format (Fabian Jahr) c14ed7f assumeutxo: Add test for changed coin size value (Fabian Jahr) de95953 rpc: Optimize serialization disk space of dumptxoutset (Fabian Jahr) Pull request description: The second attempt at implementing the `dumptxoutset` space optimization as suggested in bitcoin#25675. Closes bitcoin#25675. This builds on the work done in bitcoin#26045, addresses open feedback, adds some further improvements (most importantly usage of compact size), documentation, and an additional test. The [original snapshot at height 830,000](bitcoin#29551) came in at 10.82 GB. With this change, the same snapshot is 8.94 GB, a reduction of 17.4%. This also enhances the metadata of the output file and adds the following data to allow for better error handling and make future upgrades easier: - A newly introduced utxo set magic - A version number - The network magic - The block height ACKs for top commit: achow101: ACK 542e13b TheCharlatan: Re-ACK 542e13b theStack: ACK 542e13b Tree-SHA512: 0825d30e5c3c364062db3c6cbca4e3c680e6e6d3e259fa70c0c2b2a7020f24a47406a623582040988d5c7745b08649c31110df4c10656aa25f3f27eb35843d99 Dash adaptations: - The txid read and written for each group of coins is a uint256, as COutPoint's hash is in this tree. - The evo section follows the coins (dashpay#7601), so the check that no coin follows the last one reads that section instead of a txid, and its error covers both cases. - The test's network magics are Dash's, and the unrecognized-hash case lists the regtest heights and the -assumeutxodata pin. - The snapshot differs between runs (see the bitcoin#27596 port). For the wrong coins count of a txid, the test therefore looks for a txid with a single coin and only expects the load to be refused. It changes the first coin's outpoint index by flipping a byte, and lists no content hash for each case. rpc_dumptxoutset.py checks this tree's hash.
…in#29612 efc1b5b test: Add coverage for txid coins count check when loading snapshot (Fabian Jahr) 6b60848 assumeutxo: Add network magic ctor param to SnapshotMetadata (Fabian Jahr) 1f1f998 assumeutxo: Deserialize trailing byte instead of Txid (Fabian Jahr) 359967e doc: Add release notes for bitcoin#29612 (Fabian Jahr) Pull request description: This adds release notes for bitcoin#29612 and addresses post-merge review comments. ACKs for top commit: maflcko: utACK efc1b5b theStack: utACK efc1b5b Tree-SHA512: 3b270202e4f7b2576090ef1d970fd54a6840d96fc3621dddd28e888fb8696a97ff69af2e000bcee3b364316ca3f6e2a9b2f1694c6184f0e704dc487823127ce4 Dash adaptations: - The left-over check reads the evo section, not a single byte (see the bitcoin#29612 port), so its hunk does not apply. - The test's case table carries each case's expected log line, since the cases list no content hashes here (see the bitcoin#28647 port). - The Dash unit tests in validation_chainstatemanager_tests.cpp construct SnapshotMetadata with the message start as well.
…d not be loaded df6dc2a test: Assumeutxo: snapshots with less work should not be loaded (Hernan Marino) Pull request description: This PR adds a test which checks that snapshots with less accumulated work than the node's active chain, should not be loaded and return with an error. Although in a different context of discussion the missing test was detect in a thread in bitcoin#29394 (see bitcoin#29394 (comment)) ACKs for top commit: maflcko: utACK df6dc2a kevkevinpal: utACK [df6dc2a](bitcoin@df6dc2a) achow101: ACK df6dc2a alfonsoromanz: Re ACK df6dc2a. Make is successful and the test passes. Tree-SHA512: 07a394b4b288cc8ad3f66ed4e70dcda468db18113e9442eb7215cf491768432d55efaaa5b79d633094917e05475a30f0c5e4f64f8f2da293ba306891b4485560
…invalid chain 2f9bde6 test: Remove unnecessary restart in assumeutxo test 19ce3d4 assumeutxo: Check snapshot base block is not marked invalid 80315c0 refactor: Move early loadtxoutset checks into ActiveSnapshot Pull request description: ActivateSnapshot() returns a util::Result, so loadtxoutset reports why a load failed, and the checks that loadtxoutset made before calling it move into it. A base block in an invalid chain is refused. Dash adaptations: - 19ce3d4 is equivalent here: SnapshotActivationRefusal() already refuses a base whose chain has a block marked failed or ChainLock- conflicting, at load and again at the switch, so no second check is added. test_snapshot_block_invalidated runs on n0, the node with the downloaded chain, restarted with the pin for this check only (it never loads a snapshot), and matches the refusal's message. - The unrecognized-hash error names the hash and the metadata height and lists the available snapshot heights, as upstream at this point (bitcoin#29612 comes earlier in this stack; bitcoin#30598 later drops the height). - The refusals that this tree logs keep their log lines, which its tests and operators read; each now also returns its reason. Dash's own failures (another activation running, an earlier rejected snapshot, the Evo publication) return theirs too. - loadtxoutset looks the base up after activation for its tip_hash and base_height. - test_invalid_mempool_state (from bitcoin#29394, earlier in this stack) takes its bitcoin#30267 form, with n2 started with -persistmempool=0 as there. It overlaps a unit case of the refusals commit; both are kept. - 2f9bde6 is taken: test_snapshot_with_less_work (bitcoin#29428, earlier in this stack) no longer restarts node 0 after the refusal. Node 0 keeps the pin that check installed until test_invalid_chainstate_scenarios() restarts it without one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fa5b892 rpc: Use untranslated error strings in loadtxoutset (MarcoFalke) fa45865 refactor: Use named arguments to get path arg in loadtxoutset (MarcoFalke) Pull request description: Motivation: * Some are not translated at all, anyway. See bitcoin#30267 (comment) * For others translation is not yet needed, because they are not called by the GUI (yet) * For others translations will never be needed, because they are RPC code. See bitcoin#30267 (comment) Also, while touching this: * Remove the trailing `\n`. See bitcoin#30267 (comment) * Add back the path. See bitcoin#30267 (comment) * Use named args to get the path. ACKs for top commit: fjahr: re-ACK fa5b892 tdb3: ACK fa5b892 ryanofsky: Code review ACK fa5b892 Tree-SHA512: 46504dc5fd55a6274ef885dbe071aa9efb25bca247cd68cd86fb2ff066d70d295e0522e1fe42e63f1fdf7e4c89bd696220edaf06e33b804aba746492eafd852e Dash adaptations: - ActivateSnapshot() has no cleanup_bad_snapshot lambda (see the bitcoin#27596 port). The invalid-chain refusal comes from SnapshotActivationRefusal() (see the bitcoin#30267 port) and is already untranslated. The other errors become Untranslated, as upstream.
…ent chain + test 5b7f70b test: loadtxoutset in divergent chain with less work d35efe1 p2p: Start downloading historical blocks from common ancestor Pull request description: When the active chain tip is not an ancestor of the snapshot base, the background chainstate must download the snapshot's history from the last common ancestor of its tip and the base, not from its own tip. Dash adaptations: - The divergent-chain node is a fifth node (n4): n3 is the node that drops its snapshot with -reindex-chainstate. It is authorized with the same -assumeutxodata pin as the other loading nodes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…_FAILED_CHILD assignment 0bd53d9 test: add test for getchaintips behavior with invalid chains (Martin Zumsande) ccd98ea test: cleanup rpc_getchaintips.py (Martin Zumsande) f5149dd validation: mark blocks building on an invalid block as BLOCK_FAILED_CHILD (Martin Zumsande) 783cb73 validation: call RecalculateBestHeader in InvalidChainFound (Martin Zumsande) 9275e96 rpc: call RecalculateBestHeader as part of reconsiderblock (Martin Zumsande) a51e917 validation: add RecalculateBestHeader() function (Martin Zumsande) Pull request description: `m_best_header` (the most-work header not known to be on an invalid chain) can be wrong in the context of invalidation / reconsideration of blocks. This can happen naturally (a valid header is received and stored in our block tree db; when the full block arrives, it is found to be invalid) or triggered by the user with the `invalidateblock` / `reconsiderblock` rpc. We don't currently use `m_best_header` for any critical things (see OP of bitcoin#16974 for a list that still seems up-to-date), so it being wrong affects mostly rpcs. This PR proposes to recalculate it if necessary by looping over the block index and finding the best header. It also suggest to mark headers between an invalidatetd block and the previous `m_best_header` as invalid, so they won't be considered in the recalculation. It adds tests to `rpc_invalidateblock.py` and `rpc_getchaintips.py` that fail on master. One alternative to this suggested in the past would be to introduce a continuous tracking of header tips (bitcoin#12138). While this might be more performant, it is also more complicated, and situations where we need this data are only be remotely triggerable by paying the cost of creating a valid PoW header for an invalid block. Therefore I think it isn't necessary to optimise for performance here, plus the solution in this PR doesn't perform any extra steps in the normal node operation where no invalidated blocks are encountered. Fixes bitcoin#26245 ACKs for top commit: fjahr: reACK 0bd53d9 achow101: ACK 0bd53d9 TheCharlatan: Re-ACK 0bd53d9 Tree-SHA512: 23c2fc42d7c7bb4f9b4ba4949646b3d0031dd29ed15484e436afd66cd821ed48e0f16a1d02f45477b5d0d73a006f6e81a56b82d9721e0dee2e924219f528b445 Dash adaptations: - RecalculateBestHeader() runs in ResetBlockFailureFlags() rather than in the reconsiderblock RPC, because InstantSend and ChainLock enforcement also clear failure flags through that function. - InvalidateBlock() recalculates the best header when it was stepped back while disconnecting. InvalidChainFound() does not treat the invalidated block's parent as displaced, but the best valid header may be on another branch. rpc_invalidateblock.py covers this with an extra invalidation. - The recalculation skips headers on a ChainLock-conflicting branch. BLOCK_CONFLICT_CHAINLOCK is set only on blocks that were connected, so a candidate's ancestors are checked as well. - rpc_getchaintips.py's invalid block pays this tree's subsidy (nValue=1000), and the tips keep this tree's forkpoint field.
3c3548a validation: clarify final |= BLOCK_FAILED_VALID in InvalidateBlock (Matt Corallo) aac5488 validation: correctly update BlockStatus for invalid block descendants (stratospher) 9e29653 test: check BlockStatus when InvalidateBlock is used (stratospher) c996675 validation: fix traversal condition to mark BLOCK_FAILED_CHILD (stratospher) Pull request description: This PR addresses 3 issues related to how `BLOCK_FAILED_CHILD` is set: 1. In `InvalidateBlock()` - Previously, `BLOCK_FAILED_CHILD` was not being set when it should have been. - This was due to an incorrect traversal condition, which is fixed in this PR. 2. In `SetBlockFailure()` - `BLOCK_FAILED_VALID` is now cleared before setting `BLOCK_FAILED_CHILD`. 3. In `InvalidateBlock()` - if block is already marked as `BLOCK_FAILED_CHILD`, don't mark it as `BLOCK_FAILED_VALID` again. Also adds a unit test to check `BLOCK_FAILED_VALID` and `BLOCK_FAILED_CHILD` status in `InvalidateBlock()`. <details> <summary><h3>looking for feedback on an alternate approach</h3></summary> <br> An alternate approach could be removing `BLOCK_FAILED_CHILD` since even though we have a distinction between `BLOCK_FAILED_VALID` and `BLOCK_FAILED_CHILD` in the codebase, we don't use it for anything. Whenever we check for BlockStatus, we use `BLOCK_FAILED_MASK` which encompasses both of them. See similar discussion in bitcoin#16856. I have a branch with this approach in https://github.com/stratospher/bitcoin/commits/2025_02_remove_block_failed_child/. Compared to the version in bitcoin#16856, it also resets `BLOCK_FAILED_CHILD` already on disk to `BLOCK_FAILED_VALID` when loading from disk so that we won't be in a dirty state in a no-`BLOCK_FAILED_CHILD`-world. I'm not sure if it's a good idea to remove `BLOCK_FAILED_CHILD` though. would be curious to hear what others think of this approach. thanks @ mzumsande for helpful discussion regarding this PR! </details> ACKs for top commit: achow101: ACK 3c3548a TheCharlatan: Re-ACK 3c3548a mzumsande: re-ACK 3c3548a Tree-SHA512: 83e0d29dea95b97519d4868135c965b86f6f43be50b15c0bd8f998b3476388fc7cc22b49c0c54ec532ae8222e57dfc436438f0c8e98f54757b384f220488b6a6 Dash adaptations: - InvalidateBlock() keeps the invalidated block (or, after a stall, the last disconnected one) in m_failed_blocks when it is marked BLOCK_FAILED_VALID, as this tree's header acceptance reads that set and expects that flag on its entries; upstream inserts only in the branch for a block that never was in the chain. A block already failed through its ancestor is not added, and SetBlockFailureFlags() removes the entries of the blocks it demotes to BLOCK_FAILED_CHILD. The unit test checks the set. - The unit test takes cs_main directly instead of ChainstateManager::GetMutex() and includes validation.h and consensus/validation.h, which this blockchain_tests.cpp did not include. - Follow-up to bitcoin#30666, ported earlier in this stack. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the best header chain 55b6d7b validation: Don't load a snapshot if it's not in the best header chain. Pull request description: Refuse a snapshot whose base is not an ancestor of the best known header: the node could not reorg away from it before background validation ends. Dash adaptations: - The check is the last one in SnapshotActivationRefusal(), so it runs at load and again under the cs_main hold of the switch. Headers of a more-work fork that arrive while the snapshot is populated are refused like those known before the load. Upstream checks only at load. The refusal is logged and returned like the other refusals, with upstream's message. - It takes the height from the base's block index entry, the form upstream reaches once bitcoin#30598 drops the height from the metadata. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y go to logs fa530ec rpc: Return precise loadtxoutset error messages (MarcoFalke) faa5c86 refactor: Use untranslated error message in ActivateSnapshot (MarcoFalke) Pull request description: The error messages should never happen in normal operation. However, if they do, they are helpful to return to the user to debug the issue. For example, to notice a truncated file. This fixes bitcoin#28621 Also includes a minor refactor commit. ACKs for top commit: fjahr: Code review ACK fa530ec ryanofsky: Code review ACK fa530ec, just adjusting error messages a little since last review. (Thanks!) Tree-SHA512: 224968c9b13d082ca2ed1f6a8fcc5f51ff16d6c96bd38c3679699505b54337b99cccaf7a8474391f6b11f9ccb101977b4e626898c1217eae95802e290cf105f1 Dash adaptations: - There is no cleanup_bad_snapshot lambda (see the bitcoin#27596 port). ActivateSnapshot() builds the "Population failed: ..." reason, including for a local Evo state error, and returns it after its cleanup. - The Dash refusals in PopulateAndValidateSnapshot() (the evo section, its pin and hash, seeding and the dry run, an assumeutxo entry for another block) return their reasons too. - The Dash tests (feature_assumeutxo_dash.py and the unit tests) match the returned messages.
…ore background chain 49d569c p2p: For assumeutxo, download snapshot chain before background chain 7a88551 p2p: Restrict downloading of blocks for snapshot chain Pull request description: Download the snapshot chain's blocks first by resetting the last common block of each peer to at least the snapshot base, and do not download from peers whose best chain lacks the snapshot base, since the node could not reorg to their chain before background validation ends. Upstream adds no test; the functional rows that sync a snapshot node from n0 cover the download order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
00618e8 assumeutxo: Drop block height from metadata (Fabian Jahr) Pull request description: Fixes bitcoin#30514 which has more context and shows how the issue can be reproduced. Since the value in question is removed, there is no test to add to reproduce anything. This is an alternative approach to bitcoin#30516 with much of the [code being suggested there](bitcoin#30516 (comment)). ACKs for top commit: maflcko: re-ACK 00618e8 🎌 achow101: ACK 00618e8 theStack: Code-review ACK 00618e8 ismaelsadeeq: Re-ACK 00618e8 mzumsande: ACK 00618e8 Tree-SHA512: db9575247bae838ad7742a27a216faaf55bb11e022f9afdd05752bb09bbf9614717d0ad64304ff5722a16bf41d8dea888af544e4ae26dcaa528c1add0269a4a8 Dash adaptations: - The fuzz hunk does not apply: this tree's utxo_snapshot target does not write a snapshot, which came with bitcoin#30329. - The snapshot test's offsets drop the four height bytes, as upstream's do. Its cases keep their Dash forms (see the bitcoin#29612 port).
…operate on snapshot chainstate 917e70a test: assumeutxo: check that UTXO-querying RPCs operate on snapshot chainstate Pull request description: Inspired by some manual testing I did for bitcoin#28553, this PR checks that RPCs which explicitly query the UTXO set database (i.e. `gettxoutsetinfo`, `scantxoutset` and `gettxout`) operate on the snapshot chainstate as expected. Applies unchanged. In Dash both RPCs also flush the snapshot chainstate's Evo state from the RPC thread while the background chainstate runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… nodes during IBD 992f83b test: add coverage for assumeUTXO honest peers disconnection 6d5812e assumeUTXO: fix peers disconnection during sync Pull request description: A node with a snapshot chainstate advertised NODE_NETWORK although it cannot serve the blocks below the base, so IBD peers requested them, got no answer and disconnected it as stalling. loadtxoutset now replaces NODE_NETWORK with NODE_NETWORK_LIMITED, startup does not set NODE_NETWORK while background sync is in progress, and NODE_NETWORK returns when background validation completes (restart_indexes becomes snapshot_download_completed). Dash adaptations: - Snapshots are refused on pruned nodes here, so feature_assumeutxo.py's n1 is a full node: its checks expect NODE_NETWORK_LIMITED only while it is in dual mode and NODE_NETWORK again after completion, as for n2, instead of upstream's pruned-node checks. - The waits for NODE_NETWORK in test_sync_from_assumeutxo_node, after the base block is stored, and in the n2 row, after completion, are bitcoin#30880's 19f4a7c (test: Wait for local services to update in feature_assumeutxo), folded in here. The n1 row waits the same way: the callback that restores NODE_NETWORK runs after the step that disabled the background chainstate, which getchainstates can already reflect. - A snapshot rejected at completion does not restore NODE_NETWORK: the rejection requests a shutdown, and the next startup computes the service flags again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…re_assumeutxo 19f4a7c test: Wait for local services to update in feature_assumeutxo (Fabian Jahr) Pull request description: Closes bitcoin#30878 It seems like there is a race where the block is stored locally and `getblock` does not error anymore, but `ActivateBestChain` has not finished yet, so the local services are not updated yet either. Fix this by waiting for the local services to update. Can be reproduced locally by adding the sleep here: ```cpp ──────────────────────────────────────────────────────────────────────────────────────────────────────────┐ src/validation.cpp:3567: bool Chainstate::ActivateBestChain(BlockValidationState& state, std::shared_ptr< │ ──────────────────────────────────────────────────────────────────────────────────────────────────────────┘ } if (WITH_LOCK(::cs_main, return m_disabled)) { std::this_thread::sleep_for(std::chrono::seconds(10)); // Background chainstate has reached the snapshot base block, so exit. // Restart indexes to resume indexing for all blocks unique to the snapshot ``` ACKs for top commit: maflcko: review-only ACK 19f4a7c achow101: ACK 19f4a7c pablomartin4btc: tACK 19f4a7c furszy: Code review ACK [19f4a7c](bitcoin@19f4a7c). Tree-SHA512: 70dad3795988956c5e20f2d2d895fb56c5e3ce257c7547d3fd729c88949f0e24cb34594da1537bce8794ad02b2db44e7e46e995aa32539cd4dd84c4f1d4bb1c4
…or background chainstate c0a0c72 validation: Disable CheckForkWarningConditions for background chainstate Pull request description: The background chainstate's tip lags far behind, so comparing it with the best invalid block raised a fork warning for a fork that the active chain does not have. Dash adaptations: - feature_assumeutxo_dash.py's dual-mode scenario invalidates the block with the spend conflicting with an InstantSend lock and checks that the warnings lack "We do not appear to fully agree" after the background chainstate connected blocks below it. - As upstream until bitcoin#30214, the step that completes background validation reports NORMAL, so that one step still evaluates the condition; the next active step resets it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…_tx_count, Improve wallet RPC errors 9d2d9f7 rpc: Include assumeutxo as a failure reason of rescanblockchain 595edee test, assumeutxo: import descriptors during background sync d73ae60 rpc: Improve importdescriptor RPC error messages 27f99b6 validation: Don't assume m_chain_tx_count in GuessVerificationProgress 42d5d53 interfaces: Add helper function for wallet on pruning Pull request description: GuessVerificationProgress() can legitimately see a block without a transaction count, e.g. a wallet rescan below a snapshot base, so it returns 0 with a debug log instead of an Assume. importdescriptors and rescanblockchain name the assumeutxo background sync as the likely cause when blocks are unavailable. Dash adaptations: - 42d5d53 (Chain::getPruneHeight) is not ported: it needs GetPruneHeight() from bitcoin#29668, which this tree lacks. rescanblockchain therefore reports pruning whenever the node has pruned, as before; a node with a snapshot chainstate never prunes here, so the assumeutxo message is unaffected. - m_chain_tx_count is nChainTx in this tree; the log names dashd. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… successful 52482cb test: Check datadir cleanup after assumeutxo was successful (Fabian Jahr) Pull request description: I noticed that the proper datadir cleanup after a successful restart of an assumutxo node does not seem to be covered in our tests. This is added here. ACKs for top commit: l0rinc: utACK 52482cb mabu44: Re-ACK 52482cb Prabhat1308: re-ACK [`52482cb`](bitcoin@52482cb) TheCharlatan: Re-ACK 52482cb Tree-SHA512: cc941afeba250050eaccf5112255d961253fec9b2683545454a0d2fbe4d542178394b301d169a9dd79edbf6b5d478d95282727dbb0aca96ee79d4cd1ff80f19b
… promoted bitcoin#33604 is not adopted. Before the restart that promotes a validated snapshot, Dash cannot disconnect below the base's carried Evo state, so downloading from such peers only stalls and churns the chain. bitcoin#29519's refusal, which keys on the snapshot base, already lasts until promotion here, because no snapshot base exists after the promoting restart. Its test is replaced by this one. The snapshot node, validated but not yet restarted, still reports its snapshot base in getchainstates. It refuses a peer whose more-work chain forks below the base, without an Evo state error, and keeps its tip. The restart promotes it, so getchainstates no longer reports a snapshot base, and it then reorgs to that chain below the old base, through the validated chainstate's Evo state. The fork is mined to a fresh address: with the mock time fixed, the usual address would rebuild the block just invalidated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bitcoin#29519's download refusal only covers FindNextBlocksToDownload. A chain forking below the snapshot base still reaches the snapshot chainstate's candidates when its blocks arrive another way (direct fetch of a short fork, submitblock, blocks already on disk) once their parents below the base are linked, which the background chainstate's progress provides. The snapshot chainstate then disconnected its blocks down towards the base until it stalled on Evo state below the base that it does not have, before or after background validation reached the base, and reconnected them. FindMostWorkChain now passes over candidates that do not descend from the base while the snapshot chainstate's chain contains it. They stay in setBlockIndexCandidates, and after the restart that promotes the snapshot there is no base and the node follows them. The test submits a more-work chain forking below the base to a snapshot node whose background chainstate has not reached the base, and to one that has validated it; both keep their tip without disconnecting a block. After the promoting restart the node downloads a block of that chain it has not seen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5cd5794 test: verify node state after restart in assumeutxo Pull request description: Replace the TODO after the restart during background sync with checks of the chainstates and of wallet loading, which still needs the blocks below the snapshot. Dash adaptations: - The pruned-node rows that use the same error helper are absent: a node does not load snapshots with -prune in this tree. - A blank line precedes the nested helper, for this tree's flake8 (E306). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o.py faa68ed test: Fix intermittent issue in wallet_assumeutxo.py Pull request description: -stopatheight may let a few more blocks through during shutdown. Sync the node to the pause height with submitblock instead of restarting it, and unload the wallets so the loading checks still apply. Dash adaptations: - setup_network() keeps its form; the pruned-node rows are absent, as for bitcoin#34286. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…xo.py faf71d6 test: [refactor] Use verbosity=0 named arg 99996f6 test: Fix intermittent issue in feature_assumeutxo.py Pull request description: Sync n1 to the pause height with submitblock instead of a -stopatheight restart, which could stop a few blocks later than expected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
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.
The snapshot loader in #8078 (bitcoin#27596 and its follow-ups) works, but it carries debt that upstream fixed after bitcoin#27596:
nTxandnChainTxfor every block below the base and marks themBLOCK_ASSUMED_VALID. assumeutxo: Get rid of faked nTx and nChainTx values bitcoin/bitcoin#29370 removes the faking.loadtxoutsetaccepts a base that is not in the best header chain, and doesn't report why it refuses a snapshot.feature_assumeutxo.pyandwallet_assumeutxo.py.Restack (2026-12-04). This PR now sits on the restacked #8273, on the per-chainstate Evo design that #8286 put on develop. Its commits are the versions knst ported onto that design in #8284. Compared with the previous head:
BLOCK_FAILED_CHILD, with its unit test. The assumeutxo: Don't load a snapshot if it's not in the best header chain bitcoin/bitcoin#30320 check that the base is on the best header chain is now part ofSnapshotActivationRefusal(), so it also runs under the finalcs_mainhold of the switch.BLOCK_FAILED_VALIDtom_failed_blocksand drops the entries of blocks demoted toBLOCK_FAILED_CHILD, as header acceptance expects. The test hunks of test: Assumeutxo: snapshots with less work should not be loaded bitcoin/bitcoin#29428, rpc: Optimize serialization and enhance metadata of dumptxoutset output bitcoin/bitcoin#29612 and rpc: Return errors in loadtxoutset that currently go to logs bitcoin/bitcoin#30497 now run at their own commits:self.pinis set where it is first read, the coins parser and the truncation use the 55-byte metadata until assumeutxo: Drop block height from metadata bitcoin/bitcoin#30598 drops the height, and the node is bound where it is first used. test: Assumeutxo: ensure failure when importing a snapshot twice bitcoin/bitcoin#29973 checks the repeated load through the debug log, as upstream does, until assumeutxo: Check snapshot base block is not in invalid chain bitcoin/bitcoin#30267 returns the reason.nChainTxon the base: the assumeutxo: Get rid of faked nTx and nChainTx values bitcoin/bitcoin#29370 commit now sets it at the switch, under the finalcs_mainhold.rpc_invalidateblock.pycovers invalidating the active fork when its tip is the best header.feature_assumeutxo.pytakes the hunks the restack had dropped:What was done?
New on top of #8273:
Chain::getPruneHeight()is not ported; see the commit message), test: Check datadir cleanup after assumeutxo was successful bitcoin/bitcoin#32033, test: verify node state after restart in assumeutxo bitcoin/bitcoin#34286, test: Fix intermittent issue in wallet_assumeutxo.py bitcoin/bitcoin#34728 and test: Fix intermittent issue in feature_assumeutxo.py bitcoin/bitcoin#34852. Each Dash adaptation is described in its commit message.cef2377539test: use peers without the snapshot block only after the snapshot is promoted.4a4e5fcd6afix(validation): keep a snapshot chainstate on its base until promotion. A validated but not yet promoted snapshot node no longer follows a higher-work fork from below its base. Doing so would make it disconnect to the base and stall there.What to focus on: bitcoin#29370 (removes the faked counts), bitcoin#30666 (best-header tracking on every network), bitcoin#30497 and bitcoin#30598 (the loader's errors and metadata), and the two Dash commits.
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 feature_assumeutxo_dash.py rpc_dumptxoutset.py rpc_getchaintips.py rpc_invalidateblock.py.Breaking Changes
dumptxoutsetfile format. Snapshots dumped by earlier builds of this stack no longer load. No release ever wrote one.m_best_headeris tracked after an invalidation, on every network.Checklist:
🤖 Generated with Claude Code