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

Phragmén Validator Election #1915

Merged
merged 27 commits into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Bump and update wasm.
  • Loading branch information
kianenigma committed Mar 14, 2019
commit 3bd69ef8ce2c52e1b74208025a6a3149312e01ac
2 changes: 1 addition & 1 deletion node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_name: create_runtime_str!("substrate-node"),
authoring_version: 10,
spec_version: 35,
impl_version: 35,
impl_version: 36,
apis: RUNTIME_API_VERSIONS,
};

Expand Down
Binary file not shown.
4 changes: 1 addition & 3 deletions srml/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,6 @@ decl_storage! {
config(stakers): Vec<(T::AccountId, T::AccountId, BalanceOf<T>, StakerStatus<T::AccountId>)>;
build(|storage: &mut primitives::StorageOverlay, _: &mut primitives::ChildrenStorageOverlay, config: &GenesisConfig<T>| {
with_storage(storage, || {
println!("Staker: {:?}", config.stakers);

for &(ref stash, ref controller, balance, ref status) in &config.stakers {
let _ = <Module<T>>::bond(
T::Origin::from(Some(stash.clone()).into()),
Expand Down Expand Up @@ -695,7 +693,7 @@ impl<T: Trait> Module<T> {
<SlashCount<T>>::insert(v, slash_count - 1);
}
}
println!("Elected : {:?}", elected_candidates);

// Populate Stakers.
for candidate in &elected_candidates {
<Stakers<T>>::insert(candidate.who.clone(), candidate.exposure.clone());
Expand Down
3 changes: 0 additions & 3 deletions srml/staking/src/phragmen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,12 @@ pub fn elect<T: Trait + 'static, FR, FN, FV, FS>(
load : Perquintill::zero(),
}
}).collect::<Vec<Nominations<T::AccountId, BalanceOf<T>>>>();

println!("nom: {:?}", nominations);

// 3- optimization:
// Candidates who have 0 stake => have no votes or all null-votes. Kick them out not.
let mut candidates = candidates.into_iter().filter(|c| c.approval_stake > BalanceOf::<T>::zero())
.collect::<Vec<Candidate<T::AccountId, BalanceOf<T>>>>();

println!("candidates: {:?}", candidates);
// 4- If we have more candidates then needed, run Phragmén.
if candidates.len() > rounds {
// Main election loop
Expand Down