Skip to content

Commit 0f505e1

Browse files
Merge branch 'alin/MR-439-use-state-sync-v3' into 'master'
feat: [MR-439] Use `StateSyncVersion::V3` Default to file index independent (i.e. content only) file hashes in state manifests. See merge request dfinity-lab/public/ic!12561
2 parents 2db445a + 8cad074 commit 0f505e1

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

rs/state_manager/src/manifest/tests/computation.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,24 +1164,24 @@ fn test_file_index_independent_file_hash() {
11641164

11651165
let (file1_hash_v2_before, file3_hash_v2_before) =
11661166
compute_file1_and_file3_hashes(StateSyncVersion::V2);
1167-
let (file1_hash_v3_before, file3_hash_v3_before) =
1168-
compute_file1_and_file3_hashes(StateSyncVersion::V3);
1167+
let (file1_hash_before, file3_hash_before) =
1168+
compute_file1_and_file3_hashes(CURRENT_STATE_SYNC_VERSION);
11691169

11701170
// Directory now contains `file1`, `file2` and `file3`.
11711171
fs::write(root.join(&file2), vec![2u8; 1000])
11721172
.unwrap_or_else(|_| panic!("failed to create file '{}'", file2.display()));
11731173

11741174
let (file1_hash_v2_after, file3_hash_v2_after) =
11751175
compute_file1_and_file3_hashes(StateSyncVersion::V2);
1176-
let (file1_hash_v3_after, file3_hash_v3_after) =
1177-
compute_file1_and_file3_hashes(StateSyncVersion::V3);
1176+
let (file1_hash_after, file3_hash_after) =
1177+
compute_file1_and_file3_hashes(CURRENT_STATE_SYNC_VERSION);
11781178

11791179
// The `file1` `V2` hashes should be equal (same contents, same file index).
11801180
assert_eq!(file1_hash_v2_before, file1_hash_v2_after);
11811181
// But the `file3` `V2` hashes should be different (different file index).
11821182
assert_ne!(file3_hash_v2_before, file3_hash_v2_after);
11831183

11841184
// And the `V3` hashes should be the same, regardless of file index.
1185-
assert_eq!(file1_hash_v3_before, file1_hash_v3_after);
1186-
assert_eq!(file3_hash_v3_before, file3_hash_v3_after);
1185+
assert_eq!(file1_hash_before, file1_hash_after);
1186+
assert_eq!(file3_hash_before, file3_hash_after);
11871187
}

rs/state_manager/src/split/tests.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use ic_types::{
2727
ingress::{IngressState, IngressStatus},
2828
malicious_flags::MaliciousFlags,
2929
messages::MessageId,
30-
state_sync::{FileInfo, Manifest, StateSyncVersion},
30+
state_sync::{FileInfo, Manifest, CURRENT_STATE_SYNC_VERSION},
3131
Cycles, Height,
3232
};
3333
use std::{path::Path, sync::Arc};
@@ -125,7 +125,7 @@ fn read_write_roundtrip() {
125125
// Compute the manifest of the original checkpoint.
126126
let metrics = StateManagerMetrics::new(&metrics_registry);
127127
let manifest_metrics = &metrics.manifest_metrics;
128-
let (manifest_before, height_before) = compute_manifest_v3(&layout, manifest_metrics, &log);
128+
let (manifest_before, height_before) = compute_manifest(&layout, manifest_metrics, &log);
129129

130130
// Read the latest checkpoint into a state.
131131
let fd_factory = Arc::new(TestPageAllocatorFileDescriptorImpl::new());
@@ -150,7 +150,7 @@ fn read_write_roundtrip() {
150150
assert_eq!(2, layout.checkpoint_heights().unwrap().len());
151151

152152
// Compute the manifest of the newly written checkpoint.
153-
let (manifest_after, height_after) = compute_manifest_v3(&layout, manifest_metrics, &log);
153+
let (manifest_after, height_after) = compute_manifest(&layout, manifest_metrics, &log);
154154

155155
// The two checkpoints' manifests should be identical.
156156
assert_eq!(manifest_before, manifest_after);
@@ -168,7 +168,7 @@ fn split_subnet_a_prime() {
168168
let tmp = new_state_layout(log.clone());
169169
let root = tmp.path().to_path_buf();
170170

171-
let (manifest_a, height_a) = compute_manifest_v3_for_root(&root, &log);
171+
let (manifest_a, height_a) = compute_manifest_for_root(&root, &log);
172172
assert_eq!(SUBNET_A_FILES, manifest_files(&manifest_a).as_slice());
173173

174174
split(
@@ -180,7 +180,7 @@ fn split_subnet_a_prime() {
180180
)
181181
.unwrap();
182182

183-
let (manifest_a_prime, height_a_prime) = compute_manifest_v3_for_root(&root, &log);
183+
let (manifest_a_prime, height_a_prime) = compute_manifest_for_root(&root, &log);
184184
assert_eq!(
185185
SUBNET_A_PRIME_FILES,
186186
manifest_files(&manifest_a_prime).as_slice()
@@ -213,7 +213,7 @@ fn split_subnet_b() {
213213
let tmp = new_state_layout(log.clone());
214214
let root = tmp.path().to_path_buf();
215215

216-
let (manifest_a, height_a) = compute_manifest_v3_for_root(&root, &log);
216+
let (manifest_a, height_a) = compute_manifest_for_root(&root, &log);
217217
assert_eq!(SUBNET_A_FILES, manifest_files(&manifest_a).as_slice());
218218

219219
split(
@@ -225,7 +225,7 @@ fn split_subnet_b() {
225225
)
226226
.unwrap();
227227

228-
let (manifest_b, height_b) = compute_manifest_v3_for_root(&root, &log);
228+
let (manifest_b, height_b) = compute_manifest_for_root(&root, &log);
229229
assert_eq!(SUBNET_B_FILES, manifest_files(&manifest_b).as_slice());
230230

231231
// Checkpoint heights should differ by 1.
@@ -353,8 +353,8 @@ fn new_state_layout(log: ReplicaLogger) -> TempDir {
353353
tmp
354354
}
355355

356-
/// Computes the `V3` manifest of the last checkpoint under `state_layout`.
357-
fn compute_manifest_v3(
356+
/// Computes the manifest of the last checkpoint under `state_layout`.
357+
fn compute_manifest(
358358
state_layout: &StateLayout,
359359
manifest_metrics: &ManifestMetrics,
360360
log: &ReplicaLogger,
@@ -365,7 +365,7 @@ fn compute_manifest_v3(
365365
&mut thread_pool(),
366366
manifest_metrics,
367367
log,
368-
StateSyncVersion::V3,
368+
CURRENT_STATE_SYNC_VERSION,
369369
&last_checkpoint_layout,
370370
1024,
371371
None,
@@ -405,16 +405,16 @@ fn file_info<'a>(file: &str, manifest: &'a Manifest) -> &'a FileInfo {
405405
panic!("file '{}' not found in manifest: {:?}", file, manifest)
406406
}
407407

408-
/// Computes the V3 manifest of the latest checkpoint under the state layout at
408+
/// Computes the manifest of the latest checkpoint under the state layout at
409409
/// `root`.
410-
fn compute_manifest_v3_for_root(root: &Path, log: &ReplicaLogger) -> (Manifest, Height) {
410+
fn compute_manifest_for_root(root: &Path, log: &ReplicaLogger) -> (Manifest, Height) {
411411
let metrics_registry = MetricsRegistry::new();
412412
let layout = StateLayout::try_new(log.clone(), root.to_path_buf(), &metrics_registry).unwrap();
413413

414414
// Compute the manifest of the original checkpoint.
415415
let metrics = StateManagerMetrics::new(&metrics_registry);
416416
let manifest_metrics = &metrics.manifest_metrics;
417-
compute_manifest_v3(&layout, manifest_metrics, log)
417+
compute_manifest(&layout, manifest_metrics, log)
418418
}
419419

420420
fn deserialize_split_from(root: &Path, height: Height) -> SubnetId {

rs/types/types/src/state_sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl Display for StateSyncVersion {
164164
}
165165

166166
/// The version of StateSync protocol that should be used for all newly created manifests.
167-
pub const CURRENT_STATE_SYNC_VERSION: StateSyncVersion = StateSyncVersion::V2;
167+
pub const CURRENT_STATE_SYNC_VERSION: StateSyncVersion = StateSyncVersion::V3;
168168

169169
/// Maximum supported StateSync version.
170170
///

0 commit comments

Comments
 (0)