mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 12:20:38 +00:00
WIP: txospenderindex: hash keys and pack positions to reduce disk usage #36480
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36480
Loading…
Reference in a new issue
No description provided.
Delete branch "txospenderindex-block-keys"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This applies the txindex key scheme from #35531 to
txospenderindex. The motivation is to save space and to allow replicating what #36002 does fortxindex, by referencing blocks instead of local files.The first commits refactor the index code so the #35531 scheme can be shared:
BaseIndex::DBcan opt in to the versioned sync locator, and the block sequence keys, sequence assignment and salted hasher move from txindex intoindex/block_seq.h, without changing txindex's on-disk format. The following commits switch txospenderindex to the new keys and add tests. As in txindex, entries of disconnected blocks are kept and lookups only count blocks in the active chain, soCustomRemoveis gone. Entries written by v31 are still read as a fallback. The last commit makesFindSpenderskip candidates it cannot read and returnstd::optional, mimickingTxIndex::FindTx, since with 5-byte prefixes an unreadable false positive could otherwise hide the real spender.Each entry is about 33% smaller (key bytes):
I did not have time to do a benchmark (my setup is really cheap, laptop where i work with an external SSD connected), will try to do on the next days. But same as #35531 i hope to reduce disk space and indexing time.
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.
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:
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.
Concept ACK!
I have done this before. IIRC the db size went from ~84GB -> ~62GB. The time to index is also much lower.
Do we want to also enable pruning in one go like we are with #36002? I don't think it would be controversial so we could do it all in 1 PR.
Sorry @andrewtoth, i wasnt aware of it 😅 , should i compare with ur code and add u as co author?
sounds awesome!
Sure! i will add the commits, but it will take me some time o7
🟠 Minor · An unreadable spender becomes an ordinary unspent RPC result
When local block-storage damage makes the spender unreadable and neither format supplies a verified match, gettxspendingprevout now returns the normal unspent response instead of an error.
Location:
src/index/txospenderindex.cpp:158(head).🔵 Suggestion · The unreadable-candidate test misses the read-failure branch
Clearing BLOCK_HAVE_DATA skips the forged candidate before ReadTransaction runs, leaving continuation after an actual read failure untested.
Location:
src/test/txospenderindex_tests.cpp:221(head).🔵 Suggestion · The persistent outpoint hash mapping lacks fixed-vector coverage
The tests do not pin the salt-and-outpoint mapping, so a wrapper-only change to the hash inputs could silently make existing hashed rows unreachable.
Location:
src/test/txospenderindex_tests.cpp:126(head).🔵 Suggestion · Hashed spender persistence is not checked after restart
The only positive post-reopen lookup uses legacy data; the hashed spender is checked only before restart, so losing hashed lookup state on reopening would escape this test.
Location:
test/functional/feature_txospenderindex_compatibility.py:84(head).🔵 Suggestion · Legacy detection adds an avoidable LevelDB open
For an existing on-disk database without wipe, legacy detection opens LevelDB twice even though reading the legacy salt after the normal open preserves valid-database behavior.
Location:
src/index/txospenderindex.cpp:52(head).🔵 Suggestion · Document the reorg-related RPC result change
txospenderindex.cpp:153 now filters out spends from disconnected blocks immediately. The base returned them until the index caught up. That visible RPC change has no doc/release-notes-36480.md, and the window is only transient.
Location:
src/index/txospenderindex.cpp:152(head).Review coverage was incomplete.
Reviewed:
fadf210822d8· Full review report · Previous reportspermalink
🚧 At least one of the CI tasks failed.
Task
iwyu: https://github.com/bitcoin/bitcoin/actions/runs/37841926848/job/113533161262LLM reason (✨ experimental): CI failed because the IWYU lint check modified three files, leaving uncommitted include changes that caused
git diff --exit-codeto fail.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.
No worries, it was nothing I published. Let's just keep going with this. I don't need to be added as co-author.
On second thought, if we merge #36002 first we can reuse the TxLookupResult (sorry I have to push an update there)
Sounds good to me, i will wait an then add here
TxLookupResult!Concept ACK
👍 for pruning support and also for merging https://github.com/bitcoin/bitcoin/pull/36002 first - if you agree, please convert this to draft until then so reviewers know which PRs to prioritize.
Concept ACK
Concept ACK
🐙 This pull request conflicts with the target branch and needs rebase.