Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example: add injective example to examples/ dir #251

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions examples/injective/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
NAME = injective
FILE = configs/local.yaml

HELM_REPO = starship
HELM_CHART = devnet
HELM_VERSION = v0.1.46

###############################################################################
### 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)
95 changes: 95 additions & 0 deletions examples/injective/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Injective dev environment
Infra setup for spinning up injective nodes with other cosmos nodes/chains, relayers and explorers

Starship runs by separating out the infra from the tests that are run against the infra.
In this repo we only spin up the infra, so tests can be run against this infra from RPC,gRPC endpoints in any language.

## Getting Started
### Setup script
In the `examples/injective` dir, run

```bash
make setup-deps ## Installs dependencies for Starship
```

### Manul install (alternate)
Alternatively to the setup script one can just install the deps directly:
* docker: https://docs.docker.com/get-docker/
* kubectl: https://kubernetes.io/docs/tasks/tools/
* kind: https://kind.sigs.k8s.io/docs/user/quick-start/#installation
* helm: https://helm.sh/docs/intro/install/
* yq: https://github.com/mikefarah/yq/#install

## 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)
If one has access to a k8s cluster via a `kubeconfig` file one can run Starship directly on the remote cluster.

## Check connection with cluster
Run
```bash
kubectl get nodes
```

## Spin up infra
Once the initial connection and setup is done, then one can spin up starship infra with

```bash
make install
# OR if you want to run specific config file
make install FILE=configs/devnet.yaml
```

Once the helm chart is installed, you will have to wait for pods to be in a `Running` state. Usually takes 3-5 mins depending on the resources available.
Can check with
```bash
kubectl get pods
```

When all pods are in `Running` state, run port-forwarding to access the nodes on localhost
```bash
make port-forward
# All exposed endpoints would be printed by this command
```

Now you can connect with the explorer and play around: `http://localhost:8080`

Once done, cleanup with:
```bash
make stop
```

## Configs
Starship configs is the definition of the infra we want to spin up.
Present in `configs/`, are multiple versions of the similar infra, tweaked to be able to run in different environments
* `configs/local.yaml`: Config file to be able to run locally
* `configs/devnet.yaml`: Supposed to be run on a larger k8s cluster, with more resources and number of validators
* `configs/ci.yaml`: Limited resources on the GH-Action runner, can be adapted for with reducing cpu,memory allocated

All the config files are similar topology, but different resources allocated.
Topology:
* 2 chains: `injective-1` (custom setup scripts) and `cosmoshub-4`
* 1 hermes relayer: running between the chains
* Registry service: analogous to cosmos chain-registry, but for only our infra
* Optionally explorer: ping-pub explorer for the mini cosmos

Details of each of arguments in the config file can be found [here](https://starship.cosmology.tech/config/chains)

## Dir Structure
* `configs/`: Holds all the various config files and custom scripts for infra intitialization
* `configs/scripts/`: Custom scripts used by the config file for setup. More details [here](https://starship.cosmology.tech/config/chains#scripts-optional)
* `configs/*.yaml`: Various config files as described above
* `scripts/`: Handy scripts for dealing with starship setup and running
* `scripts/dev-setup.sh`: Checks for dependencies
* `scripts/port-forward.sh`: Performs local port-forwarding based on config file definations
* `scripts/install.sh`: Installs helm chart in a connected kubernetes cluster
* `Makefile`: Single entrypoint for Starship, has all commands needed
* `READMD.md`: Readme file
63 changes: 63 additions & 0 deletions examples/injective/configs/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
chains:
- name: injective-1
type: injective
numValidators: 1
resources:
cpu: "0.2"
memory: "200M"
faucet:
type: starship
concurrency: 2
resources:
cpu: "0.2"
memory: "200M"
ports:
rest: 1313
rpc: 26653
exposer: 38083
faucet: 8003
scripts:
createGenesis:
file: scripts/create-genesis.sh
updateGenesis:
file: scripts/update-genesis.sh
createValidator:
file: scripts/create-validator.sh
- name: cosmoshub-4
type: cosmos
numValidators: 1
resources:
cpu: "0.2"
memory: "200M"
faucet:
type: cosmjs
concurrency: 2
resources:
cpu: "0.2"
memory: "200M"
ports:
rest: 1317
rpc: 26657
exposer: 38087
faucet: 8007

relayers:
- name: injective-cosmos
type: hermes
replicas: 1
chains:
- injective-1
- cosmoshub-4
resources:
cpu: "0.2"
memory: "200M"

registry:
enabled: true
ports:
rest: 8081
grpc: 9091
resources:
cpu: "0.1"
memory: "100M"

46 changes: 46 additions & 0 deletions examples/injective/configs/devnet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
chains:
- name: injective-1
type: injective
numValidators: 4
faucet:
type: starship
ports:
rest: 1313
rpc: 26653
exposer: 38083
faucet: 8003
scripts:
createGenesis:
file: scripts/create-genesis.sh
updateGenesis:
file: scripts/update-genesis.sh
createValidator:
file: scripts/create-validator.sh
- name: cosmoshub-4
type: cosmos
numValidators: 4
ports:
rest: 1317
rpc: 26657
exposer: 38087
faucet: 8007

relayers:
- name: injective-cosmos
type: hermes
replicas: 1
chains:
- injective-1
- cosmoshub-4

explorer:
enabled: true
ports:
rest: 8080

registry:
enabled: true
ports:
rest: 8081
grpc: 9091

46 changes: 46 additions & 0 deletions examples/injective/configs/local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
chains:
- name: injective-1
type: injective
numValidators: 2
faucet:
type: starship
ports:
rest: 1313
rpc: 26653
exposer: 38083
faucet: 8003
scripts:
createGenesis:
file: scripts/create-genesis.sh
updateGenesis:
file: scripts/update-genesis.sh
createValidator:
file: scripts/create-validator.sh
- name: cosmoshub-4
type: cosmos
numValidators: 1
ports:
rest: 1317
rpc: 26657
exposer: 38087
faucet: 8007

relayers:
- name: injective-cosmos
type: hermes
replicas: 1
chains:
- injective-1
- cosmoshub-4

explorer:
enabled: true
ports:
rest: 8080

registry:
enabled: true
ports:
rest: 8081
grpc: 9091

Loading
Loading