bitcoin-core / gui

Bitcoin Core GUI staging repository
https://github.com/bitcoin/bitcoin
MIT License
603 stars 266 forks source link

Welcome screen uses GiB values as GB, risking running out of space #821

Open BenWestgate opened 6 months ago

BenWestgate commented 6 months ago

Is there an existing issue for this?

Current behaviour

The welcome screen correctly displays "55 GB of space available" while my system has 54322808 bytes available.

But it incorrectly says "... 12 GB of data will be stored in this directory" or "610 GB of data" if I uncheck the 2GB pruning. The values it is adding and comparing do not have the same unit. One is a GUI prune setting and/or space available in GB, the other is actually GiB: https://github.com/bitcoin/bitcoin/blob/master/doc/release-process.md#how-to-calculate-m_assumed_blockchain_size-and-m_assumed_chain_state_size

Since the "how to calculate m_assumed ... size" instructions add a 5-10% buffer, what we display when only a 5-7% buffer is added to the values used in our GUI's space calculations will be too small and may lead to the user running out of space without being warned by the red text XXX GB of space available (of XXX GB needed).

Expected behaviour

The Welcome dialog should either use all GB or all GiB for its math. That way it never underestimates the space needed. Converting the assumed_chain_state and assumed_blockchain_size to GB is a matter of multiplying by 1.073741824 and rounding up to the nearest GB.

That would update the values I was shown to: 13 GB and 655 GB respectively. You can see the gap between GB & GiB has gotten too massive to ignore, especially when estimating -prune=0 space needed.

Alternatively the units could be switched to GiB and my space available reported as 52 GiB and my prune setting bumped up to be 2 GiB (making it easier to predict what the GUI will show because the -prune command takes MiB).

I believe GB was used as it is the more familiar unit and matches what the OS and storage manufacturers tend to display so lets apply the first solution. Or update the https://github.com/bitcoin/bitcoin/blob/master/doc/release-process.md#how-to-calculate-assumed-blockchain-and-chain-state-size doc to require using a 13-19% buffer to allow for the previous 5-10% when they are misused as GB values despite being calculated as GiB.

Steps to reproduce

bitcoin-qt -choosedatadir notice the addition and subtraction of values that have different units as per our docs.

Relevant log output

No response

How did you obtain Bitcoin Core

Pre-built binaries

What version of Bitcoin Core are you using?

master / 27.0

Operating system and version

Debian 12

Machine specifications

No response

BenWestgate commented 6 months ago

On further analysis, the code comments in chainparams.h also think these values should be GB so I understand the origin of the gui error. It seems the release-process.md is the odd one out of the 3. This issue can be closed if the doc: PR below is ACK'd. https://github.com/bitcoin/bitcoin/pull/30171

hebasto commented 4 months ago

Also see https://github.com/bitcoin/bitcoin/pull/29678.