Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove MinCollatorStk from parachain-staking pallet #2265

Merged
merged 1 commit into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pallets/parachain-staking/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use sp_std::vec::Vec;

/// Minimum collator candidate stake
fn min_candidate_stk<T: Config>() -> BalanceOf<T> {
<<T as Config>::MinCollatorStk as Get<BalanceOf<T>>>::get()
<<T as Config>::MinCandidateStk as Get<BalanceOf<T>>>::get()
}

/// Minimum delegator stake
Expand Down
5 changes: 0 additions & 5 deletions pallets/parachain-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,6 @@ pub mod pallet {
/// Maximum delegations per delegator
#[pallet::constant]
type MaxDelegationsPerDelegator: Get<u32>;
/// Minimum stake required for any candidate to be in `SelectedCandidates` for the round
#[pallet::constant]
type MinCollatorStk: Get<BalanceOf<Self>>;
/// Minimum stake required for any account to be a collator candidate
#[pallet::constant]
type MinCandidateStk: Get<BalanceOf<Self>>;
Expand Down Expand Up @@ -1744,7 +1741,6 @@ pub mod pallet {
let mut collators = candidates
.into_iter()
.take(top_n)
.filter(|x| x.amount >= T::MinCollatorStk::get())
.map(|x| x.owner)
.collect::<Vec<T::AccountId>>();

Expand All @@ -1757,7 +1753,6 @@ pub mod pallet {
// The candidates are already sorted by AccountId, so no need to sort again
candidates
.into_iter()
.filter(|x| x.amount >= T::MinCollatorStk::get())
.map(|x| x.owner)
.collect::<Vec<T::AccountId>>()
}
Expand Down
5 changes: 2 additions & 3 deletions pallets/parachain-staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ parameter_types! {
pub const MaxTopDelegationsPerCandidate: u32 = 4;
pub const MaxBottomDelegationsPerCandidate: u32 = 4;
pub const MaxDelegationsPerDelegator: u32 = 4;
pub const MinCollatorStk: u128 = 10;
pub const MinCandidateStk: u128 = 10;
pub const MinDelegatorStk: u128 = 5;
pub const MinDelegation: u128 = 3;
}
Expand All @@ -136,8 +136,7 @@ impl Config for Test {
type MaxTopDelegationsPerCandidate = MaxTopDelegationsPerCandidate;
type MaxBottomDelegationsPerCandidate = MaxBottomDelegationsPerCandidate;
type MaxDelegationsPerDelegator = MaxDelegationsPerDelegator;
type MinCollatorStk = MinCollatorStk;
type MinCandidateStk = MinCollatorStk;
type MinCandidateStk = MinCandidateStk;
type MinDelegatorStk = MinDelegatorStk;
type MinDelegation = MinDelegation;
type BlockAuthor = BlockAuthor;
Expand Down
5 changes: 2 additions & 3 deletions precompiles/parachain-staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ parameter_types! {
pub const MaxTopDelegationsPerCandidate: u32 = 2;
pub const MaxBottomDelegationsPerCandidate: u32 = 4;
pub const MaxDelegationsPerDelegator: u32 = 4;
pub const MinCollatorStk: u128 = 10;
pub const MinCandidateStk: u128 = 10;
pub const MinDelegatorStk: u128 = 5;
pub const MinDelegation: u128 = 3;
pub BlockAuthor: AccountId = Alice.into();
Expand All @@ -180,8 +180,7 @@ impl pallet_parachain_staking::Config for Runtime {
type MaxTopDelegationsPerCandidate = MaxTopDelegationsPerCandidate;
type MaxBottomDelegationsPerCandidate = MaxBottomDelegationsPerCandidate;
type MaxDelegationsPerDelegator = MaxDelegationsPerDelegator;
type MinCollatorStk = MinCollatorStk;
type MinCandidateStk = MinCollatorStk;
type MinCandidateStk = MinCandidateStk;
type MinDelegatorStk = MinDelegatorStk;
type MinDelegation = MinDelegation;
type BlockAuthor = BlockAuthor;
Expand Down
6 changes: 0 additions & 6 deletions runtime/moonbase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,8 +707,6 @@ impl pallet_parachain_staking::Config for Runtime {
type MaxBottomDelegationsPerCandidate = ConstU32<50>;
/// Maximum delegations per delegator
type MaxDelegationsPerDelegator = ConstU32<100>;
/// Minimum stake required to become a collator
type MinCollatorStk = ConstU128<{ 1000 * currency::UNIT * currency::SUPPLY_FACTOR }>;
/// Minimum stake required to be reserved to be a candidate
type MinCandidateStk = ConstU128<{ 500 * currency::UNIT * currency::SUPPLY_FACTOR }>;
/// Minimum stake required to be reserved to be a delegator
Expand Down Expand Up @@ -1568,10 +1566,6 @@ mod tests {
);

// staking minimums
assert_eq!(
get!(pallet_parachain_staking, MinCollatorStk, u128),
Balance::from(1 * KILOUNIT)
);
assert_eq!(
get!(pallet_parachain_staking, MinCandidateStk, u128),
Balance::from(500 * UNIT)
Expand Down
6 changes: 0 additions & 6 deletions runtime/moonbeam/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,6 @@ impl pallet_parachain_staking::Config for Runtime {
type MaxBottomDelegationsPerCandidate = ConstU32<50>;
/// Maximum delegations per delegator
type MaxDelegationsPerDelegator = ConstU32<100>;
/// Minimum stake required to become a collator
type MinCollatorStk = ConstU128<{ 20_000 * currency::GLMR * currency::SUPPLY_FACTOR }>;
/// Minimum stake required to be reserved to be a candidate
type MinCandidateStk = ConstU128<{ 20_000 * currency::GLMR * currency::SUPPLY_FACTOR }>;
/// Minimum stake required to be reserved to be a delegator
Expand Down Expand Up @@ -1636,10 +1634,6 @@ mod tests {
);

// staking minimums
assert_eq!(
get!(pallet_parachain_staking, MinCollatorStk, u128),
Balance::from(2_000_000 * GLMR)
);
assert_eq!(
get!(pallet_parachain_staking, MinCandidateStk, u128),
Balance::from(2_000_000 * GLMR)
Expand Down
6 changes: 0 additions & 6 deletions runtime/moonriver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,6 @@ impl pallet_parachain_staking::Config for Runtime {
type MaxBottomDelegationsPerCandidate = ConstU32<50>;
/// Maximum delegations per delegator
type MaxDelegationsPerDelegator = ConstU32<100>;
/// Minimum stake required to become a collator
type MinCollatorStk = ConstU128<{ 10000 * currency::MOVR * currency::SUPPLY_FACTOR }>;
/// Minimum stake required to be reserved to be a candidate
type MinCandidateStk = ConstU128<{ 10000 * currency::MOVR * currency::SUPPLY_FACTOR }>;
/// Minimum stake required to be reserved to be a delegator
Expand Down Expand Up @@ -1564,10 +1562,6 @@ mod tests {
);

// staking minimums
assert_eq!(
get!(pallet_parachain_staking, MinCollatorStk, u128),
Balance::from(10 * KILOMOVR)
);
assert_eq!(
get!(pallet_parachain_staking, MinCandidateStk, u128),
Balance::from(10 * KILOMOVR)
Expand Down