That field is the last 32-bit in flat files management that is only bounded indirectly by callers' usage (unlike the file number for instance). In the spirit of the ongoing effort to avoid unnecessarily using 32 bits integers or platform specific types (for instance #24214, #33724, #34109, #35097, #35616), i was scanning for fields it could be prudent to promote to prevent any possible future misuse. This one is a good candidate because it does not change on-disk representation, since we serialize positions as varints.
refactor: store positions as a 64 bits integer in flatfiles #36669
pull darosior wants to merge 2 commits into bitcoin:master from darosior:2610_64bit_blockstorage changing 9 files +54 −23-
darosior commented at 4:01 PM on October 26, 2026: member
-
17556cb1f5
flatfile: store position as a 64 bits integer
This is the last field that is only bounded by the usage callers make of it (unlike the file number, for instance). Promoting it to a 64 bits integer also does not change on-disk representation since we serialize positions as varints. Therefore, widen them to prevent any possible future misuse.
-
flatfile: use 64-bit file positioning syscalls in Windows 48092a9042
- DrahtBot added the label Refactoring on Oct 26, 2026
-
DrahtBot commented at 4:01 PM on October 26, 2026: contributor
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--006a51241073e994b41acfe9ec718e94-->
External sites
- Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36669
- Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36669.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36669#author-ralph
<!--021abf342d371248e50ceaed478a90ca-->
Reviews
See the guideline and AI policy for information on the review process.
Type Reviewers ACK sedited, hebasto, instagibbs, l0rinc If your review is incorrectly listed, please copy-paste <code><!--meta-tag:bot-skip--></code> into the comment that the bot should ignore.
<!--5faf32d7da4f0f540f40219e4f7537a3-->
- sedited approved
-
sedited commented at 4:28 PM on October 26, 2026: contributor
tACK 48092a9042d8fcfd6bb7ae5911a1d53b8746d546
Also ran a few extra tests locally to stresss this a bit and tested and reproduced the windows code.
- hebasto approved
-
hebasto commented at 4:34 PM on October 26, 2026: member
ACK 48092a9042d8fcfd6bb7ae5911a1d53b8746d546, I have reviewed the code and it looks OK.
- instagibbs approved
-
instagibbs commented at 4:36 PM on October 26, 2026: member
ACK 48092a9042d8fcfd6bb7ae5911a1d53b8746d546
reproduced on linux only
-
in src/chain.h:93 in 48092a9042
l0rinc commented at 4:51 PM on October 26, 2026:48092a9 flatfile: use 64-bit file positioning syscalls in Windows:
This increases
sizeof(CBlockIndex)slightly, we can bring that back in a followup PR by movingnTxafterm_chain_tx_count.<details> <summary>Restore the CBlockIndex size</summary>
diff --git a/src/chain.h b/src/chain.h index 830cabe3f6..b2380468b2 100644 --- a/src/chain.h +++ b/src/chain.h @@ -117,17 +117,17 @@ public: //! (memory only) Total amount of work (expected number of hashes) in the chain up to and including this block arith_uint256 nChainWork{}; - //! Number of transactions in this block. This will be nonzero if the block - //! reached the VALID_TRANSACTIONS level, and zero otherwise. - //! Note: in a potential headers-first mode, this number cannot be relied upon - unsigned int nTx{0}; - //! (memory only) Number of transactions in the chain up to and including this block. //! This value will be non-zero if this block and all previous blocks back //! to the genesis block or an assumeutxo snapshot block have reached the //! VALID_TRANSACTIONS level. uint64_t m_chain_tx_count{0}; + //! Number of transactions in this block. This will be nonzero if the block + //! reached the VALID_TRANSACTIONS level, and zero otherwise. + //! Note: in a potential headers-first mode, this number cannot be relied upon + unsigned int nTx{0}; + //! Verification status of this block. See enum BlockStatus //! //! Note: this value is modified to show BLOCK_OPT_WITNESS during UTXO snapshot</details>
l0rinc approvedl0rinc commented at 4:52 PM on October 26, 2026: contributortested ACK 48092a9042d8fcfd6bb7ae5911a1d53b8746d546
About time we got rid of the 32-bit file offsets - checked the
CBlockIndexlayout with Clang and GCC, the padding nit can be addressed in a follow-up.fanquake merged this on Oct 26, 2026fanquake closed this on Oct 26, 2026fanquake referenced this in commit 98f204f51b on Oct 26, 2026fanquake referenced this in commit 09a3519e3b on Oct 26, 2026fanquake referenced this in commit d47e0d7e24 on Oct 26, 2026fanquake referenced this in commit 307fbeeaf4 on Oct 26, 2026sedited referenced this in commit f0de87f040 on Oct 26, 2026fanquake referenced this in commit adb363c753 on Oct 26, 2026fanquake referenced this in commit a9e7b35d06 on Oct 26, 2026fanquake referenced this in commit 241537a697 on Oct 26, 2026fanquake referenced this in commit 5c99cb6745 on Oct 26, 2026LabelsLinked (view graph)#24214 Fix unsigned integer overflows in interpreter#33724 refactor: Return uint64_t from GetSerializeSize#34109 refactor: Use uint64_t over size_t for serialize corruption check in fees.dat#35097 util: Return uint64_t from _MiB and _GiB operators#35616 refactor: Use u64 over size_t for all cache sizes to fix a 32-bit overflow#36658 [32.x] Finalise 32.1#36661 [31.x] Finalise 31.2#36664 [30.x] Finalise 30.4#36666 [29.x] Finalise 29.5
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-10-26 20:51 UTC
More mirrored repositories can be found on mirror.b10c.me