Repository navigation
Conversation
…lock Companion to blvm-consensus's Core-semantics assume-valid: build the assume-valid block's ancestry once by walking prev hashes on the stored header tree, and pass it as BlockValidationContext::assume_valid_ancestor on the IBD, connect, reorg and pruning paths.
This was referenced Oct 21, 2026
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.
What it does
BlockStore::assume_valid_ancestor_lookup()returns the hook consensus needs: the assume-valid block's ancestor at heighthon the stored header tree (Core:assumevalid->GetAncestor(h)).prev_block_hashback from the assume-valid header, which gives one 32-byte hash per height. That's about 30 MB on mainnet. It's cached in a static, keyed by (hash, height).None(nothing skips) and retries cheaply: one header read, no allocation.Wired next to
difficulty_ancestoron these paths:parallel_ibd/mod.rs)block_processor.rsreorg_executor.rspruning.rsThe
blvm-protocolvalidate_and_connect_block_with_difficultypaths (block_processor's first pass, RPC) build their own context and still verify every script. That's fail-closed, and those paths already verify fully today in block_processor.Test:
tests/assume_valid_ancestor_lookup.rsStore a competing header chain for heights 0..=3 first, so it occupies the height index, then the real 10-header chain with assume-valid at height 6. Checks:
NoneNoneAlso green:
fork_reorg_regtest,fork_reorg_events,blockchain_rpc_tests,cargo test --lib parallel_ibd(727 passed), andcargo clippy --libwith no new warnings.Not done: an IBD-throughput measurement with the hook on mainnet headers. The one-time walk is about 938k header reads at the first block below the assume-valid height.
Merge order
blvm-consensuspin bumped to that release.Relative to the 7 criticals PRs: works with or without #31 (Core v31.1 hash and height per network). With #31, the default hash is anchored, so this lookup finds it once headers sync. No file overlap with #31, #32 or #38. #38 also touches
reorg_executor.rs, but in a different hunk.