diff --git a/bin/millau/node/src/chain_spec.rs b/bin/millau/node/src/chain_spec.rs index 66ab997aa743..2ded668fdeeb 100644 --- a/bin/millau/node/src/chain_spec.rs +++ b/bin/millau/node/src/chain_spec.rs @@ -56,7 +56,7 @@ pub enum Alternative { /// Helper function to generate a crypto pair from seed pub fn get_from_seed(seed: &str) -> ::Public { - TPublic::Pair::from_string(&format!("//{}", seed), None) + TPublic::Pair::from_string(&format!("//{seed}"), None) .expect("static values are valid; qed") .public() } @@ -150,7 +150,7 @@ fn endowed_accounts() -> Vec { let all_authorities = ALL_AUTHORITIES_ACCOUNTS.iter().flat_map(|x| { [ get_account_id_from_seed::(x), - get_account_id_from_seed::(&format!("{}//stash", x)), + get_account_id_from_seed::(&format!("{x}//stash")), ] }); vec![ diff --git a/bin/millau/node/src/command.rs b/bin/millau/node/src/command.rs index e9f94b03a2ad..b8dff87f8f24 100644 --- a/bin/millau/node/src/command.rs +++ b/bin/millau/node/src/command.rs @@ -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(), )) diff --git a/bin/millau/node/src/service.rs b/bin/millau/node/src/service.rs index 72ad071726b5..72a1036c641b 100644 --- a/bin/millau/node/src/service.rs +++ b/bin/millau/node/src/service.rs @@ -293,7 +293,7 @@ pub fn new_full(mut config: Configuration) -> Result 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)?; @@ -314,7 +314,7 @@ pub fn new_full(mut config: Configuration) -> Result 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)?; diff --git a/bin/rialto-parachain/node/src/chain_spec.rs b/bin/rialto-parachain/node/src/chain_spec.rs index a0306514c039..bfce4f717c67 100644 --- a/bin/rialto-parachain/node/src/chain_spec.rs +++ b/bin/rialto-parachain/node/src/chain_spec.rs @@ -39,7 +39,7 @@ pub type ChainSpec = /// Helper function to generate a crypto pair from seed pub fn get_from_seed(seed: &str) -> ::Public { - TPublic::Pair::from_string(&format!("//{}", seed), None) + TPublic::Pair::from_string(&format!("//{seed}"), None) .expect("static values are valid; qed") .public() } @@ -81,7 +81,7 @@ fn endowed_accounts() -> Vec { let all_authorities = ALL_AUTHORITIES_ACCOUNTS.iter().flat_map(|x| { [ get_account_id_from_seed::(x), - get_account_id_from_seed::(&format!("{}//stash", x)), + get_account_id_from_seed::(&format!("{x}//stash")), ] }); vec![ diff --git a/bin/rialto-parachain/node/src/command.rs b/bin/rialto-parachain/node/src/command.rs index 533e731b3ac9..dd9e95abbe54 100644 --- a/bin/rialto-parachain/node/src/command.rs +++ b/bin/rialto-parachain/node/src/command.rs @@ -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) }) @@ -292,7 +292,7 @@ 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( @@ -300,7 +300,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}"))?; info!("Parachain id: {:?}", id); info!("Parachain Account: {}", parachain_account); diff --git a/bin/rialto-parachain/node/src/service.rs b/bin/rialto-parachain/node/src/service.rs index f97c2fcd7c45..8d722b3caa62 100644 --- a/bin/rialto-parachain/node/src/service.rs +++ b/bin/rialto-parachain/node/src/service.rs @@ -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)?; diff --git a/bin/rialto/node/src/chain_spec.rs b/bin/rialto/node/src/chain_spec.rs index ffd7bafaa837..0e9edb38ac03 100644 --- a/bin/rialto/node/src/chain_spec.rs +++ b/bin/rialto/node/src/chain_spec.rs @@ -57,7 +57,7 @@ pub enum Alternative { /// Helper function to generate a crypto pair from seed pub fn get_from_seed(seed: &str) -> ::Public { - TPublic::Pair::from_string(&format!("//{}", seed), None) + TPublic::Pair::from_string(&format!("//{seed}"), None) .expect("static values are valid; qed") .public() } @@ -156,7 +156,7 @@ fn endowed_accounts() -> Vec { let all_authorities = ALL_AUTHORITIES_ACCOUNTS.iter().flat_map(|x| { [ get_account_id_from_seed::(x), - get_account_id_from_seed::(&format!("{}//stash", x)), + get_account_id_from_seed::(&format!("{x}//stash")), ] }); vec![ diff --git a/bin/rialto/node/src/command.rs b/bin/rialto/node/src/command.rs index 852acb595531..8286444d3ea8 100644 --- a/bin/rialto/node/src/command.rs +++ b/bin/rialto/node/src/command.rs @@ -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(), )) diff --git a/relays/bin-substrate/src/cli/estimate_fee.rs b/relays/bin-substrate/src/cli/estimate_fee.rs index 806df7f01f77..88823eec2f29 100644 --- a/relays/bin-substrate/src/cli/estimate_fee.rs +++ b/relays/bin-substrate/src/cli/estimate_fee.rs @@ -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")) } } @@ -105,7 +105,7 @@ where .await?; log::info!(target: "bridge", "Fee: {:?}", Balance(fee.into())); - println!("{}", fee); + println!("{fee}"); Ok(()) } } diff --git a/relays/bin-substrate/src/cli/mod.rs b/relays/bin-substrate/src/cli/mod.rs index 42a073bd4f65..2369bb60dda7 100644 --- a/relays/bin-substrate/src/cli/mod.rs +++ b/relays/bin-substrate/src/cli/mod.rs @@ -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}") } } @@ -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")) } } @@ -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(); diff --git a/relays/bin-substrate/src/cli/resubmit_transactions.rs b/relays/bin-substrate/src/cli/resubmit_transactions.rs index ac479986ed8f..4481d3fb7121 100644 --- a/relays/bin-substrate/src/cli/resubmit_transactions.rs +++ b/relays/bin-substrate/src/cli/resubmit_transactions.rs @@ -398,10 +398,10 @@ async fn update_transaction_tip>( 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; diff --git a/relays/client-substrate/src/error.rs b/relays/client-substrate/src/error.rs index 016ec774beb4..4252a5027d44 100644 --- a/relays/client-substrate/src/error.rs +++ b/relays/client-substrate/src/error.rs @@ -70,7 +70,7 @@ pub enum Error { impl From 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}")) } } diff --git a/relays/finality/src/finality_loop.rs b/relays/finality/src/finality_loop.rs index 302a038b81eb..1ee1a8d9db6b 100644 --- a/relays/finality/src/finality_loop.rs +++ b/relays/finality/src/finality_loop.rs @@ -220,7 +220,7 @@ impl Transaction best_id_at_target.0 { return Err(format!( diff --git a/relays/finality/src/sync_loop_metrics.rs b/relays/finality/src/sync_loop_metrics.rs index fcfdbbd99f1b..ae73bbedc4f7 100644 --- a/relays/finality/src/sync_loop_metrics.rs +++ b/relays/finality/src/sync_loop_metrics.rs @@ -39,15 +39,15 @@ impl SyncLoopMetrics { ) -> Result { 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", )?, diff --git a/relays/lib-substrate-relay/src/finality/source.rs b/relays/lib-substrate-relay/src/finality/source.rs index 199de3681379..430a83eb43ca 100644 --- a/relays/lib-substrate-relay/src/finality/source.rs +++ b/relays/lib-substrate-relay/src/finality/source.rs @@ -168,7 +168,7 @@ impl SourceClient j, Err(err) => { - log_error(format!("decode failed with error {:?}", err)); + log_error(format!("decode failed with error {err:?}")); continue }, }; diff --git a/relays/lib-substrate-relay/src/helpers.rs b/relays/lib-substrate-relay/src/helpers.rs index 80359b1c2a98..0b824708a899 100644 --- a/relays/lib-substrate-relay/src/helpers.rs +++ b/relays/lib-substrate-relay/src/helpers.rs @@ -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::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()), ) diff --git a/relays/lib-substrate-relay/src/lib.rs b/relays/lib-substrate-relay/src/lib.rs index f4f1aae9d29d..86e652716f64 100644 --- a/relays/lib-substrate-relay/src/lib.rs +++ b/relays/lib-substrate-relay/src/lib.rs @@ -85,15 +85,15 @@ impl TaggedAccount { /// 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") }, } } diff --git a/relays/lib-substrate-relay/src/on_demand/headers.rs b/relays/lib-substrate-relay/src/on_demand/headers.rs index 09e7a41a0c72..87f1e012cc57 100644 --- a/relays/lib-substrate-relay/src/on_demand/headers.rs +++ b/relays/lib-substrate-relay/src/on_demand/headers.rs @@ -172,9 +172,9 @@ async fn background_task( // 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::( best_finalized_source_header_at_source.ok(), diff --git a/relays/messages/src/message_race_loop.rs b/relays/messages/src/message_race_loop.rs index 15308f93032b..4f59b635ae6f 100644 --- a/relays/messages/src/message_race_loop.rs +++ b/relays/messages/src/message_race_loop.rs @@ -425,7 +425,7 @@ pub async fn run, TC: TargetClient

>( // 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!( diff --git a/relays/utils/src/initialize.rs b/relays/utils/src/initialize.rs index ad69a766e623..8224c1803ad2 100644 --- a/relays/utils/src/initialize.rs +++ b/relays/utils/src/initialize.rs @@ -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(),) }); } @@ -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()) @@ -105,8 +105,8 @@ enum Either { impl Display for Either { 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}"), } } } diff --git a/relays/utils/src/lib.rs b/relays/utils/src/lib.rs index eb3d8ec75250..42bf86ebf5b3 100644 --- a/relays/utils/src/lib.rs +++ b/relays/utils/src/lib.rs @@ -189,12 +189,12 @@ pub fn format_ids(mut ids: impl ExactSizeIterator { 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:?}]") }, } } diff --git a/relays/utils/src/metrics.rs b/relays/utils/src/metrics.rs index b5225fca0e0c..fa7a79a71c14 100644 --- a/relays/utils/src/metrics.rs +++ b/relays/utils/src/metrics.rs @@ -121,7 +121,7 @@ impl From> 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() }