From 5902bc790ba9415ac2d25b270c2b2e7894f0ad7b Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Thu, 23 Sep 2021 15:04:42 +0300 Subject: [PATCH] Fix/ignore clippy warnings (#1157) * fix/ignore clippy * --locked check && test * RUSTC_WRAPPER="" for clippy-nightly, check-nightly, test-nightly --- bridges/bin/rialto-parachain/node/src/cli.rs | 2 -- .../bin/rialto-parachain/node/src/command.rs | 10 ++++----- .../bin/rialto-parachain/node/src/service.rs | 10 +++++---- .../bin/rialto-parachain/runtime/src/lib.rs | 10 ++++----- bridges/bin/rialto/node/src/overseer.rs | 22 +++++++++---------- bridges/bin/rialto/node/src/service.rs | 2 +- bridges/modules/ethereum/src/lib.rs | 12 +--------- bridges/modules/token-swap/src/lib.rs | 1 + bridges/primitives/chain-kusama/src/lib.rs | 2 +- bridges/primitives/ethereum-poa/src/lib.rs | 2 ++ bridges/primitives/runtime/src/lib.rs | 4 ++-- .../bin-substrate/src/cli/swap_tokens.rs | 16 +++++++++----- bridges/relays/headers/src/headers.rs | 9 -------- 13 files changed, 45 insertions(+), 57 deletions(-) diff --git a/bridges/bin/rialto-parachain/node/src/cli.rs b/bridges/bin/rialto-parachain/node/src/cli.rs index 865d8eb92bea2..3a55da24d9092 100644 --- a/bridges/bin/rialto-parachain/node/src/cli.rs +++ b/bridges/bin/rialto-parachain/node/src/cli.rs @@ -15,8 +15,6 @@ // along with Parity Bridges Common. If not, see . use crate::chain_spec; -use cumulus_client_cli; -use sc_cli; use std::path::PathBuf; use structopt::StructOpt; diff --git a/bridges/bin/rialto-parachain/node/src/command.rs b/bridges/bin/rialto-parachain/node/src/command.rs index a37673a5b9bcb..a2cffd0fae74f 100644 --- a/bridges/bin/rialto-parachain/node/src/command.rs +++ b/bridges/bin/rialto-parachain/node/src/command.rs @@ -112,7 +112,7 @@ impl SubstrateCli for RelayChainCli { } fn load_spec(&self, id: &str) -> std::result::Result, String> { - polkadot_cli::Cli::from_iter([RelayChainCli::executable_name().to_string()].iter()).load_spec(id) + polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id) } fn native_runtime_version(chain_spec: &Box) -> &'static RuntimeVersion { @@ -120,7 +120,7 @@ impl SubstrateCli for RelayChainCli { } } -fn extract_genesis_wasm(chain_spec: &Box) -> Result> { +fn extract_genesis_wasm(chain_spec: &dyn sc_service::ChainSpec) -> Result> { let mut storage = chain_spec.build_storage()?; storage @@ -181,7 +181,7 @@ pub fn run() -> Result<()> { runner.sync_run(|config| { let polkadot_cli = RelayChainCli::new( &config, - [RelayChainCli::executable_name().to_string()] + [RelayChainCli::executable_name()] .iter() .chain(cli.relaychain_args.iter()), ); @@ -225,7 +225,7 @@ pub fn run() -> Result<()> { builder.with_profiling(sc_tracing::TracingReceiver::Log, ""); let _ = builder.init(); - let raw_wasm_blob = extract_genesis_wasm(&cli.load_spec(¶ms.chain.clone().unwrap_or_default())?)?; + let raw_wasm_blob = extract_genesis_wasm(&*cli.load_spec(¶ms.chain.clone().unwrap_or_default())?)?; let output_buf = if params.raw { raw_wasm_blob } else { @@ -259,7 +259,7 @@ pub fn run() -> Result<()> { let polkadot_cli = RelayChainCli::new( &config, - [RelayChainCli::executable_name().to_string()] + [RelayChainCli::executable_name()] .iter() .chain(cli.relaychain_args.iter()), ); diff --git a/bridges/bin/rialto-parachain/node/src/service.rs b/bridges/bin/rialto-parachain/node/src/service.rs index a812358edf363..cbd10ca2aa218 100644 --- a/bridges/bin/rialto-parachain/node/src/service.rs +++ b/bridges/bin/rialto-parachain/node/src/service.rs @@ -68,6 +68,7 @@ impl NativeExecutionDispatch for ExecutorDispatch { /// /// Use this macro if you don't actually need the full service, but just the builder in order to /// be able to perform chain operations. +#[allow(clippy::type_complexity)] pub fn new_partial( config: &Configuration, build_import_queue: BIQ, @@ -123,7 +124,7 @@ where ); let (client, backend, keystore_container, task_manager) = sc_service::new_full_parts::( - &config, + config, telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), executor, )?; @@ -332,6 +333,7 @@ where } /// Build the import queue for the the parachain runtime. +#[allow(clippy::type_complexity)] pub fn parachain_build_import_queue( client: Arc>>, config: &Configuration, @@ -360,7 +362,7 @@ pub fn parachain_build_import_queue( Ok((time, slot)) }, - registry: config.prometheus_registry().clone(), + registry: config.prometheus_registry(), can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()), spawner: &task_manager.spawn_essential_handle(), telemetry, @@ -399,7 +401,7 @@ pub async fn start_node( task_manager.spawn_handle(), client.clone(), transaction_pool, - prometheus_registry.clone(), + prometheus_registry, telemetry.clone(), ); @@ -444,7 +446,7 @@ pub async fn start_node( block_import: client.clone(), relay_chain_client: relay_chain_node.client.clone(), relay_chain_backend: relay_chain_node.backend.clone(), - para_client: client.clone(), + para_client: client, backoff_authoring_blocks: Option::<()>::None, sync_oracle, keystore, diff --git a/bridges/bin/rialto-parachain/runtime/src/lib.rs b/bridges/bin/rialto-parachain/runtime/src/lib.rs index 58f592bea8cef..613c444a28f27 100644 --- a/bridges/bin/rialto-parachain/runtime/src/lib.rs +++ b/bridges/bin/rialto-parachain/runtime/src/lib.rs @@ -263,10 +263,10 @@ impl pallet_timestamp::Config for Runtime { } parameter_types! { - pub const ExistentialDeposit: u128 = 1 * MILLIUNIT; - pub const TransferFee: u128 = 1 * MILLIUNIT; - pub const CreationFee: u128 = 1 * MILLIUNIT; - pub const TransactionByteFee: u128 = 1 * MICROUNIT; + pub const ExistentialDeposit: u128 = MILLIUNIT; + pub const TransferFee: u128 = MILLIUNIT; + pub const CreationFee: u128 = MILLIUNIT; + pub const TransactionByteFee: u128 = MICROUNIT; pub const MaxLocks: u32 = 50; pub const MaxReserves: u32 = 50; } @@ -671,7 +671,7 @@ impl cumulus_pallet_parachain_system::CheckInherents for CheckInherents { .create_inherent_data() .expect("Could not create the timestamp inherent data"); - inherent_data.check_extrinsics(&block) + inherent_data.check_extrinsics(block) } } diff --git a/bridges/bin/rialto/node/src/overseer.rs b/bridges/bin/rialto/node/src/overseer.rs index ff82db8b0e57f..3742bcdc8927d 100644 --- a/bridges/bin/rialto/node/src/overseer.rs +++ b/bridges/bin/rialto/node/src/overseer.rs @@ -110,7 +110,7 @@ where /// /// A convenience for usage with malus, to avoid /// repetitive code across multiple behavior strain implementations. -pub fn create_default_subsystems<'a, Spawner, RuntimeClient>( +pub fn create_default_subsystems( OverseerGenArgs { keystore, runtime_client, @@ -130,7 +130,7 @@ pub fn create_default_subsystems<'a, Spawner, RuntimeClient>( chain_selection_config, dispute_coordinator_config, .. - }: OverseerGenArgs<'a, Spawner, RuntimeClient>, + }: OverseerGenArgs<'_, Spawner, RuntimeClient>, ) -> Result< AllSubsystems< CandidateValidationSubsystem, @@ -212,7 +212,7 @@ where Metrics::register(registry)?, ), provisioner: ProvisionerSubsystem::new(spawner.clone(), (), Metrics::register(registry)?), - runtime_api: RuntimeApiSubsystem::new(runtime_client.clone(), Metrics::register(registry)?, spawner.clone()), + runtime_api: RuntimeApiSubsystem::new(runtime_client, Metrics::register(registry)?, spawner), statement_distribution: StatementDistributionSubsystem::new( keystore.clone(), statement_req_receiver, @@ -223,7 +223,7 @@ where approval_voting_config, parachains_db.clone(), keystore.clone(), - Box::new(network_service.clone()), + Box::new(network_service), Metrics::register(registry)?, ), gossip_support: GossipSupportSubsystem::new(keystore.clone()), @@ -234,9 +234,9 @@ where ), dispute_participation: DisputeParticipationSubsystem::new(), dispute_distribution: DisputeDistributionSubsystem::new( - keystore.clone(), + keystore, dispute_req_receiver, - authority_discovery_service.clone(), + authority_discovery_service, Metrics::register(registry)?, ), chain_selection: ChainSelectionSubsystem::new(chain_selection_config, parachains_db), @@ -250,9 +250,9 @@ where /// would do. pub trait OverseerGen { /// Overwrite the full generation of the overseer, including the subsystems. - fn generate<'a, Spawner, RuntimeClient>( + fn generate( &self, - args: OverseerGenArgs<'a, Spawner, RuntimeClient>, + args: OverseerGenArgs<'_, Spawner, RuntimeClient>, ) -> Result<(Overseer>, OverseerHandle), Error> where RuntimeClient: 'static + ProvideRuntimeApi + HeaderBackend + AuxStore, @@ -271,9 +271,9 @@ pub trait OverseerGen { pub struct RealOverseerGen; impl OverseerGen for RealOverseerGen { - fn generate<'a, Spawner, RuntimeClient>( + fn generate( &self, - args: OverseerGenArgs<'a, Spawner, RuntimeClient>, + args: OverseerGenArgs<'_, Spawner, RuntimeClient>, ) -> Result<(Overseer>, OverseerHandle), Error> where RuntimeClient: 'static + ProvideRuntimeApi + HeaderBackend + AuxStore, @@ -283,7 +283,7 @@ impl OverseerGen for RealOverseerGen { let spawner = args.spawner.clone(); let leaves = args.leaves.clone(); let runtime_client = args.runtime_client.clone(); - let registry = args.registry.clone(); + let registry = args.registry; let all_subsystems = create_default_subsystems::(args)?; diff --git a/bridges/bin/rialto/node/src/service.rs b/bridges/bin/rialto/node/src/service.rs index dd7aea1b9cba5..19743933c1eaf 100644 --- a/bridges/bin/rialto/node/src/service.rs +++ b/bridges/bin/rialto/node/src/service.rs @@ -605,7 +605,7 @@ where pov_req_receiver, statement_req_receiver, })?; - let handle = Handle::Connected(overseer_handle.clone()); + let handle = Handle::Connected(overseer_handle); let handle_clone = handle.clone(); task_manager.spawn_essential_handle().spawn_blocking( diff --git a/bridges/modules/ethereum/src/lib.rs b/bridges/modules/ethereum/src/lib.rs index e1239c049401b..88a35f365e40b 100644 --- a/bridges/modules/ethereum/src/lib.rs +++ b/bridges/modules/ethereum/src/lib.rs @@ -556,6 +556,7 @@ pub mod pallet { StorageMap<_, Identity, H256, AuraScheduledChange>; #[pallet::genesis_config] + #[cfg_attr(feature = "std", derive(Default))] pub struct GenesisConfig { /// PoA header to start with. pub initial_header: AuraHeader, @@ -565,17 +566,6 @@ pub mod pallet { pub initial_validators: Vec
, } - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - Self { - initial_header: Default::default(), - initial_difficulty: Default::default(), - initial_validators: Default::default(), - } - } - } - #[pallet::genesis_build] impl, I: 'static> GenesisBuild for GenesisConfig { fn build(&self) { diff --git a/bridges/modules/token-swap/src/lib.rs b/bridges/modules/token-swap/src/lib.rs index 4c56ec5aa969d..5528a25296d50 100644 --- a/bridges/modules/token-swap/src/lib.rs +++ b/bridges/modules/token-swap/src/lib.rs @@ -192,6 +192,7 @@ pub mod pallet { /// rules will lead to losing message fees for this and other transactions + losing fees for message /// transfer. #[pallet::weight(0)] + #[allow(clippy::too_many_arguments)] pub fn create_swap( origin: OriginFor, swap: TokenSwapOf, diff --git a/bridges/primitives/chain-kusama/src/lib.rs b/bridges/primitives/chain-kusama/src/lib.rs index 4dec9cd2a0ece..f4c448e41c60f 100644 --- a/bridges/primitives/chain-kusama/src/lib.rs +++ b/bridges/primitives/chain-kusama/src/lib.rs @@ -77,7 +77,7 @@ pub const EXISTENTIAL_DEPOSIT: Balance = 1_000_000_000_000 / 30_000; /// /// Note that since this is a target sessions may change before/after this time depending on network /// conditions. -pub const SESSION_LENGTH: BlockNumber = 1 * time_units::HOURS; +pub const SESSION_LENGTH: BlockNumber = time_units::HOURS; /// Name of the With-Polkadot messages pallet instance in the Kusama runtime. pub const WITH_POLKADOT_MESSAGES_PALLET_NAME: &str = "BridgePolkadotMessages"; diff --git a/bridges/primitives/ethereum-poa/src/lib.rs b/bridges/primitives/ethereum-poa/src/lib.rs index b2e00760c01d6..657038a25f33b 100644 --- a/bridges/primitives/ethereum-poa/src/lib.rs +++ b/bridges/primitives/ethereum-poa/src/lib.rs @@ -458,6 +458,8 @@ impl PartialEq for Bloom { } } +// there's no default for [_; 256], but clippy still complains +#[allow(clippy::derivable_impls)] impl Default for Bloom { fn default() -> Self { Bloom([0; 256]) diff --git a/bridges/primitives/runtime/src/lib.rs b/bridges/primitives/runtime/src/lib.rs index 8d4e658b1e863..aee894aceefca 100644 --- a/bridges/primitives/runtime/src/lib.rs +++ b/bridges/primitives/runtime/src/lib.rs @@ -216,9 +216,9 @@ pub fn storage_map_final_key_identity(pallet_prefix: &str, map_name: &str, key_h /// Copypaste from `frame_support::parameter_types` macro pub fn storage_parameter_key(parameter_name: &str) -> StorageKey { let mut buffer = Vec::with_capacity(1 + parameter_name.len() + 1 + 1); - buffer.push(':' as u8); + buffer.push(b':'); buffer.extend_from_slice(parameter_name.as_bytes()); - buffer.push(':' as u8); + buffer.push(b':'); buffer.push(0); StorageKey(sp_io::hashing::twox_128(&buffer).to_vec()) } diff --git a/bridges/relays/bin-substrate/src/cli/swap_tokens.rs b/bridges/relays/bin-substrate/src/cli/swap_tokens.rs index b9c44a4acc85e..264b98e948ff9 100644 --- a/bridges/relays/bin-substrate/src/cli/swap_tokens.rs +++ b/bridges/relays/bin-substrate/src/cli/swap_tokens.rs @@ -16,6 +16,10 @@ //! Tokens swap using token-swap bridge pallet. +// TokenSwapBalances fields are never directly accessed, but the whole struct is printed +// to show token swap progress +#![allow(dead_code)] + use codec::Encode; use num_traits::One; use rand::random; @@ -436,7 +440,7 @@ impl SwapTokens { // prepare token swap intention Ok(bp_token_swap::TokenSwap { - swap_type: self.prepare_token_swap_type(&source_client).await?, + swap_type: self.prepare_token_swap_type(source_client).await?, source_balance_at_this_chain, source_account_at_this_chain: source_account_at_this_chain.clone(), target_balance_at_bridged_chain, @@ -498,26 +502,26 @@ async fn read_account_balances anyhow::Result, BalanceOf>> { Ok(TokenSwapBalances { source_account_at_this_chain_balance: read_account_balance( - &source_client, + source_client, &accounts.source_account_at_this_chain, ) .await?, source_account_at_bridged_chain_balance: read_account_balance( - &target_client, + target_client, &accounts.source_account_at_bridged_chain, ) .await?, target_account_at_bridged_chain_balance: read_account_balance( - &target_client, + target_client, &accounts.target_account_at_bridged_chain, ) .await?, target_account_at_this_chain_balance: read_account_balance( - &source_client, + source_client, &accounts.target_account_at_this_chain, ) .await?, - swap_account_balance: read_account_balance(&source_client, &accounts.swap_account).await?, + swap_account_balance: read_account_balance(source_client, &accounts.swap_account).await?, }) } diff --git a/bridges/relays/headers/src/headers.rs b/bridges/relays/headers/src/headers.rs index b9095e1931099..d4f3d77d79cea 100644 --- a/bridges/relays/headers/src/headers.rs +++ b/bridges/relays/headers/src/headers.rs @@ -82,15 +82,6 @@ pub struct QueuedHeaders { prune_border: P::Number, } -/// Header completion data. -#[derive(Debug)] -struct HeaderCompletion { - /// Last time when we tried to upload completion data to target node, if ever. - pub last_upload_time: Option, - /// Completion data. - pub completion: Completion, -} - impl Default for QueuedHeaders

{ fn default() -> Self { QueuedHeaders {