mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 15:11:03 +00:00
Apply some clippy lints (#11154)
* Apply some clippy hints * Revert clippy ci changes * Update client/cli/src/commands/generate.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/cli/src/commands/inspect_key.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/src/client/block_rules.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/src/client/block_rules.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/network/src/transactions.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/network/src/protocol.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Revert due to missing `or_default` function. * Fix compilation and simplify code * Undo change that corrupts benchmark. * fix clippy * Update client/service/test/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/state-db/src/noncanonical.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/state-db/src/noncanonical.rs remove leftovers! * Update client/tracing/src/logging/directives.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/fork-tree/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * added needed ref * Update frame/referenda/src/benchmarking.rs * Simplify byte-vec creation * let's just not overlap the ranges * Correction * cargo fmt * Update utils/frame/benchmarking-cli/src/shared/stats.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/frame/benchmarking-cli/src/pallet/command.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/frame/benchmarking-cli/src/pallet/command.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Giles Cope <gilescope@gmail.com>
This commit is contained in:
committed by
GitHub
parent
a990473cf9
commit
b581604aa7
@@ -263,7 +263,7 @@ where
|
||||
state_cache_child_ratio: config.state_cache_child_ratio.map(|v| (v, 100)),
|
||||
state_pruning: config.state_pruning.clone(),
|
||||
source: config.database.clone(),
|
||||
keep_blocks: config.keep_blocks.clone(),
|
||||
keep_blocks: config.keep_blocks,
|
||||
};
|
||||
|
||||
let backend = new_db_backend(db_config)?;
|
||||
@@ -421,10 +421,10 @@ where
|
||||
Some("offchain-worker"),
|
||||
sc_offchain::notification_future(
|
||||
config.role.is_authority(),
|
||||
client.clone(),
|
||||
client,
|
||||
offchain,
|
||||
Clone::clone(&spawn_handle),
|
||||
network.clone(),
|
||||
network,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -517,7 +517,7 @@ where
|
||||
let metrics_service =
|
||||
if let Some(PrometheusConfig { port, registry }) = config.prometheus_config.clone() {
|
||||
// Set static metrics.
|
||||
let metrics = MetricsService::with_prometheus(telemetry.clone(), ®istry, &config)?;
|
||||
let metrics = MetricsService::with_prometheus(telemetry, ®istry, &config)?;
|
||||
spawn_handle.spawn(
|
||||
"prometheus-endpoint",
|
||||
None,
|
||||
@@ -526,7 +526,7 @@ where
|
||||
|
||||
metrics
|
||||
} else {
|
||||
MetricsService::new(telemetry.clone())
|
||||
MetricsService::new(telemetry)
|
||||
};
|
||||
|
||||
// Periodically updated metrics and telemetry updates.
|
||||
@@ -572,7 +572,7 @@ where
|
||||
None,
|
||||
sc_informant::build(
|
||||
client.clone(),
|
||||
network.clone(),
|
||||
network,
|
||||
transaction_pool.clone(),
|
||||
config.informant_output_format,
|
||||
),
|
||||
|
||||
@@ -47,8 +47,8 @@ impl<B: BlockT> BlockRules<B> {
|
||||
/// New block rules with provided black and white lists.
|
||||
pub fn new(fork_blocks: ForkBlocks<B>, bad_blocks: BadBlocks<B>) -> Self {
|
||||
Self {
|
||||
bad: bad_blocks.unwrap_or_else(|| HashSet::new()),
|
||||
forks: fork_blocks.unwrap_or_else(|| vec![]).into_iter().collect(),
|
||||
bad: bad_blocks.unwrap_or_default(),
|
||||
forks: fork_blocks.unwrap_or_default().into_iter().collect(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ impl<B: BlockT> BlockRules<B> {
|
||||
pub fn lookup(&self, number: NumberFor<B>, hash: &B::Hash) -> LookupResult<B> {
|
||||
if let Some(hash_for_height) = self.forks.get(&number) {
|
||||
if hash_for_height != hash {
|
||||
return LookupResult::Expected(hash_for_height.clone())
|
||||
return LookupResult::Expected(*hash_for_height)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -283,7 +283,7 @@ where
|
||||
state_runtime_code.runtime_code().map_err(sp_blockchain::Error::RuntimeCode)?;
|
||||
self.executor
|
||||
.runtime_version(&mut ext, &runtime_code)
|
||||
.map_err(|e| sp_blockchain::Error::VersionInvalid(e.to_string()).into())
|
||||
.map_err(|e| sp_blockchain::Error::VersionInvalid(e.to_string()))
|
||||
}
|
||||
|
||||
fn prove_execution(
|
||||
@@ -305,7 +305,7 @@ where
|
||||
let runtime_code = self.check_override(runtime_code, at)?;
|
||||
|
||||
sp_state_machine::prove_execution_on_trie_backend(
|
||||
&trie_backend,
|
||||
trie_backend,
|
||||
&mut Default::default(),
|
||||
&self.executor,
|
||||
self.spawn_handle.clone(),
|
||||
|
||||
@@ -367,7 +367,7 @@ where
|
||||
let mut op = backend.begin_operation()?;
|
||||
let state_root =
|
||||
op.set_genesis_state(genesis_storage, !config.no_genesis, genesis_state_version)?;
|
||||
let genesis_block = genesis::construct_genesis_block::<Block>(state_root.into());
|
||||
let genesis_block = genesis::construct_genesis_block::<Block>(state_root);
|
||||
info!(
|
||||
"🔨 Initializing Genesis block/state (state: {}, header-hash: {})",
|
||||
genesis_block.header().state_root(),
|
||||
@@ -551,7 +551,7 @@ where
|
||||
<Self as ProvideRuntimeApi<Block>>::Api:
|
||||
CoreApi<Block> + ApiExt<Block, StateBackend = B::State>,
|
||||
{
|
||||
let parent_hash = import_headers.post().parent_hash().clone();
|
||||
let parent_hash = *import_headers.post().parent_hash();
|
||||
let status = self.backend.blockchain().status(BlockId::Hash(hash))?;
|
||||
let parent_exists = self.backend.blockchain().status(BlockId::Hash(parent_hash))? ==
|
||||
blockchain::BlockStatus::InChain;
|
||||
@@ -609,7 +609,7 @@ where
|
||||
sc_consensus::StorageChanges::Import(changes) => {
|
||||
let mut storage = sp_storage::Storage::default();
|
||||
for state in changes.state.0.into_iter() {
|
||||
if state.parent_storage_keys.len() == 0 && state.state_root.len() == 0 {
|
||||
if state.parent_storage_keys.is_empty() && state.state_root.is_empty() {
|
||||
for (key, value) in state.key_values.into_iter() {
|
||||
storage.top.insert(key, value);
|
||||
}
|
||||
@@ -617,7 +617,7 @@ where
|
||||
for parent_storage in state.parent_storage_keys {
|
||||
let storage_key = PrefixedStorageKey::new_ref(&parent_storage);
|
||||
let storage_key =
|
||||
match ChildType::from_prefixed_key(&storage_key) {
|
||||
match ChildType::from_prefixed_key(storage_key) {
|
||||
Some((ChildType::ParentKeyId, storage_key)) =>
|
||||
storage_key,
|
||||
None =>
|
||||
@@ -1033,7 +1033,7 @@ where
|
||||
return Ok(BlockStatus::Queued)
|
||||
}
|
||||
}
|
||||
let hash_and_number = match id.clone() {
|
||||
let hash_and_number = match *id {
|
||||
BlockId::Hash(hash) => self.backend.blockchain().number(hash)?.map(|n| (hash, n)),
|
||||
BlockId::Number(n) => self.backend.blockchain().hash(n)?.map(|hash| (hash, n)),
|
||||
};
|
||||
@@ -1212,8 +1212,8 @@ where
|
||||
}
|
||||
let state = self.state_at(id)?;
|
||||
let child_info = |storage_key: &Vec<u8>| -> sp_blockchain::Result<ChildInfo> {
|
||||
let storage_key = PrefixedStorageKey::new_ref(&storage_key);
|
||||
match ChildType::from_prefixed_key(&storage_key) {
|
||||
let storage_key = PrefixedStorageKey::new_ref(storage_key);
|
||||
match ChildType::from_prefixed_key(storage_key) {
|
||||
Some((ChildType::ParentKeyId, storage_key)) =>
|
||||
Ok(ChildInfo::new_default(storage_key)),
|
||||
None => Err(Error::Backend("Invalid child storage key.".to_string())),
|
||||
@@ -1222,7 +1222,7 @@ where
|
||||
let mut current_child = if start_key.len() == 2 {
|
||||
let start_key = start_key.get(0).expect("checked len");
|
||||
if let Some(child_root) = state
|
||||
.storage(&start_key)
|
||||
.storage(start_key)
|
||||
.map_err(|e| sp_blockchain::Error::from_state(Box::new(e)))?
|
||||
{
|
||||
Some((child_info(start_key)?, child_root))
|
||||
@@ -1232,7 +1232,7 @@ where
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let mut current_key = start_key.last().map(Clone::clone).unwrap_or(Vec::new());
|
||||
let mut current_key = start_key.last().map(Clone::clone).unwrap_or_default();
|
||||
let mut total_size = 0;
|
||||
let mut result = vec![(
|
||||
KeyValueStorageLevel {
|
||||
@@ -1276,14 +1276,13 @@ where
|
||||
total_size += size;
|
||||
|
||||
if current_child.is_none() &&
|
||||
sp_core::storage::well_known_keys::is_child_storage_key(next_key.as_slice())
|
||||
sp_core::storage::well_known_keys::is_child_storage_key(next_key.as_slice()) &&
|
||||
!child_roots.contains(value.as_slice())
|
||||
{
|
||||
if !child_roots.contains(value.as_slice()) {
|
||||
child_roots.insert(value.clone());
|
||||
switch_child_key = Some((next_key.clone(), value.clone()));
|
||||
entries.push((next_key.clone(), value));
|
||||
break
|
||||
}
|
||||
child_roots.insert(value.clone());
|
||||
switch_child_key = Some((next_key.clone(), value.clone()));
|
||||
entries.push((next_key.clone(), value));
|
||||
break
|
||||
}
|
||||
entries.push((next_key.clone(), value));
|
||||
current_key = next_key;
|
||||
@@ -1647,7 +1646,7 @@ where
|
||||
{
|
||||
type Api = <RA as ConstructRuntimeApi<Block, Self>>::RuntimeApi;
|
||||
|
||||
fn runtime_api<'a>(&'a self) -> ApiRef<'a, Self::Api> {
|
||||
fn runtime_api(&self) -> ApiRef<Self::Api> {
|
||||
RA::construct_runtime_api(self)
|
||||
}
|
||||
}
|
||||
@@ -1661,12 +1660,11 @@ where
|
||||
type StateBackend = B::State;
|
||||
|
||||
fn call_api_at<
|
||||
'a,
|
||||
R: Encode + Decode + PartialEq,
|
||||
NC: FnOnce() -> result::Result<R, sp_api::ApiError> + UnwindSafe,
|
||||
>(
|
||||
&self,
|
||||
params: CallApiAtParams<'a, Block, NC, B::State>,
|
||||
params: CallApiAtParams<Block, NC, B::State>,
|
||||
) -> Result<NativeOrEncoded<R>, sp_api::ApiError> {
|
||||
let at = params.at;
|
||||
|
||||
@@ -1742,7 +1740,7 @@ where
|
||||
})
|
||||
.map_err(|e| {
|
||||
warn!("Block import error: {}", e);
|
||||
ConsensusError::ClientImport(e.to_string()).into()
|
||||
ConsensusError::ClientImport(e.to_string())
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ fn make_hash<K: std::hash::Hash + ?Sized>(val: &K) -> Vec<u8> {
|
||||
}
|
||||
|
||||
impl FetchRuntimeCode for WasmBlob {
|
||||
fn fetch_runtime_code<'a>(&'a self) -> Option<std::borrow::Cow<'a, [u8]>> {
|
||||
fn fetch_runtime_code(&self) -> Option<std::borrow::Cow<[u8]>> {
|
||||
Some(self.code.as_slice().into())
|
||||
}
|
||||
}
|
||||
@@ -186,34 +186,30 @@ impl WasmOverride {
|
||||
for entry in fs::read_dir(dir).map_err(handle_err)? {
|
||||
let entry = entry.map_err(handle_err)?;
|
||||
let path = entry.path();
|
||||
match path.extension().and_then(|e| e.to_str()) {
|
||||
Some("wasm") => {
|
||||
let code = fs::read(&path).map_err(handle_err)?;
|
||||
let code_hash = make_hash(&code);
|
||||
let version = Self::runtime_version(executor, &code, &code_hash, Some(128))?;
|
||||
if let Some("wasm") = path.extension().and_then(|e| e.to_str()) {
|
||||
let code = fs::read(&path).map_err(handle_err)?;
|
||||
let code_hash = make_hash(&code);
|
||||
let version = Self::runtime_version(executor, &code, &code_hash, Some(128))?;
|
||||
tracing::info!(
|
||||
target: "wasm_overrides",
|
||||
version = %version,
|
||||
file = %path.display(),
|
||||
"Found wasm override.",
|
||||
);
|
||||
|
||||
let wasm =
|
||||
WasmBlob::new(code, code_hash, path.clone(), version.spec_name.to_string());
|
||||
|
||||
if let Some(other) = overrides.insert(version.spec_version, wasm) {
|
||||
tracing::info!(
|
||||
target: "wasm_overrides",
|
||||
version = %version,
|
||||
file = %path.display(),
|
||||
"Found wasm override.",
|
||||
first = %other.path.display(),
|
||||
second = %path.display(),
|
||||
%version,
|
||||
"Found duplicate spec version for runtime.",
|
||||
);
|
||||
|
||||
let wasm =
|
||||
WasmBlob::new(code, code_hash, path.clone(), version.spec_name.to_string());
|
||||
|
||||
if let Some(other) = overrides.insert(version.spec_version, wasm) {
|
||||
tracing::info!(
|
||||
target: "wasm_overrides",
|
||||
first = %other.path.display(),
|
||||
second = %path.display(),
|
||||
%version,
|
||||
"Found duplicate spec version for runtime.",
|
||||
);
|
||||
duplicates.push(path.display().to_string());
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
duplicates.push(path.display().to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ impl<Block: BlockT> WasmSubstitute<Block> {
|
||||
/// Returns `true` when the substitute matches for the given `block_id`.
|
||||
fn matches(&self, block_id: &BlockId<Block>, backend: &impl backend::Backend<Block>) -> bool {
|
||||
let requested_block_number =
|
||||
backend.blockchain().block_number_from_id(&block_id).ok().flatten();
|
||||
backend.blockchain().block_number_from_id(block_id).ok().flatten();
|
||||
|
||||
Some(self.block_number) <= requested_block_number
|
||||
}
|
||||
@@ -70,7 +70,7 @@ fn make_hash<K: std::hash::Hash + ?Sized>(val: &K) -> Vec<u8> {
|
||||
}
|
||||
|
||||
impl<Block: BlockT> FetchRuntimeCode for WasmSubstitute<Block> {
|
||||
fn fetch_runtime_code<'a>(&'a self) -> Option<std::borrow::Cow<'a, [u8]>> {
|
||||
fn fetch_runtime_code(&self) -> Option<std::borrow::Cow<[u8]>> {
|
||||
Some(self.code.as_slice().into())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ async fn build_network_future<
|
||||
if notification.is_new_best {
|
||||
network.service().new_best_block_imported(
|
||||
notification.hash,
|
||||
notification.header.number().clone(),
|
||||
*notification.header.number(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -204,7 +204,7 @@ async fn build_network_future<
|
||||
let _ = sender.send(network.local_peer_id().to_base58());
|
||||
},
|
||||
sc_rpc::system::Request::LocalListenAddresses(sender) => {
|
||||
let peer_id = network.local_peer_id().clone().into();
|
||||
let peer_id = (*network.local_peer_id()).into();
|
||||
let p2p_proto_suffix = sc_network::multiaddr::Protocol::P2p(peer_id);
|
||||
let addresses = network.listen_addresses()
|
||||
.map(|addr| addr.clone().with(p2p_proto_suffix.clone()).to_string())
|
||||
@@ -222,7 +222,7 @@ async fn build_network_future<
|
||||
).collect());
|
||||
}
|
||||
sc_rpc::system::Request::NetworkState(sender) => {
|
||||
if let Some(network_state) = serde_json::to_value(&network.network_state()).ok() {
|
||||
if let Ok(network_state) = serde_json::to_value(&network.network_state()) {
|
||||
let _ = sender.send(network_state);
|
||||
}
|
||||
}
|
||||
@@ -265,7 +265,7 @@ async fn build_network_future<
|
||||
use sc_rpc::system::SyncState;
|
||||
|
||||
let _ = sender.send(SyncState {
|
||||
starting_block: starting_block,
|
||||
starting_block,
|
||||
current_block: client.info().best_number,
|
||||
highest_block: network.best_seen_block(),
|
||||
});
|
||||
@@ -385,7 +385,7 @@ fn start_rpc_servers<
|
||||
address,
|
||||
config.rpc_cors.as_ref(),
|
||||
gen_handler(
|
||||
deny_unsafe(&address, &config.rpc_methods),
|
||||
deny_unsafe(address, &config.rpc_methods),
|
||||
sc_rpc_server::RpcMiddleware::new(
|
||||
rpc_metrics.clone(),
|
||||
rpc_method_names.clone(),
|
||||
@@ -404,7 +404,7 @@ fn start_rpc_servers<
|
||||
config.rpc_ws_max_connections,
|
||||
config.rpc_cors.as_ref(),
|
||||
gen_handler(
|
||||
deny_unsafe(&address, &config.rpc_methods),
|
||||
deny_unsafe(address, &config.rpc_methods),
|
||||
sc_rpc_server::RpcMiddleware::new(
|
||||
rpc_metrics.clone(),
|
||||
rpc_method_names.clone(),
|
||||
|
||||
@@ -61,13 +61,13 @@ impl PrometheusMetrics {
|
||||
.const_label("name", name)
|
||||
.const_label("version", version),
|
||||
)?,
|
||||
®istry,
|
||||
registry,
|
||||
)?
|
||||
.set(1);
|
||||
|
||||
register(
|
||||
Gauge::<U64>::new("substrate_node_roles", "The roles the node is running as")?,
|
||||
®istry,
|
||||
registry,
|
||||
)?
|
||||
.set(roles);
|
||||
|
||||
|
||||
@@ -38,12 +38,12 @@ mod prometheus_future;
|
||||
mod tests;
|
||||
|
||||
/// Default task group name.
|
||||
pub const DEFAULT_GROUP_NAME: &'static str = "default";
|
||||
pub const DEFAULT_GROUP_NAME: &str = "default";
|
||||
|
||||
/// The name of a group a task belongs to.
|
||||
///
|
||||
/// This name is passed belong-side the task name to the prometheus metrics and can be used
|
||||
/// to group tasks.
|
||||
/// to group tasks.
|
||||
pub enum GroupName {
|
||||
/// Sets the group name to `default`.
|
||||
Default,
|
||||
|
||||
Reference in New Issue
Block a user