Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Refund weight in system::fillBlock #11754

Merged
merged 3 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bin/node/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ node-testing = { version = "3.0.0-dev", path = "../testing" }
pallet-balances = { version = "4.0.0-dev", path = "../../../frame/balances" }
pallet-contracts = { version = "4.0.0-dev", path = "../../../frame/contracts" }
pallet-im-online = { version = "4.0.0-dev", path = "../../../frame/im-online" }
pallet-sudo = { version = "4.0.0-dev", path = "../../../frame/sudo" }
pallet-timestamp = { version = "4.0.0-dev", path = "../../../frame/timestamp" }
pallet-treasury = { version = "4.0.0-dev", path = "../../../frame/treasury" }
pallet-transaction-payment = { version = "4.0.0-dev", path = "../../../frame/transaction-payment" }
Expand Down
6 changes: 4 additions & 2 deletions bin/node/executor/tests/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ fn fee_multiplier_increases_and_decreases_on_big_weight() {
},
CheckedExtrinsic {
signed: Some((charlie(), signed_extra(0, 0))),
function: Call::System(frame_system::Call::fill_block {
ratio: Perbill::from_percent(60),
function: Call::Sudo(pallet_sudo::Call::sudo {
call: Box::new(Call::System(frame_system::Call::fill_block {
ratio: Perbill::from_percent(60),
})),
}),
},
],
Expand Down
13 changes: 11 additions & 2 deletions frame/system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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.
Expand Down