Extend Utility pallet with multisig and pseudonyms (#4462)

* Add subaccounts functionality

* More work

* Multisig prototyped with tests

* Add timepoints to prevent replay

* Remove TODO

* Check for the right owner in cancel.

* Test the timepoint stuff

* Batch works with any origin

* Refactor tuples into structs.

* Finalise function docs/complexity and also add proper weights.

* Fix wasm

* Module-level docs

* Fix typo

* Runtime fix

* Better deposit system; more tests.

* Fix typo

* Switch +1 for -1

* Add Blake2_128Concat; fix insecurity; change return policy.

* Fix typo

* Update frame/utility/src/lib.rs

Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update frame/utility/src/lib.rs

Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update bin/node/runtime/src/lib.rs

Co-Authored-By: Sergei Pepyakin <sergei@parity.io>

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Sergei Pepyakin <s.pepyakin@gmail.com>
This commit is contained in:
Gavin Wood
2019-12-22 20:41:55 +01:00
committed by GitHub
parent c3413fdea3
commit 3c70800eab
11 changed files with 988 additions and 39 deletions
+23
View File
@@ -24,6 +24,7 @@ use sp_io::hashing::{blake2_128, blake2_256, twox_64, twox_128, twox_256};
pub trait Hashable: Sized {
fn blake2_128(&self) -> [u8; 16];
fn blake2_256(&self) -> [u8; 32];
fn blake2_128_concat(&self) -> Vec<u8>;
fn twox_128(&self) -> [u8; 16];
fn twox_256(&self) -> [u8; 32];
fn twox_64_concat(&self) -> Vec<u8>;
@@ -36,6 +37,9 @@ impl<T: Codec> Hashable for T {
fn blake2_256(&self) -> [u8; 32] {
self.using_encoded(blake2_256)
}
fn blake2_128_concat(&self) -> Vec<u8> {
self.using_encoded(Blake2_128Concat::hash)
}
fn twox_128(&self) -> [u8; 16] {
self.using_encoded(twox_128)
}
@@ -66,6 +70,19 @@ impl StorageHasher for Twox64Concat {
}
}
/// Hash storage keys with `concat(blake2_128(key), key)`
pub struct Blake2_128Concat;
impl StorageHasher for Blake2_128Concat {
type Output = Vec<u8>;
fn hash(x: &[u8]) -> Vec<u8> {
blake2_128(x)
.iter()
.chain(x.into_iter())
.cloned()
.collect::<Vec<_>>()
}
}
/// Hash storage keys with blake2 128
pub struct Blake2_128;
impl StorageHasher for Blake2_128 {
@@ -111,4 +128,10 @@ mod tests {
let r = Twox64Concat::hash(b"foo");
assert_eq!(r.split_at(8), (&twox_128(b"foo")[..8], &b"foo"[..]))
}
#[test]
fn test_blake2_128_concat() {
let r = Blake2_128Concat::hash(b"foo");
assert_eq!(r.split_at(16), (&blake2_128(b"foo")[..], &b"foo"[..]))
}
}