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 61 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
7b32c89
migrate log to tracing
Dec 10, 2024
2101bc1
added logs
Dec 24, 2024
24dedbd
Merge remote-tracking branch 'origin/master' into ayevbeosa-more-xcm-…
Dec 26, 2024
96ca37c
added pr_doc
Dec 26, 2024
2caace3
remove duplicate keys
Dec 26, 2024
fb2c04f
remove duplicate keys
Dec 26, 2024
0af77c8
use correct crate name
Dec 26, 2024
a92b804
format files
Dec 26, 2024
adba1d0
fix format errors with taplo format
Dec 26, 2024
2914724
log error
Dec 26, 2024
1df6306
revert commit
Dec 26, 2024
c9b8ce2
remove unused variable
Dec 26, 2024
17197c3
replace tracing with log
Dec 26, 2024
bdbf488
add logs in `benchmarks.rs`
Dec 26, 2024
d5cb578
added logs
Dec 26, 2024
362cb49
fixes
Dec 27, 2024
06db1a8
update pr_7003.prdoc
Dec 27, 2024
c675df5
added logs
Dec 27, 2024
b4bf289
Update cumulus/parachains/runtimes/assets/common/src/fungible_convers…
ayevbeosa Dec 27, 2024
61c41ed
Update cumulus/parachains/runtimes/assets/common/src/benchmarks.rs
ayevbeosa Dec 27, 2024
74ba6cc
Update cumulus/parachains/runtimes/assets/common/src/benchmarks.rs
ayevbeosa Dec 27, 2024
5548e1e
Update cumulus/parachains/runtimes/assets/common/src/matching.rs
ayevbeosa Dec 27, 2024
e2cc86c
Merge branch 'master' into ayevbeosa-more-xcm-logs
ayevbeosa Dec 27, 2024
e9d8c5e
Merge branch 'ayevbeosa-more-xcm-logs' of https://github.com/ayevbeos…
Dec 27, 2024
d32edd7
changed tracing call pattern
Dec 28, 2024
fcdda09
Merge branch 'master' into ayevbeosa-more-xcm-logs
ayevbeosa Dec 30, 2024
39a1f2c
Update pr_7003.prdoc
ayevbeosa Jan 3, 2025
8f29ec2
Update pr_7003.prdoc
ayevbeosa Jan 3, 2025
edf9b91
Update polkadot/xcm/xcm-builder/src/barriers.rs
ayevbeosa Jan 3, 2025
94b04e9
Update polkadot/xcm/xcm-builder/src/barriers.rs
ayevbeosa Jan 3, 2025
25b7c25
Update polkadot/xcm/xcm-builder/src/barriers.rs
ayevbeosa Jan 3, 2025
b32a1cf
Update cumulus/parachains/runtimes/assets/common/src/matching.rs
ayevbeosa Jan 3, 2025
4e7ab54
Update cumulus/parachains/runtimes/assets/common/src/matching.rs
ayevbeosa Jan 3, 2025
6587bd4
Update polkadot/xcm/xcm-builder/src/barriers.rs
ayevbeosa Jan 3, 2025
93a1053
Update cumulus/parachains/runtimes/assets/common/src/matching.rs
ayevbeosa Jan 3, 2025
69a7d5d
Update cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src…
ayevbeosa Jan 3, 2025
0b77a97
Update cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src…
ayevbeosa Jan 3, 2025
be37eba
Update polkadot/xcm/xcm-builder/src/barriers.rs
ayevbeosa Jan 3, 2025
37510e1
Update polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapt…
ayevbeosa Jan 3, 2025
2cc0f36
Update polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapt…
ayevbeosa Jan 3, 2025
994421a
Update polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapt…
ayevbeosa Jan 3, 2025
86f3a73
Update polkadot/xcm/xcm-builder/src/barriers.rs
ayevbeosa Jan 3, 2025
85b3b30
Update polkadot/xcm/xcm-builder/src/currency_adapter.rs
ayevbeosa Jan 3, 2025
81b725b
Update polkadot/xcm/xcm-builder/src/fungible_adapter.rs
ayevbeosa Jan 3, 2025
664a361
Update polkadot/xcm/xcm-builder/src/fungibles_adapter.rs
ayevbeosa Jan 3, 2025
9625dab
Update polkadot/xcm/xcm-builder/src/nonfungible_adapter.rs
ayevbeosa Jan 3, 2025
d6e9bb6
Update polkadot/xcm/xcm-builder/src/nonfungibles_adapter.rs
ayevbeosa Jan 3, 2025
24106b3
Update polkadot/xcm/xcm-builder/src/routing.rs
ayevbeosa Jan 3, 2025
3c05171
Update polkadot/xcm/xcm-builder/src/weight.rs
ayevbeosa Jan 3, 2025
34aca75
Merge branch 'master' into ayevbeosa-more-xcm-logs
ayevbeosa Jan 3, 2025
b1ff882
Apply suggestions from code review
ayevbeosa Jan 14, 2025
52a4281
rename variables
Jan 15, 2025
d8306b1
use debug instead
Jan 15, 2025
3556e75
Update polkadot/xcm/xcm-builder/src/fungibles_adapter.rs
ayevbeosa Jan 15, 2025
8ab4bbf
Merge branch 'master' into ayevbeosa-more-xcm-logs
ayevbeosa Jan 15, 2025
97b7581
replace log with tracing
Jan 15, 2025
36f334d
Apply suggestions from code review
ayevbeosa Jan 15, 2025
017d4a1
add more tracing and debugging logs
Jan 15, 2025
e1aded8
Apply suggestions from code review
ayevbeosa Jan 22, 2025
cadfbcd
Update polkadot/xcm/xcm-builder/src/weight.rs
ayevbeosa Jan 22, 2025
cf93848
Update polkadot/xcm/xcm-builder/src/weight.rs
ayevbeosa Jan 22, 2025
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
26 changes: 24 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,31 @@ 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!(
target: "xcm",
?error,
"Failed to create asset pairs when seed1 is even",
);
"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!(target: "xcm", ?error, "Failed to create asset pairs");
"Something went wrong"
})
.unwrap(),
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ where
origin: RuntimeOrigin,
asset_location: &L,
) -> core::result::Result<Self::Success, RuntimeOrigin> {
tracing::trace!(target: "xcm::try_origin", ?origin, ?asset_location, "ForeignCreators");
let origin_location = EnsureXcm::<Everything, L>::try_origin(origin.clone())?;
if !IsForeign::contains(asset_location, &origin_location) {
tracing::trace!(target: "xcm::try_origin", ?asset_location, ?origin_location, "ForeignCreators: no match");
return Err(origin)
}
let latest_location: Location =
Expand Down
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", ?location, "MatchesLocation: no match");
false
}
}
Expand Down
27 changes: 16 additions & 11 deletions cumulus/parachains/runtimes/assets/common/src/matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ 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);
matches!(asset.id, AssetId(ref id) if IsForeign::contains(id, origin))
let result = matches!(asset.id, AssetId(ref id) if IsForeign::contains(id, origin));
tracing::trace!(target: "xcm::contains", ?asset, ?origin, ?result, "IsForeignConcreteAsset");
result
}
}

Expand All @@ -47,6 +48,7 @@ impl<SelfParaId: Get<ParaId>, L: TryFrom<Location> + TryInto<Location> + Clone>
for FromSiblingParachain<SelfParaId, L>
{
fn contains(a: &L, b: &L) -> bool {
tracing::trace!(target: "xcm:contains", ?a, ?b, "FromSiblingParachain");
// We convert locations to latest
let a = match ((*a).clone().try_into(), (*b).clone().try_into()) {
(Ok(a), Ok(b)) if a.starts_with(&b) => a, // `a` needs to be from `b` at least
Expand Down Expand Up @@ -74,6 +76,7 @@ impl<
> ContainsPair<L, L> for FromNetwork<UniversalLocation, ExpectedNetworkId, L>
{
fn contains(a: &L, b: &L) -> bool {
tracing::trace!(target: "xcm:contains", ?a, ?b, "FromNetwork");
// We convert locations to latest
let a = match ((*a).clone().try_into(), (*b).clone().try_into()) {
(Ok(a), Ok(b)) if a.starts_with(&b) => a, // `a` needs to be from `b` at least
Expand All @@ -86,11 +89,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::debug!(target: "xcm::contains", origin = ?a, ?universal_source, error = ?e, "FromNetwork origin is not remote to the universal_source");
false
},
}
Expand Down Expand Up @@ -118,15 +117,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",
);
}

Expand All @@ -138,6 +142,7 @@ impl<AssetsAllowedNetworks: Contains<Location>, OriginLocation: Get<Location>>
ContainsPair<Asset, Location> for RemoteAssetFromLocation<AssetsAllowedNetworks, OriginLocation>
{
fn contains(asset: &Asset, origin: &Location) -> bool {
tracing::trace!(target: "xcm:contains", ?asset, ?origin, "RemoteAssetFromLocation");
<Self as ContainsPair<Location, Location>>::contains(&asset.id.0, origin)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ substrate-wasm-builder = { optional = true, workspace = true, default-features =
[dependencies]
codec = { features = ["derive"], workspace = true }
hex-literal = { workspace = true, default-features = true }
log = { workspace = true }
scale-info = { features = ["derive"], workspace = true }
serde = { optional = true, features = ["derive"], workspace = true, default-features = true }
serde_json = { features = ["alloc"], workspace = true }
tracing = { workspace = true }

# Substrate
frame-benchmarking = { optional = true, workspace = true }
Expand Down Expand Up @@ -162,7 +162,6 @@ std = [
"frame-system-rpc-runtime-api/std",
"frame-system/std",
"frame-try-runtime?/std",
"log/std",
"pallet-aura/std",
"pallet-authorship/std",
"pallet-balances/std",
Expand Down Expand Up @@ -215,6 +214,7 @@ std = [
"sp-version/std",
"substrate-wasm-builder",
"testnet-parachains-constants/std",
"tracing/std",
"westend-runtime-constants/std",
"xcm-builder/std",
"xcm-executor/std",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,11 +795,11 @@ impl_runtime_apis! {
Ok(WeightToFee::weight_to_fee(&weight))
},
Ok(asset_id) => {
log::trace!(target: "xcm::xcm_runtime_apis", "query_weight_to_asset_fee - unhandled asset_id: {asset_id:?}!");
tracing::trace!(target: "xcm::xcm_runtime_apis", ?asset_id, "query_weight_to_asset_fee - unhandled asset_id!");
Err(XcmPaymentApiError::AssetNotFound)
},
Err(_) => {
log::trace!(target: "xcm::xcm_runtime_apis", "query_weight_to_asset_fee - failed to convert asset: {asset:?}!");
tracing::trace!(target: "xcm::xcm_runtime_apis", ?asset, "query_weight_to_asset_fee - failed to convert asset!");
Err(XcmPaymentApiError::VersionedConversionFailed)
}
}
Expand Down Expand Up @@ -1144,12 +1144,15 @@ impl_runtime_apis! {
alloc::boxed::Box::new(bridge_to_rococo_config::BridgeHubRococoLocation::get()),
XCM_VERSION,
).map_err(|e| {
log::error!(
"Failed to dispatch `force_xcm_version({:?}, {:?}, {:?})`, error: {:?}",
RuntimeOrigin::root(),
bridge_to_rococo_config::BridgeHubRococoLocation::get(),
XCM_VERSION,
e
let origin = RuntimeOrigin::root();
let bridge = bridge_to_rococo_config::BridgeHubRococoLocation::get();
tracing::error!(
target: "xcm::export_message_origin_and_destination",
?origin,
?bridge,
?XCM_VERSION,
?e
"Failed to dispatch `force_xcm_version`",
);
BenchmarkError::Stop("XcmVersion was not stored!")
})?;
Expand Down Expand Up @@ -1179,11 +1182,12 @@ impl_runtime_apis! {
bp_messages::LegacyLaneId([1, 2, 3, 4]),
true,
).map_err(|e| {
log::error!(
"Failed to `XcmOverBridgeHubRococo::open_bridge`({:?}, {:?})`, error: {:?}",
sibling_parachain_location,
bridge_destination_universal_location,
e
tracing::error!(
target: "xcm::export_message_origin_and_destination",
?sibling_parachain_location,
?bridge_destination_universal_location,
?e
"Failed to `XcmOverBridgeHubRococo::open_bridge`",
);
BenchmarkError::Stop("Bridge was not opened!")
})?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ pub type XcmOriginToTransactDispatchOrigin = (
pub struct ParentOrParentsPlurality;
impl Contains<Location> for ParentOrParentsPlurality {
fn contains(location: &Location) -> bool {
matches!(location.unpack(), (1, []) | (1, [Plurality { .. }]))
let result = matches!(location.unpack(), (1, []) | (1, [Plurality { .. }]));
tracing::trace!(target: "xcm::contains", ?location, ?result, "ParentOrParentsPlurality matches");
result
}
}

Expand Down Expand Up @@ -300,6 +302,7 @@ impl<WaivedLocations: Contains<Location>, FeeHandler: HandleFee> FeeManager
}

fn handle_fee(fee: Assets, context: Option<&XcmContext>, reason: FeeReason) {
tracing::trace!(target: "xcm::handle_fee", ?fee, ?context, ?reason, "FeeManager handle_fee");
FeeHandler::handle_fee(fee, context, reason);
}
}
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",
]
Loading
Loading