Skip to content

Use ss58 for loggings #1413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/client/src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{
};
use entropy_shared::{user::ValidatorInfo, BlockNumber, HashingAlgorithm};
use serde::{Deserialize, Serialize};
use sp_core::{sr25519, Pair};
use sp_core::{crypto::Ss58Codec, sr25519, Pair};
use subxt::{backend::legacy::LegacyRpcMethods, OnlineClient};

pub use crate::errors::{AttestationRequestError, SubgroupGetError};
Expand Down Expand Up @@ -160,7 +160,7 @@ pub async fn request_attestation(
rpc: &LegacyRpcMethods<EntropyConfig>,
attestee: &sr25519::Pair,
) -> Result<[u8; 32], AttestationRequestError> {
tracing::debug!("{:?} is requesting an attestation.", attestee.public());
tracing::debug!("{:?} is requesting an attestation.", attestee.public().to_ss58check());

let request_attestation = entropy::tx().attestation().request_attestation();

Expand Down
5 changes: 3 additions & 2 deletions crates/protocol/src/execute_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use futures::future::try_join_all;
use num::bigint::BigUint;
use rand_core::{CryptoRngCore, OsRng};
use sp_core::{sr25519, Pair};
use sp_core::{crypto::Ss58Codec, sr25519, Pair};
use std::sync::Arc;
use subxt::utils::AccountId32;
use synedrion::{
Expand Down Expand Up @@ -384,7 +384,8 @@ pub async fn execute_reshare(
ProtocolExecutionErr,
> {
tracing::info!("Executing reshare");
tracing::debug!("Signing with {:?}", &threshold_pair.public());

tracing::debug!("Signing with {:?}", &threshold_pair.public().to_ss58check());

let pair = PairWrapper(threshold_pair.clone());

Expand Down
7 changes: 5 additions & 2 deletions crates/threshold-signature-server/src/backup_provider/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ use entropy_shared::{
use rand::{seq::SliceRandom, RngCore};
use rand_core::OsRng;
use serde::{Deserialize, Serialize};
use sp_core::{sr25519, Pair};
use sp_core::{
crypto::{AccountId32, Ss58Codec},
sr25519, Pair,
};
use std::path::PathBuf;
use subxt::{backend::legacy::LegacyRpcMethods, OnlineClient};
use tdx_quote::Quote;
Expand Down Expand Up @@ -338,7 +341,7 @@ async fn select_backup_provider(

tracing::info!(
"Selected TSS account {} to act as a db encrpytion key backup provider",
server_info.tss_account
AccountId32::new(server_info.tss_account.0).to_ss58check()
);

Ok(BackupProviderDetails {
Expand Down
9 changes: 5 additions & 4 deletions crates/threshold-signature-server/src/helpers/launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ pub async fn check_node_prerequisites(
) -> Result<(), &'static str> {
let url = &app_state.configuration.endpoint;
let account_id = app_state.account_id();
let ss58_account = account_id.to_ss58check();

let connect_to_substrate_node = || async {
tracing::info!("Attempting to establish connection to Substrate node at `{}`", url);
Expand Down Expand Up @@ -337,7 +338,7 @@ pub async fn check_node_prerequisites(
tracing::info!("Sucessfully connected to Substrate node!");
app_state.cache.connected_to_chain_node().map_err(|_| "Poisoned mutex")?;

tracing::info!("Checking balance of threshold server AccountId `{}`", &account_id);
tracing::info!("Checking balance of threshold server AccountId `{}`", &ss58_account);

let balance_query = || async {
let has_minimum_balance = crate::validator::api::check_balance_for_fees(
Expand All @@ -348,7 +349,7 @@ pub async fn check_node_prerequisites(
)
.await
.map_err(|e| {
tracing::warn!("Account: {} {}", &account_id, e);
tracing::warn!("Account: {} {}", &ss58_account, e);
e.to_string()
})?;
if !has_minimum_balance {
Expand All @@ -361,7 +362,7 @@ pub async fn check_node_prerequisites(
.await
.map_err(|_| "Timed out waiting for account to be funded")?;

tracing::info!("The account `{}` has enough funds for submitting extrinsics.", &account_id);
tracing::info!("The account `{}` has enough funds for submitting extrinsics.", &ss58_account);

// Now check if there exists a threshold server with our details - if there is not,
// we need to wait until there is
Expand All @@ -381,7 +382,7 @@ pub async fn check_node_prerequisites(
Ok(())
};

tracing::info!("Checking if our account ID has been registered on chain `{}`", &account_id);
tracing::info!("Checking if our account ID has been registered on chain `{}`", &ss58_account);
backoff::future::retry(backoff, check_for_tss_account_id)
.await
.map_err(|_| "Timed out waiting for TSS account to be registered on chain")?;
Expand Down
13 changes: 9 additions & 4 deletions crates/threshold-signature-server/src/user/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use entropy_shared::{HashingAlgorithm, OcwMessageDkg, NETWORK_PARENT_KEY};
use futures::{channel::mpsc, future::join_all, StreamExt};
use parity_scale_codec::Decode;
use serde::{Deserialize, Serialize};
use sp_core::crypto::{AccountId32, Ss58Codec};
use subxt::{
backend::legacy::LegacyRpcMethods,
ext::sp_core::{sr25519, sr25519::Signature, Pair},
Expand Down Expand Up @@ -224,7 +225,7 @@ pub async fn sign_tx(
let signed_message = encrypted_msg.decrypt(&app_state.x25519_secret, &[])?;

let request_author = SubxtAccountId32(*signed_message.account_id().as_ref());
tracing::Span::current().record("request_author", signed_message.account_id().to_string());
tracing::Span::current().record("request_author", signed_message.account_id().to_ss58check());
let validators_query = entropy::storage().session().validators();

let validators = query_chain(&api, &rpc, validators_query, None)
Expand Down Expand Up @@ -394,8 +395,12 @@ async fn handle_protocol_errors(
if peers_to_report.is_empty() {
return Err(error.to_string());
}

tracing::debug!("Reporting `{:?}` for `{}`", peers_to_report.clone(), error.to_string());
let peers_to_report_ss58 = peers_to_report
.clone()
.into_iter()
.map(|x| AccountId32::new(x.0).to_ss58check())
.collect::<Vec<_>>();
tracing::debug!("Reporting `{:?}` for `{}`", peers_to_report_ss58, error.to_string());

let mut failed_reports = Vec::new();
for peer in peers_to_report {
Expand Down Expand Up @@ -452,7 +457,7 @@ pub async fn generate_network_key(
if in_registration_group.is_err() {
tracing::warn!(
"The account {:?} is not in the registration group for block_number {:?}",
app_state.subxt_account_id(),
app_state.account_id().to_ss58check(),
data.block_number
);

Expand Down