Reduce usage of Blake2Hasher (#5132)

This reduces the usage of `Blake2Hasher` in the code base and replaces
it with `BlakeTwo256`. The most important change is the removal of the
custom extern function for `Blake2Hasher`. The runtime `Hash` trait is
now also simplified and directly requires that the implementing type
implements `Hashable`.
This commit is contained in:
Benjamin Kampmann
2020-03-05 08:51:03 +01:00
committed by GitHub
parent 406fa981bb
commit 5a33228ea9
64 changed files with 372 additions and 451 deletions
@@ -19,7 +19,7 @@ mod sandbox;
use codec::{Encode, Decode};
use hex_literal::hex;
use sp_core::{
Blake2Hasher, blake2_128, blake2_256, ed25519, sr25519, map, Pair,
blake2_128, blake2_256, ed25519, sr25519, map, Pair,
offchain::{OffchainExt, testing},
traits::Externalities,
};
@@ -28,10 +28,11 @@ use sp_state_machine::TestExternalities as CoreTestExternalities;
use test_case::test_case;
use sp_trie::{TrieConfiguration, trie_types::Layout};
use sp_wasm_interface::HostFunctions as _;
use sp_runtime::traits::BlakeTwo256;
use crate::WasmExecutionMethod;
pub type TestExternalities = CoreTestExternalities<Blake2Hasher, u64>;
pub type TestExternalities = CoreTestExternalities<BlakeTwo256, u64>;
type HostFunctions = sp_io::SubstrateHostFunctions;
fn call_in_wasm<E: Externalities>(
@@ -440,7 +441,7 @@ fn ordered_trie_root_should_work(wasm_method: WasmExecutionMethod) {
wasm_method,
&mut ext.ext(),
).unwrap(),
Layout::<Blake2Hasher>::ordered_trie_root(trie_input.iter()).as_bytes().encode(),
Layout::<BlakeTwo256>::ordered_trie_root(trie_input.iter()).as_bytes().encode(),
);
}