|
1 | 1 | use std::collections::HashSet;
|
2 | 2 |
|
3 | 3 | use fvm_shared::clock::ChainEpoch;
|
4 |
| -use fvm_shared::sector::{RegisteredPoStProof, RegisteredSealProof}; |
| 4 | +use fvm_shared::sector::{RegisteredPoStProof, RegisteredSealProof, StoragePower}; |
| 5 | +use num_traits::FromPrimitive; |
5 | 6 |
|
6 | 7 | // A trait for runtime policy configuration
|
7 | 8 | pub trait RuntimePolicy {
|
@@ -130,12 +131,27 @@ pub struct Policy {
|
130 | 131 |
|
131 | 132 | /// Allowed pre commit proof types for new miners
|
132 | 133 | pub valid_pre_commit_proof_type: HashSet<RegisteredSealProof>,
|
| 134 | + |
| 135 | + // --- verifreg policy |
| 136 | + /// Minimum verified deal size |
| 137 | + pub minimum_verified_deal_size: StoragePower, |
| 138 | + |
| 139 | + // --- market policy --- |
| 140 | + /// The number of blocks between payouts for deals |
| 141 | + pub deal_updates_interval: i64, |
| 142 | + |
| 143 | + /// Numerator of the percentage of normalized cirulating |
| 144 | + /// supply that must be covered by provider collateral |
| 145 | + pub prov_collateral_percent_supply_num: i64, |
| 146 | + |
| 147 | + /// Denominator of the percentage of normalized cirulating |
| 148 | + /// supply that must be covered by provider collateral |
| 149 | + pub prov_collateral_percent_supply_denom: i64, |
133 | 150 | }
|
134 | 151 |
|
135 | 152 | impl Default for Policy {
|
136 | 153 | fn default() -> Policy {
|
137 |
| - #[allow(unused_mut)] // for devnet mutation below |
138 |
| - let mut policy = Policy { |
| 154 | + Policy { |
139 | 155 | max_aggregated_sectors: policy_constants::MAX_AGGREGATED_SECTORS,
|
140 | 156 | min_aggregated_sectors: policy_constants::MIN_AGGREGATED_SECTORS,
|
141 | 157 | max_aggregated_proof_size: policy_constants::MAX_AGGREGATED_PROOF_SIZE,
|
@@ -195,9 +211,18 @@ impl Default for Policy {
|
195 | 211 | #[cfg(feature = "sector-64g")]
|
196 | 212 | RegisteredSealProof::StackedDRG64GiBV1P1,
|
197 | 213 | ]),
|
198 |
| - }; |
199 | 214 |
|
200 |
| - policy |
| 215 | + minimum_verified_deal_size: StoragePower::from_i32( |
| 216 | + policy_constants::MINIMUM_VERIFIED_DEAL_SIZE, |
| 217 | + ) |
| 218 | + .unwrap(), |
| 219 | + |
| 220 | + deal_updates_interval: policy_constants::DEAL_UPDATES_INTERVAL, |
| 221 | + prov_collateral_percent_supply_num: |
| 222 | + policy_constants::PROV_COLLATERAL_PERCENT_SUPPLY_NUM, |
| 223 | + prov_collateral_percent_supply_denom: |
| 224 | + policy_constants::PROV_COLLATERAL_PERCENT_SUPPLY_DENOM, |
| 225 | + } |
201 | 226 | }
|
202 | 227 | }
|
203 | 228 |
|
@@ -325,4 +350,23 @@ mod policy_constants {
|
325 | 350 | /// Epochs after which chain state is final with overwhelming probability (hence the likelihood of two fork of this size is negligible)
|
326 | 351 | /// This is a conservative value that is chosen via simulations of all known attacks.
|
327 | 352 | pub const CHAIN_FINALITY: ChainEpoch = 900;
|
| 353 | + |
| 354 | + #[cfg(not(feature = "small-deals"))] |
| 355 | + pub const MINIMUM_VERIFIED_DEAL_SIZE: i32 = 1 << 20; |
| 356 | + #[cfg(feature = "small-deals")] |
| 357 | + pub const MINIMUM_VERIFIED_DEAL_SIZE: i32 = 256; |
| 358 | + |
| 359 | + /// DealUpdatesInterval is the number of blocks between payouts for deals |
| 360 | + pub const DEAL_UPDATES_INTERVAL: i64 = EPOCHS_IN_DAY; |
| 361 | + |
| 362 | + /// Numerator of the percentage of normalized cirulating |
| 363 | + /// supply that must be covered by provider collateral |
| 364 | + #[cfg(not(feature = "no-provider-deal-collateral"))] |
| 365 | + pub const PROV_COLLATERAL_PERCENT_SUPPLY_NUM: i64 = 1; |
| 366 | + #[cfg(feature = "no-provider-deal-collateral")] |
| 367 | + pub const PROV_COLLATERAL_PERCENT_SUPPLY_NUM: i64 = 0; |
| 368 | + |
| 369 | + /// Denominator of the percentage of normalized cirulating |
| 370 | + /// supply that must be covered by provider collateral |
| 371 | + pub const PROV_COLLATERAL_PERCENT_SUPPLY_DENOM: i64 = 100; |
328 | 372 | }
|
0 commit comments