Skip to content

Commit

Permalink
Fix ec2 scripts with new cli commands versions (#2002)
Browse files Browse the repository at this point in the history
* fix ec2 scripts with new cli commands versions
* split faucet into separate file, it may even run in a separate machine
  • Loading branch information
sabau authored Feb 18, 2019
1 parent d0ed585 commit 1c2112a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 42 deletions.
26 changes: 26 additions & 0 deletions .aws/faucet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

AMOUNT=100stake
ACCOUNT=$1
PASSWORD=$2
NETWORK=$3

while true
do
# Is anyone asking for money
LIST=$(aws s3 ls s3://cosmos-gaia/addresses/)
if [[ -n "${LIST}" ]];
then
echo ${LIST} | while IFS= read -r row || [[ -n "$row" ]]; do
# for every file in the list pick the address and give money to it, then delete the file
DESTINATION=$(echo $row | awk '{print $4}')

# Just in case we were running this command with rest-server switched on, get again the address
ADDRESS=$(./gaiacli keys show ${ACCOUNT} --home . --address)
echo ${PASSWORD} | ./gaiacli tx send ${DESTINATION} ${AMOUNT} --home . --from ${ADDRESS} --chain-id=${NETWORK}

# Remove this address from the ones that needs money
aws s3 rm s3://cosmos-gaia/addresses/${DESTINATION}
done
fi
done
43 changes: 3 additions & 40 deletions .aws/first.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ ACCOUNT=main_account
PORT=26657
API_PORT=8080
NETWORK=testnet
AMOUNT=100stake

# first of all remove old genesis, we do not want other node to boot with the wrong stuff
aws s3 rm s3://cosmos-gaia/genesis.json

# Initialize local node with an account name and a chain
./gaiad init --home . --moniker ${ACCOUNT} --chain-id ${NETWORK}
./gaiad init ${ACCOUNT} --home . --chain-id ${NETWORK}
NODEID=$(./gaiad tendermint show-node-id --home .)

# Create our main account and add it to the genesis with a lot of money
echo ${PASSWORD} | ./gaiacli keys add ${ACCOUNT} --home . > main_node.log
./gaiad add-genesis-account $(./gaiacli keys show ${ACCOUNT} --home . --address) 150000stake,100000photino,123cococoin --home .
./gaiad add-genesis-account $(./gaiacli keys show ${ACCOUNT} --home . --address) 100000000stake,100000photino,123cococoin --home .

echo ${PASSWORD} | ./gaiad gentx --name ${ACCOUNT} --home . --home-client .
./gaiad collect-gentxs --home .
Expand All @@ -27,41 +26,5 @@ aws s3 cp config/genesis.json s3://cosmos-gaia/genesis.json
# boot proper nodes in reachable detached sessions
screen -dmS gaia ./gaiad start --home .
screen -dmS rest ./gaiacli rest-server --laddr tcp://0.0.0.0:${API_PORT} --home . --node http://localhost:${PORT} --chain-id ${NETWORK} --trust-node true
screen -dmS faucet ./faucet.sh ${ACCOUNT} ${PASSWORD} ${NETWORK}

# get my address to use it as source of richness for others
ADDRESS=$(./gaiacli keys show ${ACCOUNT} --home . --address)

while true
do
# Is anyone asking for money
LIST=$(aws s3 ls s3://cosmos-gaia/addresses/)
if [[ -n "${LIST}" ]];
then
# TODO: SRE team is working on a clean solution.
# This hacky version is temporary and will be replaced by a stargate running on a separate machine
# Remove this logic as soon as we put back the deploy-gaia automation

# Check if a stargate is locally running
PID=$(lsof -ti tcp:${API_PORT})
if [[ -n "${PID}" ]];
then
# we cannot use gaiacli while the rest server is running, it locks the resources
kill -9 ${PID}
fi

echo ${LIST} | while IFS= read -r row || [[ -n "$row" ]]; do
# for every file in the list pick the address and give money to it, then delete the file
DESTINATION=$(echo $row | awk '{print $4}')

# Just in case we were running this command with rest-server switched on, get again the address
ADDRESS=$(./gaiacli keys show ${ACCOUNT} --home . --address)
echo ${PASSWORD} | ./gaiacli tx send --home . --from ${ADDRESS} --amount=${AMOUNT} --to=${DESTINATION} --chain-id=${NETWORK}

# Remove this address from the ones that needs money
aws s3 rm s3://cosmos-gaia/addresses/${DESTINATION}
done

#restore the rest server
screen -dmS rest ./gaiacli rest-server --laddr tcp://0.0.0.0:${API_PORT} --home . --node http://localhost:${PORT} --chain-id ${NETWORK} --trust-node true
fi
done
4 changes: 2 additions & 2 deletions .aws/others.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ PASSWORD=1234567890
ACCOUNT=operator_account
PORT=26656
# TODO: hardcoded temporary, this will become a parameter coming from the first ECS instance
MAINNODEID=d08c69fa85969f3d0173f23aadc40268559d0f66
MAINNODEID=a27e12bd071dc2eda3117a5a255743103259e184
MAINNODEIP=172.31.35.89
MAINACCOUNT=main_account
NETWORK=testnet
VALIDATOR_AMOUNT=10stake

# Initialize local node with a secondary account
./gaiad init --home . --moniker ${ACCOUNT} --chain-id ${NETWORK}
./gaiad init ${ACCOUNT} --home . --chain-id ${NETWORK}

GENESIS=`aws s3 ls s3://cosmos-gaia/genesis.json | grep genesis.json`
while [[ -z "$GENESIS" ]]; do
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- [\#1729](https://github.com/cosmos/voyager/issues/1729) Rename endpoint functions @fedekunze
- [\#1790](https://github.com/cosmos/voyager/issues/1790) Rename `lcdClient.js` to `api.js` @fedekunze
- [\#2002](https://github.com/cosmos/voyager/pull/2002) Fix boot process for remote nodes @sabau

### Fixed

Expand Down

0 comments on commit 1c2112a

Please sign in to comment.