Skip to content

Commit

Permalink
Merge branch 'ayevbeosa-more-xcm-logs' of https://github.com/ayevbeos…
Browse files Browse the repository at this point in the history
…a/polkadot-sdk into ayevbeosa-more-xcm-logs
  • Loading branch information
Ayevbeosa Iyamu committed Dec 27, 2024
2 parents c675df5 + e2cc86c commit e9d8c5e
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 21 deletions.
7 changes: 4 additions & 3 deletions cumulus/parachains/runtimes/assets/common/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ impl<Target: Get<L>, SelfParaId: Get<ParaId>, PalletId: Get<u32>, L: TryFrom<Loc
.try_into()
.map_err(|error| {
tracing::error!(
"Failed to create asset pairs when seed1 is even, error {:?}",
error
target: "xcm",
?error,
"Failed to create asset pairs when seed1 is even",
);
"Something went wrong"
})
Expand All @@ -54,7 +55,7 @@ impl<Target: Get<L>, SelfParaId: Get<ParaId>, PalletId: Get<u32>, L: TryFrom<Loc
with_id
.try_into()
.map_err(|error| {
tracing::error!("Failed to create asset pairs, error {:?}", error);
tracing::error!(target: "xcm", ?error, "Failed to create asset pairs");
"Something went wrong"
})
.unwrap(),
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, _ => () }
)* );
tracing::trace!(target: "xcm::contains", "did not match location: {:?}", &location);
tracing::trace!(target: "xcm::contains", ?location, "did not match location");
false
}
}
Expand Down
2 changes: 1 addition & 1 deletion 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 {
tracing::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))
}
}
Expand Down
31 changes: 16 additions & 15 deletions polkadot/runtime/common/src/paras_registrar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,30 +561,31 @@ impl<T: Config> Pallet<T> {
origin: <T as frame_system::Config>::RuntimeOrigin,
id: ParaId,
) -> DispatchResult {
ensure_signed(origin.clone())
.map_err(|e| e.into())
.and_then(|who| -> DispatchResult {
let para_info = Paras::<T>::get(id).ok_or(Error::<T>::NotRegistered)?;
if let Ok(who) = ensure_signed(origin.clone()) {
let para_info = Paras::<T>::get(id).ok_or(Error::<T>::NotRegistered)?;

if para_info.manager == who {
ensure!(!para_info.is_locked(), Error::<T>::ParaLocked);
ensure!(para_info.manager == who, Error::<T>::NotOwner);
Ok(())
})
.or_else(|_| -> DispatchResult { Self::ensure_root_or_para(origin, id) })
return Ok(())
}
}

Self::ensure_root_or_para(origin, id)
}

/// Ensure the origin is one of Root or the `para` itself.
fn ensure_root_or_para(
origin: <T as frame_system::Config>::RuntimeOrigin,
id: ParaId,
) -> DispatchResult {
if let Ok(caller_id) = ensure_parachain(<T as Config>::RuntimeOrigin::from(origin.clone()))
{
// Check if matching para id...
ensure!(caller_id == id, Error::<T>::NotOwner);
} else {
// Check if root...
ensure_root(origin.clone())?;
if ensure_root(origin.clone()).is_ok() {
return Ok(())
}

let caller_id = ensure_parachain(<T as Config>::RuntimeOrigin::from(origin))?;
// Check if matching para id...
ensure!(caller_id == id, Error::<T>::NotOwner);

Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion polkadot/runtime/common/src/paras_registrar/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ fn para_lock_works() {
// Owner cannot pass origin check when checking lock
assert_noop!(
mock::Registrar::ensure_root_para_or_owner(RuntimeOrigin::signed(1), para_id),
BadOrigin
Error::<Test>::ParaLocked,
);
// Owner cannot remove lock.
assert_noop!(mock::Registrar::remove_lock(RuntimeOrigin::signed(1), para_id), BadOrigin);
Expand Down
10 changes: 10 additions & 0 deletions prdoc/pr_6989.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: 'paras-registrar: Improve error reporting'
doc:
- audience: Runtime User
description: |-
This pr improves the error reporting by paras registrar when an owner wants to access a locked parachain.

Closes: https://github.com/paritytech/polkadot-sdk/issues/6745
crates:
- name: polkadot-runtime-common
bump: patch

0 comments on commit e9d8c5e

Please sign in to comment.