Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deny unused deps #1033

Merged
merged 19 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
394 changes: 202 additions & 192 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ pallet-fee-market = { git = "https://github.com/darwinia-network/darwinia

# frontier
fc-cli = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.37" }
fc-consensus = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.37" }
fc-db = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.37" }
fc-mapping-sync = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.37" }
fc-rpc = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.37" }
Expand Down Expand Up @@ -160,7 +159,6 @@ sc-network = { git = "https://github.com/parityt
sc-network-common = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
sc-offchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
sc-rpc-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
Expand Down Expand Up @@ -293,7 +291,6 @@ sc-offchain = { git = "https://github.com/darw
sc-peerset = { git = "https://github.com/darwinia-network/substrate", branch = "polkadot-v0.9.37" }
sc-proposer-metrics = { git = "https://github.com/darwinia-network/substrate", branch = "polkadot-v0.9.37" }
sc-rpc = { git = "https://github.com/darwinia-network/substrate", branch = "polkadot-v0.9.37" }
sc-rpc-api = { git = "https://github.com/darwinia-network/substrate", branch = "polkadot-v0.9.37" }
sc-rpc-server = { git = "https://github.com/darwinia-network/substrate", branch = "polkadot-v0.9.37" }
sc-service = { git = "https://github.com/darwinia-network/substrate", branch = "polkadot-v0.9.37" }
sc-state-db = { git = "https://github.com/darwinia-network/substrate", branch = "polkadot-v0.9.37" }
Expand Down Expand Up @@ -360,7 +357,6 @@ try-runtime-cli = { git = "https://github.com/darw

[patch."https://github.com/paritytech/cumulus"]
cumulus-client-cli = { git = "https://github.com/darwinia-network/cumulus", branch = "remove-assertion-v0.9.37" }
cumulus-client-collator = { git = "https://github.com/darwinia-network/cumulus", branch = "remove-assertion-v0.9.37" }
cumulus-client-consensus-aura = { git = "https://github.com/darwinia-network/cumulus", branch = "remove-assertion-v0.9.37" }
cumulus-client-consensus-common = { git = "https://github.com/darwinia-network/cumulus", branch = "remove-assertion-v0.9.37" }
cumulus-client-network = { git = "https://github.com/darwinia-network/cumulus", branch = "remove-assertion-v0.9.37" }
Expand Down
1 change: 1 addition & 0 deletions core/inflation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#![cfg_attr(not(feature = "std"), no_std)]
#![deny(missing_docs)]
#![deny(unused_crate_dependencies)]

#[cfg(test)]
mod test;
Expand Down
1 change: 1 addition & 0 deletions core/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#![cfg_attr(not(feature = "std"), no_std)]
#![deny(missing_docs)]
#![deny(unused_crate_dependencies)]

pub use dc_types::*;

Expand Down
1 change: 1 addition & 0 deletions core/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#![no_std]
#![deny(missing_docs)]
#![deny(unused_crate_dependencies)]

/// Balance type.
pub type Balance = u128;
Expand Down
17 changes: 8 additions & 9 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ trauma = { version = "2.2" }

# cumulus
cumulus-client-cli = { workspace = true }
cumulus-client-collator = { workspace = true }
cumulus-client-consensus-aura = { workspace = true }
cumulus-client-consensus-common = { workspace = true }
cumulus-client-network = { workspace = true }
Expand All @@ -42,7 +41,6 @@ pangoro-runtime = { workspace = true, optional = true }

# frontier
fc-cli = { workspace = true }
fc-consensus = { workspace = true }
fc-db = { workspace = true }
fc-mapping-sync = { workspace = true }
fc-rpc = { features = ["rpc-binary-search-estimate"], workspace = true }
Expand All @@ -53,14 +51,13 @@ fp-storage = { workspace = true }

# polkadot
polkadot-cli = { workspace = true }
polkadot-parachain = { workspace = true }
polkadot-primitives = { workspace = true }
polkadot-service = { workspace = true }
xcm = { workspace = true }

# substrate
frame-benchmarking = { workspace = true }
frame-benchmarking-cli = { workspace = true }
frame-benchmarking = { workspace = true, optional = true }
frame-benchmarking-cli = { workspace = true, optional = true }
pallet-transaction-payment-rpc = { workspace = true }
sc-basic-authorship = { workspace = true }
sc-chain-spec = { workspace = true }
Expand All @@ -69,12 +66,10 @@ sc-client-api = { workspace = true }
sc-consensus = { workspace = true }
sc-consensus-aura = { workspace = true }
sc-executor = { workspace = true }
sc-keystore = { workspace = true }
sc-network = { workspace = true }
sc-network-common = { workspace = true }
sc-offchain = { workspace = true }
sc-rpc = { workspace = true }
sc-rpc-api = { workspace = true }
sc-service = { workspace = true }
sc-sysinfo = { workspace = true }
sc-telemetry = { workspace = true }
Expand All @@ -87,8 +82,7 @@ sp-blockchain = { workspace = true }
sp-consensus = { workspace = true }
sp-consensus-aura = { workspace = true }
sp-core = { workspace = true }
sp-inherents = { workspace = true }
sp-io = { workspace = true }
sp-io = { workspace = true, optional = true }
sp-keystore = { workspace = true }
sp-offchain = { workspace = true }
sp-runtime = { workspace = true }
Expand Down Expand Up @@ -122,6 +116,10 @@ runtime-benchmarks = [

# polkadot
"polkadot-cli/runtime-benchmarks",

# substrate
"frame-benchmarking",
"frame-benchmarking-cli",
]

try-runtime = [
Expand All @@ -132,6 +130,7 @@ try-runtime = [
"pangoro-runtime?/try-runtime",

# substrate
"sp-io",
"try-runtime-cli/try-runtime",
]

Expand Down
5 changes: 5 additions & 0 deletions node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,18 @@ pub enum Subcommand {

/// Sub-commands concerned with benchmarking.
/// The pallet benchmarking moved to the `pallet` sub-command.
#[cfg(feature = "runtime-benchmarks")]
#[command(subcommand)]
Benchmark(Box<frame_benchmarking_cli::BenchmarkCmd>),

/// Try some testing command against a specified runtime state.
#[cfg(feature = "try-runtime")]
TryRuntime(try_runtime_cli::TryRuntimeCmd),

/// Errors since the binary was not build with `--features runtime-benchmarks`.
#[cfg(not(feature = "runtime-benchmarks"))]
Benchmark,

/// Errors since the binary was not build with `--features try-runtime`.
#[cfg(not(feature = "try-runtime"))]
TryRuntime,
Expand Down
24 changes: 11 additions & 13 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ use dc_primitives::Block;
// frontier
use fc_db::frontier_database_dir;
// substrate
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
use sc_cli::{
CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, NetworkParams,
Result, RuntimeVersion, SharedParams, SubstrateCli,
Expand Down Expand Up @@ -281,6 +280,7 @@ impl CliConfiguration<Self> for RelayChainCli {

/// Parse command line arguments into service configuration.
pub fn run() -> Result<()> {
#[cfg(feature = "runtime-benchmarks")]
/// Creates partial components for the runtimes that are supported by the benchmarks.
macro_rules! construct_benchmark_partials {
($config:expr, $cli:ident, |$partials:ident| $code:expr) => {{
Expand Down Expand Up @@ -538,14 +538,16 @@ pub fn run() -> Result<()> {
panic!("No feature(crab-native, darwinia-native, pangolin-native, pangoro-native) is enabled!");
})
},
#[cfg(feature = "runtime-benchmarks")]
Some(Subcommand::Benchmark(cmd)) => {
let runner = cli.create_runner(&**cmd)?;
// substrate
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};

let runner = cli.create_runner(&**cmd)?;
// Switch on the concrete benchmark sub-command-
match &**cmd {
BenchmarkCmd::Pallet(cmd) =>
if cfg!(feature = "runtime-benchmarks") {
runner.sync_run(|config| {
runner.sync_run(|config| {
#[cfg(feature = "crab-native")]
if config.chain_spec.is_crab() {
return cmd.run::<Block, CrabRuntimeExecutor>(config);
Expand All @@ -567,18 +569,10 @@ pub fn run() -> Result<()> {
}

panic!("No feature(crab-native, darwinia-native, pangolin-native, pangoro-native) is enabled!");
})
} 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| {
construct_benchmark_partials!(config, cli, |partials| cmd.run(partials.client))
}),
#[cfg(not(feature = "runtime-benchmarks"))]
BenchmarkCmd::Storage(_) => Err(sc_cli::Error::Input(
"Compile with --features=runtime-benchmarks to enable storage benchmarks.".into(),
)),
#[cfg(feature = "runtime-benchmarks")]
BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {
construct_benchmark_partials!(config, cli, |partials| {
let db = partials.backend.expose_db();
Expand All @@ -594,6 +588,10 @@ pub fn run() -> Result<()> {
_ => Err("Benchmarking sub-command unsupported".into()),
}
},
#[cfg(not(feature = "runtime-benchmarks"))]
Some(Subcommand::Benchmark) => Err(
"Benchmarking was not enabled when building the node. You can enable it with `--features runtime-benchmarks`.".into()
),
#[cfg(feature = "try-runtime")]
Some(Subcommand::TryRuntime(cmd)) => {
use sc_service::TaskManager;
Expand Down
1 change: 1 addition & 0 deletions node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
//! Darwinia node CLI.

#![deny(missing_docs)]
#![deny(unused_crate_dependencies)]

mod chain_spec;
mod cli;
Expand Down
1 change: 1 addition & 0 deletions pallet/account-migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

#![cfg_attr(not(feature = "std"), no_std)]
#![deny(missing_docs)]
#![deny(unused_crate_dependencies)]

#[cfg(test)]
mod mock;
Expand Down
3 changes: 1 addition & 2 deletions pallet/deposit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ dc-types = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
pallet-timestamp = { workspace = true }
sp-core = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }
# substrate optional
Expand All @@ -31,6 +30,7 @@ frame-benchmarking = { workspace = true, optional = true }
pallet-assets = { workspace = true, features = ["std"] }
pallet-balances = { workspace = true, features = ["std"] }
sp-io = { workspace = true, features = ["std"] }
sp-core = { workspace = true, features = ["std"] }

[features]
default = ["std"]
Expand All @@ -47,7 +47,6 @@ std = [
"frame-support/std",
"frame-system/std",
"pallet-timestamp/std",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
# substrate optional
Expand Down
1 change: 1 addition & 0 deletions pallet/deposit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#![cfg_attr(not(feature = "std"), no_std)]
#![deny(missing_docs)]
#![deny(unused_crate_dependencies)]

#[cfg(test)]
mod mock;
Expand Down
6 changes: 3 additions & 3 deletions pallet/ecdsa-authority/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ codec = { workspace = true, package = "parity-scale-codec" }
ethabi = { version = "17.0", default-features = false }
scale-info = { workspace = true }
# crates.io optional
array-bytes = { workspace = true, optional = true }
# https://github.com/paritytech/libsecp256k1/issues/134
# array-bytes = { workspace = true, optional = true }
boundless-forest marked this conversation as resolved.
Show resolved Hide resolved
# libsecp256k1 = { workspace = true, optional = true, default-features = false }

# darwinia
Expand All @@ -31,7 +31,7 @@ frame-benchmarking = { workspace = true, optional = true }

[dev-dependencies]
# crates.io
array-bytes = { workspace = true}
array-bytes = { workspace = true }
libsecp256k1 = { workspace = true, features = ["std"] }
# substrate
sp-version = { workspace = true, features = ["std"] }
Expand Down Expand Up @@ -63,8 +63,8 @@ std = [

runtime-benchmarks = [
# crates.io
"array-bytes",
# https://github.com/paritytech/libsecp256k1/issues/134
# "array-bytes",
# "libsecp256k1",

# substrate
Expand Down
3 changes: 2 additions & 1 deletion pallet/ecdsa-authority/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(clippy::type_complexity)]
#![deny(missing_docs)]
#![deny(unused_crate_dependencies)]

#[cfg(test)]
mod mock;
Expand All @@ -45,7 +46,7 @@ use ethabi::Token;
// darwinia
use dc_primitives::AccountId;
// substrate
use frame_support::{pallet_prelude::*, traits::Get};
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use sp_runtime::{
traits::{SaturatedConversion, Saturating, Zero},
Expand Down
4 changes: 4 additions & 0 deletions pallet/message-gadget/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// along with Darwinia. If not, see <https://www.gnu.org/licenses/>.

#![cfg_attr(not(feature = "std"), no_std)]
#![deny(unused_crate_dependencies)]

// core
use core::marker::PhantomData;
Expand All @@ -29,6 +30,9 @@ use sp_core::{H160, H256};
use sp_io::hashing;
use sp_std::prelude::*;

#[cfg(test)]
mod tests;

#[frame_support::pallet]
pub mod pallet {
// darwinia
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
// You should have received a copy of the GNU General Public License
// along with Darwinia. If not, see <https://www.gnu.org/licenses/>.

// TODO: move to mock later.
use crate as darwinia_message_gadget;
aurexav marked this conversation as resolved.
Show resolved Hide resolved

// darwinia
use darwinia_message_gadget::*;
use crate::*;

impl frame_system::Config for Runtime {
type AccountData = pallet_balances::AccountData<u128>;
Expand Down
3 changes: 1 addition & 2 deletions pallet/message-transact/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ pallet-evm = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
sp-core = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }

[dev-dependencies]
Expand All @@ -46,6 +45,7 @@ precompile-utils = { workspace = true, features = ["std", "testing"] }
pallet-balances = { workspace = true, features = ["std"] }
pallet-timestamp = { workspace = true, features = ["std"] }
sp-io = { workspace = true, features = ["std"] }
sp-runtime = { workspace = true, features = ["std"] }

[features]
default = ["std"]
Expand All @@ -64,7 +64,6 @@ std = [
"frame-support/std",
"frame-system/std",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
]

Expand Down
2 changes: 2 additions & 0 deletions pallet/message-transact/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
// along with Darwinia. If not, see <https://www.gnu.org/licenses/>.

#![cfg_attr(not(feature = "std"), no_std)]
// TODO: address the unused crates in test.
#![cfg_attr(not(test), deny(unused_crate_dependencies))]
aurexav marked this conversation as resolved.
Show resolved Hide resolved

#[cfg(test)]
mod mock;
Expand Down
3 changes: 1 addition & 2 deletions pallet/staking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ frame-support = { workspace = true }
frame-system = { workspace = true }
pallet-authorship = { workspace = true }
pallet-session = { workspace = true }
sp-core = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }

Expand All @@ -36,6 +35,7 @@ pallet-assets = { workspace = true, features = ["std"] }
pallet-balances = { workspace = true, features = ["std"] }
pallet-session = { workspace = true, features = ["std"] }
pallet-timestamp = { workspace = true, features = ["std"] }
sp-core = { workspace = true, features = ["std"] }
sp-io = { workspace = true, features = ["std"] }

[features]
Expand All @@ -54,7 +54,6 @@ std = [
"pallet-authorship/std",
"pallet-balances/std",
"pallet-session/std",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
]
Expand Down
Loading