|
1 | | -use aligned_sdk::{ |
2 | | - common::{ |
3 | | - constants::CBOR_ARRAY_MAX_OVERHEAD, |
4 | | - types::{NoncedVerificationData, VerificationDataCommitment}, |
5 | | - }, |
6 | | - communication::serialization::cbor_serialize, |
| 1 | +use aligned_sdk::common::{ |
| 2 | + constants::CBOR_ARRAY_MAX_OVERHEAD, |
| 3 | + types::{NoncedVerificationData, VerificationDataCommitment}, |
7 | 4 | }; |
8 | 5 | use ethers::types::{Address, Signature, U256}; |
9 | 6 | use priority_queue::PriorityQueue; |
@@ -124,14 +121,9 @@ pub(crate) type BatchQueue = PriorityQueue<BatchQueueEntry, BatchQueueEntryPrior |
124 | 121 | /// Calculates the size of the batch represented by the given batch queue. |
125 | 122 | pub(crate) fn calculate_batch_size(batch_queue: &BatchQueue) -> Result<usize, BatcherError> { |
126 | 123 | 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 | | - } |
| 124 | + let verification_data_size = entry.nonced_verification_data.cbor_size_upper_bound(); |
| 125 | + let current_batch_size = acc + verification_data_size; |
| 126 | + ControlFlow::<usize, usize>::Continue(current_batch_size) |
135 | 127 | }); |
136 | 128 |
|
137 | 129 | if let ControlFlow::Continue(batch_size) = folded_result { |
@@ -178,10 +170,7 @@ pub(crate) fn extract_batch_directly( |
178 | 170 | let (rejected_entry, rejected_priority) = batch_queue.pop().unwrap(); |
179 | 171 |
|
180 | 172 | // Update batch size |
181 | | - let verification_data_size = |
182 | | - cbor_serialize(&rejected_entry.nonced_verification_data.verification_data) |
183 | | - .unwrap() |
184 | | - .len(); |
| 173 | + let verification_data_size = rejected_entry.nonced_verification_data.cbor_size_upper_bound(); |
185 | 174 | batch_size -= verification_data_size; |
186 | 175 |
|
187 | 176 | rejected_entries.push((rejected_entry, rejected_priority)); |
|
0 commit comments