XCM Storage Query

I may just be searching for the wrong information, but I can’t seem to find any standardized way of reading another chain’s state via XCM.

I do realize XCM is probably not meant for reads, but it’s not like it’s impossible to implement a pallet that has a callable function that accepts a storage key and a MultiLocation as input and then sends the scale encoded storage data to that MultiLocation.

This just seems like a pretty useful feature but not only I can’t find an implementation, but I also can’t find anyone searching for it besides myself, as searching for combinations of the terms ‘xcm’, ‘state’, ‘storage’ and ‘query’ in both the substrate github repo and stackexchange yields nothing related to this.

So my question here is: Am I missing something? And if the answer to that question is ‘no’, then my next question is: Is this even something that makes sense to be implemented directly into XCM or should this be it’s own custom pallet?

1 Like

I think that something like this can be built out using Xcm::Transact, so it should be.

It makes sense in that it’s workable but there are also other approaches like having nodes submit merkle proofs that can be used to read the state of other chains. You could also have a chain query the hash of a storage item and then have nodes submit preimages through extrinsics.

Do you think there should be an efficient solution standardized into the XCM protocol? Or should this be considered higher level functionality?

Perhaps dialects could be of some help here too.

Also wondering if I should take this to GitHub and open an issue about it in paritytech/substrate.

Why you can use XCM to push onchain state, it may not be the best idea due to the overhead (especially with XCM-lite phase). This could be a better approach depends on the exact use case Interchain Proof Oracle Network

1 Like