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

Commit

Permalink
reduce slash defer durations (#1504)
Browse files Browse the repository at this point in the history
* reduce slash defer durations

* update comments

* tests
  • Loading branch information
rphmeier authored Jul 30, 2020
1 parent f772196 commit 4566ff6
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 8 deletions.
19 changes: 16 additions & 3 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("kusama"),
impl_name: create_runtime_str!("parity-kusama"),
authoring_version: 2,
spec_version: 2022,
spec_version: 2023,
impl_version: 0,
#[cfg(not(feature = "disable-runtime-api"))]
apis: RUNTIME_API_VERSIONS,
Expand Down Expand Up @@ -317,8 +317,8 @@ parameter_types! {
pub const SessionsPerEra: SessionIndex = 6;
// 28 eras for unbonding (7 days).
pub const BondingDuration: staking::EraIndex = 28;
// 28 eras in which slashes can be cancelled (7 days).
pub const SlashDeferDuration: staking::EraIndex = 28;
// 27 eras in which slashes can be cancelled (slightly less than 7 days).
pub const SlashDeferDuration: staking::EraIndex = 27;
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
pub const MaxNominatorRewardedPerValidator: u32 = 64;
// quarter of the last session will be for election.
Expand Down Expand Up @@ -1337,3 +1337,16 @@ sp_api::impl_runtime_apis! {
}
}
}

#[cfg(test)]
mod tests {
use super::Runtime;

#[test]
fn slash_defer_less_than_bonding_duration() {
assert!(
<Runtime as staking::Trait>::SlashDeferDuration::get()
< <Runtime as staking::Trait>::BondingDuration::get()
);
}
}
17 changes: 15 additions & 2 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("polkadot"),
impl_name: create_runtime_str!("parity-polkadot"),
authoring_version: 0,
spec_version: 22,
spec_version: 23,
impl_version: 0,
#[cfg(not(feature = "disable-runtime-api"))]
apis: RUNTIME_API_VERSIONS,
Expand Down Expand Up @@ -329,7 +329,7 @@ parameter_types! {
pub const SessionsPerEra: SessionIndex = 6;
// 28 eras for unbonding (28 days).
pub const BondingDuration: staking::EraIndex = 28;
pub const SlashDeferDuration: staking::EraIndex = 28;
pub const SlashDeferDuration: staking::EraIndex = 27;
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
pub const MaxNominatorRewardedPerValidator: u32 = 64;
// last 15 minutes of the last session will be for election.
Expand Down Expand Up @@ -1475,3 +1475,16 @@ sp_api::impl_runtime_apis! {
}
}
}

#[cfg(test)]
mod tests {
use super::Runtime;

#[test]
fn slash_defer_less_than_bonding_duration() {
assert!(
<Runtime as staking::Trait>::SlashDeferDuration::get()
< <Runtime as staking::Trait>::BondingDuration::get()
);
}
}
19 changes: 16 additions & 3 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("westend"),
impl_name: create_runtime_str!("parity-westend"),
authoring_version: 2,
spec_version: 42,
spec_version: 43,
impl_version: 0,
#[cfg(not(feature = "disable-runtime-api"))]
apis: RUNTIME_API_VERSIONS,
Expand Down Expand Up @@ -294,8 +294,8 @@ parameter_types! {
pub const SessionsPerEra: SessionIndex = 6;
// 28 eras for unbonding (7 days).
pub const BondingDuration: staking::EraIndex = 28;
// 28 eras in which slashes can be cancelled (7 days).
pub const SlashDeferDuration: staking::EraIndex = 28;
// 27 eras in which slashes can be cancelled (slightly less than 7 days).
pub const SlashDeferDuration: staking::EraIndex = 27;
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
pub const MaxNominatorRewardedPerValidator: u32 = 64;
// quarter of the last session will be for election.
Expand Down Expand Up @@ -1113,3 +1113,16 @@ sp_api::impl_runtime_apis! {
}
}
}

#[cfg(test)]
mod tests {
use super::Runtime;

#[test]
fn slash_defer_less_than_bonding_duration() {
assert!(
<Runtime as staking::Trait>::SlashDeferDuration::get()
< <Runtime as staking::Trait>::BondingDuration::get()
);
}
}

0 comments on commit 4566ff6

Please sign in to comment.