blockstorage: handle undo for assumeutxo base block already on disk#35307
Open
shuv-amp wants to merge 1 commit into
Open
blockstorage: handle undo for assumeutxo base block already on disk#35307shuv-amp wants to merge 1 commit into
shuv-amp wants to merge 1 commit into
Conversation
Contributor
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35307. ReviewsSee the guideline for information on the review process. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
An assumeutxo snapshot base block can be stored before loadtxoutset() sets BlockManager::m_snapshot_height. After the snapshot is loaded, BlockfileTypeForHeight() classifies that height as ASSUMED, but the ASSUMED blockfile cursor may not exist yet. When background validation connects the already-stored base block, write undo data to the block's existing file without requiring the height-derived cursor to exist. Keep the existing cursor finalization logic when the cursor is present. FlushChainstateBlockFile now receives the tip block index, so it can flush the file where the tip is actually stored if no height-derived cursor exists. A snapshot chainstate at the base height can still return without flushing because it has not written post-snapshot block data. Add functional coverage for storing the snapshot base block before loading the snapshot, then completing background validation.
a33b9d4 to
1a22546
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A node can receive the assumeutxo snapshot base block before loading the
snapshot. In that case the block data is written before
BlockManager::m_snapshot_heightis set, so it is tracked by the normalblockfile cursor.
After
loadtxoutset()setsm_snapshot_height, the same height maps to theASSUMEDblockfile range. If background validation later connects the baseblock that was already on disk,
WriteBlockUndo()could require anASSUMEDcursor even though no post-snapshot block data had created one yet.
Handle this by writing undo data to the block's existing file when the
height-derived cursor is not present. Keep the existing cursor finalization
logic when a cursor exists.
FlushChainstateBlockFile()now receives the tip block index, so it can flushthe file where the tip is actually stored when needed.
The functional test stores the snapshot base block before loading the snapshot,
then feeds the missing historical blocks and waits for background validation to
complete.
Tested:
test/functional/feature_assumeutxo.py --configfile=$PWD/build/test/config.ini --timeout-factor=4