Fix a few migration issues with 2D weights (#1755)

* Give a max proof size to DMP individual weight processing during migration

* Fix a few migration issues with 2D weights

* Update substrate

* Fixes

* cargo fmt

* Re-add v1 migration

* Set DEFAULT_POV_SIZE to 64 KB

* Use Weight::from_parts

* Update Polkadot

* Fixes
This commit is contained in:
Keith Yeung
2022-10-24 23:03:02 +08:00
committed by GitHub
parent 3d257b770d
commit b566f3b303
8 changed files with 421 additions and 365 deletions
+5 -1
View File
@@ -66,6 +66,7 @@ pub use pallet::*;
pub type OverweightIndex = u64;
const LOG_TARGET: &str = "xcmp_queue";
const DEFAULT_POV_SIZE: u64 = 64 * 1024; // 64 KB
#[frame_support::pallet]
pub mod pallet {
@@ -462,7 +463,10 @@ impl Default for QueueConfigData {
resume_threshold: 1,
threshold_weight: Weight::from_ref_time(100_000),
weight_restrict_decay: Weight::from_ref_time(2),
xcmp_max_individual_weight: 20u64 * WEIGHT_PER_MILLIS,
xcmp_max_individual_weight: Weight::from_parts(
20u64 * WEIGHT_PER_MILLIS.ref_time(),
DEFAULT_POV_SIZE,
),
}
}
}
+5 -2
View File
@@ -16,7 +16,7 @@
//! A module that is responsible for migration of storage.
use crate::{Config, Pallet, Store};
use crate::{Config, Pallet, Store, DEFAULT_POV_SIZE};
use frame_support::{
pallet_prelude::*,
traits::StorageVersion,
@@ -81,7 +81,10 @@ pub fn migrate_to_v2<T: Config>() -> Weight {
resume_threshold: pre.resume_threshold,
threshold_weight: Weight::from_ref_time(pre.threshold_weight),
weight_restrict_decay: Weight::from_ref_time(pre.weight_restrict_decay),
xcmp_max_individual_weight: Weight::from_ref_time(pre.xcmp_max_individual_weight),
xcmp_max_individual_weight: Weight::from_parts(
pre.xcmp_max_individual_weight,
DEFAULT_POV_SIZE,
),
}
};
+4 -1
View File
@@ -218,7 +218,10 @@ 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, 20u64 * WEIGHT_PER_MILLIS);
assert_eq!(
data.xcmp_max_individual_weight,
Weight::from_parts(20u64 * WEIGHT_PER_MILLIS.ref_time(), DEFAULT_POV_SIZE),
);
assert_ok!(XcmpQueue::update_xcmp_max_individual_weight(
RuntimeOrigin::root(),
30u64 * WEIGHT_PER_MILLIS.ref_time()