-
Notifications
You must be signed in to change notification settings - Fork 0
Merge bitcoin/bitcoin#27224: refactor: Remove CAddressBookData::destdata #1136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: backport-0.25-batch-415
Are you sure you want to change the base?
Merge bitcoin/bitcoin#27224: refactor: Remove CAddressBookData::destdata #1136
Conversation
a5986e8 refactor: Remove CAddressBookData::destdata (Ryan Ofsky) 5938ad0 wallet: Add DatabaseBatch::ErasePrefix method (Ryan Ofsky) Pull request description: This is cleanup that doesn't change external behavior. Benefits of the cleanup are: - Removes awkward `StringMap` intermediate representation for wallet address metadata. - Simplifies `CWallet`, deals with used address and received request serialization in `walletdb.cpp` instead of higher level wallet code - Adds test coverage and documentation This PR doesn't change externally observable behavior. Internally, the only change in behavior is that `EraseDestData` deletes rows directly from the database because they are no longer stored in memory. This is more direct and efficient because it uses a single lookup and scan instead of multiple lookups. Motivation for this cleanup is making changes like bitcoin#18550, bitcoin#18192, bitcoin#13756 easier to reason about and less likely to result in unintended behavior and bugs --- This PR is a rebased copy of bitcoin#18608. For some reason that PR is locked and couldn't be reopened or commented on. This PR is an alternative to bitcoin#27215 with differences described in bitcoin#27215 (review) ACKs for top commit: achow101: ACK a5986e8 furszy: Code ACK a5986e8 Tree-SHA512: 6bd3e402f1f60263fbd433760bdc29d04175ddaf8307207c4a67d59f6cffa732e176ba57886e02926f7a1615dce0ed9cda36c8cbc6430aa8e5b56934c23f3fe7
WalkthroughAdds prefix-deletion support to wallet database batches (new ErasePrefix API) with Berkeley DB and SQLite implementations. Refactors wallet address metadata: replaces “used” with previously_spent, introduces receive_requests with per-id storage, updates read/write/erase paths, adjusts interfaces, and adds tests covering multiple DB backends. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (11)
🧰 Additional context used📓 Path-based instructions (3)src/**/*.{cpp,h,cc,cxx,hpp}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**⚙️ CodeRabbit configuration file
Files:
src/{test,wallet/test,qt/test}/**/*.{cpp,h,cc,cxx,hpp}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (1)📓 Common learnings🧬 Code graph analysis (10)src/wallet/bdb.cpp (4)
src/wallet/bdb.h (4)
src/wallet/walletdb.h (4)
src/wallet/walletdb.cpp (3)
src/wallet/test/wallet_tests.cpp (2)
src/wallet/db.h (3)
src/wallet/sqlite.cpp (3)
src/wallet/sqlite.h (1)
src/wallet/wallet.h (4)
src/wallet/wallet.cpp (3)
🔇 Additional comments (21)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Backport of Bitcoin PR bitcoin#27224
This is a backport of Bitcoin Core PR bitcoin#27224
Original PR Description
This is cleanup that doesn't change external behavior. Benefits of the cleanup are:
StringMapintermediate representation for wallet address metadata.CWallet, deals with used address and received request serialization inwalletdb.cppinstead of higher level wallet codeThis PR doesn't change externally observable behavior. Internally, the only change in behavior is that
EraseDestDatadeletes rows directly from the database because they are no longer stored in memory. This is more direct and efficient because it uses a single lookup and scan instead of multiple lookups.Dash-Specific Adaptations
DataStream vs CDataStream: Bitcoin migrated from
CDataStreamtoDataStreamin a separate PR. Dash still usesCDataStream, so all method signatures have been adapted accordingly.ErasePrefix Implementation: Added the
ErasePrefixmethod toDatabaseBatchinterface and implemented it in:DummyBatch: Returns true (no-op)BerkeleyBatch: Uses cursor-based deletion with transaction supportSQLiteBatch: Uses SQLDELETE FROM main WHERE instr(key, ?) = 1queryAddress Reuse Tracking: Adapted
IsAddressUsedtoIsAddressPreviouslySpentwithout witness address types since Dash doesn't support SegWit.DESTDATA Handling: Updated DESTDATA deserialization to parse:
"used"key forpreviously_spentflag"rr##"keys for receive requestsHDCHAIN Handling: Preserved Dash's
CRYPTED_HDCHAINvariant alongsideHDCHAIN.Changes Summary
Replaced generic
CAddressBookData::destdatamap with specific fields:previously_spent: bool flag for address reuse trackingreceive_requests: map for payment requestsAdded
DatabaseBatch::ErasePrefix()for efficient deletion of key rangesRefactored wallet database operations to handle address metadata more directly
Updated wallet loading logic to properly deserialize new address data format
Bitcoin commit: 5325a61
Summary by CodeRabbit
New Features
Bug Fixes
Tests