initial walletpassphrase slow and freezing #12423

issue AdvancedStyle opened this issue on February 13, 2018
  1. AdvancedStyle commented at 12:36 PM on February 13, 2018: none

    When running walletpassphrase on a large wallet.dat (ie about 300,000 segwit P2SH addresses) the command sometimes takes a very long time, and if command is run multiple times at once (while running slow) it causes bitcoin core to freeze (stops syncing and requires kill -9 to stop/restart)

    During the locked up walletpassphrase commands being run the following messages start to appear in the debug.log:

    018-01-24 01:01:04 socket sending timeout: 1201s

    Note that this problem is intermittent, so sometimes the command runs instantly, other times it takes a few minutes, and other times it completely freezes the node.

  2. fanquake added the label RPC/REST/ZMQ on Feb 13, 2018
  3. MarcoFalke added the label Wallet on Feb 13, 2018
  4. AdvancedStyle commented at 1:37 PM on February 13, 2018: none

    I think this can be closed as actually the issue appears to have been insufficient disk IO capacity on the nodes virtual machine.

  5. AdvancedStyle closed this on Feb 13, 2018

  6. Crypto2 commented at 6:06 PM on May 21, 2019: none

    I have this issue a lot as well and disk I/O capacity would be no issue on this machine.

  7. promag commented at 7:36 PM on May 21, 2019: member

    @Crypto2 mind sharing system, bitcoind version and wallet size?

  8. Crypto2 commented at 12:26 AM on May 22, 2019: none

    Xeon E5-1660 v3 @ 3.00GHz w/64GB of RAM and Intel NVMe storage, Bitcoin 0.18.0 (but been happening at least through the whole 0.17 series as well), wallet size ~5GB. dbcache=16384 in config file.

    The machine is dedicated just to running bitcoind, nothing else on it except Linux itself.

  9. jonasschnelli commented at 9:27 AM on May 22, 2019: contributor

    Bitcoin-Core is currently not optimized for wallets that large. During walletpassphrase, each key gets a AES256CBC decryption (in your case 300'000) and all the decrypted keys are kept in memory. During the time of that decryption process, the main lock is held which can lead to disconnects on the p2p side.

  10. Crypto2 commented at 9:28 PM on September 22, 2019: none

    Resurrecting and older one here but has anyone thought about having walletpassphrase decrypt the master key then just decrypt the keys as needed on demand versus decrypting them all at once? (odds are you won't end up using but a small percentage of the privkeys anyway on larger wallets.)

  11. sipa commented at 9:54 PM on September 22, 2019: member

    @Crypto2 That's what happens. I don't know why decrypting a larger wallet would be slower.

  12. achow101 commented at 10:03 PM on September 22, 2019: member

    @Crypto2 That's what happens. I don't know why decrypting a larger wallet would be slower.

    The first time the wallet is unlocked, every key is decrypted although the decrypted keys are not stored. After that, any subsequent unlocks will only decrypt one key to determine which encryption key to use.

  13. Crypto2 commented at 12:03 AM on September 23, 2019: none

    Yeah it's that 1st time I'm talking about. That's the killer; takes 30+ minutes lol. Maybe should add a way to skip the decrypt every key part.

  14. achow101 commented at 1:24 AM on September 23, 2019: member

    Maybe should add a way to skip the decrypt every key part.

    I believe the full key decryption is being done in order to check for corruption. Maybe an equally valid way would be to have a checksum/hash of the encrypted data? I'll investigate.

  15. Crypto2 commented at 3:32 AM on September 23, 2019: none

    This is in the 0.18.0 codebase, I see they have moved it to wallet.cpp in master, but as a quick fix I did this: (default off for safety)

    @@ -184,6 +184,7 @@ bool CCryptoKeyStore::Unlock(const CKeyingMaterial& vMasterKeyIn, bool accept_no
    
             bool keyPass = mapCryptedKeys.empty(); // Always pass when there are no encrypted keys
             bool keyFail = false;
    +        bool quickUnlock = (fDecryptionThoroughlyChecked || gArgs.GetBoolArg("-quickwalletdecrypt", false));
             CryptedKeyMap::const_iterator mi = mapCryptedKeys.begin();
             for (; mi != mapCryptedKeys.end(); ++mi)
             {
    @@ -196,7 +197,7 @@ bool CCryptoKeyStore::Unlock(const CKeyingMaterial& vMasterKeyIn, bool accept_no
                     break;
                 }
                 keyPass = true;
    -            if (fDecryptionThoroughlyChecked)
    +            if (quickUnlock)
                     break;
             }
             if (keyPass && keyFail)
    

    Checksum/hash would be better for sure though.

  16. sipa commented at 3:34 AM on September 23, 2019: member

    @achow101 In native descriptor wallets this won't be a problem anymore, right? As there'll just be one private key for the master key?

  17. achow101 commented at 3:45 AM on September 23, 2019: member

    @achow101 In native descriptor wallets this won't be a problem anymore, right? As there'll just be one private key for the master key?

    Yes

  18. achow101 cross-referenced this on Sep 23, 2019 from issue wallet: include a checksum of encrypted private keys by achow101
  19. Crypto2 commented at 4:47 AM on February 9, 2020: none

    Really weird this wasn't fixed in 0.19.0+

  20. MarcoFalke reopened this on Feb 9, 2020

  21. MarcoFalke renamed this:
    walletpassphrase slow and freezing
    initial walletpassphrase slow and freezing
    on Feb 9, 2020
  22. MarcoFalke removed the label RPC/REST/ZMQ on Feb 9, 2020
  23. laanwj closed this on May 21, 2020

  24. sidhujag referenced this in commit 50a72191b0 on May 21, 2020
  25. ComputerCraftr referenced this in commit f6ee1c3482 on Jun 10, 2020
  26. ComputerCraftr referenced this in commit 9a51a27080 on Jun 10, 2020
  27. bitcoin locked this on Feb 15, 2022
  28. vijaydasmp referenced this in commit 6fa7aeae34 on May 6, 2023
  29. vijaydasmp referenced this in commit 508a41e920 on Jul 2, 2023
  30. vijaydasmp referenced this in commit 95a0f9c126 on Jul 4, 2023
  31. vijaydasmp referenced this in commit 96b1e84cc3 on Jul 4, 2023
  32. vijaydasmp referenced this in commit d0773739b3 on Jul 5, 2023
  33. vijaydasmp referenced this in commit c1cda235c3 on Jul 7, 2023
  34. vijaydasmp referenced this in commit 4a40357df0 on Jul 7, 2023
  35. vijaydasmp referenced this in commit 60d010bd92 on Jul 9, 2023
  36. vijaydasmp referenced this in commit 9cac755cf7 on Jul 9, 2023
  37. vijaydasmp referenced this in commit 3dbcbd99db on Jul 9, 2023
  38. vijaydasmp referenced this in commit 38de3185b6 on Jul 9, 2023
  39. vijaydasmp referenced this in commit 236ae9234e on Jul 9, 2023
  40. vijaydasmp referenced this in commit a16f7f80c8 on Jul 9, 2023
  41. vijaydasmp referenced this in commit 3bc5050ebe on Jul 10, 2023
  42. vijaydasmp referenced this in commit 91d0a8cf1a on Jul 10, 2023
  43. vijaydasmp referenced this in commit 9a10e8dd8d on Jul 11, 2023
  44. vijaydasmp referenced this in commit d9417dae14 on Jul 11, 2023
  45. vijaydasmp referenced this in commit 8bea9660e2 on Jul 14, 2023
  46. vijaydasmp referenced this in commit a8dec2c210 on Jul 14, 2023
  47. vijaydasmp referenced this in commit 7be44cf38c on Jul 14, 2023
  48. vijaydasmp referenced this in commit 57d3069063 on Jul 14, 2023
  49. vijaydasmp referenced this in commit 8b4b2b4ea1 on Jul 14, 2023
  50. vijaydasmp referenced this in commit 5159b63a09 on Jul 17, 2023
  51. vijaydasmp referenced this in commit 1ec570116c on Jul 18, 2023
  52. vijaydasmp referenced this in commit cd360deff1 on Jul 20, 2023
  53. vijaydasmp referenced this in commit 5e1f1a2a29 on Jul 21, 2023
  54. PastaPastaPasta referenced this in commit c0c00f9295 on Jul 21, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-20 06:55 UTC