Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laudiacay/actors review f15 #1314

Merged
merged 3 commits into from
Dec 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion vm/actor/src/builtin/miner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ use crypto::DomainSeparationTag::{
use encoding::{from_slice, BytesDe, Cbor};
use fil_types::{
deadlines::DeadlineInfo, AggregateSealVerifyInfo, AggregateSealVerifyProofAndInfos,
InteractiveSealRandomness, PoStProof, PoStRandomness, RegisteredSealProof,
InteractiveSealRandomness, PoStProof, PoStRandomness, RegisteredPoStProof, RegisteredSealProof,
SealRandomness as SealRandom, SealVerifyInfo, SealVerifyParams, SectorID, SectorInfo,
SectorNumber, SectorSize, WindowPoStVerifyInfo, MAX_SECTOR_NUMBER, RANDOMNESS_LENGTH,
};
Expand Down Expand Up @@ -145,6 +145,7 @@ impl Actor {

check_control_addresses(&params.control_addresses)?;
check_peer_info(&params.peer_id, &params.multi_addresses)?;
check_valid_post_proof_type(params.window_post_proof_type)?;

let owner = resolve_control_address(rt, params.owner)?;
let worker = resolve_worker_address(rt, params.worker)?;
Expand Down Expand Up @@ -406,6 +407,22 @@ impl Actor {
{
let current_epoch = rt.curr_epoch();

if params.proofs.len() != 1 {
return Err(actor_error!(
ErrIllegalArgument,
"expected exactly one proof, got {}",
params.proofs.len()
));
}

if check_valid_post_proof_type(params.proofs[0].post_proof).is_err() {
return Err(actor_error!(
ErrIllegalArgument,
"proof type {:?} not allowed",
params.proofs[0].post_proof
));
}

if params.deadline >= WPOST_PERIOD_DEADLINES as usize {
return Err(actor_error!(
ErrIllegalArgument,
Expand Down Expand Up @@ -4038,6 +4055,18 @@ fn check_control_addresses(control_addrs: &[Address]) -> Result<(), ActorError>
Ok(())
}

fn check_valid_post_proof_type(proof_type: RegisteredPoStProof) -> Result<(), ActorError> {
match proof_type {
RegisteredPoStProof::StackedDRGWindow32GiBV1
| RegisteredPoStProof::StackedDRGWindow64GiBV1 => Ok(()),
_ => Err(actor_error!(
ErrIllegalArgument,
"proof type {:?} not allowed for new miner actors",
proof_type
)),
}
}

fn check_peer_info(peer_id: &[u8], multiaddrs: &[BytesDe]) -> Result<(), ActorError> {
if peer_id.len() > MAX_PEER_ID_LENGTH {
return Err(actor_error!(
Expand Down