diff --git a/.github/workflows/test.yml b/.github/workflows/lint.yml similarity index 84% rename from .github/workflows/test.yml rename to .github/workflows/lint.yml index 3434722c..3d715642 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/lint.yml @@ -32,12 +32,13 @@ jobs: run: | rustup update stable --no-self-update rustup target add wasm32-unknown-unknown + rustup component add clippy # Check the build - name: Check Build run: | SKIP_WASM_BUILD=1 cargo check --release - # # Test code - # - name: Test - # run: cargo test \ No newline at end of file + - name: Check clippy + run: | + cargo clippy --all-targets --workspace --features runtime-benchmarks --features try-runtime diff --git a/Cargo.lock b/Cargo.lock index eff603a2..4b7aa29c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5912,7 +5912,7 @@ dependencies = [ [[package]] name = "pallet-livingassets-ownership" version = "0.0.1" -source = "git+https://github.com/freeverseio/pallet-livingassets-ownership?rev=a15098e080aee626580a383df1382b3cd020deae#a15098e080aee626580a383df1382b3cd020deae" +source = "git+https://github.com/freeverseio/pallet-livingassets-ownership?branch=dev#939d6dcc0e745eab5c96b21c6ea1b2947281c3d1" dependencies = [ "frame-benchmarking", "frame-support", diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index ab554f0c..3c5cbcad 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -1,5 +1,5 @@ use cumulus_primitives_core::ParaId; -use parachain_template_runtime::{AccountId, AuraId, Signature, EXISTENTIAL_DEPOSIT, SudoConfig}; +use parachain_template_runtime::{AccountId, AuraId, Signature, SudoConfig, EXISTENTIAL_DEPOSIT}; use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; use sc_service::ChainType; use serde::{Deserialize, Serialize}; @@ -15,7 +15,7 @@ const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; /// 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() } diff --git a/node/src/cli.rs b/node/src/cli.rs index 2e64a53e..1fa5d114 100644 --- a/node/src/cli.rs +++ b/node/src/cli.rs @@ -2,6 +2,7 @@ use std::path::PathBuf; /// Sub-commands supported by the collator. #[derive(Debug, clap::Subcommand)] +#[allow(clippy::large_enum_variant)] pub enum Subcommand { /// Build a chain specification. BuildSpec(sc_cli::BuildSpecCmd), diff --git a/node/src/command.rs b/node/src/command.rs index dce143da..b2fc475e 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -23,7 +23,9 @@ use crate::{ fn load_spec(id: &str) -> std::result::Result, String> { Ok(match id { - "arrakis" => Box::new(chain_spec::ChainSpec::from_json_bytes(&include_bytes!("../../specs/arrakis.json")[..])?), + "arrakis" => Box::new(chain_spec::ChainSpec::from_json_bytes( + &include_bytes!("../../specs/arrakis.json")[..], + )?), "dev" => Box::new(chain_spec::development_config()), "template-rococo" => Box::new(chain_spec::local_testnet_config()), "" | "local" => Box::new(chain_spec::local_testnet_config()), @@ -104,8 +106,11 @@ impl SubstrateCli for RelayChainCli { fn load_spec(&self, id: &str) -> std::result::Result, String> { match id { - "rococo_freeverse" => Ok(Box::new(RococoChainSpec::from_json_bytes(&include_bytes!("../../specs/rococo-freeverse-chainspec.json")[..])?)), - _ => polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id), + "rococo_freeverse" => Ok(Box::new(RococoChainSpec::from_json_bytes( + &include_bytes!("../../specs/rococo-freeverse-chainspec.json")[..], + )?)), + _ => polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()) + .load_spec(id), } } @@ -173,7 +178,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) }) @@ -211,12 +216,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)?; @@ -249,7 +253,7 @@ pub fn run() -> Result<()> { let registry = &runner.config().prometheus_config.as_ref().map(|cfg| &cfg.registry); let task_manager = sc_service::TaskManager::new(runner.config().tokio_handle.clone(), *registry) - .map_err(|e| format!("Error: {:?}", e))?; + .map_err(|e| format!("Error: {e}"))?; let info_provider = timestamp_with_aura_info(MILLISECS_PER_BLOCK); @@ -273,13 +277,13 @@ pub fn run() -> Result<()> { runner.run_node_until_exit(|config| async move { let hwbench = (!cli.no_hardware_benchmarks).then_some( config.database.path().map(|database_path| { - let _ = std::fs::create_dir_all(&database_path); + let _ = std::fs::create_dir_all(database_path); sc_sysinfo::gather_hwbench(Some(database_path)) })).flatten(); let para_id = chain_spec::Extensions::try_get(&*config.chain_spec) .map(|e| e.para_id) - .ok_or_else(|| "Could not find parachain ID in chain-spec.")?; + .ok_or("Could not find parachain ID in chain-spec.")?; let polkadot_cli = RelayChainCli::new( &config, @@ -292,21 +296,20 @@ pub fn run() -> Result<()> { AccountIdConversion::::into_account_truncating(&id); let state_version = Cli::native_runtime_version(&config.chain_spec).state_version(); - let block: Block = generate_genesis_block(&*config.chain_spec, state_version) - .map_err(|e| format!("{:?}", e))?; + let block: Block = generate_genesis_block(&*config.chain_spec, state_version)?; let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode())); let tokio_handle = config.tokio_handle.clone(); let polkadot_config = SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, tokio_handle) - .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); info!("Parachain genesis state: {}", genesis_state); info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" }); - if !collator_options.relay_chain_rpc_urls.is_empty() && cli.relay_chain_args.len() > 0 { + if !collator_options.relay_chain_rpc_urls.is_empty() && !cli.relay_chain_args.is_empty() { warn!("Detected relay chain node arguments together with --relay-chain-rpc-url. This command starts a minimal Polkadot node that only uses a network-related subset of all relay chain CLI options."); } diff --git a/node/src/service.rs b/node/src/service.rs index 4c9e1feb..1d258a62 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -59,6 +59,7 @@ type ParachainBlockImport = TParachainBlockImport, P /// /// 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, ) -> Result< @@ -354,6 +355,7 @@ fn build_import_queue( .map_err(Into::into) } +#[allow(clippy::too_many_arguments)] fn build_consensus( client: Arc, block_import: ParachainBlockImport, diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 26a77a1a..91e027bd 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -49,7 +49,7 @@ sp-std = { git = "https://github.com/paritytech/substrate", default-features = f sp-transaction-pool = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42" } sp-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42" } -pallet-livingassets-ownership = { git = "https://github.com/freeverseio/pallet-livingassets-ownership", rev="a15098e080aee626580a383df1382b3cd020deae", default-features = false } +pallet-livingassets-ownership = { git = "https://github.com/freeverseio/pallet-livingassets-ownership", branch="dev", default-features = false } # Polkadot pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.42" } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index d522ba31..4536d9c7 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -478,24 +478,24 @@ construct_runtime!( ParachainSystem: cumulus_pallet_parachain_system = 1, Timestamp: pallet_timestamp = 2, ParachainInfo: parachain_info = 3, - + // Monetary stuff. Balances: pallet_balances = 10, TransactionPayment: pallet_transaction_payment = 11, - + // Collator support. The order of these 4 are important and shall not change. Authorship: pallet_authorship = 20, CollatorSelection: pallet_collator_selection = 21, Session: pallet_session = 22, Aura: pallet_aura = 23, AuraExt: cumulus_pallet_aura_ext = 24, - + // XCM helpers. XcmpQueue: cumulus_pallet_xcmp_queue = 30, PolkadotXcm: pallet_xcm = 31, CumulusXcm: cumulus_pallet_xcm = 32, DmpQueue: cumulus_pallet_dmp_queue = 33, - + // Template Sudo: pallet_sudo = 40, LivingassetsOwnership: pallet_livingassets_ownership = 41, @@ -692,13 +692,13 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, sp_runtime::RuntimeString> { - use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey}; + use frame_benchmarking::{Benchmarking, BenchmarkBatch}; use frame_system_benchmarking::Pallet as SystemBench; impl frame_system_benchmarking::Config for Runtime {}