diff --git a/Cargo.lock b/Cargo.lock index 6151ed33c5b6..ab8c8a2fbcdc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1238,7 +1238,6 @@ dependencies = [ "cumulus-primitives-core 0.7.0", "frame-support 28.0.0", "impl-trait-for-tuples", - "log", "pallet-asset-conversion 10.0.0", "pallet-assets 29.1.0", "pallet-xcm 7.0.0", @@ -1251,6 +1250,7 @@ dependencies = [ "staging-xcm-builder 7.0.0", "staging-xcm-executor 7.0.0", "substrate-wasm-builder 17.0.0", + "tracing", ] [[package]] @@ -28176,7 +28176,6 @@ dependencies = [ "frame-support 28.0.0", "frame-system 28.0.0", "impl-trait-for-tuples", - "log", "pallet-asset-conversion 10.0.0", "pallet-assets 29.1.0", "pallet-balances 28.0.0", @@ -28197,6 +28196,7 @@ dependencies = [ "sp-weights 27.0.0", "staging-xcm 7.0.0", "staging-xcm-executor 7.0.0", + "tracing", ] [[package]] diff --git a/cumulus/parachains/runtimes/assets/common/Cargo.toml b/cumulus/parachains/runtimes/assets/common/Cargo.toml index de74f59f43c0..11cff7dd3133 100644 --- a/cumulus/parachains/runtimes/assets/common/Cargo.toml +++ b/cumulus/parachains/runtimes/assets/common/Cargo.toml @@ -14,8 +14,8 @@ workspace = true [dependencies] codec = { features = ["derive"], workspace = true } impl-trait-for-tuples = { workspace = true } -log = { workspace = true } scale-info = { features = ["derive"], workspace = true } +tracing = { workspace = true } # Substrate frame-support = { workspace = true } @@ -43,7 +43,6 @@ std = [ "codec/std", "cumulus-primitives-core/std", "frame-support/std", - "log/std", "pallet-asset-conversion/std", "pallet-assets/std", "pallet-xcm/std", @@ -51,6 +50,7 @@ std = [ "scale-info/std", "sp-api/std", "sp-runtime/std", + "tracing/std", "xcm-builder/std", "xcm-executor/std", "xcm/std", diff --git a/cumulus/parachains/runtimes/assets/common/src/benchmarks.rs b/cumulus/parachains/runtimes/assets/common/src/benchmarks.rs index d59fddc4e8f0..d144523aaacb 100644 --- a/cumulus/parachains/runtimes/assets/common/src/benchmarks.rs +++ b/cumulus/parachains/runtimes/assets/common/src/benchmarks.rs @@ -35,9 +35,31 @@ impl, SelfParaId: Get, PalletId: Get, L: TryFrom return o, _ => () } )* ); - log::trace!(target: "xcm::contains", "did not match location: {:?}", &location); + tracing::trace!(target: "xcm::contains", ?location, "did not match location"); false } } @@ -142,7 +142,10 @@ pub fn convert_balance, Balance: ) -> Result { match balance.try_into() { Ok(balance) => Ok((T::get(), balance).into()), - Err(_) => Err(FungiblesAccessError::AmountToBalanceConversionFailed), + Err(_) => { + tracing::error!(target: "xcm::convert_balance", "Failed to convert balance with location to asset"); + Err(FungiblesAccessError::AmountToBalanceConversionFailed) + }, } } diff --git a/cumulus/parachains/runtimes/assets/common/src/matching.rs b/cumulus/parachains/runtimes/assets/common/src/matching.rs index aa9d7929cb93..92428bffc6a3 100644 --- a/cumulus/parachains/runtimes/assets/common/src/matching.rs +++ b/cumulus/parachains/runtimes/assets/common/src/matching.rs @@ -33,7 +33,7 @@ impl> ContainsPair for IsForeignConcreteAsset { fn contains(asset: &Asset, origin: &Location) -> bool { - log::trace!(target: "xcm::contains", "IsForeignConcreteAsset asset: {:?}, origin: {:?}", asset, origin); + tracing::trace!(target: "xcm::contains", ?asset, ?origin, "IsForeignConcreteAsset"); matches!(asset.id, AssetId(ref id) if IsForeign::contains(id, origin)) } } @@ -86,11 +86,7 @@ impl< match ensure_is_remote(universal_source.clone(), a.clone()) { Ok((network_id, _)) => network_id == ExpectedNetworkId::get(), Err(e) => { - log::trace!( - target: "xcm::contains", - "FromNetwork origin: {:?} is not remote to the universal_source: {:?} {:?}", - a, universal_source, e - ); + tracing::trace!(target: "xcm::contains", global_location = ?a, ?universal_source, error = ?e, "FromNetwork origin is not remote to the universal_source"); false }, } @@ -118,15 +114,20 @@ impl< let expected_origin = OriginLocation::get(); // ensure `origin` is expected `OriginLocation` if !expected_origin.eq(&origin) { - log::trace!( + tracing::trace!( target: "xcm::contains", - "RemoteAssetFromLocation asset: {asset:?}, origin: {origin:?} is not from expected {expected_origin:?}" + ?asset, + ?origin, + ?expected_origin, + "RemoteAssetFromLocation: Asset is not from expected origin" ); return false; } else { - log::trace!( + tracing::trace!( target: "xcm::contains", - "RemoteAssetFromLocation asset: {asset:?}, origin: {origin:?}", + ?asset, + ?origin, + "RemoteAssetFromLocation", ); } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs index befb63ef9709..b4f292ce5621 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs @@ -123,6 +123,7 @@ pub type XcmOriginToTransactDispatchOrigin = ( pub struct ParentOrParentsPlurality; impl Contains for ParentOrParentsPlurality { fn contains(location: &Location) -> bool { + log::trace!(target: "xcm::contains", "ParentOrParentsPlurality: {:?}", &location); matches!(location.unpack(), (1, []) | (1, [Plurality { .. }])) } } @@ -300,6 +301,7 @@ impl, FeeHandler: HandleFee> FeeManager } fn handle_fee(fee: Assets, context: Option<&XcmContext>, reason: FeeReason) { + log::info!(target: "xcm::handle_fee", "handle fee: {fee:?}, with reason: {reason:?}"); FeeHandler::handle_fee(fee, context, reason); } } diff --git a/polkadot/xcm/xcm-builder/Cargo.toml b/polkadot/xcm/xcm-builder/Cargo.toml index f75c984c068e..3bd9dafdf794 100644 --- a/polkadot/xcm/xcm-builder/Cargo.toml +++ b/polkadot/xcm/xcm-builder/Cargo.toml @@ -16,7 +16,6 @@ codec = { features = ["derive"], workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } impl-trait-for-tuples = { workspace = true } -log = { workspace = true } pallet-asset-conversion = { workspace = true } pallet-transaction-payment = { workspace = true } scale-info = { features = ["derive"], workspace = true } @@ -24,6 +23,7 @@ sp-arithmetic = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } sp-weights = { workspace = true } +tracing = { workspace = true } xcm = { workspace = true } xcm-executor = { workspace = true } @@ -65,7 +65,6 @@ std = [ "codec/std", "frame-support/std", "frame-system/std", - "log/std", "pallet-asset-conversion/std", "pallet-transaction-payment/std", "polkadot-parachain-primitives/std", @@ -75,6 +74,7 @@ std = [ "sp-io/std", "sp-runtime/std", "sp-weights/std", + "tracing/std", "xcm-executor/std", "xcm/std", ] diff --git a/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/adapter.rs b/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/adapter.rs index 3108068686f9..6c67faef2c16 100644 --- a/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/adapter.rs +++ b/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/adapter.rs @@ -61,7 +61,7 @@ where ) -> Result { let mut give_iter = give.fungible_assets_iter(); let give_asset = give_iter.next().ok_or_else(|| { - log::trace!( + tracing::trace!( target: "xcm::SingleAssetExchangeAdapter::exchange_asset", "No fungible asset was in `give`.", ); @@ -73,21 +73,21 @@ where let want_asset = want.get(0).ok_or_else(|| give.clone())?; let (give_asset_id, give_amount) = Matcher::matches_fungibles(&give_asset).map_err(|error| { - log::trace!( + tracing::trace!( target: "xcm::SingleAssetExchangeAdapter::exchange_asset", - "Could not map XCM asset give {:?} to FRAME asset. Error: {:?}", - give_asset, - error, + ?give_asset, + ?error, + "Could not map XCM asset give to FRAME asset.", ); give.clone() })?; let (want_asset_id, want_amount) = Matcher::matches_fungibles(&want_asset).map_err(|error| { - log::trace!( + tracing::trace!( target: "xcm::SingleAssetExchangeAdapter::exchange_asset", - "Could not map XCM asset want {:?} to FRAME asset. Error: {:?}", - want_asset, - error, + ?want_asset, + ?error, + "Could not map XCM asset want to FRAME asset." ); give.clone() })?; @@ -106,10 +106,10 @@ where Some(want_amount), ) .map_err(|(credit_in, error)| { - log::error!( + tracing::error!( target: "xcm::SingleAssetExchangeAdapter::exchange_asset", - "Could not perform the swap, error: {:?}.", - error + ?error, + "Could not perform the swap" ); drop(credit_in); give.clone() @@ -127,10 +127,10 @@ where want_amount, ) .map_err(|(credit_in, error)| { - log::error!( + tracing::error!( target: "xcm::SingleAssetExchangeAdapter::exchange_asset", - "Could not perform the swap, error: {:?}.", - error + ?error, + "Could not perform the swap", ); drop(credit_in); give.clone() @@ -162,22 +162,22 @@ where // We first match both XCM assets to the asset ID types `AssetConversion` can handle. let (give_asset_id, give_amount) = Matcher::matches_fungibles(give_asset) .map_err(|error| { - log::trace!( + tracing::trace!( target: "xcm::SingleAssetExchangeAdapter::quote_exchange_price", - "Could not map XCM asset {:?} to FRAME asset. Error: {:?}.", - give_asset, - error, + ?give_asset, + ?error, + "Could not map XCM asset to FRAME asset." ); () }) .ok()?; let (want_asset_id, want_amount) = Matcher::matches_fungibles(want_asset) .map_err(|error| { - log::trace!( + tracing::trace!( target: "xcm::SingleAssetExchangeAdapter::quote_exchange_price", - "Could not map XCM asset {:?} to FRAME asset. Error: {:?}.", - want_asset, - error, + ?want_asset, + ?error, + "Could not map XCM asset to FRAME asset" ); () }) diff --git a/polkadot/xcm/xcm-builder/src/barriers.rs b/polkadot/xcm/xcm-builder/src/barriers.rs index adba9a3ef79f..36765c1191c9 100644 --- a/polkadot/xcm/xcm-builder/src/barriers.rs +++ b/polkadot/xcm/xcm-builder/src/barriers.rs @@ -39,10 +39,13 @@ impl ShouldExecute for TakeWeightCredit { max_weight: Weight, properties: &mut Properties, ) -> Result<(), ProcessMessageError> { - log::trace!( + tracing::trace!( target: "xcm::barriers", - "TakeWeightCredit origin: {:?}, instructions: {:?}, max_weight: {:?}, properties: {:?}", - _origin, _instructions, max_weight, properties, + origin = ?_origin, + instructions = ?_instructions, + ?max_weight, + ?properties, + "TakeWeightCredit" ); properties.weight_credit = properties .weight_credit @@ -68,10 +71,13 @@ impl> ShouldExecute for AllowTopLevelPaidExecutionFrom max_weight: Weight, _properties: &mut Properties, ) -> Result<(), ProcessMessageError> { - log::trace!( + tracing::trace!( target: "xcm::barriers", - "AllowTopLevelPaidExecutionFrom origin: {:?}, instructions: {:?}, max_weight: {:?}, properties: {:?}", - origin, instructions, max_weight, _properties, + ?origin, + ?instructions, + ?max_weight, + properties = ?_properties, + "AllowTopLevelPaidExecutionFrom", ); ensure!(T::contains(origin), ProcessMessageError::Unsupported); @@ -173,10 +179,13 @@ impl, MaxPref max_weight: Weight, properties: &mut Properties, ) -> Result<(), ProcessMessageError> { - log::trace!( + tracing::trace!( target: "xcm::barriers", - "WithComputedOrigin origin: {:?}, instructions: {:?}, max_weight: {:?}, properties: {:?}", - origin, instructions, max_weight, properties, + ?origin, + ?instructions, + ?max_weight, + ?properties, + "WithComputedOrigin" ); let mut actual_origin = origin.clone(); let skipped = Cell::new(0usize); @@ -230,10 +239,13 @@ impl ShouldExecute for TrailingSetTopicAsId Result<(), ProcessMessageError> { - log::trace!( + tracing::trace!( target: "xcm::barriers", - "TrailingSetTopicAsId origin: {:?}, instructions: {:?}, max_weight: {:?}, properties: {:?}", - origin, instructions, max_weight, properties, + ?origin, + ?instructions, + ?max_weight, + ?properties, + "TrailingSetTopicAsId" ); let until = if let Some(SetTopic(t)) = instructions.last() { properties.message_id = Some(*t); @@ -279,10 +291,10 @@ impl> ShouldExecute for AllowUnpaidExecutionFrom { _max_weight: Weight, _properties: &mut Properties, ) -> Result<(), ProcessMessageError> { - log::trace!( + tracing::trace!( target: "xcm::barriers", - "AllowUnpaidExecutionFrom origin: {:?}, instructions: {:?}, max_weight: {:?}, properties: {:?}", - origin, instructions, _max_weight, _properties, + ?origin, ?instructions, max_weight = ?_max_weight, properties = ?_properties, + "AllowUnpaidExecutionFrom" ); ensure!(T::contains(origin), ProcessMessageError::Unsupported); Ok(()) @@ -301,10 +313,10 @@ impl> ShouldExecute for AllowExplicitUnpaidExecutionFrom Result<(), ProcessMessageError> { - log::trace!( + tracing::trace!( target: "xcm::barriers", - "AllowExplicitUnpaidExecutionFrom origin: {:?}, instructions: {:?}, max_weight: {:?}, properties: {:?}", - origin, instructions, max_weight, _properties, + ?origin, ?instructions, ?max_weight, properties = ?_properties, + "AllowExplicitUnpaidExecutionFrom", ); ensure!(T::contains(origin), ProcessMessageError::Unsupported); instructions.matcher().match_next_inst(|inst| match inst { @@ -360,10 +372,10 @@ impl ShouldExecute for AllowKnownQueryResponses Result<(), ProcessMessageError> { - log::trace!( + tracing::trace!( target: "xcm::barriers", - "AllowKnownQueryResponses origin: {:?}, instructions: {:?}, max_weight: {:?}, properties: {:?}", - origin, instructions, _max_weight, _properties, + ?origin, ?instructions, max_weight = ?_max_weight, properties = ?_properties, + "AllowKnownQueryResponses" ); instructions .matcher() @@ -388,10 +400,10 @@ impl> ShouldExecute for AllowSubscriptionsFrom { _max_weight: Weight, _properties: &mut Properties, ) -> Result<(), ProcessMessageError> { - log::trace!( + tracing::trace!( target: "xcm::barriers", - "AllowSubscriptionsFrom origin: {:?}, instructions: {:?}, max_weight: {:?}, properties: {:?}", - origin, instructions, _max_weight, _properties, + ?origin, ?instructions, max_weight = ?_max_weight, properties = ?_properties, + "AllowSubscriptionsFrom", ); ensure!(T::contains(origin), ProcessMessageError::Unsupported); instructions @@ -419,10 +431,10 @@ impl ShouldExecute for AllowHrmpNotificationsFromRelayChain { _max_weight: Weight, _properties: &mut Properties, ) -> Result<(), ProcessMessageError> { - log::trace!( + tracing::trace!( target: "xcm::barriers", - "AllowHrmpNotificationsFromRelayChain origin: {:?}, instructions: {:?}, max_weight: {:?}, properties: {:?}", - origin, instructions, _max_weight, _properties, + ?origin, ?instructions, max_weight = ?_max_weight, properties = ?_properties, + "AllowHrmpNotificationsFromRelayChain" ); // accept only the Relay Chain ensure!(matches!(origin.unpack(), (1, [])), ProcessMessageError::Unsupported); @@ -489,7 +501,7 @@ impl ShouldExecute for DenyReserveTransferToRelayChain { ReserveAssetDeposited { .. } if matches!(origin, Location { parents: 1, interior: Here }) => { - log::warn!( + tracing::warn!( target: "xcm::barrier", "Unexpected ReserveAssetDeposited from the Relay Chain", ); diff --git a/polkadot/xcm/xcm-builder/src/currency_adapter.rs b/polkadot/xcm/xcm-builder/src/currency_adapter.rs index 355d6ad85388..4d9cb18b4835 100644 --- a/polkadot/xcm/xcm-builder/src/currency_adapter.rs +++ b/polkadot/xcm/xcm-builder/src/currency_adapter.rs @@ -143,7 +143,7 @@ impl< for CurrencyAdapter { fn can_check_in(_origin: &Location, what: &Asset, _context: &XcmContext) -> Result { - log::trace!(target: "xcm::currency_adapter", "can_check_in origin: {:?}, what: {:?}", _origin, what); + tracing::trace!(target: "xcm::currency_adapter", origin = ?_origin, ?what, "can_check_in origin",); // Check we handle this asset. let amount: Currency::Balance = Matcher::matches_fungible(what).ok_or(Error::AssetNotHandled)?; @@ -157,7 +157,7 @@ impl< } fn check_in(_origin: &Location, what: &Asset, _context: &XcmContext) { - log::trace!(target: "xcm::currency_adapter", "check_in origin: {:?}, what: {:?}", _origin, what); + tracing::trace!(target: "xcm::currency_adapter", origin = ?_origin, ?what, "check_in origin"); if let Some(amount) = Matcher::matches_fungible(what) { match CheckedAccount::get() { Some((checked_account, MintLocation::Local)) => @@ -170,7 +170,7 @@ impl< } fn can_check_out(_dest: &Location, what: &Asset, _context: &XcmContext) -> Result { - log::trace!(target: "xcm::currency_adapter", "can_check_out dest: {:?}, what: {:?}", _dest, what); + tracing::trace!(target: "xcm::currency_adapter", dest = ?_dest, ?what, "can_check_out",); let amount = Matcher::matches_fungible(what).ok_or(Error::AssetNotHandled)?; match CheckedAccount::get() { Some((checked_account, MintLocation::Local)) => @@ -182,7 +182,7 @@ impl< } fn check_out(_dest: &Location, what: &Asset, _context: &XcmContext) { - log::trace!(target: "xcm::currency_adapter", "check_out dest: {:?}, what: {:?}", _dest, what); + tracing::trace!(target: "xcm::currency_adapter", dest = ?_dest, ?what, "check_out",); if let Some(amount) = Matcher::matches_fungible(what) { match CheckedAccount::get() { Some((checked_account, MintLocation::Local)) => @@ -195,7 +195,7 @@ impl< } fn deposit_asset(what: &Asset, who: &Location, _context: Option<&XcmContext>) -> Result { - log::trace!(target: "xcm::currency_adapter", "deposit_asset what: {:?}, who: {:?}", what, who); + tracing::trace!(target: "xcm::currency_adapter", ?what, ?who, "deposit_asset",); // Check we handle this asset. let amount = Matcher::matches_fungible(&what).ok_or(Error::AssetNotHandled)?; let who = @@ -209,7 +209,7 @@ impl< who: &Location, _maybe_context: Option<&XcmContext>, ) -> result::Result { - log::trace!(target: "xcm::currency_adapter", "withdraw_asset what: {:?}, who: {:?}", what, who); + tracing::trace!(target: "xcm::currency_adapter", ?what, ?who, "withdraw_asset"); // Check we handle this asset. let amount = Matcher::matches_fungible(what).ok_or(Error::AssetNotHandled)?; let who = @@ -225,7 +225,7 @@ impl< to: &Location, _context: &XcmContext, ) -> result::Result { - log::trace!(target: "xcm::currency_adapter", "internal_transfer_asset asset: {:?}, from: {:?}, to: {:?}", asset, from, to); + tracing::trace!(target: "xcm::currency_adapter", ?asset, ?from, ?to, "internal_transfer_asset"); let amount = Matcher::matches_fungible(asset).ok_or(Error::AssetNotHandled)?; let from = AccountIdConverter::convert_location(from).ok_or(Error::AccountIdConversionFailed)?; diff --git a/polkadot/xcm/xcm-builder/src/fee_handling.rs b/polkadot/xcm/xcm-builder/src/fee_handling.rs index 17e9e64e00c9..352118d762ab 100644 --- a/polkadot/xcm/xcm-builder/src/fee_handling.rs +++ b/polkadot/xcm/xcm-builder/src/fee_handling.rs @@ -127,7 +127,7 @@ pub fn deposit_or_burn_fee( ) { for asset in fee.into_inner() { if let Err(e) = AssetTransactor::deposit_asset(&asset, &dest, context) { - log::trace!( + tracing::trace!( target: "xcm::fees", "`AssetTransactor::deposit_asset` returned error: {e:?}. Burning fee: {asset:?}. \ They might be burned.", diff --git a/polkadot/xcm/xcm-builder/src/filter_asset_location.rs b/polkadot/xcm/xcm-builder/src/filter_asset_location.rs index 16b7be7f3ba9..55d548de453d 100644 --- a/polkadot/xcm/xcm-builder/src/filter_asset_location.rs +++ b/polkadot/xcm/xcm-builder/src/filter_asset_location.rs @@ -26,7 +26,7 @@ use xcm::latest::{Asset, AssetFilter, AssetId, Location, WildAsset}; pub struct NativeAsset; impl ContainsPair for NativeAsset { fn contains(asset: &Asset, origin: &Location) -> bool { - log::trace!(target: "xcm::contains", "NativeAsset asset: {:?}, origin: {:?}", asset, origin); + tracing::trace!(target: "xcm::contains", ?asset, ?origin, "NativeAsset"); matches!(asset.id, AssetId(ref id) if id == origin) } } @@ -35,7 +35,7 @@ impl ContainsPair for NativeAsset { pub struct Case(PhantomData); impl> ContainsPair for Case { fn contains(asset: &Asset, origin: &Location) -> bool { - log::trace!(target: "xcm::contains", "Case asset: {:?}, origin: {:?}", asset, origin); + tracing::trace!(target: "xcm::contains", ?asset, ?origin, "Case asset"); let (a, o) = T::get(); a.matches(asset) && &o == origin } @@ -51,7 +51,7 @@ impl, AssetFilters: Get>> Contains<(Location, Vec)> for LocationWithAssetFilters { fn contains((location, assets): &(Location, Vec)) -> bool { - log::trace!(target: "xcm::contains", "LocationWithAssetFilters location: {:?}, assets: {:?}", location, assets); + tracing::trace!(target: "xcm::contains", ?location, ?assets, "LocationWithAssetFilters"); // `location` must match the `Location` filter. if !LocationFilter::contains(location) { diff --git a/polkadot/xcm/xcm-builder/src/fungible_adapter.rs b/polkadot/xcm/xcm-builder/src/fungible_adapter.rs index 25a705a39eb7..6ba6c2d9a752 100644 --- a/polkadot/xcm/xcm-builder/src/fungible_adapter.rs +++ b/polkadot/xcm/xcm-builder/src/fungible_adapter.rs @@ -53,10 +53,10 @@ impl< to: &Location, _context: &XcmContext, ) -> result::Result { - log::trace!( + tracing::trace!( target: "xcm::fungible_adapter", - "internal_transfer_asset what: {:?}, from: {:?}, to: {:?}", - what, from, to + ?what, ?from, ?to, + "internal_transfer_asset", ); // Check we handle the asset let amount = Matcher::matches_fungible(what).ok_or(MatchError::AssetNotHandled)?; @@ -119,10 +119,10 @@ impl< for FungibleMutateAdapter { fn can_check_in(_origin: &Location, what: &Asset, _context: &XcmContext) -> XcmResult { - log::trace!( + tracing::trace!( target: "xcm::fungible_adapter", - "can_check_in origin: {:?}, what: {:?}", - _origin, what + origin = ?_origin, ?what, + "can_check_in origin", ); // Check we handle this asset let amount = Matcher::matches_fungible(what).ok_or(MatchError::AssetNotHandled)?; @@ -136,10 +136,10 @@ impl< } fn check_in(_origin: &Location, what: &Asset, _context: &XcmContext) { - log::trace!( + tracing::trace!( target: "xcm::fungible_adapter", - "check_in origin: {:?}, what: {:?}", - _origin, what + origin = ?_origin, ?what, + "check_in origin", ); if let Some(amount) = Matcher::matches_fungible(what) { match CheckingAccount::get() { @@ -153,11 +153,11 @@ impl< } fn can_check_out(_dest: &Location, what: &Asset, _context: &XcmContext) -> XcmResult { - log::trace!( + tracing::trace!( target: "xcm::fungible_adapter", - "can_check_out dest: {:?}, what: {:?}", - _dest, - what + dest = ?_dest, + ?what, + "can_check_out", ); let amount = Matcher::matches_fungible(what).ok_or(MatchError::AssetNotHandled)?; match CheckingAccount::get() { @@ -170,11 +170,11 @@ impl< } fn check_out(_dest: &Location, what: &Asset, _context: &XcmContext) { - log::trace!( + tracing::trace!( target: "xcm::fungible_adapter", - "check_out dest: {:?}, what: {:?}", - _dest, - what + dest = ?_dest, + ?what, + "check_out", ); if let Some(amount) = Matcher::matches_fungible(what) { match CheckingAccount::get() { @@ -188,10 +188,10 @@ impl< } fn deposit_asset(what: &Asset, who: &Location, _context: Option<&XcmContext>) -> XcmResult { - log::trace!( + tracing::trace!( target: "xcm::fungible_adapter", - "deposit_asset what: {:?}, who: {:?}", - what, who, + ?what, ?who, + "deposit_asset", ); let amount = Matcher::matches_fungible(what).ok_or(MatchError::AssetNotHandled)?; let who = AccountIdConverter::convert_location(who) @@ -206,10 +206,10 @@ impl< who: &Location, _context: Option<&XcmContext>, ) -> result::Result { - log::trace!( + tracing::trace!( target: "xcm::fungible_adapter", - "withdraw_asset what: {:?}, who: {:?}", - what, who, + ?what, ?who, + "withdraw_asset", ); let amount = Matcher::matches_fungible(what).ok_or(MatchError::AssetNotHandled)?; let who = AccountIdConverter::convert_location(who) diff --git a/polkadot/xcm/xcm-builder/src/fungibles_adapter.rs b/polkadot/xcm/xcm-builder/src/fungibles_adapter.rs index a259afc6e682..3eed38a4f22b 100644 --- a/polkadot/xcm/xcm-builder/src/fungibles_adapter.rs +++ b/polkadot/xcm/xcm-builder/src/fungibles_adapter.rs @@ -47,10 +47,10 @@ impl< to: &Location, _context: &XcmContext, ) -> result::Result { - log::trace!( + tracing::trace!( target: "xcm::fungibles_adapter", - "internal_transfer_asset what: {:?}, from: {:?}, to: {:?}", - what, from, to + ?what, ?from, ?to, + "internal_transfer_asset", ); // Check we handle this asset. let (asset_id, amount) = Matcher::matches_fungibles(what)?; @@ -59,7 +59,10 @@ impl< let dest = AccountIdConverter::convert_location(to) .ok_or(MatchError::AccountIdConversionFailed)?; Assets::transfer(asset_id, &source, &dest, amount, Preserve) - .map_err(|e| XcmError::FailedToTransactAsset(e.into()))?; + .map_err(|e| { + tracing::error!(target: "xcm::fungibles_adapter", error = ?e, ?amount, "Failed to transfer asset internally"); + XcmError::FailedToTransactAsset(e.into()) + })?; Ok(what.clone().into()) } } @@ -204,10 +207,10 @@ impl< > { fn can_check_in(_origin: &Location, what: &Asset, _context: &XcmContext) -> XcmResult { - log::trace!( + tracing::trace!( target: "xcm::fungibles_adapter", - "can_check_in origin: {:?}, what: {:?}", - _origin, what + origin = ?_origin, ?what, + "can_check_in", ); // Check we handle this asset. let (asset_id, amount) = Matcher::matches_fungibles(what)?; @@ -221,10 +224,10 @@ impl< } fn check_in(_origin: &Location, what: &Asset, _context: &XcmContext) { - log::trace!( + tracing::trace!( target: "xcm::fungibles_adapter", - "check_in origin: {:?}, what: {:?}", - _origin, what + origin = ?_origin, ?what, + "check_in", ); if let Ok((asset_id, amount)) = Matcher::matches_fungibles(what) { match CheckAsset::asset_checking(&asset_id) { @@ -238,10 +241,10 @@ impl< } fn can_check_out(_origin: &Location, what: &Asset, _context: &XcmContext) -> XcmResult { - log::trace!( + tracing::trace!( target: "xcm::fungibles_adapter", - "can_check_out origin: {:?}, what: {:?}", - _origin, what + origin = ?_origin, ?what, + "can_check_out", ); // Check we handle this asset. let (asset_id, amount) = Matcher::matches_fungibles(what)?; @@ -255,10 +258,10 @@ impl< } fn check_out(_dest: &Location, what: &Asset, _context: &XcmContext) { - log::trace!( + tracing::trace!( target: "xcm::fungibles_adapter", - "check_out dest: {:?}, what: {:?}", - _dest, what + dest = ?_dest, ?what, + "check_out", ); if let Ok((asset_id, amount)) = Matcher::matches_fungibles(what) { match CheckAsset::asset_checking(&asset_id) { @@ -272,10 +275,10 @@ impl< } fn deposit_asset(what: &Asset, who: &Location, _context: Option<&XcmContext>) -> XcmResult { - log::trace!( + tracing::trace!( target: "xcm::fungibles_adapter", - "deposit_asset what: {:?}, who: {:?}", - what, who, + ?what, ?who, + "deposit_asset", ); // Check we handle this asset. let (asset_id, amount) = Matcher::matches_fungibles(what)?; @@ -291,10 +294,10 @@ impl< who: &Location, _maybe_context: Option<&XcmContext>, ) -> result::Result { - log::trace!( + tracing::trace!( target: "xcm::fungibles_adapter", - "withdraw_asset what: {:?}, who: {:?}", - what, who, + ?what, ?who, + "withdraw_asset", ); // Check we handle this asset. let (asset_id, amount) = Matcher::matches_fungibles(what)?; diff --git a/polkadot/xcm/xcm-builder/src/location_conversion.rs b/polkadot/xcm/xcm-builder/src/location_conversion.rs index 1d840e9c0dde..c7aa0c8b5041 100644 --- a/polkadot/xcm/xcm-builder/src/location_conversion.rs +++ b/polkadot/xcm/xcm-builder/src/location_conversion.rs @@ -392,10 +392,10 @@ impl, AccountId: From<[u8; 32]> + Clone { fn convert_location(location: &Location) -> Option { let universal_source = UniversalLocation::get(); - log::trace!( + tracing::trace!( target: "xcm::location_conversion", - "GlobalConsensusConvertsFor universal_source: {:?}, location: {:?}", - universal_source, location, + ?universal_source, ?location, + "GlobalConsensusConvertsFor", ); let (remote_network, remote_location) = ensure_is_remote(universal_source, location.clone()).ok()?; @@ -435,10 +435,10 @@ impl, AccountId: From<[u8; 32]> + Clone { fn convert_location(location: &Location) -> Option { let universal_source = UniversalLocation::get(); - log::trace!( + tracing::trace!( target: "xcm::location_conversion", - "GlobalConsensusParachainConvertsFor universal_source: {:?}, location: {:?}", - universal_source, location, + ?universal_source, ?location, + "GlobalConsensusParachainConvertsFor", ); let devolved = ensure_is_remote(universal_source, location.clone()).ok()?; let (remote_network, remote_location) = devolved; diff --git a/polkadot/xcm/xcm-builder/src/nonfungible_adapter.rs b/polkadot/xcm/xcm-builder/src/nonfungible_adapter.rs index 8e6232ea64d2..7fc52a8a5000 100644 --- a/polkadot/xcm/xcm-builder/src/nonfungible_adapter.rs +++ b/polkadot/xcm/xcm-builder/src/nonfungible_adapter.rs @@ -49,20 +49,22 @@ impl< to: &Location, context: &XcmContext, ) -> result::Result { - log::trace!( + tracing::trace!( target: LOG_TARGET, - "transfer_asset what: {:?}, from: {:?}, to: {:?}, context: {:?}", - what, - from, - to, - context, + ?what, + ?from, + ?to, + ?context, + "transfer_asset", ); // Check we handle this asset. let instance = Matcher::matches_nonfungible(what).ok_or(MatchError::AssetNotHandled)?; let destination = AccountIdConverter::convert_location(to) .ok_or(MatchError::AccountIdConversionFailed)?; - NonFungible::transfer(&instance, &destination) - .map_err(|e| XcmError::FailedToTransactAsset(e.into()))?; + NonFungible::transfer(&instance, &destination).map_err(|e| { + tracing::error!(target: LOG_TARGET, ?e, "Failed to transfer asset"); + XcmError::FailedToTransactAsset(e.into()) + })?; Ok(what.clone().into()) } } @@ -117,12 +119,12 @@ impl< for NonFungibleMutateAdapter { fn can_check_in(_origin: &Location, what: &Asset, context: &XcmContext) -> XcmResult { - log::trace!( + tracing::trace!( target: LOG_TARGET, - "can_check_in origin: {:?}, what: {:?}, context: {:?}", - _origin, - what, - context, + origin = ?_origin, + ?what, + ?context, + "can_check_in", ); // Check we handle this asset. let instance = Matcher::matches_nonfungible(what).ok_or(MatchError::AssetNotHandled)?; @@ -137,12 +139,12 @@ impl< } fn check_in(_origin: &Location, what: &Asset, context: &XcmContext) { - log::trace!( + tracing::trace!( target: LOG_TARGET, - "check_in origin: {:?}, what: {:?}, context: {:?}", - _origin, - what, - context, + origin = ?_origin, + ?what, + ?context, + "check_in", ); if let Some(instance) = Matcher::matches_nonfungible(what) { match CheckingAccount::get() { @@ -157,12 +159,12 @@ impl< } fn can_check_out(_dest: &Location, what: &Asset, context: &XcmContext) -> XcmResult { - log::trace!( + tracing::trace!( target: LOG_TARGET, - "can_check_out dest: {:?}, what: {:?}, context: {:?}", - _dest, - what, - context, + dest = ?_dest, + ?what, + ?context, + "can_check_out", ); // Check we handle this asset. let instance = Matcher::matches_nonfungible(what).ok_or(MatchError::AssetNotHandled)?; @@ -177,12 +179,12 @@ impl< } fn check_out(_dest: &Location, what: &Asset, context: &XcmContext) { - log::trace!( + tracing::trace!( target: LOG_TARGET, - "check_out dest: {:?}, what: {:?}, context: {:?}", - _dest, - what, - context, + dest = ?_dest, + ?what, + ?context, + "check_out", ); if let Some(instance) = Matcher::matches_nonfungible(what) { match CheckingAccount::get() { @@ -197,19 +199,21 @@ impl< } fn deposit_asset(what: &Asset, who: &Location, context: Option<&XcmContext>) -> XcmResult { - log::trace!( + tracing::trace!( target: LOG_TARGET, - "deposit_asset what: {:?}, who: {:?}, context: {:?}", - what, - who, - context, + ?what, + ?who, + ?context, + "deposit_asset", ); // Check we handle this asset. let instance = Matcher::matches_nonfungible(what).ok_or(MatchError::AssetNotHandled)?; let who = AccountIdConverter::convert_location(who) .ok_or(MatchError::AccountIdConversionFailed)?; - NonFungible::mint_into(&instance, &who) - .map_err(|e| XcmError::FailedToTransactAsset(e.into())) + NonFungible::mint_into(&instance, &who).map_err(|e| { + tracing::error!(target: LOG_TARGET, ?e, "Failed to mint asset"); + XcmError::FailedToTransactAsset(e.into()) + }) } fn withdraw_asset( @@ -217,19 +221,21 @@ impl< who: &Location, maybe_context: Option<&XcmContext>, ) -> result::Result { - log::trace!( + tracing::trace!( target: LOG_TARGET, - "withdraw_asset what: {:?}, who: {:?}, maybe_context: {:?}", - what, - who, - maybe_context, + ?what, + ?who, + ?maybe_context, + "withdraw_asset", ); // Check we handle this asset. let who = AccountIdConverter::convert_location(who) .ok_or(MatchError::AccountIdConversionFailed)?; let instance = Matcher::matches_nonfungible(what).ok_or(MatchError::AssetNotHandled)?; - NonFungible::burn(&instance, Some(&who)) - .map_err(|e| XcmError::FailedToTransactAsset(e.into()))?; + NonFungible::burn(&instance, Some(&who)).map_err(|e| { + tracing::error!(target: LOG_TARGET, ?e, "Failed to withdraw asset"); + XcmError::FailedToTransactAsset(e.into()) + })?; Ok(what.clone().into()) } } diff --git a/polkadot/xcm/xcm-builder/src/nonfungibles_adapter.rs b/polkadot/xcm/xcm-builder/src/nonfungibles_adapter.rs index 006c28954bce..d07bbae673d3 100644 --- a/polkadot/xcm/xcm-builder/src/nonfungibles_adapter.rs +++ b/polkadot/xcm/xcm-builder/src/nonfungibles_adapter.rs @@ -48,20 +48,22 @@ impl< to: &Location, context: &XcmContext, ) -> result::Result { - log::trace!( + tracing::trace!( target: LOG_TARGET, - "transfer_asset what: {:?}, from: {:?}, to: {:?}, context: {:?}", - what, - from, - to, - context, + ?what, + ?from, + ?to, + ?context, + "transfer_asset", ); // Check we handle this asset. let (class, instance) = Matcher::matches_nonfungibles(what)?; let destination = AccountIdConverter::convert_location(to) .ok_or(MatchError::AccountIdConversionFailed)?; - Assets::transfer(&class, &instance, &destination) - .map_err(|e| XcmError::FailedToTransactAsset(e.into()))?; + Assets::transfer(&class, &instance, &destination).map_err(|e| { + tracing::error!(target: LOG_TARGET, ?e, "Failed to transfer asset"); + XcmError::FailedToTransactAsset(e.into()) + })?; Ok(what.clone().into()) } } @@ -138,12 +140,12 @@ impl< > { fn can_check_in(_origin: &Location, what: &Asset, context: &XcmContext) -> XcmResult { - log::trace!( + tracing::trace!( target: LOG_TARGET, - "can_check_in origin: {:?}, what: {:?}, context: {:?}", - _origin, - what, - context, + origin = ?_origin, + ?what, + ?context, + "can_check_in", ); // Check we handle this asset. let (class, instance) = Matcher::matches_nonfungibles(what)?; @@ -157,12 +159,12 @@ impl< } fn check_in(_origin: &Location, what: &Asset, context: &XcmContext) { - log::trace!( + tracing::trace!( target: LOG_TARGET, - "check_in origin: {:?}, what: {:?}, context: {:?}", - _origin, - what, - context, + origin = ?_origin, + ?what, + ?context, + "check_in", ); if let Ok((class, instance)) = Matcher::matches_nonfungibles(what) { match CheckAsset::asset_checking(&class) { @@ -176,12 +178,12 @@ impl< } fn can_check_out(_dest: &Location, what: &Asset, context: &XcmContext) -> XcmResult { - log::trace!( + tracing::trace!( target: LOG_TARGET, - "can_check_out dest: {:?}, what: {:?}, context: {:?}", - _dest, - what, - context, + dest = ?_dest, + ?what, + ?context, + "can_check_out", ); // Check we handle this asset. let (class, instance) = Matcher::matches_nonfungibles(what)?; @@ -195,12 +197,12 @@ impl< } fn check_out(_dest: &Location, what: &Asset, context: &XcmContext) { - log::trace!( + tracing::trace!( target: LOG_TARGET, - "check_out dest: {:?}, what: {:?}, context: {:?}", - _dest, - what, - context, + dest = ?_dest, + ?what, + ?context, + "check_out", ); if let Ok((class, instance)) = Matcher::matches_nonfungibles(what) { match CheckAsset::asset_checking(&class) { @@ -214,19 +216,21 @@ impl< } fn deposit_asset(what: &Asset, who: &Location, context: Option<&XcmContext>) -> XcmResult { - log::trace!( + tracing::trace!( target: LOG_TARGET, - "deposit_asset what: {:?}, who: {:?}, context: {:?}", - what, - who, - context, + ?what, + ?who, + ?context, + "deposit_asset", ); // Check we handle this asset. let (class, instance) = Matcher::matches_nonfungibles(what)?; let who = AccountIdConverter::convert_location(who) .ok_or(MatchError::AccountIdConversionFailed)?; - Assets::mint_into(&class, &instance, &who) - .map_err(|e| XcmError::FailedToTransactAsset(e.into())) + Assets::mint_into(&class, &instance, &who).map_err(|e| { + tracing::error!(target: LOG_TARGET, ?e, "Failed to mint asset"); + XcmError::FailedToTransactAsset(e.into()) + }) } fn withdraw_asset( @@ -234,19 +238,21 @@ impl< who: &Location, maybe_context: Option<&XcmContext>, ) -> result::Result { - log::trace!( + tracing::trace!( target: LOG_TARGET, - "withdraw_asset what: {:?}, who: {:?}, maybe_context: {:?}", - what, - who, - maybe_context, + ?what, + ?who, + ?maybe_context, + "withdraw_asset", ); // Check we handle this asset. let who = AccountIdConverter::convert_location(who) .ok_or(MatchError::AccountIdConversionFailed)?; let (class, instance) = Matcher::matches_nonfungibles(what)?; - Assets::burn(&class, &instance, Some(&who)) - .map_err(|e| XcmError::FailedToTransactAsset(e.into()))?; + Assets::burn(&class, &instance, Some(&who)).map_err(|e| { + tracing::error!(target: LOG_TARGET, ?e, "Failed to burn asset"); + XcmError::FailedToTransactAsset(e.into()) + })?; Ok(what.clone().into()) } } diff --git a/polkadot/xcm/xcm-builder/src/origin_conversion.rs b/polkadot/xcm/xcm-builder/src/origin_conversion.rs index 6e73c0dae7b6..20dbc9bba0a5 100644 --- a/polkadot/xcm/xcm-builder/src/origin_conversion.rs +++ b/polkadot/xcm/xcm-builder/src/origin_conversion.rs @@ -39,10 +39,10 @@ where kind: OriginKind, ) -> Result { let origin = origin.into(); - log::trace!( + tracing::trace!( target: "xcm::origin_conversion", - "SovereignSignedViaLocation origin: {:?}, kind: {:?}", - origin, kind, + ?origin, ?kind, + "SovereignSignedViaLocation", ); if let OriginKind::SovereignAccount = kind { let location = LocationConverter::convert_location(&origin).ok_or(origin)?; @@ -60,7 +60,7 @@ impl ConvertOrigin for ParentAsSuperu kind: OriginKind, ) -> Result { let origin = origin.into(); - log::trace!(target: "xcm::origin_conversion", "ParentAsSuperuser origin: {:?}, kind: {:?}", origin, kind); + tracing::trace!(target: "xcm::origin_conversion", ?origin, ?kind, "ParentAsSuperuser",); if kind == OriginKind::Superuser && origin.contains_parents_only(1) { Ok(RuntimeOrigin::root()) } else { @@ -80,7 +80,7 @@ impl, RuntimeOrigin: OriginTrait> ConvertOrigin Result { let origin = origin.into(); - log::trace!(target: "xcm::origin_conversion", "ChildSystemParachainAsSuperuser origin: {:?}, kind: {:?}", origin, kind); + tracing::trace!(target: "xcm::origin_conversion", ?origin, ?kind, "ChildSystemParachainAsSuperuser",); match (kind, origin.unpack()) { (OriginKind::Superuser, (0, [Junction::Parachain(id)])) if ParaId::from(*id).is_system() => @@ -101,10 +101,10 @@ impl, RuntimeOrigin: OriginTrait> ConvertOrigin Result { let origin = origin.into(); - log::trace!( + tracing::trace!( target: "xcm::origin_conversion", - "SiblingSystemParachainAsSuperuser origin: {:?}, kind: {:?}", - origin, kind, + ?origin, ?kind, + "SiblingSystemParachainAsSuperuser", ); match (kind, origin.unpack()) { (OriginKind::Superuser, (1, [Junction::Parachain(id)])) @@ -126,7 +126,7 @@ impl, RuntimeOrigin: From> ConvertOr kind: OriginKind, ) -> Result { let origin = origin.into(); - log::trace!(target: "xcm::origin_conversion", "ChildParachainAsNative origin: {:?}, kind: {:?}", origin, kind); + tracing::trace!(target: "xcm::origin_conversion", ?origin, ?kind, "ChildParachainAsNative"); match (kind, origin.unpack()) { (OriginKind::Native, (0, [Junction::Parachain(id)])) => Ok(RuntimeOrigin::from(ParachainOrigin::from(*id))), @@ -146,10 +146,10 @@ impl, RuntimeOrigin: From> ConvertOr kind: OriginKind, ) -> Result { let origin = origin.into(); - log::trace!( + tracing::trace!( target: "xcm::origin_conversion", - "SiblingParachainAsNative origin: {:?}, kind: {:?}", - origin, kind, + ?origin, ?kind, + "SiblingParachainAsNative", ); match (kind, origin.unpack()) { (OriginKind::Native, (1, [Junction::Parachain(id)])) => @@ -171,7 +171,7 @@ impl, RuntimeOrigin> ConvertOrigin Result { let origin = origin.into(); - log::trace!(target: "xcm::origin_conversion", "RelayChainAsNative origin: {:?}, kind: {:?}", origin, kind); + tracing::trace!(target: "xcm::origin_conversion", ?origin, ?kind, "RelayChainAsNative"); if kind == OriginKind::Native && origin.contains_parents_only(1) { Ok(RelayOrigin::get()) } else { @@ -191,10 +191,10 @@ where kind: OriginKind, ) -> Result { let origin = origin.into(); - log::trace!( + tracing::trace!( target: "xcm::origin_conversion", - "SignedAccountId32AsNative origin: {:?}, kind: {:?}", - origin, kind, + ?origin, ?kind, + "SignedAccountId32AsNative", ); match (kind, origin.unpack()) { (OriginKind::Native, (0, [Junction::AccountId32 { id, network }])) @@ -218,10 +218,10 @@ where kind: OriginKind, ) -> Result { let origin = origin.into(); - log::trace!( + tracing::trace!( target: "xcm::origin_conversion", - "SignedAccountKey20AsNative origin: {:?}, kind: {:?}", - origin, kind, + ?origin, ?kind, + "SignedAccountKey20AsNative", ); match (kind, origin.unpack()) { (OriginKind::Native, (0, [Junction::AccountKey20 { key, network }])) diff --git a/polkadot/xcm/xcm-builder/src/process_xcm_message.rs b/polkadot/xcm/xcm-builder/src/process_xcm_message.rs index 67c05c116e9d..ff8655a25fd0 100644 --- a/polkadot/xcm/xcm-builder/src/process_xcm_message.rs +++ b/polkadot/xcm/xcm-builder/src/process_xcm_message.rs @@ -48,15 +48,16 @@ impl< id: &mut XcmHash, ) -> Result { let versioned_message = VersionedXcm::::decode(&mut &message[..]).map_err(|e| { - log::trace!( + tracing::trace!( target: LOG_TARGET, - "`VersionedXcm` failed to decode: {e:?}", + ?e, + "`VersionedXcm` failed to decode", ); ProcessMessageError::Corrupt })?; let message = Xcm::::try_from(versioned_message).map_err(|_| { - log::trace!( + tracing::trace!( target: LOG_TARGET, "Failed to convert `VersionedXcm` into `xcm::prelude::Xcm`!", ); @@ -64,7 +65,7 @@ impl< ProcessMessageError::Unsupported })?; let pre = XcmExecutor::prepare(message).map_err(|_| { - log::trace!( + tracing::trace!( target: LOG_TARGET, "Failed to prepare message.", ); @@ -74,7 +75,7 @@ impl< // The worst-case weight: let required = pre.weight_of(); if !meter.can_consume(required) { - log::trace!( + tracing::trace!( target: LOG_TARGET, "Xcm required {required} more than remaining {}", meter.remaining(), @@ -86,14 +87,14 @@ impl< let (consumed, result) = match XcmExecutor::execute(origin.into(), pre, id, Weight::zero()) { Outcome::Complete { used } => { - log::trace!( + tracing::trace!( target: LOG_TARGET, "XCM message execution complete, used weight: {used}", ); (used, Ok(true)) }, Outcome::Incomplete { used, error } => { - log::trace!( + tracing::trace!( target: LOG_TARGET, "XCM message execution incomplete, used weight: {used}, error: {error:?}", ); @@ -101,7 +102,7 @@ impl< }, // In the error-case we assume the worst case and consume all possible weight. Outcome::Error { error } => { - log::trace!( + tracing::trace!( target: LOG_TARGET, "XCM message execution error: {error:?}", ); diff --git a/polkadot/xcm/xcm-builder/src/routing.rs b/polkadot/xcm/xcm-builder/src/routing.rs index 5b0d0a5f9835..3452fbd64386 100644 --- a/polkadot/xcm/xcm-builder/src/routing.rs +++ b/polkadot/xcm/xcm-builder/src/routing.rs @@ -109,8 +109,10 @@ impl SendXcm for WithTopicSource SendXcm for EnsureDecodableXcm { if let Some(msg) = message { let versioned_xcm = VersionedXcm::<()>::from(msg.clone()); if versioned_xcm.validate_xcm_nesting().is_err() { - log::error!( + tracing::error!( target: "xcm::validate_xcm_nesting", - "EnsureDecodableXcm validate_xcm_nesting error for \nversioned_xcm: {versioned_xcm:?}\nbased on xcm: {msg:?}" + ?versioned_xcm, + ?msg, + "EnsureDecodableXcm `validate_xcm_nesting` failed" ); return Err(SendError::Transport("EnsureDecodableXcm validate_xcm_nesting error")) } diff --git a/polkadot/xcm/xcm-builder/src/weight.rs b/polkadot/xcm/xcm-builder/src/weight.rs index 6521121f2c94..205678b459fb 100644 --- a/polkadot/xcm/xcm-builder/src/weight.rs +++ b/polkadot/xcm/xcm-builder/src/weight.rs @@ -39,7 +39,7 @@ impl, C: Decode + GetDispatchInfo, M: Get> WeightBounds for FixedWeightBounds { fn weight(message: &mut Xcm) -> Result { - log::trace!(target: "xcm::weight", "FixedWeightBounds message: {:?}", message); + tracing::trace!(target: "xcm::weight", ?message, "FixedWeightBounds"); let mut instructions_left = M::get(); Self::weight_with_limit(message, &mut instructions_left) } @@ -82,7 +82,7 @@ where Instruction: xcm::latest::GetWeight, { fn weight(message: &mut Xcm) -> Result { - log::trace!(target: "xcm::weight", "WeightInfoBounds message: {:?}", message); + tracing::trace!(target: "xcm::weight", ?message, "WeightInfoBounds"); let mut instructions_left = M::get(); Self::weight_with_limit(message, &mut instructions_left) } @@ -154,10 +154,10 @@ impl, R: TakeRevenue> WeightTrader for FixedRateOf payment: AssetsInHolding, context: &XcmContext, ) -> Result { - log::trace!( + tracing::trace!( target: "xcm::weight", - "FixedRateOfFungible::buy_weight weight: {:?}, payment: {:?}, context: {:?}", - weight, payment, context, + ?weight, ?payment, ?context, + "FixedRateOfFungible::buy_weight", ); let (id, units_per_second, units_per_mb) = T::get(); let amount = (units_per_second * (weight.ref_time() as u128) / @@ -166,15 +166,17 @@ impl, R: TakeRevenue> WeightTrader for FixedRateOf if amount == 0 { return Ok(payment) } - let unused = - payment.checked_sub((id, amount).into()).map_err(|_| XcmError::TooExpensive)?; + let unused = payment.checked_sub((id, amount).into()).map_err(|error| { + tracing::error!(target: "xcm::weight", ?error, "Failed to substract from payment"); + XcmError::TooExpensive + })?; self.0 = self.0.saturating_add(weight); self.1 = self.1.saturating_add(amount); Ok(unused) } fn refund_weight(&mut self, weight: Weight, context: &XcmContext) -> Option { - log::trace!(target: "xcm::weight", "FixedRateOfFungible::refund_weight weight: {:?}, context: {:?}", weight, context); + tracing::trace!(target: "xcm::weight", ?weight, ?context, "FixedRateOfFungible::refund_weight"); let (id, units_per_second, units_per_mb) = T::get(); let weight = weight.min(self.0); let amount = (units_per_second * (weight.ref_time() as u128) / @@ -229,24 +231,30 @@ impl< payment: AssetsInHolding, context: &XcmContext, ) -> Result { - log::trace!(target: "xcm::weight", "UsingComponents::buy_weight weight: {:?}, payment: {:?}, context: {:?}", weight, payment, context); + tracing::trace!(target: "xcm::weight", ?weight, ?payment, ?context, "UsingComponents::buy_weight"); let amount = WeightToFee::weight_to_fee(&weight); - let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?; + let u128_amount: u128 = amount.try_into().map_err(|_| { + tracing::error!(target: "xcm::weight", "Amount could not be converted"); + XcmError::Overflow + })?; let required = Asset { id: AssetId(AssetIdValue::get()), fun: Fungible(u128_amount) }; - let unused = payment.checked_sub(required).map_err(|_| XcmError::TooExpensive)?; + let unused = payment.checked_sub(required).map_err(|error| { + tracing::error!(target: "xcm::weight", ?error, "Failed to substract from payment"); + XcmError::TooExpensive + })?; self.0 = self.0.saturating_add(weight); self.1 = self.1.saturating_add(amount); Ok(unused) } fn refund_weight(&mut self, weight: Weight, context: &XcmContext) -> Option { - log::trace!(target: "xcm::weight", "UsingComponents::refund_weight weight: {:?}, context: {:?}, available weight: {:?}, available amount: {:?}", weight, context, self.0, self.1); + tracing::trace!(target: "xcm::weight", ?weight, ?context, available_weight = ?self.0, available_amount = ?self.1, "UsingComponents::refund_weight"); let weight = weight.min(self.0); let amount = WeightToFee::weight_to_fee(&weight); self.0 -= weight; self.1 = self.1.saturating_sub(amount); let amount: u128 = amount.saturated_into(); - log::trace!(target: "xcm::weight", "UsingComponents::refund_weight amount to refund: {:?}", amount); + tracing::trace!(target: "xcm::weight", ?amount, "UsingComponents::refund_weight"); if amount > 0 { Some((AssetIdValue::get(), amount).into()) } else { diff --git a/prdoc/pr_7003.prdoc b/prdoc/pr_7003.prdoc new file mode 100644 index 000000000000..4c5ecf733b02 --- /dev/null +++ b/prdoc/pr_7003.prdoc @@ -0,0 +1,17 @@ +title: Added logging for xcm filters/helpers/matchers/types + +doc: + - audience: Runtime Dev + description: | + This PR adds error logs to assist in debugging xcm. + Specifically, for filters, helpers, matchers. + Additionally, it replaces the usages of `log` with `tracing`. + +crates: + - name: staging-xcm-builder + bump: minor + - name: assets-common + bump: minor + - name: bridge-hub-westend-runtime + bump: minor +