Skip to content
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

staging-xcm: Use versioned_type! for VersionedXcm #4378

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

dastansam
Copy link
Contributor

closes #3846

@dastansam dastansam requested a review from a team as a code owner May 4, 2024 13:08
@dastansam dastansam changed the title Use versioned_type! for VersionedXcm staging-xcm: Use versioned_type! for VersionedXcm May 4, 2024
@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: test-linux-stable 3/3
Logs: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/6127747

@dastansam dastansam marked this pull request as draft May 4, 2024 13:44
@dastansam dastansam marked this pull request as ready for review May 4, 2024 23:34
VersionedXcm::V2(x)
}
}

impl<RuntimeCall> From<v3::Xcm<RuntimeCall>> for VersionedXcm<RuntimeCall> {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this staying?

polkadot/xcm/src/lib.rs Outdated Show resolved Hide resolved
polkadot/xcm/src/lib.rs Outdated Show resolved Hide resolved
@@ -77,6 +77,37 @@ pub trait TryAs<T> {
}

macro_rules! versioned_type {
(@internal $n:ident, $v3:ty, ) => {
// only impl `MaxEncodedLen` for enums without generic type parameters
Copy link
Member

Choose a reason for hiding this comment

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

It makes no sense that this is separate.

Copy link
Contributor Author

@dastansam dastansam May 5, 2024

Choose a reason for hiding this comment

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

MaxEncodedLen is not implemented for Xcm structs of VersionedXcm, so impl it fails. This is a workaround I did to exclude VersionedXcm from it implementing MaxEncodedLen. Open to suggestions for a more idiomatic way of handling it

// only impl `MaxEncodedLen` for enums without generic type parameters
impl MaxEncodedLen for $n {
fn max_encoded_len() -> usize {
<$v3>::max_encoded_len()
Copy link
Member

Choose a reason for hiding this comment

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

This should be the max of all variants.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

some enums' 2nd versions do not implement MaxEncodedLen, v3 and v4 all implement it, so I am now taking max of v3 and v4

@dastansam dastansam requested a review from bkchr May 5, 2024 23:40
@franciscoaguirre franciscoaguirre added the T6-XCM This PR/Issue is related to XCM. label May 8, 2024
@bkchr bkchr added the R0-silent Changes should not be mentioned in any release notes label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R0-silent Changes should not be mentioned in any release notes T6-XCM This PR/Issue is related to XCM.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VersionedXcm is not created with versioned_type
4 participants