Skip to content

Commit

Permalink
chore: pass clippy (#420)
Browse files Browse the repository at this point in the history
Running `cargo clippy --features ${TASKDB},sp1,risc0,sgx -- -D warnings`
generates some clippy errors.

Co-authored-by: smtmfft <[email protected]>
  • Loading branch information
keroro520 and smtmfft authored Nov 28, 2024
1 parent 89f748f commit fdbef53
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 34 deletions.
62 changes: 32 additions & 30 deletions harness/macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,45 +59,47 @@ pub fn entrypoint(input: TokenStream) -> TokenStream {
};
}

#[cfg(feature = "sp1")]
let output = quote! {
// Set up a global allocator
use sp1_zkvm::heap::SimpleAlloc;
#[global_allocator]
static HEAP: SimpleAlloc = SimpleAlloc;
let output = if cfg!(feature = "sp1") {
quote! {
// Set up a global allocator
use sp1_zkvm::heap::SimpleAlloc;
#[global_allocator]
static HEAP: SimpleAlloc = SimpleAlloc;

#[cfg(test)]
#tests_entry
#[cfg(test)]
#tests_entry

#[cfg(not(test))]
const ZKVM_ENTRY: fn() = #main_entry;
#[cfg(test)]
const ZKVM_ENTRY: fn() = run_tests;
#[cfg(not(test))]
const ZKVM_ENTRY: fn() = #main_entry;
#[cfg(test)]
const ZKVM_ENTRY: fn() = run_tests;

mod zkvm_generated_main {
#[no_mangle]
fn main() {
super::ZKVM_ENTRY()
mod zkvm_generated_main {
#[no_mangle]
fn main() {
super::ZKVM_ENTRY()
}
}
}
};

#[cfg(feature = "risc0")]
let output = quote! {
#[cfg(test)]
#tests_entry
} else if cfg!(feature = "risc0") {
quote! {
#[cfg(test)]
#tests_entry

#[cfg(not(test))]
const ZKVM_ENTRY: fn() = #main_entry;
#[cfg(test)]
const ZKVM_ENTRY: fn() = run_tests;
#[cfg(not(test))]
const ZKVM_ENTRY: fn() = #main_entry;
#[cfg(test)]
const ZKVM_ENTRY: fn() = run_tests;

mod zkvm_generated_main {
#[no_mangle]
fn main() {
super::ZKVM_ENTRY()
mod zkvm_generated_main {
#[no_mangle]
fn main() {
super::ZKVM_ENTRY()
}
}
}
} else {
quote! {}
};

output.into()
Expand Down
2 changes: 1 addition & 1 deletion provers/risc0/driver/src/bonsai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ pub fn prove_locally(

let segment_dir = PathBuf::from("/tmp/risc0-cache");
if !segment_dir.exists() {
fs::create_dir(segment_dir.clone()).map_err(|e| ProverError::FileIo(e))?;
fs::create_dir(segment_dir.clone()).map_err(ProverError::FileIo)?;
}
let env = env_builder
.segment_path(segment_dir)
Expand Down
4 changes: 2 additions & 2 deletions provers/risc0/driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl Prover for Risc0Prover {
let proof_key = (
input.chain_spec.chain_id,
input.block.header.number,
output.hash.clone(),
output.hash,
RISC0_PROVER_CODE,
);

Expand Down Expand Up @@ -188,7 +188,7 @@ impl Prover for Risc0Prover {
proof: snark_proof,
receipt: serde_json::to_string(&receipt).unwrap(),
uuid: "".to_owned(),
input: B256::from_slice(&receipt.journal.digest().as_bytes()),
input: B256::from_slice(receipt.journal.digest().as_bytes()),
}
.into());

Expand Down
2 changes: 1 addition & 1 deletion provers/risc0/driver/src/snarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ pub async fn verify_groth16_snark_impl(
tracing_info!("Verifying SNARK:");
tracing_info!("Seal: {}", hex::encode(&enc_seal));
tracing_info!("Image ID: {}", hex::encode(image_id.as_bytes()));
tracing_info!("Post State Digest: {}", hex::encode(&post_state_digest));
tracing_info!("Post State Digest: {}", hex::encode(post_state_digest));
tracing_info!("Journal Digest: {}", hex::encode(journal_digest));
let verify_call_res = IRiscZeroVerifier::new(groth16_verifier_addr, http_client)
.verify(
Expand Down

0 comments on commit fdbef53

Please sign in to comment.