Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Configurable send origin in XCM handler #339

Closed
shaunxw opened this issue Feb 24, 2021 · 7 comments · Fixed by #346
Closed

Configurable send origin in XCM handler #339

shaunxw opened this issue Feb 24, 2021 · 7 comments · Fixed by #346

Comments

@shaunxw
Copy link
Contributor

shaunxw commented Feb 24, 2021

XCM handler module has dispatchable calls to send messages, but the origin must be root.

fn sudo_send_xcm(origin, dest: MultiLocation, message: Xcm) {
ensure_root(origin)?;

It will be helpful to make the origin configurable, so that it can work with pallet-collective. For instance, config the send origin as EnsureRootOrHalfCouncil.

@bkchr
Copy link
Member

bkchr commented Feb 24, 2021

As the name suggests, these are sudo related dispatchables for testing purposes not as a general way to send these messages.

@shaunxw
Copy link
Contributor Author

shaunxw commented Feb 24, 2021

Parachains needs to send upward message to init/accept HRMP channel requests. Before this issue solved, there is no way to add helper dispatchable calls to do these tasks. However it seems the issue cannot be solved in short term. Could you suggest a way if these testing sudo calls removed in the future?

@shaunxw
Copy link
Contributor Author

shaunxw commented Feb 24, 2021

Maybe we can add a more specific dispatchable call, which only sends upward Xcm::Transact message, to help parachains managing HRMP channels (or other future calls which checks ensure_parachain origin in relay chain). Like this:

fn send_upward_xcm_transact(origin, call: Vec<u8>) {
    T::SendOrigin::ensure_origin(origin)?;
    let msg = Xcm::Transact {
        origin_type: OriginKind::Native,
        call: call,
    };
    // send upward msg...
}

@bkchr
Copy link
Member

bkchr commented Feb 24, 2021

Best is to ask @pepyakin on what he thinks about this.

@pepyakin
Copy link
Contributor

I distanced a bit from XCM lately and not that well versed in the specifics of the pallet-collective, so I think @shawntabrizi is the man here.

However, I can note that this particular use case could be addressed using an intermediate pallet, which could accept calls from, e.g pallet-collective and manually prepare and send a message. Gross but works.

@shawntabrizi
Copy link
Member

I think having a configurable origin is a fine change and doesn't really change the pallet. Probably you would want to remove the word sudo though

As for creating a root call, you can do so in Democracy with do_enact_proposal:

https://github.com/paritytech/substrate/blob/master/frame/democracy/src/lib.rs#L1540

Which can be executed by an collective as an ExternalMajorityOrigin. This is how Runtime Upgrades happen...

@shaunxw
Copy link
Contributor Author

shaunxw commented Feb 24, 2021

I think having a configurable origin is a fine change and doesn't really change the pallet. Probably you would want to remove the word sudo though

I'm happy to open a PR to do this. Will make these send xcm dispatchable calls use configurable origin and remove word sudo.

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

Successfully merging a pull request may close this issue.

4 participants