From 0b8e8b9d91ef4acc14f9999c5b9468d44b648b2f Mon Sep 17 00:00:00 2001 From: Zhang Junyu Date: Fri, 8 Nov 2024 13:37:48 +0000 Subject: [PATCH] cli: perf: mask some checkings in release mode --- crates/cli/src/config.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/crates/cli/src/config.rs b/crates/cli/src/config.rs index f3607751..1e89034d 100644 --- a/crates/cli/src/config.rs +++ b/crates/cli/src/config.rs @@ -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) @@ -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::::read(&mut Cursor::new(&mut buf))?; @@ -169,16 +171,19 @@ impl Config { path: &PathBuf, expected_md5: &str, ) -> anyhow::Result> { - 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::::read(&mut File::open(path)?)?;