rustfmt ghost cli and fix typos
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
parent
767161ac9c
commit
6ae3fd6291
@ -17,7 +17,7 @@ homepage.workspace = true
|
||||
[workspace.package]
|
||||
license = "GPL-3.0-only"
|
||||
authors = ["571nky", "57r37ch", "f4750"]
|
||||
version = "0.7.209"
|
||||
version = "0.7.210"
|
||||
edition = "2021"
|
||||
homepage = "https://ghostchain.io"
|
||||
repository = "https://git.ghostchain.io/ghostchain/ghost-node"
|
||||
|
@ -1,4 +1,4 @@
|
||||
fn main () {
|
||||
fn main() {
|
||||
if let Ok(profile) = std::env::var("PROFILE") {
|
||||
println!("cargo:rustc-cfg=build_type=\"{}\"", profile);
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
use crate::cli::{Cli, Subcommand};
|
||||
use frame_benchmarking_cli::{BenchmarkCmd, ExtrinsicFactory};
|
||||
use futures::future::TryFutureExt;
|
||||
use keyring::Sr25519Keyring;
|
||||
use sc_cli::SubstrateCli;
|
||||
use service::{
|
||||
self, IdentifyVariant,
|
||||
benchmarking::{
|
||||
benchmark_inherent_data, RemarkBuilder, TransferKeepAliveBuilder
|
||||
},
|
||||
self,
|
||||
benchmarking::{benchmark_inherent_data, RemarkBuilder, TransferKeepAliveBuilder},
|
||||
IdentifyVariant,
|
||||
};
|
||||
use keyring::Sr25519Keyring;
|
||||
|
||||
pub use crate::{error::Error, service::BlockId};
|
||||
#[cfg(feature = "pyroscope")]
|
||||
@ -68,28 +67,35 @@ impl SubstrateCli for Cli {
|
||||
#[cfg(feature = "casper-native")]
|
||||
"casper" => Box::new(service::chain_spec::casper_config()?),
|
||||
#[cfg(feature = "casper-native")]
|
||||
"casper-dev" | "dev" | "development" => Box::new(service::chain_spec::casper_development_config()?),
|
||||
"casper-dev" | "dev" | "development" => {
|
||||
Box::new(service::chain_spec::casper_development_config()?)
|
||||
}
|
||||
#[cfg(feature = "casper-native")]
|
||||
"casper-local" | "local" => Box::new(service::chain_spec::casper_local_testnet_config()?),
|
||||
"casper-local" | "local" => {
|
||||
Box::new(service::chain_spec::casper_local_testnet_config()?)
|
||||
}
|
||||
#[cfg(feature = "casper-native")]
|
||||
"casper-staging" | "staging" => Box::new(service::chain_spec::casper_staging_testnet_config()?),
|
||||
"casper-staging" | "staging" => {
|
||||
Box::new(service::chain_spec::casper_staging_testnet_config()?)
|
||||
}
|
||||
#[cfg(not(feature = "casper-native"))]
|
||||
name if name.starts_with("casper-") && !name.ends_with(".json") =>
|
||||
Err(format!("`{}` only supported with `casper-native` feature enabled.", name))?,
|
||||
name if name.starts_with("casper-") && !name.ends_with(".json") => Err(format!(
|
||||
"`{}` only supported with `casper-native` feature enabled.",
|
||||
name
|
||||
))?,
|
||||
#[cfg(feature = "casper-native")]
|
||||
path => {
|
||||
let path = std::path::PathBuf::from(path);
|
||||
|
||||
let chain_spec = Box::new(
|
||||
service::GenericChainSpec::from_json_file(path.clone())?
|
||||
) as Box<dyn service::ChainSpec>;
|
||||
let chain_spec = Box::new(service::GenericChainSpec::from_json_file(path.clone())?)
|
||||
as Box<dyn service::ChainSpec>;
|
||||
|
||||
if chain_spec.is_casper() {
|
||||
Box::new(service::CasperChainSpec::from_json_file(path)?)
|
||||
Box::new(service::CasperChainSpec::from_json_file(path)?)
|
||||
} else {
|
||||
chain_spec
|
||||
chain_spec
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -109,10 +115,7 @@ fn set_ss58_version(spec: &Box<dyn service::ChainSpec>) {
|
||||
sp_core::crypto::set_default_ss58_version(ss58_version);
|
||||
}
|
||||
|
||||
fn run_node_inner<F>(
|
||||
cli: Cli,
|
||||
logger_hook: F,
|
||||
) -> Result<()>
|
||||
fn run_node_inner<F>(cli: Cli, logger_hook: F) -> Result<()>
|
||||
where
|
||||
F: FnOnce(&mut sc_cli::LoggerBuilder, &sc_service::Configuration),
|
||||
{
|
||||
@ -128,7 +131,8 @@ where
|
||||
.then_some(config.database.path().map(|database_path| {
|
||||
let _ = std::fs::create_dir_all(&database_path);
|
||||
sc_sysinfo::gather_hwbench(Some(database_path))
|
||||
})).flatten();
|
||||
}))
|
||||
.flatten();
|
||||
|
||||
let database_source = config.database.clone();
|
||||
let task_manager = service::build_full(
|
||||
@ -138,7 +142,8 @@ where
|
||||
telemetry_worker_handle: None,
|
||||
hwbench,
|
||||
},
|
||||
).map(|full| full.task_manager)?;
|
||||
)
|
||||
.map(|full| full.task_manager)?;
|
||||
|
||||
if let Some(path) = database_source.path() {
|
||||
sc_storage_monitor::StorageMonitorService::try_spawn(
|
||||
@ -167,7 +172,9 @@ pub fn run() -> Result<()> {
|
||||
let agent = pyro::Pyroscope::builder(
|
||||
"http://".to_owned() + address.to_string().as_str(),
|
||||
"ghost".to_owned(),
|
||||
).backend(pprof_backend(PprofConfig::new().sample_rate(113))).build()?;
|
||||
)
|
||||
.backend(pprof_backend(PprofConfig::new().sample_rate(113)))
|
||||
.build()?;
|
||||
|
||||
Some(agent.start()?)
|
||||
} else {
|
||||
@ -176,7 +183,7 @@ pub fn run() -> Result<()> {
|
||||
|
||||
#[cfg(not(feature = "pyroscope"))]
|
||||
if cli.run.pyroscope_server.is_some() {
|
||||
return Err(Error::PyroscopeNotCompiledIn)
|
||||
return Err(Error::PyroscopeNotCompiledIn);
|
||||
}
|
||||
|
||||
match &cli.subcommand {
|
||||
@ -184,7 +191,7 @@ pub fn run() -> Result<()> {
|
||||
Some(Subcommand::BuildSpec(cmd)) => {
|
||||
let runner = cli.create_runner(cmd).map_err(Error::SubstrateCli)?;
|
||||
Ok(runner.sync_run(|config| cmd.run(config.chain_spec, config.network))?)
|
||||
},
|
||||
}
|
||||
Some(Subcommand::CheckBlock(cmd)) => {
|
||||
let runner = cli.create_runner(cmd).map_err(Error::SubstrateCli)?;
|
||||
let chain_spec = &runner.config().chain_spec;
|
||||
@ -192,11 +199,13 @@ pub fn run() -> Result<()> {
|
||||
set_ss58_version(chain_spec);
|
||||
|
||||
runner.async_run(|mut config| {
|
||||
let (client, _, import_queue, task_manager) =
|
||||
service::new_chain_ops(&mut config)?;
|
||||
Ok((cmd.run(client, import_queue).map_err(Error::SubstrateCli), task_manager))
|
||||
let (client, _, import_queue, task_manager) = service::new_chain_ops(&mut config)?;
|
||||
Ok((
|
||||
cmd.run(client, import_queue).map_err(Error::SubstrateCli),
|
||||
task_manager,
|
||||
))
|
||||
})
|
||||
},
|
||||
}
|
||||
Some(Subcommand::ExportBlocks(cmd)) => {
|
||||
let runner = cli.create_runner(cmd).map_err(Error::SubstrateCli)?;
|
||||
let chain_spec = &runner.config().chain_spec;
|
||||
@ -204,11 +213,14 @@ pub fn run() -> Result<()> {
|
||||
set_ss58_version(chain_spec);
|
||||
|
||||
Ok(runner.async_run(|mut config| {
|
||||
let ( client, _, _, task_manager ) =
|
||||
service::new_chain_ops(&mut config)?;
|
||||
Ok((cmd.run(client, config.database).map_err(Error::SubstrateCli), task_manager))
|
||||
let (client, _, _, task_manager) = service::new_chain_ops(&mut config)?;
|
||||
Ok((
|
||||
cmd.run(client, config.database)
|
||||
.map_err(Error::SubstrateCli),
|
||||
task_manager,
|
||||
))
|
||||
})?)
|
||||
},
|
||||
}
|
||||
Some(Subcommand::ExportState(cmd)) => {
|
||||
let runner = cli.create_runner(cmd).map_err(Error::SubstrateCli)?;
|
||||
let chain_spec = &runner.config().chain_spec;
|
||||
@ -216,11 +228,14 @@ pub fn run() -> Result<()> {
|
||||
set_ss58_version(chain_spec);
|
||||
|
||||
Ok(runner.async_run(|mut config| {
|
||||
let ( client, _, _, task_manager ) =
|
||||
service::new_chain_ops(&mut config)?;
|
||||
Ok((cmd.run(client, config.chain_spec).map_err(Error::SubstrateCli), task_manager))
|
||||
let (client, _, _, task_manager) = service::new_chain_ops(&mut config)?;
|
||||
Ok((
|
||||
cmd.run(client, config.chain_spec)
|
||||
.map_err(Error::SubstrateCli),
|
||||
task_manager,
|
||||
))
|
||||
})?)
|
||||
},
|
||||
}
|
||||
Some(Subcommand::ImportBlocks(cmd)) => {
|
||||
let runner = cli.create_runner(cmd).map_err(Error::SubstrateCli)?;
|
||||
let chain_spec = &runner.config().chain_spec;
|
||||
@ -228,15 +243,17 @@ pub fn run() -> Result<()> {
|
||||
set_ss58_version(chain_spec);
|
||||
|
||||
Ok(runner.async_run(|mut config| {
|
||||
let ( client, _, import_queue, task_manager ) =
|
||||
service::new_chain_ops(&mut config)?;
|
||||
Ok((cmd.run(client, import_queue).map_err(Error::SubstrateCli), task_manager))
|
||||
let (client, _, import_queue, task_manager) = service::new_chain_ops(&mut config)?;
|
||||
Ok((
|
||||
cmd.run(client, import_queue).map_err(Error::SubstrateCli),
|
||||
task_manager,
|
||||
))
|
||||
})?)
|
||||
},
|
||||
}
|
||||
Some(Subcommand::PurgeChain(cmd)) => {
|
||||
let runner = cli.create_runner(cmd).map_err(Error::SubstrateCli)?;
|
||||
Ok(runner.sync_run(|config| cmd.run(config.database))?)
|
||||
},
|
||||
}
|
||||
Some(Subcommand::Revert(cmd)) => {
|
||||
let runner = cli.create_runner(cmd).map_err(Error::SubstrateCli)?;
|
||||
let chain_spec = &runner.config().chain_spec;
|
||||
@ -244,62 +261,59 @@ pub fn run() -> Result<()> {
|
||||
set_ss58_version(chain_spec);
|
||||
|
||||
Ok(runner.async_run(|mut config| {
|
||||
let (client, backend, _, task_manager) =
|
||||
service::new_chain_ops(&mut config)?;
|
||||
let (client, backend, _, task_manager) = service::new_chain_ops(&mut config)?;
|
||||
|
||||
let aux_revert = Box::new(|client, backend, blocks| {
|
||||
service::revert_backend(client, backend, blocks).map_err(|err| {
|
||||
match err {
|
||||
service::Error::Blockchain(err) => err.into(),
|
||||
err => sc_cli::Error::Application(err.into()),
|
||||
}
|
||||
service::revert_backend(client, backend, blocks).map_err(|err| match err {
|
||||
service::Error::Blockchain(err) => err.into(),
|
||||
err => sc_cli::Error::Application(err.into()),
|
||||
})
|
||||
});
|
||||
|
||||
Ok((
|
||||
cmd.run(client, backend, Some(aux_revert)).map_err(Error::SubstrateCli),
|
||||
task_manager
|
||||
cmd.run(client, backend, Some(aux_revert))
|
||||
.map_err(Error::SubstrateCli),
|
||||
task_manager,
|
||||
))
|
||||
})?)
|
||||
},
|
||||
}
|
||||
Some(Subcommand::Benchmark(cmd)) => {
|
||||
let runner = cli.create_runner(cmd).map_err(Error::SubstrateCli)?;
|
||||
let chain_spec = &runner.config().chain_spec;
|
||||
|
||||
match cmd {
|
||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||
BenchmarkCmd::Storage(_) =>
|
||||
BenchmarkCmd::Storage(_) => {
|
||||
return Err(sc_cli::Error::Input(
|
||||
"Compile with `--feature=runtime-benchmarks \
|
||||
to enable storage benchmarks.".into()
|
||||
).into()),
|
||||
to enable storage benchmarks."
|
||||
.into(),
|
||||
)
|
||||
.into())
|
||||
}
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
BenchmarkCmd::Storage(cmd) => runner.sync_run(|mut config| {
|
||||
let (client, backend, _, _,) =
|
||||
service::new_chain_ops(&mut config)?;
|
||||
let (client, backend, _, _) = service::new_chain_ops(&mut config)?;
|
||||
let db = backend.expose_db();
|
||||
let storage = backend.expose_storage();
|
||||
|
||||
cmd.run(config, client.clone(), db, storage).map_err(Error::SubstrateCli)
|
||||
cmd.run(config, client.clone(), db, storage)
|
||||
.map_err(Error::SubstrateCli)
|
||||
}),
|
||||
BenchmarkCmd::Block(cmd) => runner.sync_run(|mut config| {
|
||||
let (client, _, _, _,) =
|
||||
service::new_chain_ops(&mut config)?;
|
||||
let (client, _, _, _) = service::new_chain_ops(&mut config)?;
|
||||
cmd.run(client.clone()).map_err(Error::SubstrateCli)
|
||||
}),
|
||||
// These commands are very similar and can be handled in nearly the same way
|
||||
BenchmarkCmd::Extrinsic(_) | BenchmarkCmd::Overhead(_) =>
|
||||
BenchmarkCmd::Extrinsic(_) | BenchmarkCmd::Overhead(_) => {
|
||||
runner.sync_run(|mut config| {
|
||||
let (client, _, _, _) =
|
||||
service::new_chain_ops(&mut config)?;
|
||||
let (client, _, _, _) = service::new_chain_ops(&mut config)?;
|
||||
|
||||
let inherent_data = benchmark_inherent_data()
|
||||
.map_err(|e| format!("generating inherent data: {:?}", e))?;
|
||||
|
||||
let remark_builder = RemarkBuilder::new(
|
||||
client.clone(),
|
||||
config.chain_spec.identify_chain(),
|
||||
);
|
||||
let remark_builder =
|
||||
RemarkBuilder::new(client.clone(), config.chain_spec.identify_chain());
|
||||
|
||||
match cmd {
|
||||
BenchmarkCmd::Extrinsic(cmd) => {
|
||||
@ -316,17 +330,20 @@ pub fn run() -> Result<()> {
|
||||
|
||||
cmd.run(client.clone(), inherent_data, Vec::new(), &ext_factory)
|
||||
.map_err(Error::SubstrateCli)
|
||||
},
|
||||
BenchmarkCmd::Overhead(cmd) => cmd.run(
|
||||
config,
|
||||
client.clone(),
|
||||
inherent_data,
|
||||
Vec::new(),
|
||||
&remark_builder,
|
||||
).map_err(Error::SubstrateCli),
|
||||
}
|
||||
BenchmarkCmd::Overhead(cmd) => cmd
|
||||
.run(
|
||||
config,
|
||||
client.clone(),
|
||||
inherent_data,
|
||||
Vec::new(),
|
||||
&remark_builder,
|
||||
)
|
||||
.map_err(Error::SubstrateCli),
|
||||
_ => unreachable!("Ensured by the outside match; qed"),
|
||||
}
|
||||
}),
|
||||
})
|
||||
}
|
||||
BenchmarkCmd::Pallet(cmd) => {
|
||||
set_ss58_version(chain_spec);
|
||||
|
||||
@ -334,30 +351,36 @@ pub fn run() -> Result<()> {
|
||||
runner.sync_run(|config| {
|
||||
cmd.run_with_spec::<sp_runtime::traits::HashingFor<service::Block>, ()>(
|
||||
Some(config.chain_spec),
|
||||
).map_err(|e| Error::SubstrateCli(e))
|
||||
)
|
||||
.map_err(|e| Error::SubstrateCli(e))
|
||||
})
|
||||
} else {
|
||||
Err(sc_cli::Error::Input(
|
||||
"Benchmarking wasn't enabled when building the node. \
|
||||
You can enable it with `--features=runtime-benchmarks`.".into()
|
||||
).into())
|
||||
You can enable it with `--features=runtime-benchmarks`."
|
||||
.into(),
|
||||
)
|
||||
.into())
|
||||
}
|
||||
},
|
||||
}
|
||||
BenchmarkCmd::Machine(cmd) => runner.sync_run(|config| {
|
||||
cmd.run(&config, ghost_machine_primitives::GHOST_NODE_REFERENCE_HARDWARE.clone())
|
||||
.map_err(Error::SubstrateCli)
|
||||
cmd.run(
|
||||
&config,
|
||||
ghost_machine_primitives::GHOST_NODE_REFERENCE_HARDWARE.clone(),
|
||||
)
|
||||
.map_err(Error::SubstrateCli)
|
||||
}),
|
||||
// Note: this allows to implement additional new benchmark
|
||||
// commands.
|
||||
#[allow(unreachable_patterns)]
|
||||
_ => Err(Error::CommandNotImplemented),
|
||||
}
|
||||
},
|
||||
}
|
||||
Some(Subcommand::Key(cmd)) => Ok(cmd.run(&cli)?),
|
||||
Some(Subcommand::ChainInfo(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
Ok(runner.sync_run(|config| cmd.run::<service::Block>(&config))?)
|
||||
},
|
||||
}
|
||||
}?;
|
||||
|
||||
#[cfg(feature = "pyroscope")]
|
||||
|
@ -6,9 +6,7 @@ mod command;
|
||||
mod error;
|
||||
|
||||
#[cfg(feature = "service")]
|
||||
pub use service::{
|
||||
self, Block, CoreApi, IdentifyVariant, ProvideRuntimeApi, TFullClient,
|
||||
};
|
||||
pub use service::{self, Block, CoreApi, IdentifyVariant, ProvideRuntimeApi, TFullClient};
|
||||
|
||||
#[cfg(feature = "cli")]
|
||||
pub use cli::*;
|
||||
|
Loading…
Reference in New Issue
Block a user