@@ -7,7 +7,7 @@ use super::{
77use crate :: {
88 aggregators:: {
99 risc0_aggregator:: Risc0ProofReceiptAndImageId , sp1_aggregator:: SP1ProofWithPubValuesAndElf ,
10- AlignedProof ,
10+ AlignedProof , ZKVMEngine ,
1111 } ,
1212 backend:: s3:: get_aligned_batch_from_s3,
1313} ;
@@ -50,7 +50,7 @@ impl ProofsFetcher {
5050 }
5151 }
5252
53- pub async fn fetch ( & self ) -> Result < Vec < AlignedProof > , ProofsFetcherError > {
53+ pub async fn fetch ( & self , engine : ZKVMEngine ) -> Result < Vec < AlignedProof > , ProofsFetcherError > {
5454 let from_block = self . get_block_number_to_fetch_from ( ) . await ?;
5555 info ! (
5656 "Fetching proofs from batch logs starting from block number {}" ,
@@ -87,37 +87,47 @@ impl ProofsFetcher {
8787 info ! ( "Data downloaded from S3, number of proofs {}" , data. len( ) ) ;
8888
8989 // Filter compatible proofs to be aggregated and push to queue
90- let proofs_to_add: Vec < AlignedProof > = data
91- . into_iter ( )
92- . filter_map ( |p| match p. proving_system {
93- ProvingSystemId :: SP1 => {
94- let elf = p. vm_program_code ?;
95- let proof_with_pub_values = bincode:: deserialize ( & p. proof ) . ok ( ) ?;
96- let sp1_proof = SP1ProofWithPubValuesAndElf {
97- proof_with_pub_values,
98- elf,
99- } ;
100-
101- Some ( AlignedProof :: SP1 ( sp1_proof) )
102- }
103- ProvingSystemId :: Risc0 => {
104- let mut image_id = [ 0u8 ; 32 ] ;
105- image_id. copy_from_slice ( p. vm_program_code ?. as_slice ( ) ) ;
106- let public_inputs = p. pub_input ?;
107- let inner_receipt: risc0_zkvm:: InnerReceipt =
108- bincode:: deserialize ( & p. proof ) . ok ( ) ?;
109-
110- let receipt = Receipt :: new ( inner_receipt, public_inputs) ;
111- let risc0_proof = Risc0ProofReceiptAndImageId { image_id, receipt } ;
112-
113- Some ( AlignedProof :: Risc0 ( risc0_proof) )
114- }
115- _ => None ,
116- } )
117- . collect ( ) ;
90+ let proofs_to_add: Vec < AlignedProof > = match engine {
91+ ZKVMEngine :: SP1 => data
92+ . into_iter ( )
93+ . filter_map ( |p| match p. proving_system {
94+ ProvingSystemId :: SP1 => {
95+ let elf = p. vm_program_code ?;
96+ let proof_with_pub_values = bincode:: deserialize ( & p. proof ) . ok ( ) ?;
97+ let sp1_proof = SP1ProofWithPubValuesAndElf {
98+ proof_with_pub_values,
99+ elf,
100+ } ;
101+
102+ Some ( AlignedProof :: SP1 ( sp1_proof) )
103+ }
104+
105+ _ => None ,
106+ } )
107+ . collect ( ) ,
108+ ZKVMEngine :: RISC0 => data
109+ . into_iter ( )
110+ . filter_map ( |p| match p. proving_system {
111+ ProvingSystemId :: Risc0 => {
112+ let mut image_id = [ 0u8 ; 32 ] ;
113+ image_id. copy_from_slice ( p. vm_program_code ?. as_slice ( ) ) ;
114+ let public_inputs = p. pub_input ?;
115+ let inner_receipt: risc0_zkvm:: InnerReceipt =
116+ bincode:: deserialize ( & p. proof ) . ok ( ) ?;
117+
118+ let receipt = Receipt :: new ( inner_receipt, public_inputs) ;
119+ let risc0_proof = Risc0ProofReceiptAndImageId { image_id, receipt } ;
120+
121+ Some ( AlignedProof :: Risc0 ( risc0_proof) )
122+ }
123+ _ => None ,
124+ } )
125+ . collect ( ) ,
126+ } ;
118127
119128 info ! (
120- "Proofs filtered, total proofs to add {}" ,
129+ "{} Proofs filtered, compatible proofs found {}" ,
130+ engine,
121131 proofs_to_add. len( )
122132 ) ;
123133
0 commit comments