@@ -993,6 +993,8 @@ pub fn generate_witness<'a, E: ExtensionField>(
993993 system_config : & ConstraintSystemConfig < E > ,
994994 mut emul_result : EmulationResult < ' a > ,
995995 program : & Program ,
996+ // this is for debug purpose, which only run target shard id and skip all others
997+ target_shard_id : Option < usize > ,
996998) -> impl Iterator < Item = ( ZKVMWitnesses < E > , ShardContext < ' a > , PublicValues ) > {
997999 let mut shard_ctx_builder = std:: mem:: take ( & mut emul_result. shard_ctx_builder ) ;
9981000 let all_records = std:: mem:: take ( & mut emul_result. all_records ) ;
@@ -1038,6 +1040,21 @@ pub fn generate_witness<'a, E: ExtensionField>(
10381040 let current_shard_end_pc = all_records[ cur_index..end] . last ( ) . unwrap ( ) . pc ( ) . after . 0 ;
10391041
10401042 let mut zkvm_witness = ZKVMWitnesses :: default ( ) ;
1043+
1044+ if let Some ( target_shard_id) = target_shard_id {
1045+ if shard_ctx. shard_id < target_shard_id {
1046+ tracing:: debug!( "{}th shard skipped" , shard_ctx. shard_id) ;
1047+ // update next round start
1048+ // early stop and return empty zkvm witness, skipped all the potiential cost
1049+ cur_index = end;
1050+ return Some ( ( zkvm_witness, shard_ctx, pi) ) ;
1051+ } else if shard_ctx. shard_id > target_shard_id {
1052+ tracing:: debug!( "{}th shard skipped" , shard_ctx. shard_id) ;
1053+ return None ;
1054+ }
1055+ // go ahead to generate witness
1056+ }
1057+
10411058 let time = std:: time:: Instant :: now ( ) ;
10421059 // assign opcode circuits
10431060 let dummy_records = system_config
@@ -1353,6 +1370,8 @@ pub fn run_e2e_with_checkpoint<
13531370 public_io : & [ u32 ] ,
13541371 max_steps : usize ,
13551372 checkpoint : Checkpoint ,
1373+ // for debug purpose
1374+ target_shard_id : Option < usize > ,
13561375) -> E2ECheckpointResult < E , PCS > {
13571376 let start = std:: time:: Instant :: now ( ) ;
13581377 let ctx = setup_program :: < E > ( program, platform, multi_prover) ;
@@ -1377,7 +1396,13 @@ pub fn run_e2e_with_checkpoint<
13771396 proofs : None ,
13781397 vk : Some ( vk) ,
13791398 next_step : Some ( Box :: new ( move || {
1380- _ = run_e2e_proof :: < E , _ , _ , _ > ( & prover, & init_full_mem, max_steps, is_mock_proving)
1399+ _ = run_e2e_proof :: < E , _ , _ , _ > (
1400+ & prover,
1401+ & init_full_mem,
1402+ max_steps,
1403+ is_mock_proving,
1404+ target_shard_id,
1405+ )
13811406 } ) ) ,
13821407 } ;
13831408 }
@@ -1408,12 +1433,22 @@ pub fn run_e2e_with_checkpoint<
14081433 & prover. pk . program_ctx . as_ref ( ) . unwrap ( ) . system_config ,
14091434 emul_result,
14101435 & prover. pk . program_ctx . as_ref ( ) . unwrap ( ) . program ,
1436+ target_shard_id,
14111437 )
14121438 } ) ) ,
14131439 } ;
14141440 }
14151441
1416- let zkvm_proofs = create_proofs_helper ( emul_result, & prover, is_mock_proving) ;
1442+ let zkvm_proofs = create_proofs_helper ( emul_result, & prover, is_mock_proving, target_shard_id) ;
1443+
1444+ if target_shard_id. is_some ( ) {
1445+ // skip verify as the proof are in-completed
1446+ return E2ECheckpointResult {
1447+ proofs : Some ( zkvm_proofs) ,
1448+ vk : Some ( vk) ,
1449+ next_step : None ,
1450+ } ;
1451+ }
14171452
14181453 let verifier = ZKVMVerifier :: new ( vk. clone ( ) ) ;
14191454
@@ -1451,6 +1486,8 @@ pub fn run_e2e_proof<
14511486 init_full_mem : & InitMemState ,
14521487 max_steps : usize ,
14531488 is_mock_proving : bool ,
1489+ // for debug purpose
1490+ target_shard_id : Option < usize > ,
14541491) -> Vec < ZKVMProof < E , PCS > > {
14551492 let ctx = prover. pk . program_ctx . as_ref ( ) . unwrap ( ) ;
14561493 // Emulate program
@@ -1461,7 +1498,7 @@ pub fn run_e2e_proof<
14611498 & ctx. platform ,
14621499 & ctx. multi_prover ,
14631500 ) ;
1464- create_proofs_helper ( emul_result, prover, is_mock_proving)
1501+ create_proofs_helper ( emul_result, prover, is_mock_proving, target_shard_id )
14651502}
14661503
14671504/// defines a lightweight CPU -> GPU pipeline for witness generation and proof creation.
@@ -1499,6 +1536,7 @@ fn create_proofs_helper<
14991536 emulation_result : EmulationResult ,
15001537 prover : & ZKVMProver < E , PCS , PB , PD > ,
15011538 is_mock_proving : bool ,
1539+ target_shard_id : Option < usize > ,
15021540) -> Vec < ZKVMProof < E , PCS > > {
15031541 let ctx = prover. pk . program_ctx . as_ref ( ) . unwrap ( ) ;
15041542 #[ cfg( feature = "gpu" ) ]
@@ -1510,9 +1548,20 @@ fn create_proofs_helper<
15101548 // cpu producer
15111549 s. spawn ( {
15121550 move || {
1513- for proof_input in
1514- generate_witness ( & ctx. system_config , emulation_result, & ctx. program )
1515- {
1551+ let wit_iter = generate_witness (
1552+ & ctx. system_config ,
1553+ emulation_result,
1554+ & ctx. program ,
1555+ target_shard_id,
1556+ ) ;
1557+
1558+ let wit_iter = if let Some ( target_shard_id) = target_shard_id {
1559+ Box :: new ( wit_iter. skip ( target_shard_id) ) as Box < dyn Iterator < Item = _ > >
1560+ } else {
1561+ Box :: new ( wit_iter)
1562+ } ;
1563+
1564+ for proof_input in wit_iter {
15161565 tx. send ( proof_input) . unwrap ( )
15171566 }
15181567 }
@@ -1552,9 +1601,20 @@ fn create_proofs_helper<
15521601 #[ cfg( not( feature = "gpu" ) ) ]
15531602 {
15541603 // Generate witness
1555- let zkvm_witness = generate_witness ( & ctx. system_config , emulation_result, & ctx. program ) ;
1604+ let wit_iter = generate_witness (
1605+ & ctx. system_config ,
1606+ emulation_result,
1607+ & ctx. program ,
1608+ target_shard_id,
1609+ ) ;
15561610
1557- zkvm_witness
1611+ let wit_iter = if let Some ( target_shard_id) = target_shard_id {
1612+ Box :: new ( wit_iter. skip ( target_shard_id) ) as Box < dyn Iterator < Item = _ > >
1613+ } else {
1614+ Box :: new ( wit_iter)
1615+ } ;
1616+
1617+ wit_iter
15581618 . map ( |( zkvm_witness, shard_ctx, pi) | {
15591619 if is_mock_proving {
15601620 MockProver :: assert_satisfied_full (
0 commit comments