From 9ba2eda2214983a094e9f2bbc9a2d5c84d40c2c5 Mon Sep 17 00:00:00 2001 From: Robin Salen <30937548+Nashtare@users.noreply.github.com> Date: Sun, 1 Sep 2024 10:49:32 -0400 Subject: [PATCH] `trace_decoder`: Tweak batch size for small blocks (#576) * Tweak small batch sizes * Add explanation --- trace_decoder/src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/trace_decoder/src/lib.rs b/trace_decoder/src/lib.rs index 3e0ba29f8..ba3552fcd 100644 --- a/trace_decoder/src/lib.rs +++ b/trace_decoder/src/lib.rs @@ -287,7 +287,7 @@ pub struct BlockLevelData { pub fn entrypoint( trace: BlockTrace, other: OtherBlockData, - batch_size: usize, + mut batch_size: usize, use_burn_addr: bool, ) -> anyhow::Result> { use anyhow::Context as _; @@ -398,6 +398,12 @@ pub fn entrypoint( ) .collect::(); + // Make sure the batch size is smaller than the total number of transactions, + // or we would need to generate dummy proofs for the aggregation layers. + if batch_size > txn_info.len() { + batch_size = txn_info.len() / 2 + 1; + } + let last_tx_idx = txn_info.len().saturating_sub(1) / batch_size; let mut txn_info = txn_info