-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Root origin always bypass all filter, other origin cannot bypass BaseCallFilter even when constructed from Root origin #9948
Conversation
frame/support/procedural/src/construct_runtime/expand/origin.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
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
// when caller is system Root. One can use `OriginTrait::reset_filter` to do so. | ||
/// The runtime origin type represanting the origin of a call. | ||
/// | ||
/// Origin is always created with the base filter configured in `frame_system::Config::BaseCallFilter`. |
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.
Using proper intra doc links here would be nice.
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'll do in a follow up when I get more time #9962
@@ -140,7 +141,9 @@ pub fn expand_outer_origin( | |||
} | |||
|
|||
fn filter_call(&self, call: &Self::Call) -> bool { | |||
(self.filter)(call) | |||
// Root bypasses all filters | |||
matches!(self.caller, OriginCaller::system(#system_path::Origin::<#runtime>::Root)) |
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.
matches!(self.caller, OriginCaller::system(#system_path::Origin::<#runtime>::Root)) | |
match self.caller { OriginCaller::system(#system_path::Origin::<#runtime>::Root) => true, _ => false } |
Or use an absolute path to matches!
here.
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.
indeed, done in 84a9ac0
bot merge |
Waiting for commit status. |
Currently when an origin caller is constructed from root then it has no filter, this allowed to have root origin bypassing filters.
But:
reset_filter
then the origin had theBaseCallFilter
regardless of being root or notNow those behavior are "fixed", an origin with a root caller always bypass filter, and if the origin caller is changed this property still hold.
So any origin will have BaseCallFilter (and the added one if some were added) and if the origin caller is root then all filters are bypassed.
Idea from @basti,
cc @athei