diff --git a/Cargo.lock b/Cargo.lock index 91a9f3150..e7318276a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11899,6 +11899,7 @@ dependencies = [ "tonic 0.12.3", "tonic-web", "tower 0.5.1", + "tracing", ] [[package]] diff --git a/protocol-units/da/movement/protocol/client/Cargo.toml b/protocol-units/da/movement/protocol/client/Cargo.toml index 62acd8002..6a65454e8 100644 --- a/protocol-units/da/movement/protocol/client/Cargo.toml +++ b/protocol-units/da/movement/protocol/client/Cargo.toml @@ -20,6 +20,7 @@ tower = { workspace = true } http-body-util = { workspace = true } bytes = { workspace = true } anyhow = { workspace = true } +tracing = { workspace = true } [lints] diff --git a/protocol-units/da/movement/protocol/client/src/lib.rs b/protocol-units/da/movement/protocol/client/src/lib.rs index a52577be2..85b450b41 100644 --- a/protocol-units/da/movement/protocol/client/src/lib.rs +++ b/protocol-units/da/movement/protocol/client/src/lib.rs @@ -15,12 +15,34 @@ pub enum MovementDaLightNodeClient { impl MovementDaLightNodeClient { /// Creates an http1 connection to the light node service. pub fn try_http1(connection_string: &str) -> Result { - Ok(Self::Http1(http1::Http1::try_new(connection_string)?)) + for _ in 0..5 { + match http1::Http1::try_new(connection_string) { + Ok(result) => return Ok(Self::Http1(result)), + Err(err) => { + tracing::warn!("DA Http1 connection failed: {}. Retrying in 5s...", err); + std::thread::sleep(std::time::Duration::from_secs(5)); + } + } + } + return Err( + anyhow::anyhow!("Error DA Http1 connection failed more than 5 time aborting.",), + ); } /// Creates an http2 connection to the light node service. pub async fn try_http2(connection_string: &str) -> Result { - Ok(Self::Http2(http2::Http2::connect(connection_string).await?)) + for _ in 0..5 { + match http2::Http2::connect(connection_string).await { + Ok(result) => return Ok(Self::Http2(result)), + Err(err) => { + tracing::warn!("DA Http2 connection failed: {}. Retrying in 5s...", err); + std::thread::sleep(std::time::Duration::from_secs(5)); + } + } + } + return Err( + anyhow::anyhow!("Error DA Http2 connection failed more than 5 time aborting.",), + ); } /// Stream reads from a given height. diff --git a/util/godfig/src/backend/config_file/mod.rs b/util/godfig/src/backend/config_file/mod.rs index 1bfd39176..de2def7e1 100644 --- a/util/godfig/src/backend/config_file/mod.rs +++ b/util/godfig/src/backend/config_file/mod.rs @@ -44,7 +44,7 @@ impl ConfigFile { } let json: serde_json::Value = serde_json::from_str(&contents) - .map_err(|e| GodfigBackendError::TypeContractMismatch(e.to_string()))?; + .map_err(|e| GodfigBackendError::ConfigDeserializationError(e.to_string()))?; let keys = key.into(); let mut current = &json; diff --git a/util/godfig/src/backend/mod.rs b/util/godfig/src/backend/mod.rs index de2d0c101..19cca0853 100644 --- a/util/godfig/src/backend/mod.rs +++ b/util/godfig/src/backend/mod.rs @@ -7,8 +7,8 @@ use thiserror::Error; #[derive(Debug, Error)] pub enum GodfigBackendError { - #[error("Type Contract Mismatch")] - TypeContractMismatch(String), + #[error("An error occurs during config deserialization: {0}")] + ConfigDeserializationError(String), #[error("Backend Error: {0}")] BackendError(#[from] anyhow::Error), #[error("IO Error: {0}")] diff --git a/util/signing/interface/src/key/mod.rs b/util/signing/interface/src/key/mod.rs index 2094c355b..0ecdfd4e8 100644 --- a/util/signing/interface/src/key/mod.rs +++ b/util/signing/interface/src/key/mod.rs @@ -220,18 +220,18 @@ impl TryFromCanonicalString for Key { /// Example canonical string: "movement/prod/full_node/mcr_settlement/signer/validator/0" fn try_from_canonical_string(s: &str) -> Result { let parts: Vec<&str> = s.split('/').collect(); - if parts.len() != 7 { - return Err(format!("invalid key: {}", s)); + if parts.len() != 8 { + return Err(format!("invalid key, bad number of elements {:?}: '{}'", parts, s)); } Ok(Self { - org: Organization::try_from_canonical_string(parts[0])?, - environment: Environment::try_from_canonical_string(parts[1])?, - software_unit: SoftwareUnit::try_from_canonical_string(parts[2])?, - usage: Usage::try_from_canonical_string(parts[3])?, - allowed_roles: AllowedRoles::try_from_canonical_string(parts[4])?, - key_name: parts[5].to_string(), - app_replica: Some(parts[6].to_string()), + org: Organization::try_from_canonical_string(parts[1])?, + environment: Environment::try_from_canonical_string(parts[2])?, + software_unit: SoftwareUnit::try_from_canonical_string(parts[3])?, + usage: Usage::try_from_canonical_string(parts[4])?, + allowed_roles: AllowedRoles::try_from_canonical_string(parts[5])?, + key_name: parts[6].to_string(), + app_replica: Some(parts[7].to_string()), }) } }