-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add log and warning about inserting empty values in trie. #6121
Conversation
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 not also add the proposed change for decl_storage
directly? I think if we have this, we will have covered 98% of all failures.
You mean the #[derive(Encode)]
enum StorageVersion {
#[codec(index = "3")]
_3
} |
though maybe I can try to make a const_assert that value_type must not be |
I thought more about the following:
Will generate:
The I think that is the best we can do. |
frame/support/procedural/src/lib.rs
Outdated
@@ -50,6 +50,9 @@ use proc_macro::TokenStream; | |||
/// prefix. Instance prefix is "" for default instance and "Instance$n" for instance number $n. | |||
/// Thus, instance 3 of module Example has a module prefix of `Instance3Example` | |||
/// | |||
/// **Warning**: storage doesn't support inserting empty values, so the value must encode to |
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.
We should probably make this a sub-heading as well to make it more prominent, otherwise it may goes down in the overall text?
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.
I added a section Warning at the end and kept this one.
* add compile time test fr Option<()> and () * add runtime tests for value with defaults * add warning section in decl_storage (end keep inline warning)
done: tests generation for storage without option. And compile error for |
ok not sure this PR is wanted anymore, I can still finish it until we fix the support of empty values. |
Yeah, not sure either. |
Given the conversation in Substrate, I don't think that this is still needed. |
as a first step into fixing #5986
I updated doc and log so that it is clear that inserting an empty value is not supported. Test should fails with the debug_assert and in-production chain must log error when set an empty value in trie or child trie.