add block usage logs to system pallet (#10940)

* add block usage logs to system pallet

* add Debug

* use % instead of default Debug impl

* change formatting

* revert
This commit is contained in:
Kian Paimani
2022-03-04 20:20:19 +00:00
committed by GitHub
parent ef0b987159
commit 545ac4cf50
2 changed files with 37 additions and 4 deletions
+34
View File
@@ -1272,6 +1272,40 @@ impl<T: Config> Pallet<T> {
/// Remove temporary "environment" entries in storage, compute the storage root and return the
/// resulting header for this block.
pub fn finalize() -> T::Header {
log::debug!(
target: "runtime::system",
"[{:?}] length: {} (normal {}%, op: {}%, mandatory {}%) / normal weight: {} ({}%) \
/ op weight {} ({}%) / mandatory weight {} ({}%)",
Self::block_number(),
Self::all_extrinsics_len(),
sp_runtime::Percent::from_rational(
Self::all_extrinsics_len(),
*T::BlockLength::get().max.get(DispatchClass::Normal)
).deconstruct(),
sp_runtime::Percent::from_rational(
Self::all_extrinsics_len(),
*T::BlockLength::get().max.get(DispatchClass::Operational)
).deconstruct(),
sp_runtime::Percent::from_rational(
Self::all_extrinsics_len(),
*T::BlockLength::get().max.get(DispatchClass::Mandatory)
).deconstruct(),
Self::block_weight().get(DispatchClass::Normal),
sp_runtime::Percent::from_rational(
*Self::block_weight().get(DispatchClass::Normal),
T::BlockWeights::get().get(DispatchClass::Normal).max_total.unwrap_or(Bounded::max_value())
).deconstruct(),
Self::block_weight().get(DispatchClass::Operational),
sp_runtime::Percent::from_rational(
*Self::block_weight().get(DispatchClass::Operational),
T::BlockWeights::get().get(DispatchClass::Operational).max_total.unwrap_or(Bounded::max_value())
).deconstruct(),
Self::block_weight().get(DispatchClass::Mandatory),
sp_runtime::Percent::from_rational(
*Self::block_weight().get(DispatchClass::Mandatory),
T::BlockWeights::get().get(DispatchClass::Mandatory).max_total.unwrap_or(Bounded::max_value())
).deconstruct(),
);
ExecutionPhase::<T>::kill();
AllExtrinsicsLen::<T>::kill();