Skip to content

Commit a424a40

Browse files
committed
Handle Protocol Initializer errors as critical
1 parent 4147c92 commit a424a40

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

mithril-signer/src/runtime/state_machine.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
use slog_scope::{crit, debug, error, info};
22
use std::{fmt::Display, thread::sleep, time::Duration};
33

4-
use mithril_common::entities::{Beacon, CertificatePending, Epoch, EpochSettings, SignerWithStake};
4+
use mithril_common::{
5+
crypto_helper::ProtocolInitializerError,
6+
entities::{Beacon, CertificatePending, Epoch, EpochSettings, SignerWithStake},
7+
};
58

69
use super::{Runner, RuntimeError};
710

@@ -304,15 +307,18 @@ impl StateMachine {
304307
.map_err(|e| RuntimeError::KeepState {
305308
message: format!("Could not update stake distribution in 'unregistered → registered' phase for epoch {:?}.", beacon.epoch),
306309
nested_error: Some(e) })?;
307-
self.runner
308-
.register_signer_to_aggregator(
309-
epoch_settings.epoch,
310-
&epoch_settings.next_protocol_parameters,
311-
)
312-
.await
313-
.map_err(|e| RuntimeError::KeepState {
314-
message: format!("Could not register to aggregator in 'unregistered → registered' phase for epoch {:?}.", beacon.epoch),
315-
nested_error: Some(e) })?;
310+
311+
self.runner. register_signer_to_aggregator(
312+
epoch_settings.epoch,
313+
&epoch_settings.next_protocol_parameters,
314+
)
315+
.await.map_err(|e| {
316+
if e.downcast_ref::<ProtocolInitializerError>().is_some(){
317+
RuntimeError::Critical { message: format!("Could not register to aggregator in 'unregistered → registered' phase for epoch {:?}.", beacon.epoch), nested_error: Some(e) }
318+
}else{
319+
RuntimeError::KeepState { message: format!("Could not register to aggregator in 'unregistered → registered' phase for epoch {:?}.", beacon.epoch), nested_error: Some(e) }
320+
}
321+
})?;
316322

317323
Ok(SignerState::Registered { beacon })
318324
}

0 commit comments

Comments
 (0)