Skip to content

Commit

Permalink
Merge pull request #1979 from cosmos/release-candidate/v0.10003.4
Browse files Browse the repository at this point in the history
automatic release created for v0.10003.4
  • Loading branch information
faboweb authored Feb 17, 2019
2 parents 38e2968 + ac4ec75 commit 0bd10d4
Show file tree
Hide file tree
Showing 370 changed files with 18,138 additions and 30,348 deletions.
67 changes: 67 additions & 0 deletions .aws/first.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

PASSWORD=1234567890
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}
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 .

echo ${PASSWORD} | ./gaiad gentx --name ${ACCOUNT} --home . --home-client .
./gaiad collect-gentxs --home .

# Make our genesis avaialable to the secondary nodes
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

# 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
50 changes: 50 additions & 0 deletions .aws/others.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

PASSWORD=1234567890
ACCOUNT=operator_account
PORT=26656
# TODO: hardcoded temporary, this will become a parameter coming from the first ECS instance
MAINNODEID=d08c69fa85969f3d0173f23aadc40268559d0f66
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}

GENESIS=`aws s3 ls s3://cosmos-gaia/genesis.json | grep genesis.json`
while [[ -z "$GENESIS" ]]; do
sleep 3s
ISTHERE=`aws s3 ls s3://cosmos-gaia/genesis.json | grep genesis.json`
done
aws s3 cp s3://cosmos-gaia/genesis.json config/genesis.json

# GET Genesis file into config/genesis.json
NODEID=$(./gaiad tendermint show-node-id --home .)

# boot referring to the remote node
screen -dmS gaia ./gaiad start --home . --p2p.laddr=tcp://0.0.0.0:$((PORT)) --address=tcp://0.0.0.0:$((PORT+1)) --rpc.laddr=tcp://0.0.0.0:$((PORT+2)) --p2p.persistent_peers="$MAINNODEID@$MAINNODEIP:$((PORT))"

# get the key to make my node validator
PUBKEY=$(./gaiad tendermint show-validator --home .)
echo ${PASSWORD} | ./gaiacli keys add ${ACCOUNT} --home . > secondary_node.log
ADDRESS=$(./gaiacli keys show ${ACCOUNT} --home . --address)
echo ${PUBKEY} > ./${ADDRESS}

# ask money by declaring my node
aws s3 cp ${ADDRESS} s3://cosmos-gaia/addresses/${ADDRESS}

poor=true
while ${poor}
do
# query my account to check if I'm still poor
ACCOUNT_INFO=$(./gaiacli query account ${ADDRESS} --chain-id ${NETWORK} --trust-node --home .)
if [[ ${ACCOUNT_INFO} == *"auth/Account"* ]]; then
echo "Address funded, thanks main node!"
poor=false
fi
sleep 3s
done

echo ${PASSWORD} | ./gaiacli tx staking create-validator --home . --from ${ACCOUNT} --amount=${VALIDATOR_AMOUNT} --pubkey=${PUBKEY} --address-delegator=${ADDRESS} --moniker=${ACCOUNT} --chain-id=${NETWORK} --commission-max-change-rate=0 --commission-max-rate=0 --commission-rate=0 --min-self-delegation=1 -json
Loading

0 comments on commit 0bd10d4

Please sign in to comment.