Skip to content

Commit 0b425aa

Browse files
authored
Merge pull request #768 from input-output-hk/greg/add_signer_era_warning
make signer warn when coming era is unsupported
2 parents 24ea177 + 943bf59 commit 0b425aa

File tree

9 files changed

+54
-17
lines changed

9 files changed

+54
-17
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-aggregator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-aggregator"
3-
version = "0.2.22"
3+
version = "0.2.23"
44
description = "A Mithril Aggregator server"
55
authors = { workspace = true }
66
edition = { workspace = true }

mithril-aggregator/src/runtime/runner.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -627,13 +627,23 @@ impl AggregatorRunnerTrait for AggregatorRunner {
627627
.map_err(|e| {
628628
RuntimeError::General(format!("Could not get Era information ('{e}')").into())
629629
})?;
630-
self.dependencies.era_checker.change_era(
631-
token.get_current_supported_era().map_err(|e| {
632-
RuntimeError::General(format!("Could not update EraChecker service ('{e}')").into())
633-
})?,
634-
token.get_current_epoch(),
630+
let current_era = token.get_current_supported_era().map_err(|e| {
631+
RuntimeError::General(format!("Could not update EraChecker service ('{e}')").into())
632+
})?;
633+
self.dependencies
634+
.era_checker
635+
.change_era(current_era, token.get_current_epoch());
636+
debug!(
637+
"Current Era is {} (Epoch {}).",
638+
current_era,
639+
token.get_current_epoch()
635640
);
636641

642+
if token.get_next_supported_era().is_err() {
643+
let era_name = &token.get_next_era_marker().unwrap().name;
644+
warn!("Upcoming Era '{era_name}' is not supported by this version of the software. Please update!");
645+
}
646+
637647
Ok(())
638648
}
639649
}

mithril-aggregator/src/runtime/state_machine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl AggregatorRuntime {
101101

102102
loop {
103103
if let Err(e) = self.cycle().await {
104-
error!("STATE MACHINE: an error occurred: "; "error" => ?e);
104+
error!("STATE MACHINE: an error occurred: {e}");
105105
}
106106

107107
info!(

mithril-common/src/era/era_reader.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ impl EraEpochToken {
5757
/// software.
5858
pub fn get_current_supported_era(&self) -> Result<SupportedEra, UnsupportedEraError> {
5959
SupportedEra::from_str(&self.current_era.name)
60+
.map_err(|_| UnsupportedEraError::new(&self.current_era.name))
6061
}
6162

6263
/// Return the [EraMarker] of the current Era.
@@ -75,7 +76,10 @@ impl EraEpochToken {
7576
/// for upgrade.
7677
pub fn get_next_supported_era(&self) -> Result<Option<SupportedEra>, UnsupportedEraError> {
7778
match self.next_era.as_ref() {
78-
Some(marker) => Ok(Some(SupportedEra::from_str(&marker.name)?)),
79+
Some(marker) => Ok(Some(
80+
SupportedEra::from_str(&marker.name)
81+
.map_err(|_| UnsupportedEraError::new(&self.current_era.name))?,
82+
)),
7983
None => Ok(None),
8084
}
8185
}

mithril-common/src/era/supported_era.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
use serde::{Deserialize, Serialize};
22
use strum::IntoEnumIterator;
33
use strum_macros::{Display, EnumIter, EnumString};
4+
use thiserror::Error;
45

56
/// Error related to [SupportedEra] String parsing implementation.
6-
pub type UnsupportedEraError = strum::ParseError;
7+
#[derive(Debug, Error)]
8+
#[error("Unsupported Era '{era}'.")]
9+
pub struct UnsupportedEraError {
10+
era: String,
11+
}
12+
13+
impl UnsupportedEraError {
14+
pub fn new(era: &str) -> Self {
15+
Self {
16+
era: era.to_owned(),
17+
}
18+
}
19+
}
720

821
/// The era that the software is running or will run
922
#[derive(

mithril-signer/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-signer"
3-
version = "0.2.14"
3+
version = "0.2.15"
44
description = "A Mithril Signer"
55
authors = { workspace = true }
66
edition = { workspace = true }

mithril-signer/src/runtime/runner.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,21 @@ impl Runner for SignerRunner {
444444
.read_era_epoch_token(epoch)
445445
.await
446446
.map_err(Box::new)?;
447-
448-
self.services.era_checker.change_era(
449-
era_token.get_current_supported_era()?,
450-
era_token.get_current_epoch(),
447+
let current_era = era_token.get_current_supported_era()?;
448+
self.services
449+
.era_checker
450+
.change_era(current_era, era_token.get_current_epoch());
451+
debug!(
452+
"Current Era is {} (Epoch {}).",
453+
current_era,
454+
era_token.get_current_epoch()
451455
);
452456

457+
if era_token.get_next_supported_era().is_err() {
458+
let era_name = &era_token.get_next_era_marker().unwrap().name;
459+
warn!("Upcoming Era '{era_name}' is not supported by this version of the software. Please update!");
460+
}
461+
453462
Ok(())
454463
}
455464
}

mithril-signer/src/runtime/state_machine.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl StateMachine {
9797

9898
loop {
9999
if let Err(e) = self.cycle().await {
100-
error!("STATE MACHINE: an error occured: "; "error" => ?e);
100+
error!("STATE MACHINE: an error occured: {e}");
101101
}
102102

103103
info!(
@@ -126,6 +126,7 @@ impl StateMachine {
126126
} else if let Some(epoch_settings) = self.runner.get_epoch_settings().await? {
127127
info!("→ Epoch settings found");
128128
if epoch_settings.epoch >= *epoch {
129+
info!("new Epoch found");
129130
info!(" ⋅ transiting to REGISTERED");
130131
self.state = self
131132
.transition_from_unregistered_to_registered(&epoch_settings)

0 commit comments

Comments
 (0)