Skip to content

Commit 9bc03de

Browse files
committed
verify batch limits
1 parent 5e21e62 commit 9bc03de

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

  • batcher/aligned-batcher/src

batcher/aligned-batcher/src/lib.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,20 @@ impl Batcher {
10471047
let verification_data_comm = verification_data.clone().into();
10481048
info!("Adding verification data to batch...");
10491049

1050+
let mut queue_len = batch_state_lock.batch_queue.len();
1051+
let mut queue_size_bytes = calculate_batch_size(&batch_state_lock.batch_queue)?;
1052+
1053+
if let Ok(verification_data_bytes) =
1054+
cbor_serialize(&verification_data.verification_data)
1055+
{
1056+
if queue_len + 1 > self.max_batch_proof_qty ||
1057+
queue_size_bytes + verification_data_bytes.len() + CBOR_ARRAY_MAX_OVERHEAD > self.max_batch_byte_size
1058+
{
1059+
// do something
1060+
}
1061+
}
1062+
1063+
10501064
let max_fee = verification_data.max_fee;
10511065
let nonce = verification_data.nonce;
10521066
batch_state_lock.batch_queue.push(
@@ -1061,8 +1075,8 @@ impl Batcher {
10611075
);
10621076

10631077
// Update metrics
1064-
let queue_len = batch_state_lock.batch_queue.len();
1065-
let queue_size_bytes = calculate_batch_size(&batch_state_lock.batch_queue)?;
1078+
queue_len = batch_state_lock.batch_queue.len();
1079+
queue_size_bytes = calculate_batch_size(&batch_state_lock.batch_queue)?;
10661080
self.metrics
10671081
.update_queue_metrics(queue_len as i64, queue_size_bytes as i64);
10681082

0 commit comments

Comments
 (0)