Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
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:
Possible places where named args for integral literals may be used (e.g.
2026-12-03 15:59:34 |
|
Nice Work, @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. |

Assumeutxo currently needs two
Chainstateobjects, 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
Chainstatenor a place in validation.What this change does:
Chainstateagain.loadtxoutsetmoves the coins of the snapshot into it in place.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.validation.cppshrinks 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:
ConnectBlock()with its own coins, andConnectBlock()no longer knows anything about snapshots.cs_mainis held for minutes while the UTXO set is hashed. The verifier hashes without holding it.BlockConnectedwithout a role, and indexes follow a single accessor.A few things to note:
Chainstateobject. While a snapshot is validated there are still two coins databases on disk, in the same directories as on master, andgetchainstatesstill reports both. A datadir with a loaded snapshot needs no migration.loadtxoutsetstill fills a temporaryChainstatewith 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:
loadtxoutsetno 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.ProcessNewBlock()advances the background validation.getindexinforeports them as not synced until they have reached the tip. The sync thread reads the verifier's progress fromChainstateManager, the same way the loop already reads the chain. If this sounds like a architectural regression, indexes: Stop using node internal types and locking cs_main, improve sync logic #24230 moves that loop out of index code into the node, and this wait would move with it.-prunetarget 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_mainand 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.