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

feat: Additional Proxy Types on shiden #920

Merged
merged 8 commits into from
May 4, 2023

Conversation

gitofdeepanshu
Copy link
Contributor

@gitofdeepanshu gitofdeepanshu commented Apr 27, 2023

Pull Request Summary

This PR adds new proxy types on Shiden. Previous Iteration: #778
Related #760

Previous Proxy Types

    CancelProxy,
    DappsStaking,

Added Types

   Any,
   NonTransfer,
   Balances,
   IdentityJudgement,

@gitofdeepanshu gitofdeepanshu marked this pull request as ready for review April 27, 2023 16:08
Copy link
Member

@Dinonard Dinonard left a comment

Choose a reason for hiding this comment

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

You will also need to bump semver & spec_version.

Comment on lines +902 to +907
ProxyType::Balances => {
matches!(c, RuntimeCall::Balances(..))
Copy link
Member

Choose a reason for hiding this comment

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

Might be a good approach to also allow asset transfers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good suggestion.

Comment on lines 917 to +929
ProxyType::DappsStaking => {
matches!(c, RuntimeCall::DappsStaking(..) | RuntimeCall::Utility(..))
matches!(c, RuntimeCall::DappsStaking(..))
Copy link
Member

Choose a reason for hiding this comment

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

We will need this filter to support batch call with DappsStaking calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

RuntimeCall::Utility(..) is always passed through the filter so no need to add it to every variant.

Copy link
Member

Choose a reason for hiding this comment

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

Tbh, I didn't know that! Good!

Comment on lines 851 to 857
Any,
NonTransfer,
Balances,
IdentityJudgement,
CancelProxy,
DappsStaking,
Copy link
Member

Choose a reason for hiding this comment

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

Let's add comment to these (also in Shibuya).

}
}
}

fn is_superset(&self, o: &Self) -> bool {
match (self, o) {
(x, y) if x == y => true,
(ProxyType::Any, _) => true,
(_, ProxyType::Any) => false,
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't NonTransafer also cover many (or all?) types except for Any?

Copy link
Contributor Author

@gitofdeepanshu gitofdeepanshu Apr 29, 2023

Choose a reason for hiding this comment

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

Doesn't cover Balances.

Copy link
Member

Choose a reason for hiding this comment

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

Still, you'd need to cover those here, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Balance is not a superset or subset of any proxy type except Any which is already covered.

Copy link
Member

Choose a reason for hiding this comment

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

I meant the NonTransfer in the original message 🙂

It's superset of almost everything - expcet Balances as you noted. Right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that we have added pallet Assets, it is also not included.
is_superset() in used to check which proxy types can add/remove other proxy types. As NonTransfer has no jurisdiction over Balances or Assets so we can't add it.
If you really want to add some more cases then you can cover other cases like

(ProxyType::NonTransfer, ProxyType::IdentityJudgement) => true,
(ProxyType::NonTransfer, ProxyType::CancelProxy) => true,
(ProxyType::NonTransfer, ProxyType::DappStaking) => true,

It is up to us if we want to give NonTransfer that much power, no other parachain is doing it btw.

Comment on lines +868 to +871
// Always allowed RuntimeCall::Utility no matter type.
// Only transactions allowed by Proxy.filter can be executed
_ if matches!(c, RuntimeCall::Utility(..)) => true,
Copy link
Member

Choose a reason for hiding this comment

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

Is this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, allows for RuntimeCall::Utility to always pass through the filter for every variant.

Copy link
Member

Choose a reason for hiding this comment

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

I see!

Could we add some tests for this below? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure.

CancelProxy,
DappsStaking,
}

impl Default for ProxyType {
fn default() -> Self {
Self::CancelProxy
Self::Any
Copy link
Member

Choose a reason for hiding this comment

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

I kind of preferred the last one - less chance to do some damage 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well the idea was to make it simpler for users, when someone makes an account proxy, it is expected that the proxy should be of type Any (allows all operations). Everybody uses this as default so it's kind of standard.

Changing this to CancelProxy would be bad UX imo.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, just hope no one loses their account due to this 😶

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤐

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@shunsukew shunsukew left a comment

Choose a reason for hiding this comment

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

Other than 1 comment I added, it looks good to me

matches!(
c,
RuntimeCall::System(..)
| 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.

This can be also removed

@shunsukew shunsukew self-requested a review May 1, 2023 04:42
Copy link
Member

@shunsukew shunsukew left a comment

Choose a reason for hiding this comment

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

Why not apply changes to Shibuya too first?

@gitofdeepanshu
Copy link
Contributor Author

That makes sense, will do.

@gitofdeepanshu
Copy link
Contributor Author

@shunsukew
Added changes to Shubiya as well here

@shunsukew shunsukew self-requested a review May 1, 2023 09:37
Copy link
Member

@shunsukew shunsukew left a comment

Choose a reason for hiding this comment

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

Looks good to me

}
}
}

fn is_superset(&self, o: &Self) -> bool {
match (self, o) {
(x, y) if x == y => true,
(ProxyType::Any, _) => true,
(_, ProxyType::Any) => false,
Copy link
Member

Choose a reason for hiding this comment

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

Still, you'd need to cover those here, right?

Comment on lines 917 to +929
ProxyType::DappsStaking => {
matches!(c, RuntimeCall::DappsStaking(..) | RuntimeCall::Utility(..))
matches!(c, RuntimeCall::DappsStaking(..))
Copy link
Member

Choose a reason for hiding this comment

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

Tbh, I didn't know that! Good!

CancelProxy,
DappsStaking,
}

impl Default for ProxyType {
fn default() -> Self {
Self::CancelProxy
Self::Any
Copy link
Member

Choose a reason for hiding this comment

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

Ok, just hope no one loses their account due to this 😶

@@ -848,34 +848,94 @@ impl pallet_xc_asset_config::Config for Runtime {
scale_info::TypeInfo,
)]
pub enum ProxyType {
Any,
Copy link
Member

Choose a reason for hiding this comment

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

Please add docs for all types - I believe these are even visible in the UX when you select a type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do.

Comment on lines +868 to +871
// Always allowed RuntimeCall::Utility no matter type.
// Only transactions allowed by Proxy.filter can be executed
_ if matches!(c, RuntimeCall::Utility(..)) => true,
Copy link
Member

Choose a reason for hiding this comment

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

I see!

Could we add some tests for this below? 🤔

Copy link
Member

@Dinonard Dinonard left a comment

Choose a reason for hiding this comment

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

Nice, now we have some tests for Shiden.

Just a small CR and let's merge it!

@@ -940,6 +940,201 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
}
}
}
#[cfg(test)]
Copy link
Member

Choose a reason for hiding this comment

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

Great! 🙏

Can you please move all the tests at the bottom?
That way we can keep adding on new ones for other pallets too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure.

Copy link
Member

@Dinonard Dinonard left a comment

Choose a reason for hiding this comment

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

LGTM

@gitofdeepanshu gitofdeepanshu merged commit 66ba05d into master May 4, 2023
@gitofdeepanshu gitofdeepanshu deleted the feat/pallet-proxy-shiden branch May 4, 2023 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants