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
61 changes: 49 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
28 changes: 14 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 @@ -90,15 +90,15 @@ pub struct RunCmd {
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 +107,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 +135,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
8 changes: 4 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 @@ -47,14 +47,14 @@ pub struct RunCmd {
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
Loading