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
+4 -6
View File
@@ -333,9 +333,7 @@ mod tests {
use srml_support::{impl_outer_origin, assert_ok};
use runtime_io::{with_externalities, TestExternalities};
use substrate_primitives::H256;
use runtime_primitives::BuildStorage;
use runtime_primitives::traits::{BlakeTwo256, IdentityLookup};
use runtime_primitives::testing::Header;
use runtime_primitives::{traits::{BlakeTwo256, IdentityLookup}, testing::Header};
impl_outer_origin! {
pub enum Origin for Test {}
@@ -362,7 +360,7 @@ mod tests {
#[test]
fn timestamp_works() {
let mut t = system::GenesisConfig::<Test>::default().build_storage().unwrap().0;
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap().0;
t.extend(GenesisConfig::<Test> {
minimum_period: 5,
}.build_storage().unwrap().0);
@@ -377,7 +375,7 @@ mod tests {
#[test]
#[should_panic(expected = "Timestamp must be updated only once in the block")]
fn double_timestamp_should_fail() {
let mut t = system::GenesisConfig::<Test>::default().build_storage().unwrap().0;
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap().0;
t.extend(GenesisConfig::<Test> {
minimum_period: 5,
}.build_storage().unwrap().0);
@@ -392,7 +390,7 @@ mod tests {
#[test]
#[should_panic(expected = "Timestamp must increment by at least <MinimumPeriod> between sequential blocks")]
fn block_period_minimum_enforced() {
let mut t = system::GenesisConfig::<Test>::default().build_storage().unwrap().0;
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap().0;
t.extend(GenesisConfig::<Test> {
minimum_period: 5,
}.build_storage().unwrap().0);