Skip to content

Commit ad4470f

Browse files
authored
Remove duplicated comments in policy values (#1350)
1 parent 0679eec commit ad4470f

File tree

1 file changed

+40
-93
lines changed

1 file changed

+40
-93
lines changed

runtime/src/runtime/policy.rs

Lines changed: 40 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ pub struct Policy {
2121
pub max_replica_update_proof_size: usize,
2222

2323
/// The maximum number of sector pre-commitments in a single batch.
24-
/// 32 sectors per epoch would support a single miner onboarding 1EiB of 32GiB sectors in 1 year.
2524
pub pre_commit_sector_batch_max_size: usize,
2625
/// The maximum number of sector replica updates in a single batch.
2726
pub prove_replica_updates_max_size: usize,
@@ -49,25 +48,19 @@ pub struct Policy {
4948
pub sectors_max: usize,
5049

5150
/// Maximum number of partitions that will be assigned to a deadline.
52-
/// For a minimum storage of upto 1Eib, we need 300 partitions per deadline.
53-
/// 48 * 32GiB * 2349 * 300 = 1.00808144 EiB
54-
/// So, to support upto 10Eib storage, we set this to 3000.
5551
pub max_partitions_per_deadline: u64,
5652

5753
/// Maximum number of control addresses a miner may register.
5854
pub max_control_addresses: usize,
5955

6056
/// MaxPeerIDLength is the maximum length allowed for any on-chain peer ID.
61-
/// Most Peer IDs are expected to be less than 50 bytes.
6257
pub max_peer_id_length: usize,
6358

6459
/// MaxMultiaddrData is the maximum amount of data that can be stored in multiaddrs.
6560
pub max_multiaddr_data: usize,
6661

6762
/// The maximum number of partitions that may be required to be loaded in a single invocation.
6863
/// This limits the number of simultaneous fault, recovery, or sector-extension declarations.
69-
/// With 48 deadlines (half-hour), 200 partitions per declaration permits loading a full EiB of 32GiB
70-
/// sectors with 1 message per epoch within a single half-hour deadline. A miner can of course submit more messages.
7164
pub addressed_partitions_max: u64,
7265

7366
/// Maximum number of unique "declarations" in batch operations.
@@ -83,24 +76,15 @@ pub struct Policy {
8376
pub pre_commit_challenge_delay: ChainEpoch,
8477

8578
/// Lookback from the deadline's challenge window opening from which to sample chain randomness for the challenge seed.
86-
87-
/// This lookback exists so that deadline windows can be non-overlapping (which make the programming simpler)
88-
/// but without making the miner wait for chain stability before being able to start on PoSt computation.
89-
/// The challenge is available this many epochs before the window is actually open to receiving a PoSt.
9079
pub wpost_challenge_lookback: ChainEpoch,
9180

9281
/// Minimum period before a deadline's challenge window opens that a fault must be declared for that deadline.
93-
/// This lookback must not be less than WPoStChallengeLookback lest a malicious miner be able to selectively declare
94-
/// faults after learning the challenge value.
9582
pub fault_declaration_cutoff: ChainEpoch,
9683

9784
/// The maximum age of a fault before the sector is terminated.
9885
pub fault_max_age: ChainEpoch,
9986

10087
/// Staging period for a miner worker key change.
101-
/// Finality is a harsh delay for a miner who has lost their worker key, as the miner will miss Window PoSts until
102-
/// it can be changed. It's the only safe value, though. We may implement a mitigation mechanism such as a second
103-
/// key or allowing the owner account to submit PoSts while a key change is pending.
10488
pub worker_key_change_delay: ChainEpoch,
10589

10690
/// Minimum number of epochs past the current epoch a sector may be set to expire.
@@ -112,8 +96,7 @@ pub struct Policy {
11296
pub max_sector_expiration_extension: i64,
11397

11498
/// Ratio of sector size to maximum deals per sector.
115-
/// The maximum number of deals is the sector size divided by this number (2^27)
116-
/// which limits 32GiB sectors to 256 deals and 64GiB sectors to 512
99+
/// The maximum number of deals is the sector size divided by this number.
117100
pub deal_limit_denominator: u64,
118101

119102
/// Number of epochs after a consensus fault for which a miner is ineligible
@@ -123,8 +106,8 @@ pub struct Policy {
123106
/// The maximum number of new sectors that may be staged by a miner during a single proving period.
124107
pub new_sectors_per_period_max: usize,
125108

126-
/// Epochs after which chain state is final with overwhelming probability (hence the likelihood of two fork of this size is negligible)
127-
/// This is a conservative value that is chosen via simulations of all known attacks.
109+
/// Epochs after which chain state is final with overwhelming probability
110+
/// (hence the likelihood of two fork of this size is negligible).
128111
pub chain_finality: ChainEpoch,
129112

130113
/// Allowed post proof types for new miners
@@ -235,133 +218,96 @@ pub mod policy_constants {
235218

236219
use crate::builtin::*;
237220

238-
/// Maximum amount of sectors that can be aggregated.
221+
// See comments on Policy struct.
239222
pub const MAX_AGGREGATED_SECTORS: u64 = 819;
240-
/// Minimum amount of sectors that can be aggregated.
223+
241224
pub const MIN_AGGREGATED_SECTORS: u64 = 4;
242-
/// Maximum total aggregated proof size.
225+
243226
pub const MAX_AGGREGATED_PROOF_SIZE: usize = 81960;
244-
/// Maximum total aggregated proof size.
227+
245228
pub const MAX_REPLICA_UPDATE_PROOF_SIZE: usize = 4096;
246229

247-
/// The maximum number of sector pre-commitments in a single batch.
248-
/// 32 sectors per epoch would support a single miner onboarding 1EiB of 32GiB sectors in 1 year.
230+
// 32 sectors per epoch would support a single miner onboarding 1EiB of 32GiB sectors in 1 year.
249231
pub const PRE_COMMIT_SECTOR_BATCH_MAX_SIZE: usize = 256;
250232

251-
/// The maximum number of sector replica updates in a single batch.
252-
/// Same as PRE_COMMIT_SECTOR_BATCH_MAX_SIZE for consistency
233+
// Same as PRE_COMMIT_SECTOR_BATCH_MAX_SIZE for consistency.
253234
pub const PROVE_REPLICA_UPDATES_MAX_SIZE: usize = PRE_COMMIT_SECTOR_BATCH_MAX_SIZE;
254235

255-
/// The delay between pre commit expiration and clean up from state. This enforces that expired pre-commits
256-
/// stay in state for a period of time creating a grace period during which a late-running aggregated prove-commit
257-
/// can still prove its non-expired precommits without resubmitting a message
258236
pub const EXPIRED_PRE_COMMIT_CLEAN_UP_DELAY: i64 = 8 * EPOCHS_IN_HOUR;
259237

260-
/// The period over which all a miner's active sectors will be challenged.
261238
pub const WPOST_PROVING_PERIOD: ChainEpoch = EPOCHS_IN_DAY;
262-
/// The duration of a deadline's challenge window, the period before a deadline when the challenge is available.
263-
// Half an hour (=48 per day)
239+
240+
// Half an hour (=48 per day).
241+
// This must be consistent with WPOST_PERIOD_DEADLINES.
264242
pub const WPOST_CHALLENGE_WINDOW: ChainEpoch = 30 * 60 / EPOCH_DURATION_SECONDS;
265-
/// The number of non-overlapping PoSt deadlines in each proving period.
243+
244+
// This must be consistent with WPOST_CHALLENGE_WINDOW.
266245
pub const WPOST_PERIOD_DEADLINES: u64 = 48;
267-
/// The maximum distance back that a valid Window PoSt must commit to the current chain.
246+
268247
pub const WPOST_MAX_CHAIN_COMMIT_AGE: ChainEpoch = WPOST_CHALLENGE_WINDOW;
269-
// WPoStDisputeWindow is the period after a challenge window ends during which
270-
// PoSts submitted during that period may be disputed.
248+
271249
pub const WPOST_DISPUTE_WINDOW: ChainEpoch = 2 * CHAIN_FINALITY;
272250

273-
/// The maximum number of sectors that a miner can have simultaneously active.
274-
/// This also bounds the number of faults that can be declared, etc.
275251
pub const SECTORS_MAX: usize = 32 << 20;
276252

277-
/// Maximum number of partitions that will be assigned to a deadline.
278-
/// For a minimum storage of upto 1Eib, we need 300 partitions per deadline.
279-
/// 48 * 32GiB * 2349 * 300 = 1.00808144 EiB
280-
/// So, to support upto 10Eib storage, we set this to 3000.
253+
// For a minimum storage of upto 1Eib, we need 300 partitions per deadline.
254+
// 48 * 32GiB * 2349 * 300 = 1.00808144 EiB
255+
// So, to support upto 10Eib storage, we set this to 3000.
281256
pub const MAX_PARTITIONS_PER_DEADLINE: u64 = 3000;
282257

283-
/// Maximum number of control addresses a miner may register.
284258
pub const MAX_CONTROL_ADDRESSES: usize = 10;
285259

286-
/// MaxPeerIDLength is the maximum length allowed for any on-chain peer ID.
287-
/// Most Peer IDs are expected to be less than 50 bytes.
260+
// Most Peer IDs are expected to be less than 50 bytes.
288261
pub const MAX_PEER_ID_LENGTH: usize = 128;
289262

290-
/// MaxMultiaddrData is the maximum amount of data that can be stored in multiaddrs.
291263
pub const MAX_MULTIADDR_DATA: usize = 1024;
292264

293-
/// The maximum number of partitions that may be required to be loaded in a single invocation.
294-
/// This limits the number of simultaneous fault, recovery, or sector-extension declarations.
295-
/// With 48 deadlines (half-hour), 200 partitions per declaration permits loading a full EiB of 32GiB
296-
/// sectors with 1 message per epoch within a single half-hour deadline. A miner can of course submit more messages.
265+
// With 48 deadlines (half-hour), 300 partitions per declaration permits addressing a full EiB
266+
// of partitions of 32GiB sectors with 1 message per epoch within a single half-hour deadline.
267+
// A miner can of course submit more messages.
297268
pub const ADDRESSED_PARTITIONS_MAX: u64 = MAX_PARTITIONS_PER_DEADLINE;
298269

299-
/// Maximum number of unique "declarations" in batch operations.
300270
pub const DECLARATIONS_MAX: u64 = ADDRESSED_PARTITIONS_MAX;
301271

302-
/// The maximum number of sector infos that may be required to be loaded in a single invocation.
303272
pub const ADDRESSED_SECTORS_MAX: u64 = 25_000;
304273

305274
pub const MAX_PRE_COMMIT_RANDOMNESS_LOOKBACK: ChainEpoch = EPOCHS_IN_DAY + CHAIN_FINALITY;
306275

307-
/// Number of epochs between publishing the precommit and when the challenge for interactive PoRep is drawn
308-
/// used to ensure it is not predictable by miner.
309276
#[cfg(not(feature = "short-precommit"))]
310277
pub const PRE_COMMIT_CHALLENGE_DELAY: ChainEpoch = 150;
311278
#[cfg(feature = "short-precommit")]
312279
pub const PRE_COMMIT_CHALLENGE_DELAY: ChainEpoch = 10;
313280

314-
/// Lookback from the deadline's challenge window opening from which to sample chain randomness for the challenge seed.
315-
316-
/// This lookback exists so that deadline windows can be non-overlapping (which make the programming simpler)
317-
/// but without making the miner wait for chain stability before being able to start on PoSt computation.
318-
/// The challenge is available this many epochs before the window is actually open to receiving a PoSt.
281+
// This lookback exists so that deadline windows can be non-overlapping (which make the programming simpler)
282+
// but without making the miner wait for chain stability before being able to start on PoSt computation.
283+
// The challenge is available this many epochs before the window is actually open to receiving a PoSt.
319284
pub const WPOST_CHALLENGE_LOOKBACK: ChainEpoch = 20;
320285

321-
/// Minimum period before a deadline's challenge window opens that a fault must be declared for that deadline.
322-
/// This lookback must not be less than WPoStChallengeLookback lest a malicious miner be able to selectively declare
323-
/// faults after learning the challenge value.
286+
// This lookback must not be less than WPoStChallengeLookback lest a malicious miner be able to selectively declare
287+
// faults after learning the challenge value.
324288
pub const FAULT_DECLARATION_CUTOFF: ChainEpoch = WPOST_CHALLENGE_LOOKBACK + 50;
325289

326-
/// The maximum age of a fault before the sector is terminated.
327290
pub const FAULT_MAX_AGE: ChainEpoch = WPOST_PROVING_PERIOD * 42;
328291

329-
/// Staging period for a miner worker key change.
330-
/// Finality is a harsh delay for a miner who has lost their worker key, as the miner will miss Window PoSts until
331-
/// it can be changed. It's the only safe value, though. We may implement a mitigation mechanism such as a second
332-
/// key or allowing the owner account to submit PoSts while a key change is pending.
292+
// Finality is a harsh delay for a miner who has lost their worker key, as the miner will miss Window PoSts until
293+
// it can be changed. It's the only safe value, though. We may implement a mitigation mechanism such as a second
294+
// key or allowing the owner account to submit PoSts while a key change is pending.
333295
pub const WORKER_KEY_CHANGE_DELAY: ChainEpoch = CHAIN_FINALITY;
334296

335-
/// Minimum number of epochs past the current epoch a sector may be set to expire.
336297
pub const MIN_SECTOR_EXPIRATION: i64 = 180 * EPOCHS_IN_DAY;
337298

338-
/// Maximum number of epochs past the current epoch a sector may be set to expire.
339-
/// The actual maximum extension will be the minimum of CurrEpoch + MaximumSectorExpirationExtension
340-
/// and sector.ActivationEpoch+sealProof.SectorMaximumLifetime()
341299
pub const MAX_SECTOR_EXPIRATION_EXTENSION: i64 = 1278 * EPOCHS_IN_DAY;
342300

343-
/// Ratio of sector size to maximum deals per sector.
344-
/// The maximum number of deals is the sector size divided by this number (2^27)
345-
/// which limits 32GiB sectors to 256 deals and 64GiB sectors to 512
301+
/// A value (2^27) limits 32GiB sectors to 256 deals and 64GiB sectors to 512.
346302
pub const DEAL_LIMIT_DENOMINATOR: u64 = 134217728;
347303

348-
/// Number of epochs after a consensus fault for which a miner is ineligible
349-
/// for permissioned actor methods and winning block elections.
350304
pub const CONSENSUS_FAULT_INELIGIBILITY_DURATION: ChainEpoch = CHAIN_FINALITY;
351305

352-
/// The maximum number of new sectors that may be staged by a miner during a single proving period.
353306
pub const NEW_SECTORS_PER_PERIOD_MAX: usize = 128 << 10;
354307

355-
/// Epochs after which chain state is final with overwhelming probability (hence the likelihood of two fork of this size is negligible)
356308
/// This is a conservative value that is chosen via simulations of all known attacks.
357309
pub const CHAIN_FINALITY: ChainEpoch = 900;
358310

359-
/// The number of total possible types (enum variants) of RegisteredPoStProof
360-
pub const REGISTERED_POST_PROOF_VARIANTS: usize = 15;
361-
362-
/// The number of total possible types (enum variants) of RegisteredSealProof
363-
pub const REGISTERED_SEAL_PROOF_VARIANTS: usize = 10;
364-
365311
#[cfg(not(feature = "small-deals"))]
366312
pub const MINIMUM_VERIFIED_ALLOCATION_SIZE: i32 = 1 << 20;
367313
#[cfg(feature = "small-deals")]
@@ -371,18 +317,13 @@ pub mod policy_constants {
371317
pub const MAXIMUM_VERIFIED_ALLOCATION_EXPIRATION: i64 = 60 * EPOCHS_IN_DAY;
372318
pub const END_OF_LIFE_CLAIM_DROP_PERIOD: ChainEpoch = 30 * EPOCHS_IN_DAY;
373319

374-
/// DealUpdatesInterval is the number of epochs between payouts for deals
375320
pub const DEAL_UPDATES_INTERVAL: i64 = 30 * EPOCHS_IN_DAY;
376321

377-
/// Numerator of the percentage of normalized cirulating
378-
/// supply that must be covered by provider collateral
379322
#[cfg(not(feature = "no-provider-deal-collateral"))]
380323
pub const PROV_COLLATERAL_PERCENT_SUPPLY_NUM: i64 = 1;
381324
#[cfg(feature = "no-provider-deal-collateral")]
382325
pub const PROV_COLLATERAL_PERCENT_SUPPLY_NUM: i64 = 0;
383326

384-
/// Denominator of the percentage of normalized cirulating
385-
/// supply that must be covered by provider collateral
386327
pub const PROV_COLLATERAL_PERCENT_SUPPLY_DENOM: i64 = 100;
387328

388329
pub const MARKET_DEFAULT_ALLOCATION_TERM_BUFFER: i64 = 90 * EPOCHS_IN_DAY;
@@ -407,10 +348,16 @@ pub mod policy_constants {
407348
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
408349
pub struct ProofSet(Vec<bool>);
409350

351+
/// The number of total possible types (enum variants) of RegisteredPoStProof
352+
const REGISTERED_POST_PROOF_VARIANTS: usize = 15;
353+
354+
/// The number of total possible types (enum variants) of RegisteredSealProof
355+
const REGISTERED_SEAL_PROOF_VARIANTS: usize = 10;
356+
410357
impl ProofSet {
411358
/// Create a `ProofSet` for enabled `RegisteredPoStProof`s
412359
pub fn default_post_proofs() -> Self {
413-
let mut proofs = vec![false; policy_constants::REGISTERED_POST_PROOF_VARIANTS];
360+
let mut proofs = vec![false; REGISTERED_POST_PROOF_VARIANTS];
414361
// TODO: v12: cleanup https://github.com/filecoin-project/builtin-actors/issues/1260
415362
#[cfg(feature = "sector-2k")]
416363
{
@@ -442,7 +389,7 @@ impl ProofSet {
442389

443390
/// Create a `ProofSet` for enabled `RegisteredSealProof`s
444391
pub fn default_seal_proofs() -> Self {
445-
let mut proofs = vec![false; policy_constants::REGISTERED_SEAL_PROOF_VARIANTS];
392+
let mut proofs = vec![false; REGISTERED_SEAL_PROOF_VARIANTS];
446393
#[cfg(feature = "sector-2k")]
447394
{
448395
proofs[i64::from(RegisteredSealProof::StackedDRG2KiBV1P1) as usize] = true;

0 commit comments

Comments
 (0)