validation: check the most recent AssumeUTXO commitment during IBD #36543

Open
l0rinc wants to merge 7 commits from l0rinc/assumeutxo-latest-snapshot into master AGit
l0rinc commented 2026-10-15 13:40:24 +00:00 (Migrated from github.com)

Problem: AssumeUTXO verifies imported UTXOs against a hash we bake into the binary.
Every node reconstructs the same UTXO set during ordinary IBD, but does not check its hash against the existing AssumeUTXO commitment.

Fix: During ordinary block validation, verify the AssumeUTXO hash when block connection reaches the corresponding block.
Log mismatches and raise a GUI/RPC warning while allowing IBD to continue.
Flush pending changes to disk before hashing the UTXO set and comparing the result with the commitment.

Keep only the latest AssumeUTXO commitment per network to limit the extra hashing work during IBD, and update the release process to replace it.
Users who need older snapshots for research or other purposes can use a compatible older release or restore the corresponding commitment as m_assumeutxo_data and recompile.

**Problem:** AssumeUTXO verifies imported UTXOs against a hash we bake into the binary. Every node reconstructs the same UTXO set during ordinary IBD, but [does not check its hash against the existing AssumeUTXO commitment](https://github.com/bitcoin/bitcoin/issues/32377). **Fix:** During ordinary block validation, verify the AssumeUTXO hash when block connection reaches the corresponding block. Log mismatches and raise a GUI/RPC warning while allowing IBD to continue. Flush pending changes to disk before hashing the UTXO set and comparing the result with the commitment. Keep only the latest AssumeUTXO commitment per network to limit the extra hashing work during IBD, and update the release process to replace it. Users who need older snapshots for research or other purposes can use a compatible older release or restore the corresponding commitment as `m_assumeutxo_data` and recompile.
DrahtBot commented 2026-10-15 13:40:35 +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 Sjors, optout21, fametrano

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:

  • #36990 (test: replace hard-coded RPC error codes by l0rinc)
  • #36876 (GUARDED_BY annotations for nTx, m_chain_tx_count by Crypt-iQ)
  • #36827 (test: Kill validation mutants by Zeegaths)
  • #36778 (AssumeUTXO: replace loadtxoutset RPC with a startup arg by l0rinc)
  • #36603 (Improve loadtxoutset performance by ajtowns)
  • #36598 ([Demo] validation: remove AssumeUTXO by l0rinc)
  • #36326 (kernel: Use typed errors for fatal and flush error notifications by arejula27)
  • #36114 (wallet: harden external signer psbt processing, revamp mock by Sjors)
  • #36042 (build: Bump g++ minimum supported version to 13 by maflcko)
  • #35557 (kernel, validation: Add btck_chainstate_manager_set_clock_time 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.

<!--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/36543 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36543.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36543#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 | [Sjors](https://github.com/bitcoin/bitcoin/pull/36543#issuecomment-6229005853), [optout21](https://github.com/bitcoin/bitcoin/pull/36543#issuecomment-6230060049), [fametrano](https://github.com/bitcoin/bitcoin/pull/36543#pullrequestreview-5643008477) | 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: * [#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) * [#36876](https://github.com/bitcoin/bitcoin/pull/36876) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36876.svg"></sub> (GUARDED_BY annotations for nTx, m_chain_tx_count by Crypt-iQ) * [#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) * [#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) * [#36598](https://github.com/bitcoin/bitcoin/pull/36598) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36598.svg"></sub> ([Demo] validation: remove AssumeUTXO by l0rinc) * [#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) * [#36114](https://github.com/bitcoin/bitcoin/pull/36114) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36114.svg"></sub> (wallet: harden external signer psbt processing, revamp mock by Sjors) * [#36042](https://github.com/bitcoin/bitcoin/pull/36042) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36042.svg"></sub> (build: Bump g++ minimum supported version to 13 by maflcko) * [#35557](https://github.com/bitcoin/bitcoin/pull/35557) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35557.svg"></sub> (kernel, validation: Add btck_chainstate_manager_set_clock_time 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-->
First-time contributor

🔴 Major · Restarts bypass failed or interrupted ordinary commitment verification

The forced flush persists the commitment block before verification, so an ordinary restart can resume above the check after either a fatal mismatch or a normal interruption.

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

🔵 Suggestion · Retired commitments block startup before snapshot cleanup

Replacing the supported commitment prevents ordinary upgrades from reopening older snapshot chainstates, including fully validated ones still awaiting restart-time cleanup.

Location: src/node/blockstorage.cpp:449 (head).

🔵 Suggestion · Alternate-chain test does not assert progress past the commitment height

An early rejection of the alternate block at height 110 could leave this test passing at height 109 because the mining helpers ignore connection failures.

Location: src/test/validation_chainstatemanager_tests.cpp:992 (head).

🔵 Suggestion · The ordinary commitment audit holds global locks for the full UTXO scan

The new ordinary-IBD audit holds cs_main and the mempool mutex throughout a potentially multi-minute scan, delaying operations that need either lock.

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

🔵 Suggestion · The UTXO-hash maintenance warning describes an obsolete IBD fallback

The ApplyHash warning says a hash-format change sends snapshot users back to traditional IBD, but ordinary IBD now requests shutdown on the same commitment mismatch.

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

Review coverage was incomplete.


Reviewed: 97b2138e39ce · Full review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:8541d3fafd3ea45d3ad824914bf78a806527457ae4801671a2c4a580beddb288:1e657457416e20a18d8d2d136919c48e28e1bfed7a76c26939ab1ca10a232c6a --> <!-- ralph-base:ab7e668cc6af5d716ad40166d1f88235a2f6d25d --> <!-- ralph-head:97b2138e39ce34e239039e7d38d95e15f3c19a9d --> <!-- ralph-case:a8f205005dbcb29557a2c7e362598094f59e596962a5d7e383c2e22db669132d --> **🔴 Major · Restarts bypass failed or interrupted ordinary commitment verification** The forced flush persists the commitment block before verification, so an ordinary restart can resume above the check after either a fatal mismatch or a normal interruption. Location: [`src/validation.cpp:3078`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/97b2138e39ce34e239039e7d38d95e15f3c19a9d/src/validation.cpp#L3078>) (head). **🔵 Suggestion · Retired commitments block startup before snapshot cleanup** Replacing the supported commitment prevents ordinary upgrades from reopening older snapshot chainstates, including fully validated ones still awaiting restart-time cleanup. Location: [`src/node/blockstorage.cpp:449`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/97b2138e39ce34e239039e7d38d95e15f3c19a9d/src/node/blockstorage.cpp#L449>) (head). **🔵 Suggestion · Alternate-chain test does not assert progress past the commitment height** An early rejection of the alternate block at height 110 could leave this test passing at height 109 because the mining helpers ignore connection failures. Location: [`src/test/validation_chainstatemanager_tests.cpp:992`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/97b2138e39ce34e239039e7d38d95e15f3c19a9d/src/test/validation_chainstatemanager_tests.cpp#L992>) (head). **🔵 Suggestion · The ordinary commitment audit holds global locks for the full UTXO scan** The new ordinary-IBD audit holds cs_main and the mempool mutex throughout a potentially multi-minute scan, delaying operations that need either lock. Location: [`src/validation.cpp:3079`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/97b2138e39ce34e239039e7d38d95e15f3c19a9d/src/validation.cpp#L3079>) (head). **🔵 Suggestion · The UTXO-hash maintenance warning describes an obsolete IBD fallback** The ApplyHash warning says a hash-format change sends snapshot users back to traditional IBD, but ordinary IBD now requests shutdown on the same commitment mismatch. Location: [`src/validation.cpp:3080`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/97b2138e39ce34e239039e7d38d95e15f3c19a9d/src/validation.cpp#L3080>) (head). Review coverage was incomplete. <!-- Review tier: sensitive --> --- Reviewed: [`97b2138e39ce`](<https://git.fish.foo/bitcoin/bitcoin/commit/97b2138e39ce34e239039e7d38d95e15f3c19a9d>) · [Full review report](<https://review.fish.foo/traces/36543-97b2138e39ce34e239039e7d38d95e15f3c19a9d-1868-5.html>) · [Previous reports](<https://review.fish.foo/traces/36543/>) [permalink](<https://review.fish.foo/traces/36543-97b2138e39ce34e239039e7d38d95e15f3c19a9d-1868-5.html>)
DrahtBot commented 2026-10-15 14:01:12 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task iwyu: https://github.com/bitcoin/bitcoin/actions/runs/38744710504/job/116455202409
LLM reason (✨ experimental): CI failed because the IWYU check modified src/kernel/chainparams.cpp by removing an unused cassert include, leaving an uncommitted diff.

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/38744710504/job/116455202409</sub> <sub>LLM reason (✨ experimental): CI failed because the IWYU check modified `src/kernel/chainparams.cpp` by removing an unused `cassert` include, leaving an uncommitted diff.</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>
Sjors commented 2026-10-17 03:24:28 +00:00 (Migrated from github.com)

Concept ACK, see #32377, with two caveats:

stopping the node on a mismatch

I think this risks introducing a new effective checkpoint. If the snapshot were malicious, normal users couldn't sync and a subset may decide to restart in AssumeUTXO mode.

It seems better to emit a warning, severe enough that the GUI shows it, but not aborting. It's a clear sign there's something wrong with the software. Even though it doesn't affect them, they should seek advice, since it's a giant red flag.

(in such a malicious scenario, developers would presumably change the warning to an error, exactly to achieve this wrong behavior)

This was already discussed in https://github.com/bitcoin/bitcoin/issues/32377#issuecomment-2851372290, but the implementation doesn't match the conclusion there.

Keep only the latest AssumeUTXO commitment per network to limit the extra hashing work during IBD

Maybe limit the scope of this PR by only checking the latest hash, but not (yet) deleting the other hashes.


You mentioned offline that the performance impact of this extra check is minimal. It would be good to provide some numbers in the PR description.

I'm not up to speed on how often and when we flush the chainstate to disk during IBD nowadays. How does this interact with that?

Concept ACK, see #32377, with two caveats: > stopping the node on a mismatch I think this risks introducing a new effective checkpoint. If the snapshot were malicious, normal users couldn't sync and a subset may decide to restart in AssumeUTXO mode. It seems better to emit a warning, severe enough that the GUI shows it, but not aborting. It's a clear sign there's something wrong with the software. Even though it doesn't affect them, they should seek advice, since it's a giant red flag. (in such a malicious scenario, developers would presumably change the warning to an error, exactly to achieve this wrong behavior) This was already discussed in https://github.com/bitcoin/bitcoin/issues/32377#issuecomment-2851372290, but the implementation doesn't match the conclusion there. > Keep only the latest AssumeUTXO commitment per network to limit the extra hashing work during IBD Maybe limit the scope of this PR by only _checking_ the latest hash, but not (yet) deleting the other hashes. --- You mentioned offline that the performance impact of this extra check is minimal. It would be good to provide some numbers in the PR description. I'm not up to speed on how often and when we flush the chainstate to disk during IBD nowadays. How does this interact with that?
optout21 commented 2026-10-17 05:16:28 +00:00 (Migrated from github.com)

Concept ACK

As there is a hash provided that requires trust, the more checks the better. It makes sense to use all nodes performing IBD to also perform this check, as it's relatively cheap to do.

It seems better to emit a warning, severe enough that the GUI shows it, but not aborting.

Two suggestions:

  • Introduce an option to skip the new AssumeUTXO hash check (may be a hidden option) -- useful in itself.
  • In the unlikely case a hash mismatch is found, abort, and advice the user to shout out and restart with the ignore AssumeUTXO hash check option. That way the effect is hard to ignore by the user, but easy to bypass.

Maybe limit the scope of this PR by only checking the latest hash, but not (yet) deleting the other hashes.

For clarity it's worth mentioning that the latest hash a user is checking may not be the same as the latest hash of the latest release, nor the one used by most nodes in the network. (For the sake of example, assuming v35 has been released, and a majority of the network is on v34, when a user is running v33, the checked hash will not match the hash used by many other nodes.) Note that it would be desirable to check the hash of newer versions, but of course it's not possible to hardcode hashes of future releases in the source code. So not checking the non-latest hashes is fine, but it's useful to keep them for visibility.

Concept ACK As there is a hash provided that requires trust, the more checks the better. It makes sense to use all nodes performing IBD to also perform this check, as it's relatively cheap to do. > It seems better to emit a warning, severe enough that the GUI shows it, but not aborting. Two suggestions: - Introduce an option to skip the new AssumeUTXO hash check (may be a hidden option) -- useful in itself. - In the unlikely case a hash mismatch is found, abort, and advice the user to shout out and restart with the ignore AssumeUTXO hash check option. That way the effect is hard to ignore by the user, but easy to bypass. > Maybe limit the scope of this PR by only _checking_ the latest hash, but not (yet) deleting the other hashes. For clarity it's worth mentioning that the latest hash a user is checking may not be the same as the latest hash of the latest release, nor the one used by most nodes in the network. (For the sake of example, assuming v35 has been released, and a majority of the network is on v34, when a user is running v33, the checked hash will not match the hash used by many other nodes.) Note that it would be desirable to check the hash of newer versions, but of course it's not possible to hardcode hashes of future releases in the source code. So not checking the non-latest hashes is fine, but it's useful to keep them for visibility.
ajtowns commented 2026-10-24 04:21:13 +00:00 (Migrated from github.com)

What's the performance impact when hitting such a block?

Doesn't this make the result of a release including bad snaphot data worse for everyone -- Alice who does IBD has her node crash despite having good data that she fully verified, and Bob who uses the bad snapshot still potentially fails to an incorrect chain unless Alice has already done her IBD run and Bob happens to hear Alice complain about the failure?

Having predictable snapshot points (every 14112 blocks per bip452) would allow every node to calculate the appropriate hash (in the background on a leveldb snapshot without cs_main held, hopefully) and remember it, prior to a new release being considered, making verification much easier, and consistent across implementations. Including the block's muhash in the assumeutxo set would also probably work here, since muhash is already calculated and stored in coinstatsindex.

What's the performance impact when hitting such a block? Doesn't this make the result of a release including bad snaphot data worse for everyone -- Alice who does IBD has her node crash despite having good data that she fully verified, and Bob who uses the bad snapshot still potentially fails to an incorrect chain unless Alice has already done her IBD run and Bob happens to hear Alice complain about the failure? Having predictable snapshot points (every 14112 blocks [per bip452](https://github.com/bitcoin/bips/pull/2137/files)) would allow every node to calculate the appropriate hash (in the background on a leveldb snapshot without cs_main held, hopefully) and remember it, prior to a new release being considered, making verification much easier, and consistent across implementations. Including the block's muhash in the assumeutxo set would also probably work here, since muhash is already calculated and stored in coinstatsindex.
fametrano (Migrated from github.com) reviewed 2026-10-25 11:38:48 +00:00
fametrano (Migrated from github.com) left a comment

Concept ACK

One issue should be fixed before merge: a node that fails the new check aborts on an assertion, and a plain restart then syncs past the commitment without checking it again. I built 97b2138e39 with one digit of the regtest commitment's hash at height 299 changed, and let it sync the feature_assumeutxo.py chain to 310 from an unmodified node. In nine runs out of nine it logged the mismatch and the fatal error, then died with SIGABRT on Assertion failed: (hashPrevBlock == view.GetBestBlock()) in ConnectBlock. Restarted with no new option, it starts at 299, syncs to 310 and never hashes the UTXO set again. -reindex-chainstate stops it once more, and a plain restart then syncs past 299 again. The same change on cce32b1687 syncs to 310. I can share the harness.

In ConnectTip, block 299 reaches the coins cache and the disk before the check, and the failure returns before m_chain.SetTip. The coins are at 299 while the chain stays at 298. Connecting 299 again, when the next block arrives during shutdown, trips the assert. The next start takes its tip from the coins. Moving the check after UpdateTip is not enough: on regtest the node then aborts in CheckBlockIndex instead. The unit test processes no block after the mismatch, so it reaches neither assert.

On warning versus stopping (Sjors, ajtowns): as it stands, the stop lasts only until the next restart.

Concept ACK One issue should be fixed before merge: a node that fails the new check aborts on an assertion, and a plain restart then syncs past the commitment without checking it again. I built 97b2138e39 with one digit of the regtest commitment's hash at height 299 changed, and let it sync the `feature_assumeutxo.py` chain to 310 from an unmodified node. In nine runs out of nine it logged the mismatch and the fatal error, then died with SIGABRT on `Assertion failed: (hashPrevBlock == view.GetBestBlock())` in `ConnectBlock`. Restarted with no new option, it starts at 299, syncs to 310 and never hashes the UTXO set again. `-reindex-chainstate` stops it once more, and a plain restart then syncs past 299 again. The same change on cce32b1687 syncs to 310. I can share the harness. In `ConnectTip`, block 299 reaches the coins cache and the disk before the check, and the failure returns before `m_chain.SetTip`. The coins are at 299 while the chain stays at 298. Connecting 299 again, when the next block arrives during shutdown, trips the assert. The next start takes its tip from the coins. Moving the check after `UpdateTip` is not enough: on regtest the node then aborts in `CheckBlockIndex` instead. The unit test processes no block after the mismatch, so it reaches neither assert. On warning versus stopping (Sjors, ajtowns): as it stands, the stop lasts only until the next restart.
l0rinc commented 2026-11-02 11:46:47 +00:00 (Migrated from github.com)

Thanks for the reviews!

Maybe limit the scope of this PR by only checking the latest hash, but not (yet) deleting the other hashes.

If we keep multiple hashes, we should test all of them, which would introduce a measurable delay during IBD after a while. If we only check the latest, that would give false confidence for previous ones.
I'd rather keep just the latest commitment and remove the vector and lookup APIs. I don't see a clear use case for keeping that complexity, and if one comes up later, it's straightforward to add support back cleanly.

It seems better to emit a warning, severe enough that the GUI shows it, but not aborting

Agreed, adjusted.

You mentioned offline that the performance impact of this extra check is minimal. It would be good to provide some numbers in the PR description.

My measurements indicate no speed difference whatsoever in total -reindex-chainstate time before and after this change. Let me know if your measurements differ.
For historical context, my earlier gettxoutsetinfo measurements took 137-144 seconds, and fjahr measured 56.5 seconds on an M4 at height 887,381.

Introduce an option to skip the new AssumeUTXO hash check (may be a hidden option) -- useful in itself.

Since mismatches no longer stop IBD, I'd leave out the extra option to keep this change simple.

I'm not up to speed on how often and when we flush the chainstate to disk during IBD nowadays. How does this interact with that?

I plotted the flushes and their causes here.
This PR adds a forced sync at the AssumeUTXO height, writing pending changes while retaining the cache before hashing the UTXO set.
The next periodic write is then scheduled about an hour later.

Doesn't this make the result of a release including bad snaphot data worse for everyone

I have changed it to raise a GUI/RPC warning so ordinary IBD continues.

Having predictable snapshot points [...] prior to a new release being considered

Including the block's muhash in the assumeutxo set would also probably work here

I'm not sure I have all the context that you're referring to. Using MuHash could avoid the scan for nodes already running coinstatsindex, but would require adding another hash to the chain parameters. Given how fast this is currently, I'd keep this PR focused on checking the existing commitment during ordinary IBD.

a node that fails the new check aborts on an assertion, and a plain restart then syncs past the commitment without checking it again.

Thanks for the detailed reproducer.
Switching the IBD mismatch to a warning also removes the early return that left the coins and tip inconsistent.
The updated test connects the following block and checks that the node stays running with the warning set.

The check still isn't rerun on startup beyond that height, and the GUI/RPC warning isn't persisted across restarts. If reviewers find this surprising, I can adjust.

Thanks for the reviews! > Maybe limit the scope of this PR by only checking the latest hash, but not (yet) deleting the other hashes. If we keep multiple hashes, we should test all of them, which would introduce a measurable delay during IBD after a while. If we only check the latest, that would give false confidence for previous ones. I'd rather keep just the latest commitment and remove the vector and lookup APIs. I don't see a clear use case for keeping that complexity, and if one comes up later, it's straightforward to add support back cleanly. > It seems better to emit a warning, severe enough that the GUI shows it, but not aborting Agreed, adjusted. > You mentioned offline that the performance impact of this extra check is minimal. It would be good to provide some numbers in the PR description. My measurements indicate no speed difference whatsoever in total `-reindex-chainstate` time before and after this change. Let me know if your measurements differ. For historical context, [my earlier `gettxoutsetinfo` measurements](https://github.com/bitcoin/bitcoin/pull/30610#issuecomment-2468549376) took 137-144 seconds, and [fjahr measured 56.5 seconds on an M4 at height 887,381](https://github.com/bitcoin/bitcoin/issues/32029#issuecomment-2715987586). > Introduce an option to skip the new AssumeUTXO hash check (may be a hidden option) -- useful in itself. Since mismatches no longer stop IBD, I'd leave out the extra option to keep this change simple. > I'm not up to speed on how often and when we flush the chainstate to disk during IBD nowadays. How does this interact with that? I plotted the flushes and their causes [here](https://github.com/bitcoin/bitcoin/pull/32404#issuecomment-2848685153). This PR adds a forced sync at the AssumeUTXO height, writing pending changes while retaining the cache before hashing the UTXO set. The next periodic write is then scheduled about an hour later. > Doesn't this make the result of a release including bad snaphot data worse for everyone I have changed it to raise a GUI/RPC warning so ordinary IBD continues. > Having predictable snapshot points [...] prior to a new release being considered > > Including the block's muhash in the assumeutxo set would also probably work here I'm not sure I have all the context that you're referring to. Using MuHash could avoid the scan for nodes already running `coinstatsindex`, but would require adding another hash to the chain parameters. Given how fast this is currently, I'd keep this PR focused on checking the existing commitment during ordinary IBD. > a node that fails the new check aborts on an assertion, and a plain restart then syncs past the commitment without checking it again. Thanks for the detailed reproducer. Switching the IBD mismatch to a warning also removes the early return that left the coins and tip inconsistent. The updated test connects the following block and checks that the node stays running with the warning set. The check still isn't rerun on startup beyond that height, and the GUI/RPC warning isn't persisted across restarts. If reviewers find this surprising, I can adjust.
fametrano (Migrated from github.com) reviewed 2026-11-02 16:53:12 +00:00
fametrano (Migrated from github.com) left a comment

Yes, the lost warning surprises me and I would keep it across restarts. The abort I reported is gone at 396f6ddc.

I repeated my setup with one digit of the regtest commitment's hash changed, syncing feature_assumeutxo.py's chain from an unmodified node (harness and output). In nine runs out of nine the node hashes when it connects block 299, sets the warning in getblockchaininfo and getnetworkinfo, runs -alertnotify once and syncs on to 310; an unmodified build raises nothing. After a plain restart the warning is gone from both RPCs and another block does not bring it back, so only the debug.log line remains. -reindex-chainstate raises it again until the next restart, and invalidateblock and reconsiderblock on 299 raise it again too. I did not build the GUI or measure mainnet.

The other two kernel::Warnings are recomputed from the tip, so a restart does not lose them for good. This one cannot be, because the height has passed. In #32377 the check's value is that one honest participant exposes a mismatch, which needs the operator to see it, and whoever restarts after IBD before looking, without -alertnotify, sees it only in the log. Ralph has no report on this head; its last one, on the fatal path, asks to persist the pending check, while I only ask to keep a warning already raised, not to hash again at startup. A flag in the block index database, read at startup like prunedblockfiles, looks enough, though I have not built it: named after the commitment, so a new release does not inherit it, and cleared by a later matching check. Not blocking, your call.

Yes, the lost warning surprises me and I would keep it across restarts. The abort I reported is gone at 396f6ddc. I repeated my setup with one digit of the regtest commitment's hash changed, syncing `feature_assumeutxo.py`'s chain from an unmodified node ([harness and output](https://gist.github.com/fametrano/688409fa2ace3148edbc61d40a1a0ae0/bdba2ececca63a56a8475cd275790882cae1dd34)). In nine runs out of nine the node hashes when it connects block 299, sets the warning in `getblockchaininfo` and `getnetworkinfo`, runs `-alertnotify` once and syncs on to 310; an unmodified build raises nothing. After a plain restart the warning is gone from both RPCs and another block does not bring it back, so only the `debug.log` line remains. `-reindex-chainstate` raises it again until the next restart, and `invalidateblock` and `reconsiderblock` on 299 raise it again too. I did not build the GUI or measure mainnet. The other two `kernel::Warning`s are recomputed from the tip, so a restart does not lose them for good. This one cannot be, because the height has passed. In #32377 the check's value is that one honest participant exposes a mismatch, which needs the operator to see it, and whoever restarts after IBD before looking, without `-alertnotify`, sees it only in the log. Ralph has no report on this head; its last one, on the fatal path, asks to persist the pending check, while I only ask to keep a warning already raised, not to hash again at startup. A flag in the block index database, read at startup like `prunedblockfiles`, looks enough, though I have not built it: named after the commitment, so a new release does not inherit it, and cleared by a later matching check. Not blocking, your call.
fanquake (Migrated from github.com) reviewed 2026-11-23 15:04:12 +00:00
fanquake (Migrated from github.com) commented 2026-11-23 15:04:13 +00:00
verification remains mandatory. (#36543)
```suggestion verification remains mandatory. (#36543) ```
mamaadoshaafi-byte commented 2026-11-24 16:01:32 +00:00 (Migrated from github.com)

Mamaado shaafi

Mamaado shaafi
mamaadoshaafi-byte commented 2026-11-24 16:01:45 +00:00 (Migrated from github.com)

095 308 1092

095 308 1092
mamaadoshaafi-byte commented 2026-11-24 16:01:52 +00:00 (Migrated from github.com)

10 00453309038

10 00453309038
DrahtBot commented 2026-12-01 11:39:21 +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).
Sjors commented 2026-12-03 12:27:07 +00:00 (Migrated from github.com)

Thanks for the reviews!

Maybe limit the scope of this PR by only checking the latest hash, but not (yet) deleting the other hashes.

If we keep multiple hashes, we should test all of them, which would introduce a measurable delay during IBD after a while. If we only check the latest, that would give false confidence for previous ones. I'd rather keep just the latest commitment and remove the vector and lookup APIs. I don't see a clear use case for keeping that complexity, and if one comes up later, it's straightforward to add support back cleanly.

We should make a choice here, and that seems better for a separate PR: do we want only one hardcoded snapshot at a time?

It's a strict decrease in complexity, so it seems fine at first glance, but I'd have to look into why we supported multiple snapshot hashes to begin with.

> Thanks for the reviews! > > > Maybe limit the scope of this PR by only checking the latest hash, but not (yet) deleting the other hashes. > > If we keep multiple hashes, we should test all of them, which would introduce a measurable delay during IBD after a while. If we only check the latest, that would give false confidence for previous ones. I'd rather keep just the latest commitment and remove the vector and lookup APIs. I don't see a clear use case for keeping that complexity, and if one comes up later, it's straightforward to add support back cleanly. We should make a choice here, and that seems better for a separate PR: do we want only one hardcoded snapshot at a time? It's a strict decrease in complexity, so it seems fine at first glance, but I'd have to look into why we supported multiple snapshot hashes to begin with.
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!36543
No description provided.