Skip to content

Commit

Permalink
Timeout per submission
Browse files Browse the repository at this point in the history
  • Loading branch information
mwtian committed Nov 1, 2024
1 parent af81507 commit 11a581e
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions crates/sui-core/src/quorum_driver/transaction_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ use sui_types::{
FinalizedEffects, QuorumDriverError,
},
};
use tokio::{task::JoinSet, time::sleep};
use tokio::{
task::JoinSet,
time::{sleep, timeout},
};

use crate::{authority_aggregator::AuthorityAggregator, authority_client::AuthorityAPI};

Expand Down Expand Up @@ -104,8 +107,9 @@ where
// Send the transaction to a random validator.
let clients = auth_agg.authority_clients.iter().collect::<Vec<_>>();
let (name, client) = clients.choose(&mut rand::thread_rng()).unwrap();
let response = client
.submit_transaction(
let response = timeout(
Duration::from_secs(2),
client.submit_transaction(
HandleTransactionRequestV2 {
transaction: tx,
include_events: request.include_events,
Expand All @@ -114,11 +118,11 @@ where
include_auxiliary_data: request.include_auxiliary_data,
},
options.forwarded_client_addr,
)
.await
.map_err(|e| {
QuorumDriverError::RpcFailure(name.concise().to_string(), e.to_string())
})?;
),
)
.await
.map_err(|_| QuorumDriverError::TimeoutBeforeFinality)?
.map_err(|e| QuorumDriverError::RpcFailure(name.concise().to_string(), e.to_string()))?;

Ok(ExecuteTransactionResponseV3 {
effects: FinalizedEffects {
Expand Down

0 comments on commit 11a581e

Please sign in to comment.