Page MenuHomePhabricator

wallet: Move restorewallet() logic to the wallet section
Needs ReviewPublic

Authored by Fabien on Mon, Apr 21, 12:59.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary
Currently restorewallet() logic is written in the RPC layer and it can´t be reused by GUI. So it moves this to the wallet section and then, GUI can access it.

This is necessary to implement the "Restore Wallet" menu item in the GUI (which is already implemented in bitcoin-core/gui#471 ).

This commit also simplifies error handling and adds a new behavior: if the restore fails, the invalid wallet folder is removed.

Backport of core#23721.

Includes the bugfixes from core#26005 and the required dependencies for this bugfix PR.
Backport of core#26005, core#25594 and core#25616.

Also include a bugfix from core#26747:
https://github.com/bitcoin/bitcoin/pull/26747/commits/8c7222bda3f7136f312a6e57b76d6a2d0a114f68
Note that the test has not been backported yet, so this is a partial backport of core#26747.

Note that we don't have the restore menu in the GUI yet.

Depends on D17952.

Test Plan
ninja all check-all

Event Timeline

Tail of the build log:

Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted, 22ms
********* Finished testing of CompatTests *********
********* Start testing of GUIUtilTests *********
Config: Using QtTest library 5.15.8, Qt 5.15.8 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 12.2.0), debian 12
PASS   : GUIUtilTests::initTestCase()
PASS   : GUIUtilTests::dummyAddressTest()
PASS   : GUIUtilTests::toCurrentEncodingTest()
PASS   : GUIUtilTests::cleanupTestCase()
Totals: 4 passed, 0 failed, 0 skipped, 0 blacklisted, 20ms
********* Finished testing of GUIUtilTests *********
********* Start testing of BitcoinAddressValidatorTests *********
Config: Using QtTest library 5.15.8, Qt 5.15.8 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 12.2.0), debian 12
PASS   : BitcoinAddressValidatorTests::initTestCase()
PASS   : BitcoinAddressValidatorTests::inputTests()
PASS   : BitcoinAddressValidatorTests::cleanupTestCase()
Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted, 20ms
********* Finished testing of BitcoinAddressValidatorTests *********
********* Start testing of WalletTests *********
Config: Using QtTest library 5.15.8, Qt 5.15.8 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 12.2.0), debian 12
PASS   : WalletTests::initTestCase()
QDEBUG : WalletTests::walletTests() TransactionTablePriv::refreshWallet
QWARN  : WalletTests::walletTests() This plugin does not support propagateSizeHints()
QDEBUG : WalletTests::walletTests() "NotifyTransactionChanged: 9ec6374b5ff3a669d37603c4644c6e76c64850c83068f5f816c723671ee8d470 status= 0"
QDEBUG : WalletTests::walletTests() "NotifyTransactionChanged: 962bc10572420d1f1601186a5e58b62441edb765cdc20e2b098aef58184201c3 status= 1"
QDEBUG : WalletTests::walletTests() "NotifyAddressBookChanged: ecregtest:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqcrl5mqkt  isMine=0 purpose=send status=0"
QDEBUG : WalletTests::walletTests() "TransactionTablePriv::updateWallet: 9ec6374b5ff3a669d37603c4644c6e76c64850c83068f5f816c723671ee8d470 0"
QDEBUG : WalletTests::walletTests() "    inModel=0 Index=63-63 showTransaction=1 derivedStatus=0"
QDEBUG : WalletTests::walletTests() "TransactionTablePriv::updateWallet: 962bc10572420d1f1601186a5e58b62441edb765cdc20e2b098aef58184201c3 1"
QDEBUG : WalletTests::walletTests() "    inModel=1 Index=59-60 showTransaction=1 derivedStatus=1"
QWARN  : WalletTests::walletTests() This plugin does not support propagateSizeHints()
QDEBUG : WalletTests::walletTests() "NotifyTransactionChanged: 12d394b6cfa3340eb70d6e887942f3f05d5277a1c3ef13338bb59f256b646810 status= 0"
QDEBUG : WalletTests::walletTests() "NotifyTransactionChanged: 693325b1bfb743c6874514ad753e61979542afbceeb412619fca31f75f4cf64d status= 1"
QDEBUG : WalletTests::walletTests() "TransactionTablePriv::updateWallet: 12d394b6cfa3340eb70d6e887942f3f05d5277a1c3ef13338bb59f256b646810 0"
QDEBUG : WalletTests::walletTests() "    inModel=0 Index=7-7 showTransaction=1 derivedStatus=0"
QDEBUG : WalletTests::walletTests() "TransactionTablePriv::updateWallet: 693325b1bfb743c6874514ad753e61979542afbceeb412619fca31f75f4cf64d 1"
QDEBUG : WalletTests::walletTests() "    inModel=1 Index=34-35 showTransaction=1 derivedStatus=1"
QDEBUG : WalletTests::walletTests() "NotifyAddressBookChanged: ecregtest:qp7pvdruvj4m8tp8gcdp2xp700gn85v9w54uyahejl TEST_LABEL_1 isMine=1 purpose=receive status=0"
QWARN  : WalletTests::walletTests() This plugin does not support propagateSizeHints()
PASS   : WalletTests::walletTests()
PASS   : WalletTests::cleanupTestCase()
Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted, 1515ms
********* Finished testing of WalletTests *********
********* Start testing of AddressBookTests *********
Config: Using QtTest library 5.15.8, Qt 5.15.8 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 12.2.0), debian 12
PASS   : AddressBookTests::initTestCase()
QDEBUG : AddressBookTests::addressBookTests() TransactionTablePriv::refreshWallet
QWARN  : AddressBookTests::addressBookTests() This plugin does not support propagateSizeHints()
QWARN  : AddressBookTests::addressBookTests() This plugin does not support propagateSizeHints()
QDEBUG : AddressBookTests::addressBookTests() "NotifyAddressBookChanged: ecregtest:qpk5mwr3eedamfwmyhlrkd9vc3n0fkm3c5s7vev39p new isMine=0 purpose=send status=0"
PASS   : AddressBookTests::addressBookTests()
PASS   : AddressBookTests::cleanupTestCase()
Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted, 429ms
********* Finished testing of AddressBookTests *********
~BitcoinApplication : Stopping thread
~BitcoinApplication : Stopped thread
Segmentation fault (core dumped)
[527/529] Running bitcoin test suite
PASSED: bitcoin test suite
ninja: build stopped: cannot make progress due to previous errors.
Build build-debug failed with exit code 1
Fabien published this revision for review.Mon, Apr 21, 18:44
Fabien edited the test plan for this revision. (Show Details)

Failed tests logs:

====== Bitcoin ABC functional tests: feature_assumeutxo.py ======

------- Stdout: -------
2025-04-21T18:48:22.545000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20250421_184717/feature_assumeutxo_24
2025-04-21T18:48:25.488000Z TestFramework (INFO): -- Testing assumeutxo + some indexes + pruning
2025-04-21T18:48:25.489000Z TestFramework (INFO): Creating a UTXO snapshot at height 299
2025-04-21T18:48:25.534000Z TestFramework (INFO): Test loading snapshot when headers are not synced
2025-04-21T18:48:29.236000Z TestFramework (INFO): Test bitcoind should fail when mempool not empty.
2025-04-21T18:48:31.530000Z TestFramework (INFO): Test different scenarios of loading invalid snapshot files
2025-04-21T18:48:31.530000Z TestFramework (INFO):   - snapshot file refering to a block that is not in the assumeutxo parameters
2025-04-21T18:48:31.534000Z TestFramework (INFO):   - snapshot file with wrong number of coins
2025-04-21T18:48:31.862000Z TestFramework (INFO):   - snapshot file with alternated UTXO data
2025-04-21T18:48:33.133000Z TestFramework (INFO): Test bitcoind should fail when file path is invalid.
2025-04-21T18:48:33.137000Z TestFramework (INFO): Loading snapshot into second node from /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20250421_184717/feature_assumeutxo_24/node0/regtest/utxos.dat
2025-04-21T18:48:33.629000Z TestFramework (INFO): Submit a stale block that forked off the chain before the snapshot
2025-04-21T18:48:33.644000Z TestFramework (INFO): Submit a spending transaction for a snapshot chainstate coin to the mempool
2025-04-21T18:48:33.664000Z TestFramework (INFO): Restarting node to stop at height 359
2025-04-21T18:48:40.169000Z TestFramework (INFO): Checking that blocks are segmented on disk
2025-04-21T18:48:40.170000Z TestFramework (INFO): Restarted node before snapshot validation completed, reloading...
2025-04-21T18:48:42.337000Z TestFramework (INFO): Ensuring snapshot chain syncs to tip. (399)
2025-04-21T18:48:44.489000Z TestFramework (INFO): Ensuring background validation completes
2025-04-21T18:50:49.023000Z TestFramework.utils (ERROR): wait_until() failed. Predicate: ''''
        self.wait_until(lambda: n1.getindexinfo() == completed_idx_state)
'''
2025-04-21T18:50:49.023000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 152, in main
    self._run_test_internal()
  File "/work/test/functional/test_framework/test_framework.py", line 142, in _run_test_internal
    self.run_test()
  File "/work/test/functional/feature_assumeutxo.py", line 430, in run_test
    self.wait_until(lambda: n1.getindexinfo() == completed_idx_state)
  File "/work/test/functional/test_framework/test_framework.py", line 890, in wait_until
    return wait_until_helper(
           ^^^^^^^^^^^^^^^^^^
  File "/work/test/functional/test_framework/util.py", line 309, in wait_until_helper
    raise AssertionError(
AssertionError: Predicate ''''
        self.wait_until(lambda: n1.getindexinfo() == completed_idx_state)
''' not true after 120.0 seconds
2025-04-21T18:50:49.075000Z TestFramework (INFO): Stopping nodes
2025-04-21T18:50:49.379000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20250421_184717/feature_assumeutxo_24
2025-04-21T18:50:49.379000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20250421_184717/feature_assumeutxo_24/test_framework.log
2025-04-21T18:50:49.379000Z TestFramework (ERROR): 
2025-04-21T18:50:49.379000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20250421_184717/feature_assumeutxo_24' to consolidate all logs
2025-04-21T18:50:49.379000Z TestFramework (ERROR): 
2025-04-21T18:50:49.379000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2025-04-21T18:50:49.379000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2025-04-21T18:50:49.379000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC functional tests: feature_assumeutxo.py

Failed tests logs:

====== Bitcoin ABC functional tests: feature_assumeutxo.py ======

------- Stdout: -------
2025-04-21T18:48:22.545000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20250421_184717/feature_assumeutxo_24
2025-04-21T18:48:25.488000Z TestFramework (INFO): -- Testing assumeutxo + some indexes + pruning
2025-04-21T18:48:25.489000Z TestFramework (INFO): Creating a UTXO snapshot at height 299
2025-04-21T18:48:25.534000Z TestFramework (INFO): Test loading snapshot when headers are not synced
2025-04-21T18:48:29.236000Z TestFramework (INFO): Test bitcoind should fail when mempool not empty.
2025-04-21T18:48:31.530000Z TestFramework (INFO): Test different scenarios of loading invalid snapshot files
2025-04-21T18:48:31.530000Z TestFramework (INFO):   - snapshot file refering to a block that is not in the assumeutxo parameters
2025-04-21T18:48:31.534000Z TestFramework (INFO):   - snapshot file with wrong number of coins
2025-04-21T18:48:31.862000Z TestFramework (INFO):   - snapshot file with alternated UTXO data
2025-04-21T18:48:33.133000Z TestFramework (INFO): Test bitcoind should fail when file path is invalid.
2025-04-21T18:48:33.137000Z TestFramework (INFO): Loading snapshot into second node from /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20250421_184717/feature_assumeutxo_24/node0/regtest/utxos.dat
2025-04-21T18:48:33.629000Z TestFramework (INFO): Submit a stale block that forked off the chain before the snapshot
2025-04-21T18:48:33.644000Z TestFramework (INFO): Submit a spending transaction for a snapshot chainstate coin to the mempool
2025-04-21T18:48:33.664000Z TestFramework (INFO): Restarting node to stop at height 359
2025-04-21T18:48:40.169000Z TestFramework (INFO): Checking that blocks are segmented on disk
2025-04-21T18:48:40.170000Z TestFramework (INFO): Restarted node before snapshot validation completed, reloading...
2025-04-21T18:48:42.337000Z TestFramework (INFO): Ensuring snapshot chain syncs to tip. (399)
2025-04-21T18:48:44.489000Z TestFramework (INFO): Ensuring background validation completes
2025-04-21T18:50:49.023000Z TestFramework.utils (ERROR): wait_until() failed. Predicate: ''''
        self.wait_until(lambda: n1.getindexinfo() == completed_idx_state)
'''
2025-04-21T18:50:49.023000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 152, in main
    self._run_test_internal()
  File "/work/test/functional/test_framework/test_framework.py", line 142, in _run_test_internal
    self.run_test()
  File "/work/test/functional/feature_assumeutxo.py", line 430, in run_test
    self.wait_until(lambda: n1.getindexinfo() == completed_idx_state)
  File "/work/test/functional/test_framework/test_framework.py", line 890, in wait_until
    return wait_until_helper(
           ^^^^^^^^^^^^^^^^^^
  File "/work/test/functional/test_framework/util.py", line 309, in wait_until_helper
    raise AssertionError(
AssertionError: Predicate ''''
        self.wait_until(lambda: n1.getindexinfo() == completed_idx_state)
''' not true after 120.0 seconds
2025-04-21T18:50:49.075000Z TestFramework (INFO): Stopping nodes
2025-04-21T18:50:49.379000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20250421_184717/feature_assumeutxo_24
2025-04-21T18:50:49.379000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20250421_184717/feature_assumeutxo_24/test_framework.log
2025-04-21T18:50:49.379000Z TestFramework (ERROR): 
2025-04-21T18:50:49.379000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20250421_184717/feature_assumeutxo_24' to consolidate all logs
2025-04-21T18:50:49.379000Z TestFramework (ERROR): 
2025-04-21T18:50:49.379000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2025-04-21T18:50:49.379000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2025-04-21T18:50:49.379000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC functional tests: feature_assumeutxo.py

The coinstatsindex seems very slow under debug. Maybe https://github.com/bitcoin/bitcoin/pull/21590 can help with that.

Failed tests logs:

====== Bitcoin ABC functional tests: feature_assumeutxo.py ======

------- Stdout: -------
2025-04-21T20:13:41.601000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20250421_201238/feature_assumeutxo_24
2025-04-21T20:13:44.041000Z TestFramework (INFO): -- Testing assumeutxo + some indexes + pruning
2025-04-21T20:13:44.042000Z TestFramework (INFO): Creating a UTXO snapshot at height 299
2025-04-21T20:13:44.090000Z TestFramework (INFO): Test loading snapshot when headers are not synced
2025-04-21T20:13:47.655000Z TestFramework (INFO): Test bitcoind should fail when mempool not empty.
2025-04-21T20:13:49.190000Z TestFramework (INFO): Test different scenarios of loading invalid snapshot files
2025-04-21T20:13:49.190000Z TestFramework (INFO):   - snapshot file refering to a block that is not in the assumeutxo parameters
2025-04-21T20:13:49.193000Z TestFramework (INFO):   - snapshot file with wrong number of coins
2025-04-21T20:13:49.431000Z TestFramework (INFO):   - snapshot file with alternated UTXO data
2025-04-21T20:13:50.109000Z TestFramework (INFO): Test bitcoind should fail when file path is invalid.
2025-04-21T20:13:50.110000Z TestFramework (INFO): Loading snapshot into second node from /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20250421_201238/feature_assumeutxo_24/node0/regtest/utxos.dat
2025-04-21T20:13:50.512000Z TestFramework (INFO): Submit a stale block that forked off the chain before the snapshot
2025-04-21T20:13:50.524000Z TestFramework (INFO): Submit a spending transaction for a snapshot chainstate coin to the mempool
2025-04-21T20:13:50.543000Z TestFramework (INFO): Restarting node to stop at height 359
2025-04-21T20:13:56.182000Z TestFramework (INFO): Checking that blocks are segmented on disk
2025-04-21T20:13:56.182000Z TestFramework (INFO): Restarted node before snapshot validation completed, reloading...
2025-04-21T20:13:58.056000Z TestFramework (INFO): Ensuring snapshot chain syncs to tip. (399)
2025-04-21T20:13:59.514000Z TestFramework (INFO): Ensuring background validation completes
2025-04-21T20:16:03.911000Z TestFramework.utils (ERROR): wait_until() failed. Predicate: ''''
        self.wait_until(lambda: n1.getindexinfo() == completed_idx_state)
'''
2025-04-21T20:16:03.911000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 152, in main
    self._run_test_internal()
  File "/work/test/functional/test_framework/test_framework.py", line 142, in _run_test_internal
    self.run_test()
  File "/work/test/functional/feature_assumeutxo.py", line 430, in run_test
    self.wait_until(lambda: n1.getindexinfo() == completed_idx_state)
  File "/work/test/functional/test_framework/test_framework.py", line 890, in wait_until
    return wait_until_helper(
           ^^^^^^^^^^^^^^^^^^
  File "/work/test/functional/test_framework/util.py", line 309, in wait_until_helper
    raise AssertionError(
AssertionError: Predicate ''''
        self.wait_until(lambda: n1.getindexinfo() == completed_idx_state)
''' not true after 120.0 seconds
2025-04-21T20:16:03.963000Z TestFramework (INFO): Stopping nodes
2025-04-21T20:16:04.217000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20250421_201238/feature_assumeutxo_24
2025-04-21T20:16:04.217000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20250421_201238/feature_assumeutxo_24/test_framework.log
2025-04-21T20:16:04.217000Z TestFramework (ERROR): 
2025-04-21T20:16:04.217000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20250421_201238/feature_assumeutxo_24' to consolidate all logs
2025-04-21T20:16:04.217000Z TestFramework (ERROR): 
2025-04-21T20:16:04.217000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2025-04-21T20:16:04.217000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2025-04-21T20:16:04.217000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC functional tests: feature_assumeutxo.py