Implement a proper generic resolution in decl_storage! (#2913)

* 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
This commit is contained in:
Bastian Köcher
2019-06-27 13:40:22 +02:00
committed by GitHub
parent 23ea5d1795
commit 62b7c05def
55 changed files with 1441 additions and 860 deletions
@@ -346,7 +346,7 @@ mod tests {
// getters: pub / $default
// we need at least one type which uses T, otherwise GenesisConfig will complain.
GETU32 get(u32_getter): T::Origin;
pub PUBGETU32 get(pub_u32_getter) build(|config: &GenesisConfig<T>| config.u32_getter_with_config): u32;
pub PUBGETU32 get(pub_u32_getter) build(|config: &GenesisConfig| config.u32_getter_with_config): u32;
GETU32WITHCONFIG get(u32_getter_with_config) config(): u32;
pub PUBGETU32WITHCONFIG get(pub_u32_getter_with_config) config(): u32;
GETU32MYDEF get(u32_getter_mydef): Option<u32> = Some(4);
@@ -716,7 +716,7 @@ mod tests {
#[test]
fn check_genesis_config() {
let config = GenesisConfig::<TraitImpl>::default();
let config = GenesisConfig::default();
assert_eq!(config.u32_getter_with_config, 0u32);
assert_eq!(config.pub_u32_getter_with_config, 0u32);
@@ -820,13 +820,13 @@ mod test_map_vec_append {
use runtime_io::{with_externalities, TestExternalities};
with_externalities(&mut TestExternalities::default(), || {
let _ = <MapVec<Test>>::append(1, &[1, 2, 3]);
let _ = <MapVec<Test>>::append(1, &[4, 5]);
assert_eq!(<MapVec<Test>>::get(1), vec![1, 2, 3, 4, 5]);
let _ = MapVec::append(1, &[1, 2, 3]);
let _ = MapVec::append(1, &[4, 5]);
assert_eq!(MapVec::get(1), vec![1, 2, 3, 4, 5]);
let _ = <JustVec<Test>>::append(&[1, 2, 3]);
let _ = <JustVec<Test>>::append(&[4, 5]);
assert_eq!(<JustVec<Test>>::get(), vec![1, 2, 3, 4, 5]);
let _ = JustVec::append(&[1, 2, 3]);
let _ = JustVec::append(&[4, 5]);
assert_eq!(JustVec::get(), vec![1, 2, 3, 4, 5]);
});
}
}