Skip to content

Commit

Permalink
Merge branch 'main' into anmol/docker-multi-test
Browse files Browse the repository at this point in the history
  • Loading branch information
Anmol1696 authored Jun 28, 2023
2 parents 3ec4289 + e578f3f commit 6564967
Show file tree
Hide file tree
Showing 28 changed files with 550 additions and 51 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build all build types
- name: Build
if: github.event_name == 'pull_request'
run: |
./scripts/build-docker.sh --type ${{ matrix.build-type }} --process all --version all
- name: Build and push
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
run: |
./scripts/build-docker.sh --type ${{ matrix.build-type }} --process all --version all --push
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

strategy:
matrix:
config-file: ["two-chain.yaml", "build-chain.yaml"]
config-file: ["two-chain.yaml", "build-chain.yaml", "multi-validator.yaml"]
fail-fast: true
max-parallel: 1

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

strategy:
matrix:
config-file: ["one-chain.yaml", "two-chain.yaml", "build-chain.yaml", "one-custom-chain.yaml"]
config-file: [ "one-chain.yaml", "two-chain.yaml", "build-chain.yaml", "one-custom-chain.yaml", "multi-validator.yaml" ]
fail-fast: true
max-parallel: 1

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:

strategy:
matrix:
config-file: [ "one-chain.yaml", "one-custom-chain.yaml" ]
config-file: [ "one-chain.yaml", "one-custom-chain.yaml", "multi-validator.yaml" ]
fail-fast: true
max-parallel: 2
max-parallel: 3

env:
CONFIG_FILE: "tests/configs/${{ matrix.config-file }}"
Expand Down
2 changes: 1 addition & 1 deletion charts/devnet/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.34
version: 0.1.35

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
1 change: 0 additions & 1 deletion charts/devnet/scripts/create_validator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ $CHAIN_BIN tx staking create-validator \
--pubkey=$($CHAIN_BIN tendermint show-validator) \
--moniker $VAL_NAME \
--amount 5000000000$DENOM \
--keyring-backend="test" \
--chain-id $CHAIN_ID \
--from $VAL_NAME \
--commission-rate="0.10" \
Expand Down
1 change: 0 additions & 1 deletion charts/devnet/scripts/setup_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ sed -i -e 's/seeds = ".*"/seeds = ""/g' $CHAIN_DIR/config/config.toml
echo "Update client.toml file"
sed -i -e 's#keyring-backend = "os"#keyring-backend = "test"#g' $CHAIN_DIR/config/client.toml
sed -i -e 's#output = "text"#output = "json"#g' $CHAIN_DIR/config/client.toml
sed -i -e 's#broadcast-mode = "sync"#broadcast-mode = "block"#g' $CHAIN_DIR/config/client.toml
sed -i -e "s#chain-id = \"\"#chain-id = \"$CHAIN_ID\"#g" $CHAIN_DIR/config/client.toml


Expand Down
9 changes: 6 additions & 3 deletions charts/devnet/scripts/setup_genesis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,24 @@ WASM_PERMISSIONLESS="${WASM_PERMISSIONLESS:=true}"

set -eu

# check if the binary has genesis subcommand or not, if not, set CHAIN_GENESIS_CMD to empty
CHAIN_GENESIS_CMD=$($CHAIN_BIN 2>&1 | grep -q "genesis-related subcommands" && echo "genesis" || echo "")

jq -r ".genesis[0].mnemonic" $KEYS_CONFIG | $CHAIN_BIN init $CHAIN_ID --chain-id $CHAIN_ID --recover

# Add genesis keys to the keyring and self delegate initial coins
echo "Adding key...." $(jq -r ".genesis[0].name" $KEYS_CONFIG)
jq -r ".genesis[0].mnemonic" $KEYS_CONFIG | $CHAIN_BIN keys add $(jq -r ".genesis[0].name" $KEYS_CONFIG) --recover --keyring-backend="test"
$CHAIN_BIN add-genesis-account $($CHAIN_BIN keys show -a $(jq -r .genesis[0].name $KEYS_CONFIG) --keyring-backend="test") $COINS --keyring-backend="test"
$CHAIN_BIN $CHAIN_GENESIS_CMD add-genesis-account $($CHAIN_BIN keys show -a $(jq -r .genesis[0].name $KEYS_CONFIG) --keyring-backend="test") $COINS --keyring-backend="test"

echo "Creating gentx..."
$CHAIN_BIN gentx $(jq -r ".genesis[0].name" $KEYS_CONFIG) 5000000000$DENOM --keyring-backend="test" --chain-id $CHAIN_ID
$CHAIN_BIN $CHAIN_GENESIS_CMD gentx $(jq -r ".genesis[0].name" $KEYS_CONFIG) 5000000000$DENOM --keyring-backend="test" --chain-id $CHAIN_ID

echo "Output of gentx"
cat $CHAIN_DIR/config/gentx/*.json | jq

echo "Running collect-gentxs"
$CHAIN_BIN collect-gentxs
$CHAIN_BIN $CHAIN_GENESIS_CMD collect-gentxs

ls $CHAIN_DIR/config

Expand Down
29 changes: 29 additions & 0 deletions charts/devnet/scripts/transfer_tokens.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

ADDRESS="$1"
DENOM="$2"
FAUCET_URL="$3"

set -eu

function transfer_token() {
status_code=$(curl --header "Content-Type: application/json" \
--request POST --write-out %{http_code} --silent --output /dev/null \
--data '{"denom":"'"$DENOM"'","address":"'"$ADDRESS"'"}' \
$FAUCET_URL)
echo $status_code
}

echo "Try to send tokens, if failed, wait for 5 seconds and try again"
max_tries=5
while [[ max_tries -gt 0 ]]
do
status_code=$(transfer_token)
if [[ "$status_code" -eq 200 ]]; then
echo "Successfully sent tokens"
exit 0
fi
echo "Failed to send tokens. Sleeping for 2 secs. Tries left $max_tries"
((max_tries--))
sleep 2
done
10 changes: 7 additions & 3 deletions charts/devnet/templates/chain/genesis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
{{- $build := .build | default (dict "enabled" false) -}}
{{- $toBuild := or $build.enabled $upgrade.enabled }}

# read faucet from chain values and merge with default faucet values
{{ $faucet := get $chain "faucet" | default dict }}
{{ $faucet = merge $faucet $.Values.faucet }}

{{ $image := $chain.image }}
{{- if $toBuild }}
{{ $image = "anmol1696/runner:latest" }}
Expand Down Expand Up @@ -182,13 +186,13 @@ spec:
- mountPath: /configs
name: addresses
- name: faucet
image: {{ $.Values.faucet.image }}
image: {{ $faucet.image }}
imagePullPolicy: Always
env:
- name: FAUCET_CONCURRENCY
value: "10"
- name: FAUCET_PORT
value: "{{ $.Values.faucet.ports.rest }}"
value: "{{ $faucet.ports.rest }}"
- name: FAUCET_MEMO
value: "faucet txn"
- name: FAUCET_GAS_PRICE
Expand Down Expand Up @@ -232,7 +236,7 @@ spec:
- mountPath: /configs
name: addresses
resources:
{{ toYaml $.Values.faucet.resources | nindent 12 }}
{{ toYaml $faucet.resources | nindent 12 }}
readinessProbe:
httpGet:
path: /status
Expand Down
15 changes: 6 additions & 9 deletions charts/devnet/templates/chain/validator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ spec:
{{- end }}
if [ -f $CHAIN_DIR/config/genesis.json ]; then
echo "Genesis file exists, exiting init container"
echo "Genesis file exists, exiting early"
exit 0
fi
Expand All @@ -123,13 +123,6 @@ spec:
$CHAIN_BIN keys add $VAL_NAME --keyring-backend="test"
fi
VAL_ADDR=$($CHAIN_BIN keys show $VAL_NAME -a --keyring-backend="test")
echo "Transfer tokens to address $VAL_ADDR"
curl --header "Content-Type: application/json" \
--request POST \
--data '{"denom":"'"$DENOM"'","address":"'"$VAL_ADDR"'"}' \
http://$GENESIS_HOST.$NAMESPACE.svc.cluster.local:8000/credit
curl http://$GENESIS_HOST.$NAMESPACE.svc.cluster.local:$GENESIS_PORT/genesis -o $CHAIN_DIR/config/genesis.json
echo "Genesis file that we got....."
cat $CHAIN_DIR/config/genesis.json
Expand Down Expand Up @@ -185,7 +178,11 @@ spec:
VAL_INDEX=${HOSTNAME##*-}
VAL_NAME=$(jq -r ".validators[$VAL_INDEX].name" /configs/keys.json)
[[ $VAL_NAME == "null" ]] && VAL_NAME="validator-$VAL_INDEX"
echo "Validator Index: $VAL_INDEX, Key name: $VAL_NAME"
echo "Validator Index: $VAL_INDEX, Key name: $VAL_NAME. Chain bin $CHAIN_BIN"
VAL_ADDR=$($CHAIN_BIN keys show $VAL_NAME -a --keyring-backend="test")
echo "Transfer tokens to address $VAL_ADDR before trying to create validator. Best effort"
bash -e /scripts/transfer_tokens.sh $VAL_ADDR $DENOM http://$GENESIS_HOST.$NAMESPACE.svc.cluster.local:8000/credit || true
$CHAIN_BIN keys list | jq
Expand Down
12 changes: 7 additions & 5 deletions charts/devnet/templates/relayers/hermes/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,8 @@ spec:
--hd-path {{ $fullchain.hdPath | quote }}
DENOM="{{ $fullchain.denom }}"
RLY_ADDR=$(hermes --json keys list --chain {{ $chain }} | tail -1 | jq -r '.result."{{ $chain }}".account')
echo "Transfer funds to address $RLY_ADDR"
curl --header "Content-Type: application/json" \
--request POST \
--data '{"denom":"'"$DENOM"'","address":"'"$RLY_ADDR"'"}' \
http://{{ $fullchain.name }}-genesis.$NAMESPACE.svc.cluster.local:8000/credit
echo "Transfer tokens to address $RLY_ADDR"
bash -e /scripts/transfer_tokens.sh $RLY_ADDR $DENOM http://{{ $fullchain.name }}-genesis.$NAMESPACE.svc.cluster.local:8000/credit
{{- end }}
{{- end }}
{{- end }}
Expand All @@ -93,6 +90,8 @@ spec:
name: relayer-config
- mountPath: /keys
name: keys
- mountPath: /scripts
name: scripts
resources:
{{ toYaml $.Values.resources.init | indent 12 }}
containers:
Expand Down Expand Up @@ -128,6 +127,9 @@ spec:
- name: keys
configMap:
name: keys
- name: scripts
configMap:
name: setup-scripts
---
{{- end }}
{{- end }}
12 changes: 7 additions & 5 deletions charts/devnet/templates/relayers/ts-relayer/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,8 @@ spec:
{{ $fullchain = merge $fullchain $defaultChain }}
DENOM="{{ $fullchain.denom }}"
RLY_ADDR=$(ibc-setup keys list | grep "{{ $fullchain.name }}" | awk '{print $2}')
echo "Transfer funds to address $RLY_ADDR"
curl --header "Content-Type: application/json" \
--request POST \
--data '{"denom":"'"$DENOM"'","address":"'"$RLY_ADDR"'"}' \
http://{{ $fullchain.name }}-genesis.$NAMESPACE.svc.cluster.local:8000/credit
echo "Transfer tokens to address $RLY_ADDR"
bash -e /scripts/transfer_tokens.sh $RLY_ADDR $DENOM http://{{ $fullchain.name }}-genesis.$NAMESPACE.svc.cluster.local:8000/credit
{{- end }}
{{- end }}
{{- end }}
Expand All @@ -92,6 +89,8 @@ spec:
name: relayer-config
- mountPath: /keys
name: keys
- mountPath: /scripts
name: scripts
resources:
{{ toYaml $.Values.resources.init | indent 12 }}
containers:
Expand Down Expand Up @@ -137,6 +136,9 @@ spec:
- name: keys
configMap:
name: keys
- name: scripts
configMap:
name: setup-scripts
---
{{- end }}
{{- end }}
20 changes: 18 additions & 2 deletions charts/devnet/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ resources:
memory: "100M"

exposer:
image: ghcr.io/cosmology-tech/starship/exposer:20230614-7173db2
image: ghcr.io/cosmology-tech/starship/exposer:20230617-eea58bd
ports:
rest: 8081
resources:
Expand All @@ -42,7 +42,7 @@ exposer:
memory: "200M"

faucet:
image: ghcr.io/cosmology-tech/starship/cosmjs-faucet:0.29.0
image: ghcr.io/cosmology-tech/starship/cosmjs-faucet:v0.30.1
ports:
rest: 8000
resources:
Expand Down Expand Up @@ -108,6 +108,16 @@ defaultChains:
hdPath: m/44'/118'/0'/0/0
coinType: 118
repo: https://github.com/cosmos/gaia
simapp:
image: ghcr.io/cosmology-tech/starship/simapp:v0.47.3
home: /root/.simapp
binary: simd
prefix: cosmos
denom: stake
coins: 100000000000000stake
hdPath: m/44'/118'/0'/0/0
coinType: 118
repo: https://github.com/cosmos/cosmos-sdk/tree/main/simapp
persistencecore:
image: anmol1696/persistencecore:latest
home: /root/.persistenceCore
Expand Down Expand Up @@ -272,6 +282,12 @@ chains: []
# upgrades:
# - name: v12
# version: v12.2.0
# faucet:
# # if not mentioned will use the default directive
# # faucet directive will instruct the chart to deploy a certain version
# # of the cosmjs-faucet with the chain. Make sure to use a version compatible
# # with the chain version. Available images: https://github.com/cosmology-tech/starship/pkgs/container/starship%2Fcosmjs-faucet
# image: <faucet image to use>
# ports:
# rpc: 26653
# rest: 1313
Expand Down
1 change: 0 additions & 1 deletion docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ docker-build-push:

docker-run:
$(DOCKER) run --rm -it --entrypoint /bin/bash $(DOCKER_REPO_NAME)/$(PROCESS):$(DOCKER_TAG_NAME)

15 changes: 12 additions & 3 deletions docker/chains/build-docker-chains.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ DOCKER_REPO=${DOCKER_REPO:=anmol1696}
# Set default values for boolean arguments
PUSH=0
PUSH_LATEST=0
FORCE=0

set -euo pipefail

Expand Down Expand Up @@ -39,13 +40,17 @@ build_chain_tag() {

local base=$(yq -r ".chains[] | select(.name==\"$chain\") | .base" versions.yaml)

# Push docker image, if feature flags set
local buildx_args=""
if [[ "$push_image" == "push" || "$push_image" == "push-only" ]]; then
if [[ "$FORCE" -ne 1 ]]; then
if image_tag_exists $DOCKER_REPO/$chain $tag; then
color yellow "image $DOCKER_REPO/$chain:$tag already exists, skipping docker build"
return 0
fi
color green "image not found remote, will build docker image $DOCKER_REPO/$chain:$tag"
fi

# Push docker image, if feature flags set
local buildx_args=""
if [[ "$push_image" == "push" || "$push_image" == "push-only" ]]; then
color green "will pushing docker image $DOCKER_REPO/$chain:$tag"
buildx_args="--push"
fi
Expand Down Expand Up @@ -112,6 +117,10 @@ while [ $# -gt 0 ]; do
PUSH="push-only"
shift # past argument
;;
--force)
FORCE=1
shift # past argument
;;
-*|--*)
echo "Unknown option $1"
exit 1
Expand Down
Loading

0 comments on commit 6564967

Please sign in to comment.