Skip to content

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

Open
wants to merge 2 commits into
base: v0.x
Choose a base branch
from

Conversation

dimartiro
Copy link

@dimartiro dimartiro commented May 14, 2025

Description

  • Add support to DecodeWithMemTracking that is required to upgrade another dependencies that depends on this one to polkadot stable2503

  • Also upgrade ethereum to include my latest commit

Similar to what I did with rust-ethereum/ethereum#62

@@ -154,7 +174,7 @@ pub enum ExitError {

/// Other normal errors.
#[cfg_attr(feature = "with-codec", codec(index = 13))]
Other(Cow<'static, str>),
Other(String),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Author

@dimartiro dimartiro May 14, 2025

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

Copy link
Member

@sorpaas sorpaas May 14, 2025

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.)

Copy link
Author

@dimartiro dimartiro May 14, 2025

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

Copy link
Author

@dimartiro dimartiro May 14, 2025

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

Copy link
Author

@dimartiro dimartiro May 14, 2025

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?

Copy link
Author

@dimartiro dimartiro May 14, 2025

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 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants