mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 19:51:02 +00:00
Properly migrate weights to v2 (#6091)
* Create migration for config pallet * Use XcmWeight in XCM pallet extrinsics * Link to PR in doc comment * cargo fmt * Fix tests * Fix tests * Remove unused import * Update runtime/parachains/src/configuration/migration.rs Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add missing on_runtime_upgrade implementation * Use new migration API * cargo fmt * Fix log message Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
@@ -31,7 +31,7 @@ use sp_runtime::{
|
||||
RuntimeDebug,
|
||||
};
|
||||
use sp_std::{boxed::Box, marker::PhantomData, prelude::*, result::Result, vec};
|
||||
use xcm::prelude::*;
|
||||
use xcm::{latest::Weight as XcmWeight, prelude::*};
|
||||
use xcm_executor::traits::ConvertOrigin;
|
||||
|
||||
use frame_support::PalletId;
|
||||
@@ -570,11 +570,11 @@ pub mod pallet {
|
||||
///
|
||||
/// NOTE: A successful return to this does *not* imply that the `msg` was executed successfully
|
||||
/// to completion; only that *some* of it was executed.
|
||||
#[pallet::weight(max_weight.saturating_add(Weight::from_ref_time(100_000_000u64)))]
|
||||
#[pallet::weight(Weight::from_ref_time(max_weight.saturating_add(100_000_000u64)))]
|
||||
pub fn execute(
|
||||
origin: OriginFor<T>,
|
||||
message: Box<VersionedXcm<<T as SysConfig>::RuntimeCall>>,
|
||||
max_weight: Weight,
|
||||
max_weight: XcmWeight,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
let origin_location = T::ExecuteXcmOrigin::ensure_origin(origin)?;
|
||||
let message = (*message).try_into().map_err(|()| Error::<T>::BadVersion)?;
|
||||
@@ -584,8 +584,8 @@ pub mod pallet {
|
||||
let outcome = T::XcmExecutor::execute_xcm_in_credit(
|
||||
origin_location,
|
||||
message,
|
||||
max_weight.ref_time(),
|
||||
max_weight.ref_time(),
|
||||
max_weight,
|
||||
max_weight,
|
||||
);
|
||||
let result = Ok(Some(outcome.weight_used().saturating_add(100_000_000)).into());
|
||||
Self::deposit_event(Event::Attempted(outcome));
|
||||
|
||||
@@ -517,7 +517,7 @@ fn execute_withdraw_to_deposit_works() {
|
||||
buy_execution((Here, SEND_AMOUNT)),
|
||||
DepositAsset { assets: All.into(), max_assets: 1, beneficiary: dest },
|
||||
]))),
|
||||
Weight::from_ref_time(weight)
|
||||
weight
|
||||
));
|
||||
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE - SEND_AMOUNT);
|
||||
assert_eq!(Balances::total_balance(&BOB), SEND_AMOUNT);
|
||||
@@ -549,7 +549,7 @@ fn trapped_assets_can_be_claimed() {
|
||||
// This would succeed, but we never get to it.
|
||||
DepositAsset { assets: All.into(), max_assets: 1, beneficiary: dest.clone() },
|
||||
]))),
|
||||
Weight::from_ref_time(weight)
|
||||
weight
|
||||
));
|
||||
let source: MultiLocation =
|
||||
Junction::AccountId32 { network: NetworkId::Any, id: ALICE.into() }.into();
|
||||
@@ -579,7 +579,7 @@ fn trapped_assets_can_be_claimed() {
|
||||
buy_execution((Here, SEND_AMOUNT)),
|
||||
DepositAsset { assets: All.into(), max_assets: 1, beneficiary: dest.clone() },
|
||||
]))),
|
||||
Weight::from_ref_time(weight)
|
||||
weight
|
||||
));
|
||||
|
||||
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE - SEND_AMOUNT);
|
||||
@@ -594,7 +594,7 @@ fn trapped_assets_can_be_claimed() {
|
||||
buy_execution((Here, SEND_AMOUNT)),
|
||||
DepositAsset { assets: All.into(), max_assets: 1, beneficiary: dest },
|
||||
]))),
|
||||
Weight::from_ref_time(weight)
|
||||
weight
|
||||
));
|
||||
assert_eq!(
|
||||
last_event(),
|
||||
|
||||
Reference in New Issue
Block a user