Skip to content

fix: move certified height channel for HTTP handler to StateManagerImpl - #9850

Merged
mraszyk merged 14 commits into
masterfrom
mraszyk/certified-height-channel
Apr 22, 2026
Merged

mraszyk merged 14 commits into
masterfrom
mraszyk/certified-height-channel

Conversation

@mraszyk

@mraszyk mraszyk commented Apr 14, 2026 •

Copy link
Copy Markdown
Contributor

Move the max_certified_height channel from CertifierImpl to StateManagerImpl.

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.

@github-actions github-actions Bot added the fix label Apr 14, 2026

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

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::new to accept and retain a tokio::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.

Comment thread rs/state_manager/tests/state_manager.rs Resolved
Comment thread rs/state_manager/src/lib.rs Resolved
Comment thread rs/state_manager/src/lib.rs Resolved
@mraszyk
mraszyk marked this pull request as ready for review April 14, 2026 10:08
@mraszyk
mraszyk requested review from a team as code owners April 14, 2026 10:08

@eichhorl eichhorl 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.

Thanks @mraszyk! Do you plan to revert the "work-around" again?

Comment thread rs/state_manager/src/lib.rs Resolved
Comment thread rs/state_manager/src/lib.rs Resolved
Comment thread rs/consensus/tests/framework/runner.rs Resolved
@mraszyk
mraszyk marked this pull request as draft April 20, 2026 10:21
Comment thread rs/determinism_test/src/setup.rs Resolved
Comment thread rs/replay/src/player.rs Resolved
@mraszyk
mraszyk requested a review from Copilot April 20, 2026 12:16

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

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
mraszyk marked this pull request as ready for review April 20, 2026 12:24
@mraszyk
mraszyk added this pull request to the merge queue Apr 22, 2026
Merged via the queue into master with commit 1a389f9 Apr 22, 2026
67 of 69 checks passed
@mraszyk
mraszyk deleted the mraszyk/certified-height-channel branch April 22, 2026 09:28
github-merge-queue Bot pushed a commit that referenced this pull request Apr 23, 2026
This PR reverts #9850 and
#8464 because the latter may have
introduced a bug. The former depends on the latter, so reverting them
together leads to the smallest conflict.
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