diff --git a/Cargo.lock b/Cargo.lock index 29b9547d6d9..4a1fecd2516 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2019,7 +2019,7 @@ dependencies = [ [[package]] name = "mithril-aggregator" -version = "0.2.22" +version = "0.2.23" dependencies = [ "async-trait", "chrono", @@ -2145,7 +2145,7 @@ dependencies = [ [[package]] name = "mithril-signer" -version = "0.2.14" +version = "0.2.15" dependencies = [ "async-trait", "clap 4.1.4", diff --git a/mithril-aggregator/Cargo.toml b/mithril-aggregator/Cargo.toml index 14a15944b8a..63248a30b36 100644 --- a/mithril-aggregator/Cargo.toml +++ b/mithril-aggregator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-aggregator" -version = "0.2.22" +version = "0.2.23" description = "A Mithril Aggregator server" authors = { workspace = true } edition = { workspace = true } diff --git a/mithril-aggregator/src/runtime/runner.rs b/mithril-aggregator/src/runtime/runner.rs index 5df9a41a1c6..79c45f781db 100644 --- a/mithril-aggregator/src/runtime/runner.rs +++ b/mithril-aggregator/src/runtime/runner.rs @@ -627,13 +627,23 @@ impl AggregatorRunnerTrait for AggregatorRunner { .map_err(|e| { RuntimeError::General(format!("Could not get Era information ('{e}')").into()) })?; - self.dependencies.era_checker.change_era( - token.get_current_supported_era().map_err(|e| { - RuntimeError::General(format!("Could not update EraChecker service ('{e}')").into()) - })?, - token.get_current_epoch(), + let current_era = token.get_current_supported_era().map_err(|e| { + RuntimeError::General(format!("Could not update EraChecker service ('{e}')").into()) + })?; + self.dependencies + .era_checker + .change_era(current_era, token.get_current_epoch()); + debug!( + "Current Era is {} (Epoch {}).", + current_era, + token.get_current_epoch() ); + if token.get_next_supported_era().is_err() { + let era_name = &token.get_next_era_marker().unwrap().name; + warn!("Upcoming Era '{era_name}' is not supported by this version of the software. Please update!"); + } + Ok(()) } } diff --git a/mithril-aggregator/src/runtime/state_machine.rs b/mithril-aggregator/src/runtime/state_machine.rs index c31af384fad..741761159e5 100644 --- a/mithril-aggregator/src/runtime/state_machine.rs +++ b/mithril-aggregator/src/runtime/state_machine.rs @@ -101,7 +101,7 @@ impl AggregatorRuntime { loop { if let Err(e) = self.cycle().await { - error!("STATE MACHINE: an error occurred: "; "error" => ?e); + error!("STATE MACHINE: an error occurred: {e}"); } info!( diff --git a/mithril-common/src/era/era_reader.rs b/mithril-common/src/era/era_reader.rs index d5cf1c7c43d..20f69a8c257 100644 --- a/mithril-common/src/era/era_reader.rs +++ b/mithril-common/src/era/era_reader.rs @@ -57,6 +57,7 @@ impl EraEpochToken { /// software. pub fn get_current_supported_era(&self) -> Result { SupportedEra::from_str(&self.current_era.name) + .map_err(|_| UnsupportedEraError::new(&self.current_era.name)) } /// Return the [EraMarker] of the current Era. @@ -75,7 +76,10 @@ impl EraEpochToken { /// for upgrade. pub fn get_next_supported_era(&self) -> Result, UnsupportedEraError> { match self.next_era.as_ref() { - Some(marker) => Ok(Some(SupportedEra::from_str(&marker.name)?)), + Some(marker) => Ok(Some( + SupportedEra::from_str(&marker.name) + .map_err(|_| UnsupportedEraError::new(&self.current_era.name))?, + )), None => Ok(None), } } diff --git a/mithril-common/src/era/supported_era.rs b/mithril-common/src/era/supported_era.rs index 25c66f1f65e..c6a2992af00 100644 --- a/mithril-common/src/era/supported_era.rs +++ b/mithril-common/src/era/supported_era.rs @@ -1,9 +1,22 @@ use serde::{Deserialize, Serialize}; use strum::IntoEnumIterator; use strum_macros::{Display, EnumIter, EnumString}; +use thiserror::Error; /// Error related to [SupportedEra] String parsing implementation. -pub type UnsupportedEraError = strum::ParseError; +#[derive(Debug, Error)] +#[error("Unsupported Era '{era}'.")] +pub struct UnsupportedEraError { + era: String, +} + +impl UnsupportedEraError { + pub fn new(era: &str) -> Self { + Self { + era: era.to_owned(), + } + } +} /// The era that the software is running or will run #[derive( diff --git a/mithril-signer/Cargo.toml b/mithril-signer/Cargo.toml index 0dd21ca9806..d457c20d5f6 100644 --- a/mithril-signer/Cargo.toml +++ b/mithril-signer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-signer" -version = "0.2.14" +version = "0.2.15" description = "A Mithril Signer" authors = { workspace = true } edition = { workspace = true } diff --git a/mithril-signer/src/runtime/runner.rs b/mithril-signer/src/runtime/runner.rs index 07669a4c810..93bcec70971 100644 --- a/mithril-signer/src/runtime/runner.rs +++ b/mithril-signer/src/runtime/runner.rs @@ -444,12 +444,21 @@ impl Runner for SignerRunner { .read_era_epoch_token(epoch) .await .map_err(Box::new)?; - - self.services.era_checker.change_era( - era_token.get_current_supported_era()?, - era_token.get_current_epoch(), + let current_era = era_token.get_current_supported_era()?; + self.services + .era_checker + .change_era(current_era, era_token.get_current_epoch()); + debug!( + "Current Era is {} (Epoch {}).", + current_era, + era_token.get_current_epoch() ); + if era_token.get_next_supported_era().is_err() { + let era_name = &era_token.get_next_era_marker().unwrap().name; + warn!("Upcoming Era '{era_name}' is not supported by this version of the software. Please update!"); + } + Ok(()) } } diff --git a/mithril-signer/src/runtime/state_machine.rs b/mithril-signer/src/runtime/state_machine.rs index 73c9201eb66..a655064e46e 100644 --- a/mithril-signer/src/runtime/state_machine.rs +++ b/mithril-signer/src/runtime/state_machine.rs @@ -97,7 +97,7 @@ impl StateMachine { loop { if let Err(e) = self.cycle().await { - error!("STATE MACHINE: an error occured: "; "error" => ?e); + error!("STATE MACHINE: an error occured: {e}"); } info!( @@ -126,6 +126,7 @@ impl StateMachine { } else if let Some(epoch_settings) = self.runner.get_epoch_settings().await? { info!("→ Epoch settings found"); if epoch_settings.epoch >= *epoch { + info!("new Epoch found"); info!(" ⋅ transiting to REGISTERED"); self.state = self .transition_from_unregistered_to_registered(&epoch_settings)