From 5c3e09820601a11a9b21fdbf729fc39733a92894 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 18 Jun 2025 13:52:44 +0200 Subject: [PATCH 1/3] fix: allow rapid unstaking for all parachain stakers --- runtimes/common/src/constants.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtimes/common/src/constants.rs b/runtimes/common/src/constants.rs index 9bc7afa2f..ece5c1540 100644 --- a/runtimes/common/src/constants.rs +++ b/runtimes/common/src/constants.rs @@ -256,9 +256,9 @@ pub mod staking { pub const DEFAULT_BLOCKS_PER_ROUND: BlockNumber = 2 * HOURS; #[cfg(feature = "fast-gov")] - pub const STAKE_DURATION: BlockNumber = 30; + pub const STAKE_DURATION: BlockNumber = 1; #[cfg(not(feature = "fast-gov"))] - pub const STAKE_DURATION: BlockNumber = 7 * DAYS; + pub const STAKE_DURATION: BlockNumber = 1; #[cfg(feature = "fast-gov")] pub const MIN_COLLATORS: u32 = 4; @@ -289,7 +289,7 @@ pub mod staking { /// Minimum 16 collators selected per round, default at genesis and minimum forever after pub const MinCollators: u32 = MIN_COLLATORS; /// At least 4 candidates which cannot leave the network if there are no other candidates. - pub const MinRequiredCollators: u32 = 4; + pub const MinRequiredCollators: u32 = 0; /// We only allow one delegation per round. pub const MaxDelegationsPerRound: u32 = 1; /// Maximum 25 delegators per collator at launch, might be increased later From 17a202dbbb9d7be0a2c99a50e698862fefd5db8e Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 3 Jul 2025 16:32:33 +0200 Subject: [PATCH 2/3] feat: disallow additional staking via call filter --- runtimes/peregrine/src/system/mod.rs | 15 ++++++++++++--- runtimes/spiritnet/src/system/mod.rs | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/runtimes/peregrine/src/system/mod.rs b/runtimes/peregrine/src/system/mod.rs index 05320eead..13731b2d0 100644 --- a/runtimes/peregrine/src/system/mod.rs +++ b/runtimes/peregrine/src/system/mod.rs @@ -17,8 +17,8 @@ // If you feel like getting in touch with us, you can do so at use frame_support::{ - parameter_types, - traits::{AsEnsureOriginWithArg, Everything, PrivilegeCmp}, + match_types, parameter_types, + traits::{AsEnsureOriginWithArg, EverythingBut, PrivilegeCmp}, weights::Weight, }; use frame_system::EnsureRoot; @@ -55,6 +55,15 @@ parameter_types! { pub const Version: RuntimeVersion = VERSION; } +match_types! { + pub type IncreaseStakingCalls: impl Contains = { + RuntimeCall::ParachainStaking(parachain_staking::Call::::join_candidates { .. }) | + RuntimeCall::ParachainStaking(parachain_staking::Call::::join_delegators { .. }) | + RuntimeCall::ParachainStaking(parachain_staking::Call::::delegator_stake_more { .. }) | + RuntimeCall::ParachainStaking(parachain_staking::Call::::candidate_stake_more { .. }) + }; +} + impl frame_system::Config for Runtime { /// The identifier used to distinguish between accounts. type AccountId = AccountId; @@ -87,7 +96,7 @@ impl frame_system::Config for Runtime { type OnNewAccount = (); type OnKilledAccount = (); type DbWeight = weights::rocksdb_weights::constants::RocksDbWeight; - type BaseCallFilter = Everything; + type BaseCallFilter = EverythingBut; type SystemWeightInfo = crate::weights::frame_system::WeightInfo; type BlockWeights = BlockWeights; type BlockLength = BlockLength; diff --git a/runtimes/spiritnet/src/system/mod.rs b/runtimes/spiritnet/src/system/mod.rs index 011c867b2..72db53e62 100644 --- a/runtimes/spiritnet/src/system/mod.rs +++ b/runtimes/spiritnet/src/system/mod.rs @@ -17,8 +17,8 @@ // If you feel like getting in touch with us, you can do so at use frame_support::{ - parameter_types, - traits::{AsEnsureOriginWithArg, Everything, PrivilegeCmp}, + match_types, parameter_types, + traits::{AsEnsureOriginWithArg, EverythingBut, PrivilegeCmp}, weights::Weight, }; use frame_system::EnsureRoot; @@ -55,6 +55,15 @@ parameter_types! { pub const Version: RuntimeVersion = VERSION; } +match_types! { + pub type IncreaseStakingCalls: impl Contains = { + RuntimeCall::ParachainStaking(parachain_staking::Call::::join_candidates { .. }) | + RuntimeCall::ParachainStaking(parachain_staking::Call::::join_delegators { .. }) | + RuntimeCall::ParachainStaking(parachain_staking::Call::::delegator_stake_more { .. }) | + RuntimeCall::ParachainStaking(parachain_staking::Call::::candidate_stake_more { .. }) + }; +} + impl frame_system::Config for Runtime { /// The identifier used to distinguish between accounts. type AccountId = AccountId; @@ -87,7 +96,7 @@ impl frame_system::Config for Runtime { type OnNewAccount = (); type OnKilledAccount = (); type DbWeight = weights::rocksdb_weights::constants::RocksDbWeight; - type BaseCallFilter = Everything; + type BaseCallFilter = EverythingBut; type SystemWeightInfo = crate::weights::frame_system::WeightInfo; type BlockWeights = BlockWeights; type BlockLength = BlockLength; From b2519d400cb96497720157719390e2ff440e8112 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 16 Jul 2025 10:47:45 +0200 Subject: [PATCH 3/3] chore: no feature flag for STAKE_DURATION --- runtimes/common/src/constants.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/runtimes/common/src/constants.rs b/runtimes/common/src/constants.rs index ece5c1540..f2e1036e6 100644 --- a/runtimes/common/src/constants.rs +++ b/runtimes/common/src/constants.rs @@ -255,9 +255,6 @@ pub mod staking { #[cfg(not(feature = "fast-gov"))] pub const DEFAULT_BLOCKS_PER_ROUND: BlockNumber = 2 * HOURS; - #[cfg(feature = "fast-gov")] - pub const STAKE_DURATION: BlockNumber = 1; - #[cfg(not(feature = "fast-gov"))] pub const STAKE_DURATION: BlockNumber = 1; #[cfg(feature = "fast-gov")]