Add base-weight to System::Extrinsic* events (#12329)

* Add base-weight to events

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Fix test

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Oliver Tale-Yazdi
2022-09-24 17:17:44 +02:00
committed by GitHub
parent 3317eb76d5
commit 26ea6e1e48
5 changed files with 198 additions and 148 deletions
@@ -342,7 +342,7 @@ mod tests {
.get(DispatchClass::Operational)
.max_total
.unwrap_or_else(|| weights.max_block);
let base_weight = weights.get(DispatchClass::Normal).base_extrinsic;
let base_weight = weights.get(DispatchClass::Operational).base_extrinsic;
let weight = operational_limit - base_weight;
let okay =
@@ -378,11 +378,11 @@ mod tests {
// Max normal is 768 (75%)
// 10 is taken for block execution weight
// So normal extrinsic can be 758 weight (-5 for base extrinsic weight)
// And Operational can be 256 to produce a full block (-5 for base)
// And Operational can be 246 to produce a full block (-10 for base)
let max_normal =
DispatchInfo { weight: Weight::from_ref_time(753), ..Default::default() };
let rest_operational = DispatchInfo {
weight: Weight::from_ref_time(251),
weight: Weight::from_ref_time(246),
class: DispatchClass::Operational,
..Default::default()
};
@@ -406,7 +406,7 @@ mod tests {
let max_normal =
DispatchInfo { weight: Weight::from_ref_time(753), ..Default::default() };
let rest_operational = DispatchInfo {
weight: Weight::from_ref_time(251),
weight: Weight::from_ref_time(246),
class: DispatchClass::Operational,
..Default::default()
};
@@ -414,7 +414,7 @@ mod tests {
let len = 0_usize;
assert_ok!(CheckWeight::<Test>::do_pre_dispatch(&rest_operational, len));
// Extra 15 here from block execution + base extrinsic weight
// Extra 20 here from block execution + base extrinsic weight
assert_eq!(System::block_weight().total(), Weight::from_ref_time(266));
assert_ok!(CheckWeight::<Test>::do_pre_dispatch(&max_normal, len));
assert_eq!(block_weight_limit(), Weight::from_ref_time(1024));
@@ -433,7 +433,7 @@ mod tests {
..Default::default()
};
let dispatch_operational = DispatchInfo {
weight: Weight::from_ref_time(251),
weight: Weight::from_ref_time(246),
class: DispatchClass::Operational,
..Default::default()
};