From f4ccb40da589bccb179a27d03d6d689790b17115 Mon Sep 17 00:00:00 2001 From: Tian Qin Date: Fri, 6 Oct 2023 14:30:36 -0400 Subject: [PATCH 1/4] modify genesis scripts to take rewards vester account balance as an argument and count it towards total supply --- protocol/testing/genesis.sh | 11 +++++++++-- protocol/testing/testnet-dev/dev.sh | 2 +- protocol/testing/testnet-external/pregenesis.sh | 2 +- protocol/testing/testnet-local/local.sh | 2 +- protocol/testing/testnet-staging/staging.sh | 2 +- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/protocol/testing/genesis.sh b/protocol/testing/genesis.sh index d77d237bdc..9913ff58c5 100755 --- a/protocol/testing/genesis.sh +++ b/protocol/testing/genesis.sh @@ -58,6 +58,12 @@ function edit_genesis() { INITIAL_CLOB_PAIR_STATUS='STATUS_ACTIVE' fi + REWARDS_VESTER_ACCOUNT_BALANCE="$7" + if [ -z "$REWARDS_VESTER_ACCOUNT_BALANCE" ]; then + # Default to 1e12. + REWARDS_VESTER_ACCOUNT_BALANCE="1000000000000" + fi + # Consensus params dasel put -t string -f "$GENESIS" '.consensus_params.block.max_bytes' -v '4194304' dasel put -t string -f "$GENESIS" '.consensus_params.block.max_gas' -v '-1' @@ -966,7 +972,8 @@ function edit_genesis() { dydx_exchange_config_json=$(cat "$EXCHANGE_CONFIG_JSON_DIR/dydx_exchange_config.json" | jq -c '.') dasel put -t string -f "$GENESIS" '.app_state.prices.market_params.[34].exchange_config_json' -v "$dydx_exchange_config_json" - bridge_module_account_balance=$TOTAL_NATIVE_TOKEN_SUPPLY + # Initialize bridge module account balance as total native token supply minus rewards vester account balance. + bridge_module_account_balance=$(echo "$TOTAL_NATIVE_TOKEN_SUPPLY - $REWARDS_VESTER_ACCOUNT_BALANCE" | bc) total_accounts_quote_balance=0 acct_idx=0 # Update subaccounts module for load testing accounts and update bridge module account balance. @@ -1001,7 +1008,7 @@ function edit_genesis() { dasel put -t string -f "$GENESIS" ".app_state.bank.balances.[$next_bank_idx].address" -v "${REWARDS_VESTER_ACCOUNT_ADDR}" dasel put -t json -f "$GENESIS" ".app_state.bank.balances.[$next_bank_idx].coins.[]" -v "{}" dasel put -t string -f "$GENESIS" ".app_state.bank.balances.[$next_bank_idx].coins.[0].denom" -v "${REWARD_TOKEN}" - dasel put -t string -f "$GENESIS" ".app_state.bank.balances.[$next_bank_idx].coins.[0].amount" -v "1000000000000" # 1e12 + dasel put -t string -f "$GENESIS" ".app_state.bank.balances.[$next_bank_idx].coins.[0].amount" -v "$REWARDS_VESTER_ACCOUNT_BALANCE" next_bank_idx=$(($next_bank_idx+1)) # Initialize bank balance of bridge module account. diff --git a/protocol/testing/testnet-dev/dev.sh b/protocol/testing/testnet-dev/dev.sh index bfafd40534..1d2ff614b9 100755 --- a/protocol/testing/testnet-dev/dev.sh +++ b/protocol/testing/testnet-dev/dev.sh @@ -134,7 +134,7 @@ create_validators() { # Using "*" as a subscript results in a single arg: "dydx1... dydx1... dydx1..." # Using "@" as a subscript results in separate args: "dydx1..." "dydx1..." "dydx1..." # Note: `edit_genesis` must be called before `add-genesis-account`. - edit_genesis "$VAL_CONFIG_DIR" "${TEST_ACCOUNTS[*]}" "${FAUCET_ACCOUNTS[*]}" "" "" "" + edit_genesis "$VAL_CONFIG_DIR" "${TEST_ACCOUNTS[*]}" "${FAUCET_ACCOUNTS[*]}" "" "" "" "" update_genesis_use_test_volatile_market "$VAL_CONFIG_DIR" update_genesis_complete_bridge_delay "$VAL_CONFIG_DIR" "600" diff --git a/protocol/testing/testnet-external/pregenesis.sh b/protocol/testing/testnet-external/pregenesis.sh index 3266c34ab6..7730898200 100755 --- a/protocol/testing/testnet-external/pregenesis.sh +++ b/protocol/testing/testnet-external/pregenesis.sh @@ -188,7 +188,7 @@ create_pregenesis_file() { # Using "*" as a subscript results in a single arg: "dydx1... dydx1... dydx1..." # Using "@" as a subscript results in separate args: "dydx1..." "dydx1..." "dydx1..." # Note: `edit_genesis` must be called before `add-genesis-account`. - edit_genesis "$VAL_CONFIG_DIR" "" "" "$TMP_EXCHANGE_CONFIG_JSON_DIR" "./testing/delaymsg_config" "" + edit_genesis "$VAL_CONFIG_DIR" "" "" "$TMP_EXCHANGE_CONFIG_JSON_DIR" "./testing/delaymsg_config" "" "" overwrite_genesis_public_testnet FAUCET_BALANCE="${FAUCET_STAKE_BALANCE}$NATIVE_TOKEN" diff --git a/protocol/testing/testnet-local/local.sh b/protocol/testing/testnet-local/local.sh index 2a57f9236c..edb7112c18 100755 --- a/protocol/testing/testnet-local/local.sh +++ b/protocol/testing/testnet-local/local.sh @@ -99,7 +99,7 @@ create_validators() { # Using "*" as a subscript results in a single arg: "dydx1... dydx1... dydx1..." # Using "@" as a subscript results in separate args: "dydx1..." "dydx1..." "dydx1..." # Note: `edit_genesis` must be called before `add-genesis-account`. - edit_genesis "$VAL_CONFIG_DIR" "${TEST_ACCOUNTS[*]}" "${FAUCET_ACCOUNTS[*]}" "" "" "" + edit_genesis "$VAL_CONFIG_DIR" "${TEST_ACCOUNTS[*]}" "${FAUCET_ACCOUNTS[*]}" "" "" "" "" update_genesis_use_test_volatile_market "$VAL_CONFIG_DIR" update_genesis_complete_bridge_delay "$VAL_CONFIG_DIR" "30" diff --git a/protocol/testing/testnet-staging/staging.sh b/protocol/testing/testnet-staging/staging.sh index 8dfe55b8ee..2c3302bde2 100755 --- a/protocol/testing/testnet-staging/staging.sh +++ b/protocol/testing/testnet-staging/staging.sh @@ -188,7 +188,7 @@ create_validators() { # Using "*" as a subscript results in a single arg: "dydx1... dydx1... dydx1..." # Using "@" as a subscript results in separate args: "dydx1..." "dydx1..." "dydx1..." # Note: `edit_genesis` must be called before `add-genesis-account`. - edit_genesis "$VAL_CONFIG_DIR" "${TEST_ACCOUNTS[*]}" "${FAUCET_ACCOUNTS[*]}" "" "" "" + edit_genesis "$VAL_CONFIG_DIR" "${TEST_ACCOUNTS[*]}" "${FAUCET_ACCOUNTS[*]}" "" "" "" "" update_genesis_use_test_volatile_market "$VAL_CONFIG_DIR" update_genesis_complete_bridge_delay "$VAL_CONFIG_DIR" "600" From 92e60b549702c6b08db030f20b3b68a1a8aa4365 Mon Sep 17 00:00:00 2001 From: Tian Qin Date: Tue, 17 Oct 2023 21:42:00 -0400 Subject: [PATCH 2/4] update container and pregenesis scripts --- protocol/scripts/genesis/prod_pregenesis.sh | 2 +- protocol/testing/containertest/containertest.sh | 2 +- protocol/testing/genesis.sh | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/protocol/scripts/genesis/prod_pregenesis.sh b/protocol/scripts/genesis/prod_pregenesis.sh index dbc7dc6649..ba21eca37b 100755 --- a/protocol/scripts/genesis/prod_pregenesis.sh +++ b/protocol/scripts/genesis/prod_pregenesis.sh @@ -166,7 +166,7 @@ create_pregenesis_file() { echo "Copying exchange config jsons to $TMP_EXCHANGE_CONFIG_JSON_DIR" cp -R ./daemons/pricefeed/client/constants/testdata $TMP_EXCHANGE_CONFIG_JSON_DIR - edit_genesis "$VAL_CONFIG_DIR" "" "" "$TMP_EXCHANGE_CONFIG_JSON_DIR" "./testing/delaymsg_config" "STATUS_INITIALIZING" + edit_genesis "$VAL_CONFIG_DIR" "" "" "$TMP_EXCHANGE_CONFIG_JSON_DIR" "./testing/delaymsg_config" "STATUS_INITIALIZING" "" overwrite_genesis_production } diff --git a/protocol/testing/containertest/containertest.sh b/protocol/testing/containertest/containertest.sh index 6f3166b073..619eb01f1c 100755 --- a/protocol/testing/containertest/containertest.sh +++ b/protocol/testing/containertest/containertest.sh @@ -99,7 +99,7 @@ create_validators() { # Using "*" as a subscript results in a single arg: "dydx1... dydx1... dydx1..." # Using "@" as a subscript results in separate args: "dydx1..." "dydx1..." "dydx1..." # Note: `edit_genesis` must be called before `add-genesis-account` or `update_genesis_use_test_exchange`. - edit_genesis "$VAL_CONFIG_DIR" "${TEST_ACCOUNTS[*]}" "${FAUCET_ACCOUNTS[*]}" "" "" "" + edit_genesis "$VAL_CONFIG_DIR" "${TEST_ACCOUNTS[*]}" "${FAUCET_ACCOUNTS[*]}" "" "" "" "" # Configure the genesis file to only use the test exchange to compute index prices. update_genesis_use_test_exchange "$VAL_CONFIG_DIR" diff --git a/protocol/testing/genesis.sh b/protocol/testing/genesis.sh index 0b3542d758..307aa05696 100755 --- a/protocol/testing/genesis.sh +++ b/protocol/testing/genesis.sh @@ -72,6 +72,7 @@ function edit_genesis() { # Default to 10 million full coins. REWARDS_VESTER_ACCOUNT_BALANCE="10000000$EIGHTEEN_ZEROS" fi + # Genesis time dasel put -t string -f "$GENESIS" '.genesis_time' -v "$GENESIS_TIME" From f3cfb719a93ffaaf7e56488cba4dc8efd9b6fb6b Mon Sep 17 00:00:00 2001 From: Tian Qin Date: Tue, 17 Oct 2023 22:04:19 -0400 Subject: [PATCH 3/4] use bc to compare rewards balance with 0 --- protocol/testing/genesis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/testing/genesis.sh b/protocol/testing/genesis.sh index 9695d0f8cb..65aeba6706 100755 --- a/protocol/testing/genesis.sh +++ b/protocol/testing/genesis.sh @@ -1019,7 +1019,7 @@ function edit_genesis() { next_bank_idx=$(($next_bank_idx+1)) fi - if [ "$REWARDS_VESTER_ACCOUNT_BALANCE" -gt 0 ]; then + if [ $(echo "$REWARDS_VESTER_ACCOUNT_BALANCE > 0" | bc -l) -eq 1 ]; then # Initialize bank balance of reward vester account. dasel put -t json -f "$GENESIS" ".app_state.bank.balances.[]" -v "{}" dasel put -t string -f "$GENESIS" ".app_state.bank.balances.[$next_bank_idx].address" -v "${REWARDS_VESTER_ACCOUNT_ADDR}" From 3a90a7362aeea9f0790a39142fa4236f68247a24 Mon Sep 17 00:00:00 2001 From: Tian Qin Date: Mon, 23 Oct 2023 15:21:21 -0400 Subject: [PATCH 4/4] default rewards vester account to 200 million full coins --- protocol/testing/genesis.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protocol/testing/genesis.sh b/protocol/testing/genesis.sh index 6ddc069551..da3c29f904 100755 --- a/protocol/testing/genesis.sh +++ b/protocol/testing/genesis.sh @@ -69,8 +69,8 @@ function edit_genesis() { REWARDS_VESTER_ACCOUNT_BALANCE="$7" if [ -z "$REWARDS_VESTER_ACCOUNT_BALANCE" ]; then - # Default to 10 million full coins. - REWARDS_VESTER_ACCOUNT_BALANCE="10000000$EIGHTEEN_ZEROS" + # Default to 200 million full coins. + REWARDS_VESTER_ACCOUNT_BALANCE="200000000$EIGHTEEN_ZEROS" fi # Genesis time