AssumeUTXO: replace loadtxoutset RPC with a startup arg #36778

Open
l0rinc wants to merge 12 commits from l0rinc/assumeutxo-startup into master AGit
l0rinc commented 2026-11-05 14:31:24 +00:00 (Migrated from github.com)

Problem: Loading a UTXO snapshot through RPC requires coordinating with the active chain, mempool, caches and advertised services while the node is running.

Fix: Replace the loadtxoutset RPC with -loadtxoutset=<file> and finish importing during chainstate initialization, before networking and mempool loading begin.
Require a receiver that has not advanced beyond genesis, already knows the snapshot base header and has no stored blocks beyond genesis or unfinished reindexing.
This removes runtime activation checks, temporary import cache resizing and service demotion while preserving snapshot validation, resumption and background validation.

**Problem:** Loading a UTXO snapshot through RPC requires coordinating with the active chain, mempool, caches and advertised services while the node is running. **Fix:** Replace the `loadtxoutset` RPC with `-loadtxoutset=<file>` and finish importing during chainstate initialization, before networking and mempool loading begin. Require a receiver that has not advanced beyond genesis, already knows the snapshot base header and has no stored blocks beyond genesis or unfinished reindexing. This removes runtime activation checks, temporary import cache resizing and service demotion while preserving snapshot validation, resumption and background validation.
DrahtBot commented 2026-11-05 14:31:34 +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
Concept ACK fjahr, jeanpablojp

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:

  • #37094 (validation: validate assumeutxo snapshots with a single chainstate by fjahr)
  • #36990 (test: replace hard-coded RPC error codes by l0rinc)
  • #36629 (Add output script index and corresponding script history RPC by andrewtoth)
  • #36603 (Improve loadtxoutset performance by ajtowns)
  • #36268 (refactor: prune unused semi-colons by fanquake)
  • #34534 (rpc: Manual prune lock management (Take 2) by fjahr)
  • #33324 (blocks: add resumable reobfuscation for existing block files by l0rinc)

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.

<!--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/36778 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36778.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36778#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 | | ---- | --------- | | Concept ACK | [fjahr](https://github.com/bitcoin/bitcoin/pull/36778#issuecomment-6951723996), [jeanpablojp](https://github.com/bitcoin/bitcoin/pull/36778#pullrequestreview-6092138539) | 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: * [#37094](https://github.com/bitcoin/bitcoin/pull/37094) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/37094.svg"></sub> (validation: validate assumeutxo snapshots with a single chainstate by fjahr) * [#36990](https://github.com/bitcoin/bitcoin/pull/36990) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36990.svg"></sub> (test: replace hard-coded RPC error codes by l0rinc) * [#36629](https://github.com/bitcoin/bitcoin/pull/36629) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36629.svg"></sub> (Add output script index and corresponding script history RPC by andrewtoth) * [#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) * [#36268](https://github.com/bitcoin/bitcoin/pull/36268) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36268.svg"></sub> (refactor: prune unused semi-colons by fanquake) * [#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) * [#33324](https://github.com/bitcoin/bitcoin/pull/33324) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/33324.svg"></sub> (blocks: add resumable reobfuscation for existing block files by l0rinc) 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-->
First-time contributor

1 additional verified finding in the Review report.

Earlier concerns remain unresolved; see the Run archive linked from the Review report.

🔴 Major · Genesis-only import lacks a reliable mainnet header-preparation workflow

A fresh mainnet receiver must know the snapshot base header without storing post-genesis blocks, but ordinary synchronization cannot reliably preserve that state; the documented alternative requires roughly 965,000 parent-ordered submitheader calls for the latest snapshot.

Location: src/init.cpp:1414 (head).

🟠 Minor · The RPC removal skips the documented compatibility grace period

Existing loadtxoutset callers lose the working RPC immediately, rather than having the documented one-major-release migration period behind -deprecatedrpc.

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

🟠 Minor · The snapshot-tip notification can release startup before historical genesis connects

With retained headers and an empty ordinary coins DB, startup can expose a null historical tip to RPC or peer processing before genesis connects; no documented production workflow producing this state was identified.

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

🟠 Minor · A leftover import option produces the wrong restart guidance

After a successful import, restarting with -loadtxoutset fails with advice to use a separate datadir, although removing the option lets the existing snapshot resume.

Location: src/init.cpp:1553 (head).

🟠 Minor · An older startup wallet can prevent background validation after import

A genesis receiver may have an autoloaded wallet whose saved locator and birth time require history below the snapshot base, for example a restored older backup. With such a wallet, startup now aborts after the snapshot has already been committed. Restarting without -loadtxoutset resumes the snapshot and fails the same wallet load, so background validation never runs until the wallet is disabled. A wallet with a recent birth time skips the rescan and is unaffected.

Location: src/init.cpp:1561 (head).

🔵 Suggestion · The splash screen shows no progress during startup snapshot import

Qt users see a static loading message throughout snapshot deserialization, flushing and hashing, without progress or the available shutdown hint.

Location: src/init.cpp:1433 (head).

Review coverage was incomplete.


Reviewed: 393d05b33cc4 · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:7eebed8027c96ac27bcd79eeb7a88e35799cd96eb8fbacf34d3257986a959f64:cdc1bd61213c9363d5bb4c7b7ee073ccfd6fecdafbb2c4c18d9d9e031a6afcf8 --> <!-- ralph-base:6f1365e34f518fdc9fb963cd246abeb47a34ce8b --> <!-- ralph-head:393d05b33cc4d1626da4a63a9ed6a25678aff0a3 --> <!-- ralph-case:fbb1995502f505eb6613ab7eee56f866f4fa57d8a2c0b74288040eadcf94d150 --> [1 additional verified finding in the Review report](<https://review.fish.foo/report/36778-393d05b33cc4d1626da4a63a9ed6a25678aff0a3-2512-3.html>). Earlier concerns remain unresolved; see the Run archive linked from the Review report. **🔴 Major · Genesis-only import lacks a reliable mainnet header-preparation workflow** A fresh mainnet receiver must know the snapshot base header without storing post-genesis blocks, but ordinary synchronization cannot reliably preserve that state; the documented alternative requires roughly 965,000 parent-ordered `submitheader` calls for the latest snapshot. Location: [`src/init.cpp:1414`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/393d05b33cc4d1626da4a63a9ed6a25678aff0a3/src/init.cpp#L1414>) (head). **🟠 Minor · The RPC removal skips the documented compatibility grace period** Existing `loadtxoutset` callers lose the working RPC immediately, rather than having the documented one-major-release migration period behind `-deprecatedrpc`. Location: [`src/rpc/blockchain.cpp:3504`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/393d05b33cc4d1626da4a63a9ed6a25678aff0a3/src/rpc/blockchain.cpp#L3504>) (head). **🟠 Minor · The snapshot-tip notification can release startup before historical genesis connects** With retained headers and an empty ordinary coins DB, startup can expose a null historical tip to RPC or peer processing before genesis connects; no documented production workflow producing this state was identified. Location: [`src/validation.cpp:5770`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/393d05b33cc4d1626da4a63a9ed6a25678aff0a3/src/validation.cpp#L5770>) (head). **🟠 Minor · A leftover import option produces the wrong restart guidance** After a successful import, restarting with `-loadtxoutset` fails with advice to use a separate datadir, although removing the option lets the existing snapshot resume. Location: [`src/init.cpp:1553`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/393d05b33cc4d1626da4a63a9ed6a25678aff0a3/src/init.cpp#L1553>) (head). **🟠 Minor · An older startup wallet can prevent background validation after import** A genesis receiver may have an autoloaded wallet whose saved locator and birth time require history below the snapshot base, for example a restored older backup. With such a wallet, startup now aborts after the snapshot has already been committed. Restarting without `-loadtxoutset` resumes the snapshot and fails the same wallet load, so background validation never runs until the wallet is disabled. A wallet with a recent birth time skips the rescan and is unaffected. Location: [`src/init.cpp:1561`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/393d05b33cc4d1626da4a63a9ed6a25678aff0a3/src/init.cpp#L1561>) (head). **🔵 Suggestion · The splash screen shows no progress during startup snapshot import** Qt users see a static loading message throughout snapshot deserialization, flushing and hashing, without progress or the available shutdown hint. Location: [`src/init.cpp:1433`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/393d05b33cc4d1626da4a63a9ed6a25678aff0a3/src/init.cpp#L1433>) (head). Review coverage was incomplete. <!-- Review tier: sensitive --> --- Reviewed: [`393d05b33cc4`](<https://git.fish.foo/bitcoin/bitcoin/commit/393d05b33cc4d1626da4a63a9ed6a25678aff0a3>) · [Review report](<https://review.fish.foo/report/36778-393d05b33cc4d1626da4a63a9ed6a25678aff0a3-2512-3.html>) · [Previous reports](<https://review.fish.foo/traces/36778/>) [permalink](<https://review.fish.foo/report/36778-393d05b33cc4d1626da4a63a9ed6a25678aff0a3-2512-3.html>)
DrahtBot commented 2026-11-05 17:04:32 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-11-05 17:31:29 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task iwyu: https://github.com/bitcoin/bitcoin/actions/runs/42045836029/job/127308391176
LLM reason (✨ experimental): CI failed because IWYU/clang-format detected an uncommitted include change in src/init.cpp (<unordered_map>); the diff check then exited nonzero.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `iwyu`: https://github.com/bitcoin/bitcoin/actions/runs/42045836029/job/127308391176</sub> <sub>LLM reason (✨ experimental): CI failed because IWYU/clang-format detected an uncommitted include change in `src/init.cpp` (`<unordered_map>`); the diff check then exited nonzero.</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
fjahr commented 2026-11-17 14:58:56 +00:00 (Migrated from github.com)
Concept ACK This would also resolve https://github.com/bitcoin/bitcoin/pull/36346
jeanpablojp (Migrated from github.com) reviewed 2026-11-27 18:34:49 +00:00
jeanpablojp (Migrated from github.com) left a comment

Concept ACK

I also read Ralph's review and confirmed two of its points, the major on getting headers into a node at genesis (on signet) and the minor on the restart message when -loadtxoutset is left in the config. I think both are worth fixing in this PR.

Concept ACK I also read Ralph's review and confirmed two of its points, the major on getting headers into a node at genesis (on signet) and the minor on the restart message when `-loadtxoutset` is left in the config. I think both are worth fixing in this PR.
jeanpablojp (Migrated from github.com) commented 2026-11-27 18:34:49 +00:00

Could feature_reindex_init.py get a case for !SnapshotImportRequested(args)? The case below fails without it and passes with it.

        self.log.info("A requested snapshot import skips the reindex retry")
        self.stop_node(0)
        self.cleanup_folder(node.blocks_path / "index")
        node.assert_start_raises_init_error(
            extra_args=["-loadtxoutset=unused", "-test=reindex_after_failure_noninteractive_yes"],
            expected_msg="Error: Error initializing block database",
        )
Could `feature_reindex_init.py` get a case for `!SnapshotImportRequested(args)`? The case below fails without it and passes with it. ```python self.log.info("A requested snapshot import skips the reindex retry") self.stop_node(0) self.cleanup_folder(node.blocks_path / "index") node.assert_start_raises_init_error( extra_args=["-loadtxoutset=unused", "-test=reindex_after_failure_noninteractive_yes"], expected_msg="Error: Error initializing block database", ) ```
ajtowns commented 2026-11-30 10:00:08 +00:00 (Migrated from github.com)

Concept -1 for me -- for assumeutxo to be meaningfully usable, snapshots need to be downloaded via p2p, so the snapshot load needs to happen while the system is running, not at startup. I understand the appeal, and have now implemented "loadtxoutset" as a startup argument myself twice, but I think it's fundamentally a dead end.

Concept -1 for me -- for assumeutxo to be meaningfully usable, snapshots need to be downloaded via p2p, so the snapshot load needs to happen while the system is running, not at startup. I understand the appeal, and have now implemented "loadtxoutset" as a startup argument myself twice, but I think it's fundamentally a dead end.
l0rinc commented 2026-11-30 11:13:19 +00:00 (Migrated from github.com)

for assumeutxo to be meaningfully usable, snapshots need to be downloaded via p2p

I don't think these are incompatible. We could defer block synchronization until the headers and the snapshot have been downloaded via P2P and the snapshot has been activated, avoiding corner cases such as importing a snapshot whose base block is on a different branch from our active chain.

I think it's fundamentally a dead end

It's no secret that my preferred solution would be to remove the dual-chainstate AssumeUTXO machinery altogether. I'm trying to get there in smaller steps that eliminate edge cases and reduce complexity along the way, even if the intermediate states aren't ideal in isolation.

If these individual simplifications don't make sense on their own, we'd have to consider the removal in one much larger step - which I'd prefer to avoid since I expect more pushback there and want to find if there's a simpler set that we would mostly agree on.

> for assumeutxo to be meaningfully usable, snapshots need to be downloaded via p2p I don't think these are incompatible. We could defer block synchronization until the headers and the snapshot have been downloaded via P2P and the snapshot has been activated, avoiding corner cases such as importing a snapshot whose base block is on a different branch from our active chain. > I think it's fundamentally a dead end It's no secret that my preferred solution would be to [remove the dual-chainstate AssumeUTXO machinery altogether](https://github.com/bitcoin/bitcoin/pull/36598). I'm trying to get there in smaller steps that eliminate edge cases and reduce complexity along the way, even if the intermediate states aren't ideal in isolation. If these individual simplifications don't make sense on their own, we'd have to consider the removal in one much larger step - which I'd prefer to avoid since I expect more pushback there and want to find if there's a simpler set that we would mostly agree on.
ajtowns commented 2026-11-30 11:35:33 +00:00 (Migrated from github.com)

If your end state is "remove assumeutxo altogether" then this would be a step in that direction, though I believe describing that as just "remove the dual-chainstate implemention" is deceptive.

If the aim is to continue supporting assumeutxo (and improve it) then the steps need to be be "(1) provide a non-dual-chainstate assumeutxo implementation, (2) remove the dual-chainstate assumeutxo implementation", but moving the code to startup only isn't helpful to either step.

If your end state is "remove assumeutxo altogether" then this would be a step in that direction, though I believe describing that as just "remove the dual-chainstate implemention" is deceptive. If the aim is to continue supporting assumeutxo (and improve it) then the steps need to be be "(1) provide a non-dual-chainstate assumeutxo implementation, (2) remove the dual-chainstate assumeutxo implementation", but moving the code to startup only isn't helpful to either step.
l0rinc commented 2026-11-30 11:40:28 +00:00 (Migrated from github.com)

moving the code to startup only isn't helpful to either step

It's removing a few corner cases, and I have a few other similar open PRs carving out chunks.
Do you have a better idea how to propose the removal in smaller chunks to find out what the consensus is about this contentious feature?

> moving the code to startup only isn't helpful to either step It's removing a few corner cases, and I have a few other similar open PRs carving out chunks. Do you have a better idea how to propose the removal in smaller chunks to find out what the consensus is about this contentious feature?
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!36778
No description provided.