change HashFor to HashingFor (#14483)

* change HashFor to HashingFor

* fmt

* ".git/.scripts/commands/fmt/fmt.sh"

---------

Co-authored-by: command-bot <>
This commit is contained in:
Marijn Schouten
2023-07-25 18:24:14 +02:00
committed by GitHub
parent 00787a10e9
commit c9b54e10ff
26 changed files with 180 additions and 161 deletions
+3 -3
View File
@@ -33,13 +33,13 @@ use sp_blockchain::HeaderBackend;
use sp_core::hexdisplay::HexDisplay;
use sp_runtime::{
generic::BlockId,
traits::{Block, Hash, HashFor, NumberFor},
traits::{Block, Hash, HashingFor, NumberFor},
};
use std::{fmt, fmt::Debug, marker::PhantomData, str::FromStr};
/// A helper type for a generic block input.
pub type BlockAddressFor<TBlock> =
BlockAddress<<HashFor<TBlock> as Hash>::Output, NumberFor<TBlock>>;
BlockAddress<<HashingFor<TBlock> as Hash>::Output, NumberFor<TBlock>>;
/// A Pretty formatter implementation.
pub trait PrettyPrinter<TBlock: Block> {
@@ -166,7 +166,7 @@ impl<TBlock: Block, TPrinter: PrettyPrinter<TBlock>> Inspector<TBlock, TPrinter>
/// Get a pretty-printed extrinsic.
pub fn extrinsic(
&self,
input: ExtrinsicAddress<<HashFor<TBlock> as Hash>::Output, NumberFor<TBlock>>,
input: ExtrinsicAddress<<HashingFor<TBlock> as Hash>::Output, NumberFor<TBlock>>,
) -> Result<String, Error> {
struct ExtrinsicPrinter<'a, A: Block, B>(A::Extrinsic, &'a B);
impl<'a, A: Block, B: PrettyPrinter<A>> fmt::Display for ExtrinsicPrinter<'a, A, B> {
+1 -1
View File
@@ -125,7 +125,7 @@ where
P: TransactionPool + 'static,
SC: SelectChain<Block> + 'static,
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,
B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashingFor<Block>>,
{
use mmr_rpc::{Mmr, MmrApiServer};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
+14 -14
View File
@@ -25,7 +25,7 @@ use parking_lot::RwLock;
use sp_consensus::BlockOrigin;
use sp_core::offchain::OffchainStorage;
use sp_runtime::{
traits::{Block as BlockT, HashFor, NumberFor},
traits::{Block as BlockT, HashingFor, NumberFor},
Justification, Justifications, StateVersion, Storage,
};
use sp_state_machine::{
@@ -42,7 +42,7 @@ pub use sp_state_machine::{Backend as StateBackend, KeyValueStates};
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<HashFor<Block>>>::Transaction;
pub type TransactionForSB<B, Block> = <B as StateBackend<HashingFor<Block>>>::Transaction;
/// Extracts the transaction for the given backend.
pub type TransactionFor<B, Block> = TransactionForSB<StateBackendFor<B, Block>, Block>;
@@ -161,7 +161,7 @@ impl NewBlockState {
/// Keeps hold if the inserted block state and data.
pub trait BlockImportOperation<Block: BlockT> {
/// Associated state backend type.
type State: StateBackend<HashFor<Block>>;
type State: StateBackend<HashingFor<Block>>;
/// Returns pending state.
///
@@ -315,16 +315,16 @@ pub trait AuxStore {
/// An `Iterator` that iterates keys in a given block under a prefix.
pub struct KeysIter<State, Block>
where
State: StateBackend<HashFor<Block>>,
State: StateBackend<HashingFor<Block>>,
Block: BlockT,
{
inner: <State as StateBackend<HashFor<Block>>>::RawIter,
inner: <State as StateBackend<HashingFor<Block>>>::RawIter,
state: State,
}
impl<State, Block> KeysIter<State, Block>
where
State: StateBackend<HashFor<Block>>,
State: StateBackend<HashingFor<Block>>,
Block: BlockT,
{
/// Create a new iterator over storage keys.
@@ -361,7 +361,7 @@ where
impl<State, Block> Iterator for KeysIter<State, Block>
where
Block: BlockT,
State: StateBackend<HashFor<Block>>,
State: StateBackend<HashingFor<Block>>,
{
type Item = StorageKey;
@@ -373,17 +373,17 @@ where
/// An `Iterator` that iterates keys and values in a given block under a prefix.
pub struct PairsIter<State, Block>
where
State: StateBackend<HashFor<Block>>,
State: StateBackend<HashingFor<Block>>,
Block: BlockT,
{
inner: <State as StateBackend<HashFor<Block>>>::RawIter,
inner: <State as StateBackend<HashingFor<Block>>>::RawIter,
state: State,
}
impl<State, Block> Iterator for PairsIter<State, Block>
where
Block: BlockT,
State: StateBackend<HashFor<Block>>,
State: StateBackend<HashingFor<Block>>,
{
type Item = (StorageKey, StorageData);
@@ -397,7 +397,7 @@ where
impl<State, Block> PairsIter<State, Block>
where
State: StateBackend<HashFor<Block>>,
State: StateBackend<HashingFor<Block>>,
Block: BlockT,
{
/// Create a new iterator over storage key and value pairs.
@@ -506,11 +506,11 @@ pub trait Backend<Block: BlockT>: AuxStore + Send + Sync {
/// Associated blockchain backend type.
type Blockchain: BlockchainBackend<Block>;
/// Associated state backend type.
type State: StateBackend<HashFor<Block>>
type State: StateBackend<HashingFor<Block>>
+ Send
+ AsTrieBackend<
HashFor<Block>,
TrieBackendStorage = <Self::State as StateBackend<HashFor<Block>>>::TrieBackendStorage,
HashingFor<Block>,
TrieBackendStorage = <Self::State as StateBackend<HashingFor<Block>>>::TrieBackendStorage,
>;
/// Offchain workers local storage.
type OffchainStorage: OffchainStorage;
+9 -8
View File
@@ -25,7 +25,7 @@ use sp_core::{
};
use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, HashFor, Header as HeaderT, NumberFor, Zero},
traits::{Block as BlockT, HashingFor, Header as HeaderT, NumberFor, Zero},
Justification, Justifications, StateVersion, Storage,
};
use sp_state_machine::{
@@ -479,9 +479,10 @@ impl<Block: BlockT> backend::AuxStore for Blockchain<Block> {
/// In-memory operation.
pub struct BlockImportOperation<Block: BlockT> {
pending_block: Option<PendingBlock<Block>>,
old_state: InMemoryBackend<HashFor<Block>>,
new_state:
Option<<InMemoryBackend<HashFor<Block>> as StateBackend<HashFor<Block>>>::Transaction>,
old_state: InMemoryBackend<HashingFor<Block>>,
new_state: Option<
<InMemoryBackend<HashingFor<Block>> as StateBackend<HashingFor<Block>>>::Transaction,
>,
aux: Vec<(Vec<u8>, Option<Vec<u8>>)>,
finalized_blocks: Vec<(Block::Hash, Option<Justification>)>,
set_head: Option<Block::Hash>,
@@ -517,7 +518,7 @@ impl<Block: BlockT> BlockImportOperation<Block> {
}
impl<Block: BlockT> backend::BlockImportOperation<Block> for BlockImportOperation<Block> {
type State = InMemoryBackend<HashFor<Block>>;
type State = InMemoryBackend<HashingFor<Block>>;
fn state(&self) -> sp_blockchain::Result<Option<&Self::State>> {
Ok(Some(&self.old_state))
@@ -539,7 +540,7 @@ impl<Block: BlockT> backend::BlockImportOperation<Block> for BlockImportOperatio
fn update_db_storage(
&mut self,
update: <InMemoryBackend<HashFor<Block>> as StateBackend<HashFor<Block>>>::Transaction,
update: <InMemoryBackend<HashingFor<Block>> as StateBackend<HashingFor<Block>>>::Transaction,
) -> sp_blockchain::Result<()> {
self.new_state = Some(update);
Ok(())
@@ -606,7 +607,7 @@ impl<Block: BlockT> backend::BlockImportOperation<Block> for BlockImportOperatio
/// > **Warning**: Doesn't support all the features necessary for a proper database. Only use this
/// > struct for testing purposes. Do **NOT** use in production.
pub struct Backend<Block: BlockT> {
states: RwLock<HashMap<Block::Hash, InMemoryBackend<HashFor<Block>>>>,
states: RwLock<HashMap<Block::Hash, InMemoryBackend<HashingFor<Block>>>>,
blockchain: Blockchain<Block>,
import_lock: RwLock<()>,
pinned_blocks: RwLock<HashMap<Block::Hash, i64>>,
@@ -661,7 +662,7 @@ impl<Block: BlockT> backend::AuxStore for Backend<Block> {
impl<Block: BlockT> backend::Backend<Block> for Backend<Block> {
type BlockImportOperation = BlockImportOperation<Block>;
type Blockchain = Blockchain<Block>;
type State = InMemoryBackend<HashFor<Block>>;
type State = InMemoryBackend<HashingFor<Block>>;
type OffchainStorage = OffchainStorage;
fn begin_operation(&self) -> sp_blockchain::Result<Self::BlockImportOperation> {
@@ -304,7 +304,10 @@ where
.propose_with(inherent_data, inherent_digests, deadline, block_size_limit)
.await;
if tx.send(res).is_err() {
trace!(target: LOG_TARGET, "Could not send block production result to proposer!");
trace!(
target: LOG_TARGET,
"Could not send block production result to proposer!"
);
}
}),
);
@@ -384,7 +387,10 @@ where
for inherent in inherents {
match block_builder.push(inherent) {
Err(ApplyExtrinsicFailed(Validity(e))) if e.exhausted_resources() => {
warn!(target: LOG_TARGET, "⚠️ Dropping non-mandatory inherent from overweight block.")
warn!(
target: LOG_TARGET,
"⚠️ Dropping non-mandatory inherent from overweight block."
)
},
Err(ApplyExtrinsicFailed(Validity(e))) if e.was_mandatory() => {
error!(
@@ -393,7 +399,10 @@ where
return Err(ApplyExtrinsicFailed(Validity(e)))
},
Err(e) => {
warn!(target: LOG_TARGET, "❗️ Inherent extrinsic returned unexpected error: {}. Dropping.", e);
warn!(
target: LOG_TARGET,
"❗️ Inherent extrinsic returned unexpected error: {}. Dropping.", e
);
},
Ok(_) => {},
}
@@ -449,9 +458,10 @@ where
let now = (self.now)();
if now > deadline {
debug!(target: LOG_TARGET,
debug!(
target: LOG_TARGET,
"Consensus deadline reached when pushing block transactions, \
proceeding with proposing."
proceeding with proposing."
);
break EndProposingReason::HitDeadline
}
@@ -465,21 +475,26 @@ where
pending_iterator.report_invalid(&pending_tx);
if skipped < MAX_SKIPPED_TRANSACTIONS {
skipped += 1;
debug!(target: LOG_TARGET,
debug!(
target: LOG_TARGET,
"Transaction would overflow the block size limit, \
but will try {} more transactions before quitting.",
but will try {} more transactions before quitting.",
MAX_SKIPPED_TRANSACTIONS - skipped,
);
continue
} else if now < soft_deadline {
debug!(target: LOG_TARGET,
debug!(
target: LOG_TARGET,
"Transaction would overflow the block size limit, \
but we still have time before the soft deadline, so \
we will try a bit more."
but we still have time before the soft deadline, so \
we will try a bit more."
);
continue
} else {
debug!(target: LOG_TARGET, "Reached block size limit, proceeding with proposing.");
debug!(
target: LOG_TARGET,
"Reached block size limit, proceeding with proposing."
);
break EndProposingReason::HitBlockSizeLimit
}
}
@@ -504,22 +519,28 @@ where
so we will try a bit more before quitting."
);
} else {
debug!(target: LOG_TARGET, "Reached block weight limit, proceeding with proposing.");
debug!(
target: LOG_TARGET,
"Reached block weight limit, proceeding with proposing."
);
break EndProposingReason::HitBlockWeightLimit
}
},
Err(e) => {
pending_iterator.report_invalid(&pending_tx);
debug!(target: LOG_TARGET, "[{:?}] Invalid transaction: {}", pending_tx_hash, e);
debug!(
target: LOG_TARGET,
"[{:?}] Invalid transaction: {}", pending_tx_hash, e
);
unqueue_invalid.push(pending_tx_hash);
},
}
};
if matches!(end_reason, EndProposingReason::HitBlockSizeLimit) && !transaction_pushed {
warn!(target: LOG_TARGET,
"Hit block size limit of `{}` without including any transaction!",
block_size_limit,
warn!(
target: LOG_TARGET,
"Hit block size limit of `{}` without including any transaction!", block_size_limit,
);
}
+4 -4
View File
@@ -35,7 +35,7 @@ use sp_blockchain::{ApplyExtrinsicFailed, Error};
use sp_core::traits::CallContext;
use sp_runtime::{
legacy,
traits::{Block as BlockT, Hash, HashFor, Header as HeaderT, NumberFor, One},
traits::{Block as BlockT, Hash, HashingFor, Header as HeaderT, NumberFor, One},
Digest,
};
@@ -85,7 +85,7 @@ impl From<bool> for RecordProof {
/// backend to get the state of the block. Furthermore an optional `proof` is included which
/// can be used to proof that the build block contains the expected data. The `proof` will
/// only be set when proof recording was activated.
pub struct BuiltBlock<Block: BlockT, StateBackend: backend::StateBackend<HashFor<Block>>> {
pub struct BuiltBlock<Block: BlockT, StateBackend: backend::StateBackend<HashingFor<Block>>> {
/// The actual block that was build.
pub block: Block,
/// The changes that need to be applied to the backend to get the state of the build block.
@@ -94,7 +94,7 @@ pub struct BuiltBlock<Block: BlockT, StateBackend: backend::StateBackend<HashFor
pub proof: Option<StorageProof>,
}
impl<Block: BlockT, StateBackend: backend::StateBackend<HashFor<Block>>>
impl<Block: BlockT, StateBackend: backend::StateBackend<HashingFor<Block>>>
BuiltBlock<Block, StateBackend>
{
/// Convert into the inner values.
@@ -236,7 +236,7 @@ where
debug_assert_eq!(
header.extrinsics_root().clone(),
HashFor::<Block>::ordered_trie_root(
HashingFor::<Block>::ordered_trie_root(
self.extrinsics.iter().map(Encode::encode).collect(),
sp_runtime::StateVersion::V0,
),
@@ -20,7 +20,7 @@
use serde::{Deserialize, Serialize};
use sp_runtime::{
traits::{Block as BlockT, HashFor, Header as HeaderT, NumberFor},
traits::{Block as BlockT, HashingFor, Header as HeaderT, NumberFor},
DigestItem, Justification, Justifications,
};
use std::{any::Any, borrow::Cow, collections::HashMap, sync::Arc};
@@ -121,7 +121,7 @@ pub struct BlockCheckParams<Block: BlockT> {
/// Precomputed storage.
pub enum StorageChanges<Block: BlockT, Transaction> {
/// Changes coming from block execution.
Changes(sp_state_machine::StorageChanges<Transaction, HashFor<Block>>),
Changes(sp_state_machine::StorageChanges<Transaction, HashingFor<Block>>),
/// Whole new state.
Import(ImportedState<Block>),
}
+2 -2
View File
@@ -41,7 +41,7 @@ use sp_arithmetic::traits::BaseArithmetic;
use sp_consensus::{Proposal, Proposer, SelectChain, SyncOracle};
use sp_consensus_slots::{Slot, SlotDuration};
use sp_inherents::CreateInherentDataProviders;
use sp_runtime::traits::{Block as BlockT, HashFor, Header as HeaderT};
use sp_runtime::traits::{Block as BlockT, HashingFor, Header as HeaderT};
use std::{
fmt::Debug,
ops::Deref,
@@ -54,7 +54,7 @@ const LOG_TARGET: &str = "slots";
///
/// See [`sp_state_machine::StorageChanges`] for more information.
pub type StorageChanges<Transaction, Block> =
sp_state_machine::StorageChanges<Transaction, HashFor<Block>>;
sp_state_machine::StorageChanges<Transaction, HashingFor<Block>>;
/// The result of [`SlotWorker::on_slot`].
#[derive(Debug, Clone)]
+16 -15
View File
@@ -28,7 +28,7 @@ use sp_core::{
storage::{ChildInfo, TrackedStorageKey},
};
use sp_runtime::{
traits::{Block as BlockT, HashFor},
traits::{Block as BlockT, HashingFor},
StateVersion, Storage,
};
use sp_state_machine::{
@@ -52,9 +52,9 @@ struct StorageDb<Block: BlockT> {
_block: std::marker::PhantomData<Block>,
}
impl<Block: BlockT> sp_state_machine::Storage<HashFor<Block>> for StorageDb<Block> {
impl<Block: BlockT> sp_state_machine::Storage<HashingFor<Block>> for StorageDb<Block> {
fn get(&self, key: &Block::Hash, prefix: Prefix) -> Result<Option<DBValue>, String> {
let prefixed_key = prefixed_key::<HashFor<Block>>(key, prefix);
let prefixed_key = prefixed_key::<HashingFor<Block>>(key, prefix);
self.db
.get(0, &prefixed_key)
.map_err(|e| format!("Database backend error: {:?}", e))
@@ -84,19 +84,19 @@ pub struct BenchmarkingState<B: BlockT> {
record: Cell<Vec<Vec<u8>>>,
key_tracker: Arc<Mutex<KeyTracker>>,
whitelist: RefCell<Vec<TrackedStorageKey>>,
proof_recorder: Option<sp_trie::recorder::Recorder<HashFor<B>>>,
proof_recorder: Option<sp_trie::recorder::Recorder<HashingFor<B>>>,
proof_recorder_root: Cell<B::Hash>,
shared_trie_cache: SharedTrieCache<HashFor<B>>,
shared_trie_cache: SharedTrieCache<HashingFor<B>>,
}
/// A raw iterator over the `BenchmarkingState`.
pub struct RawIter<B: BlockT> {
inner: <DbState<B> as StateBackend<HashFor<B>>>::RawIter,
inner: <DbState<B> as StateBackend<HashingFor<B>>>::RawIter,
child_trie: Option<Vec<u8>>,
key_tracker: Arc<Mutex<KeyTracker>>,
}
impl<B: BlockT> StorageIterator<HashFor<B>> for RawIter<B> {
impl<B: BlockT> StorageIterator<HashingFor<B>> for RawIter<B> {
type Backend = BenchmarkingState<B>;
type Error = String;
@@ -138,8 +138,8 @@ impl<B: BlockT> BenchmarkingState<B> {
) -> Result<Self, String> {
let state_version = sp_runtime::StateVersion::default();
let mut root = B::Hash::default();
let mut mdb = MemoryDB::<HashFor<B>>::default();
sp_trie::trie_types::TrieDBMutBuilderV1::<HashFor<B>>::new(&mut mdb, &mut root).build();
let mut mdb = MemoryDB::<HashingFor<B>>::default();
sp_trie::trie_types::TrieDBMutBuilderV1::<HashingFor<B>>::new(&mut mdb, &mut root).build();
let mut state = BenchmarkingState {
state: RefCell::new(None),
@@ -341,10 +341,10 @@ fn state_err() -> String {
"State is not open".into()
}
impl<B: BlockT> StateBackend<HashFor<B>> for BenchmarkingState<B> {
type Error = <DbState<B> as StateBackend<HashFor<B>>>::Error;
type Transaction = <DbState<B> as StateBackend<HashFor<B>>>::Transaction;
type TrieBackendStorage = <DbState<B> as StateBackend<HashFor<B>>>::TrieBackendStorage;
impl<B: BlockT> StateBackend<HashingFor<B>> for BenchmarkingState<B> {
type Error = <DbState<B> as StateBackend<HashingFor<B>>>::Error;
type Transaction = <DbState<B> as StateBackend<HashingFor<B>>>::Transaction;
type TrieBackendStorage = <DbState<B> as StateBackend<HashingFor<B>>>::TrieBackendStorage;
type RawIter = RawIter<B>;
fn storage(&self, key: &[u8]) -> Result<Option<Vec<u8>>, Self::Error> {
@@ -459,7 +459,7 @@ impl<B: BlockT> StateBackend<HashFor<B>> for BenchmarkingState<B> {
fn commit(
&self,
storage_root: <HashFor<B> as Hasher>::Out,
storage_root: <HashingFor<B> as Hasher>::Out,
mut transaction: Self::Transaction,
main_storage_changes: StorageCollection,
child_storage_changes: ChildStorageCollection,
@@ -614,7 +614,8 @@ impl<B: BlockT> StateBackend<HashFor<B>> for BenchmarkingState<B> {
log::debug!(target: "benchmark", "Some proof size: {}", &proof_size);
proof_size
} else {
if let Some(size) = proof.encoded_compact_size::<HashFor<B>>(proof_recorder_root) {
if let Some(size) = proof.encoded_compact_size::<HashingFor<B>>(proof_recorder_root)
{
size as u32
} else if proof_recorder_root == self.root.get() {
log::debug!(target: "benchmark", "No changes - no proof");
+35 -31
View File
@@ -79,7 +79,7 @@ use sp_database::Transaction;
use sp_runtime::{
generic::BlockId,
traits::{
Block as BlockT, Hash, HashFor, Header as HeaderT, NumberFor, One, SaturatedConversion,
Block as BlockT, Hash, HashingFor, Header as HeaderT, NumberFor, One, SaturatedConversion,
Zero,
},
Justification, Justifications, StateVersion, Storage,
@@ -102,12 +102,12 @@ const CACHE_HEADERS: usize = 8;
/// DB-backed patricia trie state, transaction type is an overlay of changes to commit.
pub type DbState<B> =
sp_state_machine::TrieBackend<Arc<dyn sp_state_machine::Storage<HashFor<B>>>, HashFor<B>>;
sp_state_machine::TrieBackend<Arc<dyn sp_state_machine::Storage<HashingFor<B>>>, HashingFor<B>>;
/// Builder for [`DbState`].
pub type DbStateBuilder<B> = sp_state_machine::TrieBackendBuilder<
Arc<dyn sp_state_machine::Storage<HashFor<B>>>,
HashFor<B>,
Arc<dyn sp_state_machine::Storage<HashingFor<B>>>,
HashingFor<B>,
>;
/// Length of a [`DbHash`].
@@ -162,12 +162,12 @@ impl<Block: BlockT> std::fmt::Debug for RefTrackingState<Block> {
/// A raw iterator over the `RefTrackingState`.
pub struct RawIter<B: BlockT> {
inner: <DbState<B> as StateBackend<HashFor<B>>>::RawIter,
inner: <DbState<B> as StateBackend<HashingFor<B>>>::RawIter,
}
impl<B: BlockT> StorageIterator<HashFor<B>> for RawIter<B> {
impl<B: BlockT> StorageIterator<HashingFor<B>> for RawIter<B> {
type Backend = RefTrackingState<B>;
type Error = <DbState<B> as StateBackend<HashFor<B>>>::Error;
type Error = <DbState<B> as StateBackend<HashingFor<B>>>::Error;
fn next_key(&mut self, backend: &Self::Backend) -> Option<Result<StorageKey, Self::Error>> {
self.inner.next_key(&backend.state)
@@ -185,10 +185,10 @@ impl<B: BlockT> StorageIterator<HashFor<B>> for RawIter<B> {
}
}
impl<B: BlockT> StateBackend<HashFor<B>> for RefTrackingState<B> {
type Error = <DbState<B> as StateBackend<HashFor<B>>>::Error;
type Transaction = <DbState<B> as StateBackend<HashFor<B>>>::Transaction;
type TrieBackendStorage = <DbState<B> as StateBackend<HashFor<B>>>::TrieBackendStorage;
impl<B: BlockT> StateBackend<HashingFor<B>> for RefTrackingState<B> {
type Error = <DbState<B> as StateBackend<HashingFor<B>>>::Error;
type Transaction = <DbState<B> as StateBackend<HashingFor<B>>>::Transaction;
type TrieBackendStorage = <DbState<B> as StateBackend<HashingFor<B>>>::TrieBackendStorage;
type RawIter = RawIter<B>;
fn storage(&self, key: &[u8]) -> Result<Option<Vec<u8>>, Self::Error> {
@@ -269,12 +269,12 @@ impl<B: BlockT> StateBackend<HashFor<B>> for RefTrackingState<B> {
}
}
impl<B: BlockT> AsTrieBackend<HashFor<B>> for RefTrackingState<B> {
type TrieBackendStorage = <DbState<B> as StateBackend<HashFor<B>>>::TrieBackendStorage;
impl<B: BlockT> AsTrieBackend<HashingFor<B>> for RefTrackingState<B> {
type TrieBackendStorage = <DbState<B> as StateBackend<HashingFor<B>>>::TrieBackendStorage;
fn as_trie_backend(
&self,
) -> &sp_state_machine::TrieBackend<Self::TrieBackendStorage, HashFor<B>> {
) -> &sp_state_machine::TrieBackend<Self::TrieBackendStorage, HashingFor<B>> {
&self.state.as_trie_backend()
}
}
@@ -818,7 +818,7 @@ impl<Block: BlockT> HeaderMetadata<Block> for BlockchainDb<Block> {
/// Database transaction
pub struct BlockImportOperation<Block: BlockT> {
old_state: RecordStatsState<RefTrackingState<Block>, Block>,
db_updates: PrefixedMemoryDB<HashFor<Block>>,
db_updates: PrefixedMemoryDB<HashingFor<Block>>,
storage_updates: StorageCollection,
child_storage_updates: ChildStorageCollection,
offchain_storage_updates: OffchainChangesCollection,
@@ -907,7 +907,10 @@ impl<Block: BlockT> sc_client_api::backend::BlockImportOperation<Block>
Ok(())
}
fn update_db_storage(&mut self, update: PrefixedMemoryDB<HashFor<Block>>) -> ClientResult<()> {
fn update_db_storage(
&mut self,
update: PrefixedMemoryDB<HashingFor<Block>>,
) -> ClientResult<()> {
self.db_updates = update;
Ok(())
}
@@ -986,10 +989,10 @@ struct StorageDb<Block: BlockT> {
prefix_keys: bool,
}
impl<Block: BlockT> sp_state_machine::Storage<HashFor<Block>> for StorageDb<Block> {
impl<Block: BlockT> sp_state_machine::Storage<HashingFor<Block>> for StorageDb<Block> {
fn get(&self, key: &Block::Hash, prefix: Prefix) -> Result<Option<DBValue>, String> {
if self.prefix_keys {
let key = prefixed_key::<HashFor<Block>>(key, prefix);
let key = prefixed_key::<HashingFor<Block>>(key, prefix);
self.state_db.get(&key, self)
} else {
self.state_db.get(key.as_ref(), self)
@@ -1009,16 +1012,16 @@ impl<Block: BlockT> sc_state_db::NodeDb for StorageDb<Block> {
struct DbGenesisStorage<Block: BlockT> {
root: Block::Hash,
storage: PrefixedMemoryDB<HashFor<Block>>,
storage: PrefixedMemoryDB<HashingFor<Block>>,
}
impl<Block: BlockT> DbGenesisStorage<Block> {
pub fn new(root: Block::Hash, storage: PrefixedMemoryDB<HashFor<Block>>) -> Self {
pub fn new(root: Block::Hash, storage: PrefixedMemoryDB<HashingFor<Block>>) -> Self {
DbGenesisStorage { root, storage }
}
}
impl<Block: BlockT> sp_state_machine::Storage<HashFor<Block>> for DbGenesisStorage<Block> {
impl<Block: BlockT> sp_state_machine::Storage<HashingFor<Block>> for DbGenesisStorage<Block> {
fn get(&self, key: &Block::Hash, prefix: Prefix) -> Result<Option<DBValue>, String> {
use hash_db::HashDB;
Ok(self.storage.get(key, prefix))
@@ -1030,14 +1033,15 @@ struct EmptyStorage<Block: BlockT>(pub Block::Hash);
impl<Block: BlockT> EmptyStorage<Block> {
pub fn new() -> Self {
let mut root = Block::Hash::default();
let mut mdb = MemoryDB::<HashFor<Block>>::default();
let mut mdb = MemoryDB::<HashingFor<Block>>::default();
// both triedbmut are the same on empty storage.
sp_trie::trie_types::TrieDBMutBuilderV1::<HashFor<Block>>::new(&mut mdb, &mut root).build();
sp_trie::trie_types::TrieDBMutBuilderV1::<HashingFor<Block>>::new(&mut mdb, &mut root)
.build();
EmptyStorage(root)
}
}
impl<Block: BlockT> sp_state_machine::Storage<HashFor<Block>> for EmptyStorage<Block> {
impl<Block: BlockT> sp_state_machine::Storage<HashingFor<Block>> for EmptyStorage<Block> {
fn get(&self, _key: &Block::Hash, _prefix: Prefix) -> Result<Option<DBValue>, String> {
Ok(None)
}
@@ -1098,7 +1102,7 @@ pub struct Backend<Block: BlockT> {
io_stats: FrozenForDuration<(kvdb::IoStats, StateUsageInfo)>,
state_usage: Arc<StateUsageStats>,
genesis_state: RwLock<Option<Arc<DbGenesisStorage<Block>>>>,
shared_trie_cache: Option<sp_trie::cache::SharedTrieCache<HashFor<Block>>>,
shared_trie_cache: Option<sp_trie::cache::SharedTrieCache<HashingFor<Block>>>,
}
impl<Block: BlockT> Backend<Block> {
@@ -1173,7 +1177,7 @@ impl<Block: BlockT> Backend<Block> {
///
/// Should only be needed for benchmarking.
#[cfg(any(feature = "runtime-benchmarks"))]
pub fn expose_storage(&self) -> Arc<dyn sp_state_machine::Storage<HashFor<Block>>> {
pub fn expose_storage(&self) -> Arc<dyn sp_state_machine::Storage<HashingFor<Block>>> {
self.storage.clone()
}
@@ -3542,8 +3546,8 @@ pub(crate) mod tests {
let x0 = ExtrinsicWrapper::from(0u64).encode();
let x1 = ExtrinsicWrapper::from(1u64).encode();
let x0_hash = <HashFor<Block> as sp_core::Hasher>::hash(&x0[1..]);
let x1_hash = <HashFor<Block> as sp_core::Hasher>::hash(&x1[1..]);
let x0_hash = <HashingFor<Block> as sp_core::Hasher>::hash(&x0[1..]);
let x1_hash = <HashingFor<Block> as sp_core::Hasher>::hash(&x1[1..]);
let index = vec![
IndexOperation::Insert {
extrinsic: 0,
@@ -3586,8 +3590,8 @@ pub(crate) mod tests {
let x0 = ExtrinsicWrapper::from(0u64).encode();
let x1 = ExtrinsicWrapper::from(1u64).encode();
let x0_hash = <HashFor<Block> as sp_core::Hasher>::hash(&x0[..]);
let x1_hash = <HashFor<Block> as sp_core::Hasher>::hash(&x1[..]);
let x0_hash = <HashingFor<Block> as sp_core::Hasher>::hash(&x0[..]);
let x1_hash = <HashingFor<Block> as sp_core::Hasher>::hash(&x1[..]);
let index = vec![
IndexOperation::Insert {
extrinsic: 0,
@@ -3621,7 +3625,7 @@ pub(crate) mod tests {
let mut blocks = Vec::new();
let mut prev_hash = Default::default();
let x1 = ExtrinsicWrapper::from(0u64).encode();
let x1_hash = <HashFor<Block> as sp_core::Hasher>::hash(&x1[1..]);
let x1_hash = <HashingFor<Block> as sp_core::Hasher>::hash(&x1[1..]);
for i in 0..10 {
let mut index = Vec::new();
if i == 0 {
+13 -11
View File
@@ -21,7 +21,7 @@
use crate::stats::StateUsageStats;
use sp_core::storage::ChildInfo;
use sp_runtime::{
traits::{Block as BlockT, HashFor},
traits::{Block as BlockT, HashingFor},
StateVersion,
};
use sp_state_machine::{
@@ -56,7 +56,7 @@ impl<S, B: BlockT> Drop for RecordStatsState<S, B> {
}
}
impl<S: StateBackend<HashFor<B>>, B: BlockT> RecordStatsState<S, B> {
impl<S: StateBackend<HashingFor<B>>, B: BlockT> RecordStatsState<S, B> {
/// Create a new instance wrapping generic State and shared cache.
pub(crate) fn new(
state: S,
@@ -75,15 +75,15 @@ impl<S: StateBackend<HashFor<B>>, B: BlockT> RecordStatsState<S, B> {
pub struct RawIter<S, B>
where
S: StateBackend<HashFor<B>>,
S: StateBackend<HashingFor<B>>,
B: BlockT,
{
inner: <S as StateBackend<HashFor<B>>>::RawIter,
inner: <S as StateBackend<HashingFor<B>>>::RawIter,
}
impl<S, B> StorageIterator<HashFor<B>> for RawIter<S, B>
impl<S, B> StorageIterator<HashingFor<B>> for RawIter<S, B>
where
S: StateBackend<HashFor<B>>,
S: StateBackend<HashingFor<B>>,
B: BlockT,
{
type Backend = RecordStatsState<S, B>;
@@ -105,7 +105,9 @@ where
}
}
impl<S: StateBackend<HashFor<B>>, B: BlockT> StateBackend<HashFor<B>> for RecordStatsState<S, B> {
impl<S: StateBackend<HashingFor<B>>, B: BlockT> StateBackend<HashingFor<B>>
for RecordStatsState<S, B>
{
type Error = S::Error;
type Transaction = S::Transaction;
type TrieBackendStorage = S::TrieBackendStorage;
@@ -199,12 +201,12 @@ impl<S: StateBackend<HashFor<B>>, B: BlockT> StateBackend<HashFor<B>> for Record
}
}
impl<S: StateBackend<HashFor<B>> + AsTrieBackend<HashFor<B>>, B: BlockT> AsTrieBackend<HashFor<B>>
for RecordStatsState<S, B>
impl<S: StateBackend<HashingFor<B>> + AsTrieBackend<HashingFor<B>>, B: BlockT>
AsTrieBackend<HashingFor<B>> for RecordStatsState<S, B>
{
type TrieBackendStorage = <S as AsTrieBackend<HashFor<B>>>::TrieBackendStorage;
type TrieBackendStorage = <S as AsTrieBackend<HashingFor<B>>>::TrieBackendStorage;
fn as_trie_backend(&self) -> &TrieBackend<Self::TrieBackendStorage, HashFor<B>> {
fn as_trie_backend(&self) -> &TrieBackend<Self::TrieBackendStorage, HashingFor<B>> {
self.state.as_trie_backend()
}
}
@@ -25,7 +25,7 @@ use schnellru::{ByLength, LruMap};
use prometheus_endpoint::{register, Counter, PrometheusError, Registry, U64};
use sc_network::types::ProtocolName;
use sc_network_common::role::ObservedRole;
use sp_runtime::traits::{Block as BlockT, Hash, HashFor};
use sp_runtime::traits::{Block as BlockT, Hash, HashingFor};
use std::{collections::HashMap, iter, sync::Arc, time, time::Instant};
// FIXME: Add additional spam/DoS attack protection: https://github.com/paritytech/substrate/issues/1115
@@ -228,7 +228,7 @@ impl<B: BlockT> ConsensusGossip<B> {
/// message is already expired it should be dropped on the next garbage
/// collection.
pub fn register_message(&mut self, topic: B::Hash, message: Vec<u8>) {
let message_hash = HashFor::<B>::hash(&message[..]);
let message_hash = HashingFor::<B>::hash(&message[..]);
self.register_message_hashed(message_hash, topic, message, None);
}
@@ -343,7 +343,7 @@ impl<B: BlockT> ConsensusGossip<B> {
}
for message in messages {
let message_hash = HashFor::<B>::hash(&message[..]);
let message_hash = HashingFor::<B>::hash(&message[..]);
if self.known_messages.get(&message_hash).is_some() {
tracing::trace!(
@@ -456,7 +456,7 @@ impl<B: BlockT> ConsensusGossip<B> {
message: Vec<u8>,
force: bool,
) {
let message_hash = HashFor::<B>::hash(&message);
let message_hash = HashingFor::<B>::hash(&message);
self.register_message_hashed(message_hash, topic, message.clone(), None);
let intent = if force { MessageIntent::ForcedBroadcast } else { MessageIntent::Broadcast };
propagate(
@@ -477,7 +477,7 @@ impl<B: BlockT> ConsensusGossip<B> {
Some(peer) => peer,
};
let message_hash = HashFor::<B>::hash(&message);
let message_hash = HashingFor::<B>::hash(&message);
tracing::trace!(
target: "gossip",
@@ -740,7 +740,7 @@ mod tests {
// Register message.
let message = vec![4, 5, 6];
let topic = HashFor::<Block>::hash(&[1, 2, 3]);
let topic = HashingFor::<Block>::hash(&[1, 2, 3]);
consensus.register_message(topic, message.clone());
assert_eq!(
@@ -399,11 +399,7 @@ impl ProtocolController {
PeerState::Connected(direction)
},
None => {
trace!(
target: LOG_TARGET,
"Adding reserved node {peer_id} on {:?}.",
self.set_id,
);
trace!(target: LOG_TARGET, "Adding reserved node {peer_id} on {:?}.", self.set_id,);
PeerState::NotConnected
},
};
@@ -426,8 +422,7 @@ impl ProtocolController {
None => {
warn!(
target: LOG_TARGET,
"Trying to remove unknown reserved node {peer_id} from {:?}.",
self.set_id,
"Trying to remove unknown reserved node {peer_id} from {:?}.", self.set_id,
);
return
},
@@ -524,8 +519,7 @@ impl ProtocolController {
if self.reserved_nodes.contains_key(&peer_id) {
debug!(
target: LOG_TARGET,
"Ignoring request to disconnect reserved peer {peer_id} from {:?}.",
self.set_id,
"Ignoring request to disconnect reserved peer {peer_id} from {:?}.", self.set_id,
);
return
}
@@ -546,8 +540,7 @@ impl ProtocolController {
None => {
debug!(
target: LOG_TARGET,
"Trying to disconnect unknown peer {peer_id} from {:?}.",
self.set_id,
"Trying to disconnect unknown peer {peer_id} from {:?}.", self.set_id,
);
},
}
+2 -2
View File
@@ -78,7 +78,7 @@ use sp_consensus::{
};
use sp_runtime::{
traits::{
Block as BlockT, CheckedSub, Hash, HashFor, Header as HeaderT, NumberFor, One,
Block as BlockT, CheckedSub, Hash, HashingFor, Header as HeaderT, NumberFor, One,
SaturatedConversion, Zero,
},
EncodedJustification, Justifications,
@@ -3137,7 +3137,7 @@ fn validate_blocks<Block: BlockT>(
}
if let (Some(header), Some(body)) = (&b.header, &b.body) {
let expected = *header.extrinsics_root();
let got = HashFor::<Block>::ordered_trie_root(
let got = HashingFor::<Block>::ordered_trie_root(
body.iter().map(Encode::encode).collect(),
sp_runtime::StateVersion::V0,
);
@@ -67,7 +67,7 @@ use sp_core::{
use sp_runtime::{
generic::{BlockId, SignedBlock},
traits::{
Block as BlockT, BlockIdTo, HashFor, Header as HeaderT, NumberFor, One,
Block as BlockT, BlockIdTo, HashingFor, Header as HeaderT, NumberFor, One,
SaturatedConversion, Zero,
},
Digest, Justification, Justifications, StateVersion,
@@ -1267,11 +1267,11 @@ where
// this is a read proof, using version V0 or V1 is equivalent.
let root = state.storage_root(std::iter::empty(), StateVersion::V0).0;
let (proof, count) = prove_range_read_with_child_with_size::<_, HashFor<Block>>(
let (proof, count) = prove_range_read_with_child_with_size::<_, HashingFor<Block>>(
state, size_limit, start_key,
)?;
let proof = proof
.into_compact_proof::<HashFor<Block>>(root)
.into_compact_proof::<HashingFor<Block>>(root)
.map_err(|e| sp_blockchain::Error::from_state(Box::new(e)))?;
Ok((proof, count))
}
@@ -1394,16 +1394,16 @@ where
proof: CompactProof,
start_key: &[Vec<u8>],
) -> sp_blockchain::Result<(KeyValueStates, usize)> {
let mut db = sp_state_machine::MemoryDB::<HashFor<Block>>::new(&[]);
let mut db = sp_state_machine::MemoryDB::<HashingFor<Block>>::new(&[]);
// Compact encoding
let _ = sp_trie::decode_compact::<sp_state_machine::LayoutV0<HashFor<Block>>, _, _>(
let _ = sp_trie::decode_compact::<sp_state_machine::LayoutV0<HashingFor<Block>>, _, _>(
&mut db,
proof.iter_compact_encoded_nodes(),
Some(&root),
)
.map_err(|e| sp_blockchain::Error::from_state(Box::new(e)))?;
let proving_backend = sp_state_machine::TrieBackendBuilder::new(db, root).build();
let state = read_range_proof_check_with_child_on_proving_backend::<HashFor<Block>>(
let state = read_range_proof_check_with_child_on_proving_backend::<HashingFor<Block>>(
&proving_backend,
start_key,
)?;
+1 -1
View File
@@ -186,7 +186,7 @@ where
&self,
ex: &graph::ExtrinsicFor<Self>,
) -> (graph::ExtrinsicHash<Self>, usize) {
ex.using_encoded(|x| (<traits::HashFor<Block> as traits::Hash>::hash(x), x.len()))
ex.using_encoded(|x| (<traits::HashingFor<Block> as traits::Hash>::hash(x), x.len()))
}
fn block_header(
@@ -1618,7 +1618,7 @@ pub(crate) mod remote_tests {
use remote_externalities::Mode;
use sp_core::H256;
use sp_runtime::{
traits::{Block as BlockT, HashFor, Header as _, One, Zero},
traits::{Block as BlockT, HashingFor, Header as _, One, Zero},
DeserializeOwned,
};
use thousands::Separable;
@@ -1698,7 +1698,7 @@ pub(crate) mod remote_tests {
});
let compact_proof =
proof.clone().into_compact_proof::<HashFor<Block>>(last_state_root).unwrap();
proof.clone().into_compact_proof::<HashingFor<Block>>(last_state_root).unwrap();
log::info!(
target: LOG_TARGET,
"proceeded to #{}, weight: [{} / {}], proof: [{} / {} / {}]",
@@ -592,7 +592,7 @@ impl<'a> Fold for ApiRuntimeImplToApiRuntimeApiImpl<'a> {
where_clause.predicates.push(parse_quote! {
RuntimeApiImplCall::StateBackend:
#crate_::StateBackend<#crate_::HashFor<__SrApiBlock__>>
#crate_::StateBackend<#crate_::HashingFor<__SrApiBlock__>>
});
where_clause.predicates.push(parse_quote! { &'static RuntimeApiImplCall: Send });
@@ -66,7 +66,7 @@ fn implement_common_api_traits(block_type: TypePath, self_ty: Type) -> Result<To
Ok(quote!(
impl #crate_::ApiExt<#block_type> for #self_ty {
type StateBackend = #crate_::InMemoryBackend<#crate_::HashFor<#block_type>>;
type StateBackend = #crate_::InMemoryBackend<#crate_::HashingFor<#block_type>>;
fn execute_in_transaction<F: FnOnce(&Self) -> #crate_::TransactionOutcome<R>, R>(
&self,
+10 -10
View File
@@ -98,7 +98,7 @@ pub use sp_runtime::StateVersion;
#[doc(hidden)]
pub use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, Hash as HashT, HashFor, Header as HeaderT, NumberFor},
traits::{Block as BlockT, Hash as HashT, HashingFor, Header as HeaderT, NumberFor},
transaction_validity::TransactionValidity,
RuntimeString, TransactionOutcome,
};
@@ -454,19 +454,19 @@ pub use sp_api_proc_macro::mock_impl_runtime_apis;
/// A type that records all accessed trie nodes and generates a proof out of it.
#[cfg(feature = "std")]
pub type ProofRecorder<B> = sp_trie::recorder::Recorder<HashFor<B>>;
pub type ProofRecorder<B> = sp_trie::recorder::Recorder<HashingFor<B>>;
/// A type that is used as cache for the storage transactions.
#[cfg(feature = "std")]
pub type StorageTransactionCache<Block, Backend> = sp_state_machine::StorageTransactionCache<
<Backend as StateBackend<HashFor<Block>>>::Transaction,
HashFor<Block>,
<Backend as StateBackend<HashingFor<Block>>>::Transaction,
HashingFor<Block>,
>;
#[cfg(feature = "std")]
pub type StorageChanges<SBackend, Block> = sp_state_machine::StorageChanges<
<SBackend as StateBackend<HashFor<Block>>>::Transaction,
HashFor<Block>,
<SBackend as StateBackend<HashingFor<Block>>>::Transaction,
HashingFor<Block>,
>;
/// Extract the state backend type for a type that implements `ProvideRuntimeApi`.
@@ -477,7 +477,7 @@ pub type StateBackendFor<P, Block> =
/// Extract the state backend transaction type for a type that implements `ProvideRuntimeApi`.
#[cfg(feature = "std")]
pub type TransactionFor<P, Block> =
<StateBackendFor<P, Block> as StateBackend<HashFor<Block>>>::Transaction;
<StateBackendFor<P, Block> as StateBackend<HashingFor<Block>>>::Transaction;
/// Something that can be constructed to a runtime api.
#[cfg(feature = "std")]
@@ -532,7 +532,7 @@ pub enum ApiError {
#[cfg(feature = "std")]
pub trait ApiExt<Block: BlockT> {
/// The state backend that is used to store the block states.
type StateBackend: StateBackend<HashFor<Block>>;
type StateBackend: StateBackend<HashingFor<Block>>;
/// Execute the given closure inside a new transaction.
///
@@ -599,7 +599,7 @@ pub trait ApiExt<Block: BlockT> {
/// Parameters for [`CallApiAt::call_api_at`].
#[cfg(feature = "std")]
pub struct CallApiAtParams<'a, Block: BlockT, Backend: StateBackend<HashFor<Block>>> {
pub struct CallApiAtParams<'a, Block: BlockT, Backend: StateBackend<HashingFor<Block>>> {
/// The block id that determines the state that should be setup when calling the function.
pub at: Block::Hash,
/// The name of the function that should be called.
@@ -622,7 +622,7 @@ pub struct CallApiAtParams<'a, Block: BlockT, Backend: StateBackend<HashFor<Bloc
#[cfg(feature = "std")]
pub trait CallApiAt<Block: BlockT> {
/// The state backend that is used to store the block states.
type StateBackend: StateBackend<HashFor<Block>> + AsTrieBackend<HashFor<Block>>;
type StateBackend: StateBackend<HashingFor<Block>> + AsTrieBackend<HashingFor<Block>>;
/// Calls the given api function with the given encoded arguments at the given block and returns
/// the encoded result.
@@ -19,7 +19,7 @@ use std::panic::UnwindSafe;
use sp_api::{ApiExt, Core, ProvideRuntimeApi};
use sp_runtime::{
traits::{HashFor, Header as HeaderT},
traits::{HashingFor, Header as HeaderT},
TransactionOutcome,
};
use sp_state_machine::{create_proof_check_backend, execution_proof_check_on_trie_backend};
@@ -111,7 +111,7 @@ fn record_proof_works() {
builder.push(transaction.clone()).unwrap();
let (block, _, proof) = builder.build().expect("Bake block").into_inner();
let backend = create_proof_check_backend::<HashFor<Block>>(
let backend = create_proof_check_backend::<HashingFor<Block>>(
storage_root,
proof.expect("Proof was generated"),
)
@@ -25,7 +25,7 @@ use std::{sync::Arc, time::Duration};
use futures::prelude::*;
use sp_runtime::{
traits::{Block as BlockT, HashFor},
traits::{Block as BlockT, HashingFor},
Digest,
};
use sp_state_machine::StorageProof;
@@ -97,7 +97,7 @@ pub struct Proposal<Block: BlockT, Transaction, Proof> {
/// Proof that was recorded while building the block.
pub proof: Proof,
/// The storage changes while building this block.
pub storage_changes: sp_state_machine::StorageChanges<Transaction, HashFor<Block>>,
pub storage_changes: sp_state_machine::StorageChanges<Transaction, HashingFor<Block>>,
}
/// Error that is returned when [`ProofRecording`] requested to record a proof,
+1 -1
View File
@@ -1345,7 +1345,7 @@ pub trait ExtrinsicMetadata {
}
/// Extract the hashing type for a block.
pub type HashFor<B> = <<B as Block>::Header as Header>::Hashing;
pub type HashingFor<B> = <<B as Block>::Header as Header>::Hashing;
/// Extract the number type for a block.
pub type NumberFor<B> = <<B as Block>::Header as Header>::Number;
/// Extract the digest type for a block.
@@ -21,7 +21,7 @@ use sc_client_db::DbHash;
use sc_service::Configuration;
use sp_blockchain::HeaderBackend;
use sp_database::{ColumnId, Database};
use sp_runtime::traits::{Block as BlockT, HashFor};
use sp_runtime::traits::{Block as BlockT, HashingFor};
use sp_state_machine::Storage;
use sp_storage::{ChildInfo, ChildType, PrefixedStorageKey, StateVersion};
@@ -126,7 +126,7 @@ impl StorageCmd {
cfg: Configuration,
client: Arc<C>,
db: (Arc<dyn Database<DbHash>>, ColumnId),
storage: Arc<dyn Storage<HashFor<Block>>>,
storage: Arc<dyn Storage<HashingFor<Block>>>,
) -> Result<()>
where
BA: ClientBackend<Block>,
@@ -21,7 +21,7 @@ use sc_client_db::{DbHash, DbState, DbStateBuilder};
use sp_api::StateBackend;
use sp_blockchain::HeaderBackend;
use sp_database::{ColumnId, Transaction};
use sp_runtime::traits::{Block as BlockT, HashFor, Header as HeaderT};
use sp_runtime::traits::{Block as BlockT, HashingFor, Header as HeaderT};
use sp_trie::PrefixedMemoryDB;
use log::{info, trace};
@@ -43,7 +43,7 @@ impl StorageCmd {
&self,
client: Arc<C>,
(db, state_col): (Arc<dyn sp_database::Database<DbHash>>, ColumnId),
storage: Arc<dyn sp_state_machine::Storage<HashFor<Block>>>,
storage: Arc<dyn sp_state_machine::Storage<HashingFor<Block>>>,
) -> Result<BenchRecord>
where
Block: BlockT<Header = H, Hash = DbHash> + Debug,
@@ -164,7 +164,7 @@ impl StorageCmd {
/// `invert_inserts` replaces all inserts with removals.
fn convert_tx<B: BlockT>(
db: Arc<dyn sp_database::Database<DbHash>>,
mut tx: PrefixedMemoryDB<HashFor<B>>,
mut tx: PrefixedMemoryDB<HashingFor<B>>,
invert_inserts: bool,
col: ColumnId,
) -> Transaction<DbHash> {
@@ -776,10 +776,7 @@ where
.collect::<Vec<_>>();
if child_roots.is_empty() {
info!(
target: LOG_TARGET,
"👩‍👦 no child roots found to scrape",
);
info!(target: LOG_TARGET, "👩‍👦 no child roots found to scrape",);
return Ok(Default::default())
}