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

Companion for substrate#12970 #6807

Merged
merged 21 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8768b9d
Runtime companion changes
gpestana Mar 1, 2023
75d0d79
Merge branch 'master' into gpestana/12970_dynamic-nominators_companion
gpestana Mar 1, 2023
bcbc84a
Merge remote-tracking branch 'origin/master' into gpestana/12970_dyna…
Mar 6, 2023
ffcb905
Merge branch 'master' into gpestana/12970_dynamic-nominators_companion
gpestana Mar 16, 2023
c6d0fdf
Merge branch 'gpestana/12970_dynamic-nominators_companion' of github.…
gpestana Mar 16, 2023
3ba4dbe
Merge branch 'master' into gpestana/12970_dynamic-nominators_companion
gpestana Mar 25, 2023
f2d1c4a
updates runtime configs
gpestana Mar 25, 2023
5d2e648
Merge branch 'master' into gpestana/12970_dynamic-nominators_companion
gpestana Apr 2, 2023
eac4462
Merge branch 'master' into gpestana/12970_dynamic-nominators_companion
gpestana Apr 12, 2023
dda7b49
Merge branch 'master' into gpestana/12970_dynamic-nominators_companion
gpestana Apr 19, 2023
6257fcf
Fixes runtime-test runtime configs
gpestana Apr 19, 2023
d940023
Uses ElectionBounds and builder from own mod
gpestana Apr 19, 2023
31c4922
updates new bounds mod
gpestana Apr 19, 2023
14aba25
Fixes test-runtime mock
gpestana Apr 20, 2023
4dfad05
Merge remote-tracking branch 'origin/master' into gpestana/12970_dyna…
May 17, 2023
8b9b165
Merge branch 'master' into gpestana/12970_dynamic-nominators_companion
gpestana Aug 5, 2023
8d24a84
Merge branch 'gpestana/12970_dynamic-nominators_companion' of github.…
gpestana Aug 5, 2023
28d5cae
Merge remote-tracking branch 'origin/master' into gpestana/12970_dyna…
Aug 9, 2023
1711fd0
Merge remote-tracking branch 'origin/master' into gpestana/12970_dyna…
Aug 9, 2023
4d4a97a
Merge remote-tracking branch 'origin/master' into gpestana/12970_dyna…
Aug 10, 2023
f7b3e86
update lockfile for {"substrate"}
Aug 10, 2023
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
19 changes: 9 additions & 10 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use runtime_parachains::{
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::crypto::{AuthorityId as BeefyId, Signature as BeefySignature};
use frame_election_provider_support::{
generate_solution_type, onchain, NposSolution, SequentialPhragmen,
generate_solution_type, onchain, ElectionBoundsBuilder, NposSolution, SequentialPhragmen,
};
use frame_support::{
construct_runtime, parameter_types,
Expand Down Expand Up @@ -399,11 +399,12 @@ parameter_types! {
// 1 hour session, 15 minutes unsigned phase, 8 offchain executions.
pub OffchainRepeat: BlockNumber = UnsignedPhase::get() / 8;

/// We take the top 12500 nominators as electing voters..
pub const MaxElectingVoters: u32 = 12_500;
/// ... and all of the validators as electable targets. Whilst this is the case, we cannot and
/// shall not increase the size of the validator intentions.
pub const MaxElectableTargets: u16 = u16::MAX;
/// We take the top 12500 nominators as electing voters and all of the validators as electable
/// targets. Whilst this is the case, we cannot and shall not increase the size of the
/// validator intentions.
pub ElectionBounds: frame_election_provider_support::ElectionBounds =
ElectionBoundsBuilder::new().voters_count(MaxElectingVoters::get()).build();
pub NposSolutionPriority: TransactionPriority =
Perbill::from_percent(90) * TransactionPriority::max_value();
/// Setup election pallet to support maximum winners upto 2000. This will mean Staking Pallet
Expand All @@ -428,8 +429,7 @@ impl onchain::Config for OnChainSeqPhragmen {
type DataProvider = Staking;
type WeightInfo = weights::frame_election_provider_support::WeightInfo<Runtime>;
type MaxWinners = MaxActiveValidators;
type VotersBound = MaxElectingVoters;
type TargetsBound = MaxElectableTargets;
type ElectionBounds = ElectionBounds;
}

impl pallet_election_provider_multi_phase::MinerConfig for Runtime {
Expand Down Expand Up @@ -494,9 +494,8 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
type BenchmarkingConfig = runtime_common::elections::BenchmarkConfig;
type ForceOrigin = EitherOf<EnsureRoot<Self::AccountId>, StakingAdmin>;
type WeightInfo = weights::pallet_election_provider_multi_phase::WeightInfo<Self>;
type MaxElectingVoters = MaxElectingVoters;
type MaxElectableTargets = MaxElectableTargets;
type MaxWinners = MaxActiveValidators;
type ElectionBounds = ElectionBounds;
}

parameter_types! {
Expand Down Expand Up @@ -563,7 +562,6 @@ parameter_types! {
}

impl pallet_staking::Config for Runtime {
type MaxNominations = MaxNominations;
type Currency = Balances;
type CurrencyBalance = Balance;
type UnixTime = Timestamp;
Expand All @@ -585,6 +583,7 @@ impl pallet_staking::Config for Runtime {
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type VoterList = VoterList;
type TargetList = UseValidatorsMap<Self>;
type NominationsQuota = pallet_staking::FixedNominationsQuota<{ MaxNominations::get() }>;
type MaxUnlockingChunks = frame_support::traits::ConstU32<32>;
type HistoryDepth = frame_support::traits::ConstU32<84>;
type BenchmarkingConfig = runtime_common::StakingBenchmarkingConfig;
Expand Down
21 changes: 11 additions & 10 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ use runtime_parachains::{

use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::crypto::{AuthorityId as BeefyId, Signature as BeefySignature};
use frame_election_provider_support::{generate_solution_type, onchain, SequentialPhragmen};
use frame_election_provider_support::{
generate_solution_type, onchain, ElectionBoundsBuilder, SequentialPhragmen,
};
use frame_support::{
construct_runtime, parameter_types,
traits::{
Expand Down Expand Up @@ -394,11 +396,12 @@ parameter_types! {
// 4 hour session, 1 hour unsigned phase, 32 offchain executions.
pub OffchainRepeat: BlockNumber = UnsignedPhase::get() / 32;

/// We take the top 22500 nominators as electing voters..
pub const MaxElectingVoters: u32 = 22_500;
/// ... and all of the validators as electable targets. Whilst this is the case, we cannot and
/// shall not increase the size of the validator intentions.
pub const MaxElectableTargets: u16 = u16::MAX;
/// We take the top 22500 nominators as electing voters and all of the validators as electable
/// targets. Whilst this is the case, we cannot and shall not increase the size of the
/// validator intentions.
pub ElectionBounds: frame_election_provider_support::ElectionBounds =
ElectionBoundsBuilder::new().voters_count(MaxElectingVoters::get()).build();
/// Setup election pallet to support maximum winners upto 1200. This will mean Staking Pallet
/// cannot have active validators higher than this count.
pub const MaxActiveValidators: u32 = 1200;
Expand All @@ -421,8 +424,7 @@ impl onchain::Config for OnChainSeqPhragmen {
type DataProvider = Staking;
type WeightInfo = weights::frame_election_provider_support::WeightInfo<Runtime>;
type MaxWinners = MaxActiveValidators;
type VotersBound = MaxElectingVoters;
type TargetsBound = MaxElectableTargets;
type ElectionBounds = ElectionBounds;
}

impl pallet_election_provider_multi_phase::MinerConfig for Runtime {
Expand Down Expand Up @@ -490,9 +492,8 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 2, 3>,
>;
type WeightInfo = weights::pallet_election_provider_multi_phase::WeightInfo<Self>;
type MaxElectingVoters = MaxElectingVoters;
type MaxElectableTargets = MaxElectableTargets;
type MaxWinners = MaxActiveValidators;
type ElectionBounds = ElectionBounds;
}

parameter_types! {
Expand Down Expand Up @@ -580,7 +581,6 @@ impl pallet_staking::EraPayout<Balance> for EraPayout {
}

impl pallet_staking::Config for Runtime {
type MaxNominations = MaxNominations;
type Currency = Balances;
type CurrencyBalance = Balance;
type UnixTime = Timestamp;
Expand All @@ -602,6 +602,7 @@ impl pallet_staking::Config for Runtime {
type GenesisElectionProvider = onchain::OnChainExecution<OnChainSeqPhragmen>;
type VoterList = VoterList;
type TargetList = UseValidatorsMap<Self>;
type NominationsQuota = pallet_staking::FixedNominationsQuota<{ MaxNominations::get() }>;
type MaxUnlockingChunks = frame_support::traits::ConstU32<32>;
type HistoryDepth = frame_support::traits::ConstU32<84>;
type BenchmarkingConfig = runtime_common::StakingBenchmarkingConfig;
Expand Down
19 changes: 9 additions & 10 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::crypto::{AuthorityId as BeefyId, Signature as BeefySignature};
use frame_election_provider_support::{onchain, SequentialPhragmen};
use frame_election_provider_support::{onchain, ElectionBoundsBuilder, SequentialPhragmen};
use frame_support::{
construct_runtime, parameter_types,
traits::{ConstU32, InstanceFilter, KeyOwnerProofSystem, WithdrawReasons},
Expand Down Expand Up @@ -359,11 +359,12 @@ parameter_types! {
// 1 hour session, 15 minutes unsigned phase, 4 offchain executions.
pub OffchainRepeat: BlockNumber = UnsignedPhase::get() / 4;

/// We take the top 22500 nominators as electing voters..
pub const MaxElectingVoters: u32 = 22_500;
/// ... and all of the validators as electable targets. Whilst this is the case, we cannot and
/// shall not increase the size of the validator intentions.
pub const MaxElectableTargets: u16 = u16::MAX;
/// We take the top 22500 nominators as electing voters and all of the validators as electable
/// targets. Whilst this is the case, we cannot and shall not increase the size of the
/// validator intentions.
pub ElectionBounds: frame_election_provider_support::ElectionBounds =
ElectionBoundsBuilder::new().voters_count(MaxElectingVoters::get()).build();
// Maximum winners that can be chosen as active validators
pub const MaxActiveValidators: u32 = 1000;

Expand All @@ -386,8 +387,7 @@ impl onchain::Config for OnChainSeqPhragmen {
type DataProvider = Staking;
type WeightInfo = weights::frame_election_provider_support::WeightInfo<Runtime>;
type MaxWinners = MaxActiveValidators;
type VotersBound = MaxElectingVoters;
type TargetsBound = MaxElectableTargets;
type ElectionBounds = ElectionBounds;
}

impl pallet_election_provider_multi_phase::MinerConfig for Runtime {
Expand Down Expand Up @@ -452,9 +452,8 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
type BenchmarkingConfig = runtime_common::elections::BenchmarkConfig;
type ForceOrigin = EnsureRoot<AccountId>;
type WeightInfo = weights::pallet_election_provider_multi_phase::WeightInfo<Self>;
type MaxElectingVoters = MaxElectingVoters;
type MaxElectableTargets = MaxElectableTargets;
type MaxWinners = MaxActiveValidators;
type ElectionBounds = ElectionBounds;
}

parameter_types! {
Expand Down Expand Up @@ -495,7 +494,6 @@ parameter_types! {
}

impl pallet_staking::Config for Runtime {
type MaxNominations = MaxNominations;
type Currency = Balances;
type CurrencyBalance = Balance;
type UnixTime = Timestamp;
Expand All @@ -517,6 +515,7 @@ impl pallet_staking::Config for Runtime {
type GenesisElectionProvider = onchain::OnChainExecution<OnChainSeqPhragmen>;
type VoterList = VoterList;
type TargetList = UseValidatorsMap<Self>;
type NominationsQuota = pallet_staking::FixedNominationsQuota<{ MaxNominations::get() }>;
type MaxUnlockingChunks = frame_support::traits::ConstU32<32>;
type HistoryDepth = frame_support::traits::ConstU32<84>;
type BenchmarkingConfig = runtime_common::StakingBenchmarkingConfig;
Expand Down