From 23e47c71d44deeb0aa39da3db27ebe7d4698b9b4 Mon Sep 17 00:00:00 2001 From: Anshal Shukla Date: Sun, 7 Jan 2024 23:26:42 +0530 Subject: [PATCH 01/17] add: env vars, branch based pull --- Cargo.lock | 1 + Cargo.toml | 1 + src/app/config.rs | 8 ++++---- src/cli/explorer.rs | 27 +++++++++++++++++++++++++-- src/cli/init.rs | 21 +++++++++++---------- src/utils/constants.rs | 4 ++++ src/utils/docker.rs | 13 +++++++------ src/utils/github.rs | 19 ++++++++++--------- src/utils/madara.rs | 8 +++++--- 9 files changed, 68 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2921d42..1b158b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1679,6 +1679,7 @@ dependencies = [ "hex", "inquire", "log", + "rand 0.8.5", "reqwest", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 58f8117..cd2cf61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,3 +28,4 @@ strum_macros = { version = "0.25.3", features = [] } thiserror = "1.0.52" tokio = { version = "1.35.1", features = ["rt", "rt-multi-thread", "macros"] } toml = "0.8.8" +rand = "0.8.5" diff --git a/src/app/config.rs b/src/app/config.rs index cfc1e8c..d634352 100644 --- a/src/app/config.rs +++ b/src/app/config.rs @@ -9,12 +9,12 @@ use crate::da::da_layers::DALayer; pub struct AppChainConfig { pub app_chain: String, pub base_path: String, - pub chain_id: String, + // pub chain_id: String, pub mode: RollupMode, pub da_layer: DALayer, - pub block_time: u64, - pub disable_fees: bool, - pub fee_token: String, + // pub block_time: u64, + // pub disable_fees: bool, + // pub fee_token: String, /// Stores commit hash of madara app chain build pub madara_version: String, /// Maintains version of config, will help in handling edge diff --git a/src/cli/explorer.rs b/src/cli/explorer.rs index 01fda4b..123180c 100644 --- a/src/cli/explorer.rs +++ b/src/cli/explorer.rs @@ -1,6 +1,29 @@ +use bollard::models::HostConfig; +use rand::distributions::Alphanumeric; +use rand::Rng; + use crate::utils::docker::run_docker_image; pub fn explorer() { - let env_vars = vec!["RPC_API_HOST=\"http://127.0.0.1:9944\""]; - run_docker_image("ghcr.io/lambdaclass/stark_compass_explorer:v0.2.34.2", "madara-explorer", env_vars); + let random_string: String = (0..64).map(|_| rand::thread_rng().sample(Alphanumeric).to_string()).collect(); + let secret_key_base = format!("SECRET_KEY_BASE={}", random_string); + + let env = vec![ + "RPC_API_HOST=\"http://127.0.0.1:9944\"", + "DB_TYPE=sqlite", + "DISABLE_MAINNET_SYNC=true", + "DISABLE_TESTNET_SYNC=true", + "TESTNET_RPC_API_HOST=\"http://127.0.0.1:9944\"", + "DATABASE_PATH=/use/exp.db", + &secret_key_base, + ]; + + let host_config = HostConfig { network_mode: Some(String::from("host")), ..Default::default() }; + + run_docker_image( + "ghcr.io/lambdaclass/stark_compass_explorer:v0.2.34.2", + "madara-explorer", + Some(env), + Some(host_config), + ); } diff --git a/src/cli/init.rs b/src/cli/init.rs index 69b1363..ee78b10 100644 --- a/src/cli/init.rs +++ b/src/cli/init.rs @@ -4,7 +4,7 @@ use inquire::InquireError; use strum::IntoEnumIterator; use thiserror::Error; -use super::prompt::{get_boolean_input, get_custom_input, get_option, get_text_input}; +use super::prompt::{get_option, get_text_input}; use crate::app::config::{AppChainConfig, ConfigVersion, RollupMode}; use crate::da::da_layers::{DAFactory, DALayer}; use crate::utils::constants::{APP_CONFIG_NAME, MADARA_REPO_NAME, MADARA_REPO_ORG}; @@ -51,13 +51,14 @@ fn generate_config() -> Result { let default_base_path = binding.to_str().unwrap_or("madara-data"); let base_path = get_text_input("Enter base path for data directory of your app chain:", Some(default_base_path))?; - let chain_id = get_text_input("Enter chain id for your app chain:", Some("MADARA"))?; + // let chain_id = get_text_input("Enter chain id for your app chain:", Some("MADARA"))?; let mode = get_option("Select mode for your app chain:", RollupMode::iter().collect::>())?; let da_layer = get_option("Select DA layer for your app chain:", DALayer::iter().collect::>())?; - let block_time = - get_custom_input::("Enter block time of chain:", Some(1000), Some("Time in ms (e.g, 1000, 2000)."))?; - let disable_fees = get_boolean_input("Do you want to disable fees for your app chain:", Some(false))?; - let fee_token = get_text_input("Enter fee token:", Some("STRK"))?; + // let block_time = + // get_custom_input::("Enter block time of chain:", Some(1000), Some("Time in ms (e.g, + // 1000, 2000)."))?; let disable_fees = get_boolean_input("Do you want to disable fees for your + // app chain:", Some(false))?; let fee_token = get_text_input("Enter fee token:", + // Some("STRK"))?; let madara_version = get_latest_commit_hash(MADARA_REPO_ORG, MADARA_REPO_NAME)?; let config_version = ConfigVersion::Version1; @@ -72,12 +73,12 @@ fn generate_config() -> Result { Ok(AppChainConfig { app_chain, base_path, - chain_id, + // chain_id, mode, da_layer, - block_time, - disable_fees, - fee_token, + // block_time, + // disable_fees, + // fee_token, madara_version, config_version, }) diff --git a/src/utils/constants.rs b/src/utils/constants.rs index 5a72f8f..51770b7 100644 --- a/src/utils/constants.rs +++ b/src/utils/constants.rs @@ -1,6 +1,10 @@ pub const MADARA_REPO_ORG: &str = "keep-starknet-strange"; pub const MADARA_REPO_NAME: &str = "madara"; +pub const KARNOT_REPO_ORG: &str = "karnotxyz"; + +pub const EXPLORER_COMPATIBLE_KARNOT_MADARA_BRANCH: &str = "custom_events_page"; + pub const APP_CONFIG_NAME: &str = "config.toml"; pub const APP_DA_CONFIG_NAME: &str = "da-config.json"; pub const APP_SECRET_PHRASE: &str = "secret-phrase.txt"; diff --git a/src/utils/docker.rs b/src/utils/docker.rs index ff4b096..e03090d 100644 --- a/src/utils/docker.rs +++ b/src/utils/docker.rs @@ -1,12 +1,12 @@ use bollard::container::{Config, CreateContainerOptions}; -use bollard::Docker; - use bollard::image::CreateImageOptions; +use bollard::models::HostConfig; +use bollard::Docker; use futures_util::TryStreamExt; -pub fn run_docker_image(image: &str, container_name: &str, env_vars: Vec<&str>) { +pub fn run_docker_image(image: &str, container_name: &str, env: Option>, host_config: Option) { is_docker_installed(); - match pull_and_start_docker_image(image, container_name, env_vars) { + match pull_and_start_docker_image(image, container_name, env, host_config) { Ok(..) => { log::info!("Successfully ran {}", container_name); } @@ -34,7 +34,8 @@ async fn is_docker_installed() -> bool { async fn pull_and_start_docker_image( image: &str, container_name: &str, - env_vars: Vec<&str>, + env: Option>, + host_config: Option, ) -> Result<(), Box> { let docker = Docker::connect_with_local_defaults().unwrap(); @@ -43,7 +44,7 @@ async fn pull_and_start_docker_image( .try_collect::>() .await?; - let config = Config { image: Some(image), tty: Some(true), env: Some(env_vars), ..Default::default() }; + let config = Config { image: Some(image), tty: Some(true), env, host_config, ..Default::default() }; let container_option = Some(CreateContainerOptions { name: container_name, ..Default::default() }); diff --git a/src/utils/github.rs b/src/utils/github.rs index 1d37566..b4bf704 100644 --- a/src/utils/github.rs +++ b/src/utils/github.rs @@ -32,7 +32,7 @@ pub fn get_latest_commit_hash(org: &str, repo: &str) -> Result Result<(), GithubError> { +pub fn git_clone(url: &str, path: &PathBuf, branch: Option<&str>) -> Result<(), GithubError> { if let Ok(repo) = Repository::open(path) { // Check if the repository is valid if repo.is_empty() == Ok(false) { @@ -51,14 +51,15 @@ pub fn git_clone(url: &str, path: &PathBuf) -> Result<(), GithubError> { fs::remove_dir_all(path)?; } - let output = Command::new("git") - .arg("clone") - .arg("--progress") - .arg(url) - .arg(path) - .stdout(Stdio::inherit()) - .stderr(Stdio::inherit()) - .output()?; + let mut cmd = Command::new("git"); + cmd.arg("clone").arg("--progress").arg(url).arg(path).stdout(Stdio::inherit()).stderr(Stdio::inherit()); + + if let Some(branch) = branch { + let clone_branch = format!("--branch={}", branch); + cmd.arg(clone_branch); + } + + let output = cmd.output()?; let status = output.status; diff --git a/src/utils/madara.rs b/src/utils/madara.rs index 3e800fd..9c96f8c 100644 --- a/src/utils/madara.rs +++ b/src/utils/madara.rs @@ -1,6 +1,8 @@ use crate::da::da_layers::DALayer; use crate::utils::cmd::execute_cmd; -use crate::utils::constants::{APP_DA_CONFIG_NAME, MADARA_REPO_NAME, MADARA_REPO_ORG}; +use crate::utils::constants::{ + APP_DA_CONFIG_NAME, EXPLORER_COMPATIBLE_KARNOT_MADARA_BRANCH, KARNOT_REPO_ORG, MADARA_REPO_NAME, +}; use crate::utils::errors::MadaraError; use crate::utils::github::git_clone; use crate::utils::paths::{get_app_home, get_madara_home}; @@ -8,10 +10,10 @@ use crate::utils::toml::regenerate_app_config; pub const GITHUB_BASE_URL: &str = "https://github.com"; pub fn clone_madara_and_build_repo() -> Result<(), MadaraError> { - let repo_url = format!("{}/{}/{}", GITHUB_BASE_URL, MADARA_REPO_ORG, MADARA_REPO_NAME); + let repo_url = format!("{}/{}/{}", GITHUB_BASE_URL, KARNOT_REPO_ORG, MADARA_REPO_NAME); let madara_path = get_madara_home()?.join("madara"); - match git_clone(&repo_url, &madara_path) { + match git_clone(&repo_url, &madara_path, Some(EXPLORER_COMPATIBLE_KARNOT_MADARA_BRANCH)) { Ok(_) => { log::info!("Successfully cloned Madara repo"); } From ef700938bf63768edfa00cf8c6f2743cdc27ddd6 Mon Sep 17 00:00:00 2001 From: Anshal Shukla Date: Sun, 7 Jan 2024 23:28:40 +0530 Subject: [PATCH 02/17] fix: lint --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index cd2cf61..d3113ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ git2 = "0.18.1" hex = { version = "0.4.3", features = [] } inquire = "0.6.2" log = "0.4.20" +rand = "0.8.5" reqwest = { version = "0.11.23", features = ["json", "blocking"] } serde = { version = "1.0.193", features = ["derive"] } serde_json = "1.0.109" @@ -28,4 +29,3 @@ strum_macros = { version = "0.25.3", features = [] } thiserror = "1.0.52" tokio = { version = "1.35.1", features = ["rt", "rt-multi-thread", "macros"] } toml = "0.8.8" -rand = "0.8.5" From d60ad67223d382f608e8d842a4213c8dca48dd77 Mon Sep 17 00:00:00 2001 From: Anshal Shukla Date: Sun, 7 Jan 2024 23:35:17 +0530 Subject: [PATCH 03/17] remove:keypair.json --- keypair.json | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 keypair.json diff --git a/keypair.json b/keypair.json deleted file mode 100644 index 1f27b29..0000000 --- a/keypair.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "accountId": "0x00d2bf2d5f62e38d70739c45b56be6170ea26da6370c529cbf3b854b2c95f44f", - "networkId": "substrate", - "publicKey": "0x00d2bf2d5f62e38d70739c45b56be6170ea26da6370c529cbf3b854b2c95f44f", - "secretPhrase": "input scrap paddle tape fiction dentist differ sorry cargo cube mammal width", - "secretSeed": "0xfc9b279be387e666c3e8013c5abdf6780c8db8cb0e5374812e651cd1c331212f", - "ss58Address": "5C5nTkXmGFf56Ew7fXz1TmYzdGyhcTvAZ3KQeLrXeMfcFTFa", - "ss58PublicKey": "5C5nTkXmGFf56Ew7fXz1TmYzdGyhcTvAZ3KQeLrXeMfcFTFa" -} From fa412773e2aeed240c8437f4011ae8790cb5f0ff Mon Sep 17 00:00:00 2001 From: Anshal Shukla Date: Mon, 8 Jan 2024 00:11:08 +0530 Subject: [PATCH 04/17] resolve comments --- src/cli/init.rs | 10 ---------- src/utils/constants.rs | 2 +- src/utils/madara.rs | 4 ++-- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/cli/init.rs b/src/cli/init.rs index ee78b10..afabd9e 100644 --- a/src/cli/init.rs +++ b/src/cli/init.rs @@ -51,14 +51,8 @@ fn generate_config() -> Result { let default_base_path = binding.to_str().unwrap_or("madara-data"); let base_path = get_text_input("Enter base path for data directory of your app chain:", Some(default_base_path))?; - // let chain_id = get_text_input("Enter chain id for your app chain:", Some("MADARA"))?; let mode = get_option("Select mode for your app chain:", RollupMode::iter().collect::>())?; let da_layer = get_option("Select DA layer for your app chain:", DALayer::iter().collect::>())?; - // let block_time = - // get_custom_input::("Enter block time of chain:", Some(1000), Some("Time in ms (e.g, - // 1000, 2000)."))?; let disable_fees = get_boolean_input("Do you want to disable fees for your - // app chain:", Some(false))?; let fee_token = get_text_input("Enter fee token:", - // Some("STRK"))?; let madara_version = get_latest_commit_hash(MADARA_REPO_ORG, MADARA_REPO_NAME)?; let config_version = ConfigVersion::Version1; @@ -73,12 +67,8 @@ fn generate_config() -> Result { Ok(AppChainConfig { app_chain, base_path, - // chain_id, mode, da_layer, - // block_time, - // disable_fees, - // fee_token, madara_version, config_version, }) diff --git a/src/utils/constants.rs b/src/utils/constants.rs index 51770b7..f3277ce 100644 --- a/src/utils/constants.rs +++ b/src/utils/constants.rs @@ -3,7 +3,7 @@ pub const MADARA_REPO_NAME: &str = "madara"; pub const KARNOT_REPO_ORG: &str = "karnotxyz"; -pub const EXPLORER_COMPATIBLE_KARNOT_MADARA_BRANCH: &str = "custom_events_page"; +pub const BRANCH_NAME: &str = "custom_events_page"; pub const APP_CONFIG_NAME: &str = "config.toml"; pub const APP_DA_CONFIG_NAME: &str = "da-config.json"; diff --git a/src/utils/madara.rs b/src/utils/madara.rs index 9c96f8c..ec681e2 100644 --- a/src/utils/madara.rs +++ b/src/utils/madara.rs @@ -1,7 +1,7 @@ use crate::da::da_layers::DALayer; use crate::utils::cmd::execute_cmd; use crate::utils::constants::{ - APP_DA_CONFIG_NAME, EXPLORER_COMPATIBLE_KARNOT_MADARA_BRANCH, KARNOT_REPO_ORG, MADARA_REPO_NAME, + APP_DA_CONFIG_NAME, BRANCH_NAME, KARNOT_REPO_ORG, MADARA_REPO_NAME, }; use crate::utils::errors::MadaraError; use crate::utils::github::git_clone; @@ -13,7 +13,7 @@ pub fn clone_madara_and_build_repo() -> Result<(), MadaraError> { let repo_url = format!("{}/{}/{}", GITHUB_BASE_URL, KARNOT_REPO_ORG, MADARA_REPO_NAME); let madara_path = get_madara_home()?.join("madara"); - match git_clone(&repo_url, &madara_path, Some(EXPLORER_COMPATIBLE_KARNOT_MADARA_BRANCH)) { + match git_clone(&repo_url, &madara_path, Some(BRANCH_NAME)) { Ok(_) => { log::info!("Successfully cloned Madara repo"); } From 77485a1a90eaa843226d325282800abede7145de Mon Sep 17 00:00:00 2001 From: Anshal Shukla Date: Mon, 8 Jan 2024 00:48:51 +0530 Subject: [PATCH 05/17] fix: explorer setup --- src/cli/explorer.rs | 22 +++++++++++++++++----- src/utils/docker.rs | 1 + 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/cli/explorer.rs b/src/cli/explorer.rs index 123180c..58f11fc 100644 --- a/src/cli/explorer.rs +++ b/src/cli/explorer.rs @@ -1,7 +1,9 @@ -use bollard::models::HostConfig; +use bollard::models::{HostConfig,PortBinding}; use rand::distributions::Alphanumeric; use rand::Rng; +use std::collections::HashMap; + use crate::utils::docker::run_docker_image; pub fn explorer() { @@ -9,16 +11,26 @@ pub fn explorer() { let secret_key_base = format!("SECRET_KEY_BASE={}", random_string); let env = vec![ - "RPC_API_HOST=\"http://127.0.0.1:9944\"", + "RPC_API_HOST=http://host.docker.internal:9944", "DB_TYPE=sqlite", - "DISABLE_MAINNET_SYNC=true", + "DISABLE_MAINNET_SYNC=false", "DISABLE_TESTNET_SYNC=true", - "TESTNET_RPC_API_HOST=\"http://127.0.0.1:9944\"", + "TESTNET_RPC_API_HOST=http://host.docker.internal:9944", "DATABASE_PATH=/use/exp.db", + "PHX_HOST=localhost", &secret_key_base, ]; - let host_config = HostConfig { network_mode: Some(String::from("host")), ..Default::default() }; + let mut port_bindings = HashMap::new(); + port_bindings.insert( + "4000/tcp".to_string(), + Some(vec![PortBinding { + host_ip: Some("0.0.0.0".to_string()), + host_port: Some("4000".to_string()), + }]), + ); + + let host_config = HostConfig { port_bindings: Some(port_bindings), ..Default::default() }; run_docker_image( "ghcr.io/lambdaclass/stark_compass_explorer:v0.2.34.2", diff --git a/src/utils/docker.rs b/src/utils/docker.rs index e03090d..9f13b6b 100644 --- a/src/utils/docker.rs +++ b/src/utils/docker.rs @@ -44,6 +44,7 @@ async fn pull_and_start_docker_image( .try_collect::>() .await?; + let config = Config { image: Some(image), tty: Some(true), env, host_config, ..Default::default() }; let container_option = Some(CreateContainerOptions { name: container_name, ..Default::default() }); From bc76edc89b240a6d11c97e39fe2e4b19b38486e5 Mon Sep 17 00:00:00 2001 From: Anshal Shukla Date: Mon, 8 Jan 2024 00:51:18 +0530 Subject: [PATCH 06/17] fix: lint --- src/cli/explorer.rs | 7 ++----- src/cli/init.rs | 9 +-------- src/utils/docker.rs | 1 - src/utils/madara.rs | 4 +--- 4 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/cli/explorer.rs b/src/cli/explorer.rs index 58f11fc..82c49c3 100644 --- a/src/cli/explorer.rs +++ b/src/cli/explorer.rs @@ -1,4 +1,4 @@ -use bollard::models::{HostConfig,PortBinding}; +use bollard::models::{HostConfig, PortBinding}; use rand::distributions::Alphanumeric; use rand::Rng; @@ -24,10 +24,7 @@ pub fn explorer() { let mut port_bindings = HashMap::new(); port_bindings.insert( "4000/tcp".to_string(), - Some(vec![PortBinding { - host_ip: Some("0.0.0.0".to_string()), - host_port: Some("4000".to_string()), - }]), + Some(vec![PortBinding { host_ip: Some("0.0.0.0".to_string()), host_port: Some("4000".to_string()) }]), ); let host_config = HostConfig { port_bindings: Some(port_bindings), ..Default::default() }; diff --git a/src/cli/init.rs b/src/cli/init.rs index afabd9e..f458511 100644 --- a/src/cli/init.rs +++ b/src/cli/init.rs @@ -64,14 +64,7 @@ fn generate_config() -> Result { } }; - Ok(AppChainConfig { - app_chain, - base_path, - mode, - da_layer, - madara_version, - config_version, - }) + Ok(AppChainConfig { app_chain, base_path, mode, da_layer, madara_version, config_version }) } fn write_config(config: &AppChainConfig) -> Result<(), InitError> { diff --git a/src/utils/docker.rs b/src/utils/docker.rs index 9f13b6b..e03090d 100644 --- a/src/utils/docker.rs +++ b/src/utils/docker.rs @@ -44,7 +44,6 @@ async fn pull_and_start_docker_image( .try_collect::>() .await?; - let config = Config { image: Some(image), tty: Some(true), env, host_config, ..Default::default() }; let container_option = Some(CreateContainerOptions { name: container_name, ..Default::default() }); diff --git a/src/utils/madara.rs b/src/utils/madara.rs index ec681e2..e47a68f 100644 --- a/src/utils/madara.rs +++ b/src/utils/madara.rs @@ -1,8 +1,6 @@ use crate::da::da_layers::DALayer; use crate::utils::cmd::execute_cmd; -use crate::utils::constants::{ - APP_DA_CONFIG_NAME, BRANCH_NAME, KARNOT_REPO_ORG, MADARA_REPO_NAME, -}; +use crate::utils::constants::{APP_DA_CONFIG_NAME, BRANCH_NAME, KARNOT_REPO_ORG, MADARA_REPO_NAME}; use crate::utils::errors::MadaraError; use crate::utils::github::git_clone; use crate::utils::paths::{get_app_home, get_madara_home}; From cb7efe63d7151fcf784e7d8dc290cf3b7cfb8a40 Mon Sep 17 00:00:00 2001 From: Anshal Shukla Date: Mon, 8 Jan 2024 00:56:38 +0530 Subject: [PATCH 07/17] remove: comments --- src/app/config.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/app/config.rs b/src/app/config.rs index d634352..c3b48ea 100644 --- a/src/app/config.rs +++ b/src/app/config.rs @@ -9,12 +9,8 @@ use crate::da::da_layers::DALayer; pub struct AppChainConfig { pub app_chain: String, pub base_path: String, - // pub chain_id: String, pub mode: RollupMode, pub da_layer: DALayer, - // pub block_time: u64, - // pub disable_fees: bool, - // pub fee_token: String, /// Stores commit hash of madara app chain build pub madara_version: String, /// Maintains version of config, will help in handling edge From 93b35c42bdc8bb4f4c901fb7537e113869e024ab Mon Sep 17 00:00:00 2001 From: Anshal Shukla Date: Mon, 8 Jan 2024 01:27:12 +0530 Subject: [PATCH 08/17] update: readme --- README.md | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2bd4a85..bcc6626 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,39 @@ # Madara CLI -A CLI tool to quickly deploy Madara app chains. +A command-line tool for rapid deployment of Madara app chains. + +## Dependencies + +1. [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) +2. [Rust](https://doc.rust-lang.org/book/ch01-01-installation.html) +3. [Docker](https://docs.docker.com/desktop/) + +## Quick Start + +1. Clone the `madara-cli` repo: + ```shell + $ git clone https://github.com/karnotxyz/madara-cli + ``` + +2. Navigate to the madara-cli directory and build the tool: + ```shell + $ cd madara-cli + $ cargo build --release + ``` + +3. Initialize a new app chain. Ensure to fund the logged account, especially if you've chosen Avail as your DA Layer. + ```shell + $ ./target/release/madara-cli init + ``` + +4. Run your app chain: + ```shell + $ ./target/release/madara-cli run + ``` + +5. Optionally, explore the StarkScan explorer. Accessible at http://localhost:4000. + ```shell + $ ./target/release/madara-cli explorer + ``` + +Congratulations! You now have a custom madara app running. \ No newline at end of file From a093ea614fb350a8fb8a1c253df29417153e5e50 Mon Sep 17 00:00:00 2001 From: Anshal Shukla Date: Mon, 8 Jan 2024 01:35:27 +0530 Subject: [PATCH 09/17] lint --- README.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index bcc6626..1d741be 100644 --- a/README.md +++ b/README.md @@ -11,29 +11,34 @@ A command-line tool for rapid deployment of Madara app chains. ## Quick Start 1. Clone the `madara-cli` repo: + ```shell - $ git clone https://github.com/karnotxyz/madara-cli + git clone https://github.com/karnotxyz/madara-cli ``` 2. Navigate to the madara-cli directory and build the tool: + ```shell - $ cd madara-cli - $ cargo build --release + cd madara-cli + cargo build --release ``` 3. Initialize a new app chain. Ensure to fund the logged account, especially if you've chosen Avail as your DA Layer. + ```shell - $ ./target/release/madara-cli init + ./target/release/madara-cli init ``` 4. Run your app chain: + ```shell - $ ./target/release/madara-cli run + ./target/release/madara-cli run ``` 5. Optionally, explore the StarkScan explorer. Accessible at http://localhost:4000. + ```shell - $ ./target/release/madara-cli explorer + ./target/release/madara-cli explorer ``` -Congratulations! You now have a custom madara app running. \ No newline at end of file +Congratulations! You now have a custom madara app running. From 3a1c4eac841f3aa8deff6a904a812c67020fa7e6 Mon Sep 17 00:00:00 2001 From: Anshal Shukla Date: Tue, 9 Jan 2024 16:12:07 +0530 Subject: [PATCH 10/17] setup --- docs/setup.md | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 docs/setup.md diff --git a/docs/setup.md b/docs/setup.md new file mode 100644 index 0000000..372aa63 --- /dev/null +++ b/docs/setup.md @@ -0,0 +1,77 @@ +# Installing Dependencies + +## Install `Git` + +Install the latest `git` version + +Instruction can be found on the [official site](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git). + +Verify the `git ` installation: + +```bash +git --version +git version 2.34.1 +``` + +## `Install Rust` + +Install the latest `rust` version. + +Instructions can be found on the [official site](https://www.rust-lang.org/tools/install). + +Verify the `rust` installation: + +```bash +rustc --version +rustc 1.75.0 (82e1608df 2023-12-21) +``` + +## `Docker` + +Install `docker`. It is recommended to follow the instructions from the +[official site](https://docs.docker.com/install/). + +Installing `docker` via `snap` or from the default repository can cause troubles. + +**Note:** On linux you may encounter the following error when you’ll try to work with `madara-cli`: + +``` +ERROR: Couldn't connect to Docker daemon - you might need to run `docker-machine start default`. +``` + +If so, you **do not need** to install `docker-machine`. Most probably, it means that your user is not added to +the`docker` group. You can check it as follows: + +```bash +docker-compose up # Should raise the same error. +sudo docker-compose up # Should start doing things. +``` + +If the first command fails, but the second succeeds, then you need to add your user to the `docker` group: + +```bash +sudo usermod -a -G docker your_user_name +``` + +After that, you should logout and login again (user groups are refreshed after the login). The problem should be +solved at this step. + +If logging out does not help, restarting the computer should. + +**There are few more dependencies required by `madara` to build various crates and related dependencies**. + +## `Ubuntu` + +These are only required on ubuntu systems. + +```bash +sudo apt update +sudo apt upgrade +sudo apt install build-essential + +sudo apt install pkg-config +sudo apt install libssl-dev +sudo apt install clang +sudo apt install protobuf-compiler +``` + From 141918a84ee7fa1b88c5dd432b292f42b9688539 Mon Sep 17 00:00:00 2001 From: Anshal Shukla Date: Wed, 10 Jan 2024 01:04:15 +0530 Subject: [PATCH 11/17] add --- README.md | 12 ++++++------ docs/setup.md | 25 ++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1d741be..348a605 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ A command-line tool for rapid deployment of Madara app chains. ## Dependencies -1. [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) -2. [Rust](https://doc.rust-lang.org/book/ch01-01-installation.html) -3. [Docker](https://docs.docker.com/desktop/) +There are a few dependencies that need to be installed to smoothly `madara-cli` + +[Installing dependencies] (./docs/setup.md) ## Quick Start @@ -26,19 +26,19 @@ A command-line tool for rapid deployment of Madara app chains. 3. Initialize a new app chain. Ensure to fund the logged account, especially if you've chosen Avail as your DA Layer. ```shell - ./target/release/madara-cli init + ./target/release/madara init ``` 4. Run your app chain: ```shell - ./target/release/madara-cli run + ./target/release/madara run ``` 5. Optionally, explore the StarkScan explorer. Accessible at http://localhost:4000. ```shell - ./target/release/madara-cli explorer + ./target/release/madara explorer ``` Congratulations! You now have a custom madara app running. diff --git a/docs/setup.md b/docs/setup.md index 372aa63..dae70f3 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -58,7 +58,7 @@ solved at this step. If logging out does not help, restarting the computer should. -**There are few more dependencies required by `madara` to build various crates and related dependencies**. +**Additionally, there are a few more dependencies required by madara for building various crates and related dependencies.**. ## `Ubuntu` @@ -75,3 +75,26 @@ sudo apt install clang sudo apt install protobuf-compiler ``` +## `MacOS` + +Verify `brew` installation: + +```bash +brew --version +Homebrew 4.2.2 +``` +If brew is not found, install using following command: + +```bash +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +``` + +Then install the following: + +```bash +brew install pkg-config +brew install openssl +brew install protobuf +``` + +**Make sure to follow these instructions to ensure a smooth setup for `madara`.** \ No newline at end of file From df3d42b790d54ba4a8800be7b8260be112ad0c51 Mon Sep 17 00:00:00 2001 From: Anshal Shukla Date: Wed, 10 Jan 2024 01:06:16 +0530 Subject: [PATCH 12/17] update --- README.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 348a605..05b085d 100644 --- a/README.md +++ b/README.md @@ -12,33 +12,33 @@ There are a few dependencies that need to be installed to smoothly `madara-cli` 1. Clone the `madara-cli` repo: - ```shell - git clone https://github.com/karnotxyz/madara-cli - ``` +```shell +git clone https://github.com/karnotxyz/madara-cli +``` 2. Navigate to the madara-cli directory and build the tool: - ```shell - cd madara-cli - cargo build --release - ``` +```shell +cd madara-cli +cargo build --release +``` 3. Initialize a new app chain. Ensure to fund the logged account, especially if you've chosen Avail as your DA Layer. - ```shell - ./target/release/madara init - ``` +```shell +./target/release/madara init +``` 4. Run your app chain: - ```shell - ./target/release/madara run - ``` +```shell +./target/release/madara run +``` 5. Optionally, explore the StarkScan explorer. Accessible at http://localhost:4000. - ```shell - ./target/release/madara explorer - ``` +```shell +./target/release/madara explorer +``` -Congratulations! You now have a custom madara app running. +**Congratulations! You now have a custom madara app running.** From e6c75a34d797f64a5eb9d29bf27db003a5331bd0 Mon Sep 17 00:00:00 2001 From: Anshal Shukla Date: Wed, 10 Jan 2024 01:07:39 +0530 Subject: [PATCH 13/17] fix hyperlink --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 05b085d..ace1621 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ A command-line tool for rapid deployment of Madara app chains. ## Dependencies -There are a few dependencies that need to be installed to smoothly `madara-cli` +There are a few dependencies that need to be installed to smoothly `madara-cli`. -[Installing dependencies] (./docs/setup.md) +[Installing dependencies](./docs/setup.md) ## Quick Start From c9497d3867d01b5cde1222636934da69c34da1ba Mon Sep 17 00:00:00 2001 From: Anshal Shukla Date: Wed, 10 Jan 2024 01:08:51 +0530 Subject: [PATCH 14/17] aaa --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ace1621..6d30050 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ cd madara-cli cargo build --release ``` -3. Initialize a new app chain. Ensure to fund the logged account, especially if you've chosen Avail as your DA Layer. +3. Initialize a new app chain. Please fund the DA account (if applicable). ```shell ./target/release/madara init From 538470cf5cc88ab4062ebf2033797ea54e7a8e06 Mon Sep 17 00:00:00 2001 From: Anshal Shukla Date: Wed, 10 Jan 2024 01:14:26 +0530 Subject: [PATCH 15/17] lint --- README.md | 30 +++++++++++++++--------------- docs/setup.md | 3 ++- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 6d30050..5e08bbf 100644 --- a/README.md +++ b/README.md @@ -10,35 +10,35 @@ There are a few dependencies that need to be installed to smoothly `madara-cli`. ## Quick Start -1. Clone the `madara-cli` repo: +* Clone repo: -```shell +```bash git clone https://github.com/karnotxyz/madara-cli ``` -2. Navigate to the madara-cli directory and build the tool: +* Build repo: -```shell -cd madara-cli -cargo build --release +```bash +cd madara-cli +cargo build --release ``` - -3. Initialize a new app chain. Please fund the DA account (if applicable). -```shell -./target/release/madara init +* Initialize a new app chain. Please fund the DA account (if applicable): + +```bash +./target/release/madara init ``` -4. Run your app chain: +* Run your app chain: -```shell +```bash ./target/release/madara run ``` -5. Optionally, explore the StarkScan explorer. Accessible at http://localhost:4000. +* Optionally, explore the StarkScan explorer. Accessible at [http://localhost:4000](http://localhost:4000). -```shell +```bash ./target/release/madara explorer ``` - + **Congratulations! You now have a custom madara app running.** diff --git a/docs/setup.md b/docs/setup.md index dae70f3..7d1d994 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -83,6 +83,7 @@ Verify `brew` installation: brew --version Homebrew 4.2.2 ``` + If brew is not found, install using following command: ```bash @@ -97,4 +98,4 @@ brew install openssl brew install protobuf ``` -**Make sure to follow these instructions to ensure a smooth setup for `madara`.** \ No newline at end of file +**Make sure to follow these instructions to ensure a smooth setup for `madara`.** From 88e1f85e509aafd87072910a6ad78295634325f7 Mon Sep 17 00:00:00 2001 From: Anshal Shukla Date: Wed, 10 Jan 2024 01:17:29 +0530 Subject: [PATCH 16/17] lint --- README.md | 10 +++++----- docs/setup.md | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5e08bbf..9c6796f 100644 --- a/README.md +++ b/README.md @@ -10,32 +10,32 @@ There are a few dependencies that need to be installed to smoothly `madara-cli`. ## Quick Start -* Clone repo: +- Clone repo: ```bash git clone https://github.com/karnotxyz/madara-cli ``` -* Build repo: +- Build repo: ```bash cd madara-cli cargo build --release ``` -* Initialize a new app chain. Please fund the DA account (if applicable): +- Initialize a new app chain. Please fund the DA account (if applicable): ```bash ./target/release/madara init ``` -* Run your app chain: +- Run your app chain: ```bash ./target/release/madara run ``` -* Optionally, explore the StarkScan explorer. Accessible at [http://localhost:4000](http://localhost:4000). +- Optionally, explore the StarkScan explorer. Accessible at [http://localhost:4000](http://localhost:4000). ```bash ./target/release/madara explorer diff --git a/docs/setup.md b/docs/setup.md index 7d1d994..b29530d 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -6,7 +6,7 @@ Install the latest `git` version Instruction can be found on the [official site](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git). -Verify the `git ` installation: +Verify the `git` installation: ```bash git --version @@ -35,7 +35,7 @@ Installing `docker` via `snap` or from the default repository can cause troubles **Note:** On linux you may encounter the following error when you’ll try to work with `madara-cli`: -``` +```bash ERROR: Couldn't connect to Docker daemon - you might need to run `docker-machine start default`. ``` From c77029e41f3d088f60bd3c0c4703d30927e73035 Mon Sep 17 00:00:00 2001 From: apoorvsadana <95699312+apoorvsadana@users.noreply.github.com> Date: Thu, 11 Jan 2024 16:09:45 +0530 Subject: [PATCH 17/17] review fixes --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9c6796f..2a1a66e 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A command-line tool for rapid deployment of Madara app chains. ## Dependencies -There are a few dependencies that need to be installed to smoothly `madara-cli`. +There are a few dependencies that need to be installed to smoothly use `madara-cli`. [Installing dependencies](./docs/setup.md) @@ -35,7 +35,7 @@ cargo build --release ./target/release/madara run ``` -- Optionally, explore the StarkScan explorer. Accessible at [http://localhost:4000](http://localhost:4000). +- Optionally, explore the StarkCompass explorer. Accessible at [http://localhost:4000](http://localhost:4000). ```bash ./target/release/madara explorer