mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 00:31:07 +00:00
Add validate_xcm_nesting to the ParentAsUmp and ChildParachainRouter (#4236)
This PR: - moves `validate_xcm_nesting` from `XcmpQueue` into the `VersionedXcm` - adds `validate_xcm_nesting` to the `ParentAsUmp` - adds `validate_xcm_nesting` to the `ChildParachainRouter` Based on discussion [here](https://github.com/paritytech/polkadot-sdk/pull/4186#discussion_r1571344270) and/or [here](https://github.com/paritytech/polkadot-sdk/pull/4186#discussion_r1572076666) and/or [here]() ## Question/TODO - [x] To the [comment](https://github.com/paritytech/polkadot-sdk/pull/4186#discussion_r1572072295) - Why was `validate_xcm_nesting` added just to the `XcmpQueue` router and nowhere else? What kind of problem `MAX_XCM_DECODE_DEPTH` is solving? (see [comment](https://github.com/paritytech/polkadot-sdk/pull/4236#discussion_r1574605191))
This commit is contained in:
@@ -916,7 +916,8 @@ impl<T: Config> SendXcm for Pallet<T> {
|
||||
let price = T::PriceForSiblingDelivery::price_for_delivery(id, &xcm);
|
||||
let versioned_xcm = T::VersionWrapper::wrap_version(&d, xcm)
|
||||
.map_err(|()| SendError::DestinationUnsupported)?;
|
||||
validate_xcm_nesting(&versioned_xcm)
|
||||
versioned_xcm
|
||||
.validate_xcm_nesting()
|
||||
.map_err(|()| SendError::ExceedsMaxMessageSize)?;
|
||||
|
||||
Ok(((id, versioned_xcm), price))
|
||||
@@ -932,10 +933,6 @@ impl<T: Config> SendXcm for Pallet<T> {
|
||||
|
||||
fn deliver((id, xcm): (ParaId, VersionedXcm<()>)) -> Result<XcmHash, SendError> {
|
||||
let hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
||||
defensive_assert!(
|
||||
validate_xcm_nesting(&xcm).is_ok(),
|
||||
"Tickets are valid prior to delivery by trait XCM; qed"
|
||||
);
|
||||
|
||||
match Self::send_fragment(id, XcmpMessageFormat::ConcatenatedVersionedXcm, xcm) {
|
||||
Ok(_) => {
|
||||
@@ -950,16 +947,6 @@ impl<T: Config> SendXcm for Pallet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks that the XCM is decodable with `MAX_XCM_DECODE_DEPTH`.
|
||||
///
|
||||
/// Note that this uses the limit of the sender - not the receiver. It it best effort.
|
||||
pub(crate) fn validate_xcm_nesting(xcm: &VersionedXcm<()>) -> Result<(), ()> {
|
||||
xcm.using_encoded(|mut enc| {
|
||||
VersionedXcm::<()>::decode_all_with_depth_limit(MAX_XCM_DECODE_DEPTH, &mut enc).map(|_| ())
|
||||
})
|
||||
.map_err(|_| ())
|
||||
}
|
||||
|
||||
impl<T: Config> FeeTracker for Pallet<T> {
|
||||
type Id = ParaId;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user