From 94bb119ef9d19fdbddfe002e84f18103f700c085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Thu, 7 Jan 2021 13:14:42 +0100 Subject: [PATCH] Subkey should not import the entire world. (#7845) There is no reason for subkey to import the default Substrate node to support a feature that would only be usable for the Substrate node. Subkey itself should be more the default key management binary for Substrate related chains. If certain chains require some special functionality, they can easily stick together their own "my-chain-key". --- substrate/Cargo.lock | 5 ----- substrate/bin/utils/subkey/Cargo.toml | 8 ------- substrate/bin/utils/subkey/src/lib.rs | 30 ++++++++------------------ substrate/bin/utils/subkey/src/main.rs | 4 +--- 4 files changed, 10 insertions(+), 37 deletions(-) diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index fa7bc74ae1..1cd16f2897 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -8913,13 +8913,8 @@ dependencies = [ name = "subkey" version = "2.0.0" dependencies = [ - "frame-system", - "node-primitives", - "node-runtime", "sc-cli", - "sp-core", "structopt", - "substrate-frame-cli", ] [[package]] diff --git a/substrate/bin/utils/subkey/Cargo.toml b/substrate/bin/utils/subkey/Cargo.toml index fa0b345bc8..e445749c2c 100644 --- a/substrate/bin/utils/subkey/Cargo.toml +++ b/substrate/bin/utils/subkey/Cargo.toml @@ -16,13 +16,5 @@ name = "subkey" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -node-runtime = { version = "2.0.0", path = "../../node/runtime" } -node-primitives = { version = "2.0.0", path = "../../node/primitives" } sc-cli = { version = "0.8.0", path = "../../../client/cli" } -substrate-frame-cli = { version = "2.0.0", path = "../../../utils/frame/frame-utilities-cli" } structopt = "0.3.14" -frame-system = { version = "2.0.0", path = "../../../frame/system" } -sp-core = { version = "2.0.0", path = "../../../primitives/core" } - -[features] -bench = [] diff --git a/substrate/bin/utils/subkey/src/lib.rs b/substrate/bin/utils/subkey/src/lib.rs index 5f7787f022..e7243fbd43 100644 --- a/substrate/bin/utils/subkey/src/lib.rs +++ b/substrate/bin/utils/subkey/src/lib.rs @@ -21,8 +21,6 @@ use sc_cli::{ Error, VanityCmd, SignCmd, VerifyCmd, GenerateNodeKeyCmd, GenerateCmd, InspectKeyCmd, InspectNodeKeyCmd }; -use substrate_frame_cli::ModuleIdCmd; -use sp_core::crypto::Ss58Codec; #[derive(Debug, StructOpt)] #[structopt( @@ -44,9 +42,6 @@ pub enum Subkey { /// Print the peer ID corresponding to the node key in the given file InspectNodeKey(InspectNodeKeyCmd), - /// Inspect a module ID address - ModuleId(ModuleIdCmd), - /// Sign a message, with a given (secret) key. Sign(SignCmd), @@ -58,21 +53,14 @@ pub enum Subkey { } /// Run the subkey command, given the apropriate runtime. -pub fn run() -> Result<(), Error> - where - R: frame_system::Config, - R::AccountId: Ss58Codec -{ +pub fn run() -> Result<(), Error> { match Subkey::from_args() { - Subkey::GenerateNodeKey(cmd) => cmd.run()?, - Subkey::Generate(cmd) => cmd.run()?, - Subkey::Inspect(cmd) => cmd.run()?, - Subkey::InspectNodeKey(cmd) => cmd.run()?, - Subkey::ModuleId(cmd) => cmd.run::()?, - Subkey::Vanity(cmd) => cmd.run()?, - Subkey::Verify(cmd) => cmd.run()?, - Subkey::Sign(cmd) => cmd.run()?, - }; - - Ok(()) + Subkey::GenerateNodeKey(cmd) => cmd.run(), + Subkey::Generate(cmd) => cmd.run(), + Subkey::Inspect(cmd) => cmd.run(), + Subkey::InspectNodeKey(cmd) => cmd.run(), + Subkey::Vanity(cmd) => cmd.run(), + Subkey::Verify(cmd) => cmd.run(), + Subkey::Sign(cmd) => cmd.run(), + } } diff --git a/substrate/bin/utils/subkey/src/main.rs b/substrate/bin/utils/subkey/src/main.rs index 39f2f9e2e5..2a0f085071 100644 --- a/substrate/bin/utils/subkey/src/main.rs +++ b/substrate/bin/utils/subkey/src/main.rs @@ -18,8 +18,6 @@ //! Subkey utility, based on node_runtime. -use node_runtime::Runtime; - fn main() -> Result<(), sc_cli::Error> { - subkey::run::() + subkey::run() }