-
Notifications
You must be signed in to change notification settings - Fork 53
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
Finish implementing state_version = 1 #230
Merged
Merged
Conversation
This file contains 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
twiggy diff reportDifference in .wasm size before and after this pull request.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Close #221
This PR finishes the implementation of the
state_version = 1
feature, also known as the trie v1.This hasn't been tested thoroughly. However, the code for trie v0 and trie v1 is the same everywhere (the version is a value that can be either 0 or 1) except for the trie node encoding code which is known to work. For this reason, I have high confidence that it should work, in the sense that I don't see what could not work.
In terms of logic, each entry in the storage now has a "trie entry version" attached to it, whose value is either 0 or 1. Whenever a storage value is written, the corresponding trie entry version is indicated. When the storage value is retrieved, the trie entry version must be provided back. Note that providing the version back is only necessary for
runtime_host
and not forread_only_runtime_host
, as the latter never needs to calculate any trie hash.In terms of API, the biggest changes are:
StorageDiff
struct now attaches a value to each entry in the diff, and has a template parameter indicating the type of this value. Often it'sStorageDiff<()>
that is used, but inoptimistic.rs
it's aStorageDiff<TrieEntryVersion>
.StorageGet::inject_value
must be passed the version of the storage entry.Some
, because if there is no value then the version doesn't matter. This change solves a couple of weird cases where we passed a dummy version.CoreVersionRef::state_version
is now aTrieEntryVersion
(an enum which can be eitherV0
orV1
) instead of au8
.This PR breaks the database format of the full node and the database must be purged. Given that the full node is experimental, I don't want to bother with a migration system at the moment, even though the migration would be quite easy here.