diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index e3b24178729f..d790d3c5bb10 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -21,6 +21,7 @@ sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master sp-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-npos-elections = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-authorship = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } @@ -84,6 +85,7 @@ std = [ "pallet-transaction-payment/std", "runtime-parachains/std", "xcm/std", + "sp-npos-elections/std", ] runtime-benchmarks = [ "libsecp256k1/hmac", diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 2f62eb956606..b112a7afe989 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -129,6 +129,22 @@ pub type SlowAdjustingFeeUpdate = TargetedFeeAdjustment< pub type CurrencyToVote = frame_support::traits::U128CurrencyToVote; static_assertions::assert_eq_size!(primitives::v1::Balance, u128); +/// The a solution for staking solutions that allows 24 nominators per validator. +pub mod npos_solution { + use sp_std::prelude::*; + + /// The nominator index type. + pub type NominatorIndex = u32; + /// The validator index type. + pub type ValidatorIndex = u16; + /// The accuracy type of the solution. + pub type Accuracy = sp_runtime::PerU16; + + sp_npos_elections::generate_solution_type!{ + pub struct CompactSolution24::(24) + } +} + /// A placeholder since there is currently no provided session key handler for parachain validator /// keys. pub struct ParachainSessionKeyPlaceholder(sp_std::marker::PhantomData); diff --git a/runtime/common/src/paras_registrar.rs b/runtime/common/src/paras_registrar.rs index e9e3c3c234b7..1ad8880dd5c1 100644 --- a/runtime/common/src/paras_registrar.rs +++ b/runtime/common/src/paras_registrar.rs @@ -422,6 +422,7 @@ mod tests { type MaxIterations = (); type MinSolutionScoreBump = (); type OffchainSolutionWeightLimit = (); + type CompactSolution = pallet_staking::default_solution::CompactSolution24; type WeightInfo = (); } diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 5a9b6de5172f..4b8b65988865 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -390,6 +390,7 @@ impl pallet_staking::Config for Runtime { // The unsigned solution weight targeted by the OCW. We set it to the maximum possible value of // a single extrinsic. type OffchainSolutionWeightLimit = OffchainSolutionWeightLimit; + type CompactSolution = runtime_common::npos_solution::CompactSolution24; type WeightInfo = weights::pallet_staking::WeightInfo; } diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index f37139321d01..344ae0f5d419 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -398,6 +398,7 @@ impl pallet_staking::Config for Runtime { // The unsigned solution weight targeted by the OCW. We set it to the maximum possible value of // a single extrinsic. type OffchainSolutionWeightLimit = OffchainSolutionWeightLimit; + type CompactSolution = runtime_common::npos_solution::CompactSolution24; type WeightInfo = weights::pallet_staking::WeightInfo; } diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 11e47862c7e7..0d32a0cd727a 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -332,6 +332,7 @@ impl pallet_staking::Config for Runtime { type MaxIterations = MaxIterations; type OffchainSolutionWeightLimit = (); type MinSolutionScoreBump = MinSolutionScoreBump; + type CompactSolution = pallet_staking::default_solution::CompactSolution24; type WeightInfo = (); } diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 50fc291cee45..d59b5592311c 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -368,6 +368,7 @@ impl pallet_staking::Config for Runtime { type MaxIterations = MaxIterations; type MinSolutionScoreBump = MinSolutionScoreBump; type OffchainSolutionWeightLimit = OffchainSolutionWeightLimit; + type CompactSolution = runtime_common::npos_solution::CompactSolution24; type WeightInfo = weights::pallet_staking::WeightInfo; }