Skip to content

Commit

Permalink
fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
amoylan2 committed Jun 14, 2024
1 parent 95b1376 commit 0bc6ac3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
8 changes: 6 additions & 2 deletions prover/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: prover
.PHONY: prover lint tests_binary

ifeq (4.3,$(firstword $(sort $(MAKE_VERSION) 4.3)))
HALO2_VERSION=$(shell grep -m 1 "halo2.git" ./Cargo.lock | cut -d "#" -f2 | cut -c-7)
Expand Down Expand Up @@ -42,4 +42,8 @@ prover:

tests_binary:
cargo clean && cargo test --release --no-run
ls target/release/deps/prover* | grep -v "\.d" | xargs -I{} ln -sf {} ./prover.test
ls target/release/deps/prover* | grep -v "\.d" | xargs -I{} ln -sf {} ./prover.test

lint:
cargo check --all-features
cargo clippy --all-features --all-targets -- -D warnings
16 changes: 8 additions & 8 deletions prover/src/zk_circuits_handler/bernoulli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl BaseCircuitsHandler {
fn gen_chunk_proof(&self, task: &crate::types::Task) -> Result<String> {
let chunk_trace = self.gen_chunk_traces(task)?;
let chunk_proof = self.gen_chunk_proof_raw(chunk_trace)?;
return serde_json::to_string(&chunk_proof).map_err(|e| anyhow::anyhow!(e));
serde_json::to_string(&chunk_proof).map_err(|e| anyhow::anyhow!(e))
}

fn gen_batch_proof_raw(&self, chunk_hashes_proofs: Vec<(ChunkHash, ChunkProof)>) -> Result<BatchProof> {
Expand Down Expand Up @@ -104,7 +104,7 @@ impl BaseCircuitsHandler {
let chunk_hashes_proofs: Vec<(ChunkHash, ChunkProof)> =
self.gen_chunk_hashes_proofs(task)?;
let batch_proof = self.gen_batch_proof_raw(chunk_hashes_proofs)?;
return serde_json::to_string(&batch_proof).map_err(|e| anyhow::anyhow!(e));
serde_json::to_string(&batch_proof).map_err(|e| anyhow::anyhow!(e))
}

fn get_output_dir(&self) -> Option<&str> {
Expand Down Expand Up @@ -247,7 +247,7 @@ mod tests {
#[test]
fn it_works() {
let result = true;
assert_eq!(result, true);
assert!(result);
}

#[test]
Expand Down Expand Up @@ -285,7 +285,7 @@ mod tests {
log::info!("start to prove batch");
let batch_proof = batch_handler.gen_batch_proof_raw(chunk_hashes_proofs)?;
let proof_data = serde_json::to_string(&batch_proof)?;
dump_proof(format!("batch_proof"), proof_data)?;
dump_proof("batch_proof".to_string(), proof_data)?;

Ok(())
}
Expand All @@ -304,7 +304,7 @@ mod tests {
ProofType::Undefined => unreachable!()
};

let data = std::fs::read(&vk_file)?;
let data = std::fs::read(vk_file)?;
Ok(encode_vk(data))
}

Expand Down Expand Up @@ -334,7 +334,7 @@ mod tests {
None
}
}).collect();
files.sort_by(|a, b| a.cmp(b));
files.sort();

log::info!("files in chunk {:?} is {:?}", path, files);
for file in files {
Expand Down Expand Up @@ -366,9 +366,9 @@ mod tests {
None
}
}).collect();
files.sort_by(|a, b| a.cmp(b));
files.sort();
log::info!("files in batch {:?} is {:?}", batch_path, files);
Ok(files.into_iter().map(|f| (&batch_path).join(f)).collect())
Ok(files.into_iter().map(|f| batch_path.join(f)).collect())
}

fn traces_to_chunk_info(chunk_trace: Vec<BlockTrace>) -> Result<ChunkHash> {
Expand Down
16 changes: 8 additions & 8 deletions prover/src/zk_circuits_handler/curie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl NextCircuitsHandler {
fn gen_chunk_proof(&self, task: &crate::types::Task) -> Result<String> {
let chunk_trace = self.gen_chunk_traces(task)?;
let chunk_proof = self.gen_chunk_proof_raw(chunk_trace)?;
return serde_json::to_string(&chunk_proof).map_err(|e| anyhow::anyhow!(e));
serde_json::to_string(&chunk_proof).map_err(|e| anyhow::anyhow!(e))
}

fn gen_batch_proof_raw(&self, chunk_hashes_proofs: Vec<(ChunkInfo, ChunkProof)>) -> Result<BatchProof> {
Expand Down Expand Up @@ -105,7 +105,7 @@ impl NextCircuitsHandler {
let chunk_hashes_proofs: Vec<(ChunkInfo, ChunkProof)> =
self.gen_chunk_hashes_proofs(task)?;
let batch_proof = self.gen_batch_proof_raw(chunk_hashes_proofs)?;
return serde_json::to_string(&batch_proof).map_err(|e| anyhow::anyhow!(e));
serde_json::to_string(&batch_proof).map_err(|e| anyhow::anyhow!(e))
}

fn get_output_dir(&self) -> Option<&str> {
Expand Down Expand Up @@ -249,7 +249,7 @@ mod tests {
#[test]
fn it_works() {
let result = true;
assert_eq!(result, true);
assert!(result);
}

#[test]
Expand Down Expand Up @@ -287,7 +287,7 @@ mod tests {
log::info!("start to prove batch");
let batch_proof = batch_handler.gen_batch_proof_raw(chunk_hashes_proofs)?;
let proof_data = serde_json::to_string(&batch_proof)?;
dump_proof(format!("batch_proof"), proof_data)?;
dump_proof("batch_proof".to_string(), proof_data)?;

Ok(())
}
Expand All @@ -306,7 +306,7 @@ mod tests {
ProofType::Undefined => unreachable!()
};

let data = std::fs::read(&vk_file)?;
let data = std::fs::read(vk_file)?;
Ok(encode_vk(data))
}

Expand Down Expand Up @@ -336,7 +336,7 @@ mod tests {
None
}
}).collect();
files.sort_by(|a, b| a.cmp(b));
files.sort();

log::info!("files in chunk {:?} is {:?}", path, files);
for file in files {
Expand Down Expand Up @@ -368,9 +368,9 @@ mod tests {
None
}
}).collect();
files.sort_by(|a, b| a.cmp(b));
files.sort();
log::info!("files in batch {:?} is {:?}", batch_path, files);
Ok(files.into_iter().map(|f| (&batch_path).join(f)).collect())
Ok(files.into_iter().map(|f| batch_path.join(f)).collect())
}

fn traces_to_chunk_info(chunk_trace: Vec<BlockTrace>) -> Result<ChunkInfo> {
Expand Down

0 comments on commit 0bc6ac3

Please sign in to comment.