Skip to content

Commit 2e1dfce

Browse files
handle the same nonce for the transaction on bumps
1 parent 019e4bb commit 2e1dfce

1 file changed

Lines changed: 28 additions & 3 deletions

File tree

  • aggregation_mode/proof_aggregator/src/backend

aggregation_mode/proof_aggregator/src/backend/mod.rs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,16 +338,34 @@ impl ProofAggregator {
338338

339339
let mut last_error: Option<AggregatedProofSubmissionError> = None;
340340

341+
// Get the nonce once at the beginning and reuse it for all retries
342+
let nonce = self
343+
.proof_aggregation_service
344+
.provider()
345+
.get_transaction_count(*self.proof_aggregation_service.address())
346+
.await
347+
.map_err(|e| {
348+
RetryError::Transient(
349+
AggregatedProofSubmissionError::SendVerifyAggregatedProofTransaction(format!(
350+
"Failed to get nonce: {e}"
351+
)),
352+
)
353+
})?;
354+
355+
info!("Using nonce {} for all retry attempts", nonce);
356+
341357
for attempt in 0..max_retries {
342358
info!("Transaction attempt {} of {}", attempt + 1, max_retries);
343359

344-
// Wrap the entire transaction submission in a result to catch all errors
360+
// Wrap the entire transaction submission in a result to catch all errors, passing
361+
// the same nonce to all attempts
345362
let attempt_result = self
346363
.try_submit_transaction(
347364
&blob,
348365
blob_versioned_hash,
349366
aggregated_proof,
350367
attempt as u64,
368+
nonce,
351369
)
352370
.await;
353371

@@ -364,7 +382,7 @@ impl ProofAggregator {
364382
last_error = Some(err);
365383

366384
if attempt < max_retries - 1 {
367-
info!("Retrying with bumped gas fees...");
385+
info!("Retrying with bumped gas fees and same nonce {}...", nonce);
368386

369387
tokio::time::sleep(Duration::from_millis(500)).await;
370388
} else {
@@ -388,6 +406,7 @@ impl ProofAggregator {
388406
blob_versioned_hash: [u8; 32],
389407
aggregated_proof: &AlignedProof,
390408
attempt: u64,
409+
nonce: u64,
391410
) -> Result<TransactionReceipt, AggregatedProofSubmissionError> {
392411
let retry_interval = Duration::from_secs(self.config.bump_retry_interval_seconds);
393412
let base_bump_percentage = self.config.base_bump_percentage;
@@ -422,6 +441,9 @@ impl ProofAggregator {
422441
}
423442
};
424443

444+
// Set the nonce explicitly
445+
tx_req = tx_req.with_nonce(nonce);
446+
425447
// Apply gas fee bump for retries
426448
if attempt > 0 {
427449
tx_req = self
@@ -480,7 +502,10 @@ impl ProofAggregator {
480502
))
481503
})?;
482504

483-
info!("Transaction sent, waiting for confirmation...");
505+
info!(
506+
"Transaction sent with nonce {}, waiting for confirmation...",
507+
nonce
508+
);
484509

485510
// Wait for the receipt with timeout
486511
let receipt_result = tokio::time::timeout(retry_interval, pending_tx.get_receipt()).await;

0 commit comments

Comments
 (0)