Refund weight in system::fillBlock (#11754)

* fix

* pushed

* node: fix fee multiplier test

Co-authored-by: André Silva <andrerfosilva@gmail.com>
This commit is contained in:
Kian Paimani
2022-06-29 17:39:56 +01:00
committed by GitHub
parent 3d89fa3605
commit b293cd9290
4 changed files with 17 additions and 4 deletions
+11 -2
View File
@@ -197,6 +197,7 @@ impl<MaxNormal: Get<u32>, MaxOverflow: Get<u32>> ConsumerLimits for (MaxNormal,
pub mod pallet {
use crate::{self as frame_system, pallet_prelude::*, *};
use frame_support::pallet_prelude::*;
use sp_runtime::DispatchErrorWithPostInfo;
/// System configuration trait. Implemented by runtime.
#[pallet::config]
@@ -371,8 +372,16 @@ pub mod pallet {
// that's not possible at present (since it's within the pallet macro).
#[pallet::weight(*_ratio * T::BlockWeights::get().max_block)]
pub fn fill_block(origin: OriginFor<T>, _ratio: Perbill) -> DispatchResultWithPostInfo {
ensure_root(origin)?;
Ok(().into())
match ensure_root(origin) {
Ok(_) => Ok(().into()),
Err(_) => {
// roughly same as a 4 byte remark since perbill is u32.
Err(DispatchErrorWithPostInfo {
post_info: Some(T::SystemWeightInfo::remark(4u32)).into(),
error: DispatchError::BadOrigin,
})
},
}
}
/// Make some on-chain remark.