Skip to content

Commit

Permalink
cli: perf: mask some checkings in release mode
Browse files Browse the repository at this point in the history
  • Loading branch information
junyu0312 committed Nov 8, 2024
1 parent f5acf8c commit 0b8e8b9
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions crates/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ impl Config {
let mut buf = Vec::new();
File::open(wasm_image)?.read_to_end(&mut buf)?;

#[cfg(debug_assertions)]
self.image_consistent_check(&buf)?;

ZkWasmLoader::parse_module(&buf)
Expand All @@ -157,6 +158,7 @@ impl Config {
let mut buf = Vec::new();
File::open(path)?.read_to_end(&mut buf)?;

#[cfg(debug_assertions)]
self.params_consistent_check(&buf)?;

let params = Params::<G1Affine>::read(&mut Cursor::new(&mut buf))?;
Expand All @@ -169,16 +171,19 @@ impl Config {
path: &PathBuf,
expected_md5: &str,
) -> anyhow::Result<CircuitData<G1Affine>> {
let mut buf = Vec::new();
File::open(path)?.read_to_end(&mut buf)?;
#[cfg(debug_assertions)]
{
let mut buf = Vec::new();
File::open(path)?.read_to_end(&mut buf)?;

let circuit_data_md5 = format!("{:x}", md5::compute(&buf));
let circuit_data_md5 = format!("{:x}", md5::compute(&buf));

if circuit_data_md5 != expected_md5 {
anyhow::bail!(
"Circuit data is inconsistent with the one used to build the circuit. \
if circuit_data_md5 != expected_md5 {
anyhow::bail!(
"Circuit data is inconsistent with the one used to build the circuit. \
Maybe you have changed the circuit data after setup the circuit?",
);
);
}
}

let circuit_data = CircuitData::<G1Affine>::read(&mut File::open(path)?)?;
Expand Down

0 comments on commit 0b8e8b9

Please sign in to comment.