mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 10:31:04 +00:00
Offences Weight for OnInitialize (#5961)
* Weight accounting for on_offence. * Try to compute weight. * Guesstimate upper bounds on db read/writes for slashing * greater than or equal to * add new trait * Update mock.rs * Add basic weight test * one more test * Update frame/staking/src/lib.rs Co-authored-by: thiolliere <gui.thiolliere@gmail.com> * Update frame/staking/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Add test for offences queue Co-authored-by: Tomasz Drwięga <tomasz@parity.io> Co-authored-by: thiolliere <gui.thiolliere@gmail.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -20,7 +20,10 @@
|
||||
#![cfg(test)]
|
||||
|
||||
use super::*;
|
||||
use frame_support::parameter_types;
|
||||
use frame_support::{
|
||||
parameter_types,
|
||||
weights::{Weight, constants::WEIGHT_PER_SECOND},
|
||||
};
|
||||
use frame_system as system;
|
||||
use sp_runtime::{
|
||||
SaturatedConversion,
|
||||
@@ -34,6 +37,10 @@ type AccountIndex = u32;
|
||||
type BlockNumber = u64;
|
||||
type Balance = u64;
|
||||
|
||||
parameter_types! {
|
||||
pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;
|
||||
}
|
||||
|
||||
impl frame_system::Trait for Test {
|
||||
type Origin = Origin;
|
||||
type Index = AccountIndex;
|
||||
@@ -46,7 +53,7 @@ impl frame_system::Trait for Test {
|
||||
type Header = sp_runtime::testing::Header;
|
||||
type Event = Event;
|
||||
type BlockHashCount = ();
|
||||
type MaximumBlockWeight = ();
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type AvailableBlockRatio = ();
|
||||
type MaximumBlockLength = ();
|
||||
@@ -179,10 +186,15 @@ impl pallet_im_online::Trait for Test {
|
||||
type UnsignedPriority = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
|
||||
}
|
||||
|
||||
impl pallet_offences::Trait for Test {
|
||||
type Event = Event;
|
||||
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
|
||||
type OnOffenceHandler = Staking;
|
||||
type WeightSoftLimit = OffencesWeightSoftLimit;
|
||||
}
|
||||
|
||||
impl<T> frame_system::offchain::SendTransactionTypes<T> for Test where Call: From<T> {
|
||||
|
||||
Reference in New Issue
Block a user