Disarm OnRuntimeUpgrade::pre/post_upgrade Tuple footgun (#14759)

* return error on incorrect tuple usage of pre_upgrade and post_upgrade

* add test

* comment lint

* Update frame/support/src/traits/hooks.rs

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>

* Update frame/support/src/traits/hooks.rs

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>

* address feedback

* Update frame/support/src/traits/hooks.rs

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>

* Update frame/support/src/traits/hooks.rs

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>

* Update frame/support/src/traits/hooks.rs

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>

* muharem comments

* Update frame/support/src/traits/hooks.rs

Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com>

* Update frame/support/src/traits/hooks.rs

Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com>

* remove useless type

---------

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com>
This commit is contained in:
Liam Aharon
2023-08-17 03:04:15 +10:00
committed by GitHub
parent ffbc395d84
commit 13f05272fd
2 changed files with 39 additions and 10 deletions
@@ -53,8 +53,6 @@ pub trait UnlockConfig: 'static {
type PalletId: Get<LockIdentifier>;
/// The DB weight as configured in the runtime to calculate the correct weight.
type DbWeight: Get<RuntimeDbWeight>;
/// The block number as configured in the runtime.
type BlockNumber: Parameter + Zero + Copy + Ord;
}
#[storage_alias(dynamic)]
@@ -331,7 +329,6 @@ mod test {
assert_ok, parameter_types,
traits::{Currency, OnRuntimeUpgrade, ReservableCurrency, WithdrawReasons},
};
use frame_system::pallet_prelude::BlockNumberFor;
parameter_types! {
const PalletName: &'static str = "Elections";
@@ -341,7 +338,6 @@ mod test {
impl super::UnlockConfig for UnlockConfigImpl {
type Currency = Balances;
type AccountId = u64;
type BlockNumber = BlockNumberFor<Test>;
type DbWeight = ();
type PalletName = PalletName;
type MaxVotesPerVoter = PhragmenMaxVoters;