Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions rs/state_manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4358,6 +4358,23 @@ pub mod testing {
batch_summary: Option<BatchSummary>,
);

/// Testing only: Like `commit_and_certify_at_height`, but waits for hashing/certification metadata.
fn commit_and_certify_at_height_sync(
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.

Can these also be used in the state_machine_tests crate and/or pocket_ic?

&self,
state: ReplicatedState,
height: Height,
scope: CertificationScope,
batch_summary: Option<BatchSummary>,
);

/// 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 +4370 to +4374
batch_summary: Option<BatchSummary>,
);

/// Testing only: Purges the `manifest` at `height` in `states.states_metadata`.
fn purge_manifest(&mut self, height: Height) -> bool;

Expand Down Expand Up @@ -4390,6 +4407,14 @@ pub mod testing {

/// Testing only: Push state
fn push_state_and_cert_metadata(&self, height: Height, state: ReplicatedState);

/// Testing only: Like `fetch_state`, but waits for hashing/certification metadata.
fn fetch_state_sync(
&self,
height: Height,
root_hash: CryptoHashOfState,
cup_interval_length: Height,
);
}

impl StateManagerTesting for StateManagerImpl {
Expand All @@ -4413,6 +4438,27 @@ pub mod testing {
self.commit_and_certify(state, scope, batch_summary);
}

fn commit_and_certify_at_height_sync(
&self,
state: ReplicatedState,
height: Height,
scope: CertificationScope,
batch_summary: Option<BatchSummary>,
) {
self.commit_and_certify_at_height(state, height, scope, batch_summary);
self.flush_hash_channel();
}

fn commit_and_certify_sync(
&self,
state: ReplicatedState,
scope: CertificationScope,
batch_summary: Option<BatchSummary>,
) {
self.commit_and_certify(state, scope, batch_summary);
self.flush_hash_channel();
}
Comment on lines +4456 to +4460

fn purge_manifest(&mut self, height: Height) -> bool {
let mut guard = self.states.write();
let purged = match guard.states_metadata.get_mut(&height) {
Expand Down Expand Up @@ -4508,5 +4554,15 @@ pub mod testing {
&mut states,
);
}

fn fetch_state_sync(
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.

That is an unfortunate name, because it's simultaneously not related to state sync and kinda is.

&self,
height: Height,
root_hash: CryptoHashOfState,
cup_interval_length: Height,
) {
self.fetch_state(height, root_hash, cup_interval_length);
self.flush_hash_channel();
}
}
}
Loading
Loading