mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 18:11:03 +00:00
Disable equalize, avoiding consensus issue (#4608)
* Disable equalize, avoiding consensus issue * Update frame/staking/Cargo.toml Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -27,9 +27,8 @@ pallet-staking-reward-curve = { version = "2.0.0", path = "../staking/reward-cu
|
|||||||
substrate-test-utils = { version = "2.0.0", path = "../../test-utils" }
|
substrate-test-utils = { version = "2.0.0", path = "../../test-utils" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
equalize = []
|
|
||||||
migrate = []
|
migrate = []
|
||||||
default = ["std", "equalize"]
|
default = ["std"]
|
||||||
std = [
|
std = [
|
||||||
"serde",
|
"serde",
|
||||||
"safe-mix/std",
|
"safe-mix/std",
|
||||||
|
|||||||
@@ -1519,40 +1519,6 @@ impl<T: Trait> Module<T> {
|
|||||||
Self::slashable_balance_of,
|
Self::slashable_balance_of,
|
||||||
);
|
);
|
||||||
|
|
||||||
if cfg!(feature = "equalize") {
|
|
||||||
let mut staked_assignments
|
|
||||||
: Vec<(T::AccountId, Vec<PhragmenStakedAssignment<T::AccountId>>)>
|
|
||||||
= Vec::with_capacity(assignments.len());
|
|
||||||
for (n, assignment) in assignments.iter() {
|
|
||||||
let mut staked_assignment
|
|
||||||
: Vec<PhragmenStakedAssignment<T::AccountId>>
|
|
||||||
= Vec::with_capacity(assignment.len());
|
|
||||||
|
|
||||||
// If this is a self vote, then we don't need to equalise it at all. While the
|
|
||||||
// staking system does not allow nomination and validation at the same time,
|
|
||||||
// this must always be 100% support.
|
|
||||||
if assignment.len() == 1 && assignment[0].0 == *n {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (c, per_thing) in assignment.iter() {
|
|
||||||
let nominator_stake = to_votes(Self::slashable_balance_of(n));
|
|
||||||
let other_stake = *per_thing * nominator_stake;
|
|
||||||
staked_assignment.push((c.clone(), other_stake));
|
|
||||||
}
|
|
||||||
staked_assignments.push((n.clone(), staked_assignment));
|
|
||||||
}
|
|
||||||
|
|
||||||
let tolerance = 0_u128;
|
|
||||||
let iterations = 2_usize;
|
|
||||||
sp_phragmen::equalize::<_, _, T::CurrencyToVote, _>(
|
|
||||||
staked_assignments,
|
|
||||||
&mut supports,
|
|
||||||
tolerance,
|
|
||||||
iterations,
|
|
||||||
Self::slashable_balance_of,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear Stakers.
|
// Clear Stakers.
|
||||||
for v in Self::current_elected().iter() {
|
for v in Self::current_elected().iter() {
|
||||||
<Stakers<T>>::remove(v);
|
<Stakers<T>>::remove(v);
|
||||||
|
|||||||
Reference in New Issue
Block a user