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

allow treasury to do reserve asset transfers #1447

Merged
merged 32 commits into from
Oct 12, 2023

Conversation

samelamin
Copy link
Contributor

@samelamin samelamin commented Sep 7, 2023

This pr resolves #1428.

Added only to Kusama for now

I did raise it here and we discussed creating a chopsticks test to run an end-to-end test

however, to do that I will need a build agent/custom runner that is powerful enough to run the build

I will be doing that separately as I still think having chopsticks test your runtime with each commit will be very powerful and extremely useful for the ecosystem

For now I have used XCM simulator and replicated what the other reserve tests do

@bkchr
Copy link
Member

bkchr commented Sep 7, 2023

I don't get why you opened this here. The runtimes will be released from the fellowship repo. You also wanted to create a chopsticks test?

TLDR: Please open against the fellowship repo.

@samelamin
Copy link
Contributor Author

I don't get why you opened this here. The runtimes will be released from the fellowship repo. You also wanted to create a chopsticks test?

TLDR: Please open against the fellowship repo.

Sorry, I was under the impression the fellowship repo is read-only till it gets migrated over. My mistake.

I'll make the changes in that repo and close this pr

@samelamin
Copy link
Contributor Author

samelamin commented Sep 7, 2023

reopening after discussion with Basti because this pr requires xcm changes that are not part of the fellowship repo currently

The test currently ensures we can do a reserve asset transfer from the relay chain to a parachain (Penpal)

We can remove all the changes to the runtime itself(and make the runtime changes in the fellowship repo) and only keep the xcm changes

But that would mean we have to remove the test as we need the Treasury Origin enabled so we can do a reserve asset transfer. Otherwise, the test will fail with BadOrigin

Let me know what is best to do :)

@samelamin samelamin reopened this Sep 7, 2023
@franciscoaguirre
Copy link
Contributor

If I understand correctly, you'll leave the change to xcm-builder here, and change the runtimes in the runtimes repo?
And with that, you say you have to remove the test from here?
You could create a test for this with a mock runtime, no need to use the actual repos.

@gavofyork
Copy link
Member

Looks like you're mainly adding a means of converting Treasurer Frame-Origin to a local Plurality XCM-Origin and a means of converting a local Plurality XCM-Origin to a Frame-Origin of the Signed variant of the Treasury account ID.

Presumably you'll be wanting to communicate this XCM between two non-local XCM endpoints, in which case the local Plurality on the source endpoint will be a remote Plurality on the remote endpoint. In this case, your conversion to Treasury account ID won't work.

@samelamin
Copy link
Contributor Author

samelamin commented Sep 7, 2023

Looks like you're mainly adding a means of converting Treasurer Frame-Origin to a local Plurality XCM-Origin and a means of converting a local Plurality XCM-Origin to a Frame-Origin of the Signed variant of the Treasury account ID.

Presumably you'll be wanting to communicate this XCM between two non-local XCM endpoints, in which case the local Plurality on the source endpoint will be a remote Plurality on the remote endpoint. In this case, your conversion to Treasury account ID won't work.

Hey Gav, if I understand your concern, you are saying that this will only work from relay to para.

We can resolve that by adding another match on parent:1. i.e.

		let id: [u8; 32] = match *location {
			MultiLocation { parents: 0, interior: X1(Plurality { id: BodyId::Treasury, .. }) } |
			MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Treasury, .. }) } =>
				PalletId(*b"py/trsry").into_account_truncating(),
			_ => return None,
		};

Alternatively, if the remote plurality looks different we can rename the struct to LocalTreasuryVoiceConvertsVia, and it might make sense given its part of the LocalOriginConverter

Would that be acceptable?

@samelamin
Copy link
Contributor Author

If I understand correctly, you'll leave the change to xcm-builder here, and change the runtimes in the runtimes repo? And with that, you say you have to remove the test from here? You could create a test for this with a mock runtime, no need to use the actual repos.

Hey Cisco, thanks for the tip. Is there an existing test that uses MockRuntime that I should use to keep things consistent

Also I am assuming that if we want to isolate a test for only the xcm changes then all we need to do is test the location conversion right? because the "reserve_asset_transfer" is actually part of the runtime and can be included in a test there?

@samelamin
Copy link
Contributor Author

is there anything else that needs changing in this pr?

@samelamin
Copy link
Contributor Author

Looks like you're mainly adding a means of converting Treasurer Frame-Origin to a local Plurality XCM-Origin and a means of converting a local Plurality XCM-Origin to a Frame-Origin of the Signed variant of the Treasury account ID.

Presumably you'll be wanting to communicate this XCM between two non-local XCM endpoints, in which case the local Plurality on the source endpoint will be a remote Plurality on the remote endpoint. In this case, your conversion to Treasury account ID won't work.

Hi Gav, sorry I think I misunderstood you but _think) I understand you now.

Let's assume Chain A is sending some funds from its treasury to Chain B.

With the current conversion, Chain B will incorrectly assume the funds are coming from its own treasury. The same issue occurs if going from Relay to Chain B

Speaking to @franciscoaguirre, he kindly advised me to use HashedDesciption to match on all remote endpoints, so ill be changing this shortly

samelamin and others added 2 commits September 12, 2023 17:07
Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com>
@samelamin samelamin requested a review from a team as a code owner September 12, 2023 19:50
Copy link
Contributor

@bkontur bkontur left a comment

Choose a reason for hiding this comment

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

please, revert also those imports from cumulus/parachains/integration-tests/emulated/common/src/constants.rs

@samelamin
Copy link
Contributor Author

please, revert also those imports from cumulus/parachains/integration-tests/emulated/common/src/constants.rs

reverted

@bkchr bkchr enabled auto-merge (squash) October 11, 2023 19:04
@bkchr bkchr disabled auto-merge October 12, 2023 09:48
@bkchr bkchr merged commit 70d4907 into paritytech:master Oct 12, 2023
107 of 109 checks passed
@samelamin samelamin deleted the allow_treasury_to_send_xcm branch October 12, 2023 09:59
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 10, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 10, 2024
bkchr pushed a commit that referenced this pull request Apr 10, 2024
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.

Allow TreasuryOrigins to do XCM transfers
7 participants