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: add a check parameter command that maps parameter files #1238

Merged
merged 1 commit into from
Aug 5, 2020
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
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