-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Conversation
I like the idea of writing the weighting function right next to the actual dispatchable call. I'm not a fan of the mapping from integers to
I think if you want syntactic sugar to make this easier for the programmer, then allow them to omit the dispatch class entirely and have it default to |
paint/example/src/lib.rs
Outdated
@@ -482,6 +482,15 @@ decl_module! { | |||
Ok(()) | |||
} | |||
|
|||
// TODO: this stuff will move to a new test. | |||
#[weight = sr_primitives::weights::FunctionOf( | |||
|args: (&u32, &T::AccountId, &BalanceOf<T>)| (args.0 + 100) as Weight, |
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 it possible to have type inferring to avoid unnecessary code?
|args: (&u32, &T::AccountId, &BalanceOf<T>)| (args.0 + 100) as Weight, | |
|(val, _, _)| val + 100, |
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.
Sadly, as far s I tried, no
I might not be able to follow a lot here. This can be either merged or left stale for the time being. It will be needed for the next gen. of weights and the new struct is not yet used. Merging it is also harmless and it is done on my opinion. Just have to make sure that there are no merge conflicts, specifically with #4165 |
@gavofyork you can merge this already if you need it, but I am working on closures around |
frame/support/src/weights.rs
Outdated
|
||
impl<Args, F, Class> ClassifyDispatch<Args> for FunctionOf<F, Class> | ||
where | ||
Class: Into<DispatchClass> + Clone, |
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'm not entirely sure about the interest of having the Class abstract here ? can't we just have DispatchClass as second field of FunctionOf directly ?
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.
Yeah I will change it to that. The purpose was to provide a syntactic simplicity. I will do that later with a macro.
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.
removed.
how are we doing here @kianenigma ? |
@gavofyork I will address @thiolliere 's comments soon and label the PR for you merge it in. But don't use it everywhere just yet; maybe just in occasions that we really need a function-like weight. I have some pending changes to Those will come in another PR |
Co-Authored-By: thiolliere <gui.thiolliere@gmail.com>
@kianenigma tests failing... |
Allows easily declaring weights dynamically based on the function argument types. Can be reviewed but need to wait for #4124 to have proper testing first.
cc @JoshOrndorff