massa_versioning/
mips.rs

1#[allow(unused_imports)]
2use std::collections::BTreeMap;
3
4#[allow(unused_imports)]
5use massa_time::MassaTime;
6
7#[allow(unused_imports)]
8use crate::versioning::{MipComponent, MipInfo, MipState};
9
10/// `Execution` component version introduced by `MIP-0002-BugFix`.
11/// Single source of truth for gating features bundled into that MIP.
12pub const MIP_0002_EXECUTION_VERSION: u32 = 2;
13
14#[cfg(not(feature = "test-exports"))]
15pub fn get_mip_list() -> [(MipInfo, MipState); 2] {
16    // When the MIPs becomes defined, e.g. when merged to main branch
17    let defined_1 = MassaTime::from_utc_ymd_hms(2025, 5, 12, 10, 0, 0).unwrap(); // Monday 12th May 2025 10:00:00 UTC
18    let defined_2 = MassaTime::from_utc_ymd_hms(2026, 8, 3, 10, 0, 0).unwrap(); // Monday 3rd August 2026 10:00:00 UTC
19
20    let mip_list = [
21        (
22            MipInfo {
23                name: "MIP-0001-DeferredCalls-And-Execution-BugFix".to_string(),
24                version: 1,
25                components: BTreeMap::from([
26                    (MipComponent::Execution, 1),
27                    (MipComponent::FinalState, 1),
28                ]),
29                start: MassaTime::from_utc_ymd_hms(2025, 5, 19, 10, 0, 0).unwrap(), // Monday 19th May 2025 10:00:00 UTC
30                timeout: MassaTime::from_utc_ymd_hms(2025, 6, 19, 10, 0, 0).unwrap(), // Thursday 19th June 2025 10:00:00 UTC
31                activation_delay: MassaTime::from_millis(7 * 24 * 60 * 60 * 1000),    // 7 days
32            },
33            MipState::new(defined_1),
34        ),
35        (
36            MipInfo {
37                name: "MIP-0002-BugFix".to_string(),
38                version: 2,
39                components: BTreeMap::from([
40                    (MipComponent::Execution, MIP_0002_EXECUTION_VERSION),
41                    (MipComponent::FinalState, 2),
42                ]),
43                start: MassaTime::from_utc_ymd_hms(2026, 11, 11, 10, 0, 0).unwrap(), // Wednesday 11th November 2026 10:00:00 UTC
44                timeout: MassaTime::from_utc_ymd_hms(2026, 12, 31, 10, 0, 0).unwrap(), // Thursday 31st December 2026 10:00:00 UTC
45                activation_delay: MassaTime::from_millis(7 * 24 * 60 * 60 * 1000), // 7 days -> earliest activation Wednesday 18th November 2026 10:00:00 UTC
46            },
47            MipState::new(defined_2),
48        ),
49    ];
50
51    // debug!("MIP list: {:?}", mip_list);
52    #[allow(clippy::let_and_return)]
53    mip_list
54}
55
56#[cfg(feature = "test-exports")]
57pub fn get_mip_list() -> [(MipInfo, MipState); 2] {
58    use crate::{
59        test_helpers::versioning_helpers::advance_state_until,
60        versioning::{Active, ComponentState},
61    };
62
63    println!("Running with test-exports feature");
64
65    let mip_info_1 = MipInfo {
66        name: "MIP-0001-DeferredCalls-And-Execution-BugFix".to_string(),
67        version: 1,
68        components: BTreeMap::from([(MipComponent::Execution, 1), (MipComponent::FinalState, 1)]),
69        start: MassaTime::from_millis(2),
70        timeout: MassaTime::from_millis(10),
71        activation_delay: MassaTime::from_millis(2),
72    };
73    let mip_state_1 = advance_state_until(
74        ComponentState::Active(Active {
75            at: MassaTime::from_millis(3),
76        }),
77        &mip_info_1,
78    );
79
80    let mip_info_2 = MipInfo {
81        name: "MIP-0002-BugFix".to_string(),
82        version: 2,
83        components: BTreeMap::from([
84            (MipComponent::Execution, MIP_0002_EXECUTION_VERSION),
85            (MipComponent::FinalState, 2),
86        ]),
87        start: MassaTime::from_millis(12),
88        timeout: MassaTime::from_millis(20),
89        activation_delay: MassaTime::from_millis(2),
90    };
91    let mip_state_2 = advance_state_until(
92        ComponentState::Active(Active {
93            at: MassaTime::from_millis(13),
94        }),
95        &mip_info_2,
96    );
97
98    let mip_list = [(mip_info_1, mip_state_1), (mip_info_2, mip_state_2)];
99
100    println!("MIP list: {:?}", mip_list);
101    #[allow(clippy::let_and_return)]
102    mip_list
103}