Skip to content

Commit

Permalink
fix: move faucet into SETUP_HOME/.. to share between chains
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Aug 23, 2020
1 parent 8439ba3 commit 76b6a5d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
set -e

thisdir=$(dirname -- "$0")
FAUCET_HOME=$thisdir/../faucet

MAX_LINES=-1
STAKE=50000000uagstake
Expand All @@ -10,8 +11,9 @@ OP=$1
shift

chainName=$(cat "$thisdir/ag-chain-cosmos/chain-name.txt")
IFS=, read -r -a rpcAddrs <<<"$(AG_SETUP_COSMOS_HOME=$thisdir ag-setup-cosmos show-rpcaddrs)"
IFS=, read -r -a origRpcAddrs <<<"$(AG_SETUP_COSMOS_HOME=$thisdir ag-setup-cosmos show-rpcaddrs)"

rpcAddrs=(${origRpcAddrs[@]})
while [[ ${#rpcAddrs[@]} -gt 0 ]]; do
r=$(( $RANDOM % ${#rpcAddrs[@]} ))
selected=${rpcAddrs[$r]}
Expand All @@ -26,7 +28,7 @@ while [[ ${#rpcAddrs[@]} -gt 0 ]]; do
add-egress)
NAME=$1
ADDR=$2
exec ag-cosmos-helper --home=$thisdir/faucet \
exec ag-cosmos-helper --home=$FAUCET_HOME \
tx swingset provision-one \
--node=tcp://$selected --chain-id=$chainName \
--yes --gas=auto --gas-adjustment=1.5 --broadcast-mode=block \
Expand Down Expand Up @@ -61,8 +63,7 @@ while [[ ${#rpcAddrs[@]} -gt 0 ]]; do
fi
fi

ag-cosmos-helper --home=$thisdir/faucet tx send faucet "$ADDR" "$STAKE"
if ag-cosmos-helper --home=$thisdir/faucet \
if ag-cosmos-helper --home=$FAUCET_HOME \
tx send \
--node=tcp://$selected --chain-id=$chainName \
--yes --gas=auto --gas-adjustment=1.5 --broadcast-mode=block \
Expand All @@ -81,5 +82,5 @@ while [[ ${#rpcAddrs[@]} -gt 0 ]]; do
fi
done

echo 1>&2 "No active chain nodes found in: $(echo "$nc" | jq .rpcAddrs)"
echo 1>&2 "No active chain nodes found in: ${origRpcAddrs[@]}"
exit 1
14 changes: 7 additions & 7 deletions packages/deployment/ansible/roles/cosmos-genesis/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@
mode: '755'

- set_fact:
faucet: "{{ lookup('file', SETUP_HOME + '/faucet/address.txt', errors='ignore') }}"
faucet: "{{ lookup('file', SETUP_HOME + '/../faucet/address.txt', errors='ignore') }}"

- name: "Create faucet account"
delegate_to: localhost
shell: "ag-cosmos-helper --home={{ SETUP_HOME + '/faucet' }} --keyring-backend=test keys add faucet < /dev/null"
shell: "ag-cosmos-helper --home={{ SETUP_HOME + '/../faucet' }} --keyring-backend=test keys add faucet < /dev/null"
when: not faucet

- name: "Extract faucet address"
delegate_to: localhost
shell: "ag-cosmos-helper --home={{ SETUP_HOME + '/faucet' }} --keyring-backend=test keys show -a faucet > {{ SETUP_HOME + '/faucet/address.txt' }}"
shell: "ag-cosmos-helper --home={{ SETUP_HOME + '/../faucet' }} --keyring-backend=test keys show -a faucet > {{ SETUP_HOME + '/../faucet/address.txt' }}"
when: not faucet

- set_fact:
faucet: "{{ lookup('file', SETUP_HOME + '/faucet/address.txt') }}"
faucet: "{{ lookup('file', SETUP_HOME + '/../faucet/address.txt') }}"

- name: "Set faucet chain params"
delegate_to: localhost
shell: "ag-cosmos-helper --home={{ SETUP_HOME + '/faucet' }} config chain-id {{ CHAIN_NAME }} && \
ag-cosmos-helper --home={{ SETUP_HOME + '/faucet' }} config node tcp://{{ hostvars[STAKER_NODE]['ansible_host'] }}:26657 && \
ag-cosmos-helper --home={{ SETUP_HOME + '/faucet' }} config keyring-backend test"
shell: "ag-cosmos-helper --home={{ SETUP_HOME + '/../faucet' }} config chain-id {{ CHAIN_NAME }} && \
ag-cosmos-helper --home={{ SETUP_HOME + '/../faucet' }} config node tcp://{{ hostvars[STAKER_NODE]['ansible_host'] }}:26657 && \
ag-cosmos-helper --home={{ SETUP_HOME + '/../faucet' }} config keyring-backend test"

- name: "Check {{ STAKER }}-{{ STAKER_NODE }} exists"
become: yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
- name: "Transfer {{ STAKER_AMOUNT }} to {{ STAKER }}-*"
delegate_to: localhost
shell: "\
ag-cosmos-helper --home={{ SETUP_HOME + '/faucet' }} \
ag-cosmos-helper --home={{ SETUP_HOME + '/../faucet' }} \
tx send faucet {{ staker_address.stdout }} {{ STAKER_AMOUNT }} \
--broadcast-mode=block --yes"
vars:
Expand Down

0 comments on commit 76b6a5d

Please sign in to comment.