Skip to content

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
masterfrom
pierugo/consensus/create-cup-shares-earlier
Draft

fix(consensus): create CUP shares without waiting for finalized tip to point to CUP height#10314
pierugo-dfinity wants to merge 6 commits into
masterfrom
pierugo/consensus/create-cup-shares-earlier

Conversation

@pierugo-dfinity
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_height to be at/above the target CUP height.
  • Prevents checkpoint purging below CUP height when the finalized tip’s certified_height is 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_block now only looks up the parent via validated block_proposal(). If the parent block exists only in the validated catch_up_package() pool (which can happen after purging block proposals but retaining the CUP), the iterator will stop early and callers using the default ConsensusPoolCache::chain_iterator may observe truncated chains. Consider adding a fallback lookup similar to CachedChainIterator (check validated().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.

pierugo-dfinity and others added 3 commits May 26, 2026 14:25
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI_ALL_BAZEL_TARGETS Runs all bazel targets fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants