Rename BagsList to VoterList and Add Score (#5463)

* add migration for simple pallet rename

* fmt

* also add score migration

* add try-runtime feature to bags list

* add pre_upgrade to pallet rename

* update lockfile for {"substrate"}

Co-authored-by: parity-processbot <>
This commit is contained in:
Shawn Tabrizi
2022-05-19 14:33:24 -04:00
committed by GitHub
parent 4060017059
commit b61c7515d7
7 changed files with 240 additions and 188 deletions
+24 -5
View File
@@ -614,7 +614,7 @@ impl pallet_staking::Config for Runtime {
type NextNewSession = Session;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type VoterList = BagsList;
type VoterList = VoterList;
type MaxUnlockingChunks = frame_support::traits::ConstU32<32>;
type BenchmarkingConfig = runtime_common::StakingBenchmarkingConfig;
type OnStakerSlash = ();
@@ -1194,7 +1194,7 @@ impl InstanceFilter<Call> for ProxyType {
Call::Crowdloan(..) |
Call::Slots(..) |
Call::Auctions(..) | // Specifically omitting the entire XCM Pallet
Call::BagsList(..)
Call::VoterList(..)
),
ProxyType::Governance => matches!(
c,
@@ -1563,7 +1563,7 @@ construct_runtime! {
Gilt: pallet_gilt::{Pallet, Call, Storage, Event<T>, Config} = 38,
// Provides a semi-sorted list of nominators for staking.
BagsList: pallet_bags_list::{Pallet, Call, Storage, Event<T>} = 39,
VoterList: pallet_bags_list::{Pallet, Call, Storage, Event<T>} = 39,
// nomination pools: extension to staking.
NominationPools: pallet_nomination_pools::{Pallet, Call, Storage, Event<T>, Config<T>} = 41,
@@ -1624,11 +1624,30 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
InitiatePoolConfigs,
(
RenameBagsListToVoterList,
pallet_bags_list::migrations::AddScore<Runtime>,
InitiatePoolConfigs,
),
>;
/// The payload being signed in the transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
/// A migration which renames the pallet `BagsList` to `VoterList`
pub struct RenameBagsListToVoterList;
impl frame_support::traits::OnRuntimeUpgrade for RenameBagsListToVoterList {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<(), &'static str> {
// For other pre-upgrade checks, we need the storage to already be migrated.
frame_support::storage::migration::move_pallet(b"BagsList", b"VoterList");
Ok(())
}
fn on_runtime_upgrade() -> frame_support::weights::Weight {
frame_support::storage::migration::move_pallet(b"BagsList", b"VoterList");
frame_support::weights::Weight::MAX
}
}
#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;
@@ -1653,7 +1672,7 @@ mod benches {
[runtime_parachains::ump, Ump]
// Substrate
[pallet_balances, Balances]
[pallet_bags_list, BagsList]
[pallet_bags_list, VoterList]
[frame_benchmarking::baseline, Baseline::<Runtime>]
[pallet_bounties, Bounties]
[pallet_child_bounties, ChildBounties]