Skip to content

Commit

Permalink
modify local node script
Browse files Browse the repository at this point in the history
  • Loading branch information
keithsue committed Jul 10, 2024
1 parent 252b2eb commit 9b9b229
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 14 deletions.
35 changes: 29 additions & 6 deletions local_node.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/bash

KEYS=("dev0" "dev1")
CHAINID="S2-testnet-1"
KEYS=("validator" "test" "relayer" "btc-vault" "runes-vault")
CHAINID="grimoria-testnet-1"
MONIKER="Side Labs"
BINARY="$HOME/go/bin/sided"
DENOM_STR="uside,ubtct,uusdc,uusdc.axl,uusdc.noble,uusdt,uusdt.kava,uusdt.axl,uwbtc.axl,uwbtc.osmo,uwbtc"
INITIAL_ACCOUNT_STR="bc1q4h88d5xg2cxxcm2kaej32lx6gkdfrxslfaxm8n"
DENOM_STR="uside,sat,uusdc,uusdt"
INITIAL_ACCOUNT_STR="tb1qcr8te4kr609gcawutmrza0j4xv80jy8zmfp6l0"
set -f
IFS=,
DENOMS=($DENOM_STR)
Expand Down Expand Up @@ -73,6 +73,10 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then
# $BINARY keys add "$KEY" --keyring-backend $KEYRING --algo $KEYALGO --recover --home "$HOMEDIR"
# done

echo ""
echo "☝️ Copy the above mnemonic phrases and import them to relayer! Press [Enter] to continue..."
read -r continue

# Set moniker and chain-id for Cascadia (Moniker can be anything, chain-id must be an integer)
$BINARY init $MONIKER -o --chain-id $CHAINID --home "$HOMEDIR"

Expand All @@ -84,6 +88,19 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then
jq --arg gas "$BLOCK_GAS" '.app_state["feemarket"]["block_gas"]=$gas' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
# Set gas limit in genesis
jq --arg max_gas "$MAX_GAS" '.consensus_params["block"]["max_gas"]=$max_gas' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
# setup relayers
RELAYER=$($BINARY keys show "${KEYS[2]}" -a --keyring-backend $KEYRING --home "$HOMEDIR")
jq --arg relayer "$RELAYER" '.app_state["btcbridge"]["params"]["authorized_relayers"][0]=$relayer' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
# setup vaults
BTC_VAULT=$($BINARY keys show "${KEYS[3]}" -a --keyring-backend $KEYRING --home "$HOMEDIR")
jq --arg btc_vault "$BTC_VAULT" '.app_state["btcbridge"]["params"]["vaults"][0]["address"]=$btc_vault' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
PUKEY=$($BINARY keys show "${KEYS[3]}" --pubkeyhex --keyring-backend $KEYRING --home "$HOMEDIR")
jq --arg pubkey "$PUKEY" '.app_state["btcbridge"]["params"]["vaults"][0]["pub_key"]=$pubkey' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
RUNES_VAULT=$($BINARY keys show "${KEYS[4]}" -a --keyring-backend $KEYRING --home "$HOMEDIR")
jq --arg runes_vault "$RUNES_VAULT" '.app_state["btcbridge"]["params"]["vaults"][1]["address"]=$runes_vault' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
PUKEY=$($BINARY keys show "${KEYS[4]}" --pubkeyhex --keyring-backend $KEYRING --home "$HOMEDIR")
jq --arg pubkey "$PUKEY" '.app_state["btcbridge"]["params"]["vaults"][1]["pub_key"]=$pubkey' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"

# set custom pruning settings
sed -i.bak 's/pruning = "default"/pruning = "custom"/g' "$APP_TOML"
sed -i.bak 's/pruning-keep-recent = "0"/pruning-keep-recent = "2"/g' "$APP_TOML"
Expand All @@ -103,6 +120,8 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then
$BINARY add-genesis-account "$KEY" ${BALANCES:1} --keyring-backend $KEYRING --home "$HOMEDIR"
done

echo "Genesis accounts allocated for local accounts"

# Allocate genesis accounts (cosmos formatted addresses)
for ADDR in "${INITIAL_ACCOUNTS[@]}"; do
BALANCES=""
Expand All @@ -112,12 +131,14 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then
echo ${BALANCES:1}
$BINARY add-genesis-account "$ADDR" ${BALANCES:1} --home "$HOMEDIR"
done
echo "Genesis accounts allocated for initial accounts"



# Sign genesis transaction
echo $INITIAL_SUPPLY${DENOMS[0]}
# echo $INITIAL_SUPPLY${DENOMS[0]}
$BINARY gentx "${KEYS[0]}" $INITIAL_SUPPLY${DENOMS[0]} --keyring-backend $KEYRING --chain-id $CHAINID --identity "666AC57CC678BEC4" --website="https://side.one" --home "$HOMEDIR"
echo "Genesis transaction signed"

## In case you want to create multiple validators at genesis
## 1. Back to `$BINARY keys add` step, init more keys
Expand All @@ -128,9 +149,11 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then

# Collect genesis tx
$BINARY collect-gentxs --home "$HOMEDIR"
echo "Genesis transactions collected"

# Run this to ensure everything worked and that the genesis file is setup correctly
$BINARY validate-genesis --home "$HOMEDIR"
echo "Genesis file validated"

if [[ $1 == "pending" ]]; then
echo "pending mode is on, please wait for the first block committed."
Expand All @@ -139,4 +162,4 @@ fi


# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
$BINARY start --log_level info --minimum-gas-prices=0.0001${DENOMS[0]}
$BINARY start --log_level info --minimum-gas-prices=0.0001${DENOMS[0]} --home "$HOMEDIR"
16 changes: 8 additions & 8 deletions local_node_dev.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

KEYS=("validator" "test" "relayer")
KEYS=("validator" "test" "relayer" "btc-vault" "runes-vault")
CHAINID="devnet"
MONIKER="Side Labs"
BINARY="$HOME/go/bin/sided"
Expand Down Expand Up @@ -92,13 +92,13 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then
RELAYER=$($BINARY keys show "${KEYS[2]}" -a --keyring-backend $KEYRING --home "$HOMEDIR")
jq --arg relayer "$RELAYER" '.app_state["btcbridge"]["params"]["authorized_relayers"][0]=$relayer' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
# setup vaults
VAULT1=$($BINARY keys show "${KEYS[1]}" -a --keyring-backend $KEYRING --home "$HOMEDIR")
jq --arg vault1 "$VAULT1" '.app_state["btcbridge"]["params"]["vaults"][0]["address"]=$vault1' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
PUKEY=$($BINARY keys show "${KEYS[1]}" --pubkeyhex --keyring-backend $KEYRING --home "$HOMEDIR")
BTC_VAULT=$($BINARY keys show "${KEYS[3]}" -a --keyring-backend $KEYRING --home "$HOMEDIR")
jq --arg btc_vault "$BTC_VAULT" '.app_state["btcbridge"]["params"]["vaults"][0]["address"]=$btc_vault' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
PUKEY=$($BINARY keys show "${KEYS[3]}" --pubkeyhex --keyring-backend $KEYRING --home "$HOMEDIR")
jq --arg pubkey "$PUKEY" '.app_state["btcbridge"]["params"]["vaults"][0]["pub_key"]=$pubkey' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
VAULT2=$RELAYER
jq --arg vault2 "$VAULT2" '.app_state["btcbridge"]["params"]["vaults"][1]["address"]=$vault2' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
PUKEY=$($BINARY keys show "${KEYS[2]}" --pubkeyhex --keyring-backend $KEYRING --home "$HOMEDIR")
RUNES_VAULT=$($BINARY keys show "${KEYS[4]}" -a --keyring-backend $KEYRING --home "$HOMEDIR")
jq --arg runes_vault "$RUNES_VAULT" '.app_state["btcbridge"]["params"]["vaults"][1]["address"]=$runes_vault' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
PUKEY=$($BINARY keys show "${KEYS[4]}" --pubkeyhex --keyring-backend $KEYRING --home "$HOMEDIR")
jq --arg pubkey "$PUKEY" '.app_state["btcbridge"]["params"]["vaults"][1]["pub_key"]=$pubkey' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"

# set custom pruning settings
Expand Down Expand Up @@ -162,4 +162,4 @@ fi


# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
$BINARY start --log_level info --minimum-gas-prices=0.0001${DENOMS[0]}
$BINARY start --log_level info --minimum-gas-prices=0.0001${DENOMS[0]} --home "$HOMEDIR"

0 comments on commit 9b9b229

Please sign in to comment.