-
Notifications
You must be signed in to change notification settings - Fork 377
Add support to DecodeWithMemTracking #315
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
base: v0.x
Are you sure you want to change the base?
Conversation
@@ -154,7 +174,7 @@ pub enum ExitError { | |||
|
|||
/// Other normal errors. | |||
#[cfg_attr(feature = "with-codec", codec(index = 13))] | |||
Other(Cow<'static, str>), | |||
Other(String), |
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.
Why?
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.
Because DecodeWithMemTracking
is not supported for str
so this was the only way to fix it I found.
the trait `DecodeWithMemTracking` is not implemented for `str`, which is required by `Cow<'static, str>: DecodeWithMemTracking
Open to suggestions
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.
Can we add DecodeWithMemTracking
to Cow<'static, str>
in parity-scale-codec
? Seems like it should have been implemented there.
(In this case, scale decoding will always return Cow::Owned
, which is String
.)
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.
DecodeWithMemTracking is already implemented for Cow
But the problem is with str
since pub trait Decode: Sized
and str
does not implements Sized
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.
nevermind, I think I found a walk around just by adding impl DecodeWithMemTracking for Cow<'static, str> {}
in parity-scal-codec, I'll propose that change. Thanks
Tried again and I cannot find a way to implement DecodeWithMemTracking
for str
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.
Ok so far I opened an issue on their side, but I would really like to merge this in order to unblock other changes that need it.
Do we know how big is the performance implication in case of using String
instead of Cow
?
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.
New update: Basti opened a PR to solve it 🙌
Description
Add support to
DecodeWithMemTracking
that is required to upgrade another dependencies that depends on this one to polkadotstable2503
Also upgrade ethereum to include my latest commit
Similar to what I did with rust-ethereum/ethereum#62