From baec5a689b3f1c1e4edd233eb518c6c385167481 Mon Sep 17 00:00:00 2001 From: Zhang Zhuo Date: Tue, 30 Apr 2024 21:35:58 +0800 Subject: [PATCH 1/2] add Runtime::dry_run --- core/src/runtime/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/src/runtime/mod.rs b/core/src/runtime/mod.rs index e1c8b21fc8..faadccf96d 100644 --- a/core/src/runtime/mod.rs +++ b/core/src/runtime/mod.rs @@ -912,6 +912,12 @@ impl Runtime { while !self.execute() {} } + pub fn dry_run(&mut self) -> u64 { + self.emit_events = false; + while !self.execute() {} + self.state.global_clk + } + /// Executes up to `self.shard_batch_size` cycles of the program, returning whether the program has finished. fn execute(&mut self) -> bool { if self.state.global_clk == 0 { From 387ae096bbd624064ec00aa20b8b2ca57bbd3f0b Mon Sep 17 00:00:00 2001 From: Zhang Zhuo Date: Fri, 10 May 2024 23:24:32 +0800 Subject: [PATCH 2/2] merge with upstream --- core/src/runtime/mod.rs | 3 +-- prover/src/utils.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/core/src/runtime/mod.rs b/core/src/runtime/mod.rs index 85e4c9da5c..d7df282284 100644 --- a/core/src/runtime/mod.rs +++ b/core/src/runtime/mod.rs @@ -912,10 +912,9 @@ impl Runtime { while !self.execute() {} } - pub fn dry_run(&mut self) -> u64 { + pub fn dry_run(&mut self) { self.emit_events = false; while !self.execute() {} - self.state.global_clk } /// Executes up to `self.shard_batch_size` cycles of the program, returning whether the program has finished. diff --git a/prover/src/utils.rs b/prover/src/utils.rs index 8daa6cb6c0..40807bd080 100644 --- a/prover/src/utils.rs +++ b/prover/src/utils.rs @@ -48,7 +48,7 @@ pub fn get_cycles(elf: &[u8], stdin: &SP1Stdin) -> u64 { let program = Program::from(elf); let mut runtime = Runtime::new(program); runtime.write_vecs(&stdin.buffer); - runtime.run(); + runtime.dry_run(); runtime.state.global_clk }