Skip to content

Commit

Permalink
feat: optionally skip simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
mattstam committed May 30, 2024
1 parent 3cc3cc6 commit 1d36e43
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions sdk/src/provers/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,28 @@ impl NetworkProver {
mode: ProofMode,
) -> Result<P> {
let client = &self.client;
// Execute the runtime before creating the proof request.
let program = Program::from(elf);
let opts = SP1CoreOpts::default();
let mut runtime = Runtime::new(program, opts);
runtime.write_vecs(&stdin.buffer);
for (proof, vkey) in stdin.proofs.iter() {
runtime.write_proof(proof.clone(), vkey.clone());

let skip_simulation = env::var("SKIP_SIMULATION")
.map(|val| val == "true")
.unwrap_or(false);

// If the simulation is not skipped, execute the runtime before creating the proof request.
if !skip_simulation {
let program = Program::from(elf);
let opts = SP1CoreOpts::default();
let mut runtime = Runtime::new(program, opts);
runtime.write_vecs(&stdin.buffer);
for (proof, vkey) in stdin.proofs.iter() {
runtime.write_proof(proof.clone(), vkey.clone());
}
runtime
.run_untraced()
.context("Failed to execute program")?;

log::info!("Simulation complete, cycles: {}", runtime.state.global_clk);
} else {
log::info!("Skipping simulation");
}
runtime
.run_untraced()
.context("Failed to execute program")?;
log::info!("Simulation complete, cycles: {}", runtime.state.global_clk);

let proof_id = client.create_proof(elf, &stdin, mode).await?;
log::info!("Created {}", proof_id);
Expand Down

0 comments on commit 1d36e43

Please sign in to comment.