Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Update clap to version 4 #6128

Merged
merged 11 commits into from
Oct 18, 2022
948 changes: 312 additions & 636 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
29 changes: 15 additions & 14 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -68,7 +68,7 @@ pub enum Subcommand {
TryRuntime,

/// Key management CLI utilities
#[clap(subcommand)]
#[command(subcommand)]
Key(sc_cli::KeySubcommand),

/// Db meta columns information.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion node/malus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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/" }
Expand Down
9 changes: 4 additions & 5 deletions node/malus/src/malus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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>,
Expand Down
9 changes: 4 additions & 5 deletions node/malus/src/variants/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions node/malus/src/variants/dispute_valid_candidates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion parachain/test-parachains/adder/collator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 5 additions & 4 deletions parachain/test-parachains/adder/collator/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}

Expand All @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion parachain/test-parachains/undying/collator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
19 changes: 10 additions & 9 deletions parachain/test-parachains/undying/collator/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,28 @@ 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),
}

/// Command for exporting the genesis state of the parachain
#[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,
}

Expand All @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion utils/generate-bags/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
14 changes: 7 additions & 7 deletions utils/generate-bags/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
}

Expand Down
2 changes: 1 addition & 1 deletion utils/remote-ext-tests/bags-list/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Loading