mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 05:51:02 +00:00
Create trait for NPoS election algorithms (#9664)
* build the template, hand it over to zeke now. * Tests working * save wip * Some updates * Some cleanup * mo cleanin * Link to issue * Apply suggestions from code review Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Bound accuracy for prepare_election_result * Use npos_election::Error for phragmms * save * Apply suggestions from code review * Simplify test to use Balancing::set * Cargo.lock after build * Revert "Cargo.lock after build" This reverts commit 7d726c8efa687c09e4f377196b106eb9e9760487. * Try reduce cargo.lock diff * Update bin/node/runtime/src/lib.rs * Comment * Apply suggestions from code review * Set balancing directly * Document som pub items * Update frame/election-provider-multi-phase/src/unsigned.rs * Apply suggestions from code review Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Improve some comments * Revert accidental change to random file * tiney * revert Co-authored-by: kianenigma <kian@parity.io> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
|
||||
use super::*;
|
||||
use crate as multi_phase;
|
||||
use frame_election_provider_support::{data_provider, ElectionDataProvider};
|
||||
use frame_election_provider_support::{data_provider, ElectionDataProvider, SequentialPhragmen};
|
||||
pub use frame_support::{assert_noop, assert_ok};
|
||||
use frame_support::{parameter_types, traits::Hooks, weights::Weight};
|
||||
use multi_phase::unsigned::{IndexAssignmentOf, Voter};
|
||||
@@ -31,7 +31,7 @@ use sp_core::{
|
||||
};
|
||||
use sp_npos_elections::{
|
||||
assignment_ratio_to_staked_normalized, seq_phragmen, to_supports, to_without_backing,
|
||||
ElectionResult, EvaluateSupport, NposSolution,
|
||||
ElectionResult, EvaluateSupport, ExtendedBalance, NposSolution,
|
||||
};
|
||||
use sp_runtime::{
|
||||
testing::Header,
|
||||
@@ -262,7 +262,6 @@ parameter_types! {
|
||||
pub static SignedDepositWeight: Balance = 0;
|
||||
pub static SignedRewardBase: Balance = 7;
|
||||
pub static SignedMaxWeight: Weight = BlockWeights::get().max_block;
|
||||
pub static MinerMaxIterations: u32 = 5;
|
||||
pub static MinerTxPriority: u64 = 100;
|
||||
pub static SolutionImprovementThreshold: Perbill = Perbill::zero();
|
||||
pub static OffchainRepeat: BlockNumber = 5;
|
||||
@@ -352,6 +351,10 @@ impl multi_phase::weights::WeightInfo for DualMockWeightInfo {
|
||||
}
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub static Balancing: Option<(usize, ExtendedBalance)> = Some((0, 0));
|
||||
}
|
||||
|
||||
impl crate::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Currency = Balances;
|
||||
@@ -360,7 +363,6 @@ impl crate::Config for Runtime {
|
||||
type UnsignedPhase = UnsignedPhase;
|
||||
type SolutionImprovementThreshold = SolutionImprovementThreshold;
|
||||
type OffchainRepeat = OffchainRepeat;
|
||||
type MinerMaxIterations = MinerMaxIterations;
|
||||
type MinerMaxWeight = MinerMaxWeight;
|
||||
type MinerMaxLength = MinerMaxLength;
|
||||
type MinerTxPriority = MinerTxPriority;
|
||||
@@ -379,6 +381,7 @@ impl crate::Config for Runtime {
|
||||
type Fallback = Fallback;
|
||||
type ForceOrigin = frame_system::EnsureRoot<AccountId>;
|
||||
type Solution = TestNposSolution;
|
||||
type Solver = SequentialPhragmen<AccountId, SolutionAccuracyOf<Runtime>, Balancing>;
|
||||
}
|
||||
|
||||
impl<LocalCall> frame_system::offchain::SendTransactionTypes<LocalCall> for Runtime
|
||||
|
||||
Reference in New Issue
Block a user