diff --git a/examples/neutron/Makefile b/examples/neutron/Makefile deleted file mode 100644 index 9d31fefc4..000000000 --- a/examples/neutron/Makefile +++ /dev/null @@ -1,54 +0,0 @@ -NAME = neutron -FILE = configs/local.yaml - -HELM_REPO = starship -HELM_CHART = devnet -HELM_VERSION = v0.2.1 - -############################################################################### -### Helm Charts ### -############################################################################### - -.PHONY: start -start: install port-forward - -.PHONY: stop -stop: stop-forward delete - -############################################################################### -### Helm Charts ### -############################################################################### - -install: - bash $(CURDIR)/scripts/install.sh --config $(FILE) --name $(NAME) --version $(HELM_VERSION) - -debug: - bash $(CURDIR)/scripts/install.sh --config $(FILE) --name $(NAME) --dry-run --version $(HELM_VERSION) - -delete: - -helm delete $(NAME) - -############################################################################### -### Port forward ### -############################################################################### - -.PHONY: port-forward -port-forward: - bash $(CURDIR)/scripts/port-forward.sh --config=$(FILE) - -.PHONY: stop-forward -stop-forward: - -pkill -f "port-forward" - -############################################################################### -### Local Kind Setup ### -############################################################################### -KIND_CLUSTER=starship - -.PHONY: setup-kind -setup-kind: - kind create cluster --name $(KIND_CLUSTER) - -.PHONY: clean-kind -clean-kind: - kind delete cluster --name $(KIND_CLUSTER) diff --git a/examples/neutron/README.md b/examples/neutron/README.md index 8d3f9a8fb..ce45be1c5 100644 --- a/examples/neutron/README.md +++ b/examples/neutron/README.md @@ -9,7 +9,7 @@ In this repo we only spin up the infra, so tests can be run against this infra f In the `examples/neutron` dir, run ```bash -make setup-deps ## Installs dependencies for Starship +yarn ``` ### Manul install (alternate) @@ -22,12 +22,6 @@ Alternatively to the setup script one can just install the deps directly: ## Connect to a kubernetes cluster ### Spinup local cluster -On Linux: -```bash -make setup-kind -``` - -On Mac: Use Docker Desktop to setup kubernetes cluster: https://docs.docker.com/desktop/kubernetes/#turn-on-kubernetes ### Connect to a remote cluster (alternate) diff --git a/examples/neutron/configs/ci.yaml b/examples/neutron/configs/ci.yaml index 574517b8b..943499d47 100644 --- a/examples/neutron/configs/ci.yaml +++ b/examples/neutron/configs/ci.yaml @@ -1,11 +1,15 @@ +name: neutron-dev +version: 0.2.10 + chains: - id: neutron-1 name: neutron - numValidators: 1 + numValidators: 1 # only support for single validator node for ics faucet: enabled: false ics: enabled: true + provider: cosmoshub-4 ports: rest: 1313 rpc: 26653 @@ -15,13 +19,7 @@ chains: memory: "200M" - id: cosmoshub-4 name: cosmoshub - numValidators: 1 - faucet: - type: cosmjs - concurrency: 2 - resources: - cpu: "0.2" - memory: "200M" + numValidators: 1 # only support for single validator node for ics ports: rest: 1317 rpc: 26657 @@ -35,6 +33,19 @@ relayers: - name: neutron-cosmos type: hermes replicas: 1 + chains: + - neutron-1 + - cosmoshub-4 + ics: + enabled: true + consumer: neutron-1 + provider: cosmoshub-4 + resources: + cpu: "0.2" + memory: "200M" + - name: nqr-neutron-cosmos + type: neutron-query-relayer + replicas: 1 chains: - neutron-1 - cosmoshub-4 @@ -46,8 +57,6 @@ registry: enabled: true ports: rest: 8081 - grpc: 9091 resources: cpu: "0.1" memory: "100M" - diff --git a/examples/neutron/configs/devnet.yaml b/examples/neutron/configs/devnet.yaml index 0a4f7fe50..52c96a5b9 100644 --- a/examples/neutron/configs/devnet.yaml +++ b/examples/neutron/configs/devnet.yaml @@ -1,16 +1,22 @@ +name: neutron-dev +version: 0.2.10 + chains: - id: neutron-1 name: neutron - numValidators: 1 + numValidators: 1 # only support for single validator node for ics faucet: enabled: false + ics: + enabled: true + provider: cosmoshub-4 ports: rest: 1313 rpc: 26653 exposer: 38083 - id: cosmoshub-4 name: cosmoshub - numValidators: 4 + numValidators: 1 # only support for single validator node for ics ports: rest: 1317 rpc: 26657 @@ -24,10 +30,23 @@ relayers: chains: - neutron-1 - cosmoshub-4 + ics: + enabled: true + consumer: neutron-1 + provider: cosmoshub-4 + - name: nqr-neutron-cosmos + type: neutron-query-relayer + replicas: 1 + chains: + - neutron-1 + - cosmoshub-4 registry: enabled: true ports: rest: 8081 - grpc: 9091 +explorer: + enabled: true + ports: + rest: 8080 diff --git a/examples/neutron/configs/local.yaml b/examples/neutron/configs/local.yaml index cbd065f87..c4090e6f3 100644 --- a/examples/neutron/configs/local.yaml +++ b/examples/neutron/configs/local.yaml @@ -1,18 +1,22 @@ +name: neutron-dev +version: 0.2.10 + chains: - id: neutron-1 name: neutron - numValidators: 1 + numValidators: 1 # only support for single validator node for ics faucet: enabled: false ics: enabled: true + provider: cosmoshub-4 ports: rest: 1313 rpc: 26653 exposer: 38083 - id: cosmoshub-4 name: cosmoshub - numValidators: 1 + numValidators: 1 # only support for single validator node for ics ports: rest: 1317 rpc: 26657 @@ -26,10 +30,18 @@ relayers: chains: - neutron-1 - cosmoshub-4 + ics: + enabled: true + consumer: neutron-1 + provider: cosmoshub-4 + - name: nqr-neutron-cosmos + type: neutron-query-relayer + replicas: 1 + chains: + - neutron-1 + - cosmoshub-4 registry: enabled: true ports: rest: 8081 - grpc: 9091 - diff --git a/examples/neutron/package.json b/examples/neutron/package.json new file mode 100644 index 000000000..29e6e1db8 --- /dev/null +++ b/examples/neutron/package.json @@ -0,0 +1,10 @@ +{ + "name": "neutron", + "version": "1.0.0", + "description": "Neutron Starship example and integration", + "main": "index.js", + "license": "MIT", + "dependencies": { + "@starship-ci/cli": "^2.10.0" + } +} diff --git a/examples/neutron/scripts/dev-setup.sh b/examples/neutron/scripts/dev-setup.sh deleted file mode 100755 index a42c2ceed..000000000 --- a/examples/neutron/scripts/dev-setup.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -function color() { - local color=$1 - shift - local black=30 red=31 green=32 yellow=33 blue=34 magenta=35 cyan=36 white=37 - local color_code=${!color:-$green} - printf "\033[%sm%s\033[0m\n" "$color_code" "$*" -} - -# Define a function to install a binary on macOS -install_macos() { - case $1 in - docker) color red "Please install docker. Follow: https://docs.docker.com/desktop/install/mac-install/" ;; - kubectl) brew install kubectl ;; - helm) brew install helm ;; - yq) brew install yq ;; - kind) brew install kind ;; - esac -} - -# Define a function to install a binary on Linux -install_linux() { - color green "Installing $1 at ~/.local/bin, please add it to PATH" - mkdir -p ~/.local/bin - case $1 in - docker) color red "Please install docker. Follow: https://docs.docker.com/engine/install/ubuntu/" ;; - kubectl) curl -Lks "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" > ~/.local/bin/kubectl && chmod +x ~/.local/bin/kubectl ;; - helm) curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash ;; - yq) curl -Lks "https://github.com/mikefarah/yq/releases/download/v4.33.3/yq_linux_amd64" > ~/.local/bin/yq && chmod +x ~/.local/bin/yq ;; - kind) curl -Lks https://kind.sigs.k8s.io/dl/v0.18.1/kind-linux-amd64 > ~/.local/bin/kind && chmod +x ~/.local/bin/kind ;; - esac -} - -# Define a function to install a binary -install_binary() { - if [[ $(uname -s) == "Darwin" ]]; then - install_macos $1 - else - install_linux $1 - fi -} - -# Define a function to check for the presence of a binary -check_binary() { - if ! command -v $1 &> /dev/null - then - echo "$1 is not installed" - install_binary $1 - if ! command -v $1 &> /dev/null - then - color red "Installation of $1 failed, exiting..." - color red "Please install $1 manually, then run me again to verify the installation" - exit 1 - fi - fi -} - -# Check the binaries -check_binary kubectl -check_binary helm -check_binary yq -check_binary kind -check_binary docker - -color green "All binaries are installed" diff --git a/examples/neutron/scripts/install.sh b/examples/neutron/scripts/install.sh deleted file mode 100755 index 57a559982..000000000 --- a/examples/neutron/scripts/install.sh +++ /dev/null @@ -1,123 +0,0 @@ -#!/bin/bash - -## Script used to install the helm chart for the devnet from a config file -## Usage: -## ./scripts/install.sh --coinfig -## Options: -## -c|--config: config file to use (default: config.yaml) -## -v|--version: helm chart version (default: 0.1.43) - -set -euo pipefail - -# read config file from args into variable -CONFIGFILE="config.yaml" - -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -echo "Script dir: ${SCRIPT_DIR}" - -# default values -DRY_RUN="" -TIMEOUT="" -NAMESPACE="" -HELM_REPO="starship" -HELM_CHART="starship/devnet" -HELM_REPO_URL="https://cosmology-tech.github.io/starship/" -HELM_CHART_VERSION="0.1.47" - -# check_helm function verifies the helm binary is installed -function check_helm() { - if ! command -v helm &> /dev/null - then - echo "helm could not be found; please install it first!!!" - exit - fi -} - -# setup_helm function adds the helm repo and updates it -function setup_helm() { - if [ -d "$HELM_CHART" ]; then - echo "using local helm chart" - return - fi - helm repo add ${HELM_REPO} ${HELM_REPO_URL} - helm repo update - helm search repo ${HELM_CHART} --version ${HELM_CHART_VERSION} -} - -function set_helm_args() { - if [[ $TIMEOUT ]]; then - args="$args --timeout $TIMEOUT --wait --debug" - fi - if [[ $NAMESPACE ]]; then - args="$args --namespace $NAMESPACE --create-namespace" - fi - if [[ $DRY_RUN ]]; then - args="$args --dry-run --debug" - fi - num_chains=$(yq -r ".chains | length - 1" ${CONFIGFILE}) - if [[ $num_chains -lt 0 ]]; then - echo "No chains to parse: num: $num_chains" - return 0 - fi - for i in $(seq 0 $num_chains); do - chain=$(yq -r ".chains[$i].name" ${CONFIGFILE}) - scripts=$(yq -r ".chains[$i].scripts" ${CONFIGFILE}) - if [[ "$scripts" == "null" ]]; then - return 0 - fi - datadir="$(cd "$(dirname -- "${CONFIGFILE}")" >/dev/null; pwd -P)" - for script in $(yq -r ".chains[$i].scripts | keys | .[]" ${CONFIGFILE}); do - args="$args --set-file chains[$i].scripts.$script.data=$datadir/$(yq -r ".chains[$i].scripts.$script.file" ${CONFIGFILE})" - done - done -} - -function install_chart() { - args="" - set_helm_args - echo "name: ${HELM_NAME}, args: $args, chart: ${HELM_CHART}, version: ${HELM_CHART_VERSION}" - helm install ${HELM_NAME} ${HELM_CHART} --version ${HELM_CHART_VERSION} -f ${CONFIGFILE} $args -} - -while [ $# -gt 0 ]; do - case "$1" in - -c|--config) - CONFIGFILE="$2" - shift 2 # past argument=value - ;; - -v|--version) - HELM_CHART_VERSION="$2" - shift 2 # past argument - ;; - -t|--timeout) - TIMEOUT="$2" - shift 2 # past argument - ;; - -n|--name) - HELM_NAME="$2" - shift 2 # past argument - ;; - --namespace) - NAMESPACE="$2" - shift 2 # past argument - ;; - --chart) - HELM_CHART="$2" - shift 2 # past argument - ;; - --dry-run) - DRY_RUN=1 - shift # past argument - ;; - -*|--*) - echo "Unknown option $1" - exit 1 - ;; - *) - ;; - esac -done - -check_helm -setup_helm -install_chart diff --git a/examples/neutron/scripts/port-forward.sh b/examples/neutron/scripts/port-forward.sh deleted file mode 100755 index 071741da0..000000000 --- a/examples/neutron/scripts/port-forward.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -function color() { - local color=$1 - shift - local black=30 red=31 green=32 yellow=33 blue=34 magenta=35 cyan=36 white=37 - local color_code=${!color:-$green} - printf "\033[%sm%s\033[0m\n" "$color_code" "$*" -} - -function stop_port_forward() { - color green "Trying to stop all port-forward, if any...." - PIDS=$(ps -ef | grep -i -e 'kubectl port-forward' | grep -v 'grep' | cat | awk '{print $2}') || true - for p in $PIDS; do - kill -15 $p - done - sleep 2 -} - -# Default values -CHAIN_RPC_PORT=26657 -CHAIN_COMETMOCK_PORT=22331 -CHAIN_GRPC_PORT=9090 -CHAIN_LCD_PORT=1317 -CHAIN_EXPOSER_PORT=8081 -CHAIN_FAUCET_PORT=8000 -EXPLORER_LCD_PORT=8080 -REGISTRY_LCD_PORT=8080 -REGISTRY_GRPC_PORT=9090 - -for i in "$@"; do - case $i in - -c=*|--config=*) - CONFIGFILE="${i#*=}" - shift # past argument=value - ;; - -*|--*) - echo "Unknown option $i" - exit 1 - ;; - *) - ;; - esac -done - -stop_port_forward - -echo "Port forwarding for config ${CONFIGFILE}" -echo "Port forwarding all chains" -num_chains=$(yq -r ".chains | length - 1" ${CONFIGFILE}) -if [[ $num_chains -lt 0 ]]; then - echo "No chains to port-forward: num: $num_chains" - exit 1 -fi -for i in $(seq 0 $num_chains); do - # derive chain pod name from chain id - # https://github.com/cosmology-tech/starship/blob/main/charts/devnet/templates/_helpers.tpl#L56 - chain=$(yq -r ".chains[$i].name" ${CONFIGFILE} ) - chain=${chain/_/"-"} - localrpc=$(yq -r ".chains[$i].ports.rpc" ${CONFIGFILE} ) - localgrpc=$(yq -r ".chains[$i].ports.grpc" ${CONFIGFILE} ) - locallcd=$(yq -r ".chains[$i].ports.rest" ${CONFIGFILE} ) - localexp=$(yq -r ".chains[$i].ports.exposer" ${CONFIGFILE}) - localfaucet=$(yq -r ".chains[$i].ports.faucet" ${CONFIGFILE}) - color yellow "chains: forwarded $chain" - if [[ $(yq -r ".chains[$i].cometmock.enabled" $CONFIGFILE) == "true" ]]; - then - [[ "$localrpc" != "null" ]] && color yellow " cometmock rpc to http://localhost:$localrpc" && kubectl port-forward pods/$chain-cometmock-0 $localrpc:$CHAIN_COMETMOCK_PORT > /dev/null 2>&1 & - else - [[ "$localrpc" != "null" ]] && color yellow " rpc to http://localhost:$localrpc" && kubectl port-forward pods/$chain-genesis-0 $localrpc:$CHAIN_RPC_PORT > /dev/null 2>&1 & - fi - [[ "$localgrpc" != "null" ]] && color yellow " grpc to http://localhost:$localgrpc" && kubectl port-forward pods/$chain-genesis-0 $localgrpc:$CHAIN_GRPC_PORT > /dev/null 2>&1 & - [[ "$locallcd" != "null" ]] && color yellow " lcd to http://localhost:$locallcd" && kubectl port-forward pods/$chain-genesis-0 $locallcd:$CHAIN_LCD_PORT > /dev/null 2>&1 & - [[ "$localexp" != "null" ]] && color yellow " exposer to http://localhost:$localexp" && kubectl port-forward pods/$chain-genesis-0 $localexp:$CHAIN_EXPOSER_PORT > /dev/null 2>&1 & - [[ "$localfaucet" != "null" ]] && color yellow " faucet to http://localhost:$localfaucet" && kubectl port-forward pods/$chain-genesis-0 $localfaucet:$CHAIN_FAUCET_PORT > /dev/null 2>&1 & - sleep 1 -done - -echo "Port forward services" - -if [[ $(yq -r ".registry.enabled" $CONFIGFILE) == "true" ]]; -then - kubectl port-forward service/registry 8081:$REGISTRY_LCD_PORT > /dev/null 2>&1 & - kubectl port-forward service/registry 9091:$REGISTRY_GRPC_PORT > /dev/null 2>&1 & - sleep 1 - color yellow "registry: forwarded registry lcd to grpc http://localhost:8081, to http://localhost:9091" -fi - -if [[ $(yq -r ".explorer.enabled" $CONFIGFILE) == "true" ]]; -then - kubectl port-forward service/explorer 8080:$EXPLORER_LCD_PORT > /dev/null 2>&1 & - sleep 1 - color green "Open the explorer to get started.... http://localhost:8080" -fi