Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
445 changes: 216 additions & 229 deletions Cargo.lock

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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",
Expand All @@ -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"]
35 changes: 18 additions & 17 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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,
}
4 changes: 2 additions & 2 deletions node/malus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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"
Expand Down
16 changes: 8 additions & 8 deletions node/malus/src/malus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.")]
#[clap(rename_all = "kebab-case")]
enum NemesisVariant {
/// Suggest a candidate with an invalid proof of validity.
SuggestGarbageCandidate(RunCmd),
Expand All @@ -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,
}

Expand Down
2 changes: 1 addition & 1 deletion parachain/test-parachains/adder/collator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
24 changes: 12 additions & 12 deletions parachain/test-parachains/adder/collator/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
3 changes: 2 additions & 1 deletion utils/generate-bags/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
32 changes: 13 additions & 19 deletions utils/generate-bags/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
Loading