Inspection extension to node CLI (#4697)

* Initial inspect.

* WiP

* Add parsing tests.

* Finalize CLI.

* Update to latest substrate.

* Remove unused imports.

* Support ImportParams as well, to get the right pruning setting.

* Mention in docs that hash is no 0x.

* Move bytes above extrinsics.

* Switch to fill helper from sc_cli.

* Remove overwrite.

* Fix error.

* Fix error message.

* Remove extra allow.

* init_config
This commit is contained in:
Tomasz Drwięga
2020-02-18 17:56:52 +01:00
committed by GitHub
parent 133a4f967f
commit a14d28150d
11 changed files with 518 additions and 12 deletions
+7 -4
View File
@@ -90,6 +90,7 @@ node-executor = { version = "2.0.0", path = "../executor" }
# CLI-specific dependencies
sc-cli = { version = "0.8.0", optional = true, path = "../../../client/cli" }
node-transaction-factory = { version = "0.8.0", optional = true, path = "../transaction-factory" }
node-inspect = { version = "0.8.0", optional = true, path = "../inspect" }
# WASM-specific dependencies
wasm-bindgen = { version = "0.2.57", optional = true }
@@ -110,6 +111,7 @@ nix = "0.17"
build-script-utils = { version = "2.0.0", package = "substrate-build-script-utils", path = "../../../utils/build-script-utils" }
structopt = { version = "0.3.8", optional = true }
node-transaction-factory = { version = "0.8.0", optional = true, path = "../transaction-factory" }
node-inspect = { version = "0.8.0", optional = true, path = "../inspect" }
[build-dependencies.sc-cli]
version = "0.8.0"
@@ -129,12 +131,13 @@ browser = [
"wasm-bindgen-futures",
]
cli = [
"sc-cli",
"node-transaction-factory",
"sc-service/rocksdb",
"node-executor/wasmi-errno",
"vergen",
"node-inspect",
"node-transaction-factory",
"sc-cli",
"sc-service/rocksdb",
"structopt",
"vergen",
]
wasmtime = [
"cli",
+11 -4
View File
@@ -17,7 +17,7 @@
use sc_cli::{SharedParams, ImportParams, RunCmd};
use structopt::StructOpt;
#[allow(missing_docs)]
/// An overarching CLI command definition.
#[derive(Clone, Debug, StructOpt)]
#[structopt(settings = &[
structopt::clap::AppSettings::GlobalVersion,
@@ -25,7 +25,7 @@ use structopt::StructOpt;
structopt::clap::AppSettings::SubcommandsNegateReqs,
])]
pub struct Cli {
#[allow(missing_docs)]
/// Possible subcommand with parameters.
#[structopt(subcommand)]
pub subcommand: Option<Subcommand>,
#[allow(missing_docs)]
@@ -33,10 +33,10 @@ pub struct Cli {
pub run: RunCmd,
}
#[allow(missing_docs)]
/// Possible subcommands of the main binary.
#[derive(Clone, Debug, StructOpt)]
pub enum Subcommand {
#[allow(missing_docs)]
/// A set of base subcommands handled by `sc_cli`.
#[structopt(flatten)]
Base(sc_cli::Subcommand),
/// The custom factory subcommmand for manufacturing transactions.
@@ -46,6 +46,13 @@ pub enum Subcommand {
Only supported for development or local testnet."
)]
Factory(FactoryCmd),
/// The custom inspect subcommmand for decoding blocks and extrinsics.
#[structopt(
name = "inspect",
about = "Decode given block or extrinsic using current native runtime."
)]
Inspect(node_inspect::cli::InspectCmd),
}
/// The `factory` command used to generate transactions.
+10
View File
@@ -39,6 +39,16 @@ where
load_spec,
&version,
),
Some(Subcommand::Inspect(cmd)) => {
cmd.init(&mut config, load_spec, &version)?;
let client = sc_service::new_full_client::<
node_runtime::Block,node_runtime::RuntimeApi, node_executor::Executor, _, _,
>(&config)?;
let inspect = node_inspect::Inspector::<node_runtime::Block>::new(client);
cmd.run(inspect)
},
Some(Subcommand::Factory(cli_args)) => {
sc_cli::init(&cli_args.shared_params, &version)?;
sc_cli::init_config(&mut config, &cli_args.shared_params, &version, load_spec)?;
-1
View File
@@ -27,7 +27,6 @@
//! hasn't been tested.
#![warn(missing_docs)]
#![warn(unused_extern_crates)]
pub mod chain_spec;