add deploy scripts

This commit is contained in:
Peter Zhang 2024-04-21 20:09:34 +08:00 committed by 0g-wh
parent c8bf4644c1
commit ca3ab93657
2 changed files with 98 additions and 93 deletions

View File

@ -6,7 +6,7 @@ function help() {
echo " -i Identity file"
echo " -k Keyring password to create key (for Linux only)"
echo " -n Network (default: testnet)"
echo " -c Chain ID (default: \"zgtendermint_9000-1\")"
echo " -c Chain ID (default: \"zgtendermint_16600-1\")"
echo ""
}
@ -56,7 +56,7 @@ NUM_NODES=${#IPS[@]}
# Install dependent libraries and binary
for ((i=0; i<$NUM_NODES; i++)) do
ssh $PEM_FLAG ubuntu@${IPS[$i]} "git clone https://github.com/0glabs/0g-chain.git; cd 0g-chain; ./networks/testnet/install.sh"
ssh $PEM_FLAG ubuntu@${IPS[$i]} "rm -rf 0g-chain; git clone https://github.com/0glabs/0g-chain.git; cd 0g-chain; git checkout testnet; ./networks/testnet/install.sh"
done
# Create genesis config on node0

View File

@ -1,7 +1,7 @@
#!/bin/bash
ROOT_DIR=${ROOT_DIR:-testnet}
CHAIN_ID=${CHAIN_ID:-zgtendermint_9000-1}
CHAIN_ID=${CHAIN_ID:-zgtendermint_16600-1}
# Usage: init-genesis.sh IP1,IP2,IP3 KEYRING_PASSWORD
OS_NAME=`uname -o`
@ -33,8 +33,9 @@ set -e
IFS=","; declare -a IPS=($1); unset IFS
NUM_NODES=${#IPS[@]}
BALANCE=$((100000000/$NUM_NODES))kava
STAKING=$((50000000/$NUM_NODES))kava
VLIDATOR_BALANCE=20000000000000ukava
FAUCET_BALANCE=20000000000000ukava
STAKING=2000000000000ukava
# Init configs
for ((i=0; i<$NUM_NODES; i++)) do
@ -80,14 +81,17 @@ for ((i=0; i<$NUM_NODES; i++)) do
strategies: ["STRATEGY_TYPE_SAVINGS"],
}]' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
cat $GENESIS | jq '.app_state.savings.params.supported_denoms = ["bkava-kavavaloper1ffv7nhd3z6sych2qpqkk03ec6hzkmufyz4scd0"]' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
# cat "$GENESIS" | jq '.app_state["staking"]["params"]["bond_denom"]="ukava"' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
# cat "$GENESIS" | jq '.app_state["gov"]["params"]["min_deposit"][0]["denom"]="neuron"' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
# cat "$GENESIS" | jq '.app_state["gov"]["params"]["min_deposit"][0]["denom"]="ukava"' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
cat "$GENESIS" | jq '.app_state["staking"]["params"]["max_validators"]=200' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
cat "$GENESIS" | jq '.app_state["slashing"]["params"]["signed_blocks_window"]="1000"' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
cat "$GENESIS" | jq '.app_state["consensus_params"]["block"]["time_iota_ms"]="3000"' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
# Change app.toml
APP_TOML="$HOMEDIR"/config/app.toml
sed -i 's/minimum-gas-prices = "0akava"/minimum-gas-prices = "1000000000ukava"/' "$APP_TOML"
sed -i 's/minimum-gas-prices = "0akava"/minimum-gas-prices = "1000000000akava"/' "$APP_TOML"
sed -i '/\[json-rpc\]/,/^\[/ s/enable = false/enable = true/' "$APP_TOML"
sed -i '/\[json-rpc\]/,/^\[/ s/address = "127.0.0.1:8545"/address = "0.0.0.0:8545"/' "$APP_TOML"
@ -128,13 +132,13 @@ if [[ "$OS_NAME" = "Msys" ]]; then
set -e
if [[ "$ret" = "" ]]; then
echo "Create validator key: $VALIDATOR"
kava keys add $VALIDATOR --keyring-backend os
kava keys add $VALIDATOR --keyring-backend os --eth
fi
done
elif [[ "$OS_NAME" = "GNU/Linux" ]]; then
# Create N validators for node0
for ((i=0; i<$NUM_NODES; i++)) do
yes $PASSWORD | kava keys add "0gchain_9000_validator_$i" --keyring-backend os --home "$ROOT_DIR"/node0
yes $PASSWORD | kava keys add "0gchain_9000_validator_$i" --keyring-backend os --home "$ROOT_DIR"/node0 --eth
done
# Copy validators to other nodes
@ -153,11 +157,12 @@ fi
for ((i=0; i<$NUM_NODES; i++)) do
for ((j=0; j<$NUM_NODES; j++)) do
if [[ "$OS_NAME" = "GNU/Linux" ]]; then
yes $PASSWORD | kava add-genesis-account "0gchain_9000_validator_$i" $BALANCE --home "$ROOT_DIR/node$j"
yes $PASSWORD | kava add-genesis-account "0gchain_9000_validator_$j" $VLIDATOR_BALANCE --home "$ROOT_DIR/node$i"
else
kava add-genesis-account "0gchain_9000_validator_$i" $BALANCE --home "$ROOT_DIR/node$j"
kava add-genesis-account "0gchain_9000_validator_$j" $VLIDATOR_BALANCE --home "$ROOT_DIR/node$i"
fi
done
kava add-genesis-account kava17n8707c20e8gge2tk2gestetjcs4536pdtf8y0 $FAUCET_BALANCE --home "$ROOT_DIR/node$i"
done
# Prepare genesis txs