mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 17:41:08 +00:00
Merge branch 'master' into gav-xcm-v3
This commit is contained in:
@@ -22,7 +22,7 @@ use frame_system::RawOrigin;
|
||||
|
||||
benchmarks! {
|
||||
set_config_with_u32 {}: update_resume_threshold(RawOrigin::Root, 100)
|
||||
set_config_with_weight {}: update_weight_restrict_decay(RawOrigin::Root, 3_000_000 as Weight)
|
||||
set_config_with_weight {}: update_weight_restrict_decay(RawOrigin::Root, Weight::from_ref_time(3_000_000))
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test);
|
||||
|
||||
@@ -79,10 +79,10 @@ pub mod pallet {
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config {
|
||||
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
|
||||
|
||||
/// Something to execute an XCM message. We need this to service the XCMoXCMP queue.
|
||||
type XcmExecutor: ExecuteXcm<Self::Call>;
|
||||
type XcmExecutor: ExecuteXcm<Self::RuntimeCall>;
|
||||
|
||||
/// Information on the avaialble XCMP channels.
|
||||
type ChannelInfo: GetChannelInfo;
|
||||
@@ -91,14 +91,14 @@ pub mod pallet {
|
||||
type VersionWrapper: WrapVersion;
|
||||
|
||||
/// The origin that is allowed to execute overweight messages.
|
||||
type ExecuteOverweightOrigin: EnsureOrigin<Self::Origin>;
|
||||
type ExecuteOverweightOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
|
||||
/// The origin that is allowed to resume or suspend the XCMP queue.
|
||||
type ControllerOrigin: EnsureOrigin<Self::Origin>;
|
||||
type ControllerOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
|
||||
/// The conversion function used to attempt to convert an XCM `MultiLocation` origin to a
|
||||
/// superuser origin.
|
||||
type ControllerOriginConverter: ConvertOrigin<Self::Origin>;
|
||||
type ControllerOriginConverter: ConvertOrigin<Self::RuntimeOrigin>;
|
||||
|
||||
/// The price for delivering an XCM to a sibling parachain destination.
|
||||
type PriceForSiblingDelivery: PriceForSiblingDelivery;
|
||||
@@ -134,7 +134,7 @@ pub mod pallet {
|
||||
///
|
||||
/// Events:
|
||||
/// - `OverweightServiced`: On success.
|
||||
#[pallet::weight((weight_limit.saturating_add(1_000_000), DispatchClass::Operational,))]
|
||||
#[pallet::weight((weight_limit.saturating_add(Weight::from_ref_time(1_000_000)), DispatchClass::Operational,))]
|
||||
pub fn service_overweight(
|
||||
origin: OriginFor<T>,
|
||||
index: OverweightIndex,
|
||||
@@ -144,7 +144,7 @@ pub mod pallet {
|
||||
|
||||
let (sender, sent_at, data) =
|
||||
Overweight::<T>::get(index).ok_or(Error::<T>::BadOverweightIndex)?;
|
||||
let xcm = VersionedXcm::<T::Call>::decode_all_with_depth_limit(
|
||||
let xcm = VersionedXcm::<T::RuntimeCall>::decode_all_with_depth_limit(
|
||||
MAX_XCM_DECODE_DEPTH,
|
||||
&mut data.as_slice(),
|
||||
)
|
||||
@@ -153,7 +153,7 @@ pub mod pallet {
|
||||
.map_err(|_| Error::<T>::WeightOverLimit)?;
|
||||
Overweight::<T>::remove(index);
|
||||
Self::deposit_event(Event::OverweightServiced { index, used });
|
||||
Ok(Some(used.saturating_add(1_000_000)).into())
|
||||
Ok(Some(used.saturating_add(Weight::from_ref_time(1_000_000))).into())
|
||||
}
|
||||
|
||||
/// Suspends all XCM executions for the XCMP queue, regardless of the sender's origin.
|
||||
@@ -453,9 +453,9 @@ impl Default for QueueConfigData {
|
||||
suspend_threshold: 2,
|
||||
drop_threshold: 5,
|
||||
resume_threshold: 1,
|
||||
threshold_weight: 100_000,
|
||||
weight_restrict_decay: 2,
|
||||
xcmp_max_individual_weight: 20 * WEIGHT_PER_MILLIS,
|
||||
threshold_weight: Weight::from_ref_time(100_000),
|
||||
weight_restrict_decay: Weight::from_ref_time(2),
|
||||
xcmp_max_individual_weight: 20u64 * WEIGHT_PER_MILLIS,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -600,24 +600,37 @@ impl<T: Config> Pallet<T> {
|
||||
fn handle_xcm_message(
|
||||
sender: ParaId,
|
||||
_sent_at: RelayBlockNumber,
|
||||
xcm: VersionedXcm<T::Call>,
|
||||
xcm: VersionedXcm<T::RuntimeCall>,
|
||||
max_weight: Weight,
|
||||
) -> Result<Weight, XcmError> {
|
||||
let hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
||||
log::debug!("Processing XCMP-XCM: {:?}", &hash);
|
||||
let (result, event) = match Xcm::<T::Call>::try_from(xcm) {
|
||||
let (result, event) = match Xcm::<T::RuntimeCall>::try_from(xcm) {
|
||||
Ok(xcm) => {
|
||||
let location = (Parent, Parachain(sender.into()));
|
||||
|
||||
match T::XcmExecutor::execute_xcm(location, xcm, hash, max_weight) {
|
||||
Outcome::Error(e) =>
|
||||
(Err(e), Event::Fail { message_hash: Some(hash), error: e, weight: 0 }),
|
||||
Outcome::Complete(w) =>
|
||||
(Ok(w), Event::Success { message_hash: Some(hash), weight: w }),
|
||||
match T::XcmExecutor::execute_xcm(location, xcm, hash, max_weight.ref_time()) {
|
||||
Outcome::Error(e) => (
|
||||
Err(e),
|
||||
Event::Fail { message_hash: Some(hash), error: e, weight: Weight::zero() },
|
||||
),
|
||||
Outcome::Complete(w) => (
|
||||
Ok(Weight::from_ref_time(w)),
|
||||
Event::Success {
|
||||
message_hash: Some(hash),
|
||||
weight: Weight::from_ref_time(w),
|
||||
},
|
||||
),
|
||||
// As far as the caller is concerned, this was dispatched without error, so
|
||||
// we just report the weight used.
|
||||
Outcome::Incomplete(w, e) =>
|
||||
(Ok(w), Event::Fail { message_hash: Some(hash), error: e, weight: w }),
|
||||
Outcome::Incomplete(w, e) => (
|
||||
Ok(Weight::from_ref_time(w)),
|
||||
Event::Fail {
|
||||
message_hash: Some(hash),
|
||||
error: e,
|
||||
weight: Weight::from_ref_time(w),
|
||||
},
|
||||
),
|
||||
}
|
||||
},
|
||||
Err(()) =>
|
||||
@@ -636,12 +649,12 @@ impl<T: Config> Pallet<T> {
|
||||
let data = <InboundXcmpMessages<T>>::get(sender, sent_at);
|
||||
let mut last_remaining_fragments;
|
||||
let mut remaining_fragments = &data[..];
|
||||
let mut weight_used = 0;
|
||||
let mut weight_used = Weight::zero();
|
||||
match format {
|
||||
XcmpMessageFormat::ConcatenatedVersionedXcm => {
|
||||
while !remaining_fragments.is_empty() {
|
||||
last_remaining_fragments = remaining_fragments;
|
||||
if let Ok(xcm) = VersionedXcm::<T::Call>::decode_with_depth_limit(
|
||||
if let Ok(xcm) = VersionedXcm::<T::RuntimeCall>::decode_with_depth_limit(
|
||||
MAX_XCM_DECODE_DEPTH,
|
||||
&mut remaining_fragments,
|
||||
) {
|
||||
@@ -649,7 +662,7 @@ impl<T: Config> Pallet<T> {
|
||||
match Self::handle_xcm_message(sender, sent_at, xcm, weight) {
|
||||
Ok(used) => weight_used = weight_used.saturating_add(used),
|
||||
Err(XcmError::WeightLimitReached(required))
|
||||
if required > max_individual_weight =>
|
||||
if required > max_individual_weight.ref_time() =>
|
||||
{
|
||||
// overweight - add to overweight queue and continue with message
|
||||
// execution consuming the message.
|
||||
@@ -658,12 +671,16 @@ impl<T: Config> Pallet<T> {
|
||||
.saturating_sub(remaining_fragments.len());
|
||||
let overweight_xcm = last_remaining_fragments[..msg_len].to_vec();
|
||||
let index = Self::stash_overweight(sender, sent_at, overweight_xcm);
|
||||
let e =
|
||||
Event::OverweightEnqueued { sender, sent_at, index, required };
|
||||
let e = Event::OverweightEnqueued {
|
||||
sender,
|
||||
sent_at,
|
||||
index,
|
||||
required: Weight::from_ref_time(required),
|
||||
};
|
||||
Self::deposit_event(e);
|
||||
},
|
||||
Err(XcmError::WeightLimitReached(required))
|
||||
if required <= max_weight =>
|
||||
if required <= max_weight.ref_time() =>
|
||||
{
|
||||
// That message didn't get processed this time because of being
|
||||
// too heavy. We leave it around for next time and bail.
|
||||
@@ -770,7 +787,7 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
let mut status = <InboundXcmpStatus<T>>::get(); // <- sorted.
|
||||
if status.is_empty() {
|
||||
return 0
|
||||
return Weight::zero()
|
||||
}
|
||||
|
||||
let QueueConfigData {
|
||||
@@ -782,8 +799,8 @@ impl<T: Config> Pallet<T> {
|
||||
} = <QueueConfig<T>>::get();
|
||||
|
||||
let mut shuffled = Self::create_shuffle(status.len());
|
||||
let mut weight_used = 0;
|
||||
let mut weight_available = 0;
|
||||
let mut weight_used = Weight::zero();
|
||||
let mut weight_available = Weight::zero();
|
||||
|
||||
// We don't want the possibility of a chain sending a series of really heavy messages and
|
||||
// tying up the block's execution time from other chains. Therefore we execute any remaining
|
||||
@@ -795,7 +812,7 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
let mut shuffle_index = 0;
|
||||
while shuffle_index < shuffled.len() &&
|
||||
max_weight.saturating_sub(weight_used) >= threshold_weight
|
||||
max_weight.saturating_sub(weight_used).all_gte(threshold_weight)
|
||||
{
|
||||
let index = shuffled[shuffle_index];
|
||||
let sender = status[index].sender;
|
||||
@@ -817,8 +834,8 @@ impl<T: Config> Pallet<T> {
|
||||
// on the first round to unlocking everything, then we do so.
|
||||
if shuffle_index < status.len() {
|
||||
weight_available +=
|
||||
(max_weight - weight_available) / (weight_restrict_decay + 1);
|
||||
if weight_available + threshold_weight > max_weight {
|
||||
(max_weight - weight_available) / (weight_restrict_decay.ref_time() + 1);
|
||||
if (weight_available + threshold_weight).any_gt(max_weight) {
|
||||
weight_available = max_weight;
|
||||
}
|
||||
} else {
|
||||
@@ -828,7 +845,7 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
let weight_processed = if status[index].message_metadata.is_empty() {
|
||||
debug_assert!(false, "channel exists in status; there must be messages; qed");
|
||||
0
|
||||
Weight::zero()
|
||||
} else {
|
||||
// Process up to one block's worth for now.
|
||||
let weight_remaining = weight_available.saturating_sub(weight_used);
|
||||
@@ -858,7 +875,7 @@ impl<T: Config> Pallet<T> {
|
||||
// other channels a look in. If we've still not unlocked all weight, then we set them
|
||||
// up for processing a second time anyway.
|
||||
if !status[index].message_metadata.is_empty() &&
|
||||
(weight_processed > 0 || weight_available != max_weight)
|
||||
(weight_processed.any_gt(Weight::zero()) || weight_available != max_weight)
|
||||
{
|
||||
if shuffle_index + 1 == shuffled.len() {
|
||||
// Only this queue left. Just run around this loop once more.
|
||||
|
||||
@@ -25,7 +25,7 @@ pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
|
||||
/// Migrates the pallet storage to the most recent version, checking and setting the
|
||||
/// `StorageVersion`.
|
||||
pub fn migrate_to_latest<T: Config>() -> Weight {
|
||||
let mut weight = 0;
|
||||
let mut weight = Weight::zero();
|
||||
|
||||
if StorageVersion::get::<Pallet<T>>() == 0 {
|
||||
weight += migrate_to_v1::<T>();
|
||||
@@ -54,8 +54,8 @@ mod v0 {
|
||||
suspend_threshold: 2,
|
||||
drop_threshold: 5,
|
||||
resume_threshold: 1,
|
||||
threshold_weight: 100_000,
|
||||
weight_restrict_decay: 2,
|
||||
threshold_weight: Weight::from_ref_time(100_000),
|
||||
weight_restrict_decay: Weight::from_ref_time(2),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -102,8 +102,8 @@ mod tests {
|
||||
suspend_threshold: 5,
|
||||
drop_threshold: 12,
|
||||
resume_threshold: 3,
|
||||
threshold_weight: 333_333,
|
||||
weight_restrict_decay: 1,
|
||||
threshold_weight: Weight::from_ref_time(333_333),
|
||||
weight_restrict_decay: Weight::from_ref_time(1),
|
||||
};
|
||||
|
||||
new_test_ext().execute_with(|| {
|
||||
@@ -122,7 +122,7 @@ mod tests {
|
||||
assert_eq!(v0.resume_threshold, v1.resume_threshold);
|
||||
assert_eq!(v0.threshold_weight, v1.threshold_weight);
|
||||
assert_eq!(v0.weight_restrict_decay, v1.weight_restrict_decay);
|
||||
assert_eq!(v1.xcmp_max_individual_weight, 20_000_000_000);
|
||||
assert_eq!(v1.xcmp_max_individual_weight, Weight::from_ref_time(20_000_000_000));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,8 +63,8 @@ impl frame_system::Config for Test {
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type DbWeight = ();
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type Hash = H256;
|
||||
@@ -72,7 +72,7 @@ impl frame_system::Config for Test {
|
||||
type AccountId = AccountId;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Header = Header;
|
||||
type Event = Event;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type Version = ();
|
||||
type PalletInfo = PalletInfo;
|
||||
@@ -92,7 +92,7 @@ parameter_types! {
|
||||
|
||||
impl pallet_balances::Config for Test {
|
||||
type Balance = u64;
|
||||
type Event = Event;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type DustRemoval = ();
|
||||
type ExistentialDeposit = ExistentialDeposit;
|
||||
type AccountStore = System;
|
||||
@@ -103,7 +103,7 @@ impl pallet_balances::Config for Test {
|
||||
}
|
||||
|
||||
impl cumulus_pallet_parachain_system::Config for Test {
|
||||
type Event = Event;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type OnSystemEvent = ();
|
||||
type SelfParaId = ();
|
||||
type OutboundXcmpMessageSource = XcmpQueue;
|
||||
@@ -117,7 +117,7 @@ impl cumulus_pallet_parachain_system::Config for Test {
|
||||
parameter_types! {
|
||||
pub const RelayChain: MultiLocation = MultiLocation::parent();
|
||||
pub UniversalLocation: InteriorMultiLocation = X1(Parachain(1u32.into())).into();
|
||||
pub UnitWeightCost: Weight = 1_000_000;
|
||||
pub UnitWeightCost: u64 = 1_000_000;
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
pub const MaxAssetsIntoHolding: u32 = 64;
|
||||
}
|
||||
@@ -140,7 +140,7 @@ pub type LocationToAccountId = (ParentIsPreset<AccountId>,);
|
||||
|
||||
pub struct XcmConfig;
|
||||
impl xcm_executor::Config for XcmConfig {
|
||||
type Call = Call;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type XcmSender = XcmRouter;
|
||||
// How to withdraw and deposit an asset.
|
||||
type AssetTransactor = LocalAssetTransactor;
|
||||
@@ -149,7 +149,7 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type IsTeleporter = NativeAsset;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type Barrier = ();
|
||||
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
|
||||
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
|
||||
type Trader = ();
|
||||
type ResponseHandler = ();
|
||||
type AssetTrap = ();
|
||||
@@ -170,12 +170,14 @@ pub type XcmRouter = (
|
||||
XcmpQueue,
|
||||
);
|
||||
|
||||
pub struct SystemParachainAsSuperuser<Origin>(PhantomData<Origin>);
|
||||
impl<Origin: OriginTrait> ConvertOrigin<Origin> for SystemParachainAsSuperuser<Origin> {
|
||||
pub struct SystemParachainAsSuperuser<RuntimeOrigin>(PhantomData<RuntimeOrigin>);
|
||||
impl<RuntimeOrigin: OriginTrait> ConvertOrigin<RuntimeOrigin>
|
||||
for SystemParachainAsSuperuser<RuntimeOrigin>
|
||||
{
|
||||
fn convert_origin(
|
||||
origin: impl Into<MultiLocation>,
|
||||
kind: OriginKind,
|
||||
) -> Result<Origin, MultiLocation> {
|
||||
) -> Result<RuntimeOrigin, MultiLocation> {
|
||||
let origin = origin.into();
|
||||
if kind == OriginKind::Superuser &&
|
||||
matches!(
|
||||
@@ -185,7 +187,7 @@ impl<Origin: OriginTrait> ConvertOrigin<Origin> for SystemParachainAsSuperuser<O
|
||||
interior: X1(Parachain(id)),
|
||||
} if ParaId::from(id).is_system(),
|
||||
) {
|
||||
Ok(Origin::root())
|
||||
Ok(RuntimeOrigin::root())
|
||||
} else {
|
||||
Err(origin)
|
||||
}
|
||||
@@ -193,13 +195,13 @@ impl<Origin: OriginTrait> ConvertOrigin<Origin> for SystemParachainAsSuperuser<O
|
||||
}
|
||||
|
||||
impl Config for Test {
|
||||
type Event = Event;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>;
|
||||
type ChannelInfo = ParachainSystem;
|
||||
type VersionWrapper = ();
|
||||
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
|
||||
type ControllerOrigin = EnsureRoot<AccountId>;
|
||||
type ControllerOriginConverter = SystemParachainAsSuperuser<Origin>;
|
||||
type ControllerOriginConverter = SystemParachainAsSuperuser<RuntimeOrigin>;
|
||||
type WeightInfo = ();
|
||||
type PriceForSiblingDelivery = ();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
use super::*;
|
||||
use cumulus_primitives_core::XcmpMessageHandler;
|
||||
use frame_support::{assert_noop, assert_ok};
|
||||
use mock::{new_test_ext, Call, Origin, Test, XcmpQueue};
|
||||
use mock::{new_test_ext, RuntimeCall, RuntimeOrigin, Test, XcmpQueue};
|
||||
use sp_runtime::traits::BadOrigin;
|
||||
|
||||
#[test]
|
||||
@@ -26,7 +26,7 @@ fn one_message_does_not_panic() {
|
||||
let messages = vec![(Default::default(), 1u32.into(), message_format.as_slice())];
|
||||
|
||||
// This shouldn't cause a panic
|
||||
XcmpQueue::handle_xcmp_messages(messages.into_iter(), Weight::max_value());
|
||||
XcmpQueue::handle_xcmp_messages(messages.into_iter(), Weight::MAX);
|
||||
})
|
||||
}
|
||||
|
||||
@@ -43,7 +43,12 @@ fn bad_message_is_handled() {
|
||||
InboundXcmpMessages::<Test>::insert(ParaId::from(1000), 1, bad_data);
|
||||
let format = XcmpMessageFormat::ConcatenatedEncodedBlob;
|
||||
// This should exit with an error.
|
||||
XcmpQueue::process_xcmp_message(1000.into(), (1, format), 10_000_000_000, 10_000_000_000);
|
||||
XcmpQueue::process_xcmp_message(
|
||||
1000.into(),
|
||||
(1, format),
|
||||
Weight::from_ref_time(10_000_000_000),
|
||||
Weight::from_ref_time(10_000_000_000),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -61,7 +66,12 @@ fn handle_blob_message() {
|
||||
];
|
||||
InboundXcmpMessages::<Test>::insert(ParaId::from(1000), 1, bad_data);
|
||||
let format = XcmpMessageFormat::ConcatenatedEncodedBlob;
|
||||
XcmpQueue::process_xcmp_message(1000.into(), (1, format), 10_000_000_000, 10_000_000_000);
|
||||
XcmpQueue::process_xcmp_message(
|
||||
1000.into(),
|
||||
(1, format),
|
||||
Weight::from_ref_time(10_000_000_000),
|
||||
Weight::from_ref_time(10_000_000_000),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -73,7 +83,12 @@ fn handle_invalid_data() {
|
||||
let data = Xcm::<Test>(vec![]).encode();
|
||||
InboundXcmpMessages::<Test>::insert(ParaId::from(1000), 1, data);
|
||||
let format = XcmpMessageFormat::ConcatenatedVersionedXcm;
|
||||
XcmpQueue::process_xcmp_message(1000.into(), (1, format), 10_000_000_000, 10_000_000_000);
|
||||
XcmpQueue::process_xcmp_message(
|
||||
1000.into(),
|
||||
(1, format),
|
||||
Weight::from_ref_time(10_000_000_000),
|
||||
Weight::from_ref_time(10_000_000_000),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -81,7 +96,7 @@ fn handle_invalid_data() {
|
||||
fn service_overweight_unknown() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_noop!(
|
||||
XcmpQueue::service_overweight(Origin::root(), 0, 1000),
|
||||
XcmpQueue::service_overweight(RuntimeOrigin::root(), 0, Weight::from_ref_time(1000)),
|
||||
Error::<Test>::BadOverweightIndex,
|
||||
);
|
||||
});
|
||||
@@ -93,7 +108,10 @@ fn service_overweight_bad_xcm_format() {
|
||||
let bad_xcm = vec![255];
|
||||
Overweight::<Test>::insert(0, (ParaId::from(1000), 0, bad_xcm));
|
||||
|
||||
assert_noop!(XcmpQueue::service_overweight(Origin::root(), 0, 1000), Error::<Test>::BadXcm);
|
||||
assert_noop!(
|
||||
XcmpQueue::service_overweight(RuntimeOrigin::root(), 0, Weight::from_ref_time(1000)),
|
||||
Error::<Test>::BadXcm
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -102,13 +120,15 @@ fn suspend_xcm_execution_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
QueueSuspended::<Test>::put(true);
|
||||
|
||||
let xcm = VersionedXcm::from(Xcm::<Call>(vec![Instruction::<Call>::ClearOrigin])).encode();
|
||||
let xcm =
|
||||
VersionedXcm::from(Xcm::<RuntimeCall>(vec![Instruction::<RuntimeCall>::ClearOrigin]))
|
||||
.encode();
|
||||
let mut message_format = XcmpMessageFormat::ConcatenatedVersionedXcm.encode();
|
||||
message_format.extend(xcm.clone());
|
||||
let messages = vec![(ParaId::from(999), 1u32.into(), message_format.as_slice())];
|
||||
|
||||
// This should have executed the incoming XCM, because it came from a system parachain
|
||||
XcmpQueue::handle_xcmp_messages(messages.into_iter(), Weight::max_value());
|
||||
XcmpQueue::handle_xcmp_messages(messages.into_iter(), Weight::MAX);
|
||||
|
||||
let queued_xcm = InboundXcmpMessages::<Test>::get(ParaId::from(999), 1u32);
|
||||
assert!(queued_xcm.is_empty());
|
||||
@@ -116,7 +136,7 @@ fn suspend_xcm_execution_works() {
|
||||
let messages = vec![(ParaId::from(2000), 1u32.into(), message_format.as_slice())];
|
||||
|
||||
// This shouldn't have executed the incoming XCM
|
||||
XcmpQueue::handle_xcmp_messages(messages.into_iter(), Weight::max_value());
|
||||
XcmpQueue::handle_xcmp_messages(messages.into_iter(), Weight::MAX);
|
||||
|
||||
let queued_xcm = InboundXcmpMessages::<Test>::get(ParaId::from(2000), 1u32);
|
||||
assert_eq!(queued_xcm, xcm);
|
||||
@@ -128,8 +148,8 @@ fn update_suspend_threshold_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let data: QueueConfigData = <QueueConfig<Test>>::get();
|
||||
assert_eq!(data.suspend_threshold, 2);
|
||||
assert_ok!(XcmpQueue::update_suspend_threshold(Origin::root(), 3));
|
||||
assert_noop!(XcmpQueue::update_suspend_threshold(Origin::signed(2), 5), BadOrigin);
|
||||
assert_ok!(XcmpQueue::update_suspend_threshold(RuntimeOrigin::root(), 3));
|
||||
assert_noop!(XcmpQueue::update_suspend_threshold(RuntimeOrigin::signed(2), 5), BadOrigin);
|
||||
let data: QueueConfigData = <QueueConfig<Test>>::get();
|
||||
|
||||
assert_eq!(data.suspend_threshold, 3);
|
||||
@@ -141,8 +161,8 @@ fn update_drop_threshold_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let data: QueueConfigData = <QueueConfig<Test>>::get();
|
||||
assert_eq!(data.drop_threshold, 5);
|
||||
assert_ok!(XcmpQueue::update_drop_threshold(Origin::root(), 6));
|
||||
assert_noop!(XcmpQueue::update_drop_threshold(Origin::signed(2), 7), BadOrigin);
|
||||
assert_ok!(XcmpQueue::update_drop_threshold(RuntimeOrigin::root(), 6));
|
||||
assert_noop!(XcmpQueue::update_drop_threshold(RuntimeOrigin::signed(2), 7), BadOrigin);
|
||||
let data: QueueConfigData = <QueueConfig<Test>>::get();
|
||||
|
||||
assert_eq!(data.drop_threshold, 6);
|
||||
@@ -154,8 +174,8 @@ fn update_resume_threshold_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let data: QueueConfigData = <QueueConfig<Test>>::get();
|
||||
assert_eq!(data.resume_threshold, 1);
|
||||
assert_ok!(XcmpQueue::update_resume_threshold(Origin::root(), 2));
|
||||
assert_noop!(XcmpQueue::update_resume_threshold(Origin::signed(7), 3), BadOrigin);
|
||||
assert_ok!(XcmpQueue::update_resume_threshold(RuntimeOrigin::root(), 2));
|
||||
assert_noop!(XcmpQueue::update_resume_threshold(RuntimeOrigin::signed(7), 3), BadOrigin);
|
||||
let data: QueueConfigData = <QueueConfig<Test>>::get();
|
||||
|
||||
assert_eq!(data.resume_threshold, 2);
|
||||
@@ -166,12 +186,21 @@ fn update_resume_threshold_works() {
|
||||
fn update_threshold_weight_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let data: QueueConfigData = <QueueConfig<Test>>::get();
|
||||
assert_eq!(data.threshold_weight, 100_000);
|
||||
assert_ok!(XcmpQueue::update_threshold_weight(Origin::root(), 10_000));
|
||||
assert_noop!(XcmpQueue::update_threshold_weight(Origin::signed(5), 10_000_000), BadOrigin);
|
||||
assert_eq!(data.threshold_weight, Weight::from_ref_time(100_000));
|
||||
assert_ok!(XcmpQueue::update_threshold_weight(
|
||||
RuntimeOrigin::root(),
|
||||
Weight::from_ref_time(10_000)
|
||||
));
|
||||
assert_noop!(
|
||||
XcmpQueue::update_threshold_weight(
|
||||
RuntimeOrigin::signed(5),
|
||||
Weight::from_ref_time(10_000_000)
|
||||
),
|
||||
BadOrigin
|
||||
);
|
||||
let data: QueueConfigData = <QueueConfig<Test>>::get();
|
||||
|
||||
assert_eq!(data.threshold_weight, 10_000);
|
||||
assert_eq!(data.threshold_weight, Weight::from_ref_time(10_000));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -179,12 +208,21 @@ fn update_threshold_weight_works() {
|
||||
fn update_weight_restrict_decay_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let data: QueueConfigData = <QueueConfig<Test>>::get();
|
||||
assert_eq!(data.weight_restrict_decay, 2);
|
||||
assert_ok!(XcmpQueue::update_weight_restrict_decay(Origin::root(), 5));
|
||||
assert_noop!(XcmpQueue::update_weight_restrict_decay(Origin::signed(6), 4), BadOrigin);
|
||||
assert_eq!(data.weight_restrict_decay, Weight::from_ref_time(2));
|
||||
assert_ok!(XcmpQueue::update_weight_restrict_decay(
|
||||
RuntimeOrigin::root(),
|
||||
Weight::from_ref_time(5)
|
||||
));
|
||||
assert_noop!(
|
||||
XcmpQueue::update_weight_restrict_decay(
|
||||
RuntimeOrigin::signed(6),
|
||||
Weight::from_ref_time(4)
|
||||
),
|
||||
BadOrigin
|
||||
);
|
||||
let data: QueueConfigData = <QueueConfig<Test>>::get();
|
||||
|
||||
assert_eq!(data.weight_restrict_decay, 5);
|
||||
assert_eq!(data.weight_restrict_decay, Weight::from_ref_time(5));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -192,17 +230,20 @@ fn update_weight_restrict_decay_works() {
|
||||
fn update_xcmp_max_individual_weight() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let data: QueueConfigData = <QueueConfig<Test>>::get();
|
||||
assert_eq!(data.xcmp_max_individual_weight, 20 * WEIGHT_PER_MILLIS);
|
||||
assert_eq!(data.xcmp_max_individual_weight, 20u64 * WEIGHT_PER_MILLIS);
|
||||
assert_ok!(XcmpQueue::update_xcmp_max_individual_weight(
|
||||
Origin::root(),
|
||||
30 * WEIGHT_PER_MILLIS
|
||||
RuntimeOrigin::root(),
|
||||
30u64 * WEIGHT_PER_MILLIS
|
||||
));
|
||||
assert_noop!(
|
||||
XcmpQueue::update_xcmp_max_individual_weight(Origin::signed(3), 10 * WEIGHT_PER_MILLIS),
|
||||
XcmpQueue::update_xcmp_max_individual_weight(
|
||||
RuntimeOrigin::signed(3),
|
||||
10u64 * WEIGHT_PER_MILLIS
|
||||
),
|
||||
BadOrigin
|
||||
);
|
||||
let data: QueueConfigData = <QueueConfig<Test>>::get();
|
||||
|
||||
assert_eq!(data.xcmp_max_individual_weight, 30 * WEIGHT_PER_MILLIS);
|
||||
assert_eq!(data.xcmp_max_individual_weight, 30u64 * WEIGHT_PER_MILLIS);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,31 +18,31 @@ pub struct SubstrateWeight<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: XcmpQueue QueueConfig (r:1 w:1)
|
||||
fn set_config_with_u32() -> Weight {
|
||||
(2_717_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
Weight::from_ref_time(2_717_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
|
||||
// Storage: XcmpQueue QueueConfig (r:1 w:1)
|
||||
fn set_config_with_weight() -> Weight {
|
||||
(2_717_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
Weight::from_ref_time(2_717_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
}
|
||||
|
||||
impl WeightInfo for () {
|
||||
// Storage: XcmpQueue QueueConfig (r:1 w:1)
|
||||
fn set_config_with_u32() -> Weight {
|
||||
(2_717_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
Weight::from_ref_time(2_717_000 as u64)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as u64))
|
||||
}
|
||||
|
||||
// Storage: XcmpQueue QueueConfig (r:1 w:1)
|
||||
fn set_config_with_weight() -> Weight {
|
||||
(2_717_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
Weight::from_ref_time(2_717_000 as u64)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as u64))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user