From 53b98fde29ce55204a1185876de906af308e988c Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Mon, 25 Oct 2021 12:08:14 +0300 Subject: [PATCH] cargo +nightly fmt --all (#1192) --- bridges/bin/millau/runtime/src/lib.rs | 4 +--- bridges/modules/ethereum/src/validators.rs | 1 + bridges/modules/ethereum/src/verification.rs | 1 + bridges/modules/token-swap/src/lib.rs | 1 + bridges/relays/bin-substrate/src/chains/mod.rs | 18 ++++++++++-------- .../src/chains/rialto_headers_to_millau.rs | 2 +- .../src/chains/westend_headers_to_millau.rs | 2 +- .../bin-substrate/src/cli/init_bridge.rs | 4 ++-- .../src/cli/register_parachain.rs | 2 +- .../src/cli/resubmit_transactions.rs | 6 +++--- .../src/headers_initialize.rs | 16 +++++++--------- .../messages/src/message_race_delivery.rs | 2 +- 12 files changed, 30 insertions(+), 29 deletions(-) diff --git a/bridges/bin/millau/runtime/src/lib.rs b/bridges/bin/millau/runtime/src/lib.rs index 4e43868fe86e3..92d1c8614d23e 100644 --- a/bridges/bin/millau/runtime/src/lib.rs +++ b/bridges/bin/millau/runtime/src/lib.rs @@ -65,9 +65,7 @@ pub use frame_support::{ pub use frame_system::Call as SystemCall; pub use pallet_balances::Call as BalancesCall; -pub use pallet_bridge_grandpa::{ - Call as BridgeGrandpaRialtoCall, Call as BridgeGrandpaWestendCall, -}; +pub use pallet_bridge_grandpa::Call as BridgeGrandpaCall; pub use pallet_bridge_messages::Call as MessagesCall; pub use pallet_sudo::Call as SudoCall; pub use pallet_timestamp::Call as TimestampCall; diff --git a/bridges/modules/ethereum/src/validators.rs b/bridges/modules/ethereum/src/validators.rs index 020e6fa796126..fd010d52c39de 100644 --- a/bridges/modules/ethereum/src/validators.rs +++ b/bridges/modules/ethereum/src/validators.rs @@ -132,6 +132,7 @@ impl<'a> Validators<'a> { } let receipts = receipts.ok_or(Error::MissingTransactionsReceipts)?; + #[allow(clippy::question_mark)] if header.check_receipts_root(&receipts).is_err() { return Err(Error::TransactionsReceiptsMismatch) } diff --git a/bridges/modules/ethereum/src/verification.rs b/bridges/modules/ethereum/src/verification.rs index c708a6ba2d0b3..053ce4d0fea4d 100644 --- a/bridges/modules/ethereum/src/verification.rs +++ b/bridges/modules/ethereum/src/verification.rs @@ -152,6 +152,7 @@ pub fn accept_aura_header_into_pool( // the heaviest, but rare operation - we do not want invalid receipts in the pool if let Some(receipts) = receipts { log::trace!(target: "runtime", "Got receipts! {:?}", receipts); + #[allow(clippy::question_mark)] if header.check_receipts_root(receipts).is_err() { return Err(Error::TransactionsReceiptsMismatch) } diff --git a/bridges/modules/token-swap/src/lib.rs b/bridges/modules/token-swap/src/lib.rs index 60ca1221dd07e..43fa13ba4bdb8 100644 --- a/bridges/modules/token-swap/src/lib.rs +++ b/bridges/modules/token-swap/src/lib.rs @@ -226,6 +226,7 @@ pub mod pallet { /// Violating rule#1 will lead to losing your `source_balance_at_this_chain` tokens. /// Violating other rules will lead to losing message fees for this and other transactions + /// losing fees for message transfer. + #[allow(clippy::boxed_local)] #[pallet::weight( T::WeightInfo::create_swap() .saturating_add(T::WeightInfo::send_message_weight( diff --git a/bridges/relays/bin-substrate/src/chains/mod.rs b/bridges/relays/bin-substrate/src/chains/mod.rs index 1e5e549d519a9..2cbe3fe614622 100644 --- a/bridges/relays/bin-substrate/src/chains/mod.rs +++ b/bridges/relays/bin-substrate/src/chains/mod.rs @@ -287,10 +287,11 @@ mod rococo_tests { Box::new(header.clone()), justification.clone(), ); - let expected = millau_runtime::BridgeGrandpaRialtoCall::::submit_finality_proof( - Box::new(header), - justification, - ); + let expected = + millau_runtime::BridgeGrandpaCall::::submit_finality_proof( + Box::new(header), + justification, + ); // when let actual_encoded = actual.encode(); @@ -335,10 +336,11 @@ mod westend_tests { header.clone(), justification.clone(), ); - let expected = millau_runtime::BridgeGrandpaRialtoCall::::submit_finality_proof( - Box::new(header), - justification, - ); + let expected = + millau_runtime::BridgeGrandpaCall::::submit_finality_proof( + Box::new(header), + justification, + ); // when let actual_encoded = actual.encode(); diff --git a/bridges/relays/bin-substrate/src/chains/rialto_headers_to_millau.rs b/bridges/relays/bin-substrate/src/chains/rialto_headers_to_millau.rs index 79ce6160b87f6..f4a2f1efe781a 100644 --- a/bridges/relays/bin-substrate/src/chains/rialto_headers_to_millau.rs +++ b/bridges/relays/bin-substrate/src/chains/rialto_headers_to_millau.rs @@ -66,7 +66,7 @@ impl SubstrateFinalitySyncPipeline for RialtoFinalityToMillau { header: RialtoSyncHeader, proof: GrandpaJustification, ) -> Bytes { - let call = millau_runtime::BridgeGrandpaRialtoCall::< + let call = millau_runtime::BridgeGrandpaCall::< millau_runtime::Runtime, millau_runtime::RialtoGrandpaInstance, >::submit_finality_proof(Box::new(header.into_inner()), proof) diff --git a/bridges/relays/bin-substrate/src/chains/westend_headers_to_millau.rs b/bridges/relays/bin-substrate/src/chains/westend_headers_to_millau.rs index 1ea8fc7dd794e..41b76283e2024 100644 --- a/bridges/relays/bin-substrate/src/chains/westend_headers_to_millau.rs +++ b/bridges/relays/bin-substrate/src/chains/westend_headers_to_millau.rs @@ -74,7 +74,7 @@ impl SubstrateFinalitySyncPipeline for WestendFinalityToMillau { header: WestendSyncHeader, proof: GrandpaJustification, ) -> Bytes { - let call = millau_runtime::BridgeGrandpaWestendCall::< + let call = millau_runtime::BridgeGrandpaCall::< millau_runtime::Runtime, millau_runtime::WestendGrandpaInstance, >::submit_finality_proof(Box::new(header.into_inner()), proof) diff --git a/bridges/relays/bin-substrate/src/cli/init_bridge.rs b/bridges/relays/bin-substrate/src/cli/init_bridge.rs index f1c957f5e217d..bdabc0177d990 100644 --- a/bridges/relays/bin-substrate/src/cli/init_bridge.rs +++ b/bridges/relays/bin-substrate/src/cli/init_bridge.rs @@ -75,7 +75,7 @@ macro_rules! select_bridge { fn encode_init_bridge( init_data: InitializationData<::Header>, ) -> ::Call { - let initialize_call = millau_runtime::BridgeGrandpaRialtoCall::< + let initialize_call = millau_runtime::BridgeGrandpaCall::< millau_runtime::Runtime, millau_runtime::RialtoGrandpaInstance, >::initialize(init_data); @@ -95,7 +95,7 @@ macro_rules! select_bridge { // our deployments may fail, because we need to initialize both Rialto -> Millau // and Westend -> Millau bridge. => since there's single possible sudo account, // one of transaction may fail with duplicate nonce error - millau_runtime::BridgeGrandpaWestendCall::< + millau_runtime::BridgeGrandpaCall::< millau_runtime::Runtime, millau_runtime::WestendGrandpaInstance, >::initialize(init_data) diff --git a/bridges/relays/bin-substrate/src/cli/register_parachain.rs b/bridges/relays/bin-substrate/src/cli/register_parachain.rs index 4f15bbec86c00..7d7622ef488ea 100644 --- a/bridges/relays/bin-substrate/src/cli/register_parachain.rs +++ b/bridges/relays/bin-substrate/src/cli/register_parachain.rs @@ -112,7 +112,7 @@ impl RegisterParachain { // step 1: reserve a parachain id let relay_genesis_hash = *relay_client.genesis_hash(); - let relay_sudo_account: AccountIdOf = relay_sign.public().clone().into(); + let relay_sudo_account: AccountIdOf = relay_sign.public().into(); let reserve_parachain_id_call: CallOf = ParaRegistrarCall::reserve().into(); let reserve_parachain_signer = relay_sign.clone(); wait_until_transaction_is_finalized::( diff --git a/bridges/relays/bin-substrate/src/cli/resubmit_transactions.rs b/bridges/relays/bin-substrate/src/cli/resubmit_transactions.rs index 1091048b3ba00..66728622d755d 100644 --- a/bridges/relays/bin-substrate/src/cli/resubmit_transactions.rs +++ b/bridges/relays/bin-substrate/src/cli/resubmit_transactions.rs @@ -134,9 +134,9 @@ impl ResubmitTransactions { transaction: None, resubmitted: 0, stalled_for: Zero::zero(), - stalled_for_limit: self.stalled_blocks.into(), - tip_step: self.tip_step.cast().into(), - tip_limit: self.tip_limit.cast().into(), + stalled_for_limit: self.stalled_blocks as _, + tip_step: self.tip_step.cast() as _, + tip_limit: self.tip_limit.cast() as _, }, ) }) diff --git a/bridges/relays/lib-substrate-relay/src/headers_initialize.rs b/bridges/relays/lib-substrate-relay/src/headers_initialize.rs index ca82f50942ab3..2e802c4cb2150 100644 --- a/bridges/relays/lib-substrate-relay/src/headers_initialize.rs +++ b/bridges/relays/lib-substrate-relay/src/headers_initialize.rs @@ -34,7 +34,7 @@ use num_traits::{One, Zero}; use relay_substrate_client::{Chain, Client}; use sp_core::Bytes; use sp_finality_grandpa::AuthorityList as GrandpaAuthoritiesSet; -use sp_runtime::traits::{Header as HeaderT, Header}; +use sp_runtime::traits::Header as HeaderT; /// Submit headers-bridge initialization transaction. pub async fn initialize( @@ -79,7 +79,7 @@ async fn do_initialize( prepare_initialize_transaction: impl FnOnce(TargetChain::Index, InitializationData) -> Bytes + Send + 'static, -) -> Result::Number>> { +) -> Result::Number>> { let initialization_data = prepare_initialization_data(source_client).await?; log::info!( target: "bridge", @@ -103,7 +103,7 @@ async fn prepare_initialization_data( source_client: Client, ) -> Result< InitializationData, - Error::Number>, + Error::Number>, > { // In ideal world we just need to get best finalized header and then to read GRANDPA authorities // set (`pallet_grandpa::CurrentSetId` + `GrandpaApi::grandpa_authorities()`) at this header. @@ -121,7 +121,7 @@ async fn prepare_initialization_data( .await .map_err(|e| Error::ReadJustification(SourceChain::NAME, e)) .and_then(|justification| { - justification.ok_or_else(|| Error::ReadJustificationStreamEnded(SourceChain::NAME)) + justification.ok_or(Error::ReadJustificationStreamEnded(SourceChain::NAME)) })?; // Read initial header. @@ -174,9 +174,7 @@ async fn prepare_initialization_data( let mut initial_authorities_set_id = 0; let mut min_possible_block_number = SourceChain::BlockNumber::zero(); let authorities_for_verification = VoterSet::new(authorities_for_verification.clone()) - .ok_or_else(|| { - Error::ReadInvalidAuthorities(SourceChain::NAME, authorities_for_verification) - })?; + .ok_or(Error::ReadInvalidAuthorities(SourceChain::NAME, authorities_for_verification))?; loop { log::trace!( target: "bridge", "Trying {} GRANDPA authorities set id: {}", @@ -222,7 +220,7 @@ async fn prepare_initialization_data( async fn source_header( source_client: &Client, header_hash: SourceChain::Hash, -) -> Result::Number>> +) -> Result::Number>> { source_client .header_by_hash(header_hash) @@ -234,7 +232,7 @@ async fn source_header( async fn source_authorities_set( source_client: &Client, header_hash: SourceChain::Hash, -) -> Result::Number>> +) -> Result::Number>> { let raw_authorities_set = source_client .grandpa_authorities_set(header_hash) diff --git a/bridges/relays/messages/src/message_race_delivery.rs b/bridges/relays/messages/src/message_race_delivery.rs index 3433b683d7a77..4fd721dae5977 100644 --- a/bridges/relays/messages/src/message_race_delivery.rs +++ b/bridges/relays/messages/src/message_race_delivery.rs @@ -444,7 +444,7 @@ where ); return None - } + }, _ => (), }