test: [DSM-126] Add synchronous commit_and_certify for tests#10131
Open
michael-weigelt wants to merge 2 commits intomasterfrom
Open
test: [DSM-126] Add synchronous commit_and_certify for tests#10131michael-weigelt wants to merge 2 commits intomasterfrom
michael-weigelt wants to merge 2 commits intomasterfrom
Conversation
| ); | ||
|
|
||
| /// Testing only: Like `commit_and_certify_at_height`, but waits for hashing/certification metadata. | ||
| fn commit_and_certify_at_height_sync( |
Contributor
There was a problem hiding this comment.
Can these also be used in the state_machine_tests crate and/or pocket_ic?
| ); | ||
| } | ||
|
|
||
| fn fetch_state_sync( |
Contributor
There was a problem hiding this comment.
That is an unfortunate name, because it's simultaneously not related to state sync and kinda is.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces synchronous, test-only wrappers around StateManagerImpl operations that previously required explicit flush_hash_channel() calls, and updates state manager integration tests to use these wrappers for determinism.
Changes:
- Add
commit_and_certify_sync,commit_and_certify_at_height_sync, andfetch_state_synctoic_state_manager::testing::StateManagerTesting. - Implement these wrappers for
StateManagerImplby delegating to the existing async methods and then flushing the hash channel. - Refactor
rs/state_manager/tests/state_manager.rsto replacecommit_and_certify/commit_and_certify_at_height+flush_hash_channelcall pairs with the new synchronous helpers.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 10 comments.
| File | Description |
|---|---|
| rs/state_manager/tests/state_manager.rs | Replaces explicit hash-channel flushing patterns with new synchronous test helpers. |
| rs/state_manager/src/lib.rs | Adds and implements synchronous test-only helpers that flush the hash channel after committing/fetching. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+4456
to
+4460
| batch_summary: Option<BatchSummary>, | ||
| ) { | ||
| self.commit_and_certify(state, scope, batch_summary); | ||
| self.flush_hash_channel(); | ||
| } |
| batch_summary: Option<BatchSummary>, | ||
| ) { | ||
| self.commit_and_certify_at_height(state, height, scope, batch_summary); | ||
| self.flush_hash_channel(); |
Comment on lines
+4370
to
+4374
| /// Testing only: Commits, then waits for hashing/certification metadata to be populated. | ||
| fn commit_and_certify_sync( | ||
| &self, | ||
| state: ReplicatedState, | ||
| scope: CertificationScope, |
Comment on lines
6355
to
+6359
| for _i in 2..(divergence + 1) { | ||
| let (_height, state) = state_manager.take_tip(); | ||
| state_manager.commit_and_certify(state, CertificationScope::Metadata, None); | ||
| if _i == divergence { | ||
| state_manager.commit_and_certify_sync(state, CertificationScope::Metadata, None); | ||
| } else { |
Comment on lines
1503
to
+1507
| } else { | ||
| CertificationScope::Metadata | ||
| }; | ||
|
|
||
| state_manager.commit_and_certify(state, scope.clone(), None); | ||
| state_manager.commit_and_certify_sync(state, scope.clone(), None); |
Comment on lines
1566
to
+1570
| } else { | ||
| CertificationScope::Metadata | ||
| }; | ||
|
|
||
| state_manager.commit_and_certify(state, scope.clone(), None); | ||
| state_manager.commit_and_certify_sync(state, scope.clone(), None); |
| }; | ||
|
|
||
| state_manager.commit_and_certify(state, scope.clone(), None); | ||
| state_manager.commit_and_certify_sync(state, scope.clone(), None); |
| }; | ||
|
|
||
| state_manager.commit_and_certify(state, scope.clone(), None); | ||
| state_manager.commit_and_certify_sync(state, scope.clone(), None); |
Comment on lines
1916
to
+1921
| CertificationScope::Full | ||
| } else { | ||
| CertificationScope::Metadata | ||
| }; | ||
|
|
||
| state_manager.commit_and_certify(state, scope.clone(), None); | ||
| state_manager.commit_and_certify_sync(state, scope.clone(), None); |
Comment on lines
+1995
to
1996
| state_manager.commit_and_certify_sync(state, scope.clone(), None); | ||
| } |
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.
Co-authored by Claude