Bump clap to 4.0.x and adjust to best practices (#12381)

* Bump clap to 3.2.22

* Replace `from_os_str` with `value_parser`

* Replace `from_str` and `try_from_str` with `value_parser`

* Move possible_values to the new format

* Remove unwanted print

* Add missing match branch

* Update clap to 4.0.9 and make it compile

* Replace deprecated `clap` macro with `command` and `value`

* Move remaining `clap` attributes to `arg`

* Remove no-op value_parsers

* Adjust value_parser for state_version

* Remove "deprecated" feature flag and bump to 4.0.11

* Improve range

Co-authored-by: Bastian Köcher <git@kchr.de>

* Apply suggestions

* Trigger CI

* Fix unused error warning

* Fix doc errors

* Fix ArgGroup naming conflict

* Change default_value to default_value_t

* Use 1.. instead of 0..

Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
Sebastian Kunert
2022-10-18 08:52:46 +02:00
committed by GitHub
parent ca15fe7e3d
commit f687db40f7
70 changed files with 434 additions and 443 deletions
+57 -63
View File
@@ -16,13 +16,13 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! Definitions of [`ArgEnum`] types.
//! Definitions of [`ValueEnum`] types.
use clap::ArgEnum;
use clap::{builder::PossibleValue, ValueEnum};
/// The instantiation strategy to use in compiled mode.
#[derive(Debug, Clone, Copy, ArgEnum)]
#[clap(rename_all = "kebab-case")]
#[derive(Debug, Clone, Copy, ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum WasmtimeInstantiationStrategy {
/// Pool the instances to avoid initializing everything from scratch
/// on each instantiation. Use copy-on-write memory when possible.
@@ -59,20 +59,22 @@ pub enum WasmExecutionMethod {
Compiled,
}
impl std::fmt::Display for WasmExecutionMethod {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Interpreted => write!(f, "Interpreted"),
Self::Compiled => write!(f, "Compiled"),
const INTERPRETED_NAME: &str = "interpreted-i-know-what-i-do";
impl clap::ValueEnum for WasmExecutionMethod {
/// All possible argument values, in display order.
fn value_variants<'a>() -> &'a [Self] {
let variants = &[Self::Interpreted, Self::Compiled];
if cfg!(feature = "wasmtime") {
variants
} else {
&variants[..1]
}
}
}
impl std::str::FromStr for WasmExecutionMethod {
type Err = String;
fn from_str(s: &str) -> Result<Self, String> {
if s.eq_ignore_ascii_case("interpreted-i-know-what-i-do") {
/// Parse an argument into `Self`.
fn from_str(s: &str, _: bool) -> Result<Self, String> {
if s.eq_ignore_ascii_case(INTERPRETED_NAME) {
Ok(Self::Interpreted)
} else if s.eq_ignore_ascii_case("compiled") {
#[cfg(feature = "wasmtime")]
@@ -84,19 +86,29 @@ impl std::str::FromStr for WasmExecutionMethod {
Err("`Compiled` variant requires the `wasmtime` feature to be enabled".into())
}
} else {
Err(format!("Unknown variant `{}`, known variants: {:?}", s, Self::variants()))
Err(format!("Unknown variant `{}`", s))
}
}
/// The canonical argument value.
///
/// The value is `None` for skipped variants.
fn to_possible_value(&self) -> Option<PossibleValue> {
match self {
#[cfg(feature = "wasmtime")]
WasmExecutionMethod::Compiled => Some(PossibleValue::new("compiled")),
#[cfg(not(feature = "wasmtime"))]
WasmExecutionMethod::Compiled => None,
WasmExecutionMethod::Interpreted => Some(PossibleValue::new(INTERPRETED_NAME)),
}
}
}
impl WasmExecutionMethod {
/// Returns all the variants of this enum to be shown in the cli.
pub fn variants() -> &'static [&'static str] {
let variants = &["interpreted-i-know-what-i-do", "compiled"];
if cfg!(feature = "wasmtime") {
variants
} else {
&variants[..1]
impl std::fmt::Display for WasmExecutionMethod {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Interpreted => write!(f, "Interpreted"),
Self::Compiled => write!(f, "Compiled"),
}
}
}
@@ -133,15 +145,15 @@ pub fn execution_method_from_cli(
/// The default [`WasmExecutionMethod`].
#[cfg(feature = "wasmtime")]
pub const DEFAULT_WASM_EXECUTION_METHOD: &str = "compiled";
pub const DEFAULT_WASM_EXECUTION_METHOD: WasmExecutionMethod = WasmExecutionMethod::Compiled;
/// The default [`WasmExecutionMethod`].
#[cfg(not(feature = "wasmtime"))]
pub const DEFAULT_WASM_EXECUTION_METHOD: &str = "interpreted-i-know-what-i-do";
pub const DEFAULT_WASM_EXECUTION_METHOD: WasmExecutionMethod = WasmExecutionMethod::Interpreted;
#[allow(missing_docs)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, ArgEnum)]
#[clap(rename_all = "kebab-case")]
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum TracingReceiver {
/// Output the tracing records using the log.
Log,
@@ -156,16 +168,16 @@ impl Into<sc_tracing::TracingReceiver> for TracingReceiver {
}
/// The type of the node key.
#[derive(Debug, Copy, Clone, PartialEq, Eq, ArgEnum)]
#[clap(rename_all = "kebab-case")]
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum NodeKeyType {
/// Use ed25519.
Ed25519,
}
/// The crypto scheme to use.
#[derive(Debug, Copy, Clone, PartialEq, Eq, ArgEnum)]
#[clap(rename_all = "kebab-case")]
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum CryptoScheme {
/// Use ed25519.
Ed25519,
@@ -176,8 +188,8 @@ pub enum CryptoScheme {
}
/// The type of the output format.
#[derive(Debug, Copy, Clone, PartialEq, Eq, ArgEnum)]
#[clap(rename_all = "kebab-case")]
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum OutputType {
/// Output as json.
Json,
@@ -186,8 +198,8 @@ pub enum OutputType {
}
/// How to execute blocks
#[derive(Debug, Copy, Clone, PartialEq, Eq, ArgEnum)]
#[clap(rename_all = "kebab-case")]
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum ExecutionStrategy {
/// Execute with native build (if available, WebAssembly otherwise).
Native,
@@ -212,8 +224,8 @@ impl Into<sc_client_api::ExecutionStrategy> for ExecutionStrategy {
/// Available RPC methods.
#[allow(missing_docs)]
#[derive(Debug, Copy, Clone, PartialEq, ArgEnum)]
#[clap(rename_all = "kebab-case")]
#[derive(Debug, Copy, Clone, PartialEq, ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum RpcMethods {
/// Expose every RPC method only when RPC is listening on `localhost`,
/// otherwise serve only safe RPC methods.
@@ -235,7 +247,8 @@ impl Into<sc_service::config::RpcMethods> for RpcMethods {
}
/// Database backend
#[derive(Debug, Clone, PartialEq, Copy)]
#[derive(Debug, Clone, PartialEq, Copy, clap::ValueEnum)]
#[value(rename_all = "lower")]
pub enum Database {
/// Facebooks RocksDB
#[cfg(feature = "rocksdb")]
@@ -246,29 +259,10 @@ pub enum Database {
/// instance of ParityDb
Auto,
/// ParityDb. <https://github.com/paritytech/parity-db/>
#[value(name = "paritydb-experimental")]
ParityDbDeprecated,
}
impl std::str::FromStr for Database {
type Err = String;
fn from_str(s: &str) -> Result<Self, String> {
#[cfg(feature = "rocksdb")]
if s.eq_ignore_ascii_case("rocksdb") {
return Ok(Self::RocksDb)
}
if s.eq_ignore_ascii_case("paritydb-experimental") {
return Ok(Self::ParityDbDeprecated)
} else if s.eq_ignore_ascii_case("paritydb") {
return Ok(Self::ParityDb)
} else if s.eq_ignore_ascii_case("auto") {
Ok(Self::Auto)
} else {
Err(format!("Unknown variant `{}`, known variants: {:?}", s, Self::variants()))
}
}
}
impl Database {
/// Returns all the variants of this enum to be shown in the cli.
pub const fn variants() -> &'static [&'static str] {
@@ -284,8 +278,8 @@ impl Database {
/// Whether off-chain workers are enabled.
#[allow(missing_docs)]
#[derive(Debug, Clone, ArgEnum)]
#[clap(rename_all = "kebab-case")]
#[derive(Debug, Clone, ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum OffchainWorkerEnabled {
/// Always have offchain worker enabled.
Always,
@@ -296,8 +290,8 @@ pub enum OffchainWorkerEnabled {
}
/// Syncing mode.
#[derive(Debug, Clone, Copy, ArgEnum, PartialEq)]
#[clap(rename_all = "kebab-case")]
#[derive(Debug, Clone, Copy, ValueEnum, PartialEq)]
#[value(rename_all = "kebab-case")]
pub enum SyncMode {
/// Full sync. Download end verify all blocks.
Full,
@@ -34,14 +34,14 @@ use std::io::Write;
#[derive(Debug, Clone, Parser)]
pub struct BuildSpecCmd {
/// Force raw genesis storage output.
#[clap(long)]
#[arg(long)]
pub raw: bool,
/// Disable adding the default bootnode to the specification.
///
/// By default the `/ip4/127.0.0.1/tcp/30333/p2p/NODE_PEER_ID` bootnode is added to the
/// specification when no bootnode exists.
#[clap(long)]
#[arg(long)]
pub disable_default_bootnode: bool,
#[allow(missing_docs)]
@@ -30,13 +30,13 @@ use std::{fmt::Debug, str::FromStr, sync::Arc};
#[derive(Debug, Clone, Parser)]
pub struct CheckBlockCmd {
/// Block hash or number
#[clap(value_name = "HASH or NUMBER")]
#[arg(value_name = "HASH or NUMBER")]
pub input: BlockNumberOrHash,
/// The default number of 64KB pages to ever allocate for Wasm execution.
///
/// Don't alter this unless you know what you're doing.
#[clap(long, value_name = "COUNT")]
#[arg(long, value_name = "COUNT")]
pub default_heap_pages: Option<u32>,
#[allow(missing_docs)]
@@ -32,23 +32,23 @@ use std::{fmt::Debug, fs, io, path::PathBuf, str::FromStr, sync::Arc};
#[derive(Debug, Clone, Parser)]
pub struct ExportBlocksCmd {
/// Output file name or stdout if unspecified.
#[clap(parse(from_os_str))]
#[arg()]
pub output: Option<PathBuf>,
/// Specify starting block number.
///
/// Default is 1.
#[clap(long, value_name = "BLOCK")]
#[arg(long, value_name = "BLOCK")]
pub from: Option<GenericNumber>,
/// Specify last block number.
///
/// Default is best block.
#[clap(long, value_name = "BLOCK")]
#[arg(long, value_name = "BLOCK")]
pub to: Option<GenericNumber>,
/// Use binary output rather than JSON.
#[clap(long)]
#[arg(long)]
pub binary: bool,
#[allow(missing_docs)]
@@ -32,7 +32,7 @@ use std::{fmt::Debug, io::Write, str::FromStr, sync::Arc};
#[derive(Debug, Clone, Parser)]
pub struct ExportStateCmd {
/// Block hash or number.
#[clap(value_name = "HASH or NUMBER")]
#[arg(value_name = "HASH or NUMBER")]
pub input: Option<BlockNumberOrHash>,
#[allow(missing_docs)]
@@ -25,10 +25,10 @@ use clap::Parser;
/// The `generate` command
#[derive(Debug, Clone, Parser)]
#[clap(name = "generate", about = "Generate a random account")]
#[command(name = "generate", about = "Generate a random account")]
pub struct GenerateCmd {
/// The number of words in the phrase to generate. One of 12 (default), 15, 18, 21 and 24.
#[clap(short = 'w', long, value_name = "WORDS")]
#[arg(short = 'w', long, value_name = "WORDS")]
words: Option<usize>,
#[allow(missing_docs)]
@@ -28,7 +28,7 @@ use std::{
/// The `generate-node-key` command
#[derive(Debug, Parser)]
#[clap(
#[command(
name = "generate-node-key",
about = "Generate a random node key, write it to a file or stdout \
and write the corresponding peer-id to stderr"
@@ -37,13 +37,13 @@ pub struct GenerateNodeKeyCmd {
/// Name of file to save secret key to.
///
/// If not given, the secret key is printed to stdout.
#[clap(long)]
#[arg(long)]
file: Option<PathBuf>,
/// The output is in raw binary format.
///
/// If not given, the output is written as an hex encoded string.
#[clap(long)]
#[arg(long)]
bin: bool,
}
@@ -37,17 +37,17 @@ use std::{
#[derive(Debug, Parser)]
pub struct ImportBlocksCmd {
/// Input file or stdin if unspecified.
#[clap(parse(from_os_str))]
#[arg()]
pub input: Option<PathBuf>,
/// The default number of 64KB pages to ever allocate for Wasm execution.
///
/// Don't alter this unless you know what you're doing.
#[clap(long, value_name = "COUNT")]
#[arg(long, value_name = "COUNT")]
pub default_heap_pages: Option<u32>,
/// Try importing blocks from binary format rather than JSON.
#[clap(long)]
#[arg(long)]
pub binary: bool,
#[allow(missing_docs)]
@@ -29,16 +29,16 @@ use std::sync::Arc;
/// The `insert` command
#[derive(Debug, Clone, Parser)]
#[clap(name = "insert", about = "Insert a key to the keystore of a node.")]
#[command(name = "insert", about = "Insert a key to the keystore of a node.")]
pub struct InsertKeyCmd {
/// The secret key URI.
/// If the value is a file, the file content is used as URI.
/// If not given, you will be prompted for the URI.
#[clap(long)]
#[arg(long)]
suri: Option<String>,
/// Key type, examples: "gran", or "imon"
#[clap(long)]
#[arg(long)]
key_type: String,
#[allow(missing_docs)]
@@ -50,7 +50,7 @@ pub struct InsertKeyCmd {
pub keystore_params: KeystoreParams,
/// The cryptography scheme that should be used to generate the key out of the given URI.
#[clap(long, value_name = "SCHEME", arg_enum, ignore_case = true)]
#[arg(long, value_name = "SCHEME", value_enum, ignore_case = true)]
pub scheme: CryptoScheme,
}
@@ -27,7 +27,7 @@ use std::str::FromStr;
/// The `inspect` command
#[derive(Debug, Parser)]
#[clap(
#[command(
name = "inspect",
about = "Gets a public key and a SS58 address from the provided Secret URI"
)]
@@ -44,7 +44,7 @@ pub struct InspectKeyCmd {
uri: Option<String>,
/// Is the given `uri` a hex encoded public key?
#[clap(long)]
#[arg(long)]
public: bool,
#[allow(missing_docs)]
@@ -72,7 +72,7 @@ pub struct InspectKeyCmd {
///
/// If there is no derivation in `--uri`, the public key will be checked against the public key
/// of `--uri` directly.
#[clap(long, conflicts_with = "public")]
#[arg(long, conflicts_with = "public")]
pub expect_public: Option<String>,
}
@@ -28,7 +28,7 @@ use std::{
/// The `inspect-node-key` command
#[derive(Debug, Parser)]
#[clap(
#[command(
name = "inspect-node-key",
about = "Load a node key from a file or stdin and print the corresponding peer-id."
)]
@@ -36,18 +36,18 @@ pub struct InspectNodeKeyCmd {
/// Name of file to read the secret key from.
///
/// If not given, the secret key is read from stdin (up to EOF).
#[clap(long)]
#[arg(long)]
file: Option<PathBuf>,
/// The input is in raw binary format.
///
/// If not given, the input is read as an hex encoded string.
#[clap(long)]
#[arg(long)]
bin: bool,
/// This argument is deprecated and has no effect for this command.
#[deprecated(note = "Network identifier is not used for node-key inspection")]
#[clap(short = 'n', long = "network", value_name = "NETWORK", ignore_case = true)]
#[arg(short = 'n', long = "network", value_name = "NETWORK", ignore_case = true)]
pub network_scheme: Option<String>,
}
@@ -33,7 +33,7 @@ use std::{
#[derive(Debug, Clone, Parser)]
pub struct PurgeChainCmd {
/// Skip interactive prompt by answering yes automatically.
#[clap(short = 'y')]
#[arg(short = 'y')]
pub yes: bool,
#[allow(missing_docs)]
@@ -31,7 +31,7 @@ use std::{fmt::Debug, str::FromStr, sync::Arc};
#[derive(Debug, Parser)]
pub struct RevertCmd {
/// Number of blocks to revert.
#[clap(default_value = "256")]
#[arg(default_value = "256")]
pub num: GenericNumber,
#[allow(missing_docs)]
+40 -40
View File
@@ -42,12 +42,12 @@ pub struct RunCmd {
/// The node will be started with the authority role and actively
/// participate in any consensus task that it can (e.g. depending on
/// availability of local keys).
#[clap(long)]
#[arg(long)]
pub validator: bool,
/// Disable GRANDPA voter when running in validator mode, otherwise disable the GRANDPA
/// observer.
#[clap(long)]
#[arg(long)]
pub no_grandpa: bool,
/// Listen to all RPC interfaces.
@@ -56,13 +56,13 @@ pub struct RunCmd {
/// proxy server to filter out dangerous methods. More details:
/// <https://docs.substrate.io/main-docs/build/custom-rpc/#public-rpcs>.
/// Use `--unsafe-rpc-external` to suppress the warning if you understand the risks.
#[clap(long)]
#[arg(long)]
pub rpc_external: bool,
/// Listen to all RPC interfaces.
///
/// Same as `--rpc-external`.
#[clap(long)]
#[arg(long)]
pub unsafe_rpc_external: bool,
/// RPC methods to expose.
@@ -71,12 +71,12 @@ pub struct RunCmd {
/// - `safe`: Exposes only a safe subset of RPC methods, denying unsafe RPC methods.
/// - `auto`: Acts as `safe` if RPC is served externally, e.g. when `--{rpc,ws}-external` is
/// passed, otherwise acts as `unsafe`.
#[clap(
#[arg(
long,
value_name = "METHOD SET",
arg_enum,
value_enum,
ignore_case = true,
default_value = "auto",
default_value_t = RpcMethods::Auto,
verbatim_doc_comment
)]
pub rpc_methods: RpcMethods,
@@ -87,59 +87,59 @@ pub struct RunCmd {
/// proxy server to filter out dangerous methods. More details:
/// <https://docs.substrate.io/main-docs/build/custom-rpc/#public-rpcs>.
/// Use `--unsafe-ws-external` to suppress the warning if you understand the risks.
#[clap(long)]
#[arg(long)]
pub ws_external: bool,
/// Listen to all Websocket interfaces.
///
/// Same as `--ws-external` but doesn't warn you about it.
#[clap(long)]
#[arg(long)]
pub unsafe_ws_external: bool,
/// DEPRECATED, this has no affect anymore. Use `rpc_max_request_size` or
/// `rpc_max_response_size` instead.
#[clap(long)]
#[arg(long)]
pub rpc_max_payload: Option<usize>,
/// Set the the maximum RPC request payload size for both HTTP and WS in megabytes.
/// Default is 15MiB.
#[clap(long)]
#[arg(long)]
pub rpc_max_request_size: Option<usize>,
/// Set the the maximum RPC response payload size for both HTTP and WS in megabytes.
/// Default is 15MiB.
#[clap(long)]
#[arg(long)]
pub rpc_max_response_size: Option<usize>,
/// Set the the maximum concurrent subscriptions per connection.
/// Default is 1024.
#[clap(long)]
#[arg(long)]
pub rpc_max_subscriptions_per_connection: Option<usize>,
/// Expose Prometheus exporter on all interfaces.
///
/// Default is local.
#[clap(long)]
#[arg(long)]
pub prometheus_external: bool,
/// DEPRECATED, IPC support has been removed.
#[clap(long, value_name = "PATH")]
#[arg(long, value_name = "PATH")]
pub ipc_path: Option<String>,
/// Specify HTTP RPC server TCP port.
#[clap(long, value_name = "PORT")]
#[arg(long, value_name = "PORT")]
pub rpc_port: Option<u16>,
/// Specify WebSockets RPC server TCP port.
#[clap(long, value_name = "PORT")]
#[arg(long, value_name = "PORT")]
pub ws_port: Option<u16>,
/// Maximum number of WS RPC server connections.
#[clap(long, value_name = "COUNT")]
#[arg(long, value_name = "COUNT")]
pub ws_max_connections: Option<usize>,
/// DEPRECATED, this has no affect anymore. Use `rpc_max_response_size` instead.
#[clap(long)]
#[arg(long)]
pub ws_max_out_buffer_capacity: Option<usize>,
/// Specify browser Origins allowed to access the HTTP & WS RPC servers.
@@ -148,29 +148,29 @@ pub struct RunCmd {
/// value). Value of `all` will disable origin validation. Default is to
/// allow localhost and <https://polkadot.js.org> origins. When running in
/// --dev mode the default is to allow all origins.
#[clap(long, value_name = "ORIGINS", parse(from_str = parse_cors))]
#[arg(long, value_name = "ORIGINS", value_parser = parse_cors)]
pub rpc_cors: Option<Cors>,
/// Specify Prometheus exporter TCP Port.
#[clap(long, value_name = "PORT")]
#[arg(long, value_name = "PORT")]
pub prometheus_port: Option<u16>,
/// Do not expose a Prometheus exporter endpoint.
///
/// Prometheus metric endpoint is enabled by default.
#[clap(long)]
#[arg(long)]
pub no_prometheus: bool,
/// The human-readable name for this node.
///
/// The node name will be reported to the telemetry server, if enabled.
#[clap(long, value_name = "NAME")]
#[arg(long, value_name = "NAME")]
pub name: Option<String>,
/// Disable connecting to the Substrate telemetry server.
///
/// Telemetry is on by default on global chains.
#[clap(long)]
#[arg(long)]
pub no_telemetry: bool,
/// The URL of the telemetry server to connect to.
@@ -179,7 +179,7 @@ pub struct RunCmd {
/// telemetry endpoints. Verbosity levels range from 0-9, with 0 denoting
/// the least verbosity.
/// Expected format is 'URL VERBOSITY', e.g. `--telemetry-url 'wss://foo/bar 0'`.
#[clap(long = "telemetry-url", value_name = "URL VERBOSITY", parse(try_from_str = parse_telemetry_endpoints))]
#[arg(long = "telemetry-url", value_name = "URL VERBOSITY", value_parser = parse_telemetry_endpoints)]
pub telemetry_endpoints: Vec<(String, u8)>,
#[allow(missing_docs)]
@@ -203,40 +203,40 @@ pub struct RunCmd {
pub pool_config: TransactionPoolParams,
/// Shortcut for `--name Alice --validator` with session keys for `Alice` added to keystore.
#[clap(long, conflicts_with_all = &["bob", "charlie", "dave", "eve", "ferdie", "one", "two"])]
#[arg(long, conflicts_with_all = &["bob", "charlie", "dave", "eve", "ferdie", "one", "two"])]
pub alice: bool,
/// Shortcut for `--name Bob --validator` with session keys for `Bob` added to keystore.
#[clap(long, conflicts_with_all = &["alice", "charlie", "dave", "eve", "ferdie", "one", "two"])]
#[arg(long, conflicts_with_all = &["alice", "charlie", "dave", "eve", "ferdie", "one", "two"])]
pub bob: bool,
/// Shortcut for `--name Charlie --validator` with session keys for `Charlie` added to
/// keystore.
#[clap(long, conflicts_with_all = &["alice", "bob", "dave", "eve", "ferdie", "one", "two"])]
#[arg(long, conflicts_with_all = &["alice", "bob", "dave", "eve", "ferdie", "one", "two"])]
pub charlie: bool,
/// Shortcut for `--name Dave --validator` with session keys for `Dave` added to keystore.
#[clap(long, conflicts_with_all = &["alice", "bob", "charlie", "eve", "ferdie", "one", "two"])]
#[arg(long, conflicts_with_all = &["alice", "bob", "charlie", "eve", "ferdie", "one", "two"])]
pub dave: bool,
/// Shortcut for `--name Eve --validator` with session keys for `Eve` added to keystore.
#[clap(long, conflicts_with_all = &["alice", "bob", "charlie", "dave", "ferdie", "one", "two"])]
#[arg(long, conflicts_with_all = &["alice", "bob", "charlie", "dave", "ferdie", "one", "two"])]
pub eve: bool,
/// Shortcut for `--name Ferdie --validator` with session keys for `Ferdie` added to keystore.
#[clap(long, conflicts_with_all = &["alice", "bob", "charlie", "dave", "eve", "one", "two"])]
#[arg(long, conflicts_with_all = &["alice", "bob", "charlie", "dave", "eve", "one", "two"])]
pub ferdie: bool,
/// Shortcut for `--name One --validator` with session keys for `One` added to keystore.
#[clap(long, conflicts_with_all = &["alice", "bob", "charlie", "dave", "eve", "ferdie", "two"])]
#[arg(long, conflicts_with_all = &["alice", "bob", "charlie", "dave", "eve", "ferdie", "two"])]
pub one: bool,
/// Shortcut for `--name Two --validator` with session keys for `Two` added to keystore.
#[clap(long, conflicts_with_all = &["alice", "bob", "charlie", "dave", "eve", "ferdie", "one"])]
#[arg(long, conflicts_with_all = &["alice", "bob", "charlie", "dave", "eve", "ferdie", "one"])]
pub two: bool,
/// Enable authoring even when offline.
#[clap(long)]
#[arg(long)]
pub force_authoring: bool,
#[allow(missing_docs)]
@@ -246,11 +246,11 @@ pub struct RunCmd {
/// The size of the instances cache for each runtime.
///
/// The default value is 8 and the values higher than 256 are ignored.
#[clap(long)]
#[arg(long)]
pub max_runtime_instances: Option<usize>,
/// Maximum number of different runtimes that can be cached.
#[clap(long, default_value = "2")]
#[arg(long, default_value_t = 2)]
pub runtime_cache_size: u8,
/// Run a temporary node.
@@ -262,7 +262,7 @@ pub struct RunCmd {
/// which includes: database, node key and keystore.
///
/// When `--dev` is given and no explicit `--base-path`, this option is implied.
#[clap(long, conflicts_with = "base-path")]
#[arg(long, conflicts_with = "base_path")]
pub tmp: bool,
}
@@ -597,7 +597,7 @@ impl From<Cors> for Option<Vec<String>> {
}
/// Parse cors origins.
fn parse_cors(s: &str) -> Cors {
fn parse_cors(s: &str) -> Result<Cors> {
let mut is_all = false;
let mut origins = Vec::new();
for part in s.split(',') {
@@ -611,9 +611,9 @@ fn parse_cors(s: &str) -> Cors {
}
if is_all {
Cors::All
Ok(Cors::All)
} else {
Cors::List(origins)
Ok(Cors::List(origins))
}
}
+4 -4
View File
@@ -23,21 +23,21 @@ use sp_core::crypto::SecretString;
/// The `sign` command
#[derive(Debug, Clone, Parser)]
#[clap(name = "sign", about = "Sign a message, with a given (secret) key")]
#[command(name = "sign", about = "Sign a message, with a given (secret) key")]
pub struct SignCmd {
/// The secret key URI.
/// If the value is a file, the file content is used as URI.
/// If not given, you will be prompted for the URI.
#[clap(long)]
#[arg(long)]
suri: Option<String>,
/// Message to sign, if not provided you will be prompted to
/// pass the message via STDIN
#[clap(long)]
#[arg(long)]
message: Option<String>,
/// The message on STDIN is hex-encoded data
#[clap(long)]
#[arg(long)]
hex: bool,
#[allow(missing_docs)]
+2 -2
View File
@@ -29,10 +29,10 @@ use utils::print_from_uri;
/// The `vanity` command
#[derive(Debug, Clone, Parser)]
#[clap(name = "vanity", about = "Generate a seed that provides a vanity address")]
#[command(name = "vanity", about = "Generate a seed that provides a vanity address")]
pub struct VanityCmd {
/// Desired pattern
#[clap(long, parse(try_from_str = assert_non_empty_string))]
#[arg(long, value_parser = assert_non_empty_string)]
pattern: String,
#[allow(missing_docs)]
+3 -3
View File
@@ -24,7 +24,7 @@ use sp_core::crypto::{ByteArray, Ss58Codec};
/// The `verify` command
#[derive(Debug, Clone, Parser)]
#[clap(
#[command(
name = "verify",
about = "Verify a signature for a message, provided on STDIN, with a given (public or secret) key"
)]
@@ -39,11 +39,11 @@ pub struct VerifyCmd {
/// Message to verify, if not provided you will be prompted to
/// pass the message via STDIN
#[clap(long)]
#[arg(long)]
message: Option<String>,
/// The message on STDIN is hex-encoded data
#[clap(long)]
#[arg(long)]
hex: bool,
#[allow(missing_docs)]
+7 -11
View File
@@ -129,9 +129,9 @@ pub trait SubstrateCli: Sized {
let about = Self::description();
let app = app
.name(name)
.author(author.as_str())
.about(about.as_str())
.version(full_version.as_str())
.author(author)
.about(about)
.version(full_version)
.propagate_version(true)
.args_conflicts_with_subcommands(true)
.subcommand_negates_reqs(true);
@@ -153,9 +153,9 @@ pub trait SubstrateCli: Sized {
///
/// **NOTE:** This method WILL NOT exit when `--help` or `--version` (or short versions) are
/// used. It will return a [`clap::Error`], where the [`clap::Error::kind`] is a
/// [`clap::ErrorKind::DisplayHelp`] or [`clap::ErrorKind::DisplayVersion`] respectively.
/// You must call [`clap::Error::exit`] or perform a [`std::process::exit`].
fn try_from_iter<I>(iter: I) -> clap::Result<Self>
/// [`clap::error::ErrorKind::DisplayHelp`] or [`clap::error::ErrorKind::DisplayVersion`]
/// respectively. You must call [`clap::Error::exit`] or perform a [`std::process::exit`].
fn try_from_iter<I>(iter: I) -> clap::error::Result<Self>
where
Self: Parser + Sized,
I: IntoIterator,
@@ -169,11 +169,7 @@ pub trait SubstrateCli: Sized {
let name = Self::executable_name();
let author = Self::author();
let about = Self::description();
let app = app
.name(name)
.author(author.as_str())
.about(about.as_str())
.version(full_version.as_str());
let app = app.name(name).author(author).about(about).version(full_version);
let matches = app.try_get_matches_from(iter)?;
@@ -23,17 +23,11 @@ use clap::Args;
#[derive(Debug, Clone, PartialEq, Args)]
pub struct DatabaseParams {
/// Select database backend to use.
#[clap(
long,
alias = "db",
value_name = "DB",
ignore_case = true,
possible_values = Database::variants(),
)]
#[arg(long, alias = "db", value_name = "DB", value_enum)]
pub database: Option<Database>,
/// Limit the memory the database cache can use.
#[clap(long = "db-cache", value_name = "MiB")]
#[arg(long = "db-cache", value_name = "MiB")]
pub database_cache_size: Option<usize>,
}
@@ -42,12 +42,12 @@ pub struct ImportParams {
pub database_params: DatabaseParams,
/// Method for executing Wasm runtime code.
#[clap(
#[arg(
long = "wasm-execution",
value_name = "METHOD",
possible_values = WasmExecutionMethod::variants(),
value_enum,
ignore_case = true,
default_value = DEFAULT_WASM_EXECUTION_METHOD,
default_value_t = DEFAULT_WASM_EXECUTION_METHOD,
)]
pub wasm_method: WasmExecutionMethod,
@@ -64,18 +64,18 @@ pub struct ImportParams {
/// The `legacy-instance-reuse` strategy is deprecated and will
/// be removed in the future. It should only be used in case of
/// issues with the default instantiation strategy.
#[clap(
#[arg(
long,
value_name = "STRATEGY",
default_value_t = DEFAULT_WASMTIME_INSTANTIATION_STRATEGY,
arg_enum,
value_enum,
)]
pub wasmtime_instantiation_strategy: WasmtimeInstantiationStrategy,
/// Specify the path where local WASM runtimes are stored.
///
/// These runtimes will override on-chain runtimes when the version matches.
#[clap(long, value_name = "PATH", parse(from_os_str))]
#[arg(long, value_name = "PATH")]
pub wasm_runtime_overrides: Option<PathBuf>,
#[allow(missing_docs)]
@@ -85,13 +85,13 @@ pub struct ImportParams {
/// Specify the state cache size.
///
/// Providing `0` will disable the cache.
#[clap(long, value_name = "Bytes", default_value = "67108864")]
#[arg(long, value_name = "Bytes", default_value_t = 67108864)]
pub trie_cache_size: usize,
/// DEPRECATED
///
/// Switch to `--trie-cache-size`.
#[clap(long)]
#[arg(long)]
state_cache_size: Option<usize>,
}
@@ -156,39 +156,39 @@ impl ImportParams {
pub struct ExecutionStrategiesParams {
/// The means of execution used when calling into the runtime for importing blocks as
/// part of an initial sync.
#[clap(long, value_name = "STRATEGY", arg_enum, ignore_case = true)]
#[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true)]
pub execution_syncing: Option<ExecutionStrategy>,
/// The means of execution used when calling into the runtime for general block import
/// (including locally authored blocks).
#[clap(long, value_name = "STRATEGY", arg_enum, ignore_case = true)]
#[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true)]
pub execution_import_block: Option<ExecutionStrategy>,
/// The means of execution used when calling into the runtime while constructing blocks.
#[clap(long, value_name = "STRATEGY", arg_enum, ignore_case = true)]
#[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true)]
pub execution_block_construction: Option<ExecutionStrategy>,
/// The means of execution used when calling into the runtime while using an off-chain worker.
#[clap(long, value_name = "STRATEGY", arg_enum, ignore_case = true)]
#[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true)]
pub execution_offchain_worker: Option<ExecutionStrategy>,
/// The means of execution used when calling into the runtime while not syncing, importing or
/// constructing blocks.
#[clap(long, value_name = "STRATEGY", arg_enum, ignore_case = true)]
#[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true)]
pub execution_other: Option<ExecutionStrategy>,
/// The execution strategy that should be used by all execution contexts.
#[clap(
#[arg(
long,
value_name = "STRATEGY",
arg_enum,
value_enum,
ignore_case = true,
conflicts_with_all = &[
"execution-other",
"execution-offchain-worker",
"execution-block-construction",
"execution-import-block",
"execution-syncing",
"execution_other",
"execution_offchain_worker",
"execution_block_construction",
"execution_import_block",
"execution_syncing",
]
)]
pub execution: Option<ExecutionStrategy>,
@@ -32,32 +32,31 @@ const DEFAULT_KEYSTORE_CONFIG_PATH: &str = "keystore";
#[derive(Debug, Clone, Args)]
pub struct KeystoreParams {
/// Specify custom URIs to connect to for keystore-services
#[clap(long)]
#[arg(long)]
pub keystore_uri: Option<String>,
/// Specify custom keystore path.
#[clap(long, value_name = "PATH", parse(from_os_str))]
#[arg(long, value_name = "PATH")]
pub keystore_path: Option<PathBuf>,
/// Use interactive shell for entering the password used by the keystore.
#[clap(long, conflicts_with_all = &["password", "password-filename"])]
#[arg(long, conflicts_with_all = &["password", "password_filename"])]
pub password_interactive: bool,
/// Password used by the keystore. This allows appending an extra user-defined secret to the
/// seed.
#[clap(
#[arg(
long,
parse(try_from_str = secret_string_from_str),
conflicts_with_all = &["password-interactive", "password-filename"]
value_parser = secret_string_from_str,
conflicts_with_all = &["password_interactive", "password_filename"]
)]
pub password: Option<SecretString>,
/// File that contains the password used by the keystore.
#[clap(
#[arg(
long,
value_name = "PATH",
parse(from_os_str),
conflicts_with_all = &["password-interactive", "password"]
conflicts_with_all = &["password_interactive", "password"]
)]
pub password_filename: Option<PathBuf>,
}
+16 -6
View File
@@ -27,7 +27,7 @@ mod transaction_pool_params;
use crate::arg_enums::{CryptoScheme, OutputType};
use clap::Args;
use sp_core::crypto::Ss58AddressFormat;
use sp_core::crypto::{Ss58AddressFormat, Ss58AddressFormatRegistry};
use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, NumberFor},
@@ -40,6 +40,17 @@ pub use crate::params::{
transaction_pool_params::*,
};
/// Parse Ss58AddressFormat
pub fn parse_ss58_address_format(x: &str) -> Result<Ss58AddressFormat, String> {
match Ss58AddressFormatRegistry::try_from(x) {
Ok(format_registry) => Ok(format_registry.into()),
Err(_) => Err(format!(
"Unable to parse variant. Known variants: {:?}",
Ss58AddressFormat::all_names()
)),
}
}
/// Wrapper type of `String` that holds an unsigned integer of arbitrary size, formatted as a
/// decimal.
#[derive(Debug, Clone)]
@@ -118,7 +129,7 @@ impl BlockNumberOrHash {
#[derive(Debug, Clone, Args)]
pub struct CryptoSchemeFlag {
/// cryptography scheme
#[clap(long, value_name = "SCHEME", arg_enum, ignore_case = true, default_value = "sr25519")]
#[arg(long, value_name = "SCHEME", value_enum, ignore_case = true, default_value_t = CryptoScheme::Sr25519)]
pub scheme: CryptoScheme,
}
@@ -126,7 +137,7 @@ pub struct CryptoSchemeFlag {
#[derive(Debug, Clone, Args)]
pub struct OutputTypeFlag {
/// output format
#[clap(long, value_name = "FORMAT", arg_enum, ignore_case = true, default_value = "text")]
#[arg(long, value_name = "FORMAT", value_enum, ignore_case = true, default_value_t = OutputType::Text)]
pub output_type: OutputType,
}
@@ -134,13 +145,12 @@ pub struct OutputTypeFlag {
#[derive(Debug, Clone, Args)]
pub struct NetworkSchemeFlag {
/// network address format
#[clap(
#[arg(
short = 'n',
long,
value_name = "NETWORK",
possible_values = &Ss58AddressFormat::all_names()[..],
ignore_case = true,
parse(try_from_str = Ss58AddressFormat::try_from),
value_parser = parse_ss58_address_format,
)]
pub network: Option<Ss58AddressFormat>,
}
@@ -33,11 +33,11 @@ use std::{borrow::Cow, path::PathBuf};
#[derive(Debug, Clone, Args)]
pub struct NetworkParams {
/// Specify a list of bootnodes.
#[clap(long, value_name = "ADDR", multiple_values(true))]
#[arg(long, value_name = "ADDR", num_args = 1..)]
pub bootnodes: Vec<MultiaddrWithPeerId>,
/// Specify a list of reserved node addresses.
#[clap(long, value_name = "ADDR", multiple_values(true))]
#[arg(long, value_name = "ADDR", num_args = 1..)]
pub reserved_nodes: Vec<MultiaddrWithPeerId>,
/// Whether to only synchronize the chain with reserved nodes.
@@ -48,12 +48,12 @@ pub struct NetworkParams {
/// In particular, if you are a validator your node might still connect to other
/// validator nodes and collator nodes regardless of whether they are defined as
/// reserved nodes.
#[clap(long)]
#[arg(long)]
pub reserved_only: bool,
/// The public address that other nodes will use to connect to it.
/// This can be used if there's a proxy in front of this node.
#[clap(long, value_name = "PUBLIC_ADDR", multiple_values(true))]
#[arg(long, value_name = "PUBLIC_ADDR", num_args = 1..)]
pub public_addr: Vec<Multiaddr>,
/// Listen on this multiaddress.
@@ -61,49 +61,49 @@ pub struct NetworkParams {
/// By default:
/// If `--validator` is passed: `/ip4/0.0.0.0/tcp/<port>` and `/ip6/[::]/tcp/<port>`.
/// Otherwise: `/ip4/0.0.0.0/tcp/<port>/ws` and `/ip6/[::]/tcp/<port>/ws`.
#[clap(long, value_name = "LISTEN_ADDR", multiple_values(true))]
#[arg(long, value_name = "LISTEN_ADDR", num_args = 1..)]
pub listen_addr: Vec<Multiaddr>,
/// Specify p2p protocol TCP port.
#[clap(long, value_name = "PORT", conflicts_with_all = &[ "listen-addr" ])]
#[arg(long, value_name = "PORT", conflicts_with_all = &[ "listen_addr" ])]
pub port: Option<u16>,
/// Always forbid connecting to private IPv4 addresses (as specified in
/// [RFC1918](https://tools.ietf.org/html/rfc1918)), unless the address was passed with
/// `--reserved-nodes` or `--bootnodes`. Enabled by default for chains marked as "live" in
/// their chain specifications.
#[clap(long, conflicts_with_all = &["allow-private-ipv4"])]
#[arg(long, conflicts_with_all = &["allow_private_ipv4"])]
pub no_private_ipv4: bool,
/// Always accept connecting to private IPv4 addresses (as specified in
/// [RFC1918](https://tools.ietf.org/html/rfc1918)). Enabled by default for chains marked as
/// "local" in their chain specifications, or when `--dev` is passed.
#[clap(long, conflicts_with_all = &["no-private-ipv4"])]
#[arg(long, conflicts_with_all = &["no_private_ipv4"])]
pub allow_private_ipv4: bool,
/// Specify the number of outgoing connections we're trying to maintain.
#[clap(long, value_name = "COUNT", default_value = "25")]
#[arg(long, value_name = "COUNT", default_value_t = 25)]
pub out_peers: u32,
/// Maximum number of inbound full nodes peers.
#[clap(long, value_name = "COUNT", default_value = "25")]
#[arg(long, value_name = "COUNT", default_value_t = 25)]
pub in_peers: u32,
/// Maximum number of inbound light nodes peers.
#[clap(long, value_name = "COUNT", default_value = "100")]
#[arg(long, value_name = "COUNT", default_value_t = 100)]
pub in_peers_light: u32,
/// Disable mDNS discovery.
///
/// By default, the network will use mDNS to discover other nodes on the
/// local network. This disables it. Automatically implied when using --dev.
#[clap(long)]
#[arg(long)]
pub no_mdns: bool,
/// Maximum number of peers from which to ask for the same blocks in parallel.
///
/// This allows downloading announced blocks from multiple peers. Decrease to save
/// traffic and risk increased latency.
#[clap(long, value_name = "COUNT", default_value = "5")]
#[arg(long, value_name = "COUNT", default_value_t = 5)]
pub max_parallel_downloads: u32,
#[allow(missing_docs)]
@@ -114,7 +114,7 @@ pub struct NetworkParams {
///
/// By default this option is `true` for `--dev` or when the chain type is
/// `Local`/`Development` and false otherwise.
#[clap(long)]
#[arg(long)]
pub discover_local: bool,
/// Require iterative Kademlia DHT queries to use disjoint paths for increased resiliency in
@@ -122,11 +122,11 @@ pub struct NetworkParams {
///
/// See the S/Kademlia paper for more information on the high level design as well as its
/// security improvements.
#[clap(long)]
#[arg(long)]
pub kademlia_disjoint_query_paths: bool,
/// Join the IPFS network and serve transactions over bitswap protocol.
#[clap(long)]
#[arg(long)]
pub ipfs_server: bool,
/// Blockchain syncing mode.
@@ -135,11 +135,11 @@ pub struct NetworkParams {
/// - `fast`: Download blocks and the latest state only.
/// - `fast-unsafe`: Same as `fast`, but skip downloading state proofs.
/// - `warp`: Download the latest state and proof.
#[clap(
#[arg(
long,
arg_enum,
value_enum,
value_name = "SYNC_MODE",
default_value = "full",
default_value_t = SyncMode::Full,
ignore_case = true,
verbatim_doc_comment
)]
@@ -46,7 +46,7 @@ pub struct NodeKeyParams {
/// WARNING: Secrets provided as command-line arguments are easily exposed.
/// Use of this option should be limited to development and testing. To use
/// an externally managed secret key, use `--node-key-file` instead.
#[clap(long, value_name = "KEY")]
#[arg(long, value_name = "KEY")]
pub node_key: Option<String>,
/// The type of secret key to use for libp2p networking.
@@ -66,7 +66,7 @@ pub struct NodeKeyParams {
///
/// The node's secret key determines the corresponding public key and hence the
/// node's peer ID in the context of libp2p.
#[clap(long, value_name = "TYPE", arg_enum, ignore_case = true, default_value = "ed25519")]
#[arg(long, value_name = "TYPE", value_enum, ignore_case = true, default_value_t = NodeKeyType::Ed25519)]
pub node_key_type: NodeKeyType,
/// The file from which to read the node's secret key to use for libp2p networking.
@@ -79,7 +79,7 @@ pub struct NodeKeyParams {
///
/// If the file does not exist, it is created with a newly generated secret key of
/// the chosen type.
#[clap(long, value_name = "FILE")]
#[arg(long, value_name = "FILE")]
pub node_key_file: Option<PathBuf>,
}
@@ -122,7 +122,7 @@ fn parse_ed25519_secret(hex: &str) -> error::Result<sc_network::config::Ed25519S
#[cfg(test)]
mod tests {
use super::*;
use clap::ArgEnum;
use clap::ValueEnum;
use sc_network::config::identity::{ed25519, Keypair};
use std::fs;
@@ -35,12 +35,12 @@ pub struct OffchainWorkerParams {
/// Should execute offchain workers on every block.
///
/// By default it's only enabled for nodes that are authoring new blocks.
#[clap(
#[arg(
long = "offchain-worker",
value_name = "ENABLED",
arg_enum,
value_enum,
ignore_case = true,
default_value = "when-validating"
default_value_t = OffchainWorkerEnabled::WhenValidating
)]
pub enabled: OffchainWorkerEnabled,
@@ -48,7 +48,7 @@ pub struct OffchainWorkerParams {
///
/// Enables a runtime to write directly to a offchain workers
/// DB during block import.
#[clap(long = "enable-offchain-indexing", value_name = "ENABLE_OFFCHAIN_INDEXING")]
#[arg(long = "enable-offchain-indexing", value_name = "ENABLE_OFFCHAIN_INDEXING")]
pub indexing_enabled: bool,
}
@@ -28,7 +28,7 @@ pub struct PruningParams {
/// Default is to keep only the last 256 blocks,
/// otherwise, the state can be kept for all of the blocks (i.e 'archive'),
/// or for all of the canonical blocks (i.e 'archive-canonical').
#[clap(alias = "pruning", long, value_name = "PRUNING_MODE")]
#[arg(alias = "pruning", long, value_name = "PRUNING_MODE")]
pub state_pruning: Option<String>,
/// Specify the blocks pruning mode, a number of blocks to keep or 'archive'.
///
@@ -38,7 +38,7 @@ pub struct PruningParams {
/// or for the last N blocks (i.e a number).
///
/// NOTE: only finalized blocks are subject for removal!
#[clap(alias = "keep-blocks", long, value_name = "COUNT")]
#[arg(alias = "keep-blocks", long, value_name = "COUNT")]
pub blocks_pruning: Option<String>,
}
@@ -28,25 +28,25 @@ pub struct SharedParams {
///
/// It can be one of the predefined ones (dev, local, or staging) or it can be a path to a file
/// with the chainspec (such as one exported by the `build-spec` subcommand).
#[clap(long, value_name = "CHAIN_SPEC")]
#[arg(long, value_name = "CHAIN_SPEC")]
pub chain: Option<String>,
/// Specify the development chain.
///
/// This flag sets `--chain=dev`, `--force-authoring`, `--rpc-cors=all`,
/// `--alice`, and `--tmp` flags, unless explicitly overridden.
#[clap(long, conflicts_with_all = &["chain"])]
#[arg(long, conflicts_with_all = &["chain"])]
pub dev: bool,
/// Specify custom base path.
#[clap(long, short = 'd', value_name = "PATH", parse(from_os_str))]
#[arg(long, short = 'd', value_name = "PATH")]
pub base_path: Option<PathBuf>,
/// Sets a custom logging filter. Syntax is <target>=<level>, e.g. -lsync=debug.
///
/// Log levels (least to most verbose) are error, warn, info, debug, and trace.
/// By default, all targets log `info`. The global log level can be set with -l<level>.
#[clap(short = 'l', long, value_name = "LOG_PATTERN", multiple_values(true))]
#[arg(short = 'l', long, value_name = "LOG_PATTERN", num_args = 1..)]
pub log: Vec<String>,
/// Enable detailed log output.
@@ -54,11 +54,11 @@ pub struct SharedParams {
/// This includes displaying the log target, log level and thread name.
///
/// This is automatically enabled when something is logged with any higher level than `info`.
#[clap(long)]
#[arg(long)]
pub detailed_log_output: bool,
/// Disable log color output.
#[clap(long)]
#[arg(long)]
pub disable_log_color: bool,
/// Enable feature to dynamically update and reload the log filter.
@@ -68,15 +68,15 @@ pub struct SharedParams {
///
/// The `system_addLogFilter` and `system_resetLogFilter` RPCs will have no effect with this
/// option not being set.
#[clap(long)]
#[arg(long)]
pub enable_log_reloading: bool,
/// Sets a custom profiling filter. Syntax is the same as for logging: <target>=<level>
#[clap(long, value_name = "TARGETS")]
#[arg(long, value_name = "TARGETS")]
pub tracing_targets: Option<String>,
/// Receiver to process tracing messages.
#[clap(long, value_name = "RECEIVER", arg_enum, ignore_case = true, default_value = "log")]
#[arg(long, value_name = "RECEIVER", value_enum, ignore_case = true, default_value_t = TracingReceiver::Log)]
pub tracing_receiver: TracingReceiver,
}
@@ -23,15 +23,15 @@ use sc_service::config::TransactionPoolOptions;
#[derive(Debug, Clone, Args)]
pub struct TransactionPoolParams {
/// Maximum number of transactions in the transaction pool.
#[clap(long, value_name = "COUNT", default_value = "8192")]
#[arg(long, value_name = "COUNT", default_value_t = 8192)]
pub pool_limit: usize,
/// Maximum number of kilobytes of all transactions stored in the pool.
#[clap(long, value_name = "COUNT", default_value = "20480")]
#[arg(long, value_name = "COUNT", default_value_t = 20480)]
pub pool_kbytes: usize,
/// How long a transaction is banned for, if it is considered invalid. Defaults to 1800s.
#[clap(long, value_name = "SECONDS")]
#[arg(long, value_name = "SECONDS")]
pub tx_ban_seconds: Option<u64>,
}