Skip to content

Commit

Permalink
fix batch building (#323)
Browse files Browse the repository at this point in the history
* fix batch building

* log
  • Loading branch information
lispc authored Jun 20, 2024
1 parent ef9cab2 commit 1bb29e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 9 additions & 3 deletions bin/src/chain_prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ impl BatchBuilder {
self.chunks.len()
);

// Condition0: chunk num
let condition0 = self.chunks.len() >= MAX_AGG_SNARKS;
if condition0 {
let batch = self.chunks.clone();
self.reset();
return Some(batch);
}

let compressed_da_size = self.batch_data.get_encoded_batch_data_bytes().len();
let uncompressed_da_size = self
.batch_data
Expand All @@ -81,10 +89,8 @@ impl BatchBuilder {
let condition1 = compressed_da_size >= constants::N_BLOB_BYTES;
// Condition2: uncompressed bytes size
let condition2 = uncompressed_da_size > uncompressed_da_size_limit;
// Condition3: chunk num
let condition3 = self.chunks.len() > MAX_AGG_SNARKS;

let overflow = condition1 || condition2 || condition3;
let overflow = condition1 || condition2;
if overflow {
// pop the last chunk and emit prev chunks
self.chunks.truncate(self.chunks.len() - 1);
Expand Down
1 change: 1 addition & 0 deletions integration/src/prove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub fn prove_and_verify_chunk(
env::set_var("CHUNK_VK_FILENAME", "vk_chunk_0.vkey");
let verifier = ChunkVerifier::from_dirs(params_path, output_dir);
assert!(verifier.verify_chunk_proof(chunk_proof));
log::info!("Verified chunk proof");
}

pub fn prove_and_verify_batch(
Expand Down

0 comments on commit 1bb29e1

Please sign in to comment.