mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 22:21:07 +00:00
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:
committed by
GitHub
parent
406fa981bb
commit
5a33228ea9
@@ -21,7 +21,7 @@ use std::collections::HashMap;
|
||||
use sp_core::ChangesTrieConfigurationRange;
|
||||
use sp_core::offchain::OffchainStorage;
|
||||
use sp_runtime::{generic::BlockId, Justification, Storage};
|
||||
use sp_runtime::traits::{Block as BlockT, NumberFor, HasherFor};
|
||||
use sp_runtime::traits::{Block as BlockT, NumberFor, HashFor};
|
||||
use sp_state_machine::{
|
||||
ChangesTrieState, ChangesTrieStorage as StateChangesTrieStorage, ChangesTrieTransaction,
|
||||
StorageCollection, ChildStorageCollection,
|
||||
@@ -43,7 +43,7 @@ pub use sp_state_machine::Backend as StateBackend;
|
||||
pub type StateBackendFor<B, Block> = <B as Backend<Block>>::State;
|
||||
|
||||
/// Extracts the transaction for the given state backend.
|
||||
pub type TransactionForSB<B, Block> = <B as StateBackend<HasherFor<Block>>>::Transaction;
|
||||
pub type TransactionForSB<B, Block> = <B as StateBackend<HashFor<Block>>>::Transaction;
|
||||
|
||||
/// Extracts the transaction for the given backend.
|
||||
pub type TransactionFor<B, Block> = TransactionForSB<StateBackendFor<B, Block>, Block>;
|
||||
@@ -111,7 +111,7 @@ impl NewBlockState {
|
||||
/// Keeps hold if the inserted block state and data.
|
||||
pub trait BlockImportOperation<Block: BlockT> {
|
||||
/// Associated state backend type.
|
||||
type State: StateBackend<HasherFor<Block>>;
|
||||
type State: StateBackend<HashFor<Block>>;
|
||||
|
||||
/// Returns pending state.
|
||||
///
|
||||
@@ -149,7 +149,7 @@ pub trait BlockImportOperation<Block: BlockT> {
|
||||
/// Inject changes trie data into the database.
|
||||
fn update_changes_trie(
|
||||
&mut self,
|
||||
update: ChangesTrieTransaction<HasherFor<Block>, NumberFor<Block>>,
|
||||
update: ChangesTrieTransaction<HashFor<Block>, NumberFor<Block>>,
|
||||
) -> sp_blockchain::Result<()>;
|
||||
|
||||
/// Insert auxiliary keys.
|
||||
@@ -253,7 +253,7 @@ pub trait Backend<Block: BlockT>: AuxStore + Send + Sync {
|
||||
/// Associated blockchain backend type.
|
||||
type Blockchain: BlockchainBackend<Block>;
|
||||
/// Associated state backend type.
|
||||
type State: StateBackend<HasherFor<Block>> + Send;
|
||||
type State: StateBackend<HashFor<Block>> + Send;
|
||||
/// Offchain workers local storage.
|
||||
type OffchainStorage: OffchainStorage;
|
||||
|
||||
@@ -344,10 +344,10 @@ pub trait Backend<Block: BlockT>: AuxStore + Send + Sync {
|
||||
|
||||
/// Changes trie storage that supports pruning.
|
||||
pub trait PrunableStateChangesTrieStorage<Block: BlockT>:
|
||||
StateChangesTrieStorage<HasherFor<Block>, NumberFor<Block>>
|
||||
StateChangesTrieStorage<HashFor<Block>, NumberFor<Block>>
|
||||
{
|
||||
/// Get reference to StateChangesTrieStorage.
|
||||
fn storage(&self) -> &dyn StateChangesTrieStorage<HasherFor<Block>, NumberFor<Block>>;
|
||||
fn storage(&self) -> &dyn StateChangesTrieStorage<HashFor<Block>, NumberFor<Block>>;
|
||||
/// Get configuration at given block.
|
||||
fn configuration_at(&self, at: &BlockId<Block>) -> sp_blockchain::Result<
|
||||
ChangesTrieConfigurationRange<NumberFor<Block>, Block::Hash>
|
||||
@@ -377,7 +377,7 @@ pub trait RemoteBackend<Block: BlockT>: Backend<Block> {
|
||||
pub fn changes_tries_state_at_block<'a, Block: BlockT>(
|
||||
block: &BlockId<Block>,
|
||||
maybe_storage: Option<&'a dyn PrunableStateChangesTrieStorage<Block>>,
|
||||
) -> sp_blockchain::Result<Option<ChangesTrieState<'a, HasherFor<Block>, NumberFor<Block>>>> {
|
||||
) -> sp_blockchain::Result<Option<ChangesTrieState<'a, HashFor<Block>, NumberFor<Block>>>> {
|
||||
let storage = match maybe_storage {
|
||||
Some(storage) => storage,
|
||||
None => return Ok(None),
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
use std::{panic::UnwindSafe, result, cell::RefCell};
|
||||
use codec::{Encode, Decode};
|
||||
use sp_runtime::{
|
||||
generic::BlockId, traits::{Block as BlockT, HasherFor},
|
||||
generic::BlockId, traits::{Block as BlockT, HashFor},
|
||||
};
|
||||
use sp_state_machine::{
|
||||
OverlayedChanges, ExecutionManager, ExecutionStrategy, StorageProof,
|
||||
@@ -89,7 +89,7 @@ pub trait CallExecutor<B: BlockT> {
|
||||
/// Execute a call to a contract on top of given state, gathering execution proof.
|
||||
///
|
||||
/// No changes are made.
|
||||
fn prove_at_state<S: sp_state_machine::Backend<HasherFor<B>>>(
|
||||
fn prove_at_state<S: sp_state_machine::Backend<HashFor<B>>>(
|
||||
&self,
|
||||
mut state: S,
|
||||
overlay: &mut OverlayedChanges,
|
||||
@@ -107,9 +107,9 @@ pub trait CallExecutor<B: BlockT> {
|
||||
/// Execute a call to a contract on top of given trie state, gathering execution proof.
|
||||
///
|
||||
/// No changes are made.
|
||||
fn prove_at_trie_state<S: sp_state_machine::TrieBackendStorage<HasherFor<B>>>(
|
||||
fn prove_at_trie_state<S: sp_state_machine::TrieBackendStorage<HashFor<B>>>(
|
||||
&self,
|
||||
trie_state: &sp_state_machine::TrieBackend<S, HasherFor<B>>,
|
||||
trie_state: &sp_state_machine::TrieBackend<S, HashFor<B>>,
|
||||
overlay: &mut OverlayedChanges,
|
||||
method: &str,
|
||||
call_data: &[u8]
|
||||
|
||||
Reference in New Issue
Block a user