Skip to content

Commit c0aafb2

Browse files
Add a timeout for the get receipt final calls as alloy does not provide one
1 parent 96e69f9 commit c0aafb2

4 files changed

Lines changed: 26 additions & 10 deletions

File tree

aggregation_mode/proof_aggregator/src/backend/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub struct Config {
2626
pub base_bump_percentage: u64,
2727
pub max_fee_bump_percentage: u64,
2828
pub priority_fee_wei: u128,
29+
pub final_receipt_check_timeout_seconds: u64,
2930
}
3031

3132
impl Config {

aggregation_mode/proof_aggregator/src/backend/mod.rs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -423,33 +423,46 @@ impl ProofAggregator {
423423
}
424424
}
425425

426+
let receipt_timeout = Duration::from_secs(self.config.final_receipt_check_timeout_seconds);
427+
426428
// After exhausting all retry attempts, we iterate over every pending transaction hash
427429
// that was previously submitted with the same nonce but different gas parameters.
428430
// One of these transactions may have been included in a block while we were still
429431
// retrying and waiting on others. By explicitly checking the receipt for each hash,
430432
// we ensure we don't "lose" a transaction that was actually mined but whose receipt
431433
// we never observed due to timeouts during earlier attempts.
432434
for (i, tx_hash) in pending_hashes.into_iter().enumerate() {
433-
match self
434-
.proof_aggregation_service
435-
.provider()
436-
.get_transaction_receipt(tx_hash)
437-
.await
435+
// NOTE: `get_transaction_receipt` has no built-in timeout, so we guard it to
436+
// avoid hanging the aggregator on a stuck RPC call.
437+
match tokio::time::timeout(
438+
receipt_timeout,
439+
self.proof_aggregation_service
440+
.provider()
441+
.get_transaction_receipt(tx_hash),
442+
)
443+
.await
438444
{
439-
Ok(Some(receipt)) => {
445+
Ok(Ok(Some(receipt))) => {
440446
info!("Pending tx #{} confirmed; returning receipt", i + 1);
441447
return Ok(receipt);
442448
}
443-
Ok(None) => {
449+
Ok(Ok(None)) => {
444450
warn!(
445451
"Pending tx #{} still no receipt yet (hash {})",
446452
i + 1,
447453
tx_hash
448454
);
449455
}
450-
Err(err) => {
456+
Ok(Err(err)) => {
451457
warn!("Pending tx #{} receipt query failed: {:?}", i + 1, err);
452458
}
459+
Err(_) => {
460+
warn!(
461+
"Pending tx #{} receipt query timed out after {:?}",
462+
i + 1,
463+
receipt_timeout
464+
);
465+
}
453466
}
454467
}
455468

config-files/config-proof-aggregator-ethereum-package.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ max_bump_retries: 5
3232
bump_retry_interval_seconds: 120
3333
base_bump_percentage: 10
3434
max_fee_bump_percentage: 100
35-
priority_fee_wei: 3000000000 // 3 Gwei
35+
priority_fee_wei: 3000000000 # 3 Gwei
36+
final_receipt_check_timeout_seconds: 5
3637

3738
ecdsa:
3839
private_key_store_path: "config-files/anvil.proof-aggregator.ecdsa.key.json"

config-files/config-proof-aggregator.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ max_bump_retries: 5
3232
bump_retry_interval_seconds: 120
3333
base_bump_percentage: 10
3434
max_fee_bump_percentage: 100
35-
priority_fee_wei: 3000000000 // 3 Gwei
35+
priority_fee_wei: 3000000000 # 3 Gwei
36+
final_receipt_check_timeout_seconds: 5
3637

3738
ecdsa:
3839
private_key_store_path: "config-files/anvil.proof-aggregator.ecdsa.key.json"

0 commit comments

Comments
 (0)