merge script from branch v0.1.0

This commit is contained in:
Solovyov1796 2024-08-03 21:59:05 +08:00
parent 71d011469c
commit 161f626d06
3 changed files with 27 additions and 39 deletions

View File

@ -56,7 +56,7 @@ NUM_NODES=${#IPS[@]}
# Install dependent libraries and binary # Install dependent libraries and binary
for ((i=0; i<$NUM_NODES; i++)) do for ((i=0; i<$NUM_NODES; i++)) do
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" ssh $PEM_FLAG ubuntu@${IPS[$i]} "rm -rf 0g-chain; git clone https://github.com/0glabs/0g-chain.git; cd 0g-chain; git checkout patch_testnet_1; ./networks/testnet/install.sh"
done done
# Create genesis config on node0 # Create genesis config on node0
@ -71,7 +71,7 @@ cd $NETWORK
for ((i=0; i<$NUM_NODES; i++)) do for ((i=0; i<$NUM_NODES; i++)) do
tar czf node$i.tar.gz node$i tar czf node$i.tar.gz node$i
scp $PEM_FLAG node$i.tar.gz ubuntu@${IPS[$i]}:~ scp $PEM_FLAG node$i.tar.gz ubuntu@${IPS[$i]}:~
ssh $PEM_FLAG ubuntu@${IPS[$i]} "rm -rf kava-prod; tar xzf node$i.tar.gz; rm node$i.tar.gz; mv node$i kava-prod" ssh $PEM_FLAG ubuntu@${IPS[$i]} "rm -rf 0gchaind-prod; tar xzf node$i.tar.gz; rm node$i.tar.gz; mv node$i 0gchaind-prod"
rm node$i.tar.gz rm node$i.tar.gz
done done

View File

@ -26,16 +26,16 @@ if [[ "$OS_NAME" = "GNU/Linux" ]]; then
PASSWORD=$2 PASSWORD=$2
fi fi
kava version 2>/dev/null || export PATH=$PATH:$(go env GOPATH)/bin 0gchaind version 2>/dev/null || export PATH=$PATH:$(go env GOPATH)/bin
set -e set -e
IFS=","; declare -a IPS=($1); unset IFS IFS=","; declare -a IPS=($1); unset IFS
NUM_NODES=${#IPS[@]} NUM_NODES=${#IPS[@]}
VLIDATOR_BALANCE=20000000000000ukava VLIDATOR_BALANCE=15000000000000000000000000neuron
FAUCET_BALANCE=20000000000000ukava FAUCET_BALANCE=40000000000000000000000000neuron
STAKING=2000000000000ukava STAKING=10000000000000000000000000neuron
# Init configs # Init configs
for ((i=0; i<$NUM_NODES; i++)) do for ((i=0; i<$NUM_NODES; i++)) do
@ -46,13 +46,13 @@ for ((i=0; i<$NUM_NODES; i++)) do
TMP_GENESIS="$HOMEDIR"/config/tmp_genesis.json TMP_GENESIS="$HOMEDIR"/config/tmp_genesis.json
# Init # Init
kava init "node$i" --home "$HOMEDIR" --chain-id "$CHAIN_ID" >/dev/null 2>&1 0gchaind init "node$i" --home "$HOMEDIR" --chain-id "$CHAIN_ID" >/dev/null 2>&1
# Replace stake with ukava # Replace stake with neuron
sed -in-place='' 's/stake/ukava/g' "$GENESIS" sed -in-place='' 's/stake/neuron/g' "$GENESIS"
# Replace the default evm denom of aphoton with ukava # Replace the default evm denom of aphoton with neuron
sed -in-place='' 's/aphoton/akava/g' "$GENESIS" sed -in-place='' 's/aphoton/neuron/g' "$GENESIS"
cat $GENESIS | jq '.consensus_params.block.max_gas = "25000000"' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS cat $GENESIS | jq '.consensus_params.block.max_gas = "25000000"' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
@ -70,19 +70,8 @@ for ((i=0; i<$NUM_NODES; i++)) do
cat $GENESIS | jq '.app_state.evm.params.chain_config.shanghai_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS cat $GENESIS | jq '.app_state.evm.params.chain_config.shanghai_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
cat $GENESIS | jq '.app_state.evm.params.chain_config.cancun_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS cat $GENESIS | jq '.app_state.evm.params.chain_config.cancun_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
# Add earn vault # cat "$GENESIS" | jq '.app_state["staking"]["params"]["bond_denom"]="a0gi"' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
cat $GENESIS | jq '.app_state.earn.params.allowed_vaults = [ # cat "$GENESIS" | jq '.app_state["gov"]["params"]["min_deposit"][0]["denom"]="a0gi"' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
{
denom: "usdx",
strategies: ["STRATEGY_TYPE_HARD"],
},
{
denom: "bkava",
strategies: ["STRATEGY_TYPE_SAVINGS"],
}]' >$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"]="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["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["slashing"]["params"]["signed_blocks_window"]="1000"' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
@ -91,7 +80,7 @@ for ((i=0; i<$NUM_NODES; i++)) do
# Change app.toml # Change app.toml
APP_TOML="$HOMEDIR"/config/app.toml APP_TOML="$HOMEDIR"/config/app.toml
sed -i 's/minimum-gas-prices = "0akava"/minimum-gas-prices = "1000000000akava"/' "$APP_TOML" sed -i 's/minimum-gas-prices = "0neuron"/minimum-gas-prices = "1000000000neuron"/' "$APP_TOML"
sed -i '/\[json-rpc\]/,/^\[/ s/enable = false/enable = true/' "$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" sed -i '/\[json-rpc\]/,/^\[/ s/address = "127.0.0.1:8545"/address = "0.0.0.0:8545"/' "$APP_TOML"
@ -107,7 +96,7 @@ done
SEEDS="" SEEDS=""
for ((i=0; i<$NUM_NODES; i++)) do for ((i=0; i<$NUM_NODES; i++)) do
if [[ $i -gt 0 ]]; then SEEDS=$SEEDS,; fi if [[ $i -gt 0 ]]; then SEEDS=$SEEDS,; fi
NODE_ID=`kava tendermint show-node-id --home $ROOT_DIR/node$i` NODE_ID=`0gchaind tendermint show-node-id --home $ROOT_DIR/node$i`
SEEDS=$SEEDS$NODE_ID@${IPS[$i]}:26656 SEEDS=$SEEDS$NODE_ID@${IPS[$i]}:26656
done done
@ -126,19 +115,19 @@ done
# - Linux: under `--home` specified folder. # - Linux: under `--home` specified folder.
if [[ "$OS_NAME" = "Msys" ]]; then if [[ "$OS_NAME" = "Msys" ]]; then
for ((i=0; i<$NUM_NODES; i++)) do for ((i=0; i<$NUM_NODES; i++)) do
VALIDATOR="0gchain_9000_validator_$i" VALIDATOR="0gchain_validator_$i"
set +e set +e
ret=`kava keys list --keyring-backend os -n | grep $VALIDATOR` ret=`0gchaind keys list --keyring-backend os -n | grep $VALIDATOR`
set -e set -e
if [[ "$ret" = "" ]]; then if [[ "$ret" = "" ]]; then
echo "Create validator key: $VALIDATOR" echo "Create validator key: $VALIDATOR"
kava keys add $VALIDATOR --keyring-backend os --eth 0gchaind keys add $VALIDATOR --keyring-backend os --eth
fi fi
done done
elif [[ "$OS_NAME" = "GNU/Linux" ]]; then elif [[ "$OS_NAME" = "GNU/Linux" ]]; then
# Create N validators for node0 # Create N validators for node0
for ((i=0; i<$NUM_NODES; i++)) do for ((i=0; i<$NUM_NODES; i++)) do
yes $PASSWORD | kava keys add "0gchain_9000_validator_$i" --keyring-backend os --home "$ROOT_DIR"/node0 --eth yes $PASSWORD | 0gchaind keys add "0gchain_validator_$i" --keyring-backend os --home "$ROOT_DIR"/node0 --eth
done done
# Copy validators to other nodes # Copy validators to other nodes
@ -157,28 +146,27 @@ fi
for ((i=0; i<$NUM_NODES; i++)) do for ((i=0; i<$NUM_NODES; i++)) do
for ((j=0; j<$NUM_NODES; j++)) do for ((j=0; j<$NUM_NODES; j++)) do
if [[ "$OS_NAME" = "GNU/Linux" ]]; then if [[ "$OS_NAME" = "GNU/Linux" ]]; then
yes $PASSWORD | kava add-genesis-account "0gchain_9000_validator_$j" $VLIDATOR_BALANCE --home "$ROOT_DIR/node$i" yes $PASSWORD | 0gchaind add-genesis-account "0gchain_validator_$j" $VLIDATOR_BALANCE --home "$ROOT_DIR/node$i"
else else
kava add-genesis-account "0gchain_9000_validator_$j" $VLIDATOR_BALANCE --home "$ROOT_DIR/node$i" 0gchaind add-genesis-account "0gchain_validator_$j" $VLIDATOR_BALANCE --home "$ROOT_DIR/node$i"
fi fi
done done
kava add-genesis-account kava17n8707c20e8gge2tk2gestetjcs4536pdtf8y0 $FAUCET_BALANCE --home "$ROOT_DIR/node$i" 0gchaind add-genesis-account 0g17n8707c20e8gge2tk2gestetjcs4536p4fhqcs $FAUCET_BALANCE --home "$ROOT_DIR/node$i"
done done
# Prepare genesis txs # Prepare genesis txs
mkdir -p "$ROOT_DIR"/gentxs mkdir -p "$ROOT_DIR"/gentxs
for ((i=0; i<$NUM_NODES; i++)) do for ((i=0; i<$NUM_NODES; i++)) do
if [[ "$OS_NAME" = "GNU/Linux" ]]; then if [[ "$OS_NAME" = "GNU/Linux" ]]; then
yes $PASSWORD | kava gentx "0gchain_9000_validator_$i" $STAKING --home "$ROOT_DIR/node$i" --output-document "$ROOT_DIR/gentxs/node$i.json" yes $PASSWORD | 0gchaind gentx "0gchain_validator_$i" $STAKING --home "$ROOT_DIR/node$i" --output-document "$ROOT_DIR/gentxs/node$i.json"
else else
kava gentx "0gchain_9000_validator_$i" $STAKING --home "$ROOT_DIR/node$i" --output-document "$ROOT_DIR/gentxs/node$i.json" 0gchaind gentx "0gchain_validator_$i" $STAKING --home "$ROOT_DIR/node$i" --output-document "$ROOT_DIR/gentxs/node$i.json"
fi fi
done done
# Create genesis at node0 and copy to other nodes # Create genesis at node0 and copy to other nodes
kava collect-gentxs --home "$ROOT_DIR/node0" --gentx-dir "$ROOT_DIR/gentxs" >/dev/null 2>&1 0gchaind collect-gentxs --home "$ROOT_DIR/node0" --gentx-dir "$ROOT_DIR/gentxs" >/dev/null 2>&1
sed -i '/persistent_peers = /c\persistent_peers = ""' "$ROOT_DIR"/node0/config/config.toml 0gchaind validate-genesis --home "$ROOT_DIR/node0"
kava validate-genesis --home "$ROOT_DIR/node0"
for ((i=1; i<$NUM_NODES; i++)) do for ((i=1; i<$NUM_NODES; i++)) do
cp "$ROOT_DIR"/node0/config/genesis.json "$ROOT_DIR"/node$i/config/genesis.json cp "$ROOT_DIR"/node0/config/genesis.json "$ROOT_DIR"/node$i/config/genesis.json
done done

View File

@ -8,7 +8,7 @@ gcc --version 2>/dev/null || (sudo apt-get update; sudo apt install gcc -y)
# Build binary # Build binary
export PATH=$PATH:$(go env GOPATH)/bin export PATH=$PATH:$(go env GOPATH)/bin
kava version 2>/dev/null 0gchaind version 2>/dev/null
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
# Make under root dir # Make under root dir
SCRIPT_DIR=`dirname "${BASH_SOURCE[0]}"` SCRIPT_DIR=`dirname "${BASH_SOURCE[0]}"`