Forward port blake2 storage support (#2360)

* 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>
This commit is contained in:
Bastian Köcher
2019-04-24 11:05:22 +02:00
committed by Gavin Wood
parent 21d1ee4e99
commit f0862606b7
38 changed files with 1101 additions and 732 deletions
+18 -3
View File
@@ -253,17 +253,30 @@ impl std::fmt::Debug for DefaultByteGetter {
}
}
/// Hasher used by storage maps
#[derive(Clone, PartialEq, Eq, Encode)]
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
pub enum StorageHasher {
Blake2_128,
Blake2_256,
Twox128,
Twox256,
Twox64Concat,
}
/// A storage function type.
#[derive(Clone, PartialEq, Eq, Encode)]
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
pub enum StorageFunctionType {
Plain(DecodeDifferentStr),
Map {
hasher: StorageHasher,
key: DecodeDifferentStr,
value: DecodeDifferentStr,
is_linked: bool,
},
DoubleMap {
hasher: StorageHasher,
key1: DecodeDifferentStr,
key2: DecodeDifferentStr,
value: DecodeDifferentStr,
@@ -312,8 +325,10 @@ pub enum RuntimeMetadata {
V1(RuntimeMetadataDeprecated),
/// Version 2 for runtime metadata. No longer used.
V2(RuntimeMetadataDeprecated),
/// Version 3 for runtime metadata.
V3(RuntimeMetadataV3),
/// Version 3 for runtime metadata. No longer used.
V3(RuntimeMetadataDeprecated),
/// Version 4 for runtime metadata.
V4(RuntimeMetadataV4),
}
/// Enum that should fail.
@@ -336,7 +351,7 @@ impl Decode for RuntimeMetadataDeprecated {
/// The metadata of a runtime.
#[derive(Eq, Encode, PartialEq)]
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
pub struct RuntimeMetadataV3 {
pub struct RuntimeMetadataV4 {
pub modules: DecodeDifferentArray<ModuleMetadata>,
}