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

feat: FIP-0061: Add new PoSt proof types #1727

Merged
merged 2 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
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
37 changes: 19 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion fvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ serde_tuple = "0.5"
lazy_static = "1.4.0"
derive_more = "0.99.17"
replace_with = "0.1.7"
filecoin-proofs-api = { version = "13", default-features = false }
filecoin-proofs-api = { version = "14", default-features = false }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this network breaking? I.e., will updating to version 14 cause a hard-fork?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The answer should be no, but I will let @cryptonemo confirm.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The answer is yes, this is nv19 scope and beyond.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, it's yes once the new PoSt Proof types are used/accepted. If you continue using the old PoSt proof types in the new version of proofs, it's compatible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that's all we care about. Adding support for new types is backwards compatible.

rayon = "1"
num_cpus = "1.13.0"
log = "0.4.14"
Expand Down
2 changes: 1 addition & 1 deletion shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bitflags = "1.3.2"
## non-wasm dependencies; these dependencies and the respective code is
## only activated through non-default features, which the Kernel enables, but
## not the actors.
filecoin-proofs-api = { version = "13", default-features = false, optional = true }
filecoin-proofs-api = { version = "14", default-features = false, optional = true }
libsecp256k1 = { version = "0.7", optional = true }
bls-signatures = { version = "0.13", default-features = false, optional = true }

Expand Down
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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit but... can't we just call these V2?

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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),
Comment on lines +405 to +409
Copy link

@0x5459 0x5459 Apr 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
StackedDRGWindow2KiBV1P1 => Ok(Self::StackedDrgWindow2KiBV1),
StackedDRGWindow8MiBV1P1 => Ok(Self::StackedDrgWindow8MiBV1),
StackedDRGWindow512MiBV1P1 => Ok(Self::StackedDrgWindow512MiBV1),
StackedDRGWindow32GiBV1P1 => Ok(Self::StackedDrgWindow32GiBV1),
StackedDRGWindow64GiBV1P1 => Ok(Self::StackedDrgWindow64GiBV1),
StackedDRGWindow2KiBV1P1 => Ok(Self::StackedDrgWindow2KiBV1_2),
StackedDRGWindow8MiBV1P1 => Ok(Self::StackedDrgWindow8MiBV1_2),
StackedDRGWindow512MiBV1P1 => Ok(Self::StackedDrgWindow512MiBV1_2),
StackedDRGWindow32GiBV1P1 => Ok(Self::StackedDrgWindow32GiBV1_2),
StackedDRGWindow64GiBV1P1 => Ok(Self::StackedDrgWindow64GiBV1_2),

typo?

Invalid(i) => Err(format!("unsupported proof type: {}", i)),
}
}
Expand Down