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

Commit f397697

Browse files
Refund weight in system::fillBlock (#11754)
* fix * pushed * node: fix fee multiplier test Co-authored-by: André Silva <andrerfosilva@gmail.com>
1 parent ee3eb8f commit f397697

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/node/executor/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ node-testing = { version = "3.0.0-dev", path = "../testing" }
3434
pallet-balances = { version = "4.0.0-dev", path = "../../../frame/balances" }
3535
pallet-contracts = { version = "4.0.0-dev", path = "../../../frame/contracts" }
3636
pallet-im-online = { version = "4.0.0-dev", path = "../../../frame/im-online" }
37+
pallet-sudo = { version = "4.0.0-dev", path = "../../../frame/sudo" }
3738
pallet-timestamp = { version = "4.0.0-dev", path = "../../../frame/timestamp" }
3839
pallet-treasury = { version = "4.0.0-dev", path = "../../../frame/treasury" }
3940
pallet-transaction-payment = { version = "4.0.0-dev", path = "../../../frame/transaction-payment" }

bin/node/executor/tests/fees.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ fn fee_multiplier_increases_and_decreases_on_big_weight() {
5858
},
5959
CheckedExtrinsic {
6060
signed: Some((charlie(), signed_extra(0, 0))),
61-
function: Call::System(frame_system::Call::fill_block {
62-
ratio: Perbill::from_percent(60),
61+
function: Call::Sudo(pallet_sudo::Call::sudo {
62+
call: Box::new(Call::System(frame_system::Call::fill_block {
63+
ratio: Perbill::from_percent(60),
64+
})),
6365
}),
6466
},
6567
],

frame/system/src/lib.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ impl<MaxNormal: Get<u32>, MaxOverflow: Get<u32>> ConsumerLimits for (MaxNormal,
197197
pub mod pallet {
198198
use crate::{self as frame_system, pallet_prelude::*, *};
199199
use frame_support::pallet_prelude::*;
200+
use sp_runtime::DispatchErrorWithPostInfo;
200201

201202
/// System configuration trait. Implemented by runtime.
202203
#[pallet::config]
@@ -371,8 +372,16 @@ pub mod pallet {
371372
// that's not possible at present (since it's within the pallet macro).
372373
#[pallet::weight(*_ratio * T::BlockWeights::get().max_block)]
373374
pub fn fill_block(origin: OriginFor<T>, _ratio: Perbill) -> DispatchResultWithPostInfo {
374-
ensure_root(origin)?;
375-
Ok(().into())
375+
match ensure_root(origin) {
376+
Ok(_) => Ok(().into()),
377+
Err(_) => {
378+
// roughly same as a 4 byte remark since perbill is u32.
379+
Err(DispatchErrorWithPostInfo {
380+
post_info: Some(T::SystemWeightInfo::remark(4u32)).into(),
381+
error: DispatchError::BadOrigin,
382+
})
383+
},
384+
}
376385
}
377386

378387
/// Make some on-chain remark.

0 commit comments

Comments
 (0)