[Nomination Pool] Make staking restrictions configurable (#7685)
closes https://github.com/paritytech/polkadot-sdk/issues/5742 Need to be backported to stable2503 release. With the migration of staking accounts to [fungible currency](https://github.com/paritytech/polkadot-sdk/pull/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 <info@kchr.de> (cherry picked from commit f7e98b40)
parent
d0def04c
Pipeline
#517166
waiting for manual action
with stages
in
1 hour, 44 minutes, and 18 seconds
Stage:
Stage:
Stage:
Stage:
Stage:
Stage:
Showing
- polkadot/runtime/test-runtime/src/lib.rs 1 addition, 0 deletionspolkadot/runtime/test-runtime/src/lib.rs
- polkadot/runtime/westend/src/lib.rs 3 additions, 1 deletionpolkadot/runtime/westend/src/lib.rs
- prdoc/pr_7685.prdoc 20 additions, 0 deletionsprdoc/pr_7685.prdoc
- substrate/bin/node/runtime/src/lib.rs 2 additions, 0 deletionssubstrate/bin/node/runtime/src/lib.rs
- substrate/frame/delegated-staking/src/lib.rs 0 additions, 10 deletionssubstrate/frame/delegated-staking/src/lib.rs
- substrate/frame/delegated-staking/src/mock.rs 2 additions, 0 deletionssubstrate/frame/delegated-staking/src/mock.rs
- substrate/frame/delegated-staking/src/tests.rs 30 additions, 53 deletionssubstrate/frame/delegated-staking/src/tests.rs
- substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs 2 additions, 2 deletions...lection-provider-multi-phase/test-staking-e2e/src/mock.rs
- substrate/frame/nomination-pools/benchmarking/src/mock.rs 2 additions, 1 deletionsubstrate/frame/nomination-pools/benchmarking/src/mock.rs
- substrate/frame/nomination-pools/src/lib.rs 31 additions, 3 deletionssubstrate/frame/nomination-pools/src/lib.rs
- substrate/frame/nomination-pools/src/mock.rs 19 additions, 0 deletionssubstrate/frame/nomination-pools/src/mock.rs
- substrate/frame/nomination-pools/src/tests.rs 70 additions, 0 deletionssubstrate/frame/nomination-pools/src/tests.rs
- substrate/frame/nomination-pools/test-delegate-stake/src/mock.rs 2 additions, 1 deletion...te/frame/nomination-pools/test-delegate-stake/src/mock.rs
- substrate/frame/staking/src/lib.rs 19 additions, 1 deletionsubstrate/frame/staking/src/lib.rs
- substrate/frame/staking/src/mock.rs 19 additions, 0 deletionssubstrate/frame/staking/src/mock.rs
- substrate/frame/staking/src/pallet/mod.rs 50 additions, 2 deletionssubstrate/frame/staking/src/pallet/mod.rs
- substrate/frame/staking/src/tests.rs 126 additions, 1 deletionsubstrate/frame/staking/src/tests.rs
Please register or sign in to comment