-
Notifications
You must be signed in to change notification settings - Fork 37.7k
qt: Force set nPruneSize in QSettings after the intro dialog #17696
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
qt: Force set nPruneSize in QSettings after the intro dialog #17696
Conversation
This commit does not change behavior.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Tested ACK 6928c50 In macOS the settings are in |
utACK 6928c50 |
@promag can you do a review? |
@fanquake @MarcoFalke |
I have tested that this change resets to 2GB regardless of what's in the settings. However I'm not sure this is correct, actually I think current behavior is correct - only problem is that the intro dialog doesn't show what's in the settings. In your case the intro should have the checkbox checked and it should say "6 GB (prune)". I don't think running with |
I don't mind either way; the plan seems to be to store settings in the datadir, e.g. using rw_config #11082. |
In that case the current prune setting would still be available. |
@ryanofsky Would you mind reviewing this PR w.r.t. future of settings handling? |
It doesn't make sense to me to keep the same prune setting for a different data directory; it's probably on a different disk. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK 6928c50. I think the change makes sense and does fix a surprising behavior. Thanks for splitting this from the other PR and describing the problem so clearly here!
I think the alternate approach suggested by promag #17696 (comment) to just fix the displayed size and not change the behavior would also address the bug, and maybe be less surprising for someone not expecting -choosedatadir
to affect the prune size. But as Sjors points out there are multiple reasons to expect that changing the datadir would affect the size, so I think that as long as the displayed size is correct, using either the current value or default value seems ok.
src/qt/bitcoin.cpp
Outdated
void BitcoinApplication::SetPrune(bool prune, bool force) { | ||
optionsModel->SetPrune(prune, force); | ||
optionsModel->SetPruneTargetGB(prune ? DEFAULT_PRUNE_TARGET_GB : 0, force); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this BitcoinApplication::SetPrune
function is confusing now that it is no longer just forwarding to optionsModel. Would suggest:
- Renaming
SetPrune
to something likeInitializePruneSetting
orResetPrune
since it now resets the pruning size and is only called after the intro sequence. - Dropping the
bool force
parameter since it is only called one place withforce=true
- Maybe adding a comment to explain the behavior like, "Intentionally override existing prune size and use default size since this is called when choosing a new datadir"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with all your suggestions.
As this PR has 3 ACKs already, is it acceptable to implement your suggestions in a following PR, e.g., #17453?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this PR has 3 ACKs already, is it acceptable to implement your suggestions in a following PR, e.g., #17453?
Of course yes, my suggestions are always just suggestions, and I wouldn't ACK a PR that I didn't think was ready to merge. I'd slightly prefer cleanup here or in a standalone PR instead of #17453 to make #17453 more focused and understandable, but it doesn't matter too much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in the latest push.
Implemented @ryanofsky's suggestions. @Sjors @jonasschnelli @promag @ryanofsky |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK 192151f. Just suggested changes since the last review and some minor related changes.
src/qt/bitcoin.h
Outdated
/// Initialize prune setting. If prune is set, intentionally override | ||
/// existing prune size with the default size since this is called when | ||
/// choosing a new datadir. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "qt: Rename SetPrune() to InitializePruneSetting()" (192151f)
I think this comment would be a better placed inside the InitializePruneSetting
method body because it's describing and justifying the implementation of the function, which (I think) is pretty confusing without a nearby explanation. I also think it would be better to add this comment in the earlier commit "qt: Force set nPruneSize in QSettings after intro" (6928c50) instead of here, because that is the commit which introduces the behavior this comment is describing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/qt/optionsmodel.cpp
Outdated
@@ -252,14 +252,14 @@ void OptionsModel::SetPruneEnabled(bool prune, bool force) | |||
} | |||
} | |||
|
|||
void OptionsModel::SetPruneTargetGB(int prune_target_gb, bool force) | |||
void OptionsModel::SetPruneTargetGB(int prune_target_gb) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "refactor: Drop `bool force' parameter" (0849b51)
Not a big deal, but I don't think the force argument should be dropped from this function. The call site in InitializePruneSetting is clearer if it has to explicitly set force
to true, and it seems inconsistent and unsafe for one optionsmodel SetPrune
method to soft-set by default while the other one force sets. The need to soft or force set depends on the context of the SetPrune call, and isn't something that seems right to hardcode here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
If QSettings is set already, it is required to force set nPruneSize after the intro dialog.
This function now resets the prune size and is only called after the intro sequence.
192151f
to
af112ab
Compare
@ryanofsky |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK af112ab. Just suggested changes since last review (thanks!)
Tested ACK af112ab. Latest suggestions and changes look good to me. Once settings get stored in datadir I think the intro dialog could show prune target of the currently selected directory, if any (so it isn't overridden). Or disable/hide the prune option in the intro dialog if the currently selected directory exists and is valid - it's already initialized after all. |
Code review re-ACK af112ab |
…ialog af112ab qt: Rename SetPrune() to InitializePruneSetting() (Hennadii Stepanov) b0bfbe5 refactor: Drop `bool force' parameter (Hennadii Stepanov) 68c9bbe qt: Force set nPruneSize in QSettings after intro (Hennadii Stepanov) a82bd8f util: Replace magics with DEFAULT_PRUNE_TARGET_GB (Hennadii Stepanov) Pull request description: On master (5622d8f), having `QSettings` set already ``` $ grep nPruneSize ~/.config/Bitcoin/Bitcoin-Qt-testnet.conf nPruneSize=6 ``` enabling prune option in the intro dialog ``` $ ./src/qt/bitcoin-qt -choosedatadir -testnet ```  has no effect: ``` $ grep Prune ~/.bitcoin/testnet3/debug.log 2019-12-08T10:04:41Z Prune configured to target 5722 MiB on disk for block and undo files. ``` --- With this PR: ``` $ grep Prune ~/.bitcoin/testnet3/debug.log 2019-12-08T10:20:35Z Prune configured to target 1907 MiB on disk for block and undo files. ``` This PR has been split of #17453 (the first two commits) as it fixes an orthogonal bug. Refs: - #17453 (comment) - #17453 (comment) ACKs for top commit: Sjors: Code review re-ACK af112ab ryanofsky: Code review ACK af112ab. Just suggested changes since last review (thanks!) promag: Tested ACK af112ab. Latest suggestions and changes look good to me. Tree-SHA512: 8ddad34b30dcc2cdcad6678ba8a0b36fa176e4e3465862ef6eee9be0f98d8146705138c9c7995dd8c0990af41078ca743fef1a90ed9240081f052f32ddec72b9
…intro dialog af112ab qt: Rename SetPrune() to InitializePruneSetting() (Hennadii Stepanov) b0bfbe5 refactor: Drop `bool force' parameter (Hennadii Stepanov) 68c9bbe qt: Force set nPruneSize in QSettings after intro (Hennadii Stepanov) a82bd8f util: Replace magics with DEFAULT_PRUNE_TARGET_GB (Hennadii Stepanov) Pull request description: On master (5622d8f), having `QSettings` set already ``` $ grep nPruneSize ~/.config/Bitcoin/Bitcoin-Qt-testnet.conf nPruneSize=6 ``` enabling prune option in the intro dialog ``` $ ./src/qt/bitcoin-qt -choosedatadir -testnet ```  has no effect: ``` $ grep Prune ~/.bitcoin/testnet3/debug.log 2019-12-08T10:04:41Z Prune configured to target 5722 MiB on disk for block and undo files. ``` --- With this PR: ``` $ grep Prune ~/.bitcoin/testnet3/debug.log 2019-12-08T10:20:35Z Prune configured to target 1907 MiB on disk for block and undo files. ``` This PR has been split of bitcoin#17453 (the first two commits) as it fixes an orthogonal bug. Refs: - bitcoin#17453 (comment) - bitcoin#17453 (comment) ACKs for top commit: Sjors: Code review re-ACK af112ab ryanofsky: Code review ACK af112ab. Just suggested changes since last review (thanks!) promag: Tested ACK af112ab. Latest suggestions and changes look good to me. Tree-SHA512: 8ddad34b30dcc2cdcad6678ba8a0b36fa176e4e3465862ef6eee9be0f98d8146705138c9c7995dd8c0990af41078ca743fef1a90ed9240081f052f32ddec72b9
Fix intro dialog labels when the prune button is toggled (bitcoin#17453) Rename debug window (bitcoin#17096) Add close window shortcut (bitcoin#15768) Add privacy to the Overview page (bitcoin#16432) Remove WalletView and BitcoinGUI circular dependency (bitcoin#17937) Force set nPruneSize in QSettings after the intro dialog (bitcoin#17696)
…intro dialog af112ab qt: Rename SetPrune() to InitializePruneSetting() (Hennadii Stepanov) b0bfbe5 refactor: Drop `bool force' parameter (Hennadii Stepanov) 68c9bbe qt: Force set nPruneSize in QSettings after intro (Hennadii Stepanov) a82bd8f util: Replace magics with DEFAULT_PRUNE_TARGET_GB (Hennadii Stepanov) Pull request description: On master (5622d8f), having `QSettings` set already ``` $ grep nPruneSize ~/.config/Bitcoin/Bitcoin-Qt-testnet.conf nPruneSize=6 ``` enabling prune option in the intro dialog ``` $ ./src/qt/bitcoin-qt -choosedatadir -testnet ```  has no effect: ``` $ grep Prune ~/.bitcoin/testnet3/debug.log 2019-12-08T10:04:41Z Prune configured to target 5722 MiB on disk for block and undo files. ``` --- With this PR: ``` $ grep Prune ~/.bitcoin/testnet3/debug.log 2019-12-08T10:20:35Z Prune configured to target 1907 MiB on disk for block and undo files. ``` This PR has been split of bitcoin#17453 (the first two commits) as it fixes an orthogonal bug. Refs: - bitcoin#17453 (comment) - bitcoin#17453 (comment) ACKs for top commit: Sjors: Code review re-ACK af112ab ryanofsky: Code review ACK af112ab. Just suggested changes since last review (thanks!) promag: Tested ACK af112ab. Latest suggestions and changes look good to me. Tree-SHA512: 8ddad34b30dcc2cdcad6678ba8a0b36fa176e4e3465862ef6eee9be0f98d8146705138c9c7995dd8c0990af41078ca743fef1a90ed9240081f052f32ddec72b9
…o dialog Summary: af112ab62895b145660f4cd7ff842e9cfea2a530 qt: Rename SetPrune() to InitializePruneSetting() (Hennadii Stepanov) b0bfbe50282877a1eee87118902901a280d6656d refactor: Drop `bool force' parameter (Hennadii Stepanov) 68c9bbe9bc91f882404556998666b1b5acea60e4 qt: Force set nPruneSize in QSettings after intro (Hennadii Stepanov) a82bd8fa5708c16d1db3edc4e82d70788eb5af19 util: Replace magics with DEFAULT_PRUNE_TARGET_GB (Hennadii Stepanov) Pull request description: On master (5622d8f3156a293e61d0964c33d4b21d8c9fd5e0), having `QSettings` set already ``` $ grep nPruneSize ~/.config/Bitcoin/Bitcoin-Qt-testnet.conf nPruneSize=6 ``` enabling prune option in the intro dialog ``` $ ./src/qt/bitcoin-qt -choosedatadir -testnet ```  has no effect: ``` $ grep Prune ~/.bitcoin/testnet3/debug.log 2019-12-08T10:04:41Z Prune configured to target 5722 MiB on disk for block and undo files. ``` --- With this PR: ``` $ grep Prune ~/.bitcoin/testnet3/debug.log 2019-12-08T10:20:35Z Prune configured to target 1907 MiB on disk for block and undo files. ``` This PR has been split of #17453 (the first two commits) as it fixes an orthogonal bug. Refs: - bitcoin/bitcoin#17453 (comment) - bitcoin/bitcoin#17453 (comment) --- Backport of Core [[bitcoin/bitcoin#17696 | PR17696]] Test Plan: ninja all check check-functional ./src/qt/bitcoin-qt -choosedatadir -testnet start a new datadir with prune option selected, make sure the debug.log returns the correct value (~2GB) Reviewers: #bitcoin_abc, PiRK Reviewed By: #bitcoin_abc, PiRK Differential Revision: https://reviews.bitcoinabc.org/D8913
On master (5622d8f), having
QSettings
set alreadyenabling prune option in the intro dialog
has no effect:
With this PR:
This PR has been split of #17453 (the first two commits) as it fixes an orthogonal bug.
Refs: