|
17 | 17 | * along with this program. If not, see <https://www.gnu.org/licenses/>.
|
18 | 18 | */
|
19 | 19 |
|
20 |
| -use alloy_primitives::{Address, FixedBytes, Uint, U256, U64}; |
| 20 | +use alloy_primitives::{Address, FixedBytes, Uint, U256}; |
21 | 21 | use alloy_sol_types::SolEvent;
|
22 | 22 | use backoff::Error::Permanent;
|
23 | 23 | use std::cmp::min;
|
@@ -1131,6 +1131,11 @@ impl ChainListener {
|
1131 | 1131 | if let Some(ref ccp_client) = self.ccp_client {
|
1132 | 1132 | let batch_requests = self.get_batch_request();
|
1133 | 1133 |
|
| 1134 | + if batch_requests.is_empty() { |
| 1135 | + tracing::debug!(target: "chain-listener", "No compute units to poll proofs for. Probably all CUs have reached max proofs count"); |
| 1136 | + return Ok(()); |
| 1137 | + } |
| 1138 | + |
1134 | 1139 | let proof_batches = if self.is_epoch_ending() {
|
1135 | 1140 | let last_known_proofs = batch_requests
|
1136 | 1141 | .into_iter()
|
@@ -1419,17 +1424,19 @@ impl ChainListener {
|
1419 | 1424 | let mut batch_request = HashMap::new();
|
1420 | 1425 | for cu_id in self.cc_compute_units.keys() {
|
1421 | 1426 | let sent_proofs_count = self.proof_tracker.get_proof_counter(cu_id);
|
1422 |
| - let proofs_needed = U64::from( |
1423 |
| - self.max_proofs_per_epoch |
1424 |
| - .checked_add(-sent_proofs_count) |
1425 |
| - .unwrap_or(Uint::ZERO), |
1426 |
| - ) |
1427 |
| - .as_limbs()[0] as usize; |
| 1427 | + let proofs_needed = self |
| 1428 | + .max_proofs_per_epoch |
| 1429 | + .checked_sub(sent_proofs_count) |
| 1430 | + .unwrap_or(Uint::ZERO) |
| 1431 | + .as_limbs()[0]; |
1428 | 1432 |
|
1429 | 1433 | if proofs_needed > 0 {
|
1430 | 1434 | let request = BatchRequest {
|
1431 | 1435 | last_seen_proof_idx: self.proof_tracker.get_last_submitted_proof_id(cu_id),
|
1432 |
| - proof_batch_size: min(proofs_needed, self.listener_config.max_proof_batch_size), |
| 1436 | + proof_batch_size: min( |
| 1437 | + proofs_needed as usize, |
| 1438 | + self.listener_config.max_proof_batch_size, |
| 1439 | + ), |
1433 | 1440 | };
|
1434 | 1441 |
|
1435 | 1442 | batch_request.insert(*cu_id, request);
|
|
0 commit comments