0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-04 10:07:27 -05:00
bitcoin-bitcoin-core/src/wallet
Ryan Ofsky d9c7c2fd3e
Merge bitcoin/bitcoin#24914: wallet: Load database records in a particular order
3c83b1d884 doc: Add release note for wallet loading changes (Andrew Chow)
2636844f53 walletdb: Remove loading code where the database is iterated (Andrew Chow)
cd211b3b99 walletdb: refactor decryption key loading (Andrew Chow)
31c033e5ca walletdb: refactor defaultkey and wkey loading (Andrew Chow)
c978c6d39c walletdb: refactor active spkm loading (Andrew Chow)
6fabb7fc99 walletdb: refactor tx loading (Andrew Chow)
abcc13dd24 walletdb: refactor address book loading (Andrew Chow)
405b4d9147 walletdb: Refactor descriptor wallet records loading (Andrew Chow)
30ab11c497 walletdb: Refactor legacy wallet record loading into its own function (Andrew Chow)
9e077d9b42 salvage: Remove use of ReadKeyValue in salvage (Andrew Chow)
ad779e9ece walletdb: Refactor hd chain loading to its own function (Andrew Chow)
72c2a54ebb walletdb: Refactor encryption key loading to its own function (Andrew Chow)
3ccde4599b walletdb: Refactor crypted key loading to its own function (Andrew Chow)
7be10adff3 walletdb: Refactor key reading and loading to its own function (Andrew Chow)
52932c5adb walletdb: Refactor wallet flags loading (Andrew Chow)
01b35b55a1 walletdb: Refactor minversion loading (Andrew Chow)

Pull request description:

  Currently when we load a wallet, we just iterate through all of the records in the database and add them completely statelessly. However we have some records which do rely on other records being loaded before they are. To deal with this, we use `CWalletScanState` to hold things temporarily until all of the records have been read and then we load the stateful things.

  However this can be slow, and with some future improvements, can cause some pretty drastic slowdowns to retain this pattern. So this PR changes the way we load records by choosing to load the records in a particular order. This lets us do things such as loading a descriptor record, then finding and loading that descriptor's cache and key records. In the future, this will also let us use `IsMine` when loading transactions as then `IsMine` will actually be working as we now always load keys and descriptors before transactions.

  In order to get records of a specific type, this PR includes some refactors to how we do database cursors. Functionality is also added to retrieve a cursor that will give us records beginning with a specified prefix.

  Lastly, one thing that iterating the entire database let us do was to find unknown records. However even if unknown records were found, we would not do anything with this information except output a number in a log line. With this PR, we would no longer be aware of any unknown records. This does not change functionality as we don't do anything with unknown records, and having unknown records is not an error. Now we would just not be aware that unknown records even exist.

ACKs for top commit:
  MarcoFalke:
    re-ACK 3c83b1d884 🍤
  furszy:
    reACK 3c83b1d8
  ryanofsky:
    Code review ACK 3c83b1d884. Just Marco's suggested error handling fixes since last review

Tree-SHA512: 15fa56332fb2ce4371db468a0c674ee7a3a8889c8cee9f428d06a7d1385d17a9bf54bcb0ba885c87736841fe6a5c934594bcf4476a473616510ee47862ef30b4
2023-06-27 19:03:15 -04:00
..
rpc scripted-diff: Following the C++ Standard rules for identifiers with _. 2023-06-20 10:23:08 +02:00
test Merge bitcoin/bitcoin#27846: [coinselection] Increase SRD target by change_fee 2023-06-23 16:57:11 -04:00
bdb.cpp wallet: Add GetPrefixCursor to DatabaseBatch 2023-06-01 13:09:08 -04:00
bdb.h wallet: Add GetPrefixCursor to DatabaseBatch 2023-06-01 13:09:08 -04:00
coincontrol.cpp refactor: Make ListSelected return vector 2023-04-26 10:41:10 +02:00
coincontrol.h refactor: Make ListSelected return vector 2023-04-26 10:41:10 +02:00
coinselection.cpp [bug] Increase SRD target by change_fee 2023-06-21 16:19:19 -04:00
coinselection.h [bug] Increase SRD target by change_fee 2023-06-21 16:19:19 -04:00
context.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
context.h
crypter.cpp refactor: Move system from util to common library 2023-05-20 12:08:13 +02:00
crypter.h scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
db.cpp move-only: Extract common/args and common/config.cpp from util/system 2023-04-19 10:48:30 +02:00
db.h wallet: Add GetPrefixCursor to DatabaseBatch 2023-06-01 13:09:08 -04:00
dump.cpp streams: Drop confusing DataStream::Serialize method and << operator 2023-06-01 10:27:33 -04:00
dump.h refactor: Move fs.* to util/fs.* 2023-03-23 12:55:18 +01:00
external_signer_scriptpubkeyman.cpp refactor: Move system from util to common library 2023-05-20 12:08:13 +02:00
external_signer_scriptpubkeyman.h wallet: set keypool_size instead of access global args manager 2023-02-15 15:49:44 -03:00
feebumper.cpp refactor: Move system from util to common library 2023-05-20 12:08:13 +02:00
feebumper.h wallet: add outputs arguments to bumpfee and psbtbumpfee 2023-01-17 13:28:53 +02:00
fees.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
fees.h
init.cpp move-only: Extract common/args and common/config.cpp from util/system 2023-04-19 10:48:30 +02:00
interfaces.cpp Merge bitcoin/bitcoin#27224: refactor: Remove CAddressBookData::destdata 2023-05-01 08:16:54 -04:00
load.cpp scripted-diff: move settings to common namespace 2023-05-30 17:26:51 +02:00
load.h scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
receive.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
receive.h wallet: Add wallet/types.h for simple public enum and struct types 2023-04-11 15:52:25 -04:00
salvage.cpp salvage: Remove use of ReadKeyValue in salvage 2023-06-19 16:46:39 -04:00
salvage.h refactor: Move fs.* to util/fs.* 2023-03-23 12:55:18 +01:00
scriptpubkeyman.cpp Merge bitcoin/bitcoin#25634: wallet, tests: Expand and test when the blank wallet flag should be un/set 2023-06-14 09:30:39 -04:00
scriptpubkeyman.h Merge bitcoin/bitcoin#27759: Fix #includes in src/wallet 2023-05-29 16:33:14 +01:00
spend.cpp [bug] Increase SRD target by change_fee 2023-06-21 16:19:19 -04:00
spend.h gui: bugfix, getAvailableBalance skips selected coins 2023-04-03 17:23:42 -03:00
sqlite.cpp Merge bitcoin/bitcoin#27801: wallet: Add tracing for sqlite statements 2023-06-05 10:51:08 +01:00
sqlite.h wallet: Add GetPrefixCursor to DatabaseBatch 2023-06-01 13:09:08 -04:00
transaction.cpp
transaction.h wallet: Add wallet/types.h for simple public enum and struct types 2023-04-11 15:52:25 -04:00
types.h wallet: add AddressPurpose enum to replace string values 2023-04-11 15:52:25 -04:00
wallet.cpp Merge bitcoin/bitcoin#24914: wallet: Load database records in a particular order 2023-06-27 19:03:15 -04:00
wallet.h Add [[nodiscard]] where ignoring a Result return type is an error 2023-05-29 13:12:45 +02:00
walletdb.cpp walletdb: Remove loading code where the database is iterated 2023-06-27 11:08:05 -04:00
walletdb.h walletdb: Refactor legacy wallet record loading into its own function 2023-06-27 11:00:47 -04:00
wallettool.cpp move-only: Extract common/args and common/config.cpp from util/system 2023-04-19 10:48:30 +02:00
wallettool.h
walletutil.cpp move-only: Extract common/args and common/config.cpp from util/system 2023-04-19 10:48:30 +02:00
walletutil.h Merge bitcoin/bitcoin#25634: wallet, tests: Expand and test when the blank wallet flag should be un/set 2023-06-14 09:30:39 -04:00