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
@@ -237,7 +237,7 @@ fn generate_runtime_api_base_structures() -> Result<TokenStream> {
pub struct RuntimeApiImpl<Block: #crate_::BlockT, C: #crate_::CallApiAt<Block> + 'static>
where
// Rust bug: https://github.com/rust-lang/rust/issues/24159
C::StateBackend: #crate_::StateBackend<#crate_::HasherFor<Block>>,
C::StateBackend: #crate_::StateBackend<#crate_::HashFor<Block>>,
{
call: &'static C,
commit_on_success: std::cell::RefCell<bool>,
@@ -257,7 +257,7 @@ fn generate_runtime_api_base_structures() -> Result<TokenStream> {
for RuntimeApiImpl<Block, C>
where
// Rust bug: https://github.com/rust-lang/rust/issues/24159
C::StateBackend: #crate_::StateBackend<#crate_::HasherFor<Block>>,
C::StateBackend: #crate_::StateBackend<#crate_::HashFor<Block>>,
{}
#[cfg(any(feature = "std", test))]
@@ -265,7 +265,7 @@ fn generate_runtime_api_base_structures() -> Result<TokenStream> {
for RuntimeApiImpl<Block, C>
where
// Rust bug: https://github.com/rust-lang/rust/issues/24159
C::StateBackend: #crate_::StateBackend<#crate_::HasherFor<Block>>,
C::StateBackend: #crate_::StateBackend<#crate_::HashFor<Block>>,
{}
#[cfg(any(feature = "std", test))]
@@ -273,7 +273,7 @@ fn generate_runtime_api_base_structures() -> Result<TokenStream> {
for RuntimeApiImpl<Block, C>
where
// Rust bug: https://github.com/rust-lang/rust/issues/24159
C::StateBackend: #crate_::StateBackend<#crate_::HasherFor<Block>>,
C::StateBackend: #crate_::StateBackend<#crate_::HashFor<Block>>,
{
type Error = C::Error;
}
@@ -283,7 +283,7 @@ fn generate_runtime_api_base_structures() -> Result<TokenStream> {
RuntimeApiImpl<Block, C>
where
// Rust bug: https://github.com/rust-lang/rust/issues/24159
C::StateBackend: #crate_::StateBackend<#crate_::HasherFor<Block>>,
C::StateBackend: #crate_::StateBackend<#crate_::HashFor<Block>>,
{
type StateBackend = C::StateBackend;
@@ -327,7 +327,7 @@ fn generate_runtime_api_base_structures() -> Result<TokenStream> {
&self,
backend: &Self::StateBackend,
changes_trie_state: Option<&#crate_::ChangesTrieState<
#crate_::HasherFor<Block>,
#crate_::HashFor<Block>,
#crate_::NumberFor<Block>,
>>,
parent_hash: Block::Hash,
@@ -351,7 +351,7 @@ fn generate_runtime_api_base_structures() -> Result<TokenStream> {
where
C: #crate_::CallApiAt<Block> + 'static,
// Rust bug: https://github.com/rust-lang/rust/issues/24159
C::StateBackend: #crate_::StateBackend<#crate_::HasherFor<Block>>,
C::StateBackend: #crate_::StateBackend<#crate_::HashFor<Block>>,
{
type RuntimeApi = RuntimeApiImpl<Block, C>;
@@ -373,7 +373,7 @@ fn generate_runtime_api_base_structures() -> Result<TokenStream> {
impl<Block: #crate_::BlockT, C: #crate_::CallApiAt<Block>> RuntimeApiImpl<Block, C>
where
// Rust bug: https://github.com/rust-lang/rust/issues/24159
C::StateBackend: #crate_::StateBackend<#crate_::HasherFor<Block>>,
C::StateBackend: #crate_::StateBackend<#crate_::HashFor<Block>>,
{
fn call_api_at<
R: #crate_::Encode + #crate_::Decode + PartialEq,
@@ -603,7 +603,7 @@ impl<'a> Fold for ApiRuntimeImplToApiRuntimeApiImpl<'a> {
where_clause.predicates.push(
parse_quote! {
RuntimeApiImplCall::StateBackend:
#crate_::StateBackend<#crate_::HasherFor<__SR_API_BLOCK__>>
#crate_::StateBackend<#crate_::HashFor<__SR_API_BLOCK__>>
}
);