-
Notifications
You must be signed in to change notification settings - Fork 707
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
Support custom storage proof from the relay-chain #82
Comments
I remember a discussion between me, @rphmeier and you, @bkchr, where we thought about introducing a special host function that would provide the contents of the given key of the relay-chain storage of the relay parent. A rough idea was something like this:
The advantages of that approach is that the keys are available for querying at As per number 3. I agree that this is the most annoying one. I also had some thoughts about it and they also involved a wasm blob. In my thoughts it was a bit different angle though. Roughly It goes like this.
This way the relay-chain controls explicitly what it exposes and can move forward independently. The downside is that there is delay involved when negotiating with the governance. However, I think that it is a good thing: I think it's better that each dependency on the relay-chain structure is explicit and each particular case is carefully assessed with respect to the long-term maintenance burden. In contrast, just opening up any storage storage a parachain can reach is just a recipe for a long-term maintenance nightmare. |
Totally forgot about this one! Still a good idea :)
I like this idea! Would this extra wasm blob be dynamically linked to the parachain runtime? So that the parachain can call one of these functions? |
That's a good question, I wasn't thinking through the details. I think it's a possibility, although the Rust/Wasm dynamic linking story is a bit fuzzy though. But whatever is easy to use and performant enough. |
How often can the wasm blob change? We will have to be careful that it is still easy to execute parablocks after-the-fact even when state pruned. This wasm blob could be in the |
Store it in the state? I think this shim wasm blob should be way slimmer than the runtime itself. |
If I understand, this moves us much of the way to contextual execution too. We could also announce these more than 48 hours in advance, which helps address their availability problem. |
Is this only about collators reading the state of the relay chain? Could this be related or is it a complete different beast to read storage from other parachains? polkadot-fellows/xcm-format#16 |
Well, yes, this is about reading of the relay chain state. I think this is at least somewhat related to reading the storage of other parachains. Reading the storage of other parachains is very specific on the parachain itself, but at least one part is shared: you typically need to get some sort of commitment like a merkle root, and that should be stored in a head data of the parachain which is stored in the relay chain state. |
Step 2 is definitely the complicating factor. I think it would be better to try to do this entirely on the runtime side. What we could do is set up the runtime so that The good thing about this approach is that PVF execution and regular substrate import follows the exact same code-path (no relay chain state required) and only block authorship needs the host function to actually query data from the relay-chain state. In the beginning of In the beginning of At the end of This will require some modification of the executive to pull off. I am also not sure what will happen with other runtime APIs that invoke |
As long as we have the native runtime, this will not work. Host function overriding is currently not supported on the native side. But yeah, we want to get rid of the native runtime anyway. Something that I don't like is that you could not read data in |
This issue has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/state-proof-based-parachain-parachain-messaging/2214/3 |
This would be solved in ISMP by: polytope-labs/ismp-substrate#62 |
This will not solve this issue. What you are having there is an async way of requesting data. |
What's wrong with async? |
That it doesn't solve issues that are currently being solved by the proof inside inherent. |
Not sure what you mean here, ISMP uses inherents to respond to GET requests. If you're envisioning a solution that leverages inherents, then your design is async as well. |
The collator is already suitable to generate a storage proof of some specific keys and pass it to the runtime as inherent: https://github.com/paritytech/cumulus/blob/master/collator/src/lib.rs#L203
Currently this is mainly used to pass information about the state of message passing into the parachain. However, we want to open this for parachains to read whatever storage item they are interested in. This would enable parachains to read every item of the relay chain, for example the BABE randomness to use this in their runtime.
The foundation is there, we can read a given key and put it into a storage proof that is passed to the runtime. The following is still missing:
cumulus-system
to signal that the storage proof is now available (it is passed as inherent, so it comes afteron_initialize
and some way to read values from this proof.well_known_keys
for this, but this would not work as we can not foresee from the relay chain side which items will be required by the parachain. We also need a solution that enables us to change some storage key/move a storage item without waiting X months until the full ecosystem is moved (just assume we want to change some key in staking in Substrate).Number 3. will be clearly the hardest part of this issue. All these issues are solvable on its own.
For 3. I could imagine that we do the storage key collection in some wasm blob. This wasm-blob would be build against the current relay-chain runtime blob. It would only be required to expose one function to collect the keys and return it as a
Vec<Vec<u8>>
. Inside this blob we would have access to all storage items, of all pallets being used by the relay chain runtime (This would require that we change the pallet macros to expose the storage keys of all storage items of a pallet). If we would have such a WASM blob and there is a pending relay-chain runtime upgrade, it would still require some manual intervention as all parachains would need to update their WASM blob and issue an update of this (a hash of this WASM blob would probably be stored on chain and fetched from "somewhere" or it would be stored directly in the state 🙈 like the runtime wasm blob). After all parachains have done this/we waited long enough, the council could issue the runtime upgrade. This requires quite a lot of coordination, but is way faster than doing it in some more hard-coded way where we would need to wait until all nodes of all parachains are upgraded.The text was updated successfully, but these errors were encountered: