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() {
new_test_ext().execute_with(|| {
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 mut message = prepare_root_message(call);
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);
let result = Dispatch::dispatch(
+15 -15
View File
@@ -14,9 +14,9 @@ wasm-opt = false
crate-type = ["cdylib", "rlib"]
[dependencies]
clap = { version = "3.0", features = ["derive"], optional = true }
log = "0.4.13"
thiserror = "1.0.30"
structopt = { version = "0.3.25", optional = true }
futures = "0.3.19"
service = { package = "polkadot-service", path = "../node/service", default-features = false, optional = true }
@@ -39,11 +39,11 @@ sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master",
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "master" }
[features]
default = [ "wasmtime", "db", "cli", "full-node", "trie-memory-tracker", "polkadot-native" ]
wasmtime = [ "sc-cli/wasmtime" ]
db = [ "service/db" ]
default = ["wasmtime", "db", "cli", "full-node", "trie-memory-tracker", "polkadot-native"]
wasmtime = ["sc-cli/wasmtime"]
db = ["service/db"]
cli = [
"structopt",
"clap",
"sc-cli",
"sc-service",
"sc-tracing",
@@ -52,19 +52,19 @@ cli = [
"polkadot-node-core-pvf",
"polkadot-performance-test",
]
runtime-benchmarks = [ "service/runtime-benchmarks", "polkadot-node-metrics/runtime-benchmarks" ]
trie-memory-tracker = [ "sp-trie/memory-tracker" ]
full-node = [ "service/full-node" ]
try-runtime = [ "service/try-runtime" ]
fast-runtime = [ "service/fast-runtime" ]
runtime-benchmarks = ["service/runtime-benchmarks", "polkadot-node-metrics/runtime-benchmarks"]
trie-memory-tracker = ["sp-trie/memory-tracker"]
full-node = ["service/full-node"]
try-runtime = ["service/try-runtime"]
fast-runtime = ["service/fast-runtime"]
# Configure the native runtimes to use. Polkadot is enabled by default.
#
# Validators require the native runtime currently
polkadot-native = [ "service/polkadot-native" ]
kusama-native = [ "service/kusama-native" ]
westend-native = [ "service/westend-native" ]
rococo-native = [ "service/rococo-native" ]
polkadot-native = ["service/polkadot-native"]
kusama-native = ["service/kusama-native"]
westend-native = ["service/westend-native"]
rococo-native = ["service/rococo-native"]
malus = [ "full-node", "service/malus" ]
malus = ["full-node", "service/malus"]
runtime-metrics = ["service/runtime-metrics", "polkadot-node-metrics/runtime-metrics"]
+18 -17
View File
@@ -16,10 +16,10 @@
//! Polkadot CLI library.
use structopt::StructOpt;
use clap::{AppSettings, Parser};
#[allow(missing_docs)]
#[derive(Debug, StructOpt)]
#[derive(Debug, Parser)]
pub enum Subcommand {
/// Build a chain specification.
BuildSpec(sc_cli::BuildSpecCmd),
@@ -43,15 +43,15 @@ pub enum Subcommand {
Revert(sc_cli::RevertCmd),
#[allow(missing_docs)]
#[structopt(name = "prepare-worker", setting = structopt::clap::AppSettings::Hidden)]
#[clap(name = "prepare-worker", setting = AppSettings::Hidden)]
PvfPrepareWorker(ValidationWorkerCommand),
#[allow(missing_docs)]
#[structopt(name = "execute-worker", setting = structopt::clap::AppSettings::Hidden)]
#[clap(name = "execute-worker", setting = AppSettings::Hidden)]
PvfExecuteWorker(ValidationWorkerCommand),
/// 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),
/// Runs performance checks such as PVF compilation in order to measure machine
@@ -67,33 +67,34 @@ pub enum Subcommand {
TryRuntime,
/// Key management CLI utilities
#[clap(subcommand)]
Key(sc_cli::KeySubcommand),
}
#[allow(missing_docs)]
#[derive(Debug, StructOpt)]
#[derive(Debug, Parser)]
pub struct ValidationWorkerCommand {
/// The path to the validation host's socket.
pub socket_path: String,
}
#[allow(missing_docs)]
#[derive(Debug, StructOpt)]
#[derive(Debug, Parser)]
pub struct RunCmd {
#[allow(missing_docs)]
#[structopt(flatten)]
#[clap(flatten)]
pub base: sc_cli::RunCmd,
/// Force using Kusama native runtime.
#[structopt(long = "force-kusama")]
#[clap(long = "force-kusama")]
pub force_kusama: bool,
/// Force using Westend native runtime.
#[structopt(long = "force-westend")]
#[clap(long = "force-westend")]
pub force_westend: bool,
/// Force using Rococo native runtime.
#[structopt(long = "force-rococo")]
#[clap(long = "force-rococo")]
pub force_rococo: bool,
/// Setup a GRANDPA scheduled voting pause.
@@ -102,26 +103,26 @@ 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).
#[structopt(long = "grandpa-pause", number_of_values(2))]
#[clap(long = "grandpa-pause", number_of_values(2))]
pub grandpa_pause: Vec<u32>,
/// Enable the BEEFY gadget (only on Rococo or Wococo for now).
#[structopt(long)]
#[clap(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`.
#[structopt(long)]
#[clap(long)]
pub jaeger_agent: Option<std::net::SocketAddr>,
}
#[allow(missing_docs)]
#[derive(Debug, StructOpt)]
#[derive(Debug, Parser)]
pub struct Cli {
#[structopt(subcommand)]
#[clap(subcommand)]
pub subcommand: Option<Subcommand>,
#[structopt(flatten)]
#[clap(flatten)]
pub run: RunCmd,
}
+2 -2
View File
@@ -13,7 +13,7 @@ name = "malus"
path = "src/malus.rs"
[dependencies]
polkadot-cli = { path = "../../cli", default-features = false, features = [ "cli", "malus" ] }
polkadot-cli = { path = "../../cli", default-features = false, features = ["cli", "malus"] }
polkadot-node-subsystem = { path = "../subsystem" }
polkadot-node-subsystem-util = { path = "../subsystem-util" }
polkadot-node-subsystem-types = { path = "../subsystem-types" }
@@ -26,9 +26,9 @@ polkadot-node-core-pvf = { path = "../core/pvf" }
parity-util-mem = { version = "0.10.0", default-features = false, features = ["jemalloc-global"] }
color-eyre = { version = "0.5.11", default-features = false }
assert_matches = "1.5"
structopt = "0.3.25"
async-trait = "0.1.52"
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
clap = { version = "3.0", features = ["derive"] }
futures = "0.3.19"
futures-timer = "3.0.2"
tracing = "0.1.26"
+10 -10
View File
@@ -16,9 +16,9 @@
//! A malus or nemesis node launch code.
use clap::{AppSettings, Parser};
use color_eyre::eyre;
use polkadot_cli::{Cli, RunCmd};
use structopt::StructOpt;
pub(crate) mod interceptor;
pub(crate) mod shared;
@@ -28,9 +28,9 @@ mod variants;
use variants::*;
/// Define the different variants of behavior.
#[derive(Debug, StructOpt)]
#[structopt(about = "Malus - the nemesis of polkadot.")]
#[structopt(rename_all = "kebab-case")]
#[derive(Debug, Parser)]
#[clap(about = "Malus - the nemesis of polkadot.", version)]
#[clap(rename_all = "kebab-case")]
enum NemesisVariant {
/// Suggest a candidate with an invalid proof of validity.
SuggestGarbageCandidate(RunCmd),
@@ -40,18 +40,18 @@ enum NemesisVariant {
DisputeAncestor(RunCmd),
#[allow(missing_docs)]
#[structopt(name = "prepare-worker", setting = structopt::clap::AppSettings::Hidden)]
#[clap(name = "prepare-worker", setting = AppSettings::Hidden)]
PvfPrepareWorker(polkadot_cli::ValidationWorkerCommand),
#[allow(missing_docs)]
#[structopt(name = "execute-worker", setting = structopt::clap::AppSettings::Hidden)]
#[clap(name = "execute-worker", setting = AppSettings::Hidden)]
PvfExecuteWorker(polkadot_cli::ValidationWorkerCommand),
}
#[derive(Debug, StructOpt)]
#[derive(Debug, Parser)]
#[allow(missing_docs)]
struct MalusCli {
#[structopt(subcommand)]
#[clap(subcommand)]
pub variant: NemesisVariant,
}
@@ -99,7 +99,7 @@ impl MalusCli {
fn main() -> eyre::Result<()> {
color_eyre::install()?;
let cli = MalusCli::from_args();
let cli = MalusCli::parse();
cli.launch()?;
Ok(())
}
@@ -110,7 +110,7 @@ mod tests {
#[test]
fn subcommand_works() {
let cli = MalusCli::from_iter_safe(IntoIterator::into_iter([
let cli = MalusCli::try_parse_from(IntoIterator::into_iter([
"malus",
"dispute-ancestor",
"--bob",
@@ -15,10 +15,10 @@ path = "bin/puppet_worker.rs"
[dependencies]
parity-scale-codec = { version = "2.3.1", default-features = false, features = ["derive"] }
clap = { version = "3.0", features = ["derive"] }
futures = "0.3.19"
futures-timer = "3.0.2"
log = "0.4.13"
structopt = "0.3.25"
test-parachain-adder = { path = ".." }
polkadot-primitives = { path = "../../../../primitives" }
@@ -16,48 +16,48 @@
//! Polkadot CLI library.
use clap::Parser;
use sc_cli::{RuntimeVersion, SubstrateCli};
use structopt::StructOpt;
/// Sub-commands supported by the collator.
#[derive(Debug, StructOpt)]
#[derive(Debug, Parser)]
pub enum Subcommand {
/// Export the genesis state of the parachain.
#[structopt(name = "export-genesis-state")]
#[clap(name = "export-genesis-state")]
ExportGenesisState(ExportGenesisStateCommand),
/// Export the genesis wasm of the parachain.
#[structopt(name = "export-genesis-wasm")]
#[clap(name = "export-genesis-wasm")]
ExportGenesisWasm(ExportGenesisWasmCommand),
}
/// Command for exporting the genesis state of the parachain
#[derive(Debug, StructOpt)]
#[derive(Debug, Parser)]
pub struct ExportGenesisStateCommand {}
/// Command for exporting the genesis wasm file.
#[derive(Debug, StructOpt)]
#[derive(Debug, Parser)]
pub struct ExportGenesisWasmCommand {}
#[allow(missing_docs)]
#[derive(Debug, StructOpt)]
#[derive(Debug, Parser)]
pub struct RunCmd {
#[allow(missing_docs)]
#[structopt(flatten)]
#[clap(flatten)]
pub base: sc_cli::RunCmd,
/// Id of the parachain this collator collates for.
#[structopt(long)]
#[clap(long)]
pub parachain_id: Option<u32>,
}
#[allow(missing_docs)]
#[derive(Debug, StructOpt)]
#[derive(Debug, Parser)]
pub struct Cli {
#[structopt(subcommand)]
#[clap(subcommand)]
pub subcommand: Option<Subcommand>,
#[structopt(flatten)]
#[clap(flatten)]
pub run: RunCmd,
}
+2 -1
View File
@@ -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" }
+13 -19
View File
@@ -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!(
+1 -1
View File
@@ -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"
+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 {