Skip to content

Commit d913162

Browse files
committed
cli: perf: mask some checkings in release mode
1 parent 9c17608 commit d913162

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

crates/cli/src/config.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ pub(crate) struct Config {
7979
}
8080

8181
impl Config {
82+
#[cfg(debug_assertions)]
8283
fn image_consistent_check(&self, wasm_image: &[u8]) -> anyhow::Result<()> {
8384
if let Some(expected_wasm_image_md5) = &self.wasm_image_md5 {
8485
let wasm_image_md5 = format!("{:x}", md5::compute(wasm_image));
@@ -94,6 +95,7 @@ impl Config {
9495
Ok(())
9596
}
9697

98+
#[cfg(debug_assertions)]
9799
fn params_consistent_check(&self, params: &[u8]) -> anyhow::Result<()> {
98100
let params_md5 = format!("{:x}", md5::compute(params));
99101

@@ -146,6 +148,7 @@ impl Config {
146148
let mut buf = Vec::new();
147149
File::open(wasm_image)?.read_to_end(&mut buf)?;
148150

151+
#[cfg(debug_assertions)]
149152
self.image_consistent_check(&buf)?;
150153

151154
ZkWasmLoader::parse_module(&buf)
@@ -157,6 +160,7 @@ impl Config {
157160
let mut buf = Vec::new();
158161
File::open(path)?.read_to_end(&mut buf)?;
159162

163+
#[cfg(debug_assertions)]
160164
self.params_consistent_check(&buf)?;
161165

162166
let params = Params::<G1Affine>::read(&mut Cursor::new(&mut buf))?;
@@ -167,18 +171,21 @@ impl Config {
167171
fn read_circuit_data(
168172
&self,
169173
path: &PathBuf,
170-
expected_md5: &str,
174+
_expected_md5: &str,
171175
) -> anyhow::Result<CircuitData<G1Affine>> {
172-
let mut buf = Vec::new();
173-
File::open(path)?.read_to_end(&mut buf)?;
176+
#[cfg(debug_assertions)]
177+
{
178+
let mut buf = Vec::new();
179+
File::open(path)?.read_to_end(&mut buf)?;
174180

175-
let circuit_data_md5 = format!("{:x}", md5::compute(&buf));
181+
let circuit_data_md5 = format!("{:x}", md5::compute(&buf));
176182

177-
if circuit_data_md5 != expected_md5 {
178-
anyhow::bail!(
179-
"Circuit data is inconsistent with the one used to build the circuit. \
183+
if circuit_data_md5 != _expected_md5 {
184+
anyhow::bail!(
185+
"Circuit data is inconsistent with the one used to build the circuit. \
180186
Maybe you have changed the circuit data after setup the circuit?",
181-
);
187+
);
188+
}
182189
}
183190

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

0 commit comments

Comments
 (0)