Skip to content

Commit

Permalink
Merge branch 'master' into fvm-next
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Sep 27, 2023
2 parents b8fcb2a + e1d0eef commit 47f78cf
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 84 deletions.
42 changes: 6 additions & 36 deletions actors/miner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -163,14 +162,6 @@ impl Actor {
check_control_addresses(rt.policy(), &params.control_addresses)?;
check_peer_info(rt.policy(), &params.peer_id, &params.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(&params.owner).ok_or_else(|| {
actor_error!(illegal_argument, "unable to resolve owner address: {}", params.owner)
Expand Down Expand Up @@ -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.
Expand Down
36 changes: 0 additions & 36 deletions actors/miner/src/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RegisteredPoStProof, String> {
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(
Expand Down
2 changes: 1 addition & 1 deletion actors/miner/tests/declare_recoveries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn recovery_must_pay_back_fee_debt() {
st = h.get_state(&rt);
let (dl_idx, p_idx) = st.find_sector(&rt.store, one_sector[0].sector_number).unwrap();

// Skip to end of proving period
// advance into the deadline but not past it
h.advance_to_deadline(&rt, dl_idx);

// Can't pay during this deadline so miner goes into fee debt
Expand Down
12 changes: 7 additions & 5 deletions actors/miner/tests/miner_actor_test_wpost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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,
Expand All @@ -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",
Expand Down
6 changes: 0 additions & 6 deletions runtime/src/runtime/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 47f78cf

Please sign in to comment.