Skip to content

Commit a22fd2d

Browse files
authored
Merge pull request #469 from filecoin-project/feat/more-realistic-sectors
Specify challenges with taper format. Increase expansion degree.
2 parents ef2da49 + 8e58007 commit a22fd2d

File tree

3 files changed

+34
-19
lines changed

3 files changed

+34
-19
lines changed

filecoin-proofs/src/api/internal.rs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,29 @@ fn get_zigzag_params() -> Option<groth16::Parameters<Bls12>> {
9797
(*ZIGZAG_PARAMS).clone()
9898
}
9999

100-
fn get_post_params(sector_bytes: usize) -> groth16::Parameters<Bls12> {
101-
println!("getting post params for sector size: {}", sector_bytes);
100+
fn get_post_params(sector_bytes: usize) -> error::Result<groth16::Parameters<Bls12>> {
102101
let post_public_params = post_public_params(sector_bytes as usize);
103-
let post_circuit: VDFPoStCircuit<Bls12> =
104-
<VDFPostCompound as CompoundProof<
105-
Bls12,
106-
VDFPoSt<PedersenHasher, Sloth>,
107-
VDFPoStCircuit<Bls12>,
108-
>>::blank_circuit(&post_public_params, &ENGINE_PARAMS);
109-
VDFPostCompound::get_groth_params(post_circuit, &post_public_params).unwrap()
102+
<VDFPostCompound as CompoundProof<
103+
Bls12,
104+
VDFPoSt<PedersenHasher, Sloth>,
105+
VDFPoStCircuit<Bls12>,
106+
>>::groth_params(&post_public_params, &ENGINE_PARAMS)
107+
.map_err(|e| e.into())
110108
}
111109

112-
const DEGREE: usize = 1; // TODO: 5; FIXME: increasing degree introduces a test failure. Figure out why.
113-
const EXPANSION_DEGREE: usize = 6;
110+
const DEGREE: usize = 2;
111+
const EXPANSION_DEGREE: usize = 8;
114112
const SLOTH_ITER: usize = 0;
115113
const LAYERS: usize = 2; // TODO: 10;
116-
const CHALLENGES: LayerChallenges = LayerChallenges::new_fixed(LAYERS, 1);
114+
const TAPER_LAYERS: usize = LAYERS; // TODO: 7
115+
const TAPER: f64 = 1.0 / 3.0;
116+
const CHALLENGE_COUNT: usize = 2;
117+
const DRG_SEED: [u32; 7] = [1, 2, 3, 4, 5, 6, 7]; // Arbitrary, need a theory for how to vary this over time.
118+
119+
lazy_static! {
120+
static ref CHALLENGES: LayerChallenges =
121+
LayerChallenges::new_tapered(LAYERS, CHALLENGE_COUNT, TAPER_LAYERS, TAPER);
122+
}
117123

118124
fn setup_params(sector_bytes: usize) -> layered_drgporep::SetupParams {
119125
assert!(
@@ -128,11 +134,11 @@ fn setup_params(sector_bytes: usize) -> layered_drgporep::SetupParams {
128134
nodes,
129135
degree: DEGREE,
130136
expansion_degree: EXPANSION_DEGREE,
131-
seed: new_seed(),
137+
seed: DRG_SEED,
132138
},
133139
sloth_iter: SLOTH_ITER,
134140
},
135-
layer_challenges: CHALLENGES,
141+
layer_challenges: CHALLENGES.clone(),
136142
}
137143
}
138144

@@ -285,7 +291,7 @@ pub fn generate_post(sector_bytes: u64, input: PoStInput) -> error::Result<PoStO
285291

286292
let priv_inputs = vdf_post::PrivateInputs::<PedersenHasher>::new(&borrowed_trees[..]);
287293

288-
let groth_params = get_post_params(sector_bytes as usize);
294+
let groth_params = get_post_params(sector_bytes as usize)?;
289295

290296
let proof = VDFPostCompound::prove(&pub_params, &pub_inputs, &priv_inputs, Some(groth_params))
291297
.expect("failed while proving");
@@ -339,7 +345,7 @@ pub fn verify_post(
339345
faults,
340346
};
341347

342-
let groth_params = get_post_params(sector_bytes as usize);
348+
let groth_params = get_post_params(sector_bytes as usize)?;
343349

344350
let proof = MultiProof::new_from_reader(Some(POST_PARTITIONS), proof_vec, groth_params)?;
345351

@@ -612,7 +618,6 @@ pub fn verify_seal(
612618
let (_fake, _delay_seconds, _sector_bytes, proof_sector_bytes, uses_official_circuit) =
613619
get_config(sector_config);
614620

615-
let challenges = CHALLENGES;
616621
let prover_id = pad_safe_fr(prover_id_in);
617622
let sector_id = pad_safe_fr(sector_id_in);
618623
let replica_id = replica_id::<DefaultTreeHasher>(prover_id, sector_id);

storage-proofs/src/compound_proof.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,20 @@ where
199199
engine_params: &'a E::Params,
200200
) -> C;
201201

202-
fn blank_circuit(_public_param: &S::PublicParams, _engine_params: &'a E::Params) -> C {
202+
fn blank_circuit(_public_params: &S::PublicParams, _engine_params: &'a E::Params) -> C {
203203
unimplemented!();
204204
}
205205

206+
fn groth_params(
207+
public_params: &S::PublicParams,
208+
engine_params: &'a E::Params,
209+
) -> Result<groth16::Parameters<E>> {
210+
Self::get_groth_params(
211+
Self::blank_circuit(public_params, engine_params),
212+
public_params,
213+
)
214+
}
215+
206216
fn circuit_for_test(
207217
public_parameters: &PublicParams<'a, E, S>,
208218
public_inputs: &S::PublicInputs,

storage-proofs/src/zigzag_drgporep.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ mod tests {
100100
drg: drgporep::DrgParams {
101101
nodes: data.len() / 32,
102102
degree: 5,
103-
expansion_degree: 5,
103+
expansion_degree: 8,
104104
seed: new_seed(),
105105
},
106106
sloth_iter,

0 commit comments

Comments
 (0)