-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathone-chain-ibc.sh
executable file
·128 lines (106 loc) · 4.64 KB
/
one-chain-ibc.sh
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
#!/bin/sh
display_usage() {
echo "\nMissing $1 parameter. Please check if all parameters were specified."
echo "\nUsage: ./one-chain [BINARY] [CHAIN_ID] [CHAIN_DIR] [RPC_PORT] [P2P_PORT] [PROFILING_PORT] [GRPC_PORT]"
echo "\nExample: ./one-chain $BINARY test-chain-id ./data 26657 26656 6060 9090 \n"
exit 1
}
KEYRING=--keyring-backend="test"
SILENT=1
redirect() {
if [ "$SILENT" -eq 1 ]; then
"$@" > /dev/null 2>&1
else
"$@"
fi
}
BINARY=$1
CHAINID=$2
CHAINDIR=$3
RPCPORT=$4
P2PPORT=$5
PROFPORT=$6
GRPCPORT=$7
RESTPORT=$8
startDaenom=true
if [ -n "$9" ] ;then
startDaenom=false
fi
if [ -z "$1" ]; then
display_usage "[BINARY] ($BINARY|akash)"
fi
if [ -z "$2" ]; then
display_usage "[CHAIN_ID]"
fi
if [ -z "$3" ]; then
display_usage "[CHAIN_DIR]"
fi
if [ -z "$4" ]; then
display_usage "[RPC_PORT]"
fi
if [ -z "$5" ]; then
display_usage "[P2P_PORT]"
fi
if [ -z "$6" ]; then
display_usage "[PROFILING_PORT]"
fi
if [ -z "$7" ]; then
display_usage "[GRPC_PORT]"
fi
BINARY=gaiad
echo "Creating $BINARY instance: home=$CHAINDIR | chain-id=$CHAINID | p2p=:$P2PPORT | rpc=:$RPCPORT | profiling=:$PROFPORT | grpc=:$GRPCPORT | rest=:$RESTPORT"
# Add dir for chain, exit if error
if ! mkdir -p $CHAINDIR/$CHAINID 2>/dev/null; then
echo "Failed to create chain folder. Aborting..."
exit 1
fi
# Build genesis file incl account for passed address
coins="100000000000stake,10000000000000uatom"
delegate="100000000000stake"
$BINARY --home $CHAINDIR/$CHAINID --chain-id $CHAINID init $CHAINID
#sleep 1
$BINARY --home $CHAINDIR/$CHAINID keys add validator $KEYRING --output json > $CHAINDIR/$CHAINID/validator_seed.json 2>&1
#sleep 1
$BINARY --home $CHAINDIR/$CHAINID keys add user $KEYRING --output json > $CHAINDIR/$CHAINID/key_seed.json 2>&1
$BINARY --home $CHAINDIR/$CHAINID keys add user2 $KEYRING
#sleep 1
$BINARY --home $CHAINDIR/$CHAINID add-genesis-account $($BINARY --home $CHAINDIR/$CHAINID keys $KEYRING show user -a) $coins
#sleep 1
$BINARY --home $CHAINDIR/$CHAINID add-genesis-account $($BINARY --home $CHAINDIR/$CHAINID keys $KEYRING show validator -a) $coins
#sleep 1
$BINARY --home $CHAINDIR/$CHAINID gentx validator $delegate $KEYRING --chain-id $CHAINID
#sleep 1
$BINARY --home $CHAINDIR/$CHAINID collect-gentxs
#sleep 1
# Check platform
platform='unknown'
unamestr=`uname`
if [ "$unamestr" = 'Linux' ]; then
platform='linux'
fi
# Set proper defaults and change ports (use a different sed for Mac or Linux)
echo "Change settings in config.toml file..."
if [ $platform = 'linux' ]; then
sed -i 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:'"$RPCPORT"'"#g' $CHAINDIR/$CHAINID/config/config.toml
sed -i 's#"tcp://0.0.0.0:26656"#"tcp://0.0.0.0:'"$P2PPORT"'"#g' $CHAINDIR/$CHAINID/config/config.toml
sed -i 's#"localhost:6060"#"localhost:'"$P2PPORT"'"#g' $CHAINDIR/$CHAINID/config/config.toml
sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $CHAINDIR/$CHAINID/config/config.toml
sed -i 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $CHAINDIR/$CHAINID/config/config.toml
sed -i 's/index_all_keys = false/index_all_keys = true/g' $CHAINDIR/$CHAINID/config/config.toml
# sed -i '' 's/address = "tcp://0.0.0.0:1317"/address = "tcp://0.0.0.0:'$RESTPORT'"/g' $CHAINDIR/$CHAINID/config/app.toml
# sed -i '' 's#index-events = \[\]#index-events = \["message.action","send_packet.packet_src_channel","send_packet.packet_sequence"\]#g' $CHAINDIR/$CHAINID/config/app.toml
else
sed -i '' 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:'"$RPCPORT"'"#g' $CHAINDIR/$CHAINID/config/config.toml
sed -i '' 's#"tcp://0.0.0.0:26656"#"tcp://0.0.0.0:'"$P2PPORT"'"#g' $CHAINDIR/$CHAINID/config/config.toml
sed -i '' 's#"localhost:6060"#"localhost:'"$P2PPORT"'"#g' $CHAINDIR/$CHAINID/config/config.toml
sed -i '' 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $CHAINDIR/$CHAINID/config/config.toml
sed -i '' 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $CHAINDIR/$CHAINID/config/config.toml
sed -i '' 's/index_all_keys = false/index_all_keys = true/g' $CHAINDIR/$CHAINID/config/config.toml
# sed -i '' 's/address = "tcp://0.0.0.0:1317"/address = "tcp://0.0.0.0:12345"/g' $CHAINDIR/$CHAINID/config/app.toml
# sed -i '' 's#index-events = \[\]#index-events = \["message.action","send_packet.packet_src_channel","send_packet.packet_sequence"\]#g' $CHAINDIR/$CHAINID/config/app.toml
fi
rm -f $CHAINDIR/$CHAINID/config/app.yml
cp ./yamls/$CHAINID/app.toml $CHAINDIR/$CHAINID/config/
if [ "$startDaenom" = true ]; then
gaiad --home $CHAINDIR/$CHAINID start --pruning=nothing --grpc-web.enable=false --grpc.address="0.0.0.0:$GRPCPORT" --rpc.laddr="tcp://0.0.0.0:$RPCPORT" --p2p.laddr="tcp://0.0.0.0:$P2PPORT" --minimum-gas-prices=0.025uatom > $CHAINDIR/$CHAINID.log 2>&1 &
fi