-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Multiple storage roots #872
Comments
looks good.
chatting to @vbuterin i expect shasper to want to do this eventually, so we should probably include the option of parameterising each storage db by some means (not least trie type) |
Right now multiple trie formats can be supported. However, another issue I'm facing at the moment is that it's not yet possible to support multiple hash formats -- the hash generic is set by I don't think this is a huge issue, though -- most blockchains, even with multiple trie formats, will usually stick to one given hash format (ethereum -- keccak256, shasper -- blake2). This is also the case for UTXO. Edit: found a way to solve this, described in paritytech/trie#2 |
is this still open @sorpaas ? |
@gavofyork Yeah it's still open pending #1106. |
The final task for this is to add a generic parameter to Client/Service that accepts a |
Discussed with @gavofyork this morning. I think the conclusion is that a generic trie wouldn't really fit Substrate's philosophy, and we'd rather have fixed hash algorithm for tries we want to support. Our current implementation can already do that. So I think this issue can be closed. |
In blockchains like Ethereum and Shasper, we need additional hashes of child storage root, for example:
In Substrate, currently it's only possible to fetch the toplevel storage hash, and subsequent storage maps are stored in the toplevel storage, so it's not yet possible to compute the above value using builtin intrinsics.
Below is a possible design I have in mind to add support to this. Basically, it uses a well known key prefix in the top level storage (let's call it
sys:maps:
) to store all child storage root hashes, and backend would commit multiple changesets of all toplevel and child storage.Ext::place_child_storage(storage_key: Vec<u8>, key: Vec<u8>, value: Option<Vec<u8>>)
,Ext::child_storage(storage_key: &[u8], key: &[u8]) -> Option<Vec<u8>>
for writing and reading child storage.Ext::child_storage_root(storage_key: &[u8]) -> H256
for computing the child storage root.Ext::kill_child_storage(storage_key: &[u8])
for removing a child storage slot completely (it computes theChangeSet
needed to completely remove the child trie).:child_storage:
before the toplevel storage is committed.:child_storage:
is disallowed.Several alternatives:
&[]
. However, this breaks existing Substrate deployments.Some unresolved issues:
The text was updated successfully, but these errors were encountered: