Skip to content

Commit

Permalink
Companion for substrate#10632 (paritytech#4689)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people committed Jan 25, 2022
1 parent 1fdeef8 commit 60df3c5
Show file tree
Hide file tree
Showing 14 changed files with 335 additions and 358 deletions.
445 changes: 216 additions & 229 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions bridges/modules/dispatch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
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
20 changes: 10 additions & 10 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.", version)]
#[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 Expand Up @@ -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(())
}
Expand All @@ -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",
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
Loading

0 comments on commit 60df3c5

Please sign in to comment.