Skip to content
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

[wallet] Reopen CDBEnv after encryption instead of shutting down #2648

Merged
merged 9 commits into from
Jan 11, 2022

Conversation

furszy
Copy link

@furszy furszy commented Nov 24, 2021

An improvement for the wallet UX: Stop requiring a wallet shutdown after the initial encryption. Now the process can safely continue running without any fear of leaking unencrypted keys.

PRs backported from upstream:

real-or-random and others added 6 commits November 24, 2021 15:48
According to the BerkeleyDB docs, the DbEnv handle may not be accessed
after close() has been called. This change ensures that we create a new
handle after close() is called. This avoids a segfault when the first
connection attempt fails and then a second connection attempt tries to
call open() on the already closed DbEnv handle.
Instead of having the object destroy itself, having the caller
destroy it.
Adds a ReloadDbEnv function to BerkeleyEnvironment in order to close all Db
instances, closes the environment, resets it, and then reopens
the BerkeleyEnvironment.

Also adds a ReloadDbEnv function to BerkeleyDatabase that calls
BerkeleyEnvironment's ReloadDbEnv.
Calls ReloadDbEnv after encrypting the wallet so that the database
environment is flushed, closed, and reopened to prevent unencrypted
keys from being saved on disk.
@furszy furszy self-assigned this Nov 24, 2021
@furszy furszy added the Wallet label Nov 24, 2021
Since the database environment is flushed, closed, and reopened during
EncryptWallet, there is no need to shut down the software anymore.

Adaptation of btc@c1dde3a949b36ce9c2155777b3fa1372e7ed97d8
@furszy furszy force-pushed the 2021_wallet_encryption_restart branch from 7af11b3 to 6e03bf2 Compare November 25, 2021 12:49
@furszy furszy changed the title [wallet] Reopen CDBEnv after encryption instead of shutting down [WIP][wallet] Reopen CDBEnv after encryption instead of shutting down Nov 26, 2021
@furszy furszy changed the title [WIP][wallet] Reopen CDBEnv after encryption instead of shutting down [wallet] Reopen CDBEnv after encryption instead of shutting down Nov 26, 2021
@furszy furszy force-pushed the 2021_wallet_encryption_restart branch from dd111b8 to 3d8f54f Compare November 26, 2021 22:21
@furszy
Copy link
Author

furszy commented Nov 26, 2021

Took me a while to find the problem, ready now.
Plus added another bug fix bitcoin#14320 as well.

@furszy furszy force-pushed the 2021_wallet_encryption_restart branch 2 times, most recently from 87e56e2 to 28d17a1 Compare November 27, 2021 22:45
There are tests, like the ones that uses the wallet encryption, that need access to a real wallet database and not to a mock.
Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK c5340ec

maybe unrelated, but when doing this via the GUI with an already large wallet, the animation screen didn't fully load, so the wallet could be perceived as "frozen"/"unresponsive", but the process did eventually finish...so some follow-up may be needed. A smaller wallet did not display this issue.

@furszy
Copy link
Author

furszy commented Dec 5, 2021

yep, unrelated to this change. Could work on it on a follup-up work for sure.

Copy link

@random-zebra random-zebra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK c5340ec

@furszy furszy merged commit 7937e8e into PIVX-Project:master Jan 11, 2022
@Fuzzbawls Fuzzbawls removed this from the 6.0.0 milestone Sep 11, 2022
@Fuzzbawls Fuzzbawls added this to the 5.5.0 milestone Sep 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants