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

Implement storage_changes_root in validation context #37

Closed
bkchr opened this issue Jan 15, 2020 · 4 comments
Closed

Implement storage_changes_root in validation context #37

bkchr opened this issue Jan 15, 2020 · 4 comments

Comments

@bkchr
Copy link
Member

bkchr commented Jan 15, 2020

We need a proper implementation of https://github.com/paritytech/cumulus/blob/master/runtime/src/validate_block/implementation.rs#L261-L264 (host_storage_changes_root).

CC @svyatonik could we make the implementation of storage_changes_root no_std compatible in Substrate? Than we could reuse it here directly.

@svyatonik
Copy link
Contributor

I do not know a lot about the code you've pointed, but it looks like it only has an access to the partial state storage. Changes tries (and therefore storage_changes_root) are using separate storage => separate proof is required. Other than that, I think storage_changes_root could be changed a bit to support no_std env.

A few more words on that - the proof of storage_changes_root() call on CT storage could be huge, because building single changes trie could touch any (potentially large) number of previous tries. I.e. you could configure to build digest trie every 1024 blocks and then for every blocks [1..1023] there'll be some (probably small) changes trie. But at block 1024 you'll need to touch (read all nodes) of all these previous 1023 tries. I'm not aware of the context your function is called (especially where WitnessStorage::witness_data comes from), but probably there could be another way to achieve the same result (without introducing changes tries storage, building changes tries and providing proof-of-build)?

@bkchr
Copy link
Member Author

bkchr commented Jan 17, 2020

Yeah the code linked is Cumulus related, I will give you a more detailed explanation. Cumulus will need to generate code to execute a block on a parachain validator that does not have the full state of the parachain. For that, we have this WitnessData. The WitnessData is collected while building the block on the "collator". We use the WitnessData on the parachain-validator to build the trie that we use as storage while executing/validating the block.

So, we will need to replicate all the storage functions inside of the parachain wasm-blob that is registered on the relay-chain. storage_set, storage_get and the other "storage" functions are relative easy to implement, but I did not know how I should implement storage_changes_root. This is the reason for this issue and I just wanted to make you aware. I think for now it is okay and we can keep this issue to track the problem. We have actually more important stuff, before we need to tackle this :)

@bkchr
Copy link
Member Author

bkchr commented Jul 10, 2020

Depends on: #129

@bkchr
Copy link
Member Author

bkchr commented Dec 22, 2021

Functionality was removed.

@bkchr bkchr closed this as completed Dec 22, 2021
Maharacha pushed a commit to Maharacha/cumulus that referenced this issue May 10, 2023
…tech#46)

* moved some helper functions from chain_spec.rs -> chain_spec_helpers.rs
* changed encointer-root-key fmt into it's SS58 representation to be consistent with the rest.

Tested that local chains produce blocks.

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

No branches or pull requests

2 participants