Skip to content

Commit

Permalink
Merge branch 'scroll-v1.3.0-rc2' into scroll-dev-0914
Browse files Browse the repository at this point in the history
  • Loading branch information
lispc committed Sep 23, 2024
2 parents e59735a + 38dba2d commit 09fb4c3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
16 changes: 16 additions & 0 deletions crates/cuda/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,22 @@ impl SP1CudaProver {
.spawn()
.map_err(|e| format!("Failed to start Docker container: {}. Please check your Docker installation and permissions.", e))?;

let stderr = child.stderr.take().unwrap();
std::thread::spawn(move || {
let mut reader = BufReader::new(stderr);
let mut buffer = [0; 1024];
loop {
match reader.read(&mut buffer) {
Ok(0) => break,
Ok(n) => {
std::io::stderr().write_all(&buffer[..n]).unwrap();
std::io::stderr().flush().unwrap();
}
Err(_) => break,
}
}
});

let stdout = child.stdout.take().unwrap();
std::thread::spawn(move || {
let mut reader = BufReader::new(stdout);
Expand Down
19 changes: 18 additions & 1 deletion crates/sdk/src/provers/cuda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ impl Prover<DefaultProverComponents> for CudaProver {

// Generate the core proof.
let proof = self.cuda_prover.prove_core(pk, &stdin)?;

{
tracing::info!("verify core");
self.prover.verify(&proof.proof, &pk.vk).expect("prove core failed");
}
if kind == SP1ProofKind::Core {
return Ok(SP1ProofWithPublicValues {
proof: SP1Proof::Core(proof.proof.0),
Expand All @@ -64,6 +69,10 @@ impl Prover<DefaultProverComponents> for CudaProver {

// Generate the compressed proof.
let reduce_proof = self.cuda_prover.compress(&pk.vk, proof, deferred_proofs)?;
{
tracing::info!("verify compressed");
self.prover.verify_compressed(&reduce_proof, &pk.vk).expect("prove compressed failed");
}
if kind == SP1ProofKind::Compressed {
return Ok(SP1ProofWithPublicValues {
proof: SP1Proof::Compressed(Box::new(reduce_proof)),
Expand All @@ -75,9 +84,17 @@ impl Prover<DefaultProverComponents> for CudaProver {

// Generate the shrink proof.
let compress_proof = self.cuda_prover.shrink(reduce_proof)?;
{
tracing::info!("verify shrink");
self.prover.verify_shrink(&compress_proof, &pk.vk).expect("prove shrink failed");
}

// Genenerate the wrap proof.
let outer_proof = self.cuda_prover.wrap_bn254(compress_proof)?;
let outer_proof = self.prover.wrap_bn254(compress_proof, _opts.sp1_prover_opts)?;
{
tracing::info!("verify wrap bn254");
self.prover.verify_wrap_bn254(&outer_proof, &pk.vk).expect("prove wrap bn254 failed");
}

if kind == SP1ProofKind::Plonk {
let plonk_bn254_aritfacts = if sp1_prover::build::sp1_dev_mode() {
Expand Down

0 comments on commit 09fb4c3

Please sign in to comment.