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. |
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
be651eb to
08fc982
Compare
loadtxoutset RPC with a startup argloadtxoutset RPC with a startup arg
When startup connects genesis to an empty chainstate, an index can catch up to genesis before its queued BlockConnected notification arrives. Ignore that notification when a best block is already indexed, so Rewind never receives a null parent.
Startup snapshot loading will happen before the mempool is loaded, making this RPC scenario obsolete. Drop the receiver setting that disabled mempool persistence for this scenario.
Startup snapshot loading will require a chainstate at genesis. Remove the RPC scenarios that import with an active chain with at least as much work, or a different active fork. Preserve the difficulty-field checks in the surviving import scenario. This avoids adapting those scenarios only to delete them when the RPC is retired.
Start the receivers in the main, wallet and chainstate-tool tests at genesis while their producers keep the cached chain. Use the producer's tip time for every node's mocktime in the main and wallet tests. Supply the headers that the fresh receivers need in the wallet and chainstate-tool tests. Run the file-path and invalidated-block checks on a receiver, using the producer for block-hash lookups. Adjust the height and transaction-count checks and use the producer's snapshot metadata for the expected hash and coin count. In the wallet pruning case, check the imported chainstates first, then supply the historical blocks the cached chain used to provide and keep the manual prune sanity check. Remove the height check after invalidation on the headers-only receiver, whose chainstate remains at genesis. Exercise a database-open failure before switching the test calls to startup loading.
Add -loadtxoutset=<file> and call the existing snapshot loader during chainstate initialization, before networking starts. Both this option and the existing RPC use the same snapshot activation checks, including the requirement to know the base header. The main import test retains the header index but removes the ordinary chainstate before importing. Permit a missing active tip in the work comparisons while the RPC still needs those checks. Publish the imported tip so startup can complete without an ordinary chainstate loaded from disk. Treat interrupted imports as cancellation and report exceptions through the initialization error path. Keep snapshot loading separate from reindexing and manual block-import modes. Skip the GUI reindex retry when an import is requested, since these startup modes cannot be combined. Check conflicting startup modes, missing snapshot files and option negation.
Require a receiving chainstate at genesis so a new snapshot import does not replace an existing chain. Also reject unfinished reindexing and stored blocks beyond genesis, which startup could otherwise connect to that chainstate. Check both a populated chainstate and an empty chainstate with stored blocks. The latter must fail before connecting any of those blocks.
Use the startup option for the existing snapshot, wallet and chainstate-tool checks. Update the failure checks in place. A missing base header now fails startup. Mock only the producer's clock, since receivers restart to import and lose theirs. Restore the wallet after importing its snapshot so it can remain active during background validation. This prepares the tests for retiring the RPC without mixing their setup changes into that commit.
Retire snapshot loading through RPC now that the startup option is available. Keep a hidden method for existing callers and let the RPC fuzzer exercise it because it no longer reads files. Leave the help text and migration guidance for the final documentation commit. Existing imported snapshots still resume normally without the option.
Now that imports happen only at startup, the active chain cannot advance during an import and the mempool has not been loaded yet. Startup also rejects a new import if a snapshot chainstate already exists. Remove these checks from snapshot activation. A supported snapshot has more work than the genesis chainstate, which cannot advance during import, so both work comparisons are redundant. Remove the test helper's temporary tip rewind as well. Also remove the unit and fuzz checks that attempt another import. Only the old RPC needed the details of the snapshot's base block in the result. Return no value on success and keep the error message on failure. Keep the checks on the base header, the supported snapshot commitment and the snapshot contents.
Startup imports begin with an empty ordinary chainstate and finish before it can process blocks. Give the snapshot loader the full cache budget directly, without shrinking and flushing the ordinary cache first or restoring it after failure. Remove the old percentage split and its conversions. Keep cache redistribution after the import and during background validation, including the forced flush of the imported block-index state.
The node now announces its limited ability to serve blocks before it accepts any peers. Loading a snapshot therefore no longer needs to remove service flags from a running node. Delete `RemoveLocalServices`, and update the fuzz test to keep track of flags as they are added. The node can still announce full block service once background validation completes.
Describe the -loadtxoutset startup option in the user and design docs, the option and RPC help, and a release note. Update comments, log messages and errors for startup loading, including the base-header error that asked to call loadtxoutset again. Correct the swapped file and directory paths in the missing-base-blockhash warning.
08fc982 to
393d05b
Compare
|
Concept ACK This would also resolve #36346 |
jeanpablojp
left a comment
There was a problem hiding this 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.
| kernel_cache_sizes, | ||
| args); | ||
| if (status == ChainstateLoadStatus::FAILURE && !do_reindex && !ShutdownRequested(node)) { | ||
| if (status == ChainstateLoadStatus::FAILURE && !do_reindex && !SnapshotImportRequested(args) && !ShutdownRequested(node)) { |
There was a problem hiding this comment.
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",
)|
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. |
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.
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. |
|
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. |
It's removing a few corner cases, and I have a few other similar open PRs carving out chunks. |

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
loadtxoutsetRPC 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.