forked from informalsystems/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-chains
executable file
·105 lines (80 loc) · 2.62 KB
/
setup-chains
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash -e
# Copied from https://github.com/cosmos/relayer and modified to initialize Gaia chains.
usage() {
echo "Usage: $0 CHAIN_0_ID CHAIN_1_ID [CHAIN_2_ID] [--non-interactive]"
echo "Example: $0 ibc-0 ibc-1 ibc-2"
exit 1
}
missing() {
echo "Missing $1 parameter. Please check if all parameters were specified."
usage
}
if [ -z "$1" ]; then
missing "CHAIN_0_ID"
fi
if [ -z "$2" ]; then
missing "CHAIN_1_ID"
fi
if [ "$#" -gt 4 ]; then
echo "Incorrect number of parameters."
usage
fi
NON_INTERACTIVE=false
if [ "$#" -eq 3 ]; then
if [ "$3" == "--non-interactive" ]; then
NON_INTERACTIVE=true
fi
fi
if [ "$#" -eq 4 ]; then
if [ "$4" == "--non-interactive" ]; then
NON_INTERACTIVE=true
fi
fi
CHAIN_0_ID="$1"
CHAIN_1_ID="$2"
CHAIN_2_ID="$3"
GAIA_DATA="$(pwd)/data"
# Ensure user understands what will be deleted
if [[ -d $GAIA_DATA ]] && [[ $NON_INTERACTIVE == false ]]; then
echo "WARNING: $0 will DELETE the '$(pwd)/data' folder."
read -p "> Do you wish to continue? (y/n): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
# Ensure gaiad is installed
if ! [ -x "$(which gaiad)" ]; then
echo "Error: gaiad is not installed. Try running 'make build-gaia'" >&2
exit 1
fi
# Display software version
echo "GAIA VERSION INFO: $(gaiad version --log_level info)"
# Delete data from old runs
echo "Deleting $GAIA_DATA folder..."
rm -rf "$GAIA_DATA"
# Stop existing gaiad processes
killall gaiad &> /dev/null || true
killall akash &> /dev/null || true
echo "Generating gaia configurations..."
mkdir -p "$GAIA_DATA" && cd "$GAIA_DATA" && cd ../
ONE_CHAIN="$(dirname "$0")/one-chain"
CHAIN_0_RPC_PORT=26657
CHAIN_1_RPC_PORT=26557
CHAIN_2_RPC_PORT=26457
CHAIN_0_GRPC_PORT=9090
CHAIN_1_GRPC_PORT=9091
CHAIN_2_GRPC_PORT=9092
CHAIN_0_SAMOLEANS=100000000000
CHAIN_1_SAMOLEANS=100000000000
CHAIN_2_SAMOLEANS=100000000000
"$ONE_CHAIN" gaiad "$CHAIN_0_ID" ./data $CHAIN_0_RPC_PORT 26656 6060 $CHAIN_0_GRPC_PORT $CHAIN_0_SAMOLEANS
"$ONE_CHAIN" gaiad "$CHAIN_1_ID" ./data $CHAIN_1_RPC_PORT 26556 6061 $CHAIN_1_GRPC_PORT $CHAIN_1_SAMOLEANS
if [ -n "$CHAIN_2_ID" ]; then
"$ONE_CHAIN" gaiad "$CHAIN_2_ID" ./data $CHAIN_2_RPC_PORT 26456 6062 $CHAIN_2_GRPC_PORT $CHAIN_2_SAMOLEANS
fi
[ -f "$GAIA_DATA/$CHAIN_0_ID.log" ] && echo "$CHAIN_0_ID initialized. Watch file $GAIA_DATA/$CHAIN_0_ID.log to see its execution."
[ -f "$GAIA_DATA/$CHAIN_1_ID.log" ] && echo "$CHAIN_1_ID initialized. Watch file $GAIA_DATA/$CHAIN_1_ID.log to see its execution."
if [ -n "$CHAIN_2_ID" ]; then
[ -f "$GAIA_DATA/$CHAIN_2_ID.log" ] && echo "$CHAIN_2_ID initialized. Watch file $GAIA_DATA/$CHAIN_2_ID.log to see its execution."
fi