This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
The storage runtime interface should not enforce a hash type #4231
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
Currently the runtime interface enforces `H256` as hash type, but in the future people could use whatever they want as hash type. The hash type always needs to match between the runtime and the node, but that is already required.
gui1117
reviewed
Nov 27, 2019
gui1117
reviewed
Nov 27, 2019
gui1117
reviewed
Nov 27, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good as far as I can tell
@@ -145,6 +146,7 @@ impl<'a, S, H> ProvingBackendRecorder<'a, S, H> | |||
key: &[u8] | |||
) -> Result<Option<Vec<u8>>, String> { | |||
let root = self.storage(storage_key)? | |||
.and_then(|r| Decode::decode(&mut &r[..]).ok()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why doesn't it returns an error here ?
{ | ||
let default_root = default_child_trie_root::<Layout<H>>(storage_key); | ||
|
||
let mut write_overlay = S::Overlay::default(); | ||
let mut root = match self.storage(storage_key) { | ||
Ok(value) => value.unwrap_or(default_root.clone()), | ||
Ok(value) => | ||
value.and_then(|r| Decode::decode(&mut &r[..]).ok()).unwrap_or(default_root.clone()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this decode fails only on corrupted storage if I understand correctly, maybe it worth a warn or at least a comment
cheme
reviewed
Nov 27, 2019
gavofyork
added
A7-looksgoodtestsfail
and removed
A0-please_review
Pull request needs code review.
labels
Nov 27, 2019
Co-Authored-By: thiolliere <gui.thiolliere@gmail.com>
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.
Currently the runtime interface enforces
H256
as hash type, but in thefuture people could use whatever they want as hash type. The hash type
always needs to match between the runtime and the node, but that is
already required.