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

Starship integration #56

Merged
merged 35 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
486c697
Semi working integration of Starship with mesh-security with custom code
Anmol1696 Jul 7, 2023
a3701a1
Semi working full mesh security lifecycle
Anmol1696 Jul 8, 2023
7a9cb35
Update devnet setup for starship multi-node setup
Anmol1696 Jul 8, 2023
078925e
rename denoms to uosmo and ujuno to get seperation of chains
Anmol1696 Jul 9, 2023
deb76ef
Cleanup the tests: update the structure
Anmol1696 Jul 10, 2023
e71cb9e
Fix setup command and update cmd main file
Anmol1696 Jul 13, 2023
802c532
Update devnet information for latest contracts and endpoints
Anmol1696 Jul 14, 2023
2c72b27
update endpoints
Anmol1696 Jul 14, 2023
8a7f670
2 way inital devnet
Anmol1696 Jul 14, 2023
aaedeb0
update new devnet
Anmol1696 Jul 15, 2023
6a10b9e
updated devnet, 2 chain mesh setup working
Anmol1696 Jul 15, 2023
e9e3fb2
add e2e tests of 2 way contract to run in the CI
Anmol1696 Jul 16, 2023
6b41389
run a particular function for test
Anmol1696 Jul 16, 2023
b311939
working model of 2 way contract
Anmol1696 Jul 20, 2023
3f5cecf
Merge remote-tracking branch 'origin/main' into anmol/starship-2-way-…
Anmol1696 Aug 10, 2023
2f313c0
Revert adhoc changes made to mesh-security-sdk for hackathon
Anmol1696 Aug 10, 2023
7bee6fa
revert makefile for demo app
Anmol1696 Aug 10, 2023
ca312d1
move testdata outside for using it with e2e tests and startship tests
Anmol1696 Aug 14, 2023
83c254b
Merge main into branch
Anmol1696 Aug 22, 2023
086be79
update starship yaml files to run with mesh-security-sdk
Anmol1696 Aug 30, 2023
3df8ca4
Merge remote-tracking branch 'origin/main' into anmol/trim-starship-i…
Anmol1696 Aug 31, 2023
8a11acb
working version of starship with meshd
Anmol1696 Aug 31, 2023
4b38473
fix main_test.go and go mod
Anmol1696 Aug 31, 2023
4626a37
fix ci starship config
Anmol1696 Aug 31, 2023
3e23f9d
run starship ci on push to test branch
Anmol1696 Aug 31, 2023
8eac1af
fix typo errors
Anmol1696 Aug 31, 2023
24f4264
fix typos and type errors
Anmol1696 Sep 1, 2023
5d5dd72
add step to perform go mod before setting up the infra
Anmol1696 Sep 1, 2023
ef9cac7
Merge pull request #65 from osmosis-labs/anmol/trim-starship-integration
Anmol1696 Sep 1, 2023
e571715
commit to trigger CI
Anmol1696 Sep 1, 2023
909a74d
add retry of running tests incase of transient errors
Anmol1696 Sep 1, 2023
155cbef
temp disable workflows in the CI
Anmol1696 Sep 1, 2023
9ebf4f5
Add readme, update make commands, add todo to change docker image in …
Anmol1696 Sep 1, 2023
0d61a22
remove ci-debuging for the PR
Anmol1696 Sep 1, 2023
0c6f735
update docker image to use ghcr.io meshd image
Anmol1696 Sep 2, 2023
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
55 changes: 55 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: E2E tests

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
e2e-test:
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.20
id: go

# Starship Infra setup
# - Connects to k8s cluster with kubeconfig (digital ocean)
# - Creates a new namespace based on the name (deleted in next step)
# - Spins up the infra with the given config file
# - Waits till all nodes are running (timeout 30m)
# - Port forward all ports to localhost for next steps to connect
- name: Setup Test infra
id: starship-action
uses: cosmology-tech/starship-action@0.2.12
with:
values: tests/starship/configs/ci.yaml
port-forward: true
version: 0.1.39-rc5

- name: Run Tests
run: |
cd tests/starship/
go mod tidy
make test

# Starship resource cleanup on cluster
# todo(@anmol1696): change this to be post step of the action
- name: Cleanup cluster
if: always()
run: |
helm delete $DEVNET_NAME --debug --namespace $DEVNET_NAMESPACE --wait || true
kubectl delete namespace $DEVNET_NAMESPACE --wait=true || true
env:
DEVNET_NAME: ${{ steps.starship-action.outputs.name }}
DEVNET_NAMESPACE: ${{ steps.starship-action.outputs.namespace }}
11 changes: 8 additions & 3 deletions demo/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM golang:1.20-alpine AS go-builder
ARG ARCH=x86_64

RUN apk add --no-cache ca-certificates build-base git

Expand All @@ -13,7 +12,7 @@ ADD go.mod go.sum ./
RUN set -eux; \
WASM_VERSION=v$(go list -m github.com/CosmWasm/wasmvm | cut -d" " -f2 | cut -d"v" -f2); \
echo $WASM_VERSION; \
wget -O /lib/libwasmvm_muslc.a https://github.com/CosmWasm/wasmvm/releases/download/${WASM_VERSION}/libwasmvm_muslc.${ARCH}.a
wget -O /lib/libwasmvm_muslc.a https://github.com/CosmWasm/wasmvm/releases/download/${WASM_VERSION}/libwasmvm_muslc.$(uname -m).a

# Copy over code
COPY . /code
Expand All @@ -31,9 +30,15 @@ FROM alpine:3.16

COPY --from=go-builder /code/build/meshd /usr/bin/meshd

# Set up dependencies
ENV PACKAGES curl make bash jq sed
Anmol1696 marked this conversation as resolved.
Show resolved Hide resolved

# Install minimum necessary dependencies
RUN apk add --no-cache $PACKAGES

WORKDIR /opt

# rest server, tendermint p2p, tendermint rpc
EXPOSE 1317 26656 26657

CMD ["/usr/bin/meshd", "version"]
CMD ["/usr/bin/meshd", "version"]
19 changes: 13 additions & 6 deletions demo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=mesh \
-X github.com/cosmos/cosmos-sdk/version.AppName=meshd \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X github.com/osmosis-labs/mesh-security-sdk/demo/app.Bech32Prefix=mesh \
-X github.com/osmosis-labs/mesh-security-sdk/demo/app.Bech32Prefix=juno \
Anmol1696 marked this conversation as resolved.
Show resolved Hide resolved
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"

ifeq ($(WITH_CLEVELDB),yes)
Expand Down Expand Up @@ -82,18 +82,25 @@ endif
build-vendored:
go build -mod=vendor $(BUILD_FLAGS) -o $(BUILD_DIR)/meshd ./cmd/meshd

build-linux-static:
docker-build:
go mod vendor # quick hack to make local dependencies work in Docker
mkdir -p $(BUILD_DIR)
docker build --tag osmosis/meshd:local ./
docker create --name meshd_temp osmosis/meshd:local
docker cp meshd_temp:/usr/bin/meshd $(BUILD_DIR)/
docker rm -f meshd_temp
docker buildx build --platform linux/amd64,linux/arm64 --tag anmol1696/meshd:juno ./ --push
Anmol1696 marked this conversation as resolved.
Show resolved Hide resolved
rm -rf vendor/

install:
go install -mod=readonly $(BUILD_FLAGS) ./cmd/meshd

########################################
### Docker

.PHONY: docker-build-linux
docker-build-linux:
docker buildx build --platform linux/amd64 --tag anmol1696/meshd:latest ./ --push
Anmol1696 marked this conversation as resolved.
Show resolved Hide resolved

docker-build-arm64:
docker buildx build --platform linux/arm64 --build-arg ARCH=darwin --tag anmol1696/meshd:latest ./ --load

########################################
### Testing

Expand Down
82 changes: 82 additions & 0 deletions tests/starship/DEVNET.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
## Mesh Security Devnet

> NOTE: Host and smart contract address are subject to change on redeployment of the system

Anmol1696 marked this conversation as resolved.
Show resolved Hide resolved
### Osmosis Chain

Chain-id: `mesh-osmosis-1`
Denom: `uosmo`
Prefix: `osmo`

Host: `localhost`

Ports:
* RPC: [26657](http://localhost:26653/status)
* Rest: [1317](http://localhost:1313)
* Faucet: [8000](http://localhost:8003)

Get tokens from faucet
```bash
curl --header "Content-Type: application/json" \
--request POST \
--data '{"denom":"uosmo","address":"osmo1yre6ac7qfgyfgvh58ph0rgw627rhw766y430qq"}' \
http://localhost:8003/credit
```

#### Contracts
```
Provider Contracts:
valut: osmo14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sq2r9g9
ExternalStaking: osmo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftq56jurc
nativeStaking: osmo1qg5ega6dykkxc307y25pecuufrjkxkaggkkxh7nad0vhyhtuhw3s0p34vn
proxycode-id: 2
Consumer Contracts:
Staking: osmo1pvrwmjuusn9wh34j7y520g8gumuy9xtl3gvprlljfdpwju3x7ucsxrqwu2
PriceFeed: osmo1436kxs0w2es6xlqpp9rd35e3d0cjnw4sv8j3a7483sgks29jqwgsrdzxtj
Converter: osmo13ehuhysn5mqjeaheeuew2gjs785f6k7jm8vfsqg3jhtpkwppcmzqg496z0
```

### Juno Chain

Chain-id: `mesh-juno-1`
Denom: `ujuno`
Prefix: `juno`

Host: `localhost`

Ports:
* RPC: [26657](http://localhost:26657/status)
* Rest: [1317](http://localhost:1317/status)
* Faucet: [8000](http://localhost:8007/status)

Get tokens from faucet
```bash
curl --header "Content-Type: application/json" \
--request POST \
--data '{"denom":"ujuno","address":"juno1yre6ac7qfgyfgvh58ph0rgw627rhw766y430qq"}' \
http://localhost:8007/credit
```

#### Contracts
```
Consumer Contracts:
Staking: juno1xr3rq8yvd7qplsw5yx90ftsr2zdhg4e9z60h5duusgxpv72hud3skqksyr
PriceFeed: juno14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9skjuwg8
Converter: juno1qg5ega6dykkxc307y25pecuufrjkxkaggkkxh7nad0vhyhtuhw3seew7v3
Provider Contracts:
valut: juno1ghd753shjuwexxywmgs4xz7x2q732vcnkm6h2pyv9s6ah3hylvrq722sry
ExternalStaking: juno1wn625s4jcmvk0szpl85rj5azkfc6suyvf75q6vrddscjdphtve8sdvm67v
nativeStaking: juno1mf6ptkssddfmxvhdx0ech0k03ktp6kf9yk59renau2gvht3nq2gq0zmt6e
proxycode-id: 5
```

## Chain Registry

Host: `localhost`

Port: [8080](http://localhost:8081/chains)

Endpoints:
* Chains: [`/chains/{chain-id}`](http://localhost:8081/chains/provider)
* IBC: [`/ibc/{chain-1}/{chain-2}`](http://localhost:8081/ibc/provider/consumer)
* Mnemonics: [`/chains/{chain-id}/keys`](http://localhost:8081/chains/provider/keys)
75 changes: 75 additions & 0 deletions tests/starship/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/make -f

BUILD_DIR = ./build

all: test

test:
go test -mod=readonly -v -race -run Test2WayContract ./...

build-setup:
cd setup && go build cmd/... -o build/ ./setup

run-setup:
cd setup && go run ./...

build:
CGO_ENABLED=1 go test -c -mod=readonly -o $(BUILD_DIR)/mesh-security.e2e.test

build-linux:
CGO_ENABLED=1 GOOS=linux go test -c -mod=readonly -o $(BUILD_DIR)/mesh-security.e2e.test

.PHONY: all build build-linux test

###############################################################################
### Starship Helm Charts ###
###############################################################################
NAME = mesh-security
FILE = configs/starship.yaml

HELM_REPO = starship
HELM_CHART = devnet
HELM_VERSION = v0.1.39-rc5

.PHONY: check
setup-deps:
bash $(CURDIR)/scripts/dev-setup.sh

setup-helm:
helm repo add $(HELM_REPO) https://cosmology-tech.github.io/starship/
helm repo update
helm search repo $(HELM_REPO)/$(HELM_CHART) --version $(HELM_VERSION)

install:
helm install -f $(FILE) $(NAME) $(HELM_REPO)/$(HELM_CHART) --version $(HELM_VERSION)

debug:
helm install -f $(FILE) $(NAME) $(HELM_REPO)/$(HELM_CHART) --version $(HELM_VERSION) --dry-run --debug

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)
10 changes: 10 additions & 0 deletions tests/starship/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# End-To-End Tests
Multi-chain system tests that run against the demo app.
Anmol1696 marked this conversation as resolved.
Show resolved Hide resolved


Run them with:
```shell
make test
```


72 changes: 72 additions & 0 deletions tests/starship/configs/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
chains:
- name: mesh-osmosis-1
type: custom
numValidators: 1
image: anmol1696/meshd:osmo
home: /root/.meshd
binary: meshd
prefix: osmo
denom: uosmo
coins: 100000000000000uosmo
hdPath: m/44'/118'/0'/0/0
coinType: 118
repo: https://github.com/osmosis/mesh-security-sdk
ports:
rest: 1313
rpc: 26653
faucet: 8003
resources:
cpu: "0.2"
memory: "200M"
faucet:
resources:
cpu: "0.1"
memory: "100M"
- name: mesh-juno-1
type: custom
numValidators: 1
image: anmol1696/meshd:juno
home: /root/.meshd
binary: meshd
prefix: juno
denom: ujuno
coins: 100000000000000ujuno
hdPath: m/44'/118'/0'/0/0
coinType: 118
repo: https://github.com/osmosis/mesh-security-sdk
ports:
rest: 1317
rpc: 26657
faucet: 8007
resources:
cpu: "0.2"
memory: "200M"
faucet:
resources:
cpu: "0.1"
memory: "100M"

relayers:
- name: juno-osmo
type: hermes
replicas: 1
image: ghcr.io/cosmology-tech/starship/hermes:39033cdee9e7aaa2274aeca3ab152542bf93d8bd
chains:
- mesh-juno-1
- mesh-osmosis-1
resources:
cpu: "0.1"
memory: "100M"

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

exposer:
resources:
cpu: "0.1"
memory: "100M"
Loading