Repository navigation
fix: move certified height channel for HTTP handler to StateManagerImpl - #9850
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR moves the “max certified height” watch channel responsibility from the certification/HTTP wiring into StateManagerImpl, so the StateManager becomes the source of truth for notifying consumers when the certified height advances.
Changes:
- Extend
StateManagerImpl::newto accept and retain atokio::sync::watch::Sender<Height>, and publish updates when a certification is actually applied. - Remove the certified-height channel plumbing from consensus/certifier setup and
StateMachine, and instead pass the receiver directly to the HTTP server while the sender lives in the StateManager. - Add/adjust tests and fixtures across the repo to provide the new sender and validate the new notification behavior.
Reviewed changes
Copilot reviewed 21 out of 22 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| rs/xnet/payload_builder/tests/common/mod.rs | Updates test fixture to pass the new watch::Sender<Height> arg to StateManagerImpl::new. |
| rs/state_manager/tests/state_manager.rs | Adds targeted tests for the new max-certified-height notification semantics; updates call sites. |
| rs/state_manager/tests/common/mod.rs | Updates state manager test helpers to pass a watch::Sender<Height>. |
| rs/state_manager/src/state_sync/chunkable/cache/tests.rs | Updates state sync cache tests to pass the new sender parameter. |
| rs/state_manager/src/lib.rs | Introduces max_certified_height_tx field/ctor arg; sends updates when certifications are stored/applied. |
| rs/state_manager/Cargo.toml | Adds tokio dependency for watch usage in the library. |
| rs/state_manager/BUILD.bazel | Adds Bazel dependency on tokio for state_manager. |
| rs/state_machine_tests/src/lib.rs | Removes manual certified-height sending from StateMachine; passes sender into StateManagerImpl. |
| rs/replica/src/setup_ic_stack.rs | Creates the watch channel before StateManager construction; passes receiver to HTTP server and sender to StateManager. |
| rs/replica/setup_ic_network/src/lib.rs | Removes certified-height sender from consensus/p2p setup plumbing. |
| rs/replay/src/player.rs | Updates StateManagerImpl::new call with a dummy watch sender. |
| rs/prep/src/node.rs | Updates StateManagerImpl::new call with a dummy watch sender. |
| rs/prep/Cargo.toml | Adds tokio dependency to support creating the dummy watch channel. |
| rs/prep/BUILD.bazel | Adds Bazel dependency on tokio for prep. |
| rs/pocket_ic_server/src/pocket_ic.rs | Updates temporary StateManager creation to pass a dummy watch sender. |
| rs/determinism_test/src/setup.rs | Updates StateManager creation to pass a dummy watch sender. |
| rs/consensus/tests/payload.rs | Removes now-unneeded dummy watch sender wiring from consensus tests. |
| rs/consensus/tests/framework/runner.rs | Removes now-unneeded dummy watch sender wiring from consensus test runner. |
| rs/consensus/certification/src/certifier.rs | Removes watch::Sender<Height> field/constructor arg and associated send logic; deletes related test. |
| rs/consensus/benches/validate_payload.rs | Updates benchmark StateManager construction to pass a dummy watch sender. |
| rs/consensus/BUILD.bazel | Adds Bazel dependency on tokio (used by the bench fixture now creating a watch channel). |
| Cargo.lock | Locks new tokio deps added to crates that now create/use watch channels. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
eichhorl
approved these changes
Apr 15, 2026
mraszyk
marked this pull request as draft
April 20, 2026 10:21
mraszyk
commented
Apr 20, 2026
mraszyk
commented
Apr 20, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 24 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mraszyk
marked this pull request as ready for review
April 20, 2026 12:24
michael-weigelt
approved these changes
Apr 22, 2026
basvandijk
approved these changes
Apr 22, 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.
Move the
max_certified_heightchannel fromCertifierImpltoStateManagerImpl.The reason for this change is that the consensus certifier was updating the channel after every
deliver_state_certification, but the certified state is not available for heights that have not been committed and cloned by the state manager.This issue has also been observed in production (see slack) and mitigated by a work-around that checks if the channel was not updated too early (PR). This PR implements a proper fix by ensuring that the channel is not updated too early at the first place.