Conversation
|
After a first quick review, do we really need to replicate all this storage stuff? Could we not just take the hashing function as argument for the storage functions? |
|
hmm yes it seems some refactor are doable:
|
There was a problem hiding this comment.
If 128 bits were decided to be enough before — I think it would even be OK to use blake2_128 instead of 256-bit variant (we have that defined as well, AFAICT).
But if I understand it correctly, the performance difference between 128 and 256-bit variants should be minimal, compared to xxHash vs BLAKE2 difference.
So if we're OK with having our storage tries to be of a larger size now — than this issue indeed solves #1868.
|
also cargo run -- --dev: |
That is what I had in my mind. |
Did you purge your db? |
oh no 🤦: here the result |
Yes ok, I'll go for that, (you mean get ride of all of specialized one isn't it ? not making all specialized pointing to this one) |
|
Yep, getting rid of all the specializations. |
Also we could just write and let user hash his key. Maybe your proposition put more insistance into using a hasher which is better |
|
to be honest I can do something like that: /// Return the value of the item in storage under `key`, or `None` if there is no explicit entry.
pub fn get<T, HashFn, HashType>(hash: &HashFn, key: &[u8]) -> Option<T>
where
T: Decode + Sized,
HashFn: Fn(&[u8]) -> HashType,
HashType: AsRef<[u8]>,
{
runtime_io::read_storage(hash(key).as_ref(), &mut [0; 0][..], 0).map(|_| {
let mut input = IncrementalInput {
key,
pos: 0,
};
Decode::decode(&mut input).expect("storage is not null, therefore must be a valid type")
})
}but that feels weird to me for example kill_prefix doesn't really make sense. |
|
I would prefer to go without hash functions. and people to hash themself actually |
|
If we go the way with requiring the user to hash its key before, we should probably merge this into master.
And I don't understand your example. First for the hash function pointer, we don't require a generic parameter. This function pointer could be defined as a type once and used in every. This is the current implementation of I don't know where you took your example from. |
|
it now uses blake2_128, for doing I created ext_blake2_128 call. still have to do refactoring. But benchmark can be started now. |
|
Hmm, if we need to introduce an (In comparison to a normal function call in wasm) |
I think no, we were using ext_twox_128 before and ext_blake2_256 in the first implementation of this PR. Just I introduce it because it wasn't there. But nothing has really changed. |
|
Okay, then forget what I said. I thought that |
|
oh also it breaks UI I think no ? |
|
Yes this will break the gui. |
|
@jacogr note ^^^ |
|
all check have passed, this move all maps to blake2_256, also this update metadata |
Co-Authored-By: thiolliere <gui.thiolliere@gmail.com>
* impl twox_128_concat * comment addressed
|
ok I merged twox128concat reviewed by Basti and move to twox64concat by introducing ext_twox_64 |
|
blake2_128 previously introduced is not really needed anymore but maybe we can keep it |
* remove default hash, introduce twox_128 and blake2 * use blake2_128 & create ext_blake2_128 * refactor code * add benchmark * factorize generator * fix * parameterizable hasher * some fix * fix * fix * fix * metadata * fix * remove debug print * map -> blake2_256 * fix test * fix test * Apply suggestions from code review Co-Authored-By: thiolliere <gui.thiolliere@gmail.com> * impl twox 128 concat (#2353) * impl twox_128_concat * comment addressed * fix * impl twox_128->64_concat * fix test
* move storage maps to blake2_128 (#2268) * remove default hash, introduce twox_128 and blake2 * use blake2_128 & create ext_blake2_128 * refactor code * add benchmark * factorize generator * fix * parameterizable hasher * some fix * fix * fix * fix * metadata * fix * remove debug print * map -> blake2_256 * fix test * fix test * Apply suggestions from code review Co-Authored-By: thiolliere <gui.thiolliere@gmail.com> * impl twox 128 concat (#2353) * impl twox_128_concat * comment addressed * fix * impl twox_128->64_concat * fix test * Fix compilation and cleanup some docs * Apply suggestions from code review Co-Authored-By: bkchr <bkchr@users.noreply.github.com>
* Add failing test case * move storage maps to blake2_128 (#2268) * remove default hash, introduce twox_128 and blake2 * use blake2_128 & create ext_blake2_128 * refactor code * add benchmark * factorize generator * fix * parameterizable hasher * some fix * fix * fix * fix * metadata * fix * remove debug print * map -> blake2_256 * fix test * fix test * Apply suggestions from code review Co-Authored-By: thiolliere <gui.thiolliere@gmail.com> * impl twox 128 concat (#2353) * impl twox_128_concat * comment addressed * fix * impl twox_128->64_concat * fix test * Fix compilation and cleanup some docs * Lol * Remove traits from storage types that are not generic * Get instance test almost working as wanted * Make `srml-support-test` compile again :) * Fixes test of srml-support * Fix compilation * Break some lines * Remove incorrect macro match arm * Integrates review feedback * Update documentation * Fix compilation
* move storage maps to blake2_128 (paritytech#2268) * remove default hash, introduce twox_128 and blake2 * use blake2_128 & create ext_blake2_128 * refactor code * add benchmark * factorize generator * fix * parameterizable hasher * some fix * fix * fix * fix * metadata * fix * remove debug print * map -> blake2_256 * fix test * fix test * Apply suggestions from code review Co-Authored-By: thiolliere <gui.thiolliere@gmail.com> * impl twox 128 concat (paritytech#2353) * impl twox_128_concat * comment addressed * fix * impl twox_128->64_concat * fix test * Fix compilation and cleanup some docs * Apply suggestions from code review Co-Authored-By: bkchr <bkchr@users.noreply.github.com>
…2913) * Add failing test case * move storage maps to blake2_128 (paritytech#2268) * remove default hash, introduce twox_128 and blake2 * use blake2_128 & create ext_blake2_128 * refactor code * add benchmark * factorize generator * fix * parameterizable hasher * some fix * fix * fix * fix * metadata * fix * remove debug print * map -> blake2_256 * fix test * fix test * Apply suggestions from code review Co-Authored-By: thiolliere <gui.thiolliere@gmail.com> * impl twox 128 concat (paritytech#2353) * impl twox_128_concat * comment addressed * fix * impl twox_128->64_concat * fix test * Fix compilation and cleanup some docs * Lol * Remove traits from storage types that are not generic * Get instance test almost working as wanted * Make `srml-support-test` compile again :) * Fixes test of srml-support * Fix compilation * Break some lines * Remove incorrect macro match arm * Integrates review feedback * Update documentation * Fix compilation
This PR point to v1.0
DONE:
TODO: