mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
Use DecodeLimit for decoding XCM messages (#605)
* Use DecodeLimit for decoding XCM messages * Use decode_all_with_depth_limit in appropriate places * Use decode_all while decoding byte vector * cargo fmt
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use codec::{Decode, DecodeLimit, Encode};
|
||||
use cumulus_primitives_core::{relay_chain::BlockNumber as RelayBlockNumber, DmpMessageHandler};
|
||||
use frame_support::{
|
||||
dispatch::Weight, traits::EnsureOrigin, weights::constants::WEIGHT_PER_MILLIS,
|
||||
@@ -30,7 +30,7 @@ pub use pallet::*;
|
||||
use scale_info::TypeInfo;
|
||||
use sp_runtime::RuntimeDebug;
|
||||
use sp_std::{convert::TryFrom, prelude::*};
|
||||
use xcm::{latest::prelude::*, VersionedXcm};
|
||||
use xcm::{latest::prelude::*, VersionedXcm, MAX_XCM_DECODE_DEPTH};
|
||||
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)]
|
||||
pub struct ConfigData {
|
||||
@@ -225,8 +225,11 @@ pub mod pallet {
|
||||
data: &[u8],
|
||||
) -> Result<Weight, (MessageId, Weight)> {
|
||||
let id = sp_io::hashing::blake2_256(&data[..]);
|
||||
let maybe_msg =
|
||||
VersionedXcm::<T::Call>::decode(&mut &data[..]).map(Xcm::<T::Call>::try_from);
|
||||
let maybe_msg = VersionedXcm::<T::Call>::decode_all_with_depth_limit(
|
||||
MAX_XCM_DECODE_DEPTH,
|
||||
&mut &data[..],
|
||||
)
|
||||
.map(Xcm::<T::Call>::try_from);
|
||||
match maybe_msg {
|
||||
Err(_) => {
|
||||
Self::deposit_event(Event::InvalidFormat(id));
|
||||
|
||||
Reference in New Issue
Block a user