Repository navigation
rpc: dumptxoutset rollback without invalidating blocks (backport of bitcoin/bitcoin#33477) - #443
Open
chrisguida wants to merge 3 commits into
Open
chrisguida wants to merge 3 commits into
chrisguida wants to merge 3 commits into
Conversation
Backport of bitcoin#33477 (commits 49d5e83 and fc73601). dumptxoutset with rollback no longer invalidates blocks and suspends network activity. It copies the UTXO set into a temporary database, disconnects blocks on that copy down to the target height, computes the snapshot from the copy and deletes it. The node keeps following the chain and serving peers while a historical snapshot (or its hash, to verify an assumeutxo chainparams entry) is produced, and a fork at the target height cannot make it fail. A temporary prune lock keeps the needed block data while a pruned node rolls back. The new in_memory option keeps the temporary database in RAM (more than 10 GB on mainnet), which is faster. Adapted to Knots' human-readable dumptxoutset output: the rolled-back dump takes the same format arguments as the tip dump. Rolling back on the copy is slower than the invalidateblock approach for deep rollbacks (upstream measured 9m16s vs 3m17s for ~1500 blocks) but performance no longer depends on the state of the main chain.
Backport of bitcoin#33477 commit ab9463e, with the in-memory case from fc73601.
Backport of bitcoin#33477 commit d0fd718.
This was referenced Oct 7, 2026
Author
|
An assembler-ready copy is at chrisguida/dumptxoutset-rollback-copy-29+knots (same three commits rebased onto the compat_rpc_dumptxoutset_hr merge, the oldest point on 29.x where they apply); this branch stays as is for review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of bitcoin#33477 (fjahr, merged 2026-04-19) to 29.x-knots.
dumptxoutsetwithrollbackcurrently invalidates blocks down to the target height,suspends network activity, writes the snapshot and reconsiders the blocks. While it runs
the node is in a state that does not reflect reality, it cannot serve peers or follow the
chain, and a fork at the target height makes it fail. Reviewing an assumeutxo chainparams
entry means running exactly this on a synced node, which discourages people from doing it.
With this change the RPC copies the UTXO set into a temporary database, disconnects blocks
on that copy down to the target height, computes the snapshot from the copy and deletes
it. The node keeps running normally. A temporary prune lock keeps the needed block data on
pruned nodes. The new
in_memory=trueoption keeps the temporary database in RAM (morethan 10 GB on mainnet) and is faster.
Deep rollbacks are slower than before (upstream measured 9m16s vs 3m17s for ~1500 blocks
on disk) but the time no longer depends on the state of the main chain, and the node stays
online.
Adapted to Knots' human-readable
dumptxoutsetformat: the rolled-back dump takes thesame
format,show_headerandseparatorarguments as the tip dump. The functionaltests that checked the network-activity handling are dropped (there is nothing to suspend
any more); the upstream fork test and the in-memory case are added, and the sqlite tool
test exercises the rollback path.
Commits:
Motivation: makes verifying the assumeutxo snapshot in #444 a background
operation on any synced node.
Testing done
test/functional/rpc_dumptxoutset.pyandtool_utxo_to_sqlite.pypass (python 3.14).976000, tip 976069, 16 cores, NVMe):
dumptxoutset rollback=976001while the node keptits 10 peers and followed the chain. On disk: 784 s (copying 167M coins into the temporary
database is most of it; the copy was 9.1 GB and was removed afterwards). With
in_memory=true: 473 s. Both runs returned the sametxoutset_hash(ed7dfbf6388813105dbc7c39bb44ee5503252868c39db8f0d93607dbc342fb98) and
nchaintx(1417215824). Rolling back to the snapshot base height itself (976000) is refused on such
a node with "necessary block data is already pruned", because the base block has no undo
data until background validation reaches it; that check is unchanged from the current code.