Update clap to version 4 (#6128)

* Move clap to 4.0.9

* Remove "deprecated" feature flag

* Convert to default_value_t

* update lockfile for {"substrate"}

* Add group(skip) to avoid naming conflict

* More group(skip)

Co-authored-by: parity-processbot <>
This commit is contained in:
Sebastian Kunert
2022-10-18 11:02:41 +02:00
committed by GitHub
parent 7339fb92f2
commit 99f705537b
17 changed files with 405 additions and 728 deletions
+322 -646
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -14,7 +14,7 @@ wasm-opt = false
crate-type = ["cdylib", "rlib"]
[dependencies]
clap = { version = "3.1", features = ["derive"], optional = true }
clap = { version = "4.0.9", features = ["derive"], optional = true }
log = "0.4.17"
thiserror = "1.0.31"
futures = "0.3.21"
+15 -14
View File
@@ -43,16 +43,16 @@ pub enum Subcommand {
Revert(sc_cli::RevertCmd),
#[allow(missing_docs)]
#[clap(name = "prepare-worker", hide = true)]
#[command(name = "prepare-worker", hide = true)]
PvfPrepareWorker(ValidationWorkerCommand),
#[allow(missing_docs)]
#[clap(name = "execute-worker", hide = true)]
#[command(name = "execute-worker", hide = true)]
PvfExecuteWorker(ValidationWorkerCommand),
/// Sub-commands concerned with benchmarking.
/// The pallet benchmarking moved to the `pallet` sub-command.
#[clap(subcommand)]
#[command(subcommand)]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
/// Runs performance checks such as PVF compilation in order to measure machine
@@ -68,7 +68,7 @@ pub enum Subcommand {
TryRuntime,
/// Key management CLI utilities
#[clap(subcommand)]
#[command(subcommand)]
Key(sc_cli::KeySubcommand),
/// Db meta columns information.
@@ -84,21 +84,22 @@ pub struct ValidationWorkerCommand {
#[allow(missing_docs)]
#[derive(Debug, Parser)]
#[group(skip)]
pub struct RunCmd {
#[allow(missing_docs)]
#[clap(flatten)]
pub base: sc_cli::RunCmd,
/// Force using Kusama native runtime.
#[clap(long = "force-kusama")]
#[arg(long = "force-kusama")]
pub force_kusama: bool,
/// Force using Westend native runtime.
#[clap(long = "force-westend")]
#[arg(long = "force-westend")]
pub force_westend: bool,
/// Force using Rococo native runtime.
#[clap(long = "force-rococo")]
#[arg(long = "force-rococo")]
pub force_rococo: bool,
/// Setup a GRANDPA scheduled voting pause.
@@ -107,25 +108,25 @@ pub struct RunCmd {
/// blocks). After the given block number is finalized the GRANDPA voter
/// will temporarily stop voting for new blocks until the given delay has
/// elapsed (i.e. until a block at height `pause_block + delay` is imported).
#[clap(long = "grandpa-pause", number_of_values(2))]
#[arg(long = "grandpa-pause", num_args = 2)]
pub grandpa_pause: Vec<u32>,
/// Enable the BEEFY gadget (only on Rococo or Wococo for now).
#[clap(long)]
#[arg(long)]
pub beefy: bool,
/// Add the destination address to the jaeger agent.
///
/// Must be valid socket address, of format `IP:Port`
/// commonly `127.0.0.1:6831`.
#[clap(long)]
#[arg(long)]
pub jaeger_agent: Option<String>,
/// Add the destination address to the `pyroscope` agent.
///
/// Must be valid socket address, of format `IP:Port`
/// commonly `127.0.0.1:4040`.
#[clap(long)]
#[arg(long)]
pub pyroscope_server: Option<String>,
/// Disable automatic hardware benchmarks.
@@ -135,20 +136,20 @@ pub struct RunCmd {
///
/// The results are then printed out in the logs, and also sent as part of
/// telemetry, if telemetry is enabled.
#[clap(long)]
#[arg(long)]
pub no_hardware_benchmarks: bool,
/// Overseer message capacity override.
///
/// **Dangerous!** Do not touch unless explicitly adviced to.
#[clap(long)]
#[arg(long)]
pub overseer_channel_capacity_override: Option<usize>,
}
#[allow(missing_docs)]
#[derive(Debug, Parser)]
pub struct Cli {
#[clap(subcommand)]
#[command(subcommand)]
pub subcommand: Option<Subcommand>,
#[clap(flatten)]
pub run: RunCmd,
+1 -1
View File
@@ -29,7 +29,7 @@ assert_matches = "1.5"
async-trait = "0.1.57"
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
clap = { version = "3.2.21", features = ["derive"] }
clap = { version = "4.0.9", features = ["derive"] }
futures = "0.3.21"
futures-timer = "3.0.2"
gum = { package = "tracing-gum", path = "../gum/" }
+4 -5
View File
@@ -28,8 +28,7 @@ use variants::*;
/// Define the different variants of behavior.
#[derive(Debug, Parser)]
#[clap(about = "Malus - the nemesis of polkadot.", version)]
#[clap(rename_all = "kebab-case")]
#[command(about = "Malus - the nemesis of polkadot.", version, rename_all = "kebab-case")]
enum NemesisVariant {
/// Suggest a candidate with an invalid proof of validity.
SuggestGarbageCandidate(SuggestGarbageCandidateOptions),
@@ -39,18 +38,18 @@ enum NemesisVariant {
DisputeAncestor(DisputeAncestorOptions),
#[allow(missing_docs)]
#[clap(name = "prepare-worker", hide = true)]
#[command(name = "prepare-worker", hide = true)]
PvfPrepareWorker(polkadot_cli::ValidationWorkerCommand),
#[allow(missing_docs)]
#[clap(name = "execute-worker", hide = true)]
#[command(name = "execute-worker", hide = true)]
PvfExecuteWorker(polkadot_cli::ValidationWorkerCommand),
}
#[derive(Debug, Parser)]
#[allow(missing_docs)]
struct MalusCli {
#[clap(subcommand)]
#[command(subcommand)]
pub variant: NemesisVariant,
/// Sets the minimum delay between the best and finalized block.
pub finality_delay: Option<u32>,
+4 -5
View File
@@ -33,11 +33,10 @@ use polkadot_primitives::v2::{
};
use futures::channel::oneshot;
use rand::distributions::{Bernoulli, Distribution};
#[derive(clap::ArgEnum, Clone, Copy, Debug, PartialEq)]
#[clap(rename_all = "kebab-case")]
#[derive(clap::ValueEnum, Clone, Copy, Debug, PartialEq)]
#[value(rename_all = "kebab-case")]
#[non_exhaustive]
pub enum FakeCandidateValidation {
Disabled,
@@ -50,8 +49,8 @@ pub enum FakeCandidateValidation {
}
/// Candidate invalidity details
#[derive(clap::ArgEnum, Clone, Copy, Debug, PartialEq)]
#[clap(rename_all = "kebab-case")]
#[derive(clap::ValueEnum, Clone, Copy, Debug, PartialEq)]
#[value(rename_all = "kebab-case")]
pub enum FakeCandidateValidationError {
/// Validation outputs check doesn't pass.
InvalidOutputs,
@@ -41,18 +41,18 @@ use crate::{interceptor::*, variants::ReplaceValidationResult};
use std::sync::Arc;
#[derive(Debug, clap::Parser)]
#[clap(rename_all = "kebab-case")]
#[command(rename_all = "kebab-case")]
#[allow(missing_docs)]
pub struct DisputeAncestorOptions {
/// Malicious candidate validation subsystem configuration. When enabled, node PVF execution is skipped
/// during backing and/or approval and it's result can by specified by this option and `--fake-validation-error`
/// for invalid candidate outcomes.
#[clap(long, arg_enum, ignore_case = true, default_value_t = FakeCandidateValidation::BackingAndApprovalInvalid)]
#[arg(long, value_enum, ignore_case = true, default_value_t = FakeCandidateValidation::BackingAndApprovalInvalid)]
pub fake_validation: FakeCandidateValidation,
/// Applies only when `--fake-validation` is configured to reject candidates as invalid. It allows
/// to specify the exact error to return from the malicious candidate validation subsystem.
#[clap(long, arg_enum, ignore_case = true, default_value_t = FakeCandidateValidationError::InvalidOutputs)]
#[arg(long, value_enum, ignore_case = true, default_value_t = FakeCandidateValidationError::InvalidOutputs)]
pub fake_validation_error: FakeCandidateValidationError,
/// Determines the percentage of candidates that should be disputed. Allows for fine-tuning
@@ -15,7 +15,7 @@ path = "bin/puppet_worker.rs"
[dependencies]
parity-scale-codec = { version = "3.1.5", default-features = false, features = ["derive"] }
clap = { version = "3.1", features = ["derive"] }
clap = { version = "4.0.9", features = ["derive"] }
futures = "0.3.21"
futures-timer = "3.0.2"
log = "0.4.17"
@@ -23,11 +23,11 @@ use sc_cli::{RuntimeVersion, SubstrateCli};
#[derive(Debug, Parser)]
pub enum Subcommand {
/// Export the genesis state of the parachain.
#[clap(name = "export-genesis-state")]
#[command(name = "export-genesis-state")]
ExportGenesisState(ExportGenesisStateCommand),
/// Export the genesis wasm of the parachain.
#[clap(name = "export-genesis-wasm")]
#[command(name = "export-genesis-wasm")]
ExportGenesisWasm(ExportGenesisWasmCommand),
}
@@ -41,20 +41,21 @@ pub struct ExportGenesisWasmCommand {}
#[allow(missing_docs)]
#[derive(Debug, Parser)]
#[group(skip)]
pub struct RunCmd {
#[allow(missing_docs)]
#[clap(flatten)]
pub base: sc_cli::RunCmd,
/// Id of the parachain this collator collates for.
#[clap(long)]
#[arg(long)]
pub parachain_id: Option<u32>,
}
#[allow(missing_docs)]
#[derive(Debug, Parser)]
pub struct Cli {
#[clap(subcommand)]
#[command(subcommand)]
pub subcommand: Option<Subcommand>,
#[clap(flatten)]
@@ -15,7 +15,7 @@ path = "bin/puppet_worker.rs"
[dependencies]
parity-scale-codec = { version = "3.1.5", default-features = false, features = ["derive"] }
clap = { version = "3.1", features = ["derive"] }
clap = { version = "4.0.9", features = ["derive"] }
futures = "0.3.19"
futures-timer = "3.0.2"
log = "0.4.17"
@@ -23,11 +23,11 @@ use sc_cli::{RuntimeVersion, SubstrateCli};
#[derive(Debug, Parser)]
pub enum Subcommand {
/// Export the genesis state of the parachain.
#[clap(name = "export-genesis-state")]
#[command(name = "export-genesis-state")]
ExportGenesisState(ExportGenesisStateCommand),
/// Export the genesis wasm of the parachain.
#[clap(name = "export-genesis-wasm")]
#[command(name = "export-genesis-wasm")]
ExportGenesisWasm(ExportGenesisWasmCommand),
}
@@ -35,16 +35,16 @@ pub enum Subcommand {
#[derive(Debug, Parser)]
pub struct ExportGenesisStateCommand {
/// Id of the parachain this collator collates for.
#[clap(long, default_value = "100")]
#[arg(long, default_value_t = 100)]
pub parachain_id: u32,
/// The target raw PoV size in bytes. Minimum value is 64.
#[clap(long, default_value = "1024")]
#[arg(long, default_value_t = 1024)]
pub pov_size: usize,
/// The PVF execution complexity. Actually specifies how many iterations/signatures
/// we compute per block.
#[clap(long, default_value = "1")]
#[arg(long, default_value_t = 1)]
pub pvf_complexity: u32,
}
@@ -54,29 +54,30 @@ pub struct ExportGenesisWasmCommand {}
#[allow(missing_docs)]
#[derive(Debug, Parser)]
#[group(skip)]
pub struct RunCmd {
#[allow(missing_docs)]
#[clap(flatten)]
pub base: sc_cli::RunCmd,
/// Id of the parachain this collator collates for.
#[clap(long, default_value = "2000")]
#[arg(long, default_value_t = 2000)]
pub parachain_id: u32,
/// The target raw PoV size in bytes. Minimum value is 64.
#[clap(long, default_value = "1024")]
#[arg(long, default_value_t = 1024)]
pub pov_size: usize,
/// The PVF execution complexity. Actually specifies how many iterations/signatures
/// we compute per block.
#[clap(long, default_value = "1")]
#[arg(long, default_value_t = 1)]
pub pvf_complexity: u32,
}
#[allow(missing_docs)]
#[derive(Debug, Parser)]
pub struct Cli {
#[clap(subcommand)]
#[command(subcommand)]
pub subcommand: Option<Subcommand>,
#[clap(flatten)]
+1 -1
View File
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
[dependencies]
clap = { version = "3.1", features = ["derive"] }
clap = { version = "4.0.9", features = ["derive"] }
generate-bags = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" }
+7 -7
View File
@@ -20,15 +20,15 @@
//! touched again. It can be reused to regenerate a wholly different
//! quantity of bags, or if the existential deposit changes, etc.
use clap::{ArgEnum, Parser};
use clap::{Parser, ValueEnum};
use generate_bags::generate_thresholds;
use kusama_runtime::Runtime as KusamaRuntime;
use polkadot_runtime::Runtime as PolkadotRuntime;
use std::path::{Path, PathBuf};
use westend_runtime::Runtime as WestendRuntime;
#[derive(Clone, Debug, ArgEnum)]
#[clap(rename_all = "PascalCase")]
#[derive(Clone, Debug, ValueEnum)]
#[value(rename_all = "PascalCase")]
enum Runtime {
Westend,
Kusama,
@@ -50,22 +50,22 @@ impl Runtime {
#[derive(Debug, Parser)]
struct Opt {
/// How many bags to generate.
#[clap(long, default_value = "200")]
#[arg(long, default_value_t = 200)]
n_bags: usize,
/// Which runtime to generate.
#[clap(long, ignore_case = true, arg_enum, default_value = "Polkadot")]
#[arg(long, ignore_case = true, value_enum, default_value_t = Runtime::Polkadot)]
runtime: Runtime,
/// Where to write the output.
output: PathBuf,
/// The total issuance of the native currency.
#[clap(short, long)]
#[arg(short, long)]
total_issuance: u128,
/// The minimum account balance (i.e. existential deposit) for the native currency.
#[clap(short, long)]
#[arg(short, long)]
minimum_balance: u128,
}
@@ -17,6 +17,6 @@ sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "master
frame-system = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
clap = { version = "3.1", features = ["derive"] }
clap = { version = "4.0.9", features = ["derive"] }
log = "0.4.17"
tokio = { version = "1.19.2", features = ["macros"] }
@@ -16,18 +16,18 @@
//! Remote tests for bags-list pallet.
use clap::{ArgEnum, Parser};
use clap::{Parser, ValueEnum};
#[derive(Clone, Debug, ArgEnum)]
#[clap(rename_all = "PascalCase")]
#[derive(Clone, Debug, ValueEnum)]
#[value(rename_all = "PascalCase")]
enum Command {
CheckMigration,
SanityCheck,
Snapshot,
}
#[derive(Clone, Debug, ArgEnum)]
#[clap(rename_all = "PascalCase")]
#[derive(Clone, Debug, ValueEnum)]
#[value(rename_all = "PascalCase")]
enum Runtime {
Polkadot,
Kusama,
@@ -36,13 +36,13 @@ enum Runtime {
#[derive(Parser)]
struct Cli {
#[clap(long, short, default_value = "wss://kusama-rpc.polkadot.io:443")]
#[arg(long, short, default_value = "wss://kusama-rpc.polkadot.io:443")]
uri: String,
#[clap(long, short, ignore_case = true, arg_enum, default_value = "kusama")]
#[arg(long, short, ignore_case = true, value_enum, default_value_t = Runtime::Kusama)]
runtime: Runtime,
#[clap(long, short, ignore_case = true, arg_enum, default_value = "SanityCheck")]
#[arg(long, short, ignore_case = true, value_enum, default_value_t = Command::SanityCheck)]
command: Command,
#[clap(long, short)]
#[arg(long, short)]
snapshot_limit: Option<usize>,
}
+1 -1
View File
@@ -6,7 +6,7 @@ edition = "2021"
[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0" }
clap = { version = "3.1", features = ["derive", "env"] }
clap = { version = "4.0.9", features = ["derive", "env"] }
tracing-subscriber = { version = "0.3.11", features = ["env-filter"] }
jsonrpsee = { version = "0.15.1", features = ["ws-client", "macros"] }
log = "0.4.17"
+19 -19
View File
@@ -21,21 +21,21 @@ use std::str::FromStr;
#[derive(Debug, Clone, Parser)]
#[cfg_attr(test, derive(PartialEq))]
#[clap(author, version, about)]
#[command(author, version, about)]
pub(crate) struct Opt {
/// The `ws` node to connect to.
#[clap(long, short, default_value = DEFAULT_URI, env = "URI", global = true)]
#[arg(long, short, default_value = DEFAULT_URI, env = "URI", global = true)]
pub uri: String,
/// WS connection timeout in number of seconds.
#[clap(long, parse(try_from_str), default_value_t = 60)]
#[arg(long, default_value_t = 60)]
pub connection_timeout: usize,
/// WS request timeout in number of seconds.
#[clap(long, parse(try_from_str), default_value_t = 60 * 10)]
#[arg(long, default_value_t = 60 * 10)]
pub request_timeout: usize,
#[clap(subcommand)]
#[command(subcommand)]
pub command: Command,
}
@@ -65,7 +65,7 @@ pub(crate) struct MonitorConfig {
///
/// WARNING: Don't use an account with a large stash for this. Based on how the bot is
/// configured, it might re-try and lose funds through transaction fees/deposits.
#[clap(long, short, env = "SEED")]
#[arg(long, short, env = "SEED")]
pub seed_or_path: String,
/// They type of event to listen to.
@@ -73,11 +73,11 @@ pub(crate) struct MonitorConfig {
/// Typically, finalized is safer and there is no chance of anything going wrong, but it can be
/// slower. It is recommended to use finalized, if the duration of the signed phase is longer
/// than the the finality delay.
#[clap(long, default_value = "head", possible_values = &["head", "finalized"])]
#[arg(long, default_value = "head", value_parser = ["head", "finalized"])]
pub listen: String,
/// The solver algorithm to use.
#[clap(subcommand)]
#[command(subcommand)]
pub solver: Solver,
/// Submission strategy to use.
@@ -89,7 +89,7 @@ pub(crate) struct MonitorConfig {
/// `--submission-strategy always`: always submit.
///
/// `--submission-strategy "percent-better <percent>"`: submit if the submission is `n` percent better.
#[clap(long, parse(try_from_str), default_value = "if-leading")]
#[arg(long, default_value = "if-leading")]
pub submission_strategy: SubmissionStrategy,
/// Delay in number seconds to wait until starting mining a solution.
@@ -100,7 +100,7 @@ pub(crate) struct MonitorConfig {
///
/// When this is enabled and there are competing solutions, your solution might not be submitted
/// if the scores are equal.
#[clap(long, parse(try_from_str), default_value_t = 0)]
#[arg(long, default_value_t = 0)]
pub delay: usize,
}
@@ -114,19 +114,19 @@ pub(crate) struct DryRunConfig {
///
/// WARNING: Don't use an account with a large stash for this. Based on how the bot is
/// configured, it might re-try and lose funds through transaction fees/deposits.
#[clap(long, short, env = "SEED")]
#[arg(long, short, env = "SEED")]
pub seed_or_path: String,
/// The block hash at which scraping happens. If none is provided, the latest head is used.
#[clap(long)]
#[arg(long)]
pub at: Option<Hash>,
/// The solver algorithm to use.
#[clap(subcommand)]
#[command(subcommand)]
pub solver: Solver,
/// Force create a new snapshot, else expect one to exist onchain.
#[clap(long)]
#[arg(long)]
pub force_snapshot: bool,
}
@@ -134,11 +134,11 @@ pub(crate) struct DryRunConfig {
#[cfg_attr(test, derive(PartialEq))]
pub(crate) struct EmergencySolutionConfig {
/// The block hash at which scraping happens. If none is provided, the latest head is used.
#[clap(long)]
#[arg(long)]
pub at: Option<Hash>,
/// The solver algorithm to use.
#[clap(subcommand)]
#[command(subcommand)]
pub solver: Solver,
/// The number of top backed winners to take. All are taken, if not provided.
@@ -149,7 +149,7 @@ pub(crate) struct EmergencySolutionConfig {
#[cfg_attr(test, derive(PartialEq))]
pub(crate) struct InfoOpts {
/// Serialize the output as json
#[clap(long, short)]
#[arg(long, short)]
pub json: bool,
}
@@ -170,11 +170,11 @@ pub enum SubmissionStrategy {
#[cfg_attr(test, derive(PartialEq))]
pub(crate) enum Solver {
SeqPhragmen {
#[clap(long, default_value = "10")]
#[arg(long, default_value_t = 10)]
iterations: usize,
},
PhragMMS {
#[clap(long, default_value = "10")]
#[arg(long, default_value_t = 10)]
iterations: usize,
},
}