Skip to content

Commit

Permalink
fixes for nightly clippy (paritytech#1618)
Browse files Browse the repository at this point in the history
  • Loading branch information
svyatonik authored and serban300 committed Apr 9, 2024
1 parent b242d1b commit 49e33c6
Show file tree
Hide file tree
Showing 22 changed files with 45 additions and 45 deletions.
4 changes: 2 additions & 2 deletions bridges/bin/millau/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub enum Alternative {

/// Helper function to generate a crypto pair from seed
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{}", seed), None)
TPublic::Pair::from_string(&format!("//{seed}"), None)
.expect("static values are valid; qed")
.public()
}
Expand Down Expand Up @@ -150,7 +150,7 @@ fn endowed_accounts() -> Vec<AccountId> {
let all_authorities = ALL_AUTHORITIES_ACCOUNTS.iter().flat_map(|x| {
[
get_account_id_from_seed::<sr25519::Public>(x),
get_account_id_from_seed::<sr25519::Public>(&format!("{}//stash", x)),
get_account_id_from_seed::<sr25519::Public>(&format!("{x}//stash")),
]
});
vec![
Expand Down
2 changes: 1 addition & 1 deletion bridges/bin/millau/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl SubstrateCli for Cli {
match id {
"" | "dev" => crate::chain_spec::Alternative::Development,
"local" => crate::chain_spec::Alternative::LocalTestnet,
_ => return Err(format!("Unsupported chain specification: {}", id)),
_ => return Err(format!("Unsupported chain specification: {id}")),
}
.load(),
))
Expand Down
4 changes: 2 additions & 2 deletions bridges/bin/millau/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>

Box::new(move |_, subscription_executor: sc_rpc::SubscriptionTaskExecutor| {
let mut io = RpcModule::new(());
let map_err = |e| sc_service::Error::Other(format!("{}", e));
let map_err = |e| sc_service::Error::Other(format!("{e}"));
io.merge(System::new(client.clone(), pool.clone(), DenyUnsafe::No).into_rpc())
.map_err(map_err)?;
io.merge(TransactionPayment::new(client.clone()).into_rpc()).map_err(map_err)?;
Expand All @@ -314,7 +314,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
beefy_rpc_links.from_voter_best_beefy_stream.clone(),
subscription_executor,
)
.map_err(|e| sc_service::Error::Other(format!("{}", e)))?
.map_err(|e| sc_service::Error::Other(format!("{e}")))?
.into_rpc(),
)
.map_err(map_err)?;
Expand Down
4 changes: 2 additions & 2 deletions bridges/bin/rialto-parachain/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub type ChainSpec =

/// Helper function to generate a crypto pair from seed
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{}", seed), None)
TPublic::Pair::from_string(&format!("//{seed}"), None)
.expect("static values are valid; qed")
.public()
}
Expand Down Expand Up @@ -81,7 +81,7 @@ fn endowed_accounts() -> Vec<AccountId> {
let all_authorities = ALL_AUTHORITIES_ACCOUNTS.iter().flat_map(|x| {
[
get_account_id_from_seed::<sr25519::Public>(x),
get_account_id_from_seed::<sr25519::Public>(&format!("{}//stash", x)),
get_account_id_from_seed::<sr25519::Public>(&format!("{x}//stash")),
]
});
vec![
Expand Down
6 changes: 3 additions & 3 deletions bridges/bin/rialto-parachain/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ pub fn run() -> Result<()> {
&polkadot_cli,
config.tokio_handle.clone(),
)
.map_err(|err| format!("Relay chain argument error: {}", err))?;
.map_err(|err| format!("Relay chain argument error: {err}"))?;

cmd.run(config, polkadot_config)
})
Expand Down Expand Up @@ -292,15 +292,15 @@ pub fn run() -> Result<()> {
let state_version =
RelayChainCli::native_runtime_version(&config.chain_spec).state_version();
let block: Block = generate_genesis_block(&*config.chain_spec, state_version)
.map_err(|e| format!("{:?}", e))?;
.map_err(|e| format!("{e:?}"))?;
let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));

let polkadot_config = SubstrateCli::create_configuration(
&polkadot_cli,
&polkadot_cli,
config.tokio_handle.clone(),
)
.map_err(|err| format!("Relay chain argument error: {}", err))?;
.map_err(|err| format!("Relay chain argument error: {err}"))?;

info!("Parachain id: {:?}", id);
info!("Parachain Account: {}", parachain_account);
Expand Down
2 changes: 1 addition & 1 deletion bridges/bin/rialto-parachain/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ pub async fn start_node(
use substrate_frame_rpc_system::{System, SystemApiServer};

let mut io = jsonrpsee::RpcModule::new(());
let map_err = |e| sc_service::Error::Other(format!("{}", e));
let map_err = |e| sc_service::Error::Other(format!("{e}"));
io.merge(System::new(client.clone(), pool, DenyUnsafe::No).into_rpc())
.map_err(map_err)?;
io.merge(TransactionPayment::new(client).into_rpc()).map_err(map_err)?;
Expand Down
4 changes: 2 additions & 2 deletions bridges/bin/rialto/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub enum Alternative {

/// Helper function to generate a crypto pair from seed
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{}", seed), None)
TPublic::Pair::from_string(&format!("//{seed}"), None)
.expect("static values are valid; qed")
.public()
}
Expand Down Expand Up @@ -156,7 +156,7 @@ fn endowed_accounts() -> Vec<AccountId> {
let all_authorities = ALL_AUTHORITIES_ACCOUNTS.iter().flat_map(|x| {
[
get_account_id_from_seed::<sr25519::Public>(x),
get_account_id_from_seed::<sr25519::Public>(&format!("{}//stash", x)),
get_account_id_from_seed::<sr25519::Public>(&format!("{x}//stash")),
]
});
vec![
Expand Down
2 changes: 1 addition & 1 deletion bridges/bin/rialto/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl SubstrateCli for Cli {
match id {
"" | "dev" => crate::chain_spec::Alternative::Development,
"local" => crate::chain_spec::Alternative::LocalTestnet,
_ => return Err(format!("Unsupported chain specification: {}", id)),
_ => return Err(format!("Unsupported chain specification: {id}")),
}
.load(),
))
Expand Down
4 changes: 2 additions & 2 deletions bridges/relays/bin-substrate/src/cli/estimate_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl std::str::FromStr for ConversionRateOverride {

f64::from_str(s)
.map(ConversionRateOverride::Explicit)
.map_err(|e| format!("Failed to parse '{:?}'. Expected 'metric' or explicit value", e))
.map_err(|e| format!("Failed to parse '{e:?}'. Expected 'metric' or explicit value"))
}
}

Expand All @@ -105,7 +105,7 @@ where
.await?;

log::info!(target: "bridge", "Fee: {:?}", Balance(fee.into()));
println!("{}", fee);
println!("{fee}");
Ok(())
}
}
Expand Down
6 changes: 3 additions & 3 deletions bridges/relays/bin-substrate/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ impl std::str::FromStr for HexBytes {

impl std::fmt::Debug for HexBytes {
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(fmt, "0x{}", self)
write!(fmt, "0x{self}")
}
}

Expand Down Expand Up @@ -275,7 +275,7 @@ where

V::from_str(s)
.map(ExplicitOrMaximal::Explicit)
.map_err(|e| format!("Failed to parse '{:?}'. Expected 'max' or explicit value", e))
.map_err(|e| format!("Failed to parse '{e:?}'. Expected 'max' or explicit value"))
}
}

Expand All @@ -298,7 +298,7 @@ mod tests {
fn hex_bytes_display_matches_from_str_for_clap() {
// given
let hex = HexBytes(vec![1, 2, 3, 4]);
let display = format!("{}", hex);
let display = format!("{hex}");

// when
let hex2: HexBytes = display.parse().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions bridges/relays/bin-substrate/src/cli/resubmit_transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,10 @@ async fn update_transaction_tip<C: Chain, S: TransactionSignScheme<Chain = C>>(
tip_limit: C::Balance,
target_priority: TransactionPriority,
) -> Result<(bool, S::SignedTransaction), SubstrateError> {
let stx = format!("{:?}", tx);
let stx = format!("{tx:?}");
let mut current_priority = client.validate_transaction(at_block.1, tx.clone()).await??.priority;
let mut unsigned_tx = S::parse_transaction(tx).ok_or_else(|| {
SubstrateError::Custom(format!("Failed to parse {} transaction {}", C::NAME, stx,))
SubstrateError::Custom(format!("Failed to parse {} transaction {stx}", C::NAME,))
})?;
let old_tip = unsigned_tx.tip;

Expand Down
2 changes: 1 addition & 1 deletion bridges/relays/client-substrate/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub enum Error {

impl From<tokio::task::JoinError> for Error {
fn from(error: tokio::task::JoinError) -> Self {
Error::Custom(format!("Failed to wait tokio task: {}", error))
Error::Custom(format!("Failed to wait tokio task: {error}"))
}
}

Expand Down
2 changes: 1 addition & 1 deletion bridges/relays/finality/src/finality_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ impl<Tracker: TransactionTracker, Number: Debug + PartialOrd> Transaction<Tracke
target_client
.best_finalized_source_block_id()
.await
.map_err(|e| format!("failed to read best block from target node: {:?}", e))
.map_err(|e| format!("failed to read best block from target node: {e:?}"))
.and_then(|best_id_at_target| {
if self.submitted_header_number > best_id_at_target.0 {
return Err(format!(
Expand Down
10 changes: 5 additions & 5 deletions bridges/relays/finality/src/sync_loop_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ impl SyncLoopMetrics {
) -> Result<Self, PrometheusError> {
Ok(SyncLoopMetrics {
best_source_block_number: IntGauge::new(
metric_name(prefix, &format!("best_{}_block_number", at_source_chain_label)),
format!("Best block number at the {}", at_source_chain_label),
metric_name(prefix, &format!("best_{at_source_chain_label}_block_number")),
format!("Best block number at the {at_source_chain_label}"),
)?,
best_target_block_number: IntGauge::new(
metric_name(prefix, &format!("best_{}_block_number", at_target_chain_label)),
format!("Best block number at the {}", at_target_chain_label),
metric_name(prefix, &format!("best_{at_target_chain_label}_block_number")),
format!("Best block number at the {at_target_chain_label}"),
)?,
using_different_forks: IntGauge::new(
metric_name(prefix, &format!("is_{}_and_{}_using_different_forks", at_source_chain_label, at_target_chain_label)),
metric_name(prefix, &format!("is_{at_source_chain_label}_and_{at_target_chain_label}_using_different_forks")),
"Whether the best finalized source block at target node is different (value 1) from the \
corresponding block at the source node",
)?,
Expand Down
2 changes: 1 addition & 1 deletion bridges/relays/lib-substrate-relay/src/finality/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl<P: SubstrateFinalitySyncPipeline> SourceClient<FinalitySyncPipelineAdapter<
let justification = match decoded_justification {
Ok(j) => j,
Err(err) => {
log_error(format!("decode failed with error {:?}", err));
log_error(format!("decode failed with error {err:?}"));
continue
},
};
Expand Down
4 changes: 2 additions & 2 deletions bridges/relays/lib-substrate-relay/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use relay_utils::metrics::{FloatJsonValueMetric, PrometheusError, StandaloneMetr
/// Creates standalone token price metric.
pub fn token_price_metric(token_id: &str) -> Result<FloatJsonValueMetric, PrometheusError> {
FloatJsonValueMetric::new(
format!("https://api.coingecko.com/api/v3/simple/price?ids={}&vs_currencies=btc", token_id),
format!("$.{}.btc", token_id),
format!("https://api.coingecko.com/api/v3/simple/price?ids={token_id}&vs_currencies=btc"),
format!("$.{token_id}.btc"),
format!("{}_to_base_conversion_rate", token_id.replace('-', "_")),
format!("Rate used to convert from {} to some BASE tokens", token_id.to_uppercase()),
)
Expand Down
8 changes: 4 additions & 4 deletions bridges/relays/lib-substrate-relay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ impl<AccountId> TaggedAccount<AccountId> {
/// Returns stringified account tag.
pub fn tag(&self) -> String {
match *self {
TaggedAccount::Headers { ref bridged_chain, .. } => format!("{}Headers", bridged_chain),
TaggedAccount::Headers { ref bridged_chain, .. } => format!("{bridged_chain}Headers"),
TaggedAccount::Parachains { ref bridged_chain, .. } => {
format!("{}Parachains", bridged_chain)
format!("{bridged_chain}Parachains")
},
TaggedAccount::Messages { ref bridged_chain, .. } => {
format!("{}Messages", bridged_chain)
format!("{bridged_chain}Messages")
},
TaggedAccount::MessagesPalletOwner { ref bridged_chain, .. } => {
format!("{}MessagesPalletOwner", bridged_chain)
format!("{bridged_chain}MessagesPalletOwner")
},
}
}
Expand Down
4 changes: 2 additions & 2 deletions bridges/relays/lib-substrate-relay/src/on_demand/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ async fn background_task<P: SubstrateFinalitySyncPipeline>(

// submit mandatory header if some headers are missing
let best_finalized_source_header_at_source_fmt =
format!("{:?}", best_finalized_source_header_at_source);
format!("{best_finalized_source_header_at_source:?}");
let best_finalized_source_header_at_target_fmt =
format!("{:?}", best_finalized_source_header_at_target);
format!("{best_finalized_source_header_at_target:?}");
let required_header_number_value = *required_header_number.lock().await;
let mandatory_scan_range = mandatory_headers_scan_range::<P::SourceChain>(
best_finalized_source_header_at_source.ok(),
Expand Down
2 changes: 1 addition & 1 deletion bridges/relays/messages/src/message_race_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ pub async fn run<P: MessageRace, SC: SourceClient<P>, TC: TargetClient<P>>(
// nonce at the target node.
race_target.nonces(at_block, false)
.await
.map_err(|e| format!("failed to read nonces from target node: {:?}", e))
.map_err(|e| format!("failed to read nonces from target node: {e:?}"))
.and_then(|(_, nonces_at_target)| {
if nonces_at_target.latest_nonce < *nonces_submitted.end() {
Err(format!(
Expand Down
8 changes: 4 additions & 4 deletions bridges/relays/utils/src/initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub fn initialize_logger(with_timestamp: bool) {
let log_level = color_level(record.level());
let log_target = color_target(record.target());

writeln!(buf, "{}{} {} {}", loop_name_prefix(), log_level, log_target, record.args(),)
writeln!(buf, "{}{log_level} {log_target} {}", loop_name_prefix(), record.args(),)
});
}

Expand All @@ -92,7 +92,7 @@ fn loop_name_prefix() -> String {
if loop_name.is_empty() {
String::new()
} else {
format!("[{}] ", loop_name)
format!("[{loop_name}] ")
}
})
.unwrap_or_else(|_| String::new())
Expand All @@ -105,8 +105,8 @@ enum Either<A, B> {
impl<A: Display, B: Display> Display for Either<A, B> {
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::Left(a) => write!(fmt, "{}", a),
Self::Right(b) => write!(fmt, "{}", b),
Self::Left(a) => write!(fmt, "{a}"),
Self::Right(b) => write!(fmt, "{b}"),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions bridges/relays/utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ pub fn format_ids<Id: std::fmt::Debug>(mut ids: impl ExactSizeIterator<Item = Id
2 => {
let id0 = ids.next().expect(NTH_PROOF);
let id1 = ids.next().expect(NTH_PROOF);
format!("[{:?}, {:?}]", id0, id1)
format!("[{id0:?}, {id1:?}]")
},
len => {
let id0 = ids.next().expect(NTH_PROOF);
let id_last = ids.last().expect(NTH_PROOF);
format!("{}:[{:?} ... {:?}]", len, id0, id_last)
format!("{len}:[{id0:?} ... {id_last:?}]")
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion bridges/relays/utils/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl From<Option<MetricsAddress>> for MetricsParams {
/// Returns metric name optionally prefixed with given prefix.
pub fn metric_name(prefix: Option<&str>, name: &str) -> String {
if let Some(prefix) = prefix {
format!("{}_{}", prefix, name)
format!("{prefix}_{name}")
} else {
name.into()
}
Expand Down

0 comments on commit 49e33c6

Please sign in to comment.