From d322f5e91b31ee43d54bd7da99c04144d59e0222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Wed, 21 Sep 2022 15:20:33 +0100 Subject: [PATCH] Removed the concept of exiting validator API after X consecutive failures (#1643) --- validator-api/src/epoch_operations/mod.rs | 25 +---------------------- 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/validator-api/src/epoch_operations/mod.rs b/validator-api/src/epoch_operations/mod.rs index 62270715eb0..eb0918f2ab5 100644 --- a/validator-api/src/epoch_operations/mod.rs +++ b/validator-api/src/epoch_operations/mod.rs @@ -22,7 +22,6 @@ use mixnet_contract_common::{ use rand::prelude::SliceRandom; use rand::rngs::OsRng; use std::collections::HashSet; -use std::process; use std::time::Duration; use tokio::time::sleep; use validator_client::nymd::SigningNymdClient; @@ -314,20 +313,10 @@ impl RewardedSetUpdater { async fn wait_until_epoch_end(&mut self, shutdown: &mut ShutdownListener) -> Option { const POLL_INTERVAL: Duration = Duration::from_secs(120); - const MAXIMUM_ATTEMPTS: usize = 5; - let mut failed_attempts = 0; loop { let current_interval = match self.current_interval_details().await { Err(err) => { - failed_attempts += 1; - if failed_attempts == MAXIMUM_ATTEMPTS { - error!( - "failed to obtain epoch information {} times in a row. Existing now", - MAXIMUM_ATTEMPTS - ); - process::exit(1); - } error!("failed to obtain information about the current interval - {}. Going to retry in {}s", err, POLL_INTERVAL.as_secs()); tokio::select! { _ = sleep(POLL_INTERVAL) => { @@ -342,8 +331,6 @@ impl RewardedSetUpdater { Ok(interval) => interval, }; - failed_attempts = 0; - if current_interval.is_current_epoch_over { return Some(current_interval.interval); } else { @@ -378,14 +365,7 @@ impl RewardedSetUpdater { ) -> Result<(), RewardingError> { self.validator_cache.wait_for_initial_values().await; - const MAX_FAILURES: usize = 10; - let mut consecutive_failures = 0; while !shutdown.is_shutdown() { - if consecutive_failures == MAX_FAILURES { - error!("We have failed to perform epoch operations {} times in a row. The validator API will shutdown now", MAX_FAILURES); - std::process::exit(1); - } - let interval_details = match self.wait_until_epoch_end(&mut shutdown).await { // received a shutdown None => return Ok(()), @@ -397,10 +377,7 @@ impl RewardedSetUpdater { } if let Err(err) = self.perform_epoch_operations(interval_details).await { error!("failed to perform epoch operations - {}", err); - consecutive_failures += 1; - sleep(Duration::from_secs(5)).await; - } else { - consecutive_failures = 0; + sleep(Duration::from_secs(30)).await; } }