From 3a88c1edfde8b31171c53fbf3be53c0c1a7f900f Mon Sep 17 00:00:00 2001 From: artpav <19916123+artemijspavlovs@users.noreply.github.com> Date: Wed, 10 Jul 2024 11:26:16 +0300 Subject: [PATCH] chore: update init script to include all the necessary steps for rollapp initialization (#289) --- scripts/ibc/setup_ibc.sh | 60 ++-- scripts/init.sh | 283 ++++++++++++++---- scripts/settlement/add_genesis_accounts.sh | 27 -- scripts/settlement/generate_denom_metadata.sh | 35 --- scripts/settlement/register_rollapp_to_hub.sh | 21 +- scripts/update_genesis_file.sh | 33 -- 6 files changed, 275 insertions(+), 184 deletions(-) delete mode 100755 scripts/settlement/add_genesis_accounts.sh delete mode 100755 scripts/settlement/generate_denom_metadata.sh delete mode 100755 scripts/update_genesis_file.sh diff --git a/scripts/ibc/setup_ibc.sh b/scripts/ibc/setup_ibc.sh index 4f187c3c..5b596e6d 100755 --- a/scripts/ibc/setup_ibc.sh +++ b/scripts/ibc/setup_ibc.sh @@ -1,4 +1,31 @@ #!/bin/bash +EXECUTABLE=$(which rollapp-evm) + +if ! command -v "$EXECUTABLE" >/dev/null; then + echo "$EXECUTABLE does not exist" + echo "please run make install" + exit 1 +fi + +if [ "$BECH32_PREFIX" = "" ]; then + echo "BECH32_PREFIX is not set" + exit 1 +fi + +if [ "$BASE_DENOM" = "" ]; then + echo "BASE_DENOM is not set" + exit 1 +fi + +if [ "$HUB_KEY_WITH_FUNDS" = "" ]; then + echo "HUB_KEY_WITH_FUNDS is not set" + exit 1 +fi + +if [ "$KEY_NAME_ROLLAPP" = "" ]; then + echo "KEY_NAME_ROLLAPP is not set" + exit 1 +fi BASEDIR=$(dirname "$0") @@ -18,7 +45,7 @@ SETTLEMENT_KEY_NAME_GENESIS="$HUB_KEY_WITH_FUNDS" ROLLAPP_CHAIN_ID=$("$EXECUTABLE" config | jq -r '."chain-id"') ROLLAPP_RPC_FOR_RELAYER=$("$EXECUTABLE" config | jq -r '."node"') -RELAYER_KEY_FOR_ROLLAP="relayer-rollapp-key" +RELAYER_KEY_FOR_ROLLAPP="relayer-rollapp-key" RELAYER_KEY_FOR_HUB="relayer-hub-key" RELAYER_PATH="hub-rollapp" @@ -48,17 +75,16 @@ echo '--------------------------------- Initializing rly config... ------------- rly config init echo '--------------------------------- Adding chains to rly config.. --------------------------------' -tmp=$(mktemp) -jq --arg key "$RELAYER_KEY_FOR_ROLLAP" '.value.key = $key' "$ROLLAPP_IBC_CONF_FILE" >"$tmp" && mv "$tmp" "$ROLLAPP_IBC_CONF_FILE" -jq --arg chain "$ROLLAPP_CHAIN_ID" '.value."chain-id" = $chain' "$ROLLAPP_IBC_CONF_FILE" >"$tmp" && mv "$tmp" "$ROLLAPP_IBC_CONF_FILE" -jq --arg bech "$BECH32_PREFIX" '.value["account-prefix"] = $bech' "$ROLLAPP_IBC_CONF_FILE" >"$tmp" && mv "$tmp" "$ROLLAPP_IBC_CONF_FILE" -jq --arg rpc "$ROLLAPP_RPC_FOR_RELAYER" '.value."rpc-addr" = $rpc' "$ROLLAPP_IBC_CONF_FILE" >"$tmp" && mv "$tmp" "$ROLLAPP_IBC_CONF_FILE" -jq --arg denom "100000000$BASE_DENOM" '.value."gas-prices" = $denom' "$ROLLAPP_IBC_CONF_FILE" >"$tmp" && mv "$tmp" "$ROLLAPP_IBC_CONF_FILE" +dasel put -f "$ROLLAPP_IBC_CONF_FILE" '.value.key' -v "$RELAYER_KEY_FOR_ROLLAPP" +dasel put -f "$ROLLAPP_IBC_CONF_FILE" '.value.chain-id' -v "$ROLLAPP_CHAIN_ID" +dasel put -f "$ROLLAPP_IBC_CONF_FILE" '.value.account-prefix' -v "$BECH32_PREFIX" +dasel put -f "$ROLLAPP_IBC_CONF_FILE" '.value.rpc-addr' -v "$ROLLAPP_RPC_FOR_RELAYER" +dasel put -f "$ROLLAPP_IBC_CONF_FILE" '.value.gas-prices' -v "1000000000$BASE_DENOM" -jq --arg key "$RELAYER_KEY_FOR_HUB" '.value.key = $key' "$HUB_IBC_CONF_FILE" >"$tmp" && mv "$tmp" "$HUB_IBC_CONF_FILE" -jq --arg chain "$SETTLEMENT_CHAIN_ID" '.value."chain-id" = $chain' "$HUB_IBC_CONF_FILE" >"$tmp" && mv "$tmp" "$HUB_IBC_CONF_FILE" -jq --arg rpc "$SETTLEMENT_RPC_FOR_RELAYER" '.value."rpc-addr" = $rpc' "$HUB_IBC_CONF_FILE" >"$tmp" && mv "$tmp" "$HUB_IBC_CONF_FILE" +dasel put -f "$HUB_IBC_CONF_FILE" '.value.key' -v "$RELAYER_KEY_FOR_HUB" +dasel put -f "$HUB_IBC_CONF_FILE" '.value.chain-id' -v "$SETTLEMENT_CHAIN_ID" +dasel put -f "$HUB_IBC_CONF_FILE" '.value.rpc-addr' -v "$SETTLEMENT_RPC_FOR_RELAYER" rly chains add --file "$ROLLAPP_IBC_CONF_FILE" "$ROLLAPP_CHAIN_ID" rly chains add --file "$HUB_IBC_CONF_FILE" "$SETTLEMENT_CHAIN_ID" @@ -68,29 +94,29 @@ sed -i.bak '/min-loop-duration:/s/.*/ min-loop-duration: 100ms/' "$RL echo -e '--------------------------------- Creating keys for rly... --------------------------------' -rly keys add "$ROLLAPP_CHAIN_ID" "$RELAYER_KEY_FOR_ROLLAP" --coin-type 60 +rly keys add "$ROLLAPP_CHAIN_ID" "$RELAYER_KEY_FOR_ROLLAPP" --coin-type 60 rly keys add "$SETTLEMENT_CHAIN_ID" "$RELAYER_KEY_FOR_HUB" --coin-type 60 RLY_HUB_ADDR=$(rly keys show "$SETTLEMENT_CHAIN_ID") RLY_ROLLAPP_ADDR=$(rly keys show "$ROLLAPP_CHAIN_ID") echo '--------------------------------- Funding rly account on hub ['"$RLY_HUB_ADDR"']... --------------------------------' -DYM_BALANCE=$(${SETTLEMENT_EXECUTABLE} q bank balances ${RLY_HUB_ADDR} -o json | jq -r '.balances[0].amount') +DYM_BALANCE=$("$SETTLEMENT_EXECUTABLE" q bank balances "$RLY_HUB_ADDR" -o json | jq -r '.balances[0].amount') if [ "$(echo "$DYM_BALANCE >= 100000000000000000000" | bc)" -eq 1 ]; then echo "${RLY_HUB_ADDR} already funded" else - "$SETTLEMENT_EXECUTABLE" tx bank send "$SETTLEMENT_KEY_NAME_GENESIS" "$RLY_HUB_ADDR" 100dym --keyring-backend test --broadcast-mode block --fees 1dym --node "$SETTLEMENT_RPC_FOR_RELAYER" -y + "$SETTLEMENT_EXECUTABLE" tx bank send "$SETTLEMENT_KEY_NAME_GENESIS" "$RLY_HUB_ADDR" 100dym --keyring-backend test --broadcast-mode block --fees 1dym --node "$SETTLEMENT_RPC_FOR_RELAYER" -y || exit 1 fi echo '--------------------------------- Funding rly account on rollapp ['"$RLY_ROLLAPP_ADDR"'].. --------------------------------' -RA_BALANCE=$(${EXECUTABLE} q bank balances ${RLY_ROLLAPP_ADDR} -o json | jq -r '.balances[0].amount') +RA_BALANCE=$("$EXECUTABLE" q bank balances "$RLY_ROLLAPP_ADDR" -o json | jq -r '.balances[0].amount') if [ "$(echo "$RA_BALANCE >= 100000000000000000000" | bc)" -eq 1 ]; then echo "${RLY_ROLLAPP_ADDR} already funded" else - "$EXECUTABLE" tx bank send "$KEY_NAME_ROLLAPP" "$RLY_ROLLAPP_ADDR" 100000000000000000000"$BASE_DENOM" --keyring-backend test --broadcast-mode block -y --fees 4000000000000$BASE_DENOM + "$EXECUTABLE" tx bank send "$KEY_NAME_ROLLAPP" "$RLY_ROLLAPP_ADDR" 100000000000000000000"$BASE_DENOM" --keyring-backend test --broadcast-mode block -y --fees 4000000000000"$BASE_DENOM" || exit 1 fi echo '--------------------------------- Creating IBC path... --------------------------------' @@ -113,11 +139,11 @@ echo "$channel_info" echo -e '--------------------------------- Set channel-filter --------------------------------' -if [ -z "$rollapp_channel" ] || [ -z "$hub_channel" ]; then +if [ "$rollapp_channel" = "" ] || [ "$hub_channel" = "" ]; then echo "Both channels must be provided. Something is wrong. Exiting." exit 1 fi sed -i.bak '/rule:/s/.*/ rule: "allowlist"/' "$RLY_CONFIG_FILE" sed -i.bak '/channel-list:/s/.*/ channel-list: ["'"$rollapp_channel"'","'"$hub_channel"'"]/' "$RLY_CONFIG_FILE" -echo "Config file updated successfully." \ No newline at end of file +echo "Config file updated successfully." diff --git a/scripts/init.sh b/scripts/init.sh index 049c9bcf..cb3b2dd1 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -1,21 +1,161 @@ #!/bin/bash -tmp=$(mktemp) -EXECUTABLE="rollapp-evm" +EXECUTABLE=$(which rollapp-evm) + +if ! command -v "$EXECUTABLE" >/dev/null; then + echo "$EXECUTABLE does not exist" + echo "please run make install" + exit 1 +fi + +# ---------------------------- initial parameters ---------------------------- # +# 500,000 is staked +# set BASE_DENOM to the token denomination +STAKING_AMOUNT="500000000000000000000000$BASE_DENOM" + +CONFIG_DIRECTORY="$ROLLAPP_HOME_DIR/config" + +APP_CONFIG_FILE="$CONFIG_DIRECTORY/app.toml" +GENESIS_FILE="$CONFIG_DIRECTORY/genesis.json" +DENOM=$(echo "$BASE_DENOM" | sed 's/^.//') + +# ---------------------------- check variables ---------------------------- # +if [ "$MONIKER" = "" ]; then + MONIKER="${ROLLAPP_CHAIN_ID}-sequencer" # Default moniker value +fi + +if [ "$KEY_NAME_ROLLAPP" = "" ]; then + KEY_NAME_ROLLAPP="rol-user" # Default key name value +fi + +# Default to 1,000,000,000 tokens +if [ "$TOTAL_SUPPLY" = "" ]; then + TOTAL_SUPPLY="1000000000000000000000000" +fi + +if [ "$ROLLAPP_SETTLEMENT_INIT_DIR_PATH" = "" ]; then + # ROLLAPP_SETTLEMENT_INIT_DIR_PATH is used as a target for generating the necessary + # configuration files for RollApp initialization, such as denom metadata and genesis account + # json files + ROLLAPP_SETTLEMENT_INIT_DIR_PATH="${ROLLAPP_HOME_DIR}/init" +fi + +if [ "$ROLLAPP_CHAIN_ID" = "" ]; then + echo "ROLLAPP_CHAIN_ID is not set" exit 1 +fi + +if [ "$CELESTIA_NETWORK" = "" ]; then + echo "CELESTIA_NETWORK is not set" + exit 1 +fi + +if [ "$CELESTIA_HOME_DIR" = "" ]; then + echo "CELESTIA_HOME_DIR is not set" + exit 1 +fi set_denom() { local denom=$1 local success=true - jq --arg denom "$denom" '.app_state.mint.params.mint_denom = $denom' "$GENESIS_FILE" > "$tmp" && mv "$tmp" "$GENESIS_FILE" || - success=false - jq --arg denom "$denom" '.app_state.staking.params.bond_denom = $denom' "$GENESIS_FILE" > "$tmp" && mv "$tmp" "$GENESIS_FILE" || - success=false - jq --arg denom "$denom" '.app_state.gov.deposit_params.min_deposit[0].denom = $denom' "$GENESIS_FILE" > "$tmp" && mv "$tmp" "$GENESIS_FILE" || - success=false - jq --arg denom "$denom" '.app_state.evm.params.evm_denom = $denom' "$GENESIS_FILE" > "$tmp" && mv "$tmp" "$GENESIS_FILE" || - success=false - jq --arg denom "$denom" '.app_state.claims.params.claims_denom = $denom' "$GENESIS_FILE" > "$tmp" && mv "$tmp" "$GENESIS_FILE" || - success=false + dasel put -f "$GENESIS_FILE" '.app_state.mint.params.mint_denom' -v "$denom" || success=false + dasel put -f "$GENESIS_FILE" '.app_state.staking.params.bond_denom' -v "$denom" || success=false + dasel put -t string -f "$GENESIS_FILE" '.app_state.gov.deposit_params.min_deposit.[0].denom' -v "$denom" || success=false + dasel put -f "$GENESIS_FILE" '.app_state.evm.params.evm_denom' -v "$denom" || success=false + dasel put -f "$GENESIS_FILE" '.app_state.claims.params.claims_denom' -v "$denom" || success=false + + if [ "$success" = false ]; then + echo "An error occurred. Please refer to README.md" + exit 1 + fi +} + +update_genesis_params() { + local success=true + + dasel put -f "$GENESIS_FILE" '.app_state.gov.voting_params.voting_period' -v "300s" || success=false + dasel put -f "$GENESIS_FILE" '.app_state.bank.balances.[0].coins.[0].amount' -v "$TOTAL_SUPPLY" || success=false + dasel put -f "$GENESIS_FILE" '.app_state.bank.supply.[0].amount' -v "$TOTAL_SUPPLY" || success=false + + if [ "$success" = false ]; then + echo "An error occurred. Please refer to README.md" + return 1 + fi + echo "Successfully updated the genesis file" +} + +add_genesis_accounts() { + local success=true + + ALICE_MNEMONIC="mimic ten evoke card crowd upset tragic race borrow final vibrant gesture armed alley figure orange shock strike surge jaguar deposit hockey erosion taste" + echo "$ALICE_MNEMONIC" | dymd keys add genesis-wallet --keyring-backend test --keyring-dir "$ROLLAPP_HOME_DIR" --recover + + tee "$ROLLAPP_SETTLEMENT_INIT_DIR_PATH/genesis_accounts.json" >/dev/null </dev/null < /dev/null <"$tmp" && mv "$tmp" "$GENESIS_FILE" - jq --arg block_size "$BLOCK_SIZE" '.consensus_params["evidence"]["max_bytes"] = $block_size' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE" - jq '.consensus_params["block"]["max_gas"] = "400000000"' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE" + + dasel put -f "$GENESIS_FILE" '.consensus_params.block.max_gas' -v "400000000" || success=false + dasel put -f "$GENESIS_FILE" '.consensus_params.block.max_bytes' -v "$BLOCK_SIZE" || success=false + dasel put -f "$GENESIS_FILE" '.consensus_params.evidence.max_bytes' -v "$BLOCK_SIZE" || success=false + + if [ "$success" = false ]; then + echo "An error occurred. Please refer to README.md" + return 1 + fi } SKIP_BASE_FEE=${SKIP_EVM_BASE_FEE-false} set_EVM_params() { - jq --arg skip "$SKIP_BASE_FEE" '.app_state["feemarket"]["params"]["no_base_fee"] = ($skip == "true")' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE" - jq '.app_state["feemarket"]["params"]["min_gas_price"] = "10000000.0"' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE" + local success=true + + SKIP_BASE_FEE_LOWER=$(echo "$SKIP_BASE_FEE" | tr '[:upper:]' '[:lower:]') + + dasel put -t bool -f "$GENESIS_FILE" 'app_state.feemarket.params.no_base_fee' -v "$SKIP_BASE_FEE_LOWER" || success=false + dasel put -f "$GENESIS_FILE" '.app_state.evm.params.extra_eips.[]' -v '3855' || success=false + dasel put -f "$GENESIS_FILE" '.app_state.feemarket.params.min_gas_price' -v "10000000.0" || success=false + + if [ "$success" = false ]; then + echo "An error occurred. Please refer to README.md" + return 1 + fi } -# ---------------------------- initial parameters ---------------------------- # -# Assuming 1,000,000 tokens -# Half is staked -# set BASE_DENOM to the token denomination -TOKEN_AMOUNT="1000000000000000000000000$BASE_DENOM" -STAKING_AMOUNT="500000000000000000000000$BASE_DENOM" +update_configuration() { + celestia_namespace_id=$(openssl rand -hex 10) + if [ ! -d "$CELESTIA_HOME_DIR" ]; then + echo "Celestia light client is expected to be initialized in this directory: $CELESTIA_HOME_DIR" + echo "but it does not exist, please initialize the light client or update the 'CELESTIA_HOME_DIR'" + echo "environment variable" + exit 1 + fi -CONFIG_DIRECTORY="$ROLLAPP_HOME_DIR/config" -GENESIS_FILE="$CONFIG_DIRECTORY/genesis.json" -DYMINT_CONFIG_FILE="$CONFIG_DIRECTORY/dymint.toml" -APP_CONFIG_FILE="$CONFIG_DIRECTORY/app.toml" + celestia_token=$(celestia light auth admin --p2p.network "$CELESTIA_NETWORK" --node.store "$CELESTIA_HOME_DIR") -# --------------------------------- run init --------------------------------- # -if ! command -v "$EXECUTABLE" >/dev/null; then - echo "$EXECUTABLE does not exist" - echo "please run make install" - exit 1 -fi + if [[ "$OSTYPE" == "darwin"* ]]; then + sed -i '' "s/da_layer =.*/da_layer = \"celestia\"/" "${CONFIG_DIRECTORY}/dymint.toml" + sed -i '' "s/namespace_id .*/namespace_id = \"${celestia_namespace_id}\"/" "${CONFIG_DIRECTORY}/dymint.toml" + sed -i '' "s/da_config .*/da_config = \"{\\\\\"base_url\\\\\": \\\\\"http:\/\/localhost:26658\\\\\", \\\\\"timeout\\\\\": 60000000000, \\\\\"gas_prices\\\\\":1.0, \\\\\"gas_adjustment\\\\\": 1.3, \\\\\"namespace_id\\\\\": \\\\\"${celestia_namespace_id}\\\\\", \\\\\"auth_token\\\\\":\\\\\"${celestia_token}\\\\\"}\"/" "${CONFIG_DIRECTORY}/dymint.toml" -if [ "$ROLLAPP_CHAIN_ID" = "" ]; then - echo "ROLLAPP_CHAIN_ID is not set" - exit 1 -fi + sed -i '' 's/settlement_layer.*/settlement_layer = "dymension"/' "${CONFIG_DIRECTORY}/dymint.toml" + sed -i '' -e "/settlement_node_address =/s/.*/settlement_node_address = \"${HUB_RPC_URL//\//\\/}\"/" "${CONFIG_DIRECTORY}/dymint.toml" + sed -i '' -e "/rollapp_id =/s/.*/rollapp_id = \"$ROLLAPP_CHAIN_ID\"/" "${CONFIG_DIRECTORY}/dymint.toml" + sed -i '' -e "/minimum-gas-prices =/s/.*/minimum-gas-prices = \"1000000000${BASE_DENOM}\"/" "${CONFIG_DIRECTORY}/app.toml" + else + sed -i "s/da_layer =.*/da_layer = \"celestia\"/" "${CONFIG_DIRECTORY}/dymint.toml" + sed -i "s/namespace_id .*/namespace_id = \"${celestia_namespace_id}\"/" "${CONFIG_DIRECTORY}/dymint.toml" + sed -i "s/da_config .*/da_config = \"{\\\\\"base_url\\\\\": \\\\\"http:\/\/localhost:26658\\\\\", \\\\\"timeout\\\\\": 60000000000, \\\\\"gas_prices\\\\\":1.0, \\\\\"gas_adjustment\\\\\": 1.3, \\\\\"namespace_id\\\\\": \\\\\"${celestia_namespace_id}\\\\\", \\\\\"auth_token\\\\\":\\\\\"${celestia_token}\\\\\"}\"/" "${CONFIG_DIRECTORY}/dymint.toml" + + sed -i 's/settlement_layer.*/settlement_layer = "dymension"/' "${CONFIG_DIRECTORY}/dymint.toml" + sed -i '/settlement_node_address =/c\settlement_node_address = '\""$HUB_RPC_URL"\" "${CONFIG_DIRECTORY}/dymint.toml" + sed -i '/rollapp_id =/c\rollapp_id = '\""$ROLLAPP_CHAIN_ID"\" "${CONFIG_DIRECTORY}/dymint.toml" + sed -i '/minimum-gas-prices =/c\minimum-gas-prices = '\"1000000000"$BASE_DENOM"\" "${CONFIG_DIRECTORY}/app.toml" + fi +} + +# --------------------------------- run init --------------------------------- # # Verify that a genesis file doesn't exists for the dymension chain if [ -f "$GENESIS_FILE" ]; then @@ -75,54 +243,47 @@ if [ -f "$GENESIS_FILE" ]; then fi fi -# Check if MONIKER is set, if not, set a default value -if [ -z "$MONIKER" ]; then - MONIKER="${ROLLAPP_CHAIN_ID}-sequencer" # Default moniker value -fi - -# Check if KEY_NAME_ROLLAPP is set, if not, set a default value -if [ -z "$KEY_NAME_ROLLAPP" ]; then - KEY_NAME_ROLLAPP="rol-user" # Default key name value -fi - # ------------------------------- init rollapp ------------------------------- # "$EXECUTABLE" init "$MONIKER" --chain-id "$ROLLAPP_CHAIN_ID" +if [ ! -d "$ROLLAPP_SETTLEMENT_INIT_DIR_PATH" ]; then + mkdir -p "$ROLLAPP_SETTLEMENT_INIT_DIR_PATH" + echo "creating init directory : $ROLLAPP_SETTLEMENT_INIT_DIR_PATH" +else + echo "init directory : $ROLLAPP_SETTLEMENT_INIT_DIR_PATH already exists" +fi + # ------------------------------- client config ------------------------------ # + "$EXECUTABLE" config chain-id "$ROLLAPP_CHAIN_ID" # -------------------------------- app config -------------------------------- # -# Detect the operating system -OS=$(uname) - # Modify app.toml minimum-gas-prices using sed command based on the OS -if [ "$OS" = "Darwin" ]; then - # macOS requires an empty string '' after -i to edit in place without backup - sed -i '' "s/^minimum-gas-prices *= .*/minimum-gas-prices = \"0$BASE_DENOM\"/" "$APP_CONFIG_FILE" -else - # Linux directly uses -i for in-place editing without creating a backup - sed -i "s/^minimum-gas-prices *= .*/minimum-gas-prices = \"0$BASE_DENOM\"/" "$APP_CONFIG_FILE" -fi +dasel put -t string -f "$APP_CONFIG_FILE" 'minimum-gas-prices' -v "0$BASE_DENOM" || success=false + set_denom "$BASE_DENOM" set_consensus_params set_EVM_params +add_genesis_accounts +generate_denom_metadata +update_configuration # --------------------- adding keys and genesis accounts --------------------- # # Local genesis account "$EXECUTABLE" keys add "$KEY_NAME_ROLLAPP" --keyring-backend test -"$EXECUTABLE" add-genesis-account "$KEY_NAME_ROLLAPP" "$TOKEN_AMOUNT" --keyring-backend test +"$EXECUTABLE" add-genesis-account "$KEY_NAME_ROLLAPP" "$TOTAL_SUPPLY$BASE_DENOM" --keyring-backend test # Set sequencer's operator address operator_address=$("$EXECUTABLE" keys show "$KEY_NAME_ROLLAPP" -a --keyring-backend test --bech val) -jq --arg addr "$operator_address" '.app_state["sequencers"]["genesis_operator_address"] = $addr' "$GENESIS_FILE" > "$tmp" && mv "$tmp" "$GENESIS_FILE" - +dasel put -f "$GENESIS_FILE" '.app_state.sequencers.genesis_operator_address' -v "$operator_address" # Ask if to include a governor on genesis echo "Do you want to include a governor on genesis? (Y/n) " read -r answer if [ ! "$answer" != "${answer#[Nn]}" ] ;then - "$EXECUTABLE" gentx "$KEY_NAME_ROLLAPP" "$STAKING_AMOUNT" --chain-id "$ROLLAPP_CHAIN_ID" --keyring-backend test --home "$ROLLAPP_HOME_DIR" --fees 4000000000000$BASE_DENOM + "$EXECUTABLE" gentx "$KEY_NAME_ROLLAPP" "$STAKING_AMOUNT" --chain-id "$ROLLAPP_CHAIN_ID" --keyring-backend test --home "$ROLLAPP_HOME_DIR" --fees 4000000000000"$BASE_DENOM" "$EXECUTABLE" collect-gentxs --home "$ROLLAPP_HOME_DIR" fi +update_genesis_params "$EXECUTABLE" validate-genesis diff --git a/scripts/settlement/add_genesis_accounts.sh b/scripts/settlement/add_genesis_accounts.sh deleted file mode 100755 index 62e3cb42..00000000 --- a/scripts/settlement/add_genesis_accounts.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -if [ ! -d "$ROLLAPP_SETTLEMENT_INIT_DIR_PATH" ]; then - mkdir -p "$ROLLAPP_SETTLEMENT_INIT_DIR_PATH" - echo "Creating the ROLLAPP_SETTLEMENT_INIT_DIR_PATH: $ROLLAPP_SETTLEMENT_INIT_DIR_PATH" -else - echo "ROLLAPP_SETTLEMENT_INIT_DIR_PATH already exists: $ROLLAPP_SETTLEMENT_INIT_DIR_PATH" -fi - -# use concrete mnemonics so the addresses are always the same, just for convenience and recognisability -ALICE_MNEMONIC="mimic ten evoke card crowd upset tragic race borrow final vibrant gesture armed alley figure orange shock strike surge jaguar deposit hockey erosion taste" -BOB_MNEMONIC="matrix venture pair label proud ignore manual crunch brand board welcome suspect purity steak melt atom stadium vanish bullet hill angry bulk visa analyst" -echo $ALICE_MNEMONIC | dymd keys add alice-genesis --keyring-backend test --keyring-dir ${ROLLAPP_HOME_DIR} --recover -echo $BOB_MNEMONIC | dymd keys add bob-genesis --keyring-backend test --keyring-dir ${ROLLAPP_HOME_DIR} --recover - -tee "$ROLLAPP_SETTLEMENT_INIT_DIR_PATH/genesis_accounts.json" >/dev/null </dev/null <"$tmp" && mv "$tmp" "$GENESIS_FILE" -jq '.consensus_params["block"]["max_bytes"] = "3145728"' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE" - -jq '.app_state.gov.voting_params.voting_period = "300s"' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE" - -jq '.app_state.bank.balances[0].coins[0].amount = "2000000000000000000000000000"' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE" -jq '.app_state.bank.supply[0].amount = "2000000000000000000000000000"' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE" - -# ---------------------------- add genesis accounts for the hub ---------------------------- # -genesis_accounts=$(cat "$ROLLAPP_SETTLEMENT_INIT_DIR_PATH"/genesis_accounts.json) -jq --argjson genesis_accounts "$genesis_accounts" '.app_state.hubgenesis.state.genesis_accounts = $genesis_accounts' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE" - -# ---------------------------- add denom metadata ---------------------------- # -denom_metadata=$(cat "$ROLLAPP_SETTLEMENT_INIT_DIR_PATH"/denommetadata.json) -elevated_address=$("$EXECUTABLE" keys show "$KEY_NAME_ROLLAPP" --keyring-backend test --output json | jq -r .address) -jq --argjson denom_metadata "$denom_metadata" '.app_state.bank.denom_metadata = $denom_metadata' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE" -jq --arg elevated_address "$elevated_address" '.app_state.denommetadata.params.allowed_addresses += [$elevated_address]' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE" - -# ----------------------------- update evm params ---------------------------- # - -jq '.app_state.evm.params.extra_eips = [3855]' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE" \ No newline at end of file