From 6fd5244cfec0d228fe7c9e9b44f2c1020ac65f0a Mon Sep 17 00:00:00 2001 From: Anmol Date: Thu, 11 Jul 2024 14:15:42 +0530 Subject: [PATCH] fix: update some defaults for neutron (#517) * update some defaults for neutron * update scripts for running neutron specific scripts, update defaults * fix typo in update config * update neutron scripts to match with original neutron repo network scripts * use default neutron docker image --- starship/charts/devnet/defaults.yaml | 6 ++- .../devnet/scripts/default/update-config.sh | 22 +++------ .../scripts/neutron/create-neutron-genesis.sh | 48 ++++++++++++++++--- .../devnet/scripts/neutron/update-config.sh | 12 +++++ .../devnet/scripts/neutron/update-genesis.sh | 11 +++++ starship/tests/e2e/configs/neutron.yaml | 1 - 6 files changed, 76 insertions(+), 24 deletions(-) create mode 100644 starship/charts/devnet/scripts/neutron/update-config.sh create mode 100644 starship/charts/devnet/scripts/neutron/update-genesis.sh diff --git a/starship/charts/devnet/defaults.yaml b/starship/charts/devnet/defaults.yaml index cf5d37fc7..f0f6e3bcd 100644 --- a/starship/charts/devnet/defaults.yaml +++ b/starship/charts/devnet/defaults.yaml @@ -572,7 +572,7 @@ defaultChains: svg: https://raw.githubusercontent.com/cosmos/chain-registry/master/cheqd/images/cheq.svg coingecko_id: cheqd-network neutron: - image: ghcr.io/cosmology-tech/starship/neutron:v2.0.1 + image: ghcr.io/cosmology-tech/starship/neutron:v3.0.5 home: /root/.neutrond binary: neutrond prefix: neutron @@ -585,6 +585,10 @@ defaultChains: scripts: createGenesis: file: scripts/neutron/create-neutron-genesis.sh + updateGenesis: + file: scripts/neutron/update-genesis.sh + updateConfig: + file: scripts/neutron/update-config.sh assets: - description: The native token of Neutron chain. denom_units: diff --git a/starship/charts/devnet/scripts/default/update-config.sh b/starship/charts/devnet/scripts/default/update-config.sh index 545dabbd3..bba7785b2 100644 --- a/starship/charts/devnet/scripts/default/update-config.sh +++ b/starship/charts/devnet/scripts/default/update-config.sh @@ -14,7 +14,7 @@ sed -i -e 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:26657"#g' $CHAIN_DIR/config/ sed -i -e 's/index_all_keys = false/index_all_keys = true/g' $CHAIN_DIR/config/config.toml sed -i -e 's/seeds = ".*"/seeds = ""/g' $CHAIN_DIR/config/config.toml sed -i -e 's#cors_allowed_origins = \[\]#cors_allowed_origins = \["*"\]#g' $CHAIN_DIR/config/config.toml - +sed -i -e 's/index_all_keys = false/index_all_keys = true/g' $CHAIN_DIR/config/config.toml echo "Update client.toml file" sed -i -e 's#keyring-backend = "os"#keyring-backend = "test"#g' $CHAIN_DIR/config/client.toml @@ -25,10 +25,13 @@ sed -i -e "s#chain-id = \"\"#chain-id = \"$CHAIN_ID\"#g" $CHAIN_DIR/config/clien echo "Update app.toml file" sed -i -e "s#minimum-gas-prices = \".*\"#minimum-gas-prices = \"0$DENOM\"#g" $CHAIN_DIR/config/app.toml sed -i -e "s#pruning = \".*\"#pruning = \"default\"#g" $CHAIN_DIR/config/app.toml -sed -i -e 's#enabled-unsafe-cors = false#enabled-unsafe-cors = true#g' $CHAIN_DIR/config/app.toml -sed -i -e 's#swagger = false#swagger = true#g' $CHAIN_DIR/config/app.toml sed -i -e 's/enable-unsafe-cors = false/enable-unsafe-cors = true/g' $CHAIN_DIR/config/app.toml sed -i -e 's/enabled-unsafe-cors = false/enabled-unsafe-cors = true/g' $CHAIN_DIR/config/app.toml +sed -i -e 's/enable = false/enable = true/g' $CHAIN_DIR/config/app.toml +sed -i -e 's/swagger = false/swagger = true/g' $CHAIN_DIR/config/app.toml +sed -i -e 's/enable = false/enable = true/g' $CHAIN_DIR/config/app.toml +sed -i -e 's/enabled = false/enabled = true/g' $CHAIN_DIR/config/app.toml + function get_next_line_number() { local txt=$1 @@ -37,21 +40,14 @@ function get_next_line_number() { echo $((line_number + 1)) } -line_number=$(get_next_line_number "Enable defines if the API server should be enabled." $CHAIN_DIR/config/app.toml) -sed -i -e "${line_number}s/enable = false/enable = true/g" $CHAIN_DIR/config/app.toml - line_number=$(get_next_line_number "Address defines the API server to listen on." $CHAIN_DIR/config/app.toml) sed -i -e "${line_number}s#address = \".*\"#address = \"tcp://0.0.0.0:1317\"#g" $CHAIN_DIR/config/app.toml -line_number=$(get_next_line_number "Enable defines if the gRPC server should be enabled." $CHAIN_DIR/config/app.toml) -sed -i -e "${line_number}s/enable = false/enable = true/g" $CHAIN_DIR/config/app.toml - line_number=$(get_next_line_number "Address defines the gRPC server address to bind to." $CHAIN_DIR/config/app.toml) sed -i -e "${line_number}s#address = \".*\"#address = \"0.0.0.0:9090\"#g" $CHAIN_DIR/config/app.toml if [ "$METRICS" == "true" ]; then - line_number=$(get_next_line_number "other sinks such as Prometheus." $CHAIN_DIR/config/app.toml) - sed -i -e "${line_number}s/enabled = false/enabled = true/g" $CHAIN_DIR/config/app.toml + sed -i -e "s/prometheus = false/prometheus = true/g" $CHAIN_DIR/config/config.toml line_number=$(get_next_line_number "PrometheusRetentionTime, when positive, enables a Prometheus metrics sink." $CHAIN_DIR/config/app.toml) sed -i -e "${line_number}s/prometheus-retention-time = 0/prometheus-retention-time = 3600/g" $CHAIN_DIR/config/app.toml @@ -65,7 +61,3 @@ sed -i -e "s#timeout_prevote_delta = \".*\"#timeout_prevote_delta = \"$TIMEOUT_P sed -i -e "s#timeout_precommit = \".*\"#timeout_precommit = \"$TIMEOUT_PRECOMMIT\"#g" $CHAIN_DIR/config/config.toml sed -i -e "s#timeout_precommit_delta = \".*\"#timeout_precommit_delta = \"$TIMEOUT_PRECOMMIT_DELTA\"#g" $CHAIN_DIR/config/config.toml sed -i -e "s#timeout_commit = \".*\"#timeout_commit = \"$TIMEOUT_COMMIT\"#g" $CHAIN_DIR/config/config.toml - -if [ "$METRICS" == "true" ]; then - sed -i -e "s/prometheus = false/prometheus = true/g" $CHAIN_DIR/config/config.toml -fi diff --git a/starship/charts/devnet/scripts/neutron/create-neutron-genesis.sh b/starship/charts/devnet/scripts/neutron/create-neutron-genesis.sh index 50112067b..1d26d65e3 100644 --- a/starship/charts/devnet/scripts/neutron/create-neutron-genesis.sh +++ b/starship/charts/devnet/scripts/neutron/create-neutron-genesis.sh @@ -8,19 +8,23 @@ BINARY="${CHAIN_BIN:=neutrond}" CHAIN_DIR="${CHAIN_DIR:=$HOME/.neutrond}" KEYS_CONFIG="${KEYS_CONFIG:=configs/keys.json}" -BRANCH="${BRANCH:=v2.0.1}" +BRANCH="${BRANCH:=v3.0.5}" FAUCET_ENABLED="${FAUCET_ENABLED:=true}" NUM_VALIDATORS="${NUM_VALIDATORS:=1}" NUM_RELAYERS="${NUM_RELAYERS:=0}" +P2PPORT=${P2PPORT:-26656} +RPCPORT=${RPCPORT:-26657} +RESTPORT=${RESTPORT:-1317} +ROSETTA=${ROSETTA:-8080} + GENESIS_PATH="$CHAIN_DIR/config/genesis.json" -BASE_DIR=./data CONTRACTS_BINARIES_DIR=${CONTRACTS_BINARIES_DIR:-./contracts} THIRD_PARTY_CONTRACTS_DIR=${THIRD_PARTY_CONTRACTS_DIR:-./contracts_thirdparty} -set -eux +set -euxo pipefail mkdir -p $CONTRACTS_BINARIES_DIR $THIRD_PARTY_CONTRACTS_DIR @@ -63,6 +67,39 @@ $BINARY add-genesis-account $($BINARY keys show -a demowallet1 --keyring-backend echo "Adding key.... demowallet2" jq -r ".keys[0].mnemonic" $KEYS_CONFIG | $BINARY keys add demowallet2 --index 2 --recover --keyring-backend="test" $BINARY add-genesis-account $($BINARY keys show -a demowallet2 --keyring-backend="test") $COINS --keyring-backend="test" +# Add test addresses, second multisig address +echo "Adding key.... demowallet2" +jq -r ".keys[0].mnemonic" $KEYS_CONFIG | $BINARY keys add demowallet3 --index 3 --recover --keyring-backend="test" +$BINARY add-genesis-account $($BINARY keys show -a demowallet3 --keyring-backend="test") $COINS --keyring-backend="test" + +sed -i -e 's/timeout_commit = "5s"/timeout_commit = "1s"/g' "$CHAIN_DIR/config/config.toml" +sed -i -e 's/timeout_propose = "3s"/timeout_propose = "1s"/g' "$CHAIN_DIR/config/config.toml" +sed -i -e 's/index_all_keys = false/index_all_keys = true/g' "$CHAIN_DIR/config/config.toml" +sed -i -e 's/enable = false/enable = true/g' "$CHAIN_DIR/config/app.toml" +sed -i -e 's/swagger = false/swagger = true/g' "$CHAIN_DIR/config/app.toml" +sed -i -e "s/minimum-gas-prices = \"\"/minimum-gas-prices = \"0$STAKEDENOM\"/g" "$CHAIN_DIR/config/app.toml" +sed -i -e 's/enabled = false/enabled = true/g' "$CHAIN_DIR/config/app.toml" +sed -i -e 's/prometheus-retention-time = 0/prometheus-retention-time = 1000/g' "$CHAIN_DIR/config/app.toml" +sed -i -e 's/enabled-unsafe-cors = false/enabled-unsafe-cors = true/g' "$CHAIN_DIR/config/app.toml" + +sed -i -e 's#"tcp://0.0.0.0:26656"#"tcp://0.0.0.0:'"$P2PPORT"'"#g' "$CHAIN_DIR/config/config.toml" +sed -i -e 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:'"$RPCPORT"'"#g' "$CHAIN_DIR/config/config.toml" +sed -i -e 's#"tcp://localhost:1317"#"tcp://0.0.0.0:'"$RESTPORT"'"#g' "$CHAIN_DIR/config/app.toml" +sed -i -e 's#"tcp://0.0.0.0:1317"#"tcp://0.0.0.0:'"$RESTPORT"'"#g' "$CHAIN_DIR/config/app.toml" +sed -i -e 's#":8080"#":'"$ROSETTA"'"#g' "$CHAIN_DIR/config/app.toml" +sed -i -e 's#localhost#0.0.0.0#g' "$CHAIN_DIR/config/app.toml" + +echo "Update client.toml file" +sed -i -e 's#keyring-backend = "os"#keyring-backend = "test"#g' $CHAIN_DIR/config/client.toml +sed -i -e 's#output = "text"#output = "json"#g' $CHAIN_DIR/config/client.toml +sed -i -e "s#chain-id = \"\"#chain-id = \"$CHAIN_ID\"#g" $CHAIN_DIR/config/client.toml + +echo "Update genesis.json file with updated local params" +sed -i "s/\"time_iota_ms\": \".*\"/\"time_iota_ms\": \"$TIME_IOTA_MS\"/" $CHAIN_DIR/config/genesis.json + +sed -i -e "s/\"denom\": \"stake\",/\"denom\": \"$DENOM\",/g" "$GENESIS_PATH" +sed -i -e "s/\"mint_denom\": \"stake\",/\"mint_denom\": \"$DENOM\",/g" "$GENESIS_PATH" +sed -i -e "s/\"bond_denom\": \"stake\"/\"bond_denom\": \"$DENOM\"/g" "$GENESIS_PATH" # IMPORTANT! minimum_gas_prices should always contain at least one record, otherwise the chain will not start or halt MIN_GAS_PRICES_DEFAULT='[{"denom":"untrn","amount":"0"}]' @@ -775,9 +812,6 @@ function convert_bech32_base64_esc() { DAO_CONTRACT_ADDRESS_B64=$(convert_bech32_base64_esc "$DAO_CONTRACT_ADDRESS") echo $DAO_CONTRACT_ADDRESS_B64 -CONSUMER_REDISTRIBUTE_ACCOUNT_ADDRESS="neutron1x69dz0c0emw8m2c6kp5v6c08kgjxmu30f4a8w5" -CONSUMER_REDISTRIBUTE_ACCOUNT_ADDRESS_B64=$(convert_bech32_base64_esc "$CONSUMER_REDISTRIBUTE_ACCOUNT_ADDRESS") - set_genesis_param admins "[\"$DAO_CONTRACT_ADDRESS\"]" # admin module set_genesis_param treasury_address "\"$DAO_CONTRACT_ADDRESS\"" # feeburner set_genesis_param fee_collector_address "\"$DAO_CONTRACT_ADDRESS\"" # tokenfactory @@ -792,7 +826,7 @@ set_genesis_param minimum_gas_prices "$MIN_GAS_PRICES," set_genesis_param max_total_bypass_min_fee_msg_gas_usage "\"$MAX_TOTAL_BYPASS_MIN_FEE_MSG_GAS_USAGE\"" # globalfee set_genesis_param_jq ".app_state.globalfee.params.bypass_min_fee_msg_types" "$BYPASS_MIN_FEE_MSG_TYPES" # globalfee set_genesis_param proposer_fee "\"0.25\"" # builder(POB) -set_genesis_param escrow_account_address "\"$CONSUMER_REDISTRIBUTE_ACCOUNT_ADDRESS_B64\"," # builder(POB) +set_genesis_param escrow_account_address "\"$DAO_CONTRACT_ADDRESS_B64\"," # builder(POB) set_genesis_param sudo_call_gas_limit "\"1000000\"" # contractmanager set_genesis_param max_gas "\"1000000000\"" # consensus_params diff --git a/starship/charts/devnet/scripts/neutron/update-config.sh b/starship/charts/devnet/scripts/neutron/update-config.sh new file mode 100644 index 000000000..f1cfe19fa --- /dev/null +++ b/starship/charts/devnet/scripts/neutron/update-config.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +STAKEDENOM=${DENOM:-untrn} +CHAIN_ID="${CHAIN_ID:=osmosis}" +CHAIN_DIR="${CHAIN_DIR:=$HOME/.osmosisd}" +KEYS_CONFIG="${KEYS_CONFIG:=configs/keys.json}" + +set -eux + +ls $CHAIN_DIR + +echo "Already done" diff --git a/starship/charts/devnet/scripts/neutron/update-genesis.sh b/starship/charts/devnet/scripts/neutron/update-genesis.sh new file mode 100644 index 000000000..01b11ded8 --- /dev/null +++ b/starship/charts/devnet/scripts/neutron/update-genesis.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +DENOM="${DENOM:=uosmo}" +CHAIN_BIN="${CHAIN_BIN:=osmosisd}" +CHAIN_DIR="${CHAIN_DIR:=$HOME/.osmosisd}" + +set -eux + +ls $CHAIN_DIR/config + +$CHAIN_BIN tendermint show-node-id diff --git a/starship/tests/e2e/configs/neutron.yaml b/starship/tests/e2e/configs/neutron.yaml index 8c336989d..e259008e5 100644 --- a/starship/tests/e2e/configs/neutron.yaml +++ b/starship/tests/e2e/configs/neutron.yaml @@ -1,7 +1,6 @@ chains: - id: neutron-1 name: neutron - image: ghcr.io/cosmology-tech/starship/neutron:v3.0.6 numValidators: 1 faucet: enabled: false