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: update FIP92 min value to proposed new value #1758

Merged
merged 4 commits into from
Jun 18, 2024
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
6 changes: 3 additions & 3 deletions filecoin-proofs/src/api/seal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use crate::{
},
constants::{
DefaultBinaryTree, DefaultPieceDomain, DefaultPieceHasher,
FIP90_MAX_NI_POREP_AGGREGATION_PROOFS, FIP90_MIN_NI_POREP_AGGREGATION_PROOFS,
FIP92_MAX_NI_POREP_AGGREGATION_PROOFS, FIP92_MIN_NI_POREP_AGGREGATION_PROOFS,
SINGLE_PARTITION_PROOF_LEN,
},
parameters::setup_params,
Expand Down Expand Up @@ -758,8 +758,8 @@ pub fn aggregate_seal_commit_proofs<Tree: 'static + MerkleTreeTrait>(
// aggregated together.
if porep_config.feature_enabled(ApiFeature::NonInteractivePoRep) && commit_outputs.len() > 1 {
ensure!(
commit_outputs.len() >= FIP90_MIN_NI_POREP_AGGREGATION_PROOFS
&& commit_outputs.len() <= FIP90_MAX_NI_POREP_AGGREGATION_PROOFS,
commit_outputs.len() >= FIP92_MIN_NI_POREP_AGGREGATION_PROOFS
&& commit_outputs.len() <= FIP92_MAX_NI_POREP_AGGREGATION_PROOFS,
"{} proofs is outside of FIP-0090 specified NI-PoRep aggregation bounds",
commit_outputs.len()
);
Expand Down
7 changes: 4 additions & 3 deletions filecoin-proofs/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ pub const WINDOW_POST_CHALLENGE_COUNT: usize = 10;

pub const MAX_LEGACY_REGISTERED_SEAL_PROOF_ID: u64 = MAX_LEGACY_POREP_REGISTERED_PROOF_ID;

// Constant NI-PoRep aggregation bounds specified in FIP-0090
pub const FIP90_MIN_NI_POREP_AGGREGATION_PROOFS: usize = 2;
pub const FIP90_MAX_NI_POREP_AGGREGATION_PROOFS: usize = 65;
/// Constant NI-PoRep aggregation bounds specified in FIP-0090, but
/// superseded by FIP-0092
pub const FIP92_MIN_NI_POREP_AGGREGATION_PROOFS: usize = 1;
pub const FIP92_MAX_NI_POREP_AGGREGATION_PROOFS: usize = 65;

/// Sector sizes for which parameters are supported.
pub const SUPPORTED_SECTOR_SIZES: [u64; 10] = [
Expand Down
122 changes: 112 additions & 10 deletions filecoin-proofs/tests/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ use storage_proofs_core::{
use storage_proofs_update::constants::TreeRHasher;
use tempfile::{tempdir, NamedTempFile, TempDir};

use filecoin_proofs::constants::MAX_LEGACY_REGISTERED_SEAL_PROOF_ID;
use filecoin_proofs::constants::{
FIP92_MAX_NI_POREP_AGGREGATION_PROOFS, FIP92_MIN_NI_POREP_AGGREGATION_PROOFS,
MAX_LEGACY_REGISTERED_SEAL_PROOF_ID,
};

#[cfg(feature = "big-tests")]
use filecoin_proofs::{
Expand Down Expand Up @@ -499,6 +502,38 @@ fn test_seal_lifecycle_32gib_porep_id_v1_2_ni_top_8_8_0_api_v1_2() -> Result<()>
seal_lifecycle::<SectorShape32GiB>(&porep_config)
}

#[cfg(feature = "big-tests")]
#[test]
fn test_max_ni_seal_proof_aggregation_32gib() -> Result<()> {
let porep_id_v1_2: u64 = 8; // This is a RegisteredSealProof value

let porep_id = to_porep_id_verified(porep_id_v1_2, ApiVersion::V1_2_0);
let porep_config = PoRepConfig::new_groth16_with_features(
SECTOR_SIZE_32_GIB,
porep_id,
ApiVersion::V1_2_0,
vec![ApiFeature::NonInteractivePoRep],
)?;

aggregate_seal_proofs::<SectorShape32GiB>(&porep_config, FIP92_MAX_NI_POREP_AGGREGATION_PROOFS)
}

#[cfg(feature = "big-tests")]
#[test]
fn test_max_ni_seal_proof_aggregation_64gib() -> Result<()> {
let porep_id_v1_2: u64 = 9; // This is a RegisteredSealProof value

let porep_id = to_porep_id_verified(porep_id_v1_2, ApiVersion::V1_2_0);
let porep_config = PoRepConfig::new_groth16_with_features(
SECTOR_SIZE_64_GIB,
porep_id,
ApiVersion::V1_2_0,
vec![ApiFeature::NonInteractivePoRep],
)?;

aggregate_seal_proofs::<SectorShape64GiB>(&porep_config, FIP92_MAX_NI_POREP_AGGREGATION_PROOFS)
}

#[cfg(feature = "big-tests")]
#[test]
fn test_seal_lifecycle_upgrade_32gib_top_8_8_0_v1_2() -> Result<()> {
Expand Down Expand Up @@ -621,11 +656,21 @@ fn seal_lifecycle_upgrade<Tree: 'static + MerkleTreeTrait<Hasher = TreeRHasher>>
#[ignore]
fn test_seal_proof_aggregation_2kib() -> Result<()> {
let test_inputs = vec![
(1, 5, ApiVersion::V1_1_0, vec![]),
(5, 5, ApiVersion::V1_2_0, vec![ApiFeature::SyntheticPoRep]),
(
65,
1,
MAX_LEGACY_REGISTERED_SEAL_PROOF_ID + 1,
ApiVersion::V1_1_0,
vec![],
),
(
5,
MAX_LEGACY_REGISTERED_SEAL_PROOF_ID + 1,
ApiVersion::V1_2_0,
vec![ApiFeature::SyntheticPoRep],
),
(
FIP92_MAX_NI_POREP_AGGREGATION_PROOFS,
MAX_LEGACY_REGISTERED_SEAL_PROOF_ID + 1,
ApiVersion::V1_2_0,
vec![ApiFeature::NonInteractivePoRep],
),
Expand All @@ -646,15 +691,61 @@ fn test_seal_proof_aggregation_2kib() -> Result<()> {
Ok(())
}

#[test]
#[ignore]
fn test_seal_proof_aggregation_2kib_failures() -> Result<()> {
let test_inputs = vec![
(
FIP92_MIN_NI_POREP_AGGREGATION_PROOFS - 1,
MAX_LEGACY_REGISTERED_SEAL_PROOF_ID + 1,
ApiVersion::V1_2_0,
vec![ApiFeature::NonInteractivePoRep],
),
(
FIP92_MAX_NI_POREP_AGGREGATION_PROOFS + 1,
MAX_LEGACY_REGISTERED_SEAL_PROOF_ID + 1,
ApiVersion::V1_2_0,
vec![ApiFeature::NonInteractivePoRep],
),
];

for (proofs_to_aggregate, porep_id_num, api_version, api_features) in test_inputs {
let porep_id = to_porep_id_verified(porep_id_num, api_version);
let porep_config = PoRepConfig::new_groth16_with_features(
SECTOR_SIZE_2_KIB,
porep_id,
api_version,
api_features,
)?;

ensure!(
aggregate_seal_proofs::<SectorShape2KiB>(&porep_config, proofs_to_aggregate).is_err(),
"test case failure passed unexpectedly"
);
}

Ok(())
}

#[test]
#[ignore]
fn test_seal_proof_aggregation_4kib() -> Result<()> {
let test_inputs = vec![
(7, 5, ApiVersion::V1_1_0, vec![]),
(24, 5, ApiVersion::V1_2_0, vec![ApiFeature::SyntheticPoRep]),
(
7,
MAX_LEGACY_REGISTERED_SEAL_PROOF_ID + 1,
ApiVersion::V1_1_0,
vec![],
),
(
24,
MAX_LEGACY_REGISTERED_SEAL_PROOF_ID + 1,
ApiVersion::V1_2_0,
vec![ApiFeature::SyntheticPoRep],
),
(
17,
5,
MAX_LEGACY_REGISTERED_SEAL_PROOF_ID + 1,
ApiVersion::V1_2_0,
vec![ApiFeature::NonInteractivePoRep],
),
Expand All @@ -679,11 +770,21 @@ fn test_seal_proof_aggregation_4kib() -> Result<()> {
#[ignore]
fn test_seal_proof_aggregation_32kib() -> Result<()> {
let test_inputs = vec![
(220, 5, ApiVersion::V1_1_0, vec![]),
(500, 5, ApiVersion::V1_2_0, vec![ApiFeature::SyntheticPoRep]),
(
220,
MAX_LEGACY_REGISTERED_SEAL_PROOF_ID + 1,
ApiVersion::V1_1_0,
vec![],
),
(
500,
MAX_LEGACY_REGISTERED_SEAL_PROOF_ID + 1,
ApiVersion::V1_2_0,
vec![ApiFeature::SyntheticPoRep],
),
(
5,
5,
MAX_LEGACY_REGISTERED_SEAL_PROOF_ID + 1,
ApiVersion::V1_2_0,
vec![ApiFeature::NonInteractivePoRep],
),
Expand Down Expand Up @@ -877,6 +978,7 @@ fn aggregate_seal_proofs<Tree: 'static + MerkleTreeTrait>(
commit_outputs.as_slice(),
aggregate_version,
)?;
info!("Aggregate proof size is {} bytes", aggregate_proof.len());
assert!(verify_aggregate_seal_commit_proofs::<Tree>(
porep_config,
aggregate_proof.clone(),
Expand Down