-
Notifications
You must be signed in to change notification settings - Fork 94
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
Decode with mem limit #616
Conversation
9549654
to
5f17f2e
Compare
5f17f2e
to
5b1b387
Compare
The current implementation is enough for the usage or should we also implement it automatically in derive macro? EDIT: I feel it shouldn't be difficult, except for |
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.
overall looks good to me, some comments.
@gui1117 thank you very much for the review ! Yes, it would be nice to also implement it automatically. Normally it should be an auto trait, but this feature is still unstable so I couldn't use that. Implementing it automatically in the derive macros would be the next best thing, but I didn't manage to do it. For example for:
I tried something that would expand to:
Which generates compile errors. So probably we'll need to implement it manually for each custom struct. |
I see we can't derive it automatically with This macro will do the bound same as Encode/Decode, i.e. bound only the generic types. and it will fail if some concrete types don't implement It would still be more handy than manually write the code I guess. |
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 suggested some more types to implement the trait on.
But part from this it looks good to me.
I'm not sure if it's possible. Unless we add a mock method to the |
I see it now, indeed. :-/ |
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.
Looks good to me.
I still think requiring to implement it manually can be painful. But if the types requiring this are not many then it good.
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.
Did you try this will work on Substrate? I mean you will need to ensure that Call
implements DecodeWithMemTracking
and all the types we are using there.
Also you should expose a function decode_with_mem_limit
instead of exposing the MemLimitInput
Oh, you're right. I can patch
Yes, will do this too. |
This reverts commit 5b1b387.
Yes, sorry, you're right. We need to be able to derive it since for types like |
Done. This compiles for
Done @bkchr Addressed all the comments. PTAL ! |
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.
Some last nitpicks. Otherwise it already looks good :)
@bkchr just wanted to check if you would like to take another look on the PR or if I could merge it as it is since it already has 2 approving reviews |
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.
Nice work 👍 Thank you for doing this!
Related to #609
Ended up with almost the same approach proposed by @ggwpez in #602, but made it type safe through a marker trait.
This is not a breaking change.
The inconvenience is that
DecodeWithMemTracking
will need to be implemented manually for each struct.