refactor: Use u64 consistently for flatfile sizes #36725

pull maflcko wants to merge 3 commits into bitcoin:master from maflcko:2611-file-size-u64 changing 10 files +64 −37
  1. maflcko commented at 9:47 AM on November 2, 2026: member

    unsigned is a 32-bit integer (even on 64-bit platforms). File sizes are generally measured in 64-bit integers and using 32-bit integers or architecture-dependent integers is brittle and confusing.

    So use u64 consistently for flatfile sizes in this refactor.

    Also, use LARGE_INTEGER's QuadPart on Windows, which is recommended since C++11.

    Also, unit test VarInt overflow errors.

  2. refactor: Use u64 consistently for flatfile sizes
    File sizes are generally measured in 64-bit integers and using 32-bit
    integers or architecture-dependent integers is brittle and confusing.
    faf8d0e33a
  3. refactor: Use LARGE_INTEGER QuadPart on Windows
    Now that C++11 added 64-bit integers, follow
    https://learn.microsoft.com/en-nz/windows/win32/api/winnt/ns-winnt-large_integer-r1#remarks
    
    > If your compiler has built-in support for 64-bit integers, use the QuadPart member to store the 64-bit integer.
    faed02f6d0
  4. Add test coverage for varint overflow
    Stuff like CBlockIndex::nUndoPos or CBlockFileInfo::nUndoSize is
    serialized as VARINT. However, there is no test coverage at all for
    VarInt overflow behavior, so add test coverage for both overflow cases
    (and distinguish their error msg).
    fa2c8df181
  5. DrahtBot renamed this:
    refactor: Use u64 consistently for flatfile sizes
    refactor: Use u64 consistently for flatfile sizes
    on Nov 2, 2026
  6. DrahtBot added the label Refactoring on Nov 2, 2026
  7. DrahtBot commented at 9:48 AM on November 2, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK darosior, frankomosh, sedited

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #35713 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35713.svg"></sub> (Remove boost as a unit test runner by rustaceanrob)
    • #35646 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35646.svg"></sub> (RFC: Separate out runtime errors from BlockValidationState using util::Expected by yuvicc)
    • #29700 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/29700.svg"></sub> (kernel, refactor: return error status on all fatal errors by ryanofsky)

    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.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  8. frankomosh commented at 3:30 PM on November 3, 2026: contributor

    Concept ACK

  9. darosior approved
  10. darosior commented at 6:50 PM on November 4, 2026: member

    utACK fa2c8df1810f23e1c510e310eb246fd5abd3a066

  11. frankomosh commented at 10:56 AM on November 5, 2026: contributor

    ACK fa2c8df1810f23e1c510e310eb246fd5abd3a066

    nPos, nSize and nUndoSize were already u64, so this makes the remaining flatfile sizes match them. I checked that the block and undo size headers on disk stay 4 bytes. Built the PR at this commit and ran serialize_tests, flatfile_tests and blockmanager_tests, which all look good.

  12. sedited approved
  13. sedited commented at 10:12 PM on November 5, 2026: contributor

    ACK fa2c8df1810f23e1c510e310eb246fd5abd3a066

  14. sedited merged this on Nov 5, 2026
  15. sedited closed this on Nov 5, 2026

  16. maflcko deleted the branch on Nov 6, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-11-09 21:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me