Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Proxy for Nomination Pools #6846

Merged
merged 3 commits into from
Mar 27, 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
4 changes: 4 additions & 0 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,7 @@ pub enum ProxyType {
CancelProxy,
Auction,
Society,
NominationPools,
}

impl Default for ProxyType {
Expand Down Expand Up @@ -1024,6 +1025,9 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::FastUnstake(..)
)
},
ProxyType::NominationPools => {
matches!(c, RuntimeCall::NominationPools(..) | RuntimeCall::Utility(..))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we should support all utility calls. We should filter here explicitly on what we want to support.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably he took it for the same reason that Utility is part of Staking proxy as well.

Isn't this an issue that now with Staking proxy you can do utility::batch[transfer]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to test this and the batched calls itself are filtered again. So a proxy can only do utility::batch[some_nomination_call] if they are only allowed delegation for NominationPools .

Perhaps there are some utility calls that are unsafe (.i.e. does not pass along the filters)? It looks to me we are already supporting all utility calls in few other proxies as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the batched calls are itself checked again!

Something like aw_derivative is maybe not that good? I would have said that we only allow batching calls.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In either case, this is beyond this PR per se, I suggest we move on and revise including Utility elsewhere.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how this can be beyond this pr? This is a security issue if not done correctly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, checked the code again as_derivative is taking the same filters into account. So, it is safe.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

},
ProxyType::IdentityJudgement => matches!(
c,
RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. }) |
Expand Down
4 changes: 4 additions & 0 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@ pub enum ProxyType {
IdentityJudgement = 5,
CancelProxy = 6,
Auction = 7,
NominationPools = 8,
}

#[cfg(test)]
Expand Down Expand Up @@ -1034,6 +1035,9 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::FastUnstake(..)
)
},
ProxyType::NominationPools => {
matches!(c, RuntimeCall::NominationPools(..) | RuntimeCall::Utility(..))
},
ProxyType::IdentityJudgement => matches!(
c,
RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. }) |
Expand Down
4 changes: 4 additions & 0 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ pub enum ProxyType {
IdentityJudgement,
CancelProxy,
Auction,
NominationPools,
}
impl Default for ProxyType {
fn default() -> Self {
Expand Down Expand Up @@ -824,6 +825,9 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::FastUnstake(..)
)
},
ProxyType::NominationPools => {
matches!(c, RuntimeCall::NominationPools(..) | RuntimeCall::Utility(..))
},
ProxyType::SudoBalances => match c {
RuntimeCall::Sudo(pallet_sudo::Call::sudo { call: ref x }) => {
matches!(x.as_ref(), &RuntimeCall::Balances(..))
Expand Down