From 9fb2a41c58a2b12ccbb9f91e99bf42fbe1a6e156 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Wed, 15 Sep 2021 16:43:50 -0400 Subject: [PATCH 1/4] Add Clippy stage to CI --- .gitlab-ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 724456e..6df853d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,6 +7,7 @@ stages: - fmt + - clippy - build-linux - build-mac - publish @@ -84,6 +85,13 @@ fmt: script: - cargo +nightly fmt --verbose --all -- --check +clippy: + stage: lint + <<: *docker-env + script: + # TODO: Add `--all-features` flag once #86 is merged + - cargo +nightly clippy --verbose --all-targets -- -D warnings + ### stage: build-linux build-linux: From be175f8b9c3157ecc36ab4198cf500da5381a14f Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Wed, 15 Sep 2021 18:26:52 -0400 Subject: [PATCH 2/4] Appease Clippy --- node/src/chain_spec.rs | 2 +- node/src/cli.rs | 2 -- node/src/command.rs | 7 ++++--- node/src/rpc.rs | 2 +- node/src/service.rs | 10 ++++++---- runtime/src/lib.rs | 6 +++--- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 3f2e300..8a08c28 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -289,7 +289,7 @@ fn canvas_genesis( .map(|(acc, aura)| { ( acc.clone(), // account id - acc.clone(), // validator id + acc, // validator id canvas_session_keys(aura), // session keys ) }) diff --git a/node/src/cli.rs b/node/src/cli.rs index 9b9d318..25bcca6 100644 --- a/node/src/cli.rs +++ b/node/src/cli.rs @@ -15,8 +15,6 @@ // along with this program. If not, see . use crate::chain_spec; -use cumulus_client_cli; -use sc_cli; use std::path::PathBuf; use structopt::StructOpt; diff --git a/node/src/command.rs b/node/src/command.rs index a9c16f1..8a4971c 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -116,7 +116,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()) + polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()) .load_spec(id) } @@ -125,6 +125,7 @@ impl SubstrateCli for RelayChainCli { } } +#[allow(clippy::borrowed_box)] fn extract_genesis_wasm(chain_spec: &Box) -> Result> { let mut storage = chain_spec.build_storage()?; @@ -187,7 +188,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()), ); @@ -271,7 +272,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/node/src/rpc.rs b/node/src/rpc.rs index 7054fd2..6c13af7 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -70,7 +70,7 @@ where io.extend_with(SystemApi::to_delegate(FullSystem::new(client.clone(), pool, deny_unsafe))); io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new(client.clone()))); - io.extend_with(ContractsApi::to_delegate(Contracts::new(client.clone()))); + io.extend_with(ContractsApi::to_delegate(Contracts::new(client))); io } diff --git a/node/src/service.rs b/node/src/service.rs index 5d85055..35561c1 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -66,6 +66,7 @@ impl sc_executor::NativeExecutionDispatch for CanvasRuntimeExecutor { /// /// 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, @@ -133,7 +134,7 @@ where let (client, backend, keystore_container, task_manager) = sc_service::new_full_parts::( - &config, + config, telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), executor, )?; @@ -367,6 +368,7 @@ where } /// Build the import queue for the parachain runtime. +#[allow(clippy::type_complexity)] pub fn parachain_build_import_queue( client: Arc>>, config: &Configuration, @@ -403,7 +405,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, @@ -441,7 +443,7 @@ pub async fn start_parachain_node( task_manager.spawn_handle(), client.clone(), transaction_pool, - prometheus_registry.clone(), + prometheus_registry, telemetry.clone(), ); @@ -489,7 +491,7 @@ pub async fn start_parachain_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/runtime/src/lib.rs b/runtime/src/lib.rs index 750b4c1..aa5da68 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -232,11 +232,11 @@ pub const MILLIUNIT: Balance = 1_000_000_000; pub const MICROUNIT: Balance = 1_000_000; /// The existential deposit. Set to 1/10 of the Rococo Relay Chain. -pub const EXISTENTIAL_DEPOSIT: Balance = 1 * MILLIUNIT; +pub const EXISTENTIAL_DEPOSIT: Balance = MILLIUNIT; const fn deposit(items: u32, bytes: u32) -> Balance { // This is a 1/10 of the deposit on the Rococo Relay Chain - (items as Balance * 1 * UNIT + (bytes as Balance) * (5 * MILLIUNIT / 100)) / 10 + (items as Balance * UNIT + (bytes as Balance) * (5 * MILLIUNIT / 100)) / 10 } // 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks. @@ -924,7 +924,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) } } From 2148795081a537f1441d9b070bd930c033a2e147 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Wed, 15 Sep 2021 18:32:48 -0400 Subject: [PATCH 3/4] Change Clippy stage name --- .gitlab-ci.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6df853d..7f95086 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -77,8 +77,6 @@ workflow: - if: $CI_PIPELINE_SOURCE == "schedule" - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 -### stage: fmt - fmt: stage: fmt <<: *docker-env @@ -86,14 +84,12 @@ fmt: - cargo +nightly fmt --verbose --all -- --check clippy: - stage: lint + stage: clippy <<: *docker-env script: # TODO: Add `--all-features` flag once #86 is merged - cargo +nightly clippy --verbose --all-targets -- -D warnings -### stage: build-linux - build-linux: stage: build-linux <<: *docker-env @@ -105,8 +101,6 @@ build-linux: - mkdir -p ./artifacts/canvas-linux/ - cp ${CARGO_TARGET_DIR}/release/canvas ./artifacts/canvas-linux/canvas -### stage: build-mac - build-mac: stage: build-mac <<: *docker-env From 91ed7ca050bf5194b9d0b1ddabf3a98938d91611 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Wed, 15 Sep 2021 18:34:57 -0400 Subject: [PATCH 4/4] RustFmt --- node/src/command.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/node/src/command.rs b/node/src/command.rs index 8a4971c..24c0764 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -116,8 +116,7 @@ impl SubstrateCli for RelayChainCli { } fn load_spec(&self, id: &str) -> std::result::Result, String> { - polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].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 { @@ -188,9 +187,7 @@ pub fn run() -> Result<()> { runner.sync_run(|config| { let polkadot_cli = RelayChainCli::new( &config, - [RelayChainCli::executable_name()] - .iter() - .chain(cli.relaychain_args.iter()), + [RelayChainCli::executable_name()].iter().chain(cli.relaychain_args.iter()), ); let polkadot_config = SubstrateCli::create_configuration( @@ -272,9 +269,7 @@ pub fn run() -> Result<()> { let polkadot_cli = RelayChainCli::new( &config, - [RelayChainCli::executable_name()] - .iter() - .chain(cli.relaychain_args.iter()), + [RelayChainCli::executable_name()].iter().chain(cli.relaychain_args.iter()), ); let id = ParaId::from(cli.run.parachain_id.or(para_id).unwrap_or(1002));