Skip to content

Commit

Permalink
Improve preserve cache (#1382)
Browse files Browse the repository at this point in the history
* fix: enforce that preserve_cache is used on new cache dirs
* fix: remove unused argument
  • Loading branch information
cryptonemo authored Dec 2, 2020
1 parent 8419156 commit 88d1af8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
13 changes: 11 additions & 2 deletions fil-proofs-tooling/src/bin/benchy/window_post.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::BTreeMap;
use std::fs::{create_dir, read, read_to_string, remove_dir_all, File, OpenOptions};
use std::io::{stdout, Seek, SeekFrom, Write};
use std::path::{Path, PathBuf};
use std::path::PathBuf;
use std::time::{SystemTime, UNIX_EPOCH};

use anyhow::{ensure, Context};
Expand Down Expand Up @@ -592,6 +592,15 @@ pub fn run(
info!("Benchy Window PoSt: sector-size={}, api_version={}, preserve_cache={}, skip_precommit_phase1={}, skip_precommit_phase2={}, skip_commit_phase1={}, skip_commit_phase2={}, test_resume={}", sector_size, api_version, preserve_cache, skip_precommit_phase1, skip_precommit_phase2, skip_commit_phase1, skip_commit_phase2, test_resume);

let cache_dir_specified = !cache.is_empty();

// If 'preserve_cache' is specified, the 'cache' option must be specified and must not exist on disk.
if preserve_cache {
ensure!(
cache_dir_specified && !PathBuf::from(&cache).exists(),
"The 'preserve_cache' option cannot be used with a cache_dir that already exists"
);
}

if skip_precommit_phase1 || skip_precommit_phase2 || skip_commit_phase1 || skip_commit_phase2 {
ensure!(
!preserve_cache,
Expand All @@ -614,7 +623,7 @@ pub fn run(
)
};

if !Path::new(&cache_dir).exists() {
if !cache_dir.exists() {
create_dir(&cache_dir)?;
}
info!("Using cache directory {:?}", cache_dir);
Expand Down
1 change: 0 additions & 1 deletion storage-proofs/porep/src/stacked/vanilla/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr
t_aux: &TemporaryAuxCache<Tree, G>,
layer_challenges: &LayerChallenges,
layers: usize,
_total_layers: usize,
partition_count: usize,
) -> Result<Vec<Vec<Proof<Tree, G>>>> {
assert!(layers > 0);
Expand Down
1 change: 0 additions & 1 deletion storage-proofs/porep/src/stacked/vanilla/proof_scheme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ impl<'a, 'c, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> ProofScheme<'
&priv_inputs.t_aux,
&pub_params.layer_challenges,
pub_params.layer_challenges.layers(),
pub_params.layer_challenges.layers(),
partition_count,
)
}
Expand Down

0 comments on commit 88d1af8

Please # to comment.