Skip to content

Commit

Permalink
fix: fast fail for incorrect recursion mode
Browse files Browse the repository at this point in the history
  • Loading branch information
keroro520 committed Nov 21, 2024
1 parent 987241b commit 0ab8c38
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions provers/sp1/driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ impl Prover for Sp1Prover {
let param = Sp1Param::deserialize(config.get("sp1").unwrap()).unwrap();
let mode = param.prover.clone().unwrap_or_else(get_env_mock);

if matches!(param.recursion, RecursionMode::Compressed) {
return Err(ProverError::GuestError(
"Compressed proof is used in aggregation mode only".to_owned(),
));
}

println!("param: {param:?}");

let mut stdin = SP1Stdin::new();
Expand Down Expand Up @@ -136,7 +142,9 @@ impl Prover for Sp1Prover {
debug!("Proving locally with recursion mode: {:?}", param.recursion);
match param.recursion {
RecursionMode::Core => prove_action.run(),
RecursionMode::Compressed => prove_action.compressed().run(),
RecursionMode::Compressed => {
unreachable!("Compressed proof is used in aggregation mode only, checked above")
}
RecursionMode::Plonk => prove_action.plonk().run(),
}
.map_err(|e| ProverError::GuestError(format!("Sp1: local proving failed: {e}")))?
Expand Down Expand Up @@ -172,13 +180,7 @@ impl Prover for Sp1Prover {
.map_err(|e| ProverError::GuestError(format!("Sp1: network proof failed {e:?}")))?
};

let proof_bytes = match param.recursion {
RecursionMode::Compressed => {
info!("Compressed proof is used in aggregation mode only");
vec![]
}
_ => prove_result.bytes(),
};
let proof_bytes = prove_result.bytes();
if param.verify && !proof_bytes.is_empty() {
let time = Measurement::start("verify", false);
let pi_hash = prove_result
Expand Down

0 comments on commit 0ab8c38

Please sign in to comment.