use cid::Cid;
use fvm_ipld_encoding::strict_bytes;
use serde_tuple::*;
use super::*;
use crate::randomness::Randomness;
use crate::ActorID;
pub type PoStRandomness = Randomness;
#[derive(Debug, PartialEq, Clone, Eq, Serialize_tuple, Deserialize_tuple)]
pub struct SectorInfo {
pub proof: RegisteredSealProof,
pub sector_number: SectorNumber,
pub sealed_cid: Cid,
}
#[derive(Debug, PartialEq, Clone, Eq, Serialize_tuple, Deserialize_tuple)]
pub struct PoStProof {
pub post_proof: RegisteredPoStProof,
#[serde(with = "strict_bytes")]
pub proof_bytes: Vec<u8>,
}
#[cfg(feature = "arb")]
impl quickcheck::Arbitrary for PoStProof {
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
let registered_postproof = g
.choose(&[
RegisteredPoStProof::StackedDRGWinning2KiBV1,
RegisteredPoStProof::StackedDRGWinning8MiBV1,
RegisteredPoStProof::StackedDRGWinning512MiBV1,
RegisteredPoStProof::StackedDRGWinning32GiBV1,
RegisteredPoStProof::StackedDRGWinning64GiBV1,
RegisteredPoStProof::StackedDRGWindow2KiBV1P1,
RegisteredPoStProof::StackedDRGWindow8MiBV1P1,
RegisteredPoStProof::StackedDRGWindow512MiBV1P1,
RegisteredPoStProof::StackedDRGWindow32GiBV1P1,
RegisteredPoStProof::StackedDRGWindow64GiBV1P1,
])
.unwrap();
PoStProof {
post_proof: *registered_postproof,
proof_bytes: Vec::arbitrary(g),
}
}
}
#[derive(Debug, PartialEq, Default, Clone, Eq, Serialize_tuple, Deserialize_tuple)]
pub struct WinningPoStVerifyInfo {
pub randomness: PoStRandomness,
pub proofs: Vec<PoStProof>,
pub challenge_sectors: Vec<SectorInfo>,
pub prover: ActorID,
}
#[derive(Debug, PartialEq, Default, Clone, Eq, Serialize_tuple, Deserialize_tuple)]
pub struct WindowPoStVerifyInfo {
pub randomness: PoStRandomness,
pub proofs: Vec<PoStProof>,
pub challenged_sectors: Vec<SectorInfo>,
pub prover: ActorID,
}
#[derive(Debug, PartialEq, Default, Clone, Eq, Serialize_tuple, Deserialize_tuple)]
pub struct OnChainWindowPoStVerifyInfo {
pub proofs: Vec<PoStProof>,
}