Skip to content

Commit

Permalink
fix an issue in restore results
Browse files Browse the repository at this point in the history
Signed-off-by: noelwei <fan@scroll.io>
  • Loading branch information
noel2004 committed Oct 8, 2024
1 parent b1e121b commit 595b742
Showing 1 changed file with 34 additions and 10 deletions.
44 changes: 34 additions & 10 deletions integration/src/prove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use halo2_proofs::{halo2curves::bn256::Bn256, poly::kzg::commitment::ParamsKZG};
use prover::{
aggregator::Prover as BatchProver, zkevm::Prover as ChunkProver, BatchData, BatchProof,
BatchProvingTask, BundleProvingTask, ChunkInfo, ChunkProof, ChunkProvingTask, MAX_AGG_SNARKS,
Proof as CommonProof,
};
use std::{collections::BTreeMap, env, time::Instant};

Expand Down Expand Up @@ -64,18 +65,41 @@ impl<'params> SP1Prover<'params> {
output_dir,
)?;

let result = ChunkProof::new(
comp_snark,
self.0.prover_impl.pk(Layer2.id()),
chunk_info,
Vec::new(),
);
let pk = self.0.prover_impl.pk(Layer2.id());
// in case we read the snark directly from previous calculation,
// the pk is not avaliable and we use a work-around to construct
// the proof (and dumping is not needed)
if pk.is_none() {
log::info!("restore chunk_snark {chunk_identifier:?} from disk");
// vk must be loaded (dumped along with snark together) in this case
assert!(self.0.get_vk().is_some());
let protocol = serde_json::to_vec(&comp_snark.protocol)?;
let proof = CommonProof::from_snark(
comp_snark,
self.0.get_vk().expect("checked"),
);

Ok(ChunkProof {
proof,
protocol,
chunk_info,
row_usages: Vec::new(),
})

if let (Some(output_dir), Ok(proof)) = (output_dir, &result) {
proof.dump(output_dir, chunk_identifier)?;
} else {
let result = ChunkProof::new(
comp_snark,
pk,
chunk_info,
Vec::new(),
);

if let (Some(output_dir), Ok(proof)) = (output_dir, &result) {
proof.dump(output_dir, chunk_identifier)?;
}

result
}

result
}
}

Expand Down

0 comments on commit 595b742

Please sign in to comment.