-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integration test initial network setup (#1256)
- Loading branch information
Showing
25 changed files
with
1,014 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ deps | |
dockernet | ||
scripts | ||
genesis | ||
testutil/localstride | ||
testutil/localstride | ||
integration-tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
K8S_NAMESPACE=integration | ||
VENV_NAME=integration | ||
|
||
CONDA_BASE := $(shell conda info --base)/envs | ||
KUBECTL := $(shell which kubectl) | ||
DOCKER := $(shell which docker) | ||
HELM := $(shell which helm) | ||
VENV_BIN := $(CONDA_BASE)/$(VENV_NAME)/bin | ||
PYTHON := $(VENV_BIN)/python | ||
|
||
HELM_CHART=network | ||
|
||
python-install: | ||
conda create --name $(VENV_NAME) python=3.11 -y | ||
$(PYTHON) -m pip install -r api/requirements.txt | ||
|
||
start-api: | ||
@$(PYTHON) -m uvicorn api.main:app --proxy-headers | ||
|
||
build-api: | ||
@echo "Building docker image: api" | ||
@$(DOCKER) buildx build --platform linux/amd64 --tag api -f dockerfiles/Dockerfile.api api | ||
@$(DOCKER) tag api gcr.io/stride-nodes/integration-tests/api:latest | ||
@echo "Pushing image to GCR" | ||
@$(DOCKER) push gcr.io/stride-nodes/integration-tests/api:latest | ||
|
||
build-stride: | ||
@echo "Building docker image: stride-validator" | ||
@$(DOCKER) buildx build --platform linux/amd64 --tag core:stride .. | ||
@$(DOCKER) buildx build --platform linux/amd64 --tag stride-validator -f dockerfiles/Dockerfile.stride . | ||
@$(DOCKER) tag stride-validator gcr.io/stride-nodes/integration-tests/chains/stride:latest | ||
@echo "Pushing image to GCR" | ||
@$(DOCKER) push gcr.io/stride-nodes/integration-tests/chains/stride:latest | ||
|
||
build-cosmos: | ||
@echo "Building docker image" | ||
@$(DOCKER) buildx build --platform linux/amd64 --tag cosmos-validator -f dockerfiles/Dockerfile.cosmos . | ||
@$(DOCKER) tag cosmos-validator gcr.io/stride-nodes/integration-tests/chains/cosmoshub:v18.1.0 | ||
@echo "Pushing image to GCR" | ||
@$(DOCKER) push gcr.io/stride-nodes/integration-tests/chains/cosmoshub:v18.1.0 | ||
|
||
start: | ||
@$(HELM) install $(HELM_CHART) $(HELM_CHART) --values $(HELM_CHART)/values.yaml -n $(K8S_NAMESPACE) | ||
|
||
stop: | ||
@$(HELM) uninstall $(HELM_CHART) -n $(K8S_NAMESPACE) | ||
|
||
lint: | ||
@$(HELM) lint $(HELM_CHART) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Integration Tests | ||
|
||
This design for this integration test framework is heavily inspired by the Cosmology team's [starship](https://github.com/cosmology-tech/starship/tree/main). | ||
|
||
## Setup | ||
|
||
TODO | ||
|
||
## Motivation | ||
|
||
TODO | ||
|
||
## Network | ||
|
||
TODO | ||
|
||
## Testing Client | ||
|
||
TODO | ||
|
||
## Design Decisions | ||
|
||
### API Service to share files during chain setup | ||
|
||
In order to start the network as fast as possible, the chain should be initialized with ICS validators at genesis, rather than performing a switchover. However, in order to build the genesis file, the public keys must be gathered from each validator. This adds the constraint that keys must be consoldiated into a single process responsible for creating the genesis file. | ||
|
||
This can be achieved by having a master node creating the genesis.json and keys for each validator, and then having each validator download the files from the master node. Ideally this would be handled by a shared PVC across each validator; however, Kuberentes has a constraint where you cannot mount multiple pods onto the same volume. | ||
|
||
This led to the decision to use an API service to act as the intermediary that allows uploading and downloading of files. While at first glance, this smells of overengineering, the fastAPI implementation is actually quite simple (only marginally more code than creating and mounting a volume) and it improves the startup time dramatically since there's no need for the pods to wait for the volume to be mounted. Plus, it's likely that it can be leveraged in the future to help coordinate tasks across the different networks in the setup (e.g. it can store a registry of canonical IBC connections across chains). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from fastapi import FastAPI, File, HTTPException, UploadFile | ||
from fastapi.responses import FileResponse | ||
import os | ||
|
||
app = FastAPI() | ||
|
||
STORAGE_DIRECTORY = "storage" | ||
os.makedirs(STORAGE_DIRECTORY, exist_ok=True) | ||
|
||
|
||
@app.get("/status") | ||
async def status() -> str: | ||
""" | ||
Health check | ||
""" | ||
return "ok" | ||
|
||
|
||
@app.post("/upload/{file_name}") | ||
@app.post("/upload/{path:path}/{file_name}") | ||
async def upload_file(file_name: str, path: str = "", file: UploadFile = File(...)) -> dict: | ||
""" | ||
Allows uploading a file - stores it in the local file system | ||
""" | ||
parent = f"{STORAGE_DIRECTORY}/{path}" if path else STORAGE_DIRECTORY | ||
os.makedirs(parent, exist_ok=True) | ||
|
||
with open(f"{parent}/{file_name}", "wb") as f: | ||
f.write(file.file.read()) | ||
|
||
return {"info": f"file {file_name} saved"} | ||
|
||
|
||
@app.get("/download/{file_name}") | ||
@app.get("/download/{path:path}/{file_name}") | ||
async def download_file(file_name: str, path: str = ""): | ||
""" | ||
Allows downloading a file from the local file system | ||
""" | ||
file_location = f"{STORAGE_DIRECTORY}/{path}/{file_name}" if path else f"{STORAGE_DIRECTORY}/{file_name}" | ||
|
||
if not os.path.exists(file_location): | ||
return HTTPException(status_code=404, detail=f"file {file_location} not found") | ||
|
||
return FileResponse(file_location, media_type="application/octet-stream", filename=file_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fastapi==0.103.2 | ||
uvicorn==0.23.2 | ||
python-multipart==0.0.9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM python:3.11-slim | ||
|
||
WORKDIR /app | ||
|
||
RUN apt-get update && apt-get install -y gcc g++ bash vim git curl tzdata \ | ||
&& adduser --system --home /home/python --disabled-password --disabled-login python -u 1000 \ | ||
&& pip install --upgrade pip | ||
|
||
COPY ./requirements.txt /app/requirements.txt | ||
|
||
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt | ||
|
||
COPY main.py main.py | ||
|
||
CMD ["uvicorn", "main:app", "--proxy-headers", "--host", "0.0.0.0"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
FROM golang:1.22-alpine AS builder | ||
|
||
WORKDIR /opt | ||
|
||
RUN apk add --update curl make git libc-dev bash gcc linux-headers eudev-dev ca-certificates build-base git | ||
|
||
ENV REPO=https://github.com/cosmos/gaia | ||
ENV COMMIT_HASH=v18.1.0 | ||
ENV BINARY=gaiad | ||
|
||
RUN git clone ${REPO} chain \ | ||
&& cd chain \ | ||
&& git checkout $COMMIT_HASH | ||
|
||
WORKDIR /opt/chain | ||
|
||
RUN WASMVM_VERSION=$(cat go.mod | grep github.com/CosmWasm/wasmvm | awk '{print $2}') \ | ||
&& wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$(uname -m).a \ | ||
-O /lib/libwasmvm_muslc.a | ||
|
||
RUN CGO_ENABLED=1 BUILD_TAGS="muslc linkstatic" LINK_STATICALLY=true LEDGER_ENABLED=false make install | ||
|
||
FROM alpine:3.17 | ||
COPY --from=builder /go/bin/$BINARY /usr/local/bin/ | ||
RUN apk add bash vim sudo dasel jq curl \ | ||
&& addgroup -g 1000 validator \ | ||
&& adduser -S -h /home/validator -D validator -u 1000 -G validator | ||
|
||
USER 1000 | ||
WORKDIR /home/validator | ||
|
||
EXPOSE 26657 26656 1317 9090 |
Oops, something went wrong.