-
Notifications
You must be signed in to change notification settings - Fork 366
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
Conversation
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.
You will also need to bump semver & spec_version.
ProxyType::Balances => { | ||
matches!(c, RuntimeCall::Balances(..)) |
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.
Might be a good approach to also allow asset transfers.
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.
good suggestion.
ProxyType::DappsStaking => { | ||
matches!(c, RuntimeCall::DappsStaking(..) | RuntimeCall::Utility(..)) | ||
matches!(c, RuntimeCall::DappsStaking(..)) |
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.
We will need this filter to support batch call with DappsStaking calls.
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.
RuntimeCall::Utility(..) is always passed through the filter so no need to add it to every variant.
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.
Tbh, I didn't know that! Good!
runtime/shiden/src/lib.rs
Outdated
Any, | ||
NonTransfer, | ||
Balances, | ||
IdentityJudgement, | ||
CancelProxy, | ||
DappsStaking, |
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.
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, |
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.
Doesn't NonTransafer
also cover many (or all?) types except for Any
?
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.
Doesn't cover Balances.
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.
Still, you'd need to cover those here, right?
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.
Balance is not a superset or subset of any proxy type except Any which is already covered.
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 meant the NonTransfer
in the original message 🙂
It's superset of almost everything - expcet Balances as you noted. Right?
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.
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.
// Always allowed RuntimeCall::Utility no matter type. | ||
// Only transactions allowed by Proxy.filter can be executed | ||
_ if matches!(c, RuntimeCall::Utility(..)) => true, |
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.
Is this intentional?
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.
yes, allows for RuntimeCall::Utility to always pass through the filter for every variant.
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 see!
Could we add some tests for this below? 🤔
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.
Sure.
CancelProxy, | ||
DappsStaking, | ||
} | ||
|
||
impl Default for ProxyType { | ||
fn default() -> Self { | ||
Self::CancelProxy | ||
Self::Any |
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 kind of preferred the last one - less chance to do some damage 🙂
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.
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.
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.
Ok, just hope no one loses their account due to this 😶
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.
🤐
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 just found out that the default has to have full permission.
https://github.com/paritytech/substrate/blob/b2a914c09739478c63d318f6b294901a3290e548/frame/proxy/src/lib.rs#L784
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.
Other than 1 comment I added, it looks good to me
runtime/shiden/src/lib.rs
Outdated
matches!( | ||
c, | ||
RuntimeCall::System(..) | ||
| RuntimeCall::Utility(..) |
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.
This can be also removed
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.
Why not apply changes to Shibuya too first?
That makes sense, will do. |
@shunsukew |
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.
Looks good to me
2ce20f4
to
3d4957b
Compare
} | ||
} | ||
} | ||
|
||
fn is_superset(&self, o: &Self) -> bool { | ||
match (self, o) { | ||
(x, y) if x == y => true, | ||
(ProxyType::Any, _) => true, | ||
(_, ProxyType::Any) => false, |
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.
Still, you'd need to cover those here, right?
ProxyType::DappsStaking => { | ||
matches!(c, RuntimeCall::DappsStaking(..) | RuntimeCall::Utility(..)) | ||
matches!(c, RuntimeCall::DappsStaking(..)) |
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.
Tbh, I didn't know that! Good!
CancelProxy, | ||
DappsStaking, | ||
} | ||
|
||
impl Default for ProxyType { | ||
fn default() -> Self { | ||
Self::CancelProxy | ||
Self::Any |
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.
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, |
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.
Please add docs for all types - I believe these are even visible in the UX when you select a type.
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.
will do.
// Always allowed RuntimeCall::Utility no matter type. | ||
// Only transactions allowed by Proxy.filter can be executed | ||
_ if matches!(c, RuntimeCall::Utility(..)) => true, |
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 see!
Could we add some tests for this below? 🤔
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.
Nice, now we have some tests for Shiden
.
Just a small CR and let's merge it!
runtime/shiden/src/lib.rs
Outdated
@@ -940,6 +940,201 @@ impl InstanceFilter<RuntimeCall> for ProxyType { | |||
} | |||
} | |||
} | |||
#[cfg(test)] |
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.
Great! 🙏
Can you please move all the tests at the bottom?
That way we can keep adding on new ones for other pallets too.
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.
sure.
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.
LGTM
Pull Request Summary
This PR adds new proxy types on Shiden. Previous Iteration: #778
Related #760
Previous Proxy Types
Added Types