-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Refactor SignedExtension #5540
Refactor SignedExtension #5540
Conversation
|
It looks like @athei signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
tomusdrw
left a comment
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.
on the right track, but we need to reduce boilerplate
kianenigma
left a comment
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 realised something:
I don't think it actually makes sense for dispatchInfo to be generic at the moment. Maybe we can make it generic, but currently it isn't.
otherwise, it doesn't even make sense for it to be generic as it is since it is kinda hard-coded in frame-support::dispatch. Your weight annotation must return weight + pays_fee + class and then they get bundled into this type DispatchInfo.
Yes, you can use any type to compute these 3, but they are fixed themselves. From this PoV I think this work needs to be refactored again.
I recommend merging this PR leniently just to unblock weight refund and I can make a follow up asap and my goal would be actually to either rethink the whole process or make it un-generic, as it used to be.
|
An alternative approach would be that I pass the |
Yes, I think @athei is fully aware of that, but it making it a fixed type would require moving
I think this PR looks good and is a bit nicer than current approach, so I think we should merge it as is (especially that it unlocks stuff). We can further change it in the future if needed. |
|
Ugh, yes. So it's now generic, since weight is |
|
Yes |
* Move DispatchInfo Associated type to Dispatchable * Bound Call: Dispatchable * Pass PostDispatchInfo to post_dispatch * Pass DispatchInfo by reference to avoid clones
Co-Authored-By: Tomasz Drwięga <[email protected]>
Co-Authored-By: Kian Paimani <[email protected]>
dabb4d3 to
211334a
Compare
That would be nice. I think I addressed all raised concerns now. Praying to CI gods. |
Co-Authored-By: Bastian Köcher <[email protected]>
|
I added the Polkadot companion and tested it against this PR locally. |
…adot#986 (paritytech#982) * Companion PR to paritytech#5560 * Set priorities. * Update substrate. * Fix tests. * Update Substrate * Companion of SignedExtension refactor (paritytech#5540) Co-authored-by: Tomasz Drwięga <[email protected]> Co-authored-by: Alexander Theißen <[email protected]>
polkadot companion: paritytech/polkadot#979
This PR refactors the trait
SignedExtension. The following changes where applied:Move the
DispatchInfoassociated type toDispatchable::InfoThis information logically belongs to the
Dispatchable. Not having it there requires consuming types to duplicate this as an associated type (SignedExtension, Applyable).Bound
Call: DispatchableThis is a requirement for the first change. Because the
DispatchInfotype is now an associated type onDispatchable.Pass
Dispatchable::PostInfotoSignedExtension::post_dispatchThis is a followup of #5458 that passes this new information to the
SignedExtensionwhere it can then be used to accomplish weight refund (in a followup PR).Pass
Dispatchable::Infoby referenceThere was no apparent reason (or is there one?) for having
DispatchInfoto be cloned into everySignedExtension.