This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
implement dispatch_as #9934
Merged
Merged
implement dispatch_as #9934
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f984779
implement dispatch_as
xlc 5e54996
fix
xlc 4e19053
fix
xlc 7e8e8c4
Merge remote-tracking branch 'origin/master' into dispatch-as
xlc 0722dcf
weight for dispatch_as
xlc 50edea8
Merge branch 'master' of https://github.com/paritytech/substrate into…
d3f9c81
cargo run --quiet --release --features=runtime-benchmarks --manifest-…
f9c1fa7
fix
xlc 2b879fc
Update frame/utility/src/benchmarking.rs
xlc 0187df5
fix issues
xlc 657009c
Merge branch 'master' into pr/9934
shawntabrizi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
weight for dispatch_as
- Loading branch information
commit 0722dcf0932d842a07985d7cd73651b692f53e9e
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,7 +97,9 @@ pub mod pallet { | |
| + IsType<<Self as frame_system::Config>::Call>; | ||
|
|
||
| /// The caller origin, overarching type of all pallets origins. | ||
| type PalletsOrigin: Parameter + Into<<Self as frame_system::Config>::Origin>; | ||
| type PalletsOrigin: Parameter + | ||
| Into<<Self as frame_system::Config>::Origin> + | ||
| IsType<<<Self as frame_system::Config>::Origin as frame_support::traits::OriginTrait>::PalletsOrigin>; | ||
|
|
||
| /// Weight information for extrinsics in this pallet. | ||
| type WeightInfo: WeightInfo; | ||
|
|
@@ -337,26 +339,26 @@ pub mod pallet { | |
| /// - O(1). | ||
| /// - Limited storage reads. | ||
| /// - One DB write (event). | ||
| /// - Weight of derivative `call` execution + 10,000. | ||
| /// - Weight of derivative `call` execution + T::WeightInfo::dispatch_as(). | ||
| /// # </weight> | ||
| #[pallet::weight({ | ||
| let dispatch_info = call.get_dispatch_info(); | ||
| ( | ||
| dispatch_info.weight | ||
| .saturating_add(10_000) | ||
| T::WeightInfo::dispatch_as() | ||
| .saturating_add(dispatch_info.weight) | ||
| // AccountData for inner call origin accountdata. | ||
| .saturating_add(T::DbWeight::get().reads_writes(1, 1)), | ||
xlc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| dispatch_info.class, | ||
| ) | ||
| })] | ||
| pub fn dispatch_as( | ||
| origin: OriginFor<T>, | ||
| as_origin: T::PalletsOrigin, | ||
| as_origin: Box<T::PalletsOrigin>, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to box it? It wasn't boxed before you added the benchmark. We should solve it there when possible.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is generally good idea to box big data structure in call parameter to avoid increase the Call enum size. the same reason box is used elsewhere.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. I thought it was related to the benchmarks. Didn't know that this is a big argument, though. |
||
| call: Box<<T as Config>::Call>, | ||
| ) -> DispatchResult { | ||
| ensure_root(origin)?; | ||
|
|
||
| let res = call.dispatch_bypass_filter(as_origin.into()); | ||
| let res = call.dispatch_bypass_filter((*as_origin).into()); | ||
|
|
||
| Self::deposit_event(Event::DispatchedAs(res.map(|_| ()).map_err(|e| e.error))); | ||
| Ok(()) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.