-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Manage child trie content independently #4827
Conversation
Note that KeyspacedDB are still use. KeyspacedDBMut only for test.
switching to a btreemap.
allocation whise unless we break all api for a close to nothing perf change: switching to simple single child info struct.
…o child_trie_w3_change
This reverts commit 619b454.
In #5769 I've made prefixing optional for the database that does not require them.
|
So the way it works in #5769 is that you switch at client level the storage accessed by the state machine when querying. And you also need to probably use a MemoryDB overlay in state machine rather than a PrefixedMemory one (actually you drop of additional content from key in client, which also work but is a bit more costy but code is way more readable than having an additional types everywhere). Ok just realize that it was in your comment :) My first version of this PR (the one where child info was put in the journals), acts rather similarly by adding the child trie prefix at the place where #5769 is removing it (but that is can not achieve what #5769 does because the trie prefixes are already here). So the question at this point is 'is this PR of any use' (I am talking from the perspective of the first version where child info was written in journals).
The bads
TLDR; this PR split all data payload in order to allows the db to use child trie definition, and more generally allow db specific process for child trie as in #5280. So even if we decide to drop #5280, this could still be interesting, (if dropped, I do not know if it will be easy to bring back to life). It could make sense to drop those two pr (just wish we did this when they were drafted and got no real alternative for the rent use case). |
I would not complicate things now because of this potential future implementation. If at some point separate storage for child trees would be required, some changes to the backend would still be needed. E.g. rocksdb does not really support dynamic columns, and neither does parity-db at this point. Also, it might make sense to reuse the existing code, rather than extend it. I.e have a separate instance of |
Yes, that is a different way to do it, then state-machine is the only abstraction that cannot in my opinion be split (need to share info between child trie). In #4938 I did rollback these pr change and there was a single place where I needed to keep using child_info as storage input and it was Edit: maybe not a 'lot' more change, but a lot more state-machine change and no client change (not sure how big is the current client changes). |
converted to draft as this is still in progress. |
Closing this as it all depends on replies about question in #5280 (comment) and there is no use in keeping two pr frozen behind this, will reopen if 5280 approach get some kind of positive feedback and we proceed this way. |
This PR is a refactoring of child trie transaction.
Before this PR as single transaction of encoded trie node was produced by state-machine, packing the node from the top trie and the child trie without distinction.
As a result, prefixing rocksdb key by a unique id for child trie was done in state machine crate.
This PR move those key prefixing to client/db/src/lib.rs and split all transaction content between child trie.
We move from a single hashmap of key value to a btreemap of hashmaps of key values, but there will be a less data redundancy.
Main changes:
- change of format for journal of block change and pruning cc @arkpar : - the new format just use a different prefix, so if any change happen we would just change this prefix again. Alternate design would be to include a versioning information in the encoded journal. - the old format is still in use, this costs a double query to fetch old journal. I do not think this is very problematic in the journal case, an alternate way of doing thing would be to migrate all existing journals. I am not sure if it is useful at this point (would need rencode/rewrite of everything to avoid a double query), maybe it is fast, though it should need some testing could be done later.call
will require to isolate each trie payload by key prefix, that is far from ideal). I think this should switch, but it will break light client proof and cumulus witness, so I keep this question out of the scope of this PR. CC @bkchr @jimpoMinor changes
Even if this PR mainly touches internals, it requires changes to polkadot (cheme/polkadot-1@b94eb46 , pr will be created later).