Skip to content

Commit

Permalink
Additional madara params
Browse files Browse the repository at this point in the history
  • Loading branch information
broody committed Mar 1, 2024
1 parent 1b4b0cb commit 5165e03
Show file tree
Hide file tree
Showing 8 changed files with 235 additions and 21 deletions.
132 changes: 132 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -11597,6 +11597,66 @@
"name": "String",
"ofType": null
}
},
{
"defaultValue": null,
"description": null,
"name": "validator",
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
{
"defaultValue": null,
"description": null,
"name": "noGrandpa",
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
{
"defaultValue": null,
"description": null,
"name": "chain",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
{
"defaultValue": null,
"description": null,
"name": "basePath",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
{
"defaultValue": null,
"description": null,
"name": "dev",
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
{
"defaultValue": null,
"description": null,
"name": "sealing",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
}
],
"interfaces": [],
Expand Down Expand Up @@ -18909,6 +18969,78 @@
"name": "String",
"ofType": null
}
},
{
"args": [],
"deprecationReason": null,
"description": null,
"isDeprecated": false,
"name": "validator",
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
{
"args": [],
"deprecationReason": null,
"description": null,
"isDeprecated": false,
"name": "noGrandpa",
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
{
"args": [],
"deprecationReason": null,
"description": null,
"isDeprecated": false,
"name": "chain",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
{
"args": [],
"deprecationReason": null,
"description": null,
"isDeprecated": false,
"name": "basePath",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
{
"args": [],
"deprecationReason": null,
"description": null,
"isDeprecated": false,
"name": "dev",
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
{
"args": [],
"deprecationReason": null,
"description": null,
"isDeprecated": false,
"name": "sealing",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
}
],
"inputFields": [],
Expand Down
11 changes: 5 additions & 6 deletions src/command/deployments/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,9 @@ impl AccountsArgs {
let accounts = DevAllocationsGenerator::new(total)
.with_seed(parse_seed(&config.seed))
.generate();

let mut genesis = Genesis::default();
genesis
.extend_allocations(accounts.into_iter().map(|(k, v)| (k, v.into())));
genesis.extend_allocations(accounts.into_iter().map(|(k, v)| (k, v.into())));
print_genesis_accounts(genesis.accounts().peekable(), Some(&config.seed));
}
}
Expand Down Expand Up @@ -115,13 +114,13 @@ PREFUNDED ACCOUNTS
}

if let Some(seed) = seed {
println!(
r"
println!(
r"
ACCOUNTS SEED
=============
{seed}
"
);
);
}
}

Expand Down
15 changes: 11 additions & 4 deletions src/command/deployments/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use graphql_client::{GraphQLQuery, Response};
use crate::{
api::ApiClient,
command::deployments::create::create_deployment::{
CreateDeploymentCreateDeployment::{KatanaConfig, ToriiConfig, MadaraConfig}, CreateKatanaConfigInput, CreateMadaraConfigInput, CreateServiceConfigInput, CreateServiceInput, CreateToriiConfigInput, DeploymentService, DeploymentTier, Variables
CreateDeploymentCreateDeployment::{KatanaConfig, MadaraConfig, ToriiConfig},
CreateKatanaConfigInput, CreateMadaraConfigInput, CreateServiceConfigInput,
CreateServiceInput, CreateToriiConfigInput, DeploymentService, DeploymentTier, Variables,
},
};

Expand Down Expand Up @@ -60,7 +62,6 @@ impl CreateArgs {
}),
torii: None,
madara: None,

}),
},
CreateServiceCommands::Torii(config) => CreateServiceInput {
Expand All @@ -83,7 +84,13 @@ impl CreateArgs {
katana: None,
torii: None,
madara: Some(CreateMadaraConfigInput {
name: config.name.clone()
name: config.name.clone(),
base_path: config.base_path.clone(),
dev: config.dev.then(|| true),
no_grandpa: config.no_grandpa.then(|| true),
validator: config.validator.then(|| true),
sealing: config.sealing.clone().map(|s| s.to_string()),
chain: config.chain.clone().map(|c| c.to_string()),
}),
}),
},
Expand Down Expand Up @@ -126,7 +133,7 @@ impl CreateArgs {
println!("\nEndpoints:");
println!(" RPC: {}", config.rpc);
}
MadaraConfig(config) => {
MadaraConfig(config) => {
println!("\nEndpoints:");
println!(" RPC: {}", config.rpc);
}
Expand Down
3 changes: 2 additions & 1 deletion src/command/deployments/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::api::ApiClient;

use self::describe_deployment::{
DeploymentService,
DescribeDeploymentDeploymentConfig::{KatanaConfig, ToriiConfig, MadaraConfig},
DescribeDeploymentDeploymentConfig::{KatanaConfig, MadaraConfig, ToriiConfig},
ResponseData, Variables,
};

Expand Down Expand Up @@ -39,6 +39,7 @@ impl DescribeArgs {
let service = match self.service {
Service::Torii => DeploymentService::torii,
Service::Katana => DeploymentService::katana,
Service::Madara => DeploymentService::madara,
};

let request_body = DescribeDeployment::build_query(Variables {
Expand Down
1 change: 1 addition & 0 deletions src/command/deployments/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ impl LogReader {
let service = match self.service {
Service::Katana => DeploymentService::katana,
Service::Torii => DeploymentService::torii,
Service::Madara => DeploymentService::madara,
};

let request_body = DeploymentLogs::build_query(Variables {
Expand Down
89 changes: 81 additions & 8 deletions src/command/deployments/services/madara.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,86 @@
use clap::Args;
use core::fmt;

#[derive(Debug, Args, serde::Serialize)]
use clap::{Args, ValueEnum};
use serde::Serialize;

#[derive(Debug, Args, Serialize)]
#[command(next_help_heading = "Madara create options")]
pub struct MadaraCreateArgs {
#[arg(long, short, value_name = "version")]
#[arg(help = "Service version to use.")]
pub version: Option<String>,
#[arg(long, short, value_name = "version")]
#[arg(help = "Service version to use.")]
pub version: Option<String>,

#[arg(long, value_name = "dev")]
#[arg(
help = "Specify the development chain. This flag sets `--chain=dev`, `--force-authoring`, `--rpc-cors=all`, `--alice`, and `--tmp` flags, unless explicitly overridden"
)]
pub dev: bool,

#[arg(long, value_name = "name")]
#[arg(help = "The human-readable name for this node. It's used as network node name.")]
pub name: Option<String>,

#[arg(long, value_name = "validator")]
#[arg(
help = "Enable validator mode. The node will be started with the authority role and actively participate in any consensus task that it can (e.g. depending on availability of local keys)"
)]
pub validator: bool,

#[arg(long, value_name = "no_grandpa")]
#[arg(
help = "Disable GRANDPA voter when running in validator mode, otherwise disable the GRANDPA observer"
)]
pub no_grandpa: bool,

#[arg(long, value_name = "chain")]
#[arg(help = "Specify the chain specification. It can be one of the predefined ones")]
pub chain: Option<ChainOption>,

#[arg(long, value_name = "base_path")]
#[arg(help = "Specify custom base path")]
pub base_path: Option<String>,

#[arg(long, value_name = "chain")]
#[arg(help = "Choose sealing method")]
pub sealing: Option<SealingMethod>,

#[arg(long, value_name = "from_remote")]
#[arg(
help = "Prior to starting the node, the setup cmd will be executed using this value. If none is provided, setup will use the default config."
)]
pub from_remote: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Serialize)]
pub enum SealingMethod {
Manual,
Instant,
InstantFinality,
}

impl fmt::Display for SealingMethod {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
SealingMethod::Manual => write!(f, "manual"),
SealingMethod::Instant => write!(f, "instant"),
SealingMethod::InstantFinality => write!(f, "instant-finality"),
}
}
}

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Serialize)]
pub enum ChainOption {
Dev,
Local,
Staging,
}

#[arg(long, short, value_name = "name")]
#[arg(help = "Name.")]
pub name: Option<String>,
impl fmt::Display for ChainOption {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
ChainOption::Dev => write!(f, "dev"),
ChainOption::Local => write!(f, "local"),
ChainOption::Staging => write!(f, "staging"),
}
}
}
3 changes: 2 additions & 1 deletion src/command/deployments/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use clap::{Subcommand, ValueEnum};

use self::{
katana::{KatanaAccountArgs, KatanaCreateArgs, KatanaForkArgs, KatanaUpdateArgs},
torii::{ToriiCreateArgs, ToriiUpdateArgs},
madara::MadaraCreateArgs,
torii::{ToriiCreateArgs, ToriiUpdateArgs},
};

mod katana;
Expand Down Expand Up @@ -50,4 +50,5 @@ pub enum KatanaAccountCommands {
pub enum Service {
Katana,
Torii,
Madara,
}
2 changes: 1 addition & 1 deletion src/command/deployments/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
api::ApiClient,
command::deployments::update::update_deployment::{
DeploymentService, DeploymentTier,
UpdateDeploymentUpdateDeployment::{KatanaConfig, ToriiConfig, MadaraConfig},
UpdateDeploymentUpdateDeployment::{KatanaConfig, MadaraConfig, ToriiConfig},
UpdateKatanaConfigInput, UpdateServiceConfigInput, Variables,
},
};
Expand Down

0 comments on commit 5165e03

Please sign in to comment.