1- use std:: { env, iter:: repeat} ;
1+ use std:: { collections :: BTreeMap , env, iter:: repeat} ;
22
3- use aggregator:: { BatchHash , BatchHeader , ChunkInfo , MAX_AGG_SNARKS } ;
3+ use aggregator:: {
4+ eip4844:: decode_blob, BatchData , BatchHash , BatchHeader , ChunkInfo , MAX_AGG_SNARKS ,
5+ } ;
46use anyhow:: { bail, Result } ;
57use eth_types:: H256 ;
8+ use halo2_proofs:: { halo2curves:: bn256:: Bn256 , poly:: kzg:: commitment:: ParamsKZG } ;
69use sha2:: { Digest , Sha256 } ;
710use snark_verifier_sdk:: Snark ;
811
912use crate :: {
1013 common,
11- config:: { LayerId , AGG_DEGREES } ,
14+ config:: LayerId ,
1215 consts:: { BATCH_KECCAK_ROW , BATCH_VK_FILENAME , BUNDLE_VK_FILENAME , CHUNK_PROTOCOL_FILENAME } ,
1316 io:: { force_to_read, try_to_read} ,
1417 proof:: BundleProof ,
@@ -17,20 +20,23 @@ use crate::{
1720} ;
1821
1922#[ derive( Debug ) ]
20- pub struct Prover {
23+ pub struct Prover < ' params > {
2124 // Make it public for testing with inner functions (unnecessary for FFI).
22- pub prover_impl : common:: Prover ,
25+ pub prover_impl : common:: Prover < ' params > ,
2326 pub chunk_protocol : Vec < u8 > ,
2427 raw_vk_batch : Option < Vec < u8 > > ,
2528 raw_vk_bundle : Option < Vec < u8 > > ,
2629}
2730
28- impl Prover {
29- pub fn from_dirs ( params_dir : & str , assets_dir : & str ) -> Self {
31+ impl < ' params > Prover < ' params > {
32+ pub fn from_params_and_assets (
33+ params_map : & ' params BTreeMap < u32 , ParamsKZG < Bn256 > > ,
34+ assets_dir : & str ,
35+ ) -> Self {
3036 log:: debug!( "set env KECCAK_ROWS={}" , BATCH_KECCAK_ROW . to_string( ) ) ;
3137 env:: set_var ( "KECCAK_ROWS" , BATCH_KECCAK_ROW . to_string ( ) ) ;
3238
33- let prover_impl = common:: Prover :: from_params_dir ( params_dir , & AGG_DEGREES ) ;
39+ let prover_impl = common:: Prover :: from_params_map ( params_map ) ;
3440 let chunk_protocol = force_to_read ( assets_dir, & CHUNK_PROTOCOL_FILENAME ) ;
3541
3642 let raw_vk_batch = try_to_read ( assets_dir, & BATCH_VK_FILENAME ) ;
@@ -208,6 +214,16 @@ impl Prover {
208214 let batch_hash = batch_header. batch_hash ( ) ;
209215 let batch_info: BatchHash < N_SNARKS > =
210216 BatchHash :: construct ( & chunk_hashes, batch_header, & batch. blob_bytes ) ;
217+ let batch_data: BatchData < N_SNARKS > = BatchData :: from ( & batch_info) ;
218+
219+ // sanity check:
220+ // - conditionally decoded blob should match batch data.
221+ let batch_bytes = batch_data. get_batch_data_bytes ( ) ;
222+ let decoded_blob_bytes = decode_blob ( & batch. blob_bytes ) ?;
223+ assert_eq ! (
224+ batch_bytes, decoded_blob_bytes,
225+ "BatchProvingTask(sanity) mismatch batch bytes and decoded blob bytes" ,
226+ ) ;
211227
212228 let layer3_snark = self . prover_impl . load_or_gen_agg_snark (
213229 name,
0 commit comments