From e9c6ecf5b4eefaa2289e95a77fd5e7adcb7987b4 Mon Sep 17 00:00:00 2001 From: Przemek Rzad Date: Mon, 27 May 2024 12:58:22 +0200 Subject: [PATCH 1/7] remove workspace lints from templates --- .github/workflows/misc-sync-templates.yml | 2 -- templates/minimal/Cargo.toml | 3 --- templates/minimal/node/Cargo.toml | 3 --- templates/minimal/pallets/template/Cargo.toml | 3 --- templates/minimal/runtime/Cargo.toml | 3 --- templates/parachain/node/Cargo.toml | 3 --- templates/parachain/pallets/template/Cargo.toml | 3 --- templates/parachain/runtime/Cargo.toml | 3 --- templates/solochain/node/Cargo.toml | 3 --- templates/solochain/pallets/template/Cargo.toml | 3 --- templates/solochain/runtime/Cargo.toml | 3 --- 11 files changed, 32 deletions(-) diff --git a/.github/workflows/misc-sync-templates.yml b/.github/workflows/misc-sync-templates.yml index 2699ff0fed3f..b040c2fc89bb 100644 --- a/.github/workflows/misc-sync-templates.yml +++ b/.github/workflows/misc-sync-templates.yml @@ -105,8 +105,6 @@ jobs: toml set templates/${{ matrix.template }}/Cargo.toml 'workspace.package.edition' "$(toml get --raw Cargo.toml 'workspace.package.edition')" > Cargo.temp mv Cargo.temp ./templates/${{ matrix.template }}/Cargo.toml - toml get Cargo.toml 'workspace.lints' --output-toml >> ./templates/${{ matrix.template }}/Cargo.toml - toml get Cargo.toml 'workspace.dependencies' --output-toml >> ./templates/${{ matrix.template }}/Cargo.toml working-directory: polkadot-sdk - name: Print the result Cargo.tomls for debugging diff --git a/templates/minimal/Cargo.toml b/templates/minimal/Cargo.toml index 6cd28c5a4936..95656ff92d24 100644 --- a/templates/minimal/Cargo.toml +++ b/templates/minimal/Cargo.toml @@ -9,9 +9,6 @@ repository.workspace = true edition.workspace = true publish = false -[lints] -workspace = true - [dependencies] minimal-template-node = { path = "./node" } minimal-template-runtime = { path = "./runtime" } diff --git a/templates/minimal/node/Cargo.toml b/templates/minimal/node/Cargo.toml index 606fd0580356..f732eff445c3 100644 --- a/templates/minimal/node/Cargo.toml +++ b/templates/minimal/node/Cargo.toml @@ -10,9 +10,6 @@ edition.workspace = true publish = false build = "build.rs" -[lints] -workspace = true - [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/templates/minimal/pallets/template/Cargo.toml b/templates/minimal/pallets/template/Cargo.toml index e6fe43abc090..30962664481a 100644 --- a/templates/minimal/pallets/template/Cargo.toml +++ b/templates/minimal/pallets/template/Cargo.toml @@ -9,9 +9,6 @@ repository.workspace = true edition.workspace = true publish = false -[lints] -workspace = true - [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/templates/minimal/runtime/Cargo.toml b/templates/minimal/runtime/Cargo.toml index 99559308e5b8..3581ca7c851e 100644 --- a/templates/minimal/runtime/Cargo.toml +++ b/templates/minimal/runtime/Cargo.toml @@ -9,9 +9,6 @@ repository.workspace = true edition.workspace = true publish = false -[lints] -workspace = true - [dependencies] parity-scale-codec = { version = "3.6.12", default-features = false } scale-info = { version = "2.6.0", default-features = false } diff --git a/templates/parachain/node/Cargo.toml b/templates/parachain/node/Cargo.toml index 6f7150829829..4fe228f71fe2 100644 --- a/templates/parachain/node/Cargo.toml +++ b/templates/parachain/node/Cargo.toml @@ -10,9 +10,6 @@ edition.workspace = true publish = false build = "build.rs" -[lints] -workspace = true - # [[bin]] # name = "parachain-template-node" diff --git a/templates/parachain/pallets/template/Cargo.toml b/templates/parachain/pallets/template/Cargo.toml index c5334e871fa4..f5411c02821c 100644 --- a/templates/parachain/pallets/template/Cargo.toml +++ b/templates/parachain/pallets/template/Cargo.toml @@ -9,9 +9,6 @@ repository.workspace = true edition.workspace = true publish = false -[lints] -workspace = true - [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/templates/parachain/runtime/Cargo.toml b/templates/parachain/runtime/Cargo.toml index a74c6a541f4f..e88284bedb6a 100644 --- a/templates/parachain/runtime/Cargo.toml +++ b/templates/parachain/runtime/Cargo.toml @@ -9,9 +9,6 @@ repository.workspace = true edition.workspace = true publish = false -[lints] -workspace = true - [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/templates/solochain/node/Cargo.toml b/templates/solochain/node/Cargo.toml index 9332da3a6549..515f85e54182 100644 --- a/templates/solochain/node/Cargo.toml +++ b/templates/solochain/node/Cargo.toml @@ -11,9 +11,6 @@ publish = false build = "build.rs" -[lints] -workspace = true - [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/templates/solochain/pallets/template/Cargo.toml b/templates/solochain/pallets/template/Cargo.toml index 1a122bd82d40..8c6f26d8e5d0 100644 --- a/templates/solochain/pallets/template/Cargo.toml +++ b/templates/solochain/pallets/template/Cargo.toml @@ -9,9 +9,6 @@ repository.workspace = true edition.workspace = true publish = false -[lints] -workspace = true - [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/templates/solochain/runtime/Cargo.toml b/templates/solochain/runtime/Cargo.toml index b4a543826e79..8aeb1a6a16e6 100644 --- a/templates/solochain/runtime/Cargo.toml +++ b/templates/solochain/runtime/Cargo.toml @@ -9,9 +9,6 @@ repository.workspace = true edition.workspace = true publish = false -[lints] -workspace = true - [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] From 17ed2c3951cd181305c1fcd7a00d985672036aed Mon Sep 17 00:00:00 2001 From: rzadp Date: Mon, 27 May 2024 18:13:11 +0200 Subject: [PATCH 2/7] Clippy fix --- templates/minimal/node/src/service.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/minimal/node/src/service.rs b/templates/minimal/node/src/service.rs index d84df95dc192..5a92627621bf 100644 --- a/templates/minimal/node/src/service.rs +++ b/templates/minimal/node/src/service.rs @@ -61,7 +61,7 @@ pub fn new_partial(config: &Configuration) -> Result { }) .transpose()?; - let executor = sc_service::new_wasm_executor(&config); + let executor = sc_service::new_wasm_executor(config); let (client, backend, keystore_container, task_manager) = sc_service::new_full_parts::( From 7966fec1a94c7eb3d10b4851c6379f44e8a467eb Mon Sep 17 00:00:00 2001 From: rzadp Date: Mon, 27 May 2024 19:06:03 +0200 Subject: [PATCH 3/7] clippy autofix --- templates/parachain/node/src/command.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/templates/parachain/node/src/command.rs b/templates/parachain/node/src/command.rs index 56ae022cad2b..54e470fb2ecd 100644 --- a/templates/parachain/node/src/command.rs +++ b/templates/parachain/node/src/command.rs @@ -195,12 +195,11 @@ pub fn run() -> Result<()> { }), #[cfg(not(feature = "runtime-benchmarks"))] BenchmarkCmd::Storage(_) => - return Err(sc_cli::Error::Input( + Err(sc_cli::Error::Input( "Compile with --features=runtime-benchmarks \ to enable storage benchmarks." .into(), - ) - .into()), + )), #[cfg(feature = "runtime-benchmarks")] BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| { let partials = new_partial(&config)?; From e38687806f5f277d0737f4088b39d39a2f9d88c9 Mon Sep 17 00:00:00 2001 From: rzadp Date: Mon, 27 May 2024 19:08:25 +0200 Subject: [PATCH 4/7] manual allows for clippy --- templates/parachain/node/src/cli.rs | 1 + templates/parachain/node/src/service.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/templates/parachain/node/src/cli.rs b/templates/parachain/node/src/cli.rs index cffbfbc1db23..f008e856d99b 100644 --- a/templates/parachain/node/src/cli.rs +++ b/templates/parachain/node/src/cli.rs @@ -1,6 +1,7 @@ use std::path::PathBuf; /// Sub-commands supported by the collator. +#[allow(clippy::large_enum_variant)] #[derive(Debug, clap::Subcommand)] pub enum Subcommand { /// Build a chain specification. diff --git a/templates/parachain/node/src/service.rs b/templates/parachain/node/src/service.rs index ad4689c6e55d..ce6308915871 100644 --- a/templates/parachain/node/src/service.rs +++ b/templates/parachain/node/src/service.rs @@ -160,6 +160,7 @@ fn build_import_queue( ) } +#[allow(clippy::too_many_arguments)] fn start_consensus( client: Arc, backend: Arc, From e779eeb1ccbb507834a8f2c68dea61509f45aecb Mon Sep 17 00:00:00 2001 From: rzadp Date: Mon, 27 May 2024 19:32:36 +0200 Subject: [PATCH 5/7] another clippy --- templates/parachain/pallets/template/src/benchmarking.rs | 2 +- templates/solochain/pallets/template/src/benchmarking.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/parachain/pallets/template/src/benchmarking.rs b/templates/parachain/pallets/template/src/benchmarking.rs index 5a262417629c..d1a9554aed6d 100644 --- a/templates/parachain/pallets/template/src/benchmarking.rs +++ b/templates/parachain/pallets/template/src/benchmarking.rs @@ -13,7 +13,7 @@ mod benchmarks { #[benchmark] fn do_something() { - let value = 100u32.into(); + let value = 100u32; let caller: T::AccountId = whitelisted_caller(); #[extrinsic_call] do_something(RawOrigin::Signed(caller), value); diff --git a/templates/solochain/pallets/template/src/benchmarking.rs b/templates/solochain/pallets/template/src/benchmarking.rs index 5a262417629c..d1a9554aed6d 100644 --- a/templates/solochain/pallets/template/src/benchmarking.rs +++ b/templates/solochain/pallets/template/src/benchmarking.rs @@ -13,7 +13,7 @@ mod benchmarks { #[benchmark] fn do_something() { - let value = 100u32.into(); + let value = 100u32; let caller: T::AccountId = whitelisted_caller(); #[extrinsic_call] do_something(RawOrigin::Signed(caller), value); From 86e5f3b6a3c2e58fdd2868871b02740d05e2287d Mon Sep 17 00:00:00 2001 From: rzadp Date: Tue, 28 May 2024 09:03:35 +0200 Subject: [PATCH 6/7] cargo fmt --- templates/minimal/node/src/cli.rs | 2 +- templates/minimal/node/src/command.rs | 10 ++++++---- templates/parachain/node/src/command.rs | 19 ++++++++++--------- templates/solochain/node/src/command.rs | 12 +++++++----- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/templates/minimal/node/src/cli.rs b/templates/minimal/node/src/cli.rs index e464fa7d6caa..22726b7eb9a3 100644 --- a/templates/minimal/node/src/cli.rs +++ b/templates/minimal/node/src/cli.rs @@ -32,7 +32,7 @@ impl std::str::FromStr for Consensus { } else if let Some(block_time) = s.strip_prefix("manual-seal-") { Consensus::ManualSeal(block_time.parse().map_err(|_| "invalid block time")?) } else { - return Err("incorrect consensus identifier".into()) + return Err("incorrect consensus identifier".into()); }) } } diff --git a/templates/minimal/node/src/command.rs b/templates/minimal/node/src/command.rs index 432add922a7b..68521dd62616 100644 --- a/templates/minimal/node/src/command.rs +++ b/templates/minimal/node/src/command.rs @@ -54,8 +54,9 @@ impl SubstrateCli for Cli { fn load_spec(&self, id: &str) -> Result, String> { Ok(match id { "dev" => Box::new(chain_spec::development_config()?), - path => - Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?), + path => { + Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?) + }, }) } } @@ -120,9 +121,10 @@ pub fn run() -> sc_cli::Result<()> { let runner = cli.create_runner(&cli.run)?; runner.run_node_until_exit(|config| async move { match config.network.network_backend { - sc_network::config::NetworkBackendType::Libp2p => + sc_network::config::NetworkBackendType::Libp2p => { service::new_full::>(config, cli.consensus) - .map_err(sc_cli::Error::Service), + .map_err(sc_cli::Error::Service) + }, sc_network::config::NetworkBackendType::Litep2p => service::new_full::< sc_network::Litep2pNetworkBackend, >(config, cli.consensus) diff --git a/templates/parachain/node/src/command.rs b/templates/parachain/node/src/command.rs index 54e470fb2ecd..5231feb68710 100644 --- a/templates/parachain/node/src/command.rs +++ b/templates/parachain/node/src/command.rs @@ -181,25 +181,25 @@ pub fn run() -> Result<()> { let runner = cli.create_runner(cmd)?; // Switch on the concrete benchmark sub-command- match cmd { - BenchmarkCmd::Pallet(cmd) => + BenchmarkCmd::Pallet(cmd) => { if cfg!(feature = "runtime-benchmarks") { runner.sync_run(|config| cmd.run_with_spec::, ReclaimHostFunctions>(Some(config.chain_spec))) } else { Err("Benchmarking wasn't enabled when building the node. \ You can enable it with `--features runtime-benchmarks`." .into()) - }, + } + }, BenchmarkCmd::Block(cmd) => runner.sync_run(|config| { let partials = new_partial(&config)?; cmd.run(partials.client) }), #[cfg(not(feature = "runtime-benchmarks"))] - BenchmarkCmd::Storage(_) => - Err(sc_cli::Error::Input( - "Compile with --features=runtime-benchmarks \ + BenchmarkCmd::Storage(_) => Err(sc_cli::Error::Input( + "Compile with --features=runtime-benchmarks \ to enable storage benchmarks." - .into(), - )), + .into(), + )), #[cfg(feature = "runtime-benchmarks")] BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| { let partials = new_partial(&config)?; @@ -207,8 +207,9 @@ pub fn run() -> Result<()> { let storage = partials.backend.expose_storage(); cmd.run(config, partials.client.clone(), db, storage) }), - BenchmarkCmd::Machine(cmd) => - runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())), + BenchmarkCmd::Machine(cmd) => { + runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())) + }, // NOTE: this allows the Client to leniently implement // new benchmark commands without requiring a companion MR. #[allow(unreachable_patterns)] diff --git a/templates/solochain/node/src/command.rs b/templates/solochain/node/src/command.rs index e46fedc91f0e..1ef639b52247 100644 --- a/templates/solochain/node/src/command.rs +++ b/templates/solochain/node/src/command.rs @@ -39,8 +39,9 @@ impl SubstrateCli for Cli { Ok(match id { "dev" => Box::new(chain_spec::development_config()?), "" | "local" => Box::new(chain_spec::local_testnet_config()?), - path => - Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?), + path => { + Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?) + }, }) } } @@ -114,7 +115,7 @@ pub fn run() -> sc_cli::Result<()> { "Runtime benchmarking wasn't enabled when building the node. \ You can enable it with `--features runtime-benchmarks`." .into(), - ) + ); } cmd.run_with_spec::, ()>(Some( @@ -165,8 +166,9 @@ pub fn run() -> sc_cli::Result<()> { cmd.run(client, inherent_benchmark_data()?, Vec::new(), &ext_factory) }, - BenchmarkCmd::Machine(cmd) => - cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()), + BenchmarkCmd::Machine(cmd) => { + cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()) + }, } }) }, From 93766f5bbc998678d2e24f627c46a8219f00388f Mon Sep 17 00:00:00 2001 From: rzadp Date: Tue, 28 May 2024 09:14:35 +0200 Subject: [PATCH 7/7] cargo nightly fmt --- templates/minimal/node/src/command.rs | 10 ++++------ templates/parachain/node/src/command.rs | 10 ++++------ templates/solochain/node/src/command.rs | 10 ++++------ 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/templates/minimal/node/src/command.rs b/templates/minimal/node/src/command.rs index 68521dd62616..432add922a7b 100644 --- a/templates/minimal/node/src/command.rs +++ b/templates/minimal/node/src/command.rs @@ -54,9 +54,8 @@ impl SubstrateCli for Cli { fn load_spec(&self, id: &str) -> Result, String> { Ok(match id { "dev" => Box::new(chain_spec::development_config()?), - path => { - Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?) - }, + path => + Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?), }) } } @@ -121,10 +120,9 @@ pub fn run() -> sc_cli::Result<()> { let runner = cli.create_runner(&cli.run)?; runner.run_node_until_exit(|config| async move { match config.network.network_backend { - sc_network::config::NetworkBackendType::Libp2p => { + sc_network::config::NetworkBackendType::Libp2p => service::new_full::>(config, cli.consensus) - .map_err(sc_cli::Error::Service) - }, + .map_err(sc_cli::Error::Service), sc_network::config::NetworkBackendType::Litep2p => service::new_full::< sc_network::Litep2pNetworkBackend, >(config, cli.consensus) diff --git a/templates/parachain/node/src/command.rs b/templates/parachain/node/src/command.rs index 5231feb68710..eba7fdcdae71 100644 --- a/templates/parachain/node/src/command.rs +++ b/templates/parachain/node/src/command.rs @@ -181,15 +181,14 @@ pub fn run() -> Result<()> { let runner = cli.create_runner(cmd)?; // Switch on the concrete benchmark sub-command- match cmd { - BenchmarkCmd::Pallet(cmd) => { + BenchmarkCmd::Pallet(cmd) => if cfg!(feature = "runtime-benchmarks") { runner.sync_run(|config| cmd.run_with_spec::, ReclaimHostFunctions>(Some(config.chain_spec))) } else { Err("Benchmarking wasn't enabled when building the node. \ You can enable it with `--features runtime-benchmarks`." .into()) - } - }, + }, BenchmarkCmd::Block(cmd) => runner.sync_run(|config| { let partials = new_partial(&config)?; cmd.run(partials.client) @@ -207,9 +206,8 @@ pub fn run() -> Result<()> { let storage = partials.backend.expose_storage(); cmd.run(config, partials.client.clone(), db, storage) }), - BenchmarkCmd::Machine(cmd) => { - runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())) - }, + BenchmarkCmd::Machine(cmd) => + runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())), // NOTE: this allows the Client to leniently implement // new benchmark commands without requiring a companion MR. #[allow(unreachable_patterns)] diff --git a/templates/solochain/node/src/command.rs b/templates/solochain/node/src/command.rs index 1ef639b52247..624ace1bf350 100644 --- a/templates/solochain/node/src/command.rs +++ b/templates/solochain/node/src/command.rs @@ -39,9 +39,8 @@ impl SubstrateCli for Cli { Ok(match id { "dev" => Box::new(chain_spec::development_config()?), "" | "local" => Box::new(chain_spec::local_testnet_config()?), - path => { - Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?) - }, + path => + Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?), }) } } @@ -166,9 +165,8 @@ pub fn run() -> sc_cli::Result<()> { cmd.run(client, inherent_benchmark_data()?, Vec::new(), &ext_factory) }, - BenchmarkCmd::Machine(cmd) => { - cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()) - }, + BenchmarkCmd::Machine(cmd) => + cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()), } }) },