-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Makes storage hashers optional in dev mode #13815
Conversation
This looks great! I would definitely add a UI test covering when someone tries to use this syntax without dev mode enabled |
bot fmt |
@gupnik https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/2641655 was started for your command Comment |
@gupnik Command |
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 am not that familiar with the code but looks good.
pallet::MyStorageMap::<Runtime>::insert(1, 2); | ||
let mut k = [twox_128(b"Example"), twox_128(b"MyStorageMap")].concat(); | ||
k.extend(1u32.using_encoded(blake2_128_concat)); | ||
assert_eq!(unhashed::get::<u64>(&k), Some(2u64)); |
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.
Yes thanks for the test!
Normally we only test UI behaviour in the UI tests and not logic, but i think it is fine.
…optional_hashers_dev
error[E0121]: the placeholder `_` is not allowed within types on item signatures for type aliases | ||
--> tests/pallet_ui/dev_mode_without_arg_default_hasher.rs:21:47 | ||
| | ||
21 | type MyStorageMap<T: Config> = StorageMap<_, _, u32, u64>; | ||
| ^ not allowed in type signatures |
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 will confuse people when they disable dev_mode
. They will not get why it doesn't work. I would still be in favor of having Blake2128Concat
as default hasher, even in "normal mode". However, the bare minimum should be a proper error message that tells the user on what to do.
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.
Got it, will fix the error in another PR
I think the fact that this PR has not updated any docs is not good IMO. This is exactly the type of change that does affect the end users of FRAME, and should be better documented going forward -- Do we have any docs for
@gupnik can you make a follow-up? |
@kianenigma Got it. Will raise a follow-up. |
* Initial changes * Adds UI test for error when _ is used without dev_mode * Minor * ".git/.scripts/commands/fmt/fmt.sh" * Adds test to verify hasher --------- Co-authored-by: command-bot <>
As discussed in #13263, this PR adds the ability to make storage hashers as
_
indev_mode
. All code withoutdev_mode
continues to work indev_mode
.