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

refactor: Challenges enum #1739

Merged
merged 3 commits into from
Dec 5, 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
4 changes: 2 additions & 2 deletions fil-proofs-tooling/src/bin/gen_graph_cache/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use filecoin_proofs::{
};
use serde::{Deserialize, Serialize};
use storage_proofs_core::{api_version::ApiVersion, merkle::MerkleTreeTrait, proof::ProofScheme};
use storage_proofs_porep::stacked::{LayerChallenges, SetupParams, StackedDrg};
use storage_proofs_porep::stacked::{Challenges, SetupParams, StackedDrg};

const PARENT_CACHE_JSON_OUTPUT: &str = "./parent_cache.json";

Expand All @@ -36,7 +36,7 @@ fn gen_graph_cache<Tree: 'static + MerkleTreeTrait>(
// we just use dummy values of 1 for the setup params.
let num_layers = 1;
let challenge_count = 1;
let challenges = LayerChallenges::new(challenge_count);
let challenges = Challenges::new_interactive(challenge_count);

let sp = SetupParams {
nodes,
Expand Down
15 changes: 9 additions & 6 deletions filecoin-proofs/src/parameters.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::{ensure, Result};
use storage_proofs_core::{api_version::ApiFeature, proof::ProofScheme};
use storage_proofs_porep::stacked::{self, LayerChallenges, StackedDrg};
use storage_proofs_porep::stacked::{self, Challenges, StackedDrg};
use storage_proofs_post::fallback::{self, FallbackPoSt};

use crate::{
Expand Down Expand Up @@ -114,11 +114,13 @@ fn select_challenges(
partitions: usize,
minimum_total_challenges: usize,
use_synthetic: bool,
) -> LayerChallenges {
) -> Challenges {
let challenges = div_ceil(minimum_total_challenges, partitions);
let mut result = LayerChallenges::new(challenges);
result.use_synthetic = use_synthetic;
result
if use_synthetic {
Challenges::new_synthetic(challenges)
} else {
Challenges::new_interactive(challenges)
}
}

#[cfg(test)]
Expand All @@ -129,7 +131,8 @@ mod tests {

#[test]
fn partition_layer_challenges_test() {
let f = |partitions| select_challenges(partitions, 12, false).challenges_count_all();
let f =
|partitions| select_challenges(partitions, 12, false).num_challenges_per_partition();
// Update to ensure all supported PoRepProofPartitions options are represented here.
assert_eq!(6, f(usize::from(PoRepProofPartitions(2))));

Expand Down
2 changes: 1 addition & 1 deletion storage-proofs-porep/src/stacked/circuit/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher>
comm_r: None,
comm_r_last: None,
comm_c: None,
proofs: (0..public_params.challenges.challenges_count_all())
proofs: (0..public_params.challenges.num_challenges_per_partition())
.map(|_challenge_index| Proof::empty(public_params))
.collect(),
}
Expand Down
Loading