I had a much larger conversation (which Keith is referencing) about this topic but unfortunately it’s in the Parity XCM channel.
Basically, we need a means of querying some information encoded within a chain’s state. This system must:
- not require computation to be done on the target chain
- work as well when the querying system is on-chain (ie within a runtime or smart contract) as well as if it’s off-chain (eg a script or light client)
- work just as well for any chain which can provide some basic metadata (much like XCM works well for any chain which contains an implementation of an XCM executor)
- be extensible and work across a variety of use cases not just the obvious ones right now (eg balance querying)
XCM contains some useful primitives as Shawn says like MultiLocation and MultiAsset. However it is ultimately a scripting language for mutating state. It is not a query language. Retrofitting querying primitives would convolute it at basically zero gain. It’s conceivable that XCQ could be a linguistic subset of XCM, but I think it’s not necessary to determine that at this point.
What we (may soon) have is a means of querying one or more values in a chain’s state, and assuming we have ground truth on the state’s merkle root then have certainty that these values are genuine.
However the meaning of these values is in general unknown. XCQ can be considered a means of giving these values meaning, and to determine which keys’ values are needed for any given meaning to be determinable. In Star Trek terms, it’s a code sheet for the universal translator, to both tell us what to actually ask for from state for any given piece of information to be determined and to translate this witness data into our final result.
It lets chains (which have co-knowledge of each other’s state roots via e.g. a bridge or shared relay) understand the information within each other’s state and it lets scripts (which have knowledge of a target chain’s state root e.g. by Smoldot) to utilise the information held within the chain’s state; and, crucially, it does so without any kind of operational requirement on the chain being queried. In particular there’s no need to add RPCs or use any particular software. It’s fully compatible with the information-logistics model provided by Smoldot.