Skip to content

Commit

Permalink
chore: reduce logs (#6523)
Browse files Browse the repository at this point in the history
Description
---
reduces unnecessary logs

Motivation and Context
---
We should not log everything that happens on debug. These logs are also
only logged on certain cfg flags.
  • Loading branch information
SWvheerden authored Sep 3, 2024
1 parent 125b49c commit f7813b7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 84 deletions.
5 changes: 3 additions & 2 deletions applications/minotari_miner/src/run_miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,9 @@ async fn get_new_block_base_node(
async fn get_new_block_p2pool_node(
sha_p2pool_client: &mut ShaP2PoolGrpcClient,
) -> Result<GetNewBlockResponse, MinerError> {
let mut pow_algo = PowAlgo::default();
pow_algo.set_pow_algo(PowAlgos::Sha3x);
let pow_algo = PowAlgo {
pow_algo: PowAlgos::Sha3x.into(),
};
let block_result = sha_p2pool_client
.get_new_block(GetNewBlockRequest { pow: Some(pow_algo) })
.await?
Expand Down
82 changes: 0 additions & 82 deletions base_layer/core/src/transactions/key_manager/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ where TBackend: KeyManagerBackend<PublicKey> + 'static
}

pub async fn get_random_key(&self) -> Result<KeyAndId<PublicKey>, KeyManagerServiceError> {
#[cfg(feature = "ledger")]
{
debug!(target: LOG_TARGET, "get_random_key: wallet type {}", self.wallet_type);
}
match &*self.wallet_type {
WalletType::Ledger(ledger) => {
#[cfg(not(feature = "ledger"))]
Expand Down Expand Up @@ -258,10 +254,6 @@ where TBackend: KeyManagerBackend<PublicKey> + 'static
}

pub async fn get_public_key_at_key_id(&self, key_id: &TariKeyId) -> Result<PublicKey, KeyManagerServiceError> {
#[cfg(feature = "ledger")]
{
debug!(target: LOG_TARGET, "get_public_key_at_key_id: key_id {}, wallet type {}", key_id, self.wallet_type);
}
match key_id {
KeyId::Managed { branch, index } => {
if let WalletType::Ledger(ledger) = &*self.wallet_type {
Expand Down Expand Up @@ -728,15 +720,6 @@ where TBackend: KeyManagerBackend<PublicKey> + 'static
secret_key_id: &TariKeyId,
public_key: &PublicKey,
) -> Result<CommsDHKE, TransactionError> {
#[cfg(feature = "ledger")]
{
debug!(
target: LOG_TARGET,
"get_diffie_hellman_shared_secret: secret_key_id {}, wallet type {}",
secret_key_id,
self.wallet_type
);
}
if let WalletType::Ledger(ledger) = &*self.wallet_type {
if let KeyId::Managed { branch, index } = secret_key_id {
match TransactionKeyManagerBranch::from_key(branch) {
Expand Down Expand Up @@ -775,20 +758,10 @@ where TBackend: KeyManagerBackend<PublicKey> + 'static
secret_key_id: &TariKeyId,
public_key: &PublicKey,
) -> Result<DomainSeparatedHash<Blake2b<U64>>, TransactionError> {
#[cfg(feature = "ledger")]
{
debug!(
target: LOG_TARGET,
"get_diffie_hellman_stealth_domain_hasher: secret_key_id {}, wallet type {}",
secret_key_id,
self.wallet_type
);
}
match &*self.wallet_type {
WalletType::Ledger(ledger) => match secret_key_id {
KeyId::Managed { branch, index } => match TransactionKeyManagerBranch::from_key(branch) {
TransactionKeyManagerBranch::OneSidedSenderOffset => {
debug!(target: LOG_TARGET, "get_diffie_hellman_stealth_domain_hasher: {}", self.wallet_type);
#[cfg(not(feature = "ledger"))]
{
Err(TransactionError::LedgerNotSupported(format!(
Expand Down Expand Up @@ -871,15 +844,6 @@ where TBackend: KeyManagerBackend<PublicKey> + 'static
txi_version: &TransactionInputVersion,
script_message: &[u8; 32],
) -> Result<ComAndPubSignature, TransactionError> {
#[cfg(feature = "ledger")]
{
debug!(
target: LOG_TARGET,
"get_script_signature: script_key_id {}, wallet type {}",
script_key_id,
self.wallet_type
);
}
let commitment = self.get_commitment(commitment_mask_key_id, value).await?;
let commitment_private_key = self.get_private_key(commitment_mask_key_id).await?;

Expand Down Expand Up @@ -1064,17 +1028,6 @@ where TBackend: KeyManagerBackend<PublicKey> + 'static
script_key_ids: &[TariKeyId],
sender_offset_key_ids: &[TariKeyId],
) -> Result<PrivateKey, TransactionError> {
#[cfg(feature = "ledger")]
{
debug!(
target: LOG_TARGET,
"get_script_offset: script_key_ids {:?}, sender_offset_key_ids {:?}, wallet type {}",
script_key_ids,
sender_offset_key_ids,
self.wallet_type
);
}

match &*self.wallet_type {
WalletType::DerivedKeys | WalletType::ProvidedKeys(_) => {
let mut total_script_private_key = PrivateKey::default();
Expand Down Expand Up @@ -1233,15 +1186,6 @@ where TBackend: KeyManagerBackend<PublicKey> + 'static
private_key_id: &TariKeyId,
challenge: &[u8],
) -> Result<CheckSigSchnorrSignature, TransactionError> {
#[cfg(feature = "ledger")]
{
debug!(
target: LOG_TARGET,
"sign_script_message: private_key_id {}, wallet type {}",
private_key_id,
self.wallet_type
);
}
match &*self.wallet_type {
WalletType::Ledger(ledger) => {
#[cfg(not(feature = "ledger"))]
Expand Down Expand Up @@ -1287,16 +1231,6 @@ where TBackend: KeyManagerBackend<PublicKey> + 'static
nonce_key_id: &TariKeyId,
challenge: &[u8; 64],
) -> Result<Signature, TransactionError> {
#[cfg(feature = "ledger")]
{
debug!(
target: LOG_TARGET,
"sign_with_nonce_and_challenge: private_key_id {}, nonce_key_id {}, wallet type {}",
private_key_id,
nonce_key_id,
self.wallet_type
);
}
match &*self.wallet_type {
WalletType::Ledger(ledger) => {
#[cfg(not(feature = "ledger"))]
Expand Down Expand Up @@ -1417,16 +1351,6 @@ where TBackend: KeyManagerBackend<PublicKey> + 'static
script: &TariScript,
receiver_address: &TariAddress,
) -> Result<ComAndPubSignature, TransactionError> {
#[cfg(feature = "ledger")]
{
debug!(
target: LOG_TARGET,
"get_one_sided_metadata_signature: commitment_mask_key_id {}, sender_offset_key_id {}, wallet type {}",
commitment_mask_key_id,
sender_offset_key_id,
self.wallet_type
);
}
match &*self.wallet_type {
WalletType::DerivedKeys | WalletType::ProvidedKeys(_) => {
let metadata_signature_message = TransactionOutput::metadata_signature_message_from_script_and_common(
Expand Down Expand Up @@ -1456,17 +1380,11 @@ where TBackend: KeyManagerBackend<PublicKey> + 'static
#[cfg(feature = "ledger")]
{
let sender_offset_key_index = sender_offset_key_id.managed_index().ok_or_else(|| {
debug!(target: LOG_TARGET, "Invalid key id {:?}", sender_offset_key_id);
TransactionError::KeyManagerError("Invalid index for sender offset".to_string())
})?;

let commitment_mask = self.get_private_key(commitment_mask_key_id).await?;

debug!(
target: LOG_TARGET,
"get_one_sided_metadata_signature: (ledger) account {}",
ledger.account,
);
let comm_and_pub_sig = ledger_get_one_sided_metadata_signature(
ledger.account,
ledger.network,
Expand Down

0 comments on commit f7813b7

Please sign in to comment.