From 0e80cd5e2b5c5cde74433482dd0465987b5579ed Mon Sep 17 00:00:00 2001 From: Zhe Wu Date: Wed, 21 Feb 2024 12:14:55 -0800 Subject: [PATCH] Update retry_times in QuorumDriverTask to u32 (#16325) ## Description Given the recent retry behavior update, u8 may be too small. FailedWithTransientErrorAfterMaximumAttempts is only used inside QuorumDriver, so updating it's field type won't break compatibility. ## Test Plan How did you test the new or updated feature? --- If your changes are not user-facing and do not break anything, you can skip the following section. Otherwise, please briefly describe what has changed under the Release Notes section. ### Type of Change (Check all that apply) - [ ] protocol change - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes --- crates/sui-core/src/quorum_driver/mod.rs | 24 ++++++++++----------- crates/sui-types/src/quorum_driver_types.rs | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/sui-core/src/quorum_driver/mod.rs b/crates/sui-core/src/quorum_driver/mod.rs index cb1230223f409..a5bc9d063fa1b 100644 --- a/crates/sui-core/src/quorum_driver/mod.rs +++ b/crates/sui-core/src/quorum_driver/mod.rs @@ -46,13 +46,13 @@ mod tests; const TASK_QUEUE_SIZE: usize = 2000; const EFFECTS_QUEUE_SIZE: usize = 10000; -const TX_MAX_RETRY_TIMES: u8 = 10; +const TX_MAX_RETRY_TIMES: u32 = 10; #[derive(Clone)] pub struct QuorumDriverTask { pub transaction: Transaction, pub tx_cert: Option, - pub retry_times: u8, + pub retry_times: u32, pub next_retry_after: Instant, } @@ -73,7 +73,7 @@ pub struct QuorumDriver { effects_subscribe_sender: tokio::sync::broadcast::Sender, notifier: Arc>, metrics: Arc, - max_retry_times: u8, + max_retry_times: u32, } impl QuorumDriver { @@ -83,7 +83,7 @@ impl QuorumDriver { effects_subscribe_sender: tokio::sync::broadcast::Sender, notifier: Arc>, metrics: Arc, - max_retry_times: u8, + max_retry_times: u32, ) -> Self { Self { validators, @@ -128,7 +128,7 @@ impl QuorumDriver { &self, transaction: Transaction, tx_cert: Option, - old_retry_times: u8, + old_retry_times: u32, ) -> SuiResult<()> { if old_retry_times >= self.max_retry_times { // max out the retry times, notify failure @@ -153,10 +153,10 @@ impl QuorumDriver { &self, transaction: Transaction, tx_cert: Option, - old_retry_times: u8, + old_retry_times: u32, ) -> SuiResult<()> { let next_retry_after = - Instant::now() + Duration::from_millis(200 * u64::pow(2, old_retry_times.into())); + Instant::now() + Duration::from_millis(200 * u64::pow(2, old_retry_times)); sleep_until(next_retry_after).await; let tx_cert = match tx_cert { @@ -180,7 +180,7 @@ impl QuorumDriver { &self, transaction: &Transaction, response: &QuorumDriverResult, - total_attempts: u8, + total_attempts: u32, ) { let tx_digest = transaction.digest(); let effects_queue_result = match &response { @@ -577,7 +577,7 @@ where notifier: Arc>, reconfig_observer: Arc + Sync + Send>, metrics: Arc, - max_retry_times: u8, + max_retry_times: u32, ) -> Self { let (task_tx, task_rx) = mpsc::channel::(TASK_QUEUE_SIZE); let (subscriber_tx, subscriber_rx) = @@ -787,7 +787,7 @@ where transaction: Transaction, err: Option, tx_cert: Option, - old_retry_times: u8, + old_retry_times: u32, action: &'static str, ) { let tx_digest = *transaction.digest(); @@ -859,7 +859,7 @@ pub struct QuorumDriverHandlerBuilder { metrics: Arc, notifier: Option>>, reconfig_observer: Option + Sync + Send>>, - max_retry_times: u8, + max_retry_times: u32, } impl QuorumDriverHandlerBuilder @@ -893,7 +893,7 @@ where } /// Used in tests when smaller number of retries is desired - pub fn with_max_retry_times(mut self, max_retry_times: u8) -> Self { + pub fn with_max_retry_times(mut self, max_retry_times: u32) -> Self { self.max_retry_times = max_retry_times; self } diff --git a/crates/sui-types/src/quorum_driver_types.rs b/crates/sui-types/src/quorum_driver_types.rs index 3bd22f9a85a4c..51aeab648134c 100644 --- a/crates/sui-types/src/quorum_driver_types.rs +++ b/crates/sui-types/src/quorum_driver_types.rs @@ -48,7 +48,7 @@ pub enum QuorumDriverError { #[error("Transaction timed out before reaching finality")] TimeoutBeforeFinality, #[error("Transaction failed to reach finality with transient error after {total_attempts} attempts.")] - FailedWithTransientErrorAfterMaximumAttempts { total_attempts: u8 }, + FailedWithTransientErrorAfterMaximumAttempts { total_attempts: u32 }, #[error("{NON_RECOVERABLE_ERROR_MSG}: {errors:?}.")] NonRecoverableTransactionError { errors: GroupedErrors }, #[error("Transaction is not processed because {overloaded_stake} of validators by stake are overloaded with certificates pending execution.")]