-
Notifications
You must be signed in to change notification settings - Fork 772
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
Introduce new system origin: DispatchedAs(origin_before, origin_after)
#275
Comments
I wonder if we would need to worry about depth of nesting origins here. |
I don't understand the purpose. Sudo user should have their power on everything. |
Sudo is maybe a bad example. Other uses:
|
I am not sure. It still sounds like a leaky abstraction to me. How do deal with chaining / nested dispatched as origin? How do handle the case when you actually want to modify the original origin? Now the origin permission depends on the original origin and you suddenly make the number of possible states from N to N^2 and that just means more areas of potential bugs. |
I think the runtime is in full control here. For example, at any point, the runtime can drop the current origin, and construct a new one, or modify either field of the And that information is lost in any proxy/dispatch scenario. |
We do have this requirement to implement |
Substrate uses a lot of dispatch and origin manipulation tricks, mostly to dispatch calls from one origin as another origin.
Unfortunately, the history of dispatched origins is lost when this kind of thing happens, and runtime developers may want to know what that history looks like to make more complex decisions.
To enable a feature like this, I suggest we introduce a new system origin:
DispatchedAs(origin_before, origin_after)
This will be an new enum variant, where the dispatcher can specifically include a "before" origin and an "after" origin.
We can make this new origin completely backwards compatible by having functions like
ensure_signed
andensure_root
look at theorigin_after
item. But, now this means we can introduce functions likeorigin.original_origin()
which would either returnorigin_before
or the base origin itself.Then you could have logic like:
While
ensure_root(origin)
would continue to work just fine.The text was updated successfully, but these errors were encountered: