Skip to content

Commit

Permalink
feat: FIP-0061: Add new PoSt proof types
Browse files Browse the repository at this point in the history
  • Loading branch information
arajasek committed Mar 27, 2023
1 parent 0d760d7 commit 5936cc5
Showing 1 changed file with 52 additions and 16 deletions.
68 changes: 52 additions & 16 deletions shared/src/sector/registered_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ pub enum RegisteredPoStProof {
StackedDRGWindow512MiBV1,
StackedDRGWindow32GiBV1,
StackedDRGWindow64GiBV1,
StackedDRGWindow2KiBV1P1,
StackedDRGWindow8MiBV1P1,
StackedDRGWindow512MiBV1P1,
StackedDRGWindow32GiBV1P1,
StackedDRGWindow64GiBV1P1,
Invalid(i64),
}

Expand All @@ -116,11 +121,21 @@ impl RegisteredPoStProof {
pub fn sector_size(self) -> Result<SectorSize, String> {
use RegisteredPoStProof::*;
match self {
StackedDRGWindow2KiBV1 | StackedDRGWinning2KiBV1 => Ok(SectorSize::_2KiB),
StackedDRGWindow8MiBV1 | StackedDRGWinning8MiBV1 => Ok(SectorSize::_8MiB),
StackedDRGWindow512MiBV1 | StackedDRGWinning512MiBV1 => Ok(SectorSize::_512MiB),
StackedDRGWindow32GiBV1 | StackedDRGWinning32GiBV1 => Ok(SectorSize::_32GiB),
StackedDRGWindow64GiBV1 | StackedDRGWinning64GiBV1 => Ok(SectorSize::_64GiB),
StackedDRGWindow2KiBV1P1 | StackedDRGWindow2KiBV1 | StackedDRGWinning2KiBV1 => {
Ok(SectorSize::_2KiB)
}
StackedDRGWindow8MiBV1P1 | StackedDRGWindow8MiBV1 | StackedDRGWinning8MiBV1 => {
Ok(SectorSize::_8MiB)
}
StackedDRGWindow512MiBV1P1 | StackedDRGWindow512MiBV1 | StackedDRGWinning512MiBV1 => {
Ok(SectorSize::_512MiB)
}
StackedDRGWindow32GiBV1P1 | StackedDRGWindow32GiBV1 | StackedDRGWinning32GiBV1 => {
Ok(SectorSize::_32GiB)
}
StackedDRGWindow64GiBV1P1 | StackedDRGWindow64GiBV1 | StackedDRGWinning64GiBV1 => {
Ok(SectorSize::_64GiB)
}
Invalid(i) => Err(format!("unsupported proof type: {}", i)),
}
}
Expand All @@ -138,7 +153,12 @@ impl RegisteredPoStProof {
| StackedDRGWindow8MiBV1
| StackedDRGWindow512MiBV1
| StackedDRGWindow32GiBV1
| StackedDRGWindow64GiBV1 => Ok(192),
| StackedDRGWindow64GiBV1
| StackedDRGWindow2KiBV1P1
| StackedDRGWindow8MiBV1P1
| StackedDRGWindow512MiBV1P1
| StackedDRGWindow32GiBV1P1
| StackedDRGWindow64GiBV1P1 => Ok(192),
Invalid(i) => Err(format!("unsupported proof type: {}", i)),
}
}
Expand All @@ -148,11 +168,17 @@ impl RegisteredPoStProof {
// Resolve to post proof and then compute size from that.
use RegisteredPoStProof::*;
match self {
StackedDRGWinning64GiBV1 | StackedDRGWindow64GiBV1 => Ok(2300),
StackedDRGWinning32GiBV1 | StackedDRGWindow32GiBV1 => Ok(2349),
StackedDRGWinning2KiBV1 | StackedDRGWindow2KiBV1 => Ok(2),
StackedDRGWinning8MiBV1 | StackedDRGWindow8MiBV1 => Ok(2),
StackedDRGWinning512MiBV1 | StackedDRGWindow512MiBV1 => Ok(2),
StackedDRGWinning64GiBV1 | StackedDRGWindow64GiBV1 | StackedDRGWindow64GiBV1P1 => {
Ok(2300)
}
StackedDRGWinning32GiBV1 | StackedDRGWindow32GiBV1 | StackedDRGWindow32GiBV1P1 => {
Ok(2349)
}
StackedDRGWinning2KiBV1 | StackedDRGWindow2KiBV1 | StackedDRGWindow2KiBV1P1 => Ok(2),
StackedDRGWinning8MiBV1 | StackedDRGWindow8MiBV1 | StackedDRGWindow8MiBV1P1 => Ok(2),
StackedDRGWinning512MiBV1 | StackedDRGWindow512MiBV1 | StackedDRGWindow512MiBV1P1 => {
Ok(2)
}
Invalid(i) => Err(format!("unsupported proof type: {}", i)),
}
}
Expand Down Expand Up @@ -209,11 +235,11 @@ impl RegisteredSealProof {
pub fn registered_window_post_proof(self) -> Result<RegisteredPoStProof, String> {
use RegisteredPoStProof::*;
match self {
Self::StackedDRG64GiBV1 | Self::StackedDRG64GiBV1P1 => Ok(StackedDRGWindow64GiBV1),
Self::StackedDRG32GiBV1 | Self::StackedDRG32GiBV1P1 => Ok(StackedDRGWindow32GiBV1),
Self::StackedDRG2KiBV1 | Self::StackedDRG2KiBV1P1 => Ok(StackedDRGWindow2KiBV1),
Self::StackedDRG8MiBV1 | Self::StackedDRG8MiBV1P1 => Ok(StackedDRGWindow8MiBV1),
Self::StackedDRG512MiBV1 | Self::StackedDRG512MiBV1P1 => Ok(StackedDRGWindow512MiBV1),
Self::StackedDRG64GiBV1 | Self::StackedDRG64GiBV1P1 => Ok(StackedDRGWindow64GiBV1P1),
Self::StackedDRG32GiBV1 | Self::StackedDRG32GiBV1P1 => Ok(StackedDRGWindow32GiBV1P1),
Self::StackedDRG2KiBV1 | Self::StackedDRG2KiBV1P1 => Ok(StackedDRGWindow2KiBV1P1),
Self::StackedDRG8MiBV1 | Self::StackedDRG8MiBV1P1 => Ok(StackedDRGWindow8MiBV1P1),
Self::StackedDRG512MiBV1 | Self::StackedDRG512MiBV1P1 => Ok(StackedDRGWindow512MiBV1P1),
Self::Invalid(_) => Err(format!(
"Unsupported mapping from {:?} to PoSt-window RegisteredProof",
self
Expand Down Expand Up @@ -290,6 +316,11 @@ i64_conversion! {
StackedDRGWindow512MiBV1 => 7,
StackedDRGWindow32GiBV1 => 8,
StackedDRGWindow64GiBV1 => 9,
StackedDRGWindow2KiBV1P1 => 10,
StackedDRGWindow8MiBV1P1 => 11,
StackedDRGWindow512MiBV1P1 => 12,
StackedDRGWindow32GiBV1P1 => 13,
StackedDRGWindow64GiBV1P1 => 14,
}

i64_conversion! {
Expand Down Expand Up @@ -371,6 +402,11 @@ impl TryFrom<RegisteredPoStProof> for filecoin_proofs_api::RegisteredPoStProof {
StackedDRGWindow512MiBV1 => Ok(Self::StackedDrgWindow512MiBV1),
StackedDRGWindow32GiBV1 => Ok(Self::StackedDrgWindow32GiBV1),
StackedDRGWindow64GiBV1 => Ok(Self::StackedDrgWindow64GiBV1),
StackedDRGWindow2KiBV1P1 => Ok(Self::StackedDrgWindow2KiBV1),
StackedDRGWindow8MiBV1P1 => Ok(Self::StackedDrgWindow8MiBV1),
StackedDRGWindow512MiBV1P1 => Ok(Self::StackedDrgWindow512MiBV1),
StackedDRGWindow32GiBV1P1 => Ok(Self::StackedDrgWindow32GiBV1),
StackedDRGWindow64GiBV1P1 => Ok(Self::StackedDrgWindow64GiBV1),
Invalid(i) => Err(format!("unsupported proof type: {}", i)),
}
}
Expand Down

0 comments on commit 5936cc5

Please sign in to comment.