mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 09:11:37 +00:00
refactor: store positions as a 64 bits integer in flatfiles #36669
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36669
Loading…
Reference in a new issue
No description provided.
Delete branch "2610_64bit_blockstorage"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.tACK
48092a9042Also ran a few extra tests locally to stresss this a bit.
ACK
48092a9042, I have reviewed the code and it looks OK.ACK
48092a9042reproduced on linux only
Base:
2186232955fa70f47c584fb4973e5d849dcfe0f1Head:
48092a9042d8fcfd6bb7ae5911a1d53b8746d546Findings
Minor
Use large-file positioning APIs on 32-bit Linux (src/util/fs_helpers.h:60, head)
On 32-bit Linux,
longremains 32 bits. Although the build enables 64-bitoff_t, this branch usesfseekandftell, whose offset and result types arelong. Positions aboveLONG_MAXtherefore cannot be reliably sought or reported. Use POSIX large-file positioning APIs such asfseekoandftellowith 64-bitoff_t. No current production caller producing an offset aboveLONG_MAXwas identified; ordinary block files have a 128 MiB cap, so production impact is unconfirmed.Suggestions
Test seeking above
UINT32_MAX(src/flatfile.cpp:49, head)The new path seeks to a flat-file position, but
flatfile_openuses positions derived from short strings and the allocation tests use offsets below 200. Add a seek-only test aboveUINT32_MAXand check thatAutoFile::tell()returns the requested position. This exercises the widened seek/tell path without writing a multi-gigabyte file.Review coverage was incomplete.
Review limitations
Full review report
tested ACK
48092a9042About 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.This increases
sizeof(CBlockIndex)slightly, we can bring that back in a followup PR by movingnTxafterm_chain_tx_count.Restore the CBlockIndex size
Backported to
32.xin #36658.Backported to
31.xin #36661.Backported to
30.xin #36664.Backported to
29.xin #36666.See https://github.com/bitcoin/bitcoin/pull/36501 for a thread on this
post-merge lgtm. Only three style nits, which I fixed in https://github.com/bitcoin/bitcoin/pull/36725
style-nit: While reviewing I found there is no test coverage at all for varint overflow
style-nit: I still feel uneasy about using u32 for the length here. Obviously this is fine for all callers today, but it seems more consistent and easier to read to just use 64-bits for all file sizes and lengths.
unrelated style-nit: After C++11, this should use the 64-bit QuadPart according to the official Windows docs