Skip to content

Commit f8ddb52

Browse files
Move the waiting method to below the one that does both tasks to improve readability
1 parent 9857933 commit f8ddb52

1 file changed

Lines changed: 45 additions & 45 deletions

File tree

  • aggregation_mode/proof_aggregator/src/backend

aggregation_mode/proof_aggregator/src/backend/mod.rs

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -325,51 +325,6 @@ impl ProofAggregator {
325325
Ok((blob, blob_versioned_hash))
326326
}
327327

328-
async fn wait_until_can_submit_aggregated_proof(
329-
&self,
330-
) -> Result<(), RetryError<AggregatedProofSubmissionError>> {
331-
info!("Started waiting until we can submit the aggregated proof.");
332-
333-
// We start on 24 hours because the proof aggregator runs once a day, so the time elapsed
334-
// should be considered over a 24h period.
335-
let mut time_elapsed = Duration::from_secs(24 * 3600);
336-
337-
// Sleep for 3 minutes (15 blocks) before re-evaluating on each iteration
338-
let time_to_sleep = Duration::from_secs(180);
339-
340-
// Iterate until we can send the proof on-chain
341-
loop {
342-
// Fetch gas price from network
343-
let gas_price = self
344-
.proof_aggregation_service
345-
.provider()
346-
.get_gas_price()
347-
.await
348-
.map_err(|e| {
349-
RetryError::Transient(AggregatedProofSubmissionError::GasPriceError(
350-
e.to_string(),
351-
))
352-
})?;
353-
354-
info!("Fetched gas price from network: {gas_price}");
355-
356-
if eth::should_send_proof_to_verify_on_chain(
357-
time_elapsed,
358-
self.config.monthly_budget_eth,
359-
U256::from(gas_price),
360-
) {
361-
break;
362-
} else {
363-
info!("Skipping sending proof to ProofAggregationService contract due to budget/time constraints.");
364-
}
365-
366-
time_elapsed += time_to_sleep;
367-
sleep(time_to_sleep).await;
368-
}
369-
370-
Ok(())
371-
}
372-
373328
pub async fn wait_and_send_proof_to_verify_on_chain(
374329
&self,
375330
blob: BlobTransactionSidecar,
@@ -465,4 +420,49 @@ impl ProofAggregator {
465420

466421
Ok(receipt)
467422
}
423+
424+
async fn wait_until_can_submit_aggregated_proof(
425+
&self,
426+
) -> Result<(), RetryError<AggregatedProofSubmissionError>> {
427+
info!("Started waiting until we can submit the aggregated proof.");
428+
429+
// We start on 24 hours because the proof aggregator runs once a day, so the time elapsed
430+
// should be considered over a 24h period.
431+
let mut time_elapsed = Duration::from_secs(24 * 3600);
432+
433+
// Sleep for 3 minutes (15 blocks) before re-evaluating on each iteration
434+
let time_to_sleep = Duration::from_secs(180);
435+
436+
// Iterate until we can send the proof on-chain
437+
loop {
438+
// Fetch gas price from network
439+
let gas_price = self
440+
.proof_aggregation_service
441+
.provider()
442+
.get_gas_price()
443+
.await
444+
.map_err(|e| {
445+
RetryError::Transient(AggregatedProofSubmissionError::GasPriceError(
446+
e.to_string(),
447+
))
448+
})?;
449+
450+
info!("Fetched gas price from network: {gas_price}");
451+
452+
if eth::should_send_proof_to_verify_on_chain(
453+
time_elapsed,
454+
self.config.monthly_budget_eth,
455+
U256::from(gas_price),
456+
) {
457+
break;
458+
} else {
459+
info!("Skipping sending proof to ProofAggregationService contract due to budget/time constraints.");
460+
}
461+
462+
time_elapsed += time_to_sleep;
463+
sleep(time_to_sleep).await;
464+
}
465+
466+
Ok(())
467+
}
468468
}

0 commit comments

Comments
 (0)