Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix versioning + Started + network restart #4824

Open
wants to merge 1 commit into
base: mainnet_2_3
Choose a base branch
from
Open
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
44 changes: 33 additions & 11 deletions massa-versioning/src/versioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(..) => {
Leo-Besancon marked this conversation as resolved.
Show resolved Hide resolved
// all good if it does not start / timeout during shutdown period
if shutdown_range.contains(&mip_info.start)
|| shutdown_range.contains(&mip_info.timeout)
Expand All @@ -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)
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand All @@ -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;
Expand Down
Loading