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

Added foreign locations to local accounts converter to all the parachains #5765

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

Conversation

x3c41a
Copy link

@x3c41a x3c41a commented Sep 19, 2024

Added HashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>> foreign locations to local accounts converter to all the parachains.

prdoc/pr_5765.prdoc Outdated Show resolved Hide resolved
prdoc/pr_5765.prdoc Outdated Show resolved Hide resolved
prdoc/pr_5765.prdoc Show resolved Hide resolved
Copy link
Contributor

@acatangiu acatangiu left a comment

Choose a reason for hiding this comment

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

Request changes

Do not remove existing converters to maintain backwards compatibility (see following comments)

Testing

For each chain/runtime, please add unit tests (faster/easier than emulated tests) that cover the newly supported conversions.

E.g. you can add new test for asset-hub-westend here, then run it with cargo test -r -p asset-hub-westend-runtime. Do the same for other runtimes too.

In terms of how to test, very easy way is using LocationToAccountHelper::convert_location()` and pass it locations that use to fail conversion, but with your change now succeed.

You can see an example of how to call LocationToAccountHelper here.

@bkontur
Copy link
Contributor

bkontur commented Sep 19, 2024

bot fmt

Copy link

Review required! Latest push from author must always be reviewed

@paritytech paritytech deleted a comment from command-bot bot Sep 19, 2024
@paritytech paritytech deleted a comment from command-bot bot Sep 19, 2024
@x3c41a
Copy link
Author

x3c41a commented Sep 20, 2024

Request changes

Do not remove existing converters to maintain backwards compatibility (see following comments)

Testing

For each chain/runtime, please add unit tests (faster/easier than emulated tests) that cover the newly supported conversions.

E.g. you can add new test for asset-hub-westend here, then run it with cargo test -r -p asset-hub-westend-runtime. Do the same for other runtimes too.

In terms of how to test, very easy way is using LocationToAccountHelper::convert_location()` and pass it locations that use to fail conversion, but with your change now succeed.

You can see an example of how to call LocationToAccountHelper here.

Added the tests. Additionally removed my change and made sure that the tests fail.

@x3c41a x3c41a added A0-needs_burnin Pull request needs to be tested on a live validator node before merge. DevOps is notified via matrix T6-XCM This PR/Issue is related to XCM. and removed A0-needs_burnin Pull request needs to be tested on a live validator node before merge. DevOps is notified via matrix labels Sep 20, 2024
Comment on lines 1362 to 1368
let alice_on_bh = Location::new(
1,
[
Parachain(1111),
Junction::AccountId32 { network: None, id: AccountId::from(ALICE).into() },
],
);
Copy link
Contributor

Choose a reason for hiding this comment

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

alice_on_bh implies BH para id will be used, so either the right para id (not 1111) or change name to sibling_alice or something similar.

Copy link
Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 1369 to 1371
assert_ok!(LocationToAccountHelper::<AccountId, LocationToAccountId>::convert_location(
alice_on_bh.into()
));
Copy link
Contributor

Choose a reason for hiding this comment

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

This location_conversion_works test currently checks one single location conversion: that of an AccountId32 on a sibling parachain.

The test should verify multiple location types conversions. At the very least to completely cover regression testing for the changes in this PR it should cover all branches of DescribeFamily<DescribeAllTerminal>.

That means: 3 valid branches in DescribeFamiliy x 6 valid types of location terminals defined in DescribeAllTerminal = 18 valid locations types to verify.

Also, instead of assert_ok!(), you should check assert_eq!() against the hardcoded converted account, so that we know in the future this conversion doesn't accidentally change (breaking existing derived accounts).

Same comment applies for all the other runtimes tests.

Copy link
Author

Choose a reason for hiding this comment

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

Applied requested changes to a single runtime.
PTAL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T6-XCM This PR/Issue is related to XCM.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants