Skip to content

Commit

Permalink
Update retry_times in QuorumDriverTask to u32 (#16325)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
halfprice authored Feb 21, 2024
1 parent feb5c72 commit 0e80cd5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions crates/sui-core/src/quorum_driver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CertifiedTransaction>,
pub retry_times: u8,
pub retry_times: u32,
pub next_retry_after: Instant,
}

Expand All @@ -73,7 +73,7 @@ pub struct QuorumDriver<A: Clone> {
effects_subscribe_sender: tokio::sync::broadcast::Sender<QuorumDriverEffectsQueueResult>,
notifier: Arc<NotifyRead<TransactionDigest, QuorumDriverResult>>,
metrics: Arc<QuorumDriverMetrics>,
max_retry_times: u8,
max_retry_times: u32,
}

impl<A: Clone> QuorumDriver<A> {
Expand All @@ -83,7 +83,7 @@ impl<A: Clone> QuorumDriver<A> {
effects_subscribe_sender: tokio::sync::broadcast::Sender<QuorumDriverEffectsQueueResult>,
notifier: Arc<NotifyRead<TransactionDigest, QuorumDriverResult>>,
metrics: Arc<QuorumDriverMetrics>,
max_retry_times: u8,
max_retry_times: u32,
) -> Self {
Self {
validators,
Expand Down Expand Up @@ -128,7 +128,7 @@ impl<A: Clone> QuorumDriver<A> {
&self,
transaction: Transaction,
tx_cert: Option<CertifiedTransaction>,
old_retry_times: u8,
old_retry_times: u32,
) -> SuiResult<()> {
if old_retry_times >= self.max_retry_times {
// max out the retry times, notify failure
Expand All @@ -153,10 +153,10 @@ impl<A: Clone> QuorumDriver<A> {
&self,
transaction: Transaction,
tx_cert: Option<CertifiedTransaction>,
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 {
Expand All @@ -180,7 +180,7 @@ impl<A: Clone> QuorumDriver<A> {
&self,
transaction: &Transaction,
response: &QuorumDriverResult,
total_attempts: u8,
total_attempts: u32,
) {
let tx_digest = transaction.digest();
let effects_queue_result = match &response {
Expand Down Expand Up @@ -577,7 +577,7 @@ where
notifier: Arc<NotifyRead<TransactionDigest, QuorumDriverResult>>,
reconfig_observer: Arc<dyn ReconfigObserver<A> + Sync + Send>,
metrics: Arc<QuorumDriverMetrics>,
max_retry_times: u8,
max_retry_times: u32,
) -> Self {
let (task_tx, task_rx) = mpsc::channel::<QuorumDriverTask>(TASK_QUEUE_SIZE);
let (subscriber_tx, subscriber_rx) =
Expand Down Expand Up @@ -787,7 +787,7 @@ where
transaction: Transaction,
err: Option<QuorumDriverError>,
tx_cert: Option<CertifiedTransaction>,
old_retry_times: u8,
old_retry_times: u32,
action: &'static str,
) {
let tx_digest = *transaction.digest();
Expand Down Expand Up @@ -859,7 +859,7 @@ pub struct QuorumDriverHandlerBuilder<A: Clone> {
metrics: Arc<QuorumDriverMetrics>,
notifier: Option<Arc<NotifyRead<TransactionDigest, QuorumDriverResult>>>,
reconfig_observer: Option<Arc<dyn ReconfigObserver<A> + Sync + Send>>,
max_retry_times: u8,
max_retry_times: u32,
}

impl<A> QuorumDriverHandlerBuilder<A>
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-types/src/quorum_driver_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.")]
Expand Down

0 comments on commit 0e80cd5

Please sign in to comment.