From 36b6c0c04601778356d3bedc0d30909224f3de3d Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 28 Sep 2023 17:01:33 +0000 Subject: [PATCH] chore: remove references to v1 proof types --- actors/miner/tests/miner_actor_test_wpost.rs | 127 +------------------ actors/miner/tests/state_harness.rs | 2 +- actors/power/src/state.rs | 5 - actors/power/tests/power_actor_tests.rs | 30 ++--- 4 files changed, 21 insertions(+), 143 deletions(-) diff --git a/actors/miner/tests/miner_actor_test_wpost.rs b/actors/miner/tests/miner_actor_test_wpost.rs index 9b08bd59ff..d1aee13186 100644 --- a/actors/miner/tests/miner_actor_test_wpost.rs +++ b/actors/miner/tests/miner_actor_test_wpost.rs @@ -1,7 +1,7 @@ #![allow(clippy::all)] use fil_actor_miner as miner; -use fil_actor_miner::{PowerPair, SubmitWindowedPoStParams}; +use fil_actor_miner::PowerPair; use fil_actors_runtime::runtime::DomainSeparationTag; use fil_actors_runtime::test_utils::*; use fvm_ipld_bitfield::BitField; @@ -15,7 +15,6 @@ use fvm_shared::sector::RegisteredSealProof; mod util; use fvm_ipld_encoding::ipld_block::IpldBlock; -use fvm_shared::version::NetworkVersion; use num_traits::Zero; use util::*; @@ -270,7 +269,7 @@ fn invalid_submissions() { let params = miner::SubmitWindowedPoStParams { deadline: dlinfo.index, partitions: vec![partition], - proofs: make_post_proofs(RegisteredPoStProof::StackedDRGWindow8MiBV1), + proofs: make_post_proofs(RegisteredPoStProof::StackedDRGWindow8MiBV1P1), chain_commit_epoch: dlinfo.challenge, chain_commit_rand: Randomness(TEST_RANDOMNESS_ARRAY_FROM_ONE.into()), }; @@ -283,7 +282,7 @@ fn invalid_submissions() { ); expect_abort_contains_message( ExitCode::USR_ILLEGAL_ARGUMENT, - "proof type StackedDRGWindow8MiBV1 not allowed", + "proof type StackedDRGWindow8MiBV1P1 not allowed", result, ); rt.reset(); @@ -295,7 +294,7 @@ fn invalid_submissions() { let params = miner::SubmitWindowedPoStParams { deadline: dlinfo.index, partitions: vec![partition], - proofs: make_post_proofs(RegisteredPoStProof::StackedDRGWindow64GiBV1), + proofs: make_post_proofs(RegisteredPoStProof::StackedDRGWindow64GiBV1P1), chain_commit_epoch: dlinfo.challenge, chain_commit_rand: Randomness(TEST_RANDOMNESS_ARRAY_FROM_ONE.into()), }; @@ -308,7 +307,7 @@ fn invalid_submissions() { ); expect_abort_contains_message( ExitCode::USR_ILLEGAL_ARGUMENT, - "proof type StackedDRGWindow64GiBV1 not allowed", + "expected proof of type StackedDRGWindow32GiBV1P1, got StackedDRGWindow64GiBV1P1", result, ); rt.reset(); @@ -1294,119 +1293,3 @@ fn bad_post_fails_when_verified() { rt.reset(); h.check_state(&rt); } - -#[test] -fn cannot_submit_v1_proof_types_nv19() { - struct TestCase { - desc: &'static str, - nv: NetworkVersion, - seal_proof_type: RegisteredSealProof, - post_proof_type: RegisteredPoStProof, - exit_code: ExitCode, - error_msg: String, - } - - let tests = [ - TestCase { - desc: "cannot submit v1 proof in nv19", - nv: NetworkVersion::V19, - seal_proof_type: RegisteredSealProof::StackedDRG32GiBV1P1, - post_proof_type: RegisteredPoStProof::StackedDRGWindow32GiBV1, - 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", - nv: NetworkVersion::V19, - seal_proof_type: RegisteredSealProof::StackedDRG32GiBV1P1, - post_proof_type: RegisteredPoStProof::StackedDRGWindow32GiBV1P1, - exit_code: ExitCode::OK, - error_msg: "".to_string(), - }, - TestCase { - desc: "can submit v1p1 proof in nv20", - nv: NetworkVersion::V20, - seal_proof_type: RegisteredSealProof::StackedDRG32GiBV1P1, - post_proof_type: RegisteredPoStProof::StackedDRGWindow32GiBV1P1, - exit_code: ExitCode::OK, - error_msg: "".to_string(), - }, - TestCase { - desc: "can NOT submit v1 proof in nv20", - nv: NetworkVersion::V20, - seal_proof_type: RegisteredSealProof::StackedDRG32GiBV1P1, - post_proof_type: RegisteredPoStProof::StackedDRGWindow32GiBV1, - exit_code: ExitCode::USR_ILLEGAL_ARGUMENT, - error_msg: - "expected proof of type StackedDRGWindow32GiBV1P1, got StackedDRGWindow32GiBV1" - .to_string(), - }, - ]; - - for tc in tests { - println!("Testing: {}", tc.desc); - let period_offset = ChainEpoch::from(100); - let precommit_epoch = ChainEpoch::from(1); - - let mut h = ActorHarness::new(period_offset); - h.set_proof_type(tc.seal_proof_type); - - let mut rt = h.new_runtime(); - rt.network_version = tc.nv; - // in nv19 policy, both V1 and V1P1 are "valid" post proof types - rt.policy.valid_post_proof_type.insert(RegisteredPoStProof::StackedDRGWindow32GiBV1); - rt.policy.valid_post_proof_type.insert(RegisteredPoStProof::StackedDRGWindow32GiBV1P1); - rt.epoch.replace(precommit_epoch); - rt.balance.replace(BIG_BALANCE.clone()); - - h.construct_and_verify(&rt); - - let info = h.get_info(&rt); - // No matter what post proof type the test uses, the miner info should be V1P1 - assert_eq!(info.window_post_proof_type, RegisteredPoStProof::StackedDRGWindow32GiBV1P1); - - let sectors = h.commit_and_prove_sectors(&rt, 1, DEFAULT_SECTOR_EXPIRATION, vec![], true); - let sector = sectors[0].clone(); - let pwr = miner::power_for_sector(h.sector_size, §or); - - // Skip to the right deadline - let state = h.get_state(&rt); - let (dlidx, pidx) = state.find_sector(&rt.store, sector.sector_number).unwrap(); - let dlinfo = h.advance_to_deadline(&rt, dlidx); - - // Submit PoSt - let post_partitions = - vec![miner::PoStPartition { index: pidx, skipped: make_empty_bitfield() }]; - let post_sectors = vec![sector.clone()]; - let params = SubmitWindowedPoStParams { - deadline: dlidx, - partitions: post_partitions, - proofs: make_post_proofs(tc.post_proof_type), - chain_commit_epoch: dlinfo.challenge, - chain_commit_rand: Randomness(TEST_RANDOMNESS_ARRAY_FROM_ONE.into()), - }; - - if tc.exit_code.is_success() { - h.submit_window_post_raw( - &rt, - &dlinfo, - post_sectors, - params, - PoStConfig::with_expected_power_delta(&pwr), - ) - .unwrap(); - } else { - rt.set_caller(*ACCOUNT_ACTOR_CODE_ID, h.worker); - rt.expect_validate_caller_addr(h.caller_addrs()); - let result = rt.call::( - miner::Method::SubmitWindowedPoSt as u64, - IpldBlock::serialize_cbor(¶ms).unwrap(), - ); - expect_abort_contains_message(tc.exit_code, &tc.error_msg, result); - } - - rt.verify(); - } -} diff --git a/actors/miner/tests/state_harness.rs b/actors/miner/tests/state_harness.rs index 3e928c1625..a536dd1e05 100644 --- a/actors/miner/tests/state_harness.rs +++ b/actors/miner/tests/state_harness.rs @@ -36,7 +36,7 @@ impl StateHarness { let owner = 1; let worker = 2; - let test_window_post_proof_type = RegisteredPoStProof::StackedDRGWindow2KiBV1; + let test_window_post_proof_type = RegisteredPoStProof::StackedDRGWindow2KiBV1P1; let info = MinerInfo::new( owner, diff --git a/actors/power/src/state.rs b/actors/power/src/state.rs index 9f8edbb524..82bd3ada1b 100644 --- a/actors/power/src/state.rs +++ b/actors/power/src/state.rs @@ -407,11 +407,6 @@ pub fn consensus_miner_min_power( | StackedDRGWinning512MiBV1 | StackedDRGWinning32GiBV1 | StackedDRGWinning64GiBV1 - | StackedDRGWindow2KiBV1 - | StackedDRGWindow8MiBV1 - | StackedDRGWindow512MiBV1 - | StackedDRGWindow32GiBV1 - | StackedDRGWindow64GiBV1 | StackedDRGWindow2KiBV1P1 | StackedDRGWindow8MiBV1P1 | StackedDRGWindow512MiBV1P1 diff --git a/actors/power/tests/power_actor_tests.rs b/actors/power/tests/power_actor_tests.rs index 5c28060919..ea0bfe95c9 100644 --- a/actors/power/tests/power_actor_tests.rs +++ b/actors/power/tests/power_actor_tests.rs @@ -52,7 +52,7 @@ fn create_miner() { &ACTOR, peer, multiaddrs, - RegisteredPoStProof::StackedDRGWindow32GiBV1, + RegisteredPoStProof::StackedDRGWindow32GiBV1P1, &TokenAmount::from_atto(10), ) .unwrap(); @@ -60,7 +60,7 @@ fn create_miner() { let st: State = rt.get_state(); // Verify the miner's claim. let claim = h.get_claim(&rt, &MINER).unwrap(); - assert_eq!(RegisteredPoStProof::StackedDRGWindow32GiBV1, claim.window_post_proof_type); + assert_eq!(RegisteredPoStProof::StackedDRGWindow32GiBV1P1, claim.window_post_proof_type); assert_eq!(StoragePower::zero(), claim.raw_byte_power); assert_eq!(StoragePower::zero(), claim.quality_adj_power); @@ -89,7 +89,7 @@ fn create_miner_given_send_to_init_actor_fails_should_fail() { let create_miner_params = CreateMinerParams { owner: *OWNER, worker: *OWNER, - window_post_proof_type: RegisteredPoStProof::StackedDRGWindow32GiBV1, + window_post_proof_type: RegisteredPoStProof::StackedDRGWindow32GiBV1P1, peer: peer.clone(), multiaddrs: multiaddrs.clone(), }; @@ -105,7 +105,7 @@ fn create_miner_given_send_to_init_actor_fails_should_fail() { constructor_params: RawBytes::serialize(MinerConstructorParams { owner: *OWNER, worker: *OWNER, - window_post_proof_type: RegisteredPoStProof::StackedDRGWindow32GiBV1, + window_post_proof_type: RegisteredPoStProof::StackedDRGWindow32GiBV1P1, peer_id: peer, multi_addresses: multiaddrs, control_addresses: Default::default(), @@ -319,8 +319,8 @@ fn new_miner_updates_miner_above_min_power_count() { } let test_cases = [ - TestCase { proof: RegisteredPoStProof::StackedDRGWindow2KiBV1, expected_miners: 0 }, - TestCase { proof: RegisteredPoStProof::StackedDRGWindow32GiBV1, expected_miners: 0 }, + TestCase { proof: RegisteredPoStProof::StackedDRGWindow2KiBV1P1, expected_miners: 0 }, + TestCase { proof: RegisteredPoStProof::StackedDRGWindow32GiBV1P1, expected_miners: 0 }, ]; for test in test_cases { @@ -340,7 +340,7 @@ fn power_accounting_crossing_threshold() { let power_unit = &consensus_miner_min_power( &Policy::default(), - RegisteredPoStProof::StackedDRGWindow32GiBV1, + RegisteredPoStProof::StackedDRGWindow32GiBV1P1, ) .unwrap(); let power_unit_x10 = &(power_unit * 10); @@ -386,7 +386,7 @@ fn all_of_one_miners_power_disappears_when_that_miner_dips_below_min_power_thres let small_power_unit = &StoragePower::from(1_000_000); let power_unit = &consensus_miner_min_power( &Policy::default(), - RegisteredPoStProof::StackedDRGWindow32GiBV1, + RegisteredPoStProof::StackedDRGWindow32GiBV1P1, ) .unwrap(); @@ -444,7 +444,7 @@ fn enroll_cron_epoch_given_negative_epoch_should_fail() { fn power_gets_added_when_miner_crosses_min_power_but_not_before() { let power_unit = &consensus_miner_min_power( &Policy::default(), - RegisteredPoStProof::StackedDRGWindow32GiBV1, + RegisteredPoStProof::StackedDRGWindow32GiBV1P1, ) .unwrap(); @@ -492,7 +492,7 @@ fn power_gets_added_when_miner_crosses_min_power_but_not_before() { fn threshold_only_depends_on_raw_power_not_qa_power() { let power_unit = &consensus_miner_min_power( &Policy::default(), - RegisteredPoStProof::StackedDRGWindow32GiBV1, + RegisteredPoStProof::StackedDRGWindow32GiBV1P1, ) .unwrap(); let half_power_unit = &(power_unit / 2); @@ -520,7 +520,7 @@ fn threshold_only_depends_on_raw_power_not_qa_power() { fn qa_power_is_above_threshold_before_and_after_update() { let power_unit = &consensus_miner_min_power( &Policy::default(), - RegisteredPoStProof::StackedDRGWindow32GiBV1, + RegisteredPoStProof::StackedDRGWindow32GiBV1P1, ) .unwrap(); let power_unit_x3 = &(power_unit * 3); @@ -547,7 +547,7 @@ fn qa_power_is_above_threshold_before_and_after_update() { fn claimed_power_is_externally_available() { let power_unit = &consensus_miner_min_power( &Policy::default(), - RegisteredPoStProof::StackedDRGWindow32GiBV1, + RegisteredPoStProof::StackedDRGWindow32GiBV1P1, ) .unwrap(); @@ -567,7 +567,7 @@ fn claimed_power_is_externally_available() { fn get_network_and_miner_power() { let power_unit = &consensus_miner_min_power( &Policy::default(), - RegisteredPoStProof::StackedDRGWindow32GiBV1, + RegisteredPoStProof::StackedDRGWindow32GiBV1P1, ) .unwrap(); @@ -681,7 +681,7 @@ mod cron_tests { let (mut h, rt) = setup(); let power_unit = consensus_miner_min_power( &Policy::default(), - RegisteredPoStProof::StackedDRGWindow2KiBV1, + RegisteredPoStProof::StackedDRGWindow2KiBV1P1, ) .unwrap(); @@ -945,7 +945,7 @@ mod cron_tests { let raw_power = consensus_miner_min_power( &Policy::default(), - RegisteredPoStProof::StackedDRGWindow32GiBV1, + RegisteredPoStProof::StackedDRGWindow32GiBV1P1, ) .unwrap();