1
- use std:: { env, iter:: repeat} ;
1
+ use std:: { collections :: BTreeMap , env, iter:: repeat} ;
2
2
3
- use aggregator:: { BatchHash , BatchHeader , ChunkInfo , MAX_AGG_SNARKS } ;
3
+ use aggregator:: {
4
+ eip4844:: decode_blob, BatchData , BatchHash , BatchHeader , ChunkInfo , MAX_AGG_SNARKS ,
5
+ } ;
4
6
use anyhow:: { bail, Result } ;
5
7
use eth_types:: H256 ;
8
+ use halo2_proofs:: { halo2curves:: bn256:: Bn256 , poly:: kzg:: commitment:: ParamsKZG } ;
6
9
use sha2:: { Digest , Sha256 } ;
7
10
use snark_verifier_sdk:: Snark ;
8
11
9
12
use crate :: {
10
13
common,
11
- config:: { LayerId , AGG_DEGREES } ,
14
+ config:: LayerId ,
12
15
consts:: { BATCH_KECCAK_ROW , BATCH_VK_FILENAME , BUNDLE_VK_FILENAME , CHUNK_PROTOCOL_FILENAME } ,
13
16
io:: { force_to_read, try_to_read} ,
14
17
proof:: BundleProof ,
@@ -17,20 +20,23 @@ use crate::{
17
20
} ;
18
21
19
22
#[ derive( Debug ) ]
20
- pub struct Prover {
23
+ pub struct Prover < ' params > {
21
24
// Make it public for testing with inner functions (unnecessary for FFI).
22
- pub prover_impl : common:: Prover ,
25
+ pub prover_impl : common:: Prover < ' params > ,
23
26
pub chunk_protocol : Vec < u8 > ,
24
27
raw_vk_batch : Option < Vec < u8 > > ,
25
28
raw_vk_bundle : Option < Vec < u8 > > ,
26
29
}
27
30
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 {
30
36
log:: debug!( "set env KECCAK_ROWS={}" , BATCH_KECCAK_ROW . to_string( ) ) ;
31
37
env:: set_var ( "KECCAK_ROWS" , BATCH_KECCAK_ROW . to_string ( ) ) ;
32
38
33
- let prover_impl = common:: Prover :: from_params_dir ( params_dir , & AGG_DEGREES ) ;
39
+ let prover_impl = common:: Prover :: from_params_map ( params_map ) ;
34
40
let chunk_protocol = force_to_read ( assets_dir, & CHUNK_PROTOCOL_FILENAME ) ;
35
41
36
42
let raw_vk_batch = try_to_read ( assets_dir, & BATCH_VK_FILENAME ) ;
@@ -208,6 +214,16 @@ impl Prover {
208
214
let batch_hash = batch_header. batch_hash ( ) ;
209
215
let batch_info: BatchHash < N_SNARKS > =
210
216
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
+ ) ;
211
227
212
228
let layer3_snark = self . prover_impl . load_or_gen_agg_snark (
213
229
name,
0 commit comments