From 5f19a8c0cf070f4b468943d305aac3a6aa5620ad Mon Sep 17 00:00:00 2001 From: Dmitry Lavrenov <39522748+dmitrylavrenov@users.noreply.github.com> Date: Thu, 7 Nov 2024 19:22:59 +0300 Subject: [PATCH] Use `frame_support::logs` APIs (#1326) * Remove doubled log in execute_block * Use logs APIs at pallet-balanced-currency-swap-bridges-initializer * Use logs APIs at pallet-humanode-session * Use logs APIs at pallet-erc20-support * Use logs APIs at pallet-bioauth * Use logs APIs at pallet-currency-swap-proxy * Remove unused dep at humanode-runtime * Use log explicitly * Improve info message at pallet-humanode-session Co-authored-by: MOZGIII --------- Co-authored-by: MOZGIII --- Cargo.lock | 2 -- crates/humanode-runtime/Cargo.toml | 2 -- crates/humanode-runtime/src/lib.rs | 8 -------- .../Cargo.toml | 2 -- .../src/upgrade_init.rs | 4 ++-- crates/pallet-bioauth/src/lib.rs | 6 +++--- crates/pallet-erc20-support/src/migrations/v1.rs | 2 +- crates/pallet-humanode-session/src/migrations/v1.rs | 6 +++--- crates/primitives-currency-swap-proxy/src/lib.rs | 5 +---- 9 files changed, 10 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 41e9862a0..d9920c952 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4167,7 +4167,6 @@ dependencies = [ "sp-session", "sp-staking", "sp-std", - "sp-tracing", "sp-transaction-pool", "sp-version", "static_assertions", @@ -6342,7 +6341,6 @@ dependencies = [ "scale-info", "sp-core", "sp-std", - "sp-tracing", ] [[package]] diff --git a/crates/humanode-runtime/Cargo.toml b/crates/humanode-runtime/Cargo.toml index 8d339e23f..937ecc102 100644 --- a/crates/humanode-runtime/Cargo.toml +++ b/crates/humanode-runtime/Cargo.toml @@ -93,7 +93,6 @@ sp-runtime = { workspace = true } sp-session = { workspace = true } sp-staking = { workspace = true } sp-std = { workspace = true } -sp-tracing = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } static_assertions = { workspace = true } @@ -224,7 +223,6 @@ std = [ "sp-session/std", "sp-staking/std", "sp-std/std", - "sp-tracing/std", "sp-transaction-pool/std", "sp-version/std", "substrate-wasm-builder", diff --git a/crates/humanode-runtime/src/lib.rs b/crates/humanode-runtime/src/lib.rs index df2d595f9..18011e064 100644 --- a/crates/humanode-runtime/src/lib.rs +++ b/crates/humanode-runtime/src/lib.rs @@ -1597,14 +1597,6 @@ impl_runtime_apis! { signature_check: bool, select: frame_try_runtime::TryStateSelect ) -> Weight { - sp_tracing::info!( - target: "humanode-runtime", - "try-runtime: executing block {:?} / root checks: {:?} / signature check: {:?} / try-state-select: {:?}", - block.header.hash(), - state_root_check, - signature_check, - select, - ); // NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to // have a backtrace here. Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap() diff --git a/crates/pallet-balanced-currency-swap-bridges-initializer/Cargo.toml b/crates/pallet-balanced-currency-swap-bridges-initializer/Cargo.toml index 950972999..46ae19a2a 100644 --- a/crates/pallet-balanced-currency-swap-bridges-initializer/Cargo.toml +++ b/crates/pallet-balanced-currency-swap-bridges-initializer/Cargo.toml @@ -10,7 +10,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } scale-info = { workspace = true, features = ["derive"] } sp-std = { workspace = true } -sp-tracing = { workspace = true } [dev-dependencies] pallet-pot = { path = "../pallet-pot", default-features = false } @@ -29,7 +28,6 @@ std = [ "scale-info/std", "sp-core/std", "sp-std/std", - "sp-tracing/std", ] try-runtime = [ "frame-support/try-runtime", diff --git a/crates/pallet-balanced-currency-swap-bridges-initializer/src/upgrade_init.rs b/crates/pallet-balanced-currency-swap-bridges-initializer/src/upgrade_init.rs index 365159627..9d568be4e 100644 --- a/crates/pallet-balanced-currency-swap-bridges-initializer/src/upgrade_init.rs +++ b/crates/pallet-balanced-currency-swap-bridges-initializer/src/upgrade_init.rs @@ -1,6 +1,6 @@ //! Initialization of the bridge pot accounts on runtime upgrade. -use frame_support::pallet_prelude::*; +use frame_support::{log, pallet_prelude::*}; #[cfg(feature = "try-runtime")] use sp_std::vec::Vec; @@ -23,7 +23,7 @@ pub fn on_runtime_upgrade() -> Weight { if is_version_mismatch || is_forced { match Pallet::::initialize() { Ok(w) => weight.saturating_accrue(w), - Err(err) => sp_tracing::error!("error during bridges initialization: {err:?}"), + Err(err) => log::error!("error during bridges initialization: {err:?}"), } >::put(CURRENT_BRIDGES_INITIALIZER_VERSION); diff --git a/crates/pallet-bioauth/src/lib.rs b/crates/pallet-bioauth/src/lib.rs index eb3662dde..b6cbfa81e 100644 --- a/crates/pallet-bioauth/src/lib.rs +++ b/crates/pallet-bioauth/src/lib.rs @@ -188,7 +188,7 @@ impl AfterAuthHook for () { #[frame_support::pallet] pub mod pallet { use codec::MaxEncodedLen; - use frame_support::{pallet_prelude::*, sp_tracing, storage::types::ValueQuery, BoundedVec}; + use frame_support::{log, pallet_prelude::*, storage::types::ValueQuery, BoundedVec}; use frame_system::pallet_prelude::*; use sp_runtime::{ app_crypto::MaybeHash, @@ -625,7 +625,7 @@ pub mod pallet { let auth_ticket = Self::extract_auth_ticket_checked(transaction.clone()).map_err(|error| { - sp_tracing::error!(message = "Auth Ticket could not be extracted", ?error); + log::error!("Auth Ticket could not be extracted: {error:?}"); // Use bad proof error code, as the extraction. TransactionValidityError::Invalid(match error { AuthTicketExtractionError::UnableToValidateSignature @@ -647,7 +647,7 @@ pub mod pallet { &auth_ticket, ) .map_err(|err| { - sp_tracing::error!(message = "Authentication attemption failed", error = ?err); + log::error!("Authentication attemption failed: {err:?}"); TransactionValidityError::Invalid(match err { AuthenticationAttemptValidationError::NonceConflict => { diff --git a/crates/pallet-erc20-support/src/migrations/v1.rs b/crates/pallet-erc20-support/src/migrations/v1.rs index 3d258b23c..6d12e1dff 100644 --- a/crates/pallet-erc20-support/src/migrations/v1.rs +++ b/crates/pallet-erc20-support/src/migrations/v1.rs @@ -1,6 +1,6 @@ //! Migration to Version 1. -use frame_support::{sp_tracing::info, traits::Get, weights::Weight}; +use frame_support::{log::info, traits::Get, weights::Weight}; use crate::BalanceOf; use crate::{Approvals, Config}; diff --git a/crates/pallet-humanode-session/src/migrations/v1.rs b/crates/pallet-humanode-session/src/migrations/v1.rs index fba9fd622..0fb340224 100644 --- a/crates/pallet-humanode-session/src/migrations/v1.rs +++ b/crates/pallet-humanode-session/src/migrations/v1.rs @@ -2,7 +2,7 @@ use frame_support::pallet_prelude::*; use frame_support::storage_alias; -use frame_support::{dispatch::GetStorageVersion, sp_tracing::info, traits::Get, weights::Weight}; +use frame_support::{dispatch::GetStorageVersion, log::info, traits::Get, weights::Weight}; #[cfg(feature = "try-runtime")] use sp_std::{vec, vec::Vec}; @@ -27,10 +27,10 @@ pub fn migrate() -> Weight { // Read the onchain version. let mut weight: Weight = T::DbWeight::get().reads(1); - info!(message = "Running migration to v1", from = ?onchain); + info!("Running migration to v1 from {onchain:?}"); if onchain == 1 { - info!(message = "Already at version 1, nothing to do"); + info!("Already at version 1, nothing to do"); return weight; } diff --git a/crates/primitives-currency-swap-proxy/src/lib.rs b/crates/primitives-currency-swap-proxy/src/lib.rs index fcc5c31eb..d4c2a4193 100644 --- a/crates/primitives-currency-swap-proxy/src/lib.rs +++ b/crates/primitives-currency-swap-proxy/src/lib.rs @@ -62,10 +62,7 @@ where incoming_imbalance, }) => { let error: frame_support::sp_runtime::DispatchError = error.into(); - frame_support::sp_tracing::error!( - message = "unable to route the funds through the swap", - ?error - ); + frame_support::log::error!("unable to route the funds through the swap: {error:?}"); Fallback::on_unbalanceds(sp_std::iter::once(incoming_imbalance)); return; }