Update Staking Weights (#5964)

This commit is contained in:
Shawn Tabrizi
2020-05-15 11:07:19 +02:00
committed by GitHub
parent 27250681bf
commit 71d3abe7d4
8 changed files with 654 additions and 130 deletions
+15 -3
View File
@@ -27,7 +27,7 @@ use frame_support::{
assert_ok, impl_outer_origin, parameter_types, impl_outer_dispatch, impl_outer_event,
StorageValue, StorageMap, StorageDoubleMap, IterableStorageMap,
traits::{Currency, Get, FindAuthor, OnFinalize, OnInitialize},
weights::Weight,
weights::{Weight, constants::RocksDbWeight},
};
use sp_io;
use sp_phragmen::{
@@ -36,7 +36,7 @@ use sp_phragmen::{
};
use crate::*;
const INIT_TIMESTAMP: u64 = 30_000;
pub const INIT_TIMESTAMP: u64 = 30_000;
/// The AccountId alias in this test module.
pub(crate) type AccountId = u64;
@@ -211,7 +211,7 @@ impl frame_system::Trait for Test {
type Event = MetaEvent;
type BlockHashCount = BlockHashCount;
type MaximumBlockWeight = MaximumBlockWeight;
type DbWeight = ();
type DbWeight = RocksDbWeight;
type BlockExecutionWeight = ();
type ExtrinsicBaseWeight = ();
type AvailableBlockRatio = AvailableBlockRatio;
@@ -763,6 +763,18 @@ pub(crate) fn on_offence_now(
on_offence_in_era(offenders, slash_fraction, now)
}
pub(crate) fn add_slash(who: &AccountId) {
on_offence_now(
&[
OffenceDetails {
offender: (who.clone(), Staking::eras_stakers(Staking::active_era().unwrap().index, who.clone())),
reporters: vec![],
},
],
&[Perbill::from_percent(10)],
);
}
// winners will be chosen by simply their unweighted total backing stake. Nominator stake is
// distributed evenly.
pub(crate) fn horrible_phragmen_with_post_processing(