Companion for substrate#10632 (#4689)

* Companion for substrate#10632

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* cargo format

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Fix bags-list

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Update Substrate

* Fix

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Fix bridges test

* FMT

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
Qinxuan Chen
2022-01-25 18:58:17 +08:00
committed by GitHub
parent 6b7e40cd6c
commit f4ec9b0341
14 changed files with 335 additions and 358 deletions
+216 -229
View File
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -649,11 +649,12 @@ mod tests {
fn should_fail_on_weight_mismatch() { fn should_fail_on_weight_mismatch() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
let id = [0; 4]; let id = [0; 4];
let call = Call::System(frame_system::Call::remark { remark: vec![1, 2, 3] }); let call =
Call::System(frame_system::Call::remark_with_event { remark: vec![1, 2, 3] });
let call_weight = call.get_dispatch_info().weight; let call_weight = call.get_dispatch_info().weight;
let mut message = prepare_root_message(call); let mut message = prepare_root_message(call);
message.weight = 7; message.weight = 7;
assert!(call_weight != 7, "needed for test to actually trigger a weight mismatch"); assert!(call_weight > 7, "needed for test to actually trigger a weight mismatch");
System::set_block_number(1); System::set_block_number(1);
let result = Dispatch::dispatch( let result = Dispatch::dispatch(
+2 -2
View File
@@ -14,9 +14,9 @@ wasm-opt = false
crate-type = ["cdylib", "rlib"] crate-type = ["cdylib", "rlib"]
[dependencies] [dependencies]
clap = { version = "3.0", features = ["derive"], optional = true }
log = "0.4.13" log = "0.4.13"
thiserror = "1.0.30" thiserror = "1.0.30"
structopt = { version = "0.3.25", optional = true }
futures = "0.3.19" futures = "0.3.19"
service = { package = "polkadot-service", path = "../node/service", default-features = false, optional = true } service = { package = "polkadot-service", path = "../node/service", default-features = false, optional = true }
@@ -43,7 +43,7 @@ default = [ "wasmtime", "db", "cli", "full-node", "trie-memory-tracker", "polkad
wasmtime = ["sc-cli/wasmtime"] wasmtime = ["sc-cli/wasmtime"]
db = ["service/db"] db = ["service/db"]
cli = [ cli = [
"structopt", "clap",
"sc-cli", "sc-cli",
"sc-service", "sc-service",
"sc-tracing", "sc-tracing",
+18 -17
View File
@@ -16,10 +16,10 @@
//! Polkadot CLI library. //! Polkadot CLI library.
use structopt::StructOpt; use clap::{AppSettings, Parser};
#[allow(missing_docs)] #[allow(missing_docs)]
#[derive(Debug, StructOpt)] #[derive(Debug, Parser)]
pub enum Subcommand { pub enum Subcommand {
/// Build a chain specification. /// Build a chain specification.
BuildSpec(sc_cli::BuildSpecCmd), BuildSpec(sc_cli::BuildSpecCmd),
@@ -43,15 +43,15 @@ pub enum Subcommand {
Revert(sc_cli::RevertCmd), Revert(sc_cli::RevertCmd),
#[allow(missing_docs)] #[allow(missing_docs)]
#[structopt(name = "prepare-worker", setting = structopt::clap::AppSettings::Hidden)] #[clap(name = "prepare-worker", setting = AppSettings::Hidden)]
PvfPrepareWorker(ValidationWorkerCommand), PvfPrepareWorker(ValidationWorkerCommand),
#[allow(missing_docs)] #[allow(missing_docs)]
#[structopt(name = "execute-worker", setting = structopt::clap::AppSettings::Hidden)] #[clap(name = "execute-worker", setting = AppSettings::Hidden)]
PvfExecuteWorker(ValidationWorkerCommand), PvfExecuteWorker(ValidationWorkerCommand),
/// The custom benchmark subcommand benchmarking runtime pallets. /// The custom benchmark subcommand benchmarking runtime pallets.
#[structopt(name = "benchmark", about = "Benchmark runtime pallets.")] #[clap(name = "benchmark", about = "Benchmark runtime pallets.")]
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
@@ -67,33 +67,34 @@ pub enum Subcommand {
TryRuntime, TryRuntime,
/// Key management CLI utilities /// Key management CLI utilities
#[clap(subcommand)]
Key(sc_cli::KeySubcommand), Key(sc_cli::KeySubcommand),
} }
#[allow(missing_docs)] #[allow(missing_docs)]
#[derive(Debug, StructOpt)] #[derive(Debug, Parser)]
pub struct ValidationWorkerCommand { pub struct ValidationWorkerCommand {
/// The path to the validation host's socket. /// The path to the validation host's socket.
pub socket_path: String, pub socket_path: String,
} }
#[allow(missing_docs)] #[allow(missing_docs)]
#[derive(Debug, StructOpt)] #[derive(Debug, Parser)]
pub struct RunCmd { pub struct RunCmd {
#[allow(missing_docs)] #[allow(missing_docs)]
#[structopt(flatten)] #[clap(flatten)]
pub base: sc_cli::RunCmd, pub base: sc_cli::RunCmd,
/// Force using Kusama native runtime. /// Force using Kusama native runtime.
#[structopt(long = "force-kusama")] #[clap(long = "force-kusama")]
pub force_kusama: bool, pub force_kusama: bool,
/// Force using Westend native runtime. /// Force using Westend native runtime.
#[structopt(long = "force-westend")] #[clap(long = "force-westend")]
pub force_westend: bool, pub force_westend: bool,
/// Force using Rococo native runtime. /// Force using Rococo native runtime.
#[structopt(long = "force-rococo")] #[clap(long = "force-rococo")]
pub force_rococo: bool, pub force_rococo: bool,
/// Setup a GRANDPA scheduled voting pause. /// Setup a GRANDPA scheduled voting pause.
@@ -102,26 +103,26 @@ 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).
#[structopt(long = "grandpa-pause", number_of_values(2))] #[clap(long = "grandpa-pause", number_of_values(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).
#[structopt(long)] #[clap(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`.
#[structopt(long)] #[clap(long)]
pub jaeger_agent: Option<std::net::SocketAddr>, pub jaeger_agent: Option<std::net::SocketAddr>,
} }
#[allow(missing_docs)] #[allow(missing_docs)]
#[derive(Debug, StructOpt)] #[derive(Debug, Parser)]
pub struct Cli { pub struct Cli {
#[structopt(subcommand)] #[clap(subcommand)]
pub subcommand: Option<Subcommand>, pub subcommand: Option<Subcommand>,
#[structopt(flatten)] #[clap(flatten)]
pub run: RunCmd, pub run: RunCmd,
} }
+1 -1
View File
@@ -26,9 +26,9 @@ polkadot-node-core-pvf = { path = "../core/pvf" }
parity-util-mem = { version = "0.10.0", default-features = false, features = ["jemalloc-global"] } parity-util-mem = { version = "0.10.0", default-features = false, features = ["jemalloc-global"] }
color-eyre = { version = "0.5.11", default-features = false } color-eyre = { version = "0.5.11", default-features = false }
assert_matches = "1.5" assert_matches = "1.5"
structopt = "0.3.25"
async-trait = "0.1.52" async-trait = "0.1.52"
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
clap = { version = "3.0", features = ["derive"] }
futures = "0.3.19" futures = "0.3.19"
futures-timer = "3.0.2" futures-timer = "3.0.2"
tracing = "0.1.26" tracing = "0.1.26"
+10 -10
View File
@@ -16,9 +16,9 @@
//! A malus or nemesis node launch code. //! A malus or nemesis node launch code.
use clap::{AppSettings, Parser};
use color_eyre::eyre; use color_eyre::eyre;
use polkadot_cli::{Cli, RunCmd}; use polkadot_cli::{Cli, RunCmd};
use structopt::StructOpt;
pub(crate) mod interceptor; pub(crate) mod interceptor;
pub(crate) mod shared; pub(crate) mod shared;
@@ -28,9 +28,9 @@ mod variants;
use variants::*; use variants::*;
/// Define the different variants of behavior. /// Define the different variants of behavior.
#[derive(Debug, StructOpt)] #[derive(Debug, Parser)]
#[structopt(about = "Malus - the nemesis of polkadot.")] #[clap(about = "Malus - the nemesis of polkadot.", version)]
#[structopt(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(RunCmd), SuggestGarbageCandidate(RunCmd),
@@ -40,18 +40,18 @@ enum NemesisVariant {
DisputeAncestor(RunCmd), DisputeAncestor(RunCmd),
#[allow(missing_docs)] #[allow(missing_docs)]
#[structopt(name = "prepare-worker", setting = structopt::clap::AppSettings::Hidden)] #[clap(name = "prepare-worker", setting = AppSettings::Hidden)]
PvfPrepareWorker(polkadot_cli::ValidationWorkerCommand), PvfPrepareWorker(polkadot_cli::ValidationWorkerCommand),
#[allow(missing_docs)] #[allow(missing_docs)]
#[structopt(name = "execute-worker", setting = structopt::clap::AppSettings::Hidden)] #[clap(name = "execute-worker", setting = AppSettings::Hidden)]
PvfExecuteWorker(polkadot_cli::ValidationWorkerCommand), PvfExecuteWorker(polkadot_cli::ValidationWorkerCommand),
} }
#[derive(Debug, StructOpt)] #[derive(Debug, Parser)]
#[allow(missing_docs)] #[allow(missing_docs)]
struct MalusCli { struct MalusCli {
#[structopt(subcommand)] #[clap(subcommand)]
pub variant: NemesisVariant, pub variant: NemesisVariant,
} }
@@ -99,7 +99,7 @@ impl MalusCli {
fn main() -> eyre::Result<()> { fn main() -> eyre::Result<()> {
color_eyre::install()?; color_eyre::install()?;
let cli = MalusCli::from_args(); let cli = MalusCli::parse();
cli.launch()?; cli.launch()?;
Ok(()) Ok(())
} }
@@ -110,7 +110,7 @@ mod tests {
#[test] #[test]
fn subcommand_works() { fn subcommand_works() {
let cli = MalusCli::from_iter_safe(IntoIterator::into_iter([ let cli = MalusCli::try_parse_from(IntoIterator::into_iter([
"malus", "malus",
"dispute-ancestor", "dispute-ancestor",
"--bob", "--bob",
@@ -15,10 +15,10 @@ path = "bin/puppet_worker.rs"
[dependencies] [dependencies]
parity-scale-codec = { version = "2.3.1", default-features = false, features = ["derive"] } parity-scale-codec = { version = "2.3.1", default-features = false, features = ["derive"] }
clap = { version = "3.0", features = ["derive"] }
futures = "0.3.19" futures = "0.3.19"
futures-timer = "3.0.2" futures-timer = "3.0.2"
log = "0.4.13" log = "0.4.13"
structopt = "0.3.25"
test-parachain-adder = { path = ".." } test-parachain-adder = { path = ".." }
polkadot-primitives = { path = "../../../../primitives" } polkadot-primitives = { path = "../../../../primitives" }
@@ -16,48 +16,48 @@
//! Polkadot CLI library. //! Polkadot CLI library.
use clap::Parser;
use sc_cli::{RuntimeVersion, SubstrateCli}; use sc_cli::{RuntimeVersion, SubstrateCli};
use structopt::StructOpt;
/// Sub-commands supported by the collator. /// Sub-commands supported by the collator.
#[derive(Debug, StructOpt)] #[derive(Debug, Parser)]
pub enum Subcommand { pub enum Subcommand {
/// Export the genesis state of the parachain. /// Export the genesis state of the parachain.
#[structopt(name = "export-genesis-state")] #[clap(name = "export-genesis-state")]
ExportGenesisState(ExportGenesisStateCommand), ExportGenesisState(ExportGenesisStateCommand),
/// Export the genesis wasm of the parachain. /// Export the genesis wasm of the parachain.
#[structopt(name = "export-genesis-wasm")] #[clap(name = "export-genesis-wasm")]
ExportGenesisWasm(ExportGenesisWasmCommand), ExportGenesisWasm(ExportGenesisWasmCommand),
} }
/// Command for exporting the genesis state of the parachain /// Command for exporting the genesis state of the parachain
#[derive(Debug, StructOpt)] #[derive(Debug, Parser)]
pub struct ExportGenesisStateCommand {} pub struct ExportGenesisStateCommand {}
/// Command for exporting the genesis wasm file. /// Command for exporting the genesis wasm file.
#[derive(Debug, StructOpt)] #[derive(Debug, Parser)]
pub struct ExportGenesisWasmCommand {} pub struct ExportGenesisWasmCommand {}
#[allow(missing_docs)] #[allow(missing_docs)]
#[derive(Debug, StructOpt)] #[derive(Debug, Parser)]
pub struct RunCmd { pub struct RunCmd {
#[allow(missing_docs)] #[allow(missing_docs)]
#[structopt(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.
#[structopt(long)] #[clap(long)]
pub parachain_id: Option<u32>, pub parachain_id: Option<u32>,
} }
#[allow(missing_docs)] #[allow(missing_docs)]
#[derive(Debug, StructOpt)] #[derive(Debug, Parser)]
pub struct Cli { pub struct Cli {
#[structopt(subcommand)] #[clap(subcommand)]
pub subcommand: Option<Subcommand>, pub subcommand: Option<Subcommand>,
#[structopt(flatten)] #[clap(flatten)]
pub run: RunCmd, pub run: RunCmd,
} }
+2 -1
View File
@@ -5,9 +5,10 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
[dependencies] [dependencies]
clap = { version = "3.0", 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" }
structopt = "0.3.25"
westend-runtime = { path = "../../runtime/westend" } westend-runtime = { path = "../../runtime/westend" }
kusama-runtime = { path = "../../runtime/kusama" } kusama-runtime = { path = "../../runtime/kusama" }
+9 -15
View File
@@ -20,21 +20,20 @@
//! 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 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 structopt::{clap::arg_enum, StructOpt};
use westend_runtime::Runtime as WestendRuntime; use westend_runtime::Runtime as WestendRuntime;
arg_enum! { #[derive(Clone, Debug, ArgEnum)]
#[derive(Debug)] #[clap(rename_all = "PascalCase")]
enum Runtime { enum Runtime {
Westend, Westend,
Kusama, Kusama,
Polkadot, Polkadot,
} }
}
impl Runtime { impl Runtime {
fn generate_thresholds_fn( fn generate_thresholds_fn(
@@ -48,35 +47,30 @@ impl Runtime {
} }
} }
#[derive(Debug, StructOpt)] #[derive(Debug, Parser)]
struct Opt { struct Opt {
/// How many bags to generate. /// How many bags to generate.
#[structopt(long, default_value = "200")] #[clap(long, default_value = "200")]
n_bags: usize, n_bags: usize,
/// Which runtime to generate. /// Which runtime to generate.
#[structopt( #[clap(long, ignore_case = true, arg_enum, default_value = "Polkadot")]
long,
case_insensitive = true,
default_value = "Polkadot",
possible_values = &Runtime::variants(),
)]
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.
#[structopt(short, long)] #[clap(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.
#[structopt(short, long)] #[clap(short, long)]
minimum_balance: u128, minimum_balance: u128,
} }
fn main() -> Result<(), std::io::Error> { fn main() -> Result<(), std::io::Error> {
let Opt { n_bags, output, runtime, total_issuance, minimum_balance } = Opt::from_args(); let Opt { n_bags, output, runtime, total_issuance, minimum_balance } = Opt::parse();
runtime.generate_thresholds_fn()(n_bags, &output, total_issuance, minimum_balance) runtime.generate_thresholds_fn()(n_bags, &output, total_issuance, minimum_balance)
} }
@@ -12,13 +12,11 @@ polkadot-runtime-constants = { version = "0.9.13", path = "../../../runtime/polk
kusama-runtime-constants = { version = "0.9.13", path = "../../../runtime/kusama/constants" } kusama-runtime-constants = { version = "0.9.13", path = "../../../runtime/kusama/constants" }
westend-runtime-constants = { version = "0.9.13", path = "../../../runtime/westend/constants" } westend-runtime-constants = { version = "0.9.13", path = "../../../runtime/westend/constants" }
pallet-bags-list-remote-tests = { git = "https://github.com/paritytech/substrate", branch = "master" } pallet-bags-list-remote-tests = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" } 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.0", features = ["derive"] }
log = "0.4.14"
tokio = { version = "1", features = ["macros"] } tokio = { version = "1", features = ["macros"] }
log = { version = "0.4.14" }
structopt = {version = "0.3.25" }
clap = { version = "2.34.0" }
@@ -16,43 +16,40 @@
//! Remote tests for bags-list pallet. //! Remote tests for bags-list pallet.
use clap::arg_enum; use clap::{ArgEnum, Parser};
use std::convert::TryInto; use std::convert::TryInto;
use structopt::StructOpt;
arg_enum! { #[derive(Clone, Debug, ArgEnum)]
#[derive(Debug)] #[clap(rename_all = "PascalCase")]
enum Command { enum Command {
CheckMigration, CheckMigration,
SanityCheck, SanityCheck,
Snapshot, Snapshot,
} }
}
arg_enum! { #[derive(Clone, Debug, ArgEnum)]
#[derive(Debug)] #[clap(rename_all = "PascalCase")]
enum Runtime { enum Runtime {
Polkadot, Polkadot,
Kusama, Kusama,
Westend, Westend,
} }
}
#[derive(StructOpt)] #[derive(Parser)]
struct Cli { struct Cli {
#[structopt(long, short, default_value = "wss://kusama-rpc.polkadot.io:443")] #[clap(long, short, default_value = "wss://kusama-rpc.polkadot.io:443")]
uri: String, uri: String,
#[structopt(long, short, case_insensitive = true, possible_values = &Runtime::variants(), default_value = "kusama")] #[clap(long, short, ignore_case = true, arg_enum, default_value = "kusama")]
runtime: Runtime, runtime: Runtime,
#[structopt(long, short, case_insensitive = true, possible_values = &Command::variants(), default_value = "SanityCheck")] #[clap(long, short, ignore_case = true, arg_enum, default_value = "SanityCheck")]
command: Command, command: Command,
#[structopt(long, short)] #[clap(long, short)]
snapshot_limit: Option<usize>, snapshot_limit: Option<usize>,
} }
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
let options = Cli::from_args(); let options = Cli::parse();
sp_tracing::try_init_simple(); sp_tracing::try_init_simple();
log::info!( log::info!(
+1 -1
View File
@@ -9,7 +9,7 @@ codec = { package = "parity-scale-codec", version = "2.0.0" }
tokio = { version = "1.15", features = ["macros"] } tokio = { version = "1.15", features = ["macros"] }
log = "0.4.11" log = "0.4.11"
env_logger = "0.9.0" env_logger = "0.9.0"
structopt = "0.3.25" clap = { version = "3.0", features = ["derive", "env"] }
jsonrpsee = { version = "0.4.1", default-features = false, features = ["ws-client"] } jsonrpsee = { version = "0.4.1", default-features = false, features = ["ws-client"] }
serde_json = "1.0" serde_json = "1.0"
serde = "1.0.132" serde = "1.0.132"
+21 -23
View File
@@ -38,13 +38,13 @@ mod signer;
pub(crate) use prelude::*; pub(crate) use prelude::*;
pub(crate) use signer::get_account_info; pub(crate) use signer::get_account_info;
use clap::Parser;
use frame_election_provider_support::NposSolver; use frame_election_provider_support::NposSolver;
use frame_support::traits::Get; use frame_support::traits::Get;
use jsonrpsee::ws_client::{WsClient, WsClientBuilder}; use jsonrpsee::ws_client::{WsClient, WsClientBuilder};
use remote_externalities::{Builder, Mode, OnlineConfig}; use remote_externalities::{Builder, Mode, OnlineConfig};
use sp_npos_elections::ExtendedBalance; use sp_npos_elections::ExtendedBalance;
use sp_runtime::{traits::Block as BlockT, DeserializeOwned}; use sp_runtime::{traits::Block as BlockT, DeserializeOwned};
use structopt::StructOpt;
pub(crate) enum AnyRuntime { pub(crate) enum AnyRuntime {
Polkadot, Polkadot,
@@ -272,7 +272,7 @@ impl<T: EPM::Config> std::fmt::Display for Error<T> {
} }
} }
#[derive(Debug, Clone, StructOpt)] #[derive(Debug, Clone, Parser)]
enum Command { enum Command {
/// Monitor for the phase being signed, then compute. /// Monitor for the phase being signed, then compute.
Monitor(MonitorConfig), Monitor(MonitorConfig),
@@ -282,14 +282,14 @@ enum Command {
EmergencySolution(EmergencySolutionConfig), EmergencySolution(EmergencySolutionConfig),
} }
#[derive(Debug, Clone, StructOpt)] #[derive(Debug, Clone, Parser)]
enum Solvers { enum Solvers {
SeqPhragmen { SeqPhragmen {
#[structopt(long, default_value = "10")] #[clap(long, default_value = "10")]
iterations: usize, iterations: usize,
}, },
PhragMMS { PhragMMS {
#[structopt(long, default_value = "10")] #[clap(long, default_value = "10")]
iterations: usize, iterations: usize,
}, },
} }
@@ -301,69 +301,67 @@ frame_support::parameter_types! {
pub static Balancing: Option<(usize, ExtendedBalance)> = Some((BalanceIterations::get(), 0)); pub static Balancing: Option<(usize, ExtendedBalance)> = Some((BalanceIterations::get(), 0));
} }
#[derive(Debug, Clone, StructOpt)] #[derive(Debug, Clone, Parser)]
struct MonitorConfig { struct MonitorConfig {
/// They type of event to listen to. /// They type of event to listen to.
/// ///
/// 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.
#[structopt(long, default_value = "head", possible_values = &["head", "finalized"])] #[clap(long, default_value = "head", possible_values = &["head", "finalized"])]
listen: String, listen: String,
/// The solver algorithm to use. /// The solver algorithm to use.
#[structopt(subcommand)] #[clap(subcommand)]
solver: Solvers, solver: Solvers,
} }
#[derive(Debug, Clone, StructOpt)] #[derive(Debug, Clone, Parser)]
struct EmergencySolutionConfig { 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.
#[allow(dead_code)] #[clap(long)]
#[structopt(long)]
at: Option<Hash>, at: Option<Hash>,
/// The solver algorithm to use. /// The solver algorithm to use.
#[allow(dead_code)] #[clap(subcommand)]
#[structopt(subcommand)]
solver: Solvers, solver: Solvers,
/// 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.
take: Option<usize>, take: Option<usize>,
} }
#[derive(Debug, Clone, StructOpt)] #[derive(Debug, Clone, Parser)]
struct DryRunConfig { struct DryRunConfig {
/// 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.
#[structopt(long)] #[clap(long)]
at: Option<Hash>, at: Option<Hash>,
/// The solver algorithm to use. /// The solver algorithm to use.
#[structopt(subcommand)] #[clap(subcommand)]
solver: Solvers, solver: Solvers,
} }
#[derive(Debug, Clone, StructOpt)] #[derive(Debug, Clone, Parser)]
struct SharedConfig { struct SharedConfig {
/// The `ws` node to connect to. /// The `ws` node to connect to.
#[structopt(long, short, default_value = DEFAULT_URI, env = "URI")] #[clap(long, short, default_value = DEFAULT_URI, env = "URI")]
uri: String, uri: String,
/// The seed of a funded account in hex. /// The seed of a funded account in hex.
/// ///
/// 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.
#[structopt(long, short, env = "SEED")] #[clap(long, short, env = "SEED")]
seed: String, seed: String,
} }
#[derive(Debug, Clone, StructOpt)] #[derive(Debug, Clone, Parser)]
struct Opt { struct Opt {
/// The `ws` node to connect to. /// The `ws` node to connect to.
#[structopt(flatten)] #[clap(flatten)]
shared: SharedConfig, shared: SharedConfig,
#[structopt(subcommand)] #[clap(subcommand)]
command: Command, command: Command,
} }
@@ -523,7 +521,7 @@ async fn main() {
.format_module_path(true) .format_module_path(true)
.format_level(true) .format_level(true)
.init(); .init();
let Opt { shared, command } = Opt::from_args(); let Opt { shared, command } = Opt::parse();
log::debug!(target: LOG_TARGET, "attempting to connect to {:?}", shared.uri); log::debug!(target: LOG_TARGET, "attempting to connect to {:?}", shared.uri);
let client = loop { let client = loop {