diff --git a/README.md b/README.md index 5d5c0b4..223c7b3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -### Here you can find sample scripts and notes of how to [setup multiple EVMOS chains](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/tree/main/blockchain-in-docker) and [connect them via an IBC (using Hermes as relayer)](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/tree/main/hermes-as-ibc-relayer) to transfer tokens & coins cross chains, as well as block explorers for them (using Big Dipper 2.0 for Cosmos based chains) +### Here you can find sample scripts and notes of how to [setup multiple EVMOS chains](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/tree/main/blockchain-in-docker) and [connect them via an IBC (using Hermes as relayer)](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/tree/main/hermes-as-ibc-relayer) to transfer tokens & coins cross chains, as well as [block explorers for them](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/tree/main/big-dipper-as-block-explorer) (using Big Dipper 2.0 for Cosmos based chains) I wrote hundred lines of comments which explains every steps in each script file and each readme file, hope that helps you guys in exploring Evmos & Cosmos Ecosystem diff --git a/all-in-one.sh b/all-in-one.sh index 910aa30..698d87e 100755 --- a/all-in-one.sh +++ b/all-in-one.sh @@ -8,13 +8,13 @@ # It is not recommended to use this script if [ ! -f "./env.sh" ]; then - echo "Wrong working directory" + echo >&2 "ERR: Wrong working directory" exit 1 fi show_required_tools() { MSG="'$1' tool is required" - echo >&2 "$MSG" + echo >&2 "ERR: $MSG" echo >&2 "______" echo >&2 "The app requires following tools:" echo >&2 "- jq" @@ -36,7 +36,7 @@ show_required_tools() { echo >&2 " + https://hasura.io/docs/latest/graphql/core/hasura-cli/install-hasura-cli/" echo >&2 " + Hint: curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | bash" echo >&2 "______" - echo >&2 "$MSG" + echo >&2 "ERR: $MSG" } command -v jq > /dev/null 2>&1 || { show_required_tools 'jq'; exit 1; } @@ -74,8 +74,8 @@ echo if [[ $REPLY =~ ^[Yy]$ ]] then command -v systemctl > /dev/null 2>&1 - if [ $? -ne 0 ]; then - echo "`systemd` is required!!! You better prepare an Ubuntu machine and try this later.." + if [ $? -ne 0 ] || [ ! -d "/etc/systemd/system" ] ; then + echo >&2 "`systemd` is required!!! You better prepare an Ubuntu machine and try this later.." exit 1 fi echo " ! OK, let's go" @@ -184,3 +184,4 @@ echo "1. Check 3 validator containers & make sure they are proceducing block" echo "2. Make sure bdjuno & hasura services are ok" echo "3. Go to block explorer UI and check things there" echo "4. Check Hermes is working well" +echo "5. Make sure the service files at '/etc/systemd/system/*.service' has correct working directort and execution path (in case you changed any repo/branch)" diff --git a/big-dipper-as-block-explorer/1_install-bdjuno.sh b/big-dipper-as-block-explorer/1_install-bdjuno.sh index a8d432d..3170ece 100755 --- a/big-dipper-as-block-explorer/1_install-bdjuno.sh +++ b/big-dipper-as-block-explorer/1_install-bdjuno.sh @@ -1,7 +1,7 @@ #!/bin/bash -command -v docker > /dev/null 2>&1 || { echo >&2 "docker is required"; exit 1; } -command -v psql > /dev/null 2>&1 || { echo >&2 "psql is required, you first need to install psql client. Hint: sudo apt install postgresql-client"; exit 1; } +command -v docker > /dev/null 2>&1 || { echo >&2 "ERR: docker is required"; exit 1; } +command -v psql > /dev/null 2>&1 || { echo >&2 "ERR: psql is required, you first need to install psql client. Hint: sudo apt install postgresql-client"; exit 1; } source ../env.sh @@ -14,8 +14,8 @@ fi if [ -f "./_config.sh" ]; then source "./_config.sh" else - echo "ERR: Wrong working directory" - echo "ERR: Scripts must be executed within [big-dipper-as-block-explorer] directory" + echo >&2 "ERR: Wrong working directory" + echo >&2 "Scripts must be executed within [big-dipper-as-block-explorer] directory" exit 1 fi @@ -25,10 +25,10 @@ if [ "$CHAIN_NO" = "1" ]; then elif [ "$CHAIN_NO" = "2" ]; then echo "Chain 2" else - echo 'Missing or incorrect chain no as first argument, valid input is 1 or 2' - echo 'For example:' - echo " $0 1" - echo " or: $0 2" + echo >&2 'ERR: Missing or incorrect chain no as first argument, valid input is 1 or 2' + echo >&2 'For example:' + echo >&2 " $0 1" + echo >&2 " or: $0 2" exit 1 fi @@ -57,30 +57,56 @@ docker run \ -e POSTGRES_PASSWORD=$BD_CFG_PG_USR_PASS \ -v $PG_VOL_NAME:/data/db \ postgres:12.5 -[ $? -eq 0 ] || { echo "ERR: Failed to create a PostgreSQL container"; } +[ $? -eq 0 ] || { echo >&2 "ERR: Failed to create a PostgreSQL container"; } echo 'Waiting DB up' sleep 3s echo "- Creating database $BD_PG_DB" PGPASSWORD=$BD_CFG_PG_USR_PASS psql -h 127.0.0.1 -p $PG_PORT -d postgres -U postgres -c "CREATE DATABASE $BD_PG_DB;" -[ $? -eq 0 ] || { echo "ERR: Operation failed!"; } +[ $? -eq 0 ] || { echo >&2 "ERR: Operation failed!"; } echo "- Creating user $BD_PG_USER" PGPASSWORD=$BD_CFG_PG_USR_PASS psql -h 127.0.0.1 -p $PG_PORT -d postgres -U postgres -c "CREATE USER $BD_PG_USER WITH ENCRYPTED PASSWORD '$BD_PG_PASS';" -[ $? -eq 0 ] || { echo "ERR: Operation failed!"; } +[ $? -eq 0 ] || { echo >&2 "ERR: Operation failed!"; } echo "- Grant all privileges on db $BD_PG_DB to user $BD_PG_USER" PGPASSWORD=$BD_CFG_PG_USR_PASS psql -h 127.0.0.1 -p $PG_PORT -d postgres -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE $BD_PG_DB TO $BD_PG_USER;" -[ $? -eq 0 ] || { echo "ERR: Operation failed!"; } +[ $? -eq 0 ] || { echo >&2 "ERR: Operation failed!"; } # Check bdjuno source +# If the repo is different with config, show a warning if [ -d "./$BD_SOURCE_DIR" ]; then - echo "bdjuno repo was downloaded" + echo "bdjuno repo exists" + echo "Checking repo url & branch name" + CHK_RES_1="$(git --git-dir "./$BD_SOURCE_DIR"/.git --work-tree "./$BD_SOURCE_DIR" config --get remote.origin.url)" + if [ $? -ne 0 ] || [ -z "$CHK_RES_1" ]; then + echo "WARN! Unable to check remote origin url of git repo at $BD_SOURCE_DIR" + sleep 2s + elif [ "$CHK_RES_1" != "$BD_GIT_REPO" ]; then + echo "WARN! Git repo Url does not match" + echo "Expected: '$BD_GIT_REPO'" + echo "Actual: '$CHK_RES_1'" + echo "You should check it (script will continue execution after 10s)" + sleep 10s + fi + CHK_RES_2="$(git --git-dir "./$BD_SOURCE_DIR"/.git --work-tree "./$BD_SOURCE_DIR" rev-parse --abbrev-ref HEAD)" + if [ $? -ne 0 ] || [ -z "$CHK_RES_2" ]; then + echo "WARN! Unable to check branch of git repo at $BD_SOURCE_DIR" + sleep 2s + elif [ "$CHK_RES_2" = "HEAD" ]; then + echo "WARN! Can not check branch" + elif [ "$CHK_RES_2" != "$BD_GIT_BRANCH" ]; then + echo "WARN! Git Branch does not match" + echo "Expected: '$BD_GIT_BRANCH'" + echo "Actual: '$CHK_RES_2'" + echo "You should check it (script will continue execution after 10s)" + sleep 10s + fi else - echo "Downloading bdjuno source code from branch $BD_BRANCH" - git clone "$BD_GIT_REPO" --branch "$BD_BRANCH" --single-branch "$BD_SOURCE_DIR" + echo "Downloading bdjuno source code from branch $BD_GIT_BRANCH" + git clone "$BD_GIT_REPO" --branch "$BD_GIT_BRANCH" --single-branch "$BD_SOURCE_DIR" if [ $? -ne 0 ]; then - echo "Git clone bdjuno branch $BD_BRANCH failed" + echo >&2 "ERR: Git clone bdjuno branch $BD_GIT_BRANCH failed" exit 1 fi fi @@ -88,7 +114,7 @@ fi SCHEMA_DIR="./$BD_SOURCE_DIR/database/schema" if [ ! -d "$SCHEMA_DIR" ]; then - echo "ERR: Schema dir $SCHEMA_DIR could not be found" + echo >&2 "ERR: Schema dir $SCHEMA_DIR could not be found" exit 1 fi @@ -102,7 +128,7 @@ cd "./$BD_SOURCE_DIR" echo echo 'Compiling bdjuno' make install -[ $? -ne 0 ] && { echo "ERR: Failed to compile"; exit 1; } +[ $? -ne 0 ] && { echo >&2 "ERR: Failed to compile"; exit 1; } echo "Rename $BD_BINARY_ORIGIN into $BD_BINARY" mv "$BD_BINARY_ORIGIN" "$BD_BINARY" cd "$CUR_DIR" diff --git a/big-dipper-as-block-explorer/2_install-bdjuno.sh b/big-dipper-as-block-explorer/2_install-bdjuno.sh index 88dd070..b6747bb 100755 --- a/big-dipper-as-block-explorer/2_install-bdjuno.sh +++ b/big-dipper-as-block-explorer/2_install-bdjuno.sh @@ -11,8 +11,8 @@ fi if [ -f "./_config.sh" ]; then source "./_config.sh" else - echo "ERR: Wrong working directory" - echo "ERR: Scripts must be executed within [big-dipper-as-block-explorer] directory" + echo >&2 "ERR: Wrong working directory" + echo >&2 "Scripts must be executed within [big-dipper-as-block-explorer] directory" exit 1 fi @@ -22,10 +22,10 @@ if [ "$CHAIN_NO" = "1" ]; then elif [ "$CHAIN_NO" = "2" ]; then echo "Chain 2" else - echo 'Missing or incorrect chain no as first argument, valid input is 1 or 2' - echo 'For example:' - echo " $0 1" - echo " or: $0 2" + echo >&2 'ERR: Missing or incorrect chain no as first argument, valid input is 1 or 2' + echo >&2 'For example:' + echo >&2 " $0 1" + echo >&2 " or: $0 2" exit 1 fi @@ -41,23 +41,23 @@ if [ ! -f "$GENESIS_JSON" ]; then if [ $EXTRA_FUNC -eq 1 ]; then cp '../blockchain-in-docker/.evmosd'$CHAIN_NO'0/config/genesis.json' "$GENESIS_JSON" if [ ! -f "$GENESIS_JSON" ]; then - echo "Please copy genesis.json from your chain into $BD_HOME" + echo >&2 "ERR: Please copy genesis.json from your chain into $BD_HOME" exit 1 fi else - echo "Missing genesis.json file (expect: $GENESIS_JSON)" + echo >&2 "ERR: Missing genesis.json file (expect: $GENESIS_JSON)" echo "Please copy that file from your chain" exit 1 fi fi echo "Parsing genesis file" $BD_BINARY parse genesis-file --genesis-file-path "$GENESIS_JSON" --home "$BD_HOME" -[ $? -eq 0 ] || { echo "ERR: Failed to parse genesis.json!"; exit 1; } +[ $? -eq 0 ] || { echo >&2 "ERR: Failed to parse genesis.json!"; exit 1; } ## Check chain id GENESIS_CHAIN_ID=$(cat "$GENESIS_JSON" | jq .chain_id | head -n 1 | tr -d '"') if [ "$GENESIS_CHAIN_ID" != "$CHAIN_ID" ]; then - echo "ERR: Mis-match chain id, expect [$CHAIN_ID] but found [$GENESIS_CHAIN_ID] on genesis.json" + echo >&2 "ERR: Mis-match chain id, expect [$CHAIN_ID] but found [$GENESIS_CHAIN_ID] on genesis.json" exit 1 fi @@ -111,6 +111,7 @@ if [ $DISABLE_SYSTEMCTL -eq 0 ]; then fi echo 'Finished bdjuno installtion' +echo "Notice!!! Make sure the service file at '/etc/systemd/system/$BD_SERVICE_NAME.service' has correct working directort and execution path (in case you changed any repo/branch)" echo echo 'Now move to install Hasura by running 3_install-hasura.sh' diff --git a/big-dipper-as-block-explorer/3_install-hasura.sh b/big-dipper-as-block-explorer/3_install-hasura.sh index 9dd7548..b283fea 100755 --- a/big-dipper-as-block-explorer/3_install-hasura.sh +++ b/big-dipper-as-block-explorer/3_install-hasura.sh @@ -1,7 +1,7 @@ #!/bin/bash -command -v docker > /dev/null 2>&1 || { echo >&2 "docker is required"; exit 1; } -command -v psql > /dev/null 2>&1 || { echo >&2 "psql is required, you first need to install psql client. Hint: sudo apt install postgresql-client"; exit 1; } +command -v docker > /dev/null 2>&1 || { echo >&2 "ERR: docker is required"; exit 1; } +command -v psql > /dev/null 2>&1 || { echo >&2 "ERR: psql is required, you first need to install psql client. Hint: sudo apt install postgresql-client"; exit 1; } source ../env.sh @@ -14,8 +14,8 @@ fi if [ -f "./_config.sh" ]; then source "./_config.sh" else - echo "ERR: Wrong working directory" - echo "ERR: Scripts must be executed within [big-dipper-as-block-explorer] directory" + echo >&2 "ERR: Wrong working directory" + echo >&2 "Scripts must be executed within [big-dipper-as-block-explorer] directory" exit 1 fi @@ -25,10 +25,10 @@ if [ "$CHAIN_NO" = "1" ]; then elif [ "$CHAIN_NO" = "2" ]; then echo "Chain 2" else - echo 'Missing or incorrect chain no as first argument, valid input is 1 or 2' - echo 'For example:' - echo " $0 1" - echo " or: $0 2" + echo >&2 'ERR: Missing or incorrect chain no as first argument, valid input is 1 or 2' + echo >&2 'For example:' + echo >&2 " $0 1" + echo >&2 " or: $0 2" exit 1 fi @@ -37,7 +37,7 @@ if [ -f "$BD_HASURA_BINARY" ]; then elif [ command -v hasura > /dev/null 2>&1 ]; then export BD_HASURA_BINARY="hasura" else - echo "hasura-cli is required, more info: https://hasura.io/docs/latest/graphql/core/hasura-cli/install-hasura-cli/ . Hint: curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | bash" + echo >&2 "ERR: hasura-cli is required, more info: https://hasura.io/docs/latest/graphql/core/hasura-cli/install-hasura-cli/ . Hint: curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | bash" exit 1 fi diff --git a/big-dipper-as-block-explorer/4_install-front-end.sh b/big-dipper-as-block-explorer/4_install-front-end.sh index f5d6427..872cbf8 100755 --- a/big-dipper-as-block-explorer/4_install-front-end.sh +++ b/big-dipper-as-block-explorer/4_install-front-end.sh @@ -1,6 +1,6 @@ #!/bin/bash -command -v npm > /dev/null 2>&1 || { echo >&2 "npm is required"; exit 1; } +command -v npm > /dev/null 2>&1 || { echo >&2 "ERR: npm is required"; exit 1; } source ../env.sh @@ -13,8 +13,8 @@ fi if [ -f "./_config.sh" ]; then source "./_config.sh" else - echo "ERR: Wrong working directory" - echo "ERR: Scripts must be executed within [big-dipper-as-block-explorer] directory" + echo >&2 "ERR: Wrong working directory" + echo >&2 "Scripts must be executed within [big-dipper-as-block-explorer] directory" exit 1 fi @@ -24,10 +24,10 @@ if [ "$CHAIN_NO" = "1" ]; then elif [ "$CHAIN_NO" = "2" ]; then echo "Chain 2" else - echo 'Missing or incorrect chain no as first argument, valid input is 1 or 2' - echo 'For example:' - echo " $0 1" - echo " or: $0 2" + echo >&2 'ERR: Missing or incorrect chain no as first argument, valid input is 1 or 2' + echo >&2 'For example:' + echo >&2 " $0 1" + echo >&2 " or: $0 2" exit 1 fi @@ -40,13 +40,38 @@ fi # Check Big Dipper 2.0 source if [ -d "$BD2_SOURCE_DIR" ]; then - echo "Big Dipper 2.0 repo was downloaded" + echo "Big Dipper 2.0 repo exists" + echo "Checking repo url & branch name" + CHK_RES_1="$(git --git-dir "./$BD2_SOURCE_DIR"/.git --work-tree "./$BD2_SOURCE_DIR" config --get remote.origin.url)" + if [ $? -ne 0 ] || [ -z "$CHK_RES_1" ]; then + echo "WARN! Unable to check remote origin url of git repo at $BD2_SOURCE_DIR" + sleep 2s + elif [ "$CHK_RES_1" != "$BD2_GIT_REPO" ]; then + echo "WARN! Git repo Url does not match" + echo "Expected: '$BD2_GIT_REPO'" + echo "Actual: '$CHK_RES_1'" + echo "You should check it (script will continue execution after 10s)" + sleep 10s + fi + CHK_RES_2="$(git --git-dir "./$BD2_SOURCE_DIR"/.git --work-tree "./$BD2_SOURCE_DIR" rev-parse --abbrev-ref HEAD)" + if [ $? -ne 0 ] || [ -z "$CHK_RES_2" ]; then + echo "WARN! Unable to check branch of git repo at $BD2_SOURCE_DIR" + sleep 2s + elif [ "$CHK_RES_2" = "HEAD" ]; then + echo "WARN! Can not check branch" + elif [ "$CHK_RES_2" != "$BD2_BRANCH" ]; then + echo "WARN! Git Branch does not match" + echo "Expected: '$BD2_BRANCH'" + echo "Actual: '$CHK_RES_2'" + echo "You should check it (script will continue execution after 10s)" + sleep 10s + fi else echo "Downloading Big Dipper 2.0 source code from branch $BD2_BRANCH" git clone "$BD2_GIT_REPO" --branch "$BD2_BRANCH" --single-branch "$BD2_SOURCE_DIR" if [ $? -ne 0 ]; then - echo "Git clone Big Dipper 2.0 from branch $BD2_BRANCH was failed" + echo >&2 "ERR: Git clone Big Dipper 2.0 from branch $BD2_BRANCH was failed" exit 1 fi fi @@ -93,14 +118,14 @@ WORKING_DIR=$(pwd) # Build ## Install graphql-codegen npm i -D @graphql-codegen/cli > /dev/null 2>&1 -[ $? -eq 0 ] || { echo "Failed to install @graphql-codegen/cli"; exit 1; } +[ $? -eq 0 ] || { echo >&2 "ERR: Failed to install @graphql-codegen/cli"; exit 1; } ## Gen code echo 'Generating code' npm run graphql:codegen -[ $? -eq 0 ] || { echo "Failed to run graphql:codegen"; exit 1; } +[ $? -eq 0 ] || { echo >&2 "ERR: Failed to run graphql:codegen"; exit 1; } #echo 'Build' #npm run build -#[ $? -eq 0 ] || { echo "Failed to build"; exit 1; } +#[ $? -eq 0 ] || { echo >&2 "ERR: Failed to build"; exit 1; } cd "$CUR_DIR" @@ -147,4 +172,6 @@ if [ $DISABLE_SYSTEMCTL -eq 0 ]; then else echo "OK, you can run it now" echo "Hint: npm run dev" -fi \ No newline at end of file +fi + +echo "Notice!!! Make sure the service file at '/etc/systemd/system/$BD2_SERVICE_NAME.service' has correct working directort and execution path (in case you changed any repo/branch)" \ No newline at end of file diff --git a/big-dipper-as-block-explorer/_config.sh b/big-dipper-as-block-explorer/_config.sh index 2de8a3a..831010d 100755 --- a/big-dipper-as-block-explorer/_config.sh +++ b/big-dipper-as-block-explorer/_config.sh @@ -7,7 +7,7 @@ if [ "$CHAIN_NO" = "1" ]; then export RPC_ADDR=$BD_CFG_CHAIN_1_RPC_ADDR export GRPC_ADDR=$BD_CFG_CHAIN_1_GRPC_ADDR export BD_GIT_REPO="$BD_CFG_CHAIN_1_GIT_REPO" - export BD_BRANCH="$BD_CFG_CHAIN_1_BRANCH" + export BD_GIT_BRANCH="$BD_CFG_CHAIN_1_GIT_REPO_BRANCH" export BD_HASURA_PORT=$BD_CFG_CHAIN_1_HASURA_PORT export BD_HASURA_ACTIONBASE_PORT=$BD_CFG_CHAIN_1_HASURA_ACTIONBASE_PORT export DENOM_SYMBOL="$BD_CFG_CHAIN_1_DENOM_SYMBOL" @@ -25,7 +25,7 @@ elif [ "$CHAIN_NO" = "2" ]; then export RPC_ADDR=$BD_CFG_CHAIN_2_RPC_ADDR export GRPC_ADDR=$BD_CFG_CHAIN_2_GRPC_ADDR export BD_GIT_REPO="$BD_CFG_CHAIN_2_GIT_REPO" - export BD_BRANCH="$BD_CFG_CHAIN_2_BRANCH" + export BD_GIT_BRANCH="$BD_CFG_CHAIN_2_GIT_REPO_BRANCH" export BD_HASURA_PORT=$BD_CFG_CHAIN_2_HASURA_PORT export BD_HASURA_ACTIONBASE_PORT=$BD_CFG_CHAIN_2_HASURA_ACTIONBASE_PORT export DENOM_SYMBOL="$BD_CFG_CHAIN_2_DENOM_SYMBOL" @@ -47,7 +47,7 @@ echo "- gRPC: $GRPC_ADDR" echo "- Postgres port: $PG_PORT" echo "- Account prefix: $ACCOUNT_PREFIX" echo "- Expose UI at port: $BD2_PORT" -echo "- bdjuno repo $BD_GIT_REPO branch $BD_BRANCH" +echo "- bdjuno repo $BD_GIT_REPO branch $BD_GIT_BRANCH" echo "- bd2 repo $BD2_GIT_REPO branch $BD2_BRANCH" export BD_HOME=$(pwd)"/.bdjuno$CHAIN_NO" diff --git a/blockchain-in-docker/1_prepare-genesis.sh b/blockchain-in-docker/1_prepare-genesis.sh index 906ed78..9d7e486 100755 --- a/blockchain-in-docker/1_prepare-genesis.sh +++ b/blockchain-in-docker/1_prepare-genesis.sh @@ -1,7 +1,7 @@ #!/bin/bash -command -v docker > /dev/null 2>&1 || { echo >&2 "docker is required"; exit 1; } -command -v 'docker-compose' > /dev/null 2>&1 || { echo >&2 "docker-compose is required"; exit 1; } +command -v docker > /dev/null 2>&1 || { echo >&2 "ERR: docker is required"; exit 1; } +command -v 'docker-compose' > /dev/null 2>&1 || { echo >&2 "ERR: docker-compose is required"; exit 1; } source ../env.sh @@ -14,8 +14,8 @@ fi if [ -f "./_config.sh" ]; then source "./_config.sh" else - echo "ERR: Wrong working directory" - echo "ERR: Scripts must be executed within [blockchain-in-docker] directory" + echo >&2 "ERR: Wrong working directory" + echo >&2 "Scripts must be executed within [blockchain-in-docker] directory" exit 1 fi @@ -25,10 +25,10 @@ if [ "$CHAIN_NO" = "1" ]; then elif [ "$CHAIN_NO" = "2" ]; then echo "Chain 2" else - echo 'Missing or incorrect chain no as first argument, valid input is 1 or 2' - echo 'For example:' - echo " $0 1" - echo " or: $0 2" + echo >&2 'ERR: Missing or incorrect chain no as first argument, valid input is 1 or 2' + echo >&2 'For example:' + echo >&2 " $0 1" + echo >&2 " or: $0 2" exit 1 fi @@ -43,7 +43,7 @@ if [ "$KEYRING" = "file" ]; then elif [ "$KEYRING" = "test" ]; then echo "Keyring: test **WARNING** only use keyring-backend=test for development purpose on local machine or you must secure your cloud env by whitelist some IP addresses, otherwise someone will take all your token, even tho it's only a test env" else - echo "Non supported keyring mode = $KEYRING, only support 'file' & 'test'" + echo >&2 "ERR: Non supported keyring mode = $KEYRING, only support 'file' & 'test'" exit 1 fi @@ -52,7 +52,7 @@ export BINARY="$GOPATH/bin/$DAEMON_BINARY_NAME" # Check & Install evmosd binary if not exists ./_make_binary.sh -[ $? -eq 0 ] || { echo "Failed to check & build daemon binary '$DAEMON_BINARY_NAME' at $BINARY"; } +[ $? -eq 0 ] || { echo >&2 "ERR: Failed to check & build daemon binary '$DAEMON_BINARY_NAME' at $BINARY"; } VAL_HOME_1=$VAL_HOME_PREFIX'0' VAL_HOME_2=$VAL_HOME_PREFIX'1' @@ -78,26 +78,26 @@ $BINARY config chain-id $CHAIN_ID --home $VAL_HOME_3 ## Genesis MONIKER=$MONIKER'-'$VAL_1_KEY_NAME $BINARY init $MONIKER --chain-id $CHAIN_ID --home $VAL_HOME_1 > /dev/null 2>&1 -[ $? -eq 0 ] || { echo "Err: Failed to init chain on node 0"; exit 1; } +[ $? -eq 0 ] || { echo >&2 "ERR: Failed to init chain on node 0"; exit 1; } MONIKER=$MONIKER'-'$VAL_2_KEY_NAME $BINARY init $MONIKER --chain-id $CHAIN_ID --home $VAL_HOME_2 > /dev/null 2>&1 -[ $? -eq 0 ] || { echo "Err: Failed to init pseudo chain for node 1"; exit 1; } +[ $? -eq 0 ] || { echo >&2 "ERR: Failed to init pseudo chain for node 1"; exit 1; } MONIKER=$MONIKER'-'$VAL_3_KEY_NAME $BINARY init $MONIKER --chain-id $CHAIN_ID --home $VAL_HOME_3 > /dev/null 2>&1 -[ $? -eq 0 ] || { echo "Err: Failed to init pseudo chain for node 2"; exit 1; } +[ $? -eq 0 ] || { echo >&2 "ERR: Failed to init pseudo chain for node 2"; exit 1; } # Import validator keys echo "Import validator keys for chain no $CHAIN_NO id $CHAIN_ID" if [ "$KEYRING" = "test" ]; then echo "- Validator 1, key name '$VAL_1_KEY_NAME'" ( echo "$VAL_1_SEED"; ) | $BINARY keys add "$VAL_1_KEY_NAME" --recover --keyring-backend "test" --home "$VAL_HOME_1" - [ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; } + [ $? -eq 0 ] || { echo >&2 "ERR: Failed to import"; exit 1; } echo "- Validator 2, key name '$VAL_2_KEY_NAME'" ( echo "$VAL_2_SEED"; ) | $BINARY keys add "$VAL_2_KEY_NAME" --recover --keyring-backend "test" --home "$VAL_HOME_1" - [ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; } + [ $? -eq 0 ] || { echo >&2 "ERR: Failed to import"; exit 1; } echo "- Validator 3, key name '$VAL_3_KEY_NAME'" ( echo "$VAL_3_SEED"; ) | $BINARY keys add "$VAL_3_KEY_NAME" --recover --keyring-backend "test" --home "$VAL_HOME_1" - [ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; } + [ $? -eq 0 ] || { echo >&2 "ERR: Failed to import"; exit 1; } else if [ "$CHAIN_TYPE" = "evmos" ]; then echo "- Validator 1, key name '$VAL_1_KEY_NAME'" @@ -108,7 +108,7 @@ else echo "and encryption password '$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD' to encrypt seed phrase" echo "of validator 1" $BINARY keys add "$VAL_1_KEY_NAME" --recover --keyring-backend "file" --home "$VAL_HOME_1" - [ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; } + [ $? -eq 0 ] || { echo >&2 "ERR: Failed to import"; exit 1; } echo "- Validator 2, key name '$VAL_2_KEY_NAME'" echo "** Due to evmos daemon bug, it is not possible to import seed & encryption password automatically at the same time, please copy & paste the following seed:" echo "___" @@ -117,7 +117,7 @@ else echo "and encryption password '$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD' to encrypt seed phrase" echo "of validator 2" $BINARY keys add "$VAL_2_KEY_NAME" --recover --keyring-backend "file" --home "$VAL_HOME_1" - [ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; } + [ $? -eq 0 ] || { echo >&2 "ERR: Failed to import"; exit 1; } echo "- Validator 3, key name '$VAL_3_KEY_NAME'" echo "** Due to evmos daemon bug, it is not possible to import seed & encryption password automatically at the same time, please copy & paste the following seed:" echo "___" @@ -126,17 +126,17 @@ else echo "and encryption password '$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD' to encrypt seed phrase" echo "of validator 3" $BINARY keys add "$VAL_3_KEY_NAME" --recover --keyring-backend "file" --home "$VAL_HOME_1" - [ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; } + [ $? -eq 0 ] || { echo >&2 "ERR: Failed to import"; exit 1; } else echo "- Validator 1, key name '$VAL_1_KEY_NAME', encryption password: '$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD', seed phase '$VAL_1_SEED'" ( echo "$VAL_1_SEED"; echo "$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD"; echo "$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD"; ) | $BINARY keys add "$VAL_1_KEY_NAME" --recover --keyring-backend "file" --home "$VAL_HOME_1" - [ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; } + [ $? -eq 0 ] || { echo >&2 "ERR: Failed to import"; exit 1; } echo "- Validator 2, key name '$VAL_2_KEY_NAME', encryption password: '$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD', seed phase '$VAL_2_SEED'" ( echo "$VAL_2_SEED"; echo "$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD"; echo "$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD"; ) | $BINARY keys add "$VAL_2_KEY_NAME" --recover --keyring-backend "file" --home "$VAL_HOME_1" - [ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; } + [ $? -eq 0 ] || { echo >&2 "ERR: Failed to import"; exit 1; } echo "- Validator 3, key name '$VAL_3_KEY_NAME', encryption password: '$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD', seed phase '$VAL_3_SEED'" ( echo "$VAL_3_SEED"; echo "$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD"; echo "$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD"; ) | $BINARY keys add "$VAL_3_KEY_NAME" --recover --keyring-backend "file" --home "$VAL_HOME_1" - [ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; } + [ $? -eq 0 ] || { echo >&2 "ERR: Failed to import"; exit 1; } fi fi @@ -163,7 +163,7 @@ ADDR_PATTERN="$ACCOUNT_PREFIX[0-9][a-z0-9]+" if [[ $VAL_1_ADDR =~ $ADDR_PATTERN ]]; then echo else - echo "ERR: Validator 1 '$VAL_1_KEY_NAME' wallet address '$VAL_1_ADDR' does not starts with '$ACCOUNT_PREFIX', did you forget to update the 'CHAIN_"$CHAIN_NO"_ACCOUNT_PREFIX' var" + echo >&2 "ERR: Validator 1 '$VAL_1_KEY_NAME' wallet address '$VAL_1_ADDR' does not starts with '$ACCOUNT_PREFIX', did you forget to update the 'CHAIN_"$CHAIN_NO"_ACCOUNT_PREFIX' var" exit 1 fi @@ -306,7 +306,7 @@ else --chain-id $CHAIN_ID \ --home $VAL_HOME_1 > /dev/null 2>&1 fi -[ $? -eq 0 ] || { echo "Failed to create genesis tx for validator 1"; exit 1; } +[ $? -eq 0 ] || { echo >&2 "ERR: Failed to create genesis tx for validator 1"; exit 1; } echo 'Generate genesis staking transaction '$(bc <<< "$VAL_2_STAKE / (10^$DENOM_EXPONENT)")' '$DENOM_SYMBOL' for validator '$VAL_2_KEY_NAME if [ "$KEYRING" = "test" ]; then @@ -328,7 +328,7 @@ else --chain-id $CHAIN_ID \ --home $VAL_HOME_2 > /dev/null 2>&1 fi -[ $? -eq 0 ] || { echo "Failed to create genesis tx for validator 2"; exit 1; } +[ $? -eq 0 ] || { echo >&2 "ERR: Failed to create genesis tx for validator 2"; exit 1; } echo "Copy generated tx to $VAL_HOME_1/config/gentx" cp $VAL_HOME_2/config/gentx/gentx-* $VAL_HOME_1/config/gentx/ @@ -352,18 +352,18 @@ else --chain-id $CHAIN_ID \ --home $VAL_HOME_3 > /dev/null 2>&1 fi -[ $? -eq 0 ] || { echo "Failed to create genesis tx for validator 3"; exit 1; } +[ $? -eq 0 ] || { echo >&2 "ERR: Failed to create genesis tx for validator 3"; exit 1; } echo "Copy generated tx to $VAL_HOME_1/config/gentx" cp $VAL_HOME_3/config/gentx/gentx-* $VAL_HOME_1/config/gentx/ # Collect genesis tx to genesis.json echo "Collecting genesis transactions into genesis.json" $BINARY collect-gentxs --home $VAL_HOME_1 > /dev/null 2>&1 -[ $? -eq 0 ] || { echo "Failed to collect genesis transactions"; exit 1; } +[ $? -eq 0 ] || { echo >&2 "ERR: Failed to collect genesis transactions"; exit 1; } # Validate genesis.json $BINARY validate-genesis --home $VAL_HOME_1 -[ $? -eq 0 ] || { echo "Failed to validate genesis"; exit 1; } +[ $? -eq 0 ] || { echo >&2 "ERR: Failed to validate genesis"; exit 1; } # Update config.toml diff --git a/blockchain-in-docker/2_build-docker-image.sh b/blockchain-in-docker/2_build-docker-image.sh index c12b5f6..ae2ef72 100755 --- a/blockchain-in-docker/2_build-docker-image.sh +++ b/blockchain-in-docker/2_build-docker-image.sh @@ -1,7 +1,7 @@ #!/bin/bash -command -v docker > /dev/null 2>&1 || { echo >&2 "docker is required"; exit 1; } -command -v 'docker-compose' > /dev/null 2>&1 || { echo >&2 "docker-compose is required"; exit 1; } +command -v docker > /dev/null 2>&1 || { echo >&2 "ERR: docker is required"; exit 1; } +command -v 'docker-compose' > /dev/null 2>&1 || { echo >&2 "ERR: docker-compose is required"; exit 1; } source ../env.sh @@ -14,8 +14,8 @@ fi if [ -f "./_config.sh" ]; then source "./_config.sh" else - echo "ERR: Wrong working directory" - echo "ERR: Scripts must be executed within [blockchain-in-docker] directory" + echo >&2 "ERR: Wrong working directory" + echo >&2 "Scripts must be executed within [blockchain-in-docker] directory" exit 1 fi @@ -35,10 +35,10 @@ elif [ "$CHAIN_NO" = "2" ]; then export PORT_1317="$CHAIN_2_EXPOSE_REST_API_TO_PORT" export PORT_26656="$CHAIN_2_EXPOSE_P2P_TO_PORT" else - echo 'Missing or incorrect chain no as first argument, valid input is 1 or 2' - echo 'For example:' - echo " $0 1" - echo " or: $0 2" + echo >&2 'ERR: Missing or incorrect chain no as first argument, valid input is 1 or 2' + echo >&2 'For example:' + echo >&2 " $0 1" + echo >&2 " or: $0 2" exit 1 fi @@ -49,15 +49,40 @@ if [ -f "$DOCKER_COMPOSE_FILE" ]; then docker-compose -f "$DOCKER_COMPOSE_FILE" down fi -# Check EVMOS source +# Check source if [ -d "$SOURCE_CODE_DIR" ]; then - echo "EVMOS repo was downloaded" + echo "$CHAIN_NAME repo exists at $SOURCE_CODE_DIR" + echo "Checking repo url & branch name" + CHK_RES_1="$(git --git-dir "./$SOURCE_CODE_DIR"/.git --work-tree "./$SOURCE_CODE_DIR" config --get remote.origin.url)" + if [ $? -ne 0 ] || [ -z "$CHK_RES_1" ]; then + echo "WARN! Unable to check remote origin url of git repo at $SOURCE_CODE_DIR" + sleep 2s + elif [ "$CHK_RES_1" != "$GIT_REPO" ]; then + echo "WARN! Git repo Url does not match" + echo "Expected: '$GIT_REPO'" + echo "Actual: '$CHK_RES_1'" + echo "You should check it (script will continue execution after 10s)" + sleep 10s + fi + CHK_RES_2="$(git --git-dir "./$SOURCE_CODE_DIR"/.git --work-tree "./$SOURCE_CODE_DIR" rev-parse --abbrev-ref HEAD)" + if [ $? -ne 0 ] || [ -z "$CHK_RES_2" ]; then + echo "WARN! Unable to check branch of git repo at $SOURCE_CODE_DIR" + sleep 2s + elif [ "$CHK_RES_2" = "HEAD" ]; then + echo "WARN! Can not check branch" + elif [ "$CHK_RES_2" != "$GIT_BRANCH" ]; then + echo "WARN! Git Branch does not match" + echo "Expected: '$GIT_BRANCH'" + echo "Actual: '$CHK_RES_2'" + echo "You should check it (script will continue execution after 10s)" + sleep 10s + fi else - echo "Downloading EVMOS source code $GIT_BRANCH" + echo "Downloading $CHAIN_NAME source code $GIT_BRANCH" git clone "$GIT_REPO" --branch "$GIT_BRANCH" --single-branch "$SOURCE_CODE_DIR" if [ $? -ne 0 ]; then - echo "Git clone EVMOS $GIT_BRANCH failed" + echo >&2 "ERR: Git clone $CHAIN_NAME from branch $GIT_BRANCH has failed" exit 1 fi fi @@ -83,7 +108,7 @@ fi # Docker build echo "Build new docker image $DOCKER_IMAGE_NAME" docker build -t "$DOCKER_IMAGE_NAME" -f "$DOCKER_FILE" . -[ $? -eq 0 ] || { echo "Failed to build docker image"; exit 1; } +[ $? -eq 0 ] || { echo >&2 "ERR: Failed to build docker image"; exit 1; } # Create docker-compose yml DOCKER_COMPOSE_FILE="network$CHAIN_NO.yml" diff --git a/blockchain-in-docker/_config.sh b/blockchain-in-docker/_config.sh index df8b985..dd2a5ad 100755 --- a/blockchain-in-docker/_config.sh +++ b/blockchain-in-docker/_config.sh @@ -4,8 +4,8 @@ if [ "$CHAIN_NO" = "1" ]; then export CHAIN_TYPE="$CHAIN_1_TYPE" export CHAIN_ID="$CHAIN_1_ID" export HD_COINTYPE=$CHAIN_1_COINTYPE - export GIT_BRANCH="$CHAIN_1_GIT_REPO_BRANCH" export GIT_REPO="$CHAIN_1_GIT_REPO" + export GIT_BRANCH="$CHAIN_1_GIT_REPO_BRANCH" export DAEMON_BINARY_NAME="$CHAIN_1_DAEMON_BINARY_NAME" export DENOM_EXPONENT=$CHAIN_1_DENOM_EXPONENT export GAS_DENOM_EXPONENT=$CHAIN_1_GAS_DENOM_EXPONENT @@ -21,8 +21,8 @@ elif [ "$CHAIN_NO" = "2" ]; then export CHAIN_TYPE="$CHAIN_2_TYPE" export CHAIN_ID="$CHAIN_2_ID" export HD_COINTYPE=$CHAIN_2_COINTYPE - export GIT_BRANCH="$CHAIN_2_GIT_REPO_BRANCH" export GIT_REPO="$CHAIN_2_GIT_REPO" + export GIT_BRANCH="$CHAIN_2_GIT_REPO_BRANCH" export DAEMON_BINARY_NAME="$CHAIN_2_DAEMON_BINARY_NAME" export DENOM_EXPONENT=$CHAIN_2_DENOM_EXPONENT export GAS_DENOM_EXPONENT=$CHAIN_2_GAS_DENOM_EXPONENT diff --git a/blockchain-in-docker/_make_binary.sh b/blockchain-in-docker/_make_binary.sh index 7f7bdba..8a7d498 100755 --- a/blockchain-in-docker/_make_binary.sh +++ b/blockchain-in-docker/_make_binary.sh @@ -2,31 +2,53 @@ SOURCE_CODE_DIR="./source-code-$DENOM_SYMBOL-$GIT_BRANCH" -if [ -f "$BINARY" ]; then - echo "Nice! Daemon binary $DAEMON_BINARY_NAME is already exists" +# If the repo is different with config, show a warning +if [ -d "$SOURCE_CODE_DIR" ]; then + echo "$CHAIN_NAME repo exists at $SOURCE_CODE_DIR" + echo "Checking repo url & branch name" + CHK_RES_1="$(git --git-dir "./$SOURCE_CODE_DIR"/.git --work-tree "./$SOURCE_CODE_DIR" config --get remote.origin.url)" + if [ $? -ne 0 ] || [ -z "$CHK_RES_1" ]; then + echo "WARN! Unable to check remote origin url of git repo at $SOURCE_CODE_DIR" + sleep 2s + elif [ "$CHK_RES_1" != "$GIT_REPO" ]; then + echo "WARN! Git repo Url does not match" + echo "Expected: '$GIT_REPO'" + echo "Actual: '$CHK_RES_1'" + echo "You should check it (script will continue execution after 10s)" + sleep 10s + fi + CHK_RES_2="$(git --git-dir "./$SOURCE_CODE_DIR"/.git --work-tree "./$SOURCE_CODE_DIR" rev-parse --abbrev-ref HEAD)" + if [ $? -ne 0 ] || [ -z "$CHK_RES_2" ]; then + echo "WARN! Unable to check branch of git repo at $SOURCE_CODE_DIR" + sleep 2s + elif [ "$CHK_RES_2" = "HEAD" ]; then + echo "WARN! Can not check branch" + elif [ "$CHK_RES_2" != "$GIT_BRANCH" ]; then + echo "WARN! Git Branch does not match" + echo "Expected: '$GIT_BRANCH'" + echo "Actual: '$CHK_RES_2'" + echo "You should check it (script will continue execution after 10s)" + sleep 10s + fi else - if [ -d "$SOURCE_CODE_DIR" ]; then - echo "EVMOS repo was downloaded" - else - echo "Downloading EVMOS source code $GIT_BRANCH" - git clone "$GIT_REPO" --branch "$GIT_BRANCH" --single-branch "$SOURCE_CODE_DIR" + echo "Downloading $CHAIN_NAME source code $GIT_BRANCH" + git clone "$GIT_REPO" --branch "$GIT_BRANCH" --single-branch "$SOURCE_CODE_DIR" - if [ $? -ne 0 ]; then - echo "Git clone EVMOS $GIT_BRANCH failed" - exit 1 - fi - fi - - CUR_DIR=$(pwd) - cd "$SOURCE_CODE_DIR" - echo "Compiling $DAEMON_BINARY_NAME. If this is the first time you compile, it will take time, you can enjoy a cup of coffee and comeback later" - make install - [ $? -eq 0 ] || { echo "Failed to compile EVMOS"; exit 1; } - cd "$CUR_DIR" + if [ $? -ne 0 ]; then + echo >&2 "ERR: Git clone $CHAIN_NAME branch $GIT_BRANCH failed" + exit 1 + fi fi +CUR_DIR=$(pwd) +cd "$SOURCE_CODE_DIR" +echo "Compiling '$DAEMON_BINARY_NAME'. If this is the first time you compile, it will take time, you can enjoy a cup of coffee and comeback later" +make install +[ $? -eq 0 ] || { echo >&2 "ERR: Failed to compile $DAEMON_BINARY_NAME"; exit 1; } +cd "$CUR_DIR" + if [ ! -f "$BINARY" ]; then - echo "Chain's source code was compiled but binary $DAEMON_BINARY_NAME could not be found" + echo >&2 "ERR: Chain's source code was compiled but binary '$DAEMON_BINARY_NAME' could not be found" echo "You must find it and put it into PATH environment variable" echo "(It usually compile and moved to $GOPATH/bin)" exit 1 diff --git a/blockchain-in-docker/cleanup.sh b/blockchain-in-docker/cleanup.sh index df914f4..14d9afb 100755 --- a/blockchain-in-docker/cleanup.sh +++ b/blockchain-in-docker/cleanup.sh @@ -1,6 +1,6 @@ #!/bin/bash -command -v 'docker-compose' > /dev/null 2>&1 || { echo >&2 "docker-compose is required"; exit 1; } +command -v 'docker-compose' > /dev/null 2>&1 || { echo >&2 "ERR: docker-compose is required"; exit 1; } down() { CHAIN_NO=$1 @@ -10,7 +10,7 @@ down() { echo "Shutting down chain $CHAIN_NO" docker-compose -f "$DCF" down else - echo "Can not shutdown containers of chain $CHAIN_NO because docker compose file $DCF could not be found" + echo "WARN! Can not shutdown containers of chain $CHAIN_NO because docker compose file $DCF could not be found" fi } diff --git a/env.sh b/env.sh index a6454fe..da38209 100644 --- a/env.sh +++ b/env.sh @@ -1,12 +1,12 @@ #!/bin/bash # Pre-requisites -command -v jq > /dev/null 2>&1 || { echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/ (Hint: sudo apt install jq -y)"; exit 1; } -command -v yq > /dev/null 2>&1 || { echo >&2 "yq not installed. More info: https://github.com/kislyuk/yq/ (Hint: sudo apt install python3-pip -y && pip3 install yq)"; exit 1; } -command -v tomlq > /dev/null 2>&1 || { echo >&2 "tomlq not installed, it is expected to be delivered within yq package"; exit 1; } -command -v bc > /dev/null 2>&1 || { echo >&2 "bc command could not be found"; exit 1; } -command -v make > /dev/null 2>&1 || { echo >&2 "make command could not be found"; exit 1; } -command -v go > /dev/null 2>&1 || { echo >&2 "go was not installed. More info: https://go.dev/doc/install"; exit 1; } +command -v jq > /dev/null 2>&1 || { echo >&2 "ERR: jq not installed. More info: https://stedolan.github.io/jq/download/ (Hint: sudo apt install jq -y)"; exit 1; } +command -v yq > /dev/null 2>&1 || { echo >&2 "ERR: yq not installed. More info: https://github.com/kislyuk/yq/ (Hint: sudo apt install python3-pip -y && pip3 install yq)"; exit 1; } +command -v tomlq > /dev/null 2>&1 || { echo >&2 "ERR: tomlq not installed, it is expected to be delivered within yq package"; exit 1; } +command -v bc > /dev/null 2>&1 || { echo >&2 "ERR: bc command could not be found"; exit 1; } +command -v make > /dev/null 2>&1 || { echo >&2 "ERR: make command could not be found"; exit 1; } +command -v go > /dev/null 2>&1 || { echo >&2 "ERR: go was not installed. More info: https://go.dev/doc/install"; exit 1; } # Configurations @@ -144,7 +144,7 @@ export BD_PG_HASURA_PASS="PX2RNvtZ4m7fntnbRrtySB4ROG5EKk4J" export BD_CFG_PG_USR_PASS="6N4QtFYMt7h972uazrWTckmMvFZWIje" # Password of default user postgres ### Chain 1 export BD_CFG_CHAIN_1_GIT_REPO="https://github.com/forbole/bdjuno.git" -export BD_CFG_CHAIN_1_BRANCH="chains/evmos/mainnet" # must belong to repo $BD_CFG_CHAIN_1_GIT_REPO +export BD_CFG_CHAIN_1_GIT_REPO_BRANCH="chains/evmos/mainnet" # must belong to repo $BD_CFG_CHAIN_1_GIT_REPO export BD_CFG_CHAIN_1_PG_PORT=5432 export BD_CFG_CHAIN_1_ACCOUNT_PREFIX="$CHAIN_1_ACCOUNT_PREFIX" export BD_CFG_CHAIN_1_RPC_ADDR="127.0.0.1:$CHAIN_1_EXPOSE_RPC_TO_PORT" @@ -157,7 +157,7 @@ export BD_CFG_CHAIN_1_MIN_DENOM_SYMBOL="$CHAIN_1_MIN_DENOM_SYMBOL" # aevmos/uato export BD_CFG_CHAIN_1_DENOM_EXPONENT=$CHAIN_1_DENOM_EXPONENT # no of digits (18 for evmos, 6 for cosmos atom) ### Chain 2 export BD_CFG_CHAIN_2_GIT_REPO="https://github.com/forbole/bdjuno.git" -export BD_CFG_CHAIN_2_BRANCH="chains/evmos/mainnet" # must belong to repo $BD_CFG_CHAIN_2_GIT_REPO +export BD_CFG_CHAIN_2_GIT_REPO_BRANCH="chains/evmos/mainnet" # must belong to repo $BD_CFG_CHAIN_2_GIT_REPO export BD_CFG_CHAIN_2_PG_PORT=15432 export BD_CFG_CHAIN_2_ACCOUNT_PREFIX="$CHAIN_2_ACCOUNT_PREFIX" export BD_CFG_CHAIN_2_RPC_ADDR="127.0.0.1:$CHAIN_2_EXPOSE_RPC_TO_PORT" @@ -190,12 +190,14 @@ export DOCKER_IMAGE_NAME_PREFIX="evmos.victortrusty.dev:c" # Others # Just skip this part, don't read, no more custom-able here echo $NOTICE_DEV_ENV if [ -z "$GOPATH" ]; then - echo "Missing GOPATH environment variable, should be '$HOME/go'" + echo >&2 "ERR: Missing GOPATH environment variable, should be '$HOME/go'" exit 1 fi command -v systemctl > /dev/null 2>&1 if [ $? -eq 0 ]; then export DISABLE_SYSTEMCTL=0 +elif [ ! -d "/etc/systemd/system" ]; then + export DISABLE_SYSTEMCTL=1 else export DISABLE_SYSTEMCTL=1 fi diff --git a/hermes-as-ibc-relayer/_make_binary.sh b/hermes-as-ibc-relayer/_make_binary.sh index 0388f7d..435850b 100755 --- a/hermes-as-ibc-relayer/_make_binary.sh +++ b/hermes-as-ibc-relayer/_make_binary.sh @@ -1,31 +1,53 @@ #!/bin/bash export HERMES_SOURCE_DIR="$HERMES_SOURCE_DIR_PREFIX-$HERMES_GIT_REPO_BRANCH" -if [ -f "$BINARY" ]; then - echo "Nice! Hermes binary [$HERMES_BINARY] is already exists" +# If the repo is different with config, show a warning +if [ -d "$HERMES_SOURCE_DIR" ]; then + echo "Hermes repo exists at $HERMES_SOURCE_DIR" + echo "Checking repo url & branch name" + CHK_RES_1="$(git --git-dir "./$HERMES_SOURCE_DIR"/.git --work-tree "./$HERMES_SOURCE_DIR" config --get remote.origin.url)" + if [ $? -ne 0 ] || [ -z "$CHK_RES_1" ]; then + echo "WARN! Unable to check remote origin url of git repo at $HERMES_SOURCE_DIR" + sleep 2s + elif [ "$CHK_RES_1" != "$HERMES_GIT_REPO" ]; then + echo "WARN! Git repo Url does not match" + echo "Expected: '$HERMES_GIT_REPO'" + echo "Actual: '$CHK_RES_1'" + echo "You should check it (script will continue execution after 10s)" + sleep 10s + fi + CHK_RES_2="$(git --git-dir "./$HERMES_SOURCE_DIR"/.git --work-tree "./$HERMES_SOURCE_DIR" rev-parse --abbrev-ref HEAD)" + if [ $? -ne 0 ] || [ -z "$CHK_RES_2" ]; then + echo "WARN! Unable to check branch of git repo at $HERMES_SOURCE_DIR" + sleep 2s + elif [ "$CHK_RES_2" = "HEAD" ]; then + echo "WARN! Can not check branch" + elif [ "$CHK_RES_2" != "$HERMES_GIT_REPO_BRANCH" ]; then + echo "WARN! Git Branch does not match" + echo "Expected: '$HERMES_GIT_REPO_BRANCH'" + echo "Actual: '$CHK_RES_2'" + echo "You should check it (script will continue execution after 10s)" + sleep 10s + fi else - if [ -d "$HERMES_SOURCE_DIR" ]; then - echo "Hermes repo was downloaded" - else - echo "Downloading Hermes source code $HERMES_GIT_REPO_BRANCH" - git clone "$HERMES_GIT_REPO" --branch "$HERMES_GIT_REPO_BRANCH" --single-branch "$HERMES_SOURCE_DIR" + echo "Downloading Hermes source code $HERMES_GIT_REPO_BRANCH" + git clone "$HERMES_GIT_REPO" --branch "$HERMES_GIT_REPO_BRANCH" --single-branch "$HERMES_SOURCE_DIR" - if [ $? -ne 0 ]; then - echo "Git clone Hermes $HERMES_GIT_REPO_BRANCH failed" - exit 1 - fi - fi - - CUR_DIR=$(pwd) - cd "$HERMES_SOURCE_DIR" - echo "Compiling $HERMES_BINARY. If this is the first time you compile, it will take time, you can enjoy a cup of coffee and comeback later" - sleep 3s - cargo build --release --bin $HERMES_BINARY - [ $? -eq 0 ] || { echo "Failed to compile Hermes"; exit 1; } - cd "$CUR_DIR" + if [ $? -ne 0 ]; then + echo >&2 "ERR: Git clone Hermes $HERMES_GIT_REPO_BRANCH failed" + exit 1 + fi fi +CUR_DIR=$(pwd) +cd "$HERMES_SOURCE_DIR" +echo "Compiling $HERMES_BINARY. If this is the first time you compile, it will take time, you can enjoy a cup of coffee and comeback later" +sleep 3s +cargo build --release --bin $HERMES_BINARY +[ $? -eq 0 ] || { echo >&2 "ERR: Failed to compile Hermes"; exit 1; } +cd "$CUR_DIR" + if [ ! -f "$BINARY" ]; then - echo "Hermes source code was compiled but binary $HERMES_BINARY could not be found" + echo >&2 "ERR: Hermes source code was compiled but binary $HERMES_BINARY could not be found" exit 1 fi \ No newline at end of file diff --git a/hermes-as-ibc-relayer/cleanup.sh b/hermes-as-ibc-relayer/cleanup.sh index 37be2c8..ee07e3a 100755 --- a/hermes-as-ibc-relayer/cleanup.sh +++ b/hermes-as-ibc-relayer/cleanup.sh @@ -1,6 +1,6 @@ #!/bin/bash -command -v 'docker-compose' > /dev/null 2>&1 || { echo >&2 "docker-compose is required"; exit 1; } +command -v 'docker-compose' > /dev/null 2>&1 || { echo >&2 "ERR: docker-compose is required"; exit 1; } source ../env.sh @@ -9,5 +9,5 @@ if [ $DISABLE_SYSTEMCTL -eq 0 ]; then sudo systemctl stop $HERMES_SERVICE_NAME > /dev/null 2>&1 sudo systemctl disable $HERMES_SERVICE_NAME > /dev/null 2>&1 else - echo "I don't know what to do, this script only be used to stop hermes service name [$HERMES_SERVICE_NAME] on Debian OS" + echo "I don't know what to do, this script only be used to stop hermes service name [$HERMES_SERVICE_NAME] on systems that supports 'systemd'" fi \ No newline at end of file diff --git a/hermes-as-ibc-relayer/create-relayer.sh b/hermes-as-ibc-relayer/create-relayer.sh index 1327c48..d89c1b9 100755 --- a/hermes-as-ibc-relayer/create-relayer.sh +++ b/hermes-as-ibc-relayer/create-relayer.sh @@ -1,6 +1,6 @@ #!/bin/bash -command -v cargo > /dev/null 2>&1 || { echo >&2 "Rust & Cargo was not installed. More info: https://www.rust-lang.org/tools/install . Hint: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"; exit 1; } +command -v cargo > /dev/null 2>&1 || { echo >&2 "ERR: Rust & Cargo was not installed. More info: https://www.rust-lang.org/tools/install . Hint: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"; exit 1; } source ../env.sh @@ -31,7 +31,7 @@ if [ "$HERMES_NO_CONFIRM_BALANCE" != "1" ]; then echo " $CHAIN_1_DAEMON_BINARY_NAME tx bank send $VAL_2_KEY_NAME $REL_1_ADDR "$(bc <<< "$HERMES_RESERVED_FEE * (10^$HERMES_CFG_CHAIN_1_DENOM_EXPONENT)")"$HERMES_CFG_CHAIN_1_GAS_PRICE_DENOM_SYMBOL --home /.evmosd11 --node tcp://127.0.0.1:26657" echo " docker exec -it vtevmos21 bash" echo " $CHAIN_2_DAEMON_BINARY_NAME tx bank send $VAL_2_KEY_NAME $REL_2_ADDR "$(bc <<< "$HERMES_RESERVED_FEE * (10^$HERMES_CFG_CHAIN_2_DENOM_EXPONENT)")"$HERMES_CFG_CHAIN_2_GAS_PRICE_DENOM_SYMBOL --home /.evmosd21 --node tcp://127.0.0.1:26657" - exit 1 + exit 0 fi fi @@ -53,7 +53,7 @@ export BINARY=$(pwd)'/'$HERMES_SOURCE_DIR'/target/release/'$HERMES_BINARY # Check & Install hermes binary if not exists ./_make_binary.sh -[ $? -eq 0 ] || { echo "Failed to check & build $HERMES_BINARY binary at $BINARY"; } +[ $? -eq 0 ] || { echo >&2 "ERR: Failed to check & build $HERMES_BINARY binary at $BINARY"; } echo 'You can custom config by editing keys with prefix [HERMES_CFG_CHAIN_*] in [env.sh] file' sleep 3s @@ -137,26 +137,26 @@ $BINARY -c "$CONFIG_TOML" keys restore --mnemonic "$REL_2_SEED" --hd-path "m/44' ## Extract addr export CHECK_REL_1_ADDR="$($BINARY -c "$CONFIG_TOML" keys list "$HERMES_CFG_CHAIN_1_ID" | grep "$HERMES_CFG_CHAIN_1_KEY_NAME" | sed 's/.*\('$CHAIN_1_ACCOUNT_PREFIX'[a-z0-9]*\).*/\1/')" if [ -z "$CHECK_REL_1_ADDR" ]; then - echo "ERR: Relayer account on $HERMES_CFG_CHAIN_1_ID was imported but could not befound! Did you set the following variables correctly?" + echo >&2 "ERR: Relayer account on $HERMES_CFG_CHAIN_1_ID was imported but could not befound! Did you set the following variables correctly?" echo " + HERMES_CFG_CHAIN_1_KEY_NAME=$HERMES_CFG_CHAIN_1_KEY_NAME" echo " + CHAIN_1_ACCOUNT_PREFIX=$CHAIN_1_ACCOUNT_PREFIX" exit 1 elif [ "$CHECK_REL_1_ADDR" == "$REL_1_ADDR" ]; then echo "- Relayer wallet addr on $HERMES_CFG_CHAIN_1_ID is $REL_1_ADDR" else - echo "ERR: Relayer account on $HERMES_CFG_CHAIN_1_ID after import has wallet address is '$CHECK_REL_1_ADDR', it is different with configuration variable 'REL_1_ADDR'=$REL_1_ADDR" + echo >&2 "ERR: Relayer account on $HERMES_CFG_CHAIN_1_ID after import has wallet address is '$CHECK_REL_1_ADDR', it is different with configuration variable 'REL_1_ADDR'=$REL_1_ADDR" exit 1 fi export CHECK_REL_2_ADDR="$($BINARY -c "$CONFIG_TOML" keys list "$HERMES_CFG_CHAIN_2_ID" | grep "$HERMES_CFG_CHAIN_2_KEY_NAME" | sed 's/.*\('$CHAIN_2_ACCOUNT_PREFIX'[a-z0-9]*\).*/\1/')" if [ -z "$CHECK_REL_2_ADDR" ]; then - echo "ERR: Relayer account on $HERMES_CFG_CHAIN_2_ID was imported but could not befound! Did you set the following variables correctly?" + echo >&2 "ERR: Relayer account on $HERMES_CFG_CHAIN_2_ID was imported but could not befound! Did you set the following variables correctly?" echo " + HERMES_CFG_CHAIN_2_KEY_NAME=$HERMES_CFG_CHAIN_2_KEY_NAME" echo " + CHAIN_2_ACCOUNT_PREFIX=$CHAIN_2_ACCOUNT_PREFIX" exit 1 elif [ "$CHECK_REL_2_ADDR" == "$REL_2_ADDR" ]; then echo "- Relayer wallet addr on $HERMES_CFG_CHAIN_2_ID is $REL_2_ADDR" else - echo "ERR: Relayer account on $HERMES_CFG_CHAIN_2_ID after import has wallet address is '$CHECK_REL_2_ADDR', it is different with configuration variable 'REL_2_ADDR'=$REL_2_ADDR" + echo >&2 "ERR: Relayer account on $HERMES_CFG_CHAIN_2_ID after import has wallet address is '$CHECK_REL_2_ADDR', it is different with configuration variable 'REL_2_ADDR'=$REL_2_ADDR" exit 1 fi @@ -165,32 +165,32 @@ echo '- Creating client' RES_CREATE_CLIENT_1_TO_2=$($BINARY -c $CONFIG_TOML tx raw create-client $HERMES_CFG_CHAIN_1_ID $HERMES_CFG_CHAIN_2_ID) TENDERMINT_CLIENT_1_TO_2=$(echo $RES_CREATE_CLIENT_1_TO_2 | grep -o '07-tendermint-[0-9]*') echo ' > Client 1 to 2: '$TENDERMINT_CLIENT_1_TO_2 -[ -z "$TENDERMINT_CLIENT_1_TO_2" ] && { echo "Unable to create tendermint light client on chain 1"; exit 1; } +[ -z "$TENDERMINT_CLIENT_1_TO_2" ] && { echo >&2 "ERR: Unable to create tendermint light client on chain 1"; exit 1; } RES_CREATE_CLIENT_2_TO_1=$($BINARY -c $CONFIG_TOML tx raw create-client $HERMES_CFG_CHAIN_2_ID $HERMES_CFG_CHAIN_1_ID) TENDERMINT_CLIENT_2_TO_1=$(echo $RES_CREATE_CLIENT_2_TO_1 | grep -o '07-tendermint-[0-9]*') echo ' > Client 2 to 1: '$TENDERMINT_CLIENT_2_TO_1 -[ -z "$TENDERMINT_CLIENT_2_TO_1" ] && { echo "Unable to create tendermint light client on chain 2"; exit 1; } +[ -z "$TENDERMINT_CLIENT_2_TO_1" ] && { echo >&2 "ERR: Unable to create tendermint light client on chain 2"; exit 1; } echo '- Creating connection' RES_CREATE_CONN_1_TO_2=$($BINARY -c $CONFIG_TOML tx raw conn-init $HERMES_CFG_CHAIN_1_ID $HERMES_CFG_CHAIN_2_ID $TENDERMINT_CLIENT_1_TO_2 $TENDERMINT_CLIENT_2_TO_1) CONN_1_TO_2=$(echo $RES_CREATE_CONN_1_TO_2 | grep -o 'connection-[0-9]*') echo ' > Connection 1 to 2: '$CONN_1_TO_2 -[ -z "$CONN_1_TO_2" ] && { echo "Unable to create connection on chain 1"; exit 1; } +[ -z "$CONN_1_TO_2" ] && { echo >&2 "ERR: Unable to create connection on chain 1"; exit 1; } RES_CREATE_CONN_2_TO_1=$($BINARY -c $CONFIG_TOML tx raw conn-try $HERMES_CFG_CHAIN_2_ID $HERMES_CFG_CHAIN_1_ID $TENDERMINT_CLIENT_2_TO_1 $TENDERMINT_CLIENT_1_TO_2 -s $CONN_1_TO_2) CONN_2_TO_1=$(echo $RES_CREATE_CONN_2_TO_1 | grep -o 'connection-[0-9]*' | head -n 1) echo ' > Connection 2 to 1: '$CONN_2_TO_1 -[ -z "$CONN_2_TO_1" ] && { echo "Unable to create connection on chain 2"; exit 1; } +[ -z "$CONN_2_TO_1" ] && { echo >&2 "ERR: Unable to create connection on chain 2"; exit 1; } $BINARY -c $CONFIG_TOML tx raw conn-ack $HERMES_CFG_CHAIN_1_ID $HERMES_CFG_CHAIN_2_ID $TENDERMINT_CLIENT_1_TO_2 $TENDERMINT_CLIENT_2_TO_1 -d $CONN_1_TO_2 -s $CONN_2_TO_1 EXIT_CODE=$? sleep 2s -[ $EXIT_CODE -eq 0 ] || { echo "Operation failed"; exit 1; } +[ $EXIT_CODE -eq 0 ] || { echo >&2 "ERR: Operation failed"; exit 1; } $BINARY -c $CONFIG_TOML tx raw conn-confirm $HERMES_CFG_CHAIN_2_ID $HERMES_CFG_CHAIN_1_ID $TENDERMINT_CLIENT_2_TO_1 $TENDERMINT_CLIENT_1_TO_2 -d $CONN_2_TO_1 -s $CONN_1_TO_2 EXIT_CODE=$? sleep 2s -[ $EXIT_CODE -eq 0 ] || { echo "Operation failed"; exit 1; } +[ $EXIT_CODE -eq 0 ] || { echo >&2 "ERR: Operation failed"; exit 1; } echo ' + Testing connection 1' $BINARY -c $CONFIG_TOML query connection end $HERMES_CFG_CHAIN_1_ID $CONN_1_TO_2 | grep 'Open' @@ -202,20 +202,20 @@ echo '- Creating channel' RES_CREATE_CHAN_1_TO_2=$($BINARY -c $CONFIG_TOML tx raw chan-open-init $HERMES_CFG_CHAIN_1_ID $HERMES_CFG_CHAIN_2_ID $CONN_1_TO_2 transfer transfer -o UNORDERED) CHAN_1_TO_2=$(echo $RES_CREATE_CHAN_1_TO_2 | grep -o 'channel-[0-9]*') -[ -z "$CHAN_1_TO_2" ] && { echo "ERR: Unable to create channel on chain 1"; exit 1; } +[ -z "$CHAN_1_TO_2" ] && { echo >&2 "ERR: Unable to create channel on chain 1"; exit 1; } RES_CREATE_CHAN_2_TO_1=$($BINARY -c $CONFIG_TOML tx raw chan-open-try $HERMES_CFG_CHAIN_2_ID $HERMES_CFG_CHAIN_1_ID $CONN_2_TO_1 transfer transfer -s $CHAN_1_TO_2) CHAN_2_TO_1=$(echo $RES_CREATE_CHAN_2_TO_1 | grep -o 'channel-[0-9]*' | head -n 1) -[ -z "$CHAN_2_TO_1" ] && { echo "ERR: Unable to create channel on chain 2"; exit 1; } +[ -z "$CHAN_2_TO_1" ] && { echo >&2 "ERR: Unable to create channel on chain 2"; exit 1; } $BINARY -c $CONFIG_TOML tx raw chan-open-ack $HERMES_CFG_CHAIN_1_ID $HERMES_CFG_CHAIN_2_ID $CONN_1_TO_2 transfer transfer -d $CHAN_1_TO_2 -s $CHAN_2_TO_1 EXIT_CODE=$? sleep 2s -[ $EXIT_CODE -eq 0 ] || { echo "ERR: Operation failed (chan-open-ack)"; exit 1; } +[ $EXIT_CODE -eq 0 ] || { echo >&2 "ERR: Operation failed (chan-open-ack)"; exit 1; } $BINARY -c $CONFIG_TOML tx raw chan-open-confirm $HERMES_CFG_CHAIN_2_ID $HERMES_CFG_CHAIN_1_ID $CONN_2_TO_1 transfer transfer -d $CHAN_2_TO_1 -s $CHAN_1_TO_2 EXIT_CODE=$? sleep 2s -[ $EXIT_CODE -eq 0 ] || { echo "ERR: Operation failed (chan-open-confirm)"; exit 1; } +[ $EXIT_CODE -eq 0 ] || { echo >&2 "ERR: Operation failed (chan-open-confirm)"; exit 1; } echo ' + Testing channel 1' $BINARY -c $CONFIG_TOML query channel end $HERMES_CFG_CHAIN_1_ID transfer $CHAN_1_TO_2 | grep 'Open' @@ -245,33 +245,33 @@ echo ' + FT-Transfer from '$HERMES_CFG_CHAIN_1_ID' to '$HERMES_CFG_CHAIN_2_ID $BINARY -c $CONFIG_TOML tx raw ft-transfer $HERMES_CFG_CHAIN_2_ID $HERMES_CFG_CHAIN_1_ID transfer $CHAN_1_TO_2 1 --timeout-height-offset 1000 --number-msgs 1 --denom $HERMES_CFG_CHAIN_1_GAS_PRICE_DENOM_SYMBOL EXIT_CODE=$? sleep 2s -[ $EXIT_CODE -eq 0 ] || { echo "ERR: Operation failed (ft-transfer)"; exit 1; } +[ $EXIT_CODE -eq 0 ] || { echo >&2 "ERR: Operation failed (ft-transfer)"; exit 1; } echo ' + Send `recv_packet` to '$HERMES_CFG_CHAIN_2_ID $BINARY -c $CONFIG_TOML tx raw packet-recv $HERMES_CFG_CHAIN_2_ID $HERMES_CFG_CHAIN_1_ID transfer $CHAN_1_TO_2 EXIT_CODE=$? sleep 2s -[ $EXIT_CODE -eq 0 ] || { echo "ERR: Operation failed (packet-recv)"; exit 1; } +[ $EXIT_CODE -eq 0 ] || { echo >&2 "ERR: Operation failed (packet-recv)"; exit 1; } echo ' + Send acknowledgement to '$HERMES_CFG_CHAIN_1_ID $BINARY -c $CONFIG_TOML tx raw packet-ack $HERMES_CFG_CHAIN_1_ID $HERMES_CFG_CHAIN_2_ID transfer $CHAN_1_TO_2 EXIT_CODE=$? sleep 2s -[ $EXIT_CODE -eq 0 ] || { echo "ERR: Operation failed (packet-ack)"; exit 1; } +[ $EXIT_CODE -eq 0 ] || { echo >&2 "ERR: Operation failed (packet-ack)"; exit 1; } echo "- Init for $HERMES_CFG_CHAIN_2_GAS_PRICE_DENOM_SYMBOL on $HERMES_CFG_CHAIN_1_ID" echo ' + FT-Transfer from '$HERMES_CFG_CHAIN_2_ID' to '$HERMES_CFG_CHAIN_1_ID $BINARY -c $CONFIG_TOML tx raw ft-transfer $HERMES_CFG_CHAIN_1_ID $HERMES_CFG_CHAIN_2_ID transfer $CHAN_2_TO_1 1 --timeout-height-offset 1000 --number-msgs 1 --denom $HERMES_CFG_CHAIN_2_GAS_PRICE_DENOM_SYMBOL EXIT_CODE=$? sleep 2s -[ $EXIT_CODE -eq 0 ] || { echo "ERR: Operation failed (ft-transfer)"; exit 1; } +[ $EXIT_CODE -eq 0 ] || { echo >&2 "ERR: Operation failed (ft-transfer)"; exit 1; } echo ' + Send `recv_packet` to '$HERMES_CFG_CHAIN_1_ID $BINARY -c $CONFIG_TOML tx raw packet-recv $HERMES_CFG_CHAIN_1_ID $HERMES_CFG_CHAIN_2_ID transfer $CHAN_2_TO_1 EXIT_CODE=$? sleep 2s -[ $EXIT_CODE -eq 0 ] || { echo "ERR: Operation failed (packet-recv)"; exit 1; } +[ $EXIT_CODE -eq 0 ] || { echo >&2 "ERR: Operation failed (packet-recv)"; exit 1; } echo ' + Send acknowledgement to '$HERMES_CFG_CHAIN_2_ID $BINARY -c $CONFIG_TOML tx raw packet-ack $HERMES_CFG_CHAIN_2_ID $HERMES_CFG_CHAIN_1_ID transfer $CHAN_2_TO_1 EXIT_CODE=$? sleep 2s -[ $EXIT_CODE -eq 0 ] || { echo "ERR: Operation failed (packet-ack)"; exit 1; } +[ $EXIT_CODE -eq 0 ] || { echo >&2 "ERR: Operation failed (packet-ack)"; exit 1; } echo 'Information summary' echo '- Client 1 to 2: '$TENDERMINT_CLIENT_1_TO_2 @@ -334,4 +334,5 @@ if [ $DISABLE_SYSTEMCTL -eq 0 ]; then fi fi -echo '### Done' \ No newline at end of file +echo '### Done' +echo "Notice!!! Make sure the service file at '/etc/systemd/system/$HERMES_SERVICE_NAME.service' has correct working directort and execution path (in case you changed any repo/branch)" \ No newline at end of file diff --git a/sample.cosmos-and-evmos.override-env.sh b/sample.cosmos-and-evmos.override-env.sh index 8e51c0b..6b4df29 100644 --- a/sample.cosmos-and-evmos.override-env.sh +++ b/sample.cosmos-and-evmos.override-env.sh @@ -29,7 +29,7 @@ export HERMES_CFG_CHAIN_1_DENOM_EXPONENT=$CHAIN_1_DENOM_EXPONENT # no of digits # Big Dipper export BD_CFG_CHAIN_1_GIT_REPO="https://github.com/forbole/bdjuno.git" -export BD_CFG_CHAIN_1_BRANCH="chains/cosmos/mainnet" +export BD_CFG_CHAIN_1_GIT_REPO_BRANCH="chains/cosmos/mainnet" export BD_CFG_CHAIN_1_ACCOUNT_PREFIX="$CHAIN_1_ACCOUNT_PREFIX" export BD_CFG_CHAIN_1_ID="$CHAIN_1_ID" export BD_CFG_CHAIN_1_DENOM_SYMBOL="$CHAIN_1_DENOM_SYMBOL"