From 256752a9531fa44eabe48e9bf49175fa10a8b17c Mon Sep 17 00:00:00 2001 From: Eric Tu Date: Tue, 30 Mar 2021 01:22:59 -0400 Subject: [PATCH 1/3] Allow for older sectors to be extended for 540 days --- types/networks/src/interopnet/mod.rs | 5 ++++- types/networks/src/lib.rs | 6 +++++- types/networks/src/mainnet/mod.rs | 6 ++++-- types/src/version.rs | 4 +++- vm/actor/src/builtin/miner/mod.rs | 6 +++--- vm/actor/src/builtin/miner/policy.rs | 23 ++++++++++++++++++----- 6 files changed, 37 insertions(+), 13 deletions(-) diff --git a/types/networks/src/interopnet/mod.rs b/types/networks/src/interopnet/mod.rs index ba1fd834cef1..8f77eae170d9 100644 --- a/types/networks/src/interopnet/mod.rs +++ b/types/networks/src/interopnet/mod.rs @@ -31,7 +31,10 @@ pub const UPGRADE_ORANGE_HEIGHT: ChainEpoch = 180; /// Remove burn on window PoSt fork pub const UPGRADE_CLAUS_HEIGHT: ChainEpoch = 210; /// V10 network upgrade height TBD -pub const UPGRADE_ACTORS_V3_HEIGHT: ChainEpoch = 999999999; +pub const UPGRADE_ACTORS_V3_HEIGHT: ChainEpoch = 999999998; +/// V11 network upgrade +pub const UPGRADE_NORWEGIAN_HEIGHT: ChainEpoch = 999999999; + pub const UPGRADE_PLACEHOLDER_HEIGHT: ChainEpoch = 9999999; /// Current network version for the network diff --git a/types/networks/src/lib.rs b/types/networks/src/lib.rs index 0dda3d3ff8dc..6f20ea326ef2 100644 --- a/types/networks/src/lib.rs +++ b/types/networks/src/lib.rs @@ -33,7 +33,7 @@ struct DrandPoint<'a> { pub config: &'a DrandConfig<'a>, } -const VERSION_SCHEDULE: [Upgrade; 10] = [ +const VERSION_SCHEDULE: [Upgrade; 11] = [ Upgrade { height: UPGRADE_BREEZE_HEIGHT, network: NetworkVersion::V1, @@ -74,6 +74,10 @@ const VERSION_SCHEDULE: [Upgrade; 10] = [ height: UPGRADE_ACTORS_V3_HEIGHT, network: NetworkVersion::V10, }, + Upgrade { + height: UPGRADE_NORWEGIAN_HEIGHT, + network: NetworkVersion::V11, + }, ]; /// Gets network version from epoch using default Mainnet schedule. diff --git a/types/networks/src/mainnet/mod.rs b/types/networks/src/mainnet/mod.rs index e448a9768a1f..c764ce1088dd 100644 --- a/types/networks/src/mainnet/mod.rs +++ b/types/networks/src/mainnet/mod.rs @@ -33,13 +33,15 @@ pub const UPGRADE_PERSIAN_HEIGHT: ChainEpoch = 272400; pub const UPGRADE_ORANGE_HEIGHT: ChainEpoch = 336458; /// Remove burn on window PoSt fork pub const UPGRADE_CLAUS_HEIGHT: ChainEpoch = 343200; -/// V10 network upgrade height +/// V10 network upgrade pub const UPGRADE_ACTORS_V3_HEIGHT: ChainEpoch = 550321; +/// V11 network upgrade +pub const UPGRADE_NORWEGIAN_HEIGHT: ChainEpoch = 665280; pub const UPGRADE_PLACEHOLDER_HEIGHT: ChainEpoch = 9999999; /// Current network version for the network -pub const NEWEST_NETWORK_VERSION: NetworkVersion = NetworkVersion::V10; +pub const NEWEST_NETWORK_VERSION: NetworkVersion = NetworkVersion::V11; /// Bootstrap peer ids pub const DEFAULT_BOOTSTRAP: &[&str] = &[ diff --git a/types/src/version.rs b/types/src/version.rs index e4af40c1f8a9..ea8d7e246510 100644 --- a/types/src/version.rs +++ b/types/src/version.rs @@ -29,6 +29,8 @@ pub enum NetworkVersion { V9, /// actors v3 (specs-actors v3.0.x) V10, - /// reserved + /// norwegian (specs-actor v3.1.x) V11, + /// reserved + V12, } diff --git a/vm/actor/src/builtin/miner/mod.rs b/vm/actor/src/builtin/miner/mod.rs index 45af1e8566b8..a8e662ba854b 100644 --- a/vm/actor/src/builtin/miner/mod.rs +++ b/vm/actor/src/builtin/miner/mod.rs @@ -1693,7 +1693,7 @@ impl Actor { let (power_delta, pledge_delta) = rt.transaction(|state: &mut State, rt| { let info = get_miner_info(rt.store(), state)?; - + let nv = rt.network_version(); rt.validate_immediate_caller_is( info.control_addresses .iter() @@ -1772,7 +1772,7 @@ impl Actor { let new_sectors: Vec = old_sectors .iter() .map(|sector| { - if !can_extend_seal_proof_type(sector.seal_proof) { + if !can_extend_seal_proof_type(sector.seal_proof, nv) { return Err(actor_error!( ErrForbidden, "cannot extend expiration for sector {} with unsupported \ @@ -3249,7 +3249,7 @@ where } // total sector lifetime cannot exceed SectorMaximumLifetime for the sector's seal proof - let max_lifetime = seal_proof_sector_maximum_lifetime(seal_proof).ok_or_else(|| { + let max_lifetime = seal_proof_sector_maximum_lifetime(seal_proof, rt.network_version()).ok_or_else(|| { actor_error!( ErrIllegalArgument, "unrecognized seal proof type {:?}", diff --git a/vm/actor/src/builtin/miner/policy.rs b/vm/actor/src/builtin/miner/policy.rs index 19aea2f3fddd..a814e8d5b6ba 100644 --- a/vm/actor/src/builtin/miner/policy.rs +++ b/vm/actor/src/builtin/miner/policy.rs @@ -109,10 +109,13 @@ pub fn can_pre_commit_seal_proof(proof: RegisteredSealProof, nv: NetworkVersion) } /// Checks whether a seal proof type is supported for new miners and sectors. -pub fn can_extend_seal_proof_type(proof: RegisteredSealProof) -> bool { +pub fn can_extend_seal_proof_type(proof: RegisteredSealProof, nv: NetworkVersion) -> bool { use RegisteredSealProof::*; - - matches!(proof, StackedDRG32GiBV1P1 | StackedDRG64GiBV1P1) + // Between V7 and V11, older seal proof types could not be extended (see FIP 0014). + if nv >= NetworkVersion::V7 && nv <= NetworkVersion::V10 { + return matches!(proof, StackedDRG32GiBV1P1 | StackedDRG64GiBV1P1); + } + true } /// Maximum duration to allow for the sealing process for seal algorithms. @@ -131,14 +134,24 @@ pub fn max_prove_commit_duration(proof: RegisteredSealProof) -> Option Option { +pub fn seal_proof_sector_maximum_lifetime(proof: RegisteredSealProof, nv: NetworkVersion) -> Option { use RegisteredSealProof::*; + if nv < NetworkVersion::V11 { + return match proof { + StackedDRG32GiBV1 | StackedDRG2KiBV1 | StackedDRG8MiBV1 | StackedDRG512MiBV1 + | StackedDRG64GiBV1 | StackedDRG32GiBV1P1 | StackedDRG2KiBV1P1 | StackedDRG8MiBV1P1 + | StackedDRG512MiBV1P1 | StackedDRG64GiBV1P1 => Some(EPOCHS_IN_YEAR * 5), + _ => None, + }; + } match proof { StackedDRG32GiBV1 | StackedDRG2KiBV1 | StackedDRG8MiBV1 | StackedDRG512MiBV1 - | StackedDRG64GiBV1 | StackedDRG32GiBV1P1 | StackedDRG2KiBV1P1 | StackedDRG8MiBV1P1 + | StackedDRG64GiBV1 => Some(EPOCHS_IN_DAY * 540), + StackedDRG32GiBV1P1 | StackedDRG2KiBV1P1 | StackedDRG8MiBV1P1 | StackedDRG512MiBV1P1 | StackedDRG64GiBV1P1 => Some(EPOCHS_IN_YEAR * 5), _ => None, } + } pub const MAX_PRE_COMMIT_RANDOMNESS_LOOKBACK: ChainEpoch = EPOCHS_IN_DAY + CHAIN_FINALITY; From 027302af67e72c5d972590dd918531505d0f66e4 Mon Sep 17 00:00:00 2001 From: Eric Tu Date: Tue, 30 Mar 2021 01:26:49 -0400 Subject: [PATCH 2/3] lint and comments --- vm/actor/src/builtin/miner/mod.rs | 15 ++++++++------- vm/actor/src/builtin/miner/policy.rs | 13 ++++++++----- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/vm/actor/src/builtin/miner/mod.rs b/vm/actor/src/builtin/miner/mod.rs index a8e662ba854b..a7dc80b039d7 100644 --- a/vm/actor/src/builtin/miner/mod.rs +++ b/vm/actor/src/builtin/miner/mod.rs @@ -3249,13 +3249,14 @@ where } // total sector lifetime cannot exceed SectorMaximumLifetime for the sector's seal proof - let max_lifetime = seal_proof_sector_maximum_lifetime(seal_proof, rt.network_version()).ok_or_else(|| { - actor_error!( - ErrIllegalArgument, - "unrecognized seal proof type {:?}", - seal_proof - ) - })?; + let max_lifetime = seal_proof_sector_maximum_lifetime(seal_proof, rt.network_version()) + .ok_or_else(|| { + actor_error!( + ErrIllegalArgument, + "unrecognized seal proof type {:?}", + seal_proof + ) + })?; if expiration - activation > max_lifetime { return Err(actor_error!( ErrIllegalArgument, diff --git a/vm/actor/src/builtin/miner/policy.rs b/vm/actor/src/builtin/miner/policy.rs index a814e8d5b6ba..09bfbf565e3a 100644 --- a/vm/actor/src/builtin/miner/policy.rs +++ b/vm/actor/src/builtin/miner/policy.rs @@ -114,7 +114,7 @@ pub fn can_extend_seal_proof_type(proof: RegisteredSealProof, nv: NetworkVersion // Between V7 and V11, older seal proof types could not be extended (see FIP 0014). if nv >= NetworkVersion::V7 && nv <= NetworkVersion::V10 { return matches!(proof, StackedDRG32GiBV1P1 | StackedDRG64GiBV1P1); - } + } true } @@ -134,7 +134,10 @@ pub fn max_prove_commit_duration(proof: RegisteredSealProof) -> Option Option { +pub fn seal_proof_sector_maximum_lifetime( + proof: RegisteredSealProof, + nv: NetworkVersion, +) -> Option { use RegisteredSealProof::*; if nv < NetworkVersion::V11 { return match proof { @@ -144,14 +147,14 @@ pub fn seal_proof_sector_maximum_lifetime(proof: RegisteredSealProof, nv: Networ _ => None, }; } + // In NetworkVersion 11, we allow for sectors using the old proofs to be extended by 540 days. match proof { StackedDRG32GiBV1 | StackedDRG2KiBV1 | StackedDRG8MiBV1 | StackedDRG512MiBV1 | StackedDRG64GiBV1 => Some(EPOCHS_IN_DAY * 540), - StackedDRG32GiBV1P1 | StackedDRG2KiBV1P1 | StackedDRG8MiBV1P1 - | StackedDRG512MiBV1P1 | StackedDRG64GiBV1P1 => Some(EPOCHS_IN_YEAR * 5), + StackedDRG32GiBV1P1 | StackedDRG2KiBV1P1 | StackedDRG8MiBV1P1 | StackedDRG512MiBV1P1 + | StackedDRG64GiBV1P1 => Some(EPOCHS_IN_YEAR * 5), _ => None, } - } pub const MAX_PRE_COMMIT_RANDOMNESS_LOOKBACK: ChainEpoch = EPOCHS_IN_DAY + CHAIN_FINALITY; From 6d0f5aaf8e368f656e66c51919312fa64313d940 Mon Sep 17 00:00:00 2001 From: Eric Tu Date: Wed, 31 Mar 2021 12:55:41 -0400 Subject: [PATCH 3/3] fix docs --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 216442ae1151..e6ba7bd6be10 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -246,7 +246,7 @@ jobs: - restore_cargo_package_cache - run: name: Build Docs - command: cargo doc --no-deps --all-features + command: cargo doc --no-deps - run: name: Publish Docs command: bash ./scripts/build-rust-docs.sh