Skip to content

Commit

Permalink
feat(cli)!: update to use new chart structure, dusk-2 (#611)
Browse files Browse the repository at this point in the history
## Summary
Updates the CLI to work with dusk-2 and the many chart structural
updates since then.

## Background
Migrating to dusk-2 which uses new charts which are improved, but have
some structural differences

## Changes
- added a `debug` flag and default false on deploy. Now defaults to not
printing all k8s
- deduped the sequencer rpc constants
- updated to support namespaces with the new globals
- added naming on the celestia light node to avoid collisions in same
namespace
- made namespaces set via the rollup config file

## Testing
Manually deployed a local chart

## Breaking Changelist
- Different APIs hit, supports different charts. The yaml files from
previous cli will not be compatible.
  • Loading branch information
joroshiba authored Dec 11, 2023
1 parent 33c1a37 commit bedd261
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 50 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/astria-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "astria-cli"
version = "0.1.0"
version = "0.2.0"
edition = "2021"

[[bin]]
Expand Down
2 changes: 2 additions & 0 deletions crates/astria-cli/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use crate::cli::{
sequencer::Command as SequencerCommand,
};

const DEFAULT_SEQUENCER_RPC: &str = "https://rpc.sequencer.dusk-2.devnet.astria.org";

/// A CLI for deploying and managing Astria services and related infrastructure.
#[derive(Debug, Parser)]
#[clap(name = "astria-cli", version)]
Expand Down
15 changes: 7 additions & 8 deletions crates/astria-cli/src/cli/rollup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ use color_eyre::eyre;
use serde::Serialize;

const DEFAULT_ROLLUP_CHART_PATH: &str =
"https://astriaorg.github.io/dev-cluster/astria-evm-rollup-0.4.4.tgz";
const DEFAULT_SEQUENCER_RPC: &str = "https://rpc.sequencer.dusk-1.devnet.astria.org";
const DEFAULT_SEQUENCER_WS: &str = "wss://rpc.sequencer.dusk-1.devnet.astria.org/websocket";
"https://astriaorg.github.io/dev-cluster/astria-evm-rollup-0.7.1.tgz";
const DEFAULT_SEQUENCER_WS: &str = "wss://rpc.sequencer.dusk-2.devnet.astria.org/websocket";
const DEFAULT_LOG_LEVEL: &str = "debug";
const DEFAULT_NETWORK_ID: u64 = 1337;
const DEFAULT_HOSTNAME: &str = "localdev.me";
Expand Down Expand Up @@ -68,10 +67,6 @@ pub struct ConfigCreateArgs {
/// The Network ID for the EVM chain
#[clap(long = "rollup.network-id", env = "ROLLUP_NETWORK_ID", default_value_t = DEFAULT_NETWORK_ID)]
pub network_id: u64,
/// When enabled, rollup will skip blocks which contain zero transactions.
#[clap(long = "rollup.skip-empty-blocks", env = "ROLLUP_SKIP_EMPTY_BLOCKS")]
pub skip_empty_blocks: bool,

/// List of genesis accounts to fund, in the form of `address:balance`
#[clap(
long = "rollup.genesis-accounts",
Expand Down Expand Up @@ -99,7 +94,7 @@ pub struct ConfigCreateArgs {
#[clap(
long = "sequencer.rpc",
env = "ROLLUP_SEQUENCER_RPC",
default_value = DEFAULT_SEQUENCER_RPC
default_value = crate::cli::DEFAULT_SEQUENCER_RPC
)]
pub sequencer_rpc: String,
/// Optional. Will default to 'localdev.me' for local deployments. Will need to separately
Expand Down Expand Up @@ -219,6 +214,10 @@ pub struct DeploymentCreateArgs {
// that overwrite the key on drop and don't reveal it when printing.
#[clap(long, env = "ROLLUP_SEQUENCER_PRIVATE_KEY")]
pub(crate) sequencer_private_key: String,
/// Set if you want to see all k8s resources created by the deployment
/// Set if you want to do a dry run of the deployment
#[clap(long, env = "ROLLUP_DEBUG_DEPLOY", default_value = "false")]
pub(crate) debug: bool,
}

#[derive(Args, Debug)]
Expand Down
12 changes: 7 additions & 5 deletions crates/astria-cli/src/cli/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ use color_eyre::{
eyre::Context,
};

const DEFAULT_SEQUENCER_RPC: &str = "https://rpc.sequencer.dusk-1.devnet.astria.org";

/// Interact with a Sequencer node
#[derive(Debug, Subcommand)]
pub enum Command {
Expand Down Expand Up @@ -55,7 +53,7 @@ pub struct BasicAccountArgs {
#[clap(
long,
env = "SEQUENCER_URL",
default_value = DEFAULT_SEQUENCER_RPC
default_value = crate::cli::DEFAULT_SEQUENCER_RPC
)]
pub(crate) sequencer_url: String,
/// The address of the Sequencer account
Expand All @@ -80,7 +78,7 @@ pub struct TransferArgs {
#[clap(
long,
env = "SEQUENCER_URL",
default_value = DEFAULT_SEQUENCER_RPC
default_value = crate::cli::DEFAULT_SEQUENCER_RPC
)]
pub(crate) sequencer_url: String,
}
Expand Down Expand Up @@ -112,7 +110,11 @@ pub enum BlockHeightCommand {
#[derive(Args, Debug)]
pub struct BlockHeightGetArgs {
/// The url of the Sequencer node
#[clap(long)]
#[clap(
long,
env = "SEQUENCER_URL",
default_value = crate::cli::DEFAULT_SEQUENCER_RPC
)]
pub(crate) sequencer_url: String,
}

Expand Down
19 changes: 12 additions & 7 deletions crates/astria-cli/src/commands/rollup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ pub(crate) fn create_deployment(args: &DeploymentCreateArgs) -> eyre::Result<()>
let helm = helm_from_env();
let mut cmd = Command::new(helm.clone());
cmd.arg("install")
.arg("--debug")
.arg("--values")
.arg(rollup.deployment_config.get_filename())
// TODO: https://github.com/astriaorg/astria/issues/594
Expand All @@ -213,15 +212,17 @@ pub(crate) fn create_deployment(args: &DeploymentCreateArgs) -> eyre::Result<()>
))
.arg(rollup.deployment_config.get_chart_release_name())
.arg(&args.chart_path)
.arg("--set")
.arg(format!("namespace={}", rollup.namespace))
.arg(format!("--namespace={}", rollup.namespace))
.arg(format!("--namespace={}", rollup.globals_config.namespace))
.arg("--create-namespace");

if args.dry_run {
cmd.arg("--dry-run");
}

if args.debug {
cmd.arg("--debug");
}

match cmd.output() {
Err(e) => {
panic!("failed deploying config: failed to invoke helm (path: {helm:?}): {e:?}");
Expand Down Expand Up @@ -263,7 +264,7 @@ pub(crate) fn delete_deployment(args: &DeploymentDeleteArgs) -> eyre::Result<()>
let mut cmd = Command::new(helm.clone());
cmd.arg("uninstall")
.arg(rollup.deployment_config.get_chart_release_name())
.arg(format!("--namespace={}", rollup.namespace));
.arg(format!("--namespace={}", rollup.globals_config.namespace));

match cmd.output() {
Err(e) => {
Expand Down Expand Up @@ -327,14 +328,13 @@ mod test {
name: "test".to_string(),
chain_id: None,
network_id: 0,
skip_empty_blocks: false,
genesis_accounts: vec![],
sequencer_initial_block_height: Some(1),
sequencer_websocket: String::new(),
sequencer_rpc: String::new(),
log_level: String::new(),
hostname: String::new(),
namespace: String::new(),
namespace: "namespace_test".to_string(),
}
}

Expand All @@ -346,6 +346,11 @@ mod test {

let file_path = PathBuf::from("test-rollup-conf.yaml");
assert!(file_path.exists());

let file = File::open(&file_path).unwrap();
let rollup: Rollup = serde_yaml::from_reader(file).unwrap();
assert_eq!(rollup.globals_config.namespace, args.namespace);
assert_eq!(rollup.deployment_config.get_rollup_name(), args.name);
})
.await;
}
Expand Down
Loading

0 comments on commit bedd261

Please sign in to comment.