@@ -10,11 +10,17 @@ use openvm_native_circuit::NativeGpuBuilder as NativeBuilder;
1010
1111use openvm_circuit:: arch:: instructions:: exe:: VmExe ;
1212use openvm_sdk:: { DefaultStarkEngine , config:: SdkVmBuilder } ;
13- use openvm_sdk:: { F , Sdk , StdIn , prover:: StarkProver } ;
13+ use openvm_sdk:: {
14+ F , Sdk , StdIn ,
15+ config:: { AppConfig , SdkVmConfig } ,
16+ prover:: StarkProver ,
17+ } ;
1418use scroll_zkvm_types:: { proof:: OpenVmEvmProof , types_agg:: ProgramCommitment , utils:: serialize_vk} ;
1519use scroll_zkvm_verifier:: verifier:: { AGG_STARK_PROVING_KEY , UniversalVerifier } ;
1620use tracing:: instrument;
1721
22+ type SdkAppConfig = AppConfig < SdkVmConfig > ;
23+
1824// Re-export from openvm_sdk.
1925pub use openvm_sdk:: { self } ;
2026
@@ -31,6 +37,8 @@ pub struct Prover {
3137 pub app_exe : Arc < VmExe < F > > ,
3238 /// Prover configuration.
3339 pub config : ProverConfig ,
40+ /// SDKConfig
41+ app_config : SdkAppConfig ,
3442 /// Lazily initialized SDK
3543 sdk : OnceLock < Sdk > ,
3644 /// Lazily initialized stark prover
@@ -54,11 +62,18 @@ impl Prover {
5462 /// Setup the [`Prover`] given paths to the application's exe and proving key.
5563 #[ instrument( "Prover::setup" ) ]
5664 pub fn setup ( config : ProverConfig , name : Option < & str > ) -> Result < Self , Error > {
65+ let mut app_config = read_app_config ( & config. path_app_config ) ?;
66+ let segment_len = config. segment_len . unwrap_or ( DEFAULT_SEGMENT_SIZE ) ;
67+ let segmentation_limits = & mut app_config. app_vm_config . system . config . segmentation_limits ;
68+ segmentation_limits. max_trace_height = segment_len as u32 ;
69+ segmentation_limits. max_cells = 1_200_000_000_usize ; // For 24G vram
70+
5771 let app_exe = read_app_exe ( & config. path_app_exe ) ?;
5872 Ok ( Self {
5973 app_exe : Arc :: new ( app_exe) ,
6074 config,
6175 prover_name : name. unwrap_or ( "universal" ) . to_string ( ) ,
76+ app_config,
6277 sdk : OnceLock :: new ( ) ,
6378 prover : OnceLock :: new ( ) ,
6479 } )
@@ -74,14 +89,7 @@ impl Prover {
7489 fn get_sdk ( & self ) -> Result < & Sdk , Error > {
7590 self . sdk . get_or_try_init ( || {
7691 tracing:: info!( "Lazy initializing SDK..." ) ;
77- let mut app_config = read_app_config ( & self . config . path_app_config ) ?;
78- let segment_len = self . config . segment_len . unwrap_or ( DEFAULT_SEGMENT_SIZE ) ;
79- let segmentation_limits =
80- & mut app_config. app_vm_config . system . config . segmentation_limits ;
81- segmentation_limits. max_trace_height = segment_len as u32 ;
82- segmentation_limits. max_cells = 1_200_000_000_usize ; // For 24G vram
83-
84- let sdk = Sdk :: new ( app_config) . expect ( "sdk init failed" ) ;
92+ let sdk = Sdk :: new ( self . app_config . clone ( ) ) . expect ( "sdk init failed" ) ;
8593
8694 // 45s for first time
8795 let sdk = sdk. with_agg_pk ( AGG_STARK_PROVING_KEY . clone ( ) ) ;
@@ -157,7 +165,13 @@ impl Prover {
157165 ) -> Result < crate :: utils:: vm:: ExecutionResult , Error > {
158166 let sdk = self . get_sdk ( ) ?;
159167 let t = std:: time:: Instant :: now ( ) ;
160- let exec_result = crate :: utils:: vm:: execute_guest ( sdk, self . app_exe . clone ( ) , stdin) ?;
168+ let exec_result = crate :: utils:: vm:: execute_guest (
169+ sdk,
170+ self . app_config . app_vm_config . as_ref ( ) ,
171+ self . app_exe . clone ( ) ,
172+ stdin,
173+ )
174+ . map_err ( |e| Error :: GenProof ( e. to_string ( ) ) ) ?;
161175 let execution_time_mills = t. elapsed ( ) . as_millis ( ) as u64 ;
162176 let execution_time_s = execution_time_mills as f32 / 1000.0f32 ;
163177 let exec_speed = ( exec_result. total_cycle as f32 / 1_000_000.0f32 ) / execution_time_s; // MHz
0 commit comments