fix(consensus): create CUP shares without waiting for finalized tip to point to CUP height#10314
Draft
pierugo-dfinity wants to merge 6 commits into
Draft
fix(consensus): create CUP shares without waiting for finalized tip to point to CUP height#10314pierugo-dfinity wants to merge 6 commits into
pierugo-dfinity wants to merge 6 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts consensus behavior to allow creating Catch-Up Package (CUP) shares and building/validating blocks even when the finalized tip’s certified_height has not yet caught up to the CUP height, reducing unnecessary blocking during long state computations.
Changes:
- Simplifies ancestor chain iteration to no longer stop at the CUP height, enabling retrieval of past payloads even when a newer CUP exists.
- Removes a gating condition in the CUP maker that required finalized
certified_heightto be at/above the target CUP height. - Prevents checkpoint purging below CUP height when the finalized tip’s
certified_heightis still behind the CUP height, and updates/adds tests for the new behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| rs/interfaces/src/consensus_pool.rs | Simplifies ChainIterator API/behavior used by default pool caches. |
| rs/consensus/src/consensus/validator.rs | Updates validation test expectation to succeed even with a higher CUP present. |
| rs/consensus/src/consensus/purger.rs | Skips checkpoint purging when finalized certified height lags CUP height; adds coverage. |
| rs/consensus/src/consensus/catchup_package_maker.rs | Removes finalized-certified-height gating for CUP share creation; updates tests. |
| rs/consensus/src/consensus/block_maker.rs | Updates block maker test to expect payload generation even with higher CUP present. |
| rs/artifact_pool/src/consensus_pool_cache.rs | Removes CUP-bounded traversal assumptions in cached chain iteration call sites. |
Comments suppressed due to low confidence (1)
rs/interfaces/src/consensus_pool.rs:456
ChainIterator::get_parent_blocknow only looks up the parent via validatedblock_proposal(). If the parent block exists only in the validatedcatch_up_package()pool (which can happen after purging block proposals but retaining the CUP), the iterator will stop early and callers using the defaultConsensusPoolCache::chain_iteratormay observe truncated chains. Consider adding a fallback lookup similar toCachedChainIterator(checkvalidated().catch_up_package().get_only_by_height(parent_height)and match the hash) so the iterator can traverse through CUP blocks without relying on block proposals being present.
fn get_parent_block(&self, block: &Block) -> Option<Block> {
let height = block.height();
if height == Height::from(0) {
return None;
}
let parent_height = height.decrement();
let parent_hash = &block.parent;
self.consensus_pool
.validated()
.block_proposal()
.get_by_height(parent_height)
.find_map(|proposal| {
if proposal.content.get_hash() == parent_hash {
Some(proposal.content.into_inner())
} else {
None
}
})
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This commit fixes a potential race condition, where during a checkpoint round we first populated `certifications_metadata`, before (with a separate lock) writing `states_metadata`. This made it possible to observe a state where we have the former but not the latter. With this change they are written inside the same lock, so that they are observable at the same time.
…ondition' into pierugo/consensus/create-cup-shares-earlier
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.
No description provided.