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