-
Notifications
You must be signed in to change notification settings - Fork 38.7k
qt: Fix text display when state of prune button is changed #17035
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: Fix text display when state of prune button is changed #17035
Conversation
promag
left a comment
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.
Concept ACK.
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.
Unfortunately it doesn't fix the required storage amount, I will be working on this next.
I tend to Approach NACK. The full problem solution, with the required storage amount is fixed, is welcome.
|
@hebasto Done |
hebasto
left a comment
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.
It seems commits need to be squashed in two ones:
- introduce
pruneWasNotSetmember - all the rest
src/qt/intro.h
Outdated
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.
ui->prune->isChecked() is accessible here. bool is_pruned parameter seems redundant.
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.
Oh yeah, it is just a remaining of the first version of this patch
|
Squashing done |
|
Approach ACK 727f86f3a75051daaeb81cb3984574c06eb62449, tested on Linux Mint 19.2. Nit: #17035 (comment) Commit 727f86f3a75051daaeb81cb3984574c06eb62449 message "... It also removes a useless boolean added before" is a hint ;) Why to introduce a variable in a commit to remove it in the next one? It does not work if disk space is insufficient and EDIT: The "qt: Update the required space message when the prune box is checked" commit (727f86f3a75051daaeb81cb3984574c06eb62449) should deal with both |
I removed this message completely because a variable rename wasn't the real point of this commit |
|
@hebasto Sure, what is with the chainstate? |
|
Tested a bit, something seems incorrect. If I start with I know this is not the place to discuss that, but why have we chosen 2GB as prune target instead of the minimum of 550MB? |
I confirm this behavior, setting |
|
@promag @jonasschnelli |
|
See Line 361: |
|
Push |
|
Tested this PR on top of the current master (dcc6408). That is correct, as 5 GB is a sum of pruned blockchain size (2 GB) and chainstate size (3 GB). That is wrong, as 2 GB is the default pruned blockchain size, and chainstate size is skipped.
Yes, they should. |
|
Ok, will work on specific chain selection now |
|
@hebasto Fixed, squashed and ready for merge |
|
Tested 9ab3876b43d45e8d742adcad996537b2dcbacff3 on Linux Mint 19.2: |
|
@hebasto Fixed and tested heavily |
|
@hebasto Updated |
src/qt/intro.cpp
Outdated
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.
This is inconsistent with
Lines 386 to 388 in ec3ed5a
| gArgs.AddArg("-prune=<n>", strprintf("Reduce storage requirements by enabling pruning (deleting) of old blocks. This allows the pruneblockchain RPC to be called to delete specific blocks, and enables automatic pruning of old blocks if a target size in MiB is provided. This mode is incompatible with -txindex and -rescan. " | |
| "Warning: Reverting this setting requires re-downloading the entire blockchain. " | |
| "(default: 0 = disable pruning blocks, 1 = allow manual pruning via RPC, >=%u = automatically prune block files to stay under the specified target size in MiB)", MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); |
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.
Ok, then I will change everything to Mebibyte
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.
MiB is indeed consistent with other places, but you should also change uint64_t GB_BYTES{1000000000} to uint64_t GiB_BYTES{1073741824}. But that impacts the settings screen. Probably better to leave this change for another PR.
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.
Instead of doing ad-hoc calculations everywhere, I'd strongly encourage using the following well-defined PruneGBtoMiB and PruneMiBtoGB functions (from #15936) for this:
Lines 24 to 25 in 0ab41dd
| static inline int64_t PruneGBtoMiB(int gb) { return gb * GB_BYTES / 1024 / 1024; } | |
| static inline int PruneMiBtoGB(int64_t mib) { return (mib * 1024 * 1024 + GB_BYTES - 1) / GB_BYTES; } |
This would increase readability and prevent bugs and let us be sure when we migrate this setting out of qsettings that round trips between units work will correctly (e.g. 3GB -> 2861 MiB -> 3GB not 2GB)
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.
MiB is indeed consistent with other places, but you should also change
uint64_t GB_BYTES{1000000000}touint64_t GiB_BYTES{1073741824}. But that impacts the settings screen. Probably better to leave this change for another PR.
I'm not sure what the goal of this change would be, and would definitely think it should be done as separately from this PR. The existing conversions in this PR as of f3108a0 look correct to me, and I'd expect normal users to be more familiar with GB than GiB. Also if a user sees a GiB value and mistakenly interprets it as a GB value their node will use more storage than expected and maybe lead to problems.
EDIT: f3108a0 does actually have some buggy conversions I missed the first pass, see #17035 (review), but this tangential to the point about wanting to stick to GB instead of switching to GiB.
|
@hebasto Fixed, however it will now round down if you prune, this should be correct behavior because it's now a slightly different unit |
Sjors
left a comment
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.
Concept ACK. I don't think the original behavior is a bug, but this PR does make things more clear. The intro dialog explained how much space is needed without pruning, and then offers to reduce that if you do prune. It's nice that it now updates the amounts and colors.
"GB needed for full chain" needs to be " GB needed for pruned chain" when prune is checked.
I suggest quashing these commits. Perhaps start with a commit that introduces setSizeWarningLabel and adds member variables, but doesn't change behavior. That way it's more clear what behavior you're changing.
src/qt/intro.cpp
Outdated
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.
Move to start of function, otherwise storageRequiresMsg will have the wrong amount.
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.
Nope, see L352-354
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.
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.
This has never been a very precise number because 3 GB more or less didn't matter, but with pruning we should show the correct numbers.
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.
Oh now I understand what you mean.
Will work on that tomorrow
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.
@ryanofsky These functions are not existent in my branch.
Should I copy them?
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.
@ryanofsky These functions are not existent in my branch.
Should I copy them?
Yes, that's why I linked to my branch.
This fixes the bug of the required amount of storage in the intro screen
|
Squashed |
| QString storageRequiresMsg = QObject::tr("At least %1 GB of data will be stored in this directory, and it will grow over time."); | ||
| if (ui->prune->isChecked()) { | ||
| uint64_t prunedGBs = std::ceil(m_prune_target * 1024 * 1024 / GB_BYTES); | ||
| if (prunedGBs <= requiredSpace) { |
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.
This should check prunedGBs + m_chain_state_size <= requiredSpace (assuming you add m_chain_state_size to requiredSpace earlier).
| tr("The wallet will also be stored in this directory.") | ||
| ); | ||
| setSizeWarningLabel(); | ||
| m_prune_target = m_prune_target ? m_prune_target / 1024 : 2; |
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.
This is doing a conversion from MiB to GiB not GB. Also it is rounding down instead of up, which means round trips between two units are not stable. (Maybe not a problem for this PR since it is a one-time conversion, but definitely a problem for #12833 and #15936 which need consistent repeatable conversions.)
Would suggest:
- Renaming this variable from
m_prune_targettom_prune_target_gbto be clear about units it is supposed to contain. - Switching a temporary
int64_t prune_target_mibvariable above to hold the-prunevalue. - Changing this line to
m_prune_target_gb = prune_target_mib ? PruneMiBtoGB(prune_target_mib) : 2using thePruneGBtoMiBfunction below (orignally from interfaces: Expose settings.json methods to GUI #15936)
Lines 24 to 25 in 0ab41dd
| static inline int64_t PruneGBtoMiB(int gb) { return gb * GB_BYTES / 1024 / 1024; } | |
| static inline int PruneMiBtoGB(int64_t mib) { return (mib * 1024 * 1024 + GB_BYTES - 1) / GB_BYTES; } |
| requiredSpace = m_blockchain_size; | ||
| QString storageRequiresMsg = QObject::tr("At least %1 GB of data will be stored in this directory, and it will grow over time."); | ||
| if (ui->prune->isChecked()) { | ||
| uint64_t prunedGBs = std::ceil(m_prune_target * 1024 * 1024 / GB_BYTES); |
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.
Maybe I'm misunderstanding the flow, but it seems like there a bug here. This code is trying to convert m_prune_target from mib to gb when m_prune_target would already contain gib after running the code in the constructor.
|
@Sjors @ryanofsky |
Most of the reviews on the high-priority list are older than this, for some perspective: https://github.com/bitcoin/bitcoin/projects/8. More reviewers -> faster merges, of course. |
|
I don't think it's necessary to hold back the next release candidate for this. It can go into v0.19.1 if it doesn't make the cut. |
|
@Sjors There is still one and a half week, thats probably enough time |
|
@emilengler there's no official timetable. Usually we decide during the IRC meeting to ship a new release candidate when it looks like the most important bugs are squashed. Then we wait another week or so, and do another release candidate if new bugs were found. Otherwise the last candidate becomes the final version. |
|
I don't regard this as a blocker for the release either. IMO we'll cut rc2 without this. It would be nice to have, but it seems to be slightly controversial whether this is the right solution, has unaddressed comments, and it has garnered no ACKs yet. |
…oggled 4f7127d gui: Make Intro consistent with prune checkbox (Hennadii Stepanov) 4824a7d gui: Add Intro::UpdateFreeSpaceLabel() (Hennadii Stepanov) daa3f3f refactor: Add Intro::UpdatePruneLabels() (Hennadii Stepanov) e4caa82 refactor: Replace static variable with data member (Hennadii Stepanov) 2bede28 util: Add PruneGBtoMiB() function (Hennadii Stepanov) e35e4b2 util: Add PruneMiBtoGB() function (Hennadii Stepanov) Pull request description: On master (a6f6333) and on 0.19.0.1 the intro dialog with prune enabled (checkbox "Discard blocks..." is checked) provides a user with wrong info about the required disk space:  Also the paragraph "If you have chosen to limit..." is missed. --- With this PR when prune checkbox is toggled, the related text labels and the amount of required space shown are updated (previously they were only updated when the data directory was updated):  --- This PR is an alternative to #17035. **ryanofsky**'s [suggestion](#17035 (comment)) also has been implemented. ACKs for top commit: emilengler: ACK 4f7127d Sjors: tACK 4f7127d ryanofsky: Code review ACK 4f7127d. It seems like there are a few visible changes here: jonasschnelli: utACK 4f7127d Tree-SHA512: fa0bbdcfafde97d7906cda066cbd4608b936a71cae1b4cda3ee3aa2eed3a9795f279f14c6b1b4997278e094db891c7d3bb695368ba0882347aa42165a86e5172
…on is toggled 4f7127d gui: Make Intro consistent with prune checkbox (Hennadii Stepanov) 4824a7d gui: Add Intro::UpdateFreeSpaceLabel() (Hennadii Stepanov) daa3f3f refactor: Add Intro::UpdatePruneLabels() (Hennadii Stepanov) e4caa82 refactor: Replace static variable with data member (Hennadii Stepanov) 2bede28 util: Add PruneGBtoMiB() function (Hennadii Stepanov) e35e4b2 util: Add PruneMiBtoGB() function (Hennadii Stepanov) Pull request description: On master (a6f6333) and on 0.19.0.1 the intro dialog with prune enabled (checkbox "Discard blocks..." is checked) provides a user with wrong info about the required disk space:  Also the paragraph "If you have chosen to limit..." is missed. --- With this PR when prune checkbox is toggled, the related text labels and the amount of required space shown are updated (previously they were only updated when the data directory was updated):  --- This PR is an alternative to bitcoin#17035. **ryanofsky**'s [suggestion](bitcoin#17035 (comment)) also has been implemented. ACKs for top commit: emilengler: ACK 4f7127d Sjors: tACK 4f7127d ryanofsky: Code review ACK 4f7127d. It seems like there are a few visible changes here: jonasschnelli: utACK 4f7127d Tree-SHA512: fa0bbdcfafde97d7906cda066cbd4608b936a71cae1b4cda3ee3aa2eed3a9795f279f14c6b1b4997278e094db891c7d3bb695368ba0882347aa42165a86e5172
…on is toggled 4f7127d gui: Make Intro consistent with prune checkbox (Hennadii Stepanov) 4824a7d gui: Add Intro::UpdateFreeSpaceLabel() (Hennadii Stepanov) daa3f3f refactor: Add Intro::UpdatePruneLabels() (Hennadii Stepanov) e4caa82 refactor: Replace static variable with data member (Hennadii Stepanov) 2bede28 util: Add PruneGBtoMiB() function (Hennadii Stepanov) e35e4b2 util: Add PruneMiBtoGB() function (Hennadii Stepanov) Pull request description: On master (a6f6333) and on 0.19.0.1 the intro dialog with prune enabled (checkbox "Discard blocks..." is checked) provides a user with wrong info about the required disk space:  Also the paragraph "If you have chosen to limit..." is missed. --- With this PR when prune checkbox is toggled, the related text labels and the amount of required space shown are updated (previously they were only updated when the data directory was updated):  --- This PR is an alternative to bitcoin#17035. **ryanofsky**'s [suggestion](bitcoin#17035 (comment)) also has been implemented. ACKs for top commit: emilengler: ACK 4f7127d Sjors: tACK 4f7127d ryanofsky: Code review ACK 4f7127d. It seems like there are a few visible changes here: jonasschnelli: utACK 4f7127d Tree-SHA512: fa0bbdcfafde97d7906cda066cbd4608b936a71cae1b4cda3ee3aa2eed3a9795f279f14c6b1b4997278e094db891c7d3bb695368ba0882347aa42165a86e5172
…s toggled Summary: 4f7127d1e3a51f0f55d42a08439c516dcc8d1a26 gui: Make Intro consistent with prune checkbox (Hennadii Stepanov) 4824a7d36cf47e766865e0fefe952ec860eb82dd gui: Add Intro::UpdateFreeSpaceLabel() (Hennadii Stepanov) daa3f3fa9071a229275dd6a1b8445237ddc3fa97 refactor: Add Intro::UpdatePruneLabels() (Hennadii Stepanov) e4caa82a03df5c6a6d5d29f34ab006d732c6dac1 refactor: Replace static variable with data member (Hennadii Stepanov) 2bede28cd9ec638d8bb32c187ccf12d89345218e util: Add PruneGBtoMiB() function (Hennadii Stepanov) e35e4b2ba052c9a533626286026dbe0a2d546c5b util: Add PruneMiBtoGB() function (Hennadii Stepanov) Pull request description: On master (a6f6333ba253cda83221ee529810cacf930e413f) and on 0.19.0.1 the intro dialog with prune enabled (checkbox "Discard blocks..." is checked) provides a user with wrong info about the required disk space:  Also the paragraph "If you have chosen to limit..." is missed. --- With this PR when prune checkbox is toggled, the related text labels and the amount of required space shown are updated (previously they were only updated when the data directory was updated):  --- This PR is an alternative to #17035. **ryanofsky**'s [suggestion](bitcoin/bitcoin#17035 (comment)) also has been implemented. --- Backport of Core [[bitcoin/bitcoin#17453 | PR17453]] Depends on D8913 Test Plan: ninja all check check-functional ./src/qt/bitcoin-qt -choosedatadir check that correct information is provided, whether prune checkbox is ticked or not Reviewers: #bitcoin_abc, PiRK Reviewed By: #bitcoin_abc, PiRK Subscribers: PiRK Differential Revision: https://reviews.bitcoinabc.org/D8914





Currently there is this bug when enabling and disabling pruning: The intro screen isn't updated when something is changing.
This fixes the storage message in the top.
Here is a video of this fix
Unfortunately it doesn't fix the required storage amount, I will be working on this next.Done!This needs to get into 0.19 as well