From b16009e72795568d52ccc572e93c41388ac460bb Mon Sep 17 00:00:00 2001 From: sydhds Date: Wed, 15 Jan 2025 19:04:57 +0100 Subject: [PATCH] Fix versioning + Started + network restart --- massa-versioning/src/versioning.rs | 44 ++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/massa-versioning/src/versioning.rs b/massa-versioning/src/versioning.rs index 6eaaa6cf67..07f2994f63 100644 --- a/massa-versioning/src/versioning.rs +++ b/massa-versioning/src/versioning.rs @@ -1190,7 +1190,9 @@ impl MipStoreRaw { for (mip_info, mip_state) in &self.store { match mip_state.state { - ComponentState::Defined(..) => { + ComponentState::Defined(..) + | ComponentState::Started(..) + | ComponentState::LockedIn(..) => { // all good if it does not start / timeout during shutdown period if shutdown_range.contains(&mip_info.start) || shutdown_range.contains(&mip_info.timeout) @@ -1205,16 +1207,6 @@ impl MipStoreRaw { break; } } - ComponentState::Started(..) | ComponentState::LockedIn(..) => { - // assume this should have been reset - has_error = Err(IsConsistentWithShutdownPeriodError::NonConsistent( - mip_info.clone(), - mip_state.state, - shutdown_start_ts, - shutdown_end_ts, - )); - break; - } _ => { // active / failed, error, nothing to do // locked in, nothing to do (might go from 'locked in' to 'active' during shutdown) @@ -2393,6 +2385,9 @@ mod test { let ms_1 = advance_state_until(ComponentState::defined(), &mi_1); let ms_2 = advance_state_until(ComponentState::defined(), &mi_2); + assert_eq!(ms_1, ComponentState::defined()); + assert_eq!(ms_2, ComponentState::defined()); + let mut store = MipStoreRaw::try_from(( [(mi_1.clone(), ms_1), (mi_2.clone(), ms_2)], mip_stats_cfg.clone(), @@ -2420,6 +2415,8 @@ mod test { let ms_1 = advance_state_until(ComponentState::defined(), &mi_1); let ms_2 = advance_state_until(ComponentState::defined(), &mi_2); + assert_eq!(ms_1, ComponentState::defined()); + assert_eq!(ms_2, ComponentState::defined()); let mut store = MipStoreRaw::try_from(( [(mi_1.clone(), ms_1), (mi_2.clone(), ms_2)], mip_stats_cfg.clone(), @@ -2447,6 +2444,8 @@ mod test { let ms_1 = advance_state_until(ComponentState::started(Ratio::zero()), &mi_1); let ms_2 = advance_state_until(ComponentState::defined(), &mi_2); + assert_eq!(ms_1, ComponentState::started(Ratio::zero())); + assert_eq!(ms_2, ComponentState::defined()); let mut store = MipStoreRaw::try_from(( [(mi_1.clone(), ms_1), (mi_2.clone(), ms_2)], mip_stats_cfg.clone(), @@ -2462,6 +2461,29 @@ mod test { // _dump_store(&store); } + // MipInfo 1 @ state 'Started' after shutdown + { + mi_1.start = get_slot_ts(Slot::new(9, 2)); + mi_1.timeout = get_slot_ts(Slot::new(10, 7)); + mi_2.start = get_slot_ts(Slot::new(11, 4)); + mi_2.timeout = get_slot_ts(Slot::new(12, 0)); + + let ms_1 = advance_state_until(ComponentState::started(Ratio::zero()), &mi_1); + let ms_2 = advance_state_until(ComponentState::defined(), &mi_2); + assert_eq!(ms_1, ComponentState::started(Ratio::zero())); + assert_eq!(ms_2, ComponentState::defined()); + let mut store = MipStoreRaw::try_from(( + [(mi_1.clone(), ms_1), (mi_2.clone(), ms_2)], + mip_stats_cfg.clone(), + )) + .unwrap(); + + assert!(is_consistent(&store, shutdown_start, shutdown_end).is_ok()); + update_store(&mut store, shutdown_start, shutdown_end); + assert!(is_consistent(&store, shutdown_start, shutdown_end).is_ok()); + // _dump_store(&store); + } + // MipInfo 1 @ state 'LockedIn' with transition during shutdown { let shutdown_range = shutdown_start..=shutdown_end;