Skip to content

feat(recovery): [CON-1604] allow to override what state height to download - #9707

Merged
pierugo-dfinity merged 41 commits into
masterfrom
pierugo/recovery/download-state-chosen-by-user
Apr 23, 2026
Merged

pierugo-dfinity merged 41 commits into
masterfrom
pierugo/recovery/download-state-chosen-by-user

Conversation

@pierugo-dfinity

@pierugo-dfinity pierugo-dfinity commented Apr 1, 2026 •

Copy link
Copy Markdown
Contributor

This PR aims at deflaking subnet recovery system tests that either:

  • Download a state older than the latest CUP because the download_state_node has not computed the manifest yet.
  • Download a state higher than the latest CUP because the subnet stalled right after computing the manifest but before creating a CUP.
  • Download the correct state (equal to the latest CUP) but was considered invalid because it was received by state sync.

It does so by introducing a new download_state_height argument to ic-recovery. If provided, it will download the checkpoint at that height and throw and error if it does not exist.
If not provided (recommended in most production cases), it will default to the latest checkpoint.

Subnet recovery system tests are then adapted as such:

  • Always download the checkpoint that matches the highest CUP on the subnet (solves first two flakes).
  • Download it from a node that created a manifest for this CUP (solves third flake).
  • Download the consensus pool from a node that has this highest CUP, and choose the one with highest certification share height.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors the subnet recovery test harness and ic-recovery tooling to allow explicitly selecting which checkpoint height to download (targeting the latest CUP height), reducing flakes caused by manifest/CUP timing races during state download.

Changes:

  • Add --download-state-height support to recovery flows (App subnet, NNS same-nodes, NNS failover-nodes) and thread it through download/copy-local steps.
  • Extend node metrics parsing to include CUP height and last computed manifest height; update node selection logic in tests to use these heights.
  • Update system tests to pass an explicit download_state_height derived from CUP height and refactor parameter selection into a helper.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
rs/tests/testnets/nns_recovery.rs Switches to updated node-height selection helper and struct return type.
rs/tests/nested/nns_recovery/common.rs Uses CUP height to set download_state_height for NNS recovery runs.
rs/tests/consensus/subnet_recovery/utils.rs Introduces NodeHeights + selects node based on cert-share/CUP heights; threads download_state_height into local CLI args.
rs/tests/consensus/subnet_recovery/sr_nns_failover_nodes_test.rs Passes download_state_height into NNS failover recovery args.
rs/tests/consensus/subnet_recovery/common.rs Refactors app-subnet recovery parameter selection; ensures state download node has manifest >= CUP; passes download_state_height.
rs/recovery/subnet_splitting/src/subnet_splitting.rs Updates get_ic_state_includes call signature.
rs/recovery/src/steps.rs Makes local state copy step accept precomputed include paths; uses MaybeRemote for latest checkpoint lookup remotely.
rs/recovery/src/recovery_state.rs Updates tests to account for new args field and simplifies expectations.
rs/recovery/src/nns_recovery_same_nodes.rs Adds CLI arg + interactive prompt for download_state_height; threads it into download/copy-local steps.
rs/recovery/src/nns_recovery_failover_nodes.rs Adds CLI arg + interactive prompt for download_state_height; threads it into download step.
rs/recovery/src/lib.rs Implements download_height support in get_ic_state_includes; adds MaybeRemote; extends NodeMetrics; adds unit test.
rs/recovery/src/cli.rs Updates height-selection guidance message to mention CUP height.
rs/recovery/src/app_subnet_recovery.rs Adds CLI arg + interactive prompt for download_state_height; threads it into download/copy-local steps.
rs/recovery/Cargo.toml Adds assert_matches dev-dependency for new unit test assertions.
rs/recovery/BUILD.bazel Adds Bazel dev-dependency for assert_matches.
Cargo.lock Locks assert_matches into ic-recovery dependency set.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rs/tests/nested/nns_recovery/common.rs Resolved
Comment thread rs/recovery/src/lib.rs Resolved

@kpop-dfinity kpop-dfinity left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will make @basvandijk very happy

Comment thread rs/recovery/src/app_subnet_recovery.rs Resolved
Comment thread rs/recovery/src/lib.rs Resolved
Comment thread rs/recovery/src/lib.rs Resolved
Comment thread rs/recovery/src/lib.rs Resolved
Comment thread rs/recovery/src/lib.rs Resolved
@kpop-dfinity

Copy link
Copy Markdown
Contributor

One more meta thing: I don't think refactor tag is appropriate here. I think feat makes more sense

@basvandijk

Copy link
Copy Markdown
Collaborator

This will make @basvandijk very happy

It does!

@pierugo-dfinity pierugo-dfinity changed the title refactor(recovery): [CON-1604] allow to override what state height to download feat(recovery): [CON-1604] allow to override what state height to download Apr 17, 2026
@github-actions github-actions Bot added feat and removed refactor labels Apr 17, 2026

@kpop-dfinity kpop-dfinity left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LFG!

Comment thread rs/recovery/src/app_subnet_recovery.rs Resolved
Comment thread rs/recovery/src/lib.rs Resolved
Comment thread rs/recovery/src/lib.rs Resolved
Comment thread rs/recovery/src/util.rs Resolved
Comment thread rs/recovery/src/util.rs Resolved
@pierugo-dfinity
pierugo-dfinity added this pull request to the merge queue Apr 23, 2026
Merged via the queue into master with commit aef1670 Apr 23, 2026
35 checks passed
@pierugo-dfinity
pierugo-dfinity deleted the pierugo/recovery/download-state-chosen-by-user branch April 23, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants