Weight v1.5 Follow Ups (#12155)

* update api

* update

* remove unused

* remove `one` api

* fix unused

* fmt

* add saturating accrue

* remove `Weight::new()`

* use some macros

* div makes no sense

* Update weight_v2.rs

* missed some

* more patch

* fixes

* more fixes

* more fix

* more fix

* Update frame/support/src/weights/weight_v2.rs

* not needed

* fix weight file
This commit is contained in:
Shawn Tabrizi
2022-09-01 18:48:03 +01:00
committed by GitHub
parent 6be21e0397
commit 1df4561676
80 changed files with 965 additions and 960 deletions
+5 -5
View File
@@ -185,7 +185,7 @@ pub mod pallet {
let dispatch_infos = calls.iter().map(|call| call.get_dispatch_info()).collect::<Vec<_>>();
let dispatch_weight = dispatch_infos.iter()
.map(|di| di.weight)
.fold(Weight::new(), |total: Weight, weight: Weight| total.saturating_add(weight))
.fold(Weight::zero(), |total: Weight, weight: Weight| total.saturating_add(weight))
.saturating_add(T::WeightInfo::batch(calls.len() as u32));
let dispatch_class = {
let all_operational = dispatch_infos.iter()
@@ -208,7 +208,7 @@ pub mod pallet {
ensure!(calls_len <= Self::batched_calls_limit() as usize, Error::<T>::TooManyCalls);
// Track the actual weight of each of the batch calls.
let mut weight = Weight::new();
let mut weight = Weight::zero();
for (index, call) in calls.into_iter().enumerate() {
let info = call.get_dispatch_info();
// If origin is root, don't apply any dispatch filters; root can call anything.
@@ -301,7 +301,7 @@ pub mod pallet {
let dispatch_infos = calls.iter().map(|call| call.get_dispatch_info()).collect::<Vec<_>>();
let dispatch_weight = dispatch_infos.iter()
.map(|di| di.weight)
.fold(Weight::new(), |total: Weight, weight: Weight| total.saturating_add(weight))
.fold(Weight::zero(), |total: Weight, weight: Weight| total.saturating_add(weight))
.saturating_add(T::WeightInfo::batch_all(calls.len() as u32));
let dispatch_class = {
let all_operational = dispatch_infos.iter()
@@ -324,7 +324,7 @@ pub mod pallet {
ensure!(calls_len <= Self::batched_calls_limit() as usize, Error::<T>::TooManyCalls);
// Track the actual weight of each of the batch calls.
let mut weight = Weight::new();
let mut weight = Weight::zero();
for (index, call) in calls.into_iter().enumerate() {
let info = call.get_dispatch_info();
// If origin is root, bypass any dispatch filter; root can call anything.
@@ -429,7 +429,7 @@ pub mod pallet {
ensure!(calls_len <= Self::batched_calls_limit() as usize, Error::<T>::TooManyCalls);
// Track the actual weight of each of the batch calls.
let mut weight = Weight::new();
let mut weight = Weight::zero();
// Track failed dispatch occur.
let mut has_error: bool = false;
for call in calls.into_iter() {
+2 -2
View File
@@ -420,7 +420,7 @@ fn batch_handles_weight_refund() {
let good_call = call_foobar(false, start_weight, Some(end_weight));
let bad_call = call_foobar(true, start_weight, Some(end_weight));
let batch_calls = vec![good_call, bad_call];
let batch_len = Weight::from_ref_time(batch_calls.len() as u64);
let batch_len = batch_calls.len() as u64;
let call = Call::Utility(UtilityCall::batch { calls: batch_calls });
let info = call.get_dispatch_info();
let result = call.dispatch(Origin::signed(1));
@@ -533,7 +533,7 @@ fn batch_all_handles_weight_refund() {
let good_call = call_foobar(false, start_weight, Some(end_weight));
let bad_call = call_foobar(true, start_weight, Some(end_weight));
let batch_calls = vec![good_call, bad_call];
let batch_len = Weight::from_ref_time(batch_calls.len() as u64);
let batch_len = batch_calls.len() as u64;
let call = Call::Utility(UtilityCall::batch_all { calls: batch_calls });
let info = call.get_dispatch_info();
let result = call.dispatch(Origin::signed(1));
+6 -6
View File
@@ -60,7 +60,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
fn batch(c: u32, ) -> Weight {
Weight::from_ref_time(23_113_000 as RefTimeWeight)
// Standard Error: 2_000
.saturating_add(Weight::from_ref_time(2_701_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight))
.saturating_add(Weight::from_ref_time(2_701_000 as RefTimeWeight).saturating_mul(c as RefTimeWeight))
}
fn as_derivative() -> Weight {
Weight::from_ref_time(4_182_000 as RefTimeWeight)
@@ -69,7 +69,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
fn batch_all(c: u32, ) -> Weight {
Weight::from_ref_time(18_682_000 as RefTimeWeight)
// Standard Error: 1_000
.saturating_add(Weight::from_ref_time(2_794_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight))
.saturating_add(Weight::from_ref_time(2_794_000 as RefTimeWeight).saturating_mul(c as RefTimeWeight))
}
fn dispatch_as() -> Weight {
Weight::from_ref_time(12_049_000 as RefTimeWeight)
@@ -78,7 +78,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
fn force_batch(c: u32, ) -> Weight {
Weight::from_ref_time(19_136_000 as RefTimeWeight)
// Standard Error: 2_000
.saturating_add(Weight::from_ref_time(2_697_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight))
.saturating_add(Weight::from_ref_time(2_697_000 as RefTimeWeight).saturating_mul(c as RefTimeWeight))
}
}
@@ -88,7 +88,7 @@ impl WeightInfo for () {
fn batch(c: u32, ) -> Weight {
Weight::from_ref_time(23_113_000 as RefTimeWeight)
// Standard Error: 2_000
.saturating_add(Weight::from_ref_time(2_701_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight))
.saturating_add(Weight::from_ref_time(2_701_000 as RefTimeWeight).saturating_mul(c as RefTimeWeight))
}
fn as_derivative() -> Weight {
Weight::from_ref_time(4_182_000 as RefTimeWeight)
@@ -97,7 +97,7 @@ impl WeightInfo for () {
fn batch_all(c: u32, ) -> Weight {
Weight::from_ref_time(18_682_000 as RefTimeWeight)
// Standard Error: 1_000
.saturating_add(Weight::from_ref_time(2_794_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight))
.saturating_add(Weight::from_ref_time(2_794_000 as RefTimeWeight).saturating_mul(c as RefTimeWeight))
}
fn dispatch_as() -> Weight {
Weight::from_ref_time(12_049_000 as RefTimeWeight)
@@ -106,6 +106,6 @@ impl WeightInfo for () {
fn force_batch(c: u32, ) -> Weight {
Weight::from_ref_time(19_136_000 as RefTimeWeight)
// Standard Error: 2_000
.saturating_add(Weight::from_ref_time(2_697_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight))
.saturating_add(Weight::from_ref_time(2_697_000 as RefTimeWeight).saturating_mul(c as RefTimeWeight))
}
}