From 921dfa6b1c5ad9ba5f24033a414041f04da624ad Mon Sep 17 00:00:00 2001 From: Noah Citron Date: Sun, 13 Nov 2022 07:50:00 -0500 Subject: [PATCH] fix: better retry timing (#1855) * fix retries * increase default backoff to 1s * remove comment * fmt --- ethers-providers/src/transports/retry.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/ethers-providers/src/transports/retry.rs b/ethers-providers/src/transports/retry.rs index 8112e508..947a0495 100644 --- a/ethers-providers/src/transports/retry.rs +++ b/ethers-providers/src/transports/retry.rs @@ -188,7 +188,7 @@ impl Default for RetryClientBuilder { timeout_retries: 3, // this should be enough to even out heavy loads rate_limit_retries: 10, - initial_backoff: Duration::from_millis(100), + initial_backoff: Duration::from_millis(1000), // alchemy max cpus compute_units_per_second: 330, } @@ -289,13 +289,7 @@ where // try to extract the requested backoff from the error or compute the next backoff // based on retry count let mut next_backoff = self.policy.backoff_hint(&err).unwrap_or_else(|| { - // using `retry_number` for creating back pressure because - // of already queued requests - // this increases exponentially with retries and adds a delay based on how many - // requests are currently queued - Duration::from_millis( - self.initial_backoff.as_millis().pow(rate_limit_retry_number) as u64, - ) + Duration::from_millis(self.initial_backoff.as_millis() as u64) }); // requests are usually weighted and can vary from 10 CU to several 100 CU, cheaper