Skip to content

Commit 426091b

Browse files
chore: add sdk app prove without verify (#2164)
Co-authored-by: Jonathan Wang <[email protected]>
1 parent b804923 commit 426091b

File tree

2 files changed

+32
-17
lines changed

2 files changed

+32
-17
lines changed

crates/sdk/src/commit.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use openvm_stark_sdk::{
1818
};
1919
use serde::{Deserialize, Serialize};
2020
use serde_with::serde_as;
21+
use tracing::instrument;
2122

2223
use crate::{types::BN254_BYTES, F, SC};
2324

@@ -88,6 +89,7 @@ pub struct AppExecutionCommit {
8889
impl AppExecutionCommit {
8990
/// Users should use this function to compute `AppExecutionCommit` and check it against the
9091
/// final proof.
92+
#[instrument(name = "AppExecutionCommit::compute", skip_all)]
9193
pub fn compute<SC: StarkGenericConfig>(
9294
app_memory_config: &MemoryConfig,
9395
app_exe: &VmExe<Val<SC>>,

crates/sdk/src/prover/app.rs

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use openvm_stark_sdk::{
2121
config::baby_bear_poseidon2::BabyBearPoseidon2Engine,
2222
engine::{StarkEngine, StarkFriEngine},
2323
};
24-
use tracing::info_span;
24+
use tracing::instrument;
2525

2626
use crate::{
2727
commit::{AppExecutionCommit, CommitBytes},
@@ -118,9 +118,11 @@ where
118118
}
119119

120120
/// Generates proof for every continuation segment
121-
///
122-
/// This function internally calls [verify_app_proof] to verify the result before returning the
123-
/// proof.
121+
#[instrument(
122+
name = "app_prove",
123+
skip_all,
124+
fields(group = self.program_name.as_ref().unwrap_or(&"app_proof".to_string()))
125+
)]
124126
pub fn prove(
125127
&mut self,
126128
input: StdIn<Val<E::SC>>,
@@ -138,19 +140,30 @@ where
138140
self.vm_config().as_ref(),
139141
&self.instance.vm.engine.fri_params(),
140142
);
141-
let proofs = info_span!(
142-
"app proof",
143-
group = self
144-
.program_name
145-
.as_ref()
146-
.unwrap_or(&"app_proof".to_string())
147-
)
148-
.in_scope(|| {
149-
#[cfg(feature = "metrics")]
150-
metrics::counter!("fri.log_blowup")
151-
.absolute(self.instance.vm.engine.fri_params().log_blowup as u64);
152-
ContinuationVmProver::prove(&mut self.instance, input)
153-
})?;
143+
#[cfg(feature = "metrics")]
144+
metrics::counter!("fri.log_blowup")
145+
.absolute(self.instance.vm.engine.fri_params().log_blowup as u64);
146+
ContinuationVmProver::prove(&mut self.instance, input)
147+
}
148+
149+
/// Generates proof for every continuation segment
150+
///
151+
/// This function internally calls [verify_segments] to verify the result before returning the
152+
/// proof.
153+
///
154+
/// **Note**: This function calls [`app_commit`](Self::app_commit), which is computationally
155+
/// intensive if it is the first time it is called within an `AppProver` instance.
156+
#[instrument(name = "app_prove_and_verify", skip_all)]
157+
pub fn prove_and_verify(
158+
&mut self,
159+
input: StdIn<Val<E::SC>>,
160+
) -> Result<ContinuationVmProof<E::SC>, VirtualMachineError>
161+
where
162+
<VB::VmConfig as VmExecutionConfig<Val<E::SC>>>::Executor: Executor<Val<E::SC>>
163+
+ MeteredExecutor<Val<E::SC>>
164+
+ PreflightExecutor<Val<E::SC>, VB::RecordArena>,
165+
{
166+
let proofs = self.prove(input)?;
154167
// We skip verification of the user public values proof here because it is directly computed
155168
// from the merkle tree above
156169
let res = verify_segments(

0 commit comments

Comments
 (0)