Repository navigation
Conversation
Record the availability results for genesis and partially available blocks before fixing the mask checks. Use `Assert` for the full-mask precondition in `GetFirstBlock` so the unit test can observe which availability requests violate it.
The genesis undo exception accepts any matching requested flag, so `BLOCK_OPT_WITNESS` can hide missing block data at genesis. Check the lower block for missing requested bits before walking the range, exempting only genesis undo data. When both endpoints are the same pruned block with only undo data, a request for block data and undo data now returns `false` before reaching the walker assertion. Assert the existing `cs_main` requirement on entry so it also covers the early returns.
When the endpoints coincide, checking the lower block covers the whole range. Return early in that case so neither the upper block check nor `GetFirstBlock` requires undo data from genesis. This also accepts an empty mask on a single-block range because it requests no bits.
`GetFirstBlock` requires every requested bit on its starting block. Reject an upper block missing any of those bits before calling the walker. This also accepts an empty mask on a multi-block range because it requests no bits.
The old genesis branch rejected undo-only requests because it looked for a matching flag after removing the only requested bit. Genesis has already passed the lower block check. If the walk stops at its child because genesis lacks undo data, the whole range is available. Every other lower block has already passed the full mask check, so the walk cannot stop at its child.
|
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. |
jeanpablojp
left a comment
There was a problem hiding this comment.
tACK 41851dc
Left 2 small nits.
| //! Check if all blocks in the [upper_block, lower_block] range have data available as | ||
| //! defined by the status mask. |
There was a problem hiding this comment.
nit: could the comment say every flag is required, like the PR description does?
| //! Check if all blocks in the [upper_block, lower_block] range have data available as | |
| //! defined by the status mask. | |
| //! Check if all blocks in the [upper_block, lower_block] range have all | |
| //! block_status flags set. |
| BOOST_CHECK(blockman.CheckBlockDataAvailability(tip, *first_available_block)); | ||
| BOOST_CHECK(!blockman.CheckBlockDataAvailability(tip, *last_pruned_block)); | ||
| BOOST_REQUIRE_EQUAL(last_pruned_block->nStatus & BLOCK_HAVE_MASK, BLOCK_HAVE_UNDO); | ||
| BOOST_CHECK(!blockman.CheckBlockDataAvailability(*last_pruned_block, *last_pruned_block, BLOCK_HAVE_MASK)); |
There was a problem hiding this comment.
I think the two empty-mask checks Ralph suggested make sense here. Feel free to ignore, though.
| BOOST_CHECK(!blockman.CheckBlockDataAvailability(*last_pruned_block, *last_pruned_block, BLOCK_HAVE_MASK)); | |
| BOOST_CHECK(!blockman.CheckBlockDataAvailability(*last_pruned_block, *last_pruned_block, BLOCK_HAVE_MASK)); | |
| BOOST_CHECK(blockman.CheckBlockDataAvailability(*last_pruned_block, *last_pruned_block, BlockStatus{})); | |
| BOOST_CHECK(blockman.CheckBlockDataAvailability(tip, *last_pruned_block, BlockStatus{})); |

Problem:
CheckBlockDataAvailabilitychecks whether the upper block has any requested bit.GetFirstBlockrequires every requested bit, so a partial match can reach its assertion. At genesis, the existing undo exception can reject an undo-only request or accept a request with missing block data. It also misses ranges containing only genesis.Fix: Require every requested bit on each block in the range, except that genesis needs no undo data. An empty mask now succeeds for a valid range because it requests no bits. Both index-startup calls supply nonempty masks.