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

companion for substrate/pull/7929 (24 nominators) #2417

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
1,504 changes: 778 additions & 726 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -84,6 +85,7 @@ std = [
"pallet-transaction-payment/std",
"runtime-parachains/std",
"xcm/std",
"sp-npos-elections/std",
]
runtime-benchmarks = [
"libsecp256k1/hmac",
Expand Down
16 changes: 16 additions & 0 deletions runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,22 @@ pub type SlowAdjustingFeeUpdate<R> = 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::<NominatorIndex, ValidatorIndex, Accuracy>(24)
}
}

/// A placeholder since there is currently no provided session key handler for parachain validator
/// keys.
pub struct ParachainSessionKeyPlaceholder<T>(sp_std::marker::PhantomData<T>);
Expand Down
1 change: 1 addition & 0 deletions runtime/common/src/paras_registrar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ mod tests {
type MaxIterations = ();
type MinSolutionScoreBump = ();
type OffchainSolutionWeightLimit = ();
type CompactSolution = pallet_staking::default_solution::CompactSolution24;
type WeightInfo = ();
}

Expand Down
1 change: 1 addition & 0 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Runtime>;
}

Expand Down
1 change: 1 addition & 0 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Runtime>;
}

Expand Down
1 change: 1 addition & 0 deletions runtime/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ();

}
Expand Down
1 change: 1 addition & 0 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Runtime>;
}

Expand Down