From 173f2d429e85b44f16f8ec35b9fd35144cdfd14d Mon Sep 17 00:00:00 2001 From: Alexander Kalankhodzhaev Date: Wed, 10 May 2023 04:23:56 +0700 Subject: [PATCH] code cleanup (#166) --- README.md | 4 +- node/Cargo.toml | 3 +- node/cli/src/cli.rs | 1 - node/cli/src/lib.rs | 3 +- node/service/src/chain_spec/stout.rs | 3 +- node/service/src/chain_spec/trappist.rs | 1 - node/service/src/lib.rs | 3 + runtime/trappist/Cargo.toml | 74 ++++++++++++------------- runtime/trappist/src/impls.rs | 7 +-- 9 files changed, 49 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 6490d89e..8d4fb80a 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ cargo b -r --no-default-features --features with-stout-runtime --target-dir targ ``` Alternatively, run -`bash build_runtimes.sh` . +`bash ./scripts/build_runtimes.sh` . ### XCM Playground via Zombienet @@ -70,8 +70,6 @@ Alternatively, run Create a `bin` directory into the root of this repository and place the following binaries inside of it: - `polkadot` (which you can download from [the releases](https://github.com/paritytech/polkadot/releases)) - `polkadot-parachain` (which you will build from [cumulus](https://github.com/paritytech/cumulus)) -- `trappist-collator` (which you will build from this repository) -- `stout-collator` (which you will build from this repository) Download the [latest release of zombienet](https://github.com/paritytech/zombienet/releases/) into the root of this repository and make it executable: ``` diff --git a/node/Cargo.toml b/node/Cargo.toml index b605ba7a..d8b8ba5f 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -7,6 +7,7 @@ license = "Unlicense" homepage = "https://trappist.io" repository = "https://github.com/TrappistNetwork/trappist" edition = "2021" +default-run = "trappist-collator" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] @@ -41,7 +42,7 @@ tempfile = "3.2.0" [features] default = ["with-trappist-runtime"] runtime-benchmarks = [ - "trappist-cli/runtime-benchmarks" + "trappist-cli/runtime-benchmarks" ] with-trappist-runtime = [ "trappist-service/with-trappist-runtime", diff --git a/node/cli/src/cli.rs b/node/cli/src/cli.rs index 6a3e7aa1..2a7615e4 100644 --- a/node/cli/src/cli.rs +++ b/node/cli/src/cli.rs @@ -14,7 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . -use service::chain_spec; #[cfg(feature = "with-stout-runtime")] use service::chain_spec::stout::Extensions; #[cfg(feature = "with-trappist-runtime")] diff --git a/node/cli/src/lib.rs b/node/cli/src/lib.rs index 59ec9bd6..89e28302 100644 --- a/node/cli/src/lib.rs +++ b/node/cli/src/lib.rs @@ -1,4 +1,5 @@ -#![warn(missing_docs)] +// TODO: Write missing docs. +//#![warn(missing_docs)] #![warn(unused_extern_crates)] #[cfg(feature = "cli")] diff --git a/node/service/src/chain_spec/stout.rs b/node/service/src/chain_spec/stout.rs index dcd27578..dbc7e7e5 100644 --- a/node/service/src/chain_spec/stout.rs +++ b/node/service/src/chain_spec/stout.rs @@ -1,9 +1,8 @@ use cumulus_primitives_core::ParaId; -use hex_literal::hex; use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; use sc_service::ChainType; use serde::{Deserialize, Serialize}; -use sp_core::{crypto::UncheckedInto, sr25519, Pair, Public}; +use sp_core::{sr25519, Pair, Public}; use sp_runtime::traits::{IdentifyAccount, Verify}; use stout_runtime::{ constants::currency::EXISTENTIAL_DEPOSIT, AccountId, AssetsConfig, AuraId, BalancesConfig, diff --git a/node/service/src/chain_spec/trappist.rs b/node/service/src/chain_spec/trappist.rs index 2824d977..b2053db4 100644 --- a/node/service/src/chain_spec/trappist.rs +++ b/node/service/src/chain_spec/trappist.rs @@ -1,7 +1,6 @@ use cumulus_primitives_core::ParaId; use hex_literal::hex; use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; -use sc_cli::DefaultConfigurationValues; use sc_service::ChainType; use serde::{Deserialize, Serialize}; use sp_core::{crypto::UncheckedInto, sr25519, Pair, Public}; diff --git a/node/service/src/lib.rs b/node/service/src/lib.rs index 01c12f36..56487948 100644 --- a/node/service/src/lib.rs +++ b/node/service/src/lib.rs @@ -30,6 +30,9 @@ use substrate_prometheus_endpoint::Registry; pub mod chain_spec; +#[cfg(all(feature = "with-trappist-runtime", feature = "with-stout-runtime"))] +compile_error!("features `with-trappist-runtime` and `with-stout-runtime` are mutually exclusive"); + #[cfg(feature = "with-stout-runtime")] pub mod stout_executor { pub use stout_runtime; diff --git a/runtime/trappist/Cargo.toml b/runtime/trappist/Cargo.toml index 88db8587..47ab5b42 100644 --- a/runtime/trappist/Cargo.toml +++ b/runtime/trappist/Cargo.toml @@ -15,7 +15,7 @@ substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", bran [dependencies] hex-literal = { version = "0.3.4", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"]} +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.3.1", default-features = false, features = ["derive"] } serde = { version = "1.0.140", optional = true, features = ["derive"] } @@ -85,7 +85,7 @@ cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", br pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37", default-features = false } parachains-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37", default-features = false } parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37", default-features = false } -cumulus-pallet-session-benchmarking = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37", default-features = false, version = "3.0.0"} +cumulus-pallet-session-benchmarking = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37", default-features = false, version = "3.0.0" } # Polkadot Dependencies kusama-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.37" } @@ -109,10 +109,10 @@ pallet-asset-registry = { version = "0.0.1", default-features = false, path = ". [features] default = ["std"] std = [ - "codec/std", - "serde", - "scale-info/std", - "log/std", + "codec/std", + "serde", + "scale-info/std", + "log/std", "sp-api/std", "sp-block-builder/std", "sp-consensus-aura/std", @@ -129,32 +129,32 @@ std = [ "frame-support/std", "frame-system/std", "frame-system-rpc-runtime-api/std", - "pallet-assets/std", + "pallet-assets/std", "pallet-asset-tx-payment/std", - "pallet-aura/std", - "pallet-authorship/std", - "pallet-balances/std", + "pallet-aura/std", + "pallet-authorship/std", + "pallet-balances/std", "pallet-chess/std", - "pallet-collator-selection/std", - "pallet-collective/std", - "pallet-contracts/std", - "pallet-contracts-primitives/std", + "pallet-collator-selection/std", + "pallet-collective/std", + "pallet-contracts/std", + "pallet-contracts-primitives/std", "pallet-democracy/std", - "pallet-dex/std", + "pallet-dex/std", "pallet-dex-rpc-runtime-api/std", "pallet-identity/std", "pallet-multisig/std", - "pallet-randomness-collective-flip/std", - "pallet-scheduler/std", - "pallet-session/std", - "pallet-sudo/std", - "pallet-timestamp/std", - "pallet-transaction-payment-rpc-runtime-api/std", - "pallet-transaction-payment/std", + "pallet-randomness-collective-flip/std", + "pallet-scheduler/std", + "pallet-session/std", + "pallet-sudo/std", + "pallet-timestamp/std", + "pallet-transaction-payment-rpc-runtime-api/std", + "pallet-transaction-payment/std", "pallet-treasury/std", - "pallet-uniques/std", - "pallet-utility/std", - "pallet-xcm/std", + "pallet-uniques/std", + "pallet-utility/std", + "pallet-xcm/std", "cumulus-pallet-aura-ext/std", "cumulus-pallet-parachain-system/std", "cumulus-pallet-xcm/std", @@ -173,29 +173,29 @@ std = [ "xcm/std" ] runtime-benchmarks = [ - "hex-literal", + "hex-literal", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", "frame-system-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", - "pallet-assets/runtime-benchmarks", + "pallet-assets/runtime-benchmarks", "pallet-asset-registry/runtime-benchmarks", - "pallet-balances/runtime-benchmarks", - "pallet-collator-selection/runtime-benchmarks", - "pallet-collective/runtime-benchmarks", - "pallet-contracts/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-collator-selection/runtime-benchmarks", + "pallet-collective/runtime-benchmarks", + "pallet-contracts/runtime-benchmarks", "pallet-democracy/runtime-benchmarks", - "pallet-dex/runtime-benchmarks", + "pallet-dex/runtime-benchmarks", "pallet-identity/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", - "pallet-scheduler/runtime-benchmarks", - "pallet-timestamp/runtime-benchmarks", + "pallet-scheduler/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", "pallet-treasury/runtime-benchmarks", - "pallet-uniques/runtime-benchmarks", - "pallet-utility/runtime-benchmarks", - "pallet-xcm/runtime-benchmarks", + "pallet-uniques/runtime-benchmarks", + "pallet-utility/runtime-benchmarks", + "pallet-xcm/runtime-benchmarks", "cumulus-pallet-session-benchmarking/runtime-benchmarks", "cumulus-pallet-xcmp-queue/runtime-benchmarks" ] diff --git a/runtime/trappist/src/impls.rs b/runtime/trappist/src/impls.rs index 393d4ed5..8c53ef2f 100644 --- a/runtime/trappist/src/impls.rs +++ b/runtime/trappist/src/impls.rs @@ -81,9 +81,8 @@ mod tests { use sp_runtime::{ testing::Header, traits::{BlakeTwo256, ConstU32, ConstU64, IdentityLookup}, - Perbill, + Perbill, Permill, }; - use xcm::prelude::*; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; @@ -252,9 +251,9 @@ mod tests { DealWithFees::on_unbalanceds(vec![fee, tip].into_iter()); - /// Author should get 20% of the fee + the 100% of the tip. (50) + // Author should get 20% of the fee + the 100% of the tip. (50) assert_eq!(Balances::free_balance(CollatorSelection::account_id()), 50); - /// Treasury should get 80% of the fee. (80) + // Treasury should get 80% of the fee. (80) assert_eq!(Treasury::pot(), 80); }); }