mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 04:21:01 +00:00
Pools: Add ability to configure commission claiming permissions (#2474)
Addresses #409. This request has been raised by multiple community members - the ability for the nomination pool root role to configure permissionless commission claiming: > Would it be possible to have a claim_commission_other extrinsic for claiming commission of nomination pools permissionless? This PR does not quite introduce this additional call, but amends `do_claim_commission` to check a new `claim_permission` field in the `Commission` struct, configured by an enum: ``` enum CommissionClaimPermission { Permissionless, Account(AccountId), } ``` This can be optionally set in a bonded pool's `commission.claim_permission` field: ``` struct BondedPool { commission: { <snip> claim_permission: Option<CommissionClaimPermission<T::AccountId>>, }, <snip> } ``` This is a new field and requires a migration to add it to existing pools. This will be `None` on pool creation, falling back to the `root` role having sole access to claim commission if it is not set; this is the behaviour as it is today. Once set, the field _can_ be set to `None` again. #### Changes - [x] Add `commision.claim_permission` field. - [x] Add `can_claim_commission` and amend `do_claim_commission`. - [x] Add `set_commission_claim_permission` call. - [x] Test to cover new configs and call. - [x] Add and amend benchmarks. - [x] Generate new weights + slot into call `set_commission_claim_permission`. - [x] Add migration to introduce `commission.claim_permission`, bump storage version. - [x] Update Westend weights. - [x] Migration working. --------- Co-authored-by: command-bot <>
This commit is contained in:
@@ -35,9 +35,9 @@ use frame_support::{
|
||||
use frame_system::RawOrigin as RuntimeOrigin;
|
||||
use pallet_nomination_pools::{
|
||||
BalanceOf, BondExtra, BondedPoolInner, BondedPools, ClaimPermission, ClaimPermissions,
|
||||
Commission, CommissionChangeRate, ConfigOp, GlobalMaxCommission, MaxPoolMembers,
|
||||
MaxPoolMembersPerPool, MaxPools, Metadata, MinCreateBond, MinJoinBond, Pallet as Pools,
|
||||
PoolMembers, PoolRoles, PoolState, RewardPools, SubPoolsStorage,
|
||||
Commission, CommissionChangeRate, CommissionClaimPermission, ConfigOp, GlobalMaxCommission,
|
||||
MaxPoolMembers, MaxPoolMembersPerPool, MaxPools, Metadata, MinCreateBond, MinJoinBond,
|
||||
Pallet as Pools, PoolMembers, PoolRoles, PoolState, RewardPools, SubPoolsStorage,
|
||||
};
|
||||
use pallet_staking::MaxNominationsOf;
|
||||
use sp_runtime::{
|
||||
@@ -706,17 +706,24 @@ frame_benchmarking::benchmarks! {
|
||||
max_increase: Perbill::from_percent(20),
|
||||
min_delay: 0u32.into(),
|
||||
}).unwrap();
|
||||
// set a claim permission to an account.
|
||||
Pools::<T>::set_commission_claim_permission(
|
||||
RuntimeOrigin::Signed(depositor.clone()).into(),
|
||||
1u32.into(),
|
||||
Some(CommissionClaimPermission::Account(depositor.clone()))
|
||||
).unwrap();
|
||||
|
||||
}:_(RuntimeOrigin::Signed(depositor.clone()), 1u32.into(), Some((Perbill::from_percent(20), depositor.clone())))
|
||||
verify {
|
||||
assert_eq!(BondedPools::<T>::get(1).unwrap().commission, Commission {
|
||||
current: Some((Perbill::from_percent(20), depositor)),
|
||||
current: Some((Perbill::from_percent(20), depositor.clone())),
|
||||
max: Some(Perbill::from_percent(50)),
|
||||
change_rate: Some(CommissionChangeRate {
|
||||
max_increase: Perbill::from_percent(20),
|
||||
min_delay: 0u32.into()
|
||||
}),
|
||||
throttle_from: Some(1u32.into()),
|
||||
claim_permission: Some(CommissionClaimPermission::Account(depositor)),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -731,6 +738,7 @@ frame_benchmarking::benchmarks! {
|
||||
max: Some(Perbill::from_percent(50)),
|
||||
change_rate: None,
|
||||
throttle_from: Some(0u32.into()),
|
||||
claim_permission: None,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -751,9 +759,25 @@ frame_benchmarking::benchmarks! {
|
||||
min_delay: 1000u32.into(),
|
||||
}),
|
||||
throttle_from: Some(1_u32.into()),
|
||||
claim_permission: None,
|
||||
});
|
||||
}
|
||||
|
||||
set_commission_claim_permission {
|
||||
// Create a pool.
|
||||
let (depositor, pool_account) = create_pool_account::<T>(0, Pools::<T>::depositor_min_bond() * 2u32.into(), None);
|
||||
}:_(RuntimeOrigin::Signed(depositor.clone()), 1u32.into(), Some(CommissionClaimPermission::Account(depositor.clone())))
|
||||
verify {
|
||||
assert_eq!(
|
||||
BondedPools::<T>::get(1).unwrap().commission, Commission {
|
||||
current: None,
|
||||
max: None,
|
||||
change_rate: None,
|
||||
throttle_from: None,
|
||||
claim_permission: Some(CommissionClaimPermission::Account(depositor)),
|
||||
});
|
||||
}
|
||||
|
||||
set_claim_permission {
|
||||
// Create a pool
|
||||
let min_create_bond = Pools::<T>::depositor_min_bond();
|
||||
@@ -786,8 +810,13 @@ frame_benchmarking::benchmarks! {
|
||||
CurrencyOf::<T>::set_balance(&reward_account, ed + origin_weight);
|
||||
|
||||
// member claims a payout to make some commission available.
|
||||
let _ = Pools::<T>::claim_payout(RuntimeOrigin::Signed(claimer).into());
|
||||
|
||||
let _ = Pools::<T>::claim_payout(RuntimeOrigin::Signed(claimer.clone()).into());
|
||||
// set a claim permission to an account.
|
||||
let _ = Pools::<T>::set_commission_claim_permission(
|
||||
RuntimeOrigin::Signed(depositor.clone()).into(),
|
||||
1u32.into(),
|
||||
Some(CommissionClaimPermission::Account(claimer))
|
||||
);
|
||||
whitelist_account!(depositor);
|
||||
}:_(RuntimeOrigin::Signed(depositor.clone()), 1u32.into())
|
||||
verify {
|
||||
|
||||
Reference in New Issue
Block a user