From cb82b91fd99807af38ae9a7ad95d579dc36c7bb3 Mon Sep 17 00:00:00 2001 From: Dylan Duan Date: Fri, 27 Dec 2024 09:49:41 +0800 Subject: [PATCH 1/4] refactor: Update VSS parsing error --- mutiny-core/src/error.rs | 2 ++ mutiny-core/src/vss.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mutiny-core/src/error.rs b/mutiny-core/src/error.rs index 3dc7c811c..a0ce90a05 100644 --- a/mutiny-core/src/error.rs +++ b/mutiny-core/src/error.rs @@ -176,6 +176,8 @@ pub enum MutinyError { /// Failed to authenticate using JWT #[error("Failed to authenticate using JWT.")] JwtAuthFailure, + #[error("Failed to parse VSS value from getObject response.")] + FailedParsingVssValue, #[error(transparent)] Other(anyhow::Error), } diff --git a/mutiny-core/src/vss.rs b/mutiny-core/src/vss.rs index 3057a0545..b739c76cd 100644 --- a/mutiny-core/src/vss.rs +++ b/mutiny-core/src/vss.rs @@ -168,7 +168,7 @@ impl MutinyVssClient { .await .map_err(|e| { log_error!(self.logger, "Error parsing get objects response: {e}"); - MutinyError::Other(anyhow!("Error parsing get objects response: {e}")) + MutinyError::FailedParsingVssValue })?; result.decrypt(&self.encryption_key) From c5a6300c34a108b84478169a5eb1e2a152b6e5f0 Mon Sep 17 00:00:00 2001 From: Dylan Duan Date: Fri, 27 Dec 2024 09:50:18 +0800 Subject: [PATCH 2/4] chore: Bump version to v1.10.26 --- Cargo.lock | 2 +- mutiny-wasm/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd5da45fc..9fbe47c1c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1524,7 +1524,7 @@ dependencies = [ [[package]] name = "mutiny-wasm" -version = "1.10.25" +version = "1.10.26" dependencies = [ "anyhow", "async-trait", diff --git a/mutiny-wasm/Cargo.toml b/mutiny-wasm/Cargo.toml index d05fb0583..f3d5c1b7d 100644 --- a/mutiny-wasm/Cargo.toml +++ b/mutiny-wasm/Cargo.toml @@ -2,7 +2,7 @@ cargo-features = ["per-package-target"] [package] name = "mutiny-wasm" -version = "1.10.25" +version = "1.10.26" edition = "2021" authors = ["utxostack"] forced-target = "wasm32-unknown-unknown" From cc2fa1cf9adacdda1fe6b1bdf349d6d25fe66111 Mon Sep 17 00:00:00 2001 From: Dylan Duan Date: Fri, 27 Dec 2024 09:55:29 +0800 Subject: [PATCH 3/4] fix: Add mutiny wasm vss error --- mutiny-wasm/src/error.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mutiny-wasm/src/error.rs b/mutiny-wasm/src/error.rs index 4e004667b..616e2961b 100644 --- a/mutiny-wasm/src/error.rs +++ b/mutiny-wasm/src/error.rs @@ -186,6 +186,8 @@ pub enum MutinyJsError { InvalidHex, #[error("JWT Auth Failure")] JwtAuthFailure, + #[error("Failed to parse VSS value from getObject response.")] + FailedParsingVssValue, /// Unknown error. #[error("Unknown Error")] UnknownError, @@ -252,6 +254,7 @@ impl From for MutinyJsError { MutinyError::InvalidPsbt => MutinyJsError::InvalidPsbt, MutinyError::InvalidHex => MutinyJsError::InvalidHex, MutinyError::JwtAuthFailure => MutinyJsError::JwtAuthFailure, + MutinyError::FailedParsingVssValue => MutinyJsError::FailedParsingVssValue, } } } From 87c381ee07126c36c826619c2da1123ac5d3d610 Mon Sep 17 00:00:00 2001 From: EthanYuan Date: Fri, 27 Dec 2024 11:04:28 +0800 Subject: [PATCH 4/4] handle FailedParsingVssValue when wait device lock syncing, usually it's a failure to parse because it doesn't exist. --- mutiny-core/src/lib.rs | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/mutiny-core/src/lib.rs b/mutiny-core/src/lib.rs index c2f6f2e2a..d6fad78d9 100644 --- a/mutiny-core/src/lib.rs +++ b/mutiny-core/src/lib.rs @@ -840,19 +840,36 @@ impl MutinyWalletBuilder { let device_id = self.storage.get_device_id()?; let max_retries = 10; let mut retries = 0; - while !self - .storage - .fetch_device_lock() - .await? - .is_some_and(|lock| lock.is_last_locker(&device_id)) - { + while retries <= max_retries { log_info!(logger, "Waiting device lock syncing... {retries}"); + + match self.storage.fetch_device_lock().await { + Ok(lock_option) => { + if let Some(lock) = lock_option { + if lock.is_last_locker(&device_id) { + break; + } + } + } + Err(MutinyError::FailedParsingVssValue) => { + log_info!(logger, "Failed to parse VSS value, retrying... {retries}"); + } + Err(e) => { + log_error!(logger, "Error fetching device lock: {:?}", e); + return Err(e); + } + } + retries += 1; + if retries > max_retries { - log_error!(logger, "Can't syncing device lock to VSS"); + log_error!( + logger, + "Can't sync device lock to VSS after {max_retries} attempts" + ); return Err(MutinyError::AlreadyRunning); } - sleep(300).await + sleep(300).await; } } log_debug!(logger, "finished checking device lock");