@@ -7,18 +7,14 @@ use itertools::Itertools;
77pub use operation:: * ;
88use plonky2:: {
99 hash:: poseidon:: PoseidonHash ,
10- plonk:: {
11- circuit_builder:: CircuitBuilder ,
12- circuit_data:: { CircuitConfig , CommonCircuitData , ProverCircuitData } ,
13- config:: Hasher ,
14- } ,
10+ plonk:: { circuit_data:: CommonCircuitData , config:: Hasher } ,
1511 util:: serialization:: { Buffer , Read } ,
1612} ;
1713pub use statement:: * ;
1814
1915use crate :: {
2016 backends:: plonky2:: {
21- basetypes:: { Proof , ProofWithPublicInputs , VerifierOnlyCircuitData , C , D } ,
17+ basetypes:: { Proof , ProofWithPublicInputs , VerifierOnlyCircuitData , D } ,
2218 circuits:: mainpod:: {
2319 CustomPredicateVerification , MainPodVerifyInput , MainPodVerifyTarget , NUM_PUBLIC_INPUTS ,
2420 } ,
@@ -281,11 +277,13 @@ pub(crate) fn layout_statements(
281277 }
282278
283279 // Input main pods region
284- let empty_pod_box: Box < dyn RecursivePod > = if mock {
285- MockEmptyPod :: new ( params)
286- } else {
287- EmptyPod :: new ( params, inputs. vds_root ) ?
288- } ;
280+ let empty_pod_box: Box < dyn RecursivePod > =
281+ if mock || inputs. recursive_pods . len ( ) == params. max_input_recursive_pods {
282+ // We mocking or we don't need padding so we skip creating an EmptyPod
283+ MockEmptyPod :: new_boxed ( params)
284+ } else {
285+ EmptyPod :: new_boxed ( params, inputs. vds_root )
286+ } ;
289287 let empty_pod = empty_pod_box. as_ref ( ) ;
290288 assert ! ( inputs. recursive_pods. len( ) <= params. max_input_recursive_pods) ;
291289 for i in 0 ..params. max_input_recursive_pods {
@@ -408,32 +406,23 @@ pub struct Prover {}
408406
409407impl Prover {
410408 fn _prove ( & self , params : & Params , inputs : MainPodInputs ) -> Result < MainPod > {
411- let config = CircuitConfig :: standard_recursion_config ( ) ;
412- let mut builder = CircuitBuilder :: < F , D > :: new ( config) ;
413-
414409 let rec_circuit_data = & * STANDARD_REC_MAIN_POD_CIRCUIT_DATA ;
415410 // println!("DBG recursive MainPod build BEGIN");
416- let ( _, circuit_data) = RecursiveCircuit :: < MainPodVerifyTarget > :: circuit_data_padded (
417- params. max_input_recursive_pods ,
418- & rec_circuit_data. common ,
419- params,
420- ) ?;
411+ let ( main_pod_target, circuit_data) =
412+ RecursiveCircuit :: < MainPodVerifyTarget > :: circuit_data_padded (
413+ params. max_input_recursive_pods ,
414+ & rec_circuit_data. common ,
415+ params,
416+ ) ?;
421417 let rec_params = RecursiveParams {
422418 arity : params. max_input_recursive_pods ,
423419 common_data : circuit_data. common . clone ( ) ,
424420 verifier_data : circuit_data. verifier_data ( ) ,
425421 } ;
426- let main_pod_target = RecursiveCircuit :: < MainPodVerifyTarget > :: build_targets (
427- & mut builder,
428- params. max_input_recursive_pods ,
429- & rec_circuit_data. common ,
430- params,
431- ) ?;
432422 // println!("DBG recursive MainPod build END");
433- let prover: ProverCircuitData < F , C , D > = builder. build_prover :: < C > ( ) ;
434423 let main_pod = RecursiveCircuit {
435424 params : rec_params,
436- prover,
425+ prover : circuit_data . prover_data ( ) ,
437426 target : main_pod_target,
438427 } ;
439428
@@ -449,7 +438,12 @@ impl Prover {
449438 . collect_vec ( ) ;
450439
451440 // Pad input recursive pods with empty pods if necessary
452- let empty_pod = EmptyPod :: new ( params, inputs. vds_root ) ?;
441+ let empty_pod = if inputs. recursive_pods . len ( ) == params. max_input_recursive_pods {
442+ // We don't need padding so we skip creating an EmptyPod
443+ MockEmptyPod :: new_boxed ( params)
444+ } else {
445+ EmptyPod :: new_boxed ( params, inputs. vds_root )
446+ } ;
453447 let inputs = MainPodInputs {
454448 recursive_pods : & inputs
455449 . recursive_pods
@@ -574,10 +568,11 @@ impl MainPod {
574568 }
575569
576570 // 1, 3, 4, 5 verification via the zkSNARK proof
571+ let rec_circuit_data = & * STANDARD_REC_MAIN_POD_CIRCUIT_DATA ;
577572 // TODO: cache these artefacts
578- let rec_params = recursion :: new_params :: < MainPodVerifyTarget > (
573+ let ( _ , circuit_data ) = RecursiveCircuit :: < MainPodVerifyTarget > :: circuit_data_padded (
579574 self . params . max_input_recursive_pods ,
580- NUM_PUBLIC_INPUTS ,
575+ & rec_circuit_data . common ,
581576 & self . params ,
582577 ) ?;
583578 let public_inputs = id
@@ -586,8 +581,7 @@ impl MainPod {
586581 . chain ( self . vds_root . 0 . iter ( ) )
587582 . cloned ( )
588583 . collect_vec ( ) ;
589- rec_params
590- . verifier_data ( )
584+ circuit_data
591585 . verify ( ProofWithPublicInputs {
592586 proof : self . proof . clone ( ) ,
593587 public_inputs,
@@ -829,10 +823,7 @@ pub mod tests {
829823 max_statements : 26 ,
830824 max_public_statements : 5 ,
831825 max_signed_pod_values : 8 ,
832- max_statement_args : 3 ,
833- max_operation_args : 4 ,
834- max_custom_predicate_arity : 4 ,
835- max_custom_batch_size : 3 ,
826+ max_operation_args : 5 ,
836827 max_custom_predicate_wildcards : 6 ,
837828 max_custom_predicate_verifications : 8 ,
838829 ..Default :: default ( )
0 commit comments