-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun
More file actions
executable file
·209 lines (172 loc) · 5.26 KB
/
run
File metadata and controls
executable file
·209 lines (172 loc) · 5.26 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/bin/bash
CONFIG=$PWD/config
DATA=$PWD/data
RELAYER=$DATA/relayer
KEYS=$DATA/keys.json
CHAINID_MTM=$(jq -r .chain_id $CONFIG/microtick.json)
CHAINID_GAIAD=$(jq -r .chain_id $CONFIG/gaiad.json)
SILENT=1
redirect() {
if [ "$SILENT" -eq 1 ]; then
"$@" > /dev/null 2>&1
else
"$@"
fi
}
if [ "$1" = "seal" ]; then
echo "Skipping setup"
else
echo "=========================="
echo "Configuring new test setup"
echo "=========================="
echo
# Display software version for testers
GAIA_VERSION=`gaiad version`
echo "GAIA VERSION INFO: $GAIA_VERSION"
MTM_VERSION=`mtm version`
echo "MICROTICK VERSION INFO: $MTM_VERSION"
echo
# Ensure user understands what will be deleted
if [[ -d $DATA ]] && [[ ! "$1" == "skip" ]]; then
echo "$(basename $0) will delete:"
echo
echo "- $DATA"
echo "- $HOME/.relayer"
echo
read -p "Do you wish to continue? (y/n): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
echo
fi
echo "Stopping running processes"
echo "--------------------------"
redirect killall gaiad
redirect killall mtm
# Delete data from old runs
redirect rm -rf $DATA
redirect rm -rf $HOME/.relayer
# Setup relayer configs
mkdir -p $RELAYER/chains
mkdir -p $RELAYER/paths
cat <<- EOF > $RELAYER/chains/gaiad.json
{
"key": "testkey",
"chain-id": "$CHAINID_GAIAD",
"rpc-addr": "http://localhost:26557",
"account-prefix": "cosmos",
"gas-adjustment": 1.5,
"gas-prices": "0.025stake",
"trusting-period": "336h"
}
EOF
cat <<- EOF > $RELAYER/chains/microtick.json
{
"key": "testkey",
"chain-id": "$CHAINID_MTM",
"rpc-addr": "http://localhost:26657",
"account-prefix": "micro",
"gas-adjustment": 1.5,
"gas-prices": "0.025stake",
"trusting-period": "336h"
}
EOF
cat <<- EOF > $RELAYER/paths/microtick-ibc.json
{
"src": {
"chain-id": "$CHAINID_GAIAD",
"client-id": "",
"connection-id": "",
"channel-id": "",
"port-id": "transfer",
"order": "unordered",
"version": "ics20-1"
},
"dst": {
"chain-id": "$CHAINID_MTM",
"client-id": "",
"connection-id": "",
"channel-id": "",
"port-id": "transfer",
"order": "unordered",
"version": "ics20-1"
},
"strategy": {
"type": "naive"
}
}
EOF
# Setup chains
echo
echo "Chains"
echo "------"
# Setup Gaiad
node setup-chain.js $DATA $CONFIG/gaiad.json
if [ $? -ne 0 ]; then
exit -1
fi
echo
# Setup Microtick
node setup-chain.js $DATA $CONFIG/microtick.json
if [ $? -ne 0 ]; then
exit -1
fi
fi
if [ "$1" = "setup" ]; then
exit 0
fi
# Seal chains
node seal-chain.js $DATA $CONFIG/gaiad.json
if [ $? -ne 0 ]; then
exit -1
fi
node seal-chain.js $DATA $CONFIG/microtick.json
if [ $? -ne 0 ]; then
exit -1
fi
echo
if [ "$1" = "seal" ]; then
exit 0
fi
# Start chains
setsid gaiad start --home $DATA/gaiad > /dev/null 2>&1 &
setsid mtm start --home $DATA/mtm > /dev/null 2>&1 &
# Governance
echo "Governance"
echo "----------"
echo "Letting chains stabilize..."
sleep 10
# backing change
echo "Submitting backing change proposal..."
echo $ mtm tx gov submit-proposal microtick-denom-change --title "New backing proposal" --description "Use hub backing" ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2 --home ./data/mtm --from governance --keyring-backend test --chain-id $CHAINID_MTM --deposit 10000000stake -y
redirect mtm tx gov submit-proposal microtick-denom-change --title "New backing proposal" --description "Use hub backing" ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2 --home ./data/mtm --from governance --keyring-backend test --chain-id $CHAINID_MTM --deposit 10000000stake -y
echo "Voting yes on backing change proposal..."
echo $ mtm tx gov vote 1 yes --from validator --home ./data/mtm --keyring-backend test --chain-id $CHAINID_MTM -y
redirect mtm tx gov vote 1 yes --from validator --home ./data/mtm --keyring-backend test --chain-id $CHAINID_MTM -y
# create markets
echo "Submitting add markets proposal..."
echo $ mtm tx gov submit-proposal microtick-add-markets --proposal ./add-market-proposal.json --home ./data/mtm --from governance --keyring-backend test --chain-id $CHAINID_MTM --deposit 10000000stake -y
redirect mtm tx gov submit-proposal microtick-add-markets --proposal ./add-market-proposal.json --home ./data/mtm --from governance --keyring-backend test --chain-id $CHAINID_MTM --deposit 10000000stake -y
echo "Voting yes on add markets proposal..."
echo $ mtm tx gov vote 2 yes --from validator --home ./data/mtm --keyring-backend test --chain-id $CHAINID_MTM -y
redirect mtm tx gov vote 2 yes --from validator --home ./data/mtm --keyring-backend test --chain-id $CHAINID_MTM -y
# Relayer
sleep 10
echo
echo "Relayer"
echo "-------"
rly config init
rly config add-chains $RELAYER/chains
GAIAD_MNEMONIC=$(jq -r '."'$CHAINID_GAIAD'".relayer.mnemonic' $KEYS)
echo "Importing key $(rly keys restore $CHAINID_GAIAD testkey "$GAIAD_MNEMONIC")"
MTM_MNEMONIC=$(jq -r '."'$CHAINID_MTM'".relayer.mnemonic' $KEYS)
echo "Importing key $(rly keys restore $CHAINID_MTM testkey "$MTM_MNEMONIC")"
echo
echo "Linking chains"
echo "--------------"
rly config add-paths $RELAYER/paths
rly light init $CHAINID_GAIAD -f
rly light init $CHAINID_MTM -f
rly tx link microtick-ibc --timeout 10s
rly start microtick-ibc