Skip to content

Commit

Permalink
updated logic to continue with broadcast after failed simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKitsune committed Jan 11, 2024
1 parent f324c53 commit c371319
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions src/tasks/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ use std::collections::HashMap;
use std::sync::Arc;
use std::time::Duration;

use ethers::providers::Middleware;
use ethers::middleware::gas_oracle::MiddlewareError;

Check failure on line 5 in src/tasks/broadcast.rs

View workflow job for this annotation

GitHub Actions / cargo test

unused import: `ethers::middleware::gas_oracle::MiddlewareError`
use ethers::middleware::signer::SignerMiddlewareError;
use ethers::providers::{Middleware, ProviderError};
use ethers::types::transaction::eip2718::TypedTransaction;
use ethers::types::transaction::eip2930::AccessList;
use ethers::types::{Address, Eip1559TransactionRequest, NameOrAddress, H256};
Expand Down Expand Up @@ -120,11 +122,30 @@ async fn broadcast_relayer_txs(
);
}
Err(err) => {
tracing::error!(tx_id = tx.id, error = ?err, "Failed to simulate transaction");

// If we fail while broadcasting a tx with nonce `n`,
// it doesn't make sense to broadcast tx with nonce `n + 1`
return Ok(());
match err {
SignerMiddlewareError::MiddlewareError(
ProviderError::JsonRpcClientError(err),
) => {
// In the case that the transaction reverted during simulation, we should still continue to broadcast.
tracing::warn!(
tx_id = tx.id,
error = ?err,
"Transaction reverted during simulation"
);
}

_ => {
tracing::error!(
tx_id = tx.id,
error = ?err,
"Failed to simulate transaction"
);

// If we fail while broadcasting a tx with nonce `n`,
// it doesn't make sense to broadcast tx with nonce `n + 1`
return Ok(());
}
}
}
};

Expand Down

0 comments on commit c371319

Please sign in to comment.