Skip to content

Commit

Permalink
chore: remove references to v1 proof types
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Sep 28, 2023
1 parent ebc7307 commit 36b6c0c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 143 deletions.
127 changes: 5 additions & 122 deletions actors/miner/tests/miner_actor_test_wpost.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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::*;

Expand Down Expand Up @@ -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()),
};
Expand All @@ -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();
Expand All @@ -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()),
};
Expand All @@ -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();
Expand Down Expand Up @@ -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, &sector);

// 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::Actor>(
miner::Method::SubmitWindowedPoSt as u64,
IpldBlock::serialize_cbor(&params).unwrap(),
);
expect_abort_contains_message(tc.exit_code, &tc.error_msg, result);
}

rt.verify();
}
}
2 changes: 1 addition & 1 deletion actors/miner/tests/state_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 0 additions & 5 deletions actors/power/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,6 @@ pub fn consensus_miner_min_power(
| StackedDRGWinning512MiBV1
| StackedDRGWinning32GiBV1
| StackedDRGWinning64GiBV1
| StackedDRGWindow2KiBV1
| StackedDRGWindow8MiBV1
| StackedDRGWindow512MiBV1
| StackedDRGWindow32GiBV1
| StackedDRGWindow64GiBV1
| StackedDRGWindow2KiBV1P1
| StackedDRGWindow8MiBV1P1
| StackedDRGWindow512MiBV1P1
Expand Down
30 changes: 15 additions & 15 deletions actors/power/tests/power_actor_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ fn create_miner() {
&ACTOR,
peer,
multiaddrs,
RegisteredPoStProof::StackedDRGWindow32GiBV1,
RegisteredPoStProof::StackedDRGWindow32GiBV1P1,
&TokenAmount::from_atto(10),
)
.unwrap();

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);

Expand Down Expand Up @@ -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(),
};
Expand All @@ -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(),
Expand Down Expand Up @@ -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 {
Expand All @@ -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);
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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();

Expand All @@ -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();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -945,7 +945,7 @@ mod cron_tests {

let raw_power = consensus_miner_min_power(
&Policy::default(),
RegisteredPoStProof::StackedDRGWindow32GiBV1,
RegisteredPoStProof::StackedDRGWindow32GiBV1P1,
)
.unwrap();

Expand Down

0 comments on commit 36b6c0c

Please sign in to comment.