Skip to content

Commit

Permalink
fix: don't rely on validator DNS names when finding the network
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Sep 1, 2020
1 parent e12ecf5 commit 56e0cb3
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
24 changes: 22 additions & 2 deletions packages/deployment/bigdipper/ag-bigdipper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,30 @@
# bigdipper.sh - Run Agoric Big Dipper Explorer
set -e
ncf=`curl -Ss https://testnet.agoric.com/network-config`
l=`echo "$ncf" | jq '.rpcAddrs | length'`
rp=`echo "$ncf" | jq -r ".rpcAddrs[$(( RANDOM % l ))]"`
cn=`echo "$ncf" | jq -r '.chainName'`

origRpcAddrs=( $(echo $ncf | jq -r '.rpcAddrs | join(" ")' ) )

rpcAddrs=(${origRpcAddrs[@]})
rp=
while [[ ${#rpcAddrs[@]} -gt 0 ]]; do
r=$(( $RANDOM % ${#rpcAddrs[@]} ))
selected=${rpcAddrs[$r]}
rpcAddrs=( ${rpcAddrs[@]/$selected} )

if curl -s http://$selected/status > /dev/null; then
# Found an active node.
rp=$selected
break
fi
done

if test -z "$rp"; then
echo "Cannot find an active node; last tried $selected"
sleep 20
exit 1
fi

case $cn in
testnet-1.16.8) db=meteor ;;
*) db=`echo "$cn" | sed -e 's/\./-/g'` ;;
Expand Down
27 changes: 24 additions & 3 deletions packages/deployment/bigdipper/ag-lcd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,30 @@
set -e
PATH=$PATH:/usr/local/bin
ncf=`curl -Ss https://testnet.agoric.com/network-config`
l=`echo "$ncf" | jq '.rpcAddrs | length'`
eval rp=`echo "$ncf" | jq ".rpcAddrs[$(( RANDOM % l ))]"`
eval cn=`echo "$ncf" | jq '.chainName'`
cn=`echo "$ncf" | jq -r '.chainName'`

origRpcAddrs=( $(echo $ncf | jq -r '.rpcAddrs | join(" ")' ) )

rpcAddrs=(${origRpcAddrs[@]})
rp=
while [[ ${#rpcAddrs[@]} -gt 0 ]]; do
r=$(( $RANDOM % ${#rpcAddrs[@]} ))
selected=${rpcAddrs[$r]}
rpcAddrs=( ${rpcAddrs[@]/$selected} )

if curl -s http://$selected/status > /dev/null; then
# Found an active node.
rp=$selected
break
fi
done

if test -z "$rp"; then
echo "Cannot find an active node; last tried $selected"
sleep 20
exit 1
fi

# FIXME: Once https://github.com/cosmos/cosmos-sdk/issues/5592 is resolved,
# we can use:
#exec ag-cosmos-helper rest-server --node="tcp://$rp" --chain-id="$cn"
Expand Down

0 comments on commit 56e0cb3

Please sign in to comment.