Repository navigation
wallet: Prepare for future upgrades by recording versions of last client to open and decrypt - #32895
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32895. ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, 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. |
|
I wonder if this can be uncoupled from
|
|
Concept ACK. It shouldn't hurt to add more metadata to help detect when there might be a mix of old data in a newer format and new data in an older format in the same wallet. Conceptually, I think we could always detect these cases by just scanning the entire wallet for data that needs to be upgraded on loading. But having this extra metadata is nice because it can avoid slowing down wallet loading by avoiding unnecessary upgrade rescans. On the approach in e94ef51837daa5ec9552eb14e8ccc38d1b82b65b, I think it is ok, but would suggest some ways it might be improved:
|
Definitely, however I'd like to be able to reuse the existing "version" record which mostly has the desired behavior since v24.0. The detection only works because of older versions overwriting the field with their CLIENT_VERSION. Introducing a new field now means that we cannot detect when an upgraded wallet was opened in any version older than v30.0 (assuming this is merged for the next release). The timeline would be too soon for any newly introduced features in say v31.0 or v32.0 (and I've got a few things in mind already that would utilize this). I'm already not particularly thrilled by the fact that the current implementation can only detect down to 24.0 as I expect that users doing upgrade-downgrade-upgrade with even older versions is commonplace.
I don't think that is actually viable as it would largely end up performing the upgrade on all loads regardless of whether the upgrade has already been done. |
|
Maybe I am missing something obvious, but my suggestion was not to introduce a new field/record. It was to re-use the existing field (and value) and manually handle the value going forward only when needed. That is, old wallets will (obviously) continue to write their |
Sorry, I was responding to @ryanofsky's comment at the same time since they were very similar. I think that may be workable. |
e94ef51 to
f747394
Compare
|
I've updated the PR to do a combination of @maflcko's and @ryanofsky's suggestions. The new approach decouples I believe this preserves the behavior of detecting downgrades down to v24.0, while also giving us the flexibility of a new field and feature flags. |
f747394 to
5d367db
Compare
5d367db to
3662960
Compare
I believe that's only because the tasks were canceled by a new push. |
b0470f5 to
93d4e89
Compare
|
Took the suggestioin |
| if (has_last_client) pwallet->WalletLogPrintf("Last client version = %d\n", last_client); | ||
|
|
||
| std::optional<uint64_t> last_client_features; | ||
| if (last_client >= VERSION_LAST_CLIENT_FEATURES) { |
There was a problem hiding this comment.
in 74b2475 wallet: Introduce LastClientFeatures flags and LAST_OPENED_FEATURES record
Isn't this always true? last_client = VERSION_LATEST and VERSION_LATEST = VERSION_LAST_CLIENT_FEATURES
There was a problem hiding this comment.
No, last_client is overwritten by m_batch->Read(DBKeys::VERSION, last_client) if the record exists in the database.
|
Concept ACK I wonder if instead of two separate feature enums for decrypted and encrypted we could use the same and have half most significant bits for encrypted and the other half for the unencrypted. |
1f5c103 to
7b846ee
Compare
It's easier to have 2 fields. |
Instead of tying the last client record with the node version, introduce a separate wallet client version that will be increased as necessary when new automatic upgrades are introduced.
7b846ee to
0758310
Compare
polespinasa
left a comment
There was a problem hiding this comment.
looks pretty good to me ACK 0758310
Left two comments, maybe worth addressing now that this does not have many ACKs
| pwallet->WalletLogPrintf("Error: Unable to write the last opened version. Wallet corrupt.\n"); | ||
| return DBErrors::CORRUPT; |
There was a problem hiding this comment.
in 0f10473 walletdb: Decouple last client record from CLIENT_VERSION
I wonder if CORRUPT is the right error code here, maybe LOAD_FAIL?
There was a problem hiding this comment.
I consider write failures to be corruption failures, especially upon loading. A write failure means that something very bad is happening.
…ecord LastClientFeatures are feature flags indicating what automatic upgrade features supported by the last client that opened the wallet. The LAST_OPENED_FEATURES record stores these flags and must be set to match the exact features supported by the client that opens a wallet.
Set these flags to avoid the automatic upgrade after migrating.
0758310 to
7b32155
Compare
…ecording versions of last client to open and decrypt
7b32155458cc87e50da1fa9f245cc84bc203f25a wallet: Set last opened and decrypted features during migration (Ava Chow)
f998a740fc9f56c813973155cef44c757f1955dd wallet: Record the supported features of the last client to decrypt a wallet (Ava Chow)
8453ad801b63ec92af1652cdcf801165c59f2ab2 wallet: Introduce LastClientFeatures flags and LAST_OPENED_FEATURES record (Ava Chow)
0f104733cc8e4b1736efa6a3bc92a8e3dba1a1b3 walletdb: Decouple last client record from CLIENT_VERSION (Ava Chow)
Pull request description:
When a wallet is automatically upgraded, we always do so in a way that allows the user to load their wallet in an older version. When the user loads their wallet into an upgraded version again, the wallet may not perform the automatic upgrade and end up with upgraded and non-upgraded material in the wallet.
If we write some information about the last client to open the wallet, we would be able to detect these upgrade-downgrade-upgrade situations and perform another upgrade if so. However, in order for this to work, we need to have implemented writing such information into versions prior to the ones which introduce new automatic upgrades.
We are already writing the CLIENT_VERSION into all wallets in a "version" record, although this record is not updated in the same way across all previous versions. Since v24.0, we are always updating the record when the client version differs, but prior to that, the record would only be updated when the client version is newer. Even so, we can use this record to store the last client version.
The first commit decouples the written client version from the node version. This aids in development of new features. The version is entirely decoupled from previous versions by requiring all versions to have bit 19 set, and the initial version being `0 | (1 << 19)`. The versions just need to be at least 299900, and forcing bit 19 to be set was an easy way to achieve this.
However, using version numbers is not as flexible as feature flags, so the second commit introduces the concept of Wallet Client Features. These flags are distinct from the existing Wallet Feature Flags since they are conceptually different. These are written in a separate record, and the wallet client version is incremented to `(1 << 19) + 1`.
Lastly, since some upgrades may need private keys and can only occur after the wallet is decrypted, the third commit also adds a last decrypted features flags record to record the features of the last client to decrypt the wallet.
The result is that we will now be able to detect a downgrade down to v24.0 and be able to implement in parallel multiple features that require automatic upgrades.
ACKs for top commit:
polespinasa:
ACK 7b32155458cc87e50da1fa9f245cc84bc203f25a
w0xlt:
reACK 7b32155458cc87e50da1fa9f245cc84bc203f25a
Tree-SHA512: 7d619e24e06a48162950bd153e12ae9fe05454ca8422e7f3d185b1b8ac2506ead6c1bc094da0b1182aceffe3cf198b948335b676f383ce88f4f9e0ae78beca61
4bacf21a13c2 Merge bitcoin/bitcoin#36474: ci: Run valgrind --exclude tests again acdb32693417 Merge bitcoin/bitcoin#35989: wallet: fix crash on importdescriptors with a range ending at 2^31-1 f739c7876b81 Merge bitcoin/bitcoin#36450: test: Use timeout_factor for drain timeout in check_slow_read_throttle 8ad7e25d1fff Merge bitcoin/bitcoin#34374: kernel: use struct-based logging and simplify logging interface fa486a484322 ci: Run valgrind --exclude tests again 442884f5f3bd Merge bitcoin/bitcoin#35037: ipc: support per-address max-connections options on -ipcbind 8406af1c0d69 Merge bitcoin/bitcoin#36436: ci: Derive CONTAINER_NAME from the ci config file name 6b93788355b3 Merge bitcoin/bitcoin#36471: bitcoin-util: print genesis hash in display order f60450e98fc9 Merge bitcoin/bitcoin#36416: test: use ipaddress in addr_to_hex cc8285e8c98a bitcoin-util: print genesis hash in display order 282a05b8d10e Merge bitcoin/bitcoin#36462: rpc: fix OpenRPC hex pattern to allow empty strings 4d7e00d36bf0 rpc: Fix OpenRPC hex pattern to allow empty strings db0bde16b910 Merge bitcoin/bitcoin#36418: kernel: document that btck_WriteBytes may receive a null pointer b497a71c6630 kernel: document that btck_WriteBytes may receive a null pointer 9dfde64cc326 Merge bitcoin/bitcoin#36447: test: Misc fixes for pending validation events races 35e3c9324e67 Merge bitcoin/bitcoin#36029: cmake: Detect and log MinGW-w64 version when cross-compiling for Windows ff623cfa9beb Merge bitcoin/bitcoin#36392: test: Extract and use sigterm_node in init_fd_overflow_test fa466dea808d test: Avoid pending validation events from TestChain100Setup fa339713dbc5 test: Drain all validation events before stopping indexes 9523d2b4a185 Merge bitcoin/bitcoin#34844: util: Add util::NotNull<SmartPtrType> fa845f76d5c6 test: Use timeout_factor for drain timeout in check_slow_read_throttle 14a328f75df8 Merge bitcoin/bitcoin#36338: BIP-352: fix P2PKH pubkey extraction from malleated scriptSig 5661a65c9fb4 Merge bitcoin/bitcoin#36432: wallet: show real fee_reason strings in help 672c2d213773 Merge bitcoin/bitcoin#36448: randomenv: use `KERN_POSIX1` over `KERN_OSREV` 6b8a5524f7e7 Merge bitcoin/bitcoin#36291: test: add script_tests cases covering interpreter mutants 14f89aeea6df Merge bitcoin/bitcoin#36340: util: cap Sock::WaitMany timeout to fix -rpcclienttimeout=0 on macOS d1f9a5b3e050 randomenv: use KERN_POSIX1 over KERN_OSREV 0cd0789c86b3 test: use ipaddress in addr_to_hex fa21ac647dc2 test: [move-only] wallet rescan tests to separate TU fa2cdb6a3c18 ci: [refactor] remove redundant GOAL=install fa547e8204cb ci: [refactor] Remove redundant set -o errexit fa8fd9164fb4 ci: Derive CONTAINER_NAME from the ci config file name 93c8aec3fbc8 doc: add release note for #35989 aef8a04966d7 Merge bitcoin/bitcoin#36435: ci: isolate container test networks 3cb91bc7da67 Merge bitcoin/bitcoin#36308: test: Set tsan enable_adaptive_delay=1 by default fa42e2868414 refactor: Return util::NotNull<std::unique_ptr<ChangeSet>> from CTxMemPool::GetChangeSet() fa04fafb3aac refactor: In CNode use util::NotNull<std::unique_ptr<Transport>> m_transport fae9ab0f0dc4 refactor: Use NotNull pointer to input fetching pool fa0184afa2f9 refactor: Use util::NotNull<std::unique_ptr<LevelDBContext>> m_db_context fafa44e020ab util: Add util::NotNull<SmartPtrType> acaf322fc438 Merge bitcoin/bitcoin#36152: test: cover the feature-negotiation version boundary in p2p_leak f55788e84552 Merge bitcoin/bitcoin#36277: net: always complete all initial private broadcast connections cf80493e2367 Merge bitcoin/bitcoin#34729: Reduce log noise 2c992472842f Merge bitcoin/bitcoin#36303: http: Log bytes received from client, use to replace receive-throttle regression test 09e22fbbb0ca Merge bitcoin/bitcoin#35873: test: add a tx_valid vector for CVE-2024-38365 b47ec7c6e14e Merge bitcoin/bitcoin#35835: test: add CONST_SCRIPTCODE failure-path vectors to script_tests.json 889e7c5af841 Merge bitcoin/bitcoin#36329: psbt: add new test vectors 0036d5f1fa09 Merge bitcoin/bitcoin#36262: test: cover orphan reconsideration interruptibility 36e9e52f169c Merge bitcoin/bitcoin#34907: wallet, test: make wallet_fast_rescan robust 8c49a9abe919 Merge bitcoin/bitcoin#36151: makeseeds: fix off-by-one in field count check b42ea675334c Merge bitcoin/bitcoin#36349: rpc: avoid copying unbroadcast transaction IDs just to count them fa966fd76764 ci: Use one subnet per container 714261b508c2 Merge bitcoin/bitcoin#36426: test: check IBD insufficient work disconnect of outbound peers fae564e66ab4 ci: Use one network per container and rm it after success 367119018dea Merge bitcoin/bitcoin#36320: test: refactor: make chain_dir consistent with CreateBaseChainParams 6e419391cf41 Merge bitcoin/bitcoin#32895: wallet: Prepare for future upgrades by recording versions of last client to open and decrypt c7835db15a5b Merge bitcoin/bitcoin#36080: p2p: Suspend ping timeout while downloading blocks from a peer b3f9d8e1ddf6 Merge bitcoin/bitcoin#36128: test: add script_tests cases covering more interpreter mutants b6a1b0ff7079 Merge bitcoin/bitcoin#36327: test: speed up secp256k1 fixed-base multiplication and Schnorr signing 052cf121ab0a rpc: avoid copying unbroadcast txids to count them 781d8dbd500d wallet: show real fee_reason strings in help 66776840beb5 Merge bitcoin/bitcoin#36415: rpc: clarify preciousblock help text c502b65c007b test: check IBD insufficient work disconnect of outbound peers c8e852d3a02a Merge bitcoin/bitcoin#36404: fuzz: don't set random state for private broadcast test dd809d2c08a3 Merge bitcoin/bitcoin#36299: cli: Improve empty-response and fix -rpcclienttimeout regression 802eb7daa9a8 Merge bitcoin/bitcoin#34213: net: preserve anchors when network is disabled 15d092639957 rpc: clarify preciousblock help text 65896ac58ea6 Merge bitcoin/bitcoin#36411: ci: drop `-Wno-error=maybe-uninitialized` from win64 cxx flags eb086540b680 kernel: make logging struct-based and simplify configuration 0c327a34748a kernel: add KernelLogger 16bff77a5aaf test: cover orphan reconsideration interruptibility 3d976f464d5a kernel: remove API to format and disable logging 4ec80a5d4fa3 kernel: add log level and category name helpers to wrapper 2ce6cd3d906d kernel: expose btck_LogEntry d83647e7c48a p2p: Don't apply ping timeout while downloading blocks 69142eacd137 Merge bitcoin/bitcoin#36383: util: remove unused exception parameter in `Popen::execute_process` 2b43c62d8ef5 p2p: move ping timeout check into SendMessages 8b5bbfe1fca1 test: add functional test for pings during IBD a829aeaac1af Merge bitcoin/bitcoin#36412: ci: drop `-U_FORTIFY_SOURCE` from TSAN job c57ef546c391 ci: use LLVM libc++ 23.1.2 f2a0e7392c6e ci: drop -U_FORTIFY_SOURCE from TSAN job 963f557a721b ci: drop -Wno-error=maybe-uninitialized from win64 flags 9f0595279521 Merge bitcoin/bitcoin#36052: ci: Doc: Move all config comments right next to the option they explain 1d19cca0761a fuzz: don't set random state for private broadcast test 00c1b52ee56b net: remove PrivateBroadcast::DidNodeConfirmReception dc95a705d402 net: always complete all initial private broadcast connections 7988380da987 Merge bitcoin/bitcoin#36272: guix: split Linux toolchain d4b0e1e4b078 Merge bitcoin/bitcoin#35833: log: prevent user input from injecting fake log lines 8dcf90a9b320 util: cap Sock::WaitMany timeout fad49a733d61 test: Extract and use sigterm_node in init_fd_overflow_test 7b32155458cc wallet: Set last opened and decrypted features during migration f998a740fc9f wallet: Record the supported features of the last client to decrypt a wallet 8453ad801b63 wallet: Introduce LastClientFeatures flags and LAST_OPENED_FEATURES record 4b612c6bf8cf Merge bitcoin/bitcoin#36391: test: fix typo in rpc_psbt 0a8ffe9051ab test: fix typo in rpc_psbt cdfaa534d006 BIP-352: fix P2PKH pubkey extraction from malleated scriptSig c35b99251450 test: characterize buggy BIP-352 P2PKH extraction on malleated scriptSig 856f9ea15805 doc: add ipcbind max-connections release note bdd381b8ed47 ipc: test per-address connection limiting over unix sockets 8761d53b250e ipc: support per-address max-connections on ipcbind c9d101ca7ab5 guix: split Linux toolchain e0f16ef9a489 Merge bitcoin/bitcoin#36377: doc: add 461 (Deterministic ECDSA signatures with low-R grinding) to bips.md cde2f2ec641a build: enable -Wunused-exception-parameter 1b00dff743da util: remove unused exception parameter in Popen::execute_process e7aef7e86da7 Merge bitcoin/bitcoin#36375: wallet: accept uppercase addresses without amount in sendall de8892f9db57 Merge bitcoin/bitcoin#36336: log: move CreateNewBlock() log line behind a new mining category 0198c8533457 Merge bitcoin/bitcoin#36365: fees: fall back to `block_policy` and minor api change ba8fdb971779 Merge bitcoin/bitcoin#36381: test: avoid testing at the exact `-maxfeerate` boundary a4bc96966faa test: refactor: make chain_dir consistent with CreateBaseChainParams efe0dfcf1e5c test: cover DERSIG 9-byte signature lower bound bbc4bdf9092e test: cover DERSIG null S byte only when S is multi-byte fd2cf0450276 test: cover DERSIG null R byte only when R is multi-byte a1deba78c5f6 test: cover DERSIG total-length byte check 3d04ed8ac77b test: cover DERSIG 73-byte signature upper bound 2c0f69a04789 test: cover STRICTENC rejects bad 33-byte pubkey prefix df3008418c20 doc: add release notes 54b8795121d3 log: move CreateNewBlock() log line behind a new mining category 619185d5cefd Merge bitcoin/bitcoin#36233: guix: Update time-machine to `60f6956aeffa7f30285745bd0ea615e9acfc74f8` 3b9768a07aee Merge bitcoin/bitcoin#36275: build: enable `-Wunused-const-variable` dc2a9987aab7 Merge bitcoin/bitcoin#36364: tools: Call SHA256AutoDetect in bitcoin-util, bitcoin-tx and bitcoin-wallet 025768fb37ce test: avoid testing at the exact `-maxfeerate` boundary ced4c6e6ab47 Merge bitcoin/bitcoin#36321: net: cast vector size to avoid overflow, truncation, sign change 5b77288673e2 fees: clear mined-block stats when the mempool load fails c0b7ca3dbdba fees: fall back to block_policy when the mempool estimator can't estimate 4056908f0fea fees: rename the default fee_rate_estimator value to "auto" e7a18350967f Merge bitcoin/bitcoin#36235: ci: fail iwyu job on compiler errors instead of silently logging them d57346d682f1 doc: add 461 (Deterministic ECDSA signatures with low-R grinding) to bips.md df2994b14a4b wallet: accept uppercase addresses without amount in sendall b6fc3cf0046d test: speed up secp256k1 fixed-base multiplication 05bc2f53ce0c Merge bitcoin/bitcoin#36024: ci: Make `test_bitcoin-qt.exe` output visible 4048909a5342 tools: Call SHA256AutoDetect in bitcoin-util, bitcoin-tx and bitcoin-wallet d93d366e204e log: escape newlines in messages 960dcdb62529 test: characterize RPC and wallet input logs feb77d838eda guix: Update time-machine to `60f6956aeffa7f30285745bd0ea615e9acfc74f8` f14a3ef8c5c6 guix: Skip some packages' tests in `python-lief` and `nsis-x86_64` 493850c4c473 test: assert HTTP receive throttle from server-side log ed7dd7cf4e15 Merge bitcoin/bitcoin#34371: wallet: allow importprunedfunds for spending transactions f80aaf4bd7c6 Merge bitcoin/bitcoin#29278: Wallet: Add `maxfeerate` wallet startup option e19f83e944e9 Merge bitcoin/bitcoin#35984: sign: skip signing SIGHASH_SINGLE inputs with no corresponding output ab8033566757 Merge bitcoin/bitcoin#36135: fuzz: test HTTPRequest state machine in http_request 65e075f89fdd Merge bitcoin/bitcoin#35696: i2p: update leaseset encryption types d26f19c77c7b Merge bitcoin/bitcoin#35948: init: correct first-run disk space estimate 694eaad2eb28 kernel: add missing log levels and categories 90374132737e Merge bitcoin/bitcoin#36335: Remove my key from SECURITY.md f6b19b190b2e Merge bitcoin/bitcoin#36322: init: fee estimates can lag behind the chain after restart 5820537e1b4b Remove my key from SECURITY.md da03790dbb11 Merge bitcoin/bitcoin#36324: test: Fixup MAX_BODY_SIZE http throttling test 37969fc15211 Merge bitcoin/bitcoin#36312: net: don't discourage private broadcast peers 6fa2f3974cbb test: add BIP174 invalid value size vector e8e7e91a1144 Merge bitcoin/bitcoin#36284: wallet: don't double discard output groups with avoidpartialspends 8c27c3852641 init: drain callbacks before saving fee estimates 08729e6ef9c9 test: characterize fee callback loss at shutdown 308cd670195d net: cast vector size to avoid overflow, truncation, sign change bfdcd9797cd1 Merge bitcoin/bitcoin#35890: doc: use overwrite (>) instead of append (>>) for one-shot PSBT files in offline-signing-tutorial.md de9f42c497df Merge bitcoin/bitcoin#36316: ci: use POSIX threads for Nix Windows builds 029bc15f2cb5 test: add BIP174 sighash combiner vector fa2c62036b1d test: Fixup MAX_BODY_SIZE http throttling test 5c726f2058a4 Merge bitcoin/bitcoin#35675: mining: add block template manager 26241482e530 Merge bitcoin/bitcoin#35923: mempool: count unbroadcast txids in memory usage a632d4f697f3 Merge bitcoin/bitcoin#35177: test: use MiniWallet for getblockstats test data generation be5d0b5503fa Merge bitcoin/bitcoin#35301: Silent Payments: Implement bip352 (take 2) b3f846ec3e5c Merge bitcoin/bitcoin#35440: wallet: check descriptor cache xpub length before decoding dc3cd1969ed3 Merge bitcoin/bitcoin#35809: contrib: add deterministic fuzz coverage mode 81e2de897dbc Merge bitcoin/bitcoin#35893: test: cover submitpackage other-wtxid for same-txid-diff-witness eab6630addc3 net: don't discourage private broadcast peers 31754523cd81 Merge bitcoin/bitcoin#36309: private broadcast: clarify claims, mark as experimental 9fd18aedb088 ci: print Windows cross compiler thread model 1d59d5ad2550 ci: use POSIX threads in Nix Windows cross shell e3ee0ebd89e9 tests: add BIP352 test vectors as unit tests f133d1373af6 common: add bip352.{h,cpp} secp256k1 module 96d487c11e8f ci: raise BuildKit step log limit 44997c391afc Add "sp" HRP 356c91f6ae51 crypto: add KeyPair::GetSecpKeypair fa90a8a01318 ci: [refactor] Use eval-based string-to-argv conversion for FUZZ_TESTS_ARGS 0f104733cc8e walletdb: Decouple last client record from CLIENT_VERSION 2b95b45a9abd Merge bitcoin/bitcoin#35813: wallet, rpc: Add listrawtransactions RPC 71c30b608382 Merge bitcoin/bitcoin#27052: test: rpc: add last block announcement time to getpeerinfo result d36f4a1788da Merge bitcoin/bitcoin#36155: doc: remove json quoting from gettxoutsetinfo and getblockstats cli examples b7211ba80cde Merge bitcoin/bitcoin#34717: p2p: remove m_getaddr_sent 7ee3d622e5fa Merge bitcoin/bitcoin#35752: wallet: make encryption state updates atomic f41372998377 private broadcast: mark feature as experimental 2630d8e6c9d6 doc: scope claims about private broadcast feature 248ce46faf70 Merge bitcoin/bitcoin#35619: test: ExtendedPrivateKey follow-ups 995da8678a02 Merge bitcoin/bitcoin#36302: ci: simplify macOS codesign check db7ec4fb9762 refactor: (de)serialize CExtKey/CExtPubKey through streams cb69853fc160 wallet: check descriptor cache xpub length before decoding f86cbf53eb3e Merge bitcoin/bitcoin#36310: rpc: clarify that `getaddrmaninfo` counts unique addresses bbc40ede1ba6 Merge bitcoin/bitcoin#36261: test: cover PSBT unknown field merging cf57dc281e8f build: add -Wunused-const-variable b45a7084d809 refactor: use inline constexpr f839ee1afb0f Merge bitcoin/bitcoin#35887: ipc: use std::optional for checkSpawned(), add tests and rename arg -ipcfd to -ipcchild dac53c585b6a Merge bitcoin/bitcoin#31888: contrib: Support re-writing linearize-data dumps 0d34b6e9287f rpc: clarify that getaddrmaninfo counts unique addresses 4ecbc82d412f Merge bitcoin/bitcoin#36278: Update minisketch subtree to latest master 622817f097d6 ci, iwyu: fail job on compiler errors instead of ignoring them 5ca3773414df Merge bitcoin/bitcoin#36298: Update crc32c subtree to latest master fa18f9aeac8e ci: Doc: Move all config comments right next to the option they explain fa0e84ec53fc ci: refactor: Use printf %q quoting for BITCOIN_CONFIG 5945cb83ddcf contrib: add deterministic fuzz coverage mode fa0d826eac33 test: Use sanitizer env in functional tests by default fafce3be39a2 test: Set tsan enable_adaptive_delay=1 by default faf907fd1391 test: Add with_sanitizer_env.py fad2fc5a0f02 doc: Remove section on how to install libasan etc 716e8605e5c8 ci: simplify macOS codesign check 767d86aaa780 http: log received bytes per client read 457c9e8999fb script: avoid overflow when checking descriptor range bounds ab3bb55a67cc test: add coverage for descriptor range end bounds 867ad9bffbd3 wallet: fix integer overflow in descriptor keypool top up 1889440f821d wallet: reject unrepresentable descriptor import ranges 2c8372db1131 Update crc32c subtree to latest master 5181c61d734f Squashed 'src/crc32c/' changes from efb8ea04e4..60bcf13edf 7c311f5c6c3e doc: Add release notes for listrawtransactions b377786df14e test: Add functional test for listrawtransactions 605c4fd3aee0 wallet, rpc: Add listrawtransactions RPC ba6c179ba07c wallet, rpc: allow omitting parent_descs from TransactionDescriptionString 719324977a41 test: Check that ineligible output groups are discarded only once 6d2414542b86 wallet: reuse unlock and passphrase change errors 593554622e2c wallet: return passphrase errors with Expected f949b3ba2ad7 wallet: publish descriptor keys after writes e3712b7d492f test: characterize descriptor insertion failure bd558107784c wallet: abort failed descriptor key erases 537e79191585 test: cover encrypted descriptor key insertion d8a6f5e48d6b wallet: abort failed descriptor key writes 14ce3fdb493a test: characterize descriptor key failures 5bc0be16fe4d wallet: reject failed passphrase changes ee6d45a07e3a test: characterize passphrase write failure 2daa2f94f4a2 wallet: restore lock state before re-encryption 8b23fa47737a wallet: abort failed encryption transactions e6c374d30201 test: characterize encryption transaction failures 70381010c0af refactor/test: add wallet failure injection dc3e2bc6df68 wallet, rpc: extract PushTxAmountAndFee/PushTxDecoded helpers 20307f0ac0e1 wallet: don't double count discarded output groups with avoidpartialspends 1805716354b4 cli: Apply -rpcclienttimeout per socket wait instead of per phase b841ab694215 cli: Treat a response with Content-Length: 0 as complete 749bd10fdf01 Update minisketch subtree to latest master fcb2d832b2d9 Squashed 'src/minisketch/' changes from 4a179c61e3..a12f5de1c9 21e4ea8134d8 test: cover PSBT unknown field merging f69e56bc1c43 [doc]: add release notes 40ab7aa90de5 [wallet]: warn when `-maxtxfee` conflicts with `-minrelaytxfee` df1feeb487dc [wallet]: enforce `-maxfeerate` on wallet transactions d2c832e9e79d [util]: add a new transaction error type 633c08d3f7af [node]: update `BroadcastTransaction` to check fee rate limit 7bfce65801bf [wallet]: add `maxfeerate` wallet startup option 607568f2b002 [wallet]: update `max_fee` to `max_tx_fee` 6b913b6224bd doc: add missing verb to make sentence readable a9c39696f4be scripted-diff: rename `m_default_max_tx_fee` to `m_max_tx_fee` 8df006f23383 wallet: skip signing SIGHASH_SINGLE inputs with no corresponding output 3d7d190b6995 ci: enforce iwyu for block template manager ffe3a631f38b node: remove NodeContext::mining and EnsureMining 6c71166bcfa4 test: create templates via BlockTemplateManager ec4f24ef181a rpc: wait for tips via BlockTemplateManager 8372721f20e2 rpc: build generation templates via BlockTemplateManager 38556f817e06 rpc: only copy the header in getblocktemplate 951fac807d37 rpc: do not copy template data in getblocktemplate 0998c0bbdfcc rpc: build getblocktemplate via BlockTemplateManager 011cbfbcd2e3 rpc: route getblocktemplate internals through node 400ac328c91b interfaces: create block template via BlockTemplateManager 037d3519f2ff node: move tip and wait helpers into BlockTemplateManager 07964c525d47 miner: move SubmitBlock into BlockTemplateManager bcdadf2b7111 node: move mining_args to BlockTemplateManager 482a5d27124c node: introduce BlockTemplateManager 3d2b65d05096 ipc: add default connection limit for ipcbind listeners ddf033054ff6 test: cover anchor handling across network toggles with mocktime b0bff47d4432 net: log that anchors will be tried for connections only if network is active 4b6b85428586 test: disabling network activity should not affect anchors 04d3d474c48d net: preserve anchors on shutdown when network is inactive 41771236b4d9 net: store anchors in SetNetworkActive e5f3ea3bf6f6 net: guard m_anchors with mutex 2fabbc0bb38d test: check SENDTXRCNCL is sent at version 70016 36775471f81a test: cover the feature-negotiation version boundary in p2p_leak c786052865fd makeseeds: fix off-by-one in field count check fca8fef8f903 fuzz: assert HTTP framing is independent of stream segmentation c368de3eec9c fuzz: exercise the HTTPRequest state machine 57a79c69627d doc: remove json quoting from gettxoutsetinfo and getblockstats cli examples a34861d280b3 test: unify how to avoid the creation of the default wallet in nodes 3458837a0b76 test: use ExtendedPrivateKey in wallet_importdescriptors.py d23b53e0cfbc fuzz: allow http_request inputs to reach MAX_HEADERS_SIZE 56af5e072a0d fuzz: extract http_request parse and framing check into helpers 44a7083d4360 test: cover MAX_OPS_PER_SCRIPT in P2WSH witness scripts f1380123b6f8 test: cover P2WSH trailing byte mismatch 4e7de2ac4cc6 test: cover TAPSCRIPT_MINIMALIF for OP_IF and OP_NOTIF with 1-byte vector 0x00 09cdb3c48872 cmake: Detect and log MinGW-w64 version when cross-compiling for Windows 70701de7c555 ci: Make `test_bitcoin-qt.exe` output visible 05e7d5731840 ipc, test: add checkSpawned() unit tests 42215b85811a init: correct first-run disk space estimate 91f8b365e7e7 validation: Upgrade log levels for possible block corruption warnings 788242d6d009 txindex: Downgrade log messages and include index name 93b9613b764a kernel/coinstats: Downgrade ComputeUTXOStats log level 3c4336631e3d script: Lower level of oversized redeemScript log, push errors to callers 7902a8ee83fc netbase: Tidy up logging levels 4f42b76ca76b netbase: Reduce levels of socks5 error logging ec627b3f3b82 util/log: Add LogWarnThenDebug() helper 9054f7cde43a test: cover submitpackage other-wtxid for same-txid-diff-witness c2da52d3660f wallet: allow importprunedfunds for spending transactions db21e03c9d50 mempool: include unbroadcast txid memory 8d5c4a9290b0 test: characterize unbroadcast memory accounting be30864ed1a6 doc: use overwrite (>) instead of append (>>) for one-shot PSBT files in offline-signing-tutorial.md 8bca7555f832 ipc, refactor: rename arg -ipcfd to -ipcchild bd3a38f10ab7 ipc, refactor: return std::optional<mp::SocketId> from checkSpawned() 6cd2fa5fb4b6 test: add a tx_valid vector for CVE-2024-38365 829e44a1151f test: add CONST_SCRIPTCODE failure-path vectors to script_tests.json 13ce46ba1a79 doc: add release note for 27052 5d5397d84108 test: add functional test for block announcement time tracking 7d3d04e925c7 rpc: add last_block_announcement to the getpeerinfo output 26a25162a48a net: add m_last_block_announcement to CNodeStateStats bb8bca630a8a change m_last_block_announcement type from int64_t to NodeClock::time_point 412540e18d87 i2p: update leaseset encryption types f217da5c59f4 wallet, test: wallet_fast_rescan follow-ups b7cbd804284b test: use MiniWallet for getblockstats test data generation c8ee319fffa1 net: remove m_getaddr_sent a1ecda260996 test: delete redundant addr relay assertion e9dc16194b47 correct the linearize-data script (minor) git-subtree-dir: depend/bitcoin git-subtree-split: 4bacf21a13c2ed25ef9362ca38f26bf0a67d22c9
When a wallet is automatically upgraded, we always do so in a way that allows the user to load their wallet in an older version. When the user loads their wallet into an upgraded version again, the wallet may not perform the automatic upgrade and end up with upgraded and non-upgraded material in the wallet.
If we write some information about the last client to open the wallet, we would be able to detect these upgrade-downgrade-upgrade situations and perform another upgrade if so. However, in order for this to work, we need to have implemented writing such information into versions prior to the ones which introduce new automatic upgrades.
We are already writing the CLIENT_VERSION into all wallets in a "version" record, although this record is not updated in the same way across all previous versions. Since v24.0, we are always updating the record when the client version differs, but prior to that, the record would only be updated when the client version is newer. Even so, we can use this record to store the last client version.
The first commit decouples the written client version from the node version. This aids in development of new features. The version is entirely decoupled from previous versions by requiring all versions to have bit 19 set, and the initial version being
0 | (1 << 19). The versions just need to be at least 299900, and forcing bit 19 to be set was an easy way to achieve this.However, using version numbers is not as flexible as feature flags, so the second commit introduces the concept of Wallet Client Features. These flags are distinct from the existing Wallet Feature Flags since they are conceptually different. These are written in a separate record, and the wallet client version is incremented to
(1 << 19) + 1.Lastly, since some upgrades may need private keys and can only occur after the wallet is decrypted, the third commit also adds a last decrypted features flags record to record the features of the last client to decrypt the wallet.
The result is that we will now be able to detect a downgrade down to v24.0 and be able to implement in parallel multiple features that require automatic upgrades.