Repository navigation
refactor(messaging): read the registry in the state machine - #12408
Open
pierugo-dfinity wants to merge 3 commits into
Open
pierugo-dfinity wants to merge 3 commits into
pierugo-dfinity wants to merge 3 commits into
Conversation
Move registry reading from `BatchProcessorImpl::process_batch()` into `StateMachineImpl::execute_round()`, behind a new `RegistryReader` trait (implemented by the existing reader, renamed to `RegistryReaderImpl`). `StateMachine::execute_round()` now only takes the state and the batch. `BatchProcessorImpl` no longer needs a registry (nor its `RegistryClient` type parameter), so its tests no longer set one up; the registry reading tests construct a `RegistryReaderImpl` directly; and the state machine tests use a mock `RegistryReader`. No functional changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the registry-read ownership refactor.
No open issues 🎉
What changed in this PR
Moves registry reads into the messaging state machine, preparing for the subnet-split metadata fix in #12409 without intended functional changes.
Changes:
- Introduces a
RegistryReadertrait owned byStateMachineImpl. - Simplifies
execute_round()to accept only state and batch, and relocates registry-read timing. - Separates registry-reader tests from batch-processor tests and adds mocked registry reads to state-machine tests.
| File | Description |
|---|---|
rs/messaging/src/state_machine/tests.rs |
Adds mock registry readers and checks registry records populate state. |
rs/messaging/src/state_machine.rs |
Owns the registry reader and reads records at round start. |
rs/messaging/src/message_routing/tests.rs |
Tests the registry reader directly and simplifies batch fixtures. |
rs/messaging/src/message_routing.rs |
Defines the reader trait and implementation; removes reader ownership from the batch processor. |
Review effort: Balanced
…t fixture `StateMachineTestFixture` now holds the registry reader, rather than the network topology that each test turned into one. The readers of `test_fixture()` and `checkpoint_round_fixture()` (which now takes the batch too) expect a single read, at the batch's registry version and for the own subnet, before any other mock is called. `fake_registry_reader()` is inlined into its one remaining caller, and `own_subnet_info()` now gives every subnet a different node. Also move the `registry_version` read in `process_batch()` next to the other values taken from the batch before it is consumed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he batch's version Rename `state_machine_populates_registry_records` to `state_machine_populates_registry_records_at_batch_registry_version` and have it use a registry version other than the `BatchBuilder` default, so that it checks that the registry is read at the batch's registry version (which `test_fixture()` expects). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pierugo-dfinity
force-pushed
the
pierugo/messaging/registry-reader-in-state-machine
branch
from
December 4, 2026 15:04
5d15831 to
6dc56df
Compare
pierugo-dfinity
marked this pull request as ready for review
December 4, 2026 15:33
|
✅ No security or compliance issues detected. Reviewed everything up to 6dc56df. Security OverviewDetected Code Changes
|
schneiderstefan
approved these changes
Dec 4, 2026
This branch has not been deployed
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.
Moves reading the registry from
BatchProcessorImpl::process_batch()intoStateMachineImpl::execute_round().This change is motivated by the stacked #12409 which reads the registry for the new subnet ID in case of a subnet-split, instead of doing it only in the next round. Though without the current PR, we would have to introduce a special case for splitting batches in
process_batch, whereas thanks to this change, we can read the registry inside the state machine'sonline_split.No functional changes, except that blockmaker metrics are now observed before reading the registry, and the time taken in the
read_registryphase is more accurately measured.We put the
RegistryReaderbehind a trait such that tests can mock it, instead of having to build an actual registry which saves a lot of test boilerplate code.🤖 Generated with Claude Code, trimmed by me