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
+21 -23
View File
@@ -38,13 +38,13 @@ mod signer;
pub(crate) use prelude::*;
pub(crate) use signer::get_account_info;
use clap::Parser;
use frame_election_provider_support::NposSolver;
use frame_support::traits::Get;
use jsonrpsee::ws_client::{WsClient, WsClientBuilder};
use remote_externalities::{Builder, Mode, OnlineConfig};
use sp_npos_elections::ExtendedBalance;
use sp_runtime::{traits::Block as BlockT, DeserializeOwned};
use structopt::StructOpt;
pub(crate) enum AnyRuntime {
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 {
/// Monitor for the phase being signed, then compute.
Monitor(MonitorConfig),
@@ -282,14 +282,14 @@ enum Command {
EmergencySolution(EmergencySolutionConfig),
}
#[derive(Debug, Clone, StructOpt)]
#[derive(Debug, Clone, Parser)]
enum Solvers {
SeqPhragmen {
#[structopt(long, default_value = "10")]
#[clap(long, default_value = "10")]
iterations: usize,
},
PhragMMS {
#[structopt(long, default_value = "10")]
#[clap(long, default_value = "10")]
iterations: usize,
},
}
@@ -301,69 +301,67 @@ frame_support::parameter_types! {
pub static Balancing: Option<(usize, ExtendedBalance)> = Some((BalanceIterations::get(), 0));
}
#[derive(Debug, Clone, StructOpt)]
#[derive(Debug, Clone, Parser)]
struct MonitorConfig {
/// They type of event to listen to.
///
/// 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.
#[structopt(long, default_value = "head", possible_values = &["head", "finalized"])]
#[clap(long, default_value = "head", possible_values = &["head", "finalized"])]
listen: String,
/// The solver algorithm to use.
#[structopt(subcommand)]
#[clap(subcommand)]
solver: Solvers,
}
#[derive(Debug, Clone, StructOpt)]
#[derive(Debug, Clone, Parser)]
struct EmergencySolutionConfig {
/// The block hash at which scraping happens. If none is provided, the latest head is used.
#[allow(dead_code)]
#[structopt(long)]
#[clap(long)]
at: Option<Hash>,
/// The solver algorithm to use.
#[allow(dead_code)]
#[structopt(subcommand)]
#[clap(subcommand)]
solver: Solvers,
/// The number of top backed winners to take. All are taken, if not provided.
take: Option<usize>,
}
#[derive(Debug, Clone, StructOpt)]
#[derive(Debug, Clone, Parser)]
struct DryRunConfig {
/// The block hash at which scraping happens. If none is provided, the latest head is used.
#[structopt(long)]
#[clap(long)]
at: Option<Hash>,
/// The solver algorithm to use.
#[structopt(subcommand)]
#[clap(subcommand)]
solver: Solvers,
}
#[derive(Debug, Clone, StructOpt)]
#[derive(Debug, Clone, Parser)]
struct SharedConfig {
/// 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,
/// 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
/// configured, it might re-try and lose funds through transaction fees/deposits.
#[structopt(long, short, env = "SEED")]
#[clap(long, short, env = "SEED")]
seed: String,
}
#[derive(Debug, Clone, StructOpt)]
#[derive(Debug, Clone, Parser)]
struct Opt {
/// The `ws` node to connect to.
#[structopt(flatten)]
#[clap(flatten)]
shared: SharedConfig,
#[structopt(subcommand)]
#[clap(subcommand)]
command: Command,
}
@@ -523,7 +521,7 @@ async fn main() {
.format_module_path(true)
.format_level(true)
.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);
let client = loop {