Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
ratankaliani committed Dec 24, 2024
1 parent b4b5a9f commit 7353e75
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions scripts/utils/bin/fetch_and_save_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ use sp1_sdk::{
GetFilteredProofRequestsRequest, ProofMode,
},
},
NetworkProverV2, SP1ProofWithPublicValues,
NetworkProverV2, Prover, SP1ProofWithPublicValues, SP1Stdin,
};
use std::{env, fs, path::Path, str::FromStr};
use tonic::{
transport::{channel::ClientTlsConfig, Channel},
Code,
};

pub const RANGE_ELF: &[u8] = include_bytes!("../../../elf/range-elf");

#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Args {
Expand Down Expand Up @@ -52,7 +54,7 @@ async fn main() -> Result<()> {
requester: Some(requester.to_vec()),
fulfillment_status: Some(FulfillmentStatus::Fulfilled as i32),
limit: Some(10),
mode: Some(ProofMode::Groth16 as i32),
mode: Some(ProofMode::Compressed as i32),
..Default::default()
};

Expand All @@ -72,14 +74,18 @@ async fn main() -> Result<()> {
let private_key = env::var("SP1_PRIVATE_KEY")?;
let rpc_url = env::var("PROVER_NETWORK_RPC")?;
let prover = NetworkProverV2::new(&private_key.clone(), Some(rpc_url.clone()), false);
let (_, range_vk) = prover.setup(RANGE_ELF);
println!("Fetching proof for request: {:?}", proof_request.request_id);
let proof: SP1ProofWithPublicValues =
let mut proof: SP1ProofWithPublicValues =
prover.wait_proof(&proof_request.request_id, None).await?;
println!("Proof fetched for request: {:?}", proof_request.request_id);

let proof_size = bincode::serialized_size(&proof)?;
let stdin_size = bincode::serialized_size(&proof.stdin)?;

proof.stdin = SP1Stdin::default();
prover.verify(&proof, &range_vk.clone())?;

Ok::<_, anyhow::Error>((proof_size, stdin_size))
})
.buffer_unordered(10)
Expand Down

0 comments on commit 7353e75

Please sign in to comment.