forest/shim/actors/builtin/power/
ext.rs

1// Copyright 2019-2025 ChainSafe Systems
2// SPDX-License-Identifier: Apache-2.0, MIT
3
4use crate::shim::actors::power::State;
5use crate::shim::clock::ChainEpoch;
6
7pub trait PowerStateExt {
8    /// `FIP0081` activation epoch. Should be same as `TukTuk` epoch.
9    fn ramp_start_epoch(&self) -> ChainEpoch;
10    /// `FIP0081` activation ramp. One year on mainnet, 3 days on calibnet,
11    /// defaults to 200 epochs on devnet. Only applicable to `v15` (aka `TukTuk`)
12    /// actors.
13    fn ramp_duration_epochs(&self) -> u64;
14}
15
16impl PowerStateExt for State {
17    fn ramp_start_epoch(&self) -> ChainEpoch {
18        match self {
19            State::V15(st) => st.ramp_start_epoch,
20            State::V16(st) => st.ramp_start_epoch,
21            State::V17(st) => st.ramp_start_epoch,
22            _ => 0,
23        }
24    }
25
26    fn ramp_duration_epochs(&self) -> u64 {
27        match self {
28            State::V15(st) => st.ramp_duration_epochs,
29            State::V16(st) => st.ramp_duration_epochs,
30            State::V17(st) => st.ramp_duration_epochs,
31            _ => 0,
32        }
33    }
34}