Skip to content

Commit

Permalink
feat: add a check parameter command that maps parameter files
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptonemo committed Aug 4, 2020
1 parent 5e760a7 commit 76cecb4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
41 changes: 41 additions & 0 deletions fil-proofs-tooling/src/bin/check_parameters/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use std::path::PathBuf;

use anyhow::Result;
use bellperson::groth16::MappedParameters;
use clap::{value_t, App, Arg, SubCommand};
use paired::bls12_381::Bls12;

use storage_proofs::parameter_cache::read_cached_params;

fn run_map(parameter_file: &PathBuf) -> Result<MappedParameters<Bls12>> {
read_cached_params(parameter_file)
}

fn main() -> Result<()> {
fil_logger::init();

let map_cmd = SubCommand::with_name("map")
.about("build mapped parameters")
.arg(
Arg::with_name("param")
.long("parameter-file")
.help("The parameter file to map")
.required(true)
.takes_value(true),
);

let matches = App::new("check_parameters")
.version("0.1")
.subcommand(map_cmd)
.get_matches();

match matches.subcommand() {
("map", Some(m)) => {
let parameter_file = value_t!(m, "param", PathBuf)?;
run_map(&parameter_file)?;
}
_ => panic!("Unrecognized subcommand"),
}

Ok(())
}
2 changes: 1 addition & 1 deletion storage-proofs/core/src/parameter_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ fn ensure_parent(path: &PathBuf) -> Result<()> {

// Reads parameter mappings using mmap so that they can be lazily
// loaded later.
fn read_cached_params(cache_entry_path: &PathBuf) -> Result<groth16::MappedParameters<Bls12>> {
pub fn read_cached_params(cache_entry_path: &PathBuf) -> Result<groth16::MappedParameters<Bls12>> {
info!("checking cache_path: {:?} for parameters", cache_entry_path);
with_exclusive_read_lock(cache_entry_path, |_| {
let params = Parameters::build_mapped_parameters(cache_entry_path.to_path_buf(), false)?;
Expand Down

0 comments on commit 76cecb4

Please sign in to comment.