[Substrate Companion] Part 1: add TargetList for validator ranking (#5930)

* [Substrate Companion] Part 1: add TargetList for validator ranking

* fix fmt

* don't change the pallet name

* eloquent migration

* fmt

* fix build

* update deps

* Cargo.lock conflicts resolved

* update deps

* Revert "update deps"

This reverts commit e0b07565854f9c66e5f30cdfe2c0a8f08457c96e.

* fix deps

Co-authored-by: kianenigma <kian@parity.io>
This commit is contained in:
Roman Useinov
2022-09-18 17:00:13 +02:00
committed by GitHub
parent da23abe28a
commit 059ad8a388
5 changed files with 244 additions and 184 deletions
+22 -3
View File
@@ -80,7 +80,9 @@ pub use pallet_balances::Call as BalancesCall;
pub use pallet_election_provider_multi_phase::Call as EPMCall;
#[cfg(feature = "std")]
pub use pallet_staking::StakerStatus;
use pallet_staking::UseValidatorsMap;
pub use pallet_timestamp::Call as TimestampCall;
use sp_runtime::traits::Get;
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
@@ -450,7 +452,8 @@ parameter_types! {
pub const BagThresholds: &'static [u64] = &bag_thresholds::THRESHOLDS;
}
impl pallet_bags_list::Config for Runtime {
type VoterBagsListInstance = pallet_bags_list::Instance1;
impl pallet_bags_list::Config<VoterBagsListInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type ScoreProvider = Staking;
type WeightInfo = weights::pallet_bags_list::WeightInfo<Runtime>;
@@ -505,6 +508,7 @@ impl pallet_staking::Config for Runtime {
type ElectionProvider = ElectionProviderMultiPhase;
type GenesisElectionProvider = onchain::UnboundedExecution<OnChainSeqPhragmen>;
type VoterList = VoterList;
type TargetList = UseValidatorsMap<Self>;
type MaxUnlockingChunks = frame_support::traits::ConstU32<32>;
type BenchmarkingConfig = runtime_common::StakingBenchmarkingConfig;
type OnStakerSlash = NominationPools;
@@ -1098,7 +1102,7 @@ construct_runtime! {
ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Pallet, Call, Storage, Event<T>, ValidateUnsigned} = 24,
// Provides a semi-sorted list of nominators for staking.
VoterList: pallet_bags_list::{Pallet, Call, Storage, Event<T>} = 25,
VoterList: pallet_bags_list::<Instance1>::{Pallet, Call, Storage, Event<T>} = 25,
// Nomination pools for staking.
NominationPools: pallet_nomination_pools::{Pallet, Call, Storage, Event<T>, Config<T>} = 29,
@@ -1152,6 +1156,14 @@ pub type SignedExtra = (
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
);
pub struct StakingMigrationV11OldPallet;
impl Get<&'static str> for StakingMigrationV11OldPallet {
fn get() -> &'static str {
"VoterList"
}
}
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic =
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
@@ -1162,7 +1174,14 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
pallet_nomination_pools::migration::v3::MigrateToV3<Runtime>,
(
pallet_staking::migrations::v11::MigrateToV11<
Runtime,
VoterList,
StakingMigrationV11OldPallet,
>,
pallet_nomination_pools::migration::v3::MigrateToV3<Runtime>,
),
>;
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<RuntimeCall, SignedExtra>;