-
Notifications
You must be signed in to change notification settings - Fork 207
/
Copy pathstart_local_node.sh
76 lines (56 loc) · 3.44 KB
/
start_local_node.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
#!/bin/bash
# This script starts a single stride node locally
# It can be used in debugging scenarios where dockernet is unncessary
# (ex1: debugging an issue that does not require host chains or relayers)
# (ex2: debugging via adding logs to the SDK)
# (ex3: testing CLI commands)
set -eu
STRIDE_HOME=~/.stride-local
STRIDED="build/strided --home ${STRIDE_HOME}"
CHAIN_ID=stride-local-1
DENOM=ustrd
STRIDE_ADMIN_MNEMONIC="tone cause tribe this switch near host damage idle fragile antique tail soda alien depth write wool they rapid unfold body scan pledge soft"
STRIDE_VAL_MNEMONIC="close soup mirror crew erode defy knock trigger gather eyebrow tent farm gym gloom base lemon sleep weekend rich forget diagram hurt prize fly"
STRIDE_DAY_EPOCH_DURATION="140s"
STRIDE_EPOCH_EPOCH_DURATION="35s"
MAX_DEPOSIT_PERIOD="30s"
VOTING_PERIOD="30s"
UNBONDING_TIME="240s"
config_toml="${STRIDE_HOME}/config/config.toml"
client_toml="${STRIDE_HOME}/config/client.toml"
app_toml="${STRIDE_HOME}/config/app.toml"
genesis_json="${STRIDE_HOME}/config/genesis.json"
rm -rf ${STRIDE_HOME}
$STRIDED init stride-local --chain-id $CHAIN_ID --overwrite
sed -i -E "s|minimum-gas-prices = \".*\"|minimum-gas-prices = \"0${DENOM}\"|g" $app_toml
sed -i -E '/\[api\]/,/^enable = .*$/ s/^enable = .*$/enable = true/' $app_toml
sed -i -E "s|chain-id = \"\"|chain-id = \"${CHAIN_ID}\"|g" $client_toml
sed -i -E "s|keyring-backend = \"os\"|keyring-backend = \"test\"|g" $client_toml
sed -i -E "s|node = \".*\"|node = \"tcp://localhost:26657\"|g" $client_toml
sed -i -E "s|\"stake\"|\"${DENOM}\"|g" $genesis_json
jq '(.app_state.epochs.epochs[] | select(.identifier=="day") ).duration = $epochLen' --arg epochLen $STRIDE_DAY_EPOCH_DURATION $genesis_json > json.tmp && mv json.tmp $genesis_json
jq '(.app_state.epochs.epochs[] | select(.identifier=="stride_epoch") ).duration = $epochLen' --arg epochLen $STRIDE_EPOCH_EPOCH_DURATION $genesis_json > json.tmp && mv json.tmp $genesis_json
jq '.app_state.gov.params.max_deposit_period = $newVal' --arg newVal "$MAX_DEPOSIT_PERIOD" $genesis_json > json.tmp && mv json.tmp $genesis_json
jq '.app_state.gov.params.voting_period = $newVal' --arg newVal "$VOTING_PERIOD" $genesis_json > json.tmp && mv json.tmp $genesis_json
jq "del(.app_state.interchain_accounts)" $genesis_json > json.tmp && mv json.tmp $genesis_json
interchain_accts=$(cat dockernet/config/ica_controller.json)
jq ".app_state += $interchain_accts" $genesis_json > json.tmp && mv json.tmp $genesis_json
$STRIDED add-consumer-section --validator-home-directories $STRIDE_HOME
jq '.app_state.ccvconsumer.params.unbonding_period = $newVal' --arg newVal "$UNBONDING_TIME" $genesis_json > json.tmp && mv json.tmp $genesis_json
rm -rf ~/.stride-loca1
echo "$STRIDE_VAL_MNEMONIC" | $STRIDED keys add val --recover --keyring-backend=test
$STRIDED add-genesis-account $($STRIDED keys show val -a) 100000000000${DENOM}
echo "$STRIDE_ADMIN_MNEMONIC" | $STRIDED keys add admin --recover --keyring-backend=test
$STRIDED add-genesis-account $($STRIDED keys show admin -a) 100000000000${DENOM}
# Start the daemon in the background
$STRIDED start &
pid=$!
sleep 10
# Add a governator
echo "Adding governator..."
pub_key=$($STRIDED tendermint show-validator)
$STRIDED tx staking create-validator --amount 1000000000${DENOM} --from val \
--pubkey=$pub_key --commission-rate="0.10" --commission-max-rate="0.20" \
--commission-max-change-rate="0.01" --min-self-delegation="1" -y
# Bring the daemon back to the foreground
wait $pid