mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 06:21:02 +00:00
Companion for Weight v1.5 (#5943)
* fix to latest substrate pr
* update weights
* cargo build -p polkadot-runtime-parachains
* fix xcm-builder
* fix import
* fix a bunch
* fix a bunch of weight stuff
* kusama compile
* unused
* builds
* maybe fix
* cargo test -p polkadot-runtime-parachains
* xcm simulator example
* fix tests
* xcm sim fuzz
* fix runtime tests
* remove unused
* fix integration tests
* scalar div
* update lockfile for {"substrate"}
Co-authored-by: parity-processbot <>
This commit is contained in:
@@ -404,7 +404,7 @@ pub mod pallet {
|
||||
#[pallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
|
||||
fn on_initialize(_n: BlockNumberFor<T>) -> Weight {
|
||||
let mut weight_used = 0;
|
||||
let mut weight_used = Weight::new();
|
||||
if let Some(migration) = CurrentMigration::<T>::get() {
|
||||
// Consume 10% of block at most
|
||||
let max_weight = T::BlockWeights::get().max_block / 10;
|
||||
@@ -439,7 +439,7 @@ pub mod pallet {
|
||||
// Start a migration (this happens before on_initialize so it'll happen later in this
|
||||
// block, which should be good enough)...
|
||||
CurrentMigration::<T>::put(VersionMigrationStage::default());
|
||||
T::DbWeight::get().write
|
||||
T::DbWeight::get().writes(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -490,9 +490,9 @@ pub mod pallet {
|
||||
WithdrawAsset(assets),
|
||||
InitiateTeleport { assets: Wild(All), dest, xcm: Xcm(vec![]) },
|
||||
]);
|
||||
T::Weigher::weight(&mut message).map_or(Weight::max_value(), |w| 100_000_000.saturating_add(w))
|
||||
T::Weigher::weight(&mut message).map_or(Weight::MAX, |w| Weight::from_ref_time(100_000_000.saturating_add(w)))
|
||||
},
|
||||
_ => Weight::max_value(),
|
||||
_ => Weight::MAX,
|
||||
}
|
||||
})]
|
||||
pub fn teleport_assets(
|
||||
@@ -528,9 +528,9 @@ pub mod pallet {
|
||||
let mut message = Xcm(vec![
|
||||
TransferReserveAsset { assets, dest, xcm: Xcm(vec![]) }
|
||||
]);
|
||||
T::Weigher::weight(&mut message).map_or(Weight::max_value(), |w| 100_000_000.saturating_add(w))
|
||||
T::Weigher::weight(&mut message).map_or(Weight::MAX, |w| Weight::from_ref_time(100_000_000.saturating_add(w)))
|
||||
},
|
||||
_ => Weight::max_value(),
|
||||
_ => Weight::MAX,
|
||||
}
|
||||
})]
|
||||
pub fn reserve_transfer_assets(
|
||||
@@ -561,7 +561,7 @@ 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(100_000_000u64))]
|
||||
#[pallet::weight(max_weight.saturating_add(Weight::from_ref_time(100_000_000u64)))]
|
||||
pub fn execute(
|
||||
origin: OriginFor<T>,
|
||||
message: Box<VersionedXcm<<T as SysConfig>::Call>>,
|
||||
@@ -575,8 +575,8 @@ pub mod pallet {
|
||||
let outcome = T::XcmExecutor::execute_xcm_in_credit(
|
||||
origin_location,
|
||||
message,
|
||||
max_weight,
|
||||
max_weight,
|
||||
max_weight.ref_time(),
|
||||
max_weight.ref_time(),
|
||||
);
|
||||
let result = Ok(Some(outcome.weight_used().saturating_add(100_000_000)).into());
|
||||
Self::deposit_event(Event::Attempted(outcome));
|
||||
@@ -690,9 +690,9 @@ pub mod pallet {
|
||||
let mut message = Xcm(vec![
|
||||
TransferReserveAsset { assets, dest, xcm: Xcm(vec![]) }
|
||||
]);
|
||||
T::Weigher::weight(&mut message).map_or(Weight::max_value(), |w| 100_000_000.saturating_add(w))
|
||||
T::Weigher::weight(&mut message).map_or(Weight::MAX, |w| Weight::from_ref_time(100_000_000.saturating_add(w)))
|
||||
},
|
||||
_ => Weight::max_value(),
|
||||
_ => Weight::MAX,
|
||||
}
|
||||
})]
|
||||
pub fn limited_reserve_transfer_assets(
|
||||
@@ -740,9 +740,9 @@ pub mod pallet {
|
||||
WithdrawAsset(assets),
|
||||
InitiateTeleport { assets: Wild(All), dest, xcm: Xcm(vec![]) },
|
||||
]);
|
||||
T::Weigher::weight(&mut message).map_or(Weight::max_value(), |w| 100_000_000.saturating_add(w))
|
||||
T::Weigher::weight(&mut message).map_or(Weight::MAX, |w| Weight::from_ref_time(100_000_000.saturating_add(w)))
|
||||
},
|
||||
_ => Weight::max_value(),
|
||||
_ => Weight::MAX,
|
||||
}
|
||||
})]
|
||||
pub fn limited_teleport_assets(
|
||||
@@ -886,12 +886,12 @@ pub mod pallet {
|
||||
mut stage: VersionMigrationStage,
|
||||
weight_cutoff: Weight,
|
||||
) -> (Weight, Option<VersionMigrationStage>) {
|
||||
let mut weight_used = 0;
|
||||
let mut weight_used = Weight::new();
|
||||
|
||||
// TODO: Correct weights for the components of this:
|
||||
let todo_sv_migrate_weight: Weight = T::DbWeight::get().reads_writes(1, 1);
|
||||
let todo_vn_migrate_weight: Weight = T::DbWeight::get().reads_writes(1, 1);
|
||||
let todo_vnt_already_notified_weight: Weight = T::DbWeight::get().read;
|
||||
let todo_vnt_already_notified_weight: Weight = T::DbWeight::get().reads(1);
|
||||
let todo_vnt_notify_weight: Weight = T::DbWeight::get().reads_writes(1, 3);
|
||||
let todo_vnt_migrate_weight: Weight = T::DbWeight::get().reads_writes(1, 1);
|
||||
let todo_vnt_migrate_fail_weight: Weight = T::DbWeight::get().reads_writes(1, 1);
|
||||
@@ -1151,7 +1151,11 @@ pub mod pallet {
|
||||
let notify: <T as Config>::Call = notify.into();
|
||||
let max_response_weight = notify.get_dispatch_info().weight;
|
||||
let query_id = Self::new_notify_query(responder, notify, timeout);
|
||||
let report_error = Xcm(vec![ReportError { dest, query_id, max_response_weight }]);
|
||||
let report_error = Xcm(vec![ReportError {
|
||||
dest,
|
||||
query_id,
|
||||
max_response_weight: max_response_weight.ref_time(),
|
||||
}]);
|
||||
message.0.insert(0, SetAppendix(report_error));
|
||||
Ok(())
|
||||
}
|
||||
@@ -1270,7 +1274,7 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
impl<T: Config> DropAssets for Pallet<T> {
|
||||
fn drop_assets(origin: &MultiLocation, assets: Assets) -> Weight {
|
||||
fn drop_assets(origin: &MultiLocation, assets: Assets) -> RefTimeWeight {
|
||||
if assets.is_empty() {
|
||||
return 0
|
||||
}
|
||||
@@ -1324,8 +1328,8 @@ pub mod pallet {
|
||||
origin: &MultiLocation,
|
||||
query_id: QueryId,
|
||||
response: Response,
|
||||
max_weight: Weight,
|
||||
) -> Weight {
|
||||
max_weight: RefTimeWeight,
|
||||
) -> RefTimeWeight {
|
||||
match (response, Queries::<T>::get(query_id)) {
|
||||
(
|
||||
Response::Version(v),
|
||||
@@ -1400,6 +1404,7 @@ pub mod pallet {
|
||||
{
|
||||
Queries::<T>::remove(query_id);
|
||||
let weight = call.get_dispatch_info().weight;
|
||||
let max_weight = Weight::from_ref_time(max_weight);
|
||||
if weight > max_weight {
|
||||
let e = Event::NotifyOverweight(
|
||||
query_id,
|
||||
@@ -1431,6 +1436,7 @@ pub mod pallet {
|
||||
},
|
||||
}
|
||||
.unwrap_or(weight)
|
||||
.ref_time()
|
||||
} else {
|
||||
let e =
|
||||
Event::NotifyDecodeFailed(query_id, pallet_index, call_index);
|
||||
|
||||
Reference in New Issue
Block a user