Skip to content

Commit

Permalink
fixes for init scripts rename cosmos to gaia
Browse files Browse the repository at this point in the history
  • Loading branch information
gregnuj committed Jul 31, 2023
1 parent 38c3132 commit 03a56a5
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: cosmos-build
name: gaia-build

on:
pull_request:
Expand All @@ -8,7 +8,7 @@ on:
- 'bin/builder'
- 'alpine.Dockerfile'
- '.github/workflows/docker-build.yml'
- '.github/workflows/cosmos-build.yml'
- '.github/workflows/gaia-build.yml'

push:
branches:
Expand All @@ -17,10 +17,10 @@ on:
- 'bin/builder'
- 'alpine.Dockerfile'
- '.github/workflows/docker-build.yml'
- '.github/workflows/cosmos-build.yml'
- '.github/workflows/gaia-build.yml'

jobs:
cosmos-build:
gaia-build:
uses: ./.github/workflows/docker-build.yml
secrets: inherit
strategy:
Expand All @@ -44,7 +44,7 @@ jobs:
go_version: "1.20"
ldflags: ""
mimalloc_version: ""
name: "cosmos"
name: "gaia"
repo: "cosmos/gaia"
target: "prod"

Expand Down
43 changes: 22 additions & 21 deletions devel/bin/init-chain
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/usr/bin/env bash
set -Eeuox pipefail
set -Eeuo pipefail

# This script is used to initialize the chain

# The following environment variables are required:
APP_NAME=${APP_NAME:-"chain"}
APP_HOME=${APP_HOME:-"/home/${APP_NAME}"}
BIN_NAME=${BIN_NAME:-"chaind"}
CHAIN_NAME=${CHAIN_NAME:-"${APP_NAME}-devnet"}
DENOM=${DENOM:-"u$(echo ${APP_NAME} | head -c 4)"}
Expand All @@ -15,8 +14,8 @@ NUM_VALIDATORS=${NUM_VALIDATORS:-"$(jq -r '.mnemonics | length' ${MNEMONICS_JSON
VALIDATOR_ID=0

# load environment variables
if [ -f ${APP_HOME}/.env ]; then
. ${APP_HOME}/.env
if [ -f ${HOME}/.env ]; then
. ${HOME}/.env
fi

# Cosmos SDK v0.47 settings
Expand All @@ -40,11 +39,11 @@ select_num(){
elif [ ${VALIDATOR_ID} -ge ${NUM_VALIDATORS} ]; then
VALIDATOR_ID=0
fi
if [ -f ${APP_HOME}/.shared/validator-${VALIDATOR_ID} ]; then
if [ -f ${HOME}/.shared/claims/validator-${VALIDATOR_ID} ]; then
select_num $((VALIDATOR_ID++))
fi
touch ${APP_HOME}/.shared/validator-${VALIDATOR_ID}
echo "VALIDATOR_ID=${VALIDATOR_ID}" > ${APP_HOME}/.env
touch ${HOME}/.shared/claims/validator-${VALIDATOR_ID}
echo "VALIDATOR_ID=${VALIDATOR_ID}" > ${HOME}/.env
}

initialize_chain(){
Expand All @@ -61,7 +60,7 @@ initialize_account(){
local validator="$1"
echo "Initializing account ${validator}..."
jq -r ".mnemonics | .[] |select(.name ==\"${validator}\") | .mnemonic" ${MNEMONICS_JSON} |
${BIN_NAME} keys add ${validator} --keyring-backend test --recover --output json >> ${APP_HOME}/keys.json
${BIN_NAME} keys add ${validator} --keyring-backend test --recover --output json >> ${HOME}/keys.json
${BIN_NAME} ${GENESIS} add-genesis-account ${validator} 1000000000000${DENOM} --keyring-backend test
}

Expand All @@ -76,11 +75,12 @@ create_gentx(){
local validator="$1"
echo "Creating Gentx for ${validator}..."
# create a gentx for the validator and add it to the genesis file
mkdir -p ${APP_HOME}/.shared/gentxs
${BIN_NAME} ${GENESIS} gentx ${validator} 10000000000${DENOM} \
--keyring-backend test \
--chain-id=${CHAIN_NAME} \
--output-document=${APP_HOME}/.shared/gentxs/${validator}.gentx.json
--chain-id=${CHAIN_NAME}
mkdir -p ${HOME}/.shared/gentxs
cp -a ${HOME}/.*/config/gentx/* ${HOME}/.shared/gentxs/${validator}.gentx.json

}

initialize_validator(){
Expand All @@ -99,31 +99,31 @@ initialize_genesis(){
local validator
# wait for all gentxs to be created
for validator in $(jq -r ".mnemonics[:${NUM_VALIDATORS}] | .[].name" ${MNEMONICS_JSON}); do
until [ -f ${APP_HOME}/.shared/gentxs/${validator}.gentx.json ]; do
until [ -f ${HOME}/.shared/gentxs/${validator}.gentx.json ]; do
echo "Waiting for ${validator}.gentx.json to be created..."
sleep 1
done
done

echo "Generating Genesis..."
${BIN_NAME} ${GENESIS} collect-gentxs \
--gentx-dir=${APP_HOME}/.shared/gentxs \
> /dev/null 2>&1
--gentx-dir=${HOME}/.shared/gentxs \
> /dev/null

# modify the genesis.json
sed -e "s/stake/${DENOM}/g" \
-i ${APP_HOME}/.*/config/genesis.json
-i ${HOME}/.*/config/genesis.json

cp -a ${APP_HOME}/.${APP_NAME}/config/genesis.json ${APP_HOME}/.shared/genesis.json
cp -a ${HOME}/.${APP_NAME}/config/genesis.json ${HOME}/.shared/genesis.json
}

wait_for_genesis(){
# wait for genesis.json to be created
until [ -f ${APP_HOME}/.shared/genesis.json ]; do
until [ -f ${HOME}/.shared/genesis.json ]; do
echo "Waiting for genesis.json to be created..."
sleep 1
done
cp -a ${APP_HOME}/.shared/genesis.json ${APP_HOME}/.${APP_NAME}/config/genesis.json
cp -a ${HOME}/.shared/genesis.json ${HOME}/.${APP_NAME}/config/genesis.json
}

is_sourced() {
Expand All @@ -135,11 +135,12 @@ is_sourced() {

main(){
# genesis.json in shared
if [ -f ${APP_HOME}/.shared/genesis.json ]; then
cp -a ${APP_HOME}/.shared/genesis.json ${APP_HOME}/.${APP_NAME}/config/genesis.json
if [ -f ${HOME}/.shared/genesis.json ]; then
cp -a ${HOME}/.shared/genesis.json ${HOME}/.${APP_NAME}/config/genesis.json
fi

if [ ! -f ${APP_HOME}/.${APP_NAME}/config/genesis.json ]; then
if [ ! -f ${HOME}/.${APP_NAME}/config/genesis.json ]; then
mkdir -p ${HOME}/.shared/claims
select_num
initialize_validator ${VALIDATOR_ID}
if [ ${VALIDATOR_ID} -eq 0 ]; then
Expand Down
2 changes: 2 additions & 0 deletions devel/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ services:
./bin/modify-config && \
exec ${BIN_NAME} start"
environment:
HOME: /home/${APP_NAME}
DENOM: ${DENOM}
NUM_VALIDATORS: ${NUM_VALIDATORS}
volumes:
- /home/${APP_NAME}
Expand Down
7 changes: 7 additions & 0 deletions devel/env/gaia.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
COMPOSE_PROJECT_NAME=gaia
VERSION=11.0.0
APP_NAME=gaia
BIN_NAME=gaiad
USER_NAME=gaia
NUM_VALIDATORS=3
DENOM=uatom
2 changes: 2 additions & 0 deletions devel/terra.env → devel/env/terra.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
COMPOSE_PROJECT_NAME=terra
VERSION=2.4.1
APP_NAME=terra
BIN_NAME=terrad
USER_NAME=terra
NUM_VALIDATORS=3
DENOM=uluna

0 comments on commit 03a56a5

Please sign in to comment.