Skip to content

Commit

Permalink
Add activation delay when transitioning from LockedIn to Active (#3723)
Browse files Browse the repository at this point in the history
* Add activation delay when transitioning from LockedIn to Active

* Update doc with state machine auto gen graph

* Fix ComponentState serialization at locked in state

* Improve mip store raw deserializer context msg

* Fix test_factory_strategy_at unit test

* Clippy fixes

* Use >= instead of > for state update

* Use >= instead of > for state update (round 2)

---------

Co-authored-by: sydhds <sd@massa.net>
  • Loading branch information
sydhds and sydhds authored Mar 29, 2023
1 parent c033356 commit 6a334da
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 147 deletions.
4 changes: 4 additions & 0 deletions massa-versioning-worker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
//! * A state machine (stores the current state of deployment for a MipInfo)
//! * A history (stores a list of `Advance` message that 'really' updated the state machine)
//!
//! A auto generated graph of the state machine can be found here:
//! * dot -Tpng ./target/machine/componentstate.dot > ./target/machine/componentstate.png
//! * xdg-open ./target/machine/componentstate.png
//!
//! History is there in order to:
//! * Query the state at any time, so you can query MipStore and ask the best version at any time
//! * Used a lot when merging 2 MipStore:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::versioning::{Advance, ComponentState, MipInfo, MipState};
use massa_models::config::VERSIONING_THRESHOLD_TRANSITION_ACCEPTED;
use massa_time::MassaTime;

// TODO: rename versioning_info
pub fn advance_state_until(at_state: ComponentState, versioning_info: &MipInfo) -> MipState {
// A helper function to advance a state
// Assume enough time between versioning info start & timeout
Expand All @@ -26,6 +27,7 @@ pub fn advance_state_until(at_state: ComponentState, versioning_info: &MipInfo)
timeout,
threshold: Default::default(),
now: start.saturating_add(MassaTime::from(1)),
activation_delay: versioning_info.activation_delay,
};
state.on_advance(&advance_msg);

Expand All @@ -47,7 +49,11 @@ pub fn advance_state_until(at_state: ComponentState, versioning_info: &MipInfo)
return state;
}

advance_msg.now = timeout.saturating_add(MassaTime::from(1));
advance_msg.now = advance_msg
.now
.saturating_add(versioning_info.activation_delay)
.saturating_add(MassaTime::from(1));

state.on_advance(&advance_msg);
// Active
state
Expand Down
Loading

0 comments on commit 6a334da

Please sign in to comment.