Skip to content

Commit

Permalink
Added scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
harish551 committed Jul 27, 2021
1 parent ba1546c commit 2b7f74f
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/verify-gentx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: GenTx
on: [pull_request]
jobs:
verify-gentx:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/[email protected]
with:
go-version: 1.16
- name: Checkout code
uses: actions/checkout@v2
- name: Display go version
run: go version
- name: validate-gentx
run: |
bash -x ./scripts/verify_gentx.sh
28 changes: 28 additions & 0 deletions scripts/generate_genesis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

CHAIN_ID=flixnet-1
NODE_HOME=~/tmp/ofhub
CONFIG=~/tmp/ofhub/config

rm -rf $NODE_HOME

omniflixhubd init test --chain-id $CHAIN_ID --home $NODE_HOME

rm -rf $CONFIG/gentx && mkdir $CONFIG/gentx
rm -rf $CONFIG/genesis.json

cp $CHAIN_ID/genesis.json $CONFIG/genesis.json
for i in $CHAIN_ID/gentxs/*.json; do
echo $i
echo $(jq -r '.body.messages[0].delegator_address' $i)
omniflixhubd add-genesis-account $(jq -r '.body.messages[0].delegator_address' $i) 100000000uflix --home $NODE_HOME
cp $i $CONFIG/gentx/
done
echo "Collecting gentxs ..."
omniflixhubd collect-gentxs --home $NODE_HOME

echo "Validate genesis ..."
omniflixhubd validate-genesis --home $NODE_HOME

cp $CONFIG/genesis.json $CHAIN_ID
echo "Done. File saved at ${$CHAIN_ID}/genesis.json"
80 changes: 80 additions & 0 deletions scripts/verify_gentx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/sh
FLIX_HOME="/tmp/omniflixhub$(date +%s)"
RANDOM_KEY="random-validator-key"
CHAIN_ID=flixnet-1

GENTX_FILE=$(find ./$CHAIN_ID/gentxs -iname "*.json")
LEN_GENTX=$(echo ${#GENTX_FILE})

GENTX_DEADLINE=$(date -u -d '2021-07-26T18:00:00.000Z' +'%s')
now=$(date -u +'%s')

declare -i maxbond=50000000

if [ $now -ge $GENTX_DEADLINE ]; then
echo 'Gentx submission is closed'
exit 1
fi

if [ $LEN_GENTX -eq 0 ]; then
echo "gentx file not found."
else
set -e

echo "GentxFile::::"
echo $GENTX_FILE

denom=$(jq -r '.body.messages[0].value.denom' $GENTX_FILE)

amount=$(jq -r '.body.messages[0].value.amount' $GENTX_FILE)
if [ $denom != "uflix" ]; then
echo "invalid denom"
exit 1
fi

if [ $amount -gt $maxbond ]; then
echo "bonded amount is too high: $amt > $maxbond"
exit 1
fi
echo "...........Init omniflixhub.............."

wget -q https://github.com/OmniFlix/omniflixhub/releases/download/v0.1.0/omniflixhubd -O omniflixhubd
chmod +x omniflixhubd

./omniflixhubd keys add $RANDOM_KEY --home $FLIX_HOME

./omniflixhubd init --chain-id $CHAIN_ID validator --home $FLIX_HOME

echo "..........Updating genesis......."
sed -i "s/\"stake\"/\"uflix\"/g" $FLIX_HOME/config/genesis.json

GENACC=$(jq -r '.body.messages[0].delegator_address' $GENTX_FILE)

echo $GENACC

./omniflixhubd add-genesis-account $RANDOM_KEY 50000000uflix --home $FLIX_HOME --keyring-backend test
./omniflixhubd add-genesis-account $GENACC 50000000uflix --home $FLIX_HOME

./omniflixhubd gentx $RANDOM_KEY 40000000uflix --home $FLIX_HOME \
--keyring-backend test --chain-id $CHAIN_ID
cp $GENTX_FILE $FLIX_HOME/config/gentx/

echo "..........Collecting gentxs......."
./omniflixhubd collect-gentxs --home $FLIX_HOME
sed -i '/persistent_peers =/c\persistent_peers = ""' $FLIX_HOME/config/config.toml

./omniflixhubd validate-genesis --home $FLIX_HOME

echo "..........Starting node......."
./omniflixhubd start --home $FLIX_HOME &

sleep 5s

echo "...checking network status.."

./omniflixhubd status --node https://localhost:26657

echo "...Cleaning ..."
killall omniflixhubd >/dev/null 2>&1
rm -rf $FLIX_HOME >/dev/null 2>&1
fi

0 comments on commit 2b7f74f

Please sign in to comment.