mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-21 14:25:41 +00:00
Expose node subcommands in Malus CLI (#6135)
* Expose the full Cli through malus Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * fix lonely test Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
This commit is contained in:
@@ -84,7 +84,6 @@ pub struct ValidationWorkerCommand {
|
|||||||
|
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
#[cfg_attr(feature = "malus", derive(Clone))]
|
|
||||||
pub struct RunCmd {
|
pub struct RunCmd {
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
#[clap(flatten)]
|
#[clap(flatten)]
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use color_eyre::eyre;
|
use color_eyre::eyre;
|
||||||
use polkadot_cli::{Cli, RunCmd};
|
use polkadot_cli::Cli;
|
||||||
|
|
||||||
pub(crate) mod interceptor;
|
pub(crate) mod interceptor;
|
||||||
pub(crate) mod shared;
|
pub(crate) mod shared;
|
||||||
@@ -33,9 +33,9 @@ use variants::*;
|
|||||||
#[clap(rename_all = "kebab-case")]
|
#[clap(rename_all = "kebab-case")]
|
||||||
enum NemesisVariant {
|
enum NemesisVariant {
|
||||||
/// Suggest a candidate with an invalid proof of validity.
|
/// Suggest a candidate with an invalid proof of validity.
|
||||||
SuggestGarbageCandidate(RunCmd),
|
SuggestGarbageCandidate(Cli),
|
||||||
/// Back a candidate with a specifically crafted proof of validity.
|
/// Back a candidate with a specifically crafted proof of validity.
|
||||||
BackGarbageCandidate(RunCmd),
|
BackGarbageCandidate(Cli),
|
||||||
/// Delayed disputing of ancestors that are perfectly fine.
|
/// Delayed disputing of ancestors that are perfectly fine.
|
||||||
DisputeAncestor(DisputeAncestorOptions),
|
DisputeAncestor(DisputeAncestorOptions),
|
||||||
|
|
||||||
@@ -57,24 +57,24 @@ struct MalusCli {
|
|||||||
pub finality_delay: Option<u32>,
|
pub finality_delay: Option<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_cmd(run: RunCmd) -> Cli {
|
|
||||||
Cli { subcommand: None, run }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MalusCli {
|
impl MalusCli {
|
||||||
/// Launch a malus node.
|
/// Launch a malus node.
|
||||||
fn launch(self) -> eyre::Result<()> {
|
fn launch(self) -> eyre::Result<()> {
|
||||||
let finality_delay = self.finality_delay;
|
let finality_delay = self.finality_delay;
|
||||||
match self.variant {
|
match self.variant {
|
||||||
NemesisVariant::BackGarbageCandidate(cmd) =>
|
NemesisVariant::BackGarbageCandidate(cli) =>
|
||||||
polkadot_cli::run_node(run_cmd(cmd), BackGarbageCandidate, finality_delay)?,
|
polkadot_cli::run_node(cli, BackGarbageCandidate, finality_delay)?,
|
||||||
NemesisVariant::SuggestGarbageCandidate(cmd) =>
|
NemesisVariant::SuggestGarbageCandidate(cli) =>
|
||||||
polkadot_cli::run_node(run_cmd(cmd), BackGarbageCandidateWrapper, finality_delay)?,
|
polkadot_cli::run_node(cli, BackGarbageCandidateWrapper, finality_delay)?,
|
||||||
NemesisVariant::DisputeAncestor(opts) => polkadot_cli::run_node(
|
NemesisVariant::DisputeAncestor(opts) => {
|
||||||
run_cmd(opts.clone().cmd),
|
let DisputeAncestorOptions { fake_validation, fake_validation_error, cli } = opts;
|
||||||
DisputeValidCandidates::new(opts),
|
|
||||||
finality_delay,
|
polkadot_cli::run_node(
|
||||||
)?,
|
cli,
|
||||||
|
DisputeValidCandidates { fake_validation, fake_validation_error },
|
||||||
|
finality_delay,
|
||||||
|
)?
|
||||||
|
},
|
||||||
NemesisVariant::PvfPrepareWorker(cmd) => {
|
NemesisVariant::PvfPrepareWorker(cmd) => {
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
{
|
{
|
||||||
@@ -126,7 +126,7 @@ mod tests {
|
|||||||
variant: NemesisVariant::DisputeAncestor(run),
|
variant: NemesisVariant::DisputeAncestor(run),
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
assert!(run.cmd.base.bob);
|
assert!(run.cli.run.base.bob);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ use polkadot_cli::{
|
|||||||
OverseerConnector, OverseerGen, OverseerGenArgs, OverseerHandle, ParachainHost,
|
OverseerConnector, OverseerGen, OverseerGenArgs, OverseerHandle, ParachainHost,
|
||||||
ProvideRuntimeApi,
|
ProvideRuntimeApi,
|
||||||
},
|
},
|
||||||
RunCmd,
|
Cli,
|
||||||
};
|
};
|
||||||
use polkadot_node_subsystem::SpawnGlue;
|
use polkadot_node_subsystem::SpawnGlue;
|
||||||
use sp_core::traits::SpawnNamed;
|
use sp_core::traits::SpawnNamed;
|
||||||
@@ -40,7 +40,7 @@ use crate::{interceptor::*, variants::ReplaceValidationResult};
|
|||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
#[derive(Clone, Debug, clap::Parser)]
|
#[derive(Debug, clap::Parser)]
|
||||||
#[clap(rename_all = "kebab-case")]
|
#[clap(rename_all = "kebab-case")]
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub struct DisputeAncestorOptions {
|
pub struct DisputeAncestorOptions {
|
||||||
@@ -56,18 +56,14 @@ pub struct DisputeAncestorOptions {
|
|||||||
pub fake_validation_error: FakeCandidateValidationError,
|
pub fake_validation_error: FakeCandidateValidationError,
|
||||||
|
|
||||||
#[clap(flatten)]
|
#[clap(flatten)]
|
||||||
pub cmd: RunCmd,
|
pub cli: Cli,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct DisputeValidCandidates {
|
pub(crate) struct DisputeValidCandidates {
|
||||||
/// Fake validation config (applies to disputes as well).
|
/// Fake validation config (applies to disputes as well).
|
||||||
opts: DisputeAncestorOptions,
|
pub fake_validation: FakeCandidateValidation,
|
||||||
}
|
/// Fake validation error config.
|
||||||
|
pub fake_validation_error: FakeCandidateValidationError,
|
||||||
impl DisputeValidCandidates {
|
|
||||||
pub fn new(opts: DisputeAncestorOptions) -> Self {
|
|
||||||
Self { opts }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OverseerGen for DisputeValidCandidates {
|
impl OverseerGen for DisputeValidCandidates {
|
||||||
@@ -83,8 +79,8 @@ impl OverseerGen for DisputeValidCandidates {
|
|||||||
{
|
{
|
||||||
let spawner = args.spawner.clone();
|
let spawner = args.spawner.clone();
|
||||||
let validation_filter = ReplaceValidationResult::new(
|
let validation_filter = ReplaceValidationResult::new(
|
||||||
self.opts.fake_validation,
|
self.fake_validation,
|
||||||
self.opts.fake_validation_error,
|
self.fake_validation_error,
|
||||||
SpawnGlue(spawner.clone()),
|
SpawnGlue(spawner.clone()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user