@@ -3,7 +3,6 @@ use aligned_sdk::{
33 constants:: CBOR_ARRAY_MAX_OVERHEAD ,
44 types:: { NoncedVerificationData , VerificationDataCommitment } ,
55 } ,
6- communication:: serialization:: cbor_serialize,
76} ;
87use ethers:: types:: { Address , Signature , U256 } ;
98use priority_queue:: PriorityQueue ;
@@ -124,14 +123,9 @@ pub(crate) type BatchQueue = PriorityQueue<BatchQueueEntry, BatchQueueEntryPrior
124123/// Calculates the size of the batch represented by the given batch queue.
125124pub ( crate ) fn calculate_batch_size ( batch_queue : & BatchQueue ) -> Result < usize , BatcherError > {
126125 let folded_result = batch_queue. iter ( ) . try_fold ( 0 , |acc, ( entry, _) | {
127- if let Ok ( verification_data_bytes) =
128- cbor_serialize ( & entry. nonced_verification_data . verification_data )
129- {
130- let current_batch_size = acc + verification_data_bytes. len ( ) ;
131- ControlFlow :: Continue ( current_batch_size)
132- } else {
133- ControlFlow :: Break ( ( ) )
134- }
126+ let verification_data_size = entry. nonced_verification_data . cbor_size_upper_bound ( ) ;
127+ let current_batch_size = acc + verification_data_size;
128+ ControlFlow :: Continue ( current_batch_size)
135129 } ) ;
136130
137131 if let ControlFlow :: Continue ( batch_size) = folded_result {
@@ -178,10 +172,7 @@ pub(crate) fn extract_batch_directly(
178172 let ( rejected_entry, rejected_priority) = batch_queue. pop ( ) . unwrap ( ) ;
179173
180174 // Update batch size
181- let verification_data_size =
182- cbor_serialize ( & rejected_entry. nonced_verification_data . verification_data )
183- . unwrap ( )
184- . len ( ) ;
175+ let verification_data_size = rejected_entry. nonced_verification_data . cbor_size_upper_bound ( ) ;
185176 batch_size -= verification_data_size;
186177
187178 rejected_entries. push ( ( rejected_entry, rejected_priority) ) ;
0 commit comments