mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 08:51:09 +00:00
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:
@@ -5,9 +5,10 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "3.0", features = ["derive"] }
|
||||
|
||||
generate-bags = { 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" }
|
||||
kusama-runtime = { path = "../../runtime/kusama" }
|
||||
|
||||
@@ -20,20 +20,19 @@
|
||||
//! 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 generate_bags::generate_thresholds;
|
||||
use kusama_runtime::Runtime as KusamaRuntime;
|
||||
use polkadot_runtime::Runtime as PolkadotRuntime;
|
||||
use std::path::{Path, PathBuf};
|
||||
use structopt::{clap::arg_enum, StructOpt};
|
||||
use westend_runtime::Runtime as WestendRuntime;
|
||||
|
||||
arg_enum! {
|
||||
#[derive(Debug)]
|
||||
enum Runtime {
|
||||
Westend,
|
||||
Kusama,
|
||||
Polkadot,
|
||||
}
|
||||
#[derive(Clone, Debug, ArgEnum)]
|
||||
#[clap(rename_all = "PascalCase")]
|
||||
enum Runtime {
|
||||
Westend,
|
||||
Kusama,
|
||||
Polkadot,
|
||||
}
|
||||
|
||||
impl Runtime {
|
||||
@@ -48,35 +47,30 @@ impl Runtime {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
struct Opt {
|
||||
/// How many bags to generate.
|
||||
#[structopt(long, default_value = "200")]
|
||||
#[clap(long, default_value = "200")]
|
||||
n_bags: usize,
|
||||
|
||||
/// Which runtime to generate.
|
||||
#[structopt(
|
||||
long,
|
||||
case_insensitive = true,
|
||||
default_value = "Polkadot",
|
||||
possible_values = &Runtime::variants(),
|
||||
)]
|
||||
#[clap(long, ignore_case = true, arg_enum, default_value = "Polkadot")]
|
||||
runtime: Runtime,
|
||||
|
||||
/// Where to write the output.
|
||||
output: PathBuf,
|
||||
|
||||
/// The total issuance of the native currency.
|
||||
#[structopt(short, long)]
|
||||
#[clap(short, long)]
|
||||
total_issuance: u128,
|
||||
|
||||
/// The minimum account balance (i.e. existential deposit) for the native currency.
|
||||
#[structopt(short, long)]
|
||||
#[clap(short, long)]
|
||||
minimum_balance: u128,
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -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" }
|
||||
westend-runtime-constants = { version = "0.9.13", path = "../../../runtime/westend/constants" }
|
||||
|
||||
|
||||
pallet-bags-list-remote-tests = { 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" }
|
||||
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"] }
|
||||
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.
|
||||
|
||||
use clap::arg_enum;
|
||||
use clap::{ArgEnum, Parser};
|
||||
use std::convert::TryInto;
|
||||
use structopt::StructOpt;
|
||||
|
||||
arg_enum! {
|
||||
#[derive(Debug)]
|
||||
enum Command {
|
||||
CheckMigration,
|
||||
SanityCheck,
|
||||
Snapshot,
|
||||
}
|
||||
#[derive(Clone, Debug, ArgEnum)]
|
||||
#[clap(rename_all = "PascalCase")]
|
||||
enum Command {
|
||||
CheckMigration,
|
||||
SanityCheck,
|
||||
Snapshot,
|
||||
}
|
||||
|
||||
arg_enum! {
|
||||
#[derive(Debug)]
|
||||
enum Runtime {
|
||||
Polkadot,
|
||||
Kusama,
|
||||
Westend,
|
||||
}
|
||||
#[derive(Clone, Debug, ArgEnum)]
|
||||
#[clap(rename_all = "PascalCase")]
|
||||
enum Runtime {
|
||||
Polkadot,
|
||||
Kusama,
|
||||
Westend,
|
||||
}
|
||||
|
||||
#[derive(StructOpt)]
|
||||
#[derive(Parser)]
|
||||
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,
|
||||
#[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,
|
||||
#[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,
|
||||
#[structopt(long, short)]
|
||||
#[clap(long, short)]
|
||||
snapshot_limit: Option<usize>,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let options = Cli::from_args();
|
||||
let options = Cli::parse();
|
||||
sp_tracing::try_init_simple();
|
||||
|
||||
log::info!(
|
||||
|
||||
@@ -9,7 +9,7 @@ codec = { package = "parity-scale-codec", version = "2.0.0" }
|
||||
tokio = { version = "1.15", features = ["macros"] }
|
||||
log = "0.4.11"
|
||||
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"] }
|
||||
serde_json = "1.0"
|
||||
serde = "1.0.132"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user