hotshot_types/upgrade_config.rs
1// Copyright (c) 2021-2024 Espresso Systems (espressosys.com)
2// This file is part of the HotShot repository.
3
4// You should have received a copy of the MIT License
5// along with the HotShot repository. If not, see <https://mit-license.org/>.
6
7/// Constants associated with the upgrade process.
8pub struct UpgradeConstants {
9 /// The offset for how far in the future we will send out a `QuorumProposal` with an `UpgradeCertificate` we form. This is also how far in advance of sending a `QuorumProposal` we begin collecting votes on an `UpgradeProposal`.
10 pub propose_offset: u64,
11
12 /// The offset for how far in the future the upgrade certificate we attach should be decided on (or else discarded).
13 pub decide_by_offset: u64,
14
15 /// The offset for how far in the future the upgrade actually begins.
16 pub begin_offset: u64,
17
18 /// The offset for how far in the future the upgrade ends.
19 pub finish_offset: u64,
20}
21
22#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
23#[serde(bound(deserialize = ""))]
24/// Holds configuration for the upgrade task.
25pub struct UpgradeConfig {
26 /// View to start proposing an upgrade
27 pub start_proposing_view: u64,
28 /// View to stop proposing an upgrade. To prevent proposing an upgrade, set stop_proposing_view <= start_proposing_view.
29 pub stop_proposing_view: u64,
30 /// View to start voting on an upgrade
31 pub start_voting_view: u64,
32 /// View to stop voting on an upgrade. To prevent voting on an upgrade, set stop_voting_view <= start_voting_view.
33 pub stop_voting_view: u64,
34 /// Unix time in seconds at which we start proposing an upgrade
35 pub start_proposing_time: u64,
36 /// Unix time in seconds at which we stop proposing an upgrade. To prevent proposing an upgrade, set stop_proposing_time <= start_proposing_time.
37 pub stop_proposing_time: u64,
38 /// Unix time in seconds at which we start voting on an upgrade
39 pub start_voting_time: u64,
40 /// Unix time in seconds at which we stop voting on an upgrade. To prevent voting on an upgrade, set stop_voting_time <= start_voting_time.
41 pub stop_voting_time: u64,
42}
43
44// Explicitly implementing `Default` for clarity.
45#[allow(clippy::derivable_impls)]
46impl Default for UpgradeConfig {
47 fn default() -> Self {
48 UpgradeConfig {
49 start_proposing_view: u64::MAX,
50 stop_proposing_view: 0,
51 start_voting_view: u64::MAX,
52 stop_voting_view: 0,
53 start_proposing_time: u64::MAX,
54 stop_proposing_time: 0,
55 start_voting_time: u64::MAX,
56 stop_voting_time: 0,
57 }
58 }
59}