Skip to content

test: make FakeStateManager return a valid height witness#10364

Open
pierugo-dfinity wants to merge 4 commits into
masterfrom
pierugo/fake-state-manager-real-witness
Open

test: make FakeStateManager return a valid height witness#10364
pierugo-dfinity wants to merge 4 commits into
masterfrom
pierugo/fake-state-manager-real-witness

Conversation

@pierugo-dfinity
Copy link
Copy Markdown
Contributor

@pierugo-dfinity pierugo-dfinity commented Jun 1, 2026

This PR makes FakeStateManager return a valid height witness in its implementation of list_state_hashes_to_certify. This change is driven by an upcoming new consensus integration test which depends on the certified height increasing. Though as of today, nodes in the integration test keeps invalidating certification shares (preventing the certified height to increase) because the height witness is not valid.

To do so, the FakeStateManager now calls the same functions as StateManagerImpl (i.e. replicated_state_as_lazy_tree, hash_lazy_tree, compute_state_height_witness) to compute the witness instead of using a ::new_for_testing.
The common part of the code was thus moved to the ic_canonical_state_tree_hash crate, where HashTree and LazyTree are defined and already depends on ic_crypto_tree_hash for Witness. Moving it to the latter crate was a possibility but we would have had to add ic_canonical_state_tree_hash as dependency for HashTree and LazyTree.

@github-actions github-actions Bot added the test label Jun 1, 2026
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 updates the FakeStateManager (test utility) to produce a valid height witness for list_state_hashes_to_certify, aligning its behavior with StateManagerImpl so certification can progress in upcoming consensus integration tests.

Changes:

  • Compute FakeStateManager’s height witness using canonical-state lazy tree hashing (replicated_state_as_lazy_treehash_lazy_treecompute_state_height_witness) instead of Witness::new_for_testing.
  • Factor the shared witness-construction logic into ic-canonical-state-tree-hash as witness::compute_state_height_witness and reuse it from StateManagerImpl.
  • Add required Rust and Bazel dependencies to rs/test_utilities.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
rs/test_utilities/src/state_manager.rs Generates real height witnesses + matching partial hashes for certification metadata.
rs/test_utilities/Cargo.toml Adds canonical-state crates needed to compute witnesses in tests.
rs/test_utilities/BUILD.bazel Adds Bazel deps for the same new canonical-state crates.
rs/state_manager/src/lib.rs Reuses the new shared compute_state_height_witness helper instead of duplicating logic.
rs/canonical_state/tree_hash/src/witness.rs Introduces shared compute_state_height_witness helper.
rs/canonical_state/tree_hash/src/lib.rs Exposes the new witness module.
Cargo.lock Records the new dependency edges.

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

Comment thread rs/state_manager/src/lib.rs
@pierugo-dfinity pierugo-dfinity marked this pull request as ready for review June 1, 2026 15:03
@pierugo-dfinity pierugo-dfinity requested a review from a team as a code owner June 1, 2026 15:03
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.

2 participants