Skip to content

Commit

Permalink
Added v12 power actor
Browse files Browse the repository at this point in the history
  • Loading branch information
sudo-shashank committed Oct 4, 2023
1 parent 0f45394 commit 5042a49
Show file tree
Hide file tree
Showing 8 changed files with 826 additions and 3 deletions.
1 change: 1 addition & 0 deletions actors/power/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@

pub mod v10;
pub mod v11;
pub mod v12;
pub mod v8;
pub mod v9;
86 changes: 86 additions & 0 deletions actors/power/src/v12/ext.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Copyright 2019-2022 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use cid::Cid;
use fvm_ipld_encoding::tuple::*;
use fvm_ipld_encoding::{strict_bytes, BytesDe};

use fvm_shared3::address::Address;
use fvm_shared3::bigint::bigint_ser;
use fvm_shared3::sector::{RegisteredPoStProof, SectorNumber, StoragePower};
use fvm_shared3::smooth::FilterEstimate;
use fvm_shared3::METHOD_CONSTRUCTOR;
use num_derive::FromPrimitive;

pub mod init {
use super::*;
use fvm_ipld_encoding::RawBytes;

pub const EXEC_METHOD: u64 = 2;

/// Init actor Exec Params
#[derive(Serialize_tuple, Deserialize_tuple)]
pub struct ExecParams {
pub code_cid: Cid,
pub constructor_params: RawBytes,
}

/// Init actor Exec Return value
#[derive(Serialize_tuple, Deserialize_tuple)]
pub struct ExecReturn {
/// ID based address for created actor
pub id_address: Address,
/// Reorg safe address for actor
pub robust_address: Address,
}
}

pub mod miner {
use super::*;

pub const CONFIRM_SECTOR_PROOFS_VALID_METHOD: u64 = 17;
pub const ON_DEFERRED_CRON_EVENT_METHOD: u64 = 12;

#[derive(Serialize_tuple, Deserialize_tuple)]
pub struct ConfirmSectorProofsParams {
pub sectors: Vec<SectorNumber>,
pub reward_smoothed: FilterEstimate,
#[serde(with = "bigint_ser")]
pub reward_baseline_power: StoragePower,
pub quality_adj_power_smoothed: FilterEstimate,
}

#[derive(Serialize_tuple, Deserialize_tuple)]
pub struct MinerConstructorParams {
pub owner: Address,
pub worker: Address,
pub control_addresses: Vec<Address>,
pub window_post_proof_type: RegisteredPoStProof,
#[serde(with = "strict_bytes")]
pub peer_id: Vec<u8>,
pub multi_addresses: Vec<BytesDe>,
}

#[derive(Serialize_tuple, Deserialize_tuple)]
pub struct DeferredCronEventParams {
#[serde(with = "strict_bytes")]
pub event_payload: Vec<u8>,
pub reward_smoothed: FilterEstimate,
pub quality_adj_power_smoothed: FilterEstimate,
}
}

pub mod reward {
use super::*;

pub const UPDATE_NETWORK_KPI: u64 = 4;

#[derive(FromPrimitive)]
#[repr(u64)]
pub enum Method {
Constructor = METHOD_CONSTRUCTOR,
AwardBlockReward = 2,
ThisEpochReward = 3,
UpdateNetworkKPI = 4,
}
}
49 changes: 49 additions & 0 deletions actors/power/src/v12/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright 2019-2022 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use fvm_shared3::error::ExitCode;
use fvm_shared3::METHOD_CONSTRUCTOR;
use num_derive::FromPrimitive;

pub use self::policy::*;
pub use self::state::*;
pub use self::types::*;

#[doc(hidden)]
pub mod ext;
mod policy;
mod state;
mod types;

// * Updated to specs-actors commit: 999e57a151cc7ada020ca2844b651499ab8c0dec (v3.0.1)

/// GasOnSubmitVerifySeal is amount of gas charged for SubmitPoRepForBulkVerify
/// This number is empirically determined
pub mod detail {
pub const GAS_ON_SUBMIT_VERIFY_SEAL: i64 = 34721049;
}

/// Storage power actor methods available
#[derive(FromPrimitive)]
#[repr(u64)]
pub enum Method {
/// Constructor for Storage Power Actor
Constructor = METHOD_CONSTRUCTOR,
CreateMiner = 2,
UpdateClaimedPower = 3,
EnrollCronEvent = 4,
OnEpochTickEnd = 5,
UpdatePledgeTotal = 6,
// * Deprecated in v2
// OnConsensusFault = 7,
SubmitPoRepForBulkVerify = 8,
CurrentTotalPower = 9,
// Method numbers derived from FRC-0042 standards
CreateMinerExported = frc42_macros::method_hash!("CreateMiner"),
NetworkRawPowerExported = frc42_macros::method_hash!("NetworkRawPower"),
MinerRawPowerExported = frc42_macros::method_hash!("MinerRawPower"),
MinerCountExported = frc42_macros::method_hash!("MinerCount"),
MinerConsensusCountExported = frc42_macros::method_hash!("MinerConsensusCount"),
}

pub const ERR_TOO_MANY_PROVE_COMMITS: ExitCode = ExitCode::new(32);
13 changes: 13 additions & 0 deletions actors/power/src/v12/policy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2019-2022 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

/// Minimum power of an individual miner to meet the threshold for leader election.
pub const CONSENSUS_MINER_MIN_MINERS: i64 = 4;

/// Maximum number of prove commits a miner can submit in one epoch
///
/// We bound this to 200 to limit the number of prove partitions we may need to update in a
/// given epoch to 200.
///
/// To support onboarding 1EiB/year, we need to allow at least 32 prove commits per epoch.
pub const MAX_MINER_PROVE_COMMITS_PER_EPOCH: u64 = 200;
Loading

0 comments on commit 5042a49

Please sign in to comment.