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. Crypto2 commented at 4:47 AM on February 9, 2020: none

    Really weird this wasn't fixed in 0.19.0+

  19. MarcoFalke reopened this on Feb 9, 2020

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

  23. sidhujag referenced this in commit 50a72191b0 on May 21, 2020
  24. ComputerCraftr referenced this in commit f6ee1c3482 on Jun 10, 2020
  25. ComputerCraftr referenced this in commit 9a51a27080 on Jun 10, 2020
  26. DrahtBot locked this on Feb 15, 2022
  27. vijaydasmp referenced this in commit 6fa7aeae34 on May 6, 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-04-17 09:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me