ComputeUTXOStats#152
Draft
l0rinc wants to merge 3 commits into
Draft
Conversation
Computing gettxoutsetinfo with hash_type=none still walks the UTXO set to calculate totals, but it does not need to group outputs per transaction for hash construction. Accumulate the same statistics directly in a nullptr hash specialization and remove the unused nullptr hash helper overloads. Strengthen the RPC functional test so the none result is compared to the hashed result minus only the hash field. Benchmark on the local mainnet chainstate (165,155,899 UTXOs) with: bitcoin-cli -rpcclienttimeout=0 -named gettxoutsetinfo hash_type=none use_index=false Before (032223f): 47.462 s +/- 0.103 s After: 34.370 s +/- 0.073 s Speedup: 1.38x
scantxoutset with ranged descriptors derives a bounded set of scriptPubKeys before walking the UTXO set. Keep those scripts in an unordered set using the existing SaltedSipHasher instead of probing a tree for every UTXO.
Also track the distinct derived script sizes and skip the lookup entirely when a coin's scriptPubKey length cannot match. This targets non-empty descriptor scans, including broad xpub balance scans, without changing descriptor expansion or result handling.
Benchmark on the local mainnet chainstate (165,155,899 UTXOs) with:
bitcoin-cli -rpcclienttimeout=0 -named scantxoutset action=start scanobjects='[{"desc":"combo([d34db33f/84h/0h/0h]xpub6DJ2dNUysrn5Vt36jH2KLBT2i1auw1tTSSomg8PhqNiUtx8QX2SvC9nrHu81fT41fvDUnhMjEzQgXnQjKEu3oaqMSzhSrHMxyyoEAmUHQbY/0/*)","range":1000}]'
Before (20dd526b08): 50.266 s +/- 0.190 s
After: 46.402 s +/- 0.221 s
Speedup: 1.08x
The scantxoutset UTXO walk only needs each outpoint key for progress updates and for actual matches. The cursor has already cached the key internally, but the RPC loop was still copying it into a local COutPoint for every coin before checking whether it was needed.
Only fetch the key when updating progress or recording a match, and update progress on the same 8192-coin cadence used for interruption checks. This keeps scan status responsive while removing most key copies and progress atomic stores from the hot loop.
Benchmark, 165,155,899 UTXOs, warmup=1, runs=3:
bitcoin-cli -rpcclienttimeout=0 -named scantxoutset action=start scanobjects='[{"desc":"combo([d34db33f/84h/0h/0h]xpub6DJ2dNUysrn5Vt36jH2KLBT2i1auw1tTSSomg8PhqNiUtx8QX2SvC9nrHu81fT41fvDUnhMjEzQgXnQjKEu3oaqMSzhSrHMxyyoEAmUHQbY/0/*)","range":1000}]'
Before: 42.177 s +/- 0.162 s
After: 40.287 s +/- 0.319 s
Speedup: 1.05x
l0rinc
pushed a commit
that referenced
this pull request
May 28, 2026
The best block locator was introduced in #152, previously created wallets do not have these record.
l0rinc
pushed a commit
that referenced
this pull request
May 28, 2026
Pre-#152 wallets have no best block stored. Test we can migrate them.
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.
No description provided.