This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Inner hashing of value in state trie (chainspec versioning).#8931
Closed
cheme wants to merge 142 commits intoparitytech:masterfrom
Closed
Inner hashing of value in state trie (chainspec versioning).#8931cheme wants to merge 142 commits intoparitytech:masterfrom
cheme wants to merge 142 commits intoparitytech:masterfrom
Conversation
cheme
commented
Sep 1, 2021
| trie_nodes: Vec<Vec<u8>>, | ||
| // TODO decode no more bytes to V0 for compatibility and remove pub(crate) | ||
| pub(crate) trie_nodes: Vec<Vec<u8>>, | ||
| pub(crate) state_version: StateVersion, |
Contributor
Author
There was a problem hiding this comment.
Changes proof format by adding state version.
Unresolve question, what is better:
- decode to V0 if state version not encoded, so previous code is guaranted unbroken.
- decode to V1 default if state version is not encoded, so it takes less size, but need coordinated update.
(for compatibility I can use a two byte header in the range of compact value encoding that does not exist by using U8_OUT_OF_RANGE_VALUE for state version)
This reverts commit b695af5, the change was generally worse (more code, more generic parameter).
Member
|
An update on some design decisions after an internal discussion:
|
Contributor
Author
|
About point 1. I have some concern (more work than expected see #8931 (comment) last paragraph). |
Contributor
Author
|
I pushed a bit in the direction of using new host function in master...cheme:state-update4-host2 , still need to test, but looks promising , so part of this PR with state_versioning may be removed soon. |
Contributor
Author
|
Closing in favor of #9732 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR brings alternate hashing of value in substrate.
It uses internally and depends on paritytech/trie#134.
Basically values in trie node got hashed a first time when they are bigger than a given threshold, such as:
hash_leaf = hash(node_header ++ key_partial ++ encoded_value)
alt hashingvalue size >= thresholdhash_leaf = hash(node_header ++ key_partial ++ hash(encoded_value))
and same thing for branches with value.
To avoid migrating data, the alt hashing uses their own node header.
Note that size threshold is allowed to change and is only use when calculating trie root (triedbmut usage) in
order to possibly change type of hashing of modified and new nodes.
Node Headers for
alt_hashingare using unused range of values of previous headers (and possibly expands to an additional byte),making this backward compatible.
The threshold is define as a value in trie state at
:trie_hashing_confas a compact u32 value.So if a trie state does contain this value it will not be backward compatible (no reason to be the case).
Resolution of the threshold is done against
StateVersiondefined in chain spec.Remaining TODOs
polkadot branch: https://github.com/cheme/polkadot-1/tree/state-update4
cumulus branch: https://github.com/cheme/cumulus/tree/state-update4