Skip to content
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

xcm-builder: added logging for xcm filters/helpers/matchers/types (#2408) #7003

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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 Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cumulus/parachains/runtimes/assets/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -43,14 +43,14 @@ std = [
"codec/std",
"cumulus-primitives-core/std",
"frame-support/std",
"log/std",
"pallet-asset-conversion/std",
"pallet-assets/std",
"pallet-xcm/std",
"parachains-common/std",
"scale-info/std",
"sp-api/std",
"sp-runtime/std",
"tracing/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
Expand Down
25 changes: 23 additions & 2 deletions cumulus/parachains/runtimes/assets/common/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,30 @@ impl<Target: Get<L>, SelfParaId: Get<ParaId>, PalletId: Get<u32>, L: TryFrom<Loc
],
);
if seed1 % 2 == 0 {
(with_id.try_into().map_err(|_| "Something went wrong").unwrap(), Target::get())
(
with_id
.try_into()
.map_err(|error| {
tracing::error!(
"Failed to create asset pairs when seed1 is even, error {:?}",
error
ayevbeosa marked this conversation as resolved.
Show resolved Hide resolved
);
"Something went wrong"
})
.unwrap(),
Target::get(),
)
} else {
(Target::get(), with_id.try_into().map_err(|_| "Something went wrong").unwrap())
(
Target::get(),
with_id
.try_into()
.map_err(|error| {
tracing::error!("Failed to create asset pairs, error {:?}", error);
ayevbeosa marked this conversation as resolved.
Show resolved Hide resolved
"Something went wrong"
})
.unwrap(),
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl<
for_tuples!( #(
match Tuple::contains(location) { o @ true => return o, _ => () }
)* );
log::trace!(target: "xcm::contains", "did not match location: {:?}", &location);
tracing::trace!(target: "xcm::contains", "did not match location: {:?}", &location);
ayevbeosa marked this conversation as resolved.
Show resolved Hide resolved
false
}
}
Expand All @@ -142,7 +142,10 @@ pub fn convert_balance<T: frame_support::pallet_prelude::Get<Location>, Balance:
) -> Result<Asset, FungiblesAccessError> {
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)
},
}
}

Expand Down
8 changes: 4 additions & 4 deletions cumulus/parachains/runtimes/assets/common/src/matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl<IsForeign: ContainsPair<Location, Location>> ContainsPair<Asset, Location>
for IsForeignConcreteAsset<IsForeign>
{
fn contains(asset: &Asset, origin: &Location) -> bool {
log::trace!(target: "xcm::contains", "IsForeignConcreteAsset asset: {:?}, origin: {:?}", asset, origin);
tracing::trace!(target: "xcm::contains", "IsForeignConcreteAsset asset: {:?}, origin: {:?}", asset, origin);
ayevbeosa marked this conversation as resolved.
Show resolved Hide resolved
matches!(asset.id, AssetId(ref id) if IsForeign::contains(id, origin))
}
}
Expand Down Expand Up @@ -86,7 +86,7 @@ impl<
match ensure_is_remote(universal_source.clone(), a.clone()) {
Ok((network_id, _)) => network_id == ExpectedNetworkId::get(),
Err(e) => {
log::trace!(
tracing::trace!(
target: "xcm::contains",
"FromNetwork origin: {:?} is not remote to the universal_source: {:?} {:?}",
a, universal_source, e
Expand Down Expand Up @@ -118,13 +118,13 @@ 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:?}"
);
return false;
} else {
log::trace!(
tracing::trace!(
target: "xcm::contains",
"RemoteAssetFromLocation asset: {asset:?}, origin: {origin:?}",
);
Expand Down
4 changes: 2 additions & 2 deletions polkadot/xcm/xcm-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ 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 }
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 }

Expand Down Expand Up @@ -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",
Expand All @@ -75,6 +74,7 @@ std = [
"sp-io/std",
"sp-runtime/std",
"sp-weights/std",
"tracing/std",
"xcm-executor/std",
"xcm/std",
]
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ where
) -> Result<AssetsInHolding, AssetsInHolding> {
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`.",
);
Expand All @@ -73,7 +73,7 @@ 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,
Expand All @@ -83,7 +83,7 @@ where
})?;
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,
Expand All @@ -106,7 +106,7 @@ 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
Expand All @@ -127,7 +127,7 @@ where
want_amount,
)
.map_err(|(credit_in, error)| {
log::error!(
tracing::error!(
target: "xcm::SingleAssetExchangeAdapter::exchange_asset",
"Could not perform the swap, error: {:?}.",
error
Expand Down Expand Up @@ -162,7 +162,7 @@ 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,
Expand All @@ -173,7 +173,7 @@ where
.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,
Expand Down
20 changes: 10 additions & 10 deletions polkadot/xcm/xcm-builder/src/barriers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ 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,
Expand Down Expand Up @@ -68,7 +68,7 @@ impl<T: Contains<Location>> ShouldExecute for AllowTopLevelPaidExecutionFrom<T>
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,
Expand Down Expand Up @@ -173,7 +173,7 @@ impl<InnerBarrier: ShouldExecute, LocalUniversal: Get<InteriorLocation>, 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,
Expand Down Expand Up @@ -230,7 +230,7 @@ impl<InnerBarrier: ShouldExecute> ShouldExecute for TrailingSetTopicAsId<InnerBa
max_weight: Weight,
properties: &mut Properties,
) -> Result<(), ProcessMessageError> {
log::trace!(
tracing::trace!(
target: "xcm::barriers",
"TrailingSetTopicAsId origin: {:?}, instructions: {:?}, max_weight: {:?}, properties: {:?}",
origin, instructions, max_weight, properties,
Expand Down Expand Up @@ -279,7 +279,7 @@ impl<T: Contains<Location>> ShouldExecute for AllowUnpaidExecutionFrom<T> {
_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,
Expand All @@ -301,7 +301,7 @@ impl<T: Contains<Location>> ShouldExecute for AllowExplicitUnpaidExecutionFrom<T
max_weight: Weight,
_properties: &mut Properties,
) -> Result<(), ProcessMessageError> {
log::trace!(
tracing::trace!(
target: "xcm::barriers",
"AllowExplicitUnpaidExecutionFrom origin: {:?}, instructions: {:?}, max_weight: {:?}, properties: {:?}",
origin, instructions, max_weight, _properties,
Expand Down Expand Up @@ -360,7 +360,7 @@ impl<ResponseHandler: OnResponse> ShouldExecute for AllowKnownQueryResponses<Res
_max_weight: Weight,
_properties: &mut Properties,
) -> Result<(), ProcessMessageError> {
log::trace!(
tracing::trace!(
target: "xcm::barriers",
"AllowKnownQueryResponses origin: {:?}, instructions: {:?}, max_weight: {:?}, properties: {:?}",
origin, instructions, _max_weight, _properties,
Expand Down Expand Up @@ -388,7 +388,7 @@ impl<T: Contains<Location>> ShouldExecute for AllowSubscriptionsFrom<T> {
_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,
Expand Down Expand Up @@ -419,7 +419,7 @@ 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,
Expand Down Expand Up @@ -489,7 +489,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",
);
Expand Down
14 changes: 7 additions & 7 deletions polkadot/xcm/xcm-builder/src/currency_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl<
for CurrencyAdapter<Currency, Matcher, AccountIdConverter, AccountId, CheckedAccount>
{
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", "can_check_in origin: {:?}, what: {:?}", _origin, what);
// Check we handle this asset.
let amount: Currency::Balance =
Matcher::matches_fungible(what).ok_or(Error::AssetNotHandled)?;
Expand All @@ -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", "check_in origin: {:?}, what: {:?}", _origin, what);
if let Some(amount) = Matcher::matches_fungible(what) {
match CheckedAccount::get() {
Some((checked_account, MintLocation::Local)) =>
Expand All @@ -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", "can_check_out dest: {:?}, what: {:?}", _dest, what);
let amount = Matcher::matches_fungible(what).ok_or(Error::AssetNotHandled)?;
match CheckedAccount::get() {
Some((checked_account, MintLocation::Local)) =>
Expand All @@ -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", "check_out dest: {:?}, what: {:?}", _dest, what);
if let Some(amount) = Matcher::matches_fungible(what) {
match CheckedAccount::get() {
Some((checked_account, MintLocation::Local)) =>
Expand All @@ -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", "deposit_asset what: {:?}, who: {:?}", what, who);
// Check we handle this asset.
let amount = Matcher::matches_fungible(&what).ok_or(Error::AssetNotHandled)?;
let who =
Expand All @@ -209,7 +209,7 @@ impl<
who: &Location,
_maybe_context: Option<&XcmContext>,
) -> result::Result<AssetsInHolding, XcmError> {
log::trace!(target: "xcm::currency_adapter", "withdraw_asset what: {:?}, who: {:?}", what, who);
tracing::trace!(target: "xcm::currency_adapter", "withdraw_asset what: {:?}, who: {:?}", what, who);
// Check we handle this asset.
let amount = Matcher::matches_fungible(what).ok_or(Error::AssetNotHandled)?;
let who =
Expand All @@ -225,7 +225,7 @@ impl<
to: &Location,
_context: &XcmContext,
) -> result::Result<AssetsInHolding, XcmError> {
log::trace!(target: "xcm::currency_adapter", "internal_transfer_asset asset: {:?}, from: {:?}, to: {:?}", asset, from, to);
tracing::trace!(target: "xcm::currency_adapter", "internal_transfer_asset asset: {:?}, from: {:?}, to: {:?}", asset, from, to);
let amount = Matcher::matches_fungible(asset).ok_or(Error::AssetNotHandled)?;
let from =
AccountIdConverter::convert_location(from).ok_or(Error::AccountIdConversionFailed)?;
Expand Down
Loading
Loading