@@ -47,7 +47,7 @@ pub struct ProveTransactionResult {
4747/// The prover is generic over the runner, allowing different implementations
4848/// (RPC-based, mock, etc.) to be used interchangeably.
4949#[ derive( Clone ) ]
50- pub ( crate ) struct VirtualSnosProver < R : VirtualSnosRunner > {
50+ pub struct VirtualSnosProver < R : VirtualSnosRunner > {
5151 /// Runner for executing the virtual OS.
5252 runner : R ,
5353 /// Whether to validate that fee-related fields (resource bounds, tip) are zero.
@@ -60,7 +60,7 @@ pub(crate) struct VirtualSnosProver<R: VirtualSnosRunner> {
6060}
6161
6262/// Type alias for the RPC-based virtual SNOS prover.
63- pub ( crate ) type RpcVirtualSnosProver = VirtualSnosProver < RpcRunnerFactory > ;
63+ pub type RpcVirtualSnosProver = VirtualSnosProver < RpcRunnerFactory > ;
6464
6565impl VirtualSnosProver < RpcRunnerFactory > {
6666 /// Creates a new VirtualSnosProver from configuration.
@@ -292,24 +292,51 @@ impl<R: VirtualSnosRunner + 'static> VirtualSnosProver<R> {
292292 /// Generates a proof from the given [`RunnerOutput`] and converts the program output into
293293 /// proof facts.
294294 #[ cfg( feature = "stwo_proving" ) ]
295- async fn prove_virtual_snos_run (
295+ pub async fn prove_virtual_snos_run (
296296 & self ,
297297 runner_output : RunnerOutput ,
298298 ) -> Result < ProveTransactionResult , VirtualSnosProverError > {
299- use starknet_api:: transaction:: fields:: VIRTUAL_SNOS ;
299+ prove_virtual_snos_run_with_precomputes ( runner_output, self . precomputes . clone ( ) ) . await
300+ }
301+ }
302+
303+ /// Proves a Virtual Starknet OS run fdirectly from a `RunnerOutput`.
304+ #[ cfg( feature = "stwo_proving" ) ]
305+ pub async fn prove_virtual_snos_run (
306+ runner_output : RunnerOutput ,
307+ ) -> Result < ProveTransactionResult , VirtualSnosProverError > {
308+ let precomputes = prepare_recursive_prover_precomputes ( )
309+ . expect ( "Failed to prepare recursive prover precomputes" ) ;
310+ prove_virtual_snos_run_with_precomputes ( runner_output, precomputes) . await
311+ }
300312
301- use crate :: proving:: prover:: prove;
313+ #[ cfg( not( feature = "stwo_proving" ) ) ]
314+ pub async fn prove_virtual_snos_run (
315+ _runner_output : RunnerOutput ,
316+ ) -> Result < ProveTransactionResult , VirtualSnosProverError > {
317+ unimplemented ! (
318+ "In-memory proving requires the `stwo_proving` feature flag and a nightly Rust toolchain."
319+ ) ;
320+ }
321+
322+ #[ cfg( feature = "stwo_proving" ) ]
323+ async fn prove_virtual_snos_run_with_precomputes (
324+ runner_output : RunnerOutput ,
325+ precomputes : Arc < RecursiveProverPrecomputes > ,
326+ ) -> Result < ProveTransactionResult , VirtualSnosProverError > {
327+ use starknet_api:: transaction:: fields:: VIRTUAL_SNOS ;
302328
303- let prover_output = prove ( runner_output. cairo_pie , self . precomputes . clone ( ) ) . await ?;
304- // Convert program output to proof facts using VIRTUAL_SNOS variant marker.
305- let proof_facts = prover_output. program_output . try_into_proof_facts ( VIRTUAL_SNOS ) ?;
329+ use crate :: proving:: prover:: prove;
306330
307- Ok ( ProveTransactionResult {
308- proof : prover_output. proof ,
309- proof_facts,
310- l2_to_l1_messages : runner_output. l2_to_l1_messages ,
311- } )
312- }
331+ let prover_output = prove ( runner_output. cairo_pie , precomputes) . await ?;
332+ // Convert program output to proof facts using VIRTUAL_SNOS variant marker.
333+ let proof_facts = prover_output. program_output . try_into_proof_facts ( VIRTUAL_SNOS ) ?;
334+
335+ Ok ( ProveTransactionResult {
336+ proof : prover_output. proof ,
337+ proof_facts,
338+ l2_to_l1_messages : runner_output. l2_to_l1_messages ,
339+ } )
313340}
314341
315342/// Extracts the RPC Invoke V3 transaction, rejecting other transaction types.
0 commit comments