From c0ae55c277830689a37976310514422a0ceb395a Mon Sep 17 00:00:00 2001 From: elmattic Date: Wed, 30 Aug 2023 13:37:47 +0200 Subject: [PATCH] Remove support of v1 proofs in Miner actor --- actors/miner/src/lib.rs | 42 +++----------------- actors/miner/src/policy.rs | 36 ----------------- actors/miner/tests/miner_actor_test_wpost.rs | 12 +++--- runtime/src/runtime/policy.rs | 6 --- 4 files changed, 13 insertions(+), 83 deletions(-) diff --git a/actors/miner/src/lib.rs b/actors/miner/src/lib.rs index 46600fe22..ce3cbdc00 100644 --- a/actors/miner/src/lib.rs +++ b/actors/miner/src/lib.rs @@ -48,7 +48,6 @@ use fil_actors_runtime::{ SYSTEM_ACTOR_ADDR, VERIFIED_REGISTRY_ACTOR_ADDR, }; use fvm_ipld_encoding::ipld_block::IpldBlock; -use fvm_shared::version::NetworkVersion; pub use monies::*; pub use partition_state::*; pub use policy::*; @@ -163,14 +162,6 @@ impl Actor { check_control_addresses(rt.policy(), ¶ms.control_addresses)?; check_peer_info(rt.policy(), ¶ms.peer_id, ¶ms.multi_addresses)?; check_valid_post_proof_type(rt.policy(), params.window_post_proof_type)?; - // TODO: v12: cleanup https://github.com/filecoin-project/builtin-actors/issues/1260 - if !is_window_post_proof_v1p1(params.window_post_proof_type) { - return Err(actor_error!( - illegal_argument, - "unsupported window post proof type: {:?}", - params.window_post_proof_type - )); - } let owner = rt.resolve_address(¶ms.owner).ok_or_else(|| { actor_error!(illegal_argument, "unable to resolve owner address: {}", params.owner) @@ -550,33 +541,12 @@ impl Actor { // Make sure the miner is using the correct proof type. if params.proofs[0].post_proof != info.window_post_proof_type { - // Special for nv19: Allow the v1 version of v1p1 post proof types - let nv = rt.network_version(); - // TODO: v12: cleanup https://github.com/filecoin-project/builtin-actors/issues/1260 - if nv == NetworkVersion::V19 { - let info_v1_proof_type = - convert_window_post_proof_v1p1_to_v1(info.window_post_proof_type) - .context_code( - ExitCode::USR_ILLEGAL_STATE, - "failed to convert to v1 window post proof", - )?; - if info_v1_proof_type != params.proofs[0].post_proof { - return Err(actor_error!( - illegal_argument, - "expected proof of type {:?} or {:?}, got {:?}", - info_v1_proof_type, - info.window_post_proof_type, - params.proofs[0].post_proof - )); - } - } else { - return Err(actor_error!( - illegal_argument, - "expected proof of type {:?}, got {:?}", - info.window_post_proof_type, - params.proofs[0].post_proof - )); - } + return Err(actor_error!( + illegal_argument, + "expected proof of type {:?}, got {:?}", + info.window_post_proof_type, + params.proofs[0].post_proof + )); } // Make sure the proof size doesn't exceed the max. We could probably check for an exact match, but this is safer. diff --git a/actors/miner/src/policy.rs b/actors/miner/src/policy.rs index 1c6f1bda3..694cace90 100644 --- a/actors/miner/src/policy.rs +++ b/actors/miner/src/policy.rs @@ -58,42 +58,6 @@ pub fn can_extend_seal_proof_type(_proof: RegisteredSealProof) -> bool { true } -/// Convert the v1_1 PoSt Proof type to the older v1 types (used in nv18 and below) -pub fn convert_window_post_proof_v1p1_to_v1( - rpp: RegisteredPoStProof, -) -> Result { - match rpp { - RegisteredPoStProof::StackedDRGWindow2KiBV1P1 => { - Ok(RegisteredPoStProof::StackedDRGWindow2KiBV1) - } - RegisteredPoStProof::StackedDRGWindow8MiBV1P1 => { - Ok(RegisteredPoStProof::StackedDRGWindow8MiBV1) - } - RegisteredPoStProof::StackedDRGWindow512MiBV1P1 => { - Ok(RegisteredPoStProof::StackedDRGWindow512MiBV1) - } - RegisteredPoStProof::StackedDRGWindow32GiBV1P1 => { - Ok(RegisteredPoStProof::StackedDRGWindow32GiBV1) - } - RegisteredPoStProof::StackedDRGWindow64GiBV1P1 => { - Ok(RegisteredPoStProof::StackedDRGWindow64GiBV1) - } - i => Err(format!("not a v1p1 proof type: {:?}", i)), - } -} - -/// Convert the v1_1 PoSt Proof type to the older v1 types (used in nv18 and below) -pub fn is_window_post_proof_v1p1(rpp: RegisteredPoStProof) -> bool { - matches!( - rpp, - RegisteredPoStProof::StackedDRGWindow2KiBV1P1 - | RegisteredPoStProof::StackedDRGWindow8MiBV1P1 - | RegisteredPoStProof::StackedDRGWindow512MiBV1P1 - | RegisteredPoStProof::StackedDRGWindow32GiBV1P1 - | RegisteredPoStProof::StackedDRGWindow64GiBV1P1 - ) -} - /// Maximum duration to allow for the sealing process for seal algorithms. /// Dependent on algorithm and sector size pub fn max_prove_commit_duration( diff --git a/actors/miner/tests/miner_actor_test_wpost.rs b/actors/miner/tests/miner_actor_test_wpost.rs index 7e6501cff..9b08bd59f 100644 --- a/actors/miner/tests/miner_actor_test_wpost.rs +++ b/actors/miner/tests/miner_actor_test_wpost.rs @@ -308,7 +308,7 @@ fn invalid_submissions() { ); expect_abort_contains_message( ExitCode::USR_ILLEGAL_ARGUMENT, - "expected proof of type", + "proof type StackedDRGWindow64GiBV1 not allowed", result, ); rt.reset(); @@ -1296,7 +1296,7 @@ fn bad_post_fails_when_verified() { } #[test] -fn can_submit_v1_proof_types_nv19() { +fn cannot_submit_v1_proof_types_nv19() { struct TestCase { desc: &'static str, nv: NetworkVersion, @@ -1308,12 +1308,14 @@ fn can_submit_v1_proof_types_nv19() { let tests = [ TestCase { - desc: "can submit v1 proof in nv19", + desc: "cannot submit v1 proof in nv19", nv: NetworkVersion::V19, seal_proof_type: RegisteredSealProof::StackedDRG32GiBV1P1, post_proof_type: RegisteredPoStProof::StackedDRGWindow32GiBV1, - exit_code: ExitCode::OK, - error_msg: "".to_string(), + exit_code: ExitCode::USR_ILLEGAL_ARGUMENT, + error_msg: + "expected proof of type StackedDRGWindow32GiBV1P1, got StackedDRGWindow32GiBV1" + .to_string(), }, TestCase { desc: "can submit v1p1 proof in nv19", diff --git a/runtime/src/runtime/policy.rs b/runtime/src/runtime/policy.rs index f1180e009..7a31b8bc6 100644 --- a/runtime/src/runtime/policy.rs +++ b/runtime/src/runtime/policy.rs @@ -358,30 +358,24 @@ impl ProofSet { /// Create a `ProofSet` for enabled `RegisteredPoStProof`s pub fn default_post_proofs() -> Self { let mut proofs = vec![false; REGISTERED_POST_PROOF_VARIANTS]; - // TODO: v12: cleanup https://github.com/filecoin-project/builtin-actors/issues/1260 #[cfg(feature = "sector-2k")] { - proofs[i64::from(RegisteredPoStProof::StackedDRGWindow2KiBV1) as usize] = true; proofs[i64::from(RegisteredPoStProof::StackedDRGWindow2KiBV1P1) as usize] = true; } #[cfg(feature = "sector-8m")] { - proofs[i64::from(RegisteredPoStProof::StackedDRGWindow8MiBV1) as usize] = true; proofs[i64::from(RegisteredPoStProof::StackedDRGWindow8MiBV1P1) as usize] = true; } #[cfg(feature = "sector-512m")] { - proofs[i64::from(RegisteredPoStProof::StackedDRGWindow512MiBV1) as usize] = true; proofs[i64::from(RegisteredPoStProof::StackedDRGWindow512MiBV1P1) as usize] = true; } #[cfg(feature = "sector-32g")] { - proofs[i64::from(RegisteredPoStProof::StackedDRGWindow32GiBV1) as usize] = true; proofs[i64::from(RegisteredPoStProof::StackedDRGWindow32GiBV1P1) as usize] = true; } #[cfg(feature = "sector-64g")] { - proofs[i64::from(RegisteredPoStProof::StackedDRGWindow64GiBV1) as usize] = true; proofs[i64::from(RegisteredPoStProof::StackedDRGWindow64GiBV1P1) as usize] = true; } ProofSet(proofs)