-
Notifications
You must be signed in to change notification settings - Fork 835
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
[Nomination Pool] Make staking restrictions configurable #7685
Conversation
5bbc2c7
to
fcbb0bb
Compare
d9beb43
to
91cbb9f
Compare
8592d82
to
428b491
Compare
All GitHub workflows were cancelled due to failure one of the required jobs. |
/// This struct implements the `Contains` trait, allowing it to determine whether | ||
/// a particular account is currently staking by checking if the account exists in | ||
/// the staking ledger. | ||
pub struct AllStakers<T: Config>(core::marker::PhantomData<T>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would name this something like AllDirectStakers
or AllNativeStakers
, since people who join nomination pools could still be considered "stakers" (i.e. they have their funds at stake). This is checking that they have an entry in the staking ledger specific to their account.
closes #5742 Need to be backported to stable2503 release. With the migration of staking accounts to [fungible currency](#5501), we can now allow pool users to stake directly and vice versa. This update introduces a configurable filter mechanism to determine which accounts can join a nomination pool. To permit all accounts to join a nomination pool, use the `Nothing` filter: ```rust impl pallet_nomination_pools::Config for Runtime { ... type Filter = Nothing; } ``` To prevent direct stakers from joining a nomination pool, use `pallet_staking::AllStakers`: ```rust impl pallet_nomination_pools::Config for Runtime { ... type Filter = pallet_staking::AllStakers<Runtime>; } ``` For more granular control, you can define a custom filter: ```rust struct MyCustomFilter<T: Config>(core::marker::PhantomData<T>); impl<T: Config> Contains<T::AccountId> for MyCustomFilter<T> { fn contains(account: &T::AccountId) -> bool { todo!("Implement custom logic. Return `false` to allow the account to join a pool.") } } ``` --------- Co-authored-by: Bastian Köcher <[email protected]>
Created backport PR for
Please cherry-pick the changes locally and resolve any conflicts. git fetch origin backport-7685-to-stable2407
git worktree add --checkout .worktree/backport-7685-to-stable2407 backport-7685-to-stable2407
cd .worktree/backport-7685-to-stable2407
git reset --hard HEAD^
git cherry-pick -x f7e98b40cab7475898c99ea48809635ac069af3a
git push --force-with-lease |
Created backport PR for
Please cherry-pick the changes locally and resolve any conflicts. git fetch origin backport-7685-to-stable2409
git worktree add --checkout .worktree/backport-7685-to-stable2409 backport-7685-to-stable2409
cd .worktree/backport-7685-to-stable2409
git reset --hard HEAD^
git cherry-pick -x f7e98b40cab7475898c99ea48809635ac069af3a
git push --force-with-lease |
Created backport PR for
Please cherry-pick the changes locally and resolve any conflicts. git fetch origin backport-7685-to-stable2412
git worktree add --checkout .worktree/backport-7685-to-stable2412 backport-7685-to-stable2412
cd .worktree/backport-7685-to-stable2412
git reset --hard HEAD^
git cherry-pick -x f7e98b40cab7475898c99ea48809635ac069af3a
git push --force-with-lease |
closes #5742 Need to be backported to stable2503 release. With the migration of staking accounts to [fungible currency](#5501), we can now allow pool users to stake directly and vice versa. This update introduces a configurable filter mechanism to determine which accounts can join a nomination pool. ## Example Usage ### 1. Allow any account to join a pool To permit all accounts to join a nomination pool, use the `Nothing` filter: ```rust impl pallet_nomination_pools::Config for Runtime { ... type Filter = Nothing; } ``` ### 2. Restrict direct stakers from joining a pool To prevent direct stakers from joining a nomination pool, use `pallet_staking::AllStakers`: ```rust impl pallet_nomination_pools::Config for Runtime { ... type Filter = pallet_staking::AllStakers<Runtime>; } ``` ### 3. Define a custom filter For more granular control, you can define a custom filter: ```rust struct MyCustomFilter<T: Config>(core::marker::PhantomData<T>); impl<T: Config> Contains<T::AccountId> for MyCustomFilter<T> { fn contains(account: &T::AccountId) -> bool { todo!("Implement custom logic. Return `false` to allow the account to join a pool.") } } ``` --------- Co-authored-by: Bastian Köcher <[email protected]> (cherry picked from commit f7e98b4)
Successfully created backport PR for |
Backport #7685 into `stable2503` from Ank4n. See the [documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md) on how to use this bot. <!-- # To be used by other automation, do not modify: original-pr-number: #${pull_number} --> Co-authored-by: Ankan <[email protected]>
closes #5742
Need to be backported to stable2503 release.
With the migration of staking accounts to fungible currency, we can now allow pool users to stake directly and vice versa. This update introduces a configurable filter mechanism to determine which accounts can join a nomination pool.
Example Usage
1. Allow any account to join a pool
To permit all accounts to join a nomination pool, use the
Nothing
filter:2. Restrict direct stakers from joining a pool
To prevent direct stakers from joining a nomination pool, use
pallet_staking::AllStakers
:3. Define a custom filter
For more granular control, you can define a custom filter: