Skip to content

Bugfix: Correct first-run free space checks#29678

Open
luke-jr wants to merge 4 commits intobitcoin:masterfrom
luke-jr:fix_init_lowdisk_warning_reqd
Open

Bugfix: Correct first-run free space checks#29678
luke-jr wants to merge 4 commits intobitcoin:masterfrom
luke-jr:fix_init_lowdisk_warning_reqd

Conversation

@luke-jr
Copy link
Member

@luke-jr luke-jr commented Mar 19, 2024

It's not clear what m_assumed_*_size are actually set based on, but historically it was in GB, not GiB, and that's still used in the GUI which is more user-facing.

Could just as easily change the GUI if GiB is preferred.

@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 19, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/29678.

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept ACK hebasto, murchandamus, BrandonOdiwuor
Stale ACK sedited

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #34628 (p2p: Replace per-peer transaction rate-limiting with global rate limits by ajtowns)
  • #34436 (refactor: add overflow-safe CeilDiv helper and use it in unsigned callsites by l0rinc)
  • #34435 (refactor: use _MiB/_GiB consistently for byte conversions by l0rinc)

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.

LLM Linter (✨ experimental)

Possible places where comparison-specific test macros should replace generic comparisons:

  • [src/test/util_tests.cpp] BOOST_CHECK_THROW((void)CeilDiv(1ULL, 0ULL), NonFatalCheckError); -> Use BOOST_CHECK_EXCEPTION to also verify the failure message, e.g. BOOST_CHECK_EXCEPTION((void)CeilDiv(1ULL, 0ULL), NonFatalCheckError, HasReason("expected failure message"));
  • [src/test/util_tests.cpp] BOOST_CHECK_THROW((void)CeilDiv(size_t{1}, size_t{0}), NonFatalCheckError); -> Use BOOST_CHECK_EXCEPTION to also verify the failure message, e.g. BOOST_CHECK_EXCEPTION((void)CeilDiv(size_t{1}, size_t{0}), NonFatalCheckError, HasReason("expected failure message"));

2026-01-29 07:26:52

@Sjors
Copy link
Member

Sjors commented Mar 19, 2024

I'm not sure what the latest convention is, cc @hebasto. A few years ago #15163 made it so RPC, code and GUI all use KiB / MiB / GiB.

(though for pruning it seems the config file uses MiB, but the GUI converts it to GB - yet there are translated error strings using MiB, confusing...)

@fanquake
Copy link
Member

@hebasto can you follow up given the gui / translation Qs here. This also needs a rebase.

@hebasto
Copy link
Member

hebasto commented Jul 10, 2024

Indeed, there is inconsistency in GB/GiB unit usage.

For instance, the value of the m_assumed_blockchain_size variable in GiB is used with the "GB" units in the user-faced messages here:

"Approximately %u GB of data will be stored in this directory."
and here:
<string>When you click OK, %1 will begin to download and process the full %4 block chain (%2 GB) starting with the earliest transactions in %3 when %4 initially launched.</string>

Concept ACK.


It would be nice to mention the second commit changes in the PR description, no?


Could just as easily change the GUI if GiB is preferred.

The GUI now uses "GB" (SI prefix) as a unit, based on the mindset of non-technical/non-CS users.

@GBKS What are modern guidelines in this regard?


@Sjors

I'm not sure what the latest convention is, cc @hebasto. A few years ago #15163 made it so RPC, code and GUI all use KiB / MiB / GiB.

(though for pruning it seems the config file uses MiB, but the GUI converts it to GB - yet there are translated error strings using MiB, confusing...)

For the GUI, the conversion to/from GB is still used:

/**
* Convert configured prune target MiB to displayed GB. Round up to avoid underestimating max disk usage.
*/
static inline int PruneMiBtoGB(int64_t mib) { return (mib * 1024 * 1024 + GB_BYTES - 1) / GB_BYTES; }
/**
* Convert displayed prune target GB to configured MiB. Round down so roundtrip GB -> MiB -> GB conversion is stable.
*/
static inline int64_t PruneGBtoMiB(int gb) { return gb * GB_BYTES / 1024 / 1024; }

@GBKS
Copy link

GBKS commented Jul 11, 2024

The GUI now uses "GB" (SI prefix) as a unit, based on the mindset of non-technical/non-CS users.

GB is standard for general audiences, and GiB for technical, scientific, or engineering contexts. I'd recommend keeping GB in the GUI.

I am curious about use cases where it is essential for the user to know the GiB value in order to make decisions.

Copy link
Member

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

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

All of these changes seem consistent to me.

Concept ACK on generally using GB to refer to 1,000,000,000 bytes and GiB to refer to 1024³ bytes everywhere.

Copy link
Contributor

@BrandonOdiwuor BrandonOdiwuor left a comment

Choose a reason for hiding this comment

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

Concept ACK using GB to represent 10003 bytes for consistency with GUI

@DrahtBot DrahtBot mentioned this pull request Mar 3, 2025
@maflcko
Copy link
Member

maflcko commented May 4, 2025

(close-open for fresh GitHub CI, I guess the Cirrus failure can be ignored for now)

@sedited
Copy link
Contributor

sedited commented Oct 11, 2025

Concept ACK

Copy link
Contributor

@sedited sedited left a comment

Choose a reason for hiding this comment

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

ACK c452d6c

Introduce `CeilDiv()` for integral ceiling division without the typical `(dividend + divisor - 1) / divisor` overflow.
`CeilDiv()` asserts non-negative arguments and a non-zero divisor.
Add unit tests covering return type deduction, max-value behavior, and divisor checks.
…pruned size rather than full blockchain size
@luke-jr luke-jr force-pushed the fix_init_lowdisk_warning_reqd branch from c452d6c to b1117e5 Compare January 29, 2026 07:26
@luke-jr
Copy link
Member Author

luke-jr commented Jan 29, 2026

Used @l0rinc 's CeilDiv (from #34436) to round up prune expectations

luke-jr added a commit to bitcoinknots/bitcoin that referenced this pull request Jan 29, 2026
Introduce `CeilDiv()` for integral ceiling division without the typical `(dividend + divisor - 1) / divisor` overflow.
`CeilDiv()` asserts non-negative arguments and a non-zero divisor.
Add unit tests covering return type deduction, max-value behavior, and divisor checks.

Github-Pull: bitcoin#29678
Rebased-From: c41dd35
luke-jr added a commit to bitcoinknots/bitcoin that referenced this pull request Jan 29, 2026
@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

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.

10 participants