From 36d811a3a08bc57eda70e047f3512214256b6c2f Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Fri, 12 Jul 2024 14:04:20 -0400 Subject: [PATCH 01/11] Add exponential backoff when connecting to Substrate node --- crates/threshold-signature-server/Cargo.toml | 1 + crates/threshold-signature-server/src/main.rs | 47 ++++++++++++++++--- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/crates/threshold-signature-server/Cargo.toml b/crates/threshold-signature-server/Cargo.toml index 111cf0227..369e926e8 100644 --- a/crates/threshold-signature-server/Cargo.toml +++ b/crates/threshold-signature-server/Cargo.toml @@ -23,6 +23,7 @@ reqwest-eventsource="0.6" serde_derive ="1.0.147" synedrion ={ git="https://github.com/entropyxyz/synedrion", rev="25373111cbb01e1a25d8a5c5bb8f4652c725b3f1" } strum ="0.26.2" +backoff ={ version = "0.4.0", features = ["tokio"] } # Async futures="0.3" diff --git a/crates/threshold-signature-server/src/main.rs b/crates/threshold-signature-server/src/main.rs index 5f468b5a9..a1e68297b 100644 --- a/crates/threshold-signature-server/src/main.rs +++ b/crates/threshold-signature-server/src/main.rs @@ -112,14 +112,47 @@ async fn main() { if args.setup_only { setup_only(&kv_store).await; } else { - let api = get_api(&app_state.configuration.endpoint).await.expect("Error getting api"); - let rpc = get_rpc(&app_state.configuration.endpoint).await.expect("Error getting rpc"); - let has_fee_balance = check_balance_for_fees(&api, &rpc, account_id.clone(), MIN_BALANCE) - .await - .expect("Error in check balance"); - if !has_fee_balance { - panic!("threshold account needs balance: {:?}", account_id); + let connect_to_substrate_node = || async { + tracing::info!( + "Attempting to establish connection to Substrate node at `{}`", + &app_state.configuration.endpoint + ); + + let api = get_api(&app_state.configuration.endpoint).await.map_err(|_| { + Err::<(), String>("Unable to connect to Substrate chain API".to_string()) + })?; + + let rpc = get_rpc(&app_state.configuration.endpoint) + .await + .map_err(|_| Err("Unable to connect to Substrate chain RPC".to_string()))?; + + Ok((api, rpc)) + }; + + let backoff = backoff::ExponentialBackoffBuilder::default() + .with_max_elapsed_time(Some(std::time::Duration::from_secs(60))) + .build(); + match backoff::future::retry(backoff, connect_to_substrate_node).await { + Ok((api, rpc)) => { + tracing::info!("Sucessfully connected to Substrate node!"); + tracing::info!("Checking balance of threshold server AccountId `{}`", &account_id); + let has_fee_balance = + check_balance_for_fees(&api, &rpc, account_id.clone(), MIN_BALANCE) + .await + .expect("Error in check balance"); + if !has_fee_balance { + panic!("threshold account needs balance: {:?}", account_id); + } + }, + Err(_err) => { + tracing::error!( + "Unable to establish connection with Substrate node at `{}`", + &app_state.configuration.endpoint + ); + panic!("Unable to establish connection with Substrate node."); + }, } + let listener = tokio::net::TcpListener::bind(&addr) .await .expect("Unable to bind to given server address."); From 0e3628322fa494625154c15801af49f6fb564614 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Fri, 12 Jul 2024 14:05:57 -0400 Subject: [PATCH 02/11] Split out code for getting threshold account ID from mnemonic check --- .../src/helpers/launch.rs | 24 ++++++++++--------- crates/threshold-signature-server/src/main.rs | 5 ++-- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/crates/threshold-signature-server/src/helpers/launch.rs b/crates/threshold-signature-server/src/helpers/launch.rs index 2ca7a9b42..7d4ecba68 100644 --- a/crates/threshold-signature-server/src/helpers/launch.rs +++ b/crates/threshold-signature-server/src/helpers/launch.rs @@ -241,21 +241,23 @@ pub struct StartupArgs { pub mnemonic_file: Option, } -pub async fn has_mnemonic(kv: &KvManager) -> (bool, String) { +pub async fn threshold_account_id(kv: &KvManager) -> String { + let mnemonic = kv.kv().get(FORBIDDEN_KEY_MNEMONIC).await.expect("Issue getting mnemonic"); + let pair = ::from_phrase( + &String::from_utf8(mnemonic).expect("Issue converting mnemonic to string"), + None, + ) + .expect("Issue converting mnemonic to pair"); + AccountId32::new(pair.0.public().into()).to_ss58check() +} + +pub async fn has_mnemonic(kv: &KvManager) -> bool { let exists = kv.kv().exists(FORBIDDEN_KEY_MNEMONIC).await.expect("issue querying DB"); - let mut account_id = "".to_string(); if exists { tracing::debug!("Existing mnemonic found in keystore."); - let mnemonic = kv.kv().get(FORBIDDEN_KEYS[0]).await.expect("Issue getting mnemonic"); - let pair = ::from_phrase( - &String::from_utf8(mnemonic).expect("Issue converting mnemonic to string"), - None, - ) - .expect("Issue converting mnemonic to pair"); - account_id = AccountId32::new(pair.0.public().into()).to_ss58check(); } - (exists, account_id) + exists } pub fn development_mnemonic(validator_name: &Option) -> bip39::Mnemonic { @@ -276,7 +278,7 @@ pub fn development_mnemonic(validator_name: &Option) -> bip39::Mn } pub async fn setup_mnemonic(kv: &KvManager, mnemonic: bip39::Mnemonic) -> String { - if has_mnemonic(kv).await.0 { + if has_mnemonic(kv).await { tracing::warn!("Deleting account related keys from KVDB."); kv.kv() diff --git a/crates/threshold-signature-server/src/main.rs b/crates/threshold-signature-server/src/main.rs index a1e68297b..6da36fc2b 100644 --- a/crates/threshold-signature-server/src/main.rs +++ b/crates/threshold-signature-server/src/main.rs @@ -96,12 +96,13 @@ async fn main() { } else if cfg!(test) || validator_name.is_some() { setup_mnemonic(&kv_store, development_mnemonic(&validator_name)).await } else { - let (has_mnemonic, account_id) = entropy_tss::launch::has_mnemonic(&kv_store).await; + let has_mnemonic = entropy_tss::launch::has_mnemonic(&kv_store).await; assert!( has_mnemonic, "No mnemonic provided. Please provide one or use a development account." ); - account_id + + entropy_tss::launch::threshold_account_id(&kv_store).await }; setup_latest_block_number(&kv_store).await.expect("Issue setting up Latest Block Number"); From d1211b299c3bf4190a26269158c7701189078b28 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Fri, 12 Jul 2024 14:26:40 -0400 Subject: [PATCH 03/11] Make TSS balance check non-fatal --- .../src/helpers/launch.rs | 20 ++++++------- crates/threshold-signature-server/src/main.rs | 28 ++++++++++++++++--- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/crates/threshold-signature-server/src/helpers/launch.rs b/crates/threshold-signature-server/src/helpers/launch.rs index 7d4ecba68..5adcbc7ce 100644 --- a/crates/threshold-signature-server/src/helpers/launch.rs +++ b/crates/threshold-signature-server/src/helpers/launch.rs @@ -241,16 +241,6 @@ pub struct StartupArgs { pub mnemonic_file: Option, } -pub async fn threshold_account_id(kv: &KvManager) -> String { - let mnemonic = kv.kv().get(FORBIDDEN_KEY_MNEMONIC).await.expect("Issue getting mnemonic"); - let pair = ::from_phrase( - &String::from_utf8(mnemonic).expect("Issue converting mnemonic to string"), - None, - ) - .expect("Issue converting mnemonic to pair"); - AccountId32::new(pair.0.public().into()).to_ss58check() -} - pub async fn has_mnemonic(kv: &KvManager) -> bool { let exists = kv.kv().exists(FORBIDDEN_KEY_MNEMONIC).await.expect("issue querying DB"); if exists { @@ -346,6 +336,16 @@ pub async fn setup_mnemonic(kv: &KvManager, mnemonic: bip39::Mnemonic) -> String id.to_ss58check() } +pub async fn threshold_account_id(kv: &KvManager) -> String { + let mnemonic = kv.kv().get(FORBIDDEN_KEY_MNEMONIC).await.expect("Issue getting mnemonic"); + let pair = ::from_phrase( + &String::from_utf8(mnemonic).expect("Issue converting mnemonic to string"), + None, + ) + .expect("Issue converting mnemonic to pair"); + AccountId32::new(pair.0.public().into()).to_ss58check() +} + pub async fn setup_latest_block_number(kv: &KvManager) -> Result<(), KvError> { let exists_result_new_user = kv.kv().exists(LATEST_BLOCK_NUMBER_NEW_USER).await.expect("issue querying DB"); diff --git a/crates/threshold-signature-server/src/main.rs b/crates/threshold-signature-server/src/main.rs index 6da36fc2b..63a2b2e6d 100644 --- a/crates/threshold-signature-server/src/main.rs +++ b/crates/threshold-signature-server/src/main.rs @@ -136,13 +136,33 @@ async fn main() { match backoff::future::retry(backoff, connect_to_substrate_node).await { Ok((api, rpc)) => { tracing::info!("Sucessfully connected to Substrate node!"); + tracing::info!("Checking balance of threshold server AccountId `{}`", &account_id); - let has_fee_balance = + let balance_query = check_balance_for_fees(&api, &rpc, account_id.clone(), MIN_BALANCE) .await - .expect("Error in check balance"); - if !has_fee_balance { - panic!("threshold account needs balance: {:?}", account_id); + .map_err(|_| { + Err::("Failed to get balance of account.".to_string()) + }); + + match balance_query { + Ok(has_minimum_balance) => { + if has_minimum_balance { + tracing::info!( + "The account `{}` has enough funds for submitting extrinsics.", + &account_id + ) + } else { + tracing::warn!( + "The account `{}` does not meet the minimum balance of `{}`", + &account_id, + MIN_BALANCE + ) + } + }, + Err(_) => { + tracing::warn!("Unable to query the account balance of `{}`", &account_id) + }, } }, Err(_err) => { From cf713a273fc5a2664fe1b922a9df952d75a9d3d6 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Fri, 12 Jul 2024 14:40:04 -0400 Subject: [PATCH 04/11] Move code for checking node connection and TSS balance to a helper --- .../src/helpers/launch.rs | 61 ++++++++++++++++++ crates/threshold-signature-server/src/main.rs | 62 +------------------ 2 files changed, 63 insertions(+), 60 deletions(-) diff --git a/crates/threshold-signature-server/src/helpers/launch.rs b/crates/threshold-signature-server/src/helpers/launch.rs index 5adcbc7ce..eef0f1f58 100644 --- a/crates/threshold-signature-server/src/helpers/launch.rs +++ b/crates/threshold-signature-server/src/helpers/launch.rs @@ -243,6 +243,7 @@ pub struct StartupArgs { pub async fn has_mnemonic(kv: &KvManager) -> bool { let exists = kv.kv().exists(FORBIDDEN_KEY_MNEMONIC).await.expect("issue querying DB"); + if exists { tracing::debug!("Existing mnemonic found in keystore."); } @@ -394,3 +395,63 @@ pub async fn setup_only(kv: &KvManager) { println!("{}", output); } + +pub async fn check_node_connection(url: &str, account_id: &str) { + use crate::chain_api::{get_api, get_rpc}; + + let connect_to_substrate_node = || async { + tracing::info!("Attempting to establish connection to Substrate node at `{}`", url); + + let api = get_api(url).await.map_err(|_| { + Err::<(), String>("Unable to connect to Substrate chain API".to_string()) + })?; + + let rpc = get_rpc(url) + .await + .map_err(|_| Err("Unable to connect to Substrate chain RPC".to_string()))?; + + Ok((api, rpc)) + }; + + // Note: By default this will wait 15 minutes before it stops retry attempts. + let backoff = backoff::ExponentialBackoff::default(); + match backoff::future::retry(backoff, connect_to_substrate_node).await { + Ok((api, rpc)) => { + tracing::info!("Sucessfully connected to Substrate node!"); + + tracing::info!("Checking balance of threshold server AccountId `{}`", &account_id); + let balance_query = crate::validator::api::check_balance_for_fees( + &api, + &rpc, + account_id.to_string(), + entropy_shared::MIN_BALANCE, + ) + .await + .map_err(|_| Err::("Failed to get balance of account.".to_string())); + + match balance_query { + Ok(has_minimum_balance) => { + if has_minimum_balance { + tracing::info!( + "The account `{}` has enough funds for submitting extrinsics.", + &account_id + ) + } else { + tracing::warn!( + "The account `{}` does not meet the minimum balance of `{}`", + &account_id, + entropy_shared::MIN_BALANCE, + ) + } + }, + Err(_) => { + tracing::warn!("Unable to query the account balance of `{}`", &account_id) + }, + } + }, + Err(_err) => { + tracing::error!("Unable to establish connection with Substrate node at `{}`", url); + panic!("Unable to establish connection with Substrate node."); + }, + } +} diff --git a/crates/threshold-signature-server/src/main.rs b/crates/threshold-signature-server/src/main.rs index 63a2b2e6d..6b74914e2 100644 --- a/crates/threshold-signature-server/src/main.rs +++ b/crates/threshold-signature-server/src/main.rs @@ -113,66 +113,8 @@ async fn main() { if args.setup_only { setup_only(&kv_store).await; } else { - let connect_to_substrate_node = || async { - tracing::info!( - "Attempting to establish connection to Substrate node at `{}`", - &app_state.configuration.endpoint - ); - - let api = get_api(&app_state.configuration.endpoint).await.map_err(|_| { - Err::<(), String>("Unable to connect to Substrate chain API".to_string()) - })?; - - let rpc = get_rpc(&app_state.configuration.endpoint) - .await - .map_err(|_| Err("Unable to connect to Substrate chain RPC".to_string()))?; - - Ok((api, rpc)) - }; - - let backoff = backoff::ExponentialBackoffBuilder::default() - .with_max_elapsed_time(Some(std::time::Duration::from_secs(60))) - .build(); - match backoff::future::retry(backoff, connect_to_substrate_node).await { - Ok((api, rpc)) => { - tracing::info!("Sucessfully connected to Substrate node!"); - - tracing::info!("Checking balance of threshold server AccountId `{}`", &account_id); - let balance_query = - check_balance_for_fees(&api, &rpc, account_id.clone(), MIN_BALANCE) - .await - .map_err(|_| { - Err::("Failed to get balance of account.".to_string()) - }); - - match balance_query { - Ok(has_minimum_balance) => { - if has_minimum_balance { - tracing::info!( - "The account `{}` has enough funds for submitting extrinsics.", - &account_id - ) - } else { - tracing::warn!( - "The account `{}` does not meet the minimum balance of `{}`", - &account_id, - MIN_BALANCE - ) - } - }, - Err(_) => { - tracing::warn!("Unable to query the account balance of `{}`", &account_id) - }, - } - }, - Err(_err) => { - tracing::error!( - "Unable to establish connection with Substrate node at `{}`", - &app_state.configuration.endpoint - ); - panic!("Unable to establish connection with Substrate node."); - }, - } + entropy_tss::launch::check_node_connection(&app_state.configuration.endpoint, &account_id) + .await; let listener = tokio::net::TcpListener::bind(&addr) .await From 3f0089bd3c4161230b6dbc6621d4fcf125802181 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Fri, 12 Jul 2024 14:44:09 -0400 Subject: [PATCH 05/11] Move account check out of `setup_mnemonic` --- .../threshold-signature-server/src/helpers/launch.rs | 5 ++--- crates/threshold-signature-server/src/main.rs | 12 +++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/crates/threshold-signature-server/src/helpers/launch.rs b/crates/threshold-signature-server/src/helpers/launch.rs index eef0f1f58..8f5e686b0 100644 --- a/crates/threshold-signature-server/src/helpers/launch.rs +++ b/crates/threshold-signature-server/src/helpers/launch.rs @@ -268,7 +268,7 @@ pub fn development_mnemonic(validator_name: &Option) -> bip39::Mn .expect("Unable to parse given mnemonic.") } -pub async fn setup_mnemonic(kv: &KvManager, mnemonic: bip39::Mnemonic) -> String { +pub async fn setup_mnemonic(kv: &KvManager, mnemonic: bip39::Mnemonic) { if has_mnemonic(kv).await { tracing::warn!("Deleting account related keys from KVDB."); @@ -334,7 +334,6 @@ pub async fn setup_mnemonic(kv: &KvManager, mnemonic: bip39::Mnemonic) -> String fs::write(".entropy/account_id", format!("{id}")).expect("Failed to write account_id file"); tracing::debug!("Starting process with account ID: `{id}`"); - id.to_ss58check() } pub async fn threshold_account_id(kv: &KvManager) -> String { @@ -396,7 +395,7 @@ pub async fn setup_only(kv: &KvManager) { println!("{}", output); } -pub async fn check_node_connection(url: &str, account_id: &str) { +pub async fn check_node_prerequisites(url: &str, account_id: &str) { use crate::chain_api::{get_api, get_rpc}; let connect_to_substrate_node = || async { diff --git a/crates/threshold-signature-server/src/main.rs b/crates/threshold-signature-server/src/main.rs index 6b74914e2..db284d9e5 100644 --- a/crates/threshold-signature-server/src/main.rs +++ b/crates/threshold-signature-server/src/main.rs @@ -91,7 +91,7 @@ async fn main() { }) }); - let account_id = if let Some(mnemonic) = user_mnemonic { + if let Some(mnemonic) = user_mnemonic { setup_mnemonic(&kv_store, mnemonic).await } else if cfg!(test) || validator_name.is_some() { setup_mnemonic(&kv_store, development_mnemonic(&validator_name)).await @@ -101,8 +101,6 @@ async fn main() { has_mnemonic, "No mnemonic provided. Please provide one or use a development account." ); - - entropy_tss::launch::threshold_account_id(&kv_store).await }; setup_latest_block_number(&kv_store).await.expect("Issue setting up Latest Block Number"); @@ -113,8 +111,12 @@ async fn main() { if args.setup_only { setup_only(&kv_store).await; } else { - entropy_tss::launch::check_node_connection(&app_state.configuration.endpoint, &account_id) - .await; + let account_id = entropy_tss::launch::threshold_account_id(&kv_store).await; + entropy_tss::launch::check_node_prerequisites( + &app_state.configuration.endpoint, + &account_id, + ) + .await; let listener = tokio::net::TcpListener::bind(&addr) .await From 395b731f45904730ba9fa5419d3257dcd60ba5b1 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Fri, 12 Jul 2024 14:47:03 -0400 Subject: [PATCH 06/11] Get rid of import warnings --- crates/threshold-signature-server/src/main.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/crates/threshold-signature-server/src/main.rs b/crates/threshold-signature-server/src/main.rs index db284d9e5..c9e520e7d 100644 --- a/crates/threshold-signature-server/src/main.rs +++ b/crates/threshold-signature-server/src/main.rs @@ -17,15 +17,12 @@ use std::{net::SocketAddr, str::FromStr}; use clap::Parser; -use entropy_shared::MIN_BALANCE; use entropy_tss::{ app, - chain_api::{get_api, get_rpc}, launch::{ development_mnemonic, load_kv_store, setup_latest_block_number, setup_mnemonic, setup_only, Configuration, StartupArgs, ValidatorName, }, - validator::api::check_balance_for_fees, AppState, }; From 6693a2f56ae00a23fd82d5ef01d5170959fd50f0 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Tue, 16 Jul 2024 12:20:22 -0400 Subject: [PATCH 07/11] Update lockfile --- Cargo.lock | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 4a9eb13c3..d7858521b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -703,6 +703,20 @@ dependencies = [ "tracing", ] +[[package]] +name = "backoff" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62ddb9cb1ec0a098ad4bbf9344d0713fa193ae1a80af55febcff2627b6a00c1" +dependencies = [ + "futures-core", + "getrandom 0.2.15", + "instant", + "pin-project-lite 0.2.14", + "rand", + "tokio", +] + [[package]] name = "backtrace" version = "0.3.71" @@ -2710,6 +2724,7 @@ version = "0.2.0" dependencies = [ "anyhow", "axum", + "backoff", "base64 0.22.1", "bincode", "bip39", From 74c9c30f544e1d78bcbb3d2b9d0dd047105084e7 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Fri, 12 Jul 2024 14:49:11 -0400 Subject: [PATCH 08/11] TaploFmt --- crates/threshold-signature-server/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/threshold-signature-server/Cargo.toml b/crates/threshold-signature-server/Cargo.toml index 369e926e8..2803a9be7 100644 --- a/crates/threshold-signature-server/Cargo.toml +++ b/crates/threshold-signature-server/Cargo.toml @@ -23,7 +23,7 @@ reqwest-eventsource="0.6" serde_derive ="1.0.147" synedrion ={ git="https://github.com/entropyxyz/synedrion", rev="25373111cbb01e1a25d8a5c5bb8f4652c725b3f1" } strum ="0.26.2" -backoff ={ version = "0.4.0", features = ["tokio"] } +backoff ={ version="0.4.0", features=["tokio"] } # Async futures="0.3" From 9f49bea87571da48eacc44d73b3492a101829fcc Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Fri, 12 Jul 2024 15:42:16 -0400 Subject: [PATCH 09/11] Use `threshold_account_id()` in tests --- crates/threshold-signature-server/src/user/tests.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/threshold-signature-server/src/user/tests.rs b/crates/threshold-signature-server/src/user/tests.rs index 758f0be25..b24925ff3 100644 --- a/crates/threshold-signature-server/src/user/tests.rs +++ b/crates/threshold-signature-server/src/user/tests.rs @@ -111,8 +111,9 @@ use crate::{ get_signer, helpers::{ launch::{ - development_mnemonic, load_kv_store, setup_mnemonic, Configuration, ValidatorName, - DEFAULT_BOB_MNEMONIC, DEFAULT_CHARLIE_MNEMONIC, DEFAULT_ENDPOINT, DEFAULT_MNEMONIC, + development_mnemonic, load_kv_store, setup_mnemonic, threshold_account_id, + Configuration, ValidatorName, DEFAULT_BOB_MNEMONIC, DEFAULT_CHARLIE_MNEMONIC, + DEFAULT_ENDPOINT, DEFAULT_MNEMONIC, }, signing::Hasher, substrate::{query_chain, submit_transaction}, @@ -144,7 +145,9 @@ async fn test_get_signer_does_not_throw_err() { clean_tests(); let kv_store = load_kv_store(&None, None).await; - let account = setup_mnemonic(&kv_store, development_mnemonic(&None)).await; + setup_mnemonic(&kv_store, development_mnemonic(&None)).await; + let account = threshold_account_id(&kv_store).await; + assert_eq!(account, "5DACCJgQV6sHoYUKfTGEimddFxe16NJXgkzHZ3RC9QCBShMH"); get_signer(&kv_store).await.unwrap(); clean_tests(); From 55d57e990f6cece4a0d0fd6877c6a2d05c4b6b75 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Fri, 12 Jul 2024 16:36:01 -0400 Subject: [PATCH 10/11] Use correct account in test --- crates/threshold-signature-server/src/helpers/launch.rs | 2 +- crates/threshold-signature-server/src/user/tests.rs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/threshold-signature-server/src/helpers/launch.rs b/crates/threshold-signature-server/src/helpers/launch.rs index 8f5e686b0..e47e84cd1 100644 --- a/crates/threshold-signature-server/src/helpers/launch.rs +++ b/crates/threshold-signature-server/src/helpers/launch.rs @@ -339,7 +339,7 @@ pub async fn setup_mnemonic(kv: &KvManager, mnemonic: bip39::Mnemonic) { pub async fn threshold_account_id(kv: &KvManager) -> String { let mnemonic = kv.kv().get(FORBIDDEN_KEY_MNEMONIC).await.expect("Issue getting mnemonic"); let pair = ::from_phrase( - &String::from_utf8(mnemonic).expect("Issue converting mnemonic to string"), + dbg!(&String::from_utf8(mnemonic).expect("Issue converting mnemonic to string")), None, ) .expect("Issue converting mnemonic to pair"); diff --git a/crates/threshold-signature-server/src/user/tests.rs b/crates/threshold-signature-server/src/user/tests.rs index b24925ff3..e2febcf5f 100644 --- a/crates/threshold-signature-server/src/user/tests.rs +++ b/crates/threshold-signature-server/src/user/tests.rs @@ -144,11 +144,16 @@ async fn test_get_signer_does_not_throw_err() { initialize_test_logger().await; clean_tests(); + let pair = ::from_phrase(crate::helpers::launch::DEFAULT_MNEMONIC, None) + .expect("Issue converting mnemonic to pair"); + let expected_account_id = AccountId32::new(pair.0.public().into()).to_ss58check(); + let kv_store = load_kv_store(&None, None).await; setup_mnemonic(&kv_store, development_mnemonic(&None)).await; + development_mnemonic(&None).to_string(); let account = threshold_account_id(&kv_store).await; - assert_eq!(account, "5DACCJgQV6sHoYUKfTGEimddFxe16NJXgkzHZ3RC9QCBShMH"); + assert_eq!(account, expected_account_id); get_signer(&kv_store).await.unwrap(); clean_tests(); } From e64fa4d4a7240ee55480e114236d035c2a11dfe2 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Fri, 12 Jul 2024 16:55:55 -0400 Subject: [PATCH 11/11] Remove `dbg!` statement --- crates/threshold-signature-server/src/helpers/launch.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/threshold-signature-server/src/helpers/launch.rs b/crates/threshold-signature-server/src/helpers/launch.rs index e47e84cd1..8f5e686b0 100644 --- a/crates/threshold-signature-server/src/helpers/launch.rs +++ b/crates/threshold-signature-server/src/helpers/launch.rs @@ -339,7 +339,7 @@ pub async fn setup_mnemonic(kv: &KvManager, mnemonic: bip39::Mnemonic) { pub async fn threshold_account_id(kv: &KvManager) -> String { let mnemonic = kv.kv().get(FORBIDDEN_KEY_MNEMONIC).await.expect("Issue getting mnemonic"); let pair = ::from_phrase( - dbg!(&String::from_utf8(mnemonic).expect("Issue converting mnemonic to string")), + &String::from_utf8(mnemonic).expect("Issue converting mnemonic to string"), None, ) .expect("Issue converting mnemonic to pair");