mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +00:00
Regular → Executable
+74
-74
@@ -10,7 +10,7 @@ set -eu
|
||||
export KEY="acc0"
|
||||
export KEY2="acc1"
|
||||
|
||||
export CHAIN_ID=${CHAIN_ID:-"localchain-1"}
|
||||
export CHAIN_ID=${CHAIN_ID:-"sonrtest_1-1"}
|
||||
export MONIKER="localvalidator"
|
||||
export KEYALGO="secp256k1"
|
||||
export KEYRING=${KEYRING:-"test"}
|
||||
@@ -34,119 +34,119 @@ app_toml="${HOME_DIR}/config/app.toml"
|
||||
genesis_json="${HOME_DIR}/config/genesis.json"
|
||||
|
||||
# if which binary does not exist, install it
|
||||
if [ -z $(which $BINARY) ]; then
|
||||
make install
|
||||
if [[ -z $(which "${BINARY}") ]]; then
|
||||
make install
|
||||
|
||||
if [ -z $(which $BINARY) ]; then
|
||||
echo "Ensure $BINARY is installed and in your PATH"
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z $(which "${BINARY}") ]]; then
|
||||
echo "Ensure ${BINARY} is installed and in your PATH"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
command -v $BINARY >/dev/null 2>&1 || {
|
||||
echo >&2 "$BINARY command not found. Ensure this is setup / properly installed in your GOPATH (make install)."
|
||||
exit 1
|
||||
command -v "${BINARY}" >/dev/null 2>&1 || {
|
||||
echo >&2 "${BINARY} command not found. Ensure this is setup / properly installed in your GOPATH (make install)."
|
||||
exit 1
|
||||
}
|
||||
command -v jq >/dev/null 2>&1 || {
|
||||
echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/"
|
||||
exit 1
|
||||
echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set_config() {
|
||||
$BINARY config set client chain-id $CHAIN_ID
|
||||
$BINARY config set client keyring-backend $KEYRING
|
||||
${BINARY} config set client chain-id "${CHAIN_ID}"
|
||||
${BINARY} config set client keyring-backend "${KEYRING}"
|
||||
}
|
||||
set_config
|
||||
|
||||
from_scratch() {
|
||||
# Fresh install on current branch
|
||||
make install
|
||||
# Fresh install on current branch
|
||||
make install
|
||||
|
||||
# remove existing daemon files.
|
||||
if [ ${#HOME_DIR} -le 2 ]; then
|
||||
echo "HOME_DIR must be more than 2 characters long"
|
||||
return
|
||||
fi
|
||||
rm -rf $HOME_DIR && echo "Removed $HOME_DIR"
|
||||
# remove existing daemon files.
|
||||
if [[ ${#HOME_DIR} -le 2 ]]; then
|
||||
echo "HOME_DIR must be more than 2 characters long"
|
||||
return
|
||||
fi
|
||||
rm -rf "${HOME_DIR}" && echo "Removed ${HOME_DIR}"
|
||||
|
||||
# reset values if not set already after whipe
|
||||
set_config
|
||||
# reset values if not set already after whipe
|
||||
set_config
|
||||
|
||||
add_key() {
|
||||
key=$1
|
||||
mnemonic=$2
|
||||
echo $mnemonic | $BINARY keys add $key --home $HOME_DIR --keyring-backend $KEYRING --algo $KEYALGO --recover
|
||||
}
|
||||
add_key() {
|
||||
key=$1
|
||||
mnemonic=$2
|
||||
echo "${mnemonic}" | ${BINARY} keys add "${key}" --home "${HOME_DIR}" --keyring-backend "${KEYRING}" --algo "${KEYALGO}" --recover
|
||||
}
|
||||
|
||||
# cosmos1efd63aw40lxf3n4mhf7dzhjkr453axur6cpk92
|
||||
add_key $KEY "decorate bright ozone fork gallery riot bus exhaust worth way bone indoor calm squirrel merry zero scheme cotton until shop any excess stage laundry"
|
||||
# cosmos1hj5fveer5cjtn4wd6wstzugjfdxzl0xpxvjjvr
|
||||
add_key $KEY2 "wealth flavor believe regret funny network recall kiss grape useless pepper cram hint member few certain unveil rather brick bargain curious require crowd raise"
|
||||
# cosmos1efd63aw40lxf3n4mhf7dzhjkr453axur6cpk92
|
||||
add_key "${KEY}" "decorate bright ozone fork gallery riot bus exhaust worth way bone indoor calm squirrel merry zero scheme cotton until shop any excess stage laundry"
|
||||
# cosmos1hj5fveer5cjtn4wd6wstzugjfdxzl0xpxvjjvr
|
||||
add_key "${KEY2}" "wealth flavor believe regret funny network recall kiss grape useless pepper cram hint member few certain unveil rather brick bargain curious require crowd raise"
|
||||
|
||||
$BINARY init $CHAIN_ID --chain-id $CHAIN_ID --overwrite --default-denom $DENOM --home $HOME_DIR
|
||||
${BINARY} init "${CHAIN_ID}" --chain-id "${CHAIN_ID}" --overwrite --default-denom "${DENOM}" --home "${HOME_DIR}"
|
||||
|
||||
update_test_genesis() {
|
||||
cat $HOME_DIR/config/genesis.json | jq "$1" >$HOME_DIR/config/tmp_genesis.json && mv $HOME_DIR/config/tmp_genesis.json $HOME_DIR/config/genesis.json
|
||||
}
|
||||
update_test_genesis() {
|
||||
cat "${HOME_DIR}"/config/genesis.json | jq "$1" >"${HOME_DIR}"/config/tmp_genesis.json && mv "${HOME_DIR}"/config/tmp_genesis.json "${HOME_DIR}"/config/genesis.json
|
||||
}
|
||||
|
||||
# === CORE MODULES ===
|
||||
# block
|
||||
update_test_genesis '.consensus_params["block"]["max_gas"]="100000000"'
|
||||
# crisis
|
||||
update_test_genesis $(printf '.app_state["crisis"]["constant_fee"]={"denom":"%s","amount":"1000"}' $DENOM)
|
||||
# === CORE MODULES ===
|
||||
# block
|
||||
update_test_genesis '.consensus_params["block"]["max_gas"]="100000000"'
|
||||
# crisis
|
||||
update_test_genesis $(printf '.app_state["crisis"]["constant_fee"]={"denom":"%s","amount":"1000"}' "${DENOM}")
|
||||
|
||||
# === CUSTOM MODULES ===
|
||||
# tokenfactory
|
||||
update_test_genesis '.app_state["tokenfactory"]["params"]["denom_creation_fee"]=[]'
|
||||
update_test_genesis '.app_state["tokenfactory"]["params"]["denom_creation_gas_consume"]=100000'
|
||||
# === CUSTOM MODULES ===
|
||||
# tokenfactory
|
||||
update_test_genesis '.app_state["tokenfactory"]["params"]["denom_creation_fee"]=[]'
|
||||
update_test_genesis '.app_state["tokenfactory"]["params"]["denom_creation_gas_consume"]=100000'
|
||||
|
||||
$BINARY keys list --keyring-backend $KEYRING --home $HOME_DIR
|
||||
${BINARY} keys list --keyring-backend "${KEYRING}" --home "${HOME_DIR}"
|
||||
|
||||
# Allocate genesis accounts
|
||||
$BINARY genesis add-genesis-account $KEY 10000000$DENOM,900test --keyring-backend $KEYRING --home $HOME_DIR --append
|
||||
$BINARY genesis add-genesis-account $KEY2 10000000$DENOM,800test --keyring-backend $KEYRING --home $HOME_DIR --append
|
||||
# Allocate genesis accounts
|
||||
${BINARY} genesis add-genesis-account "${KEY}" 10000000"${DENOM}",900test --keyring-backend "${KEYRING}" --home "${HOME_DIR}" --append
|
||||
${BINARY} genesis add-genesis-account "${KEY2}" 10000000"${DENOM}",800test --keyring-backend "${KEYRING}" --home "${HOME_DIR}" --append
|
||||
|
||||
# ICS provider genesis hack
|
||||
HACK_DIR=icshack-1 && echo $HACK_DIR
|
||||
rm -rf $HACK_DIR
|
||||
cp -r ${HOME_DIR} $HACK_DIR
|
||||
# ICS provider genesis hack
|
||||
HACK_DIR=icshack-1 && echo "${HACK_DIR}"
|
||||
rm -rf "${HACK_DIR}"
|
||||
cp -r "${HOME_DIR}" "${HACK_DIR}"
|
||||
|
||||
$BINARY add-consumer-section provider --home $HACK_DIR
|
||||
ccvjson=$(jq '.app_state["ccvconsumer"]' $HACK_DIR/config/genesis.json)
|
||||
echo $ccvjson
|
||||
jq '.app_state["ccvconsumer"] = '"$ccvjson" ${HACK_DIR}/config/genesis.json >json.tmp && mv json.tmp $genesis_json
|
||||
rm -rf $HACK_DIR
|
||||
${BINARY} add-consumer-section provider --home "${HACK_DIR}"
|
||||
ccvjson=$(jq '.app_state["ccvconsumer"]' "${HACK_DIR}"/config/genesis.json)
|
||||
echo "${ccvjson}"
|
||||
jq '.app_state["ccvconsumer"] = '"${ccvjson}" "${HACK_DIR}"/config/genesis.json >json.tmp && mv json.tmp "${genesis_json}"
|
||||
rm -rf "${HACK_DIR}"
|
||||
|
||||
update_test_genesis $(printf '.app_state["ccvconsumer"]["params"]["unbonding_period"]="%s"' "240s")
|
||||
update_test_genesis $(printf '.app_state["ccvconsumer"]["params"]["unbonding_period"]="%s"' "240s")
|
||||
}
|
||||
|
||||
# check if CLEAN is not set to false
|
||||
if [ "$CLEAN" != "false" ]; then
|
||||
echo "Starting from a clean state"
|
||||
from_scratch
|
||||
if [[ ${CLEAN} != "false" ]]; then
|
||||
echo "Starting from a clean state"
|
||||
from_scratch
|
||||
fi
|
||||
|
||||
# Opens the RPC endpoint to outside connections
|
||||
sed -i -e 's/laddr = "tcp:\/\/127.0.0.1:26657"/c\laddr = "tcp:\/\/0.0.0.0:'$RPC'"/g' $HOME_DIR/config/config.toml
|
||||
sed -i -e 's/cors_allowed_origins = \[\]/cors_allowed_origins = \["\*"\]/g' $HOME_DIR/config/config.toml
|
||||
sed -i -e 's/laddr = "tcp:\/\/127.0.0.1:26657"/c\laddr = "tcp:\/\/0.0.0.0:'"${RPC}"'"/g' "${HOME_DIR}"/config/config.toml
|
||||
sed -i -e 's/cors_allowed_origins = \[\]/cors_allowed_origins = \["\*"\]/g' "${HOME_DIR}"/config/config.toml
|
||||
|
||||
# REST endpoint
|
||||
sed -i -e 's/address = "tcp:\/\/localhost:1317"/address = "tcp:\/\/0.0.0.0:'$REST'"/g' $HOME_DIR/config/app.toml
|
||||
sed -i -e 's/enable = false/enable = true/g' $HOME_DIR/config/app.toml
|
||||
sed -i -e 's/address = "tcp:\/\/localhost:1317"/address = "tcp:\/\/0.0.0.0:'"${REST}"'"/g' "${HOME_DIR}"/config/app.toml
|
||||
sed -i -e 's/enable = false/enable = true/g' "${HOME_DIR}"/config/app.toml
|
||||
|
||||
# peer exchange
|
||||
sed -i -e 's/pprof_laddr = "localhost:6060"/pprof_laddr = "localhost:'$PROFF'"/g' $HOME_DIR/config/config.toml
|
||||
sed -i -e 's/laddr = "tcp:\/\/0.0.0.0:26656"/laddr = "tcp:\/\/0.0.0.0:'$P2P'"/g' $HOME_DIR/config/config.toml
|
||||
sed -i -e 's/pprof_laddr = "localhost:6060"/pprof_laddr = "localhost:'"${PROFF}"'"/g' "${HOME_DIR}"/config/config.toml
|
||||
sed -i -e 's/laddr = "tcp:\/\/0.0.0.0:26656"/laddr = "tcp:\/\/0.0.0.0:'"${P2P}"'"/g' "${HOME_DIR}"/config/config.toml
|
||||
|
||||
# GRPC
|
||||
sed -i -e 's/address = "localhost:9090"/address = "0.0.0.0:'$GRPC'"/g' $HOME_DIR/config/app.toml
|
||||
sed -i -e 's/address = "localhost:9091"/address = "0.0.0.0:'$GRPC_WEB'"/g' $HOME_DIR/config/app.toml
|
||||
sed -i -e 's/address = "localhost:9090"/address = "0.0.0.0:'"${GRPC}"'"/g' "${HOME_DIR}"/config/app.toml
|
||||
sed -i -e 's/address = "localhost:9091"/address = "0.0.0.0:'"${GRPC_WEB}"'"/g' "${HOME_DIR}"/config/app.toml
|
||||
|
||||
# Rosetta Api
|
||||
sed -i -e 's/address = ":8080"/address = "0.0.0.0:'$ROSETTA'"/g' $HOME_DIR/config/app.toml
|
||||
sed -i -e 's/address = ":8080"/address = "0.0.0.0:'"${ROSETTA}"'"/g' "${HOME_DIR}"/config/app.toml
|
||||
|
||||
# Faster blocks
|
||||
sed -i -e 's/timeout_commit = "5s"/timeout_commit = "'$BLOCK_TIME'"/g' $HOME_DIR/config/config.toml
|
||||
sed -i -e 's/timeout_commit = "5s"/timeout_commit = "'"${BLOCK_TIME}"'"/g' "${HOME_DIR}"/config/config.toml
|
||||
|
||||
# Start the daemon in the background
|
||||
$BINARY start --pruning=nothing --minimum-gas-prices=0$DENOM --rpc.laddr="tcp://0.0.0.0:$RPC" --home $HOME_DIR
|
||||
${BINARY} start --pruning=nothing --minimum-gas-prices=0"${DENOM}" --rpc.laddr="tcp://0.0.0.0:${RPC}" --home "${HOME_DIR}"
|
||||
|
||||
Reference in New Issue
Block a user