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 1 commit
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
2 changes: 1 addition & 1 deletion filecoin-proofs/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ 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_MIN_NI_POREP_AGGREGATION_PROOFS: usize = 1;
pub const FIP90_MAX_NI_POREP_AGGREGATION_PROOFS: usize = 65;

/// Sector sizes for which parameters are supported.
Expand Down
106 changes: 96 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::{
FIP90_MAX_NI_POREP_AGGREGATION_PROOFS, FIP90_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,22 @@ 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, FIP90_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 +640,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],
),
(
FIP90_MAX_NI_POREP_AGGREGATION_PROOFS,
MAX_LEGACY_REGISTERED_SEAL_PROOF_ID + 1,
ApiVersion::V1_2_0,
vec![ApiFeature::NonInteractivePoRep],
),
Expand All @@ -646,15 +675,61 @@ fn test_seal_proof_aggregation_2kib() -> Result<()> {
Ok(())
}

#[test]
#[ignore]
fn test_seal_proof_aggregation_2kib_failures() -> Result<()> {
let test_inputs = vec![
(
FIP90_MIN_NI_POREP_AGGREGATION_PROOFS - 1,
MAX_LEGACY_REGISTERED_SEAL_PROOF_ID + 1,
ApiVersion::V1_2_0,
vec![ApiFeature::NonInteractivePoRep],
),
(
FIP90_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 cause failure passed unexpectedly"
cryptonemo marked this conversation as resolved.
Show resolved Hide resolved
);
}

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 +754,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 +962,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