Skip to content

Commit 125dac3

Browse files
committed
fix: allow fast unstaking for all (#902)
Allows unstaking for all collator candidates and delegators in the staking pallet with minimum delay. Also prevents additional candidates or delegators from joining, and existing ones from increasing their stake.
1 parent 2cb151c commit 125dac3

3 files changed

Lines changed: 26 additions & 11 deletions

File tree

runtimes/common/src/constants.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,7 @@ pub mod staking {
255255
#[cfg(not(feature = "fast-gov"))]
256256
pub const DEFAULT_BLOCKS_PER_ROUND: BlockNumber = 2 * HOURS;
257257

258-
#[cfg(feature = "fast-gov")]
259-
pub const STAKE_DURATION: BlockNumber = 30;
260-
#[cfg(not(feature = "fast-gov"))]
261-
pub const STAKE_DURATION: BlockNumber = 7 * DAYS;
258+
pub const STAKE_DURATION: BlockNumber = 1;
262259

263260
#[cfg(feature = "fast-gov")]
264261
pub const MIN_COLLATORS: u32 = 4;
@@ -289,7 +286,7 @@ pub mod staking {
289286
/// Minimum 16 collators selected per round, default at genesis and minimum forever after
290287
pub const MinCollators: u32 = MIN_COLLATORS;
291288
/// At least 4 candidates which cannot leave the network if there are no other candidates.
292-
pub const MinRequiredCollators: u32 = 4;
289+
pub const MinRequiredCollators: u32 = 0;
293290
/// We only allow one delegation per round.
294291
pub const MaxDelegationsPerRound: u32 = 1;
295292
/// Maximum 25 delegators per collator at launch, might be increased later

runtimes/peregrine/src/system/mod.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
// If you feel like getting in touch with us, you can do so at <hello@kilt.io>
1818

1919
use frame_support::{
20-
parameter_types,
21-
traits::{AsEnsureOriginWithArg, Everything, PrivilegeCmp},
20+
match_types, parameter_types,
21+
traits::{AsEnsureOriginWithArg, EverythingBut, PrivilegeCmp},
2222
weights::Weight,
2323
};
2424
use frame_system::EnsureRoot;
@@ -55,6 +55,15 @@ parameter_types! {
5555
pub const Version: RuntimeVersion = VERSION;
5656
}
5757

58+
match_types! {
59+
pub type IncreaseStakingCalls: impl Contains<RuntimeCall> = {
60+
RuntimeCall::ParachainStaking(parachain_staking::Call::<Runtime>::join_candidates { .. }) |
61+
RuntimeCall::ParachainStaking(parachain_staking::Call::<Runtime>::join_delegators { .. }) |
62+
RuntimeCall::ParachainStaking(parachain_staking::Call::<Runtime>::delegator_stake_more { .. }) |
63+
RuntimeCall::ParachainStaking(parachain_staking::Call::<Runtime>::candidate_stake_more { .. })
64+
};
65+
}
66+
5867
impl frame_system::Config for Runtime {
5968
/// The identifier used to distinguish between accounts.
6069
type AccountId = AccountId;
@@ -87,7 +96,7 @@ impl frame_system::Config for Runtime {
8796
type OnNewAccount = ();
8897
type OnKilledAccount = ();
8998
type DbWeight = weights::rocksdb_weights::constants::RocksDbWeight;
90-
type BaseCallFilter = Everything;
99+
type BaseCallFilter = EverythingBut<IncreaseStakingCalls>;
91100
type SystemWeightInfo = crate::weights::frame_system::WeightInfo<Runtime>;
92101
type BlockWeights = BlockWeights;
93102
type BlockLength = BlockLength;

runtimes/spiritnet/src/system/mod.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
// If you feel like getting in touch with us, you can do so at <hello@kilt.io>
1818

1919
use frame_support::{
20-
parameter_types,
21-
traits::{AsEnsureOriginWithArg, Everything, PrivilegeCmp},
20+
match_types, parameter_types,
21+
traits::{AsEnsureOriginWithArg, EverythingBut, PrivilegeCmp},
2222
weights::Weight,
2323
};
2424
use frame_system::EnsureRoot;
@@ -55,6 +55,15 @@ parameter_types! {
5555
pub const Version: RuntimeVersion = VERSION;
5656
}
5757

58+
match_types! {
59+
pub type IncreaseStakingCalls: impl Contains<RuntimeCall> = {
60+
RuntimeCall::ParachainStaking(parachain_staking::Call::<Runtime>::join_candidates { .. }) |
61+
RuntimeCall::ParachainStaking(parachain_staking::Call::<Runtime>::join_delegators { .. }) |
62+
RuntimeCall::ParachainStaking(parachain_staking::Call::<Runtime>::delegator_stake_more { .. }) |
63+
RuntimeCall::ParachainStaking(parachain_staking::Call::<Runtime>::candidate_stake_more { .. })
64+
};
65+
}
66+
5867
impl frame_system::Config for Runtime {
5968
/// The identifier used to distinguish between accounts.
6069
type AccountId = AccountId;
@@ -87,7 +96,7 @@ impl frame_system::Config for Runtime {
8796
type OnNewAccount = ();
8897
type OnKilledAccount = ();
8998
type DbWeight = weights::rocksdb_weights::constants::RocksDbWeight;
90-
type BaseCallFilter = Everything;
99+
type BaseCallFilter = EverythingBut<IncreaseStakingCalls>;
91100
type SystemWeightInfo = crate::weights::frame_system::WeightInfo<Runtime>;
92101
type BlockWeights = BlockWeights;
93102
type BlockLength = BlockLength;

0 commit comments

Comments
 (0)