Skip to content

Commit cd9dafd

Browse files
committed
[pallet_staking] adapt paritytech/polkadot-sdk#1189
1 parent a245c88 commit cd9dafd

2 files changed

Lines changed: 32 additions & 16 deletions

File tree

relay/kusama/src/lib.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ impl pallet_babe::Config for Runtime {
297297
type WeightInfo = ();
298298

299299
type MaxAuthorities = MaxAuthorities;
300-
type MaxNominators = MaxNominatorRewardedPerValidator;
300+
type MaxNominators = MaxNominators;
301301
}
302302

303303
parameter_types! {
@@ -342,7 +342,7 @@ parameter_types! {
342342
impl pallet_beefy::Config for Runtime {
343343
type BeefyId = BeefyId;
344344
type MaxAuthorities = MaxAuthorities;
345-
type MaxNominators = MaxNominatorRewardedPerValidator;
345+
type MaxNominators = MaxNominators;
346346
type MaxSetIdSessionEntries = BeefySetIdSessionEntries;
347347
type OnNewValidatorSet = BeefyMmrLeaf;
348348
type WeightInfo = ();
@@ -655,7 +655,12 @@ parameter_types! {
655655
27,
656656
"DOT_SLASH_DEFER_DURATION"
657657
);
658-
pub const MaxNominatorRewardedPerValidator: u32 = 512;
658+
// TODO:(PR#137) - check MaxExposurePageSize/MaxNominators 512?
659+
pub const MaxExposurePageSize: u32 = 512;
660+
// Note: this is not really correct as Max Nominators is (MaxExposurePageSize * page_count) but
661+
// this is an unbounded number. We just set it to a reasonably high value, 1 full page
662+
// of nominators.
663+
pub const MaxNominators: u32 = 512;
659664
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17);
660665
// 24
661666
pub const MaxNominations: u32 = <NposCompactSolution24 as NposSolution>::LIMIT as u32;
@@ -679,7 +684,7 @@ impl pallet_staking::Config for Runtime {
679684
type SessionInterface = Self;
680685
type EraPayout = EraPayout;
681686
type NextNewSession = Session;
682-
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
687+
type MaxExposurePageSize = MaxExposurePageSize;
683688
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
684689
type VoterList = VoterList;
685690
type TargetList = UseValidatorsMap<Self>;
@@ -699,8 +704,6 @@ impl pallet_fast_unstake::Config for Runtime {
699704
type ControlOrigin = EnsureRoot<AccountId>;
700705
type Staking = Staking;
701706
type MaxErasToCheckPerBlock = ConstU32<1>;
702-
#[cfg(feature = "runtime-benchmarks")]
703-
type MaxBackersPerValidator = MaxNominatorRewardedPerValidator;
704707
type WeightInfo = weights::pallet_fast_unstake::WeightInfo<Runtime>;
705708
}
706709

@@ -835,7 +838,7 @@ impl pallet_grandpa::Config for Runtime {
835838

836839
type WeightInfo = ();
837840
type MaxAuthorities = MaxAuthorities;
838-
type MaxNominators = MaxNominatorRewardedPerValidator;
841+
type MaxNominators = MaxNominators;
839842
type MaxSetIdSessionEntries = MaxSetIdSessionEntries;
840843

841844
type KeyOwnerProof = <Historical as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;
@@ -1680,6 +1683,7 @@ pub mod migrations {
16801683
pub type Unreleased = (
16811684
pallet_nomination_pools::migration::versioned::V5toV6<Runtime>,
16821685
pallet_nomination_pools::migration::versioned::V6ToV7<Runtime>,
1686+
pallet_staking::migrations::v14::MigrateToV14<Runtime>,
16831687
);
16841688
}
16851689

@@ -2226,10 +2230,14 @@ sp_api::impl_runtime_apis! {
22262230
}
22272231
}
22282232

2229-
impl pallet_staking_runtime_api::StakingApi<Block, Balance> for Runtime {
2233+
impl pallet_staking_runtime_api::StakingApi<Block, Balance, AccountId> for Runtime {
22302234
fn nominations_quota(balance: Balance) -> u32 {
22312235
Staking::api_nominations_quota(balance)
22322236
}
2237+
2238+
fn eras_stakers_page_count(era: sp_staking::EraIndex, account: AccountId) -> sp_staking::Page {
2239+
Staking::api_eras_stakers_page_count(era, account)
2240+
}
22332241
}
22342242

22352243
impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {

relay/polkadot/src/lib.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ impl pallet_babe::Config for Runtime {
279279
type WeightInfo = ();
280280

281281
type MaxAuthorities = MaxAuthorities;
282-
type MaxNominators = MaxNominatorRewardedPerValidator;
282+
type MaxNominators = MaxNominators;
283283

284284
type KeyOwnerProof =
285285
<Historical as KeyOwnerProofSystem<(KeyTypeId, pallet_babe::AuthorityId)>>::Proof;
@@ -330,7 +330,7 @@ parameter_types! {
330330
impl pallet_beefy::Config for Runtime {
331331
type BeefyId = BeefyId;
332332
type MaxAuthorities = MaxAuthorities;
333-
type MaxNominators = MaxNominatorRewardedPerValidator;
333+
type MaxNominators = MaxNominators;
334334
type MaxSetIdSessionEntries = BeefySetIdSessionEntries;
335335
type OnNewValidatorSet = BeefyMmrLeaf;
336336
type WeightInfo = ();
@@ -667,7 +667,12 @@ parameter_types! {
667667
"DOT_SLASH_DEFER_DURATION"
668668
);
669669
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
670-
pub const MaxNominatorRewardedPerValidator: u32 = 512;
670+
// TODO:(PR#137) - check MaxExposurePageSize/MaxNominators 512?
671+
pub const MaxExposurePageSize: u32 = 512;
672+
// Note: this is not really correct as Max Nominators is (MaxExposurePageSize * page_count) but
673+
// this is an unbounded number. We just set it to a reasonably high value, 1 full page
674+
// of nominators.
675+
pub const MaxNominators: u32 = 512;
671676
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17);
672677
// 16
673678
pub const MaxNominations: u32 = <NposCompactSolution16 as frame_election_provider_support::NposSolution>::LIMIT as u32;
@@ -764,7 +769,7 @@ impl pallet_staking::Config for Runtime {
764769
type AdminOrigin = EitherOf<EnsureRoot<Self::AccountId>, StakingAdmin>;
765770
type SessionInterface = Self;
766771
type EraPayout = EraPayout;
767-
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
772+
type MaxExposurePageSize = MaxExposurePageSize;
768773
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
769774
type NextNewSession = Session;
770775
type ElectionProvider = ElectionProviderMultiPhase;
@@ -787,8 +792,6 @@ impl pallet_fast_unstake::Config for Runtime {
787792
type ControlOrigin = EnsureRoot<AccountId>;
788793
type Staking = Staking;
789794
type MaxErasToCheckPerBlock = ConstU32<1>;
790-
#[cfg(feature = "runtime-benchmarks")]
791-
type MaxBackersPerValidator = MaxNominatorRewardedPerValidator;
792795
type WeightInfo = weights::pallet_fast_unstake::WeightInfo<Runtime>;
793796
}
794797

@@ -950,7 +953,7 @@ impl pallet_grandpa::Config for Runtime {
950953

951954
type WeightInfo = ();
952955
type MaxAuthorities = MaxAuthorities;
953-
type MaxNominators = MaxNominatorRewardedPerValidator;
956+
type MaxNominators = MaxNominators;
954957
type MaxSetIdSessionEntries = MaxSetIdSessionEntries;
955958

956959
type KeyOwnerProof = <Historical as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;
@@ -1702,6 +1705,7 @@ pub mod migrations {
17021705
UpgradeSessionKeys,
17031706
pallet_nomination_pools::migration::versioned::V5toV6<Runtime>,
17041707
pallet_nomination_pools::migration::versioned::V6ToV7<Runtime>,
1708+
pallet_staking::migrations::v14::MigrateToV14<Runtime>,
17051709
);
17061710
}
17071711

@@ -1845,10 +1849,14 @@ sp_api::impl_runtime_apis! {
18451849
}
18461850
}
18471851

1848-
impl pallet_staking_runtime_api::StakingApi<Block, Balance> for Runtime {
1852+
impl pallet_staking_runtime_api::StakingApi<Block, Balance, AccountId> for Runtime {
18491853
fn nominations_quota(balance: Balance) -> u32 {
18501854
Staking::api_nominations_quota(balance)
18511855
}
1856+
1857+
fn eras_stakers_page_count(era: sp_staking::EraIndex, account: AccountId) -> sp_staking::Page {
1858+
Staking::api_eras_stakers_page_count(era, account)
1859+
}
18521860
}
18531861

18541862
impl tx_pool_api::runtime_api::TaggedTransactionQueue<Block> for Runtime {

0 commit comments

Comments
 (0)