-
Notifications
You must be signed in to change notification settings - Fork 1.2k
backport!: bitcoin#23123, #23147 (wallet rescan related, breaking changes) #7037
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| Notable changes | ||
| =============== | ||
|
|
||
| Rescan startup parameter removed | ||
| -------------------------------- | ||
|
|
||
| The `-rescan` startup parameter has been removed. Wallets which require | ||
| rescanning due to corruption will still be rescanned on startup. | ||
| Otherwise, please use the `rescanblockchain` RPC to trigger a rescan. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1932,7 +1932,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc | |
| WalletLogPrintf("Rescan started from block %s... (%s)\n", start_block.ToString(), | ||
| fast_rescan_filter ? "fast variant using block filters" : "slow variant inspecting all blocks"); | ||
|
|
||
| ShowProgress(strprintf("%s " + _("Rescanning…").translated, GetDisplayName()), 0); // show rescan progress in GUI as dialog or on splashscreen, if -rescan on startup | ||
| ShowProgress(strprintf("%s " + _("Rescanning…").translated, GetDisplayName()), 0); // show rescan progress in GUI as dialog or on splashscreen, if rescan required on startup (e.g. due to corruption) | ||
| uint256 tip_hash = WITH_LOCK(cs_wallet, return GetLastBlockHash()); | ||
| uint256 end_hash = tip_hash; | ||
| if (max_height) chain().findAncestorByHeight(tip_hash, *max_height, FoundBlock().hash(end_hash)); | ||
|
|
@@ -2439,15 +2439,12 @@ DBErrors CWallet::LoadWallet() | |
| } | ||
| } | ||
|
|
||
| if (nLoadWalletRet != DBErrors::LOAD_OK) | ||
| return nLoadWalletRet; | ||
|
|
||
| /* If the CoinJoin salt is not set, try to set a new random hash as the salt */ | ||
| if (GetCoinJoinSalt().IsNull() && !SetCoinJoinSalt(GetRandHash())) { | ||
| if (nLoadWalletRet == DBErrors::LOAD_OK && GetCoinJoinSalt().IsNull() && !SetCoinJoinSalt(GetRandHash())) { | ||
| return DBErrors::LOAD_FAIL; | ||
| } | ||
|
|
||
| return DBErrors::LOAD_OK; | ||
| return nLoadWalletRet; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Because the early return for non- Useful? React with 👍 / 👎.
knst marked this conversation as resolved.
|
||
| } | ||
|
|
||
| // Goes through all wallet transactions and checks if they are masternode collaterals, in which case these are locked | ||
|
|
@@ -3102,6 +3099,7 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri | |
| if (!walletInstance->AutoBackupWallet(fs::PathFromString(walletFile), error, warnings) && !error.original.empty()) { | ||
| return nullptr; | ||
| } | ||
| bool rescan_required = false; | ||
| DBErrors nLoadWalletRet = walletInstance->LoadWallet(); | ||
| if (nLoadWalletRet != DBErrors::LOAD_OK) | ||
| { | ||
|
|
@@ -3127,6 +3125,10 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri | |
| { | ||
| error = strprintf(_("Wallet needed to be rewritten: restart %s to complete"), PACKAGE_NAME); | ||
| return nullptr; | ||
| } else if (nLoadWalletRet == DBErrors::NEED_RESCAN) { | ||
| warnings.push_back(strprintf(_("Error reading %s! Transaction data may be missing or incorrect." | ||
| " Rescanning wallet."), walletFile)); | ||
| rescan_required = true; | ||
| } | ||
| else { | ||
| error = strprintf(_("Error loading %s"), walletFile); | ||
|
|
@@ -3382,7 +3384,7 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri | |
|
|
||
| NotifyWalletLoading(context, walletInstance); | ||
|
|
||
| if (chain && !AttachChain(walletInstance, *chain, error, warnings)) { | ||
| if (chain && !AttachChain(walletInstance, *chain, rescan_required, error, warnings)) { | ||
| walletInstance->m_chain_notifications_handler.reset(); // Reset this pointer so that the wallet will actually be unloaded | ||
| return nullptr; | ||
| } | ||
|
|
@@ -3407,7 +3409,7 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri | |
| return walletInstance; | ||
| } | ||
|
|
||
| bool CWallet::AttachChain(const std::shared_ptr<CWallet>& walletInstance, interfaces::Chain& chain, bilingual_str& error, std::vector<bilingual_str>& warnings) | ||
| bool CWallet::AttachChain(const std::shared_ptr<CWallet>& walletInstance, interfaces::Chain& chain, const bool rescan_required, bilingual_str& error, std::vector<bilingual_str>& warnings) | ||
| { | ||
| LOCK(walletInstance->cs_wallet); | ||
| // allow setting the chain if it hasn't been set already but prevent changing it | ||
|
|
@@ -3441,8 +3443,9 @@ bool CWallet::AttachChain(const std::shared_ptr<CWallet>& walletInstance, interf | |
| walletInstance->m_attaching_chain = true; //ignores chainStateFlushed notifications | ||
| walletInstance->m_chain_notifications_handler = walletInstance->chain().handleNotifications(walletInstance); | ||
|
|
||
| // If rescan_required = true, rescan_height remains equal to 0 | ||
| int rescan_height = 0; | ||
| if (!gArgs.GetBoolArg("-rescan", false)) | ||
| if (!rescan_required) | ||
| { | ||
| WalletBatch batch(walletInstance->GetDatabase()); | ||
| CBlockLocator locator; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,6 @@ | |
| from test_framework.test_framework import DashTestFramework | ||
| from test_framework.util import ( | ||
| assert_equal, | ||
| force_finish_mnsync, | ||
| ) | ||
|
|
||
| # Linux allow all characters other than \x00 | ||
|
|
@@ -56,7 +55,6 @@ def setup_network(self): | |
| f"-shutdownnotify=echo > {self.shutdownnotify_file}", | ||
| f"-chainlocknotify=echo > {os.path.join(self.chainlocknotify_dir, '%s')}", | ||
| ], [ | ||
| "-rescan", | ||
| f"-walletnotify=echo %h_%b > {os.path.join(self.walletnotify_dir, notify_outputname('%w', '%s'))}", | ||
| f"-instantsendnotify=echo > {os.path.join(self.instantsendnotify_dir, notify_outputname('%w', '%s'))}", | ||
| ], | ||
|
|
@@ -89,17 +87,15 @@ def run_test(self): | |
|
|
||
| # directory content should equal the generated transaction hashes | ||
| tx_details = list(map(lambda t: (t['txid'], t['blockheight'], t['blockhash']), self.nodes[1].listtransactions("*", block_count))) | ||
| self.stop_node(1) | ||
| self.expect_wallet_notify(tx_details) | ||
|
|
||
| self.log.info("test -walletnotify after rescan") | ||
| # restart node to rescan to force wallet notifications | ||
| self.start_node(1) | ||
| force_finish_mnsync(self.nodes[1]) | ||
| self.connect_nodes(0, 1) | ||
|
|
||
| # rescan to force wallet notifications | ||
| self.nodes[1].rescanblockchain() | ||
| self.wait_until(lambda: len(os.listdir(self.walletnotify_dir)) == block_count, timeout=10) | ||
|
|
||
| self.connect_nodes(0, 1) | ||
|
knst marked this conversation as resolved.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💬 Nitpick: Stale connect_nodes(0, 1) after switch from startup -rescan to rescanblockchain() (carried forward) Verified at current head: the test replaces the prior stop/restart-with- source: ['claude', 'codex'] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved in this update — Stale connect_nodes(0, 1) after switch from startup -rescan to rescanblockchain() (carried forward) no longer present. Auto-resolved by the review system based on the latest commit diff. If you believe this was closed in error, reopen the thread.
Comment on lines
92
to
+97
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Blocking: Carried forward: stale reconnect after replacing startup rescan with RPC rescan Carried forward from the previous review. bitcoin#23123 replaced the notification test's startup -rescan coverage with rescanblockchain(), and Dash made the same adaptation, but the test still calls self.connect_nodes(0, 1) even though node 1 is no longer stopped or restarted on this path. This is functionally harmless, but it is stale test adaptation from the removed startup-rescan flow and the test no longer covers startup-rescan notifications. Policy gate (backport-prereq-restore): For full upstream backport PRs, a missing prerequisite is blocking unless the finding is explicitly allowlisted (e.g. source: ['codex-backport-reviewer'] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved in this update — Carried forward: stale reconnect after replacing startup rescan with RPC rescan no longer present. Auto-resolved by the review system based on the latest commit diff. If you believe this was closed in error, reopen the thread. |
||
|
|
||
| # directory content should equal the generated transaction hashes | ||
| tx_details = list(map(lambda t: (t['txid'], t['blockheight'], t['blockhash']), self.nodes[1].listtransactions("*", block_count))) | ||
| self.expect_wallet_notify(tx_details) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.