Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste 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. |
a33b9d4 to
1a22546
Compare
mzumsande
left a comment
There was a problem hiding this comment.
why would someone load a snapshot when they already downloaded the block, which means that their tip must be no more than 1024 blocks behind that block.
|
I don't think the normal P2P download path is a strong motivation here. In that case, as you say, the node would already be close to the snapshot height. The case covered here is that this blockstorage state is accepted through local block submission/import before snapshot activation. For example, So I’d frame this as making an accepted blockstorage state not abort, rather than as an important/common assumeutxo path. If maintainers prefer not to support that state, rejecting it during snapshot |
|
Taking this back to draft for now. |
1a22546 to
b520eab
Compare
b520eab to
bbdad23
Compare
The background chainstate connects the assumeutxo snapshot base block. If that block is accepted before loadtxoutset() sets m_snapshot_height, it is written using the normal blockfile cursor. After snapshot activation, classify only blocks above the base height as ASSUMED. This keeps the already-stored base block and its undo data on the normal cursor, while snapshot-chainstate flushes at the base height still avoid flushing normal block data. On restart, keep an already-stored base block in m_blocks_unlinked until its parents are processed, and avoid adding the historical target to setBlockIndexCandidates before then. Stop VerifyDB before disconnecting the snapshot base, where the snapshot database lacks the ancestor UTXO data. Add functional coverage for the base block already being on disk before snapshot activation, including a restart before background validation completes. Adjust the wallet assumeutxo prune-height test so the backup at the snapshot base remains available.
bbdad23 to
d07900c
Compare
|
Following up with what this actually does on master, in May I only described the assertion. If the node is restarted after the snapshot is loaded, it doesn't come back up: The database isn't corrupt, with this change the same sequence restarts and background I've kept this as fixing the state rather than rejecting it at activation, since rejecting Rebased. |
|
🐙 This pull request conflicts with the target branch and needs rebase. |
I agree that this is an issue that can only be hit in theory and I don't think it's important enough to fix as the motivation is stated. Concept NACK |
|
Closing for now due to controversy. If there is need in the future, this can be re-opened, or a new pull can be opened. |

A node that has the assumeutxo snapshot base block on disk before
loadtxoutset()runs ends upin a state it cannot recover from. Depending on whether it is restarted, it either aborts or
refuses to start.
Aborting, when background validation reaches the base block:
Refusing to start, if the node is restarted after the snapshot is loaded:
The block database is not corrupt, so the reindex that message asks for is wasted work.
Reaching this needs the base block stored before the snapshot is loaded, which
submitblockdoes: it is accepted and written while
BlockManager::m_snapshot_heightis still unset, so itgoes to the normal blockfile cursor.
loadtxoutset()then setsm_snapshot_heightto that sameheight, and
BlockfileTypeForHeight()starts reportingASSUMEDfor it.From there the two failures follow:
WriteBlockUndo()looks up the cursor for the block's height and does*Assert(m_blockfile_cursors[type]). The block is nowASSUMED, but nothing above thesnapshot height has been written, so that cursor does not exist and the assertion fires when
the background chainstate connects the base.
FindNextBlockPos()creates the cursor lazily inthe same situation;
WriteBlockUndo()asserts instead.VerifyDB()skips blocks withoutBLOCK_HAVE_DATAon a snapshot chainstate(
validation.cpp:4674), which is why the base is normally left alone. Here the base does havedata, and no undo data because the snapshot chainstate never connected it, so the skip does not
apply and
DisconnectBlock()is attempted on it.The base block is connected by the background chainstate, not the snapshot one, so it belongs to
the normal blockfile range.
BlockfileTypeForHeight()now classifies only blocks above thesnapshot height as
ASSUMED. A snapshot chainstate sitting at the base height must not flush thenormal cursor, so
FlushChainstateBlockFile()takes the chainstate into account.VerifyDB()stops before disconnecting the snapshot base, where the snapshot database does nothave the ancestor UTXO data the disconnect needs.
When a snapshot chainstate is loaded from disk, the base's hardcoded
m_chain_tx_countdoes notmean the background chainstate has processed its parents, so the base is kept in
m_blocks_unlinkeduntil they arrive, and a historical chainstate does not add its target to theblock index candidates before then.
The functional test submits the base block, loads the snapshot, restarts, then feeds the missing
historical blocks and checks that background validation completes. Both failures above are what
it hits without this change.
Tested: