validation: validate assumeutxo snapshots with a single chainstate #37094

Open
fjahr wants to merge 10 commits from 2026-12-au-verifier into master AGit
fjahr commented 2026-12-03 15:58:53 +00:00 (Migrated from github.com)

Assumeutxo currently needs two Chainstate objects, and validation code has to pay attention to that everywhere with chainstate roles, target blocks, a second set of block index candidates and role-aware notifications. This PR removes all of it and keeps the feature complete, including the background validation of the snapshot.

The idea is simple. Validating a snapshot never really needed chain selection. It connects a fixed list of blocks and compares one hash at the end, so it needs neither a Chainstate nor a place in validation.

What this change does:

  • Validation only works on a single Chainstate again. loadtxoutset moves the coins of the snapshot into it in place.
  • A new class in the node, node::HistoricalReplayVerifier, validates the snapshot on its own thread. It connects the blocks before the snapshot to the coins the chainstate had before and compares the UTXO set hash at the end.
  • All the code that only existed for handling the second chainstate is deleted.

validation.cpp shrinks by more than 500 lines and the kernel sources by about 50. Outside of tests the code gets smaller overall, and that includes the new verifier. With this, assumeutxo stops being something most validation changes have to take into account.

The concerns people raised about the implementation, and how this answers them:

  • Validation has to reason about several chainstates. There is only one now, and the accessors for a validated and a historical chainstate are gone. The object is created once and never replaced, so code can keep a reference to it. A new block goes through chain selection once and not once per chainstate. Validating the snapshot is one small class in the node that validation never calls. It can't select a chain, reorganize or touch the mempool. The only validation code it runs is ConnectBlock() with its own coins, and ConnectBlock() no longer knows anything about snapshots.
  • Unrelated validation work kept running into assumeutxo. The cases that came up over time share a cause, and that cause is gone. There is one set of block index candidates, so no second set can hold a block index entry while it is changed. Connecting a block, the tip log, the fork warnings and the tip notifications no longer check which chainstate they run for. One accessor says whether the chain is based on a snapshot that is not validated yet, and it changes the moment the validation completes, without a restart. The UTXO set is hashed once, and a restart afterwards only cleans up the directories.
  • The kernel library has to carry the complexity. The verifier is not part of the kernel library, and notifications no longer carry a chainstate role. An application built on the kernel sees one chainstate.
  • cs_main is held for minutes while the UTXO set is hashed. The verifier hashes without holding it.
  • Code outside of validation has to know about chainstate roles. Wallets, indexes and ZMQ get BlockConnected without a role, and indexes follow a single accessor.

A few things to note:

  • "Single chainstate" refers to the Chainstate object. While a snapshot is validated there are still two coins databases on disk, in the same directories as on master, and getchainstates still reports both. A datadir with a loaded snapshot needs no migration.
  • The snapshot loader is left as it is. loadtxoutset still fills a temporary Chainstate with the coins of the snapshot and then moves them into the real one. The temporary object never leaves the loader.

The following behavior changes compared to master are intentional:

  • loadtxoutset no longer accepts a snapshot while the node's tip is on a stale branch. The snapshot's block has to be a descendant of the tip. Background validation then only ever connects blocks, so the cases where it first had to disconnect a stale branch are gone.
  • The node starts the background validation, validation itself does not. An application built on the kernel library that opens a datadir with a snapshot keeps working on it and leaves it unvalidated. On master ProcessNewBlock() advances the background validation.
  • Indexes no longer get notifications for the blocks before the snapshot. Their sync thread stays active while a snapshot is validated and indexes each block once the verifier has written it to disk, so an index is never ahead of the verifier after an unclean shutdown. getindexinfo reports them as not synced until they have reached the tip. The sync thread reads the verifier's progress from ChainstateManager, the same way the loop already reads the chain. If this sounds like a architectural regression, #24230 moves that loop out of index code into the node, and this wait would move with it.
  • A pruned node no longer splits its -prune target in half while a snapshot is validated. A prune lock protects the blocks the verifier still needs, and the pruning code has no snapshot rule left.

Also, this is my fourth big iteration of this concept and the one that I think strikes the best balance but a lot of tweaks to the approach are possible depending on what people prefer. And there are lots of good follow-ups that I left out here like for example shrinking kernel awareness to almost none is possible at the cost of expanding the interface of the kernel. Or connecting the historical blocks with minimized holding of cs_main and keeping requests for those blocks from delaying blocks for the tip.

I couldn't check everything yet, but for now fixes #37056, fixes #37064, fixes #37070, fixes #37071, fixes #37079, fixes #37050, fixes #37053, fixes #37072, fixes #37076, fixes #37078, fixes #36495, fixes #36562, fixes #36939, fixes #32029.

Assumeutxo currently needs two `Chainstate` objects, and validation code has to pay attention to that everywhere with chainstate roles, target blocks, a second set of block index candidates and role-aware notifications. This PR removes all of it and keeps the feature complete, including the background validation of the snapshot. The idea is simple. Validating a snapshot never really needed chain selection. It connects a fixed list of blocks and compares one hash at the end, so it needs neither a `Chainstate` nor a place in validation. What this change does: - Validation only works on a single `Chainstate` again. `loadtxoutset` moves the coins of the snapshot into it in place. - A new class in the node, `node::HistoricalReplayVerifier`, validates the snapshot on its own thread. It connects the blocks before the snapshot to the coins the chainstate had before and compares the UTXO set hash at the end. - All the code that only existed for handling the second chainstate is deleted. `validation.cpp` shrinks by more than 500 lines and the kernel sources by about 50. Outside of tests the code gets smaller overall, and that includes the new verifier. With this, assumeutxo stops being something most validation changes have to take into account. The concerns people raised about the implementation, and how this answers them: - *Validation has to reason about several chainstates.* There is only one now, and the accessors for a validated and a historical chainstate are gone. The object is created once and never replaced, so code can keep a reference to it. A new block goes through chain selection once and not once per chainstate. Validating the snapshot is one small class in the node that validation never calls. It can't select a chain, reorganize or touch the mempool. The only validation code it runs is `ConnectBlock()` with its own coins, and `ConnectBlock()` no longer knows anything about snapshots. - *Unrelated validation work kept running into assumeutxo.* The cases that came up over time share a cause, and that cause is gone. There is one set of block index candidates, so no second set can hold a block index entry while it is changed. Connecting a block, the tip log, the fork warnings and the tip notifications no longer check which chainstate they run for. One accessor says whether the chain is based on a snapshot that is not validated yet, and it changes the moment the validation completes, without a restart. The UTXO set is hashed once, and a restart afterwards only cleans up the directories. - *The kernel library has to carry the complexity.* The verifier is not part of the kernel library, and notifications no longer carry a chainstate role. An application built on the kernel sees one chainstate. - *`cs_main` is held for minutes while the UTXO set is hashed.* The verifier hashes without holding it. - *Code outside of validation has to know about chainstate roles.* Wallets, indexes and ZMQ get `BlockConnected` without a role, and indexes follow a single accessor. A few things to note: - "Single chainstate" refers to the `Chainstate` object. While a snapshot is validated there are still two coins databases on disk, in the same directories as on master, and `getchainstates` still reports both. A datadir with a loaded snapshot needs no migration. - The snapshot loader is left as it is. `loadtxoutset` still fills a temporary `Chainstate` with the coins of the snapshot and then moves them into the real one. The temporary object never leaves the loader. The following behavior changes compared to master are intentional: - `loadtxoutset` no longer accepts a snapshot while the node's tip is on a stale branch. The snapshot's block has to be a descendant of the tip. Background validation then only ever connects blocks, so the cases where it first had to disconnect a stale branch are gone. - The node starts the background validation, validation itself does not. An application built on the kernel library that opens a datadir with a snapshot keeps working on it and leaves it unvalidated. On master `ProcessNewBlock()` advances the background validation. - Indexes no longer get notifications for the blocks before the snapshot. Their sync thread stays active while a snapshot is validated and indexes each block once the verifier has written it to disk, so an index is never ahead of the verifier after an unclean shutdown. `getindexinfo` reports them as not synced until they have reached the tip. The sync thread reads the verifier's progress from `ChainstateManager`, the same way the loop already reads the chain. If this sounds like a architectural regression, #24230 moves that loop out of index code into the node, and this wait would move with it. - A pruned node no longer splits its `-prune` target in half while a snapshot is validated. A prune lock protects the blocks the verifier still needs, and the pruning code has no snapshot rule left. Also, this is my fourth big iteration of this concept and the one that I think strikes the best balance but a lot of tweaks to the approach are possible depending on what people prefer. And there are lots of good follow-ups that I left out here like for example shrinking kernel awareness to almost none is possible at the cost of expanding the interface of the kernel. Or connecting the historical blocks with minimized holding of `cs_main` and keeping requests for those blocks from delaying blocks for the tip. I couldn't check everything yet, but for now fixes #37056, fixes #37064, fixes #37070, fixes #37071, fixes #37079, fixes #37050, fixes #37053, fixes #37072, fixes #37076, fixes #37078, fixes #36495, fixes #36562, fixes #36939, fixes #32029.
DrahtBot commented 2026-12-03 15:59:07 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
Approach ACK ismaelsadeeq

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #37038 (coins: store spent dbcache entries compactly by LarryRuane)
  • #37023 (contrib: Convert check-deps.sh to Python by jeanpablojp)
  • #36946 (scripted-diff: [test] Add util/check.h includes for assertions by maflcko)
  • #36904 (log: Remove trailing and embedded newlines from log messages by maflcko)
  • #36858 (refactor: break the blockstorage/validation circular dependency by pzafonte)
  • #36856 (kernel: add manual pruning by pzafonte)
  • #36854 (kernel: let callers create the block manager by pzafonte)
  • #36827 (test: Kill validation mutants by Zeegaths)
  • #36778 (AssumeUTXO: replace loadtxoutset RPC with a startup arg by l0rinc)
  • #36739 (refactor: pass BlockManager to ChainstateManager by pzafonte)
  • #36738 (refactor: move block writes and pruning into BlockManager by pzafonte)
  • #36702 (validation: don't treat snapshot block as linked on startup by shuv-amp)
  • #36621 (node: batch block file pruning in a single pass over block index by mutatrum)
  • #36603 (Improve loadtxoutset performance by ajtowns)
  • #36520 (interfaces: Avoid node crashes from invalid Chain IPC calls by ryanofsky)
  • #36326 (kernel: Use typed errors for fatal and flush error notifications by arejula27)
  • #36220 (rpc: report background validation progress in getchainstates by arejula27)
  • #36170 (net: stop sharing P2P listeners with automatic Tor services by l0rinc)
  • #36167 (build: Enable -Wunused by fanquake)
  • #36149 (validation: Leave some pruned blocks in m_blocks_unlinked, fix another nSequenceId issue by mzumsande)
  • #36000 (validation: prefetch blocks while connecting by l0rinc)
  • #35731 (Indexes: Harden the flush-error notification invariant by arejula27)
  • #35522 (refactor: Extract per-message helpers from SendMessages() (move-only) by pablomartin4btc)
  • #35229 (refactor: Use CBlockIndex parameters as reference by optout21)
  • #35003 (validation: improve block data I/O error handling in P2P paths by furszy)
  • #34778 (logging: rewrite macros to enforce restrictions at compile-time, improve efficiency and usability by ryanofsky)
  • #34534 (rpc: Manual prune lock management (Take 2) by fjahr)
  • #34360 (bench: add WalletBalanceManySpent for high-history wallet scenario by w0xlt)
  • #34132 (coins,dbwrapper: make database point-read failures fatal by l0rinc)
  • #29256 (log, refactor: Allow log macros to accept context arguments by ryanofsky)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

LLM Linter (✨ experimental)

Possible typos and grammar issues:

  • src/node/historical_verify.cpp: As below a chain tip → As with the chain tip [the original phrasing is unclear]

Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

  • src/rpc/blockchain.cpp: chainman.ActivateSnapshot(afile, metadata, false)

2026-12-03 15:59:34

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/37094 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/37094.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/37094#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | Approach ACK | [ismaelsadeeq](https://github.com/bitcoin/bitcoin/pull/37094#issuecomment-7403812908) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#37038](https://github.com/bitcoin/bitcoin/pull/37038) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/37038.svg"></sub> (coins: store spent dbcache entries compactly by LarryRuane) * [#37023](https://github.com/bitcoin/bitcoin/pull/37023) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/37023.svg"></sub> (contrib: Convert check-deps.sh to Python by jeanpablojp) * [#36946](https://github.com/bitcoin/bitcoin/pull/36946) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36946.svg"></sub> (scripted-diff: [test] Add util/check.h includes for assertions by maflcko) * [#36904](https://github.com/bitcoin/bitcoin/pull/36904) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36904.svg"></sub> (log: Remove trailing and embedded newlines from log messages by maflcko) * [#36858](https://github.com/bitcoin/bitcoin/pull/36858) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36858.svg"></sub> (refactor: break the blockstorage/validation circular dependency by pzafonte) * [#36856](https://github.com/bitcoin/bitcoin/pull/36856) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36856.svg"></sub> (kernel: add manual pruning by pzafonte) * [#36854](https://github.com/bitcoin/bitcoin/pull/36854) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36854.svg"></sub> (kernel: let callers create the block manager by pzafonte) * [#36827](https://github.com/bitcoin/bitcoin/pull/36827) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36827.svg"></sub> (test: Kill validation mutants by Zeegaths) * [#36778](https://github.com/bitcoin/bitcoin/pull/36778) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36778.svg"></sub> (AssumeUTXO: replace `loadtxoutset` RPC with a startup arg by l0rinc) * [#36739](https://github.com/bitcoin/bitcoin/pull/36739) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36739.svg"></sub> (refactor: pass BlockManager to ChainstateManager by pzafonte) * [#36738](https://github.com/bitcoin/bitcoin/pull/36738) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36738.svg"></sub> (refactor: move block writes and pruning into BlockManager by pzafonte) * [#36702](https://github.com/bitcoin/bitcoin/pull/36702) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36702.svg"></sub> (validation: don't treat snapshot block as linked on startup by shuv-amp) * [#36621](https://github.com/bitcoin/bitcoin/pull/36621) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36621.svg"></sub> (node: batch block file pruning in a single pass over block index by mutatrum) * [#36603](https://github.com/bitcoin/bitcoin/pull/36603) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36603.svg"></sub> (Improve loadtxoutset performance by ajtowns) * [#36520](https://github.com/bitcoin/bitcoin/pull/36520) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36520.svg"></sub> (interfaces: Avoid node crashes from invalid Chain IPC calls by ryanofsky) * [#36326](https://github.com/bitcoin/bitcoin/pull/36326) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36326.svg"></sub> (kernel: Use typed errors for fatal and flush error notifications by arejula27) * [#36220](https://github.com/bitcoin/bitcoin/pull/36220) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36220.svg"></sub> (rpc: report background validation progress in getchainstates by arejula27) * [#36170](https://github.com/bitcoin/bitcoin/pull/36170) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36170.svg"></sub> (net: stop sharing P2P listeners with automatic Tor services by l0rinc) * [#36167](https://github.com/bitcoin/bitcoin/pull/36167) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36167.svg"></sub> (build: Enable `-Wunused` by fanquake) * [#36149](https://github.com/bitcoin/bitcoin/pull/36149) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36149.svg"></sub> (validation: Leave some pruned blocks in `m_blocks_unlinked`, fix another `nSequenceId` issue by mzumsande) * [#36000](https://github.com/bitcoin/bitcoin/pull/36000) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36000.svg"></sub> (validation: prefetch blocks while connecting by l0rinc) * [#35731](https://github.com/bitcoin/bitcoin/pull/35731) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35731.svg"></sub> (Indexes: Harden the flush-error notification invariant by arejula27) * [#35522](https://github.com/bitcoin/bitcoin/pull/35522) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35522.svg"></sub> (refactor: Extract per-message helpers from SendMessages() (move-only) by pablomartin4btc) * [#35229](https://github.com/bitcoin/bitcoin/pull/35229) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35229.svg"></sub> (refactor: Use CBlockIndex parameters as reference by optout21) * [#35003](https://github.com/bitcoin/bitcoin/pull/35003) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35003.svg"></sub> (validation: improve block data I/O error handling in P2P paths by furszy) * [#34778](https://github.com/bitcoin/bitcoin/pull/34778) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34778.svg"></sub> (logging: rewrite macros to enforce restrictions at compile-time, improve efficiency and usability by ryanofsky) * [#34534](https://github.com/bitcoin/bitcoin/pull/34534) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34534.svg"></sub> (rpc: Manual prune lock management (Take 2) by fjahr) * [#34360](https://github.com/bitcoin/bitcoin/pull/34360) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34360.svg"></sub> (bench: add WalletBalanceManySpent for high-history wallet scenario by w0xlt) * [#34132](https://github.com/bitcoin/bitcoin/pull/34132) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34132.svg"></sub> (coins,dbwrapper: make database point-read failures fatal by l0rinc) * [#29256](https://github.com/bitcoin/bitcoin/pull/29256) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/29256.svg"></sub> (log, refactor: Allow log macros to accept context arguments by ryanofsky) If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. <!--5faf32d7da4f0f540f40219e4f7537a3--> ### LLM Linter (✨ experimental) Possible typos and grammar issues: - `src/node/historical_verify.cpp`: `As below a chain tip` → `As with the chain tip` [the original phrasing is unclear] Possible places where named args for integral literals may be used (e.g. `func(x, /*named_arg=*/0)` in C++, and `func(x, named_arg=0)` in Python): - `src/rpc/blockchain.cpp`: `chainman.ActivateSnapshot(afile, metadata, false)` <sup>2026-12-03 15:59:34</sup>
First-time contributor

3 additional verified findings in the Review report.

🟠 Minor · Replay completion leaves the snapshot base's undo unflushed

If replay writes the snapshot base's undo into the current ASSUMED file, completion persists its index and coins without flushing that file, so a power loss can leave local state requiring a rebuild.

Location: src/validation.cpp:5989 (head).

🟠 Minor · The loadtxoutset index restart can double-count coinstats

With -coinstatsindex, a timing-dependent loadtxoutset restart can reprocess blocks over an uncommitted in-memory MuHash, corrupting index statistics; production occurrence is unconfirmed.

Location: src/rpc/blockchain.cpp:3580 (head).

🟠 Minor · Validated snapshot promotion treats cleanup failure as fatal

A stray file in the old chainstate directory now prevents startup after snapshot validation, whereas the base version could promote the snapshot and only warn about incomplete cleanup.

Location: src/node/chainstate.cpp:161 (head).

🔵 Suggestion · Index tests do not exercise intermediate replay flushes

The new index wait is not tested against both unflushed replay progress and persisted progress followed by an unclean restart.

Location: src/index/base.cpp:250 (head).

🔵 Suggestion · Operator-visible assumeutxo changes lack a release note

The PR changes snapshot-loading preconditions, pruning storage expectations, and index sync reporting without a release note for operators.

Location: doc/assumeutxo.md:23 (head).

🔵 Suggestion · The loadtxoutset help omits its new preconditions

The assumeutxo guide states the new startup and ancestry requirements, but help loadtxoutset omits them.

Location: src/rpc/blockchain.cpp:3510 (head).

Review coverage was incomplete.


Reviewed: 29ed3015f8dc · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:e1a29e5e677c47d383756f0fcf8f3760725c91d1104dd3ccb2f333b6217eba26:47880f5569fd2047d249266f337c4f2a509adf7d96c3ccb1c7644c2c2a650bff --> <!-- ralph-base:2f3f6397bb92beccaccce16742f0574d1617fb3e --> <!-- ralph-head:29ed3015f8dc42bafe6fec1ccd9762c72109af6b --> <!-- ralph-case:f9512c9c77ed15312fc05c63b4b56864279a9588791f68c71d774997bab3aa69 --> [3 additional verified findings in the Review report](<https://review.fish.foo/report/37094-29ed3015f8dc42bafe6fec1ccd9762c72109af6b-3490-1.html>). **🟠 Minor · Replay completion leaves the snapshot base's undo unflushed** If replay writes the snapshot base's undo into the current `ASSUMED` file, completion persists its index and coins without flushing that file, so a power loss can leave local state requiring a rebuild. Location: [`src/validation.cpp:5989`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/29ed3015f8dc42bafe6fec1ccd9762c72109af6b/src/validation.cpp#L5989>) (head). **🟠 Minor · The `loadtxoutset` index restart can double-count coinstats** With `-coinstatsindex`, a timing-dependent `loadtxoutset` restart can reprocess blocks over an uncommitted in-memory MuHash, corrupting index statistics; production occurrence is unconfirmed. Location: [`src/rpc/blockchain.cpp:3580`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/29ed3015f8dc42bafe6fec1ccd9762c72109af6b/src/rpc/blockchain.cpp#L3580>) (head). **🟠 Minor · Validated snapshot promotion treats cleanup failure as fatal** A stray file in the old `chainstate` directory now prevents startup after snapshot validation, whereas the base version could promote the snapshot and only warn about incomplete cleanup. Location: [`src/node/chainstate.cpp:161`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/29ed3015f8dc42bafe6fec1ccd9762c72109af6b/src/node/chainstate.cpp#L161>) (head). **🔵 Suggestion · Index tests do not exercise intermediate replay flushes** The new index wait is not tested against both unflushed replay progress and persisted progress followed by an unclean restart. Location: [`src/index/base.cpp:250`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/29ed3015f8dc42bafe6fec1ccd9762c72109af6b/src/index/base.cpp#L250>) (head). **🔵 Suggestion · Operator-visible assumeutxo changes lack a release note** The PR changes snapshot-loading preconditions, pruning storage expectations, and index sync reporting without a release note for operators. Location: [`doc/assumeutxo.md:23`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/29ed3015f8dc42bafe6fec1ccd9762c72109af6b/doc/assumeutxo.md#L23>) (head). **🔵 Suggestion · The `loadtxoutset` help omits its new preconditions** The assumeutxo guide states the new startup and ancestry requirements, but `help loadtxoutset` omits them. Location: [`src/rpc/blockchain.cpp:3510`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/29ed3015f8dc42bafe6fec1ccd9762c72109af6b/src/rpc/blockchain.cpp#L3510>) (head). Review coverage was incomplete. <!-- Review tier: sensitive --> --- Reviewed: [`29ed3015f8dc`](<https://git.fish.foo/bitcoin/bitcoin/commit/29ed3015f8dc42bafe6fec1ccd9762c72109af6b>) · [Review report](<https://review.fish.foo/report/37094-29ed3015f8dc42bafe6fec1ccd9762c72109af6b-3490-1.html>) · [Previous reports](<https://review.fish.foo/traces/37094/>) [permalink](<https://review.fish.foo/report/37094-29ed3015f8dc42bafe6fec1ccd9762c72109af6b-3490-1.html>)
ismaelsadeeq commented 2026-12-04 06:44:47 +00:00 (Migrated from github.com)

Nice Work,
I read through the description and skimmed the code, this addresses my concern in bitcoin#36598 about components not being able to hold a stable Chainstate handle.

@fjahr I think this is essentially a rewrite of AssumeUTXO's background validation, we first need to align on whether we want to keep the feature at all, I think it's otherwise, given the sentiment in (#36598).

If we do decide to keep AssumeUTXO, I'm Approach ACK on doing it this way rather than maintaining two Chainstate objects.

Nice Work, I read through the description and skimmed the code, this addresses my concern in [bitcoin#36598](https://github.com/bitcoin/bitcoin/pull/36598#issuecomment-6338865042) about components not being able to hold a stable Chainstate handle. @fjahr I think this is essentially a rewrite of AssumeUTXO's background validation, we first need to align on whether we want to keep the feature at all, I think it's otherwise, given the sentiment in (#36598). If we do decide to keep AssumeUTXO, I'm Approach ACK on doing it this way rather than maintaining two Chainstate objects.
Sjors commented 2026-12-04 10:45:05 +00:00 (Migrated from github.com)

I'm open to this, but it would be good to compare it with dropping background validation (which is my current preference).

I'm open to this, but it would be good to compare it with dropping background validation (which is my current preference).
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!37094
No description provided.